Commit bcb047eb authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: bd718x7: Remove struct bd718xx_pmic

All the fields in struct bd718xx_pmic are not really necessary.
Remove struct bd718xx_pmic to simplify the code.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Reviewed-by: default avatarMatti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 63239e4b
...@@ -15,13 +15,6 @@ ...@@ -15,13 +15,6 @@
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/slab.h> #include <linux/slab.h>
struct bd718xx_pmic {
struct bd718xx_regulator_data *rdata;
struct bd718xx *mfd;
struct platform_device *pdev;
struct regulator_dev *rdev[BD718XX_REGULATOR_AMOUNT];
};
/* /*
* BUCK1/2/3/4 * BUCK1/2/3/4
* BUCK1RAMPRATE[1:0] BUCK1 DVS ramp rate setting * BUCK1RAMPRATE[1:0] BUCK1 DVS ramp rate setting
...@@ -33,12 +26,10 @@ struct bd718xx_pmic { ...@@ -33,12 +26,10 @@ struct bd718xx_pmic {
static int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev, static int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev,
int ramp_delay) int ramp_delay)
{ {
struct bd718xx_pmic *pmic = rdev_get_drvdata(rdev);
struct bd718xx *mfd = pmic->mfd;
int id = rdev->desc->id; int id = rdev->desc->id;
unsigned int ramp_value = BUCK_RAMPRATE_10P00MV; unsigned int ramp_value = BUCK_RAMPRATE_10P00MV;
dev_dbg(&pmic->pdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1, dev_dbg(&rdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1,
ramp_delay); ramp_delay);
switch (ramp_delay) { switch (ramp_delay) {
case 1 ... 1250: case 1 ... 1250:
...@@ -55,12 +46,12 @@ static int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev, ...@@ -55,12 +46,12 @@ static int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev,
break; break;
default: default:
ramp_value = BUCK_RAMPRATE_10P00MV; ramp_value = BUCK_RAMPRATE_10P00MV;
dev_err(&pmic->pdev->dev, dev_err(&rdev->dev,
"%s: ramp_delay: %d not supported, setting 10000mV//us\n", "%s: ramp_delay: %d not supported, setting 10000mV//us\n",
rdev->desc->name, ramp_delay); rdev->desc->name, ramp_delay);
} }
return regmap_update_bits(mfd->regmap, BD718XX_REG_BUCK1_CTRL + id, return regmap_update_bits(rdev->regmap, BD718XX_REG_BUCK1_CTRL + id,
BUCK_RAMPRATE_MASK, ramp_value << 6); BUCK_RAMPRATE_MASK, ramp_value << 6);
} }
...@@ -1022,7 +1013,7 @@ struct bd718xx_pmic_inits { ...@@ -1022,7 +1013,7 @@ struct bd718xx_pmic_inits {
static int bd718xx_probe(struct platform_device *pdev) static int bd718xx_probe(struct platform_device *pdev)
{ {
struct bd718xx_pmic *pmic; struct bd718xx *mfd;
struct regulator_config config = { 0 }; struct regulator_config config = { 0 };
struct bd718xx_pmic_inits pmic_regulators[] = { struct bd718xx_pmic_inits pmic_regulators[] = {
[BD718XX_TYPE_BD71837] = { [BD718XX_TYPE_BD71837] = {
...@@ -1037,54 +1028,46 @@ static int bd718xx_probe(struct platform_device *pdev) ...@@ -1037,54 +1028,46 @@ static int bd718xx_probe(struct platform_device *pdev)
int i, j, err; int i, j, err;
pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL); mfd = dev_get_drvdata(pdev->dev.parent);
if (!pmic) if (!mfd) {
return -ENOMEM;
pmic->pdev = pdev;
pmic->mfd = dev_get_drvdata(pdev->dev.parent);
if (!pmic->mfd) {
dev_err(&pdev->dev, "No MFD driver data\n"); dev_err(&pdev->dev, "No MFD driver data\n");
err = -EINVAL; err = -EINVAL;
goto err; goto err;
} }
if (pmic->mfd->chip_type >= BD718XX_TYPE_AMOUNT ||
!pmic_regulators[pmic->mfd->chip_type].r_datas) { if (mfd->chip_type >= BD718XX_TYPE_AMOUNT ||
!pmic_regulators[mfd->chip_type].r_datas) {
dev_err(&pdev->dev, "Unsupported chip type\n"); dev_err(&pdev->dev, "Unsupported chip type\n");
err = -EINVAL; err = -EINVAL;
goto err; goto err;
} }
platform_set_drvdata(pdev, pmic);
/* Register LOCK release */ /* Register LOCK release */
err = regmap_update_bits(pmic->mfd->regmap, BD718XX_REG_REGLOCK, err = regmap_update_bits(mfd->regmap, BD718XX_REG_REGLOCK,
(REGLOCK_PWRSEQ | REGLOCK_VREG), 0); (REGLOCK_PWRSEQ | REGLOCK_VREG), 0);
if (err) { if (err) {
dev_err(&pmic->pdev->dev, "Failed to unlock PMIC (%d)\n", err); dev_err(&pdev->dev, "Failed to unlock PMIC (%d)\n", err);
goto err; goto err;
} else { } else {
dev_dbg(&pmic->pdev->dev, "Unlocked lock register 0x%x\n", dev_dbg(&pdev->dev, "Unlocked lock register 0x%x\n",
BD718XX_REG_REGLOCK); BD718XX_REG_REGLOCK);
} }
for (i = 0; i < pmic_regulators[pmic->mfd->chip_type].r_amount; i++) { for (i = 0; i < pmic_regulators[mfd->chip_type].r_amount; i++) {
const struct regulator_desc *desc; const struct regulator_desc *desc;
struct regulator_dev *rdev; struct regulator_dev *rdev;
const struct bd718xx_regulator_data *r; const struct bd718xx_regulator_data *r;
r = &(*pmic_regulators[pmic->mfd->chip_type].r_datas)[i]; r = &(*pmic_regulators[mfd->chip_type].r_datas)[i];
desc = &r->desc; desc = &r->desc;
config.dev = pdev->dev.parent; config.dev = pdev->dev.parent;
config.driver_data = pmic; config.regmap = mfd->regmap;
config.regmap = pmic->mfd->regmap;
rdev = devm_regulator_register(&pdev->dev, desc, &config); rdev = devm_regulator_register(&pdev->dev, desc, &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
dev_err(pmic->mfd->dev, dev_err(&pdev->dev,
"failed to register %s regulator\n", "failed to register %s regulator\n",
desc->name); desc->name);
err = PTR_ERR(rdev); err = PTR_ERR(rdev);
...@@ -1096,28 +1079,26 @@ static int bd718xx_probe(struct platform_device *pdev) ...@@ -1096,28 +1079,26 @@ static int bd718xx_probe(struct platform_device *pdev)
* can now switch the control from PMIC state machine to the * can now switch the control from PMIC state machine to the
* register interface * register interface
*/ */
err = regmap_update_bits(pmic->mfd->regmap, r->init.reg, err = regmap_update_bits(mfd->regmap, r->init.reg,
r->init.mask, r->init.val); r->init.mask, r->init.val);
if (err) { if (err) {
dev_err(&pmic->pdev->dev, dev_err(&pdev->dev,
"Failed to write BUCK/LDO SEL bit for (%s)\n", "Failed to write BUCK/LDO SEL bit for (%s)\n",
desc->name); desc->name);
goto err; goto err;
} }
for (j = 0; j < r->additional_init_amnt; j++) { for (j = 0; j < r->additional_init_amnt; j++) {
err = regmap_update_bits(pmic->mfd->regmap, err = regmap_update_bits(mfd->regmap,
r->additional_inits[j].reg, r->additional_inits[j].reg,
r->additional_inits[j].mask, r->additional_inits[j].mask,
r->additional_inits[j].val); r->additional_inits[j].val);
if (err) { if (err) {
dev_err(&pmic->pdev->dev, dev_err(&pdev->dev,
"Buck (%s) initialization failed\n", "Buck (%s) initialization failed\n",
desc->name); desc->name);
goto err; goto err;
} }
} }
pmic->rdev[i] = rdev;
} }
err: err:
......
...@@ -321,7 +321,6 @@ enum { ...@@ -321,7 +321,6 @@ enum {
BD718XX_PWRBTN_LONG_PRESS_15S BD718XX_PWRBTN_LONG_PRESS_15S
}; };
struct bd718xx_pmic;
struct bd718xx_clk; struct bd718xx_clk;
struct bd718xx { struct bd718xx {
...@@ -333,7 +332,6 @@ struct bd718xx { ...@@ -333,7 +332,6 @@ struct bd718xx {
int chip_irq; int chip_irq;
struct regmap_irq_chip_data *irq_data; struct regmap_irq_chip_data *irq_data;
struct bd718xx_pmic *pmic;
struct bd718xx_clk *clk; struct bd718xx_clk *clk;
}; };
......
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