aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/88pm860x-core.c
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@marvell.com>2011-03-07 10:43:12 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2011-03-23 05:42:06 -0400
commitc9f560b3d0222f6a6e3faeda324e786e230e4f20 (patch)
tree8ee05fa5c77f0442bffc740fc1f7adf7ab10ea6f /drivers/mfd/88pm860x-core.c
parent22aad0011e4728a29bf3775b6f5e2f9677abd8c0 (diff)
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>
Diffstat (limited to 'drivers/mfd/88pm860x-core.c')
-rw-r--r--drivers/mfd/88pm860x-core.c251
1 files changed, 126 insertions, 125 deletions
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index 96ea0c64bbbc..9c511c1604a5 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -57,6 +57,39 @@ static struct resource regulator_resources[] __initdata = {
57 {PM8607_ID_LDO15, PM8607_ID_LDO15, "ldo-15", IORESOURCE_IO,}, 57 {PM8607_ID_LDO15, PM8607_ID_LDO15, "ldo-15", IORESOURCE_IO,},
58}; 58};
59 59
60static struct resource touch_resources[] __initdata = {
61 {PM8607_IRQ_PEN, PM8607_IRQ_PEN, "touch", IORESOURCE_IRQ,},
62};
63
64static struct resource onkey_resources[] __initdata = {
65 {PM8607_IRQ_ONKEY, PM8607_IRQ_ONKEY, "onkey", IORESOURCE_IRQ,},
66};
67
68static 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
79static 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
84static 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
60static struct mfd_cell bk_devs[] __initdata = { 93static struct mfd_cell bk_devs[] __initdata = {
61 {"88pm860x-backlight", 0,}, 94 {"88pm860x-backlight", 0,},
62 {"88pm860x-backlight", 1,}, 95 {"88pm860x-backlight", 1,},
@@ -93,98 +126,28 @@ static struct mfd_cell regulator_devs[] __initdata = {
93 {"88pm860x-regulator", 17,}, 126 {"88pm860x-regulator", 17,},
94}; 127};
95 128
96static struct pm860x_backlight_pdata bk_pdata[ARRAY_SIZE(bk_devs)]; 129static struct mfd_cell touch_devs[] __initdata = {
97static struct pm860x_led_pdata led_pdata[ARRAY_SIZE(led_devs)]; 130 {"88pm860x-touch", -1,},
98static struct regulator_init_data regulator_pdata[ARRAY_SIZE(regulator_devs)];
99
100static struct resource touch_resources[] = {
101 {
102 .start = PM8607_IRQ_PEN,
103 .end = PM8607_IRQ_PEN,
104 .flags = IORESOURCE_IRQ,
105 },
106}; 131};
107 132
108static struct mfd_cell touch_devs[] = { 133static struct mfd_cell onkey_devs[] __initdata = {
109 { 134 {"88pm860x-onkey", -1,},
110 .name = "88pm860x-touch",
111 .num_resources = 1,
112 .resources = &touch_resources[0],
113 },
114}; 135};
115 136
116static struct resource power_supply_resources[] = { 137static struct mfd_cell codec_devs[] __initdata = {
117 { 138 {"88pm860x-codec", -1,},
118 .name = "88pm860x-power",
119 .start = PM8607_IRQ_CHG,
120 .end = PM8607_IRQ_CHG,
121 .flags = IORESOURCE_IRQ,
122 },
123}; 139};
124 140
125static struct mfd_cell power_devs[] = { 141static struct mfd_cell power_devs[] = {
126 { 142 {"88pm860x-battery", -1,},
127 .name = "88pm860x-power", 143 {"88pm860x-charger", -1,},
128 .num_resources = 1,
129 .resources = &power_supply_resources[0],
130 .id = -1,
131 },
132};
133
134static 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};
142
143static 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
152static 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}; 144};
179 145
180static struct mfd_cell codec_devs[] = { 146static struct pm860x_backlight_pdata bk_pdata[ARRAY_SIZE(bk_devs)];
181 { 147static struct pm860x_led_pdata led_pdata[ARRAY_SIZE(led_devs)];
182 .name = "88pm860x-codec", 148static struct regulator_init_data regulator_pdata[ARRAY_SIZE(regulator_devs)];
183 .num_resources = ARRAY_SIZE(codec_resources), 149static struct pm860x_touch_pdata touch_pdata;
184 .resources = &codec_resources[0], 150static struct pm860x_power_pdata power_pdata;
185 .id = -1,
186 },
187};
188 151
189struct pm860x_irq_data { 152struct pm860x_irq_data {
190 int reg; 153 int reg;
@@ -672,6 +635,82 @@ out:
672 return; 635 return;
673} 636}
674 637
638static 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
658static 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
685static 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
700static 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
675static void __devinit device_8607_init(struct pm860x_chip *chip, 714static void __devinit device_8607_init(struct pm860x_chip *chip,
676 struct i2c_client *i2c, 715 struct i2c_client *i2c,
677 struct pm860x_platform_data *pdata) 716 struct pm860x_platform_data *pdata)
@@ -727,49 +766,11 @@ static void __devinit device_8607_init(struct pm860x_chip *chip,
727 if (ret < 0) 766 if (ret < 0)
728 goto out; 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 device_regulator_init(chip, i2c, pdata); 769 device_regulator_init(chip, i2c, pdata);
769 return; 770 device_onkey_init(chip, i2c, pdata);
770out_dev: 771 device_touch_init(chip, i2c, pdata);
771 mfd_remove_devices(chip->dev); 772 device_power_init(chip, i2c, pdata);
772 device_irq_exit(chip); 773 device_codec_init(chip, i2c, pdata);
773out: 774out:
774 return; 775 return;
775} 776}