[U-Boot] [RFC] AT91SAM9 series - cleanup USART definitions

Hi,
AT91SAM9 based boards have something like this in their include/configs file:
#define CONFIG_ATMEL_USART 1 #undef CONFIG_USART0 #undef CONFIG_USART1 #undef CONFIG_USART2 #define CONFIG_USART3 1 /* USART 3 is DBGU */
these defines are used in drivers/serial/atmel_usart.c:
#if defined(CONFIG_USART0) # define USART_ID 0 # define USART_BASE USART0_BASE #elif defined(CONFIG_USART1) # define USART_ID 1 # define USART_BASE USART1_BASE #elif defined(CONFIG_USART2) # define USART_ID 2 # define USART_BASE USART2_BASE #elif defined(CONFIG_USART3) # define USART_ID 3 # define USART_BASE USART3_BASE #endif
USARTx_BASE is defined in arch/arm/include/asm/arch-at91/memory_map.h:
#define USART0_BASE AT91_USART0 #define USART1_BASE AT91_USART1 #define USART2_BASE AT91_USART2 #define USART3_BASE (AT91_BASE_SYS + AT91_DBGU) #define SPI0_BASE AT91_BASE_SPI (note that nothing else is defined in that file!)
AT91_USARTx finally comes from arch/arm/include/asm/arch-at91/at91sam*.h:
#define AT91_USART0 AT91SAM9260_BASE_US0 #define AT91_USART1 AT91SAM9260_BASE_US1 #define AT91_USART2 AT91SAM9260_BASE_US2 #define AT91_USART3 AT91SAM9260_BASE_US3 #define AT91_USART4 AT91SAM9260_BASE_US4 #define AT91_USART5 AT91SAM9260_BASE_US5
1. memory_map.h is misleading, it just defines a few USARTs and one SPI 2. equalling CONFIG_USART3 with the debug UART is plain wrong, the 9260 for example has 6 'regular' USARTs (0..5) plus the debug UART
I propose to make the following changes: 1. get rid of memory_map.h and the references to it, move the USART definitions to the respective at91sam*.h files 2. use DBU_BASE for the debug UART, leaving USART[0-5]_BASE to adress the 'regular' USARTs 3. use CONFIG_UARTDEBUG to indicate use of the debug UART for console output
Note for those that don't want to dig the datasheets: the debug UART is software compatible to the 'regular' USARTs as long as only asynchronous features are used (true for the atmel_usart.c driver)
Reinhard

Dear Reinhard Meyer,
In message 4C2A3C42.7050602@emk-elektronik.de you wrote:
I propose to make the following changes:
Please go on and submit a patch.
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
Dear Reinhard Meyer,
In message 4C2A3C42.7050602@emk-elektronik.de you wrote:
I propose to make the following changes:
Please go on and submit a patch.
Hello Wolfgang,
I just became aware that this patch will involve changes to ALL include/configs/*.h files for AT91 AND AVR32 boards using atmel_usart.c. If thats OK I will do that.
Reinhard

Reinhard Meyer wrote:
Hello Wolfgang,
I just became aware that this patch will involve changes to ALL include/configs/*.h files for AT91 AND AVR32 boards using atmel_usart.c. If thats OK I will do that.
Reason:
#if defined(CONFIG_USART0) # define USART_ID 0 # define USART_BASE USART0_BASE #elif defined(CONFIG_USART1) # define USART_ID 1 # define USART_BASE USART1_BASE #elif defined(CONFIG_USART2) # define USART_ID 2 # define USART_BASE USART2_BASE #elif defined(CONFIG_USART3) # define USART_ID 3 # define USART_BASE USART3_BASE #endif
in atmel_usart.c would have to be blown up for each "new" USART incarnation Atmel invents on new SoCs. USART_ID is effectively not used and USART_BASE might as well defined directly in the include/configs/<board>.h file either by:
#define CONFIG_ATMEL_USART 1 #define CONFIG_ATMEL_USART_BASE AT91_UARTDEB /* USART used is DBGU */
OR directly by:
#define CONFIG_ATMEL_USART AT91_UARTDEB /* USART used is DBGU */
or is the 2nd solution bad because Makefiles might choke on it?
Greetings, Reinhard
participants (2)
-
Reinhard Meyer
-
Wolfgang Denk