aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/88pm860x-core.c
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@gmail.com>2012-08-08 11:17:27 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-09-11 05:38:09 -0400
commit894fc8f2c295373e6c73943d8bc2023cc49b9bb0 (patch)
treecdb7484175436b0737596bbebf427363a641f49a /drivers/mfd/88pm860x-core.c
parenta6ccdcd98c39ac13508570dbd943a1cf1b569f55 (diff)
mfd: 88pm860x: Use REG in leds resource
Since the resources of 88pm860x leds are changed from IORESOURCE_IO to IORESOURCE_REG that is register offset, change the original self-defined IORESOURCE_IO to register offset. Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.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.c114
1 files changed, 74 insertions, 40 deletions
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index b72628e8d6ee..e364b22f957d 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -37,13 +37,35 @@ static struct resource bk2_resources[] __devinitdata = {
37 {5, 5, "current", IORESOURCE_REG, }, 37 {5, 5, "current", IORESOURCE_REG, },
38}; 38};
39 39
40static struct resource led_resources[] __devinitdata = { 40static struct resource led0_resources[] __devinitdata = {
41 {PM8606_LED1_RED, PM8606_LED1_RED, "led0-red", IORESOURCE_REG,}, 41 /* RGB1 Red LED */
42 {PM8606_LED1_GREEN, PM8606_LED1_GREEN, "led0-green", IORESOURCE_REG,}, 42 {0xd, 0xd, "control", IORESOURCE_REG, },
43 {PM8606_LED1_BLUE, PM8606_LED1_BLUE, "led0-blue", IORESOURCE_REG,}, 43 {0xc, 0xc, "blink", IORESOURCE_REG, },
44 {PM8606_LED2_RED, PM8606_LED2_RED, "led1-red", IORESOURCE_REG,}, 44};
45 {PM8606_LED2_GREEN, PM8606_LED2_GREEN, "led1-green", IORESOURCE_REG,}, 45static struct resource led1_resources[] __devinitdata = {
46 {PM8606_LED2_BLUE, PM8606_LED2_BLUE, "led1-blue", IORESOURCE_REG,}, 46 /* RGB1 Green LED */
47 {0xe, 0xe, "control", IORESOURCE_REG, },
48 {0xc, 0xc, "blink", IORESOURCE_REG, },
49};
50static struct resource led2_resources[] __devinitdata = {
51 /* RGB1 Blue LED */
52 {0xf, 0xf, "control", IORESOURCE_REG, },
53 {0xc, 0xc, "blink", IORESOURCE_REG, },
54};
55static struct resource led3_resources[] __devinitdata = {
56 /* RGB2 Red LED */
57 {0x9, 0x9, "control", IORESOURCE_REG, },
58 {0x8, 0x8, "blink", IORESOURCE_REG, },
59};
60static struct resource led4_resources[] __devinitdata = {
61 /* RGB2 Green LED */
62 {0xa, 0xa, "control", IORESOURCE_REG, },
63 {0x8, 0x8, "blink", IORESOURCE_REG, },
64};
65static struct resource led5_resources[] __devinitdata = {
66 /* RGB2 Blue LED */
67 {0xb, 0xb, "control", IORESOURCE_REG, },
68 {0x8, 0x8, "blink", IORESOURCE_REG, },
47}; 69};
48 70
49static struct resource regulator_resources[] __devinitdata = { 71static struct resource regulator_resources[] __devinitdata = {
@@ -128,12 +150,37 @@ static struct mfd_cell bk_devs[] = {
128}; 150};
129 151
130static struct mfd_cell led_devs[] = { 152static struct mfd_cell led_devs[] = {
131 {"88pm860x-led", 0,}, 153 {
132 {"88pm860x-led", 1,}, 154 .name = "88pm860x-led",
133 {"88pm860x-led", 2,}, 155 .id = 0,
134 {"88pm860x-led", 3,}, 156 .num_resources = ARRAY_SIZE(led0_resources),
135 {"88pm860x-led", 4,}, 157 .resources = led0_resources,
136 {"88pm860x-led", 5,}, 158 }, {
159 .name = "88pm860x-led",
160 .id = 1,
161 .num_resources = ARRAY_SIZE(led1_resources),
162 .resources = led1_resources,
163 }, {
164 .name = "88pm860x-led",
165 .id = 2,
166 .num_resources = ARRAY_SIZE(led2_resources),
167 .resources = led2_resources,
168 }, {
169 .name = "88pm860x-led",
170 .id = 3,
171 .num_resources = ARRAY_SIZE(led3_resources),
172 .resources = led3_resources,
173 }, {
174 .name = "88pm860x-led",
175 .id = 4,
176 .num_resources = ARRAY_SIZE(led4_resources),
177 .resources = led4_resources,
178 }, {
179 .name = "88pm860x-led",
180 .id = 5,
181 .num_resources = ARRAY_SIZE(led5_resources),
182 .resources = led5_resources,
183 },
137}; 184};
138 185
139static struct mfd_cell regulator_devs[] = { 186static struct mfd_cell regulator_devs[] = {
@@ -658,36 +705,23 @@ static void __devinit device_bk_init(struct pm860x_chip *chip,
658static void __devinit device_led_init(struct pm860x_chip *chip, 705static void __devinit device_led_init(struct pm860x_chip *chip,
659 struct pm860x_platform_data *pdata) 706 struct pm860x_platform_data *pdata)
660{ 707{
661 int ret; 708 int ret, i;
662 int i, j, id;
663
664 if ((pdata == NULL) || (pdata->led == NULL))
665 return;
666 709
667 if (pdata->num_leds > ARRAY_SIZE(led_devs)) 710 if (pdata && pdata->led) {
668 pdata->num_leds = ARRAY_SIZE(led_devs); 711 if (pdata->num_leds > ARRAY_SIZE(led_devs))
669 712 pdata->num_leds = ARRAY_SIZE(led_devs);
670 for (i = 0; i < pdata->num_leds; i++) { 713 for (i = 0; i < pdata->num_leds; i++) {
671 led_devs[i].platform_data = &pdata->led[i]; 714 led_devs[i].platform_data = &pdata->led[i];
672 led_devs[i].pdata_size = sizeof(struct pm860x_led_pdata); 715 led_devs[i].pdata_size =
673 716 sizeof(struct pm860x_led_pdata);
674 for (j = 0; j < ARRAY_SIZE(led_devs); j++) {
675 id = led_resources[j].start;
676 if (pdata->led[i].flags != id)
677 continue;
678
679 led_devs[i].num_resources = 1;
680 led_devs[i].resources = &led_resources[j],
681 ret = mfd_add_devices(chip->dev, 0,
682 &led_devs[i], 1,
683 &led_resources[j], 0);
684 if (ret < 0) {
685 dev_err(chip->dev, "Failed to add "
686 "led subdev\n");
687 return;
688 }
689 } 717 }
690 } 718 }
719 ret = mfd_add_devices(chip->dev, 0, led_devs,
720 ARRAY_SIZE(led_devs), NULL, 0);
721 if (ret < 0) {
722 dev_err(chip->dev, "Failed to add led subdev\n");
723 return;
724 }
691} 725}
692 726
693static void __devinit device_regulator_init(struct pm860x_chip *chip, 727static void __devinit device_regulator_init(struct pm860x_chip *chip,