Skip to contentSkip to conversation

AT91SAM9 series - cleanup USART definitions

RFC Reinhard Meyer 2 participants 4 messages Jun 29, 2010

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

Dear Reinhard Meyer,

Quoted 2 lines · In message <[email protected]> you wrote:

I propose to make the following changes:

Please go on and submit a patch.

Best regards,

Wolfgang Denk

Signature · 6 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
Substitute "damn" every time you're inclined to write "very"; your
editor will delete it and the writing will be just as it should be.
                - Mark Twain
#2 lore raw
Quoted 9 lines · Wolfgang Denk

Dear Reinhard Meyer,

Quoted 2 lines · In message <[email protected]> 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

#3 lore raw
Quoted 6 lines · Reinhard Meyer

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