Commit 30c5c530 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'regulator/topic/axp20x',...

Merge remote-tracking branches 'regulator/topic/axp20x', 'regulator/topic/da9211' and 'regulator/topic/fan53555' into regulator-next
...@@ -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>;
}; };
}; };
}; };
...@@ -32,11 +32,13 @@ ...@@ -32,11 +32,13 @@
#define AXP20X_FREQ_DCDC_MASK 0x0f #define AXP20X_FREQ_DCDC_MASK 0x0f
#define AXP20X_DESC_IO(_id, _supply, _min, _max, _step, _vreg, _vmask, _ereg, \ #define AXP20X_DESC_IO(_id, _match, _supply, _min, _max, _step, _vreg, _vmask, \
_emask, _enable_val, _disable_val) \ _ereg, _emask, _enable_val, _disable_val) \
[AXP20X_##_id] = { \ [AXP20X_##_id] = { \
.name = #_id, \ .name = #_id, \
.supply_name = (_supply), \ .supply_name = (_supply), \
.of_match = of_match_ptr(_match), \
.regulators_node = of_match_ptr("regulators"), \
.type = REGULATOR_VOLTAGE, \ .type = REGULATOR_VOLTAGE, \
.id = AXP20X_##_id, \ .id = AXP20X_##_id, \
.n_voltages = (((_max) - (_min)) / (_step) + 1), \ .n_voltages = (((_max) - (_min)) / (_step) + 1), \
...@@ -52,11 +54,13 @@ ...@@ -52,11 +54,13 @@
.ops = &axp20x_ops, \ .ops = &axp20x_ops, \
} }
#define AXP20X_DESC(_id, _supply, _min, _max, _step, _vreg, _vmask, _ereg, \ #define AXP20X_DESC(_id, _match, _supply, _min, _max, _step, _vreg, _vmask, \
_emask) \ _ereg, _emask) \
[AXP20X_##_id] = { \ [AXP20X_##_id] = { \
.name = #_id, \ .name = #_id, \
.supply_name = (_supply), \ .supply_name = (_supply), \
.of_match = of_match_ptr(_match), \
.regulators_node = of_match_ptr("regulators"), \
.type = REGULATOR_VOLTAGE, \ .type = REGULATOR_VOLTAGE, \
.id = AXP20X_##_id, \ .id = AXP20X_##_id, \
.n_voltages = (((_max) - (_min)) / (_step) + 1), \ .n_voltages = (((_max) - (_min)) / (_step) + 1), \
...@@ -70,10 +74,12 @@ ...@@ -70,10 +74,12 @@
.ops = &axp20x_ops, \ .ops = &axp20x_ops, \
} }
#define AXP20X_DESC_FIXED(_id, _supply, _volt) \ #define AXP20X_DESC_FIXED(_id, _match, _supply, _volt) \
[AXP20X_##_id] = { \ [AXP20X_##_id] = { \
.name = #_id, \ .name = #_id, \
.supply_name = (_supply), \ .supply_name = (_supply), \
.of_match = of_match_ptr(_match), \
.regulators_node = of_match_ptr("regulators"), \
.type = REGULATOR_VOLTAGE, \ .type = REGULATOR_VOLTAGE, \
.id = AXP20X_##_id, \ .id = AXP20X_##_id, \
.n_voltages = 1, \ .n_voltages = 1, \
...@@ -82,10 +88,13 @@ ...@@ -82,10 +88,13 @@
.ops = &axp20x_ops_fixed \ .ops = &axp20x_ops_fixed \
} }
#define AXP20X_DESC_TABLE(_id, _supply, _table, _vreg, _vmask, _ereg, _emask) \ #define AXP20X_DESC_TABLE(_id, _match, _supply, _table, _vreg, _vmask, _ereg, \
_emask) \
[AXP20X_##_id] = { \ [AXP20X_##_id] = { \
.name = #_id, \ .name = #_id, \
.supply_name = (_supply), \ .supply_name = (_supply), \
.of_match = of_match_ptr(_match), \
.regulators_node = of_match_ptr("regulators"), \
.type = REGULATOR_VOLTAGE, \ .type = REGULATOR_VOLTAGE, \
.id = AXP20X_##_id, \ .id = AXP20X_##_id, \
.n_voltages = ARRAY_SIZE(_table), \ .n_voltages = ARRAY_SIZE(_table), \
...@@ -127,36 +136,20 @@ static struct regulator_ops axp20x_ops = { ...@@ -127,36 +136,20 @@ static struct regulator_ops axp20x_ops = {
}; };
static const struct regulator_desc axp20x_regulators[] = { static const struct regulator_desc axp20x_regulators[] = {
AXP20X_DESC(DCDC2, "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_DESC(DCDC2, "dcdc2", "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT,
AXP20X_PWR_OUT_CTRL, 0x10), 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
AXP20X_DESC(DCDC3, "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT, 0x7f, AXP20X_DESC(DCDC3, "dcdc3", "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT,
AXP20X_PWR_OUT_CTRL, 0x02), 0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
AXP20X_DESC_FIXED(LDO1, "acin", 1300), AXP20X_DESC_FIXED(LDO1, "ldo1", "acin", 1300),
AXP20X_DESC(LDO2, "ldo24in", 1800, 3300, 100, AXP20X_LDO24_V_OUT, 0xf0, AXP20X_DESC(LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
AXP20X_PWR_OUT_CTRL, 0x04), AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
AXP20X_DESC(LDO3, "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT, 0x7f, AXP20X_DESC(LDO3, "ldo3", "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT,
AXP20X_PWR_OUT_CTRL, 0x40), 0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
AXP20X_DESC_TABLE(LDO4, "ldo24in", axp20x_ldo4_data, AXP20X_LDO24_V_OUT, 0x0f, AXP20X_DESC_TABLE(LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
AXP20X_PWR_OUT_CTRL, 0x08), AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
AXP20X_DESC_IO(LDO5, "ldo5in", 1800, 3300, 100, AXP20X_LDO5_V_OUT, 0xf0, AXP20X_DESC_IO(LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
AXP20X_GPIO0_CTRL, 0x07, AXP20X_IO_ENABLED, AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
AXP20X_IO_DISABLED), AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
};
#define AXP_MATCH(_name, _id) \
[AXP20X_##_id] = { \
.name = #_name, \
.driver_data = (void *) &axp20x_regulators[AXP20X_##_id], \
}
static struct of_regulator_match axp20x_matches[] = {
AXP_MATCH(dcdc2, DCDC2),
AXP_MATCH(dcdc3, DCDC3),
AXP_MATCH(ldo1, LDO1),
AXP_MATCH(ldo2, LDO2),
AXP_MATCH(ldo3, LDO3),
AXP_MATCH(ldo4, LDO4),
AXP_MATCH(ldo5, LDO5),
}; };
static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
...@@ -193,13 +186,6 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev) ...@@ -193,13 +186,6 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
if (!regulators) { if (!regulators) {
dev_warn(&pdev->dev, "regulators node not found\n"); dev_warn(&pdev->dev, "regulators node not found\n");
} else { } else {
ret = of_regulator_match(&pdev->dev, regulators, axp20x_matches,
ARRAY_SIZE(axp20x_matches));
if (ret < 0) {
dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret);
return ret;
}
dcdcfreq = 1500; dcdcfreq = 1500;
of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq); of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
ret = axp20x_set_dcdc_freq(pdev, dcdcfreq); ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
...@@ -233,23 +219,17 @@ static int axp20x_regulator_probe(struct platform_device *pdev) ...@@ -233,23 +219,17 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
{ {
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = { }; struct regulator_config config = {
struct regulator_init_data *init_data; .dev = pdev->dev.parent,
.regmap = axp20x->regmap,
};
int ret, i; int ret, i;
u32 workmode; u32 workmode;
ret = axp20x_regulator_parse_dt(pdev); /* This only sets the dcdc freq. Ignore any errors */
if (ret) axp20x_regulator_parse_dt(pdev);
return ret;
for (i = 0; i < AXP20X_REG_ID_MAX; i++) { for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
init_data = axp20x_matches[i].init_data;
config.dev = pdev->dev.parent;
config.init_data = init_data;
config.regmap = axp20x->regmap;
config.of_node = axp20x_matches[i].of_node;
rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i], rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i],
&config); &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
...@@ -259,7 +239,8 @@ static int axp20x_regulator_probe(struct platform_device *pdev) ...@@ -259,7 +239,8 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
return PTR_ERR(rdev); return PTR_ERR(rdev);
} }
ret = of_property_read_u32(axp20x_matches[i].of_node, "x-powers,dcdc-workmode", ret = of_property_read_u32(rdev->dev.of_node,
"x-powers,dcdc-workmode",
&workmode); &workmode);
if (!ret) { if (!ret) {
if (axp20x_set_dcdc_workmode(rdev, i, workmode)) if (axp20x_set_dcdc_workmode(rdev, i, workmode))
......
...@@ -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"
...@@ -276,7 +277,10 @@ static struct da9211_pdata *da9211_parse_regulators_dt( ...@@ -276,7 +277,10 @@ static struct da9211_pdata *da9211_parse_regulators_dt(
continue; continue;
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->gpio_ren[n] =
of_get_named_gpio(da9211_matches[i].of_node,
"enable-gpios", 0);
n++; n++;
} }
...@@ -364,7 +368,15 @@ static int da9211_regulator_init(struct da9211 *chip) ...@@ -364,7 +368,15 @@ static int da9211_regulator_init(struct da9211 *chip)
config.dev = chip->dev; config.dev = chip->dev;
config.driver_data = chip; config.driver_data = chip;
config.regmap = chip->regmap; config.regmap = chip->regmap;
config.of_node = chip->dev->of_node; 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);
......
...@@ -147,7 +147,7 @@ static unsigned int fan53555_get_mode(struct regulator_dev *rdev) ...@@ -147,7 +147,7 @@ static unsigned int fan53555_get_mode(struct regulator_dev *rdev)
return REGULATOR_MODE_NORMAL; return REGULATOR_MODE_NORMAL;
} }
static int slew_rates[] = { static const int slew_rates[] = {
64000, 64000,
32000, 32000,
16000, 16000,
...@@ -296,7 +296,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di, ...@@ -296,7 +296,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
return PTR_ERR_OR_ZERO(di->rdev); return PTR_ERR_OR_ZERO(di->rdev);
} }
static struct regmap_config fan53555_regmap_config = { static const struct regmap_config fan53555_regmap_config = {
.reg_bits = 8, .reg_bits = 8,
.val_bits = 8, .val_bits = 8,
}; };
......
...@@ -32,6 +32,8 @@ struct da9211_pdata { ...@@ -32,6 +32,8 @@ 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 regulator_init_data *init_data[DA9211_MAX_REGULATORS]; struct regulator_init_data *init_data[DA9211_MAX_REGULATORS];
}; };
#endif #endif
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