diff options
author | Joonyoung Shim <jy0922.shim@samsung.com> | 2010-08-05 22:28:06 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-10-28 18:29:02 -0400 |
commit | 676e02d7a2ed9bb02994670a07df533a29a99de6 (patch) | |
tree | f429e20f654790895b44aca9193b6082da2a9669 /drivers/regulator/max8998.c | |
parent | 1203a1e6424d502e9c12d29512218487af5fdd1c (diff) |
mfd: Use i2c_client as an argument on MAX8998 i2c routines
The MAX8998 chip have regulator and rtc features. The i2c slave address
of regulator and rtc is different, so needs each i2c client on i2c
operation functions.
Also, this patch exports i2c operation functions instead of callback to
make easy to read.
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/regulator/max8998.c')
-rw-r--r-- | drivers/regulator/max8998.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index a1baf1fbe004..7f5fe6f198cf 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
@@ -173,6 +173,7 @@ static int max8998_get_enable_register(struct regulator_dev *rdev, | |||
173 | static int max8998_ldo_is_enabled(struct regulator_dev *rdev) | 173 | static int max8998_ldo_is_enabled(struct regulator_dev *rdev) |
174 | { | 174 | { |
175 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | 175 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); |
176 | struct i2c_client *i2c = max8998->iodev->i2c; | ||
176 | int ret, reg, shift = 8; | 177 | int ret, reg, shift = 8; |
177 | u8 val; | 178 | u8 val; |
178 | 179 | ||
@@ -180,7 +181,7 @@ static int max8998_ldo_is_enabled(struct regulator_dev *rdev) | |||
180 | if (ret) | 181 | if (ret) |
181 | return ret; | 182 | return ret; |
182 | 183 | ||
183 | ret = max8998_read_reg(max8998->iodev, reg, &val); | 184 | ret = max8998_read_reg(i2c, reg, &val); |
184 | if (ret) | 185 | if (ret) |
185 | return ret; | 186 | return ret; |
186 | 187 | ||
@@ -190,25 +191,27 @@ static int max8998_ldo_is_enabled(struct regulator_dev *rdev) | |||
190 | static int max8998_ldo_enable(struct regulator_dev *rdev) | 191 | static int max8998_ldo_enable(struct regulator_dev *rdev) |
191 | { | 192 | { |
192 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | 193 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); |
194 | struct i2c_client *i2c = max8998->iodev->i2c; | ||
193 | int reg, shift = 8, ret; | 195 | int reg, shift = 8, ret; |
194 | 196 | ||
195 | ret = max8998_get_enable_register(rdev, ®, &shift); | 197 | ret = max8998_get_enable_register(rdev, ®, &shift); |
196 | if (ret) | 198 | if (ret) |
197 | return ret; | 199 | return ret; |
198 | 200 | ||
199 | return max8998_update_reg(max8998->iodev, reg, 1<<shift, 1<<shift); | 201 | return max8998_update_reg(i2c, reg, 1<<shift, 1<<shift); |
200 | } | 202 | } |
201 | 203 | ||
202 | static int max8998_ldo_disable(struct regulator_dev *rdev) | 204 | static int max8998_ldo_disable(struct regulator_dev *rdev) |
203 | { | 205 | { |
204 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | 206 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); |
207 | struct i2c_client *i2c = max8998->iodev->i2c; | ||
205 | int reg, shift = 8, ret; | 208 | int reg, shift = 8, ret; |
206 | 209 | ||
207 | ret = max8998_get_enable_register(rdev, ®, &shift); | 210 | ret = max8998_get_enable_register(rdev, ®, &shift); |
208 | if (ret) | 211 | if (ret) |
209 | return ret; | 212 | return ret; |
210 | 213 | ||
211 | return max8998_update_reg(max8998->iodev, reg, 0, 1<<shift); | 214 | return max8998_update_reg(i2c, reg, 0, 1<<shift); |
212 | } | 215 | } |
213 | 216 | ||
214 | static int max8998_get_voltage_register(struct regulator_dev *rdev, | 217 | static int max8998_get_voltage_register(struct regulator_dev *rdev, |
@@ -276,6 +279,7 @@ static int max8998_get_voltage_register(struct regulator_dev *rdev, | |||
276 | static int max8998_get_voltage(struct regulator_dev *rdev) | 279 | static int max8998_get_voltage(struct regulator_dev *rdev) |
277 | { | 280 | { |
278 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | 281 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); |
282 | struct i2c_client *i2c = max8998->iodev->i2c; | ||
279 | int reg, shift = 0, mask, ret; | 283 | int reg, shift = 0, mask, ret; |
280 | u8 val; | 284 | u8 val; |
281 | 285 | ||
@@ -283,7 +287,7 @@ static int max8998_get_voltage(struct regulator_dev *rdev) | |||
283 | if (ret) | 287 | if (ret) |
284 | return ret; | 288 | return ret; |
285 | 289 | ||
286 | ret = max8998_read_reg(max8998->iodev, reg, &val); | 290 | ret = max8998_read_reg(i2c, reg, &val); |
287 | if (ret) | 291 | if (ret) |
288 | return ret; | 292 | return ret; |
289 | 293 | ||
@@ -297,6 +301,7 @@ static int max8998_set_voltage(struct regulator_dev *rdev, | |||
297 | int min_uV, int max_uV) | 301 | int min_uV, int max_uV) |
298 | { | 302 | { |
299 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | 303 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); |
304 | struct i2c_client *i2c = max8998->iodev->i2c; | ||
300 | int min_vol = min_uV / 1000, max_vol = max_uV / 1000; | 305 | int min_vol = min_uV / 1000, max_vol = max_uV / 1000; |
301 | int previous_vol = 0; | 306 | int previous_vol = 0; |
302 | const struct voltage_map_desc *desc; | 307 | const struct voltage_map_desc *desc; |
@@ -330,14 +335,14 @@ static int max8998_set_voltage(struct regulator_dev *rdev, | |||
330 | /* wait for RAMP_UP_DELAY if rdev is BUCK1/2 and | 335 | /* wait for RAMP_UP_DELAY if rdev is BUCK1/2 and |
331 | * ENRAMP is ON */ | 336 | * ENRAMP is ON */ |
332 | if (ldo == MAX8998_BUCK1 || ldo == MAX8998_BUCK2) { | 337 | if (ldo == MAX8998_BUCK1 || ldo == MAX8998_BUCK2) { |
333 | max8998_read_reg(max8998->iodev, MAX8998_REG_ONOFF4, &val); | 338 | max8998_read_reg(i2c, MAX8998_REG_ONOFF4, &val); |
334 | if (val & (1 << 4)) { | 339 | if (val & (1 << 4)) { |
335 | en_ramp = true; | 340 | en_ramp = true; |
336 | previous_vol = max8998_get_voltage(rdev); | 341 | previous_vol = max8998_get_voltage(rdev); |
337 | } | 342 | } |
338 | } | 343 | } |
339 | 344 | ||
340 | ret = max8998_update_reg(max8998->iodev, reg, i<<shift, mask<<shift); | 345 | ret = max8998_update_reg(i2c, reg, i<<shift, mask<<shift); |
341 | 346 | ||
342 | if (en_ramp == true) { | 347 | if (en_ramp == true) { |
343 | int difference = desc->min + desc->step*i - previous_vol/1000; | 348 | int difference = desc->min + desc->step*i - previous_vol/1000; |