Message ID | 1606103290-15034-1-git-send-email-hsin-hsiung.wang@mediatek.com |
---|---|
Headers | show |
Series | Add Support for MediaTek PMIC MT6359 | expand |
On Mon, Nov 23, 2020 at 11:48:07AM +0800, Hsin-Hsiung Wang wrote: > +static int mt6359_get_linear_voltage_sel(struct regulator_dev *rdev) > +{ > + struct mt6359_regulator_info *info = rdev_get_drvdata(rdev); > + int ret, regval; > + > + ret = regmap_read(rdev->regmap, info->da_vsel_reg, ®val); > + if (ret != 0) { > + dev_err(&rdev->dev, > + "Failed to get mt6359 Buck %s vsel reg: %d\n", > + info->desc.name, ret); > + return ret; > + } > + > + ret = (regval >> info->da_vsel_shift) & info->da_vsel_mask; > + > + return ret; > +} This looks like it could just be regmap_get_voltage_sel_regmap()? Otherwise the driver looks good.
Hi, On Tue, 2020-11-24 at 17:07 +0000, Mark Brown wrote: > On Mon, Nov 23, 2020 at 11:48:07AM +0800, Hsin-Hsiung Wang wrote: > > > +static int mt6359_get_linear_voltage_sel(struct regulator_dev *rdev) > > +{ > > + struct mt6359_regulator_info *info = rdev_get_drvdata(rdev); > > + int ret, regval; > > + > > + ret = regmap_read(rdev->regmap, info->da_vsel_reg, ®val); > > + if (ret != 0) { > > + dev_err(&rdev->dev, > > + "Failed to get mt6359 Buck %s vsel reg: %d\n", > > + info->desc.name, ret); > > + return ret; > > + } > > + > > + ret = (regval >> info->da_vsel_shift) & info->da_vsel_mask; > > + > > + return ret; > > +} > > This looks like it could just be regmap_get_voltage_sel_regmap()? > Otherwise the driver looks good. Thanks for the review. MT6359 regulator has sel_reg and status_reg, so we use mt6359_get_linear_voltage_sel for status_reg instead of regmap_get_voltage_sel_regmap() which uses sel_reg. Thanks.
On Tue, Dec 15, 2020 at 05:23:08PM +0800, Hsin-hsiung Wang wrote: > On Tue, 2020-11-24 at 17:07 +0000, Mark Brown wrote: > > This looks like it could just be regmap_get_voltage_sel_regmap()? > > Otherwise the driver looks good. > Thanks for the review. > MT6359 regulator has sel_reg and status_reg, so we use > mt6359_get_linear_voltage_sel for status_reg instead of > regmap_get_voltage_sel_regmap() which uses sel_reg. Is the selector register not readable? In general the rule is that the get should be reporting what was configured, the actual status should be reported separately if it can be read separately. We don't currently have a mechanism for doing that with voltage but one could be added.
Hi, On Tue, 2020-12-15 at 11:56 +0000, Mark Brown wrote: > On Tue, Dec 15, 2020 at 05:23:08PM +0800, Hsin-hsiung Wang wrote: > > On Tue, 2020-11-24 at 17:07 +0000, Mark Brown wrote: > > > > This looks like it could just be regmap_get_voltage_sel_regmap()? > > > Otherwise the driver looks good. > > > Thanks for the review. > > MT6359 regulator has sel_reg and status_reg, so we use > > mt6359_get_linear_voltage_sel for status_reg instead of > > regmap_get_voltage_sel_regmap() which uses sel_reg. > > Is the selector register not readable? In general the rule is that the > get should be reporting what was configured, the actual status should be > reported separately if it can be read separately. We don't currently > have a mechanism for doing that with voltage but one could be added. Thanks for your comments. The select register is readable, and I will update it in next patch.