Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: 8250_omap: Use clk_get_rate() to obtain fclk frequency

8250_omap driver uses clock-frequency DT property to obtain functional
clk frequency. This is not ideal as users need to calculate functional
clk frequency offline and populate it in DT.
Therefore add support to obtain functional clock frequency using clk
APIs when clock-frequency DT property is not defined.

Suggested-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Vignesh R <vigneshr@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Vignesh R and committed by
Greg Kroah-Hartman
7d470ebf 7f0c77f3

+13 -1
+13 -1
drivers/tty/serial/8250/8250_omap.c
··· 12 12 #define SUPPORT_SYSRQ 13 13 #endif 14 14 15 + #include <linux/clk.h> 15 16 #include <linux/device.h> 16 17 #include <linux/io.h> 17 18 #include <linux/module.h> ··· 1204 1203 } 1205 1204 up.port.line = ret; 1206 1205 1207 - of_property_read_u32(np, "clock-frequency", &up.port.uartclk); 1206 + if (of_property_read_u32(np, "clock-frequency", &up.port.uartclk)) { 1207 + struct clk *clk; 1208 + 1209 + clk = devm_clk_get(&pdev->dev, NULL); 1210 + if (IS_ERR(clk)) { 1211 + if (PTR_ERR(clk) == -EPROBE_DEFER) 1212 + return -EPROBE_DEFER; 1213 + } else { 1214 + up.port.uartclk = clk_get_rate(clk); 1215 + } 1216 + } 1217 + 1208 1218 priv->wakeirq = irq_of_parse_and_map(np, 1); 1209 1219 1210 1220 id = of_match_device(of_match_ptr(omap8250_dt_ids), &pdev->dev);