Skip to contentSkip to conversation

clk/dts: s2mps11: Fix matching as module

PATCH Superseded Krzysztof Kozlowski 2 participants 5 messages Jul 25, 2018

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Krzysztof Kozlowski

author maintainer
#0 lore raw

cover clk/dts: s2mps11: Fix matching as module

Hi,

The DTS patches depend on 1st clock patch. I will take them through samsung-soc tree in next release.

Best regards,
Krzysztof

Krzysztof Kozlowski (3):
clk: s2mps11: Fix matching when built as module and DT node contains
compatible
ARM: dts: exynos: Add compatible for s2mps11 clocks node on Exynos542x
ARM: dts: exynos: Add compatible for s5m8767 clocks node on Itop Core

 arch/arm/boot/dts/exynos4412-itop-scp-core.dtsi |  1 +
 arch/arm/boot/dts/exynos5420-arndale-octa.dts   |  1 +
 arch/arm/boot/dts/exynos5420-smdk5420.dts       |  1 +
 arch/arm/boot/dts/exynos5422-odroid-core.dtsi   |  1 +
 drivers/clk/clk-s2mps11.c                       | 30 +++++++++++++++++++++++++
 5 files changed, 34 insertions(+)
Signature · 1 line
2.14.1
author maintainer
#1 lore raw

PATCH 1/3 clk: s2mps11: Fix matching when built as module and DT node contains compatible

When driver is built as module and DT node contains clocks compatible (e.g. "samsung,s2mps11-clk"), the module will not be autoloaded because module aliases won't match.

The modalias from uevent: of:NclocksT<NULL>Csamsung,s2mps11-clk The modalias from driver: platform:s2mps11-clk

The devices are instantiated by parent's MFD. However both Device Tree bindings and parent define the compatible for clocks devices. In case of module matching this DT compatible will be used.

The issue will not happen if this is built-in (no need for module matching) or when clocks DT node does not contain compatible (not correct from bindings perspective but working for driver).

Note when backporting to stable kernels: adjust the list of device ID entries.

Fixes 53c31b3437a6 ("mfd: sec-core: Add of_compatible strings for clock MFD cells")
---
 drivers/clk/clk-s2mps11.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/clk/clk-s2mps11.c +30 -0
index d44e0eea31ec..11a1e83ff805 100644
@@ -245,6 +245,36 @@ static const struct platform_device_id s2mps11_clk_id[] = {
 };
 MODULE_DEVICE_TABLE(platform, s2mps11_clk_id);
 
+#ifdef CONFIG_OF
+/*
+ * Device is instantiated through parent MFD device and device matching is done
+ * through platform_device_id.
+ *
+ * However if device's DT node contains proper clock compatible and it is built
+ * as a module, then the module matching will be done trough DT aliases.  This
+ * requires of_device_id table.  In the same time this will not change the
+ * actual device matching so do not add .of_match_table.
+ */
+static const struct of_device_id s2mps11_dt_match[] = {
+	{
+		.compatible = "samsung,s2mps11-clk",
+		.data = (void *)S2MPS11X,
+	}, {
+		.compatible = "samsung,s2mps13-clk",
+		.data = (void *)S2MPS13X,
+	}, {
+		.compatible = "samsung,s2mps14-clk",
+		.data = (void *)S2MPS14X,
+	}, {
+		.compatible = "samsung,s5m8767-clk",
+		.data = (void *)S5M8767X,
+	}, {
+		/* Sentinel */
+	},
+};
+MODULE_DEVICE_TABLE(of, s2mps11_dt_match);
+#endif
+
 static struct platform_driver s2mps11_clk_driver = {
 	.driver = {
 		.name  = "s2mps11-clk",
Signature · 1 line
2.14.1
maintainer Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] clk: s2mps11: Fix matching when built as module and DT node contains compatible

Quoting Krzysztof Kozlowski (2018-07-25 08:55:15)

Quoted 15 lines

When driver is built as module and DT node contains clocks compatible (e.g. "samsung,s2mps11-clk"), the module will not be autoloaded because module aliases won't match.

The modalias from uevent: of:NclocksT<NULL>Csamsung,s2mps11-clk The modalias from driver: platform:s2mps11-clk

The devices are instantiated by parent's MFD. However both Device Tree bindings and parent define the compatible for clocks devices. In case of module matching this DT compatible will be used.

The issue will not happen if this is built-in (no need for module matching) or when clocks DT node does not contain compatible (not correct from bindings perspective but working for driver).

Quoted 7 lines

Note when backporting to stable kernels: adjust the list of device ID entries.

Fixes 53c31b3437a6 ("mfd: sec-core: Add of_compatible strings for clock MFD cells")

---

author maintainer
#3 lore raw

PATCH 2/3 ARM: dts: exynos: Add compatible for s2mps11 clocks node on Exynos542x

In reply to Krzysztof Kozlowski

The bindings for s2mps11/s5m8767 clocks driver require a compatible for clocks node. Parent MFD sec-core driver will also use it when instantiating children.

The compatible is not needed for proper working because device will be anyway created by parent MFD device. Add it for correctness.

---
 arch/arm/boot/dts/exynos5420-arndale-octa.dts | 1 +
 arch/arm/boot/dts/exynos5420-smdk5420.dts     | 1 +
 arch/arm/boot/dts/exynos5422-odroid-core.dtsi | 1 +
 3 files changed, 3 insertions(+)
arch/arm/boot/dts/exynos5420-arndale-octa.dts +1 -0
index cdda614e417e..3447160e1fbf 100644
@@ -89,6 +89,7 @@
 		pinctrl-0 = <&s2mps11_irq>;
 
 		s2mps11_osc: clocks {
+			compatible = "samsung,s2mps11-clk";
 			#clock-cells = <1>;
 			clock-output-names = "s2mps11_ap",
 					"s2mps11_cp", "s2mps11_bt";
arch/arm/boot/dts/exynos5420-smdk5420.dts +1 -0
index 831c7336f237..3cf905047893 100644
@@ -141,6 +141,7 @@
 		reg = <0x66>;
 
 		s2mps11_osc: clocks {
+			compatible = "samsung,s2mps11-clk";
 			#clock-cells = <1>;
 			clock-output-names = "s2mps11_ap",
 					"s2mps11_cp", "s2mps11_bt";
arch/arm/boot/dts/exynos5422-odroid-core.dtsi +1 -0
index 2f4f40882dab..a368c73a1e48 100644
@@ -141,6 +141,7 @@
 		pinctrl-0 = <&s2mps11_irq>;
 
 		s2mps11_osc: clocks {
+			compatible = "samsung,s2mps11-clk";
 			#clock-cells = <1>;
 			clock-output-names = "s2mps11_ap",
 					"s2mps11_cp", "s2mps11_bt";
Signature · 1 line
2.14.1
author maintainer
#4 lore raw

PATCH 3/3 ARM: dts: exynos: Add compatible for s5m8767 clocks node on Itop Core

In reply to Krzysztof Kozlowski

The bindings for s2mps11/s5m8767 clocks driver require a compatible for clocks node. Parent MFD sec-core driver will also use it when instantiating children.

The compatible is not needed for proper working because device will be anyway created by parent MFD device. Add it for correctness.

---
 arch/arm/boot/dts/exynos4412-itop-scp-core.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/exynos4412-itop-scp-core.dtsi +1 -0
index ab7affab7f1c..8fdfd80c3acc 100644
@@ -446,6 +446,7 @@
 		};
 
 		s5m8767_osc: clocks {
+			compatible = "samsung,s5m8767-clk";
 			#clock-cells = <1>;
 			clock-output-names = "s5m8767_ap",
 					"s5m8767_cp", "s5m8767_bt";
Signature · 1 line
2.14.1