From fe08be3ec8672ed92b3ed1b85810df9fa0f98931 Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Mon, 6 Oct 2014 21:33:36 +0200 Subject: regulator: anatop: Set default voltage selector for vddpu The code reads the default voltage selector from its register. If the bootloader disables the regulator, the default voltage selector will be 0 which results in faulty behaviour of this regulator driver. This patch sets a default voltage selector for vddpu if it is not set in the register. Signed-off-by: Markus Pargmann Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- drivers/regulator/anatop-regulator.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 4f730af70e7c..30e8d7ad5813 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c @@ -283,6 +283,14 @@ static int anatop_regulator_probe(struct platform_device *pdev) sreg->sel = 0; sreg->bypass = true; } + + /* + * In case vddpu was disabled by the bootloader, we need to set + * a sane default until imx6-cpufreq was probed and changes the + * voltage to the correct value. In this case we set 1.25V. + */ + if (!sreg->sel && !strcmp(sreg->name, "vddpu")) + sreg->sel = 22; } else { rdesc->ops = &anatop_rops; } -- cgit v1.2.3 From da0607c8df5c6277ff75468f24e055f193b6b336 Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Mon, 6 Oct 2014 21:33:37 +0200 Subject: regulator: anatop: Fail on invalid voltage selector A '0' voltage selector is invalid and can't be used with this driver. Signed-off-by: Markus Pargmann Signed-off-by: Mark Brown --- drivers/regulator/anatop-regulator.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 30e8d7ad5813..542d14ed48bb 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c @@ -291,6 +291,11 @@ static int anatop_regulator_probe(struct platform_device *pdev) */ if (!sreg->sel && !strcmp(sreg->name, "vddpu")) sreg->sel = 22; + + if (!sreg->sel) { + dev_err(&pdev->dev, "Failed to read a valid default voltage selector.\n"); + return -EINVAL; + } } else { rdesc->ops = &anatop_rops; } -- cgit v1.2.3 From 76f439df50aba1838e06dd01e5f20dada7473f57 Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Wed, 8 Oct 2014 15:47:05 +0200 Subject: regulator: Add ena_gpio_initialized to regulator_config Most drivers do not set the ena_gpio field of struct regulator_config before passing it to the regulator core. This is fine as long as the gpio identifier that is passed is a positive integer. But the gpio identifier 0 is also valid. So we are not able to decide wether we got a real gpio identifier or not based on a 0 in ena_gpio. To be able to decide if it is a valid gpio that got passed, this patch adds a ena_gpio_initialized field that should be set if was initialized with a correct value, either a gpio >= 0 or a negative error number. The core then checks if ena_gpio or ena_gpio_initialized before handling it as a gpio. This way we maintain backwards compatibility and fix the behaviour for gpio number 0. Signed-off-by: Markus Pargmann Signed-off-by: Mark Brown --- drivers/regulator/core.c | 3 ++- include/linux/regulator/driver.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index cd87c0c37034..55a87a2722d8 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3650,7 +3650,8 @@ regulator_register(const struct regulator_desc *regulator_desc, dev_set_drvdata(&rdev->dev, rdev); - if (config->ena_gpio && gpio_is_valid(config->ena_gpio)) { + if ((config->ena_gpio || config->ena_gpio_initialized) && + gpio_is_valid(config->ena_gpio)) { ret = regulator_ena_gpio_request(rdev, config); if (ret != 0) { rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index fc0ee0ce8325..28da08e4671f 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -301,6 +301,9 @@ struct regulator_desc { * NULL). * @regmap: regmap to use for core regmap helpers if dev_get_regulator() is * insufficient. + * @ena_gpio_initialized: GPIO controlling regulator enable was properly + * initialized, meaning that >= 0 is a valid gpio + * identifier and < 0 is a non existent gpio. * @ena_gpio: GPIO controlling regulator enable. * @ena_gpio_invert: Sense for GPIO enable control. * @ena_gpio_flags: Flags to use when calling gpio_request_one() @@ -312,6 +315,7 @@ struct regulator_config { struct device_node *of_node; struct regmap *regmap; + bool ena_gpio_initialized; int ena_gpio; unsigned int ena_gpio_invert:1; unsigned int ena_gpio_flags; -- cgit v1.2.3 From e6fb2aac552ab229e01169776199c13e2524c318 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 15 Oct 2014 18:20:31 +0200 Subject: regulator: max77802: Add .set_suspend_{enable,disable} callbacks The max77802 PMIC has an enable pin (PWRREQ) that can be used to switch regulators ON and OFF automatically by the Application Processor when the system is leaving and entering sleep mode. Only the BUCKs regulators had a .set_suspend_disable function handler that used the enable pin to turn OFF the regulators during suspend. But most LDOs also support that functionality (besides 1, 3, 20 and 21) so rename the function to a more generic name and use the same function for the LDOs. Also add a .set_suspend_enable handler for all regulators and use the same function used for the .enable operation. Finally, don't treat output ON/OFF controlled by PWRREQ as an operating mode using the ambiguous MAX77802_OPMODE_STANDBY since it's not an opmode. Instead make it clear that is a control value to switch the regulator OFF by PWRREQ when the system is entering in a suspend state. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index d89792b084e9..26f6963108e3 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -49,6 +49,8 @@ #define MAX77802_RAMP_RATE_MASK_4BIT 0xF0 #define MAX77802_RAMP_RATE_SHIFT_4BIT 4 +#define MAX77802_OFF_PWRREQ 0x1 + /* MAX77802 has two register formats: 2-bit and 4-bit */ static const unsigned int ramp_table_77802_2bit[] = { 12500, @@ -83,17 +85,16 @@ static int max77802_get_opmode_shift(int id) return -EINVAL; } -/* - * Some BUCKS supports Normal[ON/OFF] mode during suspend +/** + * max77802_set_suspend_disable - Disable the regulator during system suspend + * @rdev: regulator to mark as disabled * - * BUCK 1, 6, 2-4, 5, 7-10 (all) - * - * The other mode (0x02) will make PWRREQ switch between normal - * and low power. + * All regulators expect LDO 1, 3, 20 and 21 support OFF by PWRREQ. + * Configure the regulator so the PMIC will turn it OFF during system suspend. */ -static int max77802_buck_set_suspend_disable(struct regulator_dev *rdev) +static int max77802_set_suspend_disable(struct regulator_dev *rdev) { - unsigned int val = MAX77802_OPMODE_STANDBY; + unsigned int val = MAX77802_OFF_PWRREQ; struct max77802_regulator_prv *max77802 = rdev_get_drvdata(rdev); int id = rdev_get_id(rdev); int shift = max77802_get_opmode_shift(id); @@ -178,6 +179,9 @@ static int max77802_enable(struct regulator_dev *rdev) int id = rdev_get_id(rdev); int shift = max77802_get_opmode_shift(id); + if (max77802->opmode[id] == MAX77802_OFF_PWRREQ) + max77802->opmode[id] = MAX77802_OPMODE_NORMAL; + return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, max77802->opmode[id] << shift); @@ -247,6 +251,8 @@ static struct regulator_ops max77802_ldo_ops_logic1 = { .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, + .set_suspend_enable = max77802_enable, + .set_suspend_disable = max77802_set_suspend_disable, .set_suspend_mode = max77802_ldo_set_suspend_mode_logic1, }; @@ -276,7 +282,8 @@ static struct regulator_ops max77802_buck_16_dvs_ops = { .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, .set_ramp_delay = max77802_set_ramp_delay_4bit, - .set_suspend_disable = max77802_buck_set_suspend_disable, + .set_suspend_enable = max77802_enable, + .set_suspend_disable = max77802_set_suspend_disable, }; /* BUCKs 2-4, 5, 7-10 */ @@ -290,7 +297,8 @@ static struct regulator_ops max77802_buck_dvs_ops = { .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, .set_ramp_delay = max77802_set_ramp_delay_2bit, - .set_suspend_disable = max77802_buck_set_suspend_disable, + .set_suspend_enable = max77802_enable, + .set_suspend_disable = max77802_set_suspend_disable, }; /* LDOs 3-7, 9-14, 18-26, 28, 29, 32-34 */ -- cgit v1.2.3 From b0615f1da543500f8442fa6e5adacb8c54b34c5f Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 15 Oct 2014 18:20:33 +0200 Subject: regulator: max77802: Split regulator operations for BUCKs Not all the max77802 BUCKs regulators have the same functionality, for example BUCKs 2-4 support the output to be configured as normal or Low Power Mode by the PWRREQ enable pin while the other BUCKs only support their output to be set ON or OFF by PWRREQ. As a preparation for adding a set_suspend_mode function handler for all the regulators that support Low Power Mode by PWRREQ, split the operations for BUCKs regulators. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index 26f6963108e3..8425c0d520a8 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -286,7 +286,22 @@ static struct regulator_ops max77802_buck_16_dvs_ops = { .set_suspend_disable = max77802_set_suspend_disable, }; -/* BUCKs 2-4, 5, 7-10 */ +/* BUCKs 2-4 */ +static struct regulator_ops max77802_buck_234_ops = { + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, + .is_enabled = regulator_is_enabled_regmap, + .enable = max77802_enable, + .disable = regulator_disable_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .set_voltage_time_sel = regulator_set_voltage_time_sel, + .set_ramp_delay = max77802_set_ramp_delay_2bit, + .set_suspend_enable = max77802_enable, + .set_suspend_disable = max77802_set_suspend_disable, +}; + +/* BUCKs 5, 7-10 */ static struct regulator_ops max77802_buck_dvs_ops = { .list_voltage = regulator_list_voltage_linear, .map_voltage = regulator_map_voltage_linear, @@ -360,7 +375,7 @@ static struct regulator_ops max77802_buck_dvs_ops = { .name = "BUCK"#num, \ .id = MAX77802_BUCK##num, \ .supply_name = "inb"#num, \ - .ops = &max77802_buck_dvs_ops, \ + .ops = &max77802_buck_234_ops, \ .type = REGULATOR_VOLTAGE, \ .owner = THIS_MODULE, \ .min_uV = 600000, \ -- cgit v1.2.3 From efbe519945746371f92f5c3796818bf3e24c80ad Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 16 Oct 2014 18:48:47 +0200 Subject: regulator: max77802: Add .{get,set}_mode callbacks Some max77802 LDOs (1, 3, 20 and 21) support to be configured in Low Power Mode during system normal operation. Add function handlers for the .get_mode and .set_mode operations to set the mode on these LDOs. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index 8425c0d520a8..6eabb954ec7c 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -70,6 +70,12 @@ struct max77802_regulator_prv { unsigned int opmode[MAX77802_REG_MAX]; }; +static inline int max77802_map_mode(int mode) +{ + return mode == MAX77802_OPMODE_NORMAL ? + REGULATOR_MODE_NORMAL : REGULATOR_MODE_STANDBY; +} + static int max77802_get_opmode_shift(int id) { if (id == MAX77802_BUCK1 || (id >= MAX77802_BUCK5 && @@ -104,6 +110,44 @@ static int max77802_set_suspend_disable(struct regulator_dev *rdev) rdev->desc->enable_mask, val << shift); } +/* + * Some LDOs support Low Power Mode while the system is running. + * + * LDOs 1, 3, 20, 21. + */ +static int max77802_set_mode(struct regulator_dev *rdev, unsigned int mode) +{ + struct max77802_regulator_prv *max77802 = rdev_get_drvdata(rdev); + int id = rdev_get_id(rdev); + unsigned int val; + int shift = max77802_get_opmode_shift(id); + + switch (mode) { + case REGULATOR_MODE_STANDBY: + val = MAX77802_OPMODE_LP; /* ON in Low Power Mode */ + break; + case REGULATOR_MODE_NORMAL: + val = MAX77802_OPMODE_NORMAL; /* ON in Normal Mode */ + break; + default: + dev_warn(&rdev->dev, "%s: regulator mode: 0x%x not supported\n", + rdev->desc->name, mode); + return -EINVAL; + } + + max77802->opmode[id] = val; + return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, + rdev->desc->enable_mask, val << shift); +} + +static unsigned max77802_get_mode(struct regulator_dev *rdev) +{ + struct max77802_regulator_prv *max77802 = rdev_get_drvdata(rdev); + int id = rdev_get_id(rdev); + + return max77802_map_mode(max77802->opmode[id]); +} + /* * Some LDOs supports LPM-ON/OFF/Normal-ON mode during suspend state * (Enable Control Logic1 by PWRREQ) @@ -268,6 +312,8 @@ static struct regulator_ops max77802_ldo_ops_logic2 = { .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, + .set_mode = max77802_set_mode, + .get_mode = max77802_get_mode, .set_suspend_mode = max77802_ldo_set_suspend_mode_logic2, }; -- cgit v1.2.3 From 2e0eaa1aa0084ff1ee1af7cf388358b868143816 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 16 Oct 2014 18:48:48 +0200 Subject: regulator: max77802: Add set suspend mode for BUCKs and simplify code The max77802 PMIC has a special enable pin (PWRREQ) that can be used by the Application Processor (AP) to power down and up voltage rails. The max77802 PMIC regulators have 3 different enable control logics. Some regulators support to be configured on different operational mode during normal operation while others only support to be put in a Low Power Mode while the system has entered in sleep mode. Some regulators don't even support that configuration. The logics are the following: Enable Control Logic1 by PWRREQ (BUCK 2-4, LDO2, LDO4-19, LDO22, LDO35) ------------------------------- 0: Output OFF 1: Output ON/OFF (Controlled by PWRREQ) PWRREQ = HIGH (1): Output ON in Normal Mode PWRREQ = LOW (0): Output OFF 2: Output On with Low Power Mode (Controlled by PWRREQ) PWRREQ = HIGH (1) : Output ON in Normal Mode PWRREQ = LOW (0): Output ON in Low Power Mode 3: Output ON in Normal Mode Enable Control Logic2 by PWRREQ (LDO1, LDO20, LDO21) ------------------------------- 0: Output ON/OFF by ENx 1: Output ON in Low Power Mode 2: Output ON in Low Power Mode (Controlled by PWRREQ) PWRREQ = HIGH (1): Output ON in Normal Mode PWRREQ = LOW (0): Output ON in Low Power Mode 3: Output ON in Normal Mode Enable Control Logic3 by PWRREQ (LDO3) ------------------------------- 0 or 3: Output ON in Normal Mode 1: Output ON in Low Power Mode 2: Output ON in Low Power Mode (Controlled by PWRREQ) PWRREQ = HIGH (1): Output ON in Normal Mode PWRREQ = LOW (0): Output ON in Low Power Mode The driver only implemented .set_suspend_mode for the LDOs regulators but some BUCKs also support to be put in Low Power Mode on system wide suspend so they should be supported as well. Two different functions were used for the logic 1 and 2 but this is not necessary. Only normal and Low Power Mode are valid operational modes, OFF is not an mode but is a regulator state that is handled by .set_suspend_enable ad .set_suspend_disable. So the same .set_suspend_mode function can be used by all the regulators that support Output On with Low Power Mode by PWRREQ, making much simpler the code to set the suspend mode. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 93 ++++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 47 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index 6eabb954ec7c..dae2c1acd879 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -50,6 +50,7 @@ #define MAX77802_RAMP_RATE_SHIFT_4BIT 4 #define MAX77802_OFF_PWRREQ 0x1 +#define MAX77802_LP_PWRREQ 0x2 /* MAX77802 has two register formats: 2-bit and 4-bit */ static const unsigned int ramp_table_77802_2bit[] = { @@ -148,71 +149,68 @@ static unsigned max77802_get_mode(struct regulator_dev *rdev) return max77802_map_mode(max77802->opmode[id]); } -/* - * Some LDOs supports LPM-ON/OFF/Normal-ON mode during suspend state - * (Enable Control Logic1 by PWRREQ) +/** + * max77802_set_suspend_mode - set regulator opmode when the system is suspended + * @rdev: regulator to change mode + * @mode: operating mode to be set + * + * Will set the operating mode for the regulators during system suspend. + * This function is valid for the three different enable control logics: * - * LDOs 2, 4-19, 22-35. + * Enable Control Logic1 by PWRREQ (BUCK 2-4 and LDOs 2, 4-19, 22-35) + * Enable Control Logic2 by PWRREQ (LDOs 1, 20, 21) + * Enable Control Logic3 by PWRREQ (LDO 3) * + * If setting the regulator mode fails, the function only warns but does + * not return an error code to avoid the regulator core to stop setting + * the operating mode for the remaining regulators. */ -static int max77802_ldo_set_suspend_mode_logic1(struct regulator_dev *rdev, - unsigned int mode) +static int max77802_set_suspend_mode(struct regulator_dev *rdev, + unsigned int mode) { struct max77802_regulator_prv *max77802 = rdev_get_drvdata(rdev); int id = rdev_get_id(rdev); unsigned int val; int shift = max77802_get_opmode_shift(id); - switch (mode) { - case REGULATOR_MODE_IDLE: /* ON in LP Mode */ - val = MAX77802_OPMODE_LP; - break; - case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */ - val = MAX77802_OPMODE_NORMAL; - break; - case REGULATOR_MODE_STANDBY: /* ON/OFF by PWRREQ */ - val = MAX77802_OPMODE_STANDBY; - break; - default: - dev_warn(&rdev->dev, "%s: regulator mode: 0x%x not supported\n", + /* + * If the regulator has been disabled for suspend + * then is invalid to try setting a suspend mode. + */ + if (!max77802->opmode[id] == MAX77802_OFF_PWRREQ) { + dev_warn(&rdev->dev, "%s: is disabled, mode: 0x%x not set\n", rdev->desc->name, mode); - return -EINVAL; + return 0; } - max77802->opmode[id] = val; - return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, - rdev->desc->enable_mask, val << shift); -} - -/* - * Mode 1 (Output[ON/OFF] by PWRREQ) is not supported on some LDOs - * (Enable Control Logic2 by PWRREQ) - * - * LDOs 1, 20, 21, and 3, - * - */ -static int max77802_ldo_set_suspend_mode_logic2(struct regulator_dev *rdev, - unsigned int mode) -{ - struct max77802_regulator_prv *max77802 = rdev_get_drvdata(rdev); - int id = rdev_get_id(rdev); - unsigned int val; - int shift = max77802_get_opmode_shift(id); - switch (mode) { - case REGULATOR_MODE_IDLE: /* ON in LP Mode */ - val = MAX77802_OPMODE_LP; - break; - case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */ - val = MAX77802_OPMODE_NORMAL; + case REGULATOR_MODE_STANDBY: + /* + * If the regulator opmode is normal then enable + * ON in Low Power Mode by PWRREQ. If the mode is + * already Low Power then no action is required. + */ + if (max77802->opmode[id] == MAX77802_OPMODE_NORMAL) + val = MAX77802_LP_PWRREQ; + else + return 0; break; + case REGULATOR_MODE_NORMAL: + /* + * If the regulator operating mode is Low Power then + * normal is not a valid opmode in suspend. If the + * mode is already normal then no action is required. + */ + if (max77802->opmode[id] == MAX77802_OPMODE_LP) + dev_warn(&rdev->dev, "%s: in Low Power: 0x%x invalid\n", + rdev->desc->name, mode); + return 0; default: dev_warn(&rdev->dev, "%s: regulator mode: 0x%x not supported\n", rdev->desc->name, mode); return -EINVAL; } - max77802->opmode[id] = val; return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, val << shift); } @@ -297,7 +295,7 @@ static struct regulator_ops max77802_ldo_ops_logic1 = { .set_voltage_time_sel = regulator_set_voltage_time_sel, .set_suspend_enable = max77802_enable, .set_suspend_disable = max77802_set_suspend_disable, - .set_suspend_mode = max77802_ldo_set_suspend_mode_logic1, + .set_suspend_mode = max77802_set_suspend_mode, }; /* @@ -314,7 +312,7 @@ static struct regulator_ops max77802_ldo_ops_logic2 = { .set_voltage_time_sel = regulator_set_voltage_time_sel, .set_mode = max77802_set_mode, .get_mode = max77802_get_mode, - .set_suspend_mode = max77802_ldo_set_suspend_mode_logic2, + .set_suspend_mode = max77802_set_suspend_mode, }; /* BUCKS 1, 6 */ @@ -345,6 +343,7 @@ static struct regulator_ops max77802_buck_234_ops = { .set_ramp_delay = max77802_set_ramp_delay_2bit, .set_suspend_enable = max77802_enable, .set_suspend_disable = max77802_set_suspend_disable, + .set_suspend_mode = max77802_set_suspend_mode, }; /* BUCKs 5, 7-10 */ -- cgit v1.2.3 From 0505be71490e49044314ca84dd443e0f3782ca5a Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 16 Oct 2014 18:48:49 +0200 Subject: regulator: max77802: Don't treat OFF as an operating mode The only operating modes that are supported by the regulators in the max77802 PMIC are Output ON (normal) and Output On in Low Power Mode. OFF was wrongly counted as an operating mode while is only a regulator status. Make clear in the code that OFF is not an operating mode. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index dae2c1acd879..3abf99dbf953 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -49,6 +49,7 @@ #define MAX77802_RAMP_RATE_MASK_4BIT 0xF0 #define MAX77802_RAMP_RATE_SHIFT_4BIT 4 +#define MAX77802_STATUS_OFF 0x0 #define MAX77802_OFF_PWRREQ 0x1 #define MAX77802_LP_PWRREQ 0x2 @@ -615,7 +616,7 @@ static int max77802_pmic_probe(struct platform_device *pdev) * the hardware reports OFF as the regulator operating mode. * Default to operating mode NORMAL in that case. */ - if (val == MAX77802_OPMODE_OFF) + if (val == MAX77802_STATUS_OFF) max77802->opmode[id] = MAX77802_OPMODE_NORMAL; else max77802->opmode[id] = val; -- cgit v1.2.3 From 5356e0da49e61e0de29a5f61996be66e97425217 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 16 Oct 2014 18:48:50 +0200 Subject: regulator: max77802: Add header for operating modes Add a header file for the max77802 constants that could be shared between the regulator driver and Device Tree source files. Also, remove standby and off opmodes since only normal and low power are valid operating modes. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 1 + include/dt-bindings/regulator/maxim,max77802.h | 18 ++++++++++++++++++ include/linux/mfd/max77686.h | 7 ------- 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 include/dt-bindings/regulator/maxim,max77802.h (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index 3abf99dbf953..5839c4509e1f 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -33,6 +33,7 @@ #include #include #include +#include /* Default ramp delay in case it is not manually set */ #define MAX77802_RAMP_DELAY 100000 /* uV/us */ diff --git a/include/dt-bindings/regulator/maxim,max77802.h b/include/dt-bindings/regulator/maxim,max77802.h new file mode 100644 index 000000000000..cf28631d7109 --- /dev/null +++ b/include/dt-bindings/regulator/maxim,max77802.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2014 Google, Inc + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Device Tree binding constants for the Maxim 77802 PMIC regulators + */ + +#ifndef _DT_BINDINGS_REGULATOR_MAXIM_MAX77802_H +#define _DT_BINDINGS_REGULATOR_MAXIM_MAX77802_H + +/* Regulator operating modes */ +#define MAX77802_OPMODE_LP 1 +#define MAX77802_OPMODE_NORMAL 3 + +#endif /* _DT_BINDINGS_REGULATOR_MAXIM_MAX77802_H */ diff --git a/include/linux/mfd/max77686.h b/include/linux/mfd/max77686.h index 7e6dc4b2b795..553f7d09258a 100644 --- a/include/linux/mfd/max77686.h +++ b/include/linux/mfd/max77686.h @@ -131,13 +131,6 @@ enum max77686_opmode { MAX77686_OPMODE_STANDBY, }; -enum max77802_opmode { - MAX77802_OPMODE_OFF, - MAX77802_OPMODE_STANDBY, - MAX77802_OPMODE_LP, - MAX77802_OPMODE_NORMAL, -}; - struct max77686_opmode_data { int id; int mode; -- cgit v1.2.3 From 251ce318df3c07dbb3e484378a136a29e2f9bec1 Mon Sep 17 00:00:00 2001 From: Chris Zhong Date: Fri, 10 Oct 2014 15:35:06 -0700 Subject: regulator: rk808: Add support setting suspend voltage support setting suspend voltage and disable regulator in suspend. Signed-off-by: Chris Zhong Reviewed-by: Doug Anderson Signed-off-by: Mark Brown --- drivers/regulator/rk808-regulator.c | 57 +++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c index e305416d7697..8d1dc48ed8a9 100644 --- a/drivers/regulator/rk808-regulator.c +++ b/drivers/regulator/rk808-regulator.c @@ -36,6 +36,12 @@ #define RK808_RAMP_RATE_6MV_PER_US (2 << RK808_RAMP_RATE_OFFSET) #define RK808_RAMP_RATE_10MV_PER_US (3 << RK808_RAMP_RATE_OFFSET) +/* Offset from XXX_ON_VSEL to XXX_SLP_VSEL */ +#define RK808_SLP_REG_OFFSET 1 + +/* Offset from XXX_EN_REG to SLEEP_SET_OFF_XXX */ +#define RK808_SLP_SET_OFF_REG_OFFSET 2 + static const int rk808_buck_config_regs[] = { RK808_BUCK1_CONFIG_REG, RK808_BUCK2_CONFIG_REG, @@ -91,6 +97,43 @@ static int rk808_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) RK808_RAMP_RATE_MASK, ramp_value); } +int rk808_set_suspend_voltage(struct regulator_dev *rdev, int uv) +{ + unsigned int reg; + int sel = regulator_map_voltage_linear_range(rdev, uv, uv); + + if (sel < 0) + return -EINVAL; + + reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET; + + return regmap_update_bits(rdev->regmap, reg, + rdev->desc->vsel_mask, + sel); +} + +int rk808_set_suspend_enable(struct regulator_dev *rdev) +{ + unsigned int reg; + + reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET; + + return regmap_update_bits(rdev->regmap, reg, + rdev->desc->enable_mask, + 0); +} + +int rk808_set_suspend_disable(struct regulator_dev *rdev) +{ + unsigned int reg; + + reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET; + + return regmap_update_bits(rdev->regmap, reg, + rdev->desc->enable_mask, + rdev->desc->enable_mask); +} + static struct regulator_ops rk808_buck1_2_ops = { .list_voltage = regulator_list_voltage_linear_range, .map_voltage = regulator_map_voltage_linear_range, @@ -100,6 +143,9 @@ static struct regulator_ops rk808_buck1_2_ops = { .disable = regulator_disable_regmap, .is_enabled = regulator_is_enabled_regmap, .set_ramp_delay = rk808_set_ramp_delay, + .set_suspend_voltage = rk808_set_suspend_voltage, + .set_suspend_enable = rk808_set_suspend_enable, + .set_suspend_disable = rk808_set_suspend_disable, }; static struct regulator_ops rk808_reg_ops = { @@ -110,12 +156,17 @@ static struct regulator_ops rk808_reg_ops = { .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, .is_enabled = regulator_is_enabled_regmap, + .set_suspend_voltage = rk808_set_suspend_voltage, + .set_suspend_enable = rk808_set_suspend_enable, + .set_suspend_disable = rk808_set_suspend_disable, }; static struct regulator_ops rk808_switch_ops = { - .enable = regulator_enable_regmap, - .disable = regulator_disable_regmap, - .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, + .set_suspend_enable = rk808_set_suspend_enable, + .set_suspend_disable = rk808_set_suspend_disable, }; static const struct regulator_desc rk808_reg[] = { -- cgit v1.2.3 From 9075cceaac1c8d8a4cf43bebfd342bd61442967e Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 8 Oct 2014 23:19:08 +0200 Subject: regulator: rn5t618: Convert to new style DT parsing Use the simplified DT parsing method to remove some duplicated code. Since this is a MFD subdevice and its device object doesn't have an associated DT node, the configuration instance used to register the regulators has been changed to point to the parent device. Signed-off-by: Beniamino Galvani Signed-off-by: Mark Brown --- drivers/regulator/rn5t618-regulator.c | 51 +++-------------------------------- 1 file changed, 4 insertions(+), 47 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/rn5t618-regulator.c b/drivers/regulator/rn5t618-regulator.c index e58d79aeb393..b85ceb8ff911 100644 --- a/drivers/regulator/rn5t618-regulator.c +++ b/drivers/regulator/rn5t618-regulator.c @@ -31,6 +31,8 @@ static struct regulator_ops rn5t618_reg_ops = { #define REG(rid, ereg, emask, vreg, vmask, min, max, step) \ [RN5T618_##rid] = { \ .name = #rid, \ + .of_match = of_match_ptr(#rid), \ + .regulators_node = of_match_ptr("regulators"), \ .id = RN5T618_##rid, \ .type = REGULATOR_VOLTAGE, \ .owner = THIS_MODULE, \ @@ -60,60 +62,15 @@ static struct regulator_desc rn5t618_regulators[] = { REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000), }; -static struct of_regulator_match rn5t618_matches[] = { - [RN5T618_DCDC1] = { .name = "DCDC1" }, - [RN5T618_DCDC2] = { .name = "DCDC2" }, - [RN5T618_DCDC3] = { .name = "DCDC3" }, - [RN5T618_LDO1] = { .name = "LDO1" }, - [RN5T618_LDO2] = { .name = "LDO2" }, - [RN5T618_LDO3] = { .name = "LDO3" }, - [RN5T618_LDO4] = { .name = "LDO4" }, - [RN5T618_LDO5] = { .name = "LDO5" }, - [RN5T618_LDORTC1] = { .name = "LDORTC1" }, - [RN5T618_LDORTC2] = { .name = "LDORTC2" }, -}; - -static int rn5t618_regulator_parse_dt(struct platform_device *pdev) -{ - struct device_node *np, *regulators; - int ret; - - np = of_node_get(pdev->dev.parent->of_node); - if (!np) - return 0; - - regulators = of_get_child_by_name(np, "regulators"); - if (!regulators) { - dev_err(&pdev->dev, "regulators node not found\n"); - return -EINVAL; - } - - ret = of_regulator_match(&pdev->dev, regulators, rn5t618_matches, - ARRAY_SIZE(rn5t618_matches)); - of_node_put(regulators); - if (ret < 0) { - dev_err(&pdev->dev, "error parsing regulator init data: %d\n", - ret); - } - - return 0; -} - static int rn5t618_regulator_probe(struct platform_device *pdev) { struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); struct regulator_config config = { }; struct regulator_dev *rdev; - int ret, i; - - ret = rn5t618_regulator_parse_dt(pdev); - if (ret) - return ret; + int i; for (i = 0; i < RN5T618_REG_NUM; i++) { - config.dev = &pdev->dev; - config.init_data = rn5t618_matches[i].init_data; - config.of_node = rn5t618_matches[i].of_node; + config.dev = pdev->dev.parent; config.regmap = rn5t618->regmap; rdev = devm_regulator_register(&pdev->dev, -- cgit v1.2.3 From 80e82ac2ddf0e3de6f38de863b6d90de38961ed8 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 16 Oct 2014 10:23:28 +0200 Subject: regulator: s2mps11: Don't zero allocated memory for external control The driver was allocating memory for storing GPIOs for external control with unnecessary GFP_ZERO flag. Then right after allocation it initialized memory to -EINVAL in loop. Skip the GFP_ZERO flag. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/s2mps11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index adab82d5279f..7f59e67252e7 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -845,7 +845,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) return -EINVAL; }; - s2mps11->ext_control_gpio = devm_kzalloc(&pdev->dev, + s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev, sizeof(*s2mps11->ext_control_gpio) * s2mps11->rdev_num, GFP_KERNEL); if (!s2mps11->ext_control_gpio) -- cgit v1.2.3 From 6cf0bf0dfba6e1dfea061db2eef48ea2cbff68da Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 8 Oct 2014 09:57:43 +0800 Subject: regulator: sky81452: Remove module version The module version is unlikely to be updated, use kernel version should be enough. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/sky81452-regulator.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/sky81452-regulator.c b/drivers/regulator/sky81452-regulator.c index 97aff0ccd65f..476b80a0abca 100644 --- a/drivers/regulator/sky81452-regulator.c +++ b/drivers/regulator/sky81452-regulator.c @@ -127,4 +127,3 @@ module_platform_driver(sky81452_reg_driver); MODULE_DESCRIPTION("Skyworks SKY81452 Regulator driver"); MODULE_AUTHOR("Gyungoh Yoo "); MODULE_LICENSE("GPL"); -MODULE_VERSION("1.0"); -- cgit v1.2.3 From 40e20d68bb3fb1ce2704c886d597918988d3321d Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 10 Oct 2014 20:35:33 +0900 Subject: regulator: of: Add support for parsing regulator_state for suspend state The regulation_constraints structure includes specific field to support suspend state for global PMIC SUSPEND/HIBERNATE mode. This patch add support for parsing regulator_state for suspend state. Signed-off-by: Chanwoo Choi Acked-by: Kyungmin Park Signed-off-by: Mark Brown --- drivers/regulator/of_regulator.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 7a51814abdc5..b375ffe40df1 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -19,12 +19,19 @@ #include "internal.h" +const char *const regulator_states[PM_SUSPEND_MAX + 1] = { + [PM_SUSPEND_MEM] = "regulator-state-mem", + [PM_SUSPEND_MAX] = "regulator-state-disk", +}; + static void of_get_regulation_constraints(struct device_node *np, struct regulator_init_data **init_data) { const __be32 *min_uV, *max_uV; struct regulation_constraints *constraints = &(*init_data)->constraints; - int ret; + struct regulator_state *suspend_state; + struct device_node *suspend_np; + int ret, i; u32 pval; constraints->name = of_get_property(np, "regulator-name", NULL); @@ -73,6 +80,36 @@ static void of_get_regulation_constraints(struct device_node *np, ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); if (!ret) constraints->enable_time = pval; + + for (i = 0; i < ARRAY_SIZE(regulator_states); i++) { + switch (i) { + case PM_SUSPEND_MEM: + suspend_state = &constraints->state_mem; + break; + case PM_SUSPEND_MAX: + suspend_state = &constraints->state_disk; + break; + case PM_SUSPEND_ON: + case PM_SUSPEND_FREEZE: + case PM_SUSPEND_STANDBY: + default: + continue; + }; + + suspend_np = of_get_child_by_name(np, regulator_states[i]); + if (!suspend_np || !suspend_state) + continue; + + if (of_property_read_bool(suspend_np, + "regulator-on-in-suspend")) + suspend_state->enabled = true; + else if (of_property_read_bool(suspend_np, + "regulator-off-in-suspend")) + suspend_state->disabled = true; + + suspend_state = NULL; + suspend_np = NULL; + } } /** -- cgit v1.2.3 From 2b17fa2825fe6b7bf0848b4343833d7612edbccb Mon Sep 17 00:00:00 2001 From: Romain Perier Date: Tue, 14 Oct 2014 06:31:10 +0000 Subject: regulator: act8865: Add support to turn off all outputs When the property "poweroff-source" is found in the devicetree, the function pm_power_off is defined. This function sends the rights bit fields to the global off control register. shutdown/poweroff commands are now supported for hardware components which use these PMU. Signed-off-by: Romain Perier Signed-off-by: Mark Brown --- drivers/regulator/act8865-regulator.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c index afd06f92dfdf..76301ed0f8d4 100644 --- a/drivers/regulator/act8865-regulator.c +++ b/drivers/regulator/act8865-regulator.c @@ -61,6 +61,8 @@ #define ACT8846_REG12_VSET 0xa0 #define ACT8846_REG12_CTRL 0xa1 #define ACT8846_REG13_CTRL 0xb1 +#define ACT8846_GLB_OFF_CTRL 0xc3 +#define ACT8846_OFF_SYSMASK 0x18 /* * ACT8865 Global Register Map. @@ -84,6 +86,7 @@ #define ACT8865_LDO3_CTRL 0x61 #define ACT8865_LDO4_VSET 0x64 #define ACT8865_LDO4_CTRL 0x65 +#define ACT8865_MSTROFF 0x20 /* * Field Definitions. @@ -98,6 +101,8 @@ struct act8865 { struct regmap *regmap; + int off_reg; + int off_mask; }; static const struct regmap_config act8865_regmap_config = { @@ -275,6 +280,16 @@ static struct regulator_init_data return NULL; } +static struct i2c_client *act8865_i2c_client; +static void act8865_power_off(void) +{ + struct act8865 *act8865; + + act8865 = i2c_get_clientdata(act8865_i2c_client); + regmap_write(act8865->regmap, act8865->off_reg, act8865->off_mask); + while (1); +} + static int act8865_pmic_probe(struct i2c_client *client, const struct i2c_device_id *i2c_id) { @@ -285,6 +300,7 @@ static int act8865_pmic_probe(struct i2c_client *client, int i, ret, num_regulators; struct act8865 *act8865; unsigned long type; + int off_reg, off_mask; pdata = dev_get_platdata(dev); @@ -304,10 +320,14 @@ static int act8865_pmic_probe(struct i2c_client *client, case ACT8846: regulators = act8846_regulators; num_regulators = ARRAY_SIZE(act8846_regulators); + off_reg = ACT8846_GLB_OFF_CTRL; + off_mask = ACT8846_OFF_SYSMASK; break; case ACT8865: regulators = act8865_regulators; num_regulators = ARRAY_SIZE(act8865_regulators); + off_reg = ACT8865_SYS_CTRL; + off_mask = ACT8865_MSTROFF; break; default: dev_err(dev, "invalid device id %lu\n", type); @@ -345,6 +365,17 @@ static int act8865_pmic_probe(struct i2c_client *client, return ret; } + if (of_system_has_poweroff_source(dev->of_node)) { + if (!pm_power_off) { + act8865_i2c_client = client; + act8865->off_reg = off_reg; + act8865->off_mask = off_mask; + pm_power_off = act8865_power_off; + } else { + dev_err(dev, "Failed to set poweroff capability, already defined\n"); + } + } + /* Finally register devices */ for (i = 0; i < num_regulators; i++) { const struct regulator_desc *desc = ®ulators[i]; -- cgit v1.2.3 From 4eafec83aa9ea8eb21bd5c1c980debc623eea164 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 20 Oct 2014 16:47:48 +0200 Subject: regulator: of: Decrement refcount for suspend state nodes of_get_regulation_constraints() calls of_get_child_by_name() to find the regulator-state-{mem,disk} child nodes for each regulator. This function increments the device node reference counter but this is not decremented once the function is done using the node. Fix that by calling of_node_put() after finishing using the device node. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/of_regulator.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index b375ffe40df1..f0d19fc9d5d5 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -107,6 +107,7 @@ static void of_get_regulation_constraints(struct device_node *np, "regulator-off-in-suspend")) suspend_state->disabled = true; + of_node_put(suspend_np); suspend_state = NULL; suspend_np = NULL; } -- cgit v1.2.3 From bf2753755fe0f6b77f73636a2fe3f39a84ab1ca8 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 27 Oct 2014 13:45:06 +0300 Subject: regulator: max77802: fix a test in max77802_set_suspend_mode() The original test triggers a static checker warning. Javier Martinez Canillas says that the "!" is a typo and should be removed. Fixes: 2e0eaa1aa008 ('regulator: max77802: Add set suspend mode for BUCKs and simplify code') Signed-off-by: Dan Carpenter Acked-by: Javier Martinez Canillas Tested-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index 5839c4509e1f..7718c8aa0d7c 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -179,7 +179,7 @@ static int max77802_set_suspend_mode(struct regulator_dev *rdev, * If the regulator has been disabled for suspend * then is invalid to try setting a suspend mode. */ - if (!max77802->opmode[id] == MAX77802_OFF_PWRREQ) { + if (max77802->opmode[id] == MAX77802_OFF_PWRREQ) { dev_warn(&rdev->dev, "%s: is disabled, mode: 0x%x not set\n", rdev->desc->name, mode); return 0; -- cgit v1.2.3 From e1326eff80bffc43ef766c0262d1ce9375c2f610 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 27 Oct 2014 16:44:11 +0100 Subject: regulator: dummy: Make regulator_desc array const The regulator_register() expects array of 'regulator_desc' to be const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/dummy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/dummy.c b/drivers/regulator/dummy.c index 2436db9e2ca3..7aef9e4c6fbf 100644 --- a/drivers/regulator/dummy.c +++ b/drivers/regulator/dummy.c @@ -33,7 +33,7 @@ static struct regulator_init_data dummy_initdata = { static struct regulator_ops dummy_ops; -static struct regulator_desc dummy_desc = { +static const struct regulator_desc dummy_desc = { .name = "regulator-dummy", .id = -1, .type = REGULATOR_VOLTAGE, -- cgit v1.2.3 From 2515b24c04ea5a1b770eee56ed1a946ab4350a42 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 27 Oct 2014 16:44:12 +0100 Subject: regulator: max77693: Make regulator_desc array const The regulator_register() expects array of 'regulator_desc' to be const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/max77693.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77693.c b/drivers/regulator/max77693.c index c67ff05fc1dd..177dd9d2ce67 100644 --- a/drivers/regulator/max77693.c +++ b/drivers/regulator/max77693.c @@ -139,7 +139,7 @@ static struct regulator_ops max77693_charger_ops = { .enable_mask = SAFEOUT_CTRL_ENSAFEOUT##_num##_MASK , \ } -static struct regulator_desc regulators[] = { +static const struct regulator_desc regulators[] = { regulator_desc_esafeout(1), regulator_desc_esafeout(2), { -- cgit v1.2.3 From 6c4159a57a6a4867130fea26fe3f757ce5aaadb8 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 27 Oct 2014 16:44:13 +0100 Subject: regulator: max77802: Make regulator_desc array const The regulator_register() expects array of 'regulator_desc' to be const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index 7718c8aa0d7c..0464afa1585d 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -472,7 +472,7 @@ static struct regulator_ops max77802_buck_dvs_ops = { .enable_mask = MAX77802_OPMODE_MASK, \ } -static struct regulator_desc regulators[] = { +static const struct regulator_desc regulators[] = { regulator_77802_desc_16_buck(1), regulator_77802_desc_234_buck(2), regulator_77802_desc_234_buck(3), -- cgit v1.2.3 From 4b8e43f255b0ae093bb776f7415619bcd9eb7858 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 27 Oct 2014 16:44:14 +0100 Subject: regulator: s2mpa01: Make regulator_desc array const The regulator_register() expects array of 'regulator_desc' to be const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/s2mpa01.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c index 4acefa6b462e..2263071414e2 100644 --- a/drivers/regulator/s2mpa01.c +++ b/drivers/regulator/s2mpa01.c @@ -298,7 +298,7 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask = S2MPA01_ENABLE_MASK \ } -static struct regulator_desc regulators[] = { +static const struct regulator_desc regulators[] = { regulator_desc_ldo(1, STEP_25_MV), regulator_desc_ldo(2, STEP_50_MV), regulator_desc_ldo(3, STEP_50_MV), -- cgit v1.2.3 From 73dbdf8ff583ff6693536351973bd24f45ee8668 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 27 Oct 2014 16:03:42 +0100 Subject: regulator: max77686: Make regulator_desc array const The regulator_register() expects array of 'regulator_desc' to be const. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77686.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index ef1af2debbd2..0d103ba1d462 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -350,7 +350,7 @@ static struct regulator_ops max77686_buck_dvs_ops = { << MAX77686_OPMODE_BUCK234_SHIFT, \ } -static struct regulator_desc regulators[] = { +static const struct regulator_desc regulators[] = { regulator_desc_ldo1_low(1), regulator_desc_ldo_low(2), regulator_desc_ldo(3), -- cgit v1.2.3 From 7636f19c26a9c4174a139ded0d5216ea5d40b830 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 27 Oct 2014 13:11:47 +0100 Subject: regulator: max77686: Replace hard-coded opmode values with defines Add defines for regulator operating modes which should be more readable, especially if one does not have Maxim 77686 datasheet. The patch does not introduce any functional change. Signed-off-by: Krzysztof Kozlowski Suggested-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77686.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index 0d103ba1d462..db01c09e98f5 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -45,6 +45,23 @@ #define MAX77686_DVS_MINUV 600000 #define MAX77686_DVS_UVSTEP 12500 +/* + * Values used for configuring LDOs and bucks. + * Forcing low power mode: LDO1, 3-5, 9, 13, 17-26 + */ +#define MAX77686_LDO_LOWPOWER 0x1 +/* + * On/off controlled by PWRREQ: + * - LDO2, 6-8, 10-12, 14-16 + * - buck[1234] + */ +#define MAX77686_OFF_PWRREQ 0x1 +/* Low power mode controlled by PWRREQ: All LDOs */ +#define MAX77686_LDO_LOWPOWER_PWRREQ 0x2 +/* Forcing low power mode: buck[234] */ +#define MAX77686_BUCK_LOWPOWER 0x2 +#define MAX77686_NORMAL 0x3 + #define MAX77686_OPMODE_SHIFT 6 #define MAX77686_OPMODE_BUCK234_SHIFT 4 #define MAX77686_OPMODE_MASK 0x3 @@ -76,9 +93,9 @@ static int max77686_buck_set_suspend_disable(struct regulator_dev *rdev) int ret, id = rdev_get_id(rdev); if (id == MAX77686_BUCK1) - val = 0x1; + val = MAX77686_OFF_PWRREQ; else - val = 0x1 << MAX77686_OPMODE_BUCK234_SHIFT; + val = MAX77686_OFF_PWRREQ << MAX77686_OPMODE_BUCK234_SHIFT; ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, val); @@ -103,10 +120,10 @@ static int max77686_set_suspend_mode(struct regulator_dev *rdev, switch (mode) { case REGULATOR_MODE_IDLE: /* ON in LP Mode */ - val = 0x2 << MAX77686_OPMODE_SHIFT; + val = MAX77686_LDO_LOWPOWER_PWRREQ << MAX77686_OPMODE_SHIFT; break; case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */ - val = 0x3 << MAX77686_OPMODE_SHIFT; + val = MAX77686_NORMAL << MAX77686_OPMODE_SHIFT; break; default: pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n", @@ -133,13 +150,13 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev, switch (mode) { case REGULATOR_MODE_STANDBY: /* switch off */ - val = 0x1 << MAX77686_OPMODE_SHIFT; + val = MAX77686_OFF_PWRREQ << MAX77686_OPMODE_SHIFT; break; case REGULATOR_MODE_IDLE: /* ON in LP Mode */ - val = 0x2 << MAX77686_OPMODE_SHIFT; + val = MAX77686_LDO_LOWPOWER_PWRREQ << MAX77686_OPMODE_SHIFT; break; case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */ - val = 0x3 << MAX77686_OPMODE_SHIFT; + val = MAX77686_NORMAL << MAX77686_OPMODE_SHIFT; break; default: pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n", -- cgit v1.2.3 From 68c5d1868bfed0643eb4d2c608cead41f6bf4132 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 27 Oct 2014 13:11:48 +0100 Subject: regulator: max77686: Store opmode non-shifted Introduce simple helper for calculating the shift for OPMODE field in registers. This allows storing the current value of opmode in non-shifted form and simplifies a little set_suspend_disable and enable functions. Additionally this will allow adding support LDOs to the existing set_suspend_disable function. Signed-off-by: Krzysztof Kozlowski Suggested-by: Javier Martinez Canillas Reviewed-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77686.c | 49 ++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index db01c09e98f5..0c1541754e8c 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -85,20 +85,32 @@ struct max77686_data { unsigned int opmode[MAX77686_REGULATORS]; }; +static unsigned int max77686_get_opmode_shift(int id) +{ + switch (id) { + case MAX77686_BUCK1: + case MAX77686_BUCK5 ... MAX77686_BUCK9: + return 0; + case MAX77686_BUCK2 ... MAX77686_BUCK4: + return MAX77686_OPMODE_BUCK234_SHIFT; + default: + /* all LDOs */ + return MAX77686_OPMODE_SHIFT; + } +} + /* Some BUCKS supports Normal[ON/OFF] mode during suspend */ static int max77686_buck_set_suspend_disable(struct regulator_dev *rdev) { - unsigned int val; + unsigned int val, shift; struct max77686_data *max77686 = rdev_get_drvdata(rdev); int ret, id = rdev_get_id(rdev); - if (id == MAX77686_BUCK1) - val = MAX77686_OFF_PWRREQ; - else - val = MAX77686_OFF_PWRREQ << MAX77686_OPMODE_BUCK234_SHIFT; + shift = max77686_get_opmode_shift(id); + val = MAX77686_OFF_PWRREQ; ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, - rdev->desc->enable_mask, val); + rdev->desc->enable_mask, val << shift); if (ret) return ret; @@ -120,10 +132,10 @@ static int max77686_set_suspend_mode(struct regulator_dev *rdev, switch (mode) { case REGULATOR_MODE_IDLE: /* ON in LP Mode */ - val = MAX77686_LDO_LOWPOWER_PWRREQ << MAX77686_OPMODE_SHIFT; + val = MAX77686_LDO_LOWPOWER_PWRREQ; break; case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */ - val = MAX77686_NORMAL << MAX77686_OPMODE_SHIFT; + val = MAX77686_NORMAL; break; default: pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n", @@ -132,7 +144,8 @@ static int max77686_set_suspend_mode(struct regulator_dev *rdev, } ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, - rdev->desc->enable_mask, val); + rdev->desc->enable_mask, + val << MAX77686_OPMODE_SHIFT); if (ret) return ret; @@ -150,13 +163,13 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev, switch (mode) { case REGULATOR_MODE_STANDBY: /* switch off */ - val = MAX77686_OFF_PWRREQ << MAX77686_OPMODE_SHIFT; + val = MAX77686_OFF_PWRREQ; break; case REGULATOR_MODE_IDLE: /* ON in LP Mode */ - val = MAX77686_LDO_LOWPOWER_PWRREQ << MAX77686_OPMODE_SHIFT; + val = MAX77686_LDO_LOWPOWER_PWRREQ; break; case REGULATOR_MODE_NORMAL: /* ON in Normal Mode */ - val = MAX77686_NORMAL << MAX77686_OPMODE_SHIFT; + val = MAX77686_NORMAL; break; default: pr_warn("%s: regulator_suspend_mode : 0x%x not supported\n", @@ -165,7 +178,8 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev, } ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, - rdev->desc->enable_mask, val); + rdev->desc->enable_mask, + val << MAX77686_OPMODE_SHIFT); if (ret) return ret; @@ -176,10 +190,14 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev, static int max77686_enable(struct regulator_dev *rdev) { struct max77686_data *max77686 = rdev_get_drvdata(rdev); + unsigned int shift; + int id = rdev_get_id(rdev); + + shift = max77686_get_opmode_shift(id); return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, - max77686->opmode[rdev_get_id(rdev)]); + max77686->opmode[id] << shift); } static int max77686_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) @@ -495,7 +513,8 @@ static int max77686_pmic_probe(struct platform_device *pdev) config.init_data = pdata->regulators[i].initdata; config.of_node = pdata->regulators[i].of_node; - max77686->opmode[i] = regulators[i].enable_mask; + max77686->opmode[i] = regulators[i].enable_mask >> + max77686_get_opmode_shift(i); rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(rdev)) { -- cgit v1.2.3 From a1dd913f4e045927b1e758beadfdc6a180222d96 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Wed, 29 Oct 2014 12:14:53 +0100 Subject: regulator: max77802: Remove suspend_enable The Maxim 77802 PMIC regulators do not have special enable configuration for suspend. The driver instead enabled them manually which is not a best way to deal with suspend. Signed-off-by: Krzysztof Kozlowski Acked-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index 0464afa1585d..a0d146278b76 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -295,7 +295,6 @@ static struct regulator_ops max77802_ldo_ops_logic1 = { .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, - .set_suspend_enable = max77802_enable, .set_suspend_disable = max77802_set_suspend_disable, .set_suspend_mode = max77802_set_suspend_mode, }; @@ -328,7 +327,6 @@ static struct regulator_ops max77802_buck_16_dvs_ops = { .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, .set_ramp_delay = max77802_set_ramp_delay_4bit, - .set_suspend_enable = max77802_enable, .set_suspend_disable = max77802_set_suspend_disable, }; @@ -343,7 +341,6 @@ static struct regulator_ops max77802_buck_234_ops = { .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, .set_ramp_delay = max77802_set_ramp_delay_2bit, - .set_suspend_enable = max77802_enable, .set_suspend_disable = max77802_set_suspend_disable, .set_suspend_mode = max77802_set_suspend_mode, }; @@ -359,7 +356,6 @@ static struct regulator_ops max77802_buck_dvs_ops = { .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, .set_ramp_delay = max77802_set_ramp_delay_2bit, - .set_suspend_enable = max77802_enable, .set_suspend_disable = max77802_set_suspend_disable, }; -- cgit v1.2.3 From 78ce612860ce80edbec9171b4a786ce131a9631c Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Wed, 29 Oct 2014 12:14:52 +0100 Subject: regulator: max77686: Add suspend disable for some LDOs Some LDOs of Maxim 77686 PMIC support disabling during system suspend (LDO{2,6,7,8,10,11,12,14,15,16}). This was already implemented as part of set_suspend_mode function. In that case the mode was one of: - disable, - normal mode, - low power mode. However there are no bindings for setting the mode during suspend. Add suspend disable for LDO regulators supporting this. Re-use existing max77686_buck_set_suspend_disable() function. This helps reducing energy consumption during system sleep. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77686.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index 0c1541754e8c..09b0d8c20a9d 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -99,8 +99,8 @@ static unsigned int max77686_get_opmode_shift(int id) } } -/* Some BUCKS supports Normal[ON/OFF] mode during suspend */ -static int max77686_buck_set_suspend_disable(struct regulator_dev *rdev) +/* Some BUCKs and LDOs supports Normal[ON/OFF] mode during suspend */ +static int max77686_set_suspend_disable(struct regulator_dev *rdev) { unsigned int val, shift; struct max77686_data *max77686 = rdev_get_drvdata(rdev); @@ -195,6 +195,9 @@ static int max77686_enable(struct regulator_dev *rdev) shift = max77686_get_opmode_shift(id); + if (max77686->opmode[id] == MAX77686_OFF_PWRREQ) + max77686->opmode[id] = MAX77686_NORMAL; + return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, max77686->opmode[id] << shift); @@ -247,6 +250,7 @@ static struct regulator_ops max77686_ldo_ops = { .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, .set_suspend_mode = max77686_ldo_set_suspend_mode, + .set_suspend_disable = max77686_set_suspend_disable, }; static struct regulator_ops max77686_buck1_ops = { @@ -258,7 +262,7 @@ static struct regulator_ops max77686_buck1_ops = { .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, - .set_suspend_disable = max77686_buck_set_suspend_disable, + .set_suspend_disable = max77686_set_suspend_disable, }; static struct regulator_ops max77686_buck_dvs_ops = { @@ -271,7 +275,7 @@ static struct regulator_ops max77686_buck_dvs_ops = { .set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, .set_ramp_delay = max77686_set_ramp_delay, - .set_suspend_disable = max77686_buck_set_suspend_disable, + .set_suspend_disable = max77686_set_suspend_disable, }; #define regulator_desc_ldo(num) { \ -- cgit v1.2.3 From f32fa89ca9b2e1048d925af48bb0b1b3275d39d6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 31 Oct 2014 17:04:14 +0100 Subject: regulator: Staticize 'regulator_states' array The 'regulator_states' array is used only in this unit and it is not exported. Make it static. This also fixes following sparse warning: drivers/regulator/of_regulator.c:22:12: warning: symbol 'regulator_states' was not declared. Should it be static? Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/of_regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index f0d19fc9d5d5..36a1f5cc14e9 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -19,7 +19,7 @@ #include "internal.h" -const char *const regulator_states[PM_SUSPEND_MAX + 1] = { +static const char *const regulator_states[PM_SUSPEND_MAX + 1] = { [PM_SUSPEND_MEM] = "regulator-state-mem", [PM_SUSPEND_MAX] = "regulator-state-disk", }; -- cgit v1.2.3 From 194dbaefa0da24bb60d9df1c99dda807f51fc33f Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 31 Oct 2014 19:11:59 +0000 Subject: regulator: Lower priority of constraint logging Some systems have very large numbers of regulators so the constraint logging done at startup can end up being a very big part of the boot output which is both verbose and slows things down if the console is a serial console. Lower to dev_dbg() instead, we may want to provide a boot parameter to raise this in future but for now people can edit the source. Signed-off-by: Mark Brown Reviewed-by: Guenter Roeck --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index cd87c0c37034..df2af3a11351 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -828,7 +828,7 @@ static void print_constraints(struct regulator_dev *rdev) if (!count) sprintf(buf, "no parameters"); - rdev_info(rdev, "%s\n", buf); + rdev_dbg(rdev, "%s\n", buf); if ((constraints->min_uV != constraints->max_uV) && !(constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) -- cgit v1.2.3 From 8cbcaea89cfc4603c954f50aaddc3172446961d1 Mon Sep 17 00:00:00 2001 From: Doug Anderson Date: Fri, 31 Oct 2014 20:52:58 -0700 Subject: regulator: of: Add support for parsing microvolts for suspend state Leverage all the work that was done in (40e20d6 regulator: of: Add support for parsing regulator_state for suspend state) and throw in the ability to set suspend microvolts from the device tree. Signed-off-by: Doug Anderson Reviewed-by: Javier Martinez Canillas Reviewed-by: Chris Zhong Signed-off-by: Mark Brown --- drivers/regulator/of_regulator.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 36a1f5cc14e9..50be70878d2d 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -107,6 +107,10 @@ static void of_get_regulation_constraints(struct device_node *np, "regulator-off-in-suspend")) suspend_state->disabled = true; + if (!of_property_read_u32(suspend_np, + "regulator-suspend-microvolt", &pval)) + suspend_state->uV = pval; + of_node_put(suspend_np); suspend_state = NULL; suspend_np = NULL; -- cgit v1.2.3 From 4d7078e69417852283937872e210adcc633be66f Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 Nov 2014 15:40:47 +0100 Subject: regulator: max77802: Use unsigned int for modes in max77802_map_mode() All function dealing with operating modes use unsigned int for modes so change max77802_map_mode() function signature for consistency. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index a0d146278b76..f8f06ece2f3c 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -73,7 +73,7 @@ struct max77802_regulator_prv { unsigned int opmode[MAX77802_REG_MAX]; }; -static inline int max77802_map_mode(int mode) +static inline unsigned int max77802_map_mode(unsigned int mode) { return mode == MAX77802_OPMODE_NORMAL ? REGULATOR_MODE_NORMAL : REGULATOR_MODE_STANDBY; -- cgit v1.2.3 From eca29da9a2e832936c9077b8e69adb4f4b22b0d5 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Tue, 4 Nov 2014 09:49:41 +0100 Subject: regulator: max77686: Consistently index opmode array by rdev id Mixed indexes were used for array of opmodes in max77686_data structure: id of regulator and index of regulator_desc array. These indexes are exactly the same but the mixture may confuse. Use consistently the id of regulator. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/max77686.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index 09b0d8c20a9d..27c5f4556044 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -82,6 +82,7 @@ enum max77686_ramp_rate { }; struct max77686_data { + /* Array indexed by regulator id */ unsigned int opmode[MAX77686_REGULATORS]; }; @@ -513,12 +514,13 @@ static int max77686_pmic_probe(struct platform_device *pdev) for (i = 0; i < MAX77686_REGULATORS; i++) { struct regulator_dev *rdev; + int id = regulators[i].id; config.init_data = pdata->regulators[i].initdata; config.of_node = pdata->regulators[i].of_node; - max77686->opmode[i] = regulators[i].enable_mask >> - max77686_get_opmode_shift(i); + max77686->opmode[id] = regulators[i].enable_mask >> + max77686_get_opmode_shift(id); rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(rdev)) { -- cgit v1.2.3 From 4524df83c7fc4f44702099a2db7b3cc938eb111f Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Tue, 4 Nov 2014 09:49:42 +0100 Subject: regulator: max77686: Initialize opmode explicitly to normal mode Minor nit: Initialize the opmode for each regulator to normal mode in a readable explicit way. Signed-off-by: Krzysztof Kozlowski Suggested-by: Javier Martinez Canillas Reviewed-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77686.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index 27c5f4556044..28f4eab82a09 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -519,8 +519,7 @@ static int max77686_pmic_probe(struct platform_device *pdev) config.init_data = pdata->regulators[i].initdata; config.of_node = pdata->regulators[i].of_node; - max77686->opmode[id] = regulators[i].enable_mask >> - max77686_get_opmode_shift(id); + max77686->opmode[id] = MAX77686_NORMAL; rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(rdev)) { -- cgit v1.2.3 From a26ed45c912d46cedac5f15c2872aa7e462fcdf1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Tue, 4 Nov 2014 09:49:43 +0100 Subject: regulator: max77802: Don't ignore return value of current opmode The return value of regmap_read() of current opmode for regulator was silently ignored and whatever happened to be in 'val' variable was used as new opmode. This could lead to using bogus opmode. Don't ignore what regmap_read() returns. If it fails just fall back to normal opmode. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index f8f06ece2f3c..d076df1d2166 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -606,7 +606,13 @@ static int max77802_pmic_probe(struct platform_device *pdev) config.of_node = pdata->regulators[i].of_node; ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val); - val = val >> shift & MAX77802_OPMODE_MASK; + if (ret < 0) { + dev_warn(&pdev->dev, + "cannot read current mode for %d\n", i); + val = MAX77802_OPMODE_NORMAL; + } else { + val = val >> shift & MAX77802_OPMODE_MASK; + } /* * If the regulator is disabled and the system warm rebooted, -- cgit v1.2.3 From 1de3821ace8200432993821bfda043827029de2a Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Mon, 3 Nov 2014 19:12:04 +0100 Subject: regulator: Set ena_gpio_initialized in regulator drivers This patch sets ena_gpio_initialized for all drivers which set a ena_gpio from parsed DT properties. Drivers using pdata may get zero initialized pdata and therefore copy a 0 into the regulator_config ena_gpio field. Signed-off-by: Markus Pargmann Signed-off-by: Mark Brown --- drivers/regulator/arizona-ldo1.c | 2 ++ drivers/regulator/fixed.c | 5 ++++- drivers/regulator/gpio-regulator.c | 4 +++- drivers/regulator/max8952.c | 2 ++ drivers/regulator/s2mps11.c | 1 + drivers/regulator/s5m8767.c | 1 + drivers/regulator/tps65090-regulator.c | 1 + drivers/regulator/wm8994-regulator.c | 6 ++++-- 8 files changed, 18 insertions(+), 4 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c index 4c9db589f6c1..559e7ea9dcf3 100644 --- a/drivers/regulator/arizona-ldo1.c +++ b/drivers/regulator/arizona-ldo1.c @@ -260,6 +260,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev) ret = arizona_ldo1_of_get_pdata(arizona, &config); if (ret < 0) return ret; + + config.ena_gpio_initialized = true; } } diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 354105eff1f8..17f6a7d331f8 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -157,8 +157,11 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) drvdata->desc.fixed_uV = config->microvolts; - if (config->gpio >= 0) + if (config->gpio >= 0) { cfg.ena_gpio = config->gpio; + if (pdev->dev.of_node) + cfg.ena_gpio_initialized = true; + } cfg.ena_gpio_invert = !config->enable_high; if (config->enabled_at_boot) { if (config->enable_high) diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 989b23b377c0..5da0125fac6a 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -322,8 +322,10 @@ static int gpio_regulator_probe(struct platform_device *pdev) cfg.driver_data = drvdata; cfg.of_node = np; - if (config->enable_gpio >= 0) + if (config->enable_gpio >= 0) { cfg.ena_gpio = config->enable_gpio; + cfg.ena_gpio_initialized = true; + } cfg.ena_gpio_invert = !config->enable_high; if (config->enabled_at_boot) { if (config->enable_high) diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c index f7f9efcfedb7..dec57fb9cd1c 100644 --- a/drivers/regulator/max8952.c +++ b/drivers/regulator/max8952.c @@ -225,6 +225,8 @@ static int max8952_pmic_probe(struct i2c_client *client, config.of_node = client->dev.of_node; config.ena_gpio = pdata->gpio_en; + if (client->dev.of_node) + config.ena_gpio_initialized = true; if (pdata->reg_data->constraints.boot_on) config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index adab82d5279f..b4ae022091eb 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -886,6 +886,7 @@ common_reg: config.regmap = iodev->regmap_pmic; config.driver_data = s2mps11; config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; + config.ena_gpio_initialized = true; for (i = 0; i < s2mps11->rdev_num; i++) { struct regulator_dev *regulator; diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 0ab5cbeeb797..4225df68dd4d 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -950,6 +950,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) config.of_node = pdata->regulators[i].reg_node; config.ena_gpio = -EINVAL; config.ena_gpio_flags = 0; + config.ena_gpio_initialized = true; if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) s5m8767_regulator_config_ext_control(s5m8767, &pdata->regulators[i], &config); diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index d5df1e9ad1da..2e92aa8718cc 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c @@ -312,6 +312,7 @@ static void tps65090_configure_regulator_config( gpio_flag = GPIOF_OUT_INIT_HIGH; config->ena_gpio = tps_pdata->gpio; + config->ena_gpio_initialized = true; config->ena_gpio_flags = gpio_flag; } } diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index c24346db8a71..88f5064e412b 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c @@ -145,10 +145,12 @@ static int wm8994_ldo_probe(struct platform_device *pdev) config.driver_data = ldo; config.regmap = wm8994->regmap; config.init_data = &ldo->init_data; - if (pdata) + if (pdata) { config.ena_gpio = pdata->ldo[id].enable; - else if (wm8994->dev->of_node) + } else if (wm8994->dev->of_node) { config.ena_gpio = wm8994->pdata.ldo[id].enable; + config.ena_gpio_initialized = true; + } /* Use default constraints if none set up */ if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) { -- cgit v1.2.3 From 5315fe2f8defc012a5800423be3f6098f95527d7 Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Mon, 3 Nov 2014 19:12:05 +0100 Subject: regulator: fixed: Use gpio_is_valid Use gpio_is_valid instead of an explicit comparison with 0. Signed-off-by: Markus Pargmann Signed-off-by: Mark Brown --- drivers/regulator/fixed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 17f6a7d331f8..709fba19e596 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -157,7 +157,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) drvdata->desc.fixed_uV = config->microvolts; - if (config->gpio >= 0) { + if (gpio_is_valid(config->gpio)) { cfg.ena_gpio = config->gpio; if (pdev->dev.of_node) cfg.ena_gpio_initialized = true; -- cgit v1.2.3 From 2454f8d15cf75781a2714e99badbfbc2f5a7dacb Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Mon, 3 Nov 2014 19:12:06 +0100 Subject: regulator: gpio: Use gpio_is_valid Use gpio_is_valid instead of an explicit comparison with 0. Signed-off-by: Markus Pargmann Signed-off-by: Mark Brown --- drivers/regulator/gpio-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 5da0125fac6a..86546c1c32c4 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -322,7 +322,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) cfg.driver_data = drvdata; cfg.of_node = np; - if (config->enable_gpio >= 0) { + if (gpio_is_valid(config->enable_gpio)) { cfg.ena_gpio = config->enable_gpio; cfg.ena_gpio_initialized = true; } -- cgit v1.2.3 From 679c038f544e46803d4fce16636747c3e77af4f1 Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Mon, 3 Nov 2014 19:12:07 +0100 Subject: regulator: tps65090: Fix gpio initialization The config is used for multiple regulators within a for loop. The config field is not cleared before it is used for the next item. To avoid any issues this patch adds a proper initialization for the config->ena_gpio field in case no gpio is available. Signed-off-by: Markus Pargmann Signed-off-by: Mark Brown --- drivers/regulator/tps65090-regulator.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index 2e92aa8718cc..f1df4423d361 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c @@ -314,6 +314,9 @@ static void tps65090_configure_regulator_config( config->ena_gpio = tps_pdata->gpio; config->ena_gpio_initialized = true; config->ena_gpio_flags = gpio_flag; + } else { + config->ena_gpio = -EINVAL; + config->ena_gpio_initialized = false; } } -- cgit v1.2.3 From b1917578fd5d8efa67afa05a0d6d7e323f2802da Mon Sep 17 00:00:00 2001 From: Beomho Seo Date: Wed, 12 Nov 2014 21:07:59 +0900 Subject: regulator: rt5033: Add RT5033 Regulator device driver This patch add device driver of Richtek RT5033 PMIC. The driver support multiple regulator like LDO and synchronous Buck. The integrated synchronous buck converter is designed to provide 0.6 A application with high efficiency. Two LDOs are integrated. One safe LDO is for 60mA and the other one LDO is for 150 mA. Cc: Liam Girdwood Cc: Mark Brown Signed-off-by: Beomho Seo Acked-by: Chanwoo Choi Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 8 +++ drivers/regulator/Makefile | 1 + drivers/regulator/rt5033-regulator.c | 123 +++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 drivers/regulator/rt5033-regulator.c (limited to 'drivers/regulator') diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 55d7b7b0f2e0..8558e1b21f05 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -521,6 +521,14 @@ config REGULATOR_RN5T618 help Say y here to support the regulators found on Ricoh RN5T618 PMIC. +config REGULATOR_RT5033 + tristate "Richtek RT5033 Regulators" + depends on MFD_RT5033 + help + This adds support for voltage and current regulators in Richtek + RT5033 PMIC. The device supports multiple regulators like + current source, LDO and Buck. + config REGULATOR_S2MPA01 tristate "Samsung S2MPA01 voltage regulator" depends on MFD_SEC_CORE diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 1029ed39c512..1f28ebfc6f3a 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -69,6 +69,7 @@ obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o obj-$(CONFIG_REGULATOR_RK808) += rk808-regulator.o obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o +obj-$(CONFIG_REGULATOR_RT5033) += rt5033-regulator.o obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o diff --git a/drivers/regulator/rt5033-regulator.c b/drivers/regulator/rt5033-regulator.c new file mode 100644 index 000000000000..870cc49438db --- /dev/null +++ b/drivers/regulator/rt5033-regulator.c @@ -0,0 +1,123 @@ +/* + * Regulator driver for the Richtek RT5033 + * + * Copyright (C) 2014 Samsung Electronics, Co., Ltd. + * Author: Beomho Seo + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published bythe Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include + +static struct regulator_ops rt5033_safe_ldo_ops = { + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .list_voltage = regulator_list_voltage_linear, +}; + +static struct regulator_ops rt5033_buck_ops = { + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, +}; + +static const struct regulator_desc rt5033_supported_regulators[] = { + [RT5033_BUCK] = { + .name = "BUCK", + .id = RT5033_BUCK, + .ops = &rt5033_buck_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .n_voltages = RT5033_REGULATOR_BUCK_VOLTAGE_STEP_NUM, + .min_uV = RT5033_REGULATOR_BUCK_VOLTAGE_MIN, + .uV_step = RT5033_REGULATOR_BUCK_VOLTAGE_STEP, + .enable_reg = RT5033_REG_CTRL, + .enable_mask = RT5033_CTRL_EN_BUCK_MASK, + .vsel_reg = RT5033_REG_BUCK_CTRL, + .vsel_mask = RT5033_BUCK_CTRL_MASK, + }, + [RT5033_LDO] = { + .name = "LDO", + .id = RT5033_LDO, + .ops = &rt5033_buck_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .n_voltages = RT5033_REGULATOR_LDO_VOLTAGE_STEP_NUM, + .min_uV = RT5033_REGULATOR_LDO_VOLTAGE_MIN, + .uV_step = RT5033_REGULATOR_LDO_VOLTAGE_STEP, + .enable_reg = RT5033_REG_CTRL, + .enable_mask = RT5033_CTRL_EN_LDO_MASK, + .vsel_reg = RT5033_REG_LDO_CTRL, + .vsel_mask = RT5033_LDO_CTRL_MASK, + }, + [RT5033_SAFE_LDO] = { + .name = "SAFE_LDO", + .id = RT5033_SAFE_LDO, + .ops = &rt5033_safe_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .n_voltages = 1, + .min_uV = RT5033_REGULATOR_SAFE_LDO_VOLTAGE, + .enable_reg = RT5033_REG_CTRL, + .enable_mask = RT5033_CTRL_EN_SAFE_LDO_MASK, + }, +}; + +static int rt5033_regulator_probe(struct platform_device *pdev) +{ + struct rt5033_dev *rt5033 = dev_get_drvdata(pdev->dev.parent); + int ret, i; + struct regulator_config config = {}; + + config.dev = &pdev->dev; + config.driver_data = rt5033; + + for (i = 0; i < ARRAY_SIZE(rt5033_supported_regulators); i++) { + struct regulator_dev *regulator; + + config.regmap = rt5033->regmap; + + regulator = devm_regulator_register(&pdev->dev, + &rt5033_supported_regulators[i], &config); + if (IS_ERR(regulator)) { + ret = PTR_ERR(regulator); + dev_err(&pdev->dev, + "Regulator init failed %d: with error: %d\n", + i, ret); + return ret; + } + } + + return 0; +} + +static const struct platform_device_id rt5033_regulator_id[] = { + { "rt5033-regulator", }, + { } +}; +MODULE_DEVICE_TABLE(platform, rt5033_regulator_id); + +static struct platform_driver rt5033_regulator_driver = { + .driver = { + .name = "rt5033-regulator", + }, + .probe = rt5033_regulator_probe, + .id_table = rt5033_regulator_id, +}; +module_platform_driver(rt5033_regulator_driver); + +MODULE_DESCRIPTION("Richtek RT5033 Regulator driver"); +MODULE_AUTHOR("Beomho Seo "); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 70b5b27c4fbe1e8b6edc29082fcb2b79ef0838b8 Mon Sep 17 00:00:00 2001 From: Gyungoh Yoo Date: Mon, 17 Nov 2014 17:33:10 +0900 Subject: regulator: sky81452: Modify dependent Kconfig symbol Signed-off-by: Gyungoh Yoo Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 55d7b7b0f2e0..fe84bd461f86 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -547,7 +547,7 @@ config REGULATOR_S5M8767 config REGULATOR_SKY81452 tristate "Skyworks Solutions SKY81452 voltage regulator" - depends on SKY81452 + depends on MFD_SKY81452 help This driver supports Skyworks SKY81452 voltage output regulator via I2C bus. SKY81452 has one voltage linear regulator can be -- cgit v1.2.3 From 8ad365c94f45c63f2a65dd3814d1db27c388e20e Mon Sep 17 00:00:00 2001 From: Dmitry Lavnikevich Date: Fri, 21 Nov 2014 18:29:08 +0300 Subject: regulator: da9063: Do not transform local IRQ to virtual Call platform_get_irq_byname() already returns VIRQ instead of local IRQ. Passing this value to regmap_irq_get_virq() causes error which results in IRQ registration failure. This patch fixes such behaviour. Signed-off-by: Dmitry Lavnikevich Signed-off-by: Mark Brown --- drivers/regulator/da9063-regulator.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c index 7c9461d13313..37dd42759ca9 100644 --- a/drivers/regulator/da9063-regulator.c +++ b/drivers/regulator/da9063-regulator.c @@ -867,17 +867,14 @@ static int da9063_regulator_probe(struct platform_device *pdev) return irq; } - regulators->irq_ldo_lim = regmap_irq_get_virq(da9063->regmap_irq, irq); - if (regulators->irq_ldo_lim >= 0) { - ret = request_threaded_irq(regulators->irq_ldo_lim, - NULL, da9063_ldo_lim_event, - IRQF_TRIGGER_LOW | IRQF_ONESHOT, - "LDO_LIM", regulators); - if (ret) { - dev_err(&pdev->dev, - "Failed to request LDO_LIM IRQ.\n"); - regulators->irq_ldo_lim = -ENXIO; - } + ret = request_threaded_irq(irq, + NULL, da9063_ldo_lim_event, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, + "LDO_LIM", regulators); + if (ret) { + dev_err(&pdev->dev, + "Failed to request LDO_LIM IRQ.\n"); + regulators->irq_ldo_lim = -ENXIO; } return 0; -- cgit v1.2.3 From 0f5bb5b5de3b18877373f746bdb85d8ea0efeedf Mon Sep 17 00:00:00 2001 From: Josh Cartwright Date: Thu, 20 Nov 2014 13:41:25 -0600 Subject: regulator: rpm: add support for RPM-controller SMB208 The IPQ8064 reference boards make use of SMB208 regulators which are controlled by RPM. Implement support for these regulators in the RPM regulator driver. Signed-off-by: Josh Cartwright Acked-by: Bjorn Andersson Signed-off-by: Mark Brown --- drivers/regulator/qcom_rpm-regulator.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/qcom_rpm-regulator.c b/drivers/regulator/qcom_rpm-regulator.c index b55cd5b50ebe..fbcbd3fe501e 100644 --- a/drivers/regulator/qcom_rpm-regulator.c +++ b/drivers/regulator/qcom_rpm-regulator.c @@ -183,6 +183,13 @@ static const struct regulator_linear_range ftsmps_ranges[] = { REGULATOR_LINEAR_RANGE(1500000, 64, 100, 50000), }; +static const struct regulator_linear_range smb208_ranges[] = { + REGULATOR_LINEAR_RANGE( 375000, 0, 29, 12500), + REGULATOR_LINEAR_RANGE( 750000, 30, 89, 12500), + REGULATOR_LINEAR_RANGE(1500000, 90, 153, 25000), + REGULATOR_LINEAR_RANGE(3100000, 154, 234, 25000), +}; + static const struct regulator_linear_range ncp_ranges[] = { REGULATOR_LINEAR_RANGE(1500000, 0, 31, 50000), }; @@ -559,6 +566,16 @@ static const struct qcom_rpm_reg pm8921_switch = { .parts = &rpm8960_switch_parts, }; +static const struct qcom_rpm_reg smb208_smps = { + .desc.linear_ranges = smb208_ranges, + .desc.n_linear_ranges = ARRAY_SIZE(smb208_ranges), + .desc.n_voltages = 235, + .desc.ops = &uV_ops, + .parts = &rpm8960_smps_parts, + .supports_force_mode_auto = false, + .supports_force_mode_bypass = false, +}; + static const struct of_device_id rpm_of_match[] = { { .compatible = "qcom,rpm-pm8058-pldo", .data = &pm8058_pldo }, { .compatible = "qcom,rpm-pm8058-nldo", .data = &pm8058_nldo }, @@ -578,6 +595,8 @@ static const struct of_device_id rpm_of_match[] = { { .compatible = "qcom,rpm-pm8921-ftsmps", .data = &pm8921_ftsmps }, { .compatible = "qcom,rpm-pm8921-ncp", .data = &pm8921_ncp }, { .compatible = "qcom,rpm-pm8921-switch", .data = &pm8921_switch }, + + { .compatible = "qcom,rpm-smb208", .data = &smb208_smps }, { } }; MODULE_DEVICE_TABLE(of, rpm_of_match); -- cgit v1.2.3 From 9f946099fe1927aa746892232c4421e1ae175699 Mon Sep 17 00:00:00 2001 From: Richard Fitzgerald Date: Wed, 19 Nov 2014 14:13:06 +0000 Subject: regulator: gpio: fix parsing of gpio list The list of gpios is defined as optional but the code was failing to properly handle the case of no gpios, and also failing to check for errors reading the entry from the devicetree. This patch fixes the handling of optional gpios - this is a useful feature enabling the gpio-regulator to be used as a dummy variable voltage regulator without having to assign any real GPIO lines. Signed-off-by: Richard Fitzgerald Signed-off-by: Mark Brown --- drivers/regulator/gpio-regulator.c | 93 +++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 42 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 86546c1c32c4..b42c7ec0017f 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -162,34 +162,41 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0); - /* Fetch GPIOs. */ - config->nr_gpios = of_gpio_count(np); - - config->gpios = devm_kzalloc(dev, - sizeof(struct gpio) * config->nr_gpios, - GFP_KERNEL); - if (!config->gpios) - return ERR_PTR(-ENOMEM); - - proplen = of_property_count_u32_elems(np, "gpios-states"); - /* optional property */ - if (proplen < 0) - proplen = 0; - - if (proplen > 0 && proplen != config->nr_gpios) { - dev_warn(dev, "gpios <-> gpios-states mismatch\n"); - proplen = 0; - } + /* Fetch GPIOs. - optional property*/ + ret = of_gpio_count(np); + if ((ret < 0) && (ret != -ENOENT)) + return ERR_PTR(ret); + + if (ret > 0) { + config->nr_gpios = ret; + config->gpios = devm_kzalloc(dev, + sizeof(struct gpio) * config->nr_gpios, + GFP_KERNEL); + if (!config->gpios) + return ERR_PTR(-ENOMEM); + + proplen = of_property_count_u32_elems(np, "gpios-states"); + /* optional property */ + if (proplen < 0) + proplen = 0; + + if (proplen > 0 && proplen != config->nr_gpios) { + dev_warn(dev, "gpios <-> gpios-states mismatch\n"); + proplen = 0; + } - for (i = 0; i < config->nr_gpios; i++) { - gpio = of_get_named_gpio(np, "gpios", i); - if (gpio < 0) - break; - config->gpios[i].gpio = gpio; - if (proplen > 0) { - of_property_read_u32_index(np, "gpios-states", i, &ret); - if (ret) - config->gpios[i].flags = GPIOF_OUT_INIT_HIGH; + for (i = 0; i < config->nr_gpios; i++) { + gpio = of_get_named_gpio(np, "gpios", i); + if (gpio < 0) + break; + config->gpios[i].gpio = gpio; + if (proplen > 0) { + of_property_read_u32_index(np, "gpios-states", + i, &ret); + if (ret) + config->gpios[i].flags = + GPIOF_OUT_INIT_HIGH; + } } } @@ -261,13 +268,23 @@ static int gpio_regulator_probe(struct platform_device *pdev) goto err; } - drvdata->gpios = kmemdup(config->gpios, - config->nr_gpios * sizeof(struct gpio), - GFP_KERNEL); - if (drvdata->gpios == NULL) { - dev_err(&pdev->dev, "Failed to allocate gpio data\n"); - ret = -ENOMEM; - goto err_name; + if (config->nr_gpios != 0) { + drvdata->gpios = kmemdup(config->gpios, + config->nr_gpios * sizeof(struct gpio), + GFP_KERNEL); + if (drvdata->gpios == NULL) { + dev_err(&pdev->dev, "Failed to allocate gpio data\n"); + ret = -ENOMEM; + goto err_name; + } + + drvdata->nr_gpios = config->nr_gpios; + ret = gpio_request_array(drvdata->gpios, drvdata->nr_gpios); + if (ret) { + dev_err(&pdev->dev, + "Could not obtain regulator setting GPIOs: %d\n", ret); + goto err_memstate; + } } drvdata->states = kmemdup(config->states, @@ -301,14 +318,6 @@ static int gpio_regulator_probe(struct platform_device *pdev) goto err_memgpio; } - drvdata->nr_gpios = config->nr_gpios; - ret = gpio_request_array(drvdata->gpios, drvdata->nr_gpios); - if (ret) { - dev_err(&pdev->dev, - "Could not obtain regulator setting GPIOs: %d\n", ret); - goto err_memstate; - } - /* build initial state from gpio init data. */ state = 0; for (ptr = 0; ptr < drvdata->nr_gpios; ptr++) { -- cgit v1.2.3 From a1c8a5512b7cddc81767172f0de37b155cea039f Mon Sep 17 00:00:00 2001 From: Richard Fitzgerald Date: Mon, 24 Nov 2014 14:10:52 +0000 Subject: regulator: core: Add PRE_DISABLE notification Add a PRE_DISABLE notification so that consumers can use a notifier to run any steps required to prepare for the regulator being switched off. Since the regulator disable can fail an abort notification is also added. Signed-off-by: Richard Fitzgerald Signed-off-by: Mark Brown --- drivers/regulator/core.c | 16 ++++++++++++++++ include/linux/regulator/consumer.h | 4 ++++ 2 files changed, 20 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index cd87c0c37034..53de911a0954 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1976,9 +1976,18 @@ static int _regulator_disable(struct regulator_dev *rdev) /* we are last user */ if (_regulator_can_change_status(rdev)) { + ret = _notifier_call_chain(rdev, + REGULATOR_EVENT_PRE_DISABLE, + NULL); + if (ret & NOTIFY_STOP_MASK) + return -EINVAL; + ret = _regulator_do_disable(rdev); if (ret < 0) { rdev_err(rdev, "failed to disable\n"); + _notifier_call_chain(rdev, + REGULATOR_EVENT_ABORT_DISABLE, + NULL); return ret; } _notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE, @@ -2035,9 +2044,16 @@ static int _regulator_force_disable(struct regulator_dev *rdev) { int ret = 0; + ret = _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE | + REGULATOR_EVENT_PRE_DISABLE, NULL); + if (ret & NOTIFY_STOP_MASK) + return -EINVAL; + ret = _regulator_do_disable(rdev); if (ret < 0) { rdev_err(rdev, "failed to force disable\n"); + _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE | + REGULATOR_EVENT_ABORT_DISABLE, NULL); return ret; } diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index d347c805f923..9efddd2a63ee 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -99,6 +99,8 @@ struct regmap; * Data passed is "struct pre_voltage_change_data" * ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason. * Data passed is old voltage cast to (void *). + * PRE_DISABLE Regulator is about to be disabled + * ABORT_DISABLE Regulator disable failed for some reason * * NOTE: These events can be OR'ed together when passed into handler. */ @@ -113,6 +115,8 @@ struct regmap; #define REGULATOR_EVENT_DISABLE 0x80 #define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100 #define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200 +#define REGULATOR_EVENT_PRE_DISABLE 0x400 +#define REGULATOR_EVENT_ABORT_DISABLE 0x800 /** * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event -- cgit v1.2.3 From 072e78b12bf5182a3e2e460388214a291023ef1c Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 10 Nov 2014 14:43:53 +0100 Subject: regulator: of: Add regulator desc param to of_get_regulator_init_data() The of_get_regulator_init_data() function is used to extract the regulator init_data but information on how to extract certain data is defined in the static regulator descriptor (e.g: how to map the hardware operating modes). Add a const struct regulator_desc * parameter to the function signature so the parsing logic could use the information in the struct regulator_desc. of_get_regulator_init_data() relies on of_get_regulation_constraints() to actually extract the init_data so it has to pass the struct regulator_desc but that is modified on a later patch. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/88pm8607.c | 3 ++- drivers/regulator/anatop-regulator.c | 5 ++-- drivers/regulator/arizona-ldo1.c | 8 +++--- drivers/regulator/arizona-micsupp.c | 8 +++--- drivers/regulator/da9052-regulator.c | 3 ++- drivers/regulator/da9210-regulator.c | 2 +- drivers/regulator/fan53555.c | 17 ++++++------ drivers/regulator/fixed.c | 19 +++++++------ drivers/regulator/gpio-regulator.c | 18 +++++++------ drivers/regulator/max8952.c | 2 +- drivers/regulator/max8973-regulator.c | 3 ++- drivers/regulator/max8997.c | 3 ++- drivers/regulator/max8998.c | 5 ++-- drivers/regulator/mc13xxx-regulator-core.c | 3 ++- drivers/regulator/of_regulator.c | 9 ++++--- drivers/regulator/pwm-regulator.c | 3 ++- drivers/regulator/qcom_rpm-regulator.c | 9 ++++--- drivers/regulator/s5m8767.c | 3 ++- drivers/regulator/sky81452-regulator.c | 2 +- drivers/regulator/stw481x-vmmc.c | 3 ++- drivers/regulator/ti-abb-regulator.c | 3 ++- drivers/regulator/tps51632-regulator.c | 43 ++++++++++++++++-------------- drivers/regulator/tps62360-regulator.c | 31 +++++++++++---------- drivers/regulator/tps65218-regulator.c | 3 ++- drivers/regulator/twl-regulator.c | 3 ++- drivers/regulator/vexpress.c | 3 ++- include/linux/regulator/of_regulator.h | 8 ++++-- 27 files changed, 130 insertions(+), 92 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index 6d77dcd7dcf6..3fe47bd66153 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c @@ -330,7 +330,8 @@ static int pm8607_regulator_dt_init(struct platform_device *pdev, for_each_child_of_node(nproot, np) { if (!of_node_cmp(np->name, info->desc.name)) { config->init_data = - of_get_regulator_init_data(&pdev->dev, np); + of_get_regulator_init_data(&pdev->dev, np, + &info->desc); config->of_node = np; break; } diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 4f730af70e7c..6eaef9f64420 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c @@ -189,17 +189,18 @@ static int anatop_regulator_probe(struct platform_device *pdev) int ret = 0; u32 val; - initdata = of_get_regulator_init_data(dev, np); sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL); if (!sreg) return -ENOMEM; - sreg->initdata = initdata; sreg->name = of_get_property(np, "regulator-name", NULL); rdesc = &sreg->rdesc; rdesc->name = sreg->name; rdesc->type = REGULATOR_VOLTAGE; rdesc->owner = THIS_MODULE; + initdata = of_get_regulator_init_data(dev, np, rdesc); + sreg->initdata = initdata; + anatop_np = of_get_parent(np); if (!anatop_np) return -ENODEV; diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c index 4c9db589f6c1..b1eea7f76489 100644 --- a/drivers/regulator/arizona-ldo1.c +++ b/drivers/regulator/arizona-ldo1.c @@ -179,7 +179,8 @@ static const struct regulator_init_data arizona_ldo1_default = { }; static int arizona_ldo1_of_get_pdata(struct arizona *arizona, - struct regulator_config *config) + struct regulator_config *config, + const struct regulator_desc *desc) { struct arizona_pdata *pdata = &arizona->pdata; struct arizona_ldo1 *ldo1 = config->driver_data; @@ -194,7 +195,8 @@ static int arizona_ldo1_of_get_pdata(struct arizona *arizona, if (init_node) { config->of_node = init_node; - init_data = of_get_regulator_init_data(arizona->dev, init_node); + init_data = of_get_regulator_init_data(arizona->dev, init_node, + desc); if (init_data) { init_data->consumer_supplies = &ldo1->supply; @@ -257,7 +259,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev) if (IS_ENABLED(CONFIG_OF)) { if (!dev_get_platdata(arizona->dev)) { - ret = arizona_ldo1_of_get_pdata(arizona, &config); + ret = arizona_ldo1_of_get_pdata(arizona, &config, desc); if (ret < 0) return ret; } diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c index ce9aca5f8ee7..c313ef4c3a2f 100644 --- a/drivers/regulator/arizona-micsupp.c +++ b/drivers/regulator/arizona-micsupp.c @@ -198,7 +198,8 @@ static const struct regulator_init_data arizona_micsupp_ext_default = { }; static int arizona_micsupp_of_get_pdata(struct arizona *arizona, - struct regulator_config *config) + struct regulator_config *config, + const struct regulator_desc *desc) { struct arizona_pdata *pdata = &arizona->pdata; struct arizona_micsupp *micsupp = config->driver_data; @@ -210,7 +211,7 @@ static int arizona_micsupp_of_get_pdata(struct arizona *arizona, if (np) { config->of_node = np; - init_data = of_get_regulator_init_data(arizona->dev, np); + init_data = of_get_regulator_init_data(arizona->dev, np, desc); if (init_data) { init_data->consumer_supplies = &micsupp->supply; @@ -264,7 +265,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev) if (IS_ENABLED(CONFIG_OF)) { if (!dev_get_platdata(arizona->dev)) { - ret = arizona_micsupp_of_get_pdata(arizona, &config); + ret = arizona_micsupp_of_get_pdata(arizona, &config, + desc); if (ret < 0) return ret; } diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c index 00033625a09c..3945f1006d23 100644 --- a/drivers/regulator/da9052-regulator.c +++ b/drivers/regulator/da9052-regulator.c @@ -436,7 +436,8 @@ static int da9052_regulator_probe(struct platform_device *pdev) if (!of_node_cmp(np->name, regulator->info->reg_desc.name)) { config.init_data = of_get_regulator_init_data( - &pdev->dev, np); + &pdev->dev, np, + ®ulator->info->reg_desc); config.of_node = np; break; } diff --git a/drivers/regulator/da9210-regulator.c b/drivers/regulator/da9210-regulator.c index 7a320dd11c46..bc6100103f7f 100644 --- a/drivers/regulator/da9210-regulator.c +++ b/drivers/regulator/da9210-regulator.c @@ -147,7 +147,7 @@ static int da9210_i2c_probe(struct i2c_client *i2c, config.dev = &i2c->dev; config.init_data = pdata ? &pdata->da9210_constraints : - of_get_regulator_init_data(dev, dev->of_node); + of_get_regulator_init_data(dev, dev->of_node, &da9210_reg); config.driver_data = chip; config.regmap = chip->regmap; config.of_node = dev->of_node; diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index f8e4257aef92..6c43ab2d5121 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c @@ -302,7 +302,8 @@ static struct regmap_config fan53555_regmap_config = { }; static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev, - struct device_node *np) + struct device_node *np, + const struct regulator_desc *desc) { struct fan53555_platform_data *pdata; int ret; @@ -312,7 +313,7 @@ static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev, if (!pdata) return NULL; - pdata->regulator = of_get_regulator_init_data(dev, np); + pdata->regulator = of_get_regulator_init_data(dev, np, desc); ret = of_property_read_u32(np, "fcs,suspend-voltage-selector", &tmp); @@ -347,20 +348,20 @@ static int fan53555_regulator_probe(struct i2c_client *client, unsigned int val; int ret; + di = devm_kzalloc(&client->dev, sizeof(struct fan53555_device_info), + GFP_KERNEL); + if (!di) + return -ENOMEM; + pdata = dev_get_platdata(&client->dev); if (!pdata) - pdata = fan53555_parse_dt(&client->dev, np); + pdata = fan53555_parse_dt(&client->dev, np, &di->desc); if (!pdata || !pdata->regulator) { dev_err(&client->dev, "Platform data not found!\n"); return -ENODEV; } - di = devm_kzalloc(&client->dev, sizeof(struct fan53555_device_info), - GFP_KERNEL); - if (!di) - return -ENOMEM; - di->regulator = pdata->regulator; if (client->dev.of_node) { const struct of_device_id *match; diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 354105eff1f8..6cfcbc8b6594 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -40,13 +40,15 @@ struct fixed_voltage_data { /** * of_get_fixed_voltage_config - extract fixed_voltage_config structure info * @dev: device requesting for fixed_voltage_config + * @desc: regulator description * * Populates fixed_voltage_config structure by extracting data from device * tree node, returns a pointer to the populated structure of NULL if memory * alloc fails. */ static struct fixed_voltage_config * -of_get_fixed_voltage_config(struct device *dev) +of_get_fixed_voltage_config(struct device *dev, + const struct regulator_desc *desc) { struct fixed_voltage_config *config; struct device_node *np = dev->of_node; @@ -57,7 +59,7 @@ of_get_fixed_voltage_config(struct device *dev) if (!config) return ERR_PTR(-ENOMEM); - config->init_data = of_get_regulator_init_data(dev, dev->of_node); + config->init_data = of_get_regulator_init_data(dev, dev->of_node, desc); if (!config->init_data) return ERR_PTR(-EINVAL); @@ -112,8 +114,14 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) struct regulator_config cfg = { }; int ret; + drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), + GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + if (pdev->dev.of_node) { - config = of_get_fixed_voltage_config(&pdev->dev); + config = of_get_fixed_voltage_config(&pdev->dev, + &drvdata->desc); if (IS_ERR(config)) return PTR_ERR(config); } else { @@ -123,11 +131,6 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) if (!config) return -ENOMEM; - drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), - GFP_KERNEL); - if (!drvdata) - return -ENOMEM; - drvdata->desc.name = devm_kstrdup(&pdev->dev, config->supply_name, GFP_KERNEL); diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 989b23b377c0..5c3bcae478b9 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -133,7 +133,8 @@ static struct regulator_ops gpio_regulator_voltage_ops = { }; static struct gpio_regulator_config * -of_get_gpio_regulator_config(struct device *dev, struct device_node *np) +of_get_gpio_regulator_config(struct device *dev, struct device_node *np, + const struct regulator_desc *desc) { struct gpio_regulator_config *config; const char *regtype; @@ -146,7 +147,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) if (!config) return ERR_PTR(-ENOMEM); - config->init_data = of_get_regulator_init_data(dev, np); + config->init_data = of_get_regulator_init_data(dev, np, desc); if (!config->init_data) return ERR_PTR(-EINVAL); @@ -243,17 +244,18 @@ static int gpio_regulator_probe(struct platform_device *pdev) struct regulator_config cfg = { }; int ptr, ret, state; - if (np) { - config = of_get_gpio_regulator_config(&pdev->dev, np); - if (IS_ERR(config)) - return PTR_ERR(config); - } - drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), GFP_KERNEL); if (drvdata == NULL) return -ENOMEM; + if (np) { + config = of_get_gpio_regulator_config(&pdev->dev, np, + &drvdata->desc); + if (IS_ERR(config)) + return PTR_ERR(config); + } + drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); if (drvdata->desc.name == NULL) { dev_err(&pdev->dev, "Failed to allocate supply name\n"); diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c index f7f9efcfedb7..6e54d786b22c 100644 --- a/drivers/regulator/max8952.c +++ b/drivers/regulator/max8952.c @@ -174,7 +174,7 @@ static struct max8952_platform_data *max8952_parse_dt(struct device *dev) if (of_property_read_u32(np, "max8952,ramp-speed", &pd->ramp_speed)) dev_warn(dev, "max8952,ramp-speed property not specified, defaulting to 32mV/us\n"); - pd->reg_data = of_get_regulator_init_data(dev, np); + pd->reg_data = of_get_regulator_init_data(dev, np, ®ulator); if (!pd->reg_data) { dev_err(dev, "Failed to parse regulator init data\n"); return NULL; diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index dbedf1768db0..c3d55c2db593 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -458,7 +458,8 @@ static int max8973_probe(struct i2c_client *client, config.dev = &client->dev; config.init_data = pdata ? pdata->reg_init_data : - of_get_regulator_init_data(&client->dev, client->dev.of_node); + of_get_regulator_init_data(&client->dev, client->dev.of_node, + &max->desc); config.driver_data = max; config.of_node = client->dev.of_node; config.regmap = max->regmap; diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 9c31e215a521..726fde1d883e 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c @@ -953,7 +953,8 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, rdata->id = i; rdata->initdata = of_get_regulator_init_data(&pdev->dev, - reg_np); + reg_np, + ®ulators[i]); rdata->reg_node = reg_np; rdata++; } diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 961091b46557..59e34a05a4a2 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c @@ -686,8 +686,9 @@ static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev, continue; rdata->id = regulators[i].id; - rdata->initdata = of_get_regulator_init_data( - iodev->dev, reg_np); + rdata->initdata = of_get_regulator_init_data(iodev->dev, + reg_np, + ®ulators[i]); rdata->reg_node = reg_np; ++rdata; } diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c index afba024953e1..0281c31ae2ed 100644 --- a/drivers/regulator/mc13xxx-regulator-core.c +++ b/drivers/regulator/mc13xxx-regulator-core.c @@ -194,7 +194,8 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( regulators[i].desc.name)) { p->id = i; p->init_data = of_get_regulator_init_data( - &pdev->dev, child); + &pdev->dev, child, + ®ulators[i].desc); p->node = child; p++; diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 50be70878d2d..3687a1c38c1c 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -120,13 +120,16 @@ static void of_get_regulation_constraints(struct device_node *np, /** * of_get_regulator_init_data - extract regulator_init_data structure info * @dev: device requesting for regulator_init_data + * @node: regulator device node + * @desc: regulator description * * Populates regulator_init_data structure by extracting data from device * tree node, returns a pointer to the populated struture or NULL if memory * alloc fails. */ struct regulator_init_data *of_get_regulator_init_data(struct device *dev, - struct device_node *node) + struct device_node *node, + const struct regulator_desc *desc) { struct regulator_init_data *init_data; @@ -218,7 +221,7 @@ int of_regulator_match(struct device *dev, struct device_node *node, continue; match->init_data = - of_get_regulator_init_data(dev, child); + of_get_regulator_init_data(dev, child, NULL); if (!match->init_data) { dev_err(dev, "failed to parse DT for regulator %s\n", @@ -265,7 +268,7 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev, if (strcmp(desc->of_match, name)) continue; - init_data = of_get_regulator_init_data(dev, child); + init_data = of_get_regulator_init_data(dev, child, desc); if (!init_data) { dev_err(dev, "failed to parse DT for regulator %s\n", diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index d3f55eaea058..91f34ca3a9ac 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -149,7 +149,8 @@ static int pwm_regulator_probe(struct platform_device *pdev) return ret; } - config.init_data = of_get_regulator_init_data(&pdev->dev, np); + config.init_data = of_get_regulator_init_data(&pdev->dev, np, + &drvdata->desc); if (!config.init_data) return -ENOMEM; diff --git a/drivers/regulator/qcom_rpm-regulator.c b/drivers/regulator/qcom_rpm-regulator.c index b55cd5b50ebe..dabd28a359dc 100644 --- a/drivers/regulator/qcom_rpm-regulator.c +++ b/drivers/regulator/qcom_rpm-regulator.c @@ -643,10 +643,6 @@ static int rpm_reg_probe(struct platform_device *pdev) match = of_match_device(rpm_of_match, &pdev->dev); template = match->data; - initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node); - if (!initdata) - return -EINVAL; - vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); if (!vreg) { dev_err(&pdev->dev, "failed to allocate vreg\n"); @@ -666,6 +662,11 @@ static int rpm_reg_probe(struct platform_device *pdev) return -ENODEV; } + initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node, + &vreg->desc); + if (!initdata) + return -EINVAL; + key = "reg"; ret = of_property_read_u32(pdev->dev.of_node, key, &val); if (ret) { diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 0ab5cbeeb797..26932fe42b47 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -581,7 +581,8 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, rdata->id = i; rdata->initdata = of_get_regulator_init_data( - &pdev->dev, reg_np); + &pdev->dev, reg_np, + ®ulators[i]); rdata->reg_node = reg_np; rdata++; rmode->id = i; diff --git a/drivers/regulator/sky81452-regulator.c b/drivers/regulator/sky81452-regulator.c index 97aff0ccd65f..75deae706f84 100644 --- a/drivers/regulator/sky81452-regulator.c +++ b/drivers/regulator/sky81452-regulator.c @@ -76,7 +76,7 @@ static struct regulator_init_data *sky81452_reg_parse_dt(struct device *dev) return NULL; } - init_data = of_get_regulator_init_data(dev, np); + init_data = of_get_regulator_init_data(dev, np, &sky81452_reg); of_node_put(np); return init_data; diff --git a/drivers/regulator/stw481x-vmmc.c b/drivers/regulator/stw481x-vmmc.c index a7e152696a02..b4f1696456a7 100644 --- a/drivers/regulator/stw481x-vmmc.c +++ b/drivers/regulator/stw481x-vmmc.c @@ -72,7 +72,8 @@ static int stw481x_vmmc_regulator_probe(struct platform_device *pdev) config.regmap = stw481x->map; config.of_node = pdev->dev.of_node; config.init_data = of_get_regulator_init_data(&pdev->dev, - pdev->dev.of_node); + pdev->dev.of_node, + &vmmc_regulator); stw481x->vmmc_regulator = devm_regulator_register(&pdev->dev, &vmmc_regulator, &config); diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c index a2dabb575b97..1ef5aba96f17 100644 --- a/drivers/regulator/ti-abb-regulator.c +++ b/drivers/regulator/ti-abb-regulator.c @@ -837,7 +837,8 @@ skip_opt: return -EINVAL; } - initdata = of_get_regulator_init_data(dev, pdev->dev.of_node); + initdata = of_get_regulator_init_data(dev, pdev->dev.of_node, + &abb->rdesc); if (!initdata) { dev_err(dev, "%s: Unable to alloc regulator init data\n", __func__); diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c index f31f22e3e1bd..c213e37eb69e 100644 --- a/drivers/regulator/tps51632-regulator.c +++ b/drivers/regulator/tps51632-regulator.c @@ -221,7 +221,8 @@ static const struct of_device_id tps51632_of_match[] = { MODULE_DEVICE_TABLE(of, tps51632_of_match); static struct tps51632_regulator_platform_data * - of_get_tps51632_platform_data(struct device *dev) + of_get_tps51632_platform_data(struct device *dev, + const struct regulator_desc *desc) { struct tps51632_regulator_platform_data *pdata; struct device_node *np = dev->of_node; @@ -230,7 +231,8 @@ static struct tps51632_regulator_platform_data * if (!pdata) return NULL; - pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node); + pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node, + desc); if (!pdata->reg_init_data) { dev_err(dev, "Not able to get OF regulator init data\n"); return NULL; @@ -248,7 +250,8 @@ static struct tps51632_regulator_platform_data * } #else static struct tps51632_regulator_platform_data * - of_get_tps51632_platform_data(struct device *dev) + of_get_tps51632_platform_data(struct device *dev, + const struct regulator_desc *desc) { return NULL; } @@ -273,9 +276,25 @@ static int tps51632_probe(struct i2c_client *client, } } + tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); + if (!tps) + return -ENOMEM; + + tps->dev = &client->dev; + tps->desc.name = client->name; + tps->desc.id = 0; + tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY; + tps->desc.min_uV = TPS51632_MIN_VOLTAGE; + tps->desc.uV_step = TPS51632_VOLTAGE_STEP_10mV; + tps->desc.linear_min_sel = TPS51632_MIN_VSEL; + tps->desc.n_voltages = TPS51632_MAX_VSEL + 1; + tps->desc.ops = &tps51632_dcdc_ops; + tps->desc.type = REGULATOR_VOLTAGE; + tps->desc.owner = THIS_MODULE; + pdata = dev_get_platdata(&client->dev); if (!pdata && client->dev.of_node) - pdata = of_get_tps51632_platform_data(&client->dev); + pdata = of_get_tps51632_platform_data(&client->dev, &tps->desc); if (!pdata) { dev_err(&client->dev, "No Platform data\n"); return -EINVAL; @@ -296,22 +315,6 @@ static int tps51632_probe(struct i2c_client *client, } } - tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); - if (!tps) - return -ENOMEM; - - tps->dev = &client->dev; - tps->desc.name = client->name; - tps->desc.id = 0; - tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY; - tps->desc.min_uV = TPS51632_MIN_VOLTAGE; - tps->desc.uV_step = TPS51632_VOLTAGE_STEP_10mV; - tps->desc.linear_min_sel = TPS51632_MIN_VSEL; - tps->desc.n_voltages = TPS51632_MAX_VSEL + 1; - tps->desc.ops = &tps51632_dcdc_ops; - tps->desc.type = REGULATOR_VOLTAGE; - tps->desc.owner = THIS_MODULE; - if (pdata->enable_pwm_dvfs) tps->desc.vsel_reg = TPS51632_VOLTAGE_BASE_REG; else diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index a1672044e519..a1fd626c6c96 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c @@ -293,7 +293,8 @@ static const struct regmap_config tps62360_regmap_config = { }; static struct tps62360_regulator_platform_data * - of_get_tps62360_platform_data(struct device *dev) + of_get_tps62360_platform_data(struct device *dev, + const struct regulator_desc *desc) { struct tps62360_regulator_platform_data *pdata; struct device_node *np = dev->of_node; @@ -302,7 +303,8 @@ static struct tps62360_regulator_platform_data * if (!pdata) return NULL; - pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node); + pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node, + desc); if (!pdata->reg_init_data) { dev_err(dev, "Not able to get OF regulator init data\n"); return NULL; @@ -350,6 +352,17 @@ static int tps62360_probe(struct i2c_client *client, pdata = dev_get_platdata(&client->dev); + tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); + if (!tps) + return -ENOMEM; + + tps->desc.name = client->name; + tps->desc.id = 0; + tps->desc.ops = &tps62360_dcdc_ops; + tps->desc.type = REGULATOR_VOLTAGE; + tps->desc.owner = THIS_MODULE; + tps->desc.uV_step = 10000; + if (client->dev.of_node) { const struct of_device_id *match; match = of_match_device(of_match_ptr(tps62360_of_match), @@ -360,7 +373,8 @@ static int tps62360_probe(struct i2c_client *client, } chip_id = (int)(long)match->data; if (!pdata) - pdata = of_get_tps62360_platform_data(&client->dev); + pdata = of_get_tps62360_platform_data(&client->dev, + &tps->desc); } else if (id) { chip_id = id->driver_data; } else { @@ -374,10 +388,6 @@ static int tps62360_probe(struct i2c_client *client, return -EIO; } - tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); - if (!tps) - return -ENOMEM; - tps->en_discharge = pdata->en_discharge; tps->en_internal_pulldn = pdata->en_internal_pulldn; tps->vsel0_gpio = pdata->vsel0_gpio; @@ -401,13 +411,6 @@ static int tps62360_probe(struct i2c_client *client, return -ENODEV; } - tps->desc.name = client->name; - tps->desc.id = 0; - tps->desc.ops = &tps62360_dcdc_ops; - tps->desc.type = REGULATOR_VOLTAGE; - tps->desc.owner = THIS_MODULE; - tps->desc.uV_step = 10000; - tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config); if (IS_ERR(tps->regmap)) { ret = PTR_ERR(tps->regmap); diff --git a/drivers/regulator/tps65218-regulator.c b/drivers/regulator/tps65218-regulator.c index f0a40281b9c1..263cc85d6202 100644 --- a/drivers/regulator/tps65218-regulator.c +++ b/drivers/regulator/tps65218-regulator.c @@ -231,7 +231,8 @@ static int tps65218_regulator_probe(struct platform_device *pdev) template = match->data; id = template->id; - init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node); + init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node, + ®ulators[id]); platform_set_drvdata(pdev, tps); diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 0b4f8660fdb4..dd727bca1983 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c @@ -1104,7 +1104,8 @@ static int twlreg_probe(struct platform_device *pdev) template = match->data; id = template->desc.id; initdata = of_get_regulator_init_data(&pdev->dev, - pdev->dev.of_node); + pdev->dev.of_node, + &template->desc); drvdata = NULL; } else { id = pdev->id; diff --git a/drivers/regulator/vexpress.c b/drivers/regulator/vexpress.c index 02e7267ccf92..5e7c789023a9 100644 --- a/drivers/regulator/vexpress.c +++ b/drivers/regulator/vexpress.c @@ -74,7 +74,8 @@ static int vexpress_regulator_probe(struct platform_device *pdev) reg->desc.owner = THIS_MODULE; reg->desc.continuous_voltage_range = true; - init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node); + init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node, + ®->desc); if (!init_data) return -EINVAL; diff --git a/include/linux/regulator/of_regulator.h b/include/linux/regulator/of_regulator.h index f9217965aaa3..8d1d136c0fb9 100644 --- a/include/linux/regulator/of_regulator.h +++ b/include/linux/regulator/of_regulator.h @@ -6,6 +6,8 @@ #ifndef __LINUX_OF_REG_H #define __LINUX_OF_REG_H +struct regulator_desc; + struct of_regulator_match { const char *name; void *driver_data; @@ -16,14 +18,16 @@ struct of_regulator_match { #if defined(CONFIG_OF) extern struct regulator_init_data *of_get_regulator_init_data(struct device *dev, - struct device_node *node); + struct device_node *node, + const struct regulator_desc *desc); extern int of_regulator_match(struct device *dev, struct device_node *node, struct of_regulator_match *matches, unsigned int num_matches); #else static inline struct regulator_init_data *of_get_regulator_init_data(struct device *dev, - struct device_node *node) + struct device_node *node, + const struct regulator_desc *desc) { return NULL; } -- cgit v1.2.3 From 75d6b2faf79cbe9086e831351d5d9085f1852928 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 10 Nov 2014 14:43:54 +0100 Subject: regulator: of: Pass the regulator description in the match table Drivers can use the of_regulator_match() function to parse the regulator init_data from DT. A match table is used to specify the name of the node containing the regulators, the device node and to return the init_data to the caller. But also the static regulator descriptor is needed to correctly extract some DT properties like the regulator initial and suspend modes. Use the match table to pass that information. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/of_regulator.c | 3 ++- include/linux/regulator/of_regulator.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 3687a1c38c1c..64c09a37ac7f 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -221,7 +221,8 @@ int of_regulator_match(struct device *dev, struct device_node *node, continue; match->init_data = - of_get_regulator_init_data(dev, child, NULL); + of_get_regulator_init_data(dev, child, + match->desc); if (!match->init_data) { dev_err(dev, "failed to parse DT for regulator %s\n", diff --git a/include/linux/regulator/of_regulator.h b/include/linux/regulator/of_regulator.h index 8d1d136c0fb9..763953f7e3b8 100644 --- a/include/linux/regulator/of_regulator.h +++ b/include/linux/regulator/of_regulator.h @@ -13,6 +13,7 @@ struct of_regulator_match { void *driver_data; struct regulator_init_data *init_data; struct device_node *of_node; + const struct regulator_desc *desc; }; #if defined(CONFIG_OF) -- cgit v1.2.3 From 5e5e3a42c653c5ef1c281651f1882411601129bd Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 10 Nov 2014 14:43:55 +0100 Subject: regulator: of: Add support for parsing initial and suspend modes Some regulators support their operating mode to be changed on startup or by consumers when the system is running while others only support their operating mode to be changed while the system has entered in a suspend state. The regulator Device Tree binding documents a set of properties to configure the regulators operating modes from a FDT. This patch builds on (40e20d6 regulator: of: Add support for parsing regulator_state for suspend state) and adds support to parse those properties and fill the regulator constraints so the regulator core can call the right suspend handlers when the system enters into sleep. The modes are defined in the Device Tree using the hardware specific modes supported by the regulators. Regulator drivers have to define a translation function that is used to map the hardware specific modes to the standard ones. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/of_regulator.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 64c09a37ac7f..163946075656 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -25,7 +25,8 @@ static const char *const regulator_states[PM_SUSPEND_MAX + 1] = { }; static void of_get_regulation_constraints(struct device_node *np, - struct regulator_init_data **init_data) + struct regulator_init_data **init_data, + const struct regulator_desc *desc) { const __be32 *min_uV, *max_uV; struct regulation_constraints *constraints = &(*init_data)->constraints; @@ -81,6 +82,19 @@ static void of_get_regulation_constraints(struct device_node *np, if (!ret) constraints->enable_time = pval; + if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) { + if (desc && desc->of_map_mode) { + ret = desc->of_map_mode(pval); + if (ret == -EINVAL) + pr_err("%s: invalid mode %u\n", np->name, pval); + else + constraints->initial_mode = ret; + } else { + pr_warn("%s: mapping for mode %d not defined\n", + np->name, pval); + } + } + for (i = 0; i < ARRAY_SIZE(regulator_states); i++) { switch (i) { case PM_SUSPEND_MEM: @@ -100,6 +114,21 @@ static void of_get_regulation_constraints(struct device_node *np, if (!suspend_np || !suspend_state) continue; + if (!of_property_read_u32(suspend_np, "regulator-mode", + &pval)) { + if (desc && desc->of_map_mode) { + ret = desc->of_map_mode(pval); + if (ret == -EINVAL) + pr_err("%s: invalid mode %u\n", + np->name, pval); + else + suspend_state->mode = ret; + } else { + pr_warn("%s: mapping for mode %d not defined\n", + np->name, pval); + } + } + if (of_property_read_bool(suspend_np, "regulator-on-in-suspend")) suspend_state->enabled = true; @@ -140,7 +169,7 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev, if (!init_data) return NULL; /* Out of memory? */ - of_get_regulation_constraints(node, &init_data); + of_get_regulation_constraints(node, &init_data, desc); return init_data; } EXPORT_SYMBOL_GPL(of_get_regulator_init_data); -- cgit v1.2.3 From 45fc84c668ba6cc08cbae74042be838bf9283d98 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 11 Nov 2014 13:04:44 +0100 Subject: regulator: max77802: Fill regulator modes translation callback The max77802 PMIC regulators output can be configured in one of two modes: Output ON (normal) and Output ON in Low Power Mode. Some of the regulators support their operating mode to be changed on startup or by consumers when the system is running while others only support their operating mode to be changed while the system has entered in a suspend state. Use the max77802_map_mode() function to translate the device specific modes to the standard operating modes as used by the regulator core. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index d076df1d2166..0ec27cf92785 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -375,6 +375,7 @@ static struct regulator_ops max77802_buck_dvs_ops = { .vsel_mask = MAX77802_VSEL_MASK, \ .enable_reg = MAX77802_REG_LDO1CTRL1 + num - 1, \ .enable_mask = MAX77802_OPMODE_MASK << MAX77802_OPMODE_SHIFT_LDO, \ + .of_map_mode = max77802_map_mode, \ } /* LDOs 1, 2, 8, 15, 17, 27, 30, 35 */ @@ -393,6 +394,7 @@ static struct regulator_ops max77802_buck_dvs_ops = { .vsel_mask = MAX77802_VSEL_MASK, \ .enable_reg = MAX77802_REG_LDO1CTRL1 + num - 1, \ .enable_mask = MAX77802_OPMODE_MASK << MAX77802_OPMODE_SHIFT_LDO, \ + .of_map_mode = max77802_map_mode, \ } /* BUCKs 1, 6 */ @@ -411,6 +413,7 @@ static struct regulator_ops max77802_buck_dvs_ops = { .vsel_mask = MAX77802_DVS_VSEL_MASK, \ .enable_reg = MAX77802_REG_BUCK ## num ## CTRL, \ .enable_mask = MAX77802_OPMODE_MASK, \ + .of_map_mode = max77802_map_mode, \ } /* BUCKS 2-4 */ @@ -430,6 +433,7 @@ static struct regulator_ops max77802_buck_dvs_ops = { .enable_reg = MAX77802_REG_BUCK ## num ## CTRL1, \ .enable_mask = MAX77802_OPMODE_MASK << \ MAX77802_OPMODE_BUCK234_SHIFT, \ + .of_map_mode = max77802_map_mode, \ } /* BUCK 5 */ @@ -448,6 +452,7 @@ static struct regulator_ops max77802_buck_dvs_ops = { .vsel_mask = MAX77802_VSEL_MASK, \ .enable_reg = MAX77802_REG_BUCK5CTRL, \ .enable_mask = MAX77802_OPMODE_MASK, \ + .of_map_mode = max77802_map_mode, \ } /* BUCKs 7-10 */ @@ -466,6 +471,7 @@ static struct regulator_ops max77802_buck_dvs_ops = { .vsel_mask = MAX77802_VSEL_MASK, \ .enable_reg = MAX77802_REG_BUCK7CTRL + (num - 7) * 3, \ .enable_mask = MAX77802_OPMODE_MASK, \ + .of_map_mode = max77802_map_mode, \ } static const struct regulator_desc regulators[] = { -- cgit v1.2.3 From ff633bea47751f660aad1afd22790cbbd47ca9fc Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Wed, 5 Nov 2014 10:47:49 +0100 Subject: regulator: max77802: Remove support for board files The driver is used only on Exynos based boards with DTS support. Simplify the driver and remove dead (unused) entries in platform_data structure. Convert the driver to DTS-only version. Parse all regulators at once, not one-by-one. Remove dependency on data provided by max77686 MFD driver. Use new DT style parsing method for regulators init data. Signed-off-by: Krzysztof Kozlowski Acked-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/max77802.c | 92 +++++++++----------------------------------- 1 file changed, 19 insertions(+), 73 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index 9e2183c8566c..0766615c60bc 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -70,6 +70,7 @@ static unsigned int ramp_table_77802_4bit[] = { }; struct max77802_regulator_prv { + /* Array indexed by regulator id */ unsigned int opmode[MAX77802_REG_MAX]; }; @@ -362,6 +363,8 @@ static struct regulator_ops max77802_buck_dvs_ops = { /* LDOs 3-7, 9-14, 18-26, 28, 29, 32-34 */ #define regulator_77802_desc_p_ldo(num, supply, log) { \ .name = "LDO"#num, \ + .of_match = of_match_ptr("LDO"#num), \ + .regulators_node = of_match_ptr("regulators"), \ .id = MAX77802_LDO##num, \ .supply_name = "inl"#supply, \ .ops = &max77802_ldo_ops_logic##log, \ @@ -381,6 +384,8 @@ static struct regulator_ops max77802_buck_dvs_ops = { /* LDOs 1, 2, 8, 15, 17, 27, 30, 35 */ #define regulator_77802_desc_n_ldo(num, supply, log) { \ .name = "LDO"#num, \ + .of_match = of_match_ptr("LDO"#num), \ + .regulators_node = of_match_ptr("regulators"), \ .id = MAX77802_LDO##num, \ .supply_name = "inl"#supply, \ .ops = &max77802_ldo_ops_logic##log, \ @@ -400,6 +405,8 @@ static struct regulator_ops max77802_buck_dvs_ops = { /* BUCKs 1, 6 */ #define regulator_77802_desc_16_buck(num) { \ .name = "BUCK"#num, \ + .of_match = of_match_ptr("BUCK"#num), \ + .regulators_node = of_match_ptr("regulators"), \ .id = MAX77802_BUCK##num, \ .supply_name = "inb"#num, \ .ops = &max77802_buck_16_dvs_ops, \ @@ -419,6 +426,8 @@ static struct regulator_ops max77802_buck_dvs_ops = { /* BUCKS 2-4 */ #define regulator_77802_desc_234_buck(num) { \ .name = "BUCK"#num, \ + .of_match = of_match_ptr("BUCK"#num), \ + .regulators_node = of_match_ptr("regulators"), \ .id = MAX77802_BUCK##num, \ .supply_name = "inb"#num, \ .ops = &max77802_buck_234_ops, \ @@ -439,6 +448,8 @@ static struct regulator_ops max77802_buck_dvs_ops = { /* BUCK 5 */ #define regulator_77802_desc_buck5(num) { \ .name = "BUCK"#num, \ + .of_match = of_match_ptr("BUCK"#num), \ + .regulators_node = of_match_ptr("regulators"), \ .id = MAX77802_BUCK##num, \ .supply_name = "inb"#num, \ .ops = &max77802_buck_dvs_ops, \ @@ -458,6 +469,8 @@ static struct regulator_ops max77802_buck_dvs_ops = { /* BUCKs 7-10 */ #define regulator_77802_desc_buck7_10(num) { \ .name = "BUCK"#num, \ + .of_match = of_match_ptr("BUCK"#num), \ + .regulators_node = of_match_ptr("regulators"), \ .id = MAX77802_BUCK##num, \ .supply_name = "inb"#num, \ .ops = &max77802_buck_dvs_ops, \ @@ -519,85 +532,19 @@ static const struct regulator_desc regulators[] = { regulator_77802_desc_n_ldo(35, 2, 1), }; -#ifdef CONFIG_OF -static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev, - struct max77686_platform_data *pdata) -{ - struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct device_node *pmic_np, *regulators_np; - struct max77686_regulator_data *rdata; - struct of_regulator_match rmatch = { }; - unsigned int i; - - pmic_np = iodev->dev->of_node; - regulators_np = of_get_child_by_name(pmic_np, "regulators"); - if (!regulators_np) { - dev_err(&pdev->dev, "could not find regulators sub-node\n"); - return -EINVAL; - } - - pdata->num_regulators = ARRAY_SIZE(regulators); - rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * - pdata->num_regulators, GFP_KERNEL); - if (!rdata) { - of_node_put(regulators_np); - return -ENOMEM; - } - - for (i = 0; i < pdata->num_regulators; i++) { - rmatch.name = regulators[i].name; - rmatch.init_data = NULL; - rmatch.of_node = NULL; - if (of_regulator_match(&pdev->dev, regulators_np, &rmatch, - 1) != 1) { - dev_warn(&pdev->dev, "No matching regulator for '%s'\n", - rmatch.name); - continue; - } - rdata[i].initdata = rmatch.init_data; - rdata[i].of_node = rmatch.of_node; - rdata[i].id = regulators[i].id; - } - - pdata->regulators = rdata; - of_node_put(regulators_np); - - return 0; -} -#else -static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev, - struct max77686_platform_data *pdata) -{ - return 0; -} -#endif /* CONFIG_OF */ - static int max77802_pmic_probe(struct platform_device *pdev) { struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev); struct max77802_regulator_prv *max77802; - int i, ret = 0, val; + int i, val; struct regulator_config config = { }; - /* This is allocated by the MFD driver */ - if (!pdata) { - dev_err(&pdev->dev, "no platform data found for regulator\n"); - return -ENODEV; - } - max77802 = devm_kzalloc(&pdev->dev, sizeof(struct max77802_regulator_prv), GFP_KERNEL); if (!max77802) return -ENOMEM; - if (iodev->dev->of_node) { - ret = max77802_pmic_dt_parse_pdata(pdev, pdata); - if (ret) - return ret; - } - config.dev = iodev->dev; config.regmap = iodev->regmap; config.driver_data = max77802; @@ -605,11 +552,9 @@ static int max77802_pmic_probe(struct platform_device *pdev) for (i = 0; i < MAX77802_REG_MAX; i++) { struct regulator_dev *rdev; - int id = pdata->regulators[i].id; + int id = regulators[i].id; int shift = max77802_get_opmode_shift(id); - - config.init_data = pdata->regulators[i].initdata; - config.of_node = pdata->regulators[i].of_node; + int ret; ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val); if (ret < 0) { @@ -633,9 +578,10 @@ static int max77802_pmic_probe(struct platform_device *pdev) rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(rdev)) { + ret = PTR_ERR(rdev); dev_err(&pdev->dev, - "regulator init failed for %d\n", i); - return PTR_ERR(rdev); + "regulator init failed for %d: %d\n", i, ret); + return ret; } } -- cgit v1.2.3 From 0480395264fa361fc3feed05b26800debe026f57 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Wed, 5 Nov 2014 10:47:50 +0100 Subject: regulator: max77686: Remove support for board files The driver is used only on Exynos based boards with DTS support. Simplify the driver and remove dead (unused) entries in platform_data structure. Convert the driver to DTS-only version. Parse all regulators at once, not one-by-one. Remove dependency on data provided by max77686 MFD driver. Use new DT style parsing method for regulators init data. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/max77686.c | 91 +++++++++----------------------------------- 1 file changed, 19 insertions(+), 72 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index 2063532e0763..871b96bcd2d0 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c @@ -281,6 +281,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { #define regulator_desc_ldo(num) { \ .name = "LDO"#num, \ + .of_match = of_match_ptr("LDO"#num), \ + .regulators_node = of_match_ptr("voltage-regulators"), \ .id = MAX77686_LDO##num, \ .ops = &max77686_ops, \ .type = REGULATOR_VOLTAGE, \ @@ -297,6 +299,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { } #define regulator_desc_lpm_ldo(num) { \ .name = "LDO"#num, \ + .of_match = of_match_ptr("LDO"#num), \ + .regulators_node = of_match_ptr("voltage-regulators"), \ .id = MAX77686_LDO##num, \ .ops = &max77686_ldo_ops, \ .type = REGULATOR_VOLTAGE, \ @@ -313,6 +317,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { } #define regulator_desc_ldo_low(num) { \ .name = "LDO"#num, \ + .of_match = of_match_ptr("LDO"#num), \ + .regulators_node = of_match_ptr("voltage-regulators"), \ .id = MAX77686_LDO##num, \ .ops = &max77686_ldo_ops, \ .type = REGULATOR_VOLTAGE, \ @@ -329,6 +335,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { } #define regulator_desc_ldo1_low(num) { \ .name = "LDO"#num, \ + .of_match = of_match_ptr("LDO"#num), \ + .regulators_node = of_match_ptr("voltage-regulators"), \ .id = MAX77686_LDO##num, \ .ops = &max77686_ops, \ .type = REGULATOR_VOLTAGE, \ @@ -345,6 +353,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { } #define regulator_desc_buck(num) { \ .name = "BUCK"#num, \ + .of_match = of_match_ptr("BUCK"#num), \ + .regulators_node = of_match_ptr("voltage-regulators"), \ .id = MAX77686_BUCK##num, \ .ops = &max77686_ops, \ .type = REGULATOR_VOLTAGE, \ @@ -360,6 +370,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { } #define regulator_desc_buck1(num) { \ .name = "BUCK"#num, \ + .of_match = of_match_ptr("BUCK"#num), \ + .regulators_node = of_match_ptr("voltage-regulators"), \ .id = MAX77686_BUCK##num, \ .ops = &max77686_buck1_ops, \ .type = REGULATOR_VOLTAGE, \ @@ -375,6 +387,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { } #define regulator_desc_buck_dvs(num) { \ .name = "BUCK"#num, \ + .of_match = of_match_ptr("BUCK"#num), \ + .regulators_node = of_match_ptr("voltage-regulators"), \ .id = MAX77686_BUCK##num, \ .ops = &max77686_buck_dvs_ops, \ .type = REGULATOR_VOLTAGE, \ @@ -428,86 +442,21 @@ static const struct regulator_desc regulators[] = { regulator_desc_buck(9), }; -#ifdef CONFIG_OF -static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev, - struct max77686_platform_data *pdata) -{ - struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct device_node *pmic_np, *regulators_np; - struct max77686_regulator_data *rdata; - struct of_regulator_match rmatch = { }; - unsigned int i; - - pmic_np = iodev->dev->of_node; - regulators_np = of_get_child_by_name(pmic_np, "voltage-regulators"); - if (!regulators_np) { - dev_err(&pdev->dev, "could not find regulators sub-node\n"); - return -EINVAL; - } - - pdata->num_regulators = ARRAY_SIZE(regulators); - rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * - pdata->num_regulators, GFP_KERNEL); - if (!rdata) { - of_node_put(regulators_np); - return -ENOMEM; - } - - for (i = 0; i < pdata->num_regulators; i++) { - rmatch.name = regulators[i].name; - rmatch.init_data = NULL; - rmatch.of_node = NULL; - of_regulator_match(&pdev->dev, regulators_np, &rmatch, 1); - rdata[i].initdata = rmatch.init_data; - rdata[i].of_node = rmatch.of_node; - } - - pdata->regulators = rdata; - of_node_put(regulators_np); - - return 0; -} -#else -static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev, - struct max77686_platform_data *pdata) -{ - return 0; -} -#endif /* CONFIG_OF */ - static int max77686_pmic_probe(struct platform_device *pdev) { struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev); struct max77686_data *max77686; - int i, ret = 0; + int i; struct regulator_config config = { }; dev_dbg(&pdev->dev, "%s\n", __func__); - if (!pdata) { - dev_err(&pdev->dev, "no platform data found for regulator\n"); - return -ENODEV; - } - - if (iodev->dev->of_node) { - ret = max77686_pmic_dt_parse_pdata(pdev, pdata); - if (ret) - return ret; - } - - if (pdata->num_regulators != MAX77686_REGULATORS) { - dev_err(&pdev->dev, - "Invalid initial data for regulator's initialiation\n"); - return -EINVAL; - } - max77686 = devm_kzalloc(&pdev->dev, sizeof(struct max77686_data), GFP_KERNEL); if (!max77686) return -ENOMEM; - config.dev = &pdev->dev; + config.dev = iodev->dev; config.regmap = iodev->regmap; config.driver_data = max77686; platform_set_drvdata(pdev, max77686); @@ -516,16 +465,14 @@ static int max77686_pmic_probe(struct platform_device *pdev) struct regulator_dev *rdev; int id = regulators[i].id; - config.init_data = pdata->regulators[i].initdata; - config.of_node = pdata->regulators[i].of_node; - max77686->opmode[id] = MAX77686_NORMAL; rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(rdev)) { + int ret = PTR_ERR(rdev); dev_err(&pdev->dev, - "regulator init failed for %d\n", i); - return PTR_ERR(rdev); + "regulator init failed for %d: %d\n", i, ret); + return ret; } } -- cgit v1.2.3 From 8f73110f6bac043026bc923b0a66abe24dd48058 Mon Sep 17 00:00:00 2001 From: Romain Perier Date: Tue, 25 Nov 2014 12:28:25 +0000 Subject: of: Rename "poweroff-source" property to "system-power-controller" It reverts commit a4b4e0461ec5 ("of: Add standard property for poweroff capability"). As discussed on the mailing list, it makes more sense to rename back to the old established property name, without the vendor prefix. Problem being that the word "source" usually tends to be used for inputs and that is out of control of the OS. The poweroff capability is an output which simply turns the system-power off. Also, this property might be used by drivers which power-off the system and power back on subsequent RTC alarms. This seems to suggest to remove "poweroff" from the property name and to choose "system-power-controller" as the more generic name. This patchs adds the required renaming changes and defines an helper function which checks if this property is set. Signed-off-by: Romain Perier Acked-by: Grant Likely Acked-by: Johan Hovold Signed-off-by: Mark Brown --- .../devicetree/bindings/power/power-controller.txt | 18 ++++++++++++++++++ Documentation/devicetree/bindings/power/poweroff.txt | 18 ------------------ .../bindings/regulator/act8865-regulator.txt | 4 ++-- drivers/regulator/act8865-regulator.c | 2 +- include/linux/of.h | 6 +++--- 5 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/power-controller.txt delete mode 100644 Documentation/devicetree/bindings/power/poweroff.txt (limited to 'drivers/regulator') diff --git a/Documentation/devicetree/bindings/power/power-controller.txt b/Documentation/devicetree/bindings/power/power-controller.txt new file mode 100644 index 000000000000..845868bf3273 --- /dev/null +++ b/Documentation/devicetree/bindings/power/power-controller.txt @@ -0,0 +1,18 @@ +* Generic Poweroff capability + +Power-management integrated circuits or miscellaneous harware components are +sometimes able to control the system power. The device driver associated to these +components might needs to define poweroff capability, which tells to the kernel +how to switch off the system. The corresponding driver must have the standard +property "poweroff-source" in its device node. This property marks the device as +able to shutdown the system. In order to test if this property is found +programmatically, use the helper function "of_system_has_poweroff_source" from +of.h . + +Example: + +act8846: act8846@5 { + compatible = "active-semi,act8846"; + status = "okay"; + poweroff-source; +} diff --git a/Documentation/devicetree/bindings/power/poweroff.txt b/Documentation/devicetree/bindings/power/poweroff.txt deleted file mode 100644 index 845868bf3273..000000000000 --- a/Documentation/devicetree/bindings/power/poweroff.txt +++ /dev/null @@ -1,18 +0,0 @@ -* Generic Poweroff capability - -Power-management integrated circuits or miscellaneous harware components are -sometimes able to control the system power. The device driver associated to these -components might needs to define poweroff capability, which tells to the kernel -how to switch off the system. The corresponding driver must have the standard -property "poweroff-source" in its device node. This property marks the device as -able to shutdown the system. In order to test if this property is found -programmatically, use the helper function "of_system_has_poweroff_source" from -of.h . - -Example: - -act8846: act8846@5 { - compatible = "active-semi,act8846"; - status = "okay"; - poweroff-source; -} diff --git a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt index 01a5b0766e53..dad6358074ac 100644 --- a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt @@ -6,8 +6,8 @@ Required properties: - reg: I2C slave address Optional properties: -- poweroff-source: Telling whether or not this pmic is controlling - the system power. See Documentation/devicetree/bindings/power/poweroff.txt . +- system-power-controller: Telling whether or not this pmic is controlling + the system power. See Documentation/devicetree/bindings/power/power-controller.txt . Any standard regulator properties can be used to configure the single regulator. diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c index 76301ed0f8d4..9eec453b745d 100644 --- a/drivers/regulator/act8865-regulator.c +++ b/drivers/regulator/act8865-regulator.c @@ -365,7 +365,7 @@ static int act8865_pmic_probe(struct i2c_client *client, return ret; } - if (of_system_has_poweroff_source(dev->of_node)) { + if (of_device_is_system_power_controller(dev->of_node)) { if (!pm_power_off) { act8865_i2c_client = client; act8865->off_reg = off_reg; diff --git a/include/linux/of.h b/include/linux/of.h index 27b3ba1e9e59..257677256612 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -867,14 +867,14 @@ static inline int of_changeset_update_property(struct of_changeset *ocs, extern int of_resolve_phandles(struct device_node *tree); /** - * of_system_has_poweroff_source - Tells if poweroff-source is found for device_node + * of_device_is_system_power_controller - Tells if system-power-controller is found for device_node * @np: Pointer to the given device_node * * return true if present false otherwise */ -static inline bool of_system_has_poweroff_source(const struct device_node *np) +static inline bool of_device_is_system_power_controller(const struct device_node *np) { - return of_property_read_bool(np, "poweroff-source"); + return of_property_read_bool(np, "system-power-controller"); } #endif /* _LINUX_OF_H */ -- cgit v1.2.3 From 586b1514e6f66a839612bff612ce6123a84974b3 Mon Sep 17 00:00:00 2001 From: Gyungoh Yoo Date: Tue, 2 Dec 2014 17:05:28 +0900 Subject: regulator: sky81452: Modify Device Tree structure Signed-off-by: Gyungoh Yoo Signed-off-by: Mark Brown --- drivers/regulator/sky81452-regulator.c | 45 +++++++--------------------------- 1 file changed, 9 insertions(+), 36 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/sky81452-regulator.c b/drivers/regulator/sky81452-regulator.c index 476b80a0abca..647860611916 100644 --- a/drivers/regulator/sky81452-regulator.c +++ b/drivers/regulator/sky81452-regulator.c @@ -5,9 +5,8 @@ * Author : Gyungoh Yoo * * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -52,6 +51,8 @@ static const struct regulator_linear_range sky81452_reg_ranges[] = { static const struct regulator_desc sky81452_reg = { .name = "LOUT", + .of_match = of_match_ptr("lout"), + .regulators_node = of_match_ptr("regulator"), .ops = &sky81452_reg_ops, .type = REGULATOR_VOLTAGE, .owner = THIS_MODULE, @@ -64,30 +65,6 @@ static const struct regulator_desc sky81452_reg = { .enable_mask = SKY81452_LEN, }; -#ifdef CONFIG_OF -static struct regulator_init_data *sky81452_reg_parse_dt(struct device *dev) -{ - struct regulator_init_data *init_data; - struct device_node *np; - - np = of_get_child_by_name(dev->parent->of_node, "regulator"); - if (unlikely(!np)) { - dev_err(dev, "regulator node not found"); - return NULL; - } - - init_data = of_get_regulator_init_data(dev, np); - - of_node_put(np); - return init_data; -} -#else -static struct regulator_init_data *sky81452_reg_parse_dt(struct device *dev) -{ - return ERR_PTR(-EINVAL); -} -#endif - static int sky81452_reg_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -95,20 +72,16 @@ static int sky81452_reg_probe(struct platform_device *pdev) struct regulator_config config = { }; struct regulator_dev *rdev; - if (!init_data) { - init_data = sky81452_reg_parse_dt(dev); - if (IS_ERR(init_data)) - return PTR_ERR(init_data); - } - - config.dev = dev; + config.dev = dev->parent; config.init_data = init_data; config.of_node = dev->of_node; config.regmap = dev_get_drvdata(dev->parent); rdev = devm_regulator_register(dev, &sky81452_reg, &config); - if (IS_ERR(rdev)) + if (IS_ERR(rdev)) { + dev_err(dev, "failed to register. err=%ld\n", PTR_ERR(rdev)); return PTR_ERR(rdev); + } platform_set_drvdata(pdev, rdev); @@ -126,4 +99,4 @@ module_platform_driver(sky81452_reg_driver); MODULE_DESCRIPTION("Skyworks SKY81452 Regulator driver"); MODULE_AUTHOR("Gyungoh Yoo "); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 60a2362f769cf549dc466134efe71c8bf9fbaaba Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Thu, 4 Dec 2014 19:17:17 +0900 Subject: regulator: core: Fix regualtor_ena_gpio_free not to access pin after freeing After freeing pin from regulator_ena_gpio_free, loop can access the pin. So this patch fixes not to access pin after freeing. Signed-off-by: Seung-Woo Kim Signed-off-by: Mark Brown --- drivers/regulator/core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index df2af3a11351..47a455cfe04f 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1713,6 +1713,8 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev) gpiod_put(pin->gpiod); list_del(&pin->list); kfree(pin); + rdev->ena_pin = NULL; + return; } else { pin->request_count--; } -- cgit v1.2.3