2 * Base driver for Marvell 88PM8607
4 * Copyright (C) 2009 Marvell International Ltd.
5 * Haojian Zhuang <haojian.zhuang@marvell.com>
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.
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/interrupt.h>
15 #include <linux/platform_device.h>
16 #include <linux/mfd/core.h>
17 #include <linux/mfd/88pm8607.h>
20 #define PM8607_REG_RESOURCE(_start, _end) \
22 .start = PM8607_##_start, \
23 .end = PM8607_##_end, \
24 .flags = IORESOURCE_IO, \
27 static struct resource pm8607_regulator_resources[] = {
28 PM8607_REG_RESOURCE(BUCK1, BUCK1),
29 PM8607_REG_RESOURCE(BUCK2, BUCK2),
30 PM8607_REG_RESOURCE(BUCK3, BUCK3),
31 PM8607_REG_RESOURCE(LDO1, LDO1),
32 PM8607_REG_RESOURCE(LDO2, LDO2),
33 PM8607_REG_RESOURCE(LDO3, LDO3),
34 PM8607_REG_RESOURCE(LDO4, LDO4),
35 PM8607_REG_RESOURCE(LDO5, LDO5),
36 PM8607_REG_RESOURCE(LDO6, LDO6),
37 PM8607_REG_RESOURCE(LDO7, LDO7),
38 PM8607_REG_RESOURCE(LDO8, LDO8),
39 PM8607_REG_RESOURCE(LDO9, LDO9),
40 PM8607_REG_RESOURCE(LDO10, LDO10),
41 PM8607_REG_RESOURCE(LDO12, LDO12),
42 PM8607_REG_RESOURCE(LDO14, LDO14),
45 #define PM8607_REG_DEVS(_name, _id) \
47 .name = "88pm8607-" #_name, \
49 .resources = &pm8607_regulator_resources[PM8607_ID_##_id], \
52 static struct mfd_cell pm8607_devs[] = {
53 PM8607_REG_DEVS(buck1, BUCK1),
54 PM8607_REG_DEVS(buck2, BUCK2),
55 PM8607_REG_DEVS(buck3, BUCK3),
56 PM8607_REG_DEVS(ldo1, LDO1),
57 PM8607_REG_DEVS(ldo2, LDO2),
58 PM8607_REG_DEVS(ldo3, LDO3),
59 PM8607_REG_DEVS(ldo4, LDO4),
60 PM8607_REG_DEVS(ldo5, LDO5),
61 PM8607_REG_DEVS(ldo6, LDO6),
62 PM8607_REG_DEVS(ldo7, LDO7),
63 PM8607_REG_DEVS(ldo8, LDO8),
64 PM8607_REG_DEVS(ldo9, LDO9),
65 PM8607_REG_DEVS(ldo10, LDO10),
66 PM8607_REG_DEVS(ldo12, LDO12),
67 PM8607_REG_DEVS(ldo14, LDO14),
70 int pm860x_device_init(struct pm8607_chip *chip,
71 struct pm8607_platform_data *pdata)
76 ret = pm8607_reg_read(chip, PM8607_CHIP_ID);
78 dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret);
81 if ((ret & PM8607_ID_MASK) == PM8607_ID)
82 dev_info(chip->dev, "Marvell 88PM8607 (ID: %02x) detected\n",
85 dev_err(chip->dev, "Failed to detect Marvell 88PM8607. "
86 "Chip ID: %02x\n", ret);
91 ret = pm8607_reg_read(chip, PM8607_BUCK3);
93 dev_err(chip->dev, "Failed to read BUCK3 register: %d\n", ret);
96 if (ret & PM8607_BUCK3_DOUBLE)
97 chip->buck3_double = 1;
99 ret = pm8607_reg_read(chip, PM8607_MISC1);
101 dev_err(chip->dev, "Failed to read MISC1 register: %d\n", ret);
104 if (pdata->i2c_port == PI2C_PORT)
105 ret |= PM8607_MISC1_PI2C;
107 ret &= ~PM8607_MISC1_PI2C;
108 ret = pm8607_reg_write(chip, PM8607_MISC1, ret);
110 dev_err(chip->dev, "Failed to write MISC1 register: %d\n", ret);
114 count = ARRAY_SIZE(pm8607_devs);
115 for (i = 0; i < count; i++) {
116 ret = mfd_add_devices(chip->dev, i, &pm8607_devs[i],
119 dev_err(chip->dev, "Failed to add subdevs\n");
127 void pm8607_device_exit(struct pm8607_chip *chip)
129 mfd_remove_devices(chip->dev);
132 MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM8607");
133 MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
134 MODULE_LICENSE("GPL");