aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial
diff options
context:
space:
mode:
authorAnton Vorontsov <cbouatmailru@gmail.com>2010-10-01 09:21:42 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-10-22 13:20:07 -0400
commit6b5756f176568a710d008d3b478128fafb6707f0 (patch)
tree4293e5e28ad656366a478d79f6e0d157ceb5c3f6 /drivers/serial
parent2f8b9c15cd88ce22bd80e6eb3988dbaa49f1efd3 (diff)
altera_uart: Add support for getting mapbase and IRQ from resources
This makes it much easier to integrate the driver with the rest of the Linux (e.g. MFD subsystem). The old method is still supported though. Also, from now on, there is one platform device per port (no changes are needed for the platform code, as no one registers the devices anywhere in-tree yet). Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com> Acked-by: Tobias Klauser <tklauser@distanz.ch> Cc: Alan Cox <alan@linux.intel.com>, Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/altera_uart.c60
1 files changed, 38 insertions, 22 deletions
diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c
index 7dd58da0ddf5..1dfeffae5231 100644
--- a/drivers/serial/altera_uart.c
+++ b/drivers/serial/altera_uart.c
@@ -498,38 +498,54 @@ static int __devinit altera_uart_probe(struct platform_device *pdev)
498{ 498{
499 struct altera_uart_platform_uart *platp = pdev->dev.platform_data; 499 struct altera_uart_platform_uart *platp = pdev->dev.platform_data;
500 struct uart_port *port; 500 struct uart_port *port;
501 int i; 501 struct resource *res_mem;
502 struct resource *res_irq;
503 int i = pdev->id;
502 504
503 for (i = 0; i < CONFIG_SERIAL_ALTERA_UART_MAXPORTS && platp[i].mapbase; i++) { 505 /* -1 emphasizes that the platform must have one port, no .N suffix */
504 port = &altera_uart_ports[i].port; 506 if (i == -1)
507 i = 0;
505 508
506 port->line = i; 509 if (i >= CONFIG_SERIAL_ALTERA_UART_MAXPORTS)
507 port->type = PORT_ALTERA_UART; 510 return -EINVAL;
508 port->mapbase = platp[i].mapbase;
509 port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE);
510 port->iotype = SERIAL_IO_MEM;
511 port->irq = platp[i].irq;
512 port->uartclk = platp[i].uartclk;
513 port->ops = &altera_uart_ops;
514 port->flags = ASYNC_BOOT_AUTOCONF;
515 511
516 uart_add_one_port(&altera_uart_driver, port); 512 port = &altera_uart_ports[i].port;
517 } 513
514 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
515 if (res_mem)
516 port->mapbase = res_mem->start;
517 else if (platp->mapbase)
518 port->mapbase = platp->mapbase;
519 else
520 return -EINVAL;
521
522 res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
523 if (res_irq)
524 port->irq = res_irq->start;
525 else if (platp->irq)
526 port->irq = platp->irq;
527
528 port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE);
529 if (!port->membase)
530 return -ENOMEM;
531
532 port->line = i;
533 port->type = PORT_ALTERA_UART;
534 port->iotype = SERIAL_IO_MEM;
535 port->uartclk = platp->uartclk;
536 port->ops = &altera_uart_ops;
537 port->flags = ASYNC_BOOT_AUTOCONF;
538
539 uart_add_one_port(&altera_uart_driver, port);
518 540
519 return 0; 541 return 0;
520} 542}
521 543
522static int __devexit altera_uart_remove(struct platform_device *pdev) 544static int __devexit altera_uart_remove(struct platform_device *pdev)
523{ 545{
524 struct uart_port *port; 546 struct uart_port *port = &altera_uart_ports[pdev->id].port;
525 int i;
526
527 for (i = 0; i < CONFIG_SERIAL_ALTERA_UART_MAXPORTS; i++) {
528 port = &altera_uart_ports[i].port;
529 if (port)
530 uart_remove_one_port(&altera_uart_driver, port);
531 }
532 547
548 uart_remove_one_port(&altera_uart_driver, port);
533 return 0; 549 return 0;
534} 550}
535 551