regulator: pbias: Fix is_enabled callback implementation
PATCH v2 1/2 regulator: pbias: Fix is_enabled callback implementation
The is_enabled implementation is wrong in some cases:
e.g. for pbias_mmc_omap5: enable_mask is : BIT(27) | BIT(25) | BIT(26) However, pbias_regulator_enable() only sets BIT(27) | BIT(26) bits. So is_enabled callback will always return false in this case. Fix the logic to compare the register value with info->enable rather than info->enable_mask.
---
v2: Update commit log and add Balaji's Ack.
drivers/regulator/pbias-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/pbias-regulator.c +1 -1
@@ -108,7 +108,7 @@ static int pbias_regulator_is_enable(struct regulator_dev *rdev)regmap_read (data->syscon, data->pbias_reg, &value); -return (value & info->enable_mask) == info->enable_mask; +return (value & info->enable_mask) == info->enable; }static struct regulator_ops pbias_regulator_voltage_ops = {
Signature · 1 line
1.8.1.2
PATCH v2 2/2 regulator: pbias: Convert to use regmap helper functions
This patch converts this driver to use the regmap helper functions provided by regulator core.
---
v2: Add Balaji's Ack.
drivers/regulator/pbias-regulator.c | 74 ++++++++++--------------------------- 1 file changed, 19 insertions(+), 55 deletions(-)
drivers/regulator/pbias-regulator.c +19 -55
@@ -38,66 +38,24 @@ struct pbias_reg_info {struct pbias_regulator_data {struct regulator_desc desc;void __iomem *pbias_addr; -unsigned int pbias_reg;struct regulator_dev *dev;struct regmap *syscon;const struct pbias_reg_info *info;int voltage; }; -static int pbias_regulator_set_voltage (struct regulator_dev *dev, -int min_uV,int max_uV,unsigned *selector) -{ -struct pbias_regulator_data *data =rdev_get_drvdata (dev); -const struct pbias_reg_info *info = data->info; -int ret, vmode; - -if (min_uV <=1800000 ) - vmode =0 ; -else if (min_uV >1800000 ) - vmode = info->vmode; - - ret =regmap_update_bits (data->syscon, data->pbias_reg, - info->vmode, vmode); - -return ret; -} - -static int pbias_regulator_get_voltage (struct regulator_dev *rdev) -{ -struct pbias_regulator_data *data =rdev_get_drvdata (rdev); -const struct pbias_reg_info *info = data->info; -int value, voltage; - -regmap_read (data->syscon, data->pbias_reg, &value); - value &= info->vmode; - - voltage = value ?3000000 :1800000 ; - -return voltage; -} +static const unsigned int pbias_volt_table[] = { +1800000 , +3000000 +};static int pbias_regulator_enable (struct regulator_dev *rdev) {struct pbias_regulator_data *data =rdev_get_drvdata (rdev);const struct pbias_reg_info *info = data->info; -int ret; - - ret =regmap_update_bits (data->syscon, data->pbias_reg, - info->enable_mask, info->enable); - -return ret; -} - -static int pbias_regulator_disable (struct regulator_dev *rdev) -{ -struct pbias_regulator_data *data =rdev_get_drvdata (rdev); -const struct pbias_reg_info *info = data->info; -int ret; - ret =regmap_update_bits (data->syscon, data->pbias_reg, - info->enable_mask,0 ); -return ret; +return regmap_update_bits (data->syscon, rdev->desc->enable_reg, + info->enable_mask, info->enable); }static int pbias_regulator_is_enable (struct regulator_dev *rdev)
@@ -106,17 +64,18 @@ static int pbias_regulator_is_enable(struct regulator_dev *rdev)const struct pbias_reg_info *info = data->info;int value; -regmap_read (data->syscon, data->pbias_reg, &value); +regmap_read (data->syscon, rdev->desc->enable_reg, &value);return (value & info->enable_mask) == info->enable; }static struct regulator_ops pbias_regulator_voltage_ops = { - .set_voltage = pbias_regulator_set_voltage, - .get_voltage = pbias_regulator_get_voltage, - .enable = pbias_regulator_enable, - .disable = pbias_regulator_disable, - .is_enabled = pbias_regulator_is_enable, + .list_voltage = regulator_list_voltage_table, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .enable = pbias_regulator_enable, + .disable = regulator_disable_regmap, + .is_enabled = pbias_regulator_is_enable, };static const struct pbias_reg_info pbias_mmc_omap2430 = {
@@ -192,6 +151,7 @@ static int pbias_regulator_probe(struct platform_device *pdev)if (IS_ERR (syscon))return PTR_ERR (syscon); + cfg.regmap = syscon; cfg.dev = &pdev->dev;for (idx =0 ; idx <PBIAS_NUM_REGS && data_idx < count; idx++) {
@@ -207,15 +167,19 @@ static int pbias_regulator_probe(struct platform_device *pdev)if (!res)return -EINVAL ; - drvdata[data_idx].pbias_reg = res->start; drvdata[data_idx].syscon = syscon; drvdata[data_idx].info = info; drvdata[data_idx].desc.name = info->name; drvdata[data_idx].desc.owner =THIS_MODULE ; drvdata[data_idx].desc.type =REGULATOR_VOLTAGE ; drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops; + drvdata[data_idx].desc.volt_table = pbias_volt_table; drvdata[data_idx].desc.n_voltages =2 ; drvdata[data_idx].desc.enable_time = info->enable_time; + drvdata[data_idx].desc.vsel_reg = res->start; + drvdata[data_idx].desc.vsel_mask = info->vmode; + drvdata[data_idx].desc.enable_reg = res->start; + drvdata[data_idx].desc.enable_mask = info->enable_mask; cfg.init_data = pbias_matches[idx].init_data; cfg.driver_data = &drvdata[data_idx];
Signature · 1 line
1.8.1.2
2014-03-08 11:55 GMT+08:00 Axel Lin <[email protected]>:
Quoted 7 lines
The
is_enabledimplementation is wrong in some cases:
e.g. forpbias_mmc_omap5:enable_maskis : BIT(27) | BIT(25) | BIT(26) However,pbias_regulator_enable()only sets BIT(27) | BIT(26) bits. Sois_enabledcallback will always return false in this case. Fix the logic to compare the register value withinfo->enablerather thaninfo->enable_mask.
Hi Chris,
Would you pick up this patch serial?
Regards,
Axel
2014-04-02 8:26 GMT+08:00 Axel Lin <[email protected]>:
Quoted 11 lines
2014-03-08 11:55 GMT+08:00 Axel Lin <[email protected]>:
Quoted 7 lines
The
is_enabledimplementation is wrong in some cases:
e.g. forpbias_mmc_omap5:enable_maskis : BIT(27) | BIT(25) | BIT(26) However,pbias_regulator_enable()only sets BIT(27) | BIT(26) bits. Sois_enabledcallback will always return false in this case. Fix the logic to compare the register value withinfo->enablerather thaninfo->enable_mask.Hi Chris,
Would you pick up this patch serial?
I just found Chris sent a pull request for 3.15-rc1. So I'll resend this serial to Mark after 3.15-rc1 is out.
Quoted 3 lines
Regards,
Axel
Mark Brown
maintainerQuoted 2 lines · Axel Lin
I just found Chris sent a pull request for 3.15-rc1. So I'll resend this serial to Mark after 3.15-rc1 is out.
I still have it, I'll go through after -rc1. I was also kind of hoping for some review from people working on the driver but oh well.
Quoted 6 lines · Axel Lin
The
is_enabledimplementation is wrong in some cases:
e.g. forpbias_mmc_omap5:enable_maskis : BIT(27) | BIT(25) | BIT(26) However,pbias_regulator_enable()only sets BIT(27) | BIT(26) bits. Sois_enabledcallback will always return false in this case. Fix the logic to compare the register value withinfo->enablerather thaninfo->enable_mask.
Applied both, thanks.
2014-04-15 5:16 GMT+08:00 Mark Brown <[email protected]>:
Quoted 9 lines · Axel Lin
Quoted 6 lines
The
is_enabledimplementation is wrong in some cases:
e.g. forpbias_mmc_omap5:enable_maskis : BIT(27) | BIT(25) | BIT(26) However,pbias_regulator_enable()only sets BIT(27) | BIT(26) bits. Sois_enabledcallback will always return false in this case. Fix the logic to compare the register value withinfo->enablerather thaninfo->enable_mask.Applied both, thanks.
Hi Mark,
Currently these 2 commits are in topic/pbias branch.
I think commit 1cb7b43f6796
"regulator: pbias: Fix is_enabled callback implementation" is a bug fix for 3.15.
commit 60e8c1e34d3a
"regulator: pbias: Convert to use regmap helper functions" might also required for 3.15.
The reason is this commit implements .list_voltage and the mmc core calls regulator_list_voltage() in mmc_regulator_get_ocrmask().
Regards,
Axel
Mark Brown
maintainerQuoted 5 lines · Axel Lin
commit
60e8c1e34d3a
"regulator: pbias: Convert to use regmap helper functions" might also required for 3.15.
The reason is this commit implements .list_voltage and the mmc core callsregulator_list_voltage()inmmc_regulator_get_ocrmask().
Makes sense, yes.