Commit 8c7dd8bc authored by James Ban's avatar James Ban Committed by Mark Brown

regulator: da9211: Add gpio control for enable/disable of buck

This is a patch for adding gpio control about enable/disable of buck.
Signed-off-by: default avatarJames Ban <james.ban.opensource@diasemi.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 076c3b8e
...@@ -11,6 +11,7 @@ Required properties: ...@@ -11,6 +11,7 @@ Required properties:
BUCKA and BUCKB. BUCKA and BUCKB.
Optional properties: Optional properties:
- enable-gpios: platform gpio for control of BUCKA/BUCKB.
- Any optional property defined in regulator.txt - Any optional property defined in regulator.txt
Example 1) DA9211 Example 1) DA9211
...@@ -27,6 +28,7 @@ Example 1) DA9211 ...@@ -27,6 +28,7 @@ Example 1) DA9211
regulator-max-microvolt = <1570000>; regulator-max-microvolt = <1570000>;
regulator-min-microamp = <2000000>; regulator-min-microamp = <2000000>;
regulator-max-microamp = <5000000>; regulator-max-microamp = <5000000>;
enable-gpios = <&gpio 27 0>;
}; };
BUCKB { BUCKB {
regulator-name = "VBUCKB"; regulator-name = "VBUCKB";
...@@ -34,11 +36,12 @@ Example 1) DA9211 ...@@ -34,11 +36,12 @@ Example 1) DA9211
regulator-max-microvolt = <1570000>; regulator-max-microvolt = <1570000>;
regulator-min-microamp = <2000000>; regulator-min-microamp = <2000000>;
regulator-max-microamp = <5000000>; regulator-max-microamp = <5000000>;
enable-gpios = <&gpio 17 0>;
}; };
}; };
}; };
Example 2) DA92113 Example 2) DA9213
pmic: da9213@68 { pmic: da9213@68 {
compatible = "dlg,da9213"; compatible = "dlg,da9213";
reg = <0x68>; reg = <0x68>;
...@@ -51,6 +54,7 @@ Example 2) DA92113 ...@@ -51,6 +54,7 @@ Example 2) DA92113
regulator-max-microvolt = <1570000>; regulator-max-microvolt = <1570000>;
regulator-min-microamp = <3000000>; regulator-min-microamp = <3000000>;
regulator-max-microamp = <6000000>; regulator-max-microamp = <6000000>;
enable-gpios = <&gpio 27 0>;
}; };
BUCKB { BUCKB {
regulator-name = "VBUCKB"; regulator-name = "VBUCKB";
...@@ -58,6 +62,7 @@ Example 2) DA92113 ...@@ -58,6 +62,7 @@ Example 2) DA92113
regulator-max-microvolt = <1570000>; regulator-max-microvolt = <1570000>;
regulator-min-microamp = <3000000>; regulator-min-microamp = <3000000>;
regulator-max-microamp = <6000000>; regulator-max-microamp = <6000000>;
enable-gpios = <&gpio 17 0>;
}; };
}; };
}; };
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of_gpio.h>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/regulator/da9211.h> #include <linux/regulator/da9211.h>
#include "da9211-regulator.h" #include "da9211-regulator.h"
...@@ -277,6 +278,9 @@ static struct da9211_pdata *da9211_parse_regulators_dt( ...@@ -277,6 +278,9 @@ static struct da9211_pdata *da9211_parse_regulators_dt(
pdata->init_data[n] = da9211_matches[i].init_data; pdata->init_data[n] = da9211_matches[i].init_data;
pdata->reg_node[n] = da9211_matches[i].of_node; pdata->reg_node[n] = da9211_matches[i].of_node;
pdata->gpio_ren[n] =
of_get_named_gpio(da9211_matches[i].of_node,
"enable-gpios", 0);
n++; n++;
} }
...@@ -366,6 +370,14 @@ static int da9211_regulator_init(struct da9211 *chip) ...@@ -366,6 +370,14 @@ static int da9211_regulator_init(struct da9211 *chip)
config.regmap = chip->regmap; config.regmap = chip->regmap;
config.of_node = chip->pdata->reg_node[i]; config.of_node = chip->pdata->reg_node[i];
if (gpio_is_valid(chip->pdata->gpio_ren[i])) {
config.ena_gpio = chip->pdata->gpio_ren[i];
config.ena_gpio_initialized = true;
} else {
config.ena_gpio = -EINVAL;
config.ena_gpio_initialized = false;
}
chip->rdev[i] = devm_regulator_register(chip->dev, chip->rdev[i] = devm_regulator_register(chip->dev,
&da9211_regulators[i], &config); &da9211_regulators[i], &config);
if (IS_ERR(chip->rdev[i])) { if (IS_ERR(chip->rdev[i])) {
......
...@@ -32,6 +32,7 @@ struct da9211_pdata { ...@@ -32,6 +32,7 @@ struct da9211_pdata {
* 2 : 2 phase 2 buck * 2 : 2 phase 2 buck
*/ */
int num_buck; int num_buck;
int gpio_ren[DA9211_MAX_REGULATORS];
struct device_node *reg_node[DA9211_MAX_REGULATORS]; struct device_node *reg_node[DA9211_MAX_REGULATORS];
struct regulator_init_data *init_data[DA9211_MAX_REGULATORS]; struct regulator_init_data *init_data[DA9211_MAX_REGULATORS];
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment