Skip to contentSkip to conversation

regulator: twl6030: Fix the VMMC reset behavior

PATCH In review Gregory CLEMENT 2 participants 7 messages Jul 25, 2019 – Aug 12, 2019

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

cover regulator: twl6030: Fix the VMMC reset behavior

Hello,

With the TWL6030 PMIC, during reset the VMMC regulator doesn't reach 0V and only drops to 1.8V, furthermore the pulse width is under 200us whereas the SD specification expect 1ms.

Fortunately, the WR_S bit allows the TWL6030 to no reset at all the VMMC during warm reset and keep the current voltage. Thanks to this workaround the SD card doesn't reach a undefined reset stage.

The first patch describes the new property needed for this "feature".

The second one is just a small cleanup done while I wrote the last patch, but as it was not really related to the feature itself, I made a separate patch for it.

The last patch adds the feature in the driver.

Gregory

Gregory CLEMENT (3):
dt-bindings: regulator: twl6030: Add retain-on-reset property
regulator: twl6030: use variable for device node
regulator: twl6030: workaround the VMMC reset behavior

 .../bindings/regulator/twl-regulator.txt      |  7 +++++++
 drivers/regulator/twl6030-regulator.c         | 21 +++++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/3 dt-bindings: regulator: twl6030: Add retain-on-reset property

During reset the VMMC regulator doesn't reach 0V and only drops to 1.8V, furthermore the pulse width is under 200us whereas the SD specification expect 1ms.

For this 2 reasons being able to no reset at all the VMMC during warm reset and keep the current voltage is a good workaround. The TWL6030 allows this but needs to be aware of it and this configuration should also be shared with the bootloader.

This is the purpose of this new property: ti,retain-on-reset

---
 .../devicetree/bindings/regulator/twl-regulator.txt        | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/regulator/twl-regulator.txt +7 -0
index 74a91c4f8530..549f80436deb 100644
@@ -71,3 +71,10 @@ Example:
 		regulator-min-microvolt  = <1000000>;
 		regulator-max-microvolt  = <3000000>;
 	};
+
+For twl6030 regulators/LDOs:
+
+ - ti,retain-on-reset: Does not turn off the supplies during warm
+                       reset. Could be needed for VMMC, as TWL6030
+                       reset sequence for this signal does not comply
+                       with the SD specification.
Signature · 1 line
2.20.1
maintainer
#2 lore raw

Applied "dt-bindings: regulator: twl6030: Add retain-on-reset property" to the regulator tree

The patch

dt-bindings: regulator: twl6030: Add retain-on-reset property

has been applied to the regulator tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-5.4

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 906c4d5c939b4d8ebe7be357121271df7b8c9582 Mon Sep 17 00:00:00 2001

From: Gregory CLEMENT <[email protected]>
Date: Thu, 25 Jul 2019 11:45:40 +0200
Subject: [PATCH] dt-bindings: regulator: twl6030: Add retain-on-reset property

During reset the VMMC regulator doesn't reach 0V and only drops to 1.8V, furthermore the pulse width is under 200us whereas the SD specification expect 1ms.

For this 2 reasons being able to no reset at all the VMMC during warm reset and keep the current voltage is a good workaround. The TWL6030 allows this but needs to be aware of it and this configuration should also be shared with the bootloader.

This is the purpose of this new property: ti,retain-on-reset

---
 .../devicetree/bindings/regulator/twl-regulator.txt        | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/regulator/twl-regulator.txt +7 -0
index 74a91c4f8530..549f80436deb 100644
@@ -71,3 +71,10 @@ Example:
 		regulator-min-microvolt  = <1000000>;
 		regulator-max-microvolt  = <3000000>;
 	};
+
+For twl6030 regulators/LDOs:
+
+ - ti,retain-on-reset: Does not turn off the supplies during warm
+                       reset. Could be needed for VMMC, as TWL6030
+                       reset sequence for this signal does not comply
+                       with the SD specification.
Signature · 1 line
2.20.1
#3 lore raw

PATCH 2/3 regulator: twl6030: use variable for device node

In reply to Gregory CLEMENT

Instead of refering the full pdev->dev.of_node use a local variable.

---
 drivers/regulator/twl6030-regulator.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/twl6030-regulator.c +3 -3
index 5fe208b381eb..d73c81542ceb 100644
@@ -665,14 +665,14 @@ static int twlreg_probe(struct platform_device *pdev)
 	struct regulation_constraints	*c;
 	struct regulator_dev		*rdev;
 	struct regulator_config		config = { };
+	struct device_node		*np = pdev->dev.of_node;
 
 	template = of_device_get_match_data(&pdev->dev);
 	if (!template)
 		return -ENODEV;
 
 	id = template->desc.id;
-	initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node,
-						&template->desc);
+	initdata = of_get_regulator_init_data(&pdev->dev, np, &template->desc);
 	if (!initdata)
 		return -EINVAL;
 
@@ -713,7 +713,7 @@ static int twlreg_probe(struct platform_device *pdev)
 	config.dev = &pdev->dev;
 	config.init_data = initdata;
 	config.driver_data = info;
-	config.of_node = pdev->dev.of_node;
+	config.of_node = np;
 
 	rdev = devm_regulator_register(&pdev->dev, &info->desc, &config);
 	if (IS_ERR(rdev)) {
Signature · 1 line
2.20.1
maintainer
#4 lore raw

Applied "regulator: twl6030: use variable for device node" to the regulator tree

The patch

regulator: twl6030: use variable for device node

has been applied to the regulator tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-5.4

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 621d3ce830649d56ef1c9611e370d05ceaffd7fc Mon Sep 17 00:00:00 2001

From: Gregory CLEMENT <[email protected]>
Date: Thu, 25 Jul 2019 11:45:41 +0200
Subject: [PATCH] regulator: twl6030: use variable for device node

Instead of refering the full pdev->dev.of_node use a local variable.

---
 drivers/regulator/twl6030-regulator.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/twl6030-regulator.c +3 -3
index 5fe208b381eb..d73c81542ceb 100644
@@ -665,14 +665,14 @@ static int twlreg_probe(struct platform_device *pdev)
 	struct regulation_constraints	*c;
 	struct regulator_dev		*rdev;
 	struct regulator_config		config = { };
+	struct device_node		*np = pdev->dev.of_node;
 
 	template = of_device_get_match_data(&pdev->dev);
 	if (!template)
 		return -ENODEV;
 
 	id = template->desc.id;
-	initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node,
-						&template->desc);
+	initdata = of_get_regulator_init_data(&pdev->dev, np, &template->desc);
 	if (!initdata)
 		return -EINVAL;
 
@@ -713,7 +713,7 @@ static int twlreg_probe(struct platform_device *pdev)
 	config.dev = &pdev->dev;
 	config.init_data = initdata;
 	config.driver_data = info;
-	config.of_node = pdev->dev.of_node;
+	config.of_node = np;
 
 	rdev = devm_regulator_register(&pdev->dev, &info->desc, &config);
 	if (IS_ERR(rdev)) {
Signature · 1 line
2.20.1
#5 lore raw

PATCH 3/3 regulator: twl6030: workaround the VMMC reset behavior

In reply to Gregory CLEMENT

During reset the VMMC regulator doesn't reach 0V and only drops to 1.8V, furthermore the pulse width is under 200us whereas the SD specification expect 1ms.

The WR_S bit allows the TWL6030 to no reset at all the VMMC during warm reset and keep the current voltage. Thanks to this workaround the SD card doesn't reach a undefined reset stage.

Actually this behavior is available for all the LDO regulator, so the driver will also allow to use it with any of these regulator.

---
 drivers/regulator/twl6030-regulator.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/regulator/twl6030-regulator.c +14 -1
index d73c81542ceb..b8100c3cedad 100644
@@ -57,6 +57,9 @@ struct twlreg_info {
 #define VREG_BC_PROC		3
 #define VREG_BC_CLK_RST		4
 
+/* TWL6030 LDO register values for VREG_VOLTAGE */
+#define TWL6030_VREG_VOLTAGE_WR_S   BIT(7)
+
 /* TWL6030 LDO register values for CFG_STATE */
 #define TWL6030_CFG_STATE_OFF	0x00
 #define TWL6030_CFG_STATE_ON	0x01
@@ -68,9 +71,10 @@ struct twlreg_info {
 #define TWL6030_CFG_STATE_APP(v)	(((v) & TWL6030_CFG_STATE_APP_MASK) >>\
 						TWL6030_CFG_STATE_APP_SHIFT)
 
-/* Flags for SMPS Voltage reading */
+/* Flags for SMPS Voltage reading and LDO reading*/
 #define SMPS_OFFSET_EN		BIT(0)
 #define SMPS_EXTENDED_EN	BIT(1)
+#define TWL_6030_WARM_RESET	BIT(3)
 
 /* twl6032 SMPS EPROM values */
 #define TWL6030_SMPS_OFFSET		0xB0
@@ -250,6 +254,9 @@ twl6030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
 {
 	struct twlreg_info	*info = rdev_get_drvdata(rdev);
 
+	if (info->flags & TWL_6030_WARM_RESET)
+		selector |= TWL6030_VREG_VOLTAGE_WR_S;
+
 	return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE,
 			    selector);
 }
@@ -259,6 +266,9 @@ static int twl6030ldo_get_voltage_sel(struct regulator_dev *rdev)
 	struct twlreg_info	*info = rdev_get_drvdata(rdev);
 	int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE);
 
+	if (info->flags & TWL_6030_WARM_RESET)
+		vsel &= ~TWL6030_VREG_VOLTAGE_WR_S;
+
 	return vsel;
 }
 
@@ -710,6 +720,9 @@ static int twlreg_probe(struct platform_device *pdev)
 		break;
 	}
 
+	if (of_get_property(np, "ti,retain-on-reset", NULL))
+		info->flags |= TWL_6030_WARM_RESET;
+
 	config.dev = &pdev->dev;
 	config.init_data = initdata;
 	config.driver_data = info;
Signature · 1 line
2.20.1
maintainer
#6 lore raw

Applied "regulator: twl6030: workaround the VMMC reset behavior" to the regulator tree

The patch

regulator: twl6030: workaround the VMMC reset behavior

has been applied to the regulator tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-5.4

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 d9df0187b6edd5871255cee29128c63f134e599c Mon Sep 17 00:00:00 2001

From: Gregory CLEMENT <[email protected]>
Date: Thu, 25 Jul 2019 11:45:42 +0200
Subject: [PATCH] regulator: twl6030: workaround the VMMC reset behavior

During reset the VMMC regulator doesn't reach 0V and only drops to 1.8V, furthermore the pulse width is under 200us whereas the SD specification expect 1ms.

The WR_S bit allows the TWL6030 to no reset at all the VMMC during warm reset and keep the current voltage. Thanks to this workaround the SD card doesn't reach a undefined reset stage.

Actually this behavior is available for all the LDO regulator, so the driver will also allow to use it with any of these regulator.

---
 drivers/regulator/twl6030-regulator.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/regulator/twl6030-regulator.c +14 -1
index d73c81542ceb..b8100c3cedad 100644
@@ -57,6 +57,9 @@ struct twlreg_info {
 #define VREG_BC_PROC		3
 #define VREG_BC_CLK_RST		4
 
+/* TWL6030 LDO register values for VREG_VOLTAGE */
+#define TWL6030_VREG_VOLTAGE_WR_S   BIT(7)
+
 /* TWL6030 LDO register values for CFG_STATE */
 #define TWL6030_CFG_STATE_OFF	0x00
 #define TWL6030_CFG_STATE_ON	0x01
@@ -68,9 +71,10 @@ struct twlreg_info {
 #define TWL6030_CFG_STATE_APP(v)	(((v) & TWL6030_CFG_STATE_APP_MASK) >>\
 						TWL6030_CFG_STATE_APP_SHIFT)
 
-/* Flags for SMPS Voltage reading */
+/* Flags for SMPS Voltage reading and LDO reading*/
 #define SMPS_OFFSET_EN		BIT(0)
 #define SMPS_EXTENDED_EN	BIT(1)
+#define TWL_6030_WARM_RESET	BIT(3)
 
 /* twl6032 SMPS EPROM values */
 #define TWL6030_SMPS_OFFSET		0xB0
@@ -250,6 +254,9 @@ twl6030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
 {
 	struct twlreg_info	*info = rdev_get_drvdata(rdev);
 
+	if (info->flags & TWL_6030_WARM_RESET)
+		selector |= TWL6030_VREG_VOLTAGE_WR_S;
+
 	return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE,
 			    selector);
 }
@@ -259,6 +266,9 @@ static int twl6030ldo_get_voltage_sel(struct regulator_dev *rdev)
 	struct twlreg_info	*info = rdev_get_drvdata(rdev);
 	int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE);
 
+	if (info->flags & TWL_6030_WARM_RESET)
+		vsel &= ~TWL6030_VREG_VOLTAGE_WR_S;
+
 	return vsel;
 }
 
@@ -710,6 +720,9 @@ static int twlreg_probe(struct platform_device *pdev)
 		break;
 	}
 
+	if (of_get_property(np, "ti,retain-on-reset", NULL))
+		info->flags |= TWL_6030_WARM_RESET;
+
 	config.dev = &pdev->dev;
 	config.init_data = initdata;
 	config.driver_data = info;
Signature · 1 line
2.20.1