* [PATCH 1/2] pmic: pca9450: Add optional SD_VSEL GPIO for LDO5
@ 2022-06-23 17:42 Frieder Schrempf
2022-06-23 17:42 ` [PATCH 2/2] imx: kontron-sl-mx8mm: Enable PCA9450 regulator driver and fix SD card access Frieder Schrempf
2022-06-23 17:58 ` [PATCH 1/2] pmic: pca9450: Add optional SD_VSEL GPIO for LDO5 Fabio Estevam
0 siblings, 2 replies; 4+ messages in thread
From: Frieder Schrempf @ 2022-06-23 17:42 UTC (permalink / raw)
To: Jaehoon Chung, u-boot
Cc: Heiko Thiery, Tom Rini, Frieder Schrempf, Fabio Estevam,
Marek Vasut
From: Frieder Schrempf <frieder.schrempf@kontron.de>
LDO5 has two separate control registers. LDO5CTRL_L is used if the
input signal SD_VSEL is low and LDO5CTRL_H if it is high.
The current driver implementation only uses LDO5CTRL_H. To make this
work on boards that have SD_VSEL connected to a GPIO, we add support
for specifying an optional GPIO and setting it to high at probe time.
In the future we might also want to add support for boards that have
SD_VSEL set to a fixed low level. In this case we need to change the
driver to be able to use the LDO5CTRL_L register.
This is a port of the same change in the Linux kernel:
8c67a11bae88 ("regulator: pca9450: Add SD_VSEL GPIO for LDO5")
Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
drivers/power/pmic/pca9450.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/power/pmic/pca9450.c b/drivers/power/pmic/pca9450.c
index 116ac49a8db..6b9befba18c 100644
--- a/drivers/power/pmic/pca9450.c
+++ b/drivers/power/pmic/pca9450.c
@@ -7,9 +7,12 @@
#include <fdtdec.h>
#include <errno.h>
#include <dm.h>
+#include <dm/device_compat.h>
#include <i2c.h>
+#include <linux/err.h>
#include <log.h>
#include <asm/global_data.h>
+#include <asm-generic/gpio.h>
#include <power/pmic.h>
#include <power/regulator.h>
#include <power/pca9450.h>
@@ -26,6 +29,10 @@ static const struct pmic_child_info pmic_children_info[] = {
{ },
};
+struct pca9450_priv {
+ struct gpio_desc *sd_vsel_gpio;
+};
+
static int pca9450_reg_count(struct udevice *dev)
{
return PCA9450_REG_NUM;
@@ -76,6 +83,24 @@ static int pca9450_bind(struct udevice *dev)
return 0;
}
+static int pca9450_probe(struct udevice *dev)
+{
+ struct pca9450_priv *priv = dev_get_priv(dev);
+ int ret = 0;
+
+ if (IS_ENABLED(CONFIG_DM_GPIO) && IS_ENABLED(CONFIG_DM_REGULATOR_PCA9450)) {
+ priv->sd_vsel_gpio = devm_gpiod_get_optional(dev, "sd-vsel",
+ GPIOD_IS_OUT |
+ GPIOD_IS_OUT_ACTIVE);
+ if (IS_ERR(priv->sd_vsel_gpio)) {
+ ret = PTR_ERR(priv->sd_vsel_gpio);
+ dev_err(dev, "Failed to request SD_VSEL GPIO: %d\n", ret);
+ }
+ }
+
+ return ret;
+}
+
static struct dm_pmic_ops pca9450_ops = {
.reg_count = pca9450_reg_count,
.read = pca9450_read,
@@ -94,5 +119,7 @@ U_BOOT_DRIVER(pmic_pca9450) = {
.id = UCLASS_PMIC,
.of_match = pca9450_ids,
.bind = pca9450_bind,
+ .probe = pca9450_probe,
.ops = &pca9450_ops,
+ .priv_auto = sizeof(struct pca9450_priv),
};
--
2.36.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] imx: kontron-sl-mx8mm: Enable PCA9450 regulator driver and fix SD card access
2022-06-23 17:42 [PATCH 1/2] pmic: pca9450: Add optional SD_VSEL GPIO for LDO5 Frieder Schrempf
@ 2022-06-23 17:42 ` Frieder Schrempf
2022-06-23 17:58 ` Fabio Estevam
2022-06-23 17:58 ` [PATCH 1/2] pmic: pca9450: Add optional SD_VSEL GPIO for LDO5 Fabio Estevam
1 sibling, 1 reply; 4+ messages in thread
From: Frieder Schrempf @ 2022-06-23 17:42 UTC (permalink / raw)
To: Frieder Schrempf, u-boot
Cc: Heiko Thiery, Tom Rini, Fabio Estevam, Jaehoon Chung, Simon Glass
From: Frieder Schrempf <frieder.schrempf@kontron.de>
Currently accessing the SD card on USDHC2 fails with:
=> mmc dev 1
Card did not respond to voltage select! : -110
This is due to the fact that UHS modes are enabled in the defconfig
and the devicetree, but the referenced LDO5 regulator (reg_nvcc_sd)
is not available to switch the data lines from 3.3V to 1.8V mode.
By enabling the regulator driver the vqmmc-supply is now available
and the SD card works also in high speed modes:
=> mmc dev 1
switch to partitions #0, OK
mmc1 is current device
Please note that the board has a GPIO connected to the SD_VSEL signal
of the PMIC. As the driver uses the LDO5CTRL_H register to set the
voltage, we need to make sure that this GPIO (GPIO01_IO4) is set to
a high level.
Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
Hi Tom, sorry for another late fix. I just keep discovering things
that are broken.
Please note that this depends on a driver change in patch 1 of this
series.
---
configs/kontron-sl-mx8mm_defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/configs/kontron-sl-mx8mm_defconfig b/configs/kontron-sl-mx8mm_defconfig
index 2e9d52522b2..727f99f0063 100644
--- a/configs/kontron-sl-mx8mm_defconfig
+++ b/configs/kontron-sl-mx8mm_defconfig
@@ -99,6 +99,7 @@ CONFIG_DM_PMIC=y
CONFIG_DM_PMIC_PCA9450=y
CONFIG_SPL_DM_PMIC_PCA9450=y
CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_PCA9450=y
CONFIG_DM_RTC=y
CONFIG_RTC_RV8803=y
CONFIG_CONS_INDEX=2
--
2.36.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] pmic: pca9450: Add optional SD_VSEL GPIO for LDO5
2022-06-23 17:42 [PATCH 1/2] pmic: pca9450: Add optional SD_VSEL GPIO for LDO5 Frieder Schrempf
2022-06-23 17:42 ` [PATCH 2/2] imx: kontron-sl-mx8mm: Enable PCA9450 regulator driver and fix SD card access Frieder Schrempf
@ 2022-06-23 17:58 ` Fabio Estevam
1 sibling, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2022-06-23 17:58 UTC (permalink / raw)
To: Frieder Schrempf
Cc: Jaehoon Chung, u-boot, Heiko Thiery, Tom Rini, Frieder Schrempf,
Marek Vasut
On 23/06/2022 14:42, Frieder Schrempf wrote:
> From: Frieder Schrempf <frieder.schrempf@kontron.de>
>
> LDO5 has two separate control registers. LDO5CTRL_L is used if the
> input signal SD_VSEL is low and LDO5CTRL_H if it is high.
> The current driver implementation only uses LDO5CTRL_H. To make this
> work on boards that have SD_VSEL connected to a GPIO, we add support
> for specifying an optional GPIO and setting it to high at probe time.
>
> In the future we might also want to add support for boards that have
> SD_VSEL set to a fixed low level. In this case we need to change the
> driver to be able to use the LDO5CTRL_L register.
>
> This is a port of the same change in the Linux kernel:
> 8c67a11bae88 ("regulator: pca9450: Add SD_VSEL GPIO for LDO5")
>
> Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] imx: kontron-sl-mx8mm: Enable PCA9450 regulator driver and fix SD card access
2022-06-23 17:42 ` [PATCH 2/2] imx: kontron-sl-mx8mm: Enable PCA9450 regulator driver and fix SD card access Frieder Schrempf
@ 2022-06-23 17:58 ` Fabio Estevam
0 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2022-06-23 17:58 UTC (permalink / raw)
To: Frieder Schrempf
Cc: Frieder Schrempf, u-boot, Heiko Thiery, Tom Rini, Jaehoon Chung,
Simon Glass
On 23/06/2022 14:42, Frieder Schrempf wrote:
> From: Frieder Schrempf <frieder.schrempf@kontron.de>
>
> Currently accessing the SD card on USDHC2 fails with:
>
> => mmc dev 1
> Card did not respond to voltage select! : -110
>
> This is due to the fact that UHS modes are enabled in the defconfig
> and the devicetree, but the referenced LDO5 regulator (reg_nvcc_sd)
> is not available to switch the data lines from 3.3V to 1.8V mode.
>
> By enabling the regulator driver the vqmmc-supply is now available
> and the SD card works also in high speed modes:
>
> => mmc dev 1
> switch to partitions #0, OK
> mmc1 is current device
>
> Please note that the board has a GPIO connected to the SD_VSEL signal
> of the PMIC. As the driver uses the LDO5CTRL_H register to set the
> voltage, we need to make sure that this GPIO (GPIO01_IO4) is set to
> a high level.
>
> Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-06-23 17:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-23 17:42 [PATCH 1/2] pmic: pca9450: Add optional SD_VSEL GPIO for LDO5 Frieder Schrempf
2022-06-23 17:42 ` [PATCH 2/2] imx: kontron-sl-mx8mm: Enable PCA9450 regulator driver and fix SD card access Frieder Schrempf
2022-06-23 17:58 ` Fabio Estevam
2022-06-23 17:58 ` [PATCH 1/2] pmic: pca9450: Add optional SD_VSEL GPIO for LDO5 Fabio Estevam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox