forked from luck/tmp_suning_uos_patched
Merge remote-tracking branches 'regulator/topic/axp20x', 'regulator/topic/da9211' and 'regulator/topic/fan53555' into regulator-next
This commit is contained in:
commit
30c5c53042
|
@ -11,6 +11,7 @@ Required properties:
|
|||
BUCKA and BUCKB.
|
||||
|
||||
Optional properties:
|
||||
- enable-gpios: platform gpio for control of BUCKA/BUCKB.
|
||||
- Any optional property defined in regulator.txt
|
||||
|
||||
Example 1) DA9211
|
||||
|
@ -27,6 +28,7 @@ Example 1) DA9211
|
|||
regulator-max-microvolt = <1570000>;
|
||||
regulator-min-microamp = <2000000>;
|
||||
regulator-max-microamp = <5000000>;
|
||||
enable-gpios = <&gpio 27 0>;
|
||||
};
|
||||
BUCKB {
|
||||
regulator-name = "VBUCKB";
|
||||
|
@ -34,11 +36,12 @@ Example 1) DA9211
|
|||
regulator-max-microvolt = <1570000>;
|
||||
regulator-min-microamp = <2000000>;
|
||||
regulator-max-microamp = <5000000>;
|
||||
enable-gpios = <&gpio 17 0>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Example 2) DA92113
|
||||
Example 2) DA9213
|
||||
pmic: da9213@68 {
|
||||
compatible = "dlg,da9213";
|
||||
reg = <0x68>;
|
||||
|
@ -51,6 +54,7 @@ Example 2) DA92113
|
|||
regulator-max-microvolt = <1570000>;
|
||||
regulator-min-microamp = <3000000>;
|
||||
regulator-max-microamp = <6000000>;
|
||||
enable-gpios = <&gpio 27 0>;
|
||||
};
|
||||
BUCKB {
|
||||
regulator-name = "VBUCKB";
|
||||
|
@ -58,6 +62,7 @@ Example 2) DA92113
|
|||
regulator-max-microvolt = <1570000>;
|
||||
regulator-min-microamp = <3000000>;
|
||||
regulator-max-microamp = <6000000>;
|
||||
enable-gpios = <&gpio 17 0>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -32,11 +32,13 @@
|
|||
|
||||
#define AXP20X_FREQ_DCDC_MASK 0x0f
|
||||
|
||||
#define AXP20X_DESC_IO(_id, _supply, _min, _max, _step, _vreg, _vmask, _ereg, \
|
||||
_emask, _enable_val, _disable_val) \
|
||||
#define AXP20X_DESC_IO(_id, _match, _supply, _min, _max, _step, _vreg, _vmask, \
|
||||
_ereg, _emask, _enable_val, _disable_val) \
|
||||
[AXP20X_##_id] = { \
|
||||
.name = #_id, \
|
||||
.supply_name = (_supply), \
|
||||
.of_match = of_match_ptr(_match), \
|
||||
.regulators_node = of_match_ptr("regulators"), \
|
||||
.type = REGULATOR_VOLTAGE, \
|
||||
.id = AXP20X_##_id, \
|
||||
.n_voltages = (((_max) - (_min)) / (_step) + 1), \
|
||||
|
@ -52,11 +54,13 @@
|
|||
.ops = &axp20x_ops, \
|
||||
}
|
||||
|
||||
#define AXP20X_DESC(_id, _supply, _min, _max, _step, _vreg, _vmask, _ereg, \
|
||||
_emask) \
|
||||
#define AXP20X_DESC(_id, _match, _supply, _min, _max, _step, _vreg, _vmask, \
|
||||
_ereg, _emask) \
|
||||
[AXP20X_##_id] = { \
|
||||
.name = #_id, \
|
||||
.supply_name = (_supply), \
|
||||
.of_match = of_match_ptr(_match), \
|
||||
.regulators_node = of_match_ptr("regulators"), \
|
||||
.type = REGULATOR_VOLTAGE, \
|
||||
.id = AXP20X_##_id, \
|
||||
.n_voltages = (((_max) - (_min)) / (_step) + 1), \
|
||||
|
@ -70,10 +74,12 @@
|
|||
.ops = &axp20x_ops, \
|
||||
}
|
||||
|
||||
#define AXP20X_DESC_FIXED(_id, _supply, _volt) \
|
||||
#define AXP20X_DESC_FIXED(_id, _match, _supply, _volt) \
|
||||
[AXP20X_##_id] = { \
|
||||
.name = #_id, \
|
||||
.supply_name = (_supply), \
|
||||
.of_match = of_match_ptr(_match), \
|
||||
.regulators_node = of_match_ptr("regulators"), \
|
||||
.type = REGULATOR_VOLTAGE, \
|
||||
.id = AXP20X_##_id, \
|
||||
.n_voltages = 1, \
|
||||
|
@ -82,10 +88,13 @@
|
|||
.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] = { \
|
||||
.name = #_id, \
|
||||
.supply_name = (_supply), \
|
||||
.of_match = of_match_ptr(_match), \
|
||||
.regulators_node = of_match_ptr("regulators"), \
|
||||
.type = REGULATOR_VOLTAGE, \
|
||||
.id = AXP20X_##_id, \
|
||||
.n_voltages = ARRAY_SIZE(_table), \
|
||||
|
@ -127,36 +136,20 @@ static struct regulator_ops axp20x_ops = {
|
|||
};
|
||||
|
||||
static const struct regulator_desc axp20x_regulators[] = {
|
||||
AXP20X_DESC(DCDC2, "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT, 0x3f,
|
||||
AXP20X_PWR_OUT_CTRL, 0x10),
|
||||
AXP20X_DESC(DCDC3, "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT, 0x7f,
|
||||
AXP20X_PWR_OUT_CTRL, 0x02),
|
||||
AXP20X_DESC_FIXED(LDO1, "acin", 1300),
|
||||
AXP20X_DESC(LDO2, "ldo24in", 1800, 3300, 100, AXP20X_LDO24_V_OUT, 0xf0,
|
||||
AXP20X_PWR_OUT_CTRL, 0x04),
|
||||
AXP20X_DESC(LDO3, "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT, 0x7f,
|
||||
AXP20X_PWR_OUT_CTRL, 0x40),
|
||||
AXP20X_DESC_TABLE(LDO4, "ldo24in", axp20x_ldo4_data, AXP20X_LDO24_V_OUT, 0x0f,
|
||||
AXP20X_PWR_OUT_CTRL, 0x08),
|
||||
AXP20X_DESC_IO(LDO5, "ldo5in", 1800, 3300, 100, AXP20X_LDO5_V_OUT, 0xf0,
|
||||
AXP20X_GPIO0_CTRL, 0x07, 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),
|
||||
AXP20X_DESC(DCDC2, "dcdc2", "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT,
|
||||
0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
|
||||
AXP20X_DESC(DCDC3, "dcdc3", "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT,
|
||||
0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
|
||||
AXP20X_DESC_FIXED(LDO1, "ldo1", "acin", 1300),
|
||||
AXP20X_DESC(LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
|
||||
AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
|
||||
AXP20X_DESC(LDO3, "ldo3", "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT,
|
||||
0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
|
||||
AXP20X_DESC_TABLE(LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
|
||||
AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
|
||||
AXP20X_DESC_IO(LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
|
||||
AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
|
||||
AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
|
||||
};
|
||||
|
||||
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)
|
|||
if (!regulators) {
|
||||
dev_warn(&pdev->dev, "regulators node not found\n");
|
||||
} 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;
|
||||
of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
|
||||
ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
|
||||
|
@ -233,23 +219,17 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
|
|||
{
|
||||
struct regulator_dev *rdev;
|
||||
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
|
||||
struct regulator_config config = { };
|
||||
struct regulator_init_data *init_data;
|
||||
struct regulator_config config = {
|
||||
.dev = pdev->dev.parent,
|
||||
.regmap = axp20x->regmap,
|
||||
};
|
||||
int ret, i;
|
||||
u32 workmode;
|
||||
|
||||
ret = axp20x_regulator_parse_dt(pdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
/* This only sets the dcdc freq. Ignore any errors */
|
||||
axp20x_regulator_parse_dt(pdev);
|
||||
|
||||
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],
|
||||
&config);
|
||||
if (IS_ERR(rdev)) {
|
||||
|
@ -259,7 +239,8 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
|
|||
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);
|
||||
if (!ret) {
|
||||
if (axp20x_set_dcdc_workmode(rdev, i, workmode))
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <linux/regmap.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/regulator/of_regulator.h>
|
||||
#include <linux/regulator/da9211.h>
|
||||
#include "da9211-regulator.h"
|
||||
|
@ -276,7 +277,10 @@ static struct da9211_pdata *da9211_parse_regulators_dt(
|
|||
continue;
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
|
@ -364,7 +368,15 @@ static int da9211_regulator_init(struct da9211 *chip)
|
|||
config.dev = chip->dev;
|
||||
config.driver_data = chip;
|
||||
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,
|
||||
&da9211_regulators[i], &config);
|
||||
|
|
|
@ -147,7 +147,7 @@ static unsigned int fan53555_get_mode(struct regulator_dev *rdev)
|
|||
return REGULATOR_MODE_NORMAL;
|
||||
}
|
||||
|
||||
static int slew_rates[] = {
|
||||
static const int slew_rates[] = {
|
||||
64000,
|
||||
32000,
|
||||
16000,
|
||||
|
@ -296,7 +296,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
|
|||
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,
|
||||
.val_bits = 8,
|
||||
};
|
||||
|
|
|
@ -32,6 +32,8 @@ struct da9211_pdata {
|
|||
* 2 : 2 phase 2 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];
|
||||
};
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user