Commit e5c8ba06 authored by Christian Hohnstaedt's avatar Christian Hohnstaedt Committed by Mark Brown

regulator: tps65218: Add support for LS2

Re-use the "tps65218_pmic_*_current_limit()" functions of LS3
and calculate the different required bit-shift by counting the
trailing 0s in "struct regulator_desc.csel_mask"
Signed-off-by: default avatarChristian Hohnstaedt <Christian.Hohnstaedt@wago.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent bf1fc259
...@@ -204,7 +204,8 @@ static int tps65218_pmic_set_input_current_lim(struct regulator_dev *dev, ...@@ -204,7 +204,8 @@ static int tps65218_pmic_set_input_current_lim(struct regulator_dev *dev,
return -EINVAL; return -EINVAL;
return tps65218_set_bits(tps, dev->desc->csel_reg, dev->desc->csel_mask, return tps65218_set_bits(tps, dev->desc->csel_reg, dev->desc->csel_mask,
index << 2, TPS65218_PROTECT_L1); index << __builtin_ctz(dev->desc->csel_mask),
TPS65218_PROTECT_L1);
} }
static int tps65218_pmic_set_current_limit(struct regulator_dev *dev, static int tps65218_pmic_set_current_limit(struct regulator_dev *dev,
...@@ -223,7 +224,8 @@ static int tps65218_pmic_set_current_limit(struct regulator_dev *dev, ...@@ -223,7 +224,8 @@ static int tps65218_pmic_set_current_limit(struct regulator_dev *dev,
return -EINVAL; return -EINVAL;
return tps65218_set_bits(tps, dev->desc->csel_reg, dev->desc->csel_mask, return tps65218_set_bits(tps, dev->desc->csel_reg, dev->desc->csel_mask,
index << 2, TPS65218_PROTECT_L1); index << __builtin_ctz(dev->desc->csel_mask),
TPS65218_PROTECT_L1);
} }
static int tps65218_pmic_get_current_limit(struct regulator_dev *dev) static int tps65218_pmic_get_current_limit(struct regulator_dev *dev)
...@@ -236,12 +238,13 @@ static int tps65218_pmic_get_current_limit(struct regulator_dev *dev) ...@@ -236,12 +238,13 @@ static int tps65218_pmic_get_current_limit(struct regulator_dev *dev)
if (retval < 0) if (retval < 0)
return retval; return retval;
index = (index & dev->desc->csel_mask) >> 2; index = (index & dev->desc->csel_mask) >>
__builtin_ctz(dev->desc->csel_mask);
return ls3_currents[index]; return ls3_currents[index];
} }
static struct regulator_ops tps65218_ls3_ops = { static struct regulator_ops tps65218_ls23_ops = {
.is_enabled = regulator_is_enabled_regmap, .is_enabled = regulator_is_enabled_regmap,
.enable = tps65218_pmic_enable, .enable = tps65218_pmic_enable,
.disable = tps65218_pmic_disable, .disable = tps65218_pmic_disable,
...@@ -303,8 +306,13 @@ static const struct regulator_desc regulators[] = { ...@@ -303,8 +306,13 @@ static const struct regulator_desc regulators[] = {
TPS65218_ENABLE2_LDO1_EN, 0, 0, ldo1_dcdc3_ranges, TPS65218_ENABLE2_LDO1_EN, 0, 0, ldo1_dcdc3_ranges,
2, 0, 0, TPS65218_REG_SEQ6, 2, 0, 0, TPS65218_REG_SEQ6,
TPS65218_SEQ6_LDO1_SEQ_MASK), TPS65218_SEQ6_LDO1_SEQ_MASK),
TPS65218_REGULATOR("LS2", "regulator-ls2", TPS65218_LS_2,
REGULATOR_CURRENT, tps65218_ls23_ops, 0, 0, 0,
TPS65218_REG_ENABLE2, TPS65218_ENABLE2_LS2_EN,
TPS65218_REG_CONFIG2, TPS65218_CONFIG2_LS2ILIM_MASK,
NULL, 0, 0, 0, 0, 0),
TPS65218_REGULATOR("LS3", "regulator-ls3", TPS65218_LS_3, TPS65218_REGULATOR("LS3", "regulator-ls3", TPS65218_LS_3,
REGULATOR_CURRENT, tps65218_ls3_ops, 0, 0, 0, REGULATOR_CURRENT, tps65218_ls23_ops, 0, 0, 0,
TPS65218_REG_ENABLE2, TPS65218_ENABLE2_LS3_EN, TPS65218_REG_ENABLE2, TPS65218_ENABLE2_LS3_EN,
TPS65218_REG_CONFIG2, TPS65218_CONFIG2_LS3ILIM_MASK, TPS65218_REG_CONFIG2, TPS65218_CONFIG2_LS3ILIM_MASK,
NULL, 0, 0, 0, 0, 0), NULL, 0, 0, 0, 0, 0),
......
...@@ -208,6 +208,7 @@ enum tps65218_regulator_id { ...@@ -208,6 +208,7 @@ enum tps65218_regulator_id {
/* LDOs */ /* LDOs */
TPS65218_LDO_1, TPS65218_LDO_1,
/* LS's */ /* LS's */
TPS65218_LS_2,
TPS65218_LS_3, TPS65218_LS_3,
}; };
...@@ -218,7 +219,7 @@ enum tps65218_regulator_id { ...@@ -218,7 +219,7 @@ enum tps65218_regulator_id {
/* Number of LDO voltage regulators available */ /* Number of LDO voltage regulators available */
#define TPS65218_NUM_LDO 1 #define TPS65218_NUM_LDO 1
/* Number of total LS current regulators available */ /* Number of total LS current regulators available */
#define TPS65218_NUM_LS 1 #define TPS65218_NUM_LS 2
/* Number of total regulators available */ /* Number of total regulators available */
#define TPS65218_NUM_REGULATOR (TPS65218_NUM_DCDC + TPS65218_NUM_LDO \ #define TPS65218_NUM_REGULATOR (TPS65218_NUM_DCDC + TPS65218_NUM_LDO \
+ TPS65218_NUM_LS) + TPS65218_NUM_LS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment