From d3ad0d02d3717be2546d93125d152e468368bd5b Mon Sep 17 00:00:00 2001 From: Pieter du Preez Date: Wed, 8 Oct 2008 11:23:17 +0200 Subject: [PATCH] AT91: Added a generic way to setup AT91 serial ports in Kconfig Development boards sometimes have more possible serial port configurations than those catered for in the code. If someone designs a board, based on a certain development board and the serial configuration differs slightly, the developer either needs to submit new board software, or patch the development board's software. In order to avoid this, I added some serial port setup menus to Kconfig. All AT91 boards can now be set up with custom serial configurations, without touching the code. While writing the patch I also removed a huge amount of code, that was mindlessly copied, every time a new board was made. We now have much less AT91-serial code to maintain. The changes in Kconfig was tested by compiling all code for all AT91 boards after doing a 'make _defconfig'. Signed-off-by: Pieter du Preez --- arch/arm/Kconfig | 7 +- arch/arm/mach-at91/Kconfig | 453 +++++++++++++++++++++++++---- arch/arm/mach-at91/Makefile | 3 + arch/arm/mach-at91/at91cap9_devices.c | 249 +++------------- arch/arm/mach-at91/at91rm9200_devices.c | 381 +++++------------------- arch/arm/mach-at91/at91sam9260_devices.c | 413 +++++--------------------- arch/arm/mach-at91/at91sam9261_devices.c | 249 +++------------- arch/arm/mach-at91/at91sam9263_devices.c | 250 +++------------- arch/arm/mach-at91/at91sam9rl_devices.c | 327 ++++----------------- arch/arm/mach-at91/board-1arm.c | 13 +- arch/arm/mach-at91/board-cam60.c | 7 +- arch/arm/mach-at91/board-cap9adk.c | 3 +- arch/arm/mach-at91/board-carmeva.c | 12 +- arch/arm/mach-at91/board-csb337.c | 7 +- arch/arm/mach-at91/board-csb637.c | 7 +- arch/arm/mach-at91/board-dk.c | 12 +- arch/arm/mach-at91/board-eb9200.c | 15 +- arch/arm/mach-at91/board-ecbat91.c | 10 +- arch/arm/mach-at91/board-ek.c | 12 +- arch/arm/mach-at91/board-kafa.c | 13 +- arch/arm/mach-at91/board-kb9202.c | 16 +- arch/arm/mach-at91/board-picotux200.c | 13 +- arch/arm/mach-at91/board-qil-a9260.c | 19 +- arch/arm/mach-at91/board-sam9-l9260.c | 15 +- arch/arm/mach-at91/board-sam9260ek.c | 15 +- arch/arm/mach-at91/board-sam9261ek.c | 7 +- arch/arm/mach-at91/board-sam9263ek.c | 10 +- arch/arm/mach-at91/board-sam9g20ek.c | 15 +- arch/arm/mach-at91/board-sam9rlek.c | 10 +- arch/arm/mach-at91/board-usb-a9260.c | 7 +- arch/arm/mach-at91/board-usb-a9263.c | 7 +- arch/arm/mach-at91/board-yl-9200.c | 18 +- arch/arm/mach-at91/generic.h | 5 + arch/arm/mach-at91/include/mach/board.h | 31 +- arch/arm/mach-at91/include/mach/hardware.h | 6 +- arch/arm/mach-at91/uart.c | 143 +++++++++ arch/arm/mach-at91/uart.h | 55 ++++ 37 files changed, 992 insertions(+), 1843 deletions(-) create mode 100644 arch/arm/mach-at91/uart.c create mode 100644 arch/arm/mach-at91/uart.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 70dba166890..79790133fec 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -236,9 +236,12 @@ config ARCH_AT91 bool "Atmel AT91" select GENERIC_GPIO select HAVE_CLK + select SERIAL_ATMEL help - This enables support for systems based on the Atmel AT91RM9200, - AT91SAM9 and AT91CAP9 processors. + This enables support for systems based on the Atmel AT91 + range of processors. Examples are the AT91RM9200, + AT91SAM926[013], AT91SAM9G20, AT91SAM9RL and AT91CAP9 + and ARCH_AT91X40 processors. config ARCH_CLPS7500 bool "Cirrus CL-PS7500FE" diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index a048b92cb40..71d0f634d52 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -1,6 +1,5 @@ -if ARCH_AT91 - menu "Atmel AT91 System-on-Chip" + depends on ARCH_AT91 choice prompt "Atmel AT91 Processor" @@ -14,6 +13,10 @@ config ARCH_AT91SAM9260 bool "AT91SAM9260 or AT91SAM9XE" select GENERIC_TIME select GENERIC_CLOCKEVENTS + help + Select this if you are using Atmel's AT91SAM9260 or AT91SAM9XE + System-on-Chip. They are basically AT91SAM9260s with various + sizes of embedded Flash. config ARCH_AT91SAM9261 bool "AT91SAM9261" @@ -51,9 +54,12 @@ config AT91_PMC_UNIT # ---------------------------------------------------------- -if ARCH_AT91RM9200 - -comment "AT91RM9200 Board Type" +choice + prompt "Board type" + help + A kernel is always taylored to run on a specific board. + Find out what board you have and choose one of the + available ones. config MACH_ONEARM bool "Ajeco 1ARM Single Board Computer" @@ -137,23 +143,8 @@ config MACH_YL9200 help Select this if you are using the ucDragon YL-9200 board. -endif - # ---------------------------------------------------------- -if ARCH_AT91SAM9260 - -comment "AT91SAM9260 Variants" - -config ARCH_AT91SAM9260_SAM9XE - bool "AT91SAM9XE" - depends on ARCH_AT91SAM9260 - help - Select this if you are using Atmel's AT91SAM9XE System-on-Chip. - They are basically AT91SAM9260s with various sizes of embedded Flash. - -comment "AT91SAM9260 / AT91SAM9XE Board Type" - config MACH_AT91SAM9260EK bool "Atmel AT91SAM9260-EK / AT91SAM9XE Evaluation Kit" depends on ARCH_AT91SAM9260 @@ -185,18 +176,13 @@ config MACH_USB_A9260 config MACH_QIL_A9260 bool "CALAO QIL-A9260 board" depends on ARCH_AT91SAM9260 + select AT91_EARLY_USART0 help Select this if you are using a Calao Systems QIL-A9260 Board. -endif - # ---------------------------------------------------------- -if ARCH_AT91SAM9261 - -comment "AT91SAM9261 Board Type" - config MACH_AT91SAM9261EK bool "Atmel AT91SAM9261-EK Evaluation Kit" depends on ARCH_AT91SAM9261 @@ -204,14 +190,8 @@ config MACH_AT91SAM9261EK Select this if you are using Atmel's AT91SAM9261-EK Evaluation Kit. -endif - # ---------------------------------------------------------- -if ARCH_AT91SAM9263 - -comment "AT91SAM9263 Board Type" - config MACH_AT91SAM9263EK bool "Atmel AT91SAM9263-EK Evaluation Kit" depends on ARCH_AT91SAM9263 @@ -226,42 +206,25 @@ config MACH_USB_A9263 Select this if you are using a Calao Systems USB-A9263. -endif # ---------------------------------------------------------- -if ARCH_AT91SAM9RL - -comment "AT91SAM9RL Board Type" - config MACH_AT91SAM9RLEK bool "Atmel AT91SAM9RL-EK Evaluation Kit" depends on ARCH_AT91SAM9RL help Select this if you are using Atmel's AT91SAM9RL-EK Evaluation Kit. -endif - # ---------------------------------------------------------- -if ARCH_AT91SAM9G20 - -comment "AT91SAM9G20 Board Type" - config MACH_AT91SAM9G20EK bool "Atmel AT91SAM9G20-EK Evaluation Kit" depends on ARCH_AT91SAM9G20 help Select this if you are using Atmel's AT91SAM9G20-EK Evaluation Kit. -endif - # ---------------------------------------------------------- -if ARCH_AT91CAP9 - -comment "AT91CAP9 Board Type" - config MACH_AT91CAP9ADK bool "Atmel AT91CAP9A-DK Evaluation Kit" depends on ARCH_AT91CAP9 @@ -269,23 +232,18 @@ config MACH_AT91CAP9ADK Select this if you are using Atmel's AT91CAP9A-DK Evaluation Kit. -endif - # ---------------------------------------------------------- -if ARCH_AT91X40 - -comment "AT91X40 Board Type" - config MACH_AT91EB01 bool "Atmel AT91EB01 Evaluation Kit" + depends on ARCH_AT91X40 help Select this if you are using Atmel's AT91EB01 Evaluation Kit. It is also a popular target for simulators such as GDB's ARM simulator (commonly known as the ARMulator) and the Skyeye simulator. -endif +endchoice # ---------------------------------------------------------- @@ -330,8 +288,107 @@ config AT91_TIMER_HZ system clock (of at least several MHz), rounding is less of a problem so it can be safer to use a decimal values like 100. +config AT91_SETUP_USART + depends on SERIAL_ATMEL + bool "UART setup" + default y + help + All AT91 boards are set up with a pre-defined configuration for + their serial ports. It might be, that a development board has + a number of serial ports enabled by default, but more serial + ports may be actually available. This can be circumvented, by + enabling this option and customising the serial setup of a board. + + If you are building add-on boards for a AT91 based development + board, and you need a special serial port mapping, you should + modify the custom USART settings below. + + NOTE: There is no built-in check that avoids you assigning more + than one USART to a singel device, so use with care. + +# .--------------------------------------------------------------------------. +# |AT91 Serial Port Configuration Summary |.|.| USARTn - /dev/ttySn binding | +# |--------------------------------------------------------------------------| +# |ARCH_AT91RM9200: |C|D| 0 | 1 | 2 | 3 | 4 | 5 | +# |--------------------------------------------------------------------------| +# |MACH_ONEARM board-1arm.c |D|4| 0c| 1c*| | | | | +# |ARCH_AT91RM9200DK board-dk.c |D|0| | 1c*| | | | | +# |MACH_AT91RM9200EK board-ek.c |D|0| | 1c*| | | | | +# |MACH_CSB337 board-csb337.c |D|0| | | | | | | +# |MACH_CSB637 board-csb637.c |D|0| | | | | | | +# |MACH_CARMEVA board-carmeva.c |D|0| | | | | | | +# |MACH_ATEB9200 board-eb9200.c |D|0| 1| | | | | | +# |MACH_KB9200 board-kb9202.c |D|0| 1| 2| | 3c| | | +# |MACH_KAFA board-kafa.c |D|4| 0| | | | | | +# |MACH_PICOTUX2XX board-picotux200.c |D|4| | 1c*| | | | | +# |MACH_ECBAT91 board-ecbat91.c |D|0| 1| | | | | | +# |MACH_YL9200 board-yl-9200.c |D|0| 2| 1c*| | 3c.| | | +# |--------------------------------------------------------------------------| +# |ARCH_AT91SAM9260: |C|D| 0 | 1 | 2 | 3 | 4 | 5 | +# |--------------------------------------------------------------------------| +# |MACH_AT91SAM9260EK board-sam9260ek.c |D|0| 1c*| 2c| | | | | +# |MACH_CAM60 board-cam60.c |D|0| | | | | | | +# |MACH_SAM9_L9260 board-sam9-l9260.c |D|0| 1c*| 2c| | | | | +# |MACH_USB_A9260 board-usb-a9260.c |D|0| | | | | | | +# |MACH_QIL_A9260 board-qil-a9260.c |0|0| 1c*| 2c| 3c| | | | +# |--------------------------------------------------------------------------| +# |ARCH_AT91SAM9261: |C|D| 0 | 1 | 2 | 3 | 4 | 5 | +# |--------------------------------------------------------------------------| +# |MACH_AT91SAM9261EK board-sam9261ek.c |D|0| | | | | | | +# |--------------------------------------------------------------------------| +# |ARCH_AT91SAM9263: |C|D| 0 | 1 | 2 | 3 | 4 | 5 | +# |--------------------------------------------------------------------------| +# |MACH_AT91SAM9263EK board-sam9263ek.c |D|0| 1c| | | | | | +# |MACH_USB_A9263 board-usb-a9263.c |D|0| | | | | | | +# |--------------------------------------------------------------------------| +# |ARCH_AT91SAM9RL: |C|D| 0 | 1 | 2 | 3 | 4 | 5 | +# |--------------------------------------------------------------------------| +# |MACH_AT91SAM9RLEK board-sam9rlek.c |D|0| 1c| | | | | | +# |--------------------------------------------------------------------------| +# |ARCH_AT91SAM9G20: |C|D| 0 | 1 | 2 | 3 | 4 | 5 | +# |--------------------------------------------------------------------------| +# |MACH_AT91SAM9G20EK board-sam9g20ek.c |D|0| 1c*| 2c| | | | | +# |--------------------------------------------------------------------------| +# |ARCH_AT91CAP9: |C|D| 0 | 1 | 2 | 3 | 4 | 5 | +# |--------------------------------------------------------------------------| +# |MACH_AT91CAP9ADK board-cap9adk.c |D|0| | | | | | | +# |--------------------------------------------------------------------------| +# |ARCH_AT91X40: |C|D| 0 | 1 | 2 | 3 | 4 | 5 | +# |--------------------------------------------------------------------------| +# |MACH_AT91EB01 board-eb01.c |-|-| | | | | | | +# '--------------------------------------------------------------------------' +# +# Table Legend: +# ------------ +# C: console +# D: DBGU +# 0: USART0 +# 1: USART1 +# 2: USART2 +# 3: USART3 +# 4: USART4 +# 5: USART5 +# +# c : control lines (CTS and RTS) +# c* : control lines (CTS, RTS, DTR, DSR, DCD, RI) +# c. : control lines (RTS) +# +# Example: The MACH_YL9200 implementation can be found in board-yl-9200.c. +# Its console is on the serial debug port and on /dev/ttyS0. USART0 is mapped +# to /dev/ttyS2. USART1 is mapped to /dev/ttyS1 and it has CTS, RTS, DTR, +# DSR, DCD, RI enabled. USART2 is not set up. USART3 is mapped to /dev/ttyS3 +# and it has the RTS control line enabled. + +config AT91_MAX_UART + int + default "2" if ARCH_AT91X40 + default "4" if ARCH_AT91CAP9 || ARCH_AT91SAM9261 || ARCH_AT91SAM9263 + default "5" if ARCH_AT91RM9200 || ARCH_AT91SAM9RL + default "7" + choice prompt "Select a UART for early kernel messages" + depends on AT91_SETUP_USART config AT91_EARLY_DBGU bool "DBGU" @@ -348,7 +405,7 @@ config AT91_EARLY_USART2 config AT91_EARLY_USART3 bool "USART3" - depends on (ARCH_AT91RM9200 || ARCH_AT91SAM9RL || ARCH_AT91SAM9260 || ARCH_AT91SAM9G20) + depends on ARCH_AT91RM9200 || ARCH_AT91SAM9RL || ARCH_AT91SAM9260 || ARCH_AT91SAM9G20 config AT91_EARLY_USART4 bool "USART4" @@ -360,6 +417,284 @@ config AT91_EARLY_USART5 endchoice -endmenu +menuconfig AT91_SETUP_DBGU + depends on AT91_SETUP_USART + bool "DBGU" + default y if !ARCH_AT91X40 + +config AT91_DBGU_DEV_NR + depends on AT91_SETUP_DBGU + int "device number /dev/tty*(0-6)" + range 0 6 + default "4" if MACH_ONEARM + default "4" if MACH_KAFA + default "4" if MACH_PICOTUX2XX + default "0" + +menuconfig AT91_SETUP_USART0 + depends on AT91_SETUP_USART + bool "USART0" + default y if MACH_ONEARM + default y if MACH_ATEB9200 + default y if MACH_KB9200 + default y if MACH_KAFA + default y if MACH_ECBAT91 + default y if MACH_YL9200 + default y if MACH_AT91SAM9260EK + default y if MACH_SAM9_L9260 + default y if MACH_QIL_A9260 + default y if MACH_AT91SAM9263EK + default y if MACH_AT91SAM9RLEK + default y if MACH_AT91SAM9G20EK + +config AT91_USART0_DEV_NR + depends on AT91_SETUP_USART0 + int "device number /dev/tty*(0-6)" + range 0 6 + default "0" if MACH_ONEARM + default "0" if MACH_KAFA + default "2" if MACH_YL9200 + default "1" + +menuconfig AT91_USART0_MODEM_CONTROLS + depends on AT91_SETUP_USART0 && !ARCH_AT91X40 + bool "Hardware Control Lines" + default y if MACH_ONEARM + default y if MACH_AT91SAM9260EK + default y if MACH_SAM9_L9260 + default y if MACH_QIL_A9260 + default y if MACH_AT91SAM9263EK + default y if MACH_AT91SAM9RLEK + default y if MACH_AT91SAM9G20EK + +config AT91_USART0_UART_CTS + depends on AT91_USART0_MODEM_CONTROLS + bool "CTS" + default y + help + Enable the CTS control line. + +config AT91_USART0_UART_RTS + depends on AT91_USART0_MODEM_CONTROLS + bool "RTS" + default y + help + Enable the RTS control line. + +config AT91_USART0_UART_DTR + depends on AT91_USART0_MODEM_CONTROLS && !ARCH_AT91CAP9 && !ARCH_AT91RM9200 && !ARCH_AT91SAM9261 + bool "DTR" + default y if MACH_AT91SAM9260EK + default y if MACH_SAM9_L9260 + default y if MACH_QIL_A9260 + default y if MACH_AT91SAM9G20EK + help + Enable the DTR control line. + +config AT91_USART0_UART_DSR + depends on AT91_USART0_MODEM_CONTROLS && !ARCH_AT91CAP9 && !ARCH_AT91RM9200 && !ARCH_AT91SAM9261 + bool "DSR" + default y if MACH_AT91SAM9260EK + default y if MACH_SAM9_L9260 + default y if MACH_QIL_A9260 + default y if MACH_AT91SAM9G20EK + help + Enable the DSR control line. + +config AT91_USART0_UART_DCD + depends on AT91_USART0_MODEM_CONTROLS && !ARCH_AT91CAP9 && !ARCH_AT91RM9200 && !ARCH_AT91SAM9261 + bool "DCD" + default y if MACH_AT91SAM9260EK + default y if MACH_SAM9_L9260 + default y if MACH_QIL_A9260 + default y if MACH_AT91SAM9G20EK + help + Enable the DCD control line. + +config AT91_USART0_UART_RI + depends on AT91_USART0_MODEM_CONTROLS && !ARCH_AT91CAP9 && !ARCH_AT91RM9200 && !ARCH_AT91SAM9261 + bool "RI" + default y if MACH_AT91SAM9260EK + default y if MACH_SAM9_L9260 + default y if MACH_QIL_A9260 + default y if MACH_AT91SAM9G20EK + help + Enable the RI control line. + +menuconfig AT91_SETUP_USART1 + depends on AT91_SETUP_USART + bool "USART1" + default y if MACH_ONEARM + default y if ARCH_AT91RM9200DK + default y if MACH_AT91RM9200EK + default y if MACH_KB9200 + default y if MACH_PICOTUX2XX + default y if MACH_YL9200 + default y if MACH_AT91SAM9260EK + default y if MACH_SAM9_L9260 + default y if MACH_QIL_A9260 + default y if MACH_AT91SAM9G20EK + +config AT91_USART1_DEV_NR + depends on AT91_SETUP_USART1 + int "device number /dev/tty*(0-6)" + range 0 6 + default "1" if MACH_ONEARM + default "1" if ARCH_AT91RM9200DK + default "1" if MACH_AT91RM9200EK + default "1" if MACH_PICOTUX2XX + default "1" if MACH_YL9200 + default "2" + +menuconfig AT91_USART1_MODEM_CONTROLS + depends on AT91_SETUP_USART1 && !ARCH_AT91X40 + bool "Hardware Control Lines" + default y if MACH_ONEARM + default y if ARCH_AT91RM9200DK + default y if MACH_AT91RM9200EK + default y if MACH_PICOTUX2XX + default y if MACH_YL9200 + default y if MACH_AT91SAM9260EK + default y if MACH_SAM9_L9260 + default y if MACH_QIL_A9260 + default y if MACH_AT91SAM9G20EK + +config AT91_USART1_UART_CTS + depends on AT91_USART1_MODEM_CONTROLS + bool "CTS" + default y + help + Enable the CTS control line. + +config AT91_USART1_UART_RTS + depends on AT91_USART1_MODEM_CONTROLS + bool "RTS" + default y + help + Enable the RTS control line. + +config AT91_USART1_UART_DTR + depends on AT91_USART1_MODEM_CONTROLS && \ + (MACH_ONEARM || ARCH_AT91RM9200DK || \ + MACH_AT91RM9200EK || MACH_PICOTUX2XX || MACH_YL9200) + bool "DTR" + default y + help + Enable the DTR control line. + +config AT91_USART1_UART_DSR + depends on AT91_USART1_MODEM_CONTROLS && \ + (MACH_ONEARM || ARCH_AT91RM9200DK || \ + MACH_AT91RM9200EK || MACH_PICOTUX2XX || MACH_YL9200) + bool "DSR" + default y + help + Enable the DSR control line. + +config AT91_USART1_UART_DCD + depends on AT91_USART1_MODEM_CONTROLS && \ + (MACH_ONEARM || ARCH_AT91RM9200DK || \ + MACH_AT91RM9200EK || MACH_PICOTUX2XX || MACH_YL9200) + bool "DCD" + default y + help + Enable the DCD control line. + +config AT91_USART1_UART_RI + depends on AT91_USART1_MODEM_CONTROLS && \ + (MACH_ONEARM || ARCH_AT91RM9200DK || \ + MACH_AT91RM9200EK || MACH_PICOTUX2XX || MACH_YL9200) + bool "RI" + default y + help + Enable the RI control line. -endif +menuconfig AT91_SETUP_USART2 + depends on AT91_SETUP_USART && !ARCH_AT91X40 + bool "USART2" + default y if MACH_QIL_A9260 + +config AT91_USART2_DEV_NR + depends on AT91_SETUP_USART2 + int "device number /dev/tty*(0-6)" + range 0 6 + default "3" + +menuconfig AT91_USART2_MODEM_CONTROLS + depends on AT91_SETUP_USART2 && !ARCH_AT91X40 + bool "Hardware Control Lines" + default y if MACH_QIL_A9260 + +config AT91_USART2_UART_CTS + depends on AT91_USART2_MODEM_CONTROLS + bool "CTS" + default y + help + Enable the CTS control line. + +config AT91_USART2_UART_RTS + depends on AT91_USART2_MODEM_CONTROLS + bool "RTS" + default y + help + Enable the RTS control line. + +menuconfig AT91_SETUP_USART3 + depends on AT91_SETUP_USART && \ + (ARCH_AT91RM9200 || ARCH_AT91SAM9RL || \ + ARCH_AT91SAM9260 || ARCH_AT91SAM9G20) + bool "USART3" + default y if MACH_KB9200 + default y if MACH_YL9200 + +config AT91_USART3_DEV_NR + depends on AT91_SETUP_USART3 + int "device number /dev/tty*(0-6)" + range 0 6 + default "3" if MACH_KB9200 + default "3" if MACH_YL9200 + default "4" + +menuconfig AT91_USART3_MODEM_CONTROLS + depends on AT91_SETUP_USART3 + bool "Hardware Control Lines" + default y if MACH_KB9200 + default y if MACH_YL9200 + +config AT91_USART3_UART_CTS + depends on AT91_USART3_MODEM_CONTROLS + bool "CTS" + default y if MACH_KB9200 + help + Enable the CTS control line. + +config AT91_USART3_UART_RTS + depends on AT91_USART3_MODEM_CONTROLS + bool "RTS" + default y + help + Enable the RTS control line. + +menuconfig AT91_SETUP_USART4 + depends on AT91_SETUP_USART && (ARCH_AT91SAM9260 || ARCH_AT91SAM9G20) + bool "USART4" + default n + +config AT91_USART4_DEV_NR + depends on AT91_SETUP_USART4 + int "device number /dev/tty*(0-6)" + range 0 6 + default "5" + +menuconfig AT91_SETUP_USART5 + depends on AT91_SETUP_USART && (ARCH_AT91SAM9260 || ARCH_AT91SAM9G20) + bool "USART5" + default n + +config AT91_USART5_DEV_NR + depends on AT91_SETUP_USART5 + int "device number /dev/tty*(0-6)" + range 0 6 + default "6" + +endmenu diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile index 7d641f97516..d988c653426 100644 --- a/arch/arm/mach-at91/Makefile +++ b/arch/arm/mach-at91/Makefile @@ -19,6 +19,9 @@ obj-$(CONFIG_ARCH_AT91SAM9G20) += at91sam9260.o at91sam926x_time.o at91sam9260_d obj-$(CONFIG_ARCH_AT91CAP9) += at91cap9.o at91sam926x_time.o at91cap9_devices.o obj-$(CONFIG_ARCH_AT91X40) += at91x40.o at91x40_time.o +# UARTS +obj-$(CONFIG_SERIAL_ATMEL) += uart.o + # AT91RM9200 board-specific support obj-$(CONFIG_MACH_ONEARM) += board-1arm.o obj-$(CONFIG_ARCH_AT91RM9200DK) += board-dk.o diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c index abb4aac8fa9..14582f8fe77 100644 --- a/arch/arm/mach-at91/at91cap9_devices.c +++ b/arch/arm/mach-at91/at91cap9_devices.c @@ -971,238 +971,69 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {} /* -------------------------------------------------------------------- * UART * -------------------------------------------------------------------- */ - #if defined(CONFIG_SERIAL_ATMEL) -static struct resource dbgu_resources[] = { - [0] = { - .start = AT91_VA_BASE_SYS + AT91_DBGU, - .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91_ID_SYS, - .end = AT91_ID_SYS, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data dbgu_data = { - .use_dma_tx = 0, - .use_dma_rx = 0, /* DBGU not capable of receive DMA */ - .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), -}; - -static u64 dbgu_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91cap9_dbgu_device = { - .name = "atmel_usart", - .id = 0, - .dev = { - .dma_mask = &dbgu_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &dbgu_data, - }, - .resource = dbgu_resources, - .num_resources = ARRAY_SIZE(dbgu_resources), -}; - -static inline void configure_dbgu_pins(void) -{ - at91_set_A_periph(AT91_PIN_PC30, 0); /* DRXD */ - at91_set_A_periph(AT91_PIN_PC31, 1); /* DTXD */ -} - -static struct resource uart0_resources[] = { - [0] = { - .start = AT91CAP9_BASE_US0, - .end = AT91CAP9_BASE_US0 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91CAP9_ID_US0, - .end = AT91CAP9_ID_US0, - .flags = IORESOURCE_IRQ, - }, -}; -static struct atmel_uart_data uart0_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, +const resource_size_t __initdata usart_base_addr[ATMEL_MAX_UART] = { + AT91_VA_BASE_SYS + AT91_DBGU, + AT91CAP9_BASE_US0, + AT91CAP9_BASE_US1, + AT91CAP9_BASE_US2 }; -static u64 uart0_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91cap9_uart0_device = { - .name = "atmel_usart", - .id = 1, - .dev = { - .dma_mask = &uart0_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart0_data, - }, - .resource = uart0_resources, - .num_resources = ARRAY_SIZE(uart0_resources), +const resource_size_t __initdata usart_id_addr[ATMEL_MAX_UART] = { + AT91_ID_SYS, + AT91CAP9_ID_US0, + AT91CAP9_ID_US1, + AT91CAP9_ID_US2 }; -static inline void configure_usart0_pins(unsigned pins) +void __init configure_dbgu_pins(void) { - at91_set_A_periph(AT91_PIN_PA22, 1); /* TXD0 */ - at91_set_A_periph(AT91_PIN_PA23, 0); /* RXD0 */ - - if (pins & ATMEL_UART_RTS) - at91_set_A_periph(AT91_PIN_PA24, 0); /* RTS0 */ - if (pins & ATMEL_UART_CTS) - at91_set_A_periph(AT91_PIN_PA25, 0); /* CTS0 */ + at91_set_A_periph(AT91_PIN_PC30, 0); /* DRXD */ + at91_set_A_periph(AT91_PIN_PC31, 1); /* DTXD */ } -static struct resource uart1_resources[] = { - [0] = { - .start = AT91CAP9_BASE_US1, - .end = AT91CAP9_BASE_US1 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91CAP9_ID_US1, - .end = AT91CAP9_ID_US1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart1_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart1_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91cap9_uart1_device = { - .name = "atmel_usart", - .id = 2, - .dev = { - .dma_mask = &uart1_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart1_data, - }, - .resource = uart1_resources, - .num_resources = ARRAY_SIZE(uart1_resources), -}; - -static inline void configure_usart1_pins(unsigned pins) +void __init configure_usart0_pins(void) { - at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */ - at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */ + at91_set_A_periph(AT91_PIN_PA22, 1); /* TXD0 */ + at91_set_A_periph(AT91_PIN_PA23, 0); /* RXD0 */ - if (pins & ATMEL_UART_RTS) - at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */ - if (pins & ATMEL_UART_CTS) - at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */ +#if defined(CONFIG_AT91_USART0_UART_RTS) + at91_set_A_periph(AT91_PIN_PA24, 0); /* RTS0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_CTS) + at91_set_A_periph(AT91_PIN_PA25, 0); /* CTS0 */ +#endif } -static struct resource uart2_resources[] = { - [0] = { - .start = AT91CAP9_BASE_US2, - .end = AT91CAP9_BASE_US2 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91CAP9_ID_US2, - .end = AT91CAP9_ID_US2, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart2_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart2_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91cap9_uart2_device = { - .name = "atmel_usart", - .id = 3, - .dev = { - .dma_mask = &uart2_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart2_data, - }, - .resource = uart2_resources, - .num_resources = ARRAY_SIZE(uart2_resources), -}; - -static inline void configure_usart2_pins(unsigned pins) +void __init configure_usart1_pins(void) { - at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */ - at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */ + at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */ + at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */ - if (pins & ATMEL_UART_RTS) - at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */ - if (pins & ATMEL_UART_CTS) - at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */ +#if defined(CONFIG_AT91_USART1_UART_RTS) + at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */ +#endif +#if defined(CONFIG_AT91_USART1_UART_CTS) + at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */ +#endif } -static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ -struct platform_device *atmel_default_console_device; /* the serial console device */ - -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) +void __init configure_usart2_pins(void) { - struct platform_device *pdev; - - switch (id) { - case 0: /* DBGU */ - pdev = &at91cap9_dbgu_device; - configure_dbgu_pins(); - at91_clock_associate("mck", &pdev->dev, "usart"); - break; - case AT91CAP9_ID_US0: - pdev = &at91cap9_uart0_device; - configure_usart0_pins(pins); - at91_clock_associate("usart0_clk", &pdev->dev, "usart"); - break; - case AT91CAP9_ID_US1: - pdev = &at91cap9_uart1_device; - configure_usart1_pins(pins); - at91_clock_associate("usart1_clk", &pdev->dev, "usart"); - break; - case AT91CAP9_ID_US2: - pdev = &at91cap9_uart2_device; - configure_usart2_pins(pins); - at91_clock_associate("usart2_clk", &pdev->dev, "usart"); - break; - default: - return; - } - pdev->id = portnr; /* update to mapped ID */ - - if (portnr < ATMEL_MAX_UART) - at91_uarts[portnr] = pdev; -} + at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */ + at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */ -void __init at91_set_serial_console(unsigned portnr) -{ - if (portnr < ATMEL_MAX_UART) - atmel_default_console_device = at91_uarts[portnr]; +#if defined(CONFIG_AT91_USART2_UART_RTS) + at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */ +#endif +#if defined(CONFIG_AT91_USART2_UART_CTS) + at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */ +#endif } -void __init at91_add_device_serial(void) -{ - int i; - - for (i = 0; i < ATMEL_MAX_UART; i++) { - if (at91_uarts[i]) - platform_device_register(at91_uarts[i]); - } - - if (!atmel_default_console_device) - printk(KERN_INFO "AT91: No default serial console defined.\n"); -} -#else -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {} -void __init at91_add_device_serial(void) {} #endif - /* -------------------------------------------------------------------- */ /* * These devices are always present and don't need any board-specific diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c index 9338825cfcd..6a64eff83fd 100644 --- a/arch/arm/mach-at91/at91rm9200_devices.c +++ b/arch/arm/mach-at91/at91rm9200_devices.c @@ -876,346 +876,101 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {} /* -------------------------------------------------------------------- * UART * -------------------------------------------------------------------- */ - #if defined(CONFIG_SERIAL_ATMEL) -static struct resource dbgu_resources[] = { - [0] = { - .start = AT91_VA_BASE_SYS + AT91_DBGU, - .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91_ID_SYS, - .end = AT91_ID_SYS, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data dbgu_data = { - .use_dma_tx = 0, - .use_dma_rx = 0, /* DBGU not capable of receive DMA */ - .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), -}; - -static u64 dbgu_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91rm9200_dbgu_device = { - .name = "atmel_usart", - .id = 0, - .dev = { - .dma_mask = &dbgu_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &dbgu_data, - }, - .resource = dbgu_resources, - .num_resources = ARRAY_SIZE(dbgu_resources), -}; - -static inline void configure_dbgu_pins(void) -{ - at91_set_A_periph(AT91_PIN_PA30, 0); /* DRXD */ - at91_set_A_periph(AT91_PIN_PA31, 1); /* DTXD */ -} -static struct resource uart0_resources[] = { - [0] = { - .start = AT91RM9200_BASE_US0, - .end = AT91RM9200_BASE_US0 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91RM9200_ID_US0, - .end = AT91RM9200_ID_US0, - .flags = IORESOURCE_IRQ, - }, +const resource_size_t __initdata usart_base_addr[ATMEL_MAX_UART] = { + AT91_VA_BASE_SYS + AT91_DBGU, + AT91RM9200_BASE_US0, + AT91RM9200_BASE_US1, + AT91RM9200_BASE_US2, + AT91RM9200_BASE_US3 }; -static struct atmel_uart_data uart0_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart0_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91rm9200_uart0_device = { - .name = "atmel_usart", - .id = 1, - .dev = { - .dma_mask = &uart0_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart0_data, - }, - .resource = uart0_resources, - .num_resources = ARRAY_SIZE(uart0_resources), +const resource_size_t __initdata usart_id_addr[ATMEL_MAX_UART] = { + AT91_ID_SYS, + AT91RM9200_ID_US0, + AT91RM9200_ID_US1, + AT91RM9200_ID_US2, + AT91RM9200_ID_US3 }; -static inline void configure_usart0_pins(unsigned pins) +void __init configure_dbgu_pins(void) { - at91_set_A_periph(AT91_PIN_PA17, 1); /* TXD0 */ - at91_set_A_periph(AT91_PIN_PA18, 0); /* RXD0 */ - - if (pins & ATMEL_UART_CTS) - at91_set_A_periph(AT91_PIN_PA20, 0); /* CTS0 */ - - if (pins & ATMEL_UART_RTS) { - /* - * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21. - * We need to drive the pin manually. Default is off (RTS is active low). - */ - at91_set_gpio_output(AT91_PIN_PA21, 1); - } + at91_set_A_periph(AT91_PIN_PA30, 0); /* DRXD */ + at91_set_A_periph(AT91_PIN_PA31, 1); /* DTXD */ } -static struct resource uart1_resources[] = { - [0] = { - .start = AT91RM9200_BASE_US1, - .end = AT91RM9200_BASE_US1 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91RM9200_ID_US1, - .end = AT91RM9200_ID_US1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart1_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart1_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91rm9200_uart1_device = { - .name = "atmel_usart", - .id = 2, - .dev = { - .dma_mask = &uart1_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart1_data, - }, - .resource = uart1_resources, - .num_resources = ARRAY_SIZE(uart1_resources), -}; - -static inline void configure_usart1_pins(unsigned pins) +void __init configure_usart0_pins(void) { - at91_set_A_periph(AT91_PIN_PB20, 1); /* TXD1 */ - at91_set_A_periph(AT91_PIN_PB21, 0); /* RXD1 */ - - if (pins & ATMEL_UART_RI) - at91_set_A_periph(AT91_PIN_PB18, 0); /* RI1 */ - if (pins & ATMEL_UART_DTR) - at91_set_A_periph(AT91_PIN_PB19, 0); /* DTR1 */ - if (pins & ATMEL_UART_DCD) - at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD1 */ - if (pins & ATMEL_UART_CTS) - at91_set_A_periph(AT91_PIN_PB24, 0); /* CTS1 */ - if (pins & ATMEL_UART_DSR) - at91_set_A_periph(AT91_PIN_PB25, 0); /* DSR1 */ - if (pins & ATMEL_UART_RTS) - at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS1 */ -} + at91_set_A_periph(AT91_PIN_PA17, 1); /* TXD0 */ + at91_set_A_periph(AT91_PIN_PA18, 0); /* RXD0 */ -static struct resource uart2_resources[] = { - [0] = { - .start = AT91RM9200_BASE_US2, - .end = AT91RM9200_BASE_US2 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91RM9200_ID_US2, - .end = AT91RM9200_ID_US2, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart2_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart2_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91rm9200_uart2_device = { - .name = "atmel_usart", - .id = 3, - .dev = { - .dma_mask = &uart2_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart2_data, - }, - .resource = uart2_resources, - .num_resources = ARRAY_SIZE(uart2_resources), -}; - -static inline void configure_usart2_pins(unsigned pins) -{ - at91_set_A_periph(AT91_PIN_PA22, 0); /* RXD2 */ - at91_set_A_periph(AT91_PIN_PA23, 1); /* TXD2 */ - - if (pins & ATMEL_UART_CTS) - at91_set_B_periph(AT91_PIN_PA30, 0); /* CTS2 */ - if (pins & ATMEL_UART_RTS) - at91_set_B_periph(AT91_PIN_PA31, 0); /* RTS2 */ +#if defined(CONFIG_AT91_USART0_UART_CTS) + at91_set_A_periph(AT91_PIN_PA20, 0); /* CTS0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_RTS) + /* + * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21. + * We need to drive the pin manually. + * Default is off (RTS is active low). + */ + at91_set_gpio_output(AT91_PIN_PA21, 1); +#endif } -static struct resource uart3_resources[] = { - [0] = { - .start = AT91RM9200_BASE_US3, - .end = AT91RM9200_BASE_US3 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91RM9200_ID_US3, - .end = AT91RM9200_ID_US3, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart3_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart3_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91rm9200_uart3_device = { - .name = "atmel_usart", - .id = 4, - .dev = { - .dma_mask = &uart3_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart3_data, - }, - .resource = uart3_resources, - .num_resources = ARRAY_SIZE(uart3_resources), -}; - -static inline void configure_usart3_pins(unsigned pins) +void __init configure_usart1_pins(void) { - at91_set_B_periph(AT91_PIN_PA5, 1); /* TXD3 */ - at91_set_B_periph(AT91_PIN_PA6, 0); /* RXD3 */ + at91_set_A_periph(AT91_PIN_PB20, 1); /* TXD1 */ + at91_set_A_periph(AT91_PIN_PB21, 0); /* RXD1 */ - if (pins & ATMEL_UART_CTS) - at91_set_B_periph(AT91_PIN_PB1, 0); /* CTS3 */ - if (pins & ATMEL_UART_RTS) - at91_set_B_periph(AT91_PIN_PB0, 0); /* RTS3 */ +#if defined(CONFIG_AT91_USART1_UART_RI) + at91_set_A_periph(AT91_PIN_PB18, 0); /* RI1 */ +#endif +#if defined(CONFIG_AT91_USART1_UART_DTR) + at91_set_A_periph(AT91_PIN_PB19, 0); /* DTR1 */ +#endif +#if defined(CONFIG_AT91_USART1_UART_DCD) + at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD1 */ +#endif +#if defined(CONFIG_AT91_USART1_UART_CTS) + at91_set_A_periph(AT91_PIN_PB24, 0); /* CTS1 */ +#endif +#if defined(CONFIG_AT91_USART1_UART_DSR) + at91_set_A_periph(AT91_PIN_PB25, 0); /* DSR1 */ +#endif +#if defined(CONFIG_AT91_USART1_UART_RTS) + at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS1 */ +#endif } -static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ -struct platform_device *atmel_default_console_device; /* the serial console device */ - -void __init __deprecated at91_init_serial(struct at91_uart_config *config) +void __init configure_usart2_pins(void) { - int i; + at91_set_A_periph(AT91_PIN_PA22, 0); /* RXD2 */ + at91_set_A_periph(AT91_PIN_PA23, 1); /* TXD2 */ - /* Fill in list of supported UARTs */ - for (i = 0; i < config->nr_tty; i++) { - switch (config->tty_map[i]) { - case 0: - configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS); - at91_uarts[i] = &at91rm9200_uart0_device; - at91_clock_associate("usart0_clk", &at91rm9200_uart0_device.dev, "usart"); - break; - case 1: - configure_usart1_pins(ATMEL_UART_CTS | ATMEL_UART_RTS | ATMEL_UART_DSR | ATMEL_UART_DTR | ATMEL_UART_DCD | ATMEL_UART_RI); - at91_uarts[i] = &at91rm9200_uart1_device; - at91_clock_associate("usart1_clk", &at91rm9200_uart1_device.dev, "usart"); - break; - case 2: - configure_usart2_pins(0); - at91_uarts[i] = &at91rm9200_uart2_device; - at91_clock_associate("usart2_clk", &at91rm9200_uart2_device.dev, "usart"); - break; - case 3: - configure_usart3_pins(0); - at91_uarts[i] = &at91rm9200_uart3_device; - at91_clock_associate("usart3_clk", &at91rm9200_uart3_device.dev, "usart"); - break; - case 4: - configure_dbgu_pins(); - at91_uarts[i] = &at91rm9200_dbgu_device; - at91_clock_associate("mck", &at91rm9200_dbgu_device.dev, "usart"); - break; - default: - continue; - } - at91_uarts[i]->id = i; /* update ID number to mapped ID */ - } - - /* Set serial console device */ - if (config->console_tty < ATMEL_MAX_UART) - atmel_default_console_device = at91_uarts[config->console_tty]; - if (!atmel_default_console_device) - printk(KERN_INFO "AT91: No default serial console defined.\n"); +#if defined(CONFIG_AT91_USART2_UART_CTS) + at91_set_B_periph(AT91_PIN_PA30, 0); /* CTS2 */ +#endif +#if defined(CONFIG_AT91_USART2_UART_RTS) + at91_set_B_periph(AT91_PIN_PA31, 0); /* RTS2 */ +#endif } -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) +void __init configure_usart3_pins(void) { - struct platform_device *pdev; + at91_set_B_periph(AT91_PIN_PA5, 1); /* TXD3 */ + at91_set_B_periph(AT91_PIN_PA6, 0); /* RXD3 */ - switch (id) { - case 0: /* DBGU */ - pdev = &at91rm9200_dbgu_device; - configure_dbgu_pins(); - at91_clock_associate("mck", &pdev->dev, "usart"); - break; - case AT91RM9200_ID_US0: - pdev = &at91rm9200_uart0_device; - configure_usart0_pins(pins); - at91_clock_associate("usart0_clk", &pdev->dev, "usart"); - break; - case AT91RM9200_ID_US1: - pdev = &at91rm9200_uart1_device; - configure_usart1_pins(pins); - at91_clock_associate("usart1_clk", &pdev->dev, "usart"); - break; - case AT91RM9200_ID_US2: - pdev = &at91rm9200_uart2_device; - configure_usart2_pins(pins); - at91_clock_associate("usart2_clk", &pdev->dev, "usart"); - break; - case AT91RM9200_ID_US3: - pdev = &at91rm9200_uart3_device; - configure_usart3_pins(pins); - at91_clock_associate("usart3_clk", &pdev->dev, "usart"); - break; - default: - return; - } - pdev->id = portnr; /* update to mapped ID */ - - if (portnr < ATMEL_MAX_UART) - at91_uarts[portnr] = pdev; -} - -void __init at91_set_serial_console(unsigned portnr) -{ - if (portnr < ATMEL_MAX_UART) - atmel_default_console_device = at91_uarts[portnr]; +#if defined(CONFIG_AT91_USART3_UART_CTS) + at91_set_B_periph(AT91_PIN_PB1, 0); /* CTS3 */ +#endif +#if defined(CONFIG_AT91_USART3_UART_RTS) + at91_set_B_periph(AT91_PIN_PB0, 0); /* RTS3 */ +#endif } -void __init at91_add_device_serial(void) -{ - int i; - - for (i = 0; i < ATMEL_MAX_UART; i++) { - if (at91_uarts[i]) - platform_device_register(at91_uarts[i]); - } - - if (!atmel_default_console_device) - printk(KERN_INFO "AT91: No default serial console defined.\n"); -} -#else -void __init __deprecated at91_init_serial(struct at91_uart_config *config) {} -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {} -void __init at91_add_device_serial(void) {} #endif - /* -------------------------------------------------------------------- */ /* diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c index 7774d17dde7..24789f3363f 100644 --- a/arch/arm/mach-at91/at91sam9260_devices.c +++ b/arch/arm/mach-at91/at91sam9260_devices.c @@ -778,378 +778,111 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {} * UART * -------------------------------------------------------------------- */ #if defined(CONFIG_SERIAL_ATMEL) -static struct resource dbgu_resources[] = { - [0] = { - .start = AT91_VA_BASE_SYS + AT91_DBGU, - .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91_ID_SYS, - .end = AT91_ID_SYS, - .flags = IORESOURCE_IRQ, - }, -}; -static struct atmel_uart_data dbgu_data = { - .use_dma_tx = 0, - .use_dma_rx = 0, /* DBGU not capable of receive DMA */ - .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), +const resource_size_t __initdata usart_base_addr[ATMEL_MAX_UART] = { + AT91_VA_BASE_SYS + AT91_DBGU, + AT91SAM9260_BASE_US0, + AT91SAM9260_BASE_US1, + AT91SAM9260_BASE_US2, + AT91SAM9260_BASE_US3, + AT91SAM9260_BASE_US4, + AT91SAM9260_BASE_US5 }; -static u64 dbgu_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9260_dbgu_device = { - .name = "atmel_usart", - .id = 0, - .dev = { - .dma_mask = &dbgu_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &dbgu_data, - }, - .resource = dbgu_resources, - .num_resources = ARRAY_SIZE(dbgu_resources), +const resource_size_t __initdata usart_id_addr[ATMEL_MAX_UART] = { + AT91_ID_SYS, + AT91SAM9260_ID_US0, + AT91SAM9260_ID_US1, + AT91SAM9260_ID_US2, + AT91SAM9260_ID_US3, + AT91SAM9260_ID_US4, + AT91SAM9260_ID_US5 }; -static inline void configure_dbgu_pins(void) +void __init configure_dbgu_pins(void) { - at91_set_A_periph(AT91_PIN_PB14, 0); /* DRXD */ - at91_set_A_periph(AT91_PIN_PB15, 1); /* DTXD */ + at91_set_A_periph(AT91_PIN_PB14, 0); /* DRXD */ + at91_set_A_periph(AT91_PIN_PB15, 1); /* DTXD */ } -static struct resource uart0_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_US0, - .end = AT91SAM9260_BASE_US0 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9260_ID_US0, - .end = AT91SAM9260_ID_US0, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart0_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart0_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9260_uart0_device = { - .name = "atmel_usart", - .id = 1, - .dev = { - .dma_mask = &uart0_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart0_data, - }, - .resource = uart0_resources, - .num_resources = ARRAY_SIZE(uart0_resources), -}; - -static inline void configure_usart0_pins(unsigned pins) -{ - at91_set_A_periph(AT91_PIN_PB4, 1); /* TXD0 */ - at91_set_A_periph(AT91_PIN_PB5, 0); /* RXD0 */ - - if (pins & ATMEL_UART_RTS) - at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS0 */ - if (pins & ATMEL_UART_CTS) - at91_set_A_periph(AT91_PIN_PB27, 0); /* CTS0 */ - if (pins & ATMEL_UART_DTR) - at91_set_A_periph(AT91_PIN_PB24, 0); /* DTR0 */ - if (pins & ATMEL_UART_DSR) - at91_set_A_periph(AT91_PIN_PB22, 0); /* DSR0 */ - if (pins & ATMEL_UART_DCD) - at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD0 */ - if (pins & ATMEL_UART_RI) - at91_set_A_periph(AT91_PIN_PB25, 0); /* RI0 */ -} - -static struct resource uart1_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_US1, - .end = AT91SAM9260_BASE_US1 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9260_ID_US1, - .end = AT91SAM9260_ID_US1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart1_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart1_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9260_uart1_device = { - .name = "atmel_usart", - .id = 2, - .dev = { - .dma_mask = &uart1_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart1_data, - }, - .resource = uart1_resources, - .num_resources = ARRAY_SIZE(uart1_resources), -}; - -static inline void configure_usart1_pins(unsigned pins) +void __init configure_usart0_pins(void) { - at91_set_A_periph(AT91_PIN_PB6, 1); /* TXD1 */ - at91_set_A_periph(AT91_PIN_PB7, 0); /* RXD1 */ + at91_set_A_periph(AT91_PIN_PB4, 1); /* TXD0 */ + at91_set_A_periph(AT91_PIN_PB5, 0); /* RXD0 */ - if (pins & ATMEL_UART_RTS) - at91_set_A_periph(AT91_PIN_PB28, 0); /* RTS1 */ - if (pins & ATMEL_UART_CTS) - at91_set_A_periph(AT91_PIN_PB29, 0); /* CTS1 */ +#if defined(CONFIG_AT91_USART0_UART_RTS) + at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_CTS) + at91_set_A_periph(AT91_PIN_PB27, 0); /* CTS0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_DTR) + at91_set_A_periph(AT91_PIN_PB24, 0); /* DTR0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_DSR) + at91_set_A_periph(AT91_PIN_PB22, 0); /* DSR0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_DCD) + at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_RI) + at91_set_A_periph(AT91_PIN_PB25, 0); /* RI0 */ +#endif } -static struct resource uart2_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_US2, - .end = AT91SAM9260_BASE_US2 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9260_ID_US2, - .end = AT91SAM9260_ID_US2, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart2_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart2_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9260_uart2_device = { - .name = "atmel_usart", - .id = 3, - .dev = { - .dma_mask = &uart2_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart2_data, - }, - .resource = uart2_resources, - .num_resources = ARRAY_SIZE(uart2_resources), -}; - -static inline void configure_usart2_pins(unsigned pins) +void __init configure_usart1_pins(void) { - at91_set_A_periph(AT91_PIN_PB8, 1); /* TXD2 */ - at91_set_A_periph(AT91_PIN_PB9, 0); /* RXD2 */ + at91_set_A_periph(AT91_PIN_PB6, 1); /* TXD1 */ + at91_set_A_periph(AT91_PIN_PB7, 0); /* RXD1 */ - if (pins & ATMEL_UART_RTS) - at91_set_A_periph(AT91_PIN_PA4, 0); /* RTS2 */ - if (pins & ATMEL_UART_CTS) - at91_set_A_periph(AT91_PIN_PA5, 0); /* CTS2 */ +#if defined(CONFIG_AT91_USART1_UART_RTS) + at91_set_A_periph(AT91_PIN_PB28, 0); /* RTS1 */ +#endif +#if defined(CONFIG_AT91_USART1_UART_CTS) + at91_set_A_periph(AT91_PIN_PB29, 0); /* CTS1 */ +#endif } -static struct resource uart3_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_US3, - .end = AT91SAM9260_BASE_US3 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9260_ID_US3, - .end = AT91SAM9260_ID_US3, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart3_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart3_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9260_uart3_device = { - .name = "atmel_usart", - .id = 4, - .dev = { - .dma_mask = &uart3_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart3_data, - }, - .resource = uart3_resources, - .num_resources = ARRAY_SIZE(uart3_resources), -}; - -static inline void configure_usart3_pins(unsigned pins) +void __init configure_usart2_pins(void) { - at91_set_A_periph(AT91_PIN_PB10, 1); /* TXD3 */ - at91_set_A_periph(AT91_PIN_PB11, 0); /* RXD3 */ + at91_set_A_periph(AT91_PIN_PB8, 1); /* TXD2 */ + at91_set_A_periph(AT91_PIN_PB9, 0); /* RXD2 */ - if (pins & ATMEL_UART_RTS) - at91_set_B_periph(AT91_PIN_PC8, 0); /* RTS3 */ - if (pins & ATMEL_UART_CTS) - at91_set_B_periph(AT91_PIN_PC10, 0); /* CTS3 */ +#if defined(CONFIG_AT91_USART2_UART_RTS) + at91_set_A_periph(AT91_PIN_PA4, 0); /* RTS2 */ +#endif +#if defined(CONFIG_AT91_USART2_UART_CTS) + at91_set_A_periph(AT91_PIN_PA5, 0); /* CTS2 */ +#endif } -static struct resource uart4_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_US4, - .end = AT91SAM9260_BASE_US4 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9260_ID_US4, - .end = AT91SAM9260_ID_US4, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart4_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart4_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9260_uart4_device = { - .name = "atmel_usart", - .id = 5, - .dev = { - .dma_mask = &uart4_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart4_data, - }, - .resource = uart4_resources, - .num_resources = ARRAY_SIZE(uart4_resources), -}; - -static inline void configure_usart4_pins(void) +void __init configure_usart3_pins(void) { - at91_set_B_periph(AT91_PIN_PA31, 1); /* TXD4 */ - at91_set_B_periph(AT91_PIN_PA30, 0); /* RXD4 */ -} - -static struct resource uart5_resources[] = { - [0] = { - .start = AT91SAM9260_BASE_US5, - .end = AT91SAM9260_BASE_US5 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9260_ID_US5, - .end = AT91SAM9260_ID_US5, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart5_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart5_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9260_uart5_device = { - .name = "atmel_usart", - .id = 6, - .dev = { - .dma_mask = &uart5_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart5_data, - }, - .resource = uart5_resources, - .num_resources = ARRAY_SIZE(uart5_resources), -}; + at91_set_A_periph(AT91_PIN_PB10, 1); /* TXD3 */ + at91_set_A_periph(AT91_PIN_PB11, 0); /* RXD3 */ -static inline void configure_usart5_pins(void) -{ - at91_set_A_periph(AT91_PIN_PB12, 1); /* TXD5 */ - at91_set_A_periph(AT91_PIN_PB13, 0); /* RXD5 */ +#if defined(CONFIG_AT91_USART3_UART_RTS) + at91_set_B_periph(AT91_PIN_PC8, 0); /* RTS3 */ +#endif +#if defined(CONFIG_AT91_USART3_UART_CTS) + at91_set_B_periph(AT91_PIN_PC10, 0); /* CTS3 */ +#endif } -static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ -struct platform_device *atmel_default_console_device; /* the serial console device */ - -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) +void __init configure_usart4_pins(void) { - struct platform_device *pdev; - - switch (id) { - case 0: /* DBGU */ - pdev = &at91sam9260_dbgu_device; - configure_dbgu_pins(); - at91_clock_associate("mck", &pdev->dev, "usart"); - break; - case AT91SAM9260_ID_US0: - pdev = &at91sam9260_uart0_device; - configure_usart0_pins(pins); - at91_clock_associate("usart0_clk", &pdev->dev, "usart"); - break; - case AT91SAM9260_ID_US1: - pdev = &at91sam9260_uart1_device; - configure_usart1_pins(pins); - at91_clock_associate("usart1_clk", &pdev->dev, "usart"); - break; - case AT91SAM9260_ID_US2: - pdev = &at91sam9260_uart2_device; - configure_usart2_pins(pins); - at91_clock_associate("usart2_clk", &pdev->dev, "usart"); - break; - case AT91SAM9260_ID_US3: - pdev = &at91sam9260_uart3_device; - configure_usart3_pins(pins); - at91_clock_associate("usart3_clk", &pdev->dev, "usart"); - break; - case AT91SAM9260_ID_US4: - pdev = &at91sam9260_uart4_device; - configure_usart4_pins(); - at91_clock_associate("usart4_clk", &pdev->dev, "usart"); - break; - case AT91SAM9260_ID_US5: - pdev = &at91sam9260_uart5_device; - configure_usart5_pins(); - at91_clock_associate("usart5_clk", &pdev->dev, "usart"); - break; - default: - return; - } - pdev->id = portnr; /* update to mapped ID */ - - if (portnr < ATMEL_MAX_UART) - at91_uarts[portnr] = pdev; + at91_set_B_periph(AT91_PIN_PA31, 1); /* TXD4 */ + at91_set_B_periph(AT91_PIN_PA30, 0); /* RXD4 */ } -void __init at91_set_serial_console(unsigned portnr) +void __init configure_usart5_pins(void) { - if (portnr < ATMEL_MAX_UART) - atmel_default_console_device = at91_uarts[portnr]; + at91_set_A_periph(AT91_PIN_PB12, 1); /* TXD5 */ + at91_set_A_periph(AT91_PIN_PB13, 0); /* RXD5 */ } -void __init at91_add_device_serial(void) -{ - int i; - - for (i = 0; i < ATMEL_MAX_UART; i++) { - if (at91_uarts[i]) - platform_device_register(at91_uarts[i]); - } - - if (!atmel_default_console_device) - printk(KERN_INFO "AT91: No default serial console defined.\n"); -} -#else -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {} -void __init at91_add_device_serial(void) {} #endif - /* -------------------------------------------------------------------- */ /* * These devices are always present and don't need any board-specific diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c index 6b89172310c..a5bea525ff0 100644 --- a/arch/arm/mach-at91/at91sam9261_devices.c +++ b/arch/arm/mach-at91/at91sam9261_devices.c @@ -828,238 +828,69 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {} /* -------------------------------------------------------------------- * UART * -------------------------------------------------------------------- */ - #if defined(CONFIG_SERIAL_ATMEL) -static struct resource dbgu_resources[] = { - [0] = { - .start = AT91_VA_BASE_SYS + AT91_DBGU, - .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91_ID_SYS, - .end = AT91_ID_SYS, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data dbgu_data = { - .use_dma_tx = 0, - .use_dma_rx = 0, /* DBGU not capable of receive DMA */ - .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), -}; - -static u64 dbgu_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9261_dbgu_device = { - .name = "atmel_usart", - .id = 0, - .dev = { - .dma_mask = &dbgu_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &dbgu_data, - }, - .resource = dbgu_resources, - .num_resources = ARRAY_SIZE(dbgu_resources), -}; - -static inline void configure_dbgu_pins(void) -{ - at91_set_A_periph(AT91_PIN_PA9, 0); /* DRXD */ - at91_set_A_periph(AT91_PIN_PA10, 1); /* DTXD */ -} - -static struct resource uart0_resources[] = { - [0] = { - .start = AT91SAM9261_BASE_US0, - .end = AT91SAM9261_BASE_US0 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9261_ID_US0, - .end = AT91SAM9261_ID_US0, - .flags = IORESOURCE_IRQ, - }, -}; -static struct atmel_uart_data uart0_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, +const resource_size_t __initdata usart_base_addr[ATMEL_MAX_UART] = { + AT91_VA_BASE_SYS + AT91_DBGU, + AT91SAM9261_BASE_US0, + AT91SAM9261_BASE_US1, + AT91SAM9261_BASE_US2 }; -static u64 uart0_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9261_uart0_device = { - .name = "atmel_usart", - .id = 1, - .dev = { - .dma_mask = &uart0_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart0_data, - }, - .resource = uart0_resources, - .num_resources = ARRAY_SIZE(uart0_resources), +const resource_size_t __initdata usart_id_addr[ATMEL_MAX_UART] = { + AT91_ID_SYS, + AT91SAM9261_ID_US0, + AT91SAM9261_ID_US1, + AT91SAM9261_ID_US2 }; -static inline void configure_usart0_pins(unsigned pins) +void __init configure_dbgu_pins(void) { - at91_set_A_periph(AT91_PIN_PC8, 1); /* TXD0 */ - at91_set_A_periph(AT91_PIN_PC9, 0); /* RXD0 */ - - if (pins & ATMEL_UART_RTS) - at91_set_A_periph(AT91_PIN_PC10, 0); /* RTS0 */ - if (pins & ATMEL_UART_CTS) - at91_set_A_periph(AT91_PIN_PC11, 0); /* CTS0 */ + at91_set_A_periph(AT91_PIN_PA9, 0); /* DRXD */ + at91_set_A_periph(AT91_PIN_PA10, 1); /* DTXD */ } -static struct resource uart1_resources[] = { - [0] = { - .start = AT91SAM9261_BASE_US1, - .end = AT91SAM9261_BASE_US1 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9261_ID_US1, - .end = AT91SAM9261_ID_US1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart1_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart1_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9261_uart1_device = { - .name = "atmel_usart", - .id = 2, - .dev = { - .dma_mask = &uart1_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart1_data, - }, - .resource = uart1_resources, - .num_resources = ARRAY_SIZE(uart1_resources), -}; - -static inline void configure_usart1_pins(unsigned pins) +void __init configure_usart0_pins(void) { - at91_set_A_periph(AT91_PIN_PC12, 1); /* TXD1 */ - at91_set_A_periph(AT91_PIN_PC13, 0); /* RXD1 */ + at91_set_A_periph(AT91_PIN_PC8, 1); /* TXD0 */ + at91_set_A_periph(AT91_PIN_PC9, 0); /* RXD0 */ - if (pins & ATMEL_UART_RTS) - at91_set_B_periph(AT91_PIN_PA12, 0); /* RTS1 */ - if (pins & ATMEL_UART_CTS) - at91_set_B_periph(AT91_PIN_PA13, 0); /* CTS1 */ +#if defined(CONFIG_AT91_USART0_UART_RTS) + at91_set_A_periph(AT91_PIN_PC10, 0); /* RTS0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_CTS) + at91_set_A_periph(AT91_PIN_PC11, 0); /* CTS0 */ +#endif } -static struct resource uart2_resources[] = { - [0] = { - .start = AT91SAM9261_BASE_US2, - .end = AT91SAM9261_BASE_US2 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9261_ID_US2, - .end = AT91SAM9261_ID_US2, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart2_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart2_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9261_uart2_device = { - .name = "atmel_usart", - .id = 3, - .dev = { - .dma_mask = &uart2_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart2_data, - }, - .resource = uart2_resources, - .num_resources = ARRAY_SIZE(uart2_resources), -}; - -static inline void configure_usart2_pins(unsigned pins) +void __init configure_usart1_pins(void) { - at91_set_A_periph(AT91_PIN_PC15, 0); /* RXD2 */ - at91_set_A_periph(AT91_PIN_PC14, 1); /* TXD2 */ + at91_set_A_periph(AT91_PIN_PC12, 1); /* TXD1 */ + at91_set_A_periph(AT91_PIN_PC13, 0); /* RXD1 */ - if (pins & ATMEL_UART_RTS) - at91_set_B_periph(AT91_PIN_PA15, 0); /* RTS2*/ - if (pins & ATMEL_UART_CTS) - at91_set_B_periph(AT91_PIN_PA16, 0); /* CTS2 */ +#if defined(CONFIG_AT91_USART1_UART_RTS) + at91_set_B_periph(AT91_PIN_PA12, 0); /* RTS1 */ +#endif +#if defined(CONFIG_AT91_USART1_UART_CTS) + at91_set_B_periph(AT91_PIN_PA13, 0); /* CTS1 */ +#endif } -static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ -struct platform_device *atmel_default_console_device; /* the serial console device */ - -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) +void __init configure_usart2_pins(void) { - struct platform_device *pdev; - - switch (id) { - case 0: /* DBGU */ - pdev = &at91sam9261_dbgu_device; - configure_dbgu_pins(); - at91_clock_associate("mck", &pdev->dev, "usart"); - break; - case AT91SAM9261_ID_US0: - pdev = &at91sam9261_uart0_device; - configure_usart0_pins(pins); - at91_clock_associate("usart0_clk", &pdev->dev, "usart"); - break; - case AT91SAM9261_ID_US1: - pdev = &at91sam9261_uart1_device; - configure_usart1_pins(pins); - at91_clock_associate("usart1_clk", &pdev->dev, "usart"); - break; - case AT91SAM9261_ID_US2: - pdev = &at91sam9261_uart2_device; - configure_usart2_pins(pins); - at91_clock_associate("usart2_clk", &pdev->dev, "usart"); - break; - default: - return; - } - pdev->id = portnr; /* update to mapped ID */ - - if (portnr < ATMEL_MAX_UART) - at91_uarts[portnr] = pdev; -} + at91_set_A_periph(AT91_PIN_PC15, 0); /* RXD2 */ + at91_set_A_periph(AT91_PIN_PC14, 1); /* TXD2 */ -void __init at91_set_serial_console(unsigned portnr) -{ - if (portnr < ATMEL_MAX_UART) - atmel_default_console_device = at91_uarts[portnr]; +#if defined(CONFIG_AT91_USART2_UART_RTS) + at91_set_B_periph(AT91_PIN_PA15, 0); /* RTS2*/ +#endif +#if defined(CONFIG_AT91_USART2_UART_CTS) + at91_set_B_periph(AT91_PIN_PA16, 0); /* CTS2 */ +#endif } -void __init at91_add_device_serial(void) -{ - int i; - - for (i = 0; i < ATMEL_MAX_UART; i++) { - if (at91_uarts[i]) - platform_device_register(at91_uarts[i]); - } - - if (!atmel_default_console_device) - printk(KERN_INFO "AT91: No default serial console defined.\n"); -} -#else -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {} -void __init at91_add_device_serial(void) {} #endif - /* -------------------------------------------------------------------- */ /* diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c index c93992f55dc..42adf28467c 100644 --- a/arch/arm/mach-at91/at91sam9263_devices.c +++ b/arch/arm/mach-at91/at91sam9263_devices.c @@ -1014,239 +1014,69 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {} /* -------------------------------------------------------------------- * UART * -------------------------------------------------------------------- */ - #if defined(CONFIG_SERIAL_ATMEL) -static struct resource dbgu_resources[] = { - [0] = { - .start = AT91_VA_BASE_SYS + AT91_DBGU, - .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91_ID_SYS, - .end = AT91_ID_SYS, - .flags = IORESOURCE_IRQ, - }, +const resource_size_t __initdata usart_base_addr[ATMEL_MAX_UART] = { + AT91_VA_BASE_SYS + AT91_DBGU, + AT91SAM9263_BASE_US0, + AT91SAM9263_BASE_US1, + AT91SAM9263_BASE_US2 }; -static struct atmel_uart_data dbgu_data = { - .use_dma_tx = 0, - .use_dma_rx = 0, /* DBGU not capable of receive DMA */ - .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), +const resource_size_t __initdata usart_id_addr[ATMEL_MAX_UART] = { + AT91_ID_SYS, + AT91SAM9263_ID_US0, + AT91SAM9263_ID_US1, + AT91SAM9263_ID_US2 }; -static u64 dbgu_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9263_dbgu_device = { - .name = "atmel_usart", - .id = 0, - .dev = { - .dma_mask = &dbgu_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &dbgu_data, - }, - .resource = dbgu_resources, - .num_resources = ARRAY_SIZE(dbgu_resources), -}; - -static inline void configure_dbgu_pins(void) +void __init configure_dbgu_pins(void) { - at91_set_A_periph(AT91_PIN_PC30, 0); /* DRXD */ - at91_set_A_periph(AT91_PIN_PC31, 1); /* DTXD */ + at91_set_A_periph(AT91_PIN_PC30, 0); /* DRXD */ + at91_set_A_periph(AT91_PIN_PC31, 1); /* DTXD */ } -static struct resource uart0_resources[] = { - [0] = { - .start = AT91SAM9263_BASE_US0, - .end = AT91SAM9263_BASE_US0 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9263_ID_US0, - .end = AT91SAM9263_ID_US0, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart0_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart0_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9263_uart0_device = { - .name = "atmel_usart", - .id = 1, - .dev = { - .dma_mask = &uart0_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart0_data, - }, - .resource = uart0_resources, - .num_resources = ARRAY_SIZE(uart0_resources), -}; - -static inline void configure_usart0_pins(unsigned pins) +void __init configure_usart0_pins(void) { - at91_set_A_periph(AT91_PIN_PA26, 1); /* TXD0 */ - at91_set_A_periph(AT91_PIN_PA27, 0); /* RXD0 */ - - if (pins & ATMEL_UART_RTS) - at91_set_A_periph(AT91_PIN_PA28, 0); /* RTS0 */ - if (pins & ATMEL_UART_CTS) - at91_set_A_periph(AT91_PIN_PA29, 0); /* CTS0 */ -} - -static struct resource uart1_resources[] = { - [0] = { - .start = AT91SAM9263_BASE_US1, - .end = AT91SAM9263_BASE_US1 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9263_ID_US1, - .end = AT91SAM9263_ID_US1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart1_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; + at91_set_A_periph(AT91_PIN_PA26, 1); /* TXD0 */ + at91_set_A_periph(AT91_PIN_PA27, 0); /* RXD0 */ -static u64 uart1_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9263_uart1_device = { - .name = "atmel_usart", - .id = 2, - .dev = { - .dma_mask = &uart1_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart1_data, - }, - .resource = uart1_resources, - .num_resources = ARRAY_SIZE(uart1_resources), -}; - -static inline void configure_usart1_pins(unsigned pins) -{ - at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */ - at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */ - - if (pins & ATMEL_UART_RTS) - at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */ - if (pins & ATMEL_UART_CTS) - at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */ +#if defined(CONFIG_AT91_USART0_UART_RTS) + at91_set_A_periph(AT91_PIN_PA28, 0); /* RTS0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_CTS) + at91_set_A_periph(AT91_PIN_PA29, 0); /* CTS0 */ +#endif } -static struct resource uart2_resources[] = { - [0] = { - .start = AT91SAM9263_BASE_US2, - .end = AT91SAM9263_BASE_US2 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9263_ID_US2, - .end = AT91SAM9263_ID_US2, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart2_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart2_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9263_uart2_device = { - .name = "atmel_usart", - .id = 3, - .dev = { - .dma_mask = &uart2_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart2_data, - }, - .resource = uart2_resources, - .num_resources = ARRAY_SIZE(uart2_resources), -}; - -static inline void configure_usart2_pins(unsigned pins) +void __init configure_usart1_pins(void) { - at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */ - at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */ + at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */ + at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */ - if (pins & ATMEL_UART_RTS) - at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */ - if (pins & ATMEL_UART_CTS) - at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */ +#if defined(CONFIG_AT91_USART1_UART_RTS) + at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */ +#endif +#if defined(CONFIG_AT91_USART1_UART_CTS) + at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */ +#endif } -static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ -struct platform_device *atmel_default_console_device; /* the serial console device */ - -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) +void __init configure_usart2_pins(void) { - struct platform_device *pdev; - - switch (id) { - case 0: /* DBGU */ - pdev = &at91sam9263_dbgu_device; - configure_dbgu_pins(); - at91_clock_associate("mck", &pdev->dev, "usart"); - break; - case AT91SAM9263_ID_US0: - pdev = &at91sam9263_uart0_device; - configure_usart0_pins(pins); - at91_clock_associate("usart0_clk", &pdev->dev, "usart"); - break; - case AT91SAM9263_ID_US1: - pdev = &at91sam9263_uart1_device; - configure_usart1_pins(pins); - at91_clock_associate("usart1_clk", &pdev->dev, "usart"); - break; - case AT91SAM9263_ID_US2: - pdev = &at91sam9263_uart2_device; - configure_usart2_pins(pins); - at91_clock_associate("usart2_clk", &pdev->dev, "usart"); - break; - default: - return; - } - pdev->id = portnr; /* update to mapped ID */ - - if (portnr < ATMEL_MAX_UART) - at91_uarts[portnr] = pdev; -} + at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */ + at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */ -void __init at91_set_serial_console(unsigned portnr) -{ - if (portnr < ATMEL_MAX_UART) - atmel_default_console_device = at91_uarts[portnr]; +#if defined(CONFIG_AT91_USART2_UART_RTS) + at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */ +#endif +#if defined(CONFIG_AT91_USART2_UART_CTS) + at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */ +#endif } -void __init at91_add_device_serial(void) -{ - int i; - - for (i = 0; i < ATMEL_MAX_UART; i++) { - if (at91_uarts[i]) - platform_device_register(at91_uarts[i]); - } - - if (!atmel_default_console_device) - printk(KERN_INFO "AT91: No default serial console defined.\n"); -} -#else -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {} -void __init at91_add_device_serial(void) {} #endif - /* -------------------------------------------------------------------- */ /* * These devices are always present and don't need any board-specific diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c index 620886341fb..dc7fc504208 100644 --- a/arch/arm/mach-at91/at91sam9rl_devices.c +++ b/arch/arm/mach-at91/at91sam9rl_devices.c @@ -720,293 +720,94 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {} /* -------------------------------------------------------------------- * UART * -------------------------------------------------------------------- */ - #if defined(CONFIG_SERIAL_ATMEL) -static struct resource dbgu_resources[] = { - [0] = { - .start = AT91_VA_BASE_SYS + AT91_DBGU, - .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91_ID_SYS, - .end = AT91_ID_SYS, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data dbgu_data = { - .use_dma_tx = 0, - .use_dma_rx = 0, /* DBGU not capable of receive DMA */ - .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), -}; - -static u64 dbgu_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9rl_dbgu_device = { - .name = "atmel_usart", - .id = 0, - .dev = { - .dma_mask = &dbgu_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &dbgu_data, - }, - .resource = dbgu_resources, - .num_resources = ARRAY_SIZE(dbgu_resources), -}; - -static inline void configure_dbgu_pins(void) -{ - at91_set_A_periph(AT91_PIN_PA21, 0); /* DRXD */ - at91_set_A_periph(AT91_PIN_PA22, 1); /* DTXD */ -} - -static struct resource uart0_resources[] = { - [0] = { - .start = AT91SAM9RL_BASE_US0, - .end = AT91SAM9RL_BASE_US0 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9RL_ID_US0, - .end = AT91SAM9RL_ID_US0, - .flags = IORESOURCE_IRQ, - }, -}; -static struct atmel_uart_data uart0_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, +const resource_size_t __initdata usart_base_addr[ATMEL_MAX_UART] = { + AT91_VA_BASE_SYS + AT91_DBGU, + AT91SAM9RL_BASE_US0, + AT91SAM9RL_BASE_US1, + AT91SAM9RL_BASE_US2, + AT91SAM9RL_BASE_US3 }; -static u64 uart0_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9rl_uart0_device = { - .name = "atmel_usart", - .id = 1, - .dev = { - .dma_mask = &uart0_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart0_data, - }, - .resource = uart0_resources, - .num_resources = ARRAY_SIZE(uart0_resources), -}; - -static inline void configure_usart0_pins(unsigned pins) -{ - at91_set_A_periph(AT91_PIN_PA6, 1); /* TXD0 */ - at91_set_A_periph(AT91_PIN_PA7, 0); /* RXD0 */ - - if (pins & ATMEL_UART_RTS) - at91_set_A_periph(AT91_PIN_PA9, 0); /* RTS0 */ - if (pins & ATMEL_UART_CTS) - at91_set_A_periph(AT91_PIN_PA10, 0); /* CTS0 */ - if (pins & ATMEL_UART_DSR) - at91_set_A_periph(AT91_PIN_PD14, 0); /* DSR0 */ - if (pins & ATMEL_UART_DTR) - at91_set_A_periph(AT91_PIN_PD15, 0); /* DTR0 */ - if (pins & ATMEL_UART_DCD) - at91_set_A_periph(AT91_PIN_PD16, 0); /* DCD0 */ - if (pins & ATMEL_UART_RI) - at91_set_A_periph(AT91_PIN_PD17, 0); /* RI0 */ -} - -static struct resource uart1_resources[] = { - [0] = { - .start = AT91SAM9RL_BASE_US1, - .end = AT91SAM9RL_BASE_US1 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9RL_ID_US1, - .end = AT91SAM9RL_ID_US1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart1_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart1_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9rl_uart1_device = { - .name = "atmel_usart", - .id = 2, - .dev = { - .dma_mask = &uart1_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart1_data, - }, - .resource = uart1_resources, - .num_resources = ARRAY_SIZE(uart1_resources), +const resource_size_t __initdata usart_id_addr[ATMEL_MAX_UART] = { + AT91_ID_SYS, + AT91SAM9RL_ID_US0, + AT91SAM9RL_ID_US1, + AT91SAM9RL_ID_US2, + AT91SAM9RL_ID_US3 }; -static inline void configure_usart1_pins(unsigned pins) +void __init configure_dbgu_pins(void) { - at91_set_A_periph(AT91_PIN_PA11, 1); /* TXD1 */ - at91_set_A_periph(AT91_PIN_PA12, 0); /* RXD1 */ - - if (pins & ATMEL_UART_RTS) - at91_set_B_periph(AT91_PIN_PA18, 0); /* RTS1 */ - if (pins & ATMEL_UART_CTS) - at91_set_B_periph(AT91_PIN_PA19, 0); /* CTS1 */ + at91_set_A_periph(AT91_PIN_PA21, 0); /* DRXD */ + at91_set_A_periph(AT91_PIN_PA22, 1); /* DTXD */ } +#endif -static struct resource uart2_resources[] = { - [0] = { - .start = AT91SAM9RL_BASE_US2, - .end = AT91SAM9RL_BASE_US2 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9RL_ID_US2, - .end = AT91SAM9RL_ID_US2, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart2_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart2_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9rl_uart2_device = { - .name = "atmel_usart", - .id = 3, - .dev = { - .dma_mask = &uart2_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart2_data, - }, - .resource = uart2_resources, - .num_resources = ARRAY_SIZE(uart2_resources), -}; - -static inline void configure_usart2_pins(unsigned pins) +void __init configure_usart0_pins(void) { - at91_set_A_periph(AT91_PIN_PA13, 1); /* TXD2 */ - at91_set_A_periph(AT91_PIN_PA14, 0); /* RXD2 */ + at91_set_A_periph(AT91_PIN_PA6, 1); /* TXD0 */ + at91_set_A_periph(AT91_PIN_PA7, 0); /* RXD0 */ - if (pins & ATMEL_UART_RTS) - at91_set_A_periph(AT91_PIN_PA29, 0); /* RTS2 */ - if (pins & ATMEL_UART_CTS) - at91_set_A_periph(AT91_PIN_PA30, 0); /* CTS2 */ +#if defined(CONFIG_AT91_USART0_UART_RTS) + at91_set_A_periph(AT91_PIN_PA9, 0); /* RTS0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_CTS) + at91_set_A_periph(AT91_PIN_PA10, 0); /* CTS0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_DSR) + at91_set_A_periph(AT91_PIN_PD14, 0); /* DSR0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_DTR) + at91_set_A_periph(AT91_PIN_PD15, 0); /* DTR0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_DCD) + at91_set_A_periph(AT91_PIN_PD16, 0); /* DCD0 */ +#endif +#if defined(CONFIG_AT91_USART0_UART_RI) + at91_set_A_periph(AT91_PIN_PD17, 0); /* RI0 */ +#endif } -static struct resource uart3_resources[] = { - [0] = { - .start = AT91SAM9RL_BASE_US3, - .end = AT91SAM9RL_BASE_US3 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = AT91SAM9RL_ID_US3, - .end = AT91SAM9RL_ID_US3, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct atmel_uart_data uart3_data = { - .use_dma_tx = 1, - .use_dma_rx = 1, -}; - -static u64 uart3_dmamask = DMA_BIT_MASK(32); - -static struct platform_device at91sam9rl_uart3_device = { - .name = "atmel_usart", - .id = 4, - .dev = { - .dma_mask = &uart3_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &uart3_data, - }, - .resource = uart3_resources, - .num_resources = ARRAY_SIZE(uart3_resources), -}; - -static inline void configure_usart3_pins(unsigned pins) +void __init configure_usart1_pins(void) { - at91_set_A_periph(AT91_PIN_PB0, 1); /* TXD3 */ - at91_set_A_periph(AT91_PIN_PB1, 0); /* RXD3 */ + at91_set_A_periph(AT91_PIN_PA11, 1); /* TXD1 */ + at91_set_A_periph(AT91_PIN_PA12, 0); /* RXD1 */ - if (pins & ATMEL_UART_RTS) - at91_set_B_periph(AT91_PIN_PD4, 0); /* RTS3 */ - if (pins & ATMEL_UART_CTS) - at91_set_B_periph(AT91_PIN_PD3, 0); /* CTS3 */ +#if defined(CONFIG_AT91_USART1_UART_RTS) + at91_set_B_periph(AT91_PIN_PA18, 0); /* RTS1 */ +#endif +#if defined(CONFIG_AT91_USART1_UART_CTS) + at91_set_B_periph(AT91_PIN_PA19, 0); /* CTS1 */ +#endif } -static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ -struct platform_device *atmel_default_console_device; /* the serial console device */ - -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) +void __init configure_usart2_pins(void) { - struct platform_device *pdev; - - switch (id) { - case 0: /* DBGU */ - pdev = &at91sam9rl_dbgu_device; - configure_dbgu_pins(); - at91_clock_associate("mck", &pdev->dev, "usart"); - break; - case AT91SAM9RL_ID_US0: - pdev = &at91sam9rl_uart0_device; - configure_usart0_pins(pins); - at91_clock_associate("usart0_clk", &pdev->dev, "usart"); - break; - case AT91SAM9RL_ID_US1: - pdev = &at91sam9rl_uart1_device; - configure_usart1_pins(pins); - at91_clock_associate("usart1_clk", &pdev->dev, "usart"); - break; - case AT91SAM9RL_ID_US2: - pdev = &at91sam9rl_uart2_device; - configure_usart2_pins(pins); - at91_clock_associate("usart2_clk", &pdev->dev, "usart"); - break; - case AT91SAM9RL_ID_US3: - pdev = &at91sam9rl_uart3_device; - configure_usart3_pins(pins); - at91_clock_associate("usart3_clk", &pdev->dev, "usart"); - break; - default: - return; - } - pdev->id = portnr; /* update to mapped ID */ + at91_set_A_periph(AT91_PIN_PA13, 1); /* TXD2 */ + at91_set_A_periph(AT91_PIN_PA14, 0); /* RXD2 */ - if (portnr < ATMEL_MAX_UART) - at91_uarts[portnr] = pdev; -} - -void __init at91_set_serial_console(unsigned portnr) -{ - if (portnr < ATMEL_MAX_UART) - atmel_default_console_device = at91_uarts[portnr]; +#if defined(CONFIG_AT91_USART2_UART_RTS) + at91_set_A_periph(AT91_PIN_PA29, 0); /* RTS2 */ +#endif +#if defined(CONFIG_AT91_USART2_UART_CTS) + at91_set_A_periph(AT91_PIN_PA30, 0); /* CTS2 */ +#endif } -void __init at91_add_device_serial(void) +void __init configure_usart3_pins(void) { - int i; + at91_set_A_periph(AT91_PIN_PB0, 1); /* TXD3 */ + at91_set_A_periph(AT91_PIN_PB1, 0); /* RXD3 */ - for (i = 0; i < ATMEL_MAX_UART; i++) { - if (at91_uarts[i]) - platform_device_register(at91_uarts[i]); - } - - if (!atmel_default_console_device) - printk(KERN_INFO "AT91: No default serial console defined.\n"); -} -#else -void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} -void __init at91_set_serial_console(unsigned portnr) {} -void __init at91_add_device_serial(void) {} +#if defined(CONFIG_AT91_USART3_UART_RTS) + at91_set_B_periph(AT91_PIN_PD4, 0); /* RTS3 */ #endif - +#if defined(CONFIG_AT91_USART3_UART_CTS) + at91_set_B_periph(AT91_PIN_PD3, 0); /* CTS3 */ +#endif +} /* -------------------------------------------------------------------- */ diff --git a/arch/arm/mach-at91/board-1arm.c b/arch/arm/mach-at91/board-1arm.c index 9b27d167bff..ba2e0bc0542 100644 --- a/arch/arm/mach-at91/board-1arm.c +++ b/arch/arm/mach-at91/board-1arm.c @@ -39,24 +39,13 @@ #include "generic.h" -/* - * Serial port configuration. - * 0 .. 3 = USART0 .. USART3 - * 4 = DBGU - */ -static struct at91_uart_config __initdata onearm_uart_config = { - .console_tty = 0, /* ttyS0 */ - .nr_tty = 3, - .tty_map = { 4, 0, 1, -1, -1 }, /* ttyS0, ..., ttyS4 */ -}; - static void __init onearm_map_io(void) { /* Initialize processor: 18.432 MHz crystal */ at91rm9200_initialize(18432000, AT91RM9200_PQFP); /* Setup the serial ports and console */ - at91_init_serial(&onearm_uart_config); + at91_init_uarts(); } static void __init onearm_init_irq(void) diff --git a/arch/arm/mach-at91/board-cam60.c b/arch/arm/mach-at91/board-cam60.c index cdddca54b93..1afa2fc46a5 100644 --- a/arch/arm/mach-at91/board-cam60.c +++ b/arch/arm/mach-at91/board-cam60.c @@ -48,11 +48,8 @@ static void __init cam60_map_io(void) /* Initialize processor: 10 MHz crystal */ at91sam9260_initialize(10000000); - /* DGBU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init cam60_init_irq(void) diff --git a/arch/arm/mach-at91/board-cap9adk.c b/arch/arm/mach-at91/board-cap9adk.c index 196199552eb..83231d86349 100644 --- a/arch/arm/mach-at91/board-cap9adk.c +++ b/arch/arm/mach-at91/board-cap9adk.c @@ -61,8 +61,7 @@ static void __init cap9adk_map_io(void) at91_set_gpio_output(AT91_PIN_PC29, 1); /* Setup the serial ports and console */ - at91_register_uart(0, 0, 0); /* DBGU = ttyS0 */ - at91_set_serial_console(0); + at91_init_uarts(); } static void __init cap9adk_init_irq(void) diff --git a/arch/arm/mach-at91/board-carmeva.c b/arch/arm/mach-at91/board-carmeva.c index afa1ff0e957..cfb56c18633 100644 --- a/arch/arm/mach-at91/board-carmeva.c +++ b/arch/arm/mach-at91/board-carmeva.c @@ -45,16 +45,8 @@ static void __init carmeva_map_io(void) /* Initialize processor: 20.000 MHz crystal */ at91rm9200_initialize(20000000, AT91RM9200_BGA); - /* DBGU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ - at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS - | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD - | ATMEL_UART_RI); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init carmeva_init_irq(void) diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c index cb7c9a8fa48..e9cd20abf49 100644 --- a/arch/arm/mach-at91/board-csb337.c +++ b/arch/arm/mach-at91/board-csb337.c @@ -51,11 +51,8 @@ static void __init csb337_map_io(void) /* Setup the LEDs */ at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1); - /* DBGU on ttyS0 */ - at91_register_uart(0, 0, 0); - - /* make console=ttyS0 the default */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init csb337_init_irq(void) diff --git a/arch/arm/mach-at91/board-csb637.c b/arch/arm/mach-at91/board-csb637.c index 8db8bd8babd..940699b25d1 100644 --- a/arch/arm/mach-at91/board-csb637.c +++ b/arch/arm/mach-at91/board-csb637.c @@ -45,11 +45,8 @@ static void __init csb637_map_io(void) /* Initialize processor: 3.6864 MHz crystal */ at91rm9200_initialize(3686400, AT91RM9200_BGA); - /* DBGU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* make console=ttyS0 (ie, DBGU) the default */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init csb637_init_irq(void) diff --git a/arch/arm/mach-at91/board-dk.c b/arch/arm/mach-at91/board-dk.c index 43e1aa7ecef..424efe8a4c2 100644 --- a/arch/arm/mach-at91/board-dk.c +++ b/arch/arm/mach-at91/board-dk.c @@ -53,16 +53,8 @@ static void __init dk_map_io(void) /* Setup the LEDs */ at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2); - /* DBGU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ - at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS - | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD - | ATMEL_UART_RI); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init dk_init_irq(void) diff --git a/arch/arm/mach-at91/board-eb9200.c b/arch/arm/mach-at91/board-eb9200.c index 528656761ff..96f426f59c3 100644 --- a/arch/arm/mach-at91/board-eb9200.c +++ b/arch/arm/mach-at91/board-eb9200.c @@ -45,19 +45,8 @@ static void __init eb9200_map_io(void) /* Initialize processor: 18.432 MHz crystal */ at91rm9200_initialize(18432000, AT91RM9200_BGA); - /* DBGU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ - at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS - | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD - | ATMEL_UART_RI); - - /* USART2 on ttyS2. (Rx, Tx) - IRDA */ - at91_register_uart(AT91RM9200_ID_US2, 2, 0); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init eb9200_init_irq(void) diff --git a/arch/arm/mach-at91/board-ecbat91.c b/arch/arm/mach-at91/board-ecbat91.c index bfeee8a2af2..68dff6b7f6e 100644 --- a/arch/arm/mach-at91/board-ecbat91.c +++ b/arch/arm/mach-at91/board-ecbat91.c @@ -50,14 +50,8 @@ static void __init ecb_at91map_io(void) /* Setup the LEDs */ at91_init_leds(AT91_PIN_PC7, AT91_PIN_PC7); - /* DBGU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART0 on ttyS1. (Rx & Tx only) */ - at91_register_uart(AT91RM9200_ID_US0, 1, 0); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init ecb_at91init_irq(void) diff --git a/arch/arm/mach-at91/board-ek.c b/arch/arm/mach-at91/board-ek.c index 60626e7a349..a87a31fe239 100644 --- a/arch/arm/mach-at91/board-ek.c +++ b/arch/arm/mach-at91/board-ek.c @@ -53,16 +53,8 @@ static void __init ek_map_io(void) /* Setup the LEDs */ at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2); - /* DBGU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ - at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS - | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD - | ATMEL_UART_RI); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init ek_init_irq(void) diff --git a/arch/arm/mach-at91/board-kafa.c b/arch/arm/mach-at91/board-kafa.c index a87956c0a74..8776283aaa4 100644 --- a/arch/arm/mach-at91/board-kafa.c +++ b/arch/arm/mach-at91/board-kafa.c @@ -39,17 +39,6 @@ #include "generic.h" -/* - * Serial port configuration. - * 0 .. 3 = USART0 .. USART3 - * 4 = DBGU - */ -static struct at91_uart_config __initdata kafa_uart_config = { - .console_tty = 0, /* ttyS0 */ - .nr_tty = 2, - .tty_map = { 4, 0, -1, -1, -1 } /* ttyS0, ..., ttyS4 */ -}; - static void __init kafa_map_io(void) { /* Initialize processor: 18.432 MHz crystal */ @@ -59,7 +48,7 @@ static void __init kafa_map_io(void) at91_init_leds(AT91_PIN_PB4, AT91_PIN_PB4); /* Setup the serial ports and console */ - at91_init_serial(&kafa_uart_config); + at91_init_uarts(); } static void __init kafa_init_irq(void) diff --git a/arch/arm/mach-at91/board-kb9202.c b/arch/arm/mach-at91/board-kb9202.c index fe9b9913fa3..16fac05b42c 100644 --- a/arch/arm/mach-at91/board-kb9202.c +++ b/arch/arm/mach-at91/board-kb9202.c @@ -50,20 +50,8 @@ static void __init kb9202_map_io(void) /* Set up the LEDs */ at91_init_leds(AT91_PIN_PC19, AT91_PIN_PC18); - /* DBGU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART0 on ttyS1 (Rx & Tx only) */ - at91_register_uart(AT91RM9200_ID_US0, 1, 0); - - /* USART1 on ttyS2 (Rx & Tx only) - IRDA (optional) */ - at91_register_uart(AT91RM9200_ID_US1, 2, 0); - - /* USART3 on ttyS3 (Rx, Tx, CTS, RTS) - RS485 (optional) */ - at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_CTS | ATMEL_UART_RTS); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init kb9202_init_irq(void) diff --git a/arch/arm/mach-at91/board-picotux200.c b/arch/arm/mach-at91/board-picotux200.c index dbc912d633c..6e7a4e34c90 100644 --- a/arch/arm/mach-at91/board-picotux200.c +++ b/arch/arm/mach-at91/board-picotux200.c @@ -43,24 +43,13 @@ #include "generic.h" -/* - * Serial port configuration. - * 0 .. 3 = USART0 .. USART3 - * 4 = DBGU - */ -static struct at91_uart_config __initdata picotux200_uart_config = { - .console_tty = 0, /* ttyS0 */ - .nr_tty = 2, - .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */ -}; - static void __init picotux200_map_io(void) { /* Initialize processor: 18.432 MHz crystal */ at91rm9200_initialize(18432000, AT91RM9200_BGA); /* Setup the serial ports and console */ - at91_init_serial(&picotux200_uart_config); + at91_init_uarts(); } static void __init picotux200_init_irq(void) diff --git a/arch/arm/mach-at91/board-qil-a9260.c b/arch/arm/mach-at91/board-qil-a9260.c index 4c28413426c..4de2955dc03 100644 --- a/arch/arm/mach-at91/board-qil-a9260.c +++ b/arch/arm/mach-at91/board-qil-a9260.c @@ -51,23 +51,8 @@ static void __init ek_map_io(void) /* Initialize processor: 12.000 MHz crystal */ at91sam9260_initialize(12000000); - /* DGBU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ - at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS - | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD - | ATMEL_UART_RI); - - /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */ - at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS); - - /* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */ - at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS); - - /* set serial console to ttyS1 (ie, USART0) */ - at91_set_serial_console(1); - + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init ek_init_irq(void) diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c index e4910cb26c1..082313bbcf8 100644 --- a/arch/arm/mach-at91/board-sam9-l9260.c +++ b/arch/arm/mach-at91/board-sam9-l9260.c @@ -50,19 +50,8 @@ static void __init ek_map_io(void) /* Setup the LEDs */ at91_init_leds(AT91_PIN_PA9, AT91_PIN_PA6); - /* DBGU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ - at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS - | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD - | ATMEL_UART_RI); - - /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */ - at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init ek_init_irq(void) diff --git a/arch/arm/mach-at91/board-sam9260ek.c b/arch/arm/mach-at91/board-sam9260ek.c index cb20e70b3b0..02a8fa3a824 100644 --- a/arch/arm/mach-at91/board-sam9260ek.c +++ b/arch/arm/mach-at91/board-sam9260ek.c @@ -48,19 +48,8 @@ static void __init ek_map_io(void) /* Initialize processor: 18.432 MHz crystal */ at91sam9260_initialize(18432000); - /* DGBU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ - at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS - | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD - | ATMEL_UART_RI); - - /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ - at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init ek_init_irq(void) diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c index 1a9963b811c..4f9b74d09db 100644 --- a/arch/arm/mach-at91/board-sam9261ek.c +++ b/arch/arm/mach-at91/board-sam9261ek.c @@ -59,11 +59,8 @@ static void __init ek_map_io(void) /* Setup the LEDs */ at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14); - /* DGBU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init ek_init_irq(void) diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c index b1d11960a73..087abe5875f 100644 --- a/arch/arm/mach-at91/board-sam9263ek.c +++ b/arch/arm/mach-at91/board-sam9263ek.c @@ -53,14 +53,8 @@ static void __init ek_map_io(void) /* Initialize processor: 16.367 MHz crystal */ at91sam9263_initialize(16367660); - /* DGBU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */ - at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init ek_init_irq(void) diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c index d4eba5c0ce0..b7c29ca22c9 100644 --- a/arch/arm/mach-at91/board-sam9g20ek.c +++ b/arch/arm/mach-at91/board-sam9g20ek.c @@ -46,19 +46,8 @@ static void __init ek_map_io(void) /* Initialize processor: 18.432 MHz crystal */ at91sam9260_initialize(18432000); - /* DGBU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ - at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS - | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD - | ATMEL_UART_RI); - - /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ - at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init ek_init_irq(void) diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c index c6dce49c388..fd414c1417b 100644 --- a/arch/arm/mach-at91/board-sam9rlek.c +++ b/arch/arm/mach-at91/board-sam9rlek.c @@ -39,14 +39,8 @@ static void __init ek_map_io(void) /* Initialize processor: 12.000 MHz crystal */ at91sam9rl_initialize(12000000); - /* DGBU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */ - at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init ek_init_irq(void) diff --git a/arch/arm/mach-at91/board-usb-a9260.c b/arch/arm/mach-at91/board-usb-a9260.c index f9d0b65da40..1c11abf97f9 100644 --- a/arch/arm/mach-at91/board-usb-a9260.c +++ b/arch/arm/mach-at91/board-usb-a9260.c @@ -51,11 +51,8 @@ static void __init ek_map_io(void) /* Initialize processor: 12.000 MHz crystal */ at91sam9260_initialize(12000000); - /* DGBU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init ek_init_irq(void) diff --git a/arch/arm/mach-at91/board-usb-a9263.c b/arch/arm/mach-at91/board-usb-a9263.c index 673e5c27214..45ab3f696c6 100644 --- a/arch/arm/mach-at91/board-usb-a9263.c +++ b/arch/arm/mach-at91/board-usb-a9263.c @@ -50,11 +50,8 @@ static void __init ek_map_io(void) /* Initialize processor: 12.00 MHz crystal */ at91sam9263_initialize(12000000); - /* DGBU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init ek_init_irq(void) diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c index 36b380aad00..2e6d5c7ffcb 100644 --- a/arch/arm/mach-at91/board-yl-9200.c +++ b/arch/arm/mach-at91/board-yl-9200.c @@ -57,22 +57,8 @@ static void __init yl9200_map_io(void) /* Setup the LEDs D2=PB17 (timer), D3=PB16 (cpu) */ at91_init_leds(AT91_PIN_PB16, AT91_PIN_PB17); - /* DBGU on ttyS0. (Rx & Tx only) */ - at91_register_uart(0, 0, 0); - - /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ - at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS - | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD - | ATMEL_UART_RI); - - /* USART0 on ttyS2. (Rx & Tx only to JP3) */ - at91_register_uart(AT91RM9200_ID_US0, 2, 0); - - /* USART3 on ttyS3. (Rx, Tx, RTS - RS485 interface) */ - at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_RTS); - - /* set serial console to ttyS0 (ie, DBGU) */ - at91_set_serial_console(0); + /* Setup the serial ports and console */ + at91_init_uarts(); } static void __init yl9200_init_irq(void) diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index 7b9ce7a336b..03971110ad2 100644 --- a/arch/arm/mach-at91/generic.h +++ b/arch/arm/mach-at91/generic.h @@ -8,6 +8,8 @@ * published by the Free Software Foundation. */ +#include + /* Processors */ extern void __init at91rm9200_initialize(unsigned long main_clock, unsigned short banks); extern void __init at91sam9260_initialize(unsigned long main_clock); @@ -42,6 +44,9 @@ extern void __init at91_clock_associate(const char *id, struct device *dev, cons extern void at91_irq_suspend(void); extern void at91_irq_resume(void); + /* Serial Ports */ +extern void __init at91_init_uarts(void); + /* GPIO */ #define AT91RM9200_PQFP 3 /* AT91RM9200 PQFP package has 3 banks */ #define AT91RM9200_BGA 4 /* AT91RM9200 BGA package has 4 banks */ diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h index acd60f2a072..30d960c3433 100644 --- a/arch/arm/mach-at91/include/mach/board.h +++ b/arch/arm/mach-at91/include/mach/board.h @@ -107,31 +107,30 @@ extern void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_de extern void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices); /* Serial */ -#define ATMEL_UART_CTS 0x01 -#define ATMEL_UART_RTS 0x02 -#define ATMEL_UART_DSR 0x04 -#define ATMEL_UART_DTR 0x08 -#define ATMEL_UART_DCD 0x10 -#define ATMEL_UART_RI 0x20 - -extern void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins); -extern void __init at91_set_serial_console(unsigned portnr); - -struct at91_uart_config { - unsigned short console_tty; /* tty number of serial console */ - unsigned short nr_tty; /* number of serial tty's */ - short tty_map[]; /* map UART to tty number */ -}; +#if defined(CONFIG_SERIAL_ATMEL) extern struct platform_device *atmel_default_console_device; -extern void __init __deprecated at91_init_serial(struct at91_uart_config *config); struct atmel_uart_data { short use_dma_tx; /* use transmit DMA? */ short use_dma_rx; /* use receive DMA? */ void __iomem *regs; /* virtual base address, if any */ }; + extern void __init at91_add_device_serial(void); +extern const resource_size_t __initdata usart_base_addr[ATMEL_MAX_UART]; +extern const resource_size_t __initdata usart_id_addr[ATMEL_MAX_UART]; + +extern void configure_dbgu_pins(void) __init; +extern void configure_usart0_pins(void) __init; +extern void configure_usart1_pins(void) __init; +extern void configure_usart2_pins(void) __init; +extern void configure_usart3_pins(void) __init; +extern void configure_usart4_pins(void) __init; +extern void configure_usart5_pins(void) __init; + +#endif + /* * SSC -- accessed through ssc_request(id). Drivers don't bind to SSC * platform devices. Their SSC ID is part of their configuration data, diff --git a/arch/arm/mach-at91/include/mach/hardware.h b/arch/arm/mach-at91/include/mach/hardware.h index da0b681c652..e428e7fd12b 100644 --- a/arch/arm/mach-at91/include/mach/hardware.h +++ b/arch/arm/mach-at91/include/mach/hardware.h @@ -66,7 +66,11 @@ #define AT91_VIRT_BASE (AT91_IO_VIRT_BASE - AT91_SRAM_MAX) /* Serial ports */ -#define ATMEL_MAX_UART 7 /* 6 USART3's and one DBGU port (SAM9260) */ +#ifndef CONFIG_SERIAL_ATMEL_CONSOLE +#define ATMEL_MAX_UART 0 +#else +#define ATMEL_MAX_UART CONFIG_AT91_MAX_UART +#endif /* External Memory Map */ #define AT91_CHIPSELECT_0 0x10000000 diff --git a/arch/arm/mach-at91/uart.c b/arch/arm/mach-at91/uart.c new file mode 100644 index 00000000000..7908bb3284f --- /dev/null +++ b/arch/arm/mach-at91/uart.c @@ -0,0 +1,143 @@ +/* + * linux/arch/arm/mach-at91/uart.c + * + * Copyright (C) 2008 Pieter du Preez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "uart.h" + +#include +#include +#include "generic.h" + +struct platform_device *atmel_default_console_device; + +static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; + +static struct at91_uart { + struct atmel_uart_data data; + u64 dmamask; + struct platform_device devices; + struct resource resources[2]; +} uart[ATMEL_MAX_UART]; + +void __init at91_add_device_serial(void) +{ + int i; + + for (i = 0; i < ATMEL_MAX_UART; i++) { + if (at91_uarts[i]) + platform_device_register(at91_uarts[i]); + } + + if (!atmel_default_console_device) + printk(KERN_INFO "AT91: No default serial console defined.\n"); +} + +struct platform_device * __init get_at91_uart_device_ptr(int i) +{ + struct platform_device *pdev; + if (i < 0 || i >= ATMEL_MAX_UART) + return 0; + + pdev = &uart[i].devices; + pdev->name = "atmel_usart"; + pdev->id = i; + pdev->dev.dma_mask = &uart[i].dmamask; + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); + pdev->dev.platform_data = &uart[i].data; + pdev->resource = uart[i].resources; + pdev->num_resources = ARRAY_SIZE(uart[i].resources); + + return pdev; +} + +static void __init at91_register_uart(int device_number, unsigned port_number, + void (*configure_usart_pins)(void), const char *clock_name) +{ + struct platform_device *pdev; + + if (port_number < 0) + return; + + if (port_number < ATMEL_MAX_UART) { + pdev = get_at91_uart_device_ptr(device_number); + (configure_usart_pins)(); + pdev->id = port_number; + at91_clock_associate(clock_name, &pdev->dev, "usart"); + at91_uarts[port_number] = pdev; + } +} + +void __init at91_init_uarts(void) +{ + int i; + + for (i = 0; i < ATMEL_MAX_UART; i++) { + at91_uarts[i] = 0; + + uart[i].resources[0].start = usart_base_addr[i]; + uart[i].resources[0].end = usart_base_addr[i]; + uart[i].resources[0].flags = IORESOURCE_MEM; + + uart[i].resources[1].start = usart_id_addr[i]; + uart[i].resources[1].end = usart_id_addr[i]; + uart[i].resources[1].flags = IORESOURCE_IRQ; + + uart[i].dmamask = DMA_BIT_MASK(32); + + if (i == 0) { + uart[i].resources[0].end += SZ_512 - 1; + + /* DBGU not capable of receive DMA */ + uart[i].data.use_dma_tx = 0; + uart[i].data.use_dma_rx = 0; + uart[i].data.regs = + (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU); + } else { + uart[i].resources[0].end += SZ_16K - 1; + + uart[i].data.use_dma_tx = 1; + uart[i].data.use_dma_rx = 1; + } + } + + if (ATMEL_MAX_UART > 0) + at91_register_uart(0, CONFIG_AT91_DBGU_DEV_NR, + configure_dbgu_pins, "mck"); + if (ATMEL_MAX_UART > 1) + at91_register_uart(1, CONFIG_AT91_USART0_DEV_NR, + configure_usart0_pins, "usart0_clk"); + if (ATMEL_MAX_UART > 2) + at91_register_uart(2, CONFIG_AT91_USART1_DEV_NR, + configure_usart1_pins, "usart1_clk"); + if (ATMEL_MAX_UART > 3) + at91_register_uart(3, CONFIG_AT91_USART2_DEV_NR, + configure_usart2_pins, "usart2_clk"); + if (ATMEL_MAX_UART > 4) + at91_register_uart(4, CONFIG_AT91_USART3_DEV_NR, + configure_usart3_pins, "usart3_clk"); + if (ATMEL_MAX_UART > 5) + at91_register_uart(5, CONFIG_AT91_USART4_DEV_NR, + configure_usart4_pins, "usart4_clk"); + if (ATMEL_MAX_UART > 6) + at91_register_uart(6, CONFIG_AT91_USART5_DEV_NR, + configure_usart5_pins, "usart5_clk"); + + if (CONFIG_AT91_DBGU_DEV_NR < ATMEL_MAX_UART) + atmel_default_console_device = at91_uarts[0]; +} diff --git a/arch/arm/mach-at91/uart.h b/arch/arm/mach-at91/uart.h new file mode 100644 index 00000000000..48c4cb266d7 --- /dev/null +++ b/arch/arm/mach-at91/uart.h @@ -0,0 +1,55 @@ +/* + * linux/arch/arm/mach-at91/uart.c + * + * Copyright (C) 2008 Pieter du Preez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +/* + * As we the following defines are checked by the compiler, + * we need to assign some dummy values to them, as they may + * not be defined by Kconfig. + */ + +#ifndef CONFIG_AT91_DBGU_DEV_NR +#define CONFIG_AT91_DBGU_DEV_NR -1 +#endif + +#ifndef CONFIG_AT91_USART0_DEV_NR +#define CONFIG_AT91_USART0_DEV_NR -1 +#endif + +#ifndef CONFIG_AT91_USART1_DEV_NR +#define CONFIG_AT91_USART1_DEV_NR -1 +#endif + +#ifndef CONFIG_AT91_USART2_DEV_NR +#define CONFIG_AT91_USART2_DEV_NR -1 +#endif + +#ifndef CONFIG_AT91_USART3_DEV_NR +#define CONFIG_AT91_USART3_DEV_NR -1 +#endif + +#ifndef CONFIG_AT91_USART4_DEV_NR +#define CONFIG_AT91_USART4_DEV_NR -1 +#endif + +#ifndef CONFIG_AT91_USART5_DEV_NR +#define CONFIG_AT91_USART5_DEV_NR -1 +#endif -- 2.11.4.GIT