]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] ARM: OMAP: Fix problem UART index != UART line, clean up serial init
authorImre Deak <imre.deak@nokia.com>
Tue, 13 Sep 2005 11:05:35 +0000 (14:05 +0300)
committerTony Lindgren <tony@atomide.com>
Tue, 13 Sep 2005 11:05:35 +0000 (14:05 +0300)
This fixes the problem where UART index != UART line, because some of
the UARTs are disabled. Also cleans up serial init.

14 files changed:
arch/arm/mach-omap1/board-generic.c
arch/arm/mach-omap1/board-h2.c
arch/arm/mach-omap1/board-h3.c
arch/arm/mach-omap1/board-innovator.c
arch/arm/mach-omap1/board-netstar.c
arch/arm/mach-omap1/board-osk.c
arch/arm/mach-omap1/board-perseus2.c
arch/arm/mach-omap1/board-voiceblue.c
arch/arm/mach-omap1/serial.c
arch/arm/mach-omap2/board-generic.c
arch/arm/mach-omap2/board-h4.c
arch/arm/mach-omap2/serial.c
arch/arm/plat-omap/common.c
include/asm-arm/arch-omap/common.h

index c209c7172a9aedf295c725e5ecf79bbb0b8ea02f..04477f12bf87e9c10004a58f9d876cd8e842ffed 100644 (file)
@@ -28,8 +28,6 @@
 #include <asm/arch/board.h>
 #include <asm/arch/common.h>
 
-static int __initdata generic_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
-
 static void __init omap_generic_init_irq(void)
 {
        omap_init_irq();
@@ -76,20 +74,18 @@ static struct omap_mmc_config generic_mmc_config __initdata = {
 
 #endif
 
+static struct omap_uart_config generic_uart_config __initdata = {
+       .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
+};
+
 static struct omap_board_config_kernel generic_config[] = {
        { OMAP_TAG_USB,           NULL },
        { OMAP_TAG_MMC,           &generic_mmc_config },
+       { OMAP_TAG_UART,        &generic_uart_config },
 };
 
 static void __init omap_generic_init(void)
 {
-       const struct omap_uart_config *uart_conf;
-
-       /*
-        * Make sure the serial ports are muxed on at this point.
-        * You have to mux them off in device drivers later on
-        * if not needed.
-        */
 #ifdef CONFIG_ARCH_OMAP1510
        if (cpu_is_omap1510()) {
                generic_config[0].data = &generic1510_usb_config;
@@ -101,20 +97,9 @@ static void __init omap_generic_init(void)
        }
 #endif
 
-       uart_conf = omap_get_config(OMAP_TAG_UART, struct omap_uart_config);
-       if (uart_conf != NULL) {
-               unsigned int enabled_ports, i;
-
-               enabled_ports = uart_conf->enabled_uarts;
-               for (i = 0; i < 3; i++) {
-                       if (!(enabled_ports & (1 << i)))
-                               generic_serial_ports[i] = 0;
-               }
-       }
-
        omap_board_config = generic_config;
        omap_board_config_size = ARRAY_SIZE(generic_config);
-       omap_serial_init(generic_serial_ports);
+       omap_serial_init();
 }
 
 static void __init omap_generic_map_io(void)
index d46a70063b0c61821088ae2c8f483c6a9356454f..e6aba1976c929f8a8122af79674a57c8bf9f6ccc 100644 (file)
@@ -40,8 +40,6 @@
 
 extern int omap_gpio_init(void);
 
-static int __initdata h2_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
-
 static struct mtd_partition h2_partitions[] = {
        /* bootloader (U-Boot, etc) in first sector */
        {
@@ -160,9 +158,14 @@ static struct omap_mmc_config h2_mmc_config __initdata = {
        },
 };
 
+static struct omap_uart_config h2_uart_config __initdata = {
+       .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
+};
+
 static struct omap_board_config_kernel h2_config[] = {
        { OMAP_TAG_USB,           &h2_usb_config },
        { OMAP_TAG_MMC,           &h2_mmc_config },
+       { OMAP_TAG_UART,        &h2_uart_config },
 };
 
 static void __init h2_init(void)
@@ -185,7 +188,7 @@ static void __init h2_init(void)
 static void __init h2_map_io(void)
 {
        omap_map_common_io();
-       omap_serial_init(h2_serial_ports);
+       omap_serial_init();
 }
 
 MACHINE_START(OMAP_H2, "TI-H2")
index 2798613696fa7e0781609bb61132858d25089e27..de73337b2ba0790853472a2331f063e4e0b1f5f4 100644 (file)
@@ -41,8 +41,6 @@
 
 extern int omap_gpio_init(void);
 
-static int __initdata h3_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
-
 static struct mtd_partition h3_partitions[] = {
        /* bootloader (U-Boot, etc) in first sector */
        {
@@ -168,9 +166,14 @@ static struct omap_mmc_config h3_mmc_config __initdata = {
        },
 };
 
+static struct omap_uart_config h3_uart_config __initdata = {
+       .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
+};
+
 static struct omap_board_config_kernel h3_config[] = {
        { OMAP_TAG_USB,  &h3_usb_config },
        { OMAP_TAG_MMC,  &h3_mmc_config },
+       { OMAP_TAG_UART,        &h3_uart_config },
 };
 
 static void __init h3_init(void)
@@ -201,7 +204,7 @@ void h3_init_irq(void)
 static void __init h3_map_io(void)
 {
        omap_map_common_io();
-       omap_serial_init(h3_serial_ports);
+       omap_serial_init();
 }
 
 MACHINE_START(OMAP_H3, "TI OMAP1710 H3 board")
index df0312b596e484a6e79cf5356c767020e8d55c54..f75a4dcdf672c510fdf0b4198a3c73956ad4810b 100644 (file)
@@ -36,8 +36,6 @@
 #include <asm/arch/usb.h>
 #include <asm/arch/common.h>
 
-static int __initdata innovator_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
-
 static struct mtd_partition innovator_partitions[] = {
        /* bootloader (U-Boot, etc) in first sector */
        {
@@ -230,9 +228,14 @@ static struct omap_mmc_config innovator_mmc_config __initdata = {
        },
 };
 
+static struct omap_uart_config innovator_uart_config __initdata = {
+       .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
+};
+
 static struct omap_board_config_kernel innovator_config[] = {
        { OMAP_TAG_USB,         NULL },
        { OMAP_TAG_MMC,         &innovator_mmc_config },
+       { OMAP_TAG_UART,        &innovator_uart_config },
 };
 
 static void __init innovator_init(void)
@@ -276,7 +279,7 @@ static void __init innovator_map_io(void)
                       fpga_read(OMAP1510_FPGA_BOARD_REV));
        }
 #endif
-       omap_serial_init(innovator_serial_ports);
+       omap_serial_init();
 }
 
 MACHINE_START(OMAP_INNOVATOR, "TI-Innovator")
index d904e643f5ec2c30fabf5d8438f5e40cdec82ad1..5e31e6f3a5f08bd3609be660615d6a2d8579b39d 100644 (file)
@@ -55,6 +55,14 @@ static struct platform_device *netstar_devices[] __initdata = {
        &netstar_smc91x_device,
 };
 
+static struct omap_uart_config netstar_uart_config __initdata = {
+       .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
+};
+
+static struct omap_board_config_kernel netstar_config[] = {
+       { OMAP_TAG_UART,        &netstar_uart_config },
+};
+
 static void __init netstar_init_irq(void)
 {
        omap_init_irq();
@@ -92,14 +100,15 @@ static void __init netstar_init(void)
        /* Switch off red LED */
        omap_writeb(0x00, OMAP_LPG1_PMR);       /* Disable clock */
        omap_writeb(0x80, OMAP_LPG1_LCR);
-}
 
-static int __initdata omap_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
+       omap_board_config = netstar_config;
+       omap_board_config_size = ARRAY_SIZE(netstar_config);
+}
 
 static void __init netstar_map_io(void)
 {
        omap_map_common_io();
-       omap_serial_init(omap_serial_ports);
+       omap_serial_init();
 }
 
 #define MACHINE_PANICED                1
index 21103df50415a7007428f04224b54c8c2127b023..2e5c551f50c11ed9bcfbb43b6c25351107e1b0ca 100644 (file)
@@ -46,8 +46,6 @@
 #include <asm/arch/tc.h>
 #include <asm/arch/common.h>
 
-static int __initdata osk_serial_ports[OMAP_MAX_NR_PORTS] = {1, 0, 0};
-
 static struct mtd_partition osk_partitions[] = {
        /* bootloader (U-Boot, etc) in first sector */
        {
@@ -193,8 +191,13 @@ static struct omap_usb_config osk_usb_config __initdata = {
        .pins[0]        = 2,
 };
 
+static struct omap_uart_config osk_uart_config __initdata = {
+       .enabled_uarts = (1 << 0),
+};
+
 static struct omap_board_config_kernel osk_config[] = {
        { OMAP_TAG_USB,           &osk_usb_config },
+       { OMAP_TAG_UART,                &osk_uart_config },
 };
 
 #ifdef CONFIG_OMAP_OSK_MISTRAL
@@ -260,7 +263,7 @@ static void __init osk_init(void)
 static void __init osk_map_io(void)
 {
        omap_map_common_io();
-       omap_serial_init(osk_serial_ports);
+       omap_serial_init();
 }
 
 MACHINE_START(OMAP_OSK, "TI-OSK")
index 107c68c8ab54b796fe7f5271adb11a40c52de760..869990e033f6e5dd138007a2bc5e182e78000219 100644 (file)
@@ -29,6 +29,7 @@
 #include <asm/arch/mux.h>
 #include <asm/arch/fpga.h>
 #include <asm/arch/common.h>
+#include <asm/arch/board.h>
 
 static struct resource smc91x_resources[] = {
        [0] = {
@@ -43,8 +44,6 @@ static struct resource smc91x_resources[] = {
        },
 };
 
-static int __initdata p2_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 0};
-
 static struct mtd_partition p2_partitions[] = {
        /* bootloader (U-Boot, etc) in first sector */
        {
@@ -111,9 +110,20 @@ static struct platform_device *devices[] __initdata = {
        &smc91x_device,
 };
 
+static struct omap_uart_config perseus2_uart_config __initdata = {
+       .enabled_uarts = ((1 << 0) | (1 << 1)),
+};
+
+static struct omap_board_config_kernel perseus2_config[] = {
+       { OMAP_TAG_UART,        &perseus2_uart_config },
+};
+
 static void __init omap_perseus2_init(void)
 {
        (void) platform_add_devices(devices, ARRAY_SIZE(devices));
+
+       omap_board_config = perseus2_config;
+       omap_board_config_size = ARRAY_SIZE(perseus2_config);
 }
 
 static void __init perseus2_init_smc91x(void)
@@ -131,7 +141,6 @@ void omap_perseus2_init_irq(void)
        omap_gpio_init();
        perseus2_init_smc91x();
 }
-
 /* Only FPGA needs to be mapped here. All others are done with ioremap */
 static struct map_desc omap_perseus2_io_desc[] __initdata = {
        {H2P2_DBG_FPGA_BASE, H2P2_DBG_FPGA_START, H2P2_DBG_FPGA_SIZE,
@@ -175,7 +184,7 @@ static void __init omap_perseus2_map_io(void)
         * It is used as the Ethernet controller interrupt
         */
        omap_writel(omap_readl(OMAP730_IO_CONF_9) & 0x1FFFFFFF, OMAP730_IO_CONF_9);
-       omap_serial_init(p2_serial_ports);
+       omap_serial_init();
 }
 
 MACHINE_START(OMAP_PERSEUS2, "OMAP730 Perseus2")
index bf30b1acda0b97a1c9795a0006622c7db6935265..0f693f965b3e1cbdcfd55082368082bab6a67e12 100644 (file)
@@ -150,9 +150,14 @@ static struct omap_mmc_config voiceblue_mmc_config __initdata = {
        },
 };
 
+static struct omap_uart_config voiceblue_uart_config __initdata = {
+       .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
+};
+
 static struct omap_board_config_kernel voiceblue_config[] = {
        { OMAP_TAG_USB, &voiceblue_usb_config },
        { OMAP_TAG_MMC, &voiceblue_mmc_config },
+       { OMAP_TAG_UART,        &voiceblue_uart_config },
 };
 
 static void __init voiceblue_init_irq(void)
@@ -198,12 +203,10 @@ static void __init voiceblue_init(void)
        omap_writeb(0x00, OMAP_LPG1_PMR);       /* Disable clock */
 }
 
-static int __initdata omap_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
-
 static void __init voiceblue_map_io(void)
 {
        omap_map_common_io();
-       omap_serial_init(omap_serial_ports);
+       omap_serial_init();
 }
 
 #define MACHINE_PANICED                1
index 40c4f7c40e73369d6b7f052ca66e966012b99d67..6810cfb84462827c1e90718c359909e3ed2e9d5f 100644 (file)
@@ -109,9 +109,10 @@ static struct platform_device serial_device = {
  * By default UART2 does not work on Innovator-1510 if you have
  * USB OHCI enabled. To use UART2, you must disable USB2 first.
  */
-void __init omap_serial_init(int ports[OMAP_MAX_NR_PORTS])
+void __init omap_serial_init(void)
 {
        int i;
+       const struct omap_uart_config *info;
 
        if (cpu_is_omap730()) {
                serial_platform_data[0].regshift = 0;
@@ -126,10 +127,14 @@ void __init omap_serial_init(int ports[OMAP_MAX_NR_PORTS])
                serial_platform_data[2].uartclk = OMAP1510_BASE_BAUD * 16;
        }
 
+       info = omap_get_config(OMAP_TAG_UART, struct omap_uart_config);
+       if (info == NULL)
+               return;
+
        for (i = 0; i < OMAP_MAX_NR_PORTS; i++) {
                unsigned char reg;
 
-               if (ports[i] == 0) {
+               if (!((1 << i) & info->enabled_uarts)) {
                        serial_platform_data[i].membase = NULL;
                        serial_platform_data[i].mapbase = 0;
                        continue;
index 8b8e9fc8b346a730f1339ea2fd0e5e7cef451c1e..f5d94a8bcd0fec545b37a7e3261956b661ddde80 100644 (file)
 #include <asm/arch/board.h>
 #include <asm/arch/common.h>
 
-static int __initdata generic_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
-
 static void __init omap_generic_init_irq(void)
 {
        omap_init_irq();
 }
 
+static struct omap_uart_config generic_uart_config __initdata = {
+       .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
+};
+
 static struct omap_board_config_kernel generic_config[] = {
+       { OMAP_TAG_UART,        &generic_uart_config },
 };
 
 static void __init omap_generic_init(void)
 {
-       const struct omap_uart_config *uart_conf;
-
-       /*
-        * Make sure the serial ports are muxed on at this point.
-        * You have to mux them off in device drivers later on
-        * if not needed.
-        */
-
-       uart_conf = omap_get_config(OMAP_TAG_UART, struct omap_uart_config);
-       if (uart_conf != NULL) {
-               unsigned int enabled_ports, i;
-
-               enabled_ports = uart_conf->enabled_uarts;
-               for (i = 0; i < 3; i++) {
-                       if (!(enabled_ports & (1 << i)))
-                               generic_serial_ports[i] = 0;
-               }
-       }
-
        omap_board_config = generic_config;
        omap_board_config_size = ARRAY_SIZE(generic_config);
-       omap_serial_init(generic_serial_ports);
+       omap_serial_init();
 }
 
 static void __init omap_generic_map_io(void)
index 8ef23f6a2dcd9d883a75da68f9b922fb3f458206..c58b00f245cd8d24811788aa5c72be32a10987f4 100644 (file)
@@ -34,8 +34,6 @@
 #include <asm/io.h>
 #include <asm/delay.h>
 
-static int __initdata h4_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
-
 static struct resource h4_smc91x_resources[] = {
        [0] = {
                .start  = OMAP24XX_ETHR_START,          /* Physical */
@@ -86,7 +84,12 @@ static void __init omap_h4_init_irq(void)
        h4_init_smc91x();
 }
 
+static struct omap_uart_config h4_uart_config __initdata = {
+       .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
+};
+
 static struct omap_board_config_kernel h4_config[] = {
+       { OMAP_TAG_UART,        &h4_uart_config },
 };
 
 static void __init omap_h4_init(void)
@@ -99,7 +102,7 @@ static void __init omap_h4_init(void)
        platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
        omap_board_config = h4_config;
        omap_board_config_size = ARRAY_SIZE(h4_config);
-       omap_serial_init(h4_serial_ports);
+       omap_serial_init();
 }
 
 static void __init omap_h4_map_io(void)
index e86b41b6c9e62b976ec30179a9c9589d0535692b..4972dee7266d0337ffcb3f725623db6cfb28c98e 100644 (file)
 #include <linux/init.h>
 #include <linux/serial_8250.h>
 #include <linux/serial_reg.h>
+
 #include <asm/io.h>
 
+#include <asm/arch/common.h>
+#include <asm/arch/board.h>
+
 static struct plat_serial8250_port serial_platform_data[] = {
        {
                .membase        = (char *)IO_ADDRESS(OMAP_UART1_BASE),
@@ -75,14 +79,27 @@ static inline void __init omap_serial_reset(struct plat_serial8250_port *p)
        serial_write_reg(p, UART_OMAP_SYSC, 0x01);
 }
 
-void __init omap_serial_init(int ports[OMAP_MAX_NR_PORTS])
+void __init omap_serial_init()
 {
        int i;
+       const struct omap_uart_config *info;
+
+       /*
+        * Make sure the serial ports are muxed on at this point.
+        * You have to mux them off in device drivers later on
+        * if not needed.
+        */
+
+       info = omap_get_config(OMAP_TAG_UART,
+                              struct omap_uart_config);
+
+       if (info == NULL)
+               return;
 
        for (i = 0; i < OMAP_MAX_NR_PORTS; i++) {
                struct plat_serial8250_port *p = serial_platform_data + i;
 
-               if (ports[i] == 0) {
+               if (!(info->enabled_uarts & (1 << i))) {
                        p->membase = 0;
                        p->mapbase = 0;
                        continue;
index 866dc262f00f0b9b768d27dd071e0c55f2d5e9f7..206b22b94a8666ada5c14a6ed97beb989859ec50 100644 (file)
@@ -138,19 +138,43 @@ EXPORT_SYMBOL(omap_get_var_config);
 
 static int __init omap_add_serial_console(void)
 {
-       const struct omap_serial_console_config *info;
-
-       info = omap_get_config(OMAP_TAG_SERIAL_CONSOLE,
-                              struct omap_serial_console_config);
-       if (info != NULL && info->console_uart) {
-               static char speed[11], *opt = NULL;
+       const struct omap_serial_console_config *con_info;
+       const struct omap_uart_config *uart_info;
+       static char speed[11], *opt = NULL;
+       int line, i, uart_idx;
+
+       uart_info = omap_get_config(OMAP_TAG_UART, struct omap_uart_config);
+       con_info = omap_get_config(OMAP_TAG_SERIAL_CONSOLE,
+                                       struct omap_serial_console_config);
+       if (uart_info == NULL || con_info == NULL)
+               return 0;
+
+       if (con_info->console_uart == 0)
+               return 0;
+
+       if (con_info->console_speed) {
+               snprintf(speed, sizeof(speed), "%u", con_info->console_speed);
+               opt = speed;
+       }
 
-               if (info->console_speed) {
-                       snprintf(speed, sizeof(speed), "%u", info->console_speed);
-                       opt = speed;
-               }
-               return add_preferred_console("ttyS", info->console_uart - 1, opt);
+       uart_idx = con_info->console_uart - 1;
+       if (uart_idx >= OMAP_MAX_NR_PORTS) {
+               printk(KERN_INFO "Console: external UART#%d. "
+                       "Not adding it as console this time.\n",
+                       uart_idx + 1);
+               return 0;
+       }
+       if (!(uart_info->enabled_uarts & (1 << uart_idx))) {
+               printk(KERN_ERR "Console: Selected UART#%d is "
+                       "not enabled for this platform\n",
+                       uart_idx + 1);
+               return -1;
+       }
+       line = 0;
+       for (i = 0; i < uart_idx; i++) {
+               if (uart_info->enabled_uarts & (1 << i))
+                       line++;
        }
-       return 0;
+       return add_preferred_console("ttyS", line, opt);
 }
 console_initcall(omap_add_serial_console);
index 2a676b4f13b5dedb4eeb9f227f8fa4120b6e66b8..08d58abd82182a1fdd307f1a7ed94a256f86c35d 100644 (file)
@@ -31,6 +31,6 @@ struct sys_timer;
 
 extern void omap_map_common_io(void);
 extern struct sys_timer omap_timer;
-extern void omap_serial_init(int ports[]);
+extern void omap_serial_init(void);
 
 #endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */