[ARM] 4660/3: at91: allow selecting UART for early kernel messages
authorGuennadi Liakhovetski <lg@denx.de>
Tue, 29 Jan 2008 14:43:13 +0000 (15:43 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 4 Feb 2008 13:16:39 +0000 (13:16 +0000)
Currently early kernel messages, i.e., those from uncompression, go to the
debugging UART. And if it is enabled in the platform configuration, but
not initialized by the bootloader, the machine hangs, waiting for UART
status change. Besides, having those messages on another UART - typically
the console UART - may be preferrable. This patch allows selecting the
UART in kernel configuration.

Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
Acked-by: Andrew Victor <linux@maxim.org.za>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-at91/Kconfig
drivers/serial/atmel_serial.c
include/asm-arm/arch-at91/at91rm9200.h
include/asm-arm/arch-at91/at91sam9260.h
include/asm-arm/arch-at91/at91sam9261.h
include/asm-arm/arch-at91/at91sam9263.h
include/asm-arm/arch-at91/at91sam9rl.h
include/asm-arm/arch-at91/uncompress.h
include/linux/atmel_serial.h [moved from drivers/serial/atmel_serial.h with 99% similarity]

index 5b0422cdde76e7504010d8b4a8971ef3d0ca7455..074dcd5d9a7ef185d4f81d80538f5744fa440e89 100644 (file)
@@ -253,6 +253,36 @@ 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.
 
+choice
+       prompt "Select a UART for early kernel messages"
+
+config AT91_EARLY_DBGU
+       bool "DBGU"
+
+config AT91_EARLY_USART0
+       bool "USART0"
+
+config AT91_EARLY_USART1
+       bool "USART1"
+
+config AT91_EARLY_USART2
+       bool "USART2"
+       depends on ! ARCH_AT91X40
+
+config AT91_EARLY_USART3
+       bool "USART3"
+       depends on (ARCH_AT91RM9200 || ARCH_AT91SAM9RL || ARCH_AT91SAM9260)
+
+config AT91_EARLY_USART4
+       bool "USART4"
+       depends on ARCH_AT91SAM9260
+
+config AT91_EARLY_USART5
+       bool "USART5"
+       depends on ARCH_AT91SAM9260
+
+endchoice
+
 endmenu
 
 endif
index 111da57f533414671f9a924456ebcf1d08b32553..60f52904aad0fc4bfe7142d348c35a434dac1731 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/tty_flip.h>
 #include <linux/platform_device.h>
 #include <linux/atmel_pdc.h>
+#include <linux/atmel_serial.h>
 
 #include <asm/io.h>
 
@@ -45,8 +46,6 @@
 #include <asm/arch/gpio.h>
 #endif
 
-#include "atmel_serial.h"
-
 #if defined(CONFIG_SERIAL_ATMEL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
 #define SUPPORT_SYSRQ
 #endif
index 802891a9cd81d76089c980ae1ea02df5fa969e3f..e8fc0b1c33f4423647a60db76fac50f85b7f49d2 100644 (file)
 #define AT91_RTC       (0xfffffe00 - AT91_BASE_SYS)    /* Real-Time Clock */
 #define AT91_MC                (0xffffff00 - AT91_BASE_SYS)    /* Memory Controllers */
 
+#define AT91_USART0    AT91RM9200_BASE_US0
+#define AT91_USART1    AT91RM9200_BASE_US1
+#define AT91_USART2    AT91RM9200_BASE_US2
+#define AT91_USART3    AT91RM9200_BASE_US3
+
 #define AT91_MATRIX    0       /* not supported */
 
 /*
index 0427f8698c07a8e8f43ec675929b1fd907ebb033..c8934fe34dc512ff43b30518f8fe7ba480e86be0 100644 (file)
 #define AT91_WDT       (0xfffffd40 - AT91_BASE_SYS)
 #define AT91_GPBR      (0xfffffd50 - AT91_BASE_SYS)
 
+#define AT91_USART0    AT91SAM9260_BASE_US0
+#define AT91_USART1    AT91SAM9260_BASE_US1
+#define AT91_USART2    AT91SAM9260_BASE_US2
+#define AT91_USART3    AT91SAM9260_BASE_US3
+#define AT91_USART4    AT91SAM9260_BASE_US4
+#define AT91_USART5    AT91SAM9260_BASE_US5
+
 
 /*
  * Internal Memory.
index 9eb4595703307832b8cc2224fcab032f1a45ee08..c7c4778dac49bed468e44eab6a23a32dd468789a 100644 (file)
 #define AT91_WDT       (0xfffffd40 - AT91_BASE_SYS)
 #define AT91_GPBR      (0xfffffd50 - AT91_BASE_SYS)
 
+#define AT91_USART0    AT91SAM9261_BASE_US0
+#define AT91_USART1    AT91SAM9261_BASE_US1
+#define AT91_USART2    AT91SAM9261_BASE_US2
+
 
 /*
  * Internal Memory.
index 115c47ac7ebb0b22b75d00e1ddcfeaf1dee25a21..018a647311da97590a21677931ea21a8899301ea 100644 (file)
 #define AT91_RTT1      (0xfffffd50 - AT91_BASE_SYS)
 #define AT91_GPBR      (0xfffffd60 - AT91_BASE_SYS)
 
+#define AT91_USART0    AT91SAM9263_BASE_US0
+#define AT91_USART1    AT91SAM9263_BASE_US1
+#define AT91_USART2    AT91SAM9263_BASE_US2
+
 #define AT91_SMC       AT91_SMC0
 
 /*
index 8a9708a370c63fddc87b550d628eda108460dc49..16d2832f6c0abf04b2f8091f92d87af2af2cf2e9 100644 (file)
 #define AT91_GPBR      (0xfffffd60 - AT91_BASE_SYS)
 #define AT91_RTC       (0xfffffe00 - AT91_BASE_SYS)
 
+#define AT91_USART0    AT91SAM9RL_BASE_US0
+#define AT91_USART1    AT91SAM9RL_BASE_US1
+#define AT91_USART2    AT91SAM9RL_BASE_US2
+#define AT91_USART3    AT91SAM9RL_BASE_US3
+
 
 /*
  * Internal Memory.
index 272a7e0dc6cf928c11a4328741a03e5302441c8e..f5636a8f6132989de20acf64b6e04fdcbbf3245d 100644 (file)
 #define __ASM_ARCH_UNCOMPRESS_H
 
 #include <asm/io.h>
-#include <asm/arch/at91_dbgu.h>
+#include <linux/atmel_serial.h>
+
+#if defined(CONFIG_AT91_EARLY_DBGU)
+#define UART_OFFSET (AT91_DBGU + AT91_BASE_SYS)
+#elif defined(CONFIG_AT91_EARLY_USART0)
+#define UART_OFFSET AT91_USART0
+#elif defined(CONFIG_AT91_EARLY_USART1)
+#define UART_OFFSET AT91_USART1
+#elif defined(CONFIG_AT91_EARLY_USART2)
+#define UART_OFFSET AT91_USART2
+#elif defined(CONFIG_AT91_EARLY_USART3)
+#define UART_OFFSET AT91_USART3
+#elif defined(CONFIG_AT91_EARLY_USART4)
+#define UART_OFFSET AT91_USART4
+#elif defined(CONFIG_AT91_EARLY_USART5)
+#define UART_OFFSET AT91_USART5
+#endif
 
 /*
  * The following code assumes the serial port has already been
  */
 static void putc(int c)
 {
-#ifdef AT91_DBGU
-       void __iomem *sys = (void __iomem *) AT91_BASE_SYS;     /* physical address */
+#ifdef UART_OFFSET
+       void __iomem *sys = (void __iomem *) UART_OFFSET;       /* physical address */
 
-       while (!(__raw_readl(sys + AT91_DBGU_SR) & AT91_DBGU_TXRDY))
+       while (!(__raw_readl(sys + ATMEL_US_CSR) & ATMEL_US_TXRDY))
                barrier();
-       __raw_writel(c, sys + AT91_DBGU_THR);
+       __raw_writel(c, sys + ATMEL_US_THR);
 #endif
 }
 
 static inline void flush(void)
 {
-#ifdef AT91_DBGU
-       void __iomem *sys = (void __iomem *) AT91_BASE_SYS;     /* physical address */
+#ifdef UART_OFFSET
+       void __iomem *sys = (void __iomem *) UART_OFFSET;       /* physical address */
 
        /* wait for transmission to complete */
-       while (!(__raw_readl(sys + AT91_DBGU_SR) & AT91_DBGU_TXEMPTY))
+       while (!(__raw_readl(sys + ATMEL_US_CSR) & ATMEL_US_TXEMPTY))
                barrier();
 #endif
 }
similarity index 99%
rename from drivers/serial/atmel_serial.h
rename to include/linux/atmel_serial.h
index e0141776517c4fec9714d0077a8dac21d5f0c851..fd6833764d72b3bf77788741c6e85309b5aa6a72 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * drivers/serial/atmel_serial.h
+ * include/linux/atmel_serial.h
  *
  * Copyright (C) 2005 Ivan Kokshaysky
  * Copyright (C) SAN People