88pm8607.c (2654d368ea3dc7e04a78ff2531ffd886736ae374) 88pm8607.c (0e819b51fb9b2558d7cb85400a47370a631325dc)
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 * published by the Free Software Foundation.
10 */
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/err.h>
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 * published by the Free Software Foundation.
10 */
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/err.h>
14#include <linux/i2c.h>
15#include <linux/of.h>
16#include <linux/regulator/of_regulator.h>
17#include <linux/platform_device.h>
18#include <linux/regulator/driver.h>
19#include <linux/regulator/machine.h>
20#include <linux/mfd/88pm860x.h>
21#include <linux/module.h>
22
23struct pm8607_regulator_info {
24 struct regulator_desc desc;
14#include <linux/of.h>
15#include <linux/regulator/of_regulator.h>
16#include <linux/platform_device.h>
17#include <linux/regulator/driver.h>
18#include <linux/regulator/machine.h>
19#include <linux/mfd/88pm860x.h>
20#include <linux/module.h>
21
22struct pm8607_regulator_info {
23 struct regulator_desc desc;
25 struct pm860x_chip *chip;
26 struct regulator_dev *regulator;
27 struct i2c_client *i2c;
28 struct i2c_client *i2c_8606;
29
30 unsigned int *vol_suspend;
31
32 int slope_double;
33};
34
35static const unsigned int BUCK1_table[] = {
36 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000,

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

345#endif
346
347static int pm8607_regulator_probe(struct platform_device *pdev)
348{
349 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
350 struct pm8607_regulator_info *info = NULL;
351 struct regulator_init_data *pdata = dev_get_platdata(&pdev->dev);
352 struct regulator_config config = { };
24
25 unsigned int *vol_suspend;
26
27 int slope_double;
28};
29
30static const unsigned int BUCK1_table[] = {
31 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000,

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

340#endif
341
342static int pm8607_regulator_probe(struct platform_device *pdev)
343{
344 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
345 struct pm8607_regulator_info *info = NULL;
346 struct regulator_init_data *pdata = dev_get_platdata(&pdev->dev);
347 struct regulator_config config = { };
348 struct regulator_dev *rdev;
353 struct resource *res;
354 int i;
355
356 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
357 if (res) {
358 /* There're resources in 88PM8607 regulator driver */
359 for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) {
360 info = &pm8607_regulator_info[i];

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

367 return -EINVAL;
368 }
369 } else {
370 /* There's no resource in 88PM8606 PREG regulator driver */
371 info = &pm8606_regulator_info[0];
372 /* i is used to check regulator ID */
373 i = -1;
374 }
349 struct resource *res;
350 int i;
351
352 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
353 if (res) {
354 /* There're resources in 88PM8607 regulator driver */
355 for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) {
356 info = &pm8607_regulator_info[i];

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

363 return -EINVAL;
364 }
365 } else {
366 /* There's no resource in 88PM8606 PREG regulator driver */
367 info = &pm8606_regulator_info[0];
368 /* i is used to check regulator ID */
369 i = -1;
370 }
375 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
376 info->i2c_8606 = (chip->id == CHIP_PM8607) ? chip->companion :
377 chip->client;
378 info->chip = chip;
379
380 /* check DVC ramp slope double */
371
372 /* check DVC ramp slope double */
381 if ((i == PM8607_ID_BUCK3) && info->chip->buck3_double)
373 if ((i == PM8607_ID_BUCK3) && chip->buck3_double)
382 info->slope_double = 1;
383
384 config.dev = &pdev->dev;
385 config.driver_data = info;
386
387 if (pm8607_regulator_dt_init(pdev, info, &config))
388 if (pdata)
389 config.init_data = pdata;
390
391 if (chip->id == CHIP_PM8607)
392 config.regmap = chip->regmap;
393 else
394 config.regmap = chip->regmap_companion;
395
374 info->slope_double = 1;
375
376 config.dev = &pdev->dev;
377 config.driver_data = info;
378
379 if (pm8607_regulator_dt_init(pdev, info, &config))
380 if (pdata)
381 config.init_data = pdata;
382
383 if (chip->id == CHIP_PM8607)
384 config.regmap = chip->regmap;
385 else
386 config.regmap = chip->regmap_companion;
387
396 info->regulator = devm_regulator_register(&pdev->dev, &info->desc,
397 &config);
398 if (IS_ERR(info->regulator)) {
388 rdev = devm_regulator_register(&pdev->dev, &info->desc, &config);
389 if (IS_ERR(rdev)) {
399 dev_err(&pdev->dev, "failed to register regulator %s\n",
400 info->desc.name);
390 dev_err(&pdev->dev, "failed to register regulator %s\n",
391 info->desc.name);
401 return PTR_ERR(info->regulator);
392 return PTR_ERR(rdev);
402 }
403
404 platform_set_drvdata(pdev, info);
405 return 0;
406}
407
408static const struct platform_device_id pm8607_regulator_driver_ids[] = {
409 {

--- 34 unchanged lines hidden ---
393 }
394
395 platform_set_drvdata(pdev, info);
396 return 0;
397}
398
399static const struct platform_device_id pm8607_regulator_driver_ids[] = {
400 {

--- 34 unchanged lines hidden ---