lkml.org 
[lkml]   [2019]   [Jan]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 2/2] regulator: max77650: Convert to use regulator_enable/disable/is_enabled_regmap
śr., 30 sty 2019 o 10:07 Axel Lin <axel.lin@ingics.com> napisał(a):
>
> By setting enable_reg, enable_mask, enable_val and disable_val, we can
> use the regulator_enable/disable/is_enabled_regmap helpers. With this
> change, then regB field can be removed from struct max77650_regulator_desc.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> Hi Bartosz,
> I don't have this h/w, please help to review and test it.
>
> I think the only difference is the is_enabled checking:
> Before the patch, it returns en != MAX77650_REGULATOR_DISABLED;
> After the patch, it returns en == MAX77650_REGULATOR_ENABLED
> I'm not sure if this difference does matter or not.
>

NACK. I intend to support the FPS feature of the regulator module in
the future (see a similar thing in max77620) and I will need to extend
these callbacks as there will be more possible values here. Regmap
generics will not be enough.

Best regards,
Bartosz Golaszewski

> Thanks,
> Axel
> drivers/regulator/max77650-regulator.c | 87 +++++++-------------------
> 1 file changed, 23 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/regulator/max77650-regulator.c b/drivers/regulator/max77650-regulator.c
> index 5afb91400832..90c0f73f3fad 100644
> --- a/drivers/regulator/max77650-regulator.c
> +++ b/drivers/regulator/max77650-regulator.c
> @@ -13,8 +13,6 @@
> #include <linux/regulator/driver.h>
>
> #define MAX77650_REGULATOR_EN_CTRL_MASK GENMASK(3, 0)
> -#define MAX77650_REGULATOR_EN_CTRL_BITS(_reg) \
> - ((_reg) & MAX77650_REGULATOR_EN_CTRL_MASK)
> #define MAX77650_REGULATOR_ENABLED GENMASK(2, 1)
> #define MAX77650_REGULATOR_DISABLED BIT(2)
>
> @@ -41,7 +39,6 @@ enum {
> struct max77650_regulator_desc {
> struct regulator_desc desc;
> unsigned int regA;
> - unsigned int regB;
> };
>
> static const u32 max77651_sbb1_regulator_volt_table[] = {
> @@ -86,50 +83,6 @@ static const int max77650_current_limit_table[] = {
> 1000000, 866000, 707000, 500000,
> };
>
> -static int max77650_regulator_is_enabled(struct regulator_dev *rdev)
> -{
> - struct max77650_regulator_desc *rdesc;
> - struct regmap *map;
> - int val, rv, en;
> -
> - rdesc = rdev_get_drvdata(rdev);
> - map = rdev_get_regmap(rdev);
> -
> - rv = regmap_read(map, rdesc->regB, &val);
> - if (rv)
> - return rv;
> -
> - en = MAX77650_REGULATOR_EN_CTRL_BITS(val);
> -
> - return en != MAX77650_REGULATOR_DISABLED;
> -}
> -
> -static int max77650_regulator_enable(struct regulator_dev *rdev)
> -{
> - struct max77650_regulator_desc *rdesc;
> - struct regmap *map;
> -
> - rdesc = rdev_get_drvdata(rdev);
> - map = rdev_get_regmap(rdev);
> -
> - return regmap_update_bits(map, rdesc->regB,
> - MAX77650_REGULATOR_EN_CTRL_MASK,
> - MAX77650_REGULATOR_ENABLED);
> -}
> -
> -static int max77650_regulator_disable(struct regulator_dev *rdev)
> -{
> - struct max77650_regulator_desc *rdesc;
> - struct regmap *map;
> -
> - rdesc = rdev_get_drvdata(rdev);
> - map = rdev_get_regmap(rdev);
> -
> - return regmap_update_bits(map, rdesc->regB,
> - MAX77650_REGULATOR_EN_CTRL_MASK,
> - MAX77650_REGULATOR_DISABLED);
> -}
> -
> static int max77650_regulator_set_voltage_sel(struct regulator_dev *rdev,
> unsigned int sel)
> {
> @@ -140,7 +93,7 @@ static int max77650_regulator_set_voltage_sel(struct regulator_dev *rdev,
> * If the regulator is disabled, we can program the desired
> * voltage right away.
> */
> - if (!max77650_regulator_is_enabled(rdev))
> + if (!regulator_is_enabled_regmap(rdev))
> return regulator_set_voltage_sel_regmap(rdev, sel);
>
> /*
> @@ -189,7 +142,7 @@ static int max77651_regulator_sbb1_set_voltage_sel(struct regulator_dev *rdev,
> * If the regulator is disabled, we can program the desired
> * voltage right away.
> */
> - if (!max77650_regulator_is_enabled(rdev))
> + if (!regulator_is_enabled_regmap(rdev))
> return regulator_set_voltage_sel_regmap(rdev, sel);
>
> curr = regulator_get_voltage_sel_regmap(rdev);
> @@ -264,9 +217,9 @@ static int max77650_regulator_set_current_limit(struct regulator_dev *rdev,
> }
>
> static const struct regulator_ops max77650_regulator_LDO_ops = {
> - .is_enabled = max77650_regulator_is_enabled,
> - .enable = max77650_regulator_enable,
> - .disable = max77650_regulator_disable,
> + .is_enabled = regulator_is_enabled_regmap,
> + .enable = regulator_enable_regmap,
> + .disable = regulator_disable_regmap,
> .list_voltage = regulator_list_voltage_linear,
> .map_voltage = regulator_map_voltage_linear,
> .get_voltage_sel = regulator_get_voltage_sel_regmap,
> @@ -275,9 +228,9 @@ static const struct regulator_ops max77650_regulator_LDO_ops = {
> };
>
> static const struct regulator_ops max77650_regulator_SBB_ops = {
> - .is_enabled = max77650_regulator_is_enabled,
> - .enable = max77650_regulator_enable,
> - .disable = max77650_regulator_disable,
> + .is_enabled = regulator_is_enabled_regmap,
> + .enable = regulator_enable_regmap,
> + .disable = regulator_disable_regmap,
> .list_voltage = regulator_list_voltage_linear,
> .map_voltage = regulator_map_voltage_linear,
> .get_voltage_sel = regulator_get_voltage_sel_regmap,
> @@ -289,9 +242,9 @@ static const struct regulator_ops max77650_regulator_SBB_ops = {
>
> /* Special case for max77651 SBB1 - non-linear voltage mapping. */
> static const struct regulator_ops max77651_SBB1_regulator_ops = {
> - .is_enabled = max77650_regulator_is_enabled,
> - .enable = max77650_regulator_enable,
> - .disable = max77650_regulator_disable,
> + .is_enabled = regulator_is_enabled_regmap,
> + .enable = regulator_enable_regmap,
> + .disable = regulator_disable_regmap,
> .list_voltage = regulator_list_voltage_table,
> .get_voltage_sel = regulator_get_voltage_sel_regmap,
> .set_voltage_sel = max77651_regulator_sbb1_set_voltage_sel,
> @@ -313,6 +266,10 @@ static struct max77650_regulator_desc max77650_LDO_desc = {
> .n_voltages = 128,
> .vsel_mask = MAX77650_REGULATOR_V_LDO_MASK,
> .vsel_reg = MAX77650_REG_CNFG_LDO_A,
> + .enable_reg = MAX77650_REG_CNFG_LDO_B,
> + .enable_mask = MAX77650_REGULATOR_EN_CTRL_MASK,
> + .enable_val = MAX77650_REGULATOR_ENABLED,
> + .disable_val = MAX77650_REGULATOR_DISABLED,
> .active_discharge_off = MAX77650_REGULATOR_AD_DISABLED,
> .active_discharge_on = MAX77650_REGULATOR_AD_ENABLED,
> .active_discharge_mask = MAX77650_REGULATOR_AD_MASK,
> @@ -321,7 +278,6 @@ static struct max77650_regulator_desc max77650_LDO_desc = {
> .type = REGULATOR_VOLTAGE,
> },
> .regA = MAX77650_REG_CNFG_LDO_A,
> - .regB = MAX77650_REG_CNFG_LDO_B,
> };
>
> static struct max77650_regulator_desc max77650_SBB0_desc = {
> @@ -337,6 +293,10 @@ static struct max77650_regulator_desc max77650_SBB0_desc = {
> .n_voltages = 64,
> .vsel_mask = MAX77650_REGULATOR_V_SBB_MASK,
> .vsel_reg = MAX77650_REG_CNFG_SBB0_A,
> + .enable_reg = MAX77650_REG_CNFG_LDO_B,
> + .enable_mask = MAX77650_REGULATOR_EN_CTRL_MASK,
> + .enable_val = MAX77650_REGULATOR_ENABLED,
> + .disable_val = MAX77650_REGULATOR_DISABLED,
> .active_discharge_off = MAX77650_REGULATOR_AD_DISABLED,
> .active_discharge_on = MAX77650_REGULATOR_AD_ENABLED,
> .active_discharge_mask = MAX77650_REGULATOR_AD_MASK,
> @@ -345,7 +305,6 @@ static struct max77650_regulator_desc max77650_SBB0_desc = {
> .type = REGULATOR_VOLTAGE,
> },
> .regA = MAX77650_REG_CNFG_SBB0_A,
> - .regB = MAX77650_REG_CNFG_SBB0_B,
> };
>
> static struct max77650_regulator_desc max77650_SBB1_desc = {
> @@ -361,6 +320,10 @@ static struct max77650_regulator_desc max77650_SBB1_desc = {
> .n_voltages = 64,
> .vsel_mask = MAX77650_REGULATOR_V_SBB_MASK,
> .vsel_reg = MAX77650_REG_CNFG_SBB1_A,
> + .enable_reg = MAX77650_REG_CNFG_LDO_B,
> + .enable_mask = MAX77650_REGULATOR_EN_CTRL_MASK,
> + .enable_val = MAX77650_REGULATOR_ENABLED,
> + .disable_val = MAX77650_REGULATOR_DISABLED,
> .active_discharge_off = MAX77650_REGULATOR_AD_DISABLED,
> .active_discharge_on = MAX77650_REGULATOR_AD_ENABLED,
> .active_discharge_mask = MAX77650_REGULATOR_AD_MASK,
> @@ -369,7 +332,6 @@ static struct max77650_regulator_desc max77650_SBB1_desc = {
> .type = REGULATOR_VOLTAGE,
> },
> .regA = MAX77650_REG_CNFG_SBB1_A,
> - .regB = MAX77650_REG_CNFG_SBB1_B,
> };
>
> static struct max77650_regulator_desc max77651_SBB1_desc = {
> @@ -392,7 +354,6 @@ static struct max77650_regulator_desc max77651_SBB1_desc = {
> .type = REGULATOR_VOLTAGE,
> },
> .regA = MAX77650_REG_CNFG_SBB1_A,
> - .regB = MAX77650_REG_CNFG_SBB1_B,
> };
>
> static struct max77650_regulator_desc max77650_SBB2_desc = {
> @@ -416,7 +377,6 @@ static struct max77650_regulator_desc max77650_SBB2_desc = {
> .type = REGULATOR_VOLTAGE,
> },
> .regA = MAX77650_REG_CNFG_SBB2_A,
> - .regB = MAX77650_REG_CNFG_SBB2_B,
> };
>
> static struct max77650_regulator_desc max77651_SBB2_desc = {
> @@ -440,7 +400,6 @@ static struct max77650_regulator_desc max77651_SBB2_desc = {
> .type = REGULATOR_VOLTAGE,
> },
> .regA = MAX77650_REG_CNFG_SBB2_A,
> - .regB = MAX77650_REG_CNFG_SBB2_B,
> };
>
> static int max77650_regulator_probe(struct platform_device *pdev)
> --
> 2.17.1
>

\
 
 \ /
  Last update: 2019-01-30 10:13    [W:0.045 / U:1.936 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site