Skip to contentSkip to conversation

arm64: berlin: add pinctrl support

PATCH Superseded Jisheng Zhang 2 participants 15 messages Oct 9, 2015 – Oct 10, 2015

Subsystems (5)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover arm64: berlin: add pinctrl support

This series adds support for Marvell berlin4ct pin-controller, allowing to configure the pin muxing from the device tree.

Since v3:
- fix stupid build error: I missed local changes to berlin-bg4ct.c

Since v2:
- introduce new berlin_pinctrl_probe_regmap() to avoid duplicated code
- renaming such as s/urt/uart etc. but keep the group name as URT* to keep consistent with HW/ASIC

Since v1:
- use generic name for pin functions
- a new commit to add pinmux for uart0
- correct pinctrl usage in dts

Jisheng Zhang (6):
pinctrl: berlin: introduce berlin_pinctrl_probe_regmap()
pinctrl: berlin: add the berlin4ct pinctrl driver
arm64: berlin: add the pinctrl dependency for Marvell Berlin SoCs
pinctrl: dt-binding: document berlin4ct SoC pinctrl
arm64: dts: berlin4ct: add the pinctrl node
arm64: dts: berlin4ct: add default pinmux for uart0

 .../devicetree/bindings/pinctrl/berlin,pinctrl.txt |   5 +-
 arch/arm64/Kconfig.platforms                       |   1 +
 arch/arm64/boot/dts/marvell/berlin4ct.dtsi         |  22 +
 drivers/pinctrl/berlin/Kconfig                     |   5 +
 drivers/pinctrl/berlin/Makefile                    |   1 +
 drivers/pinctrl/berlin/berlin-bg4ct.c              | 503 +++++++++++++++++++++
 drivers/pinctrl/berlin/berlin.c                    |  26 +-
 drivers/pinctrl/berlin/berlin.h                    |   4 +
 8 files changed, 557 insertions(+), 10 deletions(-)
 create mode 100644 drivers/pinctrl/berlin/berlin-bg4ct.c
Signature · 1 line
2.6.1
#1 lore raw

PATCH v4 1/6 pinctrl: berlin: introduce berlin_pinctrl_probe_regmap()

This is to prepare for the next berlin4ct support, where we won't use simple-mfd any more.

---
 drivers/pinctrl/berlin/berlin.c | 26 +++++++++++++++++---------
 drivers/pinctrl/berlin/berlin.h |  4 ++++
 2 files changed, 21 insertions(+), 9 deletions(-)
drivers/pinctrl/berlin/berlin.c +17 -9
index f495806..898afa4 100644
@@ -292,20 +292,14 @@ static struct pinctrl_desc berlin_pctrl_desc = {
 	.owner		= THIS_MODULE,
 };
 
-int berlin_pinctrl_probe(struct platform_device *pdev,
-			 const struct berlin_pinctrl_desc *desc)
+int berlin_pinctrl_probe_regmap(struct platform_device *pdev,
+				const struct berlin_pinctrl_desc *desc,
+				struct regmap *regmap)
 {
 	struct device *dev = &pdev->dev;
-	struct device_node *parent_np = of_get_parent(dev->of_node);
 	struct berlin_pinctrl *pctrl;
-	struct regmap *regmap;
 	int ret;
 
-	regmap = syscon_node_to_regmap(parent_np);
-	of_node_put(parent_np);
-	if (IS_ERR(regmap))
-		return PTR_ERR(regmap);
-
 	pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL);
 	if (!pctrl)
 		return -ENOMEM;
@@ -330,3 +324,17 @@ int berlin_pinctrl_probe(struct platform_device *pdev,
 
 	return 0;
 }
+
+int berlin_pinctrl_probe(struct platform_device *pdev,
+			 const struct berlin_pinctrl_desc *desc)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *parent_np = of_get_parent(dev->of_node);
+	struct regmap *regmap = syscon_node_to_regmap(parent_np);
+
+	of_node_put(parent_np);
+	if (IS_ERR(regmap))
+		return PTR_ERR(regmap);
+
+	return berlin_pinctrl_probe_regmap(pdev, desc, regmap);
+}
drivers/pinctrl/berlin/berlin.h +4 -0
index e1aa841..dabbd2a 100644
@@ -58,4 +58,8 @@ struct berlin_pinctrl_function {
 int berlin_pinctrl_probe(struct platform_device *pdev,
 			 const struct berlin_pinctrl_desc *desc);
 
+int berlin_pinctrl_probe_regmap(struct platform_device *pdev,
+				const struct berlin_pinctrl_desc *desc,
+				struct regmap *regmap);
+
 #endif /* __PINCTRL_BERLIN_H */
Signature · 1 line
2.6.1
#3 lore raw

PATCH v4 2/6 pinctrl: berlin: add the berlin4ct pinctrl driver

In reply to Jisheng Zhang

Add the pin-controller driver for Marvell Berlin BG4CT SoC, with definition of its groups and functions. This uses the core Berlin pinctrl driver.

---
 drivers/pinctrl/berlin/Kconfig        |   5 +
 drivers/pinctrl/berlin/Makefile       |   1 +
 drivers/pinctrl/berlin/berlin-bg4ct.c | 503 ++++++++++++++++++++++++++++++++++
 3 files changed, 509 insertions(+)
 create mode 100644 drivers/pinctrl/berlin/berlin-bg4ct.c
drivers/pinctrl/berlin/Kconfig +5 -0
index b18322b..c13f6d2 100644
@@ -17,4 +17,9 @@ config PINCTRL_BERLIN_BG2Q
 	bool
 	select PINCTRL_BERLIN
 
+config PINCTRL_BERLIN_BG4CT
+	depends on OF && (ARCH_BERLIN || COMPILE_TEST)
+	bool "Marvell berlin4ct pin controller driver"
+	select PINCTRL_BERLIN
+
 endif
drivers/pinctrl/berlin/Makefile +1 -0
index deb0c6b..06f9402 100644
@@ -2,3 +2,4 @@ obj-$(CONFIG_PINCTRL_BERLIN)		+= berlin.o
 obj-$(CONFIG_PINCTRL_BERLIN_BG2)	+= berlin-bg2.o
 obj-$(CONFIG_PINCTRL_BERLIN_BG2CD)	+= berlin-bg2cd.o
 obj-$(CONFIG_PINCTRL_BERLIN_BG2Q)	+= berlin-bg2q.o
+obj-$(CONFIG_PINCTRL_BERLIN_BG4CT)	+= berlin-bg4ct.o
drivers/pinctrl/berlin/berlin-bg4ct.c new file +503 -0

503 lines not on this page · raw message

Signature · 1 line
2.6.1
#7 lore raw

PATCH v4 3/6 arm64: berlin: add the pinctrl dependency for Marvell Berlin SoCs

In reply to Jisheng Zhang

This is to add the pinctrl dependency for Marvell Berlin SoCs.

---
 arch/arm64/Kconfig.platforms | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/Kconfig.platforms +1 -0
index c6e2c75..3d17ee2 100644
@@ -9,6 +9,7 @@ config ARCH_BERLIN
 	bool "Marvell Berlin SoC Family"
 	select ARCH_REQUIRE_GPIOLIB
 	select DW_APB_ICTL
+	select PINCTRL
 	help
 	  This enables support for Marvell Berlin SoC Family
 
Signature · 1 line
2.6.1
#9 lore raw

PATCH v4 4/6 pinctrl: dt-binding: document berlin4ct SoC pinctrl

In reply to Jisheng Zhang

Add berlin4ct to existing berlin pinctrl device tree binding.

---
 Documentation/devicetree/bindings/pinctrl/berlin,pinctrl.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/pinctrl/berlin,pinctrl.txt +4 -1
index a8bb5e2..f8fa28c 100644
@@ -20,7 +20,10 @@ Required properties:
 	"marvell,berlin2cd-soc-pinctrl",
 	"marvell,berlin2cd-system-pinctrl",
 	"marvell,berlin2q-soc-pinctrl",
-	"marvell,berlin2q-system-pinctrl"
+	"marvell,berlin2q-system-pinctrl",
+	"marvell,berlin4ct-avio-pinctrl",
+	"marvell,berlin4ct-soc-pinctrl",
+	"marvell,berlin4ct-system-pinctrl"
 
 Required subnode-properties:
 - groups: a list of strings describing the group names.
Signature · 1 line
2.6.1
#11 lore raw

PATCH v4 5/6 arm64: dts: berlin4ct: add the pinctrl node

In reply to Jisheng Zhang

Add the avio, soc, sm pinctrl nodes for Marvell berlin4ct SoC.

---
 arch/arm64/boot/dts/marvell/berlin4ct.dtsi | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm64/boot/dts/marvell/berlin4ct.dtsi +15 -0
index a3b5f1d..8e66355 100644
@@ -225,6 +225,16 @@
 			};
 		};
 
+		soc_pinctrl: pin-controller at ea8000 {
+			compatible = "marvell,berlin4ct-soc-pinctrl";
+			reg = <0xea8000 0x14>;
+		};
+
+		avio_pinctrl: pin-controller at ea8400 {
+			compatible = "marvell,berlin4ct-avio-pinctrl";
+			reg = <0xea8400 0x8>;
+		};
+
 		apb at fc0000 {
 			compatible = "simple-bus";
 			#address-cells = <1>;
@@ -280,5 +290,10 @@
 				status = "disabled";
 			};
 		};
+
+		system_pinctrl: pin-controller at fe2200 {
+			compatible = "marvell,berlin4ct-system-pinctrl";
+			reg = <0xfe2200 0xc>;
+		};
 	};
 };
Signature · 1 line
2.6.1
#13 lore raw

PATCH v4 6/6 arm64: dts: berlin4ct: add default pinmux for uart0

In reply to Jisheng Zhang

Add urt0 txd and rxd muxing setup in the dtsi because uart0 always uses them to work, no other possibilities.

---
 arch/arm64/boot/dts/marvell/berlin4ct.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/marvell/berlin4ct.dtsi +7 -0
index 8e66355..a4a1876 100644
@@ -288,12 +288,19 @@
 				clocks = <&osc>;
 				reg-shift = <2>;
 				status = "disabled";
+				pinctrl-0 = <&uart0_pmux>;
+				pinctrl-names = "default";
 			};
 		};
 
 		system_pinctrl: pin-controller at fe2200 {
 			compatible = "marvell,berlin4ct-system-pinctrl";
 			reg = <0xfe2200 0xc>;
+
+			uart0_pmux: uart0-pmux {
+				groups = "SM_URT0_TXD", "SM_URT0_RXD";
+				function = "uart0";
+			};
 		};
 	};
 };
Signature · 1 line
2.6.1
#4 lore raw

Re: [PATCH v4 2/6] pinctrl: berlin: add the berlin4ct pinctrl driver

In reply to Jisheng Zhang

Hi Jisheng,

Quoted 5 lines · Jisheng Zhang
drivers/pinctrl/berlin/Kconfig +0 -0
index b18322b..c13f6d2 100644

drivers/pinctrl/berlin/Kconfig config PINCTRL_BERLIN_BG2Q · line 25

Quoted 9 lines
drivers/pinctrl/berlin/Kconfig +5 -0
@@ -17,4 +17,9 @@ config PINCTRL_BERLIN_BG2Q
 	bool
 	select PINCTRL_BERLIN
 
+config PINCTRL_BERLIN_BG4CT
+	depends on OF && (ARCH_BERLIN || COMPILE_TEST)
+	bool "Marvell berlin4ct pin controller driver"
+	select PINCTRL_BERLIN
+
 endif

This endif ends the following condition:

	if ARCH_BERLIN
	[...]

So the "depends on ARCH_BERLIN" here can be dropped. Also the COMPILE_TEST can be moved as it isn't BG4CT specific and all other Berlin pinctrl drivers would benefit from this.

So we would have something like:

	if (ARCH_BERLIN || COMPILE_TEST)
	[...]
	endif

Finally you can move the OF dependency to the PINCTRL_BERLIN config as all Berlin pinctrl drivers depends on it.

Thanks!

Antoine

Signature · 3 lines
Antoine T?nart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
Acked-by on v4 1/6
#2 lore raw

Re: [PATCH v4 1/6] pinctrl: berlin: introduce berlin_pinctrl_probe_regmap()

In reply to Jisheng Zhang
Quoted 4 lines · Jisheng Zhang

This is to prepare for the next berlin4ct support, where we won't use simple-mfd any more.

Quoted 67 lines
---
 drivers/pinctrl/berlin/berlin.c | 26 +++++++++++++++++---------
 drivers/pinctrl/berlin/berlin.h |  4 ++++
 2 files changed, 21 insertions(+), 9 deletions(-)
drivers/pinctrl/berlin/berlin.c +17 -9
index f495806..898afa4 100644
@@ -292,20 +292,14 @@ static struct pinctrl_desc berlin_pctrl_desc = {
 	.owner		= THIS_MODULE,
 };
 
-int berlin_pinctrl_probe(struct platform_device *pdev,
-			 const struct berlin_pinctrl_desc *desc)
+int berlin_pinctrl_probe_regmap(struct platform_device *pdev,
+				const struct berlin_pinctrl_desc *desc,
+				struct regmap *regmap)
 {
 	struct device *dev = &pdev->dev;
-	struct device_node *parent_np = of_get_parent(dev->of_node);
 	struct berlin_pinctrl *pctrl;
-	struct regmap *regmap;
 	int ret;
 
-	regmap = syscon_node_to_regmap(parent_np);
-	of_node_put(parent_np);
-	if (IS_ERR(regmap))
-		return PTR_ERR(regmap);
-
 	pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL);
 	if (!pctrl)
 		return -ENOMEM;
@@ -330,3 +324,17 @@ int berlin_pinctrl_probe(struct platform_device *pdev,
 
 	return 0;
 }
+
+int berlin_pinctrl_probe(struct platform_device *pdev,
+			 const struct berlin_pinctrl_desc *desc)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *parent_np = of_get_parent(dev->of_node);
+	struct regmap *regmap = syscon_node_to_regmap(parent_np);
+
+	of_node_put(parent_np);
+	if (IS_ERR(regmap))
+		return PTR_ERR(regmap);
+
+	return berlin_pinctrl_probe_regmap(pdev, desc, regmap);
+}
drivers/pinctrl/berlin/berlin.h +4 -0
index e1aa841..dabbd2a 100644
@@ -58,4 +58,8 @@ struct berlin_pinctrl_function {
 int berlin_pinctrl_probe(struct platform_device *pdev,
 			 const struct berlin_pinctrl_desc *desc);
 
+int berlin_pinctrl_probe_regmap(struct platform_device *pdev,
+				const struct berlin_pinctrl_desc *desc,
+				struct regmap *regmap);
+
 #endif /* __PINCTRL_BERLIN_H */
Signature · 1 line
2.6.1
Signature · 3 lines
Antoine T?nart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
Acked-by on v4 3/6
#8 lore raw

Re: [PATCH v4 3/6] arm64: berlin: add the pinctrl dependency for Marvell Berlin SoCs

In reply to Jisheng Zhang
Quoted 3 lines · Jisheng Zhang

This is to add the pinctrl dependency for Marvell Berlin SoCs.

Quoted 19 lines
---
 arch/arm64/Kconfig.platforms | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/Kconfig.platforms +1 -0
index c6e2c75..3d17ee2 100644
@@ -9,6 +9,7 @@ config ARCH_BERLIN
 	bool "Marvell Berlin SoC Family"
 	select ARCH_REQUIRE_GPIOLIB
 	select DW_APB_ICTL
+	select PINCTRL
 	help
 	  This enables support for Marvell Berlin SoC Family
 
Signature · 1 line
2.6.1
Signature · 3 lines
Antoine T?nart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
Acked-by on v4 4/6
#10 lore raw

Re: [PATCH v4 4/6] pinctrl: dt-binding: document berlin4ct SoC pinctrl

In reply to Jisheng Zhang
Quoted 3 lines · Jisheng Zhang

Add berlin4ct to existing berlin pinctrl device tree binding.

Quoted 23 lines
---
 Documentation/devicetree/bindings/pinctrl/berlin,pinctrl.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/pinctrl/berlin,pinctrl.txt +4 -1
index a8bb5e2..f8fa28c 100644
@@ -20,7 +20,10 @@ Required properties:
 	"marvell,berlin2cd-soc-pinctrl",
 	"marvell,berlin2cd-system-pinctrl",
 	"marvell,berlin2q-soc-pinctrl",
-	"marvell,berlin2q-system-pinctrl"
+	"marvell,berlin2q-system-pinctrl",
+	"marvell,berlin4ct-avio-pinctrl",
+	"marvell,berlin4ct-soc-pinctrl",
+	"marvell,berlin4ct-system-pinctrl"
 
 Required subnode-properties:
 - groups: a list of strings describing the group names.
Signature · 1 line
2.6.1
Signature · 3 lines
Antoine T?nart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
Acked-by on v4 5/6
#12 lore raw

Re: [PATCH v4 5/6] arm64: dts: berlin4ct: add the pinctrl node

In reply to Jisheng Zhang
Quoted 3 lines · Jisheng Zhang

Add the avio, soc, sm pinctrl nodes for Marvell berlin4ct SoC.

Quoted 39 lines
---
 arch/arm64/boot/dts/marvell/berlin4ct.dtsi | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm64/boot/dts/marvell/berlin4ct.dtsi +15 -0
index a3b5f1d..8e66355 100644
@@ -225,6 +225,16 @@
 			};
 		};
 
+		soc_pinctrl: pin-controller at ea8000 {
+			compatible = "marvell,berlin4ct-soc-pinctrl";
+			reg = <0xea8000 0x14>;
+		};
+
+		avio_pinctrl: pin-controller at ea8400 {
+			compatible = "marvell,berlin4ct-avio-pinctrl";
+			reg = <0xea8400 0x8>;
+		};
+
 		apb at fc0000 {
 			compatible = "simple-bus";
 			#address-cells = <1>;
@@ -280,5 +290,10 @@
 				status = "disabled";
 			};
 		};
+
+		system_pinctrl: pin-controller at fe2200 {
+			compatible = "marvell,berlin4ct-system-pinctrl";
+			reg = <0xfe2200 0xc>;
+		};
 	};
 };
Signature · 1 line
2.6.1
Signature · 3 lines
Antoine T?nart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
Acked-by on v4 6/6
#14 lore raw

Re: [PATCH v4 6/6] arm64: dts: berlin4ct: add default pinmux for uart0

In reply to Jisheng Zhang
Quoted 4 lines · Jisheng Zhang

Add urt0 txd and rxd muxing setup in the dtsi because uart0 always uses them to work, no other possibilities.

Quoted 36 lines
---
 arch/arm64/boot/dts/marvell/berlin4ct.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/marvell/berlin4ct.dtsi +7 -0
index 8e66355..a4a1876 100644
@@ -288,12 +288,19 @@
 				clocks = <&osc>;
 				reg-shift = <2>;
 				status = "disabled";
+				pinctrl-0 = <&uart0_pmux>;
+				pinctrl-names = "default";
 			};
 		};
 
 		system_pinctrl: pin-controller at fe2200 {
 			compatible = "marvell,berlin4ct-system-pinctrl";
 			reg = <0xfe2200 0xc>;
+
+			uart0_pmux: uart0-pmux {
+				groups = "SM_URT0_TXD", "SM_URT0_RXD";
+				function = "uart0";
+			};
 		};
 	};
 };
Signature · 7 lines
2.6.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 3 lines
Antoine T?nart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#5 lore raw

Re: [PATCH v4 2/6] pinctrl: berlin: add the berlin4ct pinctrl driver

In reply to Antoine Tenart

Hi Antoine,

Quoted 23 lines · On Fri, 9 Oct 2015 11:03:53 +0200 Antoine Tenart…

Hi Jisheng,

Quoted 5 lines · Jisheng Zhang
drivers/pinctrl/berlin/Kconfig +0 -0
index b18322b..c13f6d2 100644

drivers/pinctrl/berlin/Kconfig config PINCTRL_BERLIN_BG2Q · line 25

Quoted 9 lines
drivers/pinctrl/berlin/Kconfig +5 -0
@@ -17,4 +17,9 @@ config PINCTRL_BERLIN_BG2Q
 	bool
 	select PINCTRL_BERLIN
 
+config PINCTRL_BERLIN_BG4CT
+	depends on OF && (ARCH_BERLIN || COMPILE_TEST)
+	bool "Marvell berlin4ct pin controller driver"
+	select PINCTRL_BERLIN
+
 endif

This endif ends the following condition:

	if ARCH_BERLIN
	[...]
Quoted 7 lines

So the "depends on ARCH_BERLIN" here can be dropped. Also the COMPILE_TEST can be moved as it isn't BG4CT specific and all other Berlin pinctrl drivers would benefit from this.

So we would have something like:

	if (ARCH_BERLIN || COMPILE_TEST)

Oh yeah! This is better.

Quoted 5 lines
	[...]
	endif

Finally you can move the OF dependency to the PINCTRL_BERLIN config as all Berlin pinctrl drivers depends on it.

PINCTRL_BERLIN isn't user visible and it's selected by PINCTRL_BERLIN_BG4CT. So we may have the following random config case:

CONFIG_OF=n
CONFIG_PINCTRL_BERLIN_BG4CT=y

In this case, there will be build errors for we missed OF. So we have to make PINCTRL_BERLIN_BG4CT depends on OF. What do you think? Or is there better solution?

Thanks for kind review,
Jisheng

Quoted 5 lines

Thanks!

Antoine

#6 lore raw

Re: [PATCH v4 2/6] pinctrl: berlin: add the berlin4ct pinctrl driver

Hi Jisheng,

Quoted 9 lines · Jisheng Zhang
Quoted 3 lines · On Fri, 9 Oct 2015 11:03:53 +0200 Antoine Tenart…

Finally you can move the OF dependency to the PINCTRL_BERLIN config as all Berlin pinctrl drivers depends on it.

PINCTRL_BERLIN isn't user visible and it's selected by PINCTRL_BERLIN_BG4CT. So we may have the following random config case:

Quoted 6 lines

CONFIG_OF=n
CONFIG_PINCTRL_BERLIN_BG4CT=y

In this case, there will be build errors for we missed OF. So we have to make PINCTRL_BERLIN_BG4CT depends on OF. What do you think? Or is there better solution?

That's true.

But because other Berlin pinctrl drivers also depends on CONFIG_OF, we need to make then depend on it too. This isn't the topic of this series so I'll send a separate patch later.

Antoine

Signature · 3 lines
Antoine T?nart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com