Skip to contentSkip to conversation

warp7: add UART6 support

PATCH New Ryan Harkin 4 participants 8 messages Jan 19, 2018 – Jan 22, 2018

lore
Share & tools
lore
#0 lore raw

cover warp7: add UART6 support

This small series adds support for using the console on UART6 on the WaRP7 board.

The board retains current functionality: UART6 is not used by default and needs it needs to be enabled in defconfig.

[PATCH 1/2] serial: mxc: support DTE mode
[PATCH 2/2] warp7: add support for console on UART6 and mikroBus

 board/warp7/Kconfig         |  9 +++++++++
 board/warp7/warp7.c         |  6 ++++++
 drivers/serial/Kconfig      |  7 +++++++
 drivers/serial/serial_mxc.c | 10 ++++++++--
 include/configs/warp7.h     |  8 +++++++-
 5 files changed, 37 insertions(+), 3 deletions(-)
#1 lore raw

PATCH 1/2 serial: mxc: support DTE mode

Add DTE mode support via Kconfig on the MXC uart.

---
 drivers/serial/Kconfig      |  7 +++++++
 drivers/serial/serial_mxc.c | 10 ++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
drivers/serial/Kconfig +7 -0
index 122b8e7..0df57c0 100644
@@ -597,4 +597,11 @@ config SYS_SDMR
 	depends on MPC8XX_CONS
 	default 0
 
+config SERIAL_MXC_DTE_MODE
+	bool "Use DTE mode for the MXC UART"
+	default n
+	help
+	  This is used to set DTE mode on the serial console controlled by
+	  serial_mxc.c.
+
 endmenu
drivers/serial/serial_mxc.c +8 -2
index cce80a8..e7ea30c 100644
@@ -111,6 +111,12 @@
 #define TXTL		2  /* reset default */
 #define RXTL		1  /* reset default */
 
+#ifdef CONFIG_SERIAL_MXC_DTE_MODE
+#define MXC_DTE_MODE	true
+#else
+#define MXC_DTE_MODE	false
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 struct mxc_uart {
@@ -189,7 +195,7 @@ static void mxc_serial_setbrg(void)
 	if (!gd->baudrate)
 		gd->baudrate = CONFIG_BAUDRATE;
 
-	_mxc_serial_setbrg(mxc_base, clk, gd->baudrate, false);
+	_mxc_serial_setbrg(mxc_base, clk, gd->baudrate, MXC_DTE_MODE);
 }
 
 static int mxc_serial_getc(void)
@@ -367,7 +373,7 @@ static inline void _debug_uart_init(void)
 
 	_mxc_serial_init(base);
 	_mxc_serial_setbrg(base, CONFIG_DEBUG_UART_CLOCK,
-			   CONFIG_BAUDRATE, false);
+			   CONFIG_BAUDRATE, MXC_DTE_MODE);
 }
 
 static inline void _debug_uart_putc(int ch)
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/2 serial: mxc: support DTE mode

Hi Ryan,

Quoted 1 line · Ryan Harkin

Add DTE mode support via Kconfig on the MXC uart.

Make use of the driver model, there DTE is supported already today:
https://lists.denx.de/pipermail/u-boot/2016-July/259573.html

--
Stefan

Quoted 59 lines
---
 drivers/serial/Kconfig      |  7 +++++++
 drivers/serial/serial_mxc.c | 10 ++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
drivers/serial/Kconfig +7 -0
index 122b8e7..0df57c0 100644
@@ -597,4 +597,11 @@ config SYS_SDMR
 	depends on MPC8XX_CONS
 	default 0
 
+config SERIAL_MXC_DTE_MODE
+	bool "Use DTE mode for the MXC UART"
+	default n
+	help
+	  This is used to set DTE mode on the serial console controlled by
+	  serial_mxc.c.
+
 endmenu
drivers/serial/serial_mxc.c +8 -2
index cce80a8..e7ea30c 100644
@@ -111,6 +111,12 @@
 #define TXTL		2  /* reset default */
 #define RXTL		1  /* reset default */
 
+#ifdef CONFIG_SERIAL_MXC_DTE_MODE
+#define MXC_DTE_MODE	true
+#else
+#define MXC_DTE_MODE	false
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 struct mxc_uart {
@@ -189,7 +195,7 @@ static void mxc_serial_setbrg(void)
 	if (!gd->baudrate)
 		gd->baudrate = CONFIG_BAUDRATE;
 
-	_mxc_serial_setbrg(mxc_base, clk, gd->baudrate, false);
+	_mxc_serial_setbrg(mxc_base, clk, gd->baudrate, MXC_DTE_MODE);
 }
 
 static int mxc_serial_getc(void)
@@ -367,7 +373,7 @@ static inline void _debug_uart_init(void)
 
 	_mxc_serial_init(base);
 	_mxc_serial_setbrg(base, CONFIG_DEBUG_UART_CLOCK,
-			   CONFIG_BAUDRATE, false);
+			   CONFIG_BAUDRATE, MXC_DTE_MODE);
 }
 
 static inline void _debug_uart_putc(int ch)
#3 lore raw

PATCH 1/2 serial: mxc: support DTE mode

Hi Stefan,

Thanks for looking so quickly.

Quoted 8 lines · Stefan Agner

Hi Ryan,

Quoted 1 line · Ryan Harkin

Add DTE mode support via Kconfig on the MXC uart.

Make use of the driver model, there DTE is supported already today:
https://lists.denx.de/pipermail/u-boot/2016-July/259573.html

My change would be useful for other non-DM users of serial_mxc.c, of course. Not just WaRP7.

I don't have any objection to WaRP7 moving to DM, although that isn't my call, but moving using the driver model is not a straight-forward change, is it? WaRP7 today doesn't use it.

Do you have an example of a board using this driver that switched using the driver model? I'd like to see the scale of the changes needed.

Regards,
Ryan.

Quoted 65 lines

--
Stefan

Quoted 59 lines
---
 drivers/serial/Kconfig      |  7 +++++++
 drivers/serial/serial_mxc.c | 10 ++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
drivers/serial/Kconfig +7 -0
index 122b8e7..0df57c0 100644
@@ -597,4 +597,11 @@ config SYS_SDMR
      depends on MPC8XX_CONS
      default 0
 
+config SERIAL_MXC_DTE_MODE
+     bool "Use DTE mode for the MXC UART"
+     default n
+     help
+       This is used to set DTE mode on the serial console controlled by
+       serial_mxc.c.
+
 endmenu
drivers/serial/serial_mxc.c +8 -2
index cce80a8..e7ea30c 100644
@@ -111,6 +111,12 @@
 #define TXTL         2  /* reset default */
 #define RXTL         1  /* reset default */
 
+#ifdef CONFIG_SERIAL_MXC_DTE_MODE
+#define MXC_DTE_MODE true
+#else
+#define MXC_DTE_MODE false
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 struct mxc_uart {
@@ -189,7 +195,7 @@ static void mxc_serial_setbrg(void)
      if (!gd->baudrate)
              gd->baudrate = CONFIG_BAUDRATE;
 
-     _mxc_serial_setbrg(mxc_base, clk, gd->baudrate, false);
+     _mxc_serial_setbrg(mxc_base, clk, gd->baudrate, MXC_DTE_MODE);
 }
 
 static int mxc_serial_getc(void)
@@ -367,7 +373,7 @@ static inline void _debug_uart_init(void)
 
      _mxc_serial_init(base);
      _mxc_serial_setbrg(base, CONFIG_DEBUG_UART_CLOCK,
-                        CONFIG_BAUDRATE, false);
+                        CONFIG_BAUDRATE, MXC_DTE_MODE);
 }
 
 static inline void _debug_uart_putc(int ch)
#4 lore raw

PATCH 1/2 serial: mxc: support DTE mode

Hi Ryan,

Quoted 16 lines · Ryan Harkin

Hi Stefan,

Thanks for looking so quickly.

Quoted 9 lines · Stefan Agner

Hi Ryan,

Quoted 1 line · Ryan Harkin

Add DTE mode support via Kconfig on the MXC uart.

Make use of the driver model, there DTE is supported already today:
https://lists.denx.de/pipermail/u-boot/2016-July/259573.html

Quoted 6 lines

My change would be useful for other non-DM users of serial_mxc.c, of course. Not just WaRP7.

I don't have any objection to WaRP7 moving to DM, although that isn't my call, but moving using the driver model is not a straight-forward change, is it? WaRP7 today doesn't use it.

We are planning to require that board use CONFIG_BLK fairly soon, and that likely means conversion to device tree I don't think it makes sense to accept patches like this. If the board can be converted, then let's do it!

Quoted 3 lines

Do you have an example of a board using this driver that switched using the driver model? I'd like to see the scale of the changes needed.

It probably requires:

- Adding a DT (with u-boot,dm-pre-reloc as needed)
- Checking that stdio-path is correct

Regards,
Simon

#5 lore raw

PATCH 1/2 serial: mxc: support DTE mode

Hi Simon,

Quoted 26 lines · Simon Glass

Hi Ryan,

Quoted 5 lines · Ryan Harkin

Hi Stefan,

Thanks for looking so quickly.

On 19 January 2018 at 12:23, Stefan Agner <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines

Hi Ryan,

Quoted 8 lines
Quoted 5 lines · Ryan Harkin
Quoted 1 line

Add DTE mode support via Kconfig on the MXC uart.

Make use of the driver model, there DTE is supported already today:
https://lists.denx.de/pipermail/u-boot/2016-July/259573.html

My change would be useful for other non-DM users of serial_mxc.c, of

course.

Quoted 4 lines

Not just WaRP7.

I don't have any objection to WaRP7 moving to DM, although that isn't my call, but moving using the driver model is not a straight-forward

Quoted 8 lines

change, is

Quoted 1 line

it? WaRP7 today doesn't use it.

We are planning to require that board use CONFIG_BLK fairly soon, and that likely means conversion to device tree I don't think it makes sense to accept patches like this. If the board can be converted, then let's do it!

I'm not the maintainer of this board. I'm only making this patch so I can put it into our test farm. But I'm interested in giving it a go. In fact, I started already after Stefan's email. And bricked my board :-)

Quoted 9 lines
Quoted 2 lines

Do you have an example of a board using this driver that switched using

the

Quoted 1 line

driver model? I'd like to see the scale of the changes needed.

It probably requires:

- Adding a DT (with u-boot,dm-pre-reloc as needed)

I take it we add the DT from the upstream linux kernel? The upstream DT doesn't define UART6, the one I want to use. I have a patch for the kernel that I have not attempted to send upstream yet.

What approach should I take?
- upstream my patch to the kernel first
- use the DT from upstream kernel as-is and add a separate patch in the u-boot tree
- use the DT from upstream kernel as-is and squash in my patch

Or something else?

Updating the DT from upstream will possibly mean updating the DTs for all other iMX7 boards [1], because the include/dt-bindings stuff has changed slightly, as well as the imx7s.dtsi file. I have no way of testing the other boards, but I guess their maintainers can help there.

- Checking that stdio-path is correct

Quoted 1 line

That's probably what bricked my board...

Cheers,
Ryan.

[1] There only appear to be two iMX7 board in u-boot already:
arch/arm/dts/imx7d.dtsi:44:#include "imx7s.dtsi" arch/arm/dts/imx7-colibri.dts:9:#include "imx7d.dtsi" arch/arm/dts/imx7d-sdb.dts:9:#include "imx7d.dtsi"

Quoted 3 lines

Regards,
Simon

#6 lore raw

PATCH 2/2 warp7: add support for console on UART6 and mikroBus

In reply to Ryan Harkin

Add support to route the serial console on the NXP WaRP7 board to UART6 and the mikroBus.

To use UART6 on the WaRP7 board, I add the following lines to configs/warp7_defconfig:

+CONFIG_MXC_CONSOLE_NUM=6
+CONFIG_SERIAL_MXC_DTE_MODE=y

---
 board/warp7/Kconfig     | 9 +++++++++
 board/warp7/warp7.c     | 6 ++++++
 include/configs/warp7.h | 8 +++++++-
 3 files changed, 22 insertions(+), 1 deletion(-)
board/warp7/Kconfig +9 -0
index 61c33fb..5fb4824 100644
@@ -6,4 +6,13 @@ config SYS_BOARD
 config SYS_CONFIG_NAME
 	default "warp7"
 
+config MXC_CONSOLE_NUM
+	int "UART used for the console"
+	default 1
+	help
+	  The UART used for the console, expressed as a 1-based integer.
+	  This is also used to set the console variable passed to the kernel.
+	  Currently, only UART1 and UART6 are supported. Specifying a value
+	  other than 6 will result in using UART1.
+
 endif
board/warp7/warp7.c +6 -0
index d422d63..d345b0e 100644
@@ -67,6 +67,11 @@ static iomux_v3_cfg_t const uart1_pads[] = {
 	MX7D_PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
 };
 
+static iomux_v3_cfg_t const uart6_pads[] = {
+	MX7D_PAD_ECSPI1_MOSI__UART6_DTE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
+	MX7D_PAD_ECSPI1_SCLK__UART6_DTE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
+};
+
 static iomux_v3_cfg_t const usdhc3_pads[] = {
 	MX7D_PAD_SD3_CLK__SD3_CLK     | MUX_PAD_CTRL(USDHC_PAD_CTRL),
 	MX7D_PAD_SD3_CMD__SD3_CMD     | MUX_PAD_CTRL(USDHC_PAD_CTRL),
@@ -84,6 +89,7 @@ static iomux_v3_cfg_t const usdhc3_pads[] = {
 static void setup_iomux_uart(void)
 {
 	imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
+	imx_iomux_v3_setup_multiple_pads(uart6_pads, ARRAY_SIZE(uart6_pads));
 };
 
 static struct fsl_esdhc_cfg usdhc_cfg[1] = {
include/configs/warp7.h +7 -1
index 11f1bc3..271667d 100644
@@ -13,7 +13,13 @@
 
 #define PHYS_SDRAM_SIZE			SZ_512M
 
+#if (CONFIG_MXC_CONSOLE_NUM == 6)
+#define CONFIG_MXC_UART_BASE		UART6_IPS_BASE_ADDR
+#define CONSOLE				"ttymxc5"
+#else
 #define CONFIG_MXC_UART_BASE		UART1_IPS_BASE_ADDR
+#define CONSOLE				"ttymxc0"
+#endif
 
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(35 * SZ_1M)
@@ -31,7 +37,7 @@
 	CONFIG_DFU_ENV_SETTINGS \
 	"script=boot.scr\0" \
 	"image=zImage\0" \
-	"console=ttymxc0\0" \
+	"console=" CONSOLE "\0" \
 	"ethact=usb_ether\0" \
 	"fdt_high=0xffffffff\0" \
 	"initrd_high=0xffffffff\0" \
Signature · 1 line
2.7.4
#7 lore raw

cover warp7: add UART6 support

In reply to Ryan Harkin
Quoted 16 lines · Ryan Harkin

This small series adds support for using the console on UART6 on the WaRP7 board.

The board retains current functionality: UART6 is not used by default and needs it needs to be enabled in defconfig.

[PATCH 1/2] serial: mxc: support DTE mode
[PATCH 2/2] warp7: add support for console on UART6 and mikroBus

  board/warp7/Kconfig         |  9 +++++++++
  board/warp7/warp7.c         |  6 ++++++
  drivers/serial/Kconfig      |  7 +++++++
  drivers/serial/serial_mxc.c | 10 ++++++++--
  include/configs/warp7.h     |  8 +++++++-
  5 files changed, 37 insertions(+), 3 deletions(-)
Quoted 5 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot