[PATCH] AVR32: Allow renumbering of serial devices
authorHaavard Skinnemoen <hskinnemoen@atmel.com>
Wed, 4 Oct 2006 14:02:10 +0000 (16:02 +0200)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 4 Oct 2006 17:25:06 +0000 (10:25 -0700)
Allow the board to remap actual USART peripheral devices to serial
devices by calling at32_map_usart(hw_id, serial_line). This ensures
that even though ATSTK1002 uses USART1 as the first serial port, it
will still have a ttyS0 device.

This also adds a board-specific early setup hook and moves the
at32_setup_serial_console() call there from the platform code.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/avr32/boards/atstk1000/atstk1002.c
arch/avr32/kernel/setup.c
arch/avr32/mach-at32ap/at32ap.c
arch/avr32/mach-at32ap/at32ap7000.c
include/asm-avr32/arch-at32ap/board.h
include/asm-avr32/arch-at32ap/init.h

index 49164e9aadd64be321ffa37e98c326a5eb940504..cced73c58115f8323d4b19e95451ad76f4038374 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/init.h>
 
 #include <asm/arch/board.h>
+#include <asm/arch/init.h>
 
 struct eth_platform_data __initdata eth0_data = {
        .valid          = 1,
@@ -20,13 +21,22 @@ struct eth_platform_data __initdata eth0_data = {
 
 extern struct lcdc_platform_data atstk1000_fb0_data;
 
+void __init setup_board(void)
+{
+       at32_map_usart(1, 0);   /* /dev/ttyS0 */
+       at32_map_usart(2, 1);   /* /dev/ttyS1 */
+       at32_map_usart(3, 2);   /* /dev/ttyS2 */
+
+       at32_setup_serial_console(0);
+}
+
 static int __init atstk1002_init(void)
 {
        at32_add_system_devices();
 
-       at32_add_device_usart(1);       /* /dev/ttyS0 */
-       at32_add_device_usart(2);       /* /dev/ttyS1 */
-       at32_add_device_usart(3);       /* /dev/ttyS2 */
+       at32_add_device_usart(0);
+       at32_add_device_usart(1);
+       at32_add_device_usart(2);
 
        at32_add_device_eth(0, &eth0_data);
        at32_add_device_spi(0);
index 5d68f3c6990b3d7fb40038f4e51437260051f713..ea2d1ffee4780c14ea6237f21090d1cbfd036f65 100644 (file)
@@ -292,6 +292,7 @@ void __init setup_arch (char **cmdline_p)
 
        setup_processor();
        setup_platform();
+       setup_board();
 
        cpu_clk = clk_get(NULL, "cpu");
        if (IS_ERR(cpu_clk)) {
index f7cedf5aabeaa4a09d192e3301343bca695cd283..90f207e8e96d809c1e14ac3348e90772e1d87826 100644 (file)
@@ -48,9 +48,6 @@ void __init setup_platform(void)
        at32_sm_init();
        at32_clock_init();
        at32_portmux_init();
-
-       /* FIXME: This doesn't belong here */
-       at32_setup_serial_console(1);
 }
 
 static int __init pdc_probe(struct platform_device *pdev)
index 3dd3058750878cf0fedc2895bc0b1442a49b2438..7ff6ad8bab5faa5132871aa869edeec875dd2001 100644 (file)
@@ -591,11 +591,13 @@ static inline void configure_usart3_pins(void)
        portmux_set_func(PIOB, 17, FUNC_B);     /* TXD  */
 }
 
-static struct platform_device *setup_usart(unsigned int id)
+static struct platform_device *at32_usarts[4];
+
+void __init at32_map_usart(unsigned int hw_id, unsigned int line)
 {
        struct platform_device *pdev;
 
-       switch (id) {
+       switch (hw_id) {
        case 0:
                pdev = &atmel_usart0_device;
                configure_usart0_pins();
@@ -613,7 +615,7 @@ static struct platform_device *setup_usart(unsigned int id)
                configure_usart3_pins();
                break;
        default:
-               return NULL;
+               return;
        }
 
        if (PXSEG(pdev->resource[0].start) == P4SEG) {
@@ -622,25 +624,21 @@ static struct platform_device *setup_usart(unsigned int id)
                data->regs = (void __iomem *)pdev->resource[0].start;
        }
 
-       return pdev;
+       pdev->id = line;
+       at32_usarts[line] = pdev;
 }
 
 struct platform_device *__init at32_add_device_usart(unsigned int id)
 {
-       struct platform_device *pdev;
-
-       pdev = setup_usart(id);
-       if (pdev)
-               platform_device_register(pdev);
-
-       return pdev;
+       platform_device_register(at32_usarts[id]);
+       return at32_usarts[id];
 }
 
 struct platform_device *atmel_default_console_device;
 
 void __init at32_setup_serial_console(unsigned int usart_id)
 {
-       atmel_default_console_device = setup_usart(usart_id);
+       atmel_default_console_device = at32_usarts[usart_id];
 }
 
 /* --------------------------------------------------------------------
index 435507281f8958d86527e8a4c269bd65fdb47751..a39b3e999f18dca54774979c4f500b17fe785b3d 100644 (file)
@@ -17,6 +17,7 @@ struct atmel_uart_data {
        short           use_dma_rx;     /* use receive DMA? */
        void __iomem    *regs;          /* virtual base address, if any */
 };
+void at32_map_usart(unsigned int hw_id, unsigned int line);
 struct platform_device *at32_add_device_usart(unsigned int id);
 
 struct eth_platform_data {
index 43722634e0696ae78ee108d62e382244215a042c..5e75d850d7076409ecd6fea47adfb36412736886 100644 (file)
@@ -11,6 +11,7 @@
 #define __ASM_AVR32_AT32AP_INIT_H__
 
 void setup_platform(void);
+void setup_board(void);
 
 /* Called by setup_platform */
 void at32_clock_init(void);