aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorMark A. Greer <mgreer@mvista.com>2009-03-18 13:36:08 -0400
committerKevin Hilman <khilman@deeprootsystems.com>2009-05-28 18:17:41 -0400
commit65e866a9741126c678e6dcd5d4fa8c9eca18e945 (patch)
tree069a15d3baed6c34b59e8504f1d5e3f73477f349 /arch/arm
parenta994955cc091a8a51b7d7412174d9cf6de04d26b (diff)
davinci: Move serial platform_device into SoC-specific files
Currently, there is one set of platform_device and platform_data structures for all DaVinci SoCs. The differences in the data between the various SoCs is handled by davinci_serial_init() by checking the SoC type. However, as new SoCs appear, this routine will become more & more cluttered. To clean up the routine and make it easier to add support for new SoCs, move the platform_device and platform_data structures into the SoC-specific code and use the SoC infrastructure to provide access to the data. In the process, fix a bug where the wrong irq is used for uart2 of the dm646x. Signed-off-by: Mark A. Greer <mgreer@mvista.com> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-davinci/dm355.c41
-rw-r--r--arch/arm/mach-davinci/dm644x.c41
-rw-r--r--arch/arm/mach-davinci/dm646x.c41
-rw-r--r--arch/arm/mach-davinci/include/mach/common.h1
-rw-r--r--arch/arm/mach-davinci/include/mach/serial.h2
-rw-r--r--arch/arm/mach-davinci/serial.c74
6 files changed, 135 insertions, 65 deletions
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index 757def75201..4c3257ef5dd 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/clk.h> 13#include <linux/clk.h>
14#include <linux/serial_8250.h>
14#include <linux/platform_device.h> 15#include <linux/platform_device.h>
15#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
16#include <linux/gpio.h> 17#include <linux/gpio.h>
@@ -27,6 +28,7 @@
27#include <mach/mux.h> 28#include <mach/mux.h>
28#include <mach/irqs.h> 29#include <mach/irqs.h>
29#include <mach/time.h> 30#include <mach/time.h>
31#include <mach/serial.h>
30#include <mach/common.h> 32#include <mach/common.h>
31 33
32#include "clock.h" 34#include "clock.h"
@@ -630,6 +632,44 @@ struct davinci_timer_info dm355_timer_info = {
630 .clocksource_id = T0_TOP, 632 .clocksource_id = T0_TOP,
631}; 633};
632 634
635static struct plat_serial8250_port dm355_serial_platform_data[] = {
636 {
637 .mapbase = DAVINCI_UART0_BASE,
638 .irq = IRQ_UARTINT0,
639 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
640 UPF_IOREMAP,
641 .iotype = UPIO_MEM,
642 .regshift = 2,
643 },
644 {
645 .mapbase = DAVINCI_UART1_BASE,
646 .irq = IRQ_UARTINT1,
647 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
648 UPF_IOREMAP,
649 .iotype = UPIO_MEM,
650 .regshift = 2,
651 },
652 {
653 .mapbase = DM355_UART2_BASE,
654 .irq = IRQ_DM355_UARTINT2,
655 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
656 UPF_IOREMAP,
657 .iotype = UPIO_MEM,
658 .regshift = 2,
659 },
660 {
661 .flags = 0
662 },
663};
664
665static struct platform_device dm355_serial_device = {
666 .name = "serial8250",
667 .id = PLAT8250_DEV_PLATFORM,
668 .dev = {
669 .platform_data = dm355_serial_platform_data,
670 },
671};
672
633static struct davinci_soc_info davinci_soc_info_dm355 = { 673static struct davinci_soc_info davinci_soc_info_dm355 = {
634 .io_desc = dm355_io_desc, 674 .io_desc = dm355_io_desc,
635 .io_desc_num = ARRAY_SIZE(dm355_io_desc), 675 .io_desc_num = ARRAY_SIZE(dm355_io_desc),
@@ -651,6 +691,7 @@ static struct davinci_soc_info davinci_soc_info_dm355 = {
651 .gpio_base = IO_ADDRESS(DAVINCI_GPIO_BASE), 691 .gpio_base = IO_ADDRESS(DAVINCI_GPIO_BASE),
652 .gpio_num = 104, 692 .gpio_num = 104,
653 .gpio_irq = IRQ_DM355_GPIOBNK0, 693 .gpio_irq = IRQ_DM355_GPIOBNK0,
694 .serial_dev = &dm355_serial_device,
654}; 695};
655 696
656void __init dm355_init(void) 697void __init dm355_init(void)
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index cfd918e41e2..a5629864d02 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/clk.h> 13#include <linux/clk.h>
14#include <linux/serial_8250.h>
14#include <linux/platform_device.h> 15#include <linux/platform_device.h>
15#include <linux/gpio.h> 16#include <linux/gpio.h>
16 17
@@ -24,6 +25,7 @@
24#include <mach/psc.h> 25#include <mach/psc.h>
25#include <mach/mux.h> 26#include <mach/mux.h>
26#include <mach/time.h> 27#include <mach/time.h>
28#include <mach/serial.h>
27#include <mach/common.h> 29#include <mach/common.h>
28 30
29#include "clock.h" 31#include "clock.h"
@@ -573,6 +575,44 @@ struct davinci_timer_info dm644x_timer_info = {
573 .clocksource_id = T0_TOP, 575 .clocksource_id = T0_TOP,
574}; 576};
575 577
578static struct plat_serial8250_port dm644x_serial_platform_data[] = {
579 {
580 .mapbase = DAVINCI_UART0_BASE,
581 .irq = IRQ_UARTINT0,
582 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
583 UPF_IOREMAP,
584 .iotype = UPIO_MEM,
585 .regshift = 2,
586 },
587 {
588 .mapbase = DAVINCI_UART1_BASE,
589 .irq = IRQ_UARTINT1,
590 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
591 UPF_IOREMAP,
592 .iotype = UPIO_MEM,
593 .regshift = 2,
594 },
595 {
596 .mapbase = DAVINCI_UART2_BASE,
597 .irq = IRQ_UARTINT2,
598 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
599 UPF_IOREMAP,
600 .iotype = UPIO_MEM,
601 .regshift = 2,
602 },
603 {
604 .flags = 0
605 },
606};
607
608static struct platform_device dm644x_serial_device = {
609 .name = "serial8250",
610 .id = PLAT8250_DEV_PLATFORM,
611 .dev = {
612 .platform_data = dm644x_serial_platform_data,
613 },
614};
615
576static struct davinci_soc_info davinci_soc_info_dm644x = { 616static struct davinci_soc_info davinci_soc_info_dm644x = {
577 .io_desc = dm644x_io_desc, 617 .io_desc = dm644x_io_desc,
578 .io_desc_num = ARRAY_SIZE(dm644x_io_desc), 618 .io_desc_num = ARRAY_SIZE(dm644x_io_desc),
@@ -594,6 +634,7 @@ static struct davinci_soc_info davinci_soc_info_dm644x = {
594 .gpio_base = IO_ADDRESS(DAVINCI_GPIO_BASE), 634 .gpio_base = IO_ADDRESS(DAVINCI_GPIO_BASE),
595 .gpio_num = 71, 635 .gpio_num = 71,
596 .gpio_irq = IRQ_GPIOBNK0, 636 .gpio_irq = IRQ_GPIOBNK0,
637 .serial_dev = &dm644x_serial_device,
597}; 638};
598 639
599void __init dm644x_init(void) 640void __init dm644x_init(void)
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index f980c2f95de..544658e5885 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/clk.h> 13#include <linux/clk.h>
14#include <linux/serial_8250.h>
14#include <linux/platform_device.h> 15#include <linux/platform_device.h>
15#include <linux/gpio.h> 16#include <linux/gpio.h>
16 17
@@ -24,6 +25,7 @@
24#include <mach/psc.h> 25#include <mach/psc.h>
25#include <mach/mux.h> 26#include <mach/mux.h>
26#include <mach/time.h> 27#include <mach/time.h>
28#include <mach/serial.h>
27#include <mach/common.h> 29#include <mach/common.h>
28 30
29#include "clock.h" 31#include "clock.h"
@@ -552,6 +554,44 @@ struct davinci_timer_info dm646x_timer_info = {
552 .clocksource_id = T0_TOP, 554 .clocksource_id = T0_TOP,
553}; 555};
554 556
557static struct plat_serial8250_port dm646x_serial_platform_data[] = {
558 {
559 .mapbase = DAVINCI_UART0_BASE,
560 .irq = IRQ_UARTINT0,
561 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
562 UPF_IOREMAP,
563 .iotype = UPIO_MEM32,
564 .regshift = 2,
565 },
566 {
567 .mapbase = DAVINCI_UART1_BASE,
568 .irq = IRQ_UARTINT1,
569 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
570 UPF_IOREMAP,
571 .iotype = UPIO_MEM32,
572 .regshift = 2,
573 },
574 {
575 .mapbase = DAVINCI_UART2_BASE,
576 .irq = IRQ_DM646X_UARTINT2,
577 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
578 UPF_IOREMAP,
579 .iotype = UPIO_MEM32,
580 .regshift = 2,
581 },
582 {
583 .flags = 0
584 },
585};
586
587static struct platform_device dm646x_serial_device = {
588 .name = "serial8250",
589 .id = PLAT8250_DEV_PLATFORM,
590 .dev = {
591 .platform_data = dm646x_serial_platform_data,
592 },
593};
594
555static struct davinci_soc_info davinci_soc_info_dm646x = { 595static struct davinci_soc_info davinci_soc_info_dm646x = {
556 .io_desc = dm646x_io_desc, 596 .io_desc = dm646x_io_desc,
557 .io_desc_num = ARRAY_SIZE(dm646x_io_desc), 597 .io_desc_num = ARRAY_SIZE(dm646x_io_desc),
@@ -573,6 +613,7 @@ static struct davinci_soc_info davinci_soc_info_dm646x = {
573 .gpio_base = IO_ADDRESS(DAVINCI_GPIO_BASE), 613 .gpio_base = IO_ADDRESS(DAVINCI_GPIO_BASE),
574 .gpio_num = 43, /* Only 33 usable */ 614 .gpio_num = 43, /* Only 33 usable */
575 .gpio_irq = IRQ_DM646X_GPIOBNK0, 615 .gpio_irq = IRQ_DM646X_GPIOBNK0,
616 .serial_dev = &dm646x_serial_device,
576}; 617};
577 618
578void __init dm646x_init(void) 619void __init dm646x_init(void)
diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h
index 06ff6d6e367..9624e038253 100644
--- a/arch/arm/mach-davinci/include/mach/common.h
+++ b/arch/arm/mach-davinci/include/mach/common.h
@@ -61,6 +61,7 @@ struct davinci_soc_info {
61 void __iomem *gpio_base; 61 void __iomem *gpio_base;
62 unsigned gpio_num; 62 unsigned gpio_num;
63 unsigned gpio_irq; 63 unsigned gpio_irq;
64 struct platform_device *serial_dev;
64}; 65};
65 66
66extern struct davinci_soc_info davinci_soc_info; 67extern struct davinci_soc_info davinci_soc_info;
diff --git a/arch/arm/mach-davinci/include/mach/serial.h b/arch/arm/mach-davinci/include/mach/serial.h
index 761ab2b483a..b0c57fa9e4e 100644
--- a/arch/arm/mach-davinci/include/mach/serial.h
+++ b/arch/arm/mach-davinci/include/mach/serial.h
@@ -30,6 +30,6 @@ struct davinci_uart_config {
30 unsigned int enabled_uarts; 30 unsigned int enabled_uarts;
31}; 31};
32 32
33extern void davinci_serial_init(struct davinci_uart_config *); 33extern int davinci_serial_init(struct davinci_uart_config *);
34 34
35#endif /* __ASM_ARCH_SERIAL_H */ 35#endif /* __ASM_ARCH_SERIAL_H */
diff --git a/arch/arm/mach-davinci/serial.c b/arch/arm/mach-davinci/serial.c
index 69507579652..c530c7333d0 100644
--- a/arch/arm/mach-davinci/serial.c
+++ b/arch/arm/mach-davinci/serial.c
@@ -33,6 +33,8 @@
33#include <mach/serial.h> 33#include <mach/serial.h>
34#include <mach/irqs.h> 34#include <mach/irqs.h>
35#include <mach/cputype.h> 35#include <mach/cputype.h>
36#include <mach/common.h>
37
36#include "clock.h" 38#include "clock.h"
37 39
38static inline unsigned int serial_read_reg(struct plat_serial8250_port *up, 40static inline unsigned int serial_read_reg(struct plat_serial8250_port *up,
@@ -49,44 +51,6 @@ static inline void serial_write_reg(struct plat_serial8250_port *p, int offset,
49 __raw_writel(value, IO_ADDRESS(p->mapbase) + offset); 51 __raw_writel(value, IO_ADDRESS(p->mapbase) + offset);
50} 52}
51 53
52static struct plat_serial8250_port serial_platform_data[] = {
53 {
54 .mapbase = DAVINCI_UART0_BASE,
55 .irq = IRQ_UARTINT0,
56 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
57 UPF_IOREMAP,
58 .iotype = UPIO_MEM,
59 .regshift = 2,
60 },
61 {
62 .mapbase = DAVINCI_UART1_BASE,
63 .irq = IRQ_UARTINT1,
64 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
65 UPF_IOREMAP,
66 .iotype = UPIO_MEM,
67 .regshift = 2,
68 },
69 {
70 .mapbase = DAVINCI_UART2_BASE,
71 .irq = IRQ_UARTINT2,
72 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
73 UPF_IOREMAP,
74 .iotype = UPIO_MEM,
75 .regshift = 2,
76 },
77 {
78 .flags = 0
79 },
80};
81
82static struct platform_device serial_device = {
83 .name = "serial8250",
84 .id = PLAT8250_DEV_PLATFORM,
85 .dev = {
86 .platform_data = serial_platform_data,
87 },
88};
89
90static void __init davinci_serial_reset(struct plat_serial8250_port *p) 54static void __init davinci_serial_reset(struct plat_serial8250_port *p)
91{ 55{
92 unsigned int pwremu = 0; 56 unsigned int pwremu = 0;
@@ -106,35 +70,22 @@ static void __init davinci_serial_reset(struct plat_serial8250_port *p)
106 UART_DM646X_SCR_TX_WATERMARK); 70 UART_DM646X_SCR_TX_WATERMARK);
107} 71}
108 72
109void __init davinci_serial_init(struct davinci_uart_config *info) 73int __init davinci_serial_init(struct davinci_uart_config *info)
110{ 74{
111 int i; 75 int i;
112 char name[16]; 76 char name[16];
113 struct clk *uart_clk; 77 struct clk *uart_clk;
114 struct device *dev = &serial_device.dev; 78 struct davinci_soc_info *soc_info = &davinci_soc_info;
79 struct device *dev = &soc_info->serial_dev->dev;
80 struct plat_serial8250_port *p = dev->platform_data;
115 81
116 /* 82 /*
117 * Make sure the serial ports are muxed on at this point. 83 * Make sure the serial ports are muxed on at this point.
118 * You have to mux them off in device drivers later on 84 * You have to mux them off in device drivers later on if not needed.
119 * if not needed.
120 */ 85 */
121 for (i = 0; i < DAVINCI_MAX_NR_UARTS; i++) { 86 for (i = 0; i < DAVINCI_MAX_NR_UARTS; i++, p++) {
122 struct plat_serial8250_port *p = serial_platform_data + i; 87 if (!(info->enabled_uarts & (1 << i)))
123
124 if (!(info->enabled_uarts & (1 << i))) {
125 p->flags = 0;
126 continue; 88 continue;
127 }
128
129 if (cpu_is_davinci_dm646x())
130 p->iotype = UPIO_MEM32;
131
132 if (cpu_is_davinci_dm355()) {
133 if (i == 2) {
134 p->mapbase = (unsigned long)DM355_UART2_BASE;
135 p->irq = IRQ_DM355_UARTINT2;
136 }
137 }
138 89
139 sprintf(name, "uart%d", i); 90 sprintf(name, "uart%d", i);
140 uart_clk = clk_get(dev, name); 91 uart_clk = clk_get(dev, name);
@@ -147,11 +98,6 @@ void __init davinci_serial_init(struct davinci_uart_config *info)
147 davinci_serial_reset(p); 98 davinci_serial_reset(p);
148 } 99 }
149 } 100 }
150}
151 101
152static int __init davinci_init(void) 102 return platform_device_register(soc_info->serial_dev);
153{
154 return platform_device_register(&serial_device);
155} 103}
156
157arch_initcall(davinci_init);