[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201229145130.2680442-1-aford173@gmail.com>
Date: Tue, 29 Dec 2020 08:51:28 -0600
From: Adam Ford <aford173@...il.com>
To: linux-arm-kernel@...ts.infradead.org
Cc: Adam Ford <aford173@...il.com>, Fugang Duan <fugang.duan@....com>,
Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>,
Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>,
NXP Linux Team <linux-imx@....com>,
Linus Walleij <linus.walleij@...aro.org>,
Jerome Brunet <jbrunet@...libre.com>,
linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 1/2] clk: imx: enable the earlycon uart clocks by parsing from dt
Remove the earlycon uart clocks that are hard cord in platforms
clock driver, instead of parsing the earlycon uart port from dt
and enable these clocks from clock property in dt node.
Fixes: 9461f7b33d11c ("clk: fix CLK_SET_RATE_GATE with clock rate protection")
Signed-off-by: Fugang Duan <fugang.duan@....com>
Signed-off-by: Adam Ford <aford173@...il.com>
---
Based on NXP's code base and adapted for 5.11-rc1.
https://source.codeaurora.org/external/imx/linux-imx/commit/drivers/clk/imx/clk.c?h=imx_5.4.47_2.2.0&id=754ae82cc55b7445545fc2f092a70e0f490e9c1b
The original signed-off was retained.
Added the fixes tag.
---
drivers/clk/imx/clk.c | 43 +++++++++++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 14 deletions(-)
diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
index 47882c51cb85..c32b46890945 100644
--- a/drivers/clk/imx/clk.c
+++ b/drivers/clk/imx/clk.c
@@ -148,7 +148,7 @@ void imx_cscmr1_fixup(u32 *val)
#ifndef MODULE
static int imx_keep_uart_clocks;
-static struct clk ** const *imx_uart_clocks;
+static bool imx_uart_clks_on;
static int __init imx_keep_uart_clocks_param(char *str)
{
@@ -161,25 +161,40 @@ __setup_param("earlycon", imx_keep_uart_earlycon,
__setup_param("earlyprintk", imx_keep_uart_earlyprintk,
imx_keep_uart_clocks_param, 0);
-void imx_register_uart_clocks(struct clk ** const clks[])
+static void imx_earlycon_uart_clks_onoff(bool is_on)
{
- if (imx_keep_uart_clocks) {
- int i;
+ struct clk *uart_clk;
+ int i = 0;
- imx_uart_clocks = clks;
- for (i = 0; imx_uart_clocks[i]; i++)
- clk_prepare_enable(*imx_uart_clocks[i]);
- }
+ if (!imx_keep_uart_clocks || (!is_on && !imx_uart_clks_on))
+ return;
+
+ /* only support dt */
+ if (!of_stdout)
+ return;
+
+ do {
+ uart_clk = of_clk_get(of_stdout, i++);
+ if (IS_ERR(uart_clk))
+ break;
+
+ if (is_on)
+ clk_prepare_enable(uart_clk);
+ else
+ clk_disable_unprepare(uart_clk);
+ } while (true);
+
+ if (is_on)
+ imx_uart_clks_on = true;
+}
+void imx_register_uart_clocks(struct clk ** const clks[])
+{
+ imx_earlycon_uart_clks_onoff(true);
}
static int __init imx_clk_disable_uart(void)
{
- if (imx_keep_uart_clocks && imx_uart_clocks) {
- int i;
-
- for (i = 0; imx_uart_clocks[i]; i++)
- clk_disable_unprepare(*imx_uart_clocks[i]);
- }
+ imx_earlycon_uart_clks_onoff(false);
return 0;
}
--
2.25.1
Powered by blists - more mailing lists