Skip to contentSkip to conversation

PHYTEC patches to be mainlined

PATCH Applied Andrej Picej 3 participants 14 messages Nov 19, 2021 – Mar 1, 2022

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

v2 cover PHYTEC patches to be mainlined

Hi all,

this patch series contains PHYTEC barebox patches which weren't yet introduced to this mailing list (or at least not in this form).

1. The first patch increases the stability during boot in extreme cold conditions.

2. The second and third patch adds some missing configs (OCOTP write support and some OF commands).

3. The last three patches (fourth, fifth and sixth) are meant as a fixup for patches that deleted the PMIC supply nodes. They were introduced because barebox doesn't support DA9063 PMIC regulator driver and instead prints ugly warnings (recently downgraded from error) like:

imx-esdhc [email protected]: Failed to get 'vmmc' regulator (ignored).

In either way, we rely on PMIC's reset default and use dummy regulators. Using barebox specific device-tree property ('barebox,allow-dummy-supply') shouldn't break booting Linux with barebox internal device-tree and allows using dummy regulators in bootloader where regulator support is limited. The complete solution would be porting DA9063 regulator driver to barebox, but let's add that to our "to-do" list for now and use this workaround instead.

Best regards,
Andrej

Changes in v2:
- remove "PHYTEC specific" config patch. Drop removing IPUV3 driver and move enabled configs to default imx_v7_defconfig,
- move "barebox,allow-dummy-supply" to be added to regulator provider

Andrej Picej (5):
ARM: configs: imx_v7_defconfig: add OF commands
ARM: configs: imx_v7_defconfig: add OCOTP write support
regulator: allow use of dummy regulator
ARM: dts: imx6qdl: pfla02: use dummy regulators
documentation: regulator: add allow-dummy-supply

Stefan Riedmueller (1):
flash-header-phytec-pcl063: Set SOC voltage to 1.25 V during boot

 .../bindings/regulator/regulator.rst          | 35 +++++++++++++++++++
 .../flash-header-phytec-pcl063.h              |  2 ++
 arch/arm/configs/imx_v7_defconfig             |  4 +++
 arch/arm/dts/imx6qdl-phytec-pfla02.dtsi       | 12 ++-----
 drivers/regulator/core.c                      | 20 +++++++++--
 5 files changed, 62 insertions(+), 11 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/regulator/regulator.rst
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH v2 1/6 flash-header-phytec-pcl063: Set SOC voltage to 1.25 V during boot

From: Stefan Riedmueller <[email protected]>

To increase stability during boot in cold conditions (< -30 °C) increase the SOC voltage from 1.15 V to 1.25 V in DCD. The ARM voltage is left unchanged at its default 1.15 V.

---
Changes in v2:
- no changes

---
 arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063.h +2 -0
index 9a8f5f18e..8e0ab6f58 100644
@@ -3,6 +3,8 @@ loadaddr 0x80000000
 soc imx6
 ivtofs 0x400
 
+wm 32 0x020c8140 0x00580012
+
 wm 32 0x020c4068 0xffffffff
 wm 32 0x020c406c 0xffffffff
 wm 32 0x020c4070 0xffffffff
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH v2 2/6 ARM: configs: imx_v7_defconfig: add OF commands

In reply to Andrej Picej

Add OF commands:
- of_overlay,
- of_display_timings and
- of_fixup_status.

---
Changes in v2:
- drop "PHYTEC specific" patch and add changes directly to imx_v7_defconfig

---
 arch/arm/configs/imx_v7_defconfig | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/configs/imx_v7_defconfig +3 -0
index 624698ae3..29c2d3190 100644
@@ -133,6 +133,9 @@ CONFIG_CMD_WD=y
 CONFIG_CMD_BAREBOX_UPDATE=y
 CONFIG_CMD_OF_NODE=y
 CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OF_DISPLAY_TIMINGS=y
+CONFIG_CMD_OF_FIXUP_STATUS=y
+CONFIG_CMD_OF_OVERLAY=y
 CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_STATE=y
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH v2 3/6 ARM: configs: imx_v7_defconfig: add OCOTP write support

In reply to Andrej Picej

---
Changes in v2:
- drop "PHYTEC specific" patch and add changes directly to imx_v7_defconfig

---
 arch/arm/configs/imx_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm/configs/imx_v7_defconfig +1 -0
index 29c2d3190..8e707b960 100644
@@ -198,6 +198,7 @@ CONFIG_WATCHDOG=y
 CONFIG_WATCHDOG_IMX=y
 CONFIG_PWM=y
 CONFIG_PWM_IMX=y
+CONFIG_IMX_OCOTP_WRITE=y
 CONFIG_MXS_APBH_DMA=y
 CONFIG_GPIO_STMPE=y
 CONFIG_REGULATOR=y
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH v2 4/6 regulator: allow use of dummy regulator

In reply to Andrej Picej

The idea of devicetree property which allows use of dummy regulator is not new but has not been implemented until now.
This implementation uses barebox specific devicetree property "barebox,allow-dummy-supply" to allow switching to a dummy power regulator in cases where proper regulator driver is not available. This property can be set for regulator or for PMIC regulators nodes, which then allow use of dummy regulator for all its child nodes. Basically just catch the regulators ensure_probed error, if "barebox,allow-dummy-supply" property is set and return dummy regulator.

---
Changes in v2:
- node is now added on regulator side, so check for property on provider side

---
 drivers/regulator/core.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/regulator/core.c +18 -2
index 097f7d779..4f45c23cd 100644
@@ -197,7 +197,7 @@ static struct regulator_internal *of_regulator_get(struct device_d *dev, const c
 {
 	char *propname;
 	struct regulator_internal *ri;
-	struct device_node *node;
+	struct device_node *node, *node_parent;
 	int ret;
 
 	propname = basprintf("%s-supply", supply);
@@ -231,8 +231,24 @@ static struct regulator_internal *of_regulator_get(struct device_d *dev, const c
 	}
 
 	ret = of_device_ensure_probed(node);
-	if (ret)
+	if (ret) {
+		/* 
+		 * If "barebox,allow-dummy-supply" property is set for regulator
+		 * provider allow use of dummy regulator (NULL is returned).
+		 * Check regulator node and its parent if this setting is set
+		 * PMIC wide.
+		 */
+		node_parent = of_get_parent(node);
+		if (of_get_property(node, "barebox,allow-dummy-supply", NULL) ||
+		    of_get_property(node_parent, "barebox,allow-dummy-supply", NULL)) {
+			dev_dbg(dev, "Allow use of dummy regulator for " \
+				"%s-supply\n", supply);
+			ri = NULL;
+			goto out;
+		}
+
 		return ERR_PTR(ret);
+	}
 
 	list_for_each_entry(ri, &regulator_list, list) {
 		if (ri->node == node) {
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

Re: [PATCH v2 4/6] regulator: allow use of dummy regulator

Quoted 10 lines · Andrej Picej
        ret = of_device_ensure_probed(node);
drivers/regulator/core.c +7 -1
-       if (ret)
+       if (ret) {
+               /*
+                * If "barebox,allow-dummy-supply" property is set for regulator
+                * provider allow use of dummy regulator (NULL is returned).
+                * Check regulator node and its parent if this setting is set
+                * PMIC wide.
+                */

drivers/regulator/core.c static struct regulator_internal *of_regulator_get(struct device_d *dev, const c · line 250

Quoted 10 lines
drivers/regulator/core.c +9 -0
+               node_parent = of_get_parent(node);
+               if (of_get_property(node, "barebox,allow-dummy-supply", NULL) ||
+                   of_get_property(node_parent, "barebox,allow-dummy-supply", NULL)) {
+                       dev_dbg(dev, "Allow use of dummy regulator for " \
+                               "%s-supply\n", supply);
+                       ri = NULL;
+                       goto out;
+               }
+
                return ERR_PTR(ret);

This return, which was added in "common: add initial barebox deep-probe support", is a memory leak of propname. It should be goto out.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#6 lore raw

Re: [PATCH v2 4/6] regulator: allow use of dummy regulator

Quoted 22 lines · Trent Piepho
Quoted 10 lines · Andrej Picej
         ret = of_device_ensure_probed(node);
drivers/regulator/core.c +7 -1
-       if (ret)
+       if (ret) {
+               /*
+                * If "barebox,allow-dummy-supply" property is set for regulator
+                * provider allow use of dummy regulator (NULL is returned).
+                * Check regulator node and its parent if this setting is set
+                * PMIC wide.
+                */

drivers/regulator/core.c static struct regulator_internal *of_regulator_get(struct device_d *dev, const c · line 250

Quoted 10 lines
drivers/regulator/core.c +9 -0
+               node_parent = of_get_parent(node);
+               if (of_get_property(node, "barebox,allow-dummy-supply", NULL) ||
+                   of_get_property(node_parent, "barebox,allow-dummy-supply", NULL)) {
+                       dev_dbg(dev, "Allow use of dummy regulator for " \
+                               "%s-supply\n", supply);
+                       ri = NULL;
+                       goto out;
+               }
+
                 return ERR_PTR(ret);
Quoted 4 lines

This return, which was added in "common: add initial barebox deep-probe support", is a memory leak of propname. It should be goto out.

You are right, if that's ok I will create a separate patch for that.

BR, Andrej

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#7 lore raw

PATCH 1/1 regulator: fix memory leak

In reply to Trent Piepho

Fix memory leak of propname.

---
 drivers/regulator/core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/regulator/core.c +4 -2
index 097f7d779..c5cb9ee34 100644
@@ -231,8 +231,10 @@ static struct regulator_internal *of_regulator_get(struct device_d *dev, const c
 	}
 
 	ret = of_device_ensure_probed(node);
-	if (ret)
-		return ERR_PTR(ret);
+	if (ret) {
+		ri = ERR_PTR(ret);
+		goto out;
+	}
 
 	list_for_each_entry(ri, &regulator_list, list) {
 		if (ri->node == node) {
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

Re: [PATCH] regulator: fix memory leak

Gentle ping. The patch was probably missed as is was send as an reply to Trent's memory leak find.

Quoted 14 lines · Andrej Picej

Fix memory leak of propname.

---
  drivers/regulator/core.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/regulator/core.c +0 -0
index 097f7d779..c5cb9ee34 100644
@@ -231,8 +231,10 @@ static struct regulator_internal *of_regulator_get(struct device_d *dev, const c
  	}
 

drivers/regulator/core.c static struct regulator_internal *of_regulator_get(struct device_d *dev, const c · line 240

Quoted 10 lines
drivers/regulator/core.c +4 -2
  	ret = of_device_ensure_probed(node);
-	if (ret)
-		return ERR_PTR(ret);
+	if (ret) {
+		ri = ERR_PTR(ret);
+		goto out;
+	}
 
  	list_for_each_entry(ri, &regulator_list, list) {
  		if (ri->node == node) {

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#9 lore raw

Re: [PATCH] regulator: fix memory leak

Quoted 11 lines · Andrej Picej

Gentle ping. The patch was probably missed as is was send as an reply to Trent's memory leak find.

Quoted 7 lines · Andrej Picej

Fix memory leak of propname.

---
  drivers/regulator/core.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 13 lines

drivers/regulator/core.c static struct regulator_internal *of_regulator_get(struct device_d *dev, const c · line 236

Quoted 13 lines
drivers/regulator/core.c +4 -2
index 097f7d779..c5cb9ee34 100644
@@ -231,8 +231,10 @@ static struct regulator_internal *of_regulator_get(struct device_d *dev, const c
  	}
  	ret = of_device_ensure_probed(node);
-	if (ret)
-		return ERR_PTR(ret);
+	if (ret) {
+		ri = ERR_PTR(ret);
+		goto out;
+	}

This conflicts with b720625659 ("regulator: allow use of dummy regulator"). I fixed this up, see the result in next.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#10 lore raw

Re: [PATCH] regulator: fix memory leak

Quoted 12 lines · Sascha Hauer
Quoted 11 lines · Andrej Picej

Gentle ping. The patch was probably missed as is was send as an reply to Trent's memory leak find.

Quoted 7 lines · Andrej Picej

Fix memory leak of propname.

---
   drivers/regulator/core.c | 6 ++++--
   1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
drivers/regulator/core.c +0 -0
index 097f7d779..c5cb9ee34 100644
@@ -231,8 +231,10 @@ static struct regulator_internal *of_regulator_get(struct device_d *dev, const c
Quoted 8 lines

drivers/regulator/core.c static struct regulator_internal *of_regulator_get(struct device_d *dev, const c · line 237

Quoted 8 lines
drivers/regulator/core.c +4 -2
   	}
   	ret = of_device_ensure_probed(node);
-	if (ret)
-		return ERR_PTR(ret);
+	if (ret) {
+		ri = ERR_PTR(ret);
+		goto out;
+	}

This conflicts with b720625659 ("regulator: allow use of dummy regulator"). I fixed this up, see the result in next.

Ohh, ok. That was fast.

Thanks.
Andrej

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#11 lore raw

PATCH v2 5/6 ARM: dts: imx6qdl: pfla02: use dummy regulators

In reply to Andrej Picej

The power for the phyFLEX sd cards and ethernet controller are supplied by the DA9063 PMIC's LDOs. There is no barebox driver for those LDO regulators. Thus use dummy-regulators to suppress warning message.

---
Changes in v2:
- move "barebox,allow-dummy-supply" property from regulator consumer to regulator provider

---
 arch/arm/dts/imx6qdl-phytec-pfla02.dtsi | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
arch/arm/dts/imx6qdl-phytec-pfla02.dtsi +3 -9
index 0653fcc3c..ada160768 100644
@@ -81,15 +81,6 @@
 	};
 };
 
-&fec {
-	/*
-	 * barebox doesn't have a driver for the PMIC providing the phy-supply
-	 * (dlg,da9063). So remove the phy-supply property and rely on the
-	 * PMIC's reset default which has this supply enabled.
-	 */
-	/delete-property/ phy-supply;
-};
-
 &gpmi {
 	partitions {
 		compatible = "fixed-partitions";
@@ -162,5 +153,8 @@
 		watchdog-priority = <500>;
 		restart-priority = <500>;
 		reset-source-priority = <500>;
+		regulators {
+			barebox,allow-dummy-supply;
+		};
 	};
 };
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#12 lore raw

PATCH v2 6/6 documentation: regulator: add allow-dummy-supply

In reply to Andrej Picej

Add "barebox,allow-dummy-supply" property documentation.

---
Changes in v2:
- adapt documentation to changed usage

---
 .../bindings/regulator/regulator.rst          | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/regulator.rst
Documentation/devicetree/bindings/regulator/regulator.rst new file +35 -0
new file mode 100644
index 000000000..9afc020ac
@@ -0,0 +1,35 @@
+Voltage/Current Regulators
+==========================
+
+In addition to the upstream bindings, another property is added:
+
+Optional properties:
+- ``barebox,allow-dummy-supply`` : A property to allow usage of dummy power
+  regulator. This can be added to regulator nodes, whose drivers are not yet
+  supported. It will rely on regulator reset defaults and use of dummy regulator
+  instead.
+
+Examples:
+
+.. code-block:: none
+
+  pmic@58 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_pmic>;
+	compatible = "dlg,da9063";
+	reg = <0x58>;
+
+	regulators {
+		barebox,allow-dummy-supply;
+
+		vddcore_reg: bcore1 {
+			regulator-min-microvolt = <730000>;
+			regulator-max-microvolt = <1380000>;
+		};
+
+		vddsoc_reg: bcore2 {
+			regulator-min-microvolt = <730000>;
+			regulator-max-microvolt = <1380000>;
+		};
+	}
+  }
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#13 lore raw
In reply to Andrej Picej
Quoted 34 lines · Andrej Picej

Hi all,

this patch series contains PHYTEC barebox patches which weren't yet introduced to this mailing list (or at least not in this form).

1. The first patch increases the stability during boot in extreme cold conditions.

2. The second and third patch adds some missing configs (OCOTP write support and some OF commands).

3. The last three patches (fourth, fifth and sixth) are meant as a fixup for patches that deleted the PMIC supply nodes. They were introduced because barebox doesn't support DA9063 PMIC regulator driver and instead prints ugly warnings (recently downgraded from error) like:

imx-esdhc [email protected]: Failed to get 'vmmc' regulator (ignored).

In either way, we rely on PMIC's reset default and use dummy regulators. Using barebox specific device-tree property ('barebox,allow-dummy-supply') shouldn't break booting Linux with barebox internal device-tree and allows using dummy regulators in bootloader where regulator support is limited. The complete solution would be porting DA9063 regulator driver to barebox, but let's add that to our "to-do" list for now and use this workaround instead.

Best regards,
Andrej

Changes in v2:
- remove "PHYTEC specific" config patch. Drop removing IPUV3 driver and move enabled configs to default imx_v7_defconfig,
- move "barebox,allow-dummy-supply" to be added to regulator provider

Quoted 6 lines

Andrej Picej (5):
ARM: configs: imx_v7_defconfig: add OF commands
ARM: configs: imx_v7_defconfig: add OCOTP write support
regulator: allow use of dummy regulator
ARM: dts: imx6qdl: pfla02: use dummy regulators
documentation: regulator: add allow-dummy-supply

Applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox