Commit c4497f16 authored by Imre Deak's avatar Imre Deak Committed by Tony Lindgren

[PATCH] ARM: OMAP: Fix problem UART index != UART line, clean up serial init

This fixes the problem where UART index != UART line, because some of
the UARTs are disabled. Also cleans up serial init.
parent c9c7de1d
......@@ -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)
......
......@@ -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")
......
......@@ -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")
......
......@@ -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")
......
......@@ -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
......
......@@ -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")
......
......@@ -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")
......
......@@ -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
......
......@@ -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;
......
......@@ -31,40 +31,24 @@
#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)
......
......@@ -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)
......
......@@ -16,8 +16,12 @@
#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;
......
......@@ -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);
......@@ -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 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment