diff options
author | Haojian Zhuang <haojian.zhuang@gmail.com> | 2012-09-17 00:19:05 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-09-19 06:39:13 -0400 |
commit | 51acdb61185e9c7579366712a415fc929929d3bb (patch) | |
tree | c37afd2862d859ba9e9b3ae31e0b0a75b77fb476 /drivers/mfd/max8925-core.c | |
parent | 63b501e22aa9b22cdfe206a5670aaae646d93021 (diff) |
mfd: max8925: Remove array in regulator platform data
Remove array in parent's platform data. Use struct regulator_init_data
as regulator device's platform data directly. So a lot of pdata are
added into parent's platform data. And voltage out register offset
is used as IORESOURCE_REG to distinguish different regualtor devices.
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/max8925-core.c')
-rw-r--r-- | drivers/mfd/max8925-core.c | 388 |
1 files changed, 316 insertions, 72 deletions
diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c index 934be40cd542..9f54c04912f2 100644 --- a/drivers/mfd/max8925-core.c +++ b/drivers/mfd/max8925-core.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/irq.h> | 15 | #include <linux/irq.h> |
16 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/regulator/machine.h> | ||
18 | #include <linux/mfd/core.h> | 19 | #include <linux/mfd/core.h> |
19 | #include <linux/mfd/max8925.h> | 20 | #include <linux/mfd/max8925.h> |
20 | 21 | ||
@@ -109,71 +110,215 @@ static struct mfd_cell onkey_devs[] = { | |||
109 | }, | 110 | }, |
110 | }; | 111 | }; |
111 | 112 | ||
112 | #define MAX8925_REG_RESOURCE(_start, _end) \ | 113 | static struct resource sd1_resources[] __devinitdata = { |
113 | { \ | 114 | {0x06, 0x06, "sdv", IORESOURCE_REG, }, |
114 | .start = MAX8925_##_start, \ | 115 | }; |
115 | .end = MAX8925_##_end, \ | ||
116 | .flags = IORESOURCE_REG, \ | ||
117 | } | ||
118 | 116 | ||
119 | static struct resource regulator_resources[] = { | 117 | static struct resource sd2_resources[] __devinitdata = { |
120 | MAX8925_REG_RESOURCE(SDCTL1, SDCTL1), | 118 | {0x09, 0x09, "sdv", IORESOURCE_REG, }, |
121 | MAX8925_REG_RESOURCE(SDCTL2, SDCTL2), | 119 | }; |
122 | MAX8925_REG_RESOURCE(SDCTL3, SDCTL3), | 120 | |
123 | MAX8925_REG_RESOURCE(LDOCTL1, LDOCTL1), | 121 | static struct resource sd3_resources[] __devinitdata = { |
124 | MAX8925_REG_RESOURCE(LDOCTL2, LDOCTL2), | 122 | {0x0c, 0x0c, "sdv", IORESOURCE_REG, }, |
125 | MAX8925_REG_RESOURCE(LDOCTL3, LDOCTL3), | 123 | }; |
126 | MAX8925_REG_RESOURCE(LDOCTL4, LDOCTL4), | 124 | |
127 | MAX8925_REG_RESOURCE(LDOCTL5, LDOCTL5), | 125 | static struct resource ldo1_resources[] __devinitdata = { |
128 | MAX8925_REG_RESOURCE(LDOCTL6, LDOCTL6), | 126 | {0x1a, 0x1a, "ldov", IORESOURCE_REG, }, |
129 | MAX8925_REG_RESOURCE(LDOCTL7, LDOCTL7), | 127 | }; |
130 | MAX8925_REG_RESOURCE(LDOCTL8, LDOCTL8), | 128 | |
131 | MAX8925_REG_RESOURCE(LDOCTL9, LDOCTL9), | 129 | static struct resource ldo2_resources[] __devinitdata = { |
132 | MAX8925_REG_RESOURCE(LDOCTL10, LDOCTL10), | 130 | {0x1e, 0x1e, "ldov", IORESOURCE_REG, }, |
133 | MAX8925_REG_RESOURCE(LDOCTL11, LDOCTL11), | 131 | }; |
134 | MAX8925_REG_RESOURCE(LDOCTL12, LDOCTL12), | 132 | |
135 | MAX8925_REG_RESOURCE(LDOCTL13, LDOCTL13), | 133 | static struct resource ldo3_resources[] __devinitdata = { |
136 | MAX8925_REG_RESOURCE(LDOCTL14, LDOCTL14), | 134 | {0x22, 0x22, "ldov", IORESOURCE_REG, }, |
137 | MAX8925_REG_RESOURCE(LDOCTL15, LDOCTL15), | 135 | }; |
138 | MAX8925_REG_RESOURCE(LDOCTL16, LDOCTL16), | 136 | |
139 | MAX8925_REG_RESOURCE(LDOCTL17, LDOCTL17), | 137 | static struct resource ldo4_resources[] __devinitdata = { |
140 | MAX8925_REG_RESOURCE(LDOCTL18, LDOCTL18), | 138 | {0x26, 0x26, "ldov", IORESOURCE_REG, }, |
141 | MAX8925_REG_RESOURCE(LDOCTL19, LDOCTL19), | 139 | }; |
142 | MAX8925_REG_RESOURCE(LDOCTL20, LDOCTL20), | ||
143 | }; | ||
144 | |||
145 | #define MAX8925_REG_DEVS(_id) \ | ||
146 | { \ | ||
147 | .name = "max8925-regulator", \ | ||
148 | .num_resources = 1, \ | ||
149 | .resources = ®ulator_resources[MAX8925_ID_##_id], \ | ||
150 | .id = MAX8925_ID_##_id, \ | ||
151 | } | ||
152 | 140 | ||
153 | static struct mfd_cell regulator_devs[] = { | 141 | static struct resource ldo5_resources[] __devinitdata = { |
154 | MAX8925_REG_DEVS(SD1), | 142 | {0x2a, 0x2a, "ldov", IORESOURCE_REG, }, |
155 | MAX8925_REG_DEVS(SD2), | 143 | }; |
156 | MAX8925_REG_DEVS(SD3), | 144 | |
157 | MAX8925_REG_DEVS(LDO1), | 145 | static struct resource ldo6_resources[] __devinitdata = { |
158 | MAX8925_REG_DEVS(LDO2), | 146 | {0x2e, 0x2e, "ldov", IORESOURCE_REG, }, |
159 | MAX8925_REG_DEVS(LDO3), | 147 | }; |
160 | MAX8925_REG_DEVS(LDO4), | 148 | |
161 | MAX8925_REG_DEVS(LDO5), | 149 | static struct resource ldo7_resources[] __devinitdata = { |
162 | MAX8925_REG_DEVS(LDO6), | 150 | {0x32, 0x32, "ldov", IORESOURCE_REG, }, |
163 | MAX8925_REG_DEVS(LDO7), | 151 | }; |
164 | MAX8925_REG_DEVS(LDO8), | 152 | |
165 | MAX8925_REG_DEVS(LDO9), | 153 | static struct resource ldo8_resources[] __devinitdata = { |
166 | MAX8925_REG_DEVS(LDO10), | 154 | {0x36, 0x36, "ldov", IORESOURCE_REG, }, |
167 | MAX8925_REG_DEVS(LDO11), | 155 | }; |
168 | MAX8925_REG_DEVS(LDO12), | 156 | |
169 | MAX8925_REG_DEVS(LDO13), | 157 | static struct resource ldo9_resources[] __devinitdata = { |
170 | MAX8925_REG_DEVS(LDO14), | 158 | {0x3a, 0x3a, "ldov", IORESOURCE_REG, }, |
171 | MAX8925_REG_DEVS(LDO15), | 159 | }; |
172 | MAX8925_REG_DEVS(LDO16), | 160 | |
173 | MAX8925_REG_DEVS(LDO17), | 161 | static struct resource ldo10_resources[] __devinitdata = { |
174 | MAX8925_REG_DEVS(LDO18), | 162 | {0x3e, 0x3e, "ldov", IORESOURCE_REG, }, |
175 | MAX8925_REG_DEVS(LDO19), | 163 | }; |
176 | MAX8925_REG_DEVS(LDO20), | 164 | |
165 | static struct resource ldo11_resources[] __devinitdata = { | ||
166 | {0x42, 0x42, "ldov", IORESOURCE_REG, }, | ||
167 | }; | ||
168 | |||
169 | static struct resource ldo12_resources[] __devinitdata = { | ||
170 | {0x46, 0x46, "ldov", IORESOURCE_REG, }, | ||
171 | }; | ||
172 | |||
173 | static struct resource ldo13_resources[] __devinitdata = { | ||
174 | {0x4a, 0x4a, "ldov", IORESOURCE_REG, }, | ||
175 | }; | ||
176 | |||
177 | static struct resource ldo14_resources[] __devinitdata = { | ||
178 | {0x4e, 0x4e, "ldov", IORESOURCE_REG, }, | ||
179 | }; | ||
180 | |||
181 | static struct resource ldo15_resources[] __devinitdata = { | ||
182 | {0x52, 0x52, "ldov", IORESOURCE_REG, }, | ||
183 | }; | ||
184 | |||
185 | static struct resource ldo16_resources[] __devinitdata = { | ||
186 | {0x12, 0x12, "ldov", IORESOURCE_REG, }, | ||
187 | }; | ||
188 | |||
189 | static struct resource ldo17_resources[] __devinitdata = { | ||
190 | {0x16, 0x16, "ldov", IORESOURCE_REG, }, | ||
191 | }; | ||
192 | |||
193 | static struct resource ldo18_resources[] __devinitdata = { | ||
194 | {0x74, 0x74, "ldov", IORESOURCE_REG, }, | ||
195 | }; | ||
196 | |||
197 | static struct resource ldo19_resources[] __devinitdata = { | ||
198 | {0x5e, 0x5e, "ldov", IORESOURCE_REG, }, | ||
199 | }; | ||
200 | |||
201 | static struct resource ldo20_resources[] __devinitdata = { | ||
202 | {0x9e, 0x9e, "ldov", IORESOURCE_REG, }, | ||
203 | }; | ||
204 | |||
205 | static struct mfd_cell reg_devs[] __devinitdata = { | ||
206 | { | ||
207 | .name = "max8925-regulator", | ||
208 | .id = 0, | ||
209 | .num_resources = ARRAY_SIZE(sd1_resources), | ||
210 | .resources = sd1_resources, | ||
211 | }, { | ||
212 | .name = "max8925-regulator", | ||
213 | .id = 1, | ||
214 | .num_resources = ARRAY_SIZE(sd2_resources), | ||
215 | .resources = sd2_resources, | ||
216 | }, { | ||
217 | .name = "max8925-regulator", | ||
218 | .id = 2, | ||
219 | .num_resources = ARRAY_SIZE(sd3_resources), | ||
220 | .resources = sd3_resources, | ||
221 | }, { | ||
222 | .name = "max8925-regulator", | ||
223 | .id = 3, | ||
224 | .num_resources = ARRAY_SIZE(ldo1_resources), | ||
225 | .resources = ldo1_resources, | ||
226 | }, { | ||
227 | .name = "max8925-regulator", | ||
228 | .id = 4, | ||
229 | .num_resources = ARRAY_SIZE(ldo2_resources), | ||
230 | .resources = ldo2_resources, | ||
231 | }, { | ||
232 | .name = "max8925-regulator", | ||
233 | .id = 5, | ||
234 | .num_resources = ARRAY_SIZE(ldo3_resources), | ||
235 | .resources = ldo3_resources, | ||
236 | }, { | ||
237 | .name = "max8925-regulator", | ||
238 | .id = 6, | ||
239 | .num_resources = ARRAY_SIZE(ldo4_resources), | ||
240 | .resources = ldo4_resources, | ||
241 | }, { | ||
242 | .name = "max8925-regulator", | ||
243 | .id = 7, | ||
244 | .num_resources = ARRAY_SIZE(ldo5_resources), | ||
245 | .resources = ldo5_resources, | ||
246 | }, { | ||
247 | .name = "max8925-regulator", | ||
248 | .id = 8, | ||
249 | .num_resources = ARRAY_SIZE(ldo6_resources), | ||
250 | .resources = ldo6_resources, | ||
251 | }, { | ||
252 | .name = "max8925-regulator", | ||
253 | .id = 9, | ||
254 | .num_resources = ARRAY_SIZE(ldo7_resources), | ||
255 | .resources = ldo7_resources, | ||
256 | }, { | ||
257 | .name = "max8925-regulator", | ||
258 | .id = 10, | ||
259 | .num_resources = ARRAY_SIZE(ldo8_resources), | ||
260 | .resources = ldo8_resources, | ||
261 | }, { | ||
262 | .name = "max8925-regulator", | ||
263 | .id = 11, | ||
264 | .num_resources = ARRAY_SIZE(ldo9_resources), | ||
265 | .resources = ldo9_resources, | ||
266 | }, { | ||
267 | .name = "max8925-regulator", | ||
268 | .id = 12, | ||
269 | .num_resources = ARRAY_SIZE(ldo10_resources), | ||
270 | .resources = ldo10_resources, | ||
271 | }, { | ||
272 | .name = "max8925-regulator", | ||
273 | .id = 13, | ||
274 | .num_resources = ARRAY_SIZE(ldo11_resources), | ||
275 | .resources = ldo11_resources, | ||
276 | }, { | ||
277 | .name = "max8925-regulator", | ||
278 | .id = 14, | ||
279 | .num_resources = ARRAY_SIZE(ldo12_resources), | ||
280 | .resources = ldo12_resources, | ||
281 | }, { | ||
282 | .name = "max8925-regulator", | ||
283 | .id = 15, | ||
284 | .num_resources = ARRAY_SIZE(ldo13_resources), | ||
285 | .resources = ldo13_resources, | ||
286 | }, { | ||
287 | .name = "max8925-regulator", | ||
288 | .id = 16, | ||
289 | .num_resources = ARRAY_SIZE(ldo14_resources), | ||
290 | .resources = ldo14_resources, | ||
291 | }, { | ||
292 | .name = "max8925-regulator", | ||
293 | .id = 17, | ||
294 | .num_resources = ARRAY_SIZE(ldo15_resources), | ||
295 | .resources = ldo15_resources, | ||
296 | }, { | ||
297 | .name = "max8925-regulator", | ||
298 | .id = 18, | ||
299 | .num_resources = ARRAY_SIZE(ldo16_resources), | ||
300 | .resources = ldo16_resources, | ||
301 | }, { | ||
302 | .name = "max8925-regulator", | ||
303 | .id = 19, | ||
304 | .num_resources = ARRAY_SIZE(ldo17_resources), | ||
305 | .resources = ldo17_resources, | ||
306 | }, { | ||
307 | .name = "max8925-regulator", | ||
308 | .id = 20, | ||
309 | .num_resources = ARRAY_SIZE(ldo18_resources), | ||
310 | .resources = ldo18_resources, | ||
311 | }, { | ||
312 | .name = "max8925-regulator", | ||
313 | .id = 21, | ||
314 | .num_resources = ARRAY_SIZE(ldo19_resources), | ||
315 | .resources = ldo19_resources, | ||
316 | }, { | ||
317 | .name = "max8925-regulator", | ||
318 | .id = 22, | ||
319 | .num_resources = ARRAY_SIZE(ldo20_resources), | ||
320 | .resources = ldo20_resources, | ||
321 | }, | ||
177 | }; | 322 | }; |
178 | 323 | ||
179 | enum { | 324 | enum { |
@@ -569,6 +714,113 @@ tsc_irq: | |||
569 | return 0; | 714 | return 0; |
570 | } | 715 | } |
571 | 716 | ||
717 | static void __devinit init_regulator(struct max8925_chip *chip, | ||
718 | struct max8925_platform_data *pdata) | ||
719 | { | ||
720 | int ret; | ||
721 | |||
722 | if (!pdata) | ||
723 | return; | ||
724 | if (pdata->sd1) { | ||
725 | reg_devs[0].platform_data = pdata->sd1; | ||
726 | reg_devs[0].pdata_size = sizeof(struct regulator_init_data); | ||
727 | } | ||
728 | if (pdata->sd2) { | ||
729 | reg_devs[1].platform_data = pdata->sd2; | ||
730 | reg_devs[1].pdata_size = sizeof(struct regulator_init_data); | ||
731 | } | ||
732 | if (pdata->sd3) { | ||
733 | reg_devs[2].platform_data = pdata->sd3; | ||
734 | reg_devs[2].pdata_size = sizeof(struct regulator_init_data); | ||
735 | } | ||
736 | if (pdata->ldo1) { | ||
737 | reg_devs[3].platform_data = pdata->ldo1; | ||
738 | reg_devs[3].pdata_size = sizeof(struct regulator_init_data); | ||
739 | } | ||
740 | if (pdata->ldo2) { | ||
741 | reg_devs[4].platform_data = pdata->ldo2; | ||
742 | reg_devs[4].pdata_size = sizeof(struct regulator_init_data); | ||
743 | } | ||
744 | if (pdata->ldo3) { | ||
745 | reg_devs[5].platform_data = pdata->ldo3; | ||
746 | reg_devs[5].pdata_size = sizeof(struct regulator_init_data); | ||
747 | } | ||
748 | if (pdata->ldo4) { | ||
749 | reg_devs[6].platform_data = pdata->ldo4; | ||
750 | reg_devs[6].pdata_size = sizeof(struct regulator_init_data); | ||
751 | } | ||
752 | if (pdata->ldo5) { | ||
753 | reg_devs[7].platform_data = pdata->ldo5; | ||
754 | reg_devs[7].pdata_size = sizeof(struct regulator_init_data); | ||
755 | } | ||
756 | if (pdata->ldo6) { | ||
757 | reg_devs[8].platform_data = pdata->ldo6; | ||
758 | reg_devs[8].pdata_size = sizeof(struct regulator_init_data); | ||
759 | } | ||
760 | if (pdata->ldo7) { | ||
761 | reg_devs[9].platform_data = pdata->ldo7; | ||
762 | reg_devs[9].pdata_size = sizeof(struct regulator_init_data); | ||
763 | } | ||
764 | if (pdata->ldo8) { | ||
765 | reg_devs[10].platform_data = pdata->ldo8; | ||
766 | reg_devs[10].pdata_size = sizeof(struct regulator_init_data); | ||
767 | } | ||
768 | if (pdata->ldo9) { | ||
769 | reg_devs[11].platform_data = pdata->ldo9; | ||
770 | reg_devs[11].pdata_size = sizeof(struct regulator_init_data); | ||
771 | } | ||
772 | if (pdata->ldo10) { | ||
773 | reg_devs[12].platform_data = pdata->ldo10; | ||
774 | reg_devs[12].pdata_size = sizeof(struct regulator_init_data); | ||
775 | } | ||
776 | if (pdata->ldo11) { | ||
777 | reg_devs[13].platform_data = pdata->ldo11; | ||
778 | reg_devs[13].pdata_size = sizeof(struct regulator_init_data); | ||
779 | } | ||
780 | if (pdata->ldo12) { | ||
781 | reg_devs[14].platform_data = pdata->ldo12; | ||
782 | reg_devs[14].pdata_size = sizeof(struct regulator_init_data); | ||
783 | } | ||
784 | if (pdata->ldo13) { | ||
785 | reg_devs[15].platform_data = pdata->ldo13; | ||
786 | reg_devs[15].pdata_size = sizeof(struct regulator_init_data); | ||
787 | } | ||
788 | if (pdata->ldo14) { | ||
789 | reg_devs[16].platform_data = pdata->ldo14; | ||
790 | reg_devs[16].pdata_size = sizeof(struct regulator_init_data); | ||
791 | } | ||
792 | if (pdata->ldo15) { | ||
793 | reg_devs[17].platform_data = pdata->ldo15; | ||
794 | reg_devs[17].pdata_size = sizeof(struct regulator_init_data); | ||
795 | } | ||
796 | if (pdata->ldo16) { | ||
797 | reg_devs[18].platform_data = pdata->ldo16; | ||
798 | reg_devs[18].pdata_size = sizeof(struct regulator_init_data); | ||
799 | } | ||
800 | if (pdata->ldo17) { | ||
801 | reg_devs[19].platform_data = pdata->ldo17; | ||
802 | reg_devs[19].pdata_size = sizeof(struct regulator_init_data); | ||
803 | } | ||
804 | if (pdata->ldo18) { | ||
805 | reg_devs[20].platform_data = pdata->ldo18; | ||
806 | reg_devs[20].pdata_size = sizeof(struct regulator_init_data); | ||
807 | } | ||
808 | if (pdata->ldo19) { | ||
809 | reg_devs[21].platform_data = pdata->ldo19; | ||
810 | reg_devs[21].pdata_size = sizeof(struct regulator_init_data); | ||
811 | } | ||
812 | if (pdata->ldo20) { | ||
813 | reg_devs[22].platform_data = pdata->ldo20; | ||
814 | reg_devs[22].pdata_size = sizeof(struct regulator_init_data); | ||
815 | } | ||
816 | ret = mfd_add_devices(chip->dev, 0, reg_devs, ARRAY_SIZE(reg_devs), | ||
817 | NULL, 0, NULL); | ||
818 | if (ret < 0) { | ||
819 | dev_err(chip->dev, "Failed to add regulator subdev\n"); | ||
820 | return; | ||
821 | } | ||
822 | } | ||
823 | |||
572 | int __devinit max8925_device_init(struct max8925_chip *chip, | 824 | int __devinit max8925_device_init(struct max8925_chip *chip, |
573 | struct max8925_platform_data *pdata) | 825 | struct max8925_platform_data *pdata) |
574 | { | 826 | { |
@@ -608,15 +860,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip, | |||
608 | goto out_dev; | 860 | goto out_dev; |
609 | } | 861 | } |
610 | 862 | ||
611 | if (pdata) { | 863 | init_regulator(chip, pdata); |
612 | ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[0], | ||
613 | ARRAY_SIZE(regulator_devs), | ||
614 | ®ulator_resources[0], 0, NULL); | ||
615 | if (ret < 0) { | ||
616 | dev_err(chip->dev, "Failed to add regulator subdev\n"); | ||
617 | goto out_dev; | ||
618 | } | ||
619 | } | ||
620 | 864 | ||
621 | if (pdata && pdata->backlight) { | 865 | if (pdata && pdata->backlight) { |
622 | bk_devs[0].platform_data = &pdata->backlight; | 866 | bk_devs[0].platform_data = &pdata->backlight; |