[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1395392518.17194.2.camel@AMDC1943>
Date: Fri, 21 Mar 2014 10:01:58 +0100
From: Krzysztof Kozlowski <k.kozlowski@...sung.com>
To: Axel Lin <axel.lin@...ics.com>
Cc: Mark Brown <broonie@...nel.org>,
Sangbeom Kim <sbkim73@...sung.com>,
Liam Girdwood <lgirdwood@...il.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFT] regulator: s5m8767: Convert to use
regulator_[enable|disable|is_enabled]_regmap
On Fri, 2014-03-21 at 14:54 +0800, Axel Lin wrote:
> Since commit ca5d1b3524b4d
> "regulator: helpers: Modify helpers enabling multi-bit control",
> we can set enable_val setting for device that use multiple bits for control.
>
> Signed-off-by: Axel Lin <axel.lin@...ics.com>
> ---
> drivers/regulator/s5m8767.c | 78 +++++++++++----------------------------------
> 1 file changed, 19 insertions(+), 59 deletions(-)
Hi,
Works and looks great, thanks! Tested on board with S5M8767.
Tested-by: Krzysztof Kozlowski <k.kozlowski@...sung.com>
Reviewed-by Krzysztof Kozlowski <k.kozlowski@...sung.com>
Best regards,
Krzysztof
>
> diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
> index 342a66ab..f05bada 100644
> --- a/drivers/regulator/s5m8767.c
> +++ b/drivers/regulator/s5m8767.c
> @@ -167,12 +167,11 @@ static unsigned int s5m8767_opmode_reg[][4] = {
> {0x0, 0x3, 0x1, 0x1}, /* BUCK9 */
> };
>
> -static int s5m8767_get_register(struct regulator_dev *rdev, int *reg,
> - int *enable_ctrl)
> +static int s5m8767_get_register(struct s5m8767_info *s5m8767, int reg_id,
> + int *reg, int *enable_ctrl)
> {
> - int i, reg_id = rdev_get_id(rdev);
> + int i;
> unsigned int mode;
> - struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
>
> switch (reg_id) {
> case S5M8767_LDO1 ... S5M8767_LDO2:
> @@ -211,53 +210,6 @@ static int s5m8767_get_register(struct regulator_dev *rdev, int *reg,
> return 0;
> }
>
> -static int s5m8767_reg_is_enabled(struct regulator_dev *rdev)
> -{
> - struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
> - int ret, reg;
> - int enable_ctrl;
> - unsigned int val;
> -
> - ret = s5m8767_get_register(rdev, ®, &enable_ctrl);
> - if (ret == -EINVAL)
> - return 1;
> - else if (ret)
> - return ret;
> -
> - ret = regmap_read(s5m8767->iodev->regmap_pmic, reg, &val);
> - if (ret)
> - return ret;
> -
> - return (val & S5M8767_ENCTRL_MASK) == enable_ctrl;
> -}
> -
> -static int s5m8767_reg_enable(struct regulator_dev *rdev)
> -{
> - struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
> - int ret, reg;
> - int enable_ctrl;
> -
> - ret = s5m8767_get_register(rdev, ®, &enable_ctrl);
> - if (ret)
> - return ret;
> -
> - return regmap_update_bits(s5m8767->iodev->regmap_pmic, reg,
> - S5M8767_ENCTRL_MASK, enable_ctrl);
> -}
> -
> -static int s5m8767_reg_disable(struct regulator_dev *rdev)
> -{
> - struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
> - int ret, reg, enable_ctrl;
> -
> - ret = s5m8767_get_register(rdev, ®, &enable_ctrl);
> - if (ret)
> - return ret;
> -
> - return regmap_update_bits(s5m8767->iodev->regmap_pmic, reg,
> - S5M8767_ENCTRL_MASK, ~S5M8767_ENCTRL_MASK);
> -}
> -
> static int s5m8767_get_vsel_reg(int reg_id, struct s5m8767_info *s5m8767)
> {
> int reg;
> @@ -407,9 +359,9 @@ static int s5m8767_set_voltage_time_sel(struct regulator_dev *rdev,
>
> static struct regulator_ops s5m8767_ops = {
> .list_voltage = regulator_list_voltage_linear,
> - .is_enabled = s5m8767_reg_is_enabled,
> - .enable = s5m8767_reg_enable,
> - .disable = s5m8767_reg_disable,
> + .is_enabled = regulator_is_enabled_regmap,
> + .enable = regulator_enable_regmap,
> + .disable = regulator_disable_regmap,
> .get_voltage_sel = regulator_get_voltage_sel_regmap,
> .set_voltage_sel = s5m8767_set_voltage_sel,
> .set_voltage_time_sel = s5m8767_set_voltage_time_sel,
> @@ -417,9 +369,9 @@ static struct regulator_ops s5m8767_ops = {
>
> static struct regulator_ops s5m8767_buck78_ops = {
> .list_voltage = regulator_list_voltage_linear,
> - .is_enabled = s5m8767_reg_is_enabled,
> - .enable = s5m8767_reg_enable,
> - .disable = s5m8767_reg_disable,
> + .is_enabled = regulator_is_enabled_regmap,
> + .enable = regulator_enable_regmap,
> + .disable = regulator_disable_regmap,
> .get_voltage_sel = regulator_get_voltage_sel_regmap,
> .set_voltage_sel = regulator_set_voltage_sel_regmap,
> };
> @@ -524,12 +476,13 @@ static void s5m8767_regulator_config_ext_control(struct s5m8767_info *s5m8767,
> static int s5m8767_enable_ext_control(struct s5m8767_info *s5m8767,
> struct regulator_dev *rdev)
> {
> + int id = rdev_get_id(rdev);
> int ret, reg, enable_ctrl;
>
> - if (rdev_get_id(rdev) != S5M8767_BUCK9)
> + if (id != S5M8767_BUCK9)
> return -EINVAL;
>
> - ret = s5m8767_get_register(rdev, ®, &enable_ctrl);
> + ret = s5m8767_get_register(s5m8767, id, ®, &enable_ctrl);
> if (ret)
> return ret;
>
> @@ -984,6 +937,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
> for (i = 0; i < pdata->num_regulators; i++) {
> const struct sec_voltage_desc *desc;
> int id = pdata->regulators[i].id;
> + int enable_reg, enable_val;
>
> desc = reg_voltage_map[id];
> if (desc) {
> @@ -997,6 +951,12 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
> regulators[id].vsel_mask = 0x3f;
> else
> regulators[id].vsel_mask = 0xff;
> +
> + s5m8767_get_register(s5m8767, id, &enable_reg,
> + &enable_val);
> + regulators[id].enable_reg = enable_reg;
> + regulators[id].enable_mask = S5M8767_ENCTRL_MASK;
> + regulators[id].enable_val = enable_val;
> }
>
> config.dev = s5m8767->dev;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists