Commit 76d57ce6ef6060f611c14675249b7300a3c96368
1 parent
b6f1ffed9d
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 2 changed files with 28 additions and 12 deletions Side-by-side Diff
arch/arm/mach-davinci/include/mach/serial.h
arch/arm/mach-davinci/serial.c
... | ... | @@ -70,13 +70,35 @@ |
70 | 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 | 76 | char name[16]; |
77 | - struct clk *uart_clk; | |
77 | + struct clk *clk; | |
78 | 78 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
79 | 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; | |
100 | + struct davinci_soc_info *soc_info = &davinci_soc_info; | |
101 | + struct device *dev = &soc_info->serial_dev->dev; | |
80 | 102 | struct plat_serial8250_port *p = dev->platform_data; |
81 | 103 | |
82 | 104 | /* |
83 | 105 | |
... | ... | @@ -87,16 +109,9 @@ |
87 | 109 | if (!(info->enabled_uarts & (1 << i))) |
88 | 110 | continue; |
89 | 111 | |
90 | - sprintf(name, "uart%d", i); | |
91 | - uart_clk = clk_get(dev, name); | |
92 | - if (IS_ERR(uart_clk)) { | |
93 | - printk(KERN_ERR "%s:%d: failed to get UART%d clock\n", | |
94 | - __func__, __LINE__, i); | |
112 | + ret = davinci_serial_setup_clk(i, &p->uartclk); | |
113 | + if (ret) | |
95 | 114 | continue; |
96 | - } | |
97 | - | |
98 | - clk_prepare_enable(uart_clk); | |
99 | - p->uartclk = clk_get_rate(uart_clk); | |
100 | 115 | |
101 | 116 | if (!p->membase && p->mapbase) { |
102 | 117 | p->membase = ioremap(p->mapbase, SZ_4K); |