regulator: max77650: Fix include files
PATCH 1/2 regulator: max77650: Fix include files
This is a platform driver, no need to include linux/i2c.h. Include linux/of.h for of_match_ptr.
--- drivers/regulator/max77650-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/max77650-regulator.c +1 -1
@@ -5,7 +5,7 @@// // Regulator driver for MAXIM 77650/77651 charger/power-supply. -#include <linux/i2c.h> +#include <linux/of.h> #include <linux/mfd/max77650.h> #include <linux/module.h> #include <linux/platform_device.h>
Signature · 1 line
2.17.1
PATCH 2/2 regulator: max77650: Convert to use regulator_enable/disable/is_enabled_regmap
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.
---
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.
Thanks,
Axel
drivers/regulator/max77650-regulator.c | 87 +++++++------------------- 1 file changed, 23 insertions(+), 64 deletions(-)
drivers/regulator/max77650-regulator.c +23 -64
@@ -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)
Signature · 1 line
2.17.1
Re: [PATCH 2/2] regulator: max77650: Convert to use regulator_enable/disable/is_enabled_regmap
śr., 30 sty 2019 o 10:07 Axel Lin <[email protected]> napisał(a):
Quoted 6 lines
By setting
enable_reg,enable_mask,enable_valanddisable_val, we can use the regulator_enable/disable/is_enabled_regmap helpers. With this change, then regB field can be removed from structmax77650_regulator_desc.Signed-off-by Axel Lin <[email protected]>
Quoted 9 lines
---
Hi Bartosz,
I don't have this h/w, please help to review and test it.I think the only difference is the
is_enabledchecking:
Before the patch, it returns en !=MAX77650_REGULATOR_DISABLED; After the patch, it returns en ==MAX77650_REGULATOR_ENABLEDI'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
Quoted 218 lines
Thanks,
Axeldrivers/regulator/max77650-regulator.c | 87 +++++++------------------- 1 file changed, 23 insertions(+), 64 deletions(-)drivers/regulator/max77650-regulator.c +23
-65@@ -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
Re: [PATCH 2/2] regulator: max77650: Convert to use regulator_enable/disable/is_enabled_regmap
Bartosz Golaszewski <[email protected]> 於 2019年1月30日 週三 下午5:12寫道:
Quoted 18 lines
śr., 30 sty 2019 o 10:07 Axel Lin <[email protected]> napisał(a):
Quoted 6 lines
By setting
enable_reg,enable_mask,enable_valanddisable_val, we can use the regulator_enable/disable/is_enabled_regmap helpers. With this change, then regB field can be removed from structmax77650_regulator_desc.Signed-off-by Axel Lin <[email protected]>Quoted 9 lines
---
Hi Bartosz,
I don't have this h/w, please help to review and test it.I think the only difference is the
is_enabledchecking:
Before the patch, it returns en !=MAX77650_REGULATOR_DISABLED; After the patch, it returns en ==MAX77650_REGULATOR_ENABLEDI'm not sure if this difference does matter or not.
Quoted 4 lines
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.
Got it, thanks for the quick review.
śr., 30 sty 2019 o 10:07 Axel Lin <[email protected]> napisał(a):
Quoted 23 lines
This is a platform driver, no need to include
linux/i2c.h. Includelinux/of.hforof_match_ptr.Signed-off-by Axel Lin <[email protected]>--- drivers/regulator/max77650-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/regulator/max77650-regulator.c +1
-2@@ -5,7 +5,7 @@// // Regulator driver for MAXIM 77650/77651 charger/power-supply. -#include <linux/i2c.h> +#include <linux/of.h> #include <linux/mfd/max77650.h> #include <linux/module.h> #include <linux/platform_device.h> --
Quoted 2 lines
2.17.1