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

regulator: ab8500: Use regulator_list_voltage_table()

Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent a3beb742
...@@ -40,8 +40,6 @@ ...@@ -40,8 +40,6 @@
* @voltage_bank: bank to control regulator voltage * @voltage_bank: bank to control regulator voltage
* @voltage_reg: register to control regulator voltage * @voltage_reg: register to control regulator voltage
* @voltage_mask: mask to control regulator voltage * @voltage_mask: mask to control regulator voltage
* @voltages: supported voltage table
* @voltages_len: number of supported voltages for the regulator
* @delay: startup/set voltage delay in us * @delay: startup/set voltage delay in us
*/ */
struct ab8500_regulator_info { struct ab8500_regulator_info {
...@@ -58,13 +56,11 @@ struct ab8500_regulator_info { ...@@ -58,13 +56,11 @@ struct ab8500_regulator_info {
u8 voltage_bank; u8 voltage_bank;
u8 voltage_reg; u8 voltage_reg;
u8 voltage_mask; u8 voltage_mask;
int const *voltages;
int voltages_len;
unsigned int delay; unsigned int delay;
}; };
/* voltage tables for the vauxn/vintcore supplies */ /* voltage tables for the vauxn/vintcore supplies */
static const int ldo_vauxn_voltages[] = { static const unsigned int ldo_vauxn_voltages[] = {
1100000, 1100000,
1200000, 1200000,
1300000, 1300000,
...@@ -83,7 +79,7 @@ static const int ldo_vauxn_voltages[] = { ...@@ -83,7 +79,7 @@ static const int ldo_vauxn_voltages[] = {
3300000, 3300000,
}; };
static const int ldo_vaux3_voltages[] = { static const unsigned int ldo_vaux3_voltages[] = {
1200000, 1200000,
1500000, 1500000,
1800000, 1800000,
...@@ -94,7 +90,7 @@ static const int ldo_vaux3_voltages[] = { ...@@ -94,7 +90,7 @@ static const int ldo_vaux3_voltages[] = {
2910000, 2910000,
}; };
static const int ldo_vintcore_voltages[] = { static const unsigned int ldo_vintcore_voltages[] = {
1200000, 1200000,
1225000, 1225000,
1250000, 1250000,
...@@ -185,25 +181,6 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) ...@@ -185,25 +181,6 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
return false; return false;
} }
static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector)
{
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
if (info == NULL) {
dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
}
/* return the uV for the fixed regulators */
if (info->fixed_uV)
return info->fixed_uV;
if (selector >= info->voltages_len)
return -EINVAL;
return info->voltages[selector];
}
static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev) static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
{ {
int ret, val; int ret, val;
...@@ -296,11 +273,24 @@ static struct regulator_ops ab8500_regulator_ops = { ...@@ -296,11 +273,24 @@ static struct regulator_ops ab8500_regulator_ops = {
.is_enabled = ab8500_regulator_is_enabled, .is_enabled = ab8500_regulator_is_enabled,
.get_voltage_sel = ab8500_regulator_get_voltage_sel, .get_voltage_sel = ab8500_regulator_get_voltage_sel,
.set_voltage_sel = ab8500_regulator_set_voltage_sel, .set_voltage_sel = ab8500_regulator_set_voltage_sel,
.list_voltage = ab8500_list_voltage, .list_voltage = regulator_list_voltage_table,
.enable_time = ab8500_regulator_enable_time, .enable_time = ab8500_regulator_enable_time,
.set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel, .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel,
}; };
static int ab8500_fixed_list_voltage(struct regulator_dev *rdev,
unsigned selector)
{
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
if (info == NULL) {
dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
}
return info->fixed_uV;
}
static int ab8500_fixed_get_voltage(struct regulator_dev *rdev) static int ab8500_fixed_get_voltage(struct regulator_dev *rdev)
{ {
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
...@@ -318,7 +308,7 @@ static struct regulator_ops ab8500_regulator_fixed_ops = { ...@@ -318,7 +308,7 @@ static struct regulator_ops ab8500_regulator_fixed_ops = {
.disable = ab8500_regulator_disable, .disable = ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled, .is_enabled = ab8500_regulator_is_enabled,
.get_voltage = ab8500_fixed_get_voltage, .get_voltage = ab8500_fixed_get_voltage,
.list_voltage = ab8500_list_voltage, .list_voltage = ab8500_fixed_list_voltage,
.enable_time = ab8500_regulator_enable_time, .enable_time = ab8500_regulator_enable_time,
.set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel, .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel,
}; };
...@@ -329,7 +319,7 @@ static struct ab8500_regulator_info ...@@ -329,7 +319,7 @@ static struct ab8500_regulator_info
* Variable Voltage Regulators * Variable Voltage Regulators
* name, min mV, max mV, * name, min mV, max mV,
* update bank, reg, mask, enable val * update bank, reg, mask, enable val
* volt bank, reg, mask, table, table length * volt bank, reg, mask
*/ */
[AB8500_LDO_AUX1] = { [AB8500_LDO_AUX1] = {
.desc = { .desc = {
...@@ -339,6 +329,7 @@ static struct ab8500_regulator_info ...@@ -339,6 +329,7 @@ static struct ab8500_regulator_info
.id = AB8500_LDO_AUX1, .id = AB8500_LDO_AUX1,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
.volt_table = ldo_vauxn_voltages,
}, },
.min_uV = 1100000, .min_uV = 1100000,
.max_uV = 3300000, .max_uV = 3300000,
...@@ -349,8 +340,6 @@ static struct ab8500_regulator_info ...@@ -349,8 +340,6 @@ static struct ab8500_regulator_info
.voltage_bank = 0x04, .voltage_bank = 0x04,
.voltage_reg = 0x1f, .voltage_reg = 0x1f,
.voltage_mask = 0x0f, .voltage_mask = 0x0f,
.voltages = ldo_vauxn_voltages,
.voltages_len = ARRAY_SIZE(ldo_vauxn_voltages),
}, },
[AB8500_LDO_AUX2] = { [AB8500_LDO_AUX2] = {
.desc = { .desc = {
...@@ -360,6 +349,7 @@ static struct ab8500_regulator_info ...@@ -360,6 +349,7 @@ static struct ab8500_regulator_info
.id = AB8500_LDO_AUX2, .id = AB8500_LDO_AUX2,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
.volt_table = ldo_vauxn_voltages,
}, },
.min_uV = 1100000, .min_uV = 1100000,
.max_uV = 3300000, .max_uV = 3300000,
...@@ -370,8 +360,6 @@ static struct ab8500_regulator_info ...@@ -370,8 +360,6 @@ static struct ab8500_regulator_info
.voltage_bank = 0x04, .voltage_bank = 0x04,
.voltage_reg = 0x20, .voltage_reg = 0x20,
.voltage_mask = 0x0f, .voltage_mask = 0x0f,
.voltages = ldo_vauxn_voltages,
.voltages_len = ARRAY_SIZE(ldo_vauxn_voltages),
}, },
[AB8500_LDO_AUX3] = { [AB8500_LDO_AUX3] = {
.desc = { .desc = {
...@@ -381,6 +369,7 @@ static struct ab8500_regulator_info ...@@ -381,6 +369,7 @@ static struct ab8500_regulator_info
.id = AB8500_LDO_AUX3, .id = AB8500_LDO_AUX3,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.n_voltages = ARRAY_SIZE(ldo_vaux3_voltages), .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
.volt_table = ldo_vaux3_voltages,
}, },
.min_uV = 1100000, .min_uV = 1100000,
.max_uV = 3300000, .max_uV = 3300000,
...@@ -391,8 +380,6 @@ static struct ab8500_regulator_info ...@@ -391,8 +380,6 @@ static struct ab8500_regulator_info
.voltage_bank = 0x04, .voltage_bank = 0x04,
.voltage_reg = 0x21, .voltage_reg = 0x21,
.voltage_mask = 0x07, .voltage_mask = 0x07,
.voltages = ldo_vaux3_voltages,
.voltages_len = ARRAY_SIZE(ldo_vaux3_voltages),
}, },
[AB8500_LDO_INTCORE] = { [AB8500_LDO_INTCORE] = {
.desc = { .desc = {
...@@ -402,6 +389,7 @@ static struct ab8500_regulator_info ...@@ -402,6 +389,7 @@ static struct ab8500_regulator_info
.id = AB8500_LDO_INTCORE, .id = AB8500_LDO_INTCORE,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.n_voltages = ARRAY_SIZE(ldo_vintcore_voltages), .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
.volt_table = ldo_vintcore_voltages,
}, },
.min_uV = 1100000, .min_uV = 1100000,
.max_uV = 3300000, .max_uV = 3300000,
...@@ -412,8 +400,6 @@ static struct ab8500_regulator_info ...@@ -412,8 +400,6 @@ static struct ab8500_regulator_info
.voltage_bank = 0x03, .voltage_bank = 0x03,
.voltage_reg = 0x80, .voltage_reg = 0x80,
.voltage_mask = 0x38, .voltage_mask = 0x38,
.voltages = ldo_vintcore_voltages,
.voltages_len = ARRAY_SIZE(ldo_vintcore_voltages),
}, },
/* /*
...@@ -769,9 +755,7 @@ static __devinit int ab8500_regulator_register(struct platform_device *pdev, ...@@ -769,9 +755,7 @@ static __devinit int ab8500_regulator_register(struct platform_device *pdev,
if (info->desc.id == AB8500_LDO_AUX3) { if (info->desc.id == AB8500_LDO_AUX3) {
info->desc.n_voltages = info->desc.n_voltages =
ARRAY_SIZE(ldo_vauxn_voltages); ARRAY_SIZE(ldo_vauxn_voltages);
info->voltages = ldo_vauxn_voltages; info->desc.volt_table = ldo_vauxn_voltages;
info->voltages_len =
ARRAY_SIZE(ldo_vauxn_voltages);
info->voltage_mask = 0xf; info->voltage_mask = 0xf;
} }
} }
......
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