mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 05:02:12 +00:00
Merge remote-tracking branches 'regulator/topic/mt6397', 'regulator/topic/of', 'regulator/topic/pv88060', 'regulator/topic/pwm' and 'regulator/topic/s2mps11' into regulator-next
This commit is contained in:
commit
41eeb34acd
@ -317,11 +317,25 @@ static int mt6397_regulator_probe(struct platform_device *pdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct platform_device_id mt6397_platform_ids[] = {
|
||||
{"mt6397-regulator", 0},
|
||||
{ /* sentinel */ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(platform, mt6397_platform_ids);
|
||||
|
||||
static const struct of_device_id mt6397_of_match[] = {
|
||||
{ .compatible = "mediatek,mt6397-regulator", },
|
||||
{ /* sentinel */ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, mt6397_of_match);
|
||||
|
||||
static struct platform_driver mt6397_regulator_driver = {
|
||||
.driver = {
|
||||
.name = "mt6397-regulator",
|
||||
.of_match_table = of_match_ptr(mt6397_of_match),
|
||||
},
|
||||
.probe = mt6397_regulator_probe,
|
||||
.id_table = mt6397_platform_ids,
|
||||
};
|
||||
|
||||
module_platform_driver(mt6397_regulator_driver);
|
||||
@ -329,4 +343,3 @@ module_platform_driver(mt6397_regulator_driver);
|
||||
MODULE_AUTHOR("Flora Fu <flora.fu@mediatek.com>");
|
||||
MODULE_DESCRIPTION("Regulator Driver for MediaTek MT6397 PMIC");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_ALIAS("platform:mt6397-regulator");
|
||||
|
@ -28,7 +28,6 @@ static void of_get_regulation_constraints(struct device_node *np,
|
||||
struct regulator_init_data **init_data,
|
||||
const struct regulator_desc *desc)
|
||||
{
|
||||
const __be32 *min_uV, *max_uV;
|
||||
struct regulation_constraints *constraints = &(*init_data)->constraints;
|
||||
struct regulator_state *suspend_state;
|
||||
struct device_node *suspend_np;
|
||||
@ -37,18 +36,18 @@ static void of_get_regulation_constraints(struct device_node *np,
|
||||
|
||||
constraints->name = of_get_property(np, "regulator-name", NULL);
|
||||
|
||||
min_uV = of_get_property(np, "regulator-min-microvolt", NULL);
|
||||
if (min_uV)
|
||||
constraints->min_uV = be32_to_cpu(*min_uV);
|
||||
max_uV = of_get_property(np, "regulator-max-microvolt", NULL);
|
||||
if (max_uV)
|
||||
constraints->max_uV = be32_to_cpu(*max_uV);
|
||||
if (!of_property_read_u32(np, "regulator-min-microvolt", &pval))
|
||||
constraints->min_uV = pval;
|
||||
|
||||
if (!of_property_read_u32(np, "regulator-max-microvolt", &pval))
|
||||
constraints->max_uV = pval;
|
||||
|
||||
/* Voltage change possible? */
|
||||
if (constraints->min_uV != constraints->max_uV)
|
||||
constraints->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE;
|
||||
/* Only one voltage? Then make sure it's set. */
|
||||
if (min_uV && max_uV && constraints->min_uV == constraints->max_uV)
|
||||
if (constraints->min_uV && constraints->max_uV &&
|
||||
constraints->min_uV == constraints->max_uV)
|
||||
constraints->apply_uV = true;
|
||||
|
||||
if (!of_property_read_u32(np, "regulator-microvolt-offset", &pval))
|
||||
|
@ -285,8 +285,8 @@ static irqreturn_t pv88060_irq_handler(int irq, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
err = regmap_update_bits(chip->regmap, PV88060_REG_EVENT_A,
|
||||
PV88060_E_VDD_FLT, PV88060_E_VDD_FLT);
|
||||
err = regmap_write(chip->regmap, PV88060_REG_EVENT_A,
|
||||
PV88060_E_VDD_FLT);
|
||||
if (err < 0)
|
||||
goto error_i2c;
|
||||
|
||||
@ -302,8 +302,8 @@ static irqreturn_t pv88060_irq_handler(int irq, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
err = regmap_update_bits(chip->regmap, PV88060_REG_EVENT_A,
|
||||
PV88060_E_OVER_TEMP, PV88060_E_OVER_TEMP);
|
||||
err = regmap_write(chip->regmap, PV88060_REG_EVENT_A,
|
||||
PV88060_E_OVER_TEMP);
|
||||
if (err < 0)
|
||||
goto error_i2c;
|
||||
|
||||
|
@ -27,6 +27,13 @@ struct pwm_regulator_data {
|
||||
|
||||
/* Voltage table */
|
||||
struct pwm_voltages *duty_cycle_table;
|
||||
|
||||
/* regulator descriptor */
|
||||
struct regulator_desc desc;
|
||||
|
||||
/* Regulator ops */
|
||||
struct regulator_ops ops;
|
||||
|
||||
int state;
|
||||
|
||||
/* Continuous voltage */
|
||||
@ -115,7 +122,7 @@ static int pwm_voltage_to_duty_cycle_percentage(struct regulator_dev *rdev, int
|
||||
int max_uV = rdev->constraints->max_uV;
|
||||
int diff = max_uV - min_uV;
|
||||
|
||||
return 100 - (((req_uV * 100) - (min_uV * 100)) / diff);
|
||||
return ((req_uV * 100) - (min_uV * 100)) / diff;
|
||||
}
|
||||
|
||||
static int pwm_regulator_get_voltage(struct regulator_dev *rdev)
|
||||
@ -212,8 +219,10 @@ static int pwm_regulator_init_table(struct platform_device *pdev,
|
||||
}
|
||||
|
||||
drvdata->duty_cycle_table = duty_cycle_table;
|
||||
pwm_regulator_desc.ops = &pwm_regulator_voltage_table_ops;
|
||||
pwm_regulator_desc.n_voltages = length / sizeof(*duty_cycle_table);
|
||||
memcpy(&drvdata->ops, &pwm_regulator_voltage_table_ops,
|
||||
sizeof(drvdata->ops));
|
||||
drvdata->desc.ops = &drvdata->ops;
|
||||
drvdata->desc.n_voltages = length / sizeof(*duty_cycle_table);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -221,8 +230,10 @@ static int pwm_regulator_init_table(struct platform_device *pdev,
|
||||
static int pwm_regulator_init_continuous(struct platform_device *pdev,
|
||||
struct pwm_regulator_data *drvdata)
|
||||
{
|
||||
pwm_regulator_desc.ops = &pwm_regulator_voltage_continuous_ops;
|
||||
pwm_regulator_desc.continuous_voltage_range = true;
|
||||
memcpy(&drvdata->ops, &pwm_regulator_voltage_continuous_ops,
|
||||
sizeof(drvdata->ops));
|
||||
drvdata->desc.ops = &drvdata->ops;
|
||||
drvdata->desc.continuous_voltage_range = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -245,6 +256,8 @@ static int pwm_regulator_probe(struct platform_device *pdev)
|
||||
if (!drvdata)
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy(&drvdata->desc, &pwm_regulator_desc, sizeof(drvdata->desc));
|
||||
|
||||
if (of_find_property(np, "voltage-table", NULL))
|
||||
ret = pwm_regulator_init_table(pdev, drvdata);
|
||||
else
|
||||
@ -253,7 +266,7 @@ static int pwm_regulator_probe(struct platform_device *pdev)
|
||||
return ret;
|
||||
|
||||
init_data = of_get_regulator_init_data(&pdev->dev, np,
|
||||
&pwm_regulator_desc);
|
||||
&drvdata->desc);
|
||||
if (!init_data)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -269,10 +282,10 @@ static int pwm_regulator_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
regulator = devm_regulator_register(&pdev->dev,
|
||||
&pwm_regulator_desc, &config);
|
||||
&drvdata->desc, &config);
|
||||
if (IS_ERR(regulator)) {
|
||||
dev_err(&pdev->dev, "Failed to register regulator %s\n",
|
||||
pwm_regulator_desc.name);
|
||||
drvdata->desc.name);
|
||||
return PTR_ERR(regulator);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,6 @@
|
||||
/* The highest number of possible regulators for supported devices. */
|
||||
#define S2MPS_REGULATOR_MAX S2MPS13_REGULATOR_MAX
|
||||
struct s2mps11_info {
|
||||
unsigned int rdev_num;
|
||||
int ramp_delay2;
|
||||
int ramp_delay34;
|
||||
int ramp_delay5;
|
||||
@ -54,7 +53,10 @@ struct s2mps11_info {
|
||||
*/
|
||||
DECLARE_BITMAP(suspend_state, S2MPS_REGULATOR_MAX);
|
||||
|
||||
/* Array of size rdev_num with GPIO-s for external sleep control */
|
||||
/*
|
||||
* Array (size: number of regulators) with GPIO-s for external
|
||||
* sleep control.
|
||||
*/
|
||||
int *ext_control_gpio;
|
||||
};
|
||||
|
||||
@ -819,7 +821,8 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev,
|
||||
}
|
||||
|
||||
static int s2mps11_pmic_dt_parse(struct platform_device *pdev,
|
||||
struct of_regulator_match *rdata, struct s2mps11_info *s2mps11)
|
||||
struct of_regulator_match *rdata, struct s2mps11_info *s2mps11,
|
||||
unsigned int rdev_num)
|
||||
{
|
||||
struct device_node *reg_np;
|
||||
|
||||
@ -829,7 +832,7 @@ static int s2mps11_pmic_dt_parse(struct platform_device *pdev,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
of_regulator_match(&pdev->dev, reg_np, rdata, s2mps11->rdev_num);
|
||||
of_regulator_match(&pdev->dev, reg_np, rdata, rdev_num);
|
||||
if (s2mps11->dev_type == S2MPS14X)
|
||||
s2mps14_pmic_dt_parse_ext_control_gpio(pdev, rdata, s2mps11);
|
||||
|
||||
@ -1077,6 +1080,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
|
||||
struct of_regulator_match *rdata = NULL;
|
||||
struct regulator_config config = { };
|
||||
struct s2mps11_info *s2mps11;
|
||||
unsigned int rdev_num = 0;
|
||||
int i, ret = 0;
|
||||
const struct regulator_desc *regulators;
|
||||
|
||||
@ -1088,28 +1092,29 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
|
||||
s2mps11->dev_type = platform_get_device_id(pdev)->driver_data;
|
||||
switch (s2mps11->dev_type) {
|
||||
case S2MPS11X:
|
||||
s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators);
|
||||
rdev_num = ARRAY_SIZE(s2mps11_regulators);
|
||||
regulators = s2mps11_regulators;
|
||||
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
|
||||
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps11_regulators));
|
||||
break;
|
||||
case S2MPS13X:
|
||||
s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators);
|
||||
rdev_num = ARRAY_SIZE(s2mps13_regulators);
|
||||
regulators = s2mps13_regulators;
|
||||
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
|
||||
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps13_regulators));
|
||||
break;
|
||||
case S2MPS14X:
|
||||
s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators);
|
||||
rdev_num = ARRAY_SIZE(s2mps14_regulators);
|
||||
regulators = s2mps14_regulators;
|
||||
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
|
||||
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps14_regulators));
|
||||
break;
|
||||
case S2MPS15X:
|
||||
s2mps11->rdev_num = ARRAY_SIZE(s2mps15_regulators);
|
||||
rdev_num = ARRAY_SIZE(s2mps15_regulators);
|
||||
regulators = s2mps15_regulators;
|
||||
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps15_regulators));
|
||||
break;
|
||||
case S2MPU02:
|
||||
s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators);
|
||||
rdev_num = ARRAY_SIZE(s2mpu02_regulators);
|
||||
regulators = s2mpu02_regulators;
|
||||
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
|
||||
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mpu02_regulators));
|
||||
break;
|
||||
default:
|
||||
dev_err(&pdev->dev, "Invalid device type: %u\n",
|
||||
@ -1118,7 +1123,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev,
|
||||
sizeof(*s2mps11->ext_control_gpio) * s2mps11->rdev_num,
|
||||
sizeof(*s2mps11->ext_control_gpio) * rdev_num,
|
||||
GFP_KERNEL);
|
||||
if (!s2mps11->ext_control_gpio)
|
||||
return -ENOMEM;
|
||||
@ -1126,7 +1131,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
|
||||
* 0 is a valid GPIO so initialize all GPIO-s to negative value
|
||||
* to indicate that external control won't be used for this regulator.
|
||||
*/
|
||||
for (i = 0; i < s2mps11->rdev_num; i++)
|
||||
for (i = 0; i < rdev_num; i++)
|
||||
s2mps11->ext_control_gpio[i] = -EINVAL;
|
||||
|
||||
if (!iodev->dev->of_node) {
|
||||
@ -1140,14 +1145,14 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
|
||||
}
|
||||
}
|
||||
|
||||
rdata = kzalloc(sizeof(*rdata) * s2mps11->rdev_num, GFP_KERNEL);
|
||||
rdata = kzalloc(sizeof(*rdata) * rdev_num, GFP_KERNEL);
|
||||
if (!rdata)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < s2mps11->rdev_num; i++)
|
||||
for (i = 0; i < rdev_num; i++)
|
||||
rdata[i].name = regulators[i].name;
|
||||
|
||||
ret = s2mps11_pmic_dt_parse(pdev, rdata, s2mps11);
|
||||
ret = s2mps11_pmic_dt_parse(pdev, rdata, s2mps11, rdev_num);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -1159,7 +1164,7 @@ common_reg:
|
||||
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++) {
|
||||
for (i = 0; i < rdev_num; i++) {
|
||||
struct regulator_dev *regulator;
|
||||
|
||||
if (pdata) {
|
||||
|
Loading…
Reference in New Issue
Block a user