diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2007-10-01 22:16:09 -0400 |
---|---|---|
committer | Josh Boyer <jwboyer@linux.vnet.ibm.com> | 2007-10-03 08:23:16 -0400 |
commit | fb4e6e663b404ecdfac2e3f6e643d204488b28e9 (patch) | |
tree | 3722233130a7d31667949078513631af15989a67 /drivers/serial | |
parent | 852e1ea748e83eba7fdb1cc198f271837b16137b (diff) |
[POWERPC] Uartlite: Let the console be initialized earlier
By configuring it earlier we get console output sooner which is helpful
for debugging when the kernel crashes before the serial drivers are
initialized.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/uartlite.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c index 0904c2a62fc4..2b8404c81164 100644 --- a/drivers/serial/uartlite.c +++ b/drivers/serial/uartlite.c | |||
@@ -373,6 +373,31 @@ static void ulite_console_write(struct console *co, const char *s, | |||
373 | spin_unlock_irqrestore(&port->lock, flags); | 373 | spin_unlock_irqrestore(&port->lock, flags); |
374 | } | 374 | } |
375 | 375 | ||
376 | #if defined(CONFIG_OF) | ||
377 | static inline void __init ulite_console_of_find_device(int id) | ||
378 | { | ||
379 | struct device_node *np; | ||
380 | struct resource res; | ||
381 | const unsigned int *of_id; | ||
382 | int rc; | ||
383 | |||
384 | for_each_compatible_node(np, NULL, "xilinx,uartlite") { | ||
385 | of_id = of_get_property(np, "port-number", NULL); | ||
386 | if ((!of_id) || (*of_id != id)) | ||
387 | continue; | ||
388 | |||
389 | rc = of_address_to_resource(np, 0, &res); | ||
390 | if (rc) | ||
391 | continue; | ||
392 | |||
393 | ulite_ports[id].mapbase = res.start; | ||
394 | return; | ||
395 | } | ||
396 | } | ||
397 | #else /* CONFIG_OF */ | ||
398 | static inline void __init ulite_console_of_find_device(int id) { /* do nothing */ } | ||
399 | #endif /* CONFIG_OF */ | ||
400 | |||
376 | static int __init ulite_console_setup(struct console *co, char *options) | 401 | static int __init ulite_console_setup(struct console *co, char *options) |
377 | { | 402 | { |
378 | struct uart_port *port; | 403 | struct uart_port *port; |
@@ -386,10 +411,20 @@ static int __init ulite_console_setup(struct console *co, char *options) | |||
386 | 411 | ||
387 | port = &ulite_ports[co->index]; | 412 | port = &ulite_ports[co->index]; |
388 | 413 | ||
414 | /* Check if it is an OF device */ | ||
415 | if (!port->mapbase) | ||
416 | ulite_console_of_find_device(co->index); | ||
417 | |||
418 | /* Do we have a device now? */ | ||
419 | if (!port->mapbase) { | ||
420 | pr_debug("console on ttyUL%i not present\n", co->index); | ||
421 | return -ENODEV; | ||
422 | } | ||
423 | |||
389 | /* not initialized yet? */ | 424 | /* not initialized yet? */ |
390 | if (!port->membase) { | 425 | if (!port->membase) { |
391 | pr_debug("console on ttyUL%i not initialized\n", co->index); | 426 | if (ulite_request_port(port)) |
392 | return -ENODEV; | 427 | return -ENODEV; |
393 | } | 428 | } |
394 | 429 | ||
395 | if (options) | 430 | if (options) |
@@ -461,7 +496,7 @@ static int __devinit ulite_assign(struct device *dev, int id, u32 base, int irq) | |||
461 | return -EINVAL; | 496 | return -EINVAL; |
462 | } | 497 | } |
463 | 498 | ||
464 | if (ulite_ports[id].mapbase) { | 499 | if ((ulite_ports[id].mapbase) && (ulite_ports[id].mapbase != base)) { |
465 | dev_err(dev, "cannot assign to %s%i; it is already in use\n", | 500 | dev_err(dev, "cannot assign to %s%i; it is already in use\n", |
466 | ULITE_NAME, id); | 501 | ULITE_NAME, id); |
467 | return -EBUSY; | 502 | return -EBUSY; |