aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci/serial.c
diff options
context:
space:
mode:
authorSekhar Nori <nsekhar@ti.com>2012-08-29 13:18:52 -0400
committerSekhar Nori <nsekhar@ti.com>2012-10-27 06:58:31 -0400
commit76d57ce6ef6060f611c14675249b7300a3c96368 (patch)
treeee5aff6789cc9b5d79caca405cc622cb29669aae /arch/arm/mach-davinci/serial.c
parentb6f1ffed9d8a830ab94fd3fc6182e2fc8c77cba0 (diff)
ARM: davinci: serial: provide API to initialze UART clocks
Provide an API to initialize a UART clock. Refactor existing davinci_serial_init() to separate out the part which enables the clock. This will later be used to help DA850 DT boot support. Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Diffstat (limited to 'arch/arm/mach-davinci/serial.c')
-rw-r--r--arch/arm/mach-davinci/serial.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/arch/arm/mach-davinci/serial.c b/arch/arm/mach-davinci/serial.c
index 24ddb0d32a0f..f2625814c3c9 100644
--- a/arch/arm/mach-davinci/serial.c
+++ b/arch/arm/mach-davinci/serial.c
@@ -70,11 +70,33 @@ 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
73int __init davinci_serial_init(struct davinci_uart_config *info) 73/* Enable UART clock and obtain its rate */
74int __init davinci_serial_setup_clk(unsigned instance, unsigned int *rate)
74{ 75{
75 int i;
76 char name[16]; 76 char name[16];
77 struct clk *uart_clk; 77 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;
78 struct davinci_soc_info *soc_info = &davinci_soc_info; 100 struct davinci_soc_info *soc_info = &davinci_soc_info;
79 struct device *dev = &soc_info->serial_dev->dev; 101 struct device *dev = &soc_info->serial_dev->dev;
80 struct plat_serial8250_port *p = dev->platform_data; 102 struct plat_serial8250_port *p = dev->platform_data;
@@ -87,16 +109,9 @@ int __init davinci_serial_init(struct davinci_uart_config *info)
87 if (!(info->enabled_uarts & (1 << i))) 109 if (!(info->enabled_uarts & (1 << i)))
88 continue; 110 continue;
89 111
90 sprintf(name, "uart%d", i); 112 ret = davinci_serial_setup_clk(i, &p->uartclk);
91 uart_clk = clk_get(dev, name); 113 if (ret)
92 if (IS_ERR(uart_clk)) {
93 printk(KERN_ERR "%s:%d: failed to get UART%d clock\n",
94 __func__, __LINE__, i);
95 continue; 114 continue;
96 }
97
98 clk_prepare_enable(uart_clk);
99 p->uartclk = clk_get_rate(uart_clk);
100 115
101 if (!p->membase && p->mapbase) { 116 if (!p->membase && p->mapbase) {
102 p->membase = ioremap(p->mapbase, SZ_4K); 117 p->membase = ioremap(p->mapbase, SZ_4K);