diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-06-07 20:25:41 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-07 20:48:22 -0400 |
commit | 93f5de5c58a863b48a8c44d70c4f7e3d0c7af50e (patch) | |
tree | 0c42a0eef36e69b33b56a308280e2656149e0bae /drivers/regulator/max1586.c | |
parent | f46470379342033bdd9f740ce483c96f5c20eab2 (diff) |
regulator: max1586: Convert max1586_v3_ops to regulator_list_voltage_linear
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max1586.c')
-rw-r--r-- | drivers/regulator/max1586.c | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index 126c7d8f31c6..a54771e4d960 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c | |||
@@ -63,14 +63,6 @@ static int v6_voltages_uv[] = { 1, 1800000, 2500000, 3000000 }; | |||
63 | * R24 and R25=100kOhm as described in the data sheet. | 63 | * R24 and R25=100kOhm as described in the data sheet. |
64 | * The gain is approximately: 1 + R24/R25 + R24/185.5kOhm | 64 | * The gain is approximately: 1 + R24/R25 + R24/185.5kOhm |
65 | */ | 65 | */ |
66 | static int max1586_v3_calc_voltage(struct max1586_data *max1586, | ||
67 | unsigned selector) | ||
68 | { | ||
69 | unsigned range_uV = max1586->max_uV - max1586->min_uV; | ||
70 | |||
71 | return max1586->min_uV + (selector * range_uV / MAX1586_V3_MAX_VSEL); | ||
72 | } | ||
73 | |||
74 | static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV, | 66 | static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV, |
75 | unsigned *selector) | 67 | unsigned *selector) |
76 | { | 68 | { |
@@ -86,25 +78,16 @@ static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV, | |||
86 | 78 | ||
87 | *selector = DIV_ROUND_UP((min_uV - max1586->min_uV) * | 79 | *selector = DIV_ROUND_UP((min_uV - max1586->min_uV) * |
88 | MAX1586_V3_MAX_VSEL, range_uV); | 80 | MAX1586_V3_MAX_VSEL, range_uV); |
89 | if (max1586_v3_calc_voltage(max1586, *selector) > max_uV) | 81 | if (regulator_list_voltage_linear(rdev, *selector) > max_uV) |
90 | return -EINVAL; | 82 | return -EINVAL; |
91 | 83 | ||
92 | dev_dbg(&client->dev, "changing voltage v3 to %dmv\n", | 84 | dev_dbg(&client->dev, "changing voltage v3 to %dmv\n", |
93 | max1586_v3_calc_voltage(max1586, *selector) / 1000); | 85 | regulator_list_voltage_linear(rdev, *selector) / 1000); |
94 | 86 | ||
95 | v3_prog = I2C_V3_SELECT | (u8) *selector; | 87 | v3_prog = I2C_V3_SELECT | (u8) *selector; |
96 | return i2c_smbus_write_byte(client, v3_prog); | 88 | return i2c_smbus_write_byte(client, v3_prog); |
97 | } | 89 | } |
98 | 90 | ||
99 | static int max1586_v3_list(struct regulator_dev *rdev, unsigned selector) | ||
100 | { | ||
101 | struct max1586_data *max1586 = rdev_get_drvdata(rdev); | ||
102 | |||
103 | if (selector > MAX1586_V3_MAX_VSEL) | ||
104 | return -EINVAL; | ||
105 | return max1586_v3_calc_voltage(max1586, selector); | ||
106 | } | ||
107 | |||
108 | static int max1586_v6_set_voltage_sel(struct regulator_dev *rdev, | 91 | static int max1586_v6_set_voltage_sel(struct regulator_dev *rdev, |
109 | unsigned int selector) | 92 | unsigned int selector) |
110 | { | 93 | { |
@@ -124,7 +107,7 @@ static int max1586_v6_set_voltage_sel(struct regulator_dev *rdev, | |||
124 | */ | 107 | */ |
125 | static struct regulator_ops max1586_v3_ops = { | 108 | static struct regulator_ops max1586_v3_ops = { |
126 | .set_voltage = max1586_v3_set, | 109 | .set_voltage = max1586_v3_set, |
127 | .list_voltage = max1586_v3_list, | 110 | .list_voltage = regulator_list_voltage_linear, |
128 | }; | 111 | }; |
129 | 112 | ||
130 | static struct regulator_ops max1586_v6_ops = { | 113 | static struct regulator_ops max1586_v6_ops = { |
@@ -132,7 +115,7 @@ static struct regulator_ops max1586_v6_ops = { | |||
132 | .list_voltage = regulator_list_voltage_table, | 115 | .list_voltage = regulator_list_voltage_table, |
133 | }; | 116 | }; |
134 | 117 | ||
135 | static const struct regulator_desc max1586_reg[] = { | 118 | static struct regulator_desc max1586_reg[] = { |
136 | { | 119 | { |
137 | .name = "Output_V3", | 120 | .name = "Output_V3", |
138 | .id = MAX1586_V3, | 121 | .id = MAX1586_V3, |
@@ -185,6 +168,13 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client, | |||
185 | goto err; | 168 | goto err; |
186 | } | 169 | } |
187 | 170 | ||
171 | if (id == MAX1586_V3) { | ||
172 | max1586_reg[id].min_uV = max1586->min_uV; | ||
173 | max1586_reg[id].uV_step = | ||
174 | (max1586->max_uV - max1586->min_uV) / | ||
175 | MAX1586_V3_MAX_VSEL; | ||
176 | } | ||
177 | |||
188 | config.dev = &client->dev; | 178 | config.dev = &client->dev; |
189 | config.init_data = pdata->subdevs[i].platform_data; | 179 | config.init_data = pdata->subdevs[i].platform_data; |
190 | config.driver_data = max1586; | 180 | config.driver_data = max1586; |