aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/serial.c')
-rw-r--r--arch/arm/mach-omap2/serial.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index b79bc8926cc9..3771254dfa81 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -115,7 +115,6 @@ static struct plat_serial8250_port serial_platform_data2[] = {
115 } 115 }
116}; 116};
117 117
118#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
119static struct plat_serial8250_port serial_platform_data3[] = { 118static struct plat_serial8250_port serial_platform_data3[] = {
120 { 119 {
121 .irq = 70, 120 .irq = 70,
@@ -128,23 +127,12 @@ static struct plat_serial8250_port serial_platform_data3[] = {
128 } 127 }
129}; 128};
130 129
131static inline void omap2_set_globals_uart4(struct omap_globals *omap2_globals)
132{
133 serial_platform_data3[0].mapbase = omap2_globals->uart4_phys;
134}
135#else
136static inline void omap2_set_globals_uart4(struct omap_globals *omap2_globals)
137{
138}
139#endif
140
141void __init omap2_set_globals_uart(struct omap_globals *omap2_globals) 130void __init omap2_set_globals_uart(struct omap_globals *omap2_globals)
142{ 131{
143 serial_platform_data0[0].mapbase = omap2_globals->uart1_phys; 132 serial_platform_data0[0].mapbase = omap2_globals->uart1_phys;
144 serial_platform_data1[0].mapbase = omap2_globals->uart2_phys; 133 serial_platform_data1[0].mapbase = omap2_globals->uart2_phys;
145 serial_platform_data2[0].mapbase = omap2_globals->uart3_phys; 134 serial_platform_data2[0].mapbase = omap2_globals->uart3_phys;
146 if (cpu_is_omap3630() || cpu_is_omap44xx()) 135 serial_platform_data3[0].mapbase = omap2_globals->uart4_phys;
147 omap2_set_globals_uart4(omap2_globals);
148} 136}
149 137
150static inline unsigned int __serial_read_reg(struct uart_port *up, 138static inline unsigned int __serial_read_reg(struct uart_port *up,
@@ -550,7 +538,7 @@ static ssize_t sleep_timeout_store(struct device *dev,
550 unsigned int value; 538 unsigned int value;
551 539
552 if (sscanf(buf, "%u", &value) != 1) { 540 if (sscanf(buf, "%u", &value) != 1) {
553 printk(KERN_ERR "sleep_timeout_store: Invalid value\n"); 541 dev_err(dev, "sleep_timeout_store: Invalid value\n");
554 return -EINVAL; 542 return -EINVAL;
555 } 543 }
556 544
@@ -644,42 +632,53 @@ static void serial_out_override(struct uart_port *up, int offset, int value)
644} 632}
645void __init omap_serial_early_init(void) 633void __init omap_serial_early_init(void)
646{ 634{
647 int i; 635 int i, nr_ports;
648 char name[16]; 636 char name[16];
649 637
638 if (!(cpu_is_omap3630() || cpu_is_omap4430()))
639 nr_ports = 3;
640 else
641 nr_ports = ARRAY_SIZE(omap_uart);
642
650 /* 643 /*
651 * Make sure the serial ports are muxed on at this point. 644 * Make sure the serial ports are muxed on at this point.
652 * You have to mux them off in device drivers later on 645 * You have to mux them off in device drivers later on
653 * if not needed. 646 * if not needed.
654 */ 647 */
655 648
656 for (i = 0; i < ARRAY_SIZE(omap_uart); i++) { 649 for (i = 0; i < nr_ports; i++) {
657 struct omap_uart_state *uart = &omap_uart[i]; 650 struct omap_uart_state *uart = &omap_uart[i];
658 struct platform_device *pdev = &uart->pdev; 651 struct platform_device *pdev = &uart->pdev;
659 struct device *dev = &pdev->dev; 652 struct device *dev = &pdev->dev;
660 struct plat_serial8250_port *p = dev->platform_data; 653 struct plat_serial8250_port *p = dev->platform_data;
661 654
655 /* Don't map zero-based physical address */
656 if (p->mapbase == 0) {
657 dev_warn(dev, "no physical address for uart#%d,"
658 " so skipping early_init...\n", i);
659 continue;
660 }
662 /* 661 /*
663 * Module 4KB + L4 interconnect 4KB 662 * Module 4KB + L4 interconnect 4KB
664 * Static mapping, never released 663 * Static mapping, never released
665 */ 664 */
666 p->membase = ioremap(p->mapbase, SZ_8K); 665 p->membase = ioremap(p->mapbase, SZ_8K);
667 if (!p->membase) { 666 if (!p->membase) {
668 printk(KERN_ERR "ioremap failed for uart%i\n", i + 1); 667 dev_err(dev, "ioremap failed for uart%i\n", i + 1);
669 continue; 668 continue;
670 } 669 }
671 670
672 sprintf(name, "uart%d_ick", i+1); 671 sprintf(name, "uart%d_ick", i + 1);
673 uart->ick = clk_get(NULL, name); 672 uart->ick = clk_get(NULL, name);
674 if (IS_ERR(uart->ick)) { 673 if (IS_ERR(uart->ick)) {
675 printk(KERN_ERR "Could not get uart%d_ick\n", i+1); 674 dev_err(dev, "Could not get uart%d_ick\n", i + 1);
676 uart->ick = NULL; 675 uart->ick = NULL;
677 } 676 }
678 677
679 sprintf(name, "uart%d_fck", i+1); 678 sprintf(name, "uart%d_fck", i+1);
680 uart->fck = clk_get(NULL, name); 679 uart->fck = clk_get(NULL, name);
681 if (IS_ERR(uart->fck)) { 680 if (IS_ERR(uart->fck)) {
682 printk(KERN_ERR "Could not get uart%d_fck\n", i+1); 681 dev_err(dev, "Could not get uart%d_fck\n", i + 1);
683 uart->fck = NULL; 682 uart->fck = NULL;
684 } 683 }
685 684
@@ -722,6 +721,13 @@ void __init omap_serial_init_port(int port)
722 pdev = &uart->pdev; 721 pdev = &uart->pdev;
723 dev = &pdev->dev; 722 dev = &pdev->dev;
724 723
724 /* Don't proceed if there's no clocks available */
725 if (unlikely(!uart->ick || !uart->fck)) {
726 WARN(1, "%s: can't init uart%d, no clocks available\n",
727 kobject_name(&dev->kobj), port);
728 return;
729 }
730
725 omap_uart_enable_clocks(uart); 731 omap_uart_enable_clocks(uart);
726 732
727 omap_uart_reset(uart); 733 omap_uart_reset(uart);