@@ -97,6 +97,13 @@ struct omap_uart_state {
#endif
};
+struct uart_oh {
+ struct list_head node;
+ struct omap_hwmod *oh;
+ int uart_num;
+};
+
+static LIST_HEAD(uart_oh_list);
static LIST_HEAD(uart_list);
static u8 num_uarts;
@@ -593,39 +600,32 @@ static void serial_out_override(struct uart_port *up, int offset, int value)
void __init omap_serial_early_init(void)
{
- int i = 0;
+ struct omap_hwmod *oh;
+ struct uart_oh *uoh;
+ char oh_name[MAX_UART_HWMOD_NAME_LEN];
do {
- char oh_name[MAX_UART_HWMOD_NAME_LEN];
- struct omap_hwmod *oh;
- struct omap_uart_state *uart;
+ uoh = kzalloc(sizeof(struct uart_oh), GFP_KERNEL);
+ if (WARN_ON(!uoh))
+ return;
snprintf(oh_name, MAX_UART_HWMOD_NAME_LEN,
- "uart%d", i + 1);
+ "uart%d", num_uarts + 1);
oh = omap_hwmod_lookup(oh_name);
if (!oh)
break;
-
- uart = kzalloc(sizeof(struct omap_uart_state), GFP_KERNEL);
- if (WARN_ON(!uart))
- return;
-
- uart->oh = oh;
- uart->num = i++;
- list_add_tail(&uart->node, &uart_list);
- num_uarts++;
-
/*
* NOTE: omap_hwmod_init() has not yet been called,
- * so no hwmod functions will work yet.
- */
-
- /*
+ * so no hwmod functions will work yet.
* During UART early init, device need to be probed
* to determine SoC specific init before omap_device
- * is ready. Therefore, don't allow idle here
+ * is ready. Therefore, don't allow idle here
*/
- uart->oh->flags |= HWMOD_INIT_NO_IDLE;
+ oh->flags |= HWMOD_INIT_NO_IDLE;
+ uoh->oh = oh;
+ uoh->uart_num = num_uarts;
+ list_add_tail(&uoh->node, &uart_oh_list);
+ num_uarts++;
} while (1);
}
@@ -645,6 +645,7 @@ void __init omap_serial_init_port(int port)
struct omap_uart_state *uart;
struct omap_hwmod *oh;
struct omap_device *od;
+ struct uart_oh *uoh;
void *pdata = NULL;
u32 pdata_size = 0;
char *name;
@@ -663,6 +664,17 @@ void __init omap_serial_init_port(int port)
if (WARN_ON(port >= num_uarts))
return;
+ uart = kzalloc(sizeof(struct omap_uart_state), GFP_KERNEL);
+ if (WARN_ON(!uart))
+ return;
+
+ uart->num = port;
+ list_add_tail(&uart->node, &uart_list);
+ list_for_each_entry(uoh, &uart_oh_list, node)
+ if (port == uoh->uart_num)
+ break;
+
+ uart->oh = uoh->oh;
list_for_each_entry(uart, &uart_list, node)
if (port == uart->num)
break;
@@ -781,8 +793,8 @@ void __init omap_serial_init_port(int port)
*/
void __init omap_serial_init(void)
{
- struct omap_uart_state *uart;
+ struct uart_oh *uoh;
- list_for_each_entry(uart, &uart_list, node)
- omap_serial_init_port(uart->num);
+ list_for_each_entry(uoh, &uart_oh_list, node)
+ omap_serial_init_port(uoh->uart_num);
}