aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/altera_uart.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/serial/altera_uart.c')
-rw-r--r--drivers/tty/serial/altera_uart.c69
1 files changed, 35 insertions, 34 deletions
diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c
index 684a0808e1c..50bc5a5ac65 100644
--- a/drivers/tty/serial/altera_uart.c
+++ b/drivers/tty/serial/altera_uart.c
@@ -315,7 +315,7 @@ static int altera_uart_startup(struct uart_port *port)
315 return 0; 315 return 0;
316 } 316 }
317 317
318 ret = request_irq(port->irq, altera_uart_interrupt, 0, 318 ret = request_irq(port->irq, altera_uart_interrupt, IRQF_DISABLED,
319 DRV_NAME, port); 319 DRV_NAME, port);
320 if (ret) { 320 if (ret) {
321 pr_err(DRV_NAME ": unable to attach Altera UART %d " 321 pr_err(DRV_NAME ": unable to attach Altera UART %d "
@@ -377,26 +377,6 @@ static int altera_uart_verify_port(struct uart_port *port,
377 return 0; 377 return 0;
378} 378}
379 379
380#ifdef CONFIG_CONSOLE_POLL
381static int altera_uart_poll_get_char(struct uart_port *port)
382{
383 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) &
384 ALTERA_UART_STATUS_RRDY_MSK))
385 cpu_relax();
386
387 return altera_uart_readl(port, ALTERA_UART_RXDATA_REG);
388}
389
390static void altera_uart_poll_put_char(struct uart_port *port, unsigned char c)
391{
392 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) &
393 ALTERA_UART_STATUS_TRDY_MSK))
394 cpu_relax();
395
396 altera_uart_writel(port, c, ALTERA_UART_TXDATA_REG);
397}
398#endif
399
400/* 380/*
401 * Define the basic serial functions we support. 381 * Define the basic serial functions we support.
402 */ 382 */
@@ -417,16 +397,35 @@ static struct uart_ops altera_uart_ops = {
417 .release_port = altera_uart_release_port, 397 .release_port = altera_uart_release_port,
418 .config_port = altera_uart_config_port, 398 .config_port = altera_uart_config_port,
419 .verify_port = altera_uart_verify_port, 399 .verify_port = altera_uart_verify_port,
420#ifdef CONFIG_CONSOLE_POLL
421 .poll_get_char = altera_uart_poll_get_char,
422 .poll_put_char = altera_uart_poll_put_char,
423#endif
424}; 400};
425 401
426static struct altera_uart altera_uart_ports[CONFIG_SERIAL_ALTERA_UART_MAXPORTS]; 402static struct altera_uart altera_uart_ports[CONFIG_SERIAL_ALTERA_UART_MAXPORTS];
427 403
428#if defined(CONFIG_SERIAL_ALTERA_UART_CONSOLE) 404#if defined(CONFIG_SERIAL_ALTERA_UART_CONSOLE)
429 405
406int __init early_altera_uart_setup(struct altera_uart_platform_uart *platp)
407{
408 struct uart_port *port;
409 int i;
410
411 for (i = 0; i < CONFIG_SERIAL_ALTERA_UART_MAXPORTS && platp[i].mapbase; i++) {
412 port = &altera_uart_ports[i].port;
413
414 port->line = i;
415 port->type = PORT_ALTERA_UART;
416 port->mapbase = platp[i].mapbase;
417 port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE);
418 port->iotype = SERIAL_IO_MEM;
419 port->irq = platp[i].irq;
420 port->uartclk = platp[i].uartclk;
421 port->flags = UPF_BOOT_AUTOCONF;
422 port->ops = &altera_uart_ops;
423 port->private_data = platp;
424 }
425
426 return 0;
427}
428
430static void altera_uart_console_putc(struct uart_port *port, const char c) 429static void altera_uart_console_putc(struct uart_port *port, const char c)
431{ 430{
432 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & 431 while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) &
@@ -532,7 +531,7 @@ static int altera_uart_get_of_uartclk(struct platform_device *pdev,
532} 531}
533#endif /* CONFIG_OF */ 532#endif /* CONFIG_OF */
534 533
535static int altera_uart_probe(struct platform_device *pdev) 534static int __devinit altera_uart_probe(struct platform_device *pdev)
536{ 535{
537 struct altera_uart_platform_uart *platp = pdev->dev.platform_data; 536 struct altera_uart_platform_uart *platp = pdev->dev.platform_data;
538 struct uart_port *port; 537 struct uart_port *port;
@@ -556,7 +555,7 @@ static int altera_uart_probe(struct platform_device *pdev)
556 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 555 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
557 if (res_mem) 556 if (res_mem)
558 port->mapbase = res_mem->start; 557 port->mapbase = res_mem->start;
559 else if (platp) 558 else if (platp->mapbase)
560 port->mapbase = platp->mapbase; 559 port->mapbase = platp->mapbase;
561 else 560 else
562 return -EINVAL; 561 return -EINVAL;
@@ -564,7 +563,7 @@ static int altera_uart_probe(struct platform_device *pdev)
564 res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 563 res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
565 if (res_irq) 564 if (res_irq)
566 port->irq = res_irq->start; 565 port->irq = res_irq->start;
567 else if (platp) 566 else if (platp->irq)
568 port->irq = platp->irq; 567 port->irq = platp->irq;
569 568
570 /* Check platform data first so we can override device node data */ 569 /* Check platform data first so we can override device node data */
@@ -591,20 +590,20 @@ static int altera_uart_probe(struct platform_device *pdev)
591 port->ops = &altera_uart_ops; 590 port->ops = &altera_uart_ops;
592 port->flags = UPF_BOOT_AUTOCONF; 591 port->flags = UPF_BOOT_AUTOCONF;
593 592
594 platform_set_drvdata(pdev, port); 593 dev_set_drvdata(&pdev->dev, port);
595 594
596 uart_add_one_port(&altera_uart_driver, port); 595 uart_add_one_port(&altera_uart_driver, port);
597 596
598 return 0; 597 return 0;
599} 598}
600 599
601static int altera_uart_remove(struct platform_device *pdev) 600static int __devexit altera_uart_remove(struct platform_device *pdev)
602{ 601{
603 struct uart_port *port = platform_get_drvdata(pdev); 602 struct uart_port *port = dev_get_drvdata(&pdev->dev);
604 603
605 if (port) { 604 if (port) {
606 uart_remove_one_port(&altera_uart_driver, port); 605 uart_remove_one_port(&altera_uart_driver, port);
607 platform_set_drvdata(pdev, NULL); 606 dev_set_drvdata(&pdev->dev, NULL);
608 port->mapbase = 0; 607 port->mapbase = 0;
609 } 608 }
610 609
@@ -617,15 +616,17 @@ static struct of_device_id altera_uart_match[] = {
617 {}, 616 {},
618}; 617};
619MODULE_DEVICE_TABLE(of, altera_uart_match); 618MODULE_DEVICE_TABLE(of, altera_uart_match);
619#else
620#define altera_uart_match NULL
620#endif /* CONFIG_OF */ 621#endif /* CONFIG_OF */
621 622
622static struct platform_driver altera_uart_platform_driver = { 623static struct platform_driver altera_uart_platform_driver = {
623 .probe = altera_uart_probe, 624 .probe = altera_uart_probe,
624 .remove = altera_uart_remove, 625 .remove = __devexit_p(altera_uart_remove),
625 .driver = { 626 .driver = {
626 .name = DRV_NAME, 627 .name = DRV_NAME,
627 .owner = THIS_MODULE, 628 .owner = THIS_MODULE,
628 .of_match_table = of_match_ptr(altera_uart_match), 629 .of_match_table = altera_uart_match,
629 }, 630 },
630}; 631};
631 632