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;
|
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 = {
|
static struct platform_driver mt6397_regulator_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "mt6397-regulator",
|
.name = "mt6397-regulator",
|
||||||
|
.of_match_table = of_match_ptr(mt6397_of_match),
|
||||||
},
|
},
|
||||||
.probe = mt6397_regulator_probe,
|
.probe = mt6397_regulator_probe,
|
||||||
|
.id_table = mt6397_platform_ids,
|
||||||
};
|
};
|
||||||
|
|
||||||
module_platform_driver(mt6397_regulator_driver);
|
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_AUTHOR("Flora Fu <flora.fu@mediatek.com>");
|
||||||
MODULE_DESCRIPTION("Regulator Driver for MediaTek MT6397 PMIC");
|
MODULE_DESCRIPTION("Regulator Driver for MediaTek MT6397 PMIC");
|
||||||
MODULE_LICENSE("GPL");
|
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,
|
struct regulator_init_data **init_data,
|
||||||
const struct regulator_desc *desc)
|
const struct regulator_desc *desc)
|
||||||
{
|
{
|
||||||
const __be32 *min_uV, *max_uV;
|
|
||||||
struct regulation_constraints *constraints = &(*init_data)->constraints;
|
struct regulation_constraints *constraints = &(*init_data)->constraints;
|
||||||
struct regulator_state *suspend_state;
|
struct regulator_state *suspend_state;
|
||||||
struct device_node *suspend_np;
|
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);
|
constraints->name = of_get_property(np, "regulator-name", NULL);
|
||||||
|
|
||||||
min_uV = of_get_property(np, "regulator-min-microvolt", NULL);
|
if (!of_property_read_u32(np, "regulator-min-microvolt", &pval))
|
||||||
if (min_uV)
|
constraints->min_uV = pval;
|
||||||
constraints->min_uV = be32_to_cpu(*min_uV);
|
|
||||||
max_uV = of_get_property(np, "regulator-max-microvolt", NULL);
|
if (!of_property_read_u32(np, "regulator-max-microvolt", &pval))
|
||||||
if (max_uV)
|
constraints->max_uV = pval;
|
||||||
constraints->max_uV = be32_to_cpu(*max_uV);
|
|
||||||
|
|
||||||
/* Voltage change possible? */
|
/* Voltage change possible? */
|
||||||
if (constraints->min_uV != constraints->max_uV)
|
if (constraints->min_uV != constraints->max_uV)
|
||||||
constraints->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE;
|
constraints->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE;
|
||||||
/* Only one voltage? Then make sure it's set. */
|
/* 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;
|
constraints->apply_uV = true;
|
||||||
|
|
||||||
if (!of_property_read_u32(np, "regulator-microvolt-offset", &pval))
|
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,
|
err = regmap_write(chip->regmap, PV88060_REG_EVENT_A,
|
||||||
PV88060_E_VDD_FLT, PV88060_E_VDD_FLT);
|
PV88060_E_VDD_FLT);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto error_i2c;
|
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,
|
err = regmap_write(chip->regmap, PV88060_REG_EVENT_A,
|
||||||
PV88060_E_OVER_TEMP, PV88060_E_OVER_TEMP);
|
PV88060_E_OVER_TEMP);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto error_i2c;
|
goto error_i2c;
|
||||||
|
|
||||||
|
@ -27,6 +27,13 @@ struct pwm_regulator_data {
|
|||||||
|
|
||||||
/* Voltage table */
|
/* Voltage table */
|
||||||
struct pwm_voltages *duty_cycle_table;
|
struct pwm_voltages *duty_cycle_table;
|
||||||
|
|
||||||
|
/* regulator descriptor */
|
||||||
|
struct regulator_desc desc;
|
||||||
|
|
||||||
|
/* Regulator ops */
|
||||||
|
struct regulator_ops ops;
|
||||||
|
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
/* Continuous voltage */
|
/* 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 max_uV = rdev->constraints->max_uV;
|
||||||
int diff = max_uV - min_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)
|
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;
|
drvdata->duty_cycle_table = duty_cycle_table;
|
||||||
pwm_regulator_desc.ops = &pwm_regulator_voltage_table_ops;
|
memcpy(&drvdata->ops, &pwm_regulator_voltage_table_ops,
|
||||||
pwm_regulator_desc.n_voltages = length / sizeof(*duty_cycle_table);
|
sizeof(drvdata->ops));
|
||||||
|
drvdata->desc.ops = &drvdata->ops;
|
||||||
|
drvdata->desc.n_voltages = length / sizeof(*duty_cycle_table);
|
||||||
|
|
||||||
return 0;
|
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,
|
static int pwm_regulator_init_continuous(struct platform_device *pdev,
|
||||||
struct pwm_regulator_data *drvdata)
|
struct pwm_regulator_data *drvdata)
|
||||||
{
|
{
|
||||||
pwm_regulator_desc.ops = &pwm_regulator_voltage_continuous_ops;
|
memcpy(&drvdata->ops, &pwm_regulator_voltage_continuous_ops,
|
||||||
pwm_regulator_desc.continuous_voltage_range = true;
|
sizeof(drvdata->ops));
|
||||||
|
drvdata->desc.ops = &drvdata->ops;
|
||||||
|
drvdata->desc.continuous_voltage_range = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -245,6 +256,8 @@ static int pwm_regulator_probe(struct platform_device *pdev)
|
|||||||
if (!drvdata)
|
if (!drvdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
memcpy(&drvdata->desc, &pwm_regulator_desc, sizeof(drvdata->desc));
|
||||||
|
|
||||||
if (of_find_property(np, "voltage-table", NULL))
|
if (of_find_property(np, "voltage-table", NULL))
|
||||||
ret = pwm_regulator_init_table(pdev, drvdata);
|
ret = pwm_regulator_init_table(pdev, drvdata);
|
||||||
else
|
else
|
||||||
@ -253,7 +266,7 @@ static int pwm_regulator_probe(struct platform_device *pdev)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
init_data = of_get_regulator_init_data(&pdev->dev, np,
|
init_data = of_get_regulator_init_data(&pdev->dev, np,
|
||||||
&pwm_regulator_desc);
|
&drvdata->desc);
|
||||||
if (!init_data)
|
if (!init_data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -269,10 +282,10 @@ static int pwm_regulator_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
regulator = devm_regulator_register(&pdev->dev,
|
regulator = devm_regulator_register(&pdev->dev,
|
||||||
&pwm_regulator_desc, &config);
|
&drvdata->desc, &config);
|
||||||
if (IS_ERR(regulator)) {
|
if (IS_ERR(regulator)) {
|
||||||
dev_err(&pdev->dev, "Failed to register regulator %s\n",
|
dev_err(&pdev->dev, "Failed to register regulator %s\n",
|
||||||
pwm_regulator_desc.name);
|
drvdata->desc.name);
|
||||||
return PTR_ERR(regulator);
|
return PTR_ERR(regulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
/* The highest number of possible regulators for supported devices. */
|
/* The highest number of possible regulators for supported devices. */
|
||||||
#define S2MPS_REGULATOR_MAX S2MPS13_REGULATOR_MAX
|
#define S2MPS_REGULATOR_MAX S2MPS13_REGULATOR_MAX
|
||||||
struct s2mps11_info {
|
struct s2mps11_info {
|
||||||
unsigned int rdev_num;
|
|
||||||
int ramp_delay2;
|
int ramp_delay2;
|
||||||
int ramp_delay34;
|
int ramp_delay34;
|
||||||
int ramp_delay5;
|
int ramp_delay5;
|
||||||
@ -54,7 +53,10 @@ struct s2mps11_info {
|
|||||||
*/
|
*/
|
||||||
DECLARE_BITMAP(suspend_state, S2MPS_REGULATOR_MAX);
|
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;
|
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,
|
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;
|
struct device_node *reg_np;
|
||||||
|
|
||||||
@ -829,7 +832,7 @@ static int s2mps11_pmic_dt_parse(struct platform_device *pdev,
|
|||||||
return -EINVAL;
|
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)
|
if (s2mps11->dev_type == S2MPS14X)
|
||||||
s2mps14_pmic_dt_parse_ext_control_gpio(pdev, rdata, s2mps11);
|
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 of_regulator_match *rdata = NULL;
|
||||||
struct regulator_config config = { };
|
struct regulator_config config = { };
|
||||||
struct s2mps11_info *s2mps11;
|
struct s2mps11_info *s2mps11;
|
||||||
|
unsigned int rdev_num = 0;
|
||||||
int i, ret = 0;
|
int i, ret = 0;
|
||||||
const struct regulator_desc *regulators;
|
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;
|
s2mps11->dev_type = platform_get_device_id(pdev)->driver_data;
|
||||||
switch (s2mps11->dev_type) {
|
switch (s2mps11->dev_type) {
|
||||||
case S2MPS11X:
|
case S2MPS11X:
|
||||||
s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators);
|
rdev_num = ARRAY_SIZE(s2mps11_regulators);
|
||||||
regulators = 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;
|
break;
|
||||||
case S2MPS13X:
|
case S2MPS13X:
|
||||||
s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators);
|
rdev_num = ARRAY_SIZE(s2mps13_regulators);
|
||||||
regulators = 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;
|
break;
|
||||||
case S2MPS14X:
|
case S2MPS14X:
|
||||||
s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators);
|
rdev_num = ARRAY_SIZE(s2mps14_regulators);
|
||||||
regulators = 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;
|
break;
|
||||||
case S2MPS15X:
|
case S2MPS15X:
|
||||||
s2mps11->rdev_num = ARRAY_SIZE(s2mps15_regulators);
|
rdev_num = ARRAY_SIZE(s2mps15_regulators);
|
||||||
regulators = s2mps15_regulators;
|
regulators = s2mps15_regulators;
|
||||||
|
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps15_regulators));
|
||||||
break;
|
break;
|
||||||
case S2MPU02:
|
case S2MPU02:
|
||||||
s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators);
|
rdev_num = ARRAY_SIZE(s2mpu02_regulators);
|
||||||
regulators = 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;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(&pdev->dev, "Invalid device type: %u\n",
|
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,
|
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);
|
GFP_KERNEL);
|
||||||
if (!s2mps11->ext_control_gpio)
|
if (!s2mps11->ext_control_gpio)
|
||||||
return -ENOMEM;
|
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
|
* 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.
|
* 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;
|
s2mps11->ext_control_gpio[i] = -EINVAL;
|
||||||
|
|
||||||
if (!iodev->dev->of_node) {
|
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)
|
if (!rdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
for (i = 0; i < s2mps11->rdev_num; i++)
|
for (i = 0; i < rdev_num; i++)
|
||||||
rdata[i].name = regulators[i].name;
|
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)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -1159,7 +1164,7 @@ common_reg:
|
|||||||
config.driver_data = s2mps11;
|
config.driver_data = s2mps11;
|
||||||
config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
|
config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
|
||||||
config.ena_gpio_initialized = true;
|
config.ena_gpio_initialized = true;
|
||||||
for (i = 0; i < s2mps11->rdev_num; i++) {
|
for (i = 0; i < rdev_num; i++) {
|
||||||
struct regulator_dev *regulator;
|
struct regulator_dev *regulator;
|
||||||
|
|
||||||
if (pdata) {
|
if (pdata) {
|
||||||
|
Loading…
Reference in New Issue
Block a user