88pm8607.c (a67f7e6b601ab55067d02de42e89be34c4b6f345) 88pm8607.c (ef26e0dbe8bebd8dc559d39ed804720002225fc3)
1/*
2 * Regulators driver for Marvell 88PM8607
3 *
4 * Copyright (C) 2009 Marvell International Ltd.
5 * Haojian Zhuang <haojian.zhuang@marvell.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 17 unchanged lines hidden (view full) ---

26
27 unsigned int *vol_table;
28 unsigned int *vol_suspend;
29
30 int vol_reg;
31 int vol_shift;
32 int update_reg;
33 int update_bit;
1/*
2 * Regulators driver for Marvell 88PM8607
3 *
4 * Copyright (C) 2009 Marvell International Ltd.
5 * Haojian Zhuang <haojian.zhuang@marvell.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 17 unchanged lines hidden (view full) ---

26
27 unsigned int *vol_table;
28 unsigned int *vol_suspend;
29
30 int vol_reg;
31 int vol_shift;
32 int update_reg;
33 int update_bit;
34 int enable_reg;
35 int enable_bit;
36 int slope_double;
37};
38
39static const unsigned int BUCK1_table[] = {
40 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000,
41 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000,
42 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000,
43 1325000, 1350000, 1375000, 1400000, 1425000, 1450000, 1475000, 1500000,

--- 183 unchanged lines hidden (view full) ---

227{
228 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
229 uint8_t val, mask;
230 int ret;
231
232 val = (uint8_t)(selector << info->vol_shift);
233 mask = (rdev->desc->n_voltages - 1) << info->vol_shift;
234
34 int slope_double;
35};
36
37static const unsigned int BUCK1_table[] = {
38 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000,
39 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000,
40 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000,
41 1325000, 1350000, 1375000, 1400000, 1425000, 1450000, 1475000, 1500000,

--- 183 unchanged lines hidden (view full) ---

225{
226 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
227 uint8_t val, mask;
228 int ret;
229
230 val = (uint8_t)(selector << info->vol_shift);
231 mask = (rdev->desc->n_voltages - 1) << info->vol_shift;
232
235 ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, val);
233 ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, selector);
236 if (ret)
237 return ret;
238 switch (info->desc.id) {
239 case PM8607_ID_BUCK1:
240 case PM8607_ID_BUCK3:
241 ret = pm860x_set_bits(info->i2c, info->update_reg,
242 1 << info->update_bit,
243 1 << info->update_bit);

--- 13 unchanged lines hidden (view full) ---

257 return ret;
258
259 mask = (rdev->desc->n_voltages - 1) << info->vol_shift;
260 val = ((unsigned char)ret & mask) >> info->vol_shift;
261
262 return val;
263}
264
234 if (ret)
235 return ret;
236 switch (info->desc.id) {
237 case PM8607_ID_BUCK1:
238 case PM8607_ID_BUCK3:
239 ret = pm860x_set_bits(info->i2c, info->update_reg,
240 1 << info->update_bit,
241 1 << info->update_bit);

--- 13 unchanged lines hidden (view full) ---

255 return ret;
256
257 mask = (rdev->desc->n_voltages - 1) << info->vol_shift;
258 val = ((unsigned char)ret & mask) >> info->vol_shift;
259
260 return val;
261}
262
265static int pm8607_enable(struct regulator_dev *rdev)
266{
267 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
268
269 return pm860x_set_bits(info->i2c, info->enable_reg,
270 1 << info->enable_bit,
271 1 << info->enable_bit);
272}
273
274static int pm8607_disable(struct regulator_dev *rdev)
275{
276 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
277
278 return pm860x_set_bits(info->i2c, info->enable_reg,
279 1 << info->enable_bit, 0);
280}
281
282static int pm8607_is_enabled(struct regulator_dev *rdev)
283{
284 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
285 int ret;
286
287 ret = pm860x_reg_read(info->i2c, info->enable_reg);
288 if (ret < 0)
289 return ret;
290
291 return !!((unsigned char)ret & (1 << info->enable_bit));
292}
293
294static struct regulator_ops pm8607_regulator_ops = {
295 .list_voltage = pm8607_list_voltage,
296 .set_voltage_sel = pm8607_set_voltage_sel,
297 .get_voltage_sel = pm8607_get_voltage_sel,
263static struct regulator_ops pm8607_regulator_ops = {
264 .list_voltage = pm8607_list_voltage,
265 .set_voltage_sel = pm8607_set_voltage_sel,
266 .get_voltage_sel = pm8607_get_voltage_sel,
298 .enable = pm8607_enable,
299 .disable = pm8607_disable,
300 .is_enabled = pm8607_is_enabled,
267 .enable = regulator_enable_regmap,
268 .disable = regulator_disable_regmap,
269 .is_enabled = regulator_is_enabled_regmap,
301};
302
303#define PM8607_DVC(vreg, ureg, ubit, ereg, ebit) \
304{ \
305 .desc = { \
306 .name = #vreg, \
307 .ops = &pm8607_regulator_ops, \
308 .type = REGULATOR_VOLTAGE, \
309 .id = PM8607_ID_##vreg, \
310 .owner = THIS_MODULE, \
311 .n_voltages = ARRAY_SIZE(vreg##_table), \
270};
271
272#define PM8607_DVC(vreg, ureg, ubit, ereg, ebit) \
273{ \
274 .desc = { \
275 .name = #vreg, \
276 .ops = &pm8607_regulator_ops, \
277 .type = REGULATOR_VOLTAGE, \
278 .id = PM8607_ID_##vreg, \
279 .owner = THIS_MODULE, \
280 .n_voltages = ARRAY_SIZE(vreg##_table), \
281 .enable_reg = PM8607_##ereg, \
282 .enable_mask = 1 << (ebit), \
312 }, \
313 .vol_reg = PM8607_##vreg, \
314 .vol_shift = (0), \
315 .update_reg = PM8607_##ureg, \
316 .update_bit = (ubit), \
283 }, \
284 .vol_reg = PM8607_##vreg, \
285 .vol_shift = (0), \
286 .update_reg = PM8607_##ureg, \
287 .update_bit = (ubit), \
317 .enable_reg = PM8607_##ereg, \
318 .enable_bit = (ebit), \
319 .slope_double = (0), \
320 .vol_table = (unsigned int *)&vreg##_table, \
321 .vol_suspend = (unsigned int *)&vreg##_suspend_table, \
322}
323
324#define PM8607_LDO(_id, vreg, shift, ereg, ebit) \
325{ \
326 .desc = { \
327 .name = "LDO" #_id, \
328 .ops = &pm8607_regulator_ops, \
329 .type = REGULATOR_VOLTAGE, \
330 .id = PM8607_ID_LDO##_id, \
331 .owner = THIS_MODULE, \
332 .n_voltages = ARRAY_SIZE(LDO##_id##_table), \
288 .slope_double = (0), \
289 .vol_table = (unsigned int *)&vreg##_table, \
290 .vol_suspend = (unsigned int *)&vreg##_suspend_table, \
291}
292
293#define PM8607_LDO(_id, vreg, shift, ereg, ebit) \
294{ \
295 .desc = { \
296 .name = "LDO" #_id, \
297 .ops = &pm8607_regulator_ops, \
298 .type = REGULATOR_VOLTAGE, \
299 .id = PM8607_ID_LDO##_id, \
300 .owner = THIS_MODULE, \
301 .n_voltages = ARRAY_SIZE(LDO##_id##_table), \
302 .enable_reg = PM8607_##ereg, \
303 .enable_mask = 1 << (ebit), \
333 }, \
334 .vol_reg = PM8607_##vreg, \
335 .vol_shift = (shift), \
304 }, \
305 .vol_reg = PM8607_##vreg, \
306 .vol_shift = (shift), \
336 .enable_reg = PM8607_##ereg, \
337 .enable_bit = (ebit), \
338 .slope_double = (0), \
339 .vol_table = (unsigned int *)&LDO##_id##_table, \
340 .vol_suspend = (unsigned int *)&LDO##_id##_suspend_table, \
341}
342
343static struct pm8607_regulator_info pm8607_regulator_info[] = {
344 PM8607_DVC(BUCK1, GO, 0, SUPPLIES_EN11, 0),
345 PM8607_DVC(BUCK2, GO, 1, SUPPLIES_EN11, 1),

--- 44 unchanged lines hidden (view full) ---

390 /* check DVC ramp slope double */
391 if ((i == PM8607_ID_BUCK3) && info->chip->buck3_double)
392 info->slope_double = 1;
393
394 config.dev = &pdev->dev;
395 config.init_data = pdata;
396 config.driver_data = info;
397
307 .slope_double = (0), \
308 .vol_table = (unsigned int *)&LDO##_id##_table, \
309 .vol_suspend = (unsigned int *)&LDO##_id##_suspend_table, \
310}
311
312static struct pm8607_regulator_info pm8607_regulator_info[] = {
313 PM8607_DVC(BUCK1, GO, 0, SUPPLIES_EN11, 0),
314 PM8607_DVC(BUCK2, GO, 1, SUPPLIES_EN11, 1),

--- 44 unchanged lines hidden (view full) ---

359 /* check DVC ramp slope double */
360 if ((i == PM8607_ID_BUCK3) && info->chip->buck3_double)
361 info->slope_double = 1;
362
363 config.dev = &pdev->dev;
364 config.init_data = pdata;
365 config.driver_data = info;
366
367 if (chip->id == CHIP_PM8607)
368 config.regmap = chip->regmap;
369 else
370 config.regmap = chip->regmap_companion;
371
398 /* replace driver_data with info */
399 info->regulator = regulator_register(&info->desc, &config);
400 if (IS_ERR(info->regulator)) {
401 dev_err(&pdev->dev, "failed to register regulator %s\n",
402 info->desc.name);
403 return PTR_ERR(info->regulator);
404 }
405

--- 38 unchanged lines hidden ---
372 /* replace driver_data with info */
373 info->regulator = regulator_register(&info->desc, &config);
374 if (IS_ERR(info->regulator)) {
375 dev_err(&pdev->dev, "failed to register regulator %s\n",
376 info->desc.name);
377 return PTR_ERR(info->regulator);
378 }
379

--- 38 unchanged lines hidden ---