diff options
author | Haojian Zhuang <haojian.zhuang@marvell.com> | 2010-01-06 17:04:18 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-03-07 16:17:01 -0500 |
commit | bbd51b1ff1bf57b9ed7f062486a415509968d4d9 (patch) | |
tree | a7a4270a34b8f3fa0661af088b139c8d9d8314d5 /drivers/mfd/88pm860x-core.c | |
parent | 0df883df8e8aea79b501f6262b595e66dec175dc (diff) |
mfd: Split 88pm8607 driver
Create 88pm8607-i2c driver to support all I2C operation of 88PM8607.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/88pm860x-core.c')
-rw-r--r-- | drivers/mfd/88pm860x-core.c | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c new file mode 100644 index 000000000000..d1464e54e656 --- /dev/null +++ b/drivers/mfd/88pm860x-core.c | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * Base 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 | |||
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> | ||
18 | |||
19 | |||
20 | #define PM8607_REG_RESOURCE(_start, _end) \ | ||
21 | { \ | ||
22 | .start = PM8607_##_start, \ | ||
23 | .end = PM8607_##_end, \ | ||
24 | .flags = IORESOURCE_IO, \ | ||
25 | } | ||
26 | |||
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), | ||
43 | }; | ||
44 | |||
45 | #define PM8607_REG_DEVS(_name, _id) \ | ||
46 | { \ | ||
47 | .name = "88pm8607-" #_name, \ | ||
48 | .num_resources = 1, \ | ||
49 | .resources = &pm8607_regulator_resources[PM8607_ID_##_id], \ | ||
50 | } | ||
51 | |||
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), | ||
68 | }; | ||
69 | |||
70 | int pm860x_device_init(struct pm8607_chip *chip, | ||
71 | struct pm8607_platform_data *pdata) | ||
72 | { | ||
73 | int i, count; | ||
74 | int ret; | ||
75 | |||
76 | ret = pm8607_reg_read(chip, PM8607_CHIP_ID); | ||
77 | if (ret < 0) { | ||
78 | dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret); | ||
79 | goto out; | ||
80 | } | ||
81 | if ((ret & PM8607_ID_MASK) == PM8607_ID) | ||
82 | dev_info(chip->dev, "Marvell 88PM8607 (ID: %02x) detected\n", | ||
83 | ret); | ||
84 | else { | ||
85 | dev_err(chip->dev, "Failed to detect Marvell 88PM8607. " | ||
86 | "Chip ID: %02x\n", ret); | ||
87 | goto out; | ||
88 | } | ||
89 | chip->chip_id = ret; | ||
90 | |||
91 | ret = pm8607_reg_read(chip, PM8607_BUCK3); | ||
92 | if (ret < 0) { | ||
93 | dev_err(chip->dev, "Failed to read BUCK3 register: %d\n", ret); | ||
94 | goto out; | ||
95 | } | ||
96 | if (ret & PM8607_BUCK3_DOUBLE) | ||
97 | chip->buck3_double = 1; | ||
98 | |||
99 | ret = pm8607_reg_read(chip, PM8607_MISC1); | ||
100 | if (ret < 0) { | ||
101 | dev_err(chip->dev, "Failed to read MISC1 register: %d\n", ret); | ||
102 | goto out; | ||
103 | } | ||
104 | if (pdata->i2c_port == PI2C_PORT) | ||
105 | ret |= PM8607_MISC1_PI2C; | ||
106 | else | ||
107 | ret &= ~PM8607_MISC1_PI2C; | ||
108 | ret = pm8607_reg_write(chip, PM8607_MISC1, ret); | ||
109 | if (ret < 0) { | ||
110 | dev_err(chip->dev, "Failed to write MISC1 register: %d\n", ret); | ||
111 | goto out; | ||
112 | } | ||
113 | |||
114 | count = ARRAY_SIZE(pm8607_devs); | ||
115 | for (i = 0; i < count; i++) { | ||
116 | ret = mfd_add_devices(chip->dev, i, &pm8607_devs[i], | ||
117 | 1, NULL, 0); | ||
118 | if (ret != 0) { | ||
119 | dev_err(chip->dev, "Failed to add subdevs\n"); | ||
120 | goto out; | ||
121 | } | ||
122 | } | ||
123 | out: | ||
124 | return ret; | ||
125 | } | ||
126 | |||
127 | void pm8607_device_exit(struct pm8607_chip *chip) | ||
128 | { | ||
129 | mfd_remove_devices(chip->dev); | ||
130 | } | ||
131 | |||
132 | MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM8607"); | ||
133 | MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>"); | ||
134 | MODULE_LICENSE("GPL"); | ||