From 2c652a98ca556cca7749c184f0246315367bfad4 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Wed, 2 Sep 2015 15:46:51 -0700 Subject: regulator: qcom_smd: Handle big endian CPUs The smd rpm structures are always in little endian, but this driver is not capable of being used on big endian CPUs. Annotate the little endian data members and update the code to do the proper byte swapping. Signed-off-by: Stephen Boyd Signed-off-by: Mark Brown --- drivers/regulator/qcom_smd-regulator.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c index 9c6167dd2c8b..b72c693e29ff 100644 --- a/drivers/regulator/qcom_smd-regulator.c +++ b/drivers/regulator/qcom_smd-regulator.c @@ -36,9 +36,9 @@ struct qcom_rpm_reg { }; struct rpm_regulator_req { - u32 key; - u32 nbytes; - u32 value; + __le32 key; + __le32 nbytes; + __le32 value; }; #define RPM_KEY_SWEN 0x6e657773 /* "swen" */ @@ -62,9 +62,9 @@ static int rpm_reg_enable(struct regulator_dev *rdev) struct rpm_regulator_req req; int ret; - req.key = RPM_KEY_SWEN; - req.nbytes = sizeof(u32); - req.value = 1; + req.key = cpu_to_le32(RPM_KEY_SWEN); + req.nbytes = cpu_to_le32(sizeof(u32)); + req.value = cpu_to_le32(1); ret = rpm_reg_write_active(vreg, &req, sizeof(req)); if (!ret) @@ -86,8 +86,8 @@ static int rpm_reg_disable(struct regulator_dev *rdev) struct rpm_regulator_req req; int ret; - req.key = RPM_KEY_SWEN; - req.nbytes = sizeof(u32); + req.key = cpu_to_le32(RPM_KEY_SWEN); + req.nbytes = cpu_to_le32(sizeof(u32)); req.value = 0; ret = rpm_reg_write_active(vreg, &req, sizeof(req)); @@ -113,9 +113,9 @@ static int rpm_reg_set_voltage(struct regulator_dev *rdev, struct rpm_regulator_req req; int ret = 0; - req.key = RPM_KEY_UV; - req.nbytes = sizeof(u32); - req.value = min_uV; + req.key = cpu_to_le32(RPM_KEY_UV); + req.nbytes = cpu_to_le32(sizeof(u32)); + req.value = cpu_to_le32(min_uV); ret = rpm_reg_write_active(vreg, &req, sizeof(req)); if (!ret) @@ -129,9 +129,9 @@ static int rpm_reg_set_load(struct regulator_dev *rdev, int load_uA) struct qcom_rpm_reg *vreg = rdev_get_drvdata(rdev); struct rpm_regulator_req req; - req.key = RPM_KEY_MA; - req.nbytes = sizeof(u32); - req.value = load_uA; + req.key = cpu_to_le32(RPM_KEY_MA); + req.nbytes = cpu_to_le32(sizeof(u32)); + req.value = cpu_to_le32(load_uA); return rpm_reg_write_active(vreg, &req, sizeof(req)); } -- cgit v1.2.3 From b263d20373d7726dd3ac0cd5e32f123e69a02847 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Tue, 18 Aug 2015 15:14:06 -0700 Subject: regulator: Introduce property to flag set-load support Introduce "regulator-allow-set-load" property to make it possible to flag in the board configuration that a regulator is allowed to have the load requirements changed. Signed-off-by: Bjorn Andersson Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/regulator/regulator.txt | 1 + drivers/regulator/of_regulator.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt index 24bd422cecd5..1d112fc456aa 100644 --- a/Documentation/devicetree/bindings/regulator/regulator.txt +++ b/Documentation/devicetree/bindings/regulator/regulator.txt @@ -11,6 +11,7 @@ Optional properties: - regulator-always-on: boolean, regulator should never be disabled - regulator-boot-on: bootloader/firmware enabled regulator - regulator-allow-bypass: allow the regulator to go into bypass mode +- regulator-allow-set-load: allow the regulator performance level to be configured - -supply: phandle to the parent supply/regulator node - regulator-ramp-delay: ramp delay for regulator(in uV/uS) For hardware which supports disabling ramp rate, it should be explicitly diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 250700c853bf..499e437c7e91 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -76,6 +76,9 @@ static void of_get_regulation_constraints(struct device_node *np, if (of_property_read_bool(np, "regulator-allow-bypass")) constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS; + if (of_property_read_bool(np, "regulator-allow-set-load")) + constraints->valid_ops_mask |= REGULATOR_CHANGE_DRMS; + ret = of_property_read_u32(np, "regulator-ramp-delay", &pval); if (!ret) { if (pval) -- cgit v1.2.3 From 1de7d80246a047edaa4ea7de225437571a3aec34 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Mon, 21 Sep 2015 11:33:28 +0200 Subject: regulator: pwm: implement ->enable(), ->disable() and ->is_enabled methods Implement the ->enable(), ->disable() and ->is_enabled methods and remove the PWM call in ->set_voltage_sel(). This is particularly important for critical regulators tagged as always-on, because not claiming the PWM (and its dependencies) might lead to unpredictable behavior (like a system hang because the PWM clk is only claimed when the PWM device is enabled). Signed-off-by: Boris Brezillon Signed-off-by: Mark Brown --- drivers/regulator/pwm-regulator.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index fc3166dfcbfa..3aca067b9901 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -69,12 +69,6 @@ static int pwm_regulator_set_voltage_sel(struct regulator_dev *rdev, drvdata->state = selector; - ret = pwm_enable(drvdata->pwm); - if (ret) { - dev_err(&rdev->dev, "Failed to enable PWM\n"); - return ret; - } - return 0; } @@ -89,6 +83,29 @@ static int pwm_regulator_list_voltage(struct regulator_dev *rdev, return drvdata->duty_cycle_table[selector].uV; } +static int pwm_regulator_enable(struct regulator_dev *dev) +{ + struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); + + return pwm_enable(drvdata->pwm); +} + +static int pwm_regulator_disable(struct regulator_dev *dev) +{ + struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); + + pwm_disable(drvdata->pwm); + + return 0; +} + +static int pwm_regulator_is_enabled(struct regulator_dev *dev) +{ + struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); + + return pwm_is_enabled(drvdata->pwm); +} + /** * Continuous voltage call-backs */ @@ -144,11 +161,17 @@ static struct regulator_ops pwm_regulator_voltage_table_ops = { .get_voltage_sel = pwm_regulator_get_voltage_sel, .list_voltage = pwm_regulator_list_voltage, .map_voltage = regulator_map_voltage_iterate, + .enable = pwm_regulator_enable, + .disable = pwm_regulator_disable, + .is_enabled = pwm_regulator_is_enabled, }; static struct regulator_ops pwm_regulator_voltage_continuous_ops = { .get_voltage = pwm_regulator_get_voltage, .set_voltage = pwm_regulator_set_voltage, + .enable = pwm_regulator_enable, + .disable = pwm_regulator_disable, + .is_enabled = pwm_regulator_is_enabled, }; static struct regulator_desc pwm_regulator_desc = { -- cgit v1.2.3 From f40eb916aae018e6133f338503eafdc0e80bec27 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 5 Oct 2015 17:07:23 +0200 Subject: regulator: max77802: Add input supply properties to DT binding doc The max77802 regulator driver defines the supply name for each regulator so these can be described in DT but is not mentioned in the binding doc. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- .../devicetree/bindings/regulator/max77802.txt | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/regulator/max77802.txt b/Documentation/devicetree/bindings/regulator/max77802.txt index 79e5476444f7..b466689c47ea 100644 --- a/Documentation/devicetree/bindings/regulator/max77802.txt +++ b/Documentation/devicetree/bindings/regulator/max77802.txt @@ -8,7 +8,26 @@ regulators that can be controlled over I2C. Following properties should be present in main device node of the MFD chip. -Optional node: +Optional properties: +- inb1-supply: The input supply for BUCK1 +- inb2-supply: The input supply for BUCK2 +- inb3-supply: The input supply for BUCK3 +- inb4-supply: The input supply for BUCK4 +- inb5-supply: The input supply for BUCK5 +- inb6-supply: The input supply for BUCK6 +- inb7-supply: The input supply for BUCK7 +- inb8-supply: The input supply for BUCK8 +- inb9-supply: The input supply for BUCK9 +- inb10-supply: The input supply for BUCK10 +- inl1-supply: The input supply for LDO8 and LDO15 +- inl2-supply: The input supply for LDO17, LDO27, LDO30 and LDO35 +- inl3-supply: The input supply for LDO3, LDO5, LDO6 and LDO7 +- inl4-supply: The input supply for LDO10, LDO11, LDO13 and LDO14 +- inl5-supply: The input supply for LDO9 and LDO19 +- inl6-supply: The input supply for LDO4, LDO21, LDO24 and LDO33 +- inl7-supply: The input supply for LDO18, LDO20, LDO28 and LDO29 +- inl9-supply: The input supply for LDO12, LDO23, LDO25, LDO26, LDO32 and LDO34 +- inl10-supply: The input supply for LDO1 and LDO2 - regulators : The regulators of max77802 have to be instantiated under subnode named "regulators" using the following format. @@ -58,6 +77,8 @@ Example: #address-cells = <1>; #size-cells = <0>; + inb1-supply = <&parent_reg>; + regulators { ldo1_reg: LDO1 { regulator-name = "vdd_1v0"; -- cgit v1.2.3 From 45d5ea48e1d4dc3b9df2e37aebaa4e97c52a7f2c Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 5 Oct 2015 19:35:24 +0200 Subject: regulator: max77802: Separate sections for nodes and properties The optional "regulators" is a node and not a property so it should not be in the "Optional properties" section but in an "Optional nodes" one. Suggested-by: Rob Herring Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/regulator/max77802.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/max77802.txt b/Documentation/devicetree/bindings/regulator/max77802.txt index b466689c47ea..09d796ed48be 100644 --- a/Documentation/devicetree/bindings/regulator/max77802.txt +++ b/Documentation/devicetree/bindings/regulator/max77802.txt @@ -28,6 +28,8 @@ Optional properties: - inl7-supply: The input supply for LDO18, LDO20, LDO28 and LDO29 - inl9-supply: The input supply for LDO12, LDO23, LDO25, LDO26, LDO32 and LDO34 - inl10-supply: The input supply for LDO1 and LDO2 + +Optional nodes: - regulators : The regulators of max77802 have to be instantiated under subnode named "regulators" using the following format. -- cgit v1.2.3 From a3e123c1c4dc97b52bfcf57213eefbee9443a9bd Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Mon, 12 Oct 2015 17:49:52 -0700 Subject: regulator: qcom-smd: Correct set_load() unit The set_load() op deals with uA while the SMD packets used mA, so convert as we're building the packet. Signed-off-by: Bjorn Andersson Signed-off-by: Mark Brown --- drivers/regulator/qcom_smd-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c index b72c693e29ff..6fa0c7d13290 100644 --- a/drivers/regulator/qcom_smd-regulator.c +++ b/drivers/regulator/qcom_smd-regulator.c @@ -131,7 +131,7 @@ static int rpm_reg_set_load(struct regulator_dev *rdev, int load_uA) req.key = cpu_to_le32(RPM_KEY_MA); req.nbytes = cpu_to_le32(sizeof(u32)); - req.value = cpu_to_le32(load_uA); + req.value = cpu_to_le32(load_uA / 1000); return rpm_reg_write_active(vreg, &req, sizeof(req)); } -- cgit v1.2.3 From 4049dc1a43d1530eb462ec42201335e7b0439a80 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Mon, 12 Oct 2015 17:27:08 +0100 Subject: regulator: stw481x: compile on COMPILE_TEST The driver depends on MFD_STW481X but there isn't a build dependency so it's a good idea to allow the driver to always be built when the COMPILE_TEST option is enabled. That way, the driver can be built with a config generated by make allyesconfig and check if a patch would break the build. Signed-off-by: Luis de Bethencourt Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 64bccff557be..8df0b0e62976 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -627,7 +627,7 @@ config REGULATOR_TI_ABB config REGULATOR_STW481X_VMMC bool "ST Microelectronics STW481X VMMC regulator" - depends on MFD_STW481X + depends on MFD_STW481X || COMPILE_TEST default y if MFD_STW481X help This driver supports the internal VMMC regulator in the STw481x -- cgit v1.2.3