Merge tag 'mmc-power-next-2025-09-01' of https://source.denx.de/u-boot/custodians/u-boot-mmc into next

CI: https://source.denx.de/u-boot/custodians/u-boot-mmc/-/pipelines/27536

- Update compatibles for PMICs used by exynos devices
- Support system reset and reset status for pca9450
- Fix for pca9450 LDO5 registers and drop deprecated sd-vsel-gpios
- Two minor fixes found by smatch
This commit is contained in:
Tom Rini
2025-09-01 14:32:00 -06:00
16 changed files with 138 additions and 57 deletions

View File

@@ -102,9 +102,9 @@
status = "okay";
max8997-pmic@66 {
compatible = "maxim,max8997";
compatible = "maxim,max8997-pmic";
reg = <0x66 0 0>;
voltage-regulators {
regulators {
valive_reg: LDO2 {
regulator-name = "VALIVE_1.1V_C210";
regulator-min-microvolt = <1100000>;

View File

@@ -77,7 +77,7 @@
max8998-pmic@66 {
compatible = "maxim,max8998";
reg = <0x66 0 0>;
voltage-regulators {
regulators {
ldo2_reg: LDO2 {
regulator-name = "VALIVE_1.2V";
regulator-min-microvolt = <1200000>;

View File

@@ -40,7 +40,7 @@
s2mps11_pmic@66 {
compatible = "samsung,s2mps11-pmic";
reg = <0x66>;
voltage-regulators {
regulators {
ldo1_reg: LDO1 {
regulator-name = "vdd_ldo1";
regulator-min-microvolt = <1000000>;

View File

@@ -344,7 +344,6 @@
pinctrl-0 = <&pinctrl_pmic>;
interrupt-parent = <&gpio1>;
interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
sd-vsel-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
/*
* i.MX 8M Plus Data Sheet for Consumer Products

View File

@@ -245,7 +245,6 @@
pinctrl-0 = <&pinctrl_pmic>;
interrupt-parent = <&gpio1>;
interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
sd-vsel-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
/*
* i.MX 8M Plus Data Sheet for Consumer Products

View File

@@ -45,7 +45,7 @@
compatible = "maxim,max8998";
reg = <0x66 0 0>;
voltage-regulators {
regulators {
ldo2_reg: LDO2 {
regulator-compatible = "LDO2";
regulator-name = "VALIVE_1.1V";

View File

@@ -428,21 +428,6 @@ void exynos_init(void)
board_gpio_init();
}
int exynos_power_init(void)
{
const char *mmc_regulators[] = {
"VDDQ_EMMC_1.8V",
"VDDQ_EMMC_2.8V",
"TFLASH_2.8V",
NULL,
};
if (regulator_list_autoset(mmc_regulators, NULL, true))
pr_err("Unable to init all mmc regulators\n");
return 0;
}
#ifdef CONFIG_USB_GADGET
static int s5pc210_phy_control(int on)
{

View File

@@ -182,7 +182,7 @@ static int sdhci_iproc_execute_tuning(struct mmc *mmc, u8 opcode)
u32 ctrl;
u32 blocksize = SDHCI_MAKE_BLKSZ(SDHCI_DEFAULT_BOUNDARY_ARG, 64);
struct sdhci_host *host = dev_get_priv(mmc->dev);
char tuning_loop_counter = MAX_TUNING_LOOP;
s8 tuning_loop_counter = MAX_TUNING_LOOP;
int ret = 0;
sdhci_start_tuning(host);

View File

@@ -125,21 +125,21 @@ void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret)
printf("\t\tMMC_RSP_NONE\n");
break;
case MMC_RSP_R1:
printf("\t\tMMC_RSP_R1,5,6,7 \t 0x%08x \n",
printf("\t\tMMC_RSP_R1,5,6,7 \t 0x%08x\n",
cmd->response[0]);
break;
case MMC_RSP_R1b:
printf("\t\tMMC_RSP_R1b\t\t 0x%08x \n",
printf("\t\tMMC_RSP_R1b\t\t 0x%08x\n",
cmd->response[0]);
break;
case MMC_RSP_R2:
printf("\t\tMMC_RSP_R2\t\t 0x%08x \n",
printf("\t\tMMC_RSP_R2\t\t 0x%08x\n",
cmd->response[0]);
printf("\t\t \t\t 0x%08x \n",
printf("\t\t \t\t 0x%08x\n",
cmd->response[1]);
printf("\t\t \t\t 0x%08x \n",
printf("\t\t \t\t 0x%08x\n",
cmd->response[2]);
printf("\t\t \t\t 0x%08x \n",
printf("\t\t \t\t 0x%08x\n",
cmd->response[3]);
printf("\n");
printf("\t\t\t\t\tDUMPING DATA\n");
@@ -154,7 +154,7 @@ void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret)
}
break;
case MMC_RSP_R3:
printf("\t\tMMC_RSP_R3,4\t\t 0x%08x \n",
printf("\t\tMMC_RSP_R3,4\t\t 0x%08x\n",
cmd->response[0]);
break;
default:

View File

@@ -228,9 +228,9 @@ config PMIC_MAX8997
This is a Power Management IC with RTC, Fuel Gauge, MUIC control on Chip.
- 21x LDOs
- 12x GPIOs
- Haptic Motor driver
- Haptic motor driver
- RTC with two alarms
- Fueal Gauge and One backup battery charger
- Fuel Gauge and one backup battery charger
- MUIC
- Others

View File

@@ -46,7 +46,7 @@ static struct dm_pmic_ops max8997_ops = {
};
static const struct udevice_id max8997_ids[] = {
{ .compatible = "maxim,max8997" },
{ .compatible = "maxim,max8997-pmic" },
{ },
};

View File

@@ -7,15 +7,16 @@
#include <errno.h>
#include <dm.h>
#include <dm/device_compat.h>
#include <dm/lists.h>
#include <i2c.h>
#include <linux/err.h>
#include <log.h>
#include <asm/global_data.h>
#include <asm-generic/gpio.h>
#include <linux/delay.h>
#include <linux/printk.h>
#include <power/pmic.h>
#include <power/regulator.h>
#include <power/pca9450.h>
#include <sysreset.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -29,10 +30,6 @@ 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;
@@ -85,20 +82,15 @@ static int pca9450_bind(struct udevice *dev)
static int pca9450_probe(struct udevice *dev)
{
struct pca9450_priv *priv = dev_get_priv(dev);
unsigned int reset_ctrl;
int ret = 0;
int ret;
if (CONFIG_IS_ENABLED(DM_GPIO) && CONFIG_IS_ENABLED(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);
if (ret)
return ret;
}
if (CONFIG_IS_ENABLED(SYSRESET)) {
ret = device_bind_driver_to_node(dev, "pca9450_sysreset",
"pca9450_sysreset",
dev_ofnode(dev), NULL);
if (ret)
return ret;
}
if (ofnode_read_bool(dev_ofnode(dev), "nxp,wdog_b-warm-reset"))
@@ -132,5 +124,73 @@ U_BOOT_DRIVER(pmic_pca9450) = {
.bind = pca9450_bind,
.probe = pca9450_probe,
.ops = &pca9450_ops,
.priv_auto = sizeof(struct pca9450_priv),
};
#ifdef CONFIG_SYSRESET
static int pca9450_sysreset_request(struct udevice *dev, enum sysreset_t type)
{
u8 cmd = PCA9450_SW_RST_COLD_RST;
if (type != SYSRESET_COLD)
return -EPROTONOSUPPORT;
if (pmic_write(dev->parent, PCA9450_SW_RST, &cmd, 1)) {
dev_err(dev, "reset command failed\n");
} else {
/* tRESTART is 250ms, delay 300ms just to be sure */
mdelay(300);
/* Should not get here, warn if we do */
dev_warn(dev, "didn't respond to reset command\n");
}
return -EINPROGRESS;
}
int pca9450_sysreset_get_status(struct udevice *dev, char *buf, int size)
{
const char *reason;
int ret;
u8 reg;
ret = pmic_read(dev->parent, PCA9450_PWRON_STAT, &reg, 1);
if (ret)
return ret;
switch (reg) {
case PCA9450_PWRON_STAT_PWRON_MASK:
reason = "PWRON";
break;
case PCA9450_PWRON_STAT_WDOG_MASK:
reason = "WDOGB";
break;
case PCA9450_PWRON_STAT_SW_RST_MASK:
reason = "SW_RST";
break;
case PCA9450_PWRON_STAT_PMIC_RST_MASK:
reason = "PMIC_RST";
break;
default:
reason = "UNKNOWN";
break;
}
ret = snprintf(buf, size, "Reset Status: %s\n", reason);
if (ret < 0) {
dev_err(dev, "Write reset status error (err = %d)\n", ret);
return -EIO;
}
return 0;
}
static struct sysreset_ops pca9450_sysreset_ops = {
.request = pca9450_sysreset_request,
.get_status = pca9450_sysreset_get_status,
};
U_BOOT_DRIVER(pca9450_sysreset) = {
.name = "pca9450_sysreset",
.id = UCLASS_SYSRESET,
.ops = &pca9450_sysreset_ops,
};
#endif /* CONFIG_SYSRESET */

View File

@@ -52,7 +52,7 @@ static int s2mps11_probe(struct udevice *dev)
ofnode regulators_node;
int children;
regulators_node = dev_read_subnode(dev, "voltage-regulators");
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
debug("%s: %s regulators subnode not found!\n", __func__,
dev->name);

View File

@@ -7,9 +7,12 @@
* ROHM BD71837 regulator driver
*/
#include <asm-generic/gpio.h>
#include <dm.h>
#include <dm/device_compat.h>
#include <log.h>
#include <linux/bitops.h>
#include <linux/err.h>
#include <power/pca9450.h>
#include <power/pmic.h>
#include <power/regulator.h>
@@ -52,6 +55,8 @@ struct pca9450_plat {
u8 volt_mask;
struct pca9450_vrange *ranges;
unsigned int numranges;
struct gpio_desc *sd_vsel_gpio;
bool sd_vsel_fixed_low;
};
#define PCA_RANGE(_min, _vstep, _sel_low, _sel_hi) \
@@ -144,7 +149,7 @@ static struct pca9450_plat pca9450_reg_data[] = {
PCA_DATA("LDO4", PCA9450_LDO4CTRL, HW_STATE_CONTROL,
PCA9450_LDO4CTRL, PCA9450_LDO34_MASK,
pca9450_ldo34_vranges),
PCA_DATA("LDO5", PCA9450_LDO5CTRL_H, HW_STATE_CONTROL,
PCA_DATA("LDO5", PCA9450_LDO5CTRL_L, HW_STATE_CONTROL,
PCA9450_LDO5CTRL_H, PCA9450_LDO5_MASK,
pca9450_ldo5_vranges),
};
@@ -222,13 +227,24 @@ static int pca9450_set_enable(struct udevice *dev, bool enable)
val);
}
static u8 pca9450_get_vsel_reg(struct pca9450_plat *plat)
{
if (!strcmp(plat->name, "LDO5") &&
((plat->sd_vsel_gpio && !dm_gpio_get_value(plat->sd_vsel_gpio)) ||
plat->sd_vsel_fixed_low)) {
return PCA9450_LDO5CTRL_L;
}
return plat->volt_reg;
}
static int pca9450_get_value(struct udevice *dev)
{
struct pca9450_plat *plat = dev_get_plat(dev);
unsigned int reg, tmp;
int i, ret;
ret = pmic_reg_read(dev->parent, plat->volt_reg);
ret = pmic_reg_read(dev->parent, pca9450_get_vsel_reg(plat));
if (ret < 0)
return ret;
@@ -274,7 +290,7 @@ static int pca9450_set_value(struct udevice *dev, int uvolt)
if (!found)
return -EINVAL;
return pmic_clrsetbits(dev->parent, plat->volt_reg,
return pmic_clrsetbits(dev->parent, pca9450_get_vsel_reg(plat),
plat->volt_mask, sel);
}
@@ -335,6 +351,21 @@ static int pca9450_regulator_probe(struct udevice *dev)
*plat = pca9450_reg_data[i];
if (!strcmp(plat->name, "LDO5")) {
if (CONFIG_IS_ENABLED(DM_GPIO) && CONFIG_IS_ENABLED(DM_REGULATOR_PCA9450)) {
plat->sd_vsel_gpio = devm_gpiod_get_optional(dev, "sd-vsel",
GPIOD_IS_IN);
if (IS_ERR(plat->sd_vsel_gpio)) {
ret = PTR_ERR(plat->sd_vsel_gpio);
dev_err(dev, "Failed to request SD_VSEL GPIO: %d\n", ret);
if (ret)
return ret;
}
}
plat->sd_vsel_fixed_low = dev_read_bool(dev, "nxp,sd-vsel-fixed-low");
}
return 0;
}

View File

@@ -75,4 +75,11 @@ enum {
#define PCA9450_PMIC_RESET_WDOG_B_CFG_WARM 0x40
#define PCA9450_PMIC_RESET_WDOG_B_CFG_COLD_LDO12 0x80
#define PCA9450_PWRON_STAT_PWRON_MASK 0x80
#define PCA9450_PWRON_STAT_WDOG_MASK 0x40
#define PCA9450_PWRON_STAT_SW_RST_MASK 0x20
#define PCA9450_PWRON_STAT_PMIC_RST_MASK 0x10
#define PCA9450_SW_RST_COLD_RST 0x14
#endif

View File

@@ -123,7 +123,7 @@ enum {
/* platform data */
struct tps65910_regulator_pdata {
u32 supply; /* regulator supply voltage in uV */
int supply; /* regulator supply voltage in uV */
uint unit; /* unit-address according to DT */
};