From e98d5fef8556f1da7f903fd1908feed84bb0f90d Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 21 Oct 2016 16:40:05 +0800 Subject: regulator: tps6507x: Drop pointless static qualifier for *reg_data variable There is no need to use static for this local variable. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/tps6507x-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c index dad0bac09ecf..c179a3a221af 100644 --- a/drivers/regulator/tps6507x-regulator.c +++ b/drivers/regulator/tps6507x-regulator.c @@ -375,7 +375,7 @@ static struct tps6507x_board *tps6507x_parse_dt_reg_data( struct device_node *np = pdev->dev.parent->of_node; struct device_node *regulators; struct of_regulator_match *matches; - static struct regulator_init_data *reg_data; + struct regulator_init_data *reg_data; int idx = 0, count, ret; tps_board = devm_kzalloc(&pdev->dev, sizeof(*tps_board), -- cgit v1.2.3 From 205321f0927ad2303e7f71767d402e0ff36a9a87 Mon Sep 17 00:00:00 2001 From: Lokesh Vutla Date: Thu, 10 Nov 2016 10:59:15 +0530 Subject: regulator: lp873x: Add support for populating input supply In order to have a proper topology of regulators for a platform, each registering regulator needs to populate supply_name field for identifying its supply's name. Add supply_name field for lp873x regulators. Acked-by: Rob Herring Signed-off-by: Lokesh Vutla Acked-for-MFD-by: Lee Jones Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/mfd/lp873x.txt | 8 ++++++++ drivers/regulator/lp873x-regulator.c | 1 + 2 files changed, 9 insertions(+) (limited to 'drivers/regulator') diff --git a/Documentation/devicetree/bindings/mfd/lp873x.txt b/Documentation/devicetree/bindings/mfd/lp873x.txt index 52766c2035f7..ae9cf39bd101 100644 --- a/Documentation/devicetree/bindings/mfd/lp873x.txt +++ b/Documentation/devicetree/bindings/mfd/lp873x.txt @@ -7,6 +7,9 @@ Required properties: - #gpio-cells: Should be two. The first cell is the pin number and the second cell is used to specify flags. See ../gpio/gpio.txt for more information. + - xxx-in-supply: Phandle to parent supply node of each regulator + populated under regulators node. xxx can be + buck0, buck1, ldo0 or ldo1. - regulators: List of child nodes that specify the regulator initialization data. Example: @@ -17,6 +20,11 @@ pmic: lp8733@60 { gpio-controller; #gpio-cells = <2>; + buck0-in-supply = <&vsys_3v3>; + buck1-in-supply = <&vsys_3v3>; + ldo0-in-supply = <&vsys_3v3>; + ldo1-in-supply = <&vsys_3v3>; + regulators { lp8733_buck0: buck0 { regulator-name = "lp8733-buck0"; diff --git a/drivers/regulator/lp873x-regulator.c b/drivers/regulator/lp873x-regulator.c index e504b9148226..70e3df653381 100644 --- a/drivers/regulator/lp873x-regulator.c +++ b/drivers/regulator/lp873x-regulator.c @@ -24,6 +24,7 @@ [_id] = { \ .desc = { \ .name = _name, \ + .supply_name = _of "-in", \ .id = _id, \ .of_match = of_match_ptr(_of), \ .regulators_node = of_match_ptr("regulators"),\ -- cgit v1.2.3 From 09f2ba0b0b7c44ecea49cf69a708203b76ba5535 Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Thu, 10 Nov 2016 17:21:29 +0800 Subject: regulator: gpio: properly check return value of of_get_named_gpio The function of_get_named_gpio() could return -ENOENT, -EPROBE_DEFER -EINVAL and so on. Currently, for the optional property "enable-gpio", we only check -EPROBE_DEFER, this is not enough since there may be misconfigured "enable-gpio" in the DTB, of_get_named_gpio() will return -EINVAL in this case, we should return immediately here. And for the optional property "gpios", we didn't check the return value, the driver will continue to the point where gpio_request_array() is called, it doesn't make sense to continue if we got -EPROBE_DEFER or -EINVAL here. This patch tries to address these two issues by properly checking the return value of of_get_named_gpio. Signed-off-by: Jisheng Zhang Signed-off-by: Mark Brown --- drivers/regulator/gpio-regulator.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 83e89e5d4752..0fce06acfaec 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -162,8 +162,8 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, of_property_read_u32(np, "startup-delay-us", &config->startup_delay); config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0); - if (config->enable_gpio == -EPROBE_DEFER) - return ERR_PTR(-EPROBE_DEFER); + if (config->enable_gpio < 0 && config->enable_gpio != -ENOENT) + return ERR_PTR(config->enable_gpio); /* Fetch GPIOs. - optional property*/ ret = of_gpio_count(np); @@ -190,8 +190,11 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, for (i = 0; i < config->nr_gpios; i++) { gpio = of_get_named_gpio(np, "gpios", i); - if (gpio < 0) + if (gpio < 0) { + if (gpio != -ENOENT) + return ERR_PTR(gpio); break; + } config->gpios[i].gpio = gpio; if (proplen > 0) { of_property_read_u32_index(np, "gpios-states", -- cgit v1.2.3 From 9a40cb0cb8b55ecfdcd3cec1381bcc46ec488588 Mon Sep 17 00:00:00 2001 From: Venkat Reddy Talla Date: Tue, 15 Nov 2016 22:51:20 +0530 Subject: regulator: max77620: remove unused variable max77620_reuglator_pdata structure variable reg_idata is not used anywhere in the regulator driver, so removing it. Signed-off-by: Venkat Reddy Talla Signed-off-by: Mark Brown --- drivers/regulator/max77620-regulator.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77620-regulator.c b/drivers/regulator/max77620-regulator.c index a1b49a6d538f..c39a56b41901 100644 --- a/drivers/regulator/max77620-regulator.c +++ b/drivers/regulator/max77620-regulator.c @@ -73,7 +73,6 @@ struct max77620_regulator_info { }; struct max77620_regulator_pdata { - struct regulator_init_data *reg_idata; int active_fps_src; int active_fps_pd_slot; int active_fps_pu_slot; -- cgit v1.2.3 From 383d0fca7035a12f1201277d33e8fc87c9d60c9a Mon Sep 17 00:00:00 2001 From: Venkat Reddy Talla Date: Thu, 17 Nov 2016 23:24:35 +0530 Subject: regulator: max77620: add support to configure MPOK Adding support to configure regulator POK mapping bit to control nRST_IO and GPIO1 POK function. In tegra based platform which uses MAX20024 pmic, when some of regulators are configured FPS_NONE(flexible power sequencer) causes PMIC GPIO1 to go low which lead to various other rails turning off, to avoid this MPOK bit of those regulators need to be set to 0 so that PMIC GPIO1 will not go low. Signed-off-by: Venkat Reddy Talla Acked-by: Lee Jones Signed-off-by: Mark Brown --- drivers/regulator/max77620-regulator.c | 46 ++++++++++++++++++++++++++++++++++ include/linux/mfd/max77620.h | 2 ++ 2 files changed, 48 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77620-regulator.c b/drivers/regulator/max77620-regulator.c index c39a56b41901..d088a7c79e60 100644 --- a/drivers/regulator/max77620-regulator.c +++ b/drivers/regulator/max77620-regulator.c @@ -80,6 +80,7 @@ struct max77620_regulator_pdata { int suspend_fps_pd_slot; int suspend_fps_pu_slot; int current_mode; + int power_ok; int ramp_rate_setting; }; @@ -350,11 +351,48 @@ static int max77620_set_slew_rate(struct max77620_regulator *pmic, int id, return 0; } +static int max77620_config_power_ok(struct max77620_regulator *pmic, int id) +{ + struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; + struct max77620_regulator_info *rinfo = pmic->rinfo[id]; + struct max77620_chip *chip = dev_get_drvdata(pmic->dev->parent); + u8 val, mask; + int ret; + + switch (chip->chip_id) { + case MAX20024: + if (rpdata->power_ok >= 0) { + if (rinfo->type == MAX77620_REGULATOR_TYPE_SD) + mask = MAX20024_SD_CFG1_MPOK_MASK; + else + mask = MAX20024_LDO_CFG2_MPOK_MASK; + + val = rpdata->power_ok ? mask : 0; + + ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr, + mask, val); + if (ret < 0) { + dev_err(pmic->dev, "Reg 0x%02x update failed %d\n", + rinfo->cfg_addr, ret); + return ret; + } + } + break; + + default: + break; + } + + return 0; +} + static int max77620_init_pmic(struct max77620_regulator *pmic, int id) { struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; int ret; + max77620_config_power_ok(pmic, id); + /* Update power mode */ ret = max77620_regulator_get_power_mode(pmic, id); if (ret < 0) @@ -594,6 +632,12 @@ static int max77620_of_parse_cb(struct device_node *np, np, "maxim,suspend-fps-power-down-slot", &pval); rpdata->suspend_fps_pd_slot = (!ret) ? pval : -1; + ret = of_property_read_u32(np, "maxim,power-ok-control", &pval); + if (!ret) + rpdata->power_ok = pval; + else + rpdata->power_ok = -1; + ret = of_property_read_u32(np, "maxim,ramp-rate-setting", &pval); rpdata->ramp_rate_setting = (!ret) ? pval : 0; @@ -806,6 +850,8 @@ static int max77620_regulator_resume(struct device *dev) for (id = 0; id < MAX77620_NUM_REGS; id++) { reg_pdata = &pmic->reg_pdata[id]; + max77620_config_power_ok(pmic, id); + max77620_regulator_set_fps_slots(pmic, id, false); if (reg_pdata->active_fps_src < 0) continue; diff --git a/include/linux/mfd/max77620.h b/include/linux/mfd/max77620.h index 3ca0af07fc78..ad2a9a852aea 100644 --- a/include/linux/mfd/max77620.h +++ b/include/linux/mfd/max77620.h @@ -180,6 +180,7 @@ #define MAX77620_SD_CFG1_FPWM_SD_MASK BIT(2) #define MAX77620_SD_CFG1_FPWM_SD_SKIP 0 #define MAX77620_SD_CFG1_FPWM_SD_FPWM BIT(2) +#define MAX20024_SD_CFG1_MPOK_MASK BIT(1) #define MAX77620_SD_CFG1_FSRADE_SD_MASK BIT(0) #define MAX77620_SD_CFG1_FSRADE_SD_DISABLE 0 #define MAX77620_SD_CFG1_FSRADE_SD_ENABLE BIT(0) @@ -187,6 +188,7 @@ /* LDO_CNFG2 */ #define MAX77620_LDO_POWER_MODE_MASK 0xC0 #define MAX77620_LDO_POWER_MODE_SHIFT 6 +#define MAX20024_LDO_CFG2_MPOK_MASK BIT(2) #define MAX77620_LDO_CFG2_ADE_MASK BIT(1) #define MAX77620_LDO_CFG2_ADE_DISABLE 0 #define MAX77620_LDO_CFG2_ADE_ENABLE BIT(1) -- cgit v1.2.3