Skip to contentSkip to conversation

clk: imx: scu: support defer probe properly

PATCH New Dong Aisheng 1 participant 4 messages Nov 24, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover clk: imx: scu: support defer probe properly

This patch series is a continued solution for the issue discussed here:
https://lore.kernel.org/patchwork/patch/1334670/

As kernel doesn't want user to call device_is_bound() which is removed
https://patchwork.kernel.org/project/linux-clk/patch/[email protected]/

Because SCU clock-controller (SCU clock protocol) itself does not have a power domain property in DT as it does not depend on power domain, but the sub clocks registered requires power domains to be ready first.
We export an API for SCU clk driver to query the status in
order to support -EPROBE_DEFER properly.

Dong Aisheng (3):
clk: imx: scu: make scu clk driver depend on scu pd
firmware: imx: scu-pd: export SCU PD register status
clk: imx: scu: defer probe if scu pd is still not ready

 drivers/clk/imx/Kconfig          |  4 ++--
 drivers/clk/imx/clk-scu.c        |  3 +++
 drivers/firmware/imx/scu-pd.c    | 20 +++++++++++++++++++-
 include/linux/firmware/imx/sci.h |  6 ++++++
 4 files changed, 30 insertions(+), 3 deletions(-)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/3 clk: imx: scu: make scu clk driver depend on scu pd

The SCU clocks depends on SCU power domains.

---
 drivers/clk/imx/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/imx/Kconfig +2 -2
index 3b393cb07295..e79375c76159 100644
@@ -7,7 +7,7 @@ config MXC_CLK
 config MXC_CLK_SCU
 	tristate "IMX SCU clock"
 	depends on ARCH_MXC || COMPILE_TEST
-	depends on IMX_SCU && HAVE_ARM_SMCCC
+	depends on IMX_SCU && IMX_SCU_PD && HAVE_ARM_SMCCC
 
 config CLK_IMX1
 	def_bool SOC_IMX1
@@ -96,7 +96,7 @@ config CLK_IMX8MQ
 config CLK_IMX8QXP
 	tristate "IMX8QXP SCU Clock"
 	depends on (ARCH_MXC && ARM64) || COMPILE_TEST
-	depends on IMX_SCU && HAVE_ARM_SMCCC
+	depends on IMX_SCU && IMX_SCU_PD && HAVE_ARM_SMCCC
 	select MXC_CLK_SCU
 	help
 	  Build the driver for IMX8QXP SCU based clocks.
Signature · 1 line
2.23.0
#2 lore raw

PATCH 2/3 firmware: imx: scu-pd: export SCU PD register status

In reply to Dong Aisheng

SCU clock-controller (SCU clock protocol) does not have a power domain property in DT, but the sub clocks registered requires power domain to be ready first. Export an API for SCU clk driver to query the status in order to support -EPROBE_DEFER properly.

---
 drivers/firmware/imx/scu-pd.c    | 20 +++++++++++++++++++-
 include/linux/firmware/imx/sci.h |  6 ++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
drivers/firmware/imx/scu-pd.c +19 -1
index 946eea292b52..53b49ef20014 100644
@@ -86,6 +86,20 @@ struct imx_sc_pd_soc {
 	u8 num_ranges;
 };
 
+bool imx_scu_pd_initialized;
+
+/*
+ * SCU clock-controller (SCU clock protocol) does not have a power domain
+ * property in DT, but the sub clocks registered requires power domain to
+ * be ready first. Export an API for SCU clk driver to query the status in
+ * order to support -EPROBE_DEFER properly.
+ */
+bool imx_scu_pd_is_initialized(void)
+{
+	return imx_scu_pd_initialized;
+}
+EXPORT_SYMBOL_GPL(imx_scu_pd_is_initialized);
+
 static const struct imx_sc_pd_range imx8qxp_scu_pd_ranges[] = {
 	/* LSIO SS */
 	{ "pwm", IMX_SC_R_PWM_0, 8, true, 0 },
@@ -351,7 +365,11 @@ static int imx_sc_pd_probe(struct platform_device *pdev)
 	if (!pd_soc)
 		return -ENODEV;
 
-	return imx_scu_init_pm_domains(&pdev->dev, pd_soc);
+	ret = imx_scu_init_pm_domains(&pdev->dev, pd_soc);
+	if (!ret)
+		imx_scu_pd_initialized = true;
+
+	return ret;
 }
 
 static const struct of_device_id imx_sc_pd_match[] = {
include/linux/firmware/imx/sci.h +6 -0
index 5cc63fe7e84d..0eaf00ad6305 100644
@@ -22,6 +22,7 @@ int imx_scu_irq_register_notifier(struct notifier_block *nb);
 int imx_scu_irq_unregister_notifier(struct notifier_block *nb);
 int imx_scu_irq_group_enable(u8 group, u32 mask, u8 enable);
 int imx_scu_soc_init(struct device *dev);
+bool imx_scu_pd_is_initialized(void);
 #else
 static inline int imx_scu_soc_init(struct device *dev)
 {
@@ -47,5 +48,10 @@ static inline int imx_scu_irq_group_enable(u8 group, u32 mask, u8 enable)
 {
 	return -ENOTSUPP;
 }
+
+static inline bool imx_scu_pd_is_initialized(void)
+{
+	return false;
+}
 #endif
 #endif /* _SC_SCI_H */
Signature · 1 line
2.23.0
#3 lore raw

PATCH 3/3 clk: imx: scu: defer probe if scu pd is still not ready

In reply to Dong Aisheng

The clocks registered by SCU clock protocol driver requires power domain to be ready first. Query the SCU PD status to support -EPROBE_DEFER properly.

---
 drivers/clk/imx/clk-scu.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/clk/imx/clk-scu.c +3 -0
index 1f5518b7ab39..846201f9b72d 100644
@@ -163,6 +163,9 @@ int imx_clk_scu_init(struct device_node *np)
 	of_property_read_u32(np, "#clock-cells", &clk_cells);
 
 	if (clk_cells == 2) {
+		if (!imx_scu_pd_is_initialized())
+			return -EPROBE_DEFER;
+
 		for (i = 0; i < IMX_SC_R_LAST; i++)
 			INIT_LIST_HEAD(&imx_scu_clks[i]);
 
Signature · 1 line
2.23.0