Commit e2eb169b authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: s5m8767: Convert to regulator_list_voltage_linear

In current code, .list_voltage and .set_voltage_sel callbacks for BUCK7 and
BUCK8 return -EINVAL.

This patch adds s5m8767_buck78_ops for BUCK7 and BUCK8 which does not set
.list_voltage, .get_voltage_sel and .set_voltage_sel. ( This has the same
effect of returning -EINVAL in the callbacks)

Then for all the users of s5m8767_list_voltage, we don't need to worry about
the case reg_voltage_map[reg_id] is NULL.
So we can convert s5m8767_list_voltage to regulator_list_voltage_linear.
Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 7f217d36
...@@ -121,27 +121,6 @@ static const struct s5m_voltage_desc *reg_voltage_map[] = { ...@@ -121,27 +121,6 @@ static const struct s5m_voltage_desc *reg_voltage_map[] = {
[S5M8767_BUCK9] = &buck_voltage_val3, [S5M8767_BUCK9] = &buck_voltage_val3,
}; };
static int s5m8767_list_voltage(struct regulator_dev *rdev,
unsigned int selector)
{
const struct s5m_voltage_desc *desc;
int reg_id = rdev_get_id(rdev);
int val;
if (reg_id >= ARRAY_SIZE(reg_voltage_map) || reg_id < 0)
return -EINVAL;
desc = reg_voltage_map[reg_id];
if (desc == NULL)
return -EINVAL;
val = desc->min + desc->step * selector;
if (val > desc->max)
return -EINVAL;
return val;
}
static unsigned int s5m8767_opmode_reg[][4] = { static unsigned int s5m8767_opmode_reg[][4] = {
/* {OFF, ON, LOWPOWER, SUSPEND} */ /* {OFF, ON, LOWPOWER, SUSPEND} */
/* LDO1 ... LDO28 */ /* LDO1 ... LDO28 */
...@@ -449,7 +428,7 @@ static int s5m8767_set_voltage_time_sel(struct regulator_dev *rdev, ...@@ -449,7 +428,7 @@ static int s5m8767_set_voltage_time_sel(struct regulator_dev *rdev,
} }
static struct regulator_ops s5m8767_ops = { static struct regulator_ops s5m8767_ops = {
.list_voltage = s5m8767_list_voltage, .list_voltage = regulator_list_voltage_linear,
.is_enabled = s5m8767_reg_is_enabled, .is_enabled = s5m8767_reg_is_enabled,
.enable = s5m8767_reg_enable, .enable = s5m8767_reg_enable,
.disable = s5m8767_reg_disable, .disable = s5m8767_reg_disable,
...@@ -458,6 +437,12 @@ static struct regulator_ops s5m8767_ops = { ...@@ -458,6 +437,12 @@ static struct regulator_ops s5m8767_ops = {
.set_voltage_time_sel = s5m8767_set_voltage_time_sel, .set_voltage_time_sel = s5m8767_set_voltage_time_sel,
}; };
static struct regulator_ops s5m8767_buck78_ops = {
.is_enabled = s5m8767_reg_is_enabled,
.enable = s5m8767_reg_enable,
.disable = s5m8767_reg_disable,
};
#define s5m8767_regulator_desc(_name) { \ #define s5m8767_regulator_desc(_name) { \
.name = #_name, \ .name = #_name, \
.id = S5M8767_##_name, \ .id = S5M8767_##_name, \
...@@ -466,6 +451,14 @@ static struct regulator_ops s5m8767_ops = { ...@@ -466,6 +451,14 @@ static struct regulator_ops s5m8767_ops = {
.owner = THIS_MODULE, \ .owner = THIS_MODULE, \
} }
#define s5m8767_regulator_buck78_desc(_name) { \
.name = #_name, \
.id = S5M8767_##_name, \
.ops = &s5m8767_buck78_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
}
static struct regulator_desc regulators[] = { static struct regulator_desc regulators[] = {
s5m8767_regulator_desc(LDO1), s5m8767_regulator_desc(LDO1),
s5m8767_regulator_desc(LDO2), s5m8767_regulator_desc(LDO2),
...@@ -501,8 +494,8 @@ static struct regulator_desc regulators[] = { ...@@ -501,8 +494,8 @@ static struct regulator_desc regulators[] = {
s5m8767_regulator_desc(BUCK4), s5m8767_regulator_desc(BUCK4),
s5m8767_regulator_desc(BUCK5), s5m8767_regulator_desc(BUCK5),
s5m8767_regulator_desc(BUCK6), s5m8767_regulator_desc(BUCK6),
s5m8767_regulator_desc(BUCK7), s5m8767_regulator_buck78_desc(BUCK7),
s5m8767_regulator_desc(BUCK8), s5m8767_regulator_buck78_desc(BUCK8),
s5m8767_regulator_desc(BUCK9), s5m8767_regulator_desc(BUCK9),
}; };
...@@ -751,9 +744,12 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev) ...@@ -751,9 +744,12 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
int id = pdata->regulators[i].id; int id = pdata->regulators[i].id;
desc = reg_voltage_map[id]; desc = reg_voltage_map[id];
if (desc) if (desc) {
regulators[id].n_voltages = regulators[id].n_voltages =
(desc->max - desc->min) / desc->step + 1; (desc->max - desc->min) / desc->step + 1;
regulators[id].min_uV = desc->min;
regulators[id].uV_step = desc->step;
}
config.dev = s5m8767->dev; config.dev = s5m8767->dev;
config.init_data = pdata->regulators[i].initdata; config.init_data = pdata->regulators[i].initdata;
......
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