use "boot selecr" jumper on NGW100 to select USART
PATCH 1/1 use "boot selecr" jumper on NGW100 to select USART
Without the "boot select" jumper U-Boot will use the USART selected using the CONFIG_USART1, CONFIG_USART2, directive.
If CONFIG_ALT_USART1 (or ..2, ..3, ..0) is defined then, with the jumper in place, that USART is used instead.
--- board/atmel/atngw100/atngw100.c | 40 ++++++++++++++++++++++++++++ drivers/serial/atmel_usart.c | 54 ++++++++++++++++++++++++++++++++++++++- drivers/serial/atmel_usart.h | 9 +++--- include/configs/atngw100.h | 1 + 4 files changed, 98 insertions(+), 6 deletions(-)
board/atmel/atngw100/atngw100.c +40 -0
@@ -53,7 +53,47 @@ int board_early_init_f(void)hmatrix_slave_write (EBI ,SFR ,HMATRIX_BIT (EBI_SDRAM_ENABLE ));portmux_enable_ebi (16 ,23 ,0 ,PORTMUX_DRIVE_HIGH ); + +#if defined(CONFIG_ALT_USART0 ) || defined(CONFIG_ALT_USART1 ) || \ + defined(CONFIG_ALT_USART2 ) || defined(CONFIG_ALT_USART3 ) +#define USART_USE_ALT (!gpio_get_value(GPIO_PIN_PB(30))) + +/* PB30, the 'boot' jumper with external pull-up resistor */ +/* PORTMUX_DIR_INPUT == 0 as high-impedance input is the default state. +In other words, I don't think this actually does anything... */ +portmux_select_gpio (PORTMUX_PORT_B , + (1 <<30 ), +PORTMUX_DIR_INPUT ); +/* Now to read the state of the pin and use it to determine which +USART to initialise. Should I sleep first to make sure the +pin settles down (just in case the above call did actually +do something)? */ +if (USART_USE_ALT ) { +#if defined(CONFIG_ALT_USART0 ) +portmux_enable_usart0 (PORTMUX_DRIVE_MIN ); +#elif defined(CONFIG_ALT_USART1 ) +portmux_enable_usart1 (PORTMUX_DRIVE_MIN ); +#elif defined(CONFIG_ALT_USART2 ) +portmux_enable_usart2 (PORTMUX_DRIVE_MIN ); +#elif defined(CONFIG_ALT_USART3 ) +portmux_enable_usart3 (PORTMUX_DRIVE_MIN ); +#endif + }else { +#endif +#if defined(CONFIG_USART0 ) +portmux_enable_usart0 (PORTMUX_DRIVE_MIN ); +#elif defined(CONFIG_USART1 )portmux_enable_usart1 (PORTMUX_DRIVE_MIN ); +#elif defined(CONFIG_USART2 ) +portmux_enable_usart2 (PORTMUX_DRIVE_MIN ); +#elif defined(CONFIG_USART3 ) +portmux_enable_usart3 (PORTMUX_DRIVE_MIN ); +#else +#error "Define CONFIG_USART0..3" +#endif +#ifdef USART_USE_ALT + } +#endif #if defined(CONFIG_MACB )portmux_enable_macb0 (PORTMUX_MACB_MII ,PORTMUX_DRIVE_HIGH );
drivers/serial/atmel_usart.c +53 -1
69 lines not on this page · raw message
drivers/serial/atmel_usart.h +4 -5
@@ -305,10 +305,9 @@ << USART3_##name##_OFFSET)) \ | USART3_BF(name,value)) -/* Register access macros */ -#define usart3_readl (reg) \ - readl((void *)USART_BASE + USART3_##reg) -#define usart3_writel (reg,value) \ - writel((value), (void *)USART_BASE + USART3_##reg) +int atmel_serial_read (int reg); +void atmel_serial_write (int reg,int value); +#define usart3_readl (reg) atmel_serial_read(USART3_##reg) +#define usart3_writel (reg, value) atmel_serial_write(USART3_##reg, value)#endif /* __DRIVERS_ATMEL_USART_H__ */
include/configs/atngw100.h +1 -0
@@ -59,6 +59,7 @@#define CONFIG_SYS_PLL0_OPT 0x04#define CONFIG_USART1 1 +#define CONFIG_ALT_USART1 3/* User serviceable stuff */ #define CONFIG_DOS_PARTITION 1
Signature · 1 line
1.6.3.3
PATCH 1/1 use "boot selecr" jumper on NGW100 to select USART
Dear Thomas Sprinkmeier,
Quoted 2 lines · In message <[email protected]> you…
Without the "boot select" jumper U-Boot will use the USART selected using the
CONFIG_USART1,CONFIG_USART2, directive.
Please fix the typo in the Subject:
Quoted 16 lines
If
CONFIG_ALT_USART1(or ..2, ..3, ..0) is defined then, with the jumper in place, that USART is used instead.Signed-off-by Thomas Sprinkmeier <[email protected]>--- board/atmel/atngw100/atngw100.c | 40 ++++++++++++++++++++++++++++ drivers/serial/atmel_usart.c | 54 ++++++++++++++++++++++++++++++++++++++- drivers/serial/atmel_usart.h | 9 +++--- include/configs/atngw100.h | 1 + 4 files changed, 98 insertions(+), 6 deletions(-)board/atmel/atngw100/atngw100.c +0
-0
board/atmel/atngw100/atngw100.c int board_early_init_f(void) · line 59
Quoted 7 lines
board/atmel/atngw100/atngw100.c +4
-0@@ -53,7 +53,47 @@ int board_early_init_f(void)hmatrix_slave_write (EBI ,SFR ,HMATRIX_BIT (EBI_SDRAM_ENABLE ));portmux_enable_ebi (16 ,23 ,0 ,PORTMUX_DRIVE_HIGH ); + +#if defined(CONFIG_ALT_USART0 ) || defined(CONFIG_ALT_USART1 ) || \ + defined(CONFIG_ALT_USART2 ) || defined(CONFIG_ALT_USART3 ) +#define USART_USE_ALT (!gpio_get_value(GPIO_PIN_PB(30)))
Your patch is white space corrupted. All "original" indentation was by TABs, but in your patch it's all spaces.
board/atmel/atngw100/atngw100.c int board_early_init_f(void) · line 63
Quoted 3 lines
board/atmel/atngw100/atngw100.c +3
-0+/* PB30, the 'boot' jumper with external pull-up resistor */ +/* PORTMUX_DIR_INPUT == 0 as high-impedance input is the default state. +In other words, I don't think this actually does anything... */
Incorrect multiline comment style. Please fix globally.
board/atmel/atngw100/atngw100.c int board_early_init_f(void) · line 80
Quoted 10 lines
board/atmel/atngw100/atngw100.c +10
-0+if (USART_USE_ALT ) { +#if defined(CONFIG_ALT_USART0 ) +portmux_enable_usart0 (PORTMUX_DRIVE_MIN ); +#elif defined(CONFIG_ALT_USART1 ) +portmux_enable_usart1 (PORTMUX_DRIVE_MIN ); +#elif defined(CONFIG_ALT_USART2 ) +portmux_enable_usart2 (PORTMUX_DRIVE_MIN ); +#elif defined(CONFIG_ALT_USART3 ) +portmux_enable_usart3 (PORTMUX_DRIVE_MIN ); +#endif
Incorrect indentation. Please fix globally.
board/atmel/atngw100/atngw100.c int board_early_init_f(void) · line 91
Quoted 11 lines
board/atmel/atngw100/atngw100.c +10
-0+ } else { +#endif +#if defined(CONFIG_USART0 ) +portmux_enable_usart0 (PORTMUX_DRIVE_MIN ); +#elif defined(CONFIG_USART1 )portmux_enable_usart1 (PORTMUX_DRIVE_MIN ); +#elif defined(CONFIG_USART2 ) +portmux_enable_usart2 (PORTMUX_DRIVE_MIN ); +#elif defined(CONFIG_USART3 ) +portmux_enable_usart3 (PORTMUX_DRIVE_MIN ); +#else
If only one CONFIG_USARTx is allowed, you should think opf a way to get rid of these long, repeated #if...#elif...#elif constructs.
board/atmel/atngw100/atngw100.c int board_early_init_f(void)
Quoted 10 lines
board/atmel/atngw100/atngw100.c +4
-5-/* Register access macros */ -#define usart3_readl (reg) \ - readl((void *)USART_BASE + USART3_##reg) -#define usart3_writel (reg,value) \ - writel((value), (void *)USART_BASE + USART3_##reg) +int atmel_serial_read (int reg); +void atmel_serial_write (int reg,int value); +#define usart3_readl (reg) atmel_serial_read(USART3_##reg) +#define usart3_writel (reg, value) atmel_serial_write(USART3_##reg, value)
Instead of making code more AT91 specific, we should try the opposite:
make it _less_ so.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I really hate this damned machine It never does quite what I want I wish that they would sell it. But only what I tell it.