Use correct LDO5 control registers for PCA9450
v3 cover Use correct LDO5 control registers for PCA9450
From: Frieder Schrempf <[email protected]>
This is a follow-up of [1].
The main objective of this is to fix the PCA9450 driver to use the correct control register for the LDO5 regulator.
Currently the control register to use for LDO5 is hardcoded to LDO5CTRL_H. This is wrong for two reasons:
1. LDO5CTRL_H doesn't contain the bits for enabling/disabling the regulator. Only LDO5CTRL_L does.
2. The actual output voltage of the regulator is determined by the LDO5CTRL_H only if the SD_VSEL input is HIGH. If it is low, then LDO5CTRL_L is used. The driver does not take this into account.
This can cause several problems:
1. LDO5 can not be turned on/off and we rely on the bootloader to leave it turned on. On the other hand we can't save power if LDO5 is unused.
2. There is a potential for corner-cases where switching SD_VSEL via USDHC_VSELECT and writing to the (wrong) control register can cause wrong output voltage and therfore SD card failures (not observed yet).
3. Reading the current voltage of the LDO5 regulator (e. g. via sysfs can yield the wrong value as the voltage is read from the wrong control register.
At the same time there is now hardware that hardwires SD_VSEL to a fixed LOW level and therefore relies on switching the voltage only via a single control register. We add support for this through an additional property "nxp,sd-vsel-fixed-low" in the LDO5 node.
Summary of binding changes (patch 1):
1. Adjust the bindings to remove the old and abandoned use of sd-vsel-gpios property.
2. Adjust the bindings to use sd-vsel-gpios in the LDO5 node to retrieve an input that can be used to sample the SD_VSEL status.
3. Adjust bindings to allow "nxp,sd-vsel-fixed-low" to be used for boards that have SD_VSEL hardwired to low level.
Summary of driver changes (patch 2-6):
1. Remove the old sd-vsel-gpios handling.
2. Use the new sd-vsel-gpios property to determine the correct control register for LDO5.
3. Fix the enable register for LDO5.
4. Support hardware with fixed low level of SD_VSEL.
Summary of devicetree changes (patch 7-9):
Implement the changes in the devicetrees for Kontron hardware (i.MX8MM, i.MX8MP and i.MX93).
Changelog:
v2 -> v3:
* Merge binding patches into one and extend commit message
* Rebase to next-20241218
v1 -> v2:
* Split binding patch
* Add solution for hardwired SD_VSEL
* Leave regulator core untouched as requested by Mark
* Add devicetree changes for i.MX8MP and i.MX93
[1] https://lore.kernel.org/lkml/[email protected]/
Frieder Schrempf (9):
dt-bindings: regulator: pca9450: Add properties for handling LDO5
arm64: dts: imx8mp-skov-reva: Use hardware signal for SD card VSELECT Revert "regulator: pca9450: Add SD_VSEL GPIO for LDO5"
regulator: pca9450: Fix control register for LDO5
regulator: pca9450: Fix enable register for LDO5
regulator: pca9450: Handle hardware with fixed SD_VSEL for LDO5
arm64: dts: imx8mm-kontron: Add support for reading SD_VSEL signal
arm64: dts: imx93-kontron: Fix SD card IO voltage control
arm64: dts: imx8mp-kontron: Add support for reading SD_VSEL signal
.../regulator/nxp,pca9450-regulator.yaml | 29 ++++- .../boot/dts/freescale/imx8mm-kontron-bl.dts | 10 +- .../dts/freescale/imx8mm-kontron-osm-s.dtsi | 7 +- .../dts/freescale/imx8mp-kontron-osm-s.dtsi | 7 +- .../boot/dts/freescale/imx8mp-skov-reva.dtsi | 5 +- .../dts/freescale/imx93-kontron-osm-s.dtsi | 5 +- drivers/regulator/pca9450-regulator.c | 103 +++++++++++++++--- 7 files changed, 133 insertions(+), 33 deletions(-)
Signature · 1 line
2.47.1
PATCH v3 1/9 dt-bindings: regulator: pca9450: Add properties for handling LDO5
From: Frieder Schrempf <[email protected]>
This reverts commit 27866e3e8a7e93494f8374f48061aa73ee46ceb2 and implements a new future-proof way of handling the mismatch between the PMIC driver and the hardware for LDO5.
It turned out that this feature was implemented based on the wrong assumption that the SD_VSEL signal needs to be controlled as GPIO in any case.
In fact the straight-forward approach is to mux the signal as USDHC_VSELECT and let the USDHC controller do the job.
Most users never even used this property and the few who did have been or are getting migrated to the alternative approach.
In order to know the current status (which of the two control registers is used) for the LDO5 regulator, we need to route back the USDHC_VSELECT signal by setting the SION bit in the IOMUX.
By adding the according GPIO as sd-vsel-gpios to the LDO5 node, we allow the regulator driver to sample the current status of the SD_VSEL signal that is used to select the correct control register.
The SD_VSEL on the PMIC is always an input. It's driven by the SoC's VSELECT signal (controlled by the USDHC controller) and we use the SION bit in the IOMUX to internally loop back the signal in order to sample it using the GPIO.
As the SD_VSEL pin is directly routed to the LDO5 regulator in the PMIC, make the sd-vsel-gpios property part of the LDO5 node.
SoC PMIC
+-----------------------+ +-------------------+ | | | | | | | | | GPIO <----------+ | | | | | | SD_VSEL| +-------+ | | USDHC_VSELECT ->+------------------->| LDO5 | | | | | +-------+ | | | | | +-----------------------+ +-------------------+
For boards which have the SD_VSEL tied to a fixed low level, we add 'nxp,sd-vsel-fixed-low'. The voltage of LDO5 is therefore only controlled by writing to the LDO5CTRL_L register.
If none of 'nxp,sd-vsel-fixed-low' or 'sd-vsel-gpios' is set, we keep the same behavior as before. The driver assumes that SD_VSEL is tied high and the LDO5CTRL_H register can be used, which is in fact not true for all known boards and works merely by chance.
---
Changes for v3:
* Merge binding patches into single patch
* Rebase to next-20241218
Changes for v2:
* split revert into separate patch
* extend commit message
* add 'nxp,sd-vsel-fixed-low'
--- .../regulator/nxp,pca9450-regulator.yaml | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml +23 -6
@@ -42,8 +42,30 @@ properties: description: | list of regulators provided by this controller + properties: + LDO5: + type: object + $ref: regulator.yaml# + description: + Properties for single LDO5 regulator. + + properties: + nxp,sd-vsel-fixed-low: + type: boolean + description: + Let the driver know that SD_VSEL is hardwired to low level and + there is no GPIO to get the actual value from. + + sd-vsel-gpios: + description: + GPIO that can be used to read the current status of the SD_VSEL + signal in order for the driver to know if LDO5CTRL_L or LDO5CTRL_H + is used by the hardware. + + unevaluatedProperties: false + patternProperties: - "^LDO[1-5]$": + "^LDO[1-4]$": type: object $ref: regulator.yaml# description:
@@ -78,11 +100,6 @@ properties: additionalProperties: false - sd-vsel-gpios: - description: GPIO that is used to switch LDO5 between being configured by - LDO5CTRL_L or LDO5CTRL_H register. Use this if the SD_VSEL signal is - connected to a host GPIO. - nxp,i2c-lt-enable: type: boolean description:
Signature · 1 line
2.47.1
Re: [PATCH v3 1/9] dt-bindings: regulator: pca9450: Add properties for handling LDO5
Quoted 47 lines · Frieder Schrempf
From: Frieder Schrempf <[email protected]>
This reverts commit
27866e3e8a7e93494f8374f48061aa73ee46ceb2and implements a new future-proof way of handling the mismatch between the PMIC driver and the hardware for LDO5.It turned out that this feature was implemented based on the wrong assumption that the
SD_VSELsignal needs to be controlled as GPIO in any case.In fact the straight-forward approach is to mux the signal as
USDHC_VSELECTand let the USDHC controller do the job.Most users never even used this property and the few who did have been or are getting migrated to the alternative approach.
In order to know the current status (which of the two control registers is used) for the LDO5 regulator, we need to route back the
USDHC_VSELECTsignal by setting the SION bit in the IOMUX.By adding the according GPIO as sd-vsel-gpios to the LDO5 node, we allow the regulator driver to sample the current status of the
SD_VSELsignal that is used to select the correct control register.The
SD_VSELon the PMIC is always an input. It's driven by the SoC's VSELECT signal (controlled by the USDHC controller) and we use the SION bit in the IOMUX to internally loop back the signal in order to sample it using the GPIO.As the
SD_VSELpin is directly routed to the LDO5 regulator in the PMIC, make the sd-vsel-gpios property part of the LDO5 node.SoC PMIC
+-----------------------+ +-------------------+ | | | | | | | | | GPIO <----------+ | | | | | | SD_VSEL| +-------+ | | USDHC_VSELECT ->+------------------->| LDO5 | | | | | +-------+ | | | | | +-----------------------+ +-------------------+For boards which have the
SD_VSELtied to a fixed low level, we add 'nxp,sd-vsel-fixed-low'. The voltage of LDO5 is therefore only controlled by writing to theLDO5CTRL_Lregister.
Quoted 6 lines
If none of 'nxp,sd-vsel-fixed-low' or 'sd-vsel-gpios' is set, we keep the same behavior as before. The driver assumes that
SD_VSELis tied high and theLDO5CTRL_Hregister can be used, which is in fact not true for all known boards and works merely by chance.Signed-off-by Frieder Schrempf <[email protected]>
PATCH v3 2/9 arm64: dts: imx8mp-skov-reva: Use hardware signal for SD card VSELECT
In reply to Frieder SchrempfFrom: Frieder Schrempf <[email protected]>
The USDHC controller is able to control the IO voltage of the SD card. There is no reason to use a GPIO to control it.
---
Changes for v3:
* Rebase to next-20241218
Changes for v2:
* new patch
--- arch/arm64/boot/dts/freescale/imx8mp-skov-reva.dtsi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/freescale/imx8mp-skov-reva.dtsi +3 -2
@@ -232,7 +232,6 @@ pmic@25 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_pmic>; interrupts-extended = <&gpio1 3 IRQ_TYPE_EDGE_RISING>; - sd-vsel-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; regulators { reg_vdd_soc: BUCK1 {
@@ -555,7 +554,6 @@ MX8MP_IOMUXC_I2C4_SDA__I2C4_SDA 0x400001c3 pinctrl_pmic: pmicirqgrp { fsl,pins = < MX8MP_IOMUXC_GPIO1_IO03__GPIO1_IO03 0x41 - MX8MP_IOMUXC_GPIO1_IO04__GPIO1_IO04 0x41 >; };
@@ -623,6 +621,7 @@ MX8MP_IOMUXC_SD2_DATA0__USDHC2_DATA0 0x1d0 MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1 0x1d0 MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2 0x1d0 MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3 0x1d0 + MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc0 >; };
@@ -634,6 +633,7 @@ MX8MP_IOMUXC_SD2_DATA0__USDHC2_DATA0 0x1d4 MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1 0x1d4 MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2 0x1d4 MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3 0x1d4 + MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc0 >; };
@@ -645,6 +645,7 @@ MX8MP_IOMUXC_SD2_DATA0__USDHC2_DATA0 0x1d6 MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1 0x1d6 MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2 0x1d6 MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3 0x1d6 + MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0xc0 >; };
Signature · 1 line
2.47.1
PATCH v3 3/9 Revert "regulator: pca9450: Add SD_VSEL GPIO for LDO5"
In reply to Frieder SchrempfFrom: Frieder Schrempf <[email protected]>
This reverts commit 8c67a11bae889f51fe5054364c3c789dfae3ad73.
It turns out that all boards using the PCA9450 actually have the SD_VSEL input connected to the VSELECT signal of the SoCs SD/MMC interface or use a fixed level.
The assumptions on which this was implemented were wrong. There is no need for a GPIO-only-based approach and keeping this will cause confusion and lead people to implement non-standard setups.
All in-tree users of this have been migrated and we can savely remove this now and allow for a more future-proof approach of syncing the actual status of SD_VSEL and the PMIC driver.
---
Changes for v3:
* Rebase to next-20241218
Changes for v2:
* rebase to current master
--- drivers/regulator/pca9450-regulator.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/regulator/pca9450-regulator.c +0 -13
@@ -5,7 +5,6 @@*/ #include <linux/err.h> -#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/kernel.h>
@@ -32,7 +31,6 @@ struct pca9450_regulator_desc {struct pca9450 {struct device *dev;struct regmap *regmap; -struct gpio_desc *sd_vsel_gpio;enum pca9450_chip_type type;unsigned int rcnt;int irq;
@@ -1031,17 +1029,6 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) "Failed to enable I2C level translator\n"); } -/* -* The driver uses the LDO5CTRL_H register to control the LDO5 regulator. -* This is only valid if the SD_VSEL input of the PMIC is high. Let's -* check if the pin is available as GPIO and set it to high. -*/ - pca9450->sd_vsel_gpio =gpiod_get_optional (pca9450->dev,"sd-vsel" ,GPIOD_OUT_HIGH ); - -if (IS_ERR (pca9450->sd_vsel_gpio)) -return dev_err_probe (&i2c->dev,PTR_ERR (pca9450->sd_vsel_gpio), -"Failed to get SD_VSEL GPIO\n" ); -dev_info (&i2c->dev,"%s probed.\n" , type ==PCA9450_TYPE_PCA9450A ?"pca9450a" : (type ==PCA9450_TYPE_PCA9451A ?"pca9451a" :"pca9450bc" ));
Signature · 1 line
2.47.1
Mark Brown
maintainerRe: [PATCH v3 3/9] Revert "regulator: pca9450: Add SD_VSEL GPIO for LDO5"
Quoted 3 lines · Frieder Schrempf
From: Frieder Schrempf <[email protected]>
This reverts commit
8c67a11bae889f51fe5054364c3c789dfae3ad73.
Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.
Please include human readable descriptions of things like commits and issues being discussed in e-mail in your mails, this makes them much easier for humans to read especially when they have no internet access. I do frequently catch up on my mail on flights or while otherwise travelling so this is even more pressing for me than just being about making things a bit easier to read.
PATCH v3 4/9 regulator: pca9450: Fix control register for LDO5
In reply to Frieder SchrempfFrom: Frieder Schrempf <[email protected]>
For LDO5 we need to be able to check the status of the SD_VSEL input in order to know which control register is used. Read the status of the SD_VSEL signal via GPIO and use the correct register accordingly.
To use this, the LDO5 node in the devicetree needs the sd-vsel-gpios property to reference the GPIO that is used to read back the SD_VSEL status internally. Please note that the SION bit in the IOMUX must be set if the signal is muxed as VSELECT and controlled by the USDHC controller.
---
Changes for v3:
* Rebase to next-20241218
Changes for v2:
* rebase to current master and stop using generic helper from regulator core
--- drivers/regulator/pca9450-regulator.c | 89 ++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 3 deletions(-)
drivers/regulator/pca9450-regulator.c +86 -3
@@ -5,6 +5,7 @@*/ #include <linux/err.h> +#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/kernel.h>
@@ -31,6 +32,7 @@ struct pca9450_regulator_desc {struct pca9450 {struct device *dev;struct regmap *regmap; +struct gpio_desc *sd_vsel_gpio;enum pca9450_chip_type type;unsigned int rcnt;int irq;
@@ -96,6 +98,58 @@ static const struct regulator_ops pca9450_ldo_regulator_ops = { .get_voltage_sel = regulator_get_voltage_sel_regmap, }; +static unsigned int pca9450_ldo5_get_reg_voltage_sel (struct regulator_dev *rdev) +{ +struct pca9450 *pca9450 =rdev_get_drvdata (rdev); + +if (pca9450->sd_vsel_gpio && !gpiod_get_value (pca9450->sd_vsel_gpio)) +return PCA9450_REG_LDO5CTRL_L ; + +return rdev->desc->vsel_reg; +} + +static int pca9450_ldo5_get_voltage_sel_regmap (struct regulator_dev *rdev) +{ +unsigned int val; +int ret; + + ret =regmap_read (rdev->regmap,pca9450_ldo5_get_reg_voltage_sel (rdev), &val); +if (ret !=0 ) +return ret; + + val &= rdev->desc->vsel_mask; + val >>=ffs (rdev->desc->vsel_mask) -1 ; + +return val; +} + +static int pca9450_ldo5_set_voltage_sel_regmap (struct regulator_dev *rdev,unsigned int sel) +{ +int ret; + + sel <<=ffs (rdev->desc->vsel_mask) -1 ; + + ret =regmap_update_bits (rdev->regmap,pca9450_ldo5_get_reg_voltage_sel (rdev), + rdev->desc->vsel_mask, sel); +if (ret) +return ret; + +if (rdev->desc->apply_bit) + ret =regmap_update_bits (rdev->regmap, rdev->desc->apply_reg, + rdev->desc->apply_bit, + rdev->desc->apply_bit); +return ret; +} + +static const struct regulator_ops pca9450_ldo5_regulator_ops = { + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, + .list_voltage = regulator_list_voltage_linear_range, + .set_voltage_sel = pca9450_ldo5_set_voltage_sel_regmap, + .get_voltage_sel = pca9450_ldo5_get_voltage_sel_regmap, +}; +/* * BUCK1/2/3 * 0.60 to 2.1875V (12.5mV step)
@@ -451,7 +505,7 @@ static const struct pca9450_regulator_desc pca9450a_regulators[] = { .of_match = of_match_ptr("LDO5"), .regulators_node = of_match_ptr("regulators"), .id = PCA9450_LDO5, - .ops = &pca9450_ldo_regulator_ops, + .ops = &pca9450_ldo5_regulator_ops, .type = REGULATOR_VOLTAGE, .n_voltages = PCA9450_LDO5_VOLTAGE_NUM, .linear_ranges = pca9450_ldo5_volts,
@@ -665,7 +719,7 @@ static const struct pca9450_regulator_desc pca9450bc_regulators[] = { .of_match = of_match_ptr("LDO5"), .regulators_node = of_match_ptr("regulators"), .id = PCA9450_LDO5, - .ops = &pca9450_ldo_regulator_ops, + .ops = &pca9450_ldo5_regulator_ops, .type = REGULATOR_VOLTAGE, .n_voltages = PCA9450_LDO5_VOLTAGE_NUM, .linear_ranges = pca9450_ldo5_volts,
@@ -855,7 +909,7 @@ static const struct pca9450_regulator_desc pca9451a_regulators[] = { .of_match = of_match_ptr("LDO5"), .regulators_node = of_match_ptr("regulators"), .id = PCA9450_LDO5, - .ops = &pca9450_ldo_regulator_ops, + .ops = &pca9450_ldo5_regulator_ops, .type = REGULATOR_VOLTAGE, .n_voltages = PCA9450_LDO5_VOLTAGE_NUM, .linear_ranges = pca9450_ldo5_volts,
@@ -913,6 +967,7 @@ static int pca9450_i2c_probe(struct i2c_client *i2c)of_device_get_match_data (&i2c->dev);const struct pca9450_regulator_desc *regulator_desc;struct regulator_config config = { }; +struct regulator_dev *ldo5;struct pca9450 *pca9450;unsigned int device_id, i;unsigned int reset_ctrl;
@@ -978,11 +1033,15 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) config.regmap = pca9450->regmap; config.dev = pca9450->dev; + config.driver_data = pca9450; rdev =devm_regulator_register (pca9450->dev, desc, &config);if (IS_ERR (rdev))return dev_err_probe (pca9450->dev,PTR_ERR (rdev),"Failed to register regulator(%s)\n" , desc->name); + +if (!strcmp (desc->name,"ldo5" )) + ldo5 = rdev; }if (pca9450->irq) {
@@ -1029,6 +1088,30 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) "Failed to enable I2C level translator\n"); } +/* +* For LDO5 we need to be able to check the status of the SD_VSEL input in +* order to know which control register is used. Most boards connect SD_VSEL +* to the VSELECT signal, so we can use the GPIO that is internally routed +* to this signal (if SION bit is set in IOMUX). +*/ + pca9450->sd_vsel_gpio =gpiod_get_optional (&ldo5->dev,"sd-vsel" ,GPIOD_IN ); +if (IS_ERR (pca9450->sd_vsel_gpio)) { +dev_err (&i2c->dev,"Failed to get SD_VSEL GPIO\n" ); +return ret; + } + +/* +* For LDO5 we need to be able to check the status of the SD_VSEL input in +* order to know which control register is used. Most boards connect SD_VSEL +* to the VSELECT signal, so we can use the GPIO that is internally routed +* to this signal (if SION bit is set in IOMUX). +*/ + pca9450->sd_vsel_gpio =gpiod_get_optional (&ldo5->dev,"sd-vsel" ,GPIOD_IN ); +if (IS_ERR (pca9450->sd_vsel_gpio)) { +dev_err (&i2c->dev,"Failed to get SD_VSEL GPIO\n" ); +return ret; + } +dev_info (&i2c->dev,"%s probed.\n" , type ==PCA9450_TYPE_PCA9450A ?"pca9450a" : (type ==PCA9450_TYPE_PCA9451A ?"pca9451a" :"pca9450bc" ));
Signature · 1 line
2.47.1
PATCH v3 5/9 regulator: pca9450: Fix enable register for LDO5
In reply to Frieder SchrempfFrom: Frieder Schrempf <[email protected]>
The LDO5 regulator has two configuration registers, but only LDO5CTRL_L contains the bits for enabling/disabling the regulator.
---
Changes for v3:
* Rebase to next-20241218
Changes for v2:
* none
--- drivers/regulator/pca9450-regulator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/pca9450-regulator.c +3 -3
@@ -512,7 +512,7 @@ static const struct pca9450_regulator_desc pca9450a_regulators[] = { .n_linear_ranges = ARRAY_SIZE(pca9450_ldo5_volts), .vsel_reg = PCA9450_REG_LDO5CTRL_H, .vsel_mask = LDO5HOUT_MASK, - .enable_reg = PCA9450_REG_LDO5CTRL_H, + .enable_reg = PCA9450_REG_LDO5CTRL_L, .enable_mask = LDO5H_EN_MASK, .owner = THIS_MODULE, },
@@ -726,7 +726,7 @@ static const struct pca9450_regulator_desc pca9450bc_regulators[] = { .n_linear_ranges = ARRAY_SIZE(pca9450_ldo5_volts), .vsel_reg = PCA9450_REG_LDO5CTRL_H, .vsel_mask = LDO5HOUT_MASK, - .enable_reg = PCA9450_REG_LDO5CTRL_H, + .enable_reg = PCA9450_REG_LDO5CTRL_L, .enable_mask = LDO5H_EN_MASK, .owner = THIS_MODULE, },
@@ -916,7 +916,7 @@ static const struct pca9450_regulator_desc pca9451a_regulators[] = { .n_linear_ranges = ARRAY_SIZE(pca9450_ldo5_volts), .vsel_reg = PCA9450_REG_LDO5CTRL_H, .vsel_mask = LDO5HOUT_MASK, - .enable_reg = PCA9450_REG_LDO5CTRL_H, + .enable_reg = PCA9450_REG_LDO5CTRL_L, .enable_mask = LDO5H_EN_MASK, .owner = THIS_MODULE, },
Signature · 1 line
2.47.1
PATCH v3 6/9 regulator: pca9450: Handle hardware with fixed SD_VSEL for LDO5
In reply to Frieder SchrempfFrom: Frieder Schrempf <[email protected]>
There are two ways to set the output voltage of the LD05 regulator. First by writing to the voltage selection registers and second by toggling the SD_VSEL signal.
Usually board designers connect SD_VSEL to the VSELECT signal controlled by the USDHC controller, but in some cases the signal is hardwired to a fixed low level (therefore selecting 3.3V as initial value for allowing to boot from the SD card).
In these cases, the voltage is only determined by the value of the LDO5CTRL_L register. Introduce a property nxp,sd-vsel-fixed-low to let the driver know that SD_VSEL is low and there is no GPIO to actually get that information from dynamically.
---
Changes for v3:
* Rebase to next-20241218
Changes for v2:
* new patch
--- drivers/regulator/pca9450-regulator.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/regulator/pca9450-regulator.c +7 -0
@@ -36,6 +36,7 @@ struct pca9450 {enum pca9450_chip_type type;unsigned int rcnt;int irq; +bool sd_vsel_fixed_low; };static const struct regmap_range pca9450_status_range = {
@@ -102,6 +103,9 @@ static unsigned int pca9450_ldo5_get_reg_voltage_sel(struct regulator_dev *rdev) {struct pca9450 *pca9450 =rdev_get_drvdata (rdev); +if (pca9450->sd_vsel_fixed_low) +return PCA9450_REG_LDO5CTRL_L ; +if (pca9450->sd_vsel_gpio && !gpiod_get_value (pca9450->sd_vsel_gpio))return PCA9450_REG_LDO5CTRL_L ;
@@ -1112,6 +1116,9 @@ static int pca9450_i2c_probe(struct i2c_client *i2c)return ret; } + pca9450->sd_vsel_fixed_low = +of_property_read_bool (ldo5->dev.of_node,"nxp,sd-vsel-fixed-low" ); +dev_info (&i2c->dev,"%s probed.\n" , type ==PCA9450_TYPE_PCA9450A ?"pca9450a" : (type ==PCA9450_TYPE_PCA9451A ?"pca9451a" :"pca9450bc" ));
Signature · 1 line
2.47.1
PATCH v3 7/9 arm64: dts: imx8mm-kontron: Add support for reading SD_VSEL signal
In reply to Frieder SchrempfFrom: Frieder Schrempf <[email protected]>
This fixes the LDO5 regulator handling of the pca9450 driver by taking the status of the SD_VSEL into account to determine which configuration register is used for the voltage setting.
Even without this change there is no functional issue, as the code for switching the voltage in sdhci.c currently switches both, the VSELECT/SD_VSEL signal and the regulator voltage at the same time and doesn't run into an invalid corner case.
We should still make sure, that we always use the correct register when controlling the regulator. At least in U-Boot this fixes an actual bug where the wrong IO voltage is used and it makes sure that the correct voltage can be read from sysfs.
---
Changes for v3:
* Rebase to next-20241218
Changes for v2:
* rebase to current master
--- arch/arm64/boot/dts/freescale/imx8mm-kontron-bl.dts | 10 +++++++--- .../arm64/boot/dts/freescale/imx8mm-kontron-osm-s.dtsi | 7 ++++--- 2 files changed, 11 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/freescale/imx8mm-kontron-bl.dts +7 -3
@@ -254,6 +254,10 @@ &pwm2 { status = "okay"; }; +®_nvcc_sd { + sd-vsel-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; +}; + &uart1 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_uart1>;
@@ -454,7 +458,7 @@ MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1 0x1d0 MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d0 MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d0 MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO12 0x19 - MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0xd0 + MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x40000d0 >; };
@@ -467,7 +471,7 @@ MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1 0x1d4 MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d4 MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d4 MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO12 0x19 - MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0xd0 + MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x40000d0 >; };
@@ -480,7 +484,7 @@ MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1 0x1d6 MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d6 MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d6 MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO12 0x19 - MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0xd0 + MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x40000d0 >; }; };
arch/arm64/boot/dts/freescale/imx8mm-kontron-osm-s.dtsi +4 -3
@@ -342,6 +342,7 @@ reg_nvcc_sd: LDO5 { regulator-name = "NVCC_SD (LDO5)"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <3300000>; + sd-vsel-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; }; }; };
@@ -794,7 +795,7 @@ MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1 0x1d0 /* SDIO_A_D1 */ MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d0 /* SDIO_A_D2 */ MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d0 /* SDIO_A_D3 */ MX8MM_IOMUXC_SD2_WP_USDHC2_WP 0x400000d6 /* SDIO_A_WP */ - MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x90 + MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x40000090 >; };
@@ -807,7 +808,7 @@ MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1 0x1d4 /* SDIO_A_D1 */ MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d4 /* SDIO_A_D2 */ MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d4 /* SDIO_A_D3 */ MX8MM_IOMUXC_SD2_WP_USDHC2_WP 0x400000d6 /* SDIO_A_WP */ - MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x90 + MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x40000090 >; };
@@ -820,7 +821,7 @@ MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1 0x1d6 /* SDIO_A_D1 */ MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d6 /* SDIO_A_D2 */ MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d6 /* SDIO_A_D3 */ MX8MM_IOMUXC_SD2_WP_USDHC2_WP 0x400000d6 /* SDIO_A_WP */ - MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x90 + MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x40000090 >; };
Signature · 1 line
2.47.1
PATCH v3 8/9 arm64: dts: imx93-kontron: Fix SD card IO voltage control
In reply to Frieder SchrempfFrom: Frieder Schrempf <[email protected]>
The OSM-S i.MX93 SoM doesn't have the VSELECT signal of the USDHC controller connected to the PMICs SD_VSEL input. Instead SD_VSEL is hardwired to low level. Let the driver know this in order to use the proper register for reading and writing the voltage level.
This fixes SD card access with the latest hardware revision of the Kontron OSM-S i.MX93 SoM.
---
Changes for v3:
* Rebase to next-20241218
Changes for v2:
* new patch
--- arch/arm64/boot/dts/freescale/imx93-kontron-osm-s.dtsi | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/freescale/imx93-kontron-osm-s.dtsi +2 -3
@@ -189,6 +189,7 @@ reg_nvcc_sd: LDO5 { regulator-name = "NVCC_SD (LDO5)"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <3300000>; + nxp,sd-vsel-fixed-low; }; }; };
@@ -282,6 +283,7 @@ &usdhc2 { /* OSM-S SDIO_A */ pinctrl-1 = <&pinctrl_usdhc2_100mhz>, <&pinctrl_usdhc2_gpio>; pinctrl-2 = <&pinctrl_usdhc2_200mhz>, <&pinctrl_usdhc2_gpio>; vmmc-supply = <®_usdhc2_vcc>; + vqmmc-supply = <®_nvcc_sd>; cd-gpios = <&gpio3 0 GPIO_ACTIVE_LOW>; };
@@ -553,7 +555,6 @@ MX93_PAD_SD2_DATA0__USDHC2_DATA0 0x40001382 /* SDIO_A_D0 */ MX93_PAD_SD2_DATA1__USDHC2_DATA1 0x40001382 /* SDIO_A_D1 */ MX93_PAD_SD2_DATA2__USDHC2_DATA2 0x40001382 /* SDIO_A_D2 */ MX93_PAD_SD2_DATA3__USDHC2_DATA3 0x40001382 /* SDIO_A_D3 */ - MX93_PAD_SD2_VSELECT__USDHC2_VSELECT 0x1d0 >; };
@@ -565,7 +566,6 @@ MX93_PAD_SD2_DATA0__USDHC2_DATA0 0x4000138e /* SDIO_A_D0 */ MX93_PAD_SD2_DATA1__USDHC2_DATA1 0x4000138e /* SDIO_A_D1 */ MX93_PAD_SD2_DATA2__USDHC2_DATA2 0x4000138e /* SDIO_A_D2 */ MX93_PAD_SD2_DATA3__USDHC2_DATA3 0x4000138e /* SDIO_A_D3 */ - MX93_PAD_SD2_VSELECT__USDHC2_VSELECT 0x1d0 >; };
@@ -577,7 +577,6 @@ MX93_PAD_SD2_DATA0__USDHC2_DATA0 0x400013fe /* SDIO_A_D0 */ MX93_PAD_SD2_DATA1__USDHC2_DATA1 0x400013fe /* SDIO_A_D1 */ MX93_PAD_SD2_DATA2__USDHC2_DATA2 0x400013fe /* SDIO_A_D2 */ MX93_PAD_SD2_DATA3__USDHC2_DATA3 0x400013fe /* SDIO_A_D3 */ - MX93_PAD_SD2_VSELECT__USDHC2_VSELECT 0x1d0 >; };
Signature · 1 line
2.47.1
PATCH v3 9/9 arm64: dts: imx8mp-kontron: Add support for reading SD_VSEL signal
In reply to Frieder SchrempfFrom: Frieder Schrempf <[email protected]>
This fixes the LDO5 regulator handling of the pca9450 driver by taking the status of the SD_VSEL into account to determine which configuration register is used for the voltage setting.
Even without this change there is no functional issue, as the code for switching the voltage in sdhci.c currently switches both, the VSELECT/SD_VSEL signal and the regulator voltage at the same time and doesn't run into an invalid corner case.
We should still make sure, that we always use the correct register when controlling the regulator. At least in U-Boot this fixes an actual bug where the wrong IO voltage is used and it makes sure that the correct voltage can be read from sysfs.
---
Changes for v3:
* Rebase to next-20241218
Changes for v2:
* new patch
--- arch/arm64/boot/dts/freescale/imx8mp-kontron-osm-s.dtsi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/freescale/imx8mp-kontron-osm-s.dtsi +4 -3
@@ -311,6 +311,7 @@ reg_nvcc_sd: LDO5 { regulator-name = "NVCC_SD (LDO5)"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <3300000>; + sd-vsel-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; }; }; };
@@ -808,7 +809,7 @@ MX8MP_IOMUXC_SD2_DATA0__USDHC2_DATA0 0x1d0 /* SDIO_A_D0 */ MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1 0x1d0 /* SDIO_A_D1 */ MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2 0x1d0 /* SDIO_A_D2 */ MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3 0x1d0 /* SDIO_A_D3 */ - MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0x1d0 + MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0x400001d0 >; };
@@ -820,7 +821,7 @@ MX8MP_IOMUXC_SD2_DATA0__USDHC2_DATA0 0x1d4 /* SDIO_A_D0 */ MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1 0x1d4 /* SDIO_A_D1 */ MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2 0x1d4 /* SDIO_A_D2 */ MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3 0x1d4 /* SDIO_A_D3 */ - MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0x1d0 + MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0x400001d0 >; };
@@ -832,7 +833,7 @@ MX8MP_IOMUXC_SD2_DATA0__USDHC2_DATA0 0x1d6 /* SDIO_A_D0 */ MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1 0x1d6 /* SDIO_A_D1 */ MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2 0x1d6 /* SDIO_A_D2 */ MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3 0x1d6 /* SDIO_A_D3 */ - MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0x1d0 + MX8MP_IOMUXC_GPIO1_IO04__USDHC2_VSELECT 0x400001d0 >; };
Signature · 1 line
2.47.1
Hi,
Quoted 94 lines · Frieder Schrempf
From: Frieder Schrempf <[email protected]>
This is a follow-up of [1].
The main objective of this is to fix the PCA9450 driver to use the correct control register for the LDO5 regulator.
Currently the control register to use for LDO5 is hardcoded to
LDO5CTRL_H. This is wrong for two reasons:1.
LDO5CTRL_Hdoesn't contain the bits for enabling/disabling the regulator. OnlyLDO5CTRL_Ldoes.2. The actual output voltage of the regulator is determined by the
LDO5CTRL_Honly if theSD_VSELinput is HIGH. If it is low, thenLDO5CTRL_Lis used. The driver does not take this into account.This can cause several problems:
1. LDO5 can not be turned on/off and we rely on the bootloader to leave it turned on. On the other hand we can't save power if LDO5 is unused.
2. There is a potential for corner-cases where switching
SD_VSELviaUSDHC_VSELECTand writing to the (wrong) control register can cause wrong output voltage and therfore SD card failures (not observed yet).3. Reading the current voltage of the LDO5 regulator (e. g. via sysfs can yield the wrong value as the voltage is read from the wrong control register.
At the same time there is now hardware that hardwires
SD_VSELto a fixed LOW level and therefore relies on switching the voltage only via a single control register. We add support for this through an additional property "nxp,sd-vsel-fixed-low" in the LDO5 node.Summary of binding changes (patch 1):
1. Adjust the bindings to remove the old and abandoned use of sd-vsel-gpios property.
2. Adjust the bindings to use sd-vsel-gpios in the LDO5 node to retrieve an input that can be used to sample the
SD_VSELstatus.3. Adjust bindings to allow "nxp,sd-vsel-fixed-low" to be used for boards that have
SD_VSELhardwired to low level.Summary of driver changes (patch 2-6):
1. Remove the old sd-vsel-gpios handling.
2. Use the new sd-vsel-gpios property to determine the correct control register for LDO5.
3. Fix the enable register for LDO5.
4. Support hardware with fixed low level of
SD_VSEL.Summary of devicetree changes (patch 7-9):
Implement the changes in the devicetrees for Kontron hardware (i.MX8MM, i.MX8MP and i.MX93).
Changelog:
v2 -> v3:
* Merge binding patches into one and extend commit message
* Rebase to next-20241218v1 -> v2:
* Split binding patch
* Add solution for hardwiredSD_VSEL
* Leave regulator core untouched as requested by Mark
* Add devicetree changes for i.MX8MP and i.MX93[1] https://lore.kernel.org/lkml/[email protected]/
Frieder Schrempf (9):
dt-bindings: regulator: pca9450: Add properties for handling LDO5
arm64: dts: imx8mp-skov-reva: Use hardware signal for SD card VSELECT Revert "regulator: pca9450: AddSD_VSELGPIO for LDO5"
regulator: pca9450: Fix control register for LDO5
regulator: pca9450: Fix enable register for LDO5
regulator: pca9450: Handle hardware with fixedSD_VSELfor LDO5
arm64: dts: imx8mm-kontron: Add support for readingSD_VSELsignal
arm64: dts: imx93-kontron: Fix SD card IO voltage control
arm64: dts: imx8mp-kontron: Add support for readingSD_VSELsignal
Quoted 9 lines
.../regulator/nxp,pca9450-regulator.yaml | 29 ++++- .../boot/dts/freescale/imx8mm-kontron-bl.dts | 10 +- .../dts/freescale/imx8mm-kontron-osm-s.dtsi | 7 +- .../dts/freescale/imx8mp-kontron-osm-s.dtsi | 7 +- .../boot/dts/freescale/imx8mp-skov-reva.dtsi | 5 +- .../dts/freescale/imx93-kontron-osm-s.dtsi | 5 +- drivers/regulator/pca9450-regulator.c | 103 +++++++++++++++--- 7 files changed, 133 insertions(+), 33 deletions(-)
I just want to ask kindly if there is any feedback for the driver and devicetree changes in this set?
Thanks
Frieder
Mark Brown
maintainerQuoted 2 lines · Frieder Schrempf
I just want to ask kindly if there is any feedback for the driver and devicetree changes in this set?
Please don't send content free pings and please allow a reasonable time for review. People get busy, go on holiday, attend conferences and so on so unless there is some reason for urgency (like critical bug fixes) please allow at least a couple of weeks for review. If there have been review comments then people may be waiting for those to be addressed.
Sending content free pings adds to the mail volume (if they are seen at all) which is often the problem and since they can't be reviewed directly if something has gone wrong you'll have to resend the patches anyway, so sending again is generally a better approach though there are some other maintainers who like them - if in doubt look at how patches for the subsystem are normally handled.
Mark Brown
maintainerRe: (subset) [PATCH v3 0/9] Use correct LDO5 control registers for PCA9450
In reply to Frieder SchrempfQuoted 9 lines · Frieder Schrempf
This is a follow-up of [1].
The main objective of this is to fix the PCA9450 driver to use the correct control register for the LDO5 regulator.
Currently the control register to use for LDO5 is hardcoded to
LDO5CTRL_H. This is wrong for two reasons:[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
Thanks!
[1/9] dt-bindings: regulator: pca9450: Add properties for handling LDO5
commit: f9cbf56b0a1966d977df87d15a5bdbff2c342062
[2/9] arm64: dts: imx8mp-skov-reva: Use hardware signal for SD card VSELECT
commit: b5ec74c2aec76fbdff9bc16951455602e11902bf
[3/9] Revert "regulator: pca9450: Add SD_VSEL GPIO for LDO5"
commit: c73be62caabbec6629689c705aea65e5ce364d5d
[4/9] regulator: pca9450: Fix control register for LDO5
commit: 3ce6f4f943ddd9edc03e450a2a0d89cb025b165b
[5/9] regulator: pca9450: Fix enable register for LDO5
commit: f5aab0438ef17f01c5ecd25e61ae6a03f82a4586All 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
Re: (subset) [PATCH v3 0/9] Use correct LDO5 control registers for PCA9450
Hi Mark,
Quoted 18 lines · Mark Brown
Quoted 9 lines · Frieder Schrempf
This is a follow-up of [1].
The main objective of this is to fix the PCA9450 driver to use the correct control register for the LDO5 regulator.
Currently the control register to use for LDO5 is hardcoded to
LDO5CTRL_H. This is wrong for two reasons:[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
Thanks!
[1/9] dt-bindings: regulator: pca9450: Add properties for handling LDO5
Quoted 10 lines
commit: f9cbf56b0a1966d977df87d15a5bdbff2c342062
[2/9] arm64: dts: imx8mp-skov-reva: Use hardware signal for SD card VSELECT
commit: b5ec74c2aec76fbdff9bc16951455602e11902bf
[3/9] Revert "regulator: pca9450: Add SD_VSEL GPIO for LDO5"
commit: c73be62caabbec6629689c705aea65e5ce364d5d
[4/9] regulator: pca9450: Fix control register for LDO5
commit: 3ce6f4f943ddd9edc03e450a2a0d89cb025b165b
[5/9] regulator: pca9450: Fix enable register for LDO5
commit: f5aab0438ef17f01c5ecd25e61ae6a03f82a4586Thanks for picking up these patches. Meanwhile Shawn has applied patch 2 and 7-9 on his side. What about patch 6? Is there a specific reason why this was left out?
Thanks
Frieder
Shawn Guo
AppliedQuoted 2 lines · Frieder Schrempf
Frieder Schrempf (9):
arm64: dts: imx8mp-skov-reva: Use hardware signal for SD card VSELECT
...
Quoted 3 lines
arm64: dts: imx8mm-kontron: Add support for reading
SD_VSELsignal
arm64: dts: imx93-kontron: Fix SD card IO voltage control
arm64: dts: imx8mp-kontron: Add support for readingSD_VSELsignal
Applied all 4 DTS patches, thanks!