[ifxmips] many more code cleanups for checkpatch.pl, most flagged as errors
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1203-fix-pcf50633-migrate-gta02-peripherals-out.patch.patch
1 From 80b4a26a51a75a92ddbb64b342068b741ef88416 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Wed, 2 Jul 2008 22:42:39 +0100
4 Subject: [PATCH] fix-pcf50633-migrate-gta02-peripherals-out.patch
5
6 pcf50633.c shouldn't know GTAxx at all. Move to using a
7 platform callback to allow definition of platform devices
8 with pcf50633 as parent device (good for enforcing suspend /
9 resume ordering). Remove all code references to GTAxx from
10 the sources (one string left for compatability).
11
12 Signed-off-by: Andy Green <andy@openmoko.com>
13 ---
14 arch/arm/mach-s3c2440/mach-gta02.c | 30 +++++++++++++++++++-
15 drivers/i2c/chips/pcf50633.c | 54 ++++++++++++++++++-----------------
16 include/linux/pcf50633.h | 9 +++++-
17 3 files changed, 65 insertions(+), 28 deletions(-)
18
19 diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
20 index 309e484..fd746fd 100644
21 --- a/arch/arm/mach-s3c2440/mach-gta02.c
22 +++ b/arch/arm/mach-s3c2440/mach-gta02.c
23 @@ -464,6 +464,29 @@ static int pmu_callback(struct device *dev, unsigned int feature,
24 return 0;
25 }
26
27 +static struct platform_device gta01_pm_gps_dev = {
28 + .name = "neo1973-pm-gps",
29 +};
30 +
31 +static struct platform_device gta01_pm_bt_dev = {
32 + .name = "neo1973-pm-bt",
33 +};
34 +
35 +/* this is called when pc50633 is probed, unfortunately quite late in the
36 + * day since it is an I2C bus device. Here we can belatedly define some
37 + * platform devices with the advantage that we can mark the pcf50633 as the
38 + * parent. This makes them get suspended and resumed with their parent
39 + * the pcf50633 still around.
40 + */
41 +
42 +static void gta02_pcf50633_attach_child_devices(struct device *parent_device)
43 +{
44 + gta01_pm_gps_dev.dev.parent = parent_device;
45 + gta01_pm_bt_dev.dev.parent = parent_device;
46 + platform_device_register(&gta01_pm_bt_dev);
47 + platform_device_register(&gta01_pm_gps_dev);
48 +}
49 +
50 static struct pcf50633_platform_data gta02_pcf_pdata = {
51 .used_features = PCF50633_FEAT_MBC |
52 PCF50633_FEAT_BBC |
53 @@ -478,6 +501,7 @@ static struct pcf50633_platform_data gta02_pcf_pdata = {
54 .r_fix_batt = 10000,
55 .r_fix_batt_par = 10000,
56 .r_sense_milli = 220,
57 + .flag_use_apm_emulation = 0,
58 .resumers = {
59 [0] = PCF50633_INT1_USBINS |
60 PCF50633_INT1_USBREM |
61 @@ -577,7 +601,9 @@ static struct pcf50633_platform_data gta02_pcf_pdata = {
62 },
63 },
64 .defer_resume_backlight = 1,
65 - .resume_backlight_ramp_speed = 5
66 + .resume_backlight_ramp_speed = 5,
67 + .attach_child_devices = gta02_pcf50633_attach_child_devices
68 +
69 };
70
71 #if 0 /* currently unused */
72 @@ -772,6 +798,7 @@ struct platform_device s3c24xx_pwm_device = {
73 .num_resources = 0,
74 };
75
76 +
77 static struct platform_device *gta02_devices[] __initdata = {
78 &s3c_device_usb,
79 &s3c_device_wdt,
80 @@ -786,6 +813,7 @@ static struct platform_device *gta02_devices[] __initdata = {
81 &gta02_version_device,
82 &gta02_resume_reason_device,
83 &s3c24xx_pwm_device,
84 +
85 };
86
87 static struct s3c2410_nand_set gta02_nand_sets[] = {
88 diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
89 index a697ee1..0f40f3f 100644
90 --- a/drivers/i2c/chips/pcf50633.c
91 +++ b/drivers/i2c/chips/pcf50633.c
92 @@ -50,7 +50,6 @@
93 #include <linux/jiffies.h>
94
95 #include <asm/mach-types.h>
96 -#include <asm/arch/gta02.h>
97
98 #include "pcf50633.h"
99 #include <linux/resume-dependency.h>
100 @@ -2011,18 +2010,6 @@ static DEVICE_ATTR(dump_regs, 0400, show_dump_regs, NULL);
101 * Driver initialization
102 ***********************************************************************/
103
104 -#ifdef CONFIG_MACH_NEO1973_GTA02
105 -/* We currently place those platform devices here to make sure the device
106 - * suspend/resume order is correct */
107 -static struct platform_device gta01_pm_gps_dev = {
108 - .name = "neo1973-pm-gps",
109 -};
110 -
111 -static struct platform_device gta01_pm_bt_dev = {
112 - .name = "neo1973-pm-bt",
113 -};
114 -#endif
115 -
116 /*
117 * CARE! This table is modified at runtime!
118 */
119 @@ -2217,14 +2204,16 @@ static int pcf50633_detect(struct i2c_adapter *adapter, int address, int kind)
120
121 data->probe_completed = 1;
122
123 - if (machine_is_neo1973_gta02()) {
124 - gta01_pm_gps_dev.dev.parent = &new_client->dev;
125 - gta01_pm_bt_dev.dev.parent = &new_client->dev;
126 - platform_device_register(&gta01_pm_bt_dev);
127 - platform_device_register(&gta01_pm_gps_dev);
128 - } else
129 + if (data->pdata->flag_use_apm_emulation)
130 apm_get_power_status = pcf50633_get_power_status;
131
132 + /* if platform was interested, give him a chance to register
133 + * platform devices that switch power with us as the parent
134 + * at registration time -- ensures suspend / resume ordering
135 + */
136 + if (data->pdata->attach_child_devices)
137 + (data->pdata->attach_child_devices)(&new_client->dev);
138 +
139 return 0;
140 exit_rtc:
141 if (data->pdata->used_features & PCF50633_FEAT_RTC)
142 @@ -2268,13 +2257,6 @@ static int pcf50633_detach_client(struct i2c_client *client)
143 if (pcf->pdata->used_features & PCF50633_FEAT_RTC)
144 rtc_device_unregister(pcf->rtc);
145
146 -#ifdef CONFIG_MACH_NEO1973_GTA02
147 - if (machine_is_neo1973_gta02()) {
148 - platform_device_unregister(&gta01_pm_bt_dev);
149 - platform_device_unregister(&gta01_pm_gps_dev);
150 - }
151 -#endif
152 -
153 sysfs_remove_group(&client->dev.kobj, &pcf_attr_group);
154
155 pm_power_off = NULL;
156 @@ -2472,6 +2454,26 @@ int pcf50633_ready(struct pcf50633_data *pcf)
157 }
158 EXPORT_SYMBOL_GPL(pcf50633_ready);
159
160 +int pcf50633_wait_for_ready(struct pcf50633_data *pcf, int timeout_ms,
161 + char *name)
162 +{
163 + /* so we always go once */
164 + timeout_ms += 5;
165 +
166 + while ((timeout_ms >= 5) && (pcf50633_ready(pcf))) {
167 + timeout_ms -= 5; /* well, it isn't very accurate, but OK */
168 + msleep(5);
169 + }
170 +
171 + if (timeout_ms < 5) {
172 + printk(KERN_ERR"pcf50633_wait_for_ready: "
173 + "%s BAILING on timeout\n", name);
174 + return -EBUSY;
175 + }
176 +
177 + return 0;
178 +}
179 +EXPORT_SYMBOL_GPL(pcf50633_wait_for_ready);
180
181 /*
182 * if backlight resume is selected to be deferred by platform, then it
183 diff --git a/include/linux/pcf50633.h b/include/linux/pcf50633.h
184 index b94b72a..4653285 100644
185 --- a/include/linux/pcf50633.h
186 +++ b/include/linux/pcf50633.h
187 @@ -132,7 +132,9 @@ pcf50633_register_resume_dependency(struct pcf50633_data *pcf,
188 extern int
189 pcf50633_notify_usb_current_limit_change(struct pcf50633_data *pcf,
190 unsigned int ma);
191 -
192 +extern int
193 +pcf50633_wait_for_ready(struct pcf50633_data *pcf, int timeout_ms,
194 + char *name);
195
196 /* 0 = initialized and resumed and ready to roll, !=0 = either not
197 * initialized or not resumed yet
198 @@ -155,6 +157,10 @@ struct pcf50633_platform_data {
199 unsigned int onkey_seconds_sig_init;
200 unsigned int onkey_seconds_shutdown;
201
202 + /* callback to attach platform children (to enforce suspend / resume
203 + * ordering */
204 + void (*attach_child_devices)(struct device *parent_device);
205 +
206 /* voltage regulator related */
207 struct pmu_voltage_rail rails[__NUM_PCF50633_REGULATORS];
208 unsigned int used_regulators;
209 @@ -163,6 +169,7 @@ struct pcf50633_platform_data {
210 unsigned int r_fix_batt;
211 unsigned int r_fix_batt_par;
212 unsigned int r_sense_milli;
213 + int flag_use_apm_emulation;
214
215 unsigned char resumers[5];
216
217 --
218 1.5.6.5
219
This page took 0.052704 seconds and 5 git commands to generate.