diff options
author | Haojian Zhuang <haojian.zhuang@gmail.com> | 2012-08-08 11:17:28 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-09-11 05:38:17 -0400 |
commit | a70abacb06b884131ec181551a71ef325490f374 (patch) | |
tree | 4372f7751588d3b47a56571e36edfcf9a0fde0a8 | |
parent | 894fc8f2c295373e6c73943d8bc2023cc49b9bb0 (diff) |
mfd: 88pm860x: Use REG resource in regulator
Since IORESOURCE_IO is changed to IORESOURCE_REG in 88pm860x driver,
update self-defined IORESOURCE_IO resource to register offset that
is IORESOURCE_REG in regulator driver. And split regulator platform
data array into scattered platform data.
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | drivers/mfd/88pm860x-core.c | 265 | ||||
-rw-r--r-- | drivers/regulator/88pm8607.c | 5 | ||||
-rw-r--r-- | include/linux/mfd/88pm860x.h | 18 |
3 files changed, 217 insertions, 71 deletions
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c index e364b22f957d..fca15be6c0d1 100644 --- a/drivers/mfd/88pm860x-core.c +++ b/drivers/mfd/88pm860x-core.c | |||
@@ -68,25 +68,53 @@ static struct resource led5_resources[] __devinitdata = { | |||
68 | {0x8, 0x8, "blink", IORESOURCE_REG, }, | 68 | {0x8, 0x8, "blink", IORESOURCE_REG, }, |
69 | }; | 69 | }; |
70 | 70 | ||
71 | static struct resource regulator_resources[] __devinitdata = { | 71 | static struct resource buck1_resources[] __devinitdata = { |
72 | {PM8607_ID_BUCK1, PM8607_ID_BUCK1, "buck-1", IORESOURCE_REG,}, | 72 | {0x24, 0x24, "buck set", IORESOURCE_REG, }, |
73 | {PM8607_ID_BUCK2, PM8607_ID_BUCK2, "buck-2", IORESOURCE_REG,}, | 73 | }; |
74 | {PM8607_ID_BUCK3, PM8607_ID_BUCK3, "buck-3", IORESOURCE_REG,}, | 74 | static struct resource buck2_resources[] __devinitdata = { |
75 | {PM8607_ID_LDO1, PM8607_ID_LDO1, "ldo-01", IORESOURCE_REG,}, | 75 | {0x25, 0x25, "buck set", IORESOURCE_REG, }, |
76 | {PM8607_ID_LDO2, PM8607_ID_LDO2, "ldo-02", IORESOURCE_REG,}, | 76 | }; |
77 | {PM8607_ID_LDO3, PM8607_ID_LDO3, "ldo-03", IORESOURCE_REG,}, | 77 | static struct resource buck3_resources[] __devinitdata = { |
78 | {PM8607_ID_LDO4, PM8607_ID_LDO4, "ldo-04", IORESOURCE_REG,}, | 78 | {0x26, 0x26, "buck set", IORESOURCE_REG, }, |
79 | {PM8607_ID_LDO5, PM8607_ID_LDO5, "ldo-05", IORESOURCE_REG,}, | 79 | }; |
80 | {PM8607_ID_LDO6, PM8607_ID_LDO6, "ldo-06", IORESOURCE_REG,}, | 80 | static struct resource ldo1_resources[] __devinitdata = { |
81 | {PM8607_ID_LDO7, PM8607_ID_LDO7, "ldo-07", IORESOURCE_REG,}, | 81 | {0x10, 0x10, "ldo set", IORESOURCE_REG, }, |
82 | {PM8607_ID_LDO8, PM8607_ID_LDO8, "ldo-08", IORESOURCE_REG,}, | 82 | }; |
83 | {PM8607_ID_LDO9, PM8607_ID_LDO9, "ldo-09", IORESOURCE_REG,}, | 83 | static struct resource ldo2_resources[] __devinitdata = { |
84 | {PM8607_ID_LDO10, PM8607_ID_LDO10, "ldo-10", IORESOURCE_REG,}, | 84 | {0x11, 0x11, "ldo set", IORESOURCE_REG, }, |
85 | {PM8607_ID_LDO11, PM8607_ID_LDO11, "ldo-11", IORESOURCE_REG,}, | 85 | }; |
86 | {PM8607_ID_LDO12, PM8607_ID_LDO12, "ldo-12", IORESOURCE_REG,}, | 86 | static struct resource ldo3_resources[] __devinitdata = { |
87 | {PM8607_ID_LDO13, PM8607_ID_LDO13, "ldo-13", IORESOURCE_REG,}, | 87 | {0x12, 0x12, "ldo set", IORESOURCE_REG, }, |
88 | {PM8607_ID_LDO14, PM8607_ID_LDO14, "ldo-14", IORESOURCE_REG,}, | 88 | }; |
89 | {PM8607_ID_LDO15, PM8607_ID_LDO15, "ldo-15", IORESOURCE_REG,}, | 89 | static struct resource ldo4_resources[] __devinitdata = { |
90 | {0x13, 0x13, "ldo set", IORESOURCE_REG, }, | ||
91 | }; | ||
92 | static struct resource ldo5_resources[] __devinitdata = { | ||
93 | {0x14, 0x14, "ldo set", IORESOURCE_REG, }, | ||
94 | }; | ||
95 | static struct resource ldo6_resources[] __devinitdata = { | ||
96 | {0x15, 0x15, "ldo set", IORESOURCE_REG, }, | ||
97 | }; | ||
98 | static struct resource ldo7_resources[] __devinitdata = { | ||
99 | {0x16, 0x16, "ldo set", IORESOURCE_REG, }, | ||
100 | }; | ||
101 | static struct resource ldo8_resources[] __devinitdata = { | ||
102 | {0x17, 0x17, "ldo set", IORESOURCE_REG, }, | ||
103 | }; | ||
104 | static struct resource ldo9_resources[] __devinitdata = { | ||
105 | {0x18, 0x18, "ldo set", IORESOURCE_REG, }, | ||
106 | }; | ||
107 | static struct resource ldo10_resources[] __devinitdata = { | ||
108 | {0x19, 0x19, "ldo set", IORESOURCE_REG, }, | ||
109 | }; | ||
110 | static struct resource ldo12_resources[] __devinitdata = { | ||
111 | {0x1a, 0x1a, "ldo set", IORESOURCE_REG, }, | ||
112 | }; | ||
113 | static struct resource ldo_vibrator_resources[] __devinitdata = { | ||
114 | {0x28, 0x28, "ldo set", IORESOURCE_REG, }, | ||
115 | }; | ||
116 | static struct resource ldo14_resources[] __devinitdata = { | ||
117 | {0x1b, 0x1b, "ldo set", IORESOURCE_REG, }, | ||
90 | }; | 118 | }; |
91 | 119 | ||
92 | static struct resource touch_resources[] __devinitdata = { | 120 | static struct resource touch_resources[] __devinitdata = { |
@@ -183,25 +211,88 @@ static struct mfd_cell led_devs[] = { | |||
183 | }, | 211 | }, |
184 | }; | 212 | }; |
185 | 213 | ||
186 | static struct mfd_cell regulator_devs[] = { | 214 | static struct mfd_cell reg_devs[] = { |
187 | {"88pm860x-regulator", 0,}, | 215 | { |
188 | {"88pm860x-regulator", 1,}, | 216 | .name = "88pm860x-regulator", |
189 | {"88pm860x-regulator", 2,}, | 217 | .id = 0, |
190 | {"88pm860x-regulator", 3,}, | 218 | .num_resources = ARRAY_SIZE(buck1_resources), |
191 | {"88pm860x-regulator", 4,}, | 219 | .resources = buck1_resources, |
192 | {"88pm860x-regulator", 5,}, | 220 | }, { |
193 | {"88pm860x-regulator", 6,}, | 221 | .name = "88pm860x-regulator", |
194 | {"88pm860x-regulator", 7,}, | 222 | .id = 1, |
195 | {"88pm860x-regulator", 8,}, | 223 | .num_resources = ARRAY_SIZE(buck2_resources), |
196 | {"88pm860x-regulator", 9,}, | 224 | .resources = buck2_resources, |
197 | {"88pm860x-regulator", 10,}, | 225 | }, { |
198 | {"88pm860x-regulator", 11,}, | 226 | .name = "88pm860x-regulator", |
199 | {"88pm860x-regulator", 12,}, | 227 | .id = 2, |
200 | {"88pm860x-regulator", 13,}, | 228 | .num_resources = ARRAY_SIZE(buck3_resources), |
201 | {"88pm860x-regulator", 14,}, | 229 | .resources = buck3_resources, |
202 | {"88pm860x-regulator", 15,}, | 230 | }, { |
203 | {"88pm860x-regulator", 16,}, | 231 | .name = "88pm860x-regulator", |
204 | {"88pm860x-regulator", 17,}, | 232 | .id = 3, |
233 | .num_resources = ARRAY_SIZE(ldo1_resources), | ||
234 | .resources = ldo1_resources, | ||
235 | }, { | ||
236 | .name = "88pm860x-regulator", | ||
237 | .id = 4, | ||
238 | .num_resources = ARRAY_SIZE(ldo2_resources), | ||
239 | .resources = ldo2_resources, | ||
240 | }, { | ||
241 | .name = "88pm860x-regulator", | ||
242 | .id = 5, | ||
243 | .num_resources = ARRAY_SIZE(ldo3_resources), | ||
244 | .resources = ldo3_resources, | ||
245 | }, { | ||
246 | .name = "88pm860x-regulator", | ||
247 | .id = 6, | ||
248 | .num_resources = ARRAY_SIZE(ldo4_resources), | ||
249 | .resources = ldo4_resources, | ||
250 | }, { | ||
251 | .name = "88pm860x-regulator", | ||
252 | .id = 7, | ||
253 | .num_resources = ARRAY_SIZE(ldo5_resources), | ||
254 | .resources = ldo5_resources, | ||
255 | }, { | ||
256 | .name = "88pm860x-regulator", | ||
257 | .id = 8, | ||
258 | .num_resources = ARRAY_SIZE(ldo6_resources), | ||
259 | .resources = ldo6_resources, | ||
260 | }, { | ||
261 | .name = "88pm860x-regulator", | ||
262 | .id = 9, | ||
263 | .num_resources = ARRAY_SIZE(ldo7_resources), | ||
264 | .resources = ldo7_resources, | ||
265 | }, { | ||
266 | .name = "88pm860x-regulator", | ||
267 | .id = 10, | ||
268 | .num_resources = ARRAY_SIZE(ldo8_resources), | ||
269 | .resources = ldo8_resources, | ||
270 | }, { | ||
271 | .name = "88pm860x-regulator", | ||
272 | .id = 11, | ||
273 | .num_resources = ARRAY_SIZE(ldo9_resources), | ||
274 | .resources = ldo9_resources, | ||
275 | }, { | ||
276 | .name = "88pm860x-regulator", | ||
277 | .id = 12, | ||
278 | .num_resources = ARRAY_SIZE(ldo10_resources), | ||
279 | .resources = ldo10_resources, | ||
280 | }, { | ||
281 | .name = "88pm860x-regulator", | ||
282 | .id = 13, | ||
283 | .num_resources = ARRAY_SIZE(ldo12_resources), | ||
284 | .resources = ldo12_resources, | ||
285 | }, { | ||
286 | .name = "88pm860x-regulator", | ||
287 | .id = 14, | ||
288 | .num_resources = ARRAY_SIZE(ldo_vibrator_resources), | ||
289 | .resources = ldo_vibrator_resources, | ||
290 | }, { | ||
291 | .name = "88pm860x-regulator", | ||
292 | .id = 15, | ||
293 | .num_resources = ARRAY_SIZE(ldo14_resources), | ||
294 | .resources = ldo14_resources, | ||
295 | }, | ||
205 | }; | 296 | }; |
206 | 297 | ||
207 | static struct mfd_cell touch_devs[] = { | 298 | static struct mfd_cell touch_devs[] = { |
@@ -727,38 +818,80 @@ static void __devinit device_led_init(struct pm860x_chip *chip, | |||
727 | static void __devinit device_regulator_init(struct pm860x_chip *chip, | 818 | static void __devinit device_regulator_init(struct pm860x_chip *chip, |
728 | struct pm860x_platform_data *pdata) | 819 | struct pm860x_platform_data *pdata) |
729 | { | 820 | { |
730 | struct regulator_init_data *initdata; | ||
731 | int ret; | 821 | int ret; |
732 | int i, seq; | ||
733 | 822 | ||
734 | if ((pdata == NULL) || (pdata->regulator == NULL)) | 823 | if (pdata == NULL) |
824 | return; | ||
825 | if (pdata->buck1) { | ||
826 | reg_devs[0].platform_data = pdata->buck1; | ||
827 | reg_devs[0].pdata_size = sizeof(struct regulator_init_data); | ||
828 | } | ||
829 | if (pdata->buck2) { | ||
830 | reg_devs[1].platform_data = pdata->buck2; | ||
831 | reg_devs[1].pdata_size = sizeof(struct regulator_init_data); | ||
832 | } | ||
833 | if (pdata->buck3) { | ||
834 | reg_devs[2].platform_data = pdata->buck3; | ||
835 | reg_devs[2].pdata_size = sizeof(struct regulator_init_data); | ||
836 | } | ||
837 | if (pdata->ldo1) { | ||
838 | reg_devs[3].platform_data = pdata->ldo1; | ||
839 | reg_devs[3].pdata_size = sizeof(struct regulator_init_data); | ||
840 | } | ||
841 | if (pdata->ldo2) { | ||
842 | reg_devs[4].platform_data = pdata->ldo2; | ||
843 | reg_devs[4].pdata_size = sizeof(struct regulator_init_data); | ||
844 | } | ||
845 | if (pdata->ldo3) { | ||
846 | reg_devs[5].platform_data = pdata->ldo3; | ||
847 | reg_devs[5].pdata_size = sizeof(struct regulator_init_data); | ||
848 | } | ||
849 | if (pdata->ldo4) { | ||
850 | reg_devs[6].platform_data = pdata->ldo4; | ||
851 | reg_devs[6].pdata_size = sizeof(struct regulator_init_data); | ||
852 | } | ||
853 | if (pdata->ldo5) { | ||
854 | reg_devs[7].platform_data = pdata->ldo5; | ||
855 | reg_devs[7].pdata_size = sizeof(struct regulator_init_data); | ||
856 | } | ||
857 | if (pdata->ldo6) { | ||
858 | reg_devs[8].platform_data = pdata->ldo6; | ||
859 | reg_devs[8].pdata_size = sizeof(struct regulator_init_data); | ||
860 | } | ||
861 | if (pdata->ldo7) { | ||
862 | reg_devs[9].platform_data = pdata->ldo7; | ||
863 | reg_devs[9].pdata_size = sizeof(struct regulator_init_data); | ||
864 | } | ||
865 | if (pdata->ldo8) { | ||
866 | reg_devs[10].platform_data = pdata->ldo8; | ||
867 | reg_devs[10].pdata_size = sizeof(struct regulator_init_data); | ||
868 | } | ||
869 | if (pdata->ldo9) { | ||
870 | reg_devs[11].platform_data = pdata->ldo9; | ||
871 | reg_devs[11].pdata_size = sizeof(struct regulator_init_data); | ||
872 | } | ||
873 | if (pdata->ldo10) { | ||
874 | reg_devs[12].platform_data = pdata->ldo10; | ||
875 | reg_devs[12].pdata_size = sizeof(struct regulator_init_data); | ||
876 | } | ||
877 | if (pdata->ldo12) { | ||
878 | reg_devs[13].platform_data = pdata->ldo12; | ||
879 | reg_devs[13].pdata_size = sizeof(struct regulator_init_data); | ||
880 | } | ||
881 | if (pdata->ldo_vibrator) { | ||
882 | reg_devs[14].platform_data = pdata->ldo_vibrator; | ||
883 | reg_devs[14].pdata_size = sizeof(struct regulator_init_data); | ||
884 | } | ||
885 | if (pdata->ldo14) { | ||
886 | reg_devs[15].platform_data = pdata->ldo14; | ||
887 | reg_devs[15].pdata_size = sizeof(struct regulator_init_data); | ||
888 | } | ||
889 | ret = mfd_add_devices(chip->dev, 0, reg_devs, | ||
890 | ARRAY_SIZE(reg_devs), NULL, 0); | ||
891 | if (ret < 0) { | ||
892 | dev_err(chip->dev, "Failed to add regulator subdev\n"); | ||
735 | return; | 893 | return; |
736 | |||
737 | if (pdata->num_regulators > ARRAY_SIZE(regulator_devs)) | ||
738 | pdata->num_regulators = ARRAY_SIZE(regulator_devs); | ||
739 | |||
740 | for (i = 0, seq = -1; i < pdata->num_regulators; i++) { | ||
741 | initdata = &pdata->regulator[i]; | ||
742 | seq = *(unsigned int *)initdata->driver_data; | ||
743 | if ((seq < 0) || (seq > PM8607_ID_RG_MAX)) { | ||
744 | dev_err(chip->dev, "Wrong ID(%d) on regulator(%s)\n", | ||
745 | seq, initdata->constraints.name); | ||
746 | goto out; | ||
747 | } | ||
748 | regulator_devs[i].platform_data = &pdata->regulator[i]; | ||
749 | regulator_devs[i].pdata_size = sizeof(struct regulator_init_data); | ||
750 | regulator_devs[i].num_resources = 1; | ||
751 | regulator_devs[i].resources = ®ulator_resources[seq]; | ||
752 | |||
753 | ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[i], 1, | ||
754 | ®ulator_resources[seq], 0); | ||
755 | if (ret < 0) { | ||
756 | dev_err(chip->dev, "Failed to add regulator subdev\n"); | ||
757 | goto out; | ||
758 | } | ||
759 | } | 894 | } |
760 | out: | ||
761 | return; | ||
762 | } | 895 | } |
763 | 896 | ||
764 | static void __devinit device_rtc_init(struct pm860x_chip *chip, | 897 | static void __devinit device_rtc_init(struct pm860x_chip *chip, |
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index 0b76372aee72..843c89a15472 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
@@ -322,12 +322,12 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev) | |||
322 | 322 | ||
323 | res = platform_get_resource(pdev, IORESOURCE_REG, 0); | 323 | res = platform_get_resource(pdev, IORESOURCE_REG, 0); |
324 | if (res == NULL) { | 324 | if (res == NULL) { |
325 | dev_err(&pdev->dev, "No I/O resource!\n"); | 325 | dev_err(&pdev->dev, "No REG resource!\n"); |
326 | return -EINVAL; | 326 | return -EINVAL; |
327 | } | 327 | } |
328 | for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) { | 328 | for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) { |
329 | info = &pm8607_regulator_info[i]; | 329 | info = &pm8607_regulator_info[i]; |
330 | if (info->desc.id == res->start) | 330 | if (info->desc.vsel_reg == res->start) |
331 | break; | 331 | break; |
332 | } | 332 | } |
333 | if (i == ARRAY_SIZE(pm8607_regulator_info)) { | 333 | if (i == ARRAY_SIZE(pm8607_regulator_info)) { |
@@ -351,7 +351,6 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev) | |||
351 | else | 351 | else |
352 | config.regmap = chip->regmap_companion; | 352 | config.regmap = chip->regmap_companion; |
353 | 353 | ||
354 | /* replace driver_data with info */ | ||
355 | info->regulator = regulator_register(&info->desc, &config); | 354 | info->regulator = regulator_register(&info->desc, &config); |
356 | if (IS_ERR(info->regulator)) { | 355 | if (IS_ERR(info->regulator)) { |
357 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 356 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
diff --git a/include/linux/mfd/88pm860x.h b/include/linux/mfd/88pm860x.h index 2d042f972c68..87c933d1b912 100644 --- a/include/linux/mfd/88pm860x.h +++ b/include/linux/mfd/88pm860x.h | |||
@@ -359,7 +359,22 @@ struct pm860x_platform_data { | |||
359 | struct pm860x_rtc_pdata *rtc; | 359 | struct pm860x_rtc_pdata *rtc; |
360 | struct pm860x_touch_pdata *touch; | 360 | struct pm860x_touch_pdata *touch; |
361 | struct pm860x_power_pdata *power; | 361 | struct pm860x_power_pdata *power; |
362 | struct regulator_init_data *regulator; | 362 | struct regulator_init_data *buck1; |
363 | struct regulator_init_data *buck2; | ||
364 | struct regulator_init_data *buck3; | ||
365 | struct regulator_init_data *ldo1; | ||
366 | struct regulator_init_data *ldo2; | ||
367 | struct regulator_init_data *ldo3; | ||
368 | struct regulator_init_data *ldo4; | ||
369 | struct regulator_init_data *ldo5; | ||
370 | struct regulator_init_data *ldo6; | ||
371 | struct regulator_init_data *ldo7; | ||
372 | struct regulator_init_data *ldo8; | ||
373 | struct regulator_init_data *ldo9; | ||
374 | struct regulator_init_data *ldo10; | ||
375 | struct regulator_init_data *ldo12; | ||
376 | struct regulator_init_data *ldo_vibrator; | ||
377 | struct regulator_init_data *ldo14; | ||
363 | 378 | ||
364 | unsigned short companion_addr; /* I2C address of companion chip */ | 379 | unsigned short companion_addr; /* I2C address of companion chip */ |
365 | int i2c_port; /* Controlled by GI2C or PI2C */ | 380 | int i2c_port; /* Controlled by GI2C or PI2C */ |
@@ -367,7 +382,6 @@ struct pm860x_platform_data { | |||
367 | int irq_base; /* IRQ base number of 88pm860x */ | 382 | int irq_base; /* IRQ base number of 88pm860x */ |
368 | int num_leds; | 383 | int num_leds; |
369 | int num_backlights; | 384 | int num_backlights; |
370 | int num_regulators; | ||
371 | }; | 385 | }; |
372 | 386 | ||
373 | extern int pm8606_osc_enable(struct pm860x_chip *, unsigned short); | 387 | extern int pm8606_osc_enable(struct pm860x_chip *, unsigned short); |