aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/pxa.c
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2007-08-20 04:47:41 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2007-10-12 16:14:49 -0400
commite259a3aecbfb61981175ddc7fc02dd180da7d73e (patch)
treefb265b5c377f2e82b3cf8d3b0805ff9ba17df891 /drivers/serial/pxa.c
parent08197f6e3b262f4fb8b164c818d5e54b46c14711 (diff)
[ARM] pxa: convert PXA serial drivers to use platform resources
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/serial/pxa.c')
-rw-r--r--drivers/serial/pxa.c139
1 files changed, 61 insertions, 78 deletions
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index e9c6cb391a23..59889f6a86b2 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -582,7 +582,7 @@ serial_pxa_type(struct uart_port *port)
582 582
583#ifdef CONFIG_SERIAL_PXA_CONSOLE 583#ifdef CONFIG_SERIAL_PXA_CONSOLE
584 584
585static struct uart_pxa_port serial_pxa_ports[]; 585static struct uart_pxa_port *serial_pxa_ports[4];
586static struct uart_driver serial_pxa_reg; 586static struct uart_driver serial_pxa_reg;
587 587
588#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 588#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
@@ -632,7 +632,7 @@ static void serial_pxa_console_putchar(struct uart_port *port, int ch)
632static void 632static void
633serial_pxa_console_write(struct console *co, const char *s, unsigned int count) 633serial_pxa_console_write(struct console *co, const char *s, unsigned int count)
634{ 634{
635 struct uart_pxa_port *up = &serial_pxa_ports[co->index]; 635 struct uart_pxa_port *up = serial_pxa_ports[co->index];
636 unsigned int ier; 636 unsigned int ier;
637 637
638 /* 638 /*
@@ -662,7 +662,9 @@ serial_pxa_console_setup(struct console *co, char *options)
662 662
663 if (co->index == -1 || co->index >= serial_pxa_reg.nr) 663 if (co->index == -1 || co->index >= serial_pxa_reg.nr)
664 co->index = 0; 664 co->index = 0;
665 up = &serial_pxa_ports[co->index]; 665 up = serial_pxa_ports[co->index];
666 if (!up)
667 return -ENODEV;
666 668
667 if (options) 669 if (options)
668 uart_parse_options(options, &baud, &parity, &bits, &flow); 670 uart_parse_options(options, &baud, &parity, &bits, &flow);
@@ -680,15 +682,6 @@ static struct console serial_pxa_console = {
680 .data = &serial_pxa_reg, 682 .data = &serial_pxa_reg,
681}; 683};
682 684
683static int __init
684serial_pxa_console_init(void)
685{
686 register_console(&serial_pxa_console);
687 return 0;
688}
689
690console_initcall(serial_pxa_console_init);
691
692#define PXA_CONSOLE &serial_pxa_console 685#define PXA_CONSOLE &serial_pxa_console
693#else 686#else
694#define PXA_CONSOLE NULL 687#define PXA_CONSOLE NULL
@@ -714,73 +707,13 @@ struct uart_ops serial_pxa_pops = {
714 .verify_port = serial_pxa_verify_port, 707 .verify_port = serial_pxa_verify_port,
715}; 708};
716 709
717static struct uart_pxa_port serial_pxa_ports[] = {
718 { /* FFUART */
719 .name = "FFUART",
720 .cken = CKEN_FFUART,
721 .port = {
722 .type = PORT_PXA,
723 .iotype = UPIO_MEM,
724 .membase = (void *)&FFUART,
725 .mapbase = __PREG(FFUART),
726 .irq = IRQ_FFUART,
727 .uartclk = 921600 * 16,
728 .fifosize = 64,
729 .ops = &serial_pxa_pops,
730 .line = 0,
731 },
732 }, { /* BTUART */
733 .name = "BTUART",
734 .cken = CKEN_BTUART,
735 .port = {
736 .type = PORT_PXA,
737 .iotype = UPIO_MEM,
738 .membase = (void *)&BTUART,
739 .mapbase = __PREG(BTUART),
740 .irq = IRQ_BTUART,
741 .uartclk = 921600 * 16,
742 .fifosize = 64,
743 .ops = &serial_pxa_pops,
744 .line = 1,
745 },
746 }, { /* STUART */
747 .name = "STUART",
748 .cken = CKEN_STUART,
749 .port = {
750 .type = PORT_PXA,
751 .iotype = UPIO_MEM,
752 .membase = (void *)&STUART,
753 .mapbase = __PREG(STUART),
754 .irq = IRQ_STUART,
755 .uartclk = 921600 * 16,
756 .fifosize = 64,
757 .ops = &serial_pxa_pops,
758 .line = 2,
759 },
760 }, { /* HWUART */
761 .name = "HWUART",
762 .cken = CKEN_HWUART,
763 .port = {
764 .type = PORT_PXA,
765 .iotype = UPIO_MEM,
766 .membase = (void *)&HWUART,
767 .mapbase = __PREG(HWUART),
768 .irq = IRQ_HWUART,
769 .uartclk = 921600 * 16,
770 .fifosize = 64,
771 .ops = &serial_pxa_pops,
772 .line = 3,
773 },
774 }
775};
776
777static struct uart_driver serial_pxa_reg = { 710static struct uart_driver serial_pxa_reg = {
778 .owner = THIS_MODULE, 711 .owner = THIS_MODULE,
779 .driver_name = "PXA serial", 712 .driver_name = "PXA serial",
780 .dev_name = "ttyS", 713 .dev_name = "ttyS",
781 .major = TTY_MAJOR, 714 .major = TTY_MAJOR,
782 .minor = 64, 715 .minor = 64,
783 .nr = ARRAY_SIZE(serial_pxa_ports), 716 .nr = 4,
784 .cons = PXA_CONSOLE, 717 .cons = PXA_CONSOLE,
785}; 718};
786 719
@@ -806,10 +739,60 @@ static int serial_pxa_resume(struct platform_device *dev)
806 739
807static int serial_pxa_probe(struct platform_device *dev) 740static int serial_pxa_probe(struct platform_device *dev)
808{ 741{
809 serial_pxa_ports[dev->id].port.dev = &dev->dev; 742 struct uart_pxa_port *sport;
810 uart_add_one_port(&serial_pxa_reg, &serial_pxa_ports[dev->id].port); 743 struct resource *mmres, *irqres;
811 platform_set_drvdata(dev, &serial_pxa_ports[dev->id]); 744 int ret;
745
746 mmres = platform_get_resource(dev, IORESOURCE_MEM, 0);
747 irqres = platform_get_resource(dev, IORESOURCE_IRQ, 0);
748 if (!mmres || !irqres)
749 return -ENODEV;
750
751 sport = kzalloc(sizeof(struct uart_pxa_port), GFP_KERNEL);
752 if (!sport)
753 return -ENOMEM;
754
755 sport->port.type = PORT_PXA;
756 sport->port.iotype = UPIO_MEM;
757 sport->port.mapbase = mmres->start;
758 sport->port.irq = irqres->start;
759 sport->port.fifosize = 64;
760 sport->port.ops = &serial_pxa_pops;
761 sport->port.line = dev->id;
762 sport->port.dev = &dev->dev;
763 sport->port.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF;
764 sport->port.uartclk = 921600 * 16;
765
766 /*
767 * Is it worth keeping this?
768 */
769 if (mmres->start == __PREG(FFUART))
770 sport->name = "FFUART";
771 else if (mmres->start == __PREG(BTUART))
772 sport->name = "BTUART";
773 else if (mmres->start == __PREG(STUART))
774 sport->name = "STUART";
775 else if (mmres->start == __PREG(HWUART))
776 sport->name = "HWUART";
777 else
778 sport->name = "???";
779
780 sport->port.membase = ioremap(mmres->start, mmres->end - mmres->start + 1);
781 if (!sport->port.membase) {
782 ret = -ENOMEM;
783 goto err_free;
784 }
785
786 serial_pxa_ports[dev->id] = sport;
787
788 uart_add_one_port(&serial_pxa_reg, &sport->port);
789 platform_set_drvdata(dev, sport);
790
812 return 0; 791 return 0;
792
793 err_free:
794 kfree(sport);
795 return ret;
813} 796}
814 797
815static int serial_pxa_remove(struct platform_device *dev) 798static int serial_pxa_remove(struct platform_device *dev)
@@ -818,8 +801,8 @@ static int serial_pxa_remove(struct platform_device *dev)
818 801
819 platform_set_drvdata(dev, NULL); 802 platform_set_drvdata(dev, NULL);
820 803
821 if (sport) 804 uart_remove_one_port(&serial_pxa_reg, &sport->port);
822 uart_remove_one_port(&serial_pxa_reg, &sport->port); 805 kfree(sport);
823 806
824 return 0; 807 return 0;
825} 808}