[U-Boot] [PATCH v4 0/4] am335x_evm: Enable UART{1,2,3,4,5}

To support serial ports other than UART0 on am335x based systems like the Beaglebone with the RS232 cape and am335x_evm with daughterboard.
Changes from v3: * Patch 4/4 simplified further. Changes from v2: * Patch 4/4 cleaned up to define CONS_INDEX and SERIALX in the target options. Changes from v1: * Reduced from 6 patches to 4. * Reworked on Marek Vasut's serial changes. * Added UART3 for am335x_evm profile 5.
Andrew Bradford (4): am33xx: Enable UART{1,2,3,4,5} clocks am33xx: Enable UART{1,2,3,4,5} pin-mux serial: ns16550: Enable COM5 and COM6 am335x_evm: Enable use of UART{1,2,3,4,5}
arch/arm/cpu/armv7/am33xx/board.c | 17 ++++++++ arch/arm/cpu/armv7/am33xx/clock.c | 35 +++++++++++++++++ arch/arm/include/asm/arch-am33xx/sys_proto.h | 7 +++- board/ti/am335x/mux.c | 54 ++++++++++++++++++++++++++ boards.cfg | 7 +++- drivers/serial/serial_ns16550.c | 36 +++++++++++++++-- include/configs/am335x_evm.h | 12 +++--- 7 files changed, 158 insertions(+), 10 deletions(-)

If configured to use UART{1,2,3,4,5} such as on the Beaglebone RS232 cape or the am335x_evm daughterboard, enable the required clocks for the UART in use.
Signed-off-by: Andrew Bradford andrew@bradfordembedded.com --- Changes from v3: No changes Changes from v2: No changes Changes from v1: Also enable UART3 clocks
arch/arm/cpu/armv7/am33xx/clock.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/arch/arm/cpu/armv7/am33xx/clock.c b/arch/arm/cpu/armv7/am33xx/clock.c index 2b19506..b34f969 100644 --- a/arch/arm/cpu/armv7/am33xx/clock.c +++ b/arch/arm/cpu/armv7/am33xx/clock.c @@ -114,6 +114,41 @@ static void enable_per_clocks(void) while (readl(&cmwkup->wkup_uart0ctrl) != PRCM_MOD_EN) ;
+ /* UART1 */ +#ifdef CONFIG_SERIAL2 + writel(PRCM_MOD_EN, &cmper->uart1clkctrl); + while (readl(&cmper->uart1clkctrl) != PRCM_MOD_EN) + ; +#endif /* CONFIG_SERIAL2 */ + + /* UART2 */ +#ifdef CONFIG_SERIAL3 + writel(PRCM_MOD_EN, &cmper->uart2clkctrl); + while (readl(&cmper->uart2clkctrl) != PRCM_MOD_EN) + ; +#endif /* CONFIG_SERIAL3 */ + + /* UART3 */ +#ifdef CONFIG_SERIAL4 + writel(PRCM_MOD_EN, &cmper->uart3clkctrl); + while (readl(&cmper->uart3clkctrl) != PRCM_MOD_EN) + ; +#endif /* CONFIG_SERIAL4 */ + + /* UART4 */ +#ifdef CONFIG_SERIAL5 + writel(PRCM_MOD_EN, &cmper->uart4clkctrl); + while (readl(&cmper->uart4clkctrl) != PRCM_MOD_EN) + ; +#endif /* CONFIG_SERIAL5 */ + + /* UART5 */ +#ifdef CONFIG_SERIAL6 + writel(PRCM_MOD_EN, &cmper->uart5clkctrl); + while (readl(&cmper->uart5clkctrl) != PRCM_MOD_EN) + ; +#endif /* CONFIG_SERIAL6 */ + /* MMC0*/ writel(PRCM_MOD_EN, &cmper->mmc0clkctrl); while (readl(&cmper->mmc0clkctrl) != PRCM_MOD_EN)

If configured to use UART{1,2,3,4,5} such as on the Beaglebone RS232 cape or on the am335x_evm daughterboard, enable the proper pin-muxing.
Signed-off-by: Andrew Bradford andrew@bradfordembedded.com --- Changes from v3: No changes Changes from v2: No changes Changes from v1: Also enable UART3 pin mux
arch/arm/cpu/armv7/am33xx/board.c | 17 ++++++++ arch/arm/include/asm/arch-am33xx/sys_proto.h | 7 +++- board/ti/am335x/mux.c | 54 ++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index 978b184..e324265 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -152,7 +152,24 @@ void s_init(void) /* UART softreset */ u32 regVal;
+#ifdef CONFIG_SERIAL1 enable_uart0_pin_mux(); +#endif /* CONFIG_SERIAL1 */ +#ifdef CONFIG_SERIAL2 + enable_uart1_pin_mux(); +#endif /* CONFIG_SERIAL2 */ +#ifdef CONFIG_SERIAL3 + enable_uart2_pin_mux(); +#endif /* CONFIG_SERIAL3 */ +#ifdef CONFIG_SERIAL4 + enable_uart3_pin_mux(); +#endif /* CONFIG_SERIAL4 */ +#ifdef CONFIG_SERIAL5 + enable_uart4_pin_mux(); +#endif /* CONFIG_SERIAL5 */ +#ifdef CONFIG_SERIAL6 + enable_uart5_pin_mux(); +#endif /* CONFIG_SERIAL6 */
regVal = readl(&uart_base->uartsyscfg); regVal |= UART_RESET; diff --git a/arch/arm/include/asm/arch-am33xx/sys_proto.h b/arch/arm/include/asm/arch-am33xx/sys_proto.h index 819ea65..3ef1ff2 100644 --- a/arch/arm/include/asm/arch-am33xx/sys_proto.h +++ b/arch/arm/include/asm/arch-am33xx/sys_proto.h @@ -53,11 +53,16 @@ void ddr_pll_config(unsigned int ddrpll_M);
/* * We have three pin mux functions that must exist. We must be able to enable - * uart0, for initial output and i2c0 to read the main EEPROM. We then have a + * a uart for initial output and i2c0 to read the main EEPROM. We then have a * main pinmux function that can be overridden to enable all other pinmux that * is required on the board. */ void enable_uart0_pin_mux(void); +void enable_uart1_pin_mux(void); +void enable_uart2_pin_mux(void); +void enable_uart3_pin_mux(void); +void enable_uart4_pin_mux(void); +void enable_uart5_pin_mux(void); void enable_i2c0_pin_mux(void); void enable_board_pin_mux(struct am335x_baseboard_id *header); #endif diff --git a/board/ti/am335x/mux.c b/board/ti/am335x/mux.c index 80becd5..82b5852 100644 --- a/board/ti/am335x/mux.c +++ b/board/ti/am335x/mux.c @@ -259,6 +259,36 @@ static struct module_pin_mux uart0_pin_mux[] = { {-1}, };
+static struct module_pin_mux uart1_pin_mux[] = { + {OFFSET(uart1_rxd), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* UART1_RXD */ + {OFFSET(uart1_txd), (MODE(0) | PULLUDEN)}, /* UART1_TXD */ + {-1}, +}; + +static struct module_pin_mux uart2_pin_mux[] = { + {OFFSET(spi0_sclk), (MODE(1) | PULLUP_EN | RXACTIVE)}, /* UART2_RXD */ + {OFFSET(spi0_d0), (MODE(1) | PULLUDEN)}, /* UART2_TXD */ + {-1}, +}; + +static struct module_pin_mux uart3_pin_mux[] = { + {OFFSET(spi0_cs1), (MODE(1) | PULLUP_EN | RXACTIVE)}, /* UART3_RXD */ + {OFFSET(ecap0_in_pwm0_out), (MODE(1) | PULLUDEN)}, /* UART3_TXD */ + {-1}, +}; + +static struct module_pin_mux uart4_pin_mux[] = { + {OFFSET(gpmc_wait0), (MODE(6) | PULLUP_EN | RXACTIVE)}, /* UART4_RXD */ + {OFFSET(gpmc_wpn), (MODE(6) | PULLUDEN)}, /* UART4_TXD */ + {-1}, +}; + +static struct module_pin_mux uart5_pin_mux[] = { + {OFFSET(lcd_data9), (MODE(4) | PULLUP_EN | RXACTIVE)}, /* UART5_RXD */ + {OFFSET(lcd_data8), (MODE(4) | PULLUDEN)}, /* UART5_TXD */ + {-1}, +}; + static struct module_pin_mux mmc0_pin_mux[] = { {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */ {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */ @@ -381,6 +411,30 @@ void enable_uart0_pin_mux(void) configure_module_pin_mux(uart0_pin_mux); }
+void enable_uart1_pin_mux(void) +{ + configure_module_pin_mux(uart1_pin_mux); +} + +void enable_uart2_pin_mux(void) +{ + configure_module_pin_mux(uart2_pin_mux); +} + +void enable_uart3_pin_mux(void) +{ + configure_module_pin_mux(uart3_pin_mux); +} + +void enable_uart4_pin_mux(void) +{ + configure_module_pin_mux(uart4_pin_mux); +} + +void enable_uart5_pin_mux(void) +{ + configure_module_pin_mux(uart5_pin_mux); +}
void enable_i2c0_pin_mux(void) {

Increase the possible number of ns16550 serial devices from 4 to 6.
Signed-off-by: Andrew Bradford andrew@bradfordembedded.com --- Changes from v3: No changes Changes from v2: No changes Changes from v1: Consolidation of patches 3, 4, and 5 on top of Marek Vasut's recent serial changes.
drivers/serial/serial_ns16550.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c index b5d1248..5fb3841 100644 --- a/drivers/serial/serial_ns16550.c +++ b/drivers/serial/serial_ns16550.c @@ -34,7 +34,7 @@ DECLARE_GLOBAL_DATA_PTR;
#if !defined(CONFIG_CONS_INDEX) -#elif (CONFIG_CONS_INDEX < 1) || (CONFIG_CONS_INDEX > 4) +#elif (CONFIG_CONS_INDEX < 1) || (CONFIG_CONS_INDEX > 6) #error "Invalid console index value." #endif
@@ -46,12 +46,16 @@ DECLARE_GLOBAL_DATA_PTR; #error "Console port 3 defined but not configured." #elif CONFIG_CONS_INDEX == 4 && !defined(CONFIG_SYS_NS16550_COM4) #error "Console port 4 defined but not configured." +#elif CONFIG_CONS_INDEX == 5 && !defined(CONFIG_SYS_NS16550_COM5) +#error "Console port 5 defined but not configured." +#elif CONFIG_CONS_INDEX == 6 && !defined(CONFIG_SYS_NS16550_COM6) +#error "Console port 6 defined but not configured." #endif
/* Note: The port number specified in the functions is 1 based. * the array is 0 based. */ -static NS16550_t serial_ports[4] = { +static NS16550_t serial_ports[6] = { #ifdef CONFIG_SYS_NS16550_COM1 (NS16550_t)CONFIG_SYS_NS16550_COM1, #else @@ -68,7 +72,17 @@ static NS16550_t serial_ports[4] = { NULL, #endif #ifdef CONFIG_SYS_NS16550_COM4 - (NS16550_t)CONFIG_SYS_NS16550_COM4 + (NS16550_t)CONFIG_SYS_NS16550_COM4, +#else + NULL, +#endif +#ifdef CONFIG_SYS_NS16550_COM5 + (NS16550_t)CONFIG_SYS_NS16550_COM5, +#else + NULL, +#endif +#ifdef CONFIG_SYS_NS16550_COM6 + (NS16550_t)CONFIG_SYS_NS16550_COM6 #else NULL #endif @@ -231,6 +245,12 @@ struct serial_device eserial3_device = DECLARE_ESERIAL_FUNCTIONS(4); struct serial_device eserial4_device = INIT_ESERIAL_STRUCTURE(4, "eserial3"); +DECLARE_ESERIAL_FUNCTIONS(5); +struct serial_device eserial5_device = + INIT_ESERIAL_STRUCTURE(5, "eserial4"); +DECLARE_ESERIAL_FUNCTIONS(6); +struct serial_device eserial6_device = + INIT_ESERIAL_STRUCTURE(6, "eserial5");
__weak struct serial_device *default_serial_console(void) { @@ -242,6 +262,10 @@ __weak struct serial_device *default_serial_console(void) return &eserial3_device; #elif CONFIG_CONS_INDEX == 4 return &eserial4_device; +#elif CONFIG_CONS_INDEX == 5 + return &eserial5_device; +#elif CONFIG_CONS_INDEX == 6 + return &eserial6_device; #else #error "Bad CONFIG_CONS_INDEX." #endif @@ -261,4 +285,10 @@ void ns16550_serial_initialize(void) #if defined(CONFIG_SYS_NS16550_COM4) serial_register(&eserial4_device); #endif +#if defined(CONFIG_SYS_NS16550_COM5) + serial_register(&eserial5_device); +#endif +#if defined(CONFIG_SYS_NS16550_COM6) + serial_register(&eserial6_device); +#endif }

Add targets of am335x_evm_uart{1,2,3,4,5} to have serial input/output on UART{1,2,3,4,5} for use with the Beaglebone RS232 cape, am335x_evm daughterboard, and other custom configurations.
Modify target for am335x_evm to include SERIAL1 and CONS_INDEX=1 options in order to clarify UART selection requirements.
Signed-off-by: Andrew Bradford andrew@bradfordembedded.com --- Changes from v3: All am335x_evm targets get SERIALX without a 1 and CONS_INDEX=X defined in boards.cfg. am335x_evm.h no longer define any CONFIG_SERIALX or CONFIG_CONS_INDEX. Changes from v2: Set CONS_INDEX and SERIALX in the target options instead of using AM33XX_UART_SELECT resulting in an easier to read config. Changes from v1: Add UART3 target and register location.
boards.cfg | 7 ++++++- include/configs/am335x_evm.h | 12 +++++++----- 2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/boards.cfg b/boards.cfg index b14a08f..4047966 100644 --- a/boards.cfg +++ b/boards.cfg @@ -225,7 +225,12 @@ versatileqemu arm arm926ejs versatile armltd integratorap_cm946es arm arm946es integrator armltd - integratorap:CM946ES integratorcp_cm946es arm arm946es integrator armltd - integratorcp:CM946ES ca9x4_ct_vxp arm armv7 vexpress armltd -am335x_evm arm armv7 am335x ti am33xx +am335x_evm arm armv7 am335x ti am33xx am335x_evm:SERIAL1,CONS_INDEX=1 +am335x_evm_uart1 arm armv7 am335x ti am33xx am335x_evm:SERIAL2,CONS_INDEX=2 +am335x_evm_uart2 arm armv7 am335x ti am33xx am335x_evm:SERIAL3,CONS_INDEX=3 +am335x_evm_uart3 arm armv7 am335x ti am33xx am335x_evm:SERIAL4,CONS_INDEX=4 +am335x_evm_uart4 arm armv7 am335x ti am33xx am335x_evm:SERIAL5,CONS_INDEX=5 +am335x_evm_uart5 arm armv7 am335x ti am33xx am335x_evm:SERIAL6,CONS_INDEX=6 highbank arm armv7 highbank - highbank mx51_efikamx arm armv7 mx51_efikamx genesi mx5 mx51_efikamx:MACH_TYPE=MACH_TYPE_MX51_EFIKAMX,IMX_CONFIG=board/genesi/mx51_efikamx/imximage_mx.cfg mx51_efikasb arm armv7 mx51_efikamx genesi mx5 mx51_efikamx:MACH_TYPE=MACH_TYPE_MX51_EFIKASB,IMX_CONFIG=board/genesi/mx51_efikamx/imximage_sb.cfg diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 339d4bd..e822d25 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -158,9 +158,15 @@ /* NS16550 Configuration */ #define CONFIG_SYS_NS16550 #define CONFIG_SYS_NS16550_SERIAL +#define CONFIG_SERIAL_MULTI #define CONFIG_SYS_NS16550_REG_SIZE (-4) #define CONFIG_SYS_NS16550_CLK (48000000) #define CONFIG_SYS_NS16550_COM1 0x44e09000 /* Base EVM has UART0 */ +#define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1 */ +#define CONFIG_SYS_NS16550_COM3 0x48024000 /* UART2 */ +#define CONFIG_SYS_NS16550_COM4 0x481a6000 /* UART3 */ +#define CONFIG_SYS_NS16550_COM5 0x481a8000 /* UART4 */ +#define CONFIG_SYS_NS16550_COM6 0x481aa000 /* UART5 */
/* I2C Configuration */ #define CONFIG_I2C @@ -182,11 +188,7 @@ #define CONFIG_SYS_BAUDRATE_TABLE { 110, 300, 600, 1200, 2400, \ 4800, 9600, 14400, 19200, 28800, 38400, 56000, 57600, 115200 }
-/* - * select serial console configuration - */ -#define CONFIG_SERIAL1 1 -#define CONFIG_CONS_INDEX 1 +#define CONFIG_ENV_OVERWRITE 1 #define CONFIG_SYS_CONSOLE_INFO_QUIET
#define CONFIG_ENV_IS_NOWHERE

Tested-by: Matthias Fuchs matthias.fuchs@esd.eu
... on AM335x IDK board with console on UART3.
Matthias
On 25.10.2012 14:21, Andrew Bradford wrote:
To support serial ports other than UART0 on am335x based systems like the Beaglebone with the RS232 cape and am335x_evm with daughterboard.
Changes from v3:
- Patch 4/4 simplified further.
Changes from v2:
- Patch 4/4 cleaned up to define CONS_INDEX and SERIALX in the
target options. Changes from v1:
- Reduced from 6 patches to 4.
- Reworked on Marek Vasut's serial changes.
- Added UART3 for am335x_evm profile 5.
Andrew Bradford (4): am33xx: Enable UART{1,2,3,4,5} clocks am33xx: Enable UART{1,2,3,4,5} pin-mux serial: ns16550: Enable COM5 and COM6 am335x_evm: Enable use of UART{1,2,3,4,5}
arch/arm/cpu/armv7/am33xx/board.c | 17 ++++++++ arch/arm/cpu/armv7/am33xx/clock.c | 35 +++++++++++++++++ arch/arm/include/asm/arch-am33xx/sys_proto.h | 7 +++- board/ti/am335x/mux.c | 54 ++++++++++++++++++++++++++ boards.cfg | 7 +++- drivers/serial/serial_ns16550.c | 36 +++++++++++++++-- include/configs/am335x_evm.h | 12 +++--- 7 files changed, 158 insertions(+), 10 deletions(-)

Andrew,
can you rebase your series? arch/arm/cpu/armv7/am33xx/board.c has been moved to board/ti/am335x.
I expect w/o this it won't get applied, right?
Matthias
On 25.10.2012 14:21, Andrew Bradford wrote:
To support serial ports other than UART0 on am335x based systems like the Beaglebone with the RS232 cape and am335x_evm with daughterboard.
Changes from v3:
- Patch 4/4 simplified further.
Changes from v2:
- Patch 4/4 cleaned up to define CONS_INDEX and SERIALX in the
target options. Changes from v1:
- Reduced from 6 patches to 4.
- Reworked on Marek Vasut's serial changes.
- Added UART3 for am335x_evm profile 5.
Andrew Bradford (4): am33xx: Enable UART{1,2,3,4,5} clocks am33xx: Enable UART{1,2,3,4,5} pin-mux serial: ns16550: Enable COM5 and COM6 am335x_evm: Enable use of UART{1,2,3,4,5}
arch/arm/cpu/armv7/am33xx/board.c | 17 ++++++++ arch/arm/cpu/armv7/am33xx/clock.c | 35 +++++++++++++++++ arch/arm/include/asm/arch-am33xx/sys_proto.h | 7 +++- board/ti/am335x/mux.c | 54 ++++++++++++++++++++++++++ boards.cfg | 7 +++- drivers/serial/serial_ns16550.c | 36 +++++++++++++++-- include/configs/am335x_evm.h | 12 +++--- 7 files changed, 158 insertions(+), 10 deletions(-)

On Fri, 02 Nov 2012 14:05:23 +0100 Matthias Fuchs matthias.fuchs@esd.eu wrote:
can you rebase your series? arch/arm/cpu/armv7/am33xx/board.c has been moved to board/ti/am335x.
Yes, I will send a v5 patch series to support u-boot/master changes early next week. Time has not permitted me to do so this week, sorry.
-Andrew

On Fri, Nov 02, 2012 at 11:12:41AM -0400, Andrew Bradford wrote:
On Fri, 02 Nov 2012 14:05:23 +0100 Matthias Fuchs matthias.fuchs@esd.eu wrote:
can you rebase your series? arch/arm/cpu/armv7/am33xx/board.c has been moved to board/ti/am335x.
Yes, I will send a v5 patch series to support u-boot/master changes early next week. Time has not permitted me to do so this week, sorry.
Actually, it was a trivial move and I've got this queued locally, just waiting on the warning fix patch I had posted a little longer before doing a pull request.

On Thu, Oct 25, 2012 at 08:21:28AM -0400, Andrew Bradford wrote:
To support serial ports other than UART0 on am335x based systems like the Beaglebone with the RS232 cape and am335x_evm with daughterboard.
Changes from v3:
- Patch 4/4 simplified further.
Changes from v2:
- Patch 4/4 cleaned up to define CONS_INDEX and SERIALX in the
target options. Changes from v1:
- Reduced from 6 patches to 4.
- Reworked on Marek Vasut's serial changes.
- Added UART3 for am335x_evm profile 5.
Andrew Bradford (4): am33xx: Enable UART{1,2,3,4,5} clocks am33xx: Enable UART{1,2,3,4,5} pin-mux serial: ns16550: Enable COM5 and COM6 am335x_evm: Enable use of UART{1,2,3,4,5}
arch/arm/cpu/armv7/am33xx/board.c | 17 ++++++++ arch/arm/cpu/armv7/am33xx/clock.c | 35 +++++++++++++++++ arch/arm/include/asm/arch-am33xx/sys_proto.h | 7 +++- board/ti/am335x/mux.c | 54 ++++++++++++++++++++++++++ boards.cfg | 7 +++- drivers/serial/serial_ns16550.c | 36 +++++++++++++++-- include/configs/am335x_evm.h | 12 +++--- 7 files changed, 158 insertions(+), 10 deletions(-)
Applied to u-boot-ti/master with the easy fixup for board/ti/am335x/board.c instead, thanks!
participants (3)
-
Andrew Bradford
-
Matthias Fuchs
-
Tom Rini