aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/altera_uart.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial/altera_uart.c')
-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