Skip to contentSkip to conversation

regulator: mt6358: Remove bogus regulators and improvements

PATCH Superseded Chen-Yu Tsai 1 participant 5 messages Jul 21, 2023

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover regulator: mt6358: Remove bogus regulators and improvements

Hi,

This is v2 of the remainder of the MT6358 regulator driver cleanup and improvement series. v1 can be found here [1].

Changes since v1:
- Merged patches dropped
- Added patch to move VCN33 regulator status sync after ID check
- Added patch to fix VCN33 sync fail error message
- Added patch to add missing register definitions

Various discrepancies were found while preparing to upstream MT8186 device trees, which utilize the MT6366 PMIC, that is also covered by this driver.

Patch 1 should either go through the mfd tree and an immutable branch created for the regulator tree to consume, or given an Ack, merged directly through the regulator tree.

Spoiler: a follow-up series dealing with the MT6366 PMIC, which is covered by the same driver, also has an mfd header patch that would need the same treatment.

Patches 2~6 should go through the regulator tree, and patch 7 through the soc tree. Patches 2 and 3 should be merged as fixes for v6.5, as the commit they fix was just introduced in -rc1.

Patches 5 and 6 depends on "[v3] regulator: Use bitfield values for range selectors" [2] I sent out earlier.

This v2 series can be seen as three parts. v1 also had three parts, but one part was fully merged, and then v2 gained another cleanup.

Part 1 - Fixing bogus regulators (patches 2, 3, and 7)

There are some regulators listed in the bindings and driver that have no corresponding pin on the actual hardware. MediaTek says these are a hardware construct for shared control of the same regulator in the VCN33 case and an alternative control scheme for low power suspend.

In the VCN33 case, there's only one actual regulator, so we merge the two and rename them to match the hardware pin. No existing devices use these AFAICT, so this should be safe to change.

The driver changes for this part have been merged, but two review comments were not accounted for. They are addressed here with two new patches

Part 2 - Robust chip ID checking (patch 4)

Angelo suggested making the driver fail to probe if an unexpected chip ID was found. Patch 4 implements this.

Part 3 - Output voltage fine tuning support (patches 1, 5, and 6)

Many of the LDOs on these PMIC support an extra level of output voltage fine tuning. Most default to no offset, but a couple have a non-zero offset by default. Previously this was unaccounted for in the driver and device tree constraints. On the outputs with non-zero offset, this ends up becoming a discrepancy between the device tree and actual hardware. These two patches adds support for this second level of tuning, modeled as bunch of linear ranges. While it's unlikely we need this level of control, it's nice to be able to read back the accurate hardware settings.

Please have a look. After this series is done I'll send out patches for the MT6366 PMIC, which is what started this. That will also include updated YAML bindings for MT6366. I think we can merge MT6358 bindings into them afterwards.

Thanks
ChenYu

[1] https://lore.kernel.org/linux-arm-kernel/[email protected]/
[2] https://lore.kernel.org/linux-arm-kernel/[email protected]/

Chen-Yu Tsai (7):
mfd: mt6358: Add missing registers for LDO voltage calibration
regulator: mt6358: Sync VCN33_* enable status after checking ID
regulator: mt6358: Fix incorrect VCN33 sync error message
regulator: mt6358: Fail probe on unknown chip ID
regulator: mt6358: Add output voltage fine tuning to fixed regulators
regulator: mt6358: Add output voltage fine tuning to variable LDOs
arm64: dts: mediatek: mt6358: Merge ldo_vcn33_* regulators

 arch/arm64/boot/dts/mediatek/mt6358.dtsi |  11 +-
 drivers/regulator/mt6358-regulator.c     | 314 +++++++++++------------
 include/linux/mfd/mt6358/registers.h     |   6 +
 3 files changed, 151 insertions(+), 180 deletions(-)
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#1 lore raw

PATCH v2 1/7 mfd: mt6358: Add missing registers for LDO voltage calibration

Most of the LDOs, except the "VSRAM_*" ones, on the MT6358 and MT6366 PMICs support a finer output voltage calibration within the range of +0 mV to +100 mV with 10 mV step. Some of the registers for this function are missing from the register table.

Add the missing ones for MT6358.

---
 include/linux/mfd/mt6358/registers.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/linux/mfd/mt6358/registers.h +6 -0
index 3d33517f178c..5ea2590be710 100644
@@ -262,6 +262,12 @@
 #define MT6358_LDO_VBIF28_CON3                0x1db0
 #define MT6358_VCAMA1_ANA_CON0                0x1e08
 #define MT6358_VCAMA2_ANA_CON0                0x1e0c
+#define MT6358_VFE28_ANA_CON0                 0x1e10
+#define MT6358_VCN28_ANA_CON0                 0x1e14
+#define MT6358_VBIF28_ANA_CON0                0x1e18
+#define MT6358_VAUD28_ANA_CON0                0x1e1c
+#define MT6358_VAUX18_ANA_CON0                0x1e20
+#define MT6358_VXO22_ANA_CON0                 0x1e24
 #define MT6358_VCN33_ANA_CON0                 0x1e28
 #define MT6358_VSIM1_ANA_CON0                 0x1e2c
 #define MT6358_VSIM2_ANA_CON0                 0x1e30
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#2 lore raw

PATCH v2 2/7 regulator: mt6358: Sync VCN33_* enable status after checking ID

In reply to Chen-Yu Tsai

Syncing VCN33_* enable status should be done after checking the PMIC's ID, to avoid setting random bits on other PMICs.

Fixes 65bae54e08c1 ("regulator: mt6358: Merge VCN33_* regulators")
---
 drivers/regulator/mt6358-regulator.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/regulator/mt6358-regulator.c +4 -4
index 31a16fb28ecd..da6b40f947c4 100644
@@ -676,10 +676,6 @@ static int mt6358_regulator_probe(struct platform_device *pdev)
 	const struct mt6358_regulator_info *mt6358_info;
 	int i, max_regulator, ret;
 
-	ret = mt6358_sync_vcn33_setting(&pdev->dev);
-	if (ret)
-		return ret;
-
 	if (mt6397->chip_id == MT6366_CHIP_ID) {
 		max_regulator = MT6366_MAX_REGULATOR;
 		mt6358_info = mt6366_regulators;
@@ -688,6 +684,10 @@ static int mt6358_regulator_probe(struct platform_device *pdev)
 		mt6358_info = mt6358_regulators;
 	}
 
+	ret = mt6358_sync_vcn33_setting(&pdev->dev);
+	if (ret)
+		return ret;
+
 	for (i = 0; i < max_regulator; i++) {
 		config.dev = &pdev->dev;
 		config.regmap = mt6397->regmap;
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#3 lore raw

PATCH v2 3/7 regulator: mt6358: Fix incorrect VCN33 sync error message

In reply to Chen-Yu Tsai

After syncing the enable status of VCN33_WIFI to VCN33_BT, the driver will disable VCN33_WIFI. If it fails it will error out with a message. However the error message incorrectly refers to VCN33_BT.

Fix the error message so that it correctly refers to VCN33_WIFI.

Fixes 65bae54e08c1 ("regulator: mt6358: Merge VCN33_* regulators")
---
 drivers/regulator/mt6358-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/mt6358-regulator.c +1 -1
index da6b40f947c4..b9cda2210c33 100644
@@ -661,7 +661,7 @@ static int mt6358_sync_vcn33_setting(struct device *dev)
 	/* Disable VCN33_WIFI */
 	ret = regmap_update_bits(mt6397->regmap, MT6358_LDO_VCN33_CON0_1, BIT(0), 0);
 	if (ret) {
-		dev_err(dev, "Failed to disable VCN33_BT\n");
+		dev_err(dev, "Failed to disable VCN33_WIFI\n");
 		return ret;
 	}
 
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#4 lore raw
In reply to Chen-Yu Tsai
Quoted 12 lines · Chen-Yu Tsai

Hi,

This is v2 of the remainder of the MT6358 regulator driver cleanup and improvement series. v1 can be found here [1].

Changes since v1:
- Merged patches dropped
- Added patch to move VCN33 regulator status sync after ID check
- Added patch to fix VCN33 sync fail error message
- Added patch to add missing register definitions

Quoted 7 lines

Various discrepancies were found while preparing to upstream MT8186 device trees, which utilize the MT6366 PMIC, that is also covered by this driver.

Patch 1 should either go through the mfd tree and an immutable branch created for the regulator tree to consume, or given an Ack, merged directly through the regulator tree.

Please ignore this thread. I forgot to add Lee to the recipients. I will resend later.

ChenYu