Commit 8658f0ac authored by Peng Fan's avatar Peng Fan Committed by Abel Vesa

clk: imx: get stdout clk count from device tree

Currently the clk_count is specified by API users, but this
parameter is wrongly used, for example, i.MX8M clk driver use 4,
however the uart device tree node only use 2 clock entries. So
let using of_clk_get_parent_count to get the exact clock count.
Signed-off-by: default avatarPeng Fan <peng.fan@nxp.com>
Reviewed-by: default avatarAbel Vesa <abel.vesa@linaro.org>
Signed-off-by: default avatarAbel Vesa <abel.vesa@linaro.org>
Link: https://lore.kernel.org/r/20230104110032.1220721-3-peng.fan@oss.nxp.com
parent f4419db4
...@@ -167,6 +167,8 @@ __setup_param("earlyprintk", imx_keep_uart_earlyprintk, ...@@ -167,6 +167,8 @@ __setup_param("earlyprintk", imx_keep_uart_earlyprintk,
void imx_register_uart_clocks(unsigned int clk_count) void imx_register_uart_clocks(unsigned int clk_count)
{ {
unsigned int num __maybe_unused;
imx_enabled_uart_clocks = 0; imx_enabled_uart_clocks = 0;
/* i.MX boards use device trees now. For build tests without CONFIG_OF, do nothing */ /* i.MX boards use device trees now. For build tests without CONFIG_OF, do nothing */
...@@ -174,14 +176,18 @@ void imx_register_uart_clocks(unsigned int clk_count) ...@@ -174,14 +176,18 @@ void imx_register_uart_clocks(unsigned int clk_count)
if (imx_keep_uart_clocks) { if (imx_keep_uart_clocks) {
int i; int i;
imx_uart_clocks = kcalloc(clk_count, sizeof(struct clk *), GFP_KERNEL); num = of_clk_get_parent_count(of_stdout);
if (!imx_uart_clocks) if (!num)
return; return;
if (!of_stdout) if (!of_stdout)
return; return;
for (i = 0; i < clk_count; i++) { imx_uart_clocks = kcalloc(num, sizeof(struct clk *), GFP_KERNEL);
if (!imx_uart_clocks)
return;
for (i = 0; i < num; i++) {
imx_uart_clocks[imx_enabled_uart_clocks] = of_clk_get(of_stdout, i); imx_uart_clocks[imx_enabled_uart_clocks] = of_clk_get(of_stdout, i);
/* Stop if there are no more of_stdout references */ /* Stop if there are no more of_stdout references */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment