Commit 30402f97 authored by Yoshihiro Shimoda's avatar Yoshihiro Shimoda Committed by Lee Jones

regulator: bd9571mwv: rid of using struct bd9571mwv

To simplify this driver, use dev_get_regmap() and
rid of using struct bd9571mwv.
Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: default avatarMatti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent b0f87e8a
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <linux/mfd/bd9571mwv.h> #include <linux/mfd/bd9571mwv.h>
struct bd9571mwv_reg { struct bd9571mwv_reg {
struct bd9571mwv *bd; struct regmap *regmap;
/* DDR Backup Power */ /* DDR Backup Power */
u8 bkup_mode_cnt_keepon; /* from "rohm,ddr-backup-power" */ u8 bkup_mode_cnt_keepon; /* from "rohm,ddr-backup-power" */
...@@ -137,26 +137,30 @@ static const struct regulator_desc regulators[] = { ...@@ -137,26 +137,30 @@ static const struct regulator_desc regulators[] = {
}; };
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int bd9571mwv_bkup_mode_read(struct bd9571mwv *bd, unsigned int *mode) static int bd9571mwv_bkup_mode_read(struct bd9571mwv_reg *bdreg,
unsigned int *mode)
{ {
int ret; int ret;
ret = regmap_read(bd->regmap, BD9571MWV_BKUP_MODE_CNT, mode); ret = regmap_read(bdreg->regmap, BD9571MWV_BKUP_MODE_CNT, mode);
if (ret) { if (ret) {
dev_err(bd->dev, "failed to read backup mode (%d)\n", ret); dev_err(regmap_get_device(bdreg->regmap),
"failed to read backup mode (%d)\n", ret);
return ret; return ret;
} }
return 0; return 0;
} }
static int bd9571mwv_bkup_mode_write(struct bd9571mwv *bd, unsigned int mode) static int bd9571mwv_bkup_mode_write(struct bd9571mwv_reg *bdreg,
unsigned int mode)
{ {
int ret; int ret;
ret = regmap_write(bd->regmap, BD9571MWV_BKUP_MODE_CNT, mode); ret = regmap_write(bdreg->regmap, BD9571MWV_BKUP_MODE_CNT, mode);
if (ret) { if (ret) {
dev_err(bd->dev, "failed to configure backup mode 0x%x (%d)\n", dev_err(regmap_get_device(bdreg->regmap),
"failed to configure backup mode 0x%x (%d)\n",
mode, ret); mode, ret);
return ret; return ret;
} }
...@@ -194,7 +198,7 @@ static ssize_t backup_mode_store(struct device *dev, ...@@ -194,7 +198,7 @@ static ssize_t backup_mode_store(struct device *dev,
* Configure DDR Backup Mode, to change the role of the accessory power * Configure DDR Backup Mode, to change the role of the accessory power
* switch from a power switch to a wake-up switch, or vice versa * switch from a power switch to a wake-up switch, or vice versa
*/ */
ret = bd9571mwv_bkup_mode_read(bdreg->bd, &mode); ret = bd9571mwv_bkup_mode_read(bdreg, &mode);
if (ret) if (ret)
return ret; return ret;
...@@ -202,7 +206,7 @@ static ssize_t backup_mode_store(struct device *dev, ...@@ -202,7 +206,7 @@ static ssize_t backup_mode_store(struct device *dev,
if (bdreg->bkup_mode_enabled) if (bdreg->bkup_mode_enabled)
mode |= bdreg->bkup_mode_cnt_keepon; mode |= bdreg->bkup_mode_cnt_keepon;
ret = bd9571mwv_bkup_mode_write(bdreg->bd, mode); ret = bd9571mwv_bkup_mode_write(bdreg, mode);
if (ret) if (ret)
return ret; return ret;
...@@ -221,7 +225,7 @@ static int bd9571mwv_suspend(struct device *dev) ...@@ -221,7 +225,7 @@ static int bd9571mwv_suspend(struct device *dev)
return 0; return 0;
/* Save DDR Backup Mode */ /* Save DDR Backup Mode */
ret = bd9571mwv_bkup_mode_read(bdreg->bd, &mode); ret = bd9571mwv_bkup_mode_read(bdreg, &mode);
if (ret) if (ret)
return ret; return ret;
...@@ -235,7 +239,7 @@ static int bd9571mwv_suspend(struct device *dev) ...@@ -235,7 +239,7 @@ static int bd9571mwv_suspend(struct device *dev)
mode |= bdreg->bkup_mode_cnt_keepon; mode |= bdreg->bkup_mode_cnt_keepon;
if (mode != bdreg->bkup_mode_cnt_saved) if (mode != bdreg->bkup_mode_cnt_saved)
return bd9571mwv_bkup_mode_write(bdreg->bd, mode); return bd9571mwv_bkup_mode_write(bdreg, mode);
return 0; return 0;
} }
...@@ -248,7 +252,7 @@ static int bd9571mwv_resume(struct device *dev) ...@@ -248,7 +252,7 @@ static int bd9571mwv_resume(struct device *dev)
return 0; return 0;
/* Restore DDR Backup Mode */ /* Restore DDR Backup Mode */
return bd9571mwv_bkup_mode_write(bdreg->bd, bdreg->bkup_mode_cnt_saved); return bd9571mwv_bkup_mode_write(bdreg, bdreg->bkup_mode_cnt_saved);
} }
static const struct dev_pm_ops bd9571mwv_pm = { static const struct dev_pm_ops bd9571mwv_pm = {
...@@ -268,7 +272,6 @@ static int bd9571mwv_regulator_remove(struct platform_device *pdev) ...@@ -268,7 +272,6 @@ static int bd9571mwv_regulator_remove(struct platform_device *pdev)
static int bd9571mwv_regulator_probe(struct platform_device *pdev) static int bd9571mwv_regulator_probe(struct platform_device *pdev)
{ {
struct bd9571mwv *bd = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = { }; struct regulator_config config = { };
struct bd9571mwv_reg *bdreg; struct bd9571mwv_reg *bdreg;
struct regulator_dev *rdev; struct regulator_dev *rdev;
...@@ -279,40 +282,40 @@ static int bd9571mwv_regulator_probe(struct platform_device *pdev) ...@@ -279,40 +282,40 @@ static int bd9571mwv_regulator_probe(struct platform_device *pdev)
if (!bdreg) if (!bdreg)
return -ENOMEM; return -ENOMEM;
bdreg->bd = bd; bdreg->regmap = dev_get_regmap(pdev->dev.parent, NULL);
platform_set_drvdata(pdev, bdreg); platform_set_drvdata(pdev, bdreg);
config.dev = &pdev->dev; config.dev = &pdev->dev;
config.dev->of_node = bd->dev->of_node; config.dev->of_node = pdev->dev.parent->of_node;
config.driver_data = bd; config.driver_data = bdreg;
config.regmap = bd->regmap; config.regmap = bdreg->regmap;
for (i = 0; i < ARRAY_SIZE(regulators); i++) { for (i = 0; i < ARRAY_SIZE(regulators); i++) {
rdev = devm_regulator_register(&pdev->dev, &regulators[i], rdev = devm_regulator_register(&pdev->dev, &regulators[i],
&config); &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
dev_err(bd->dev, "failed to register %s regulator\n", dev_err(&pdev->dev, "failed to register %s regulator\n",
pdev->name); pdev->name);
return PTR_ERR(rdev); return PTR_ERR(rdev);
} }
} }
val = 0; val = 0;
of_property_read_u32(bd->dev->of_node, "rohm,ddr-backup-power", &val); of_property_read_u32(config.dev->of_node, "rohm,ddr-backup-power", &val);
if (val & ~BD9571MWV_BKUP_MODE_CNT_KEEPON_MASK) { if (val & ~BD9571MWV_BKUP_MODE_CNT_KEEPON_MASK) {
dev_err(bd->dev, "invalid %s mode %u\n", dev_err(&pdev->dev, "invalid %s mode %u\n",
"rohm,ddr-backup-power", val); "rohm,ddr-backup-power", val);
return -EINVAL; return -EINVAL;
} }
bdreg->bkup_mode_cnt_keepon = val; bdreg->bkup_mode_cnt_keepon = val;
bdreg->rstbmode_level = of_property_read_bool(bd->dev->of_node, bdreg->rstbmode_level = of_property_read_bool(config.dev->of_node,
"rohm,rstbmode-level"); "rohm,rstbmode-level");
bdreg->rstbmode_pulse = of_property_read_bool(bd->dev->of_node, bdreg->rstbmode_pulse = of_property_read_bool(config.dev->of_node,
"rohm,rstbmode-pulse"); "rohm,rstbmode-pulse");
if (bdreg->rstbmode_level && bdreg->rstbmode_pulse) { if (bdreg->rstbmode_level && bdreg->rstbmode_pulse) {
dev_err(bd->dev, "only one rohm,rstbmode-* may be specified"); dev_err(&pdev->dev, "only one rohm,rstbmode-* may be specified");
return -EINVAL; return -EINVAL;
} }
......
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