Commit c9f560b3d0222f6a6e3faeda324e786e230e4f20

Authored by Haojian Zhuang
Committed by Samuel Ortiz
1 parent 22aad0011e

mfd: Adopt mfd_data in 88pm860x input driver

Copy 88pm860x platform data into different mfd_data structure for
onkey/touch/codec/power driver. So move the identification of
device node from those drivers to mfd driver.

Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

Showing 2 changed files with 127 additions and 126 deletions Side-by-side Diff

drivers/input/misc/88pm860x_onkey.c
... ... @@ -74,7 +74,7 @@
74 74 info->chip = chip;
75 75 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
76 76 info->dev = &pdev->dev;
77   - info->irq = irq + chip->irq_base;
  77 + info->irq = irq;
78 78  
79 79 info->idev = input_allocate_device();
80 80 if (!info->idev) {
drivers/mfd/88pm860x-core.c
... ... @@ -57,6 +57,39 @@
57 57 {PM8607_ID_LDO15, PM8607_ID_LDO15, "ldo-15", IORESOURCE_IO,},
58 58 };
59 59  
  60 +static struct resource touch_resources[] __initdata = {
  61 + {PM8607_IRQ_PEN, PM8607_IRQ_PEN, "touch", IORESOURCE_IRQ,},
  62 +};
  63 +
  64 +static struct resource onkey_resources[] __initdata = {
  65 + {PM8607_IRQ_ONKEY, PM8607_IRQ_ONKEY, "onkey", IORESOURCE_IRQ,},
  66 +};
  67 +
  68 +static struct resource codec_resources[] __initdata = {
  69 + /* Headset microphone insertion or removal */
  70 + {PM8607_IRQ_MICIN, PM8607_IRQ_MICIN, "micin", IORESOURCE_IRQ,},
  71 + /* Hook-switch press or release */
  72 + {PM8607_IRQ_HOOK, PM8607_IRQ_HOOK, "hook", IORESOURCE_IRQ,},
  73 + /* Headset insertion or removal */
  74 + {PM8607_IRQ_HEADSET, PM8607_IRQ_HEADSET, "headset", IORESOURCE_IRQ,},
  75 + /* Audio short */
  76 + {PM8607_IRQ_AUDIO_SHORT, PM8607_IRQ_AUDIO_SHORT, "audio-short", IORESOURCE_IRQ,},
  77 +};
  78 +
  79 +static struct resource battery_resources[] __initdata = {
  80 + {PM8607_IRQ_CC, PM8607_IRQ_CC, "columb counter", IORESOURCE_IRQ,},
  81 + {PM8607_IRQ_BAT, PM8607_IRQ_BAT, "battery", IORESOURCE_IRQ,},
  82 +};
  83 +
  84 +static struct resource charger_resources[] __initdata = {
  85 + {PM8607_IRQ_CHG, PM8607_IRQ_CHG, "charger detect", IORESOURCE_IRQ,},
  86 + {PM8607_IRQ_CHG_DONE, PM8607_IRQ_CHG_DONE, "charging done", IORESOURCE_IRQ,},
  87 + {PM8607_IRQ_CHG_FAULT, PM8607_IRQ_CHG_FAULT, "charging timeout", IORESOURCE_IRQ,},
  88 + {PM8607_IRQ_GPADC1, PM8607_IRQ_GPADC1, "battery temperature", IORESOURCE_IRQ,},
  89 + {PM8607_IRQ_VBAT, PM8607_IRQ_VBAT, "battery voltage", IORESOURCE_IRQ,},
  90 + {PM8607_IRQ_VCHG, PM8607_IRQ_VCHG, "vchg voltage", IORESOURCE_IRQ,},
  91 +};
  92 +
60 93 static struct mfd_cell bk_devs[] __initdata = {
61 94 {"88pm860x-backlight", 0,},
62 95 {"88pm860x-backlight", 1,},
63 96  
64 97  
65 98  
66 99  
67 100  
... ... @@ -93,99 +126,29 @@
93 126 {"88pm860x-regulator", 17,},
94 127 };
95 128  
96   -static struct pm860x_backlight_pdata bk_pdata[ARRAY_SIZE(bk_devs)];
97   -static struct pm860x_led_pdata led_pdata[ARRAY_SIZE(led_devs)];
98   -static struct regulator_init_data regulator_pdata[ARRAY_SIZE(regulator_devs)];
99   -
100   -static struct resource touch_resources[] = {
101   - {
102   - .start = PM8607_IRQ_PEN,
103   - .end = PM8607_IRQ_PEN,
104   - .flags = IORESOURCE_IRQ,
105   - },
  129 +static struct mfd_cell touch_devs[] __initdata = {
  130 + {"88pm860x-touch", -1,},
106 131 };
107 132  
108   -static struct mfd_cell touch_devs[] = {
109   - {
110   - .name = "88pm860x-touch",
111   - .num_resources = 1,
112   - .resources = &touch_resources[0],
113   - },
  133 +static struct mfd_cell onkey_devs[] __initdata = {
  134 + {"88pm860x-onkey", -1,},
114 135 };
115 136  
116   -static struct resource power_supply_resources[] = {
117   - {
118   - .name = "88pm860x-power",
119   - .start = PM8607_IRQ_CHG,
120   - .end = PM8607_IRQ_CHG,
121   - .flags = IORESOURCE_IRQ,
122   - },
  137 +static struct mfd_cell codec_devs[] __initdata = {
  138 + {"88pm860x-codec", -1,},
123 139 };
124 140  
125 141 static struct mfd_cell power_devs[] = {
126   - {
127   - .name = "88pm860x-power",
128   - .num_resources = 1,
129   - .resources = &power_supply_resources[0],
130   - .id = -1,
131   - },
  142 + {"88pm860x-battery", -1,},
  143 + {"88pm860x-charger", -1,},
132 144 };
133 145  
134   -static struct resource onkey_resources[] = {
135   - {
136   - .name = "88pm860x-onkey",
137   - .start = PM8607_IRQ_ONKEY,
138   - .end = PM8607_IRQ_ONKEY,
139   - .flags = IORESOURCE_IRQ,
140   - },
141   -};
  146 +static struct pm860x_backlight_pdata bk_pdata[ARRAY_SIZE(bk_devs)];
  147 +static struct pm860x_led_pdata led_pdata[ARRAY_SIZE(led_devs)];
  148 +static struct regulator_init_data regulator_pdata[ARRAY_SIZE(regulator_devs)];
  149 +static struct pm860x_touch_pdata touch_pdata;
  150 +static struct pm860x_power_pdata power_pdata;
142 151  
143   -static struct mfd_cell onkey_devs[] = {
144   - {
145   - .name = "88pm860x-onkey",
146   - .num_resources = 1,
147   - .resources = &onkey_resources[0],
148   - .id = -1,
149   - },
150   -};
151   -
152   -static struct resource codec_resources[] = {
153   - {
154   - /* Headset microphone insertion or removal */
155   - .name = "micin",
156   - .start = PM8607_IRQ_MICIN,
157   - .end = PM8607_IRQ_MICIN,
158   - .flags = IORESOURCE_IRQ,
159   - }, {
160   - /* Hook-switch press or release */
161   - .name = "hook",
162   - .start = PM8607_IRQ_HOOK,
163   - .end = PM8607_IRQ_HOOK,
164   - .flags = IORESOURCE_IRQ,
165   - }, {
166   - /* Headset insertion or removal */
167   - .name = "headset",
168   - .start = PM8607_IRQ_HEADSET,
169   - .end = PM8607_IRQ_HEADSET,
170   - .flags = IORESOURCE_IRQ,
171   - }, {
172   - /* Audio short */
173   - .name = "audio-short",
174   - .start = PM8607_IRQ_AUDIO_SHORT,
175   - .end = PM8607_IRQ_AUDIO_SHORT,
176   - .flags = IORESOURCE_IRQ,
177   - },
178   -};
179   -
180   -static struct mfd_cell codec_devs[] = {
181   - {
182   - .name = "88pm860x-codec",
183   - .num_resources = ARRAY_SIZE(codec_resources),
184   - .resources = &codec_resources[0],
185   - .id = -1,
186   - },
187   -};
188   -
189 152 struct pm860x_irq_data {
190 153 int reg;
191 154 int mask_reg;
... ... @@ -672,6 +635,82 @@
672 635 return;
673 636 }
674 637  
  638 +static void __devinit device_touch_init(struct pm860x_chip *chip,
  639 + struct i2c_client *i2c,
  640 + struct pm860x_platform_data *pdata)
  641 +{
  642 + int ret;
  643 +
  644 + if ((pdata == NULL) || (pdata->touch == NULL))
  645 + return;
  646 +
  647 + memcpy(&touch_pdata, pdata->touch, sizeof(struct pm860x_touch_pdata));
  648 + touch_devs[0].mfd_data = &touch_pdata;
  649 + touch_devs[0].num_resources = ARRAY_SIZE(touch_resources);
  650 + touch_devs[0].resources = &touch_resources[0];
  651 + ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
  652 + ARRAY_SIZE(touch_devs), &touch_resources[0],
  653 + chip->irq_base);
  654 + if (ret < 0)
  655 + dev_err(chip->dev, "Failed to add touch subdev\n");
  656 +}
  657 +
  658 +static void __devinit device_power_init(struct pm860x_chip *chip,
  659 + struct i2c_client *i2c,
  660 + struct pm860x_platform_data *pdata)
  661 +{
  662 + int ret;
  663 +
  664 + if ((pdata == NULL) || (pdata->power == NULL))
  665 + return;
  666 +
  667 + memcpy(&power_pdata, pdata->power, sizeof(struct pm860x_power_pdata));
  668 + power_devs[0].mfd_data = &power_pdata;
  669 + power_devs[0].num_resources = ARRAY_SIZE(battery_resources);
  670 + power_devs[0].resources = &battery_resources[0],
  671 + ret = mfd_add_devices(chip->dev, 0, &power_devs[0], 1,
  672 + &battery_resources[0], chip->irq_base);
  673 + if (ret < 0)
  674 + dev_err(chip->dev, "Failed to add battery subdev\n");
  675 +
  676 + power_devs[1].mfd_data = &power_pdata;
  677 + power_devs[1].num_resources = ARRAY_SIZE(charger_resources);
  678 + power_devs[1].resources = &charger_resources[0],
  679 + ret = mfd_add_devices(chip->dev, 0, &power_devs[1], 1,
  680 + &charger_resources[0], chip->irq_base);
  681 + if (ret < 0)
  682 + dev_err(chip->dev, "Failed to add charger subdev\n");
  683 +}
  684 +
  685 +static void __devinit device_onkey_init(struct pm860x_chip *chip,
  686 + struct i2c_client *i2c,
  687 + struct pm860x_platform_data *pdata)
  688 +{
  689 + int ret;
  690 +
  691 + onkey_devs[0].num_resources = ARRAY_SIZE(onkey_resources);
  692 + onkey_devs[0].resources = &onkey_resources[0],
  693 + ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
  694 + ARRAY_SIZE(onkey_devs), &onkey_resources[0],
  695 + chip->irq_base);
  696 + if (ret < 0)
  697 + dev_err(chip->dev, "Failed to add onkey subdev\n");
  698 +}
  699 +
  700 +static void __devinit device_codec_init(struct pm860x_chip *chip,
  701 + struct i2c_client *i2c,
  702 + struct pm860x_platform_data *pdata)
  703 +{
  704 + int ret;
  705 +
  706 + codec_devs[0].num_resources = ARRAY_SIZE(codec_resources);
  707 + codec_devs[0].resources = &codec_resources[0],
  708 + ret = mfd_add_devices(chip->dev, 0, &codec_devs[0],
  709 + ARRAY_SIZE(codec_devs), &codec_resources[0], 0);
  710 + if (ret < 0)
  711 + dev_err(chip->dev, "Failed to add codec subdev\n");
  712 +}
  713 +
675 714 static void __devinit device_8607_init(struct pm860x_chip *chip,
676 715 struct i2c_client *i2c,
677 716 struct pm860x_platform_data *pdata)
678 717  
... ... @@ -727,49 +766,11 @@
727 766 if (ret < 0)
728 767 goto out;
729 768  
730   - if (pdata && pdata->touch) {
731   - ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
732   - ARRAY_SIZE(touch_devs),
733   - &touch_resources[0], 0);
734   - if (ret < 0) {
735   - dev_err(chip->dev, "Failed to add touch "
736   - "subdev\n");
737   - goto out_dev;
738   - }
739   - }
740   -
741   - if (pdata && pdata->power) {
742   - ret = mfd_add_devices(chip->dev, 0, &power_devs[0],
743   - ARRAY_SIZE(power_devs),
744   - &power_supply_resources[0], 0);
745   - if (ret < 0) {
746   - dev_err(chip->dev, "Failed to add power supply "
747   - "subdev\n");
748   - goto out_dev;
749   - }
750   - }
751   -
752   - ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
753   - ARRAY_SIZE(onkey_devs),
754   - &onkey_resources[0], 0);
755   - if (ret < 0) {
756   - dev_err(chip->dev, "Failed to add onkey subdev\n");
757   - goto out_dev;
758   - }
759   -
760   - ret = mfd_add_devices(chip->dev, 0, &codec_devs[0],
761   - ARRAY_SIZE(codec_devs),
762   - &codec_resources[0], 0);
763   - if (ret < 0) {
764   - dev_err(chip->dev, "Failed to add codec subdev\n");
765   - goto out_dev;
766   - }
767   -
768 769 device_regulator_init(chip, i2c, pdata);
769   - return;
770   -out_dev:
771   - mfd_remove_devices(chip->dev);
772   - device_irq_exit(chip);
  770 + device_onkey_init(chip, i2c, pdata);
  771 + device_touch_init(chip, i2c, pdata);
  772 + device_power_init(chip, i2c, pdata);
  773 + device_codec_init(chip, i2c, pdata);
773 774 out:
774 775 return;
775 776 }