aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-davinci/serial.c')
-rw-r--r--arch/arm/mach-davinci/serial.c54
1 files changed, 20 insertions, 34 deletions
diff --git a/arch/arm/mach-davinci/serial.c b/arch/arm/mach-davinci/serial.c
index f2625814c3c9..5e93a734c858 100644
--- a/arch/arm/mach-davinci/serial.c
+++ b/arch/arm/mach-davinci/serial.c
@@ -70,49 +70,36 @@ static void __init davinci_serial_reset(struct plat_serial8250_port *p)
70 UART_DM646X_SCR_TX_WATERMARK); 70 UART_DM646X_SCR_TX_WATERMARK);
71} 71}
72 72
73/* Enable UART clock and obtain its rate */ 73int __init davinci_serial_init(struct platform_device *serial_dev)
74int __init davinci_serial_setup_clk(unsigned instance, unsigned int *rate)
75{ 74{
76 char name[16]; 75 int i, ret = 0;
76 struct device *dev;
77 struct plat_serial8250_port *p;
77 struct clk *clk; 78 struct clk *clk;
78 struct davinci_soc_info *soc_info = &davinci_soc_info;
79 struct device *dev = &soc_info->serial_dev->dev;
80
81 sprintf(name, "uart%d", instance);
82 clk = clk_get(dev, name);
83 if (IS_ERR(clk)) {
84 pr_err("%s:%d: failed to get UART%d clock\n",
85 __func__, __LINE__, instance);
86 return PTR_ERR(clk);
87 }
88
89 clk_prepare_enable(clk);
90
91 if (rate)
92 *rate = clk_get_rate(clk);
93
94 return 0;
95}
96
97int __init davinci_serial_init(struct davinci_uart_config *info)
98{
99 int i, ret;
100 struct davinci_soc_info *soc_info = &davinci_soc_info;
101 struct device *dev = &soc_info->serial_dev->dev;
102 struct plat_serial8250_port *p = dev->platform_data;
103 79
104 /* 80 /*
105 * Make sure the serial ports are muxed on at this point. 81 * Make sure the serial ports are muxed on at this point.
106 * You have to mux them off in device drivers later on if not needed. 82 * You have to mux them off in device drivers later on if not needed.
107 */ 83 */
108 for (i = 0; p->flags; i++, p++) { 84 for (i = 0; serial_dev[i].dev.platform_data != NULL; i++) {
109 if (!(info->enabled_uarts & (1 << i))) 85 dev = &serial_dev[i].dev;
110 continue; 86 p = dev->platform_data;
111 87
112 ret = davinci_serial_setup_clk(i, &p->uartclk); 88 ret = platform_device_register(&serial_dev[i]);
113 if (ret) 89 if (ret)
114 continue; 90 continue;
115 91
92 clk = clk_get(dev, NULL);
93 if (IS_ERR(clk)) {
94 pr_err("%s:%d: failed to get UART%d clock\n",
95 __func__, __LINE__, i);
96 continue;
97 }
98
99 clk_prepare_enable(clk);
100
101 p->uartclk = clk_get_rate(clk);
102
116 if (!p->membase && p->mapbase) { 103 if (!p->membase && p->mapbase) {
117 p->membase = ioremap(p->mapbase, SZ_4K); 104 p->membase = ioremap(p->mapbase, SZ_4K);
118 105
@@ -125,6 +112,5 @@ int __init davinci_serial_init(struct davinci_uart_config *info)
125 if (p->membase && p->type != PORT_AR7) 112 if (p->membase && p->type != PORT_AR7)
126 davinci_serial_reset(p); 113 davinci_serial_reset(p);
127 } 114 }
128 115 return ret;
129 return platform_device_register(soc_info->serial_dev);
130} 116}