Skip to contentSkip to conversation

ARM: dts: imx6: Specify 'anatop-enable-bit' where appropriate

PATCH In review Andrey Smirnov 4 participants 8 messages Jan 10, 2017 – Jan 24, 2017

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

PATCH 1/2 ARM: dts: imx6: Specify 'anatop-enable-bit' where appropriate

ENABLE_LINREG bit is implemented by 3P0, 1P1 and 2P5 regulators on i.MX6. This property is present in similar code in Fresscale BSP and made its way upstream in imx6ul.dtsi, so this patch adds this property to the rest of i.MX6 family for completness.

Cc yurovsky at gmail.com
Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Russell King <[email protected]>
Cc devicetree at vger.kernel.org
Cc linux-kernel at vger.kernel.org
---
 arch/arm/boot/dts/imx6qdl.dtsi | 3 +++
 arch/arm/boot/dts/imx6sl.dtsi  | 3 +++
 arch/arm/boot/dts/imx6sx.dtsi  | 3 +++
 3 files changed, 9 insertions(+)
arch/arm/boot/dts/imx6qdl.dtsi +3 -0
index 89b834f..9702e18 100644
@@ -635,6 +635,7 @@
 					anatop-min-bit-val = <4>;
 					anatop-min-voltage = <800000>;
 					anatop-max-voltage = <1375000>;
+					anatop-enable-bit = <0>;
 				};
 
 				regulator-3p0 {
@@ -649,6 +650,7 @@
 					anatop-min-bit-val = <0>;
 					anatop-min-voltage = <2625000>;
 					anatop-max-voltage = <3400000>;
+					anatop-enable-bit = <0>;
 				};
 
 				regulator-2p5 {
@@ -663,6 +665,7 @@
 					anatop-min-bit-val = <0>;
 					anatop-min-voltage = <2000000>;
 					anatop-max-voltage = <2750000>;
+					anatop-enable-bit = <0>;
 				};
 
 				reg_arm: regulator-vddcore {
arch/arm/boot/dts/imx6sl.dtsi +3 -0
index 19cbd87..a478a06f 100644
@@ -522,6 +522,7 @@
 					anatop-min-bit-val = <4>;
 					anatop-min-voltage = <800000>;
 					anatop-max-voltage = <1375000>;
+					anatop-enable-bit = <0>;
 				};
 
 				regulator-3p0 {
@@ -536,6 +537,7 @@
 					anatop-min-bit-val = <0>;
 					anatop-min-voltage = <2625000>;
 					anatop-max-voltage = <3400000>;
+					anatop-enable-bit = <0>;
 				};
 
 				regulator-2p5 {
@@ -550,6 +552,7 @@
 					anatop-min-bit-val = <0>;
 					anatop-min-voltage = <2100000>;
 					anatop-max-voltage = <2850000>;
+					anatop-enable-bit = <0>;
 				};
 
 				reg_arm: regulator-vddcore {
arch/arm/boot/dts/imx6sx.dtsi +3 -0
index 10f3330..3de3cca 100644
@@ -578,6 +578,7 @@
 					anatop-min-bit-val = <4>;
 					anatop-min-voltage = <800000>;
 					anatop-max-voltage = <1375000>;
+					anatop-enable-bit = <0>;
 				};
 
 				regulator-3p0 {
@@ -592,6 +593,7 @@
 					anatop-min-bit-val = <0>;
 					anatop-min-voltage = <2625000>;
 					anatop-max-voltage = <3400000>;
+					anatop-enable-bit = <0>;
 				};
 
 				regulator-2p5 {
@@ -606,6 +608,7 @@
 					anatop-min-bit-val = <0>;
 					anatop-min-voltage = <2100000>;
 					anatop-max-voltage = <2875000>;
+					anatop-enable-bit = <0>;
 				};
 
 				reg_arm: regulator-vddcore {
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/1 regulator: anatop: Add support for "anatop-enable-bit"

Add code to support support for "anatop-enable-bit" device-tree property. This property translates to LINREG_ENABLE bit in real hardware and is present on 1p1, 2p5 and 3p0 regulators on i.MX6 and 1p0d regulator on i.MX7.

---

Note: "anatop-enable-bit" has already found its way into upstream tree before this patch (probably not on purpose). See imx6ul.dtsi and imx7s.dtsi for concrete examples

 .../devicetree/bindings/regulator/anatop-regulator.txt       |  1 +
 drivers/regulator/anatop-regulator.c                         | 12 ++++++++++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/regulator/anatop-regulator.txt +1 -0
index 37c4ea0..1d58c8c 100644
@@ -14,6 +14,7 @@ Optional properties:
 - anatop-delay-bit-shift: Bit shift for the step time register
 - anatop-delay-bit-width: Number of bits used in the step time register
 - vin-supply: The supply for this regulator
+- anatop-enable-bit: Regulator enable bit offset
 
 Any property defined as part of the core regulator
 binding, defined in regulator.txt, can also be used.
drivers/regulator/anatop-regulator.c +12 -0
index 3a6d029..b041f27 100644
@@ -301,7 +301,19 @@ static int anatop_regulator_probe(struct platform_device *pdev)
 			return -EINVAL;
 		}
 	} else {
+		u32 enable_bit;
+
 		rdesc->ops = &anatop_rops;
+
+		if (!of_property_read_u32(np, "anatop-enable-bit",
+					  &enable_bit)) {
+			anatop_rops.enable  = regulator_enable_regmap;
+			anatop_rops.disable = regulator_disable_regmap;
+			anatop_rops.is_enabled = regulator_is_enabled_regmap;
+
+			rdesc->enable_reg = sreg->control_reg;
+			rdesc->enable_mask = BIT(enable_bit);
+		}
 	}
 
 	/* register regulator */
Signature · 1 line
2.9.3
maintainer
#2 lore raw

Re: [PATCH] regulator: anatop: Add support for "anatop-enable-bit"

Quoted 13 lines · Andrey Smirnov

Add code to support support for "anatop-enable-bit" device-tree property. This property translates to LINREG_ENABLE bit in real hardware and is present on 1p1, 2p5 and 3p0 regulators on i.MX6 and 1p0d regulator on i.MX7.

Quoted 5 lines

---

Note: "anatop-enable-bit" has already found its way into upstream tree before this patch (probably not on purpose). See imx6ul.dtsi and imx7s.dtsi for concrete examples

But since the kernel is not using it, it doesn't really mean we have to keep it. Yes, other OSs could be, but that's unlikely.

Documentation/devicetree/bindings/regulator/anatop-regulator.txt Optional properties: · line 17

Quoted 13 lines
 .../devicetree/bindings/regulator/anatop-regulator.txt       |  1 +
 drivers/regulator/anatop-regulator.c                         | 12 ++++++++++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/regulator/anatop-regulator.txt +1 -0
index 37c4ea0..1d58c8c 100644
@@ -14,6 +14,7 @@ Optional properties:
 - anatop-delay-bit-shift: Bit shift for the step time register
 - anatop-delay-bit-width: Number of bits used in the step time register
 - vin-supply: The supply for this regulator
+- anatop-enable-bit: Regulator enable bit offset

Looks like we have several properties describing the register layout. IMO, we should drop all of them and use the compatible strings to determine those instead.

Rob

maintainer Acked-by
#3 lore raw

Re: [PATCH] regulator: anatop: Add support for "anatop-enable-bit"

Quoted 27 lines · Rob Herring
Quoted 13 lines · Andrey Smirnov

Add code to support support for "anatop-enable-bit" device-tree property. This property translates to LINREG_ENABLE bit in real hardware and is present on 1p1, 2p5 and 3p0 regulators on i.MX6 and 1p0d regulator on i.MX7.

Quoted 5 lines

---

Note: "anatop-enable-bit" has already found its way into upstream tree before this patch (probably not on purpose). See imx6ul.dtsi and imx7s.dtsi for concrete examples

But since the kernel is not using it, it doesn't really mean we have to keep it. Yes, other OSs could be, but that's unlikely.

Quoted 4 lines
 .../devicetree/bindings/regulator/anatop-regulator.txt       |  1 +
 drivers/regulator/anatop-regulator.c                         | 12 ++++++++++++
 2 files changed, 13 insertions(+)
Quoted 13 lines

Documentation/devicetree/bindings/regulator/anatop-regulator.txt Optional properties: · line 17

Quoted 9 lines
Documentation/devicetree/bindings/regulator/anatop-regulator.txt +1 -0
index 37c4ea0..1d58c8c 100644
@@ -14,6 +14,7 @@ Optional properties:
 - anatop-delay-bit-shift: Bit shift for the step time register
 - anatop-delay-bit-width: Number of bits used in the step time register
 - vin-supply: The supply for this regulator
+- anatop-enable-bit: Regulator enable bit offset

Looks like we have several properties describing the register layout. IMO, we should drop all of them and use the compatible strings to determine those instead.

NM, I see this on each regulator...

maintainer
#4 lore raw

Applied "regulator: anatop: Add support for "anatop-enable-bit"" to the regulator tree

In reply to Andrey Smirnov

The patch

regulator: anatop: Add support for "anatop-enable-bit"

has been applied to the regulator tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From ca7734ad77b4ffb83a03c80b8d64d40c7ef49263 Mon Sep 17 00:00:00 2001

From: Andrey Smirnov <[email protected]>
Date: Tue, 10 Jan 2017 08:30:14 -0800
Subject: [PATCH] regulator: anatop: Add support for "anatop-enable-bit"

Add code to support support for "anatop-enable-bit" device-tree property. This property translates to LINREG_ENABLE bit in real hardware and is present on 1p1, 2p5 and 3p0 regulators on i.MX6 and 1p0d regulator on i.MX7.

---
 .../devicetree/bindings/regulator/anatop-regulator.txt       |  1 +
 drivers/regulator/anatop-regulator.c                         | 12 ++++++++++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/regulator/anatop-regulator.txt +1 -0
index 37c4ea076f88..1d58c8cfdbc0 100644
@@ -14,6 +14,7 @@ Optional properties:
 - anatop-delay-bit-shift: Bit shift for the step time register
 - anatop-delay-bit-width: Number of bits used in the step time register
 - vin-supply: The supply for this regulator
+- anatop-enable-bit: Regulator enable bit offset
 
 Any property defined as part of the core regulator
 binding, defined in regulator.txt, can also be used.
drivers/regulator/anatop-regulator.c +12 -0
index 3a6d0290c54c..b041f277a38b 100644
@@ -301,7 +301,19 @@ static int anatop_regulator_probe(struct platform_device *pdev)
 			return -EINVAL;
 		}
 	} else {
+		u32 enable_bit;
+
 		rdesc->ops = &anatop_rops;
+
+		if (!of_property_read_u32(np, "anatop-enable-bit",
+					  &enable_bit)) {
+			anatop_rops.enable  = regulator_enable_regmap;
+			anatop_rops.disable = regulator_disable_regmap;
+			anatop_rops.is_enabled = regulator_is_enabled_regmap;
+
+			rdesc->enable_reg = sreg->control_reg;
+			rdesc->enable_mask = BIT(enable_bit);
+		}
 	}
 
 	/* register regulator */
Signature · 1 line
2.11.0
#5 lore raw

PATCH 2/2 ARM: dts: imx7s: Adjust anatop-enable-bit for 'reg_1p0d'

In reply to Andrey Smirnov

In PMU_REG_1P0Dn ENABLE_LINREG is bit 0. Bit 31 is called OVERRIDE and it serves the funtion of granting permission to GPC IP block to alter various other bit-fields of the register. The reason why this property, that trickeld here from Freescale BSP, is set up like that is because in the code it came from it is used in conjunction with a notifier handler for REGULATOR_EVENT_PRE_DO_ENABLE and REGULATOR_EVENT_PRE_DO_DISABLE events (not found in upstream kernel) that triggers GPC to start manipulating aforementioned other bitfields.

Since:
a) none of the aforementioned machinery is implemented by upstream
b) using 'anatop-enable-bit' in that capacity is a bit of a semantic stretch

simplify the situation by setting the value of 'anatop-enable-bit' to point to ENABLE_LINREG (same as i.MX6).

Cc yurovsky at gmail.com
Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Russell King <[email protected]>
Cc devicetree at vger.kernel.org
Cc linux-kernel at vger.kernel.org
---
 arch/arm/boot/dts/imx7s.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/imx7s.dtsi +1 -1
index 8ff2cbdd..c80d0db 100644
@@ -509,7 +509,7 @@
 					anatop-min-bit-val = <8>;
 					anatop-min-voltage = <800000>;
 					anatop-max-voltage = <1200000>;
-					anatop-enable-bit = <31>;
+					anatop-enable-bit = <0>;
 				};
 			};
 
Signature · 1 line
2.9.3
reviewer
#6 lore raw
In reply to Andrey Smirnov
Quoted 4 lines · Andrey Smirnov

ENABLE_LINREG bit is implemented by 3P0, 1P1 and 2P5 regulators on i.MX6. This property is present in similar code in Fresscale BSP and made its way upstream in imx6ul.dtsi, so this patch adds this property to the rest of i.MX6 family for completness.

Please see:
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/patch/arch/arm/boot/dts/imx6ul.dtsi?id=27958ccdf29e9971732e02494b48be54b0691269

#7 lore raw
Quoted 9 lines · Fabio Estevam
Quoted 4 lines · Andrey Smirnov

ENABLE_LINREG bit is implemented by 3P0, 1P1 and 2P5 regulators on i.MX6. This property is present in similar code in Fresscale BSP and made its way upstream in imx6ul.dtsi, so this patch adds this property to the rest of i.MX6 family for completness.

Please see:
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/patch/arch/arm/boot/dts/imx6ul.dtsi?id=27958ccdf29e9971732e02494b48be54b0691269

Fabio:

I submitted a patch implementing this property to LKML as well, see
https://www.spinics.net/lists/kernel/msg2418471.html

All of these patches are a part of a broader attempt to add PCIe support for i.MX7, and on that platform this is a part of a 1P0D regulator which supplies PCIe PHY.

I can rebase this patch set to take your commit into account, or else let's discuss the best way to allow setting ENABLE_LINREG.

Thanks,
Andrey Smirnov