diff options
-rw-r--r-- | drivers/mfd/Kconfig | 10 | ||||
-rw-r--r-- | drivers/mfd/Makefile | 1 | ||||
-rw-r--r-- | drivers/mfd/max8998.c | 160 | ||||
-rw-r--r-- | drivers/regulator/Kconfig | 9 | ||||
-rw-r--r-- | drivers/regulator/Makefile | 1 | ||||
-rw-r--r-- | drivers/regulator/max8998.c | 610 | ||||
-rw-r--r-- | include/linux/mfd/max8998-private.h | 112 | ||||
-rw-r--r-- | include/linux/mfd/max8998.h | 78 |
8 files changed, 981 insertions, 0 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 9da0e504bbe9..ad61a9e8e04e 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -252,6 +252,16 @@ config MFD_MAX8925 | |||
252 | accessing the device, additional drivers must be enabled in order | 252 | accessing the device, additional drivers must be enabled in order |
253 | to use the functionality of the device. | 253 | to use the functionality of the device. |
254 | 254 | ||
255 | config MFD_MAX8998 | ||
256 | bool "Maxim Semiconductor MAX8998 PMIC Support" | ||
257 | depends on I2C=y | ||
258 | select MFD_CORE | ||
259 | help | ||
260 | Say yes here to support for Maxim Semiconductor MAX8998. This is | ||
261 | a Power Management IC. This driver provies common support for | ||
262 | accessing the device, additional drivers must be enabled in order | ||
263 | to use the functionality of the device. | ||
264 | |||
255 | config MFD_WM8400 | 265 | config MFD_WM8400 |
256 | tristate "Support Wolfson Microelectronics WM8400" | 266 | tristate "Support Wolfson Microelectronics WM8400" |
257 | select MFD_CORE | 267 | select MFD_CORE |
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index fb503e77dc60..a362ccfe8997 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
@@ -56,6 +56,7 @@ obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o | |||
56 | obj-$(CONFIG_PMIC_DA903X) += da903x.o | 56 | obj-$(CONFIG_PMIC_DA903X) += da903x.o |
57 | max8925-objs := max8925-core.o max8925-i2c.o | 57 | max8925-objs := max8925-core.o max8925-i2c.o |
58 | obj-$(CONFIG_MFD_MAX8925) += max8925.o | 58 | obj-$(CONFIG_MFD_MAX8925) += max8925.o |
59 | obj-$(CONFIG_MFD_MAX8998) += max8998.o | ||
59 | 60 | ||
60 | pcf50633-objs := pcf50633-core.o pcf50633-irq.o | 61 | pcf50633-objs := pcf50633-core.o pcf50633-irq.o |
61 | obj-$(CONFIG_MFD_PCF50633) += pcf50633.o | 62 | obj-$(CONFIG_MFD_PCF50633) += pcf50633.o |
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c new file mode 100644 index 000000000000..0d68de21ea9e --- /dev/null +++ b/drivers/mfd/max8998.c | |||
@@ -0,0 +1,160 @@ | |||
1 | /* | ||
2 | * max8698.c - mfd core driver for the Maxim 8998 | ||
3 | * | ||
4 | * Copyright (C) 2009-2010 Samsung Electronics | ||
5 | * Kyungmin Park <kyungmin.park@samsung.com> | ||
6 | * Marek Szyprowski <m.szyprowski@samsung.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/moduleparam.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/slab.h> | ||
27 | #include <linux/i2c.h> | ||
28 | #include <linux/mutex.h> | ||
29 | #include <linux/mfd/core.h> | ||
30 | #include <linux/mfd/max8998.h> | ||
31 | #include <linux/mfd/max8998-private.h> | ||
32 | |||
33 | static struct mfd_cell max8998_devs[] = { | ||
34 | { | ||
35 | .name = "max8998-pmic", | ||
36 | } | ||
37 | }; | ||
38 | |||
39 | static int max8998_i2c_device_read(struct max8998_dev *max8998, u8 reg, u8 *dest) | ||
40 | { | ||
41 | struct i2c_client *client = max8998->i2c_client; | ||
42 | int ret; | ||
43 | |||
44 | mutex_lock(&max8998->iolock); | ||
45 | ret = i2c_smbus_read_byte_data(client, reg); | ||
46 | mutex_unlock(&max8998->iolock); | ||
47 | if (ret < 0) | ||
48 | return ret; | ||
49 | |||
50 | ret &= 0xff; | ||
51 | *dest = ret; | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | static int max8998_i2c_device_write(struct max8998_dev *max8998, u8 reg, u8 value) | ||
56 | { | ||
57 | struct i2c_client *client = max8998->i2c_client; | ||
58 | int ret; | ||
59 | |||
60 | mutex_lock(&max8998->iolock); | ||
61 | ret = i2c_smbus_write_byte_data(client, reg, value); | ||
62 | mutex_unlock(&max8998->iolock); | ||
63 | return ret; | ||
64 | } | ||
65 | |||
66 | static int max8998_i2c_device_update(struct max8998_dev *max8998, u8 reg, | ||
67 | u8 val, u8 mask) | ||
68 | { | ||
69 | struct i2c_client *client = max8998->i2c_client; | ||
70 | int ret; | ||
71 | |||
72 | mutex_lock(&max8998->iolock); | ||
73 | ret = i2c_smbus_read_byte_data(client, reg); | ||
74 | if (ret >= 0) { | ||
75 | u8 old_val = ret & 0xff; | ||
76 | u8 new_val = (val & mask) | (old_val & (~mask)); | ||
77 | ret = i2c_smbus_write_byte_data(client, reg, new_val); | ||
78 | if (ret >= 0) | ||
79 | ret = 0; | ||
80 | } | ||
81 | mutex_unlock(&max8998->iolock); | ||
82 | return ret; | ||
83 | } | ||
84 | |||
85 | static int max8998_i2c_probe(struct i2c_client *i2c, | ||
86 | const struct i2c_device_id *id) | ||
87 | { | ||
88 | struct max8998_dev *max8998; | ||
89 | int ret = 0; | ||
90 | |||
91 | max8998 = kzalloc(sizeof(struct max8998_dev), GFP_KERNEL); | ||
92 | if (max8998 == NULL) { | ||
93 | kfree(i2c); | ||
94 | return -ENOMEM; | ||
95 | } | ||
96 | |||
97 | i2c_set_clientdata(i2c, max8998); | ||
98 | max8998->dev = &i2c->dev; | ||
99 | max8998->i2c_client = i2c; | ||
100 | max8998->dev_read = max8998_i2c_device_read; | ||
101 | max8998->dev_write = max8998_i2c_device_write; | ||
102 | max8998->dev_update = max8998_i2c_device_update; | ||
103 | mutex_init(&max8998->iolock); | ||
104 | |||
105 | ret = mfd_add_devices(max8998->dev, -1, | ||
106 | max8998_devs, ARRAY_SIZE(max8998_devs), | ||
107 | NULL, 0); | ||
108 | if (ret < 0) | ||
109 | goto err; | ||
110 | |||
111 | return ret; | ||
112 | |||
113 | err: | ||
114 | mfd_remove_devices(max8998->dev); | ||
115 | kfree(max8998); | ||
116 | return ret; | ||
117 | } | ||
118 | |||
119 | static int max8998_i2c_remove(struct i2c_client *i2c) | ||
120 | { | ||
121 | struct max8998_dev *max8998 = i2c_get_clientdata(i2c); | ||
122 | |||
123 | mfd_remove_devices(max8998->dev); | ||
124 | kfree(max8998); | ||
125 | |||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | static const struct i2c_device_id max8998_i2c_id[] = { | ||
130 | { "max8998", 0 }, | ||
131 | { } | ||
132 | }; | ||
133 | MODULE_DEVICE_TABLE(i2c, max8998_i2c_id); | ||
134 | |||
135 | static struct i2c_driver max8998_i2c_driver = { | ||
136 | .driver = { | ||
137 | .name = "max8998", | ||
138 | .owner = THIS_MODULE, | ||
139 | }, | ||
140 | .probe = max8998_i2c_probe, | ||
141 | .remove = max8998_i2c_remove, | ||
142 | .id_table = max8998_i2c_id, | ||
143 | }; | ||
144 | |||
145 | static int __init max8998_i2c_init(void) | ||
146 | { | ||
147 | return i2c_add_driver(&max8998_i2c_driver); | ||
148 | } | ||
149 | /* init early so consumer devices can complete system boot */ | ||
150 | subsys_initcall(max8998_i2c_init); | ||
151 | |||
152 | static void __exit max8998_i2c_exit(void) | ||
153 | { | ||
154 | i2c_del_driver(&max8998_i2c_driver); | ||
155 | } | ||
156 | module_exit(max8998_i2c_exit); | ||
157 | |||
158 | MODULE_DESCRIPTION("MAXIM 8998 multi-function core driver"); | ||
159 | MODULE_AUTHOR("Kyungmin Park <kyungmin.park@samsung.com>"); | ||
160 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 6bf56c93a336..671b81a39482 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
@@ -100,6 +100,15 @@ config REGULATOR_MAX8925 | |||
100 | help | 100 | help |
101 | Say y here to support the voltage regulaltor of Maxim MAX8925 PMIC. | 101 | Say y here to support the voltage regulaltor of Maxim MAX8925 PMIC. |
102 | 102 | ||
103 | config REGULATOR_MAX8998 | ||
104 | tristate "Maxim 8998 voltage regulator" | ||
105 | depends on I2C | ||
106 | default n | ||
107 | help | ||
108 | This driver controls a Maxim 8998 voltage output regulator | ||
109 | via I2C bus. The provided regulator is suitable for S3C6410 | ||
110 | and S5PC1XX chips to control VCC_CORE and VCC_USIM voltages. | ||
111 | |||
103 | config REGULATOR_TWL4030 | 112 | config REGULATOR_TWL4030 |
104 | bool "TI TWL4030/TWL5030/TWL6030/TPS695x0 PMIC" | 113 | bool "TI TWL4030/TWL5030/TWL6030/TPS695x0 PMIC" |
105 | depends on TWL4030_CORE | 114 | depends on TWL4030_CORE |
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 451a14a873f6..74a4638bd9a6 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
@@ -17,6 +17,7 @@ obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o | |||
17 | obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o | 17 | obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o |
18 | obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o | 18 | obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o |
19 | obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o | 19 | obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o |
20 | obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o | ||
20 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o | 21 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o |
21 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o | 22 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o |
22 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o | 23 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o |
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c new file mode 100644 index 000000000000..174fd1957ae4 --- /dev/null +++ b/drivers/regulator/max8998.c | |||
@@ -0,0 +1,610 @@ | |||
1 | /* | ||
2 | * max8998.c - Voltage regulator driver for the Maxim 8998 | ||
3 | * | ||
4 | * Copyright (C) 2009-2010 Samsung Electronics | ||
5 | * Kyungmin Park <kyungmin.park@samsung.com> | ||
6 | * Marek Szyprowski <m.szyprowski@samsung.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/i2c.h> | ||
26 | #include <linux/err.h> | ||
27 | #include <linux/gpio.h> | ||
28 | #include <linux/slab.h> | ||
29 | #include <linux/interrupt.h> | ||
30 | #include <linux/mutex.h> | ||
31 | #include <linux/platform_device.h> | ||
32 | #include <linux/regulator/driver.h> | ||
33 | #include <linux/mfd/max8998.h> | ||
34 | #include <linux/mfd/max8998-private.h> | ||
35 | |||
36 | struct max8998_data { | ||
37 | struct device *dev; | ||
38 | struct max8998_dev *iodev; | ||
39 | int num_regulators; | ||
40 | struct regulator_dev **rdev; | ||
41 | }; | ||
42 | |||
43 | struct voltage_map_desc { | ||
44 | int min; | ||
45 | int max; | ||
46 | int step; | ||
47 | }; | ||
48 | |||
49 | /* Voltage maps */ | ||
50 | static const struct voltage_map_desc ldo23_voltage_map_desc = { | ||
51 | .min = 800, .step = 50, .max = 1300, | ||
52 | }; | ||
53 | static const struct voltage_map_desc ldo456711_voltage_map_desc = { | ||
54 | .min = 1600, .step = 100, .max = 3600, | ||
55 | }; | ||
56 | static const struct voltage_map_desc ldo8_voltage_map_desc = { | ||
57 | .min = 3000, .step = 100, .max = 3600, | ||
58 | }; | ||
59 | static const struct voltage_map_desc ldo9_voltage_map_desc = { | ||
60 | .min = 2800, .step = 100, .max = 3100, | ||
61 | }; | ||
62 | static const struct voltage_map_desc ldo10_voltage_map_desc = { | ||
63 | .min = 950, .step = 50, .max = 1300, | ||
64 | }; | ||
65 | static const struct voltage_map_desc ldo1213_voltage_map_desc = { | ||
66 | .min = 800, .step = 100, .max = 3300, | ||
67 | }; | ||
68 | static const struct voltage_map_desc ldo1415_voltage_map_desc = { | ||
69 | .min = 1200, .step = 100, .max = 3300, | ||
70 | }; | ||
71 | static const struct voltage_map_desc ldo1617_voltage_map_desc = { | ||
72 | .min = 1600, .step = 100, .max = 3600, | ||
73 | }; | ||
74 | static const struct voltage_map_desc buck12_voltage_map_desc = { | ||
75 | .min = 750, .step = 25, .max = 1525, | ||
76 | }; | ||
77 | static const struct voltage_map_desc buck3_voltage_map_desc = { | ||
78 | .min = 1600, .step = 100, .max = 3600, | ||
79 | }; | ||
80 | static const struct voltage_map_desc buck4_voltage_map_desc = { | ||
81 | .min = 800, .step = 100, .max = 2300, | ||
82 | }; | ||
83 | |||
84 | static const struct voltage_map_desc *ldo_voltage_map[] = { | ||
85 | NULL, | ||
86 | NULL, | ||
87 | &ldo23_voltage_map_desc, /* LDO2 */ | ||
88 | &ldo23_voltage_map_desc, /* LDO3 */ | ||
89 | &ldo456711_voltage_map_desc, /* LDO4 */ | ||
90 | &ldo456711_voltage_map_desc, /* LDO5 */ | ||
91 | &ldo456711_voltage_map_desc, /* LDO6 */ | ||
92 | &ldo456711_voltage_map_desc, /* LDO7 */ | ||
93 | &ldo8_voltage_map_desc, /* LDO8 */ | ||
94 | &ldo9_voltage_map_desc, /* LDO9 */ | ||
95 | &ldo10_voltage_map_desc, /* LDO10 */ | ||
96 | &ldo456711_voltage_map_desc, /* LDO11 */ | ||
97 | &ldo1213_voltage_map_desc, /* LDO12 */ | ||
98 | &ldo1213_voltage_map_desc, /* LDO13 */ | ||
99 | &ldo1415_voltage_map_desc, /* LDO14 */ | ||
100 | &ldo1415_voltage_map_desc, /* LDO15 */ | ||
101 | &ldo1617_voltage_map_desc, /* LDO16 */ | ||
102 | &ldo1617_voltage_map_desc, /* LDO17 */ | ||
103 | &buck12_voltage_map_desc, /* BUCK1 */ | ||
104 | &buck12_voltage_map_desc, /* BUCK2 */ | ||
105 | &buck3_voltage_map_desc, /* BUCK3 */ | ||
106 | &buck4_voltage_map_desc, /* BUCK4 */ | ||
107 | }; | ||
108 | |||
109 | static inline int max8998_get_ldo(struct regulator_dev *rdev) | ||
110 | { | ||
111 | return rdev_get_id(rdev); | ||
112 | } | ||
113 | |||
114 | static int max8998_list_voltage(struct regulator_dev *rdev, | ||
115 | unsigned int selector) | ||
116 | { | ||
117 | const struct voltage_map_desc *desc; | ||
118 | int ldo = max8998_get_ldo(rdev); | ||
119 | int val; | ||
120 | |||
121 | if (ldo > ARRAY_SIZE(ldo_voltage_map)) | ||
122 | return -EINVAL; | ||
123 | |||
124 | desc = ldo_voltage_map[ldo]; | ||
125 | if (desc == NULL) | ||
126 | return -EINVAL; | ||
127 | |||
128 | val = desc->min + desc->step * selector; | ||
129 | if (val > desc->max) | ||
130 | return -EINVAL; | ||
131 | |||
132 | return val * 1000; | ||
133 | } | ||
134 | |||
135 | static int max8998_get_enable_register(struct regulator_dev *rdev, | ||
136 | int *reg, int *shift) | ||
137 | { | ||
138 | int ldo = max8998_get_ldo(rdev); | ||
139 | |||
140 | switch (ldo) { | ||
141 | case MAX8998_LDO2 ... MAX8998_LDO5: | ||
142 | *reg = MAX8998_REG_ONOFF1; | ||
143 | *shift = 3 - (ldo - MAX8998_LDO2); | ||
144 | break; | ||
145 | case MAX8998_LDO6 ... MAX8998_LDO13: | ||
146 | *reg = MAX8998_REG_ONOFF2; | ||
147 | *shift = 7 - (ldo - MAX8998_LDO6); | ||
148 | break; | ||
149 | case MAX8998_LDO14 ... MAX8998_LDO17: | ||
150 | *reg = MAX8998_REG_ONOFF3; | ||
151 | *shift = 7 - (ldo - MAX8998_LDO14); | ||
152 | break; | ||
153 | case MAX8998_BUCK1 ... MAX8998_BUCK4: | ||
154 | *reg = MAX8998_REG_ONOFF1; | ||
155 | *shift = 7 - (ldo - MAX8998_BUCK1); | ||
156 | break; | ||
157 | case MAX8998_EN32KHZ_AP ... MAX8998_ENVICHG: | ||
158 | *reg = MAX8998_REG_ONOFF4; | ||
159 | *shift = 7 - (ldo - MAX8998_EN32KHZ_AP); | ||
160 | break; | ||
161 | case MAX8998_ESAFEOUT1 ... MAX8998_ESAFEOUT2: | ||
162 | *reg = MAX8998_REG_CHGR2; | ||
163 | *shift = 7 - (ldo - MAX8998_ESAFEOUT1); | ||
164 | break; | ||
165 | default: | ||
166 | return -EINVAL; | ||
167 | } | ||
168 | |||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | static int max8998_ldo_is_enabled(struct regulator_dev *rdev) | ||
173 | { | ||
174 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | ||
175 | int ret, reg, shift = 8; | ||
176 | u8 val; | ||
177 | |||
178 | ret = max8998_get_enable_register(rdev, ®, &shift); | ||
179 | if (ret) | ||
180 | return ret; | ||
181 | |||
182 | ret = max8998_read_reg(max8998->iodev, reg, &val); | ||
183 | if (ret) | ||
184 | return ret; | ||
185 | |||
186 | return val & (1 << shift); | ||
187 | } | ||
188 | |||
189 | static int max8998_ldo_enable(struct regulator_dev *rdev) | ||
190 | { | ||
191 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | ||
192 | int reg, shift = 8, ret; | ||
193 | |||
194 | ret = max8998_get_enable_register(rdev, ®, &shift); | ||
195 | if (ret) | ||
196 | return ret; | ||
197 | |||
198 | return max8998_update_reg(max8998->iodev, reg, 1<<shift, 1<<shift); | ||
199 | } | ||
200 | |||
201 | static int max8998_ldo_disable(struct regulator_dev *rdev) | ||
202 | { | ||
203 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | ||
204 | int reg, shift = 8, ret; | ||
205 | |||
206 | ret = max8998_get_enable_register(rdev, ®, &shift); | ||
207 | if (ret) | ||
208 | return ret; | ||
209 | |||
210 | return max8998_update_reg(max8998->iodev, reg, 0, 1<<shift); | ||
211 | } | ||
212 | |||
213 | static int max8998_get_voltage_register(struct regulator_dev *rdev, | ||
214 | int *_reg, int *_shift, int *_mask) | ||
215 | { | ||
216 | int ldo = max8998_get_ldo(rdev); | ||
217 | int reg, shift = 0, mask = 0xff; | ||
218 | |||
219 | switch (ldo) { | ||
220 | case MAX8998_LDO2 ... MAX8998_LDO3: | ||
221 | reg = MAX8998_REG_LDO2_LDO3; | ||
222 | mask = 0xf; | ||
223 | if (ldo == MAX8998_LDO2) | ||
224 | shift = 4; | ||
225 | else | ||
226 | shift = 0; | ||
227 | break; | ||
228 | case MAX8998_LDO4 ... MAX8998_LDO7: | ||
229 | reg = MAX8998_REG_LDO4 + (ldo - MAX8998_LDO4); | ||
230 | break; | ||
231 | case MAX8998_LDO8 ... MAX8998_LDO9: | ||
232 | reg = MAX8998_REG_LDO8_LDO9; | ||
233 | mask = 0xf; | ||
234 | if (ldo == MAX8998_LDO8) | ||
235 | shift = 4; | ||
236 | else | ||
237 | shift = 0; | ||
238 | break; | ||
239 | case MAX8998_LDO10 ... MAX8998_LDO11: | ||
240 | reg = MAX8998_REG_LDO10_LDO11; | ||
241 | if (ldo == MAX8998_LDO10) { | ||
242 | shift = 5; | ||
243 | mask = 0x7; | ||
244 | } else { | ||
245 | shift = 0; | ||
246 | mask = 0x1f; | ||
247 | } | ||
248 | break; | ||
249 | case MAX8998_LDO12 ... MAX8998_LDO17: | ||
250 | reg = MAX8998_REG_LDO12 + (ldo - MAX8998_LDO12); | ||
251 | break; | ||
252 | case MAX8998_BUCK1: | ||
253 | reg = MAX8998_REG_BUCK1_DVSARM1; | ||
254 | break; | ||
255 | case MAX8998_BUCK2: | ||
256 | reg = MAX8998_REG_BUCK2_DVSINT1; | ||
257 | break; | ||
258 | case MAX8998_BUCK3: | ||
259 | reg = MAX8998_REG_BUCK3; | ||
260 | break; | ||
261 | case MAX8998_BUCK4: | ||
262 | reg = MAX8998_REG_BUCK4; | ||
263 | break; | ||
264 | default: | ||
265 | return -EINVAL; | ||
266 | } | ||
267 | |||
268 | *_reg = reg; | ||
269 | *_shift = shift; | ||
270 | *_mask = mask; | ||
271 | |||
272 | return 0; | ||
273 | } | ||
274 | |||
275 | static int max8998_get_voltage(struct regulator_dev *rdev) | ||
276 | { | ||
277 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | ||
278 | int reg, shift = 0, mask, ret; | ||
279 | u8 val; | ||
280 | |||
281 | ret = max8998_get_voltage_register(rdev, ®, &shift, &mask); | ||
282 | if (ret) | ||
283 | return ret; | ||
284 | |||
285 | ret = max8998_read_reg(max8998->iodev, reg, &val); | ||
286 | if (ret) | ||
287 | return ret; | ||
288 | |||
289 | val >>= shift; | ||
290 | val &= mask; | ||
291 | |||
292 | return max8998_list_voltage(rdev, val); | ||
293 | } | ||
294 | |||
295 | static int max8998_set_voltage(struct regulator_dev *rdev, | ||
296 | int min_uV, int max_uV) | ||
297 | { | ||
298 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | ||
299 | int min_vol = min_uV / 1000, max_vol = max_uV / 1000; | ||
300 | const struct voltage_map_desc *desc; | ||
301 | int ldo = max8998_get_ldo(rdev); | ||
302 | int reg, shift = 0, mask, ret; | ||
303 | int i = 0; | ||
304 | |||
305 | if (ldo > ARRAY_SIZE(ldo_voltage_map)) | ||
306 | return -EINVAL; | ||
307 | |||
308 | desc = ldo_voltage_map[ldo]; | ||
309 | if (desc == NULL) | ||
310 | return -EINVAL; | ||
311 | |||
312 | if (max_vol < desc->min || min_vol > desc->max) | ||
313 | return -EINVAL; | ||
314 | |||
315 | while (desc->min + desc->step*i < max_vol && | ||
316 | desc->min + desc->step*i < desc->max) | ||
317 | i++; | ||
318 | |||
319 | ret = max8998_get_voltage_register(rdev, ®, &shift, &mask); | ||
320 | if (ret) | ||
321 | return ret; | ||
322 | |||
323 | return max8998_update_reg(max8998->iodev, reg, i<<shift, mask<<shift); | ||
324 | } | ||
325 | |||
326 | static struct regulator_ops max8998_ldo_ops = { | ||
327 | .list_voltage = max8998_list_voltage, | ||
328 | .is_enabled = max8998_ldo_is_enabled, | ||
329 | .enable = max8998_ldo_enable, | ||
330 | .disable = max8998_ldo_disable, | ||
331 | .get_voltage = max8998_get_voltage, | ||
332 | .set_voltage = max8998_set_voltage, | ||
333 | .set_suspend_enable = max8998_ldo_enable, | ||
334 | .set_suspend_disable = max8998_ldo_disable, | ||
335 | }; | ||
336 | |||
337 | static struct regulator_ops max8998_buck_ops = { | ||
338 | .list_voltage = max8998_list_voltage, | ||
339 | .is_enabled = max8998_ldo_is_enabled, | ||
340 | .enable = max8998_ldo_enable, | ||
341 | .disable = max8998_ldo_disable, | ||
342 | .get_voltage = max8998_get_voltage, | ||
343 | .set_voltage = max8998_set_voltage, | ||
344 | .set_suspend_enable = max8998_ldo_enable, | ||
345 | .set_suspend_disable = max8998_ldo_disable, | ||
346 | }; | ||
347 | |||
348 | static struct regulator_ops max8998_others_ops = { | ||
349 | .is_enabled = max8998_ldo_is_enabled, | ||
350 | .enable = max8998_ldo_enable, | ||
351 | .disable = max8998_ldo_disable, | ||
352 | .set_suspend_enable = max8998_ldo_enable, | ||
353 | .set_suspend_disable = max8998_ldo_disable, | ||
354 | }; | ||
355 | |||
356 | static struct regulator_desc regulators[] = { | ||
357 | { | ||
358 | .name = "LDO2", | ||
359 | .id = MAX8998_LDO2, | ||
360 | .ops = &max8998_ldo_ops, | ||
361 | .type = REGULATOR_VOLTAGE, | ||
362 | .owner = THIS_MODULE, | ||
363 | }, { | ||
364 | .name = "LDO3", | ||
365 | .id = MAX8998_LDO3, | ||
366 | .ops = &max8998_ldo_ops, | ||
367 | .type = REGULATOR_VOLTAGE, | ||
368 | .owner = THIS_MODULE, | ||
369 | }, { | ||
370 | .name = "LDO4", | ||
371 | .id = MAX8998_LDO4, | ||
372 | .ops = &max8998_ldo_ops, | ||
373 | .type = REGULATOR_VOLTAGE, | ||
374 | .owner = THIS_MODULE, | ||
375 | }, { | ||
376 | .name = "LDO5", | ||
377 | .id = MAX8998_LDO5, | ||
378 | .ops = &max8998_ldo_ops, | ||
379 | .type = REGULATOR_VOLTAGE, | ||
380 | .owner = THIS_MODULE, | ||
381 | }, { | ||
382 | .name = "LDO6", | ||
383 | .id = MAX8998_LDO6, | ||
384 | .ops = &max8998_ldo_ops, | ||
385 | .type = REGULATOR_VOLTAGE, | ||
386 | .owner = THIS_MODULE, | ||
387 | }, { | ||
388 | .name = "LDO7", | ||
389 | .id = MAX8998_LDO7, | ||
390 | .ops = &max8998_ldo_ops, | ||
391 | .type = REGULATOR_VOLTAGE, | ||
392 | .owner = THIS_MODULE, | ||
393 | }, { | ||
394 | .name = "LDO8", | ||
395 | .id = MAX8998_LDO8, | ||
396 | .ops = &max8998_ldo_ops, | ||
397 | .type = REGULATOR_VOLTAGE, | ||
398 | .owner = THIS_MODULE, | ||
399 | }, { | ||
400 | .name = "LDO9", | ||
401 | .id = MAX8998_LDO9, | ||
402 | .ops = &max8998_ldo_ops, | ||
403 | .type = REGULATOR_VOLTAGE, | ||
404 | .owner = THIS_MODULE, | ||
405 | }, { | ||
406 | .name = "LDO10", | ||
407 | .id = MAX8998_LDO10, | ||
408 | .ops = &max8998_ldo_ops, | ||
409 | .type = REGULATOR_VOLTAGE, | ||
410 | .owner = THIS_MODULE, | ||
411 | }, { | ||
412 | .name = "LDO11", | ||
413 | .id = MAX8998_LDO11, | ||
414 | .ops = &max8998_ldo_ops, | ||
415 | .type = REGULATOR_VOLTAGE, | ||
416 | .owner = THIS_MODULE, | ||
417 | }, { | ||
418 | .name = "LDO12", | ||
419 | .id = MAX8998_LDO12, | ||
420 | .ops = &max8998_ldo_ops, | ||
421 | .type = REGULATOR_VOLTAGE, | ||
422 | .owner = THIS_MODULE, | ||
423 | }, { | ||
424 | .name = "LDO13", | ||
425 | .id = MAX8998_LDO13, | ||
426 | .ops = &max8998_ldo_ops, | ||
427 | .type = REGULATOR_VOLTAGE, | ||
428 | .owner = THIS_MODULE, | ||
429 | }, { | ||
430 | .name = "LDO14", | ||
431 | .id = MAX8998_LDO14, | ||
432 | .ops = &max8998_ldo_ops, | ||
433 | .type = REGULATOR_VOLTAGE, | ||
434 | .owner = THIS_MODULE, | ||
435 | }, { | ||
436 | .name = "LDO15", | ||
437 | .id = MAX8998_LDO15, | ||
438 | .ops = &max8998_ldo_ops, | ||
439 | .type = REGULATOR_VOLTAGE, | ||
440 | .owner = THIS_MODULE, | ||
441 | }, { | ||
442 | .name = "LDO16", | ||
443 | .id = MAX8998_LDO16, | ||
444 | .ops = &max8998_ldo_ops, | ||
445 | .type = REGULATOR_VOLTAGE, | ||
446 | .owner = THIS_MODULE, | ||
447 | }, { | ||
448 | .name = "LDO17", | ||
449 | .id = MAX8998_LDO17, | ||
450 | .ops = &max8998_ldo_ops, | ||
451 | .type = REGULATOR_VOLTAGE, | ||
452 | .owner = THIS_MODULE, | ||
453 | }, { | ||
454 | .name = "BUCK1", | ||
455 | .id = MAX8998_BUCK1, | ||
456 | .ops = &max8998_buck_ops, | ||
457 | .type = REGULATOR_VOLTAGE, | ||
458 | .owner = THIS_MODULE, | ||
459 | }, { | ||
460 | .name = "BUCK2", | ||
461 | .id = MAX8998_BUCK2, | ||
462 | .ops = &max8998_buck_ops, | ||
463 | .type = REGULATOR_VOLTAGE, | ||
464 | .owner = THIS_MODULE, | ||
465 | }, { | ||
466 | .name = "BUCK3", | ||
467 | .id = MAX8998_BUCK3, | ||
468 | .ops = &max8998_buck_ops, | ||
469 | .type = REGULATOR_VOLTAGE, | ||
470 | .owner = THIS_MODULE, | ||
471 | }, { | ||
472 | .name = "BUCK4", | ||
473 | .id = MAX8998_BUCK4, | ||
474 | .ops = &max8998_buck_ops, | ||
475 | .type = REGULATOR_VOLTAGE, | ||
476 | .owner = THIS_MODULE, | ||
477 | }, { | ||
478 | .name = "EN32KHz AP", | ||
479 | .id = MAX8998_EN32KHZ_AP, | ||
480 | .ops = &max8998_others_ops, | ||
481 | .type = REGULATOR_VOLTAGE, | ||
482 | .owner = THIS_MODULE, | ||
483 | }, { | ||
484 | .name = "EN32KHz CP", | ||
485 | .id = MAX8998_EN32KHZ_CP, | ||
486 | .ops = &max8998_others_ops, | ||
487 | .type = REGULATOR_VOLTAGE, | ||
488 | .owner = THIS_MODULE, | ||
489 | }, { | ||
490 | .name = "ENVICHG", | ||
491 | .id = MAX8998_ENVICHG, | ||
492 | .ops = &max8998_others_ops, | ||
493 | .type = REGULATOR_VOLTAGE, | ||
494 | .owner = THIS_MODULE, | ||
495 | }, { | ||
496 | .name = "ESAFEOUT1", | ||
497 | .id = MAX8998_ESAFEOUT1, | ||
498 | .ops = &max8998_others_ops, | ||
499 | .type = REGULATOR_VOLTAGE, | ||
500 | .owner = THIS_MODULE, | ||
501 | }, { | ||
502 | .name = "ESAFEOUT2", | ||
503 | .id = MAX8998_ESAFEOUT2, | ||
504 | .ops = &max8998_others_ops, | ||
505 | .type = REGULATOR_VOLTAGE, | ||
506 | .owner = THIS_MODULE, | ||
507 | } | ||
508 | }; | ||
509 | |||
510 | static __devinit int max8998_pmic_probe(struct platform_device *pdev) | ||
511 | { | ||
512 | struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent); | ||
513 | struct max8998_platform_data *pdata = dev_get_platdata(iodev->dev); | ||
514 | struct regulator_dev **rdev; | ||
515 | struct max8998_data *max8998; | ||
516 | int i, ret, size; | ||
517 | |||
518 | if (!pdata) { | ||
519 | dev_err(pdev->dev.parent, "No platform init data supplied\n"); | ||
520 | return -ENODEV; | ||
521 | } | ||
522 | |||
523 | max8998 = kzalloc(sizeof(struct max8998_data), GFP_KERNEL); | ||
524 | if (!max8998) | ||
525 | return -ENOMEM; | ||
526 | |||
527 | size = sizeof(struct regulator_dev *) * (pdata->num_regulators + 1); | ||
528 | max8998->rdev = kzalloc(size, GFP_KERNEL); | ||
529 | if (!max8998->rdev) { | ||
530 | kfree(max8998); | ||
531 | return -ENOMEM; | ||
532 | } | ||
533 | |||
534 | rdev = max8998->rdev; | ||
535 | max8998->iodev = iodev; | ||
536 | platform_set_drvdata(pdev, max8998); | ||
537 | |||
538 | for (i = 0; i < pdata->num_regulators; i++) { | ||
539 | const struct voltage_map_desc *desc; | ||
540 | int id = pdata->regulators[i].id; | ||
541 | int index = id - MAX8998_LDO2; | ||
542 | |||
543 | desc = ldo_voltage_map[id]; | ||
544 | if (desc && regulators[index].ops != &max8998_others_ops) { | ||
545 | int count = (desc->max - desc->min) / desc->step + 1; | ||
546 | regulators[index].n_voltages = count; | ||
547 | } | ||
548 | rdev[i] = regulator_register(®ulators[index], max8998->dev, | ||
549 | pdata->regulators[i].initdata, max8998); | ||
550 | if (IS_ERR(rdev[i])) { | ||
551 | ret = PTR_ERR(rdev[i]); | ||
552 | dev_err(max8998->dev, "regulator init failed\n"); | ||
553 | rdev[i] = NULL; | ||
554 | goto err; | ||
555 | } | ||
556 | } | ||
557 | |||
558 | |||
559 | return 0; | ||
560 | err: | ||
561 | for (i = 0; i <= max8998->num_regulators; i++) | ||
562 | if (rdev[i]) | ||
563 | regulator_unregister(rdev[i]); | ||
564 | |||
565 | kfree(max8998->rdev); | ||
566 | kfree(max8998); | ||
567 | |||
568 | return ret; | ||
569 | } | ||
570 | |||
571 | static int __devexit max8998_pmic_remove(struct platform_device *pdev) | ||
572 | { | ||
573 | struct max8998_data *max8998 = platform_get_drvdata(pdev); | ||
574 | struct regulator_dev **rdev = max8998->rdev; | ||
575 | int i; | ||
576 | |||
577 | for (i = 0; i <= max8998->num_regulators; i++) | ||
578 | if (rdev[i]) | ||
579 | regulator_unregister(rdev[i]); | ||
580 | |||
581 | kfree(max8998->rdev); | ||
582 | kfree(max8998); | ||
583 | |||
584 | return 0; | ||
585 | } | ||
586 | |||
587 | static struct platform_driver max8998_pmic_driver = { | ||
588 | .driver = { | ||
589 | .name = "max8998-pmic", | ||
590 | .owner = THIS_MODULE, | ||
591 | }, | ||
592 | .probe = max8998_pmic_probe, | ||
593 | .remove = __devexit_p(max8998_pmic_remove), | ||
594 | }; | ||
595 | |||
596 | static int __init max8998_pmic_init(void) | ||
597 | { | ||
598 | return platform_driver_register(&max8998_pmic_driver); | ||
599 | } | ||
600 | subsys_initcall(max8998_pmic_init); | ||
601 | |||
602 | static void __exit max8998_pmic_cleanup(void) | ||
603 | { | ||
604 | platform_driver_unregister(&max8998_pmic_driver); | ||
605 | } | ||
606 | module_exit(max8998_pmic_cleanup); | ||
607 | |||
608 | MODULE_DESCRIPTION("MAXIM 8998 voltage regulator driver"); | ||
609 | MODULE_AUTHOR("Kyungmin Park <kyungmin.park@samsung.com>"); | ||
610 | MODULE_LICENSE("GPL"); | ||
diff --git a/include/linux/mfd/max8998-private.h b/include/linux/mfd/max8998-private.h new file mode 100644 index 000000000000..6dc75b3e2d33 --- /dev/null +++ b/include/linux/mfd/max8998-private.h | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | * max8698.h - Voltage regulator driver for the Maxim 8998 | ||
3 | * | ||
4 | * Copyright (C) 2009-2010 Samsung Electrnoics | ||
5 | * Kyungmin Park <kyungmin.park@samsung.com> | ||
6 | * Marek Szyprowski <m.szyprowski@samsung.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #ifndef __LINUX_MFD_MAX8998_PRIV_H | ||
24 | #define __LINUX_MFD_MAX8998_PRIV_H | ||
25 | |||
26 | /* MAX 8998 registers */ | ||
27 | enum { | ||
28 | MAX8998_REG_IRQ1, | ||
29 | MAX8998_REG_IRQ2, | ||
30 | MAX8998_REG_IRQ3, | ||
31 | MAX8998_REG_IRQ4, | ||
32 | MAX8998_REG_IRQM1, | ||
33 | MAX8998_REG_IRQM2, | ||
34 | MAX8998_REG_IRQM3, | ||
35 | MAX8998_REG_IRQM4, | ||
36 | MAX8998_REG_STATUS1, | ||
37 | MAX8998_REG_STATUS2, | ||
38 | MAX8998_REG_STATUSM1, | ||
39 | MAX8998_REG_STATUSM2, | ||
40 | MAX8998_REG_CHGR1, | ||
41 | MAX8998_REG_CHGR2, | ||
42 | MAX8998_REG_LDO_ACTIVE_DISCHARGE1, | ||
43 | MAX8998_REG_LDO_ACTIVE_DISCHARGE2, | ||
44 | MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, | ||
45 | MAX8998_REG_ONOFF1, | ||
46 | MAX8998_REG_ONOFF2, | ||
47 | MAX8998_REG_ONOFF3, | ||
48 | MAX8998_REG_ONOFF4, | ||
49 | MAX8998_REG_BUCK1_DVSARM1, | ||
50 | MAX8998_REG_BUCK1_DVSARM2, | ||
51 | MAX8998_REG_BUCK1_DVSARM3, | ||
52 | MAX8998_REG_BUCK1_DVSARM4, | ||
53 | MAX8998_REG_BUCK2_DVSINT1, | ||
54 | MAX8998_REG_BUCK2_DVSINT2, | ||
55 | MAX8998_REG_BUCK3, | ||
56 | MAX8998_REG_BUCK4, | ||
57 | MAX8998_REG_LDO2_LDO3, | ||
58 | MAX8998_REG_LDO4, | ||
59 | MAX8998_REG_LDO5, | ||
60 | MAX8998_REG_LDO6, | ||
61 | MAX8998_REG_LDO7, | ||
62 | MAX8998_REG_LDO8_LDO9, | ||
63 | MAX8998_REG_LDO10_LDO11, | ||
64 | MAX8998_REG_LDO12, | ||
65 | MAX8998_REG_LDO13, | ||
66 | MAX8998_REG_LDO14, | ||
67 | MAX8998_REG_LDO15, | ||
68 | MAX8998_REG_LDO16, | ||
69 | MAX8998_REG_LDO17, | ||
70 | MAX8998_REG_BKCHR, | ||
71 | MAX8998_REG_LBCNFG1, | ||
72 | MAX8998_REG_LBCNFG2, | ||
73 | }; | ||
74 | |||
75 | /** | ||
76 | * struct max8998_dev - max8998 master device for sub-drivers | ||
77 | * @dev: master device of the chip (can be used to access platform data) | ||
78 | * @i2c_client: i2c client private data | ||
79 | * @dev_read(): chip register read function | ||
80 | * @dev_write(): chip register write function | ||
81 | * @dev_update(): chip register update function | ||
82 | * @iolock: mutex for serializing io access | ||
83 | */ | ||
84 | |||
85 | struct max8998_dev { | ||
86 | struct device *dev; | ||
87 | struct i2c_client *i2c_client; | ||
88 | int (*dev_read)(struct max8998_dev *max8998, u8 reg, u8 *dest); | ||
89 | int (*dev_write)(struct max8998_dev *max8998, u8 reg, u8 val); | ||
90 | int (*dev_update)(struct max8998_dev *max8998, u8 reg, u8 val, u8 mask); | ||
91 | struct mutex iolock; | ||
92 | }; | ||
93 | |||
94 | static inline int max8998_read_reg(struct max8998_dev *max8998, u8 reg, | ||
95 | u8 *value) | ||
96 | { | ||
97 | return max8998->dev_read(max8998, reg, value); | ||
98 | } | ||
99 | |||
100 | static inline int max8998_write_reg(struct max8998_dev *max8998, u8 reg, | ||
101 | u8 value) | ||
102 | { | ||
103 | return max8998->dev_write(max8998, reg, value); | ||
104 | } | ||
105 | |||
106 | static inline int max8998_update_reg(struct max8998_dev *max8998, u8 reg, | ||
107 | u8 value, u8 mask) | ||
108 | { | ||
109 | return max8998->dev_update(max8998, reg, value, mask); | ||
110 | } | ||
111 | |||
112 | #endif /* __LINUX_MFD_MAX8998_PRIV_H */ | ||
diff --git a/include/linux/mfd/max8998.h b/include/linux/mfd/max8998.h new file mode 100644 index 000000000000..1d3601a2d853 --- /dev/null +++ b/include/linux/mfd/max8998.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * max8698.h - Voltage regulator driver for the Maxim 8998 | ||
3 | * | ||
4 | * Copyright (C) 2009-2010 Samsung Electrnoics | ||
5 | * Kyungmin Park <kyungmin.park@samsung.com> | ||
6 | * Marek Szyprowski <m.szyprowski@samsung.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #ifndef __LINUX_MFD_MAX8998_H | ||
24 | #define __LINUX_MFD_MAX8998_H | ||
25 | |||
26 | #include <linux/regulator/machine.h> | ||
27 | |||
28 | /* MAX 8998 regulator ids */ | ||
29 | enum { | ||
30 | MAX8998_LDO2 = 2, | ||
31 | MAX8998_LDO3, | ||
32 | MAX8998_LDO4, | ||
33 | MAX8998_LDO5, | ||
34 | MAX8998_LDO6, | ||
35 | MAX8998_LDO7, | ||
36 | MAX8998_LDO8, | ||
37 | MAX8998_LDO9, | ||
38 | MAX8998_LDO10, | ||
39 | MAX8998_LDO11, | ||
40 | MAX8998_LDO12, | ||
41 | MAX8998_LDO13, | ||
42 | MAX8998_LDO14, | ||
43 | MAX8998_LDO15, | ||
44 | MAX8998_LDO16, | ||
45 | MAX8998_LDO17, | ||
46 | MAX8998_BUCK1, | ||
47 | MAX8998_BUCK2, | ||
48 | MAX8998_BUCK3, | ||
49 | MAX8998_BUCK4, | ||
50 | MAX8998_EN32KHZ_AP, | ||
51 | MAX8998_EN32KHZ_CP, | ||
52 | MAX8998_ENVICHG, | ||
53 | MAX8998_ESAFEOUT1, | ||
54 | MAX8998_ESAFEOUT2, | ||
55 | }; | ||
56 | |||
57 | /** | ||
58 | * max8998_regulator_data - regulator data | ||
59 | * @id: regulator id | ||
60 | * @initdata: regulator init data (contraints, supplies, ...) | ||
61 | */ | ||
62 | struct max8998_regulator_data { | ||
63 | int id; | ||
64 | struct regulator_init_data *initdata; | ||
65 | }; | ||
66 | |||
67 | /** | ||
68 | * struct max8998_board - packages regulator init data | ||
69 | * @num_regulators: number of regultors used | ||
70 | * @regulators: array of defined regulators | ||
71 | */ | ||
72 | |||
73 | struct max8998_platform_data { | ||
74 | int num_regulators; | ||
75 | struct max8998_regulator_data *regulators; | ||
76 | }; | ||
77 | |||
78 | #endif /* __LINUX_MFD_MAX8998_H */ | ||