diff options
Diffstat (limited to 'arch/arm/mach-davinci/serial.c')
-rw-r--r-- | arch/arm/mach-davinci/serial.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/arch/arm/mach-davinci/serial.c b/arch/arm/mach-davinci/serial.c index 1875740fe27c..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 | ||
73 | int __init davinci_serial_init(struct davinci_uart_config *info) | 73 | /* Enable UART clock and obtain its rate */ |
74 | int __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 | |||
97 | int __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_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); |