88pm8607.c (a70abacb06b884131ec181551a71ef325490f374) 88pm8607.c (e7a7810ae08bfca5cb2cad8a8d55c16f299cc3fe)
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

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

18#include <linux/mfd/88pm860x.h>
19#include <linux/module.h>
20
21struct pm8607_regulator_info {
22 struct regulator_desc desc;
23 struct pm860x_chip *chip;
24 struct regulator_dev *regulator;
25 struct i2c_client *i2c;
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

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

18#include <linux/mfd/88pm860x.h>
19#include <linux/module.h>
20
21struct pm8607_regulator_info {
22 struct regulator_desc desc;
23 struct pm860x_chip *chip;
24 struct regulator_dev *regulator;
25 struct i2c_client *i2c;
26 struct i2c_client *i2c_8606;
26
27 unsigned int *vol_table;
28 unsigned int *vol_suspend;
29
30 int update_reg;
31 int update_bit;
32 int slope_double;
33};

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

237 ret = pm860x_set_bits(info->i2c, info->update_reg,
238 1 << info->update_bit,
239 1 << info->update_bit);
240 break;
241 }
242 return ret;
243}
244
27
28 unsigned int *vol_table;
29 unsigned int *vol_suspend;
30
31 int update_reg;
32 int update_bit;
33 int slope_double;
34};

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

238 ret = pm860x_set_bits(info->i2c, info->update_reg,
239 1 << info->update_bit,
240 1 << info->update_bit);
241 break;
242 }
243 return ret;
244}
245
246static int pm8606_preg_enable(struct regulator_dev *rdev)
247{
248 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
249
250 return pm860x_set_bits(info->i2c, rdev->desc->enable_reg,
251 1 << rdev->desc->enable_mask, 0);
252}
253
254static int pm8606_preg_disable(struct regulator_dev *rdev)
255{
256 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
257
258 return pm860x_set_bits(info->i2c, rdev->desc->enable_reg,
259 1 << rdev->desc->enable_mask,
260 1 << rdev->desc->enable_mask);
261}
262
263static int pm8606_preg_is_enabled(struct regulator_dev *rdev)
264{
265 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
266 int ret;
267
268 ret = pm860x_reg_read(info->i2c, rdev->desc->enable_reg);
269 if (ret < 0)
270 return ret;
271
272 return !((unsigned char)ret & (1 << rdev->desc->enable_mask));
273}
274
245static struct regulator_ops pm8607_regulator_ops = {
246 .list_voltage = pm8607_list_voltage,
247 .set_voltage_sel = pm8607_set_voltage_sel,
248 .get_voltage_sel = regulator_get_voltage_sel_regmap,
249 .enable = regulator_enable_regmap,
250 .disable = regulator_disable_regmap,
251 .is_enabled = regulator_is_enabled_regmap,
252};
253
275static struct regulator_ops pm8607_regulator_ops = {
276 .list_voltage = pm8607_list_voltage,
277 .set_voltage_sel = pm8607_set_voltage_sel,
278 .get_voltage_sel = regulator_get_voltage_sel_regmap,
279 .enable = regulator_enable_regmap,
280 .disable = regulator_disable_regmap,
281 .is_enabled = regulator_is_enabled_regmap,
282};
283
284static struct regulator_ops pm8606_preg_ops = {
285 .enable = pm8606_preg_enable,
286 .disable = pm8606_preg_disable,
287 .is_enabled = pm8606_preg_is_enabled,
288};
289
290#define PM8606_PREG(ereg, ebit) \
291{ \
292 .desc = { \
293 .name = "PREG", \
294 .ops = &pm8606_preg_ops, \
295 .type = REGULATOR_CURRENT, \
296 .id = PM8606_ID_PREG, \
297 .owner = THIS_MODULE, \
298 .enable_reg = PM8606_##ereg, \
299 .enable_mask = (ebit), \
300 }, \
301}
302
254#define PM8607_DVC(vreg, ureg, ubit, ereg, ebit) \
255{ \
256 .desc = { \
257 .name = #vreg, \
258 .ops = &pm8607_regulator_ops, \
259 .type = REGULATOR_VOLTAGE, \
260 .id = PM8607_ID_##vreg, \
261 .owner = THIS_MODULE, \

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

304 PM8607_LDO(6, LDO6, 0, SUPPLIES_EN12, 0),
305 PM8607_LDO(7, LDO7, 0, SUPPLIES_EN12, 1),
306 PM8607_LDO(8, LDO8, 0, SUPPLIES_EN12, 2),
307 PM8607_LDO(9, LDO9, 0, SUPPLIES_EN12, 3),
308 PM8607_LDO(10, LDO10, 0, SUPPLIES_EN12, 4),
309 PM8607_LDO(12, LDO12, 0, SUPPLIES_EN12, 5),
310 PM8607_LDO(13, VIBRATOR_SET, 1, VIBRATOR_SET, 0),
311 PM8607_LDO(14, LDO14, 0, SUPPLIES_EN12, 6),
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, \

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

353 PM8607_LDO(6, LDO6, 0, SUPPLIES_EN12, 0),
354 PM8607_LDO(7, LDO7, 0, SUPPLIES_EN12, 1),
355 PM8607_LDO(8, LDO8, 0, SUPPLIES_EN12, 2),
356 PM8607_LDO(9, LDO9, 0, SUPPLIES_EN12, 3),
357 PM8607_LDO(10, LDO10, 0, SUPPLIES_EN12, 4),
358 PM8607_LDO(12, LDO12, 0, SUPPLIES_EN12, 5),
359 PM8607_LDO(13, VIBRATOR_SET, 1, VIBRATOR_SET, 0),
360 PM8607_LDO(14, LDO14, 0, SUPPLIES_EN12, 6),
361
362 PM8606_PREG(PREREGULATORB, 5),
312};
313
314static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
315{
316 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
317 struct pm8607_regulator_info *info = NULL;
318 struct regulator_init_data *pdata = pdev->dev.platform_data;
319 struct regulator_config config = { };

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

331 break;
332 }
333 if (i == ARRAY_SIZE(pm8607_regulator_info)) {
334 dev_err(&pdev->dev, "Failed to find regulator %llu\n",
335 (unsigned long long)res->start);
336 return -EINVAL;
337 }
338 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
363};
364
365static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
366{
367 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
368 struct pm8607_regulator_info *info = NULL;
369 struct regulator_init_data *pdata = pdev->dev.platform_data;
370 struct regulator_config config = { };

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

382 break;
383 }
384 if (i == ARRAY_SIZE(pm8607_regulator_info)) {
385 dev_err(&pdev->dev, "Failed to find regulator %llu\n",
386 (unsigned long long)res->start);
387 return -EINVAL;
388 }
389 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
390 info->i2c_8606 = (chip->id == CHIP_PM8607) ? chip->companion :
391 chip->client;
339 info->chip = chip;
340
341 /* check DVC ramp slope double */
342 if ((i == PM8607_ID_BUCK3) && info->chip->buck3_double)
343 info->slope_double = 1;
344
345 config.dev = &pdev->dev;
346 config.init_data = pdata;

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

366{
367 struct pm8607_regulator_info *info = platform_get_drvdata(pdev);
368
369 platform_set_drvdata(pdev, NULL);
370 regulator_unregister(info->regulator);
371 return 0;
372}
373
392 info->chip = chip;
393
394 /* check DVC ramp slope double */
395 if ((i == PM8607_ID_BUCK3) && info->chip->buck3_double)
396 info->slope_double = 1;
397
398 config.dev = &pdev->dev;
399 config.init_data = pdata;

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

419{
420 struct pm8607_regulator_info *info = platform_get_drvdata(pdev);
421
422 platform_set_drvdata(pdev, NULL);
423 regulator_unregister(info->regulator);
424 return 0;
425}
426
427static struct platform_device_id pm8607_regulator_driver_ids[] = {
428 {
429 .name = "88pm860x-regulator",
430 .driver_data = 0,
431 }, {
432 .name = "88pm860x-preg",
433 .driver_data = 0,
434 },
435 { },
436};
437MODULE_DEVICE_TABLE(platform, pm8607_regulator_driver_ids);
438
374static struct platform_driver pm8607_regulator_driver = {
375 .driver = {
376 .name = "88pm860x-regulator",
377 .owner = THIS_MODULE,
378 },
379 .probe = pm8607_regulator_probe,
380 .remove = __devexit_p(pm8607_regulator_remove),
439static struct platform_driver pm8607_regulator_driver = {
440 .driver = {
441 .name = "88pm860x-regulator",
442 .owner = THIS_MODULE,
443 },
444 .probe = pm8607_regulator_probe,
445 .remove = __devexit_p(pm8607_regulator_remove),
446 .id_table = pm8607_regulator_driver_ids,
381};
382
383static int __init pm8607_regulator_init(void)
384{
385 return platform_driver_register(&pm8607_regulator_driver);
386}
387subsys_initcall(pm8607_regulator_init);
388
389static void __exit pm8607_regulator_exit(void)
390{
391 platform_driver_unregister(&pm8607_regulator_driver);
392}
393module_exit(pm8607_regulator_exit);
394
395MODULE_LICENSE("GPL");
396MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
397MODULE_DESCRIPTION("Regulator Driver for Marvell 88PM8607 PMIC");
398MODULE_ALIAS("platform:88pm8607-regulator");
447};
448
449static int __init pm8607_regulator_init(void)
450{
451 return platform_driver_register(&pm8607_regulator_driver);
452}
453subsys_initcall(pm8607_regulator_init);
454
455static void __exit pm8607_regulator_exit(void)
456{
457 platform_driver_unregister(&pm8607_regulator_driver);
458}
459module_exit(pm8607_regulator_exit);
460
461MODULE_LICENSE("GPL");
462MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
463MODULE_DESCRIPTION("Regulator Driver for Marvell 88PM8607 PMIC");
464MODULE_ALIAS("platform:88pm8607-regulator");