diff options
author | Denis M. Sadykov <denis.m.sadykov@intel.com> | 2006-09-26 11:50:33 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2006-10-14 00:49:54 -0400 |
commit | 703959d47e887a29dc58123c05aa0ffcbbfa131d (patch) | |
tree | 553ca4d1f0b76c77d3eeacc75f246dbbe5cafc0f /drivers/acpi | |
parent | 7c6db5e51227761f42c6ac8260753f5c24dc1dde (diff) |
ACPI: EC: Remove unused variables and duplicated code
Signed-off-by: Alexey Y. Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/ec.c | 711 |
1 files changed, 253 insertions, 458 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index b6f935d0c3ad..c816b4eab50d 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -45,203 +45,162 @@ ACPI_MODULE_NAME("acpi_ec") | |||
45 | #define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" | 45 | #define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" |
46 | #define ACPI_EC_DEVICE_NAME "Embedded Controller" | 46 | #define ACPI_EC_DEVICE_NAME "Embedded Controller" |
47 | #define ACPI_EC_FILE_INFO "info" | 47 | #define ACPI_EC_FILE_INFO "info" |
48 | |||
49 | /* EC status register */ | ||
48 | #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ | 50 | #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ |
49 | #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ | 51 | #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ |
50 | #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ | 52 | #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ |
51 | #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ | 53 | #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ |
52 | #define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */ | 54 | |
53 | #define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */ | 55 | /* EC commands */ |
54 | #define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */ | ||
55 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ | ||
56 | #define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */ | ||
57 | #define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */ | ||
58 | #define ACPI_EC_COMMAND_READ 0x80 | 56 | #define ACPI_EC_COMMAND_READ 0x80 |
59 | #define ACPI_EC_COMMAND_WRITE 0x81 | 57 | #define ACPI_EC_COMMAND_WRITE 0x81 |
60 | #define ACPI_EC_BURST_ENABLE 0x82 | 58 | #define ACPI_EC_BURST_ENABLE 0x82 |
61 | #define ACPI_EC_BURST_DISABLE 0x83 | 59 | #define ACPI_EC_BURST_DISABLE 0x83 |
62 | #define ACPI_EC_COMMAND_QUERY 0x84 | 60 | #define ACPI_EC_COMMAND_QUERY 0x84 |
63 | #define EC_POLL 0xFF | 61 | |
64 | #define EC_INTR 0x00 | 62 | /* EC events */ |
63 | enum { | ||
64 | ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */ | ||
65 | ACPI_EC_EVENT_IBF_0, /* Input buffer empty */ | ||
66 | }; | ||
67 | |||
68 | #define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */ | ||
69 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ | ||
70 | #define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */ | ||
71 | #define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */ | ||
72 | |||
73 | enum { | ||
74 | EC_INTR = 1, /* Output buffer full */ | ||
75 | EC_POLL, /* Input buffer empty */ | ||
76 | }; | ||
77 | |||
65 | static int acpi_ec_remove(struct acpi_device *device, int type); | 78 | static int acpi_ec_remove(struct acpi_device *device, int type); |
66 | static int acpi_ec_start(struct acpi_device *device); | 79 | static int acpi_ec_start(struct acpi_device *device); |
67 | static int acpi_ec_stop(struct acpi_device *device, int type); | 80 | static int acpi_ec_stop(struct acpi_device *device, int type); |
68 | static int acpi_ec_intr_add(struct acpi_device *device); | 81 | static int acpi_ec_add(struct acpi_device *device); |
69 | static int acpi_ec_poll_add(struct acpi_device *device); | ||
70 | 82 | ||
71 | static struct acpi_driver acpi_ec_driver = { | 83 | static struct acpi_driver acpi_ec_driver = { |
72 | .name = ACPI_EC_DRIVER_NAME, | 84 | .name = ACPI_EC_DRIVER_NAME, |
73 | .class = ACPI_EC_CLASS, | 85 | .class = ACPI_EC_CLASS, |
74 | .ids = ACPI_EC_HID, | 86 | .ids = ACPI_EC_HID, |
75 | .ops = { | 87 | .ops = { |
76 | .add = acpi_ec_intr_add, | 88 | .add = acpi_ec_add, |
77 | .remove = acpi_ec_remove, | 89 | .remove = acpi_ec_remove, |
78 | .start = acpi_ec_start, | 90 | .start = acpi_ec_start, |
79 | .stop = acpi_ec_stop, | 91 | .stop = acpi_ec_stop, |
80 | }, | 92 | }, |
81 | }; | 93 | }; |
82 | union acpi_ec { | 94 | struct acpi_ec { |
83 | struct { | 95 | acpi_handle handle; |
84 | u32 mode; | 96 | unsigned long uid; |
85 | acpi_handle handle; | 97 | unsigned long gpe_bit; |
86 | unsigned long uid; | 98 | struct acpi_generic_address status_addr; |
87 | unsigned long gpe_bit; | 99 | struct acpi_generic_address command_addr; |
88 | struct acpi_generic_address status_addr; | 100 | struct acpi_generic_address data_addr; |
89 | struct acpi_generic_address command_addr; | 101 | unsigned long global_lock; |
90 | struct acpi_generic_address data_addr; | 102 | struct semaphore sem; |
91 | unsigned long global_lock; | 103 | unsigned int expect_event; |
92 | } common; | 104 | atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */ |
93 | 105 | wait_queue_head_t wait; | |
94 | struct { | ||
95 | u32 mode; | ||
96 | acpi_handle handle; | ||
97 | unsigned long uid; | ||
98 | unsigned long gpe_bit; | ||
99 | struct acpi_generic_address status_addr; | ||
100 | struct acpi_generic_address command_addr; | ||
101 | struct acpi_generic_address data_addr; | ||
102 | unsigned long global_lock; | ||
103 | u8 expect_event; | ||
104 | atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */ | ||
105 | atomic_t pending_gpe; | ||
106 | struct semaphore sem; | ||
107 | wait_queue_head_t wait; | ||
108 | } intr; | ||
109 | |||
110 | struct { | ||
111 | u32 mode; | ||
112 | acpi_handle handle; | ||
113 | unsigned long uid; | ||
114 | unsigned long gpe_bit; | ||
115 | struct acpi_generic_address status_addr; | ||
116 | struct acpi_generic_address command_addr; | ||
117 | struct acpi_generic_address data_addr; | ||
118 | unsigned long global_lock; | ||
119 | struct semaphore sem; | ||
120 | } poll; | ||
121 | }; | 106 | }; |
122 | 107 | ||
123 | static int acpi_ec_poll_wait(union acpi_ec *ec, u8 event); | 108 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ |
124 | static int acpi_ec_intr_wait(union acpi_ec *ec, u8 event); | 109 | static struct acpi_ec *ec_ecdt; |
125 | static int acpi_ec_poll_transaction(union acpi_ec *ec, u8 command, | 110 | |
111 | /* External interfaces use first EC only, so remember */ | ||
112 | static struct acpi_device *first_ec; | ||
113 | static int acpi_ec_mode = EC_INTR; | ||
114 | |||
115 | static int acpi_ec_poll_transaction(struct acpi_ec *ec, u8 command, | ||
126 | const u8 *wdata, unsigned wdata_len, | 116 | const u8 *wdata, unsigned wdata_len, |
127 | u8 *rdata, unsigned rdata_len); | 117 | u8 *rdata, unsigned rdata_len); |
128 | static int acpi_ec_intr_transaction(union acpi_ec *ec, u8 command, | 118 | static int acpi_ec_intr_transaction(struct acpi_ec *ec, u8 command, |
129 | const u8 *wdata, unsigned wdata_len, | 119 | const u8 *wdata, unsigned wdata_len, |
130 | u8 *rdata, unsigned rdata_len); | 120 | u8 *rdata, unsigned rdata_len); |
131 | static void acpi_ec_gpe_poll_query(void *ec_cxt); | 121 | static void acpi_ec_gpe_poll_query(void *ec_cxt); |
132 | static void acpi_ec_gpe_intr_query(void *ec_cxt); | 122 | static void acpi_ec_gpe_intr_query(void *ec_cxt); |
133 | static u32 acpi_ec_gpe_poll_handler(void *data); | 123 | static u32 acpi_ec_gpe_poll_handler(void *data); |
134 | static u32 acpi_ec_gpe_intr_handler(void *data); | 124 | static u32 acpi_ec_gpe_intr_handler(void *data); |
135 | static acpi_status __init | ||
136 | acpi_fake_ecdt_poll_callback(acpi_handle handle, | ||
137 | u32 Level, void *context, void **retval); | ||
138 | |||
139 | static acpi_status __init | ||
140 | acpi_fake_ecdt_intr_callback(acpi_handle handle, | ||
141 | u32 Level, void *context, void **retval); | ||
142 | |||
143 | static int __init acpi_ec_poll_get_real_ecdt(void); | ||
144 | static int __init acpi_ec_intr_get_real_ecdt(void); | ||
145 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ | ||
146 | static union acpi_ec *ec_ecdt; | ||
147 | |||
148 | /* External interfaces use first EC only, so remember */ | ||
149 | static struct acpi_device *first_ec; | ||
150 | static int acpi_ec_poll_mode = EC_INTR; | ||
151 | 125 | ||
152 | /* -------------------------------------------------------------------------- | 126 | /* -------------------------------------------------------------------------- |
153 | Transaction Management | 127 | Transaction Management |
154 | -------------------------------------------------------------------------- */ | 128 | -------------------------------------------------------------------------- */ |
155 | 129 | ||
156 | static u32 acpi_ec_read_status(union acpi_ec *ec) | 130 | static u32 acpi_ec_read_status(struct acpi_ec *ec) |
157 | { | 131 | { |
158 | u32 status = 0; | 132 | u32 status = 0; |
159 | 133 | ||
160 | acpi_hw_low_level_read(8, &status, &ec->common.status_addr); | 134 | acpi_hw_low_level_read(8, &status, &ec->status_addr); |
161 | return status; | 135 | return status; |
162 | } | 136 | } |
163 | 137 | ||
164 | static int acpi_ec_check_status(u32 status, u8 event) { | 138 | static u32 acpi_ec_read_data(struct acpi_ec *ec) |
165 | 139 | { | |
166 | switch (event) { | 140 | u32 data = 0; |
167 | case ACPI_EC_EVENT_OBF: | ||
168 | if (status & ACPI_EC_FLAG_OBF) | ||
169 | return 1; | ||
170 | case ACPI_EC_EVENT_IBE: | ||
171 | if (!(status & ACPI_EC_FLAG_IBF)) | ||
172 | return 1; | ||
173 | default: | ||
174 | break; | ||
175 | } | ||
176 | 141 | ||
177 | return 0; | 142 | acpi_hw_low_level_read(8, &data, &ec->data_addr); |
143 | return data; | ||
178 | } | 144 | } |
179 | 145 | ||
180 | static int acpi_ec_wait(union acpi_ec *ec, u8 event) | 146 | static void acpi_ec_write_cmd(struct acpi_ec *ec, u32 command) |
181 | { | 147 | { |
182 | if (acpi_ec_poll_mode) | 148 | acpi_hw_low_level_write(8, command, &ec->command_addr); |
183 | return acpi_ec_poll_wait(ec, event); | ||
184 | else | ||
185 | return acpi_ec_intr_wait(ec, event); | ||
186 | } | 149 | } |
187 | 150 | ||
188 | static int acpi_ec_poll_wait(union acpi_ec *ec, u8 event) | 151 | static void acpi_ec_write_data(struct acpi_ec *ec, u32 data) |
189 | { | 152 | { |
190 | u32 acpi_ec_status = 0; | 153 | acpi_hw_low_level_write(8, data, &ec->data_addr); |
191 | u32 i = ACPI_EC_UDELAY_COUNT; | 154 | } |
192 | 155 | ||
193 | if (!ec) | 156 | static int acpi_ec_check_status(u32 status, u8 event) { |
194 | return -EINVAL; | ||
195 | 157 | ||
196 | /* Poll the EC status register waiting for the event to occur. */ | ||
197 | switch (event) { | 158 | switch (event) { |
198 | case ACPI_EC_EVENT_OBF: | 159 | case ACPI_EC_EVENT_OBF_1: |
199 | do { | 160 | if (status & ACPI_EC_FLAG_OBF) |
200 | acpi_hw_low_level_read(8, &acpi_ec_status, | 161 | return 1; |
201 | &ec->common.status_addr); | ||
202 | if (acpi_ec_status & ACPI_EC_FLAG_OBF) | ||
203 | return 0; | ||
204 | udelay(ACPI_EC_UDELAY); | ||
205 | } while (--i > 0); | ||
206 | break; | 162 | break; |
207 | case ACPI_EC_EVENT_IBE: | 163 | case ACPI_EC_EVENT_IBF_0: |
208 | do { | 164 | if (!(status & ACPI_EC_FLAG_IBF)) |
209 | acpi_hw_low_level_read(8, &acpi_ec_status, | 165 | return 1; |
210 | &ec->common.status_addr); | ||
211 | if (!(acpi_ec_status & ACPI_EC_FLAG_IBF)) | ||
212 | return 0; | ||
213 | udelay(ACPI_EC_UDELAY); | ||
214 | } while (--i > 0); | ||
215 | break; | 166 | break; |
216 | default: | 167 | default: |
217 | return -EINVAL; | 168 | break; |
218 | } | 169 | } |
219 | 170 | ||
220 | return -ETIME; | 171 | return 0; |
221 | } | 172 | } |
222 | 173 | ||
223 | static int acpi_ec_intr_wait(union acpi_ec *ec, u8 event) | 174 | static int acpi_ec_wait(struct acpi_ec *ec, u8 event) |
224 | { | 175 | { |
225 | long time_left; | 176 | int i = (acpi_ec_mode == EC_POLL) ? ACPI_EC_UDELAY_COUNT : 0; |
226 | 177 | long time_left; | |
227 | ec->intr.expect_event = event; | ||
228 | 178 | ||
179 | ec->expect_event = event; | ||
229 | if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) { | 180 | if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) { |
230 | ec->intr.expect_event = 0; | 181 | ec->expect_event = 0; |
231 | return 0; | 182 | return 0; |
232 | } | 183 | } |
233 | 184 | ||
234 | time_left = wait_event_timeout(ec->intr.wait, !ec->intr.expect_event, | 185 | do { |
235 | msecs_to_jiffies(ACPI_EC_DELAY)); | 186 | if (acpi_ec_mode == EC_POLL) { |
236 | 187 | udelay(ACPI_EC_UDELAY); | |
237 | ec->intr.expect_event = 0; | 188 | } else { |
238 | if (time_left <= 0) { | 189 | time_left = wait_event_timeout(ec->wait, |
239 | if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) { | 190 | !ec->expect_event, |
191 | msecs_to_jiffies(ACPI_EC_DELAY)); | ||
192 | if (time_left > 0) { | ||
193 | ec->expect_event = 0; | ||
240 | return 0; | 194 | return 0; |
195 | } | ||
241 | } | 196 | } |
242 | } else { | 197 | if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) { |
243 | return 0; | 198 | ec->expect_event = 0; |
244 | } | 199 | return 0; |
200 | } | ||
201 | } while (--i > 0); | ||
202 | |||
203 | ec->expect_event = 0; | ||
245 | 204 | ||
246 | return -ETIME; | 205 | return -ETIME; |
247 | } | 206 | } |
@@ -251,64 +210,63 @@ static int acpi_ec_intr_wait(union acpi_ec *ec, u8 event) | |||
251 | * Note: samsung nv5000 doesn't work with ec burst mode. | 210 | * Note: samsung nv5000 doesn't work with ec burst mode. |
252 | * http://bugzilla.kernel.org/show_bug.cgi?id=4980 | 211 | * http://bugzilla.kernel.org/show_bug.cgi?id=4980 |
253 | */ | 212 | */ |
254 | int acpi_ec_enter_burst_mode(union acpi_ec *ec) | 213 | int acpi_ec_enter_burst_mode(struct acpi_ec *ec) |
255 | { | 214 | { |
256 | u32 tmp = 0; | 215 | u32 tmp = 0; |
257 | int status = 0; | 216 | u32 status = 0; |
258 | 217 | ||
259 | 218 | ||
260 | status = acpi_ec_read_status(ec); | 219 | status = acpi_ec_read_status(ec); |
261 | if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { | 220 | if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { |
262 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 221 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); |
263 | if (status) | 222 | if (status) |
264 | goto end; | 223 | goto end; |
265 | acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, | 224 | acpi_ec_write_cmd(ec, ACPI_EC_BURST_ENABLE); |
266 | &ec->common.command_addr); | 225 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1); |
267 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); | 226 | tmp = acpi_ec_read_data(ec); |
268 | acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); | ||
269 | if (tmp != 0x90) { /* Burst ACK byte */ | 227 | if (tmp != 0x90) { /* Burst ACK byte */ |
270 | return -EINVAL; | 228 | return -EINVAL; |
271 | } | 229 | } |
272 | } | 230 | } |
273 | 231 | ||
274 | atomic_set(&ec->intr.leaving_burst, 0); | 232 | atomic_set(&ec->leaving_burst, 0); |
275 | return 0; | 233 | return 0; |
276 | end: | 234 | end: |
277 | ACPI_EXCEPTION ((AE_INFO, status, "EC wait, burst mode"); | 235 | ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode")); |
278 | return -1; | 236 | return -1; |
279 | } | 237 | } |
280 | 238 | ||
281 | int acpi_ec_leave_burst_mode(union acpi_ec *ec) | 239 | int acpi_ec_leave_burst_mode(struct acpi_ec *ec) |
282 | { | 240 | { |
283 | int status = 0; | 241 | u32 status = 0; |
284 | 242 | ||
285 | 243 | ||
286 | status = acpi_ec_read_status(ec); | 244 | status = acpi_ec_read_status(ec); |
287 | if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){ | 245 | if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){ |
288 | status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); | 246 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); |
289 | if(status) | 247 | if(status) |
290 | goto end; | 248 | goto end; |
291 | acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr); | 249 | acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE); |
292 | acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); | 250 | acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); |
293 | } | 251 | } |
294 | atomic_set(&ec->intr.leaving_burst, 1); | 252 | atomic_set(&ec->leaving_burst, 1); |
295 | return 0; | 253 | return 0; |
296 | end: | 254 | end: |
297 | ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"); | 255 | ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode")); |
298 | return -1; | 256 | return -1; |
299 | } | 257 | } |
300 | #endif /* ACPI_FUTURE_USAGE */ | 258 | #endif /* ACPI_FUTURE_USAGE */ |
301 | 259 | ||
302 | static int acpi_ec_transaction(union acpi_ec *ec, u8 command, | 260 | static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, |
303 | const u8 *wdata, unsigned wdata_len, | 261 | const u8 *wdata, unsigned wdata_len, |
304 | u8 *rdata, unsigned rdata_len) | 262 | u8 *rdata, unsigned rdata_len) |
305 | { | 263 | { |
306 | if (acpi_ec_poll_mode) | 264 | if (acpi_ec_mode == EC_POLL) |
307 | return acpi_ec_poll_transaction(ec, command, wdata, wdata_len, rdata, rdata_len); | 265 | return acpi_ec_poll_transaction(ec, command, wdata, wdata_len, rdata, rdata_len); |
308 | else | 266 | else |
309 | return acpi_ec_intr_transaction(ec, command, wdata, wdata_len, rdata, rdata_len); | 267 | return acpi_ec_intr_transaction(ec, command, wdata, wdata_len, rdata, rdata_len); |
310 | } | 268 | } |
311 | static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data) | 269 | static int acpi_ec_read(struct acpi_ec *ec, u8 address, u32 * data) |
312 | { | 270 | { |
313 | int result; | 271 | int result; |
314 | u8 d; | 272 | u8 d; |
@@ -316,30 +274,30 @@ static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data) | |||
316 | *data = d; | 274 | *data = d; |
317 | return result; | 275 | return result; |
318 | } | 276 | } |
319 | static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data) | 277 | static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data) |
320 | { | 278 | { |
321 | u8 wdata[2] = { address, data }; | 279 | u8 wdata[2] = { address, data }; |
322 | return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE, wdata, 2, NULL, 0); | 280 | return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE, wdata, 2, NULL, 0); |
323 | } | 281 | } |
324 | 282 | ||
325 | static int acpi_ec_transaction_unlocked(union acpi_ec *ec, u8 command, | 283 | static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, |
326 | const u8 *wdata, unsigned wdata_len, | 284 | const u8 *wdata, unsigned wdata_len, |
327 | u8 *rdata, unsigned rdata_len) | 285 | u8 *rdata, unsigned rdata_len) |
328 | { | 286 | { |
329 | int result; | 287 | int result; |
330 | 288 | ||
331 | acpi_hw_low_level_write(8, command, &ec->common.command_addr); | 289 | acpi_ec_write_cmd(ec, command); |
332 | 290 | ||
333 | for (; wdata_len > 0; wdata_len --) { | 291 | for (; wdata_len > 0; wdata_len --) { |
334 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 292 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); |
335 | if (result) | 293 | if (result) |
336 | return result; | 294 | return result; |
337 | 295 | ||
338 | acpi_hw_low_level_write(8, *(wdata++), &ec->common.data_addr); | 296 | acpi_ec_write_data(ec, *(wdata++)); |
339 | } | 297 | } |
340 | 298 | ||
341 | if (command == ACPI_EC_COMMAND_WRITE) { | 299 | if (command == ACPI_EC_COMMAND_WRITE) { |
342 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 300 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); |
343 | if (result) | 301 | if (result) |
344 | return result; | 302 | return result; |
345 | } | 303 | } |
@@ -347,18 +305,18 @@ static int acpi_ec_transaction_unlocked(union acpi_ec *ec, u8 command, | |||
347 | for (; rdata_len > 0; rdata_len --) { | 305 | for (; rdata_len > 0; rdata_len --) { |
348 | u32 d; | 306 | u32 d; |
349 | 307 | ||
350 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); | 308 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1); |
351 | if (result) | 309 | if (result) |
352 | return result; | 310 | return result; |
353 | 311 | ||
354 | acpi_hw_low_level_read(8, &d, &ec->common.data_addr); | 312 | d = acpi_ec_read_data(ec); |
355 | *(rdata++) = (u8) d; | 313 | *(rdata++) = (u8) d; |
356 | } | 314 | } |
357 | 315 | ||
358 | return 0; | 316 | return 0; |
359 | } | 317 | } |
360 | 318 | ||
361 | static int acpi_ec_poll_transaction(union acpi_ec *ec, u8 command, | 319 | static int acpi_ec_poll_transaction(struct acpi_ec *ec, u8 command, |
362 | const u8 *wdata, unsigned wdata_len, | 320 | const u8 *wdata, unsigned wdata_len, |
363 | u8 *rdata, unsigned rdata_len) | 321 | u8 *rdata, unsigned rdata_len) |
364 | { | 322 | { |
@@ -372,13 +330,13 @@ static int acpi_ec_poll_transaction(union acpi_ec *ec, u8 command, | |||
372 | if (rdata) | 330 | if (rdata) |
373 | memset(rdata, 0, rdata_len); | 331 | memset(rdata, 0, rdata_len); |
374 | 332 | ||
375 | if (ec->common.global_lock) { | 333 | if (ec->global_lock) { |
376 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); | 334 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); |
377 | if (ACPI_FAILURE(status)) | 335 | if (ACPI_FAILURE(status)) |
378 | return -ENODEV; | 336 | return -ENODEV; |
379 | } | 337 | } |
380 | 338 | ||
381 | if (down_interruptible(&ec->poll.sem)) { | 339 | if (down_interruptible(&ec->sem)) { |
382 | result = -ERESTARTSYS; | 340 | result = -ERESTARTSYS; |
383 | goto end_nosem; | 341 | goto end_nosem; |
384 | } | 342 | } |
@@ -386,16 +344,16 @@ static int acpi_ec_poll_transaction(union acpi_ec *ec, u8 command, | |||
386 | result = acpi_ec_transaction_unlocked(ec, command, | 344 | result = acpi_ec_transaction_unlocked(ec, command, |
387 | wdata, wdata_len, | 345 | wdata, wdata_len, |
388 | rdata, rdata_len); | 346 | rdata, rdata_len); |
389 | up(&ec->poll.sem); | 347 | up(&ec->sem); |
390 | 348 | ||
391 | end_nosem: | 349 | end_nosem: |
392 | if (ec->common.global_lock) | 350 | if (ec->global_lock) |
393 | acpi_release_global_lock(glk); | 351 | acpi_release_global_lock(glk); |
394 | 352 | ||
395 | return result; | 353 | return result; |
396 | } | 354 | } |
397 | 355 | ||
398 | static int acpi_ec_intr_transaction(union acpi_ec *ec, u8 command, | 356 | static int acpi_ec_intr_transaction(struct acpi_ec *ec, u8 command, |
399 | const u8 *wdata, unsigned wdata_len, | 357 | const u8 *wdata, unsigned wdata_len, |
400 | u8 *rdata, unsigned rdata_len) | 358 | u8 *rdata, unsigned rdata_len) |
401 | { | 359 | { |
@@ -408,18 +366,18 @@ static int acpi_ec_intr_transaction(union acpi_ec *ec, u8 command, | |||
408 | if (rdata) | 366 | if (rdata) |
409 | memset(rdata, 0, rdata_len); | 367 | memset(rdata, 0, rdata_len); |
410 | 368 | ||
411 | if (ec->common.global_lock) { | 369 | if (ec->global_lock) { |
412 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); | 370 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); |
413 | if (ACPI_FAILURE(status)) | 371 | if (ACPI_FAILURE(status)) |
414 | return -ENODEV; | 372 | return -ENODEV; |
415 | } | 373 | } |
416 | 374 | ||
417 | WARN_ON(in_interrupt()); | 375 | WARN_ON(in_interrupt()); |
418 | down(&ec->intr.sem); | 376 | down(&ec->sem); |
419 | 377 | ||
420 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 378 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); |
421 | if (status) { | 379 | if (status) { |
422 | printk(KERN_DEBUG PREFIX "read EC, IB not empty\n"); | 380 | ACPI_EXCEPTION((AE_INFO, status, "read EC, IB not empty")); |
423 | goto end; | 381 | goto end; |
424 | } | 382 | } |
425 | 383 | ||
@@ -428,9 +386,9 @@ static int acpi_ec_intr_transaction(union acpi_ec *ec, u8 command, | |||
428 | rdata, rdata_len); | 386 | rdata, rdata_len); |
429 | 387 | ||
430 | end: | 388 | end: |
431 | up(&ec->intr.sem); | 389 | up(&ec->sem); |
432 | 390 | ||
433 | if (ec->common.global_lock) | 391 | if (ec->global_lock) |
434 | acpi_release_global_lock(glk); | 392 | acpi_release_global_lock(glk); |
435 | 393 | ||
436 | return status; | 394 | return status; |
@@ -441,7 +399,7 @@ end: | |||
441 | */ | 399 | */ |
442 | int ec_read(u8 addr, u8 * val) | 400 | int ec_read(u8 addr, u8 * val) |
443 | { | 401 | { |
444 | union acpi_ec *ec; | 402 | struct acpi_ec *ec; |
445 | int err; | 403 | int err; |
446 | u32 temp_data; | 404 | u32 temp_data; |
447 | 405 | ||
@@ -463,7 +421,7 @@ EXPORT_SYMBOL(ec_read); | |||
463 | 421 | ||
464 | int ec_write(u8 addr, u8 val) | 422 | int ec_write(u8 addr, u8 val) |
465 | { | 423 | { |
466 | union acpi_ec *ec; | 424 | struct acpi_ec *ec; |
467 | int err; | 425 | int err; |
468 | 426 | ||
469 | if (!first_ec) | 427 | if (!first_ec) |
@@ -482,7 +440,7 @@ extern int ec_transaction(u8 command, | |||
482 | const u8 *wdata, unsigned wdata_len, | 440 | const u8 *wdata, unsigned wdata_len, |
483 | u8 *rdata, unsigned rdata_len) | 441 | u8 *rdata, unsigned rdata_len) |
484 | { | 442 | { |
485 | union acpi_ec *ec; | 443 | struct acpi_ec *ec; |
486 | 444 | ||
487 | if (!first_ec) | 445 | if (!first_ec) |
488 | return -ENODEV; | 446 | return -ENODEV; |
@@ -494,7 +452,7 @@ extern int ec_transaction(u8 command, | |||
494 | 452 | ||
495 | EXPORT_SYMBOL(ec_transaction); | 453 | EXPORT_SYMBOL(ec_transaction); |
496 | 454 | ||
497 | static int acpi_ec_query(union acpi_ec *ec, u32 * data) { | 455 | static int acpi_ec_query(struct acpi_ec *ec, u32 * data) { |
498 | int result; | 456 | int result; |
499 | u8 d; | 457 | u8 d; |
500 | 458 | ||
@@ -529,7 +487,7 @@ union acpi_ec_query_data { | |||
529 | 487 | ||
530 | static void acpi_ec_gpe_query(void *ec_cxt) | 488 | static void acpi_ec_gpe_query(void *ec_cxt) |
531 | { | 489 | { |
532 | if (acpi_ec_poll_mode) | 490 | if (acpi_ec_mode == EC_POLL) |
533 | acpi_ec_gpe_poll_query(ec_cxt); | 491 | acpi_ec_gpe_poll_query(ec_cxt); |
534 | else | 492 | else |
535 | acpi_ec_gpe_intr_query(ec_cxt); | 493 | acpi_ec_gpe_intr_query(ec_cxt); |
@@ -537,7 +495,7 @@ static void acpi_ec_gpe_query(void *ec_cxt) | |||
537 | 495 | ||
538 | static void acpi_ec_gpe_poll_query(void *ec_cxt) | 496 | static void acpi_ec_gpe_poll_query(void *ec_cxt) |
539 | { | 497 | { |
540 | union acpi_ec *ec = (union acpi_ec *)ec_cxt; | 498 | struct acpi_ec *ec = (struct acpi_ec *)ec_cxt; |
541 | u32 value = 0; | 499 | u32 value = 0; |
542 | static char object_name[5] = { '_', 'Q', '0', '0', '\0' }; | 500 | static char object_name[5] = { '_', 'Q', '0', '0', '\0' }; |
543 | const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', | 501 | const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', |
@@ -548,11 +506,11 @@ static void acpi_ec_gpe_poll_query(void *ec_cxt) | |||
548 | if (!ec_cxt) | 506 | if (!ec_cxt) |
549 | goto end; | 507 | goto end; |
550 | 508 | ||
551 | if (down_interruptible (&ec->poll.sem)) { | 509 | if (down_interruptible (&ec->sem)) { |
552 | return; | 510 | return; |
553 | } | 511 | } |
554 | acpi_hw_low_level_read(8, &value, &ec->common.command_addr); | 512 | value = acpi_ec_read_status(ec); |
555 | up(&ec->poll.sem); | 513 | up(&ec->sem); |
556 | 514 | ||
557 | /* TBD: Implement asynch events! | 515 | /* TBD: Implement asynch events! |
558 | * NOTE: All we care about are EC-SCI's. Other EC events are | 516 | * NOTE: All we care about are EC-SCI's. Other EC events are |
@@ -571,14 +529,14 @@ static void acpi_ec_gpe_poll_query(void *ec_cxt) | |||
571 | 529 | ||
572 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); | 530 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); |
573 | 531 | ||
574 | acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); | 532 | acpi_evaluate_object(ec->handle, object_name, NULL, NULL); |
575 | 533 | ||
576 | end: | 534 | end: |
577 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 535 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); |
578 | } | 536 | } |
579 | static void acpi_ec_gpe_intr_query(void *ec_cxt) | 537 | static void acpi_ec_gpe_intr_query(void *ec_cxt) |
580 | { | 538 | { |
581 | union acpi_ec *ec = (union acpi_ec *)ec_cxt; | 539 | struct acpi_ec *ec = (struct acpi_ec *)ec_cxt; |
582 | u32 value; | 540 | u32 value; |
583 | int result = -ENODATA; | 541 | int result = -ENODATA; |
584 | static char object_name[5] = { '_', 'Q', '0', '0', '\0' }; | 542 | static char object_name[5] = { '_', 'Q', '0', '0', '\0' }; |
@@ -598,15 +556,14 @@ static void acpi_ec_gpe_intr_query(void *ec_cxt) | |||
598 | 556 | ||
599 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); | 557 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); |
600 | 558 | ||
601 | acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); | 559 | acpi_evaluate_object(ec->handle, object_name, NULL, NULL); |
602 | end: | 560 | end: |
603 | atomic_dec(&ec->intr.pending_gpe); | ||
604 | return; | 561 | return; |
605 | } | 562 | } |
606 | 563 | ||
607 | static u32 acpi_ec_gpe_handler(void *data) | 564 | static u32 acpi_ec_gpe_handler(void *data) |
608 | { | 565 | { |
609 | if (acpi_ec_poll_mode) | 566 | if (acpi_ec_mode == EC_POLL) |
610 | return acpi_ec_gpe_poll_handler(data); | 567 | return acpi_ec_gpe_poll_handler(data); |
611 | else | 568 | else |
612 | return acpi_ec_gpe_intr_handler(data); | 569 | return acpi_ec_gpe_intr_handler(data); |
@@ -614,12 +571,12 @@ static u32 acpi_ec_gpe_handler(void *data) | |||
614 | static u32 acpi_ec_gpe_poll_handler(void *data) | 571 | static u32 acpi_ec_gpe_poll_handler(void *data) |
615 | { | 572 | { |
616 | acpi_status status = AE_OK; | 573 | acpi_status status = AE_OK; |
617 | union acpi_ec *ec = (union acpi_ec *)data; | 574 | struct acpi_ec *ec = (struct acpi_ec *)data; |
618 | 575 | ||
619 | if (!ec) | 576 | if (!ec) |
620 | return ACPI_INTERRUPT_NOT_HANDLED; | 577 | return ACPI_INTERRUPT_NOT_HANDLED; |
621 | 578 | ||
622 | acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); | 579 | acpi_disable_gpe(NULL, ec->gpe_bit, ACPI_ISR); |
623 | 580 | ||
624 | status = acpi_os_execute(OSL_EC_POLL_HANDLER, acpi_ec_gpe_query, ec); | 581 | status = acpi_os_execute(OSL_EC_POLL_HANDLER, acpi_ec_gpe_query, ec); |
625 | 582 | ||
@@ -632,39 +589,38 @@ static u32 acpi_ec_gpe_intr_handler(void *data) | |||
632 | { | 589 | { |
633 | acpi_status status = AE_OK; | 590 | acpi_status status = AE_OK; |
634 | u32 value; | 591 | u32 value; |
635 | union acpi_ec *ec = (union acpi_ec *)data; | 592 | struct acpi_ec *ec = (struct acpi_ec *)data; |
636 | 593 | ||
637 | if (!ec) | 594 | if (!ec) |
638 | return ACPI_INTERRUPT_NOT_HANDLED; | 595 | return ACPI_INTERRUPT_NOT_HANDLED; |
639 | 596 | ||
640 | acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); | 597 | acpi_clear_gpe(NULL, ec->gpe_bit, ACPI_ISR); |
641 | value = acpi_ec_read_status(ec); | 598 | value = acpi_ec_read_status(ec); |
642 | 599 | ||
643 | switch (ec->intr.expect_event) { | 600 | switch (ec->expect_event) { |
644 | case ACPI_EC_EVENT_OBF: | 601 | case ACPI_EC_EVENT_OBF_1: |
645 | if (!(value & ACPI_EC_FLAG_OBF)) | 602 | if (!(value & ACPI_EC_FLAG_OBF)) |
646 | break; | 603 | break; |
647 | ec->intr.expect_event = 0; | 604 | ec->expect_event = 0; |
648 | wake_up(&ec->intr.wait); | 605 | wake_up(&ec->wait); |
649 | break; | 606 | break; |
650 | case ACPI_EC_EVENT_IBE: | 607 | case ACPI_EC_EVENT_IBF_0: |
651 | if ((value & ACPI_EC_FLAG_IBF)) | 608 | if ((value & ACPI_EC_FLAG_IBF)) |
652 | break; | 609 | break; |
653 | ec->intr.expect_event = 0; | 610 | ec->expect_event = 0; |
654 | wake_up(&ec->intr.wait); | 611 | wake_up(&ec->wait); |
655 | break; | 612 | break; |
656 | default: | 613 | default: |
657 | break; | 614 | break; |
658 | } | 615 | } |
659 | 616 | ||
660 | if (value & ACPI_EC_FLAG_SCI) { | 617 | if (value & ACPI_EC_FLAG_SCI) { |
661 | atomic_add(1, &ec->intr.pending_gpe); | ||
662 | status = acpi_os_execute(OSL_EC_BURST_HANDLER, | 618 | status = acpi_os_execute(OSL_EC_BURST_HANDLER, |
663 | acpi_ec_gpe_query, ec); | 619 | acpi_ec_gpe_query, ec); |
664 | return status == AE_OK ? | 620 | return status == AE_OK ? |
665 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; | 621 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; |
666 | } | 622 | } |
667 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); | 623 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_ISR); |
668 | return status == AE_OK ? | 624 | return status == AE_OK ? |
669 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; | 625 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; |
670 | } | 626 | } |
@@ -695,7 +651,7 @@ acpi_ec_space_handler(u32 function, | |||
695 | void *handler_context, void *region_context) | 651 | void *handler_context, void *region_context) |
696 | { | 652 | { |
697 | int result = 0; | 653 | int result = 0; |
698 | union acpi_ec *ec = NULL; | 654 | struct acpi_ec *ec = NULL; |
699 | u64 temp = *value; | 655 | u64 temp = *value; |
700 | acpi_integer f_v = 0; | 656 | acpi_integer f_v = 0; |
701 | int i = 0; | 657 | int i = 0; |
@@ -705,12 +661,10 @@ acpi_ec_space_handler(u32 function, | |||
705 | return AE_BAD_PARAMETER; | 661 | return AE_BAD_PARAMETER; |
706 | 662 | ||
707 | if (bit_width != 8 && acpi_strict) { | 663 | if (bit_width != 8 && acpi_strict) { |
708 | printk(KERN_WARNING PREFIX | ||
709 | "acpi_ec_space_handler: bit_width should be 8\n"); | ||
710 | return AE_BAD_PARAMETER; | 664 | return AE_BAD_PARAMETER; |
711 | } | 665 | } |
712 | 666 | ||
713 | ec = (union acpi_ec *)handler_context; | 667 | ec = (struct acpi_ec *)handler_context; |
714 | 668 | ||
715 | next_byte: | 669 | next_byte: |
716 | switch (function) { | 670 | switch (function) { |
@@ -767,20 +721,20 @@ static struct proc_dir_entry *acpi_ec_dir; | |||
767 | 721 | ||
768 | static int acpi_ec_read_info(struct seq_file *seq, void *offset) | 722 | static int acpi_ec_read_info(struct seq_file *seq, void *offset) |
769 | { | 723 | { |
770 | union acpi_ec *ec = (union acpi_ec *)seq->private; | 724 | struct acpi_ec *ec = (struct acpi_ec *)seq->private; |
771 | 725 | ||
772 | 726 | ||
773 | if (!ec) | 727 | if (!ec) |
774 | goto end; | 728 | goto end; |
775 | 729 | ||
776 | seq_printf(seq, "gpe bit: 0x%02x\n", | 730 | seq_printf(seq, "gpe bit: 0x%02x\n", |
777 | (u32) ec->common.gpe_bit); | 731 | (u32) ec->gpe_bit); |
778 | seq_printf(seq, "ports: 0x%02x, 0x%02x\n", | 732 | seq_printf(seq, "ports: 0x%02x, 0x%02x\n", |
779 | (u32) ec->common.status_addr.address, | 733 | (u32) ec->status_addr.address, |
780 | (u32) ec->common.data_addr.address); | 734 | (u32) ec->data_addr.address); |
781 | seq_printf(seq, "use global lock: %s\n", | 735 | seq_printf(seq, "use global lock: %s\n", |
782 | ec->common.global_lock ? "yes" : "no"); | 736 | ec->global_lock ? "yes" : "no"); |
783 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 737 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); |
784 | 738 | ||
785 | end: | 739 | end: |
786 | return 0; | 740 | return 0; |
@@ -791,7 +745,7 @@ static int acpi_ec_info_open_fs(struct inode *inode, struct file *file) | |||
791 | return single_open(file, acpi_ec_read_info, PDE(inode)->data); | 745 | return single_open(file, acpi_ec_read_info, PDE(inode)->data); |
792 | } | 746 | } |
793 | 747 | ||
794 | static const struct file_operations acpi_ec_info_ops = { | 748 | static struct file_operations acpi_ec_info_ops = { |
795 | .open = acpi_ec_info_open_fs, | 749 | .open = acpi_ec_info_open_fs, |
796 | .read = seq_read, | 750 | .read = seq_read, |
797 | .llseek = seq_lseek, | 751 | .llseek = seq_lseek, |
@@ -840,101 +794,35 @@ static int acpi_ec_remove_fs(struct acpi_device *device) | |||
840 | Driver Interface | 794 | Driver Interface |
841 | -------------------------------------------------------------------------- */ | 795 | -------------------------------------------------------------------------- */ |
842 | 796 | ||
843 | static int acpi_ec_poll_add(struct acpi_device *device) | 797 | static int acpi_ec_add(struct acpi_device *device) |
844 | { | 798 | { |
845 | int result = 0; | 799 | int result = 0; |
846 | acpi_status status = AE_OK; | 800 | acpi_status status = AE_OK; |
847 | union acpi_ec *ec = NULL; | 801 | struct acpi_ec *ec = NULL; |
848 | 802 | ||
849 | 803 | ||
850 | if (!device) | 804 | if (!device) |
851 | return -EINVAL; | 805 | return -EINVAL; |
852 | 806 | ||
853 | ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); | 807 | ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); |
854 | if (!ec) | 808 | if (!ec) |
855 | return -ENOMEM; | 809 | return -ENOMEM; |
856 | memset(ec, 0, sizeof(union acpi_ec)); | 810 | memset(ec, 0, sizeof(struct acpi_ec)); |
857 | 811 | ||
858 | ec->common.handle = device->handle; | 812 | ec->handle = device->handle; |
859 | ec->common.uid = -1; | 813 | ec->uid = -1; |
860 | init_MUTEX(&ec->poll.sem); | 814 | init_MUTEX(&ec->sem); |
861 | strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); | 815 | if (acpi_ec_mode == EC_INTR) { |
862 | strcpy(acpi_device_class(device), ACPI_EC_CLASS); | 816 | atomic_set(&ec->leaving_burst, 1); |
863 | acpi_driver_data(device) = ec; | 817 | init_waitqueue_head(&ec->wait); |
864 | |||
865 | /* Use the global lock for all EC transactions? */ | ||
866 | acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, | ||
867 | &ec->common.global_lock); | ||
868 | |||
869 | /* XXX we don't test uids, because on some boxes ecdt uid = 0, see: | ||
870 | http://bugzilla.kernel.org/show_bug.cgi?id=6111 */ | ||
871 | if (ec_ecdt) { | ||
872 | acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, | ||
873 | ACPI_ADR_SPACE_EC, | ||
874 | &acpi_ec_space_handler); | ||
875 | |||
876 | acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, | ||
877 | &acpi_ec_gpe_handler); | ||
878 | |||
879 | kfree(ec_ecdt); | ||
880 | } | ||
881 | |||
882 | /* Get GPE bit assignment (EC events). */ | ||
883 | /* TODO: Add support for _GPE returning a package */ | ||
884 | status = | ||
885 | acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, | ||
886 | &ec->common.gpe_bit); | ||
887 | if (ACPI_FAILURE(status)) { | ||
888 | ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit")); | ||
889 | result = -ENODEV; | ||
890 | goto end; | ||
891 | } | 818 | } |
892 | |||
893 | result = acpi_ec_add_fs(device); | ||
894 | if (result) | ||
895 | goto end; | ||
896 | |||
897 | printk(KERN_INFO PREFIX "%s [%s] (gpe %d) polling mode.\n", | ||
898 | acpi_device_name(device), acpi_device_bid(device), | ||
899 | (u32) ec->common.gpe_bit); | ||
900 | |||
901 | if (!first_ec) | ||
902 | first_ec = device; | ||
903 | |||
904 | end: | ||
905 | if (result) | ||
906 | kfree(ec); | ||
907 | |||
908 | return result; | ||
909 | } | ||
910 | static int acpi_ec_intr_add(struct acpi_device *device) | ||
911 | { | ||
912 | int result = 0; | ||
913 | acpi_status status = AE_OK; | ||
914 | union acpi_ec *ec = NULL; | ||
915 | |||
916 | |||
917 | if (!device) | ||
918 | return -EINVAL; | ||
919 | |||
920 | ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); | ||
921 | if (!ec) | ||
922 | return -ENOMEM; | ||
923 | memset(ec, 0, sizeof(union acpi_ec)); | ||
924 | |||
925 | ec->common.handle = device->handle; | ||
926 | ec->common.uid = -1; | ||
927 | atomic_set(&ec->intr.pending_gpe, 0); | ||
928 | atomic_set(&ec->intr.leaving_burst, 1); | ||
929 | init_MUTEX(&ec->intr.sem); | ||
930 | init_waitqueue_head(&ec->intr.wait); | ||
931 | strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); | 819 | strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); |
932 | strcpy(acpi_device_class(device), ACPI_EC_CLASS); | 820 | strcpy(acpi_device_class(device), ACPI_EC_CLASS); |
933 | acpi_driver_data(device) = ec; | 821 | acpi_driver_data(device) = ec; |
934 | 822 | ||
935 | /* Use the global lock for all EC transactions? */ | 823 | /* Use the global lock for all EC transactions? */ |
936 | acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, | 824 | acpi_evaluate_integer(ec->handle, "_GLK", NULL, |
937 | &ec->common.global_lock); | 825 | &ec->global_lock); |
938 | 826 | ||
939 | /* XXX we don't test uids, because on some boxes ecdt uid = 0, see: | 827 | /* XXX we don't test uids, because on some boxes ecdt uid = 0, see: |
940 | http://bugzilla.kernel.org/show_bug.cgi?id=6111 */ | 828 | http://bugzilla.kernel.org/show_bug.cgi?id=6111 */ |
@@ -943,7 +831,7 @@ static int acpi_ec_intr_add(struct acpi_device *device) | |||
943 | ACPI_ADR_SPACE_EC, | 831 | ACPI_ADR_SPACE_EC, |
944 | &acpi_ec_space_handler); | 832 | &acpi_ec_space_handler); |
945 | 833 | ||
946 | acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, | 834 | acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, |
947 | &acpi_ec_gpe_handler); | 835 | &acpi_ec_gpe_handler); |
948 | 836 | ||
949 | kfree(ec_ecdt); | 837 | kfree(ec_ecdt); |
@@ -952,10 +840,10 @@ static int acpi_ec_intr_add(struct acpi_device *device) | |||
952 | /* Get GPE bit assignment (EC events). */ | 840 | /* Get GPE bit assignment (EC events). */ |
953 | /* TODO: Add support for _GPE returning a package */ | 841 | /* TODO: Add support for _GPE returning a package */ |
954 | status = | 842 | status = |
955 | acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, | 843 | acpi_evaluate_integer(ec->handle, "_GPE", NULL, |
956 | &ec->common.gpe_bit); | 844 | &ec->gpe_bit); |
957 | if (ACPI_FAILURE(status)) { | 845 | if (ACPI_FAILURE(status)) { |
958 | printk(KERN_ERR PREFIX "Obtaining GPE bit assignment\n"); | 846 | ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit assignment")); |
959 | result = -ENODEV; | 847 | result = -ENODEV; |
960 | goto end; | 848 | goto end; |
961 | } | 849 | } |
@@ -964,14 +852,14 @@ static int acpi_ec_intr_add(struct acpi_device *device) | |||
964 | if (result) | 852 | if (result) |
965 | goto end; | 853 | goto end; |
966 | 854 | ||
967 | printk(KERN_INFO PREFIX "%s [%s] (gpe %d) interrupt mode.\n", | 855 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.", |
968 | acpi_device_name(device), acpi_device_bid(device), | 856 | acpi_device_name(device), acpi_device_bid(device), |
969 | (u32) ec->common.gpe_bit); | 857 | (u32) ec->gpe_bit)); |
970 | 858 | ||
971 | if (!first_ec) | 859 | if (!first_ec) |
972 | first_ec = device; | 860 | first_ec = device; |
973 | 861 | ||
974 | end: | 862 | end: |
975 | if (result) | 863 | if (result) |
976 | kfree(ec); | 864 | kfree(ec); |
977 | 865 | ||
@@ -980,7 +868,7 @@ static int acpi_ec_intr_add(struct acpi_device *device) | |||
980 | 868 | ||
981 | static int acpi_ec_remove(struct acpi_device *device, int type) | 869 | static int acpi_ec_remove(struct acpi_device *device, int type) |
982 | { | 870 | { |
983 | union acpi_ec *ec = NULL; | 871 | struct acpi_ec *ec = NULL; |
984 | 872 | ||
985 | 873 | ||
986 | if (!device) | 874 | if (!device) |
@@ -998,7 +886,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type) | |||
998 | static acpi_status | 886 | static acpi_status |
999 | acpi_ec_io_ports(struct acpi_resource *resource, void *context) | 887 | acpi_ec_io_ports(struct acpi_resource *resource, void *context) |
1000 | { | 888 | { |
1001 | union acpi_ec *ec = (union acpi_ec *)context; | 889 | struct acpi_ec *ec = (struct acpi_ec *)context; |
1002 | struct acpi_generic_address *addr; | 890 | struct acpi_generic_address *addr; |
1003 | 891 | ||
1004 | if (resource->type != ACPI_RESOURCE_TYPE_IO) { | 892 | if (resource->type != ACPI_RESOURCE_TYPE_IO) { |
@@ -1010,10 +898,10 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context) | |||
1010 | * the second address region returned is the status/command | 898 | * the second address region returned is the status/command |
1011 | * port. | 899 | * port. |
1012 | */ | 900 | */ |
1013 | if (ec->common.data_addr.register_bit_width == 0) { | 901 | if (ec->data_addr.register_bit_width == 0) { |
1014 | addr = &ec->common.data_addr; | 902 | addr = &ec->data_addr; |
1015 | } else if (ec->common.command_addr.register_bit_width == 0) { | 903 | } else if (ec->command_addr.register_bit_width == 0) { |
1016 | addr = &ec->common.command_addr; | 904 | addr = &ec->command_addr; |
1017 | } else { | 905 | } else { |
1018 | return AE_CTRL_TERMINATE; | 906 | return AE_CTRL_TERMINATE; |
1019 | } | 907 | } |
@@ -1029,7 +917,7 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context) | |||
1029 | static int acpi_ec_start(struct acpi_device *device) | 917 | static int acpi_ec_start(struct acpi_device *device) |
1030 | { | 918 | { |
1031 | acpi_status status = AE_OK; | 919 | acpi_status status = AE_OK; |
1032 | union acpi_ec *ec = NULL; | 920 | struct acpi_ec *ec = NULL; |
1033 | 921 | ||
1034 | 922 | ||
1035 | if (!device) | 923 | if (!device) |
@@ -1043,39 +931,40 @@ static int acpi_ec_start(struct acpi_device *device) | |||
1043 | /* | 931 | /* |
1044 | * Get I/O port addresses. Convert to GAS format. | 932 | * Get I/O port addresses. Convert to GAS format. |
1045 | */ | 933 | */ |
1046 | status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS, | 934 | status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS, |
1047 | acpi_ec_io_ports, ec); | 935 | acpi_ec_io_ports, ec); |
1048 | if (ACPI_FAILURE(status) | 936 | if (ACPI_FAILURE(status) |
1049 | || ec->common.command_addr.register_bit_width == 0) { | 937 | || ec->command_addr.register_bit_width == 0) { |
1050 | printk(KERN_ERR PREFIX "Error getting I/O port addresses\n"); | 938 | ACPI_EXCEPTION((AE_INFO, status, |
939 | "Error getting I/O port addresses")); | ||
1051 | return -ENODEV; | 940 | return -ENODEV; |
1052 | } | 941 | } |
1053 | 942 | ||
1054 | ec->common.status_addr = ec->common.command_addr; | 943 | ec->status_addr = ec->command_addr; |
1055 | 944 | ||
1056 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n", | 945 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x", |
1057 | (u32) ec->common.gpe_bit, | 946 | (u32) ec->gpe_bit, |
1058 | (u32) ec->common.command_addr.address, | 947 | (u32) ec->command_addr.address, |
1059 | (u32) ec->common.data_addr.address)); | 948 | (u32) ec->data_addr.address)); |
1060 | 949 | ||
1061 | /* | 950 | /* |
1062 | * Install GPE handler | 951 | * Install GPE handler |
1063 | */ | 952 | */ |
1064 | status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit, | 953 | status = acpi_install_gpe_handler(NULL, ec->gpe_bit, |
1065 | ACPI_GPE_EDGE_TRIGGERED, | 954 | ACPI_GPE_EDGE_TRIGGERED, |
1066 | &acpi_ec_gpe_handler, ec); | 955 | &acpi_ec_gpe_handler, ec); |
1067 | if (ACPI_FAILURE(status)) { | 956 | if (ACPI_FAILURE(status)) { |
1068 | return -ENODEV; | 957 | return -ENODEV; |
1069 | } | 958 | } |
1070 | acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); | 959 | acpi_set_gpe_type(NULL, ec->gpe_bit, ACPI_GPE_TYPE_RUNTIME); |
1071 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 960 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); |
1072 | 961 | ||
1073 | status = acpi_install_address_space_handler(ec->common.handle, | 962 | status = acpi_install_address_space_handler(ec->handle, |
1074 | ACPI_ADR_SPACE_EC, | 963 | ACPI_ADR_SPACE_EC, |
1075 | &acpi_ec_space_handler, | 964 | &acpi_ec_space_handler, |
1076 | &acpi_ec_space_setup, ec); | 965 | &acpi_ec_space_setup, ec); |
1077 | if (ACPI_FAILURE(status)) { | 966 | if (ACPI_FAILURE(status)) { |
1078 | acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, | 967 | acpi_remove_gpe_handler(NULL, ec->gpe_bit, |
1079 | &acpi_ec_gpe_handler); | 968 | &acpi_ec_gpe_handler); |
1080 | return -ENODEV; | 969 | return -ENODEV; |
1081 | } | 970 | } |
@@ -1086,7 +975,7 @@ static int acpi_ec_start(struct acpi_device *device) | |||
1086 | static int acpi_ec_stop(struct acpi_device *device, int type) | 975 | static int acpi_ec_stop(struct acpi_device *device, int type) |
1087 | { | 976 | { |
1088 | acpi_status status = AE_OK; | 977 | acpi_status status = AE_OK; |
1089 | union acpi_ec *ec = NULL; | 978 | struct acpi_ec *ec = NULL; |
1090 | 979 | ||
1091 | 980 | ||
1092 | if (!device) | 981 | if (!device) |
@@ -1094,14 +983,14 @@ static int acpi_ec_stop(struct acpi_device *device, int type) | |||
1094 | 983 | ||
1095 | ec = acpi_driver_data(device); | 984 | ec = acpi_driver_data(device); |
1096 | 985 | ||
1097 | status = acpi_remove_address_space_handler(ec->common.handle, | 986 | status = acpi_remove_address_space_handler(ec->handle, |
1098 | ACPI_ADR_SPACE_EC, | 987 | ACPI_ADR_SPACE_EC, |
1099 | &acpi_ec_space_handler); | 988 | &acpi_ec_space_handler); |
1100 | if (ACPI_FAILURE(status)) | 989 | if (ACPI_FAILURE(status)) |
1101 | return -ENODEV; | 990 | return -ENODEV; |
1102 | 991 | ||
1103 | status = | 992 | status = |
1104 | acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, | 993 | acpi_remove_gpe_handler(NULL, ec->gpe_bit, |
1105 | &acpi_ec_gpe_handler); | 994 | &acpi_ec_gpe_handler); |
1106 | if (ACPI_FAILURE(status)) | 995 | if (ACPI_FAILURE(status)) |
1107 | return -ENODEV; | 996 | return -ENODEV; |
@@ -1113,76 +1002,33 @@ static acpi_status __init | |||
1113 | acpi_fake_ecdt_callback(acpi_handle handle, | 1002 | acpi_fake_ecdt_callback(acpi_handle handle, |
1114 | u32 Level, void *context, void **retval) | 1003 | u32 Level, void *context, void **retval) |
1115 | { | 1004 | { |
1116 | |||
1117 | if (acpi_ec_poll_mode) | ||
1118 | return acpi_fake_ecdt_poll_callback(handle, | ||
1119 | Level, context, retval); | ||
1120 | else | ||
1121 | return acpi_fake_ecdt_intr_callback(handle, | ||
1122 | Level, context, retval); | ||
1123 | } | ||
1124 | |||
1125 | static acpi_status __init | ||
1126 | acpi_fake_ecdt_poll_callback(acpi_handle handle, | ||
1127 | u32 Level, void *context, void **retval) | ||
1128 | { | ||
1129 | acpi_status status; | ||
1130 | |||
1131 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | ||
1132 | acpi_ec_io_ports, ec_ecdt); | ||
1133 | if (ACPI_FAILURE(status)) | ||
1134 | return status; | ||
1135 | ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; | ||
1136 | |||
1137 | ec_ecdt->common.uid = -1; | ||
1138 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); | ||
1139 | |||
1140 | status = | ||
1141 | acpi_evaluate_integer(handle, "_GPE", NULL, | ||
1142 | &ec_ecdt->common.gpe_bit); | ||
1143 | if (ACPI_FAILURE(status)) | ||
1144 | return status; | ||
1145 | init_MUTEX(&ec_ecdt->poll.sem); | ||
1146 | ec_ecdt->common.global_lock = TRUE; | ||
1147 | ec_ecdt->common.handle = handle; | ||
1148 | |||
1149 | printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", | ||
1150 | (u32) ec_ecdt->common.gpe_bit, | ||
1151 | (u32) ec_ecdt->common.command_addr.address, | ||
1152 | (u32) ec_ecdt->common.data_addr.address); | ||
1153 | |||
1154 | return AE_CTRL_TERMINATE; | ||
1155 | } | ||
1156 | |||
1157 | static acpi_status __init | ||
1158 | acpi_fake_ecdt_intr_callback(acpi_handle handle, | ||
1159 | u32 Level, void *context, void **retval) | ||
1160 | { | ||
1161 | acpi_status status; | 1005 | acpi_status status; |
1162 | 1006 | ||
1163 | init_MUTEX(&ec_ecdt->intr.sem); | 1007 | init_MUTEX(&ec_ecdt->sem); |
1164 | init_waitqueue_head(&ec_ecdt->intr.wait); | 1008 | if (acpi_ec_mode == EC_INTR) { |
1009 | init_waitqueue_head(&ec_ecdt->wait); | ||
1010 | } | ||
1165 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | 1011 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
1166 | acpi_ec_io_ports, ec_ecdt); | 1012 | acpi_ec_io_ports, ec_ecdt); |
1167 | if (ACPI_FAILURE(status)) | 1013 | if (ACPI_FAILURE(status)) |
1168 | return status; | 1014 | return status; |
1169 | ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; | 1015 | ec_ecdt->status_addr = ec_ecdt->command_addr; |
1170 | 1016 | ||
1171 | ec_ecdt->common.uid = -1; | 1017 | ec_ecdt->uid = -1; |
1172 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); | 1018 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid); |
1173 | 1019 | ||
1174 | status = | 1020 | status = |
1175 | acpi_evaluate_integer(handle, "_GPE", NULL, | 1021 | acpi_evaluate_integer(handle, "_GPE", NULL, |
1176 | &ec_ecdt->common.gpe_bit); | 1022 | &ec_ecdt->gpe_bit); |
1177 | if (ACPI_FAILURE(status)) | 1023 | if (ACPI_FAILURE(status)) |
1178 | return status; | 1024 | return status; |
1179 | ec_ecdt->common.global_lock = TRUE; | 1025 | ec_ecdt->global_lock = TRUE; |
1180 | ec_ecdt->common.handle = handle; | 1026 | ec_ecdt->handle = handle; |
1181 | 1027 | ||
1182 | printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", | 1028 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02x, ports=0x%2x, 0x%2x", |
1183 | (u32) ec_ecdt->common.gpe_bit, | 1029 | (u32) ec_ecdt->gpe_bit, |
1184 | (u32) ec_ecdt->common.command_addr.address, | 1030 | (u32) ec_ecdt->command_addr.address, |
1185 | (u32) ec_ecdt->common.data_addr.address); | 1031 | (u32) ec_ecdt->data_addr.address)); |
1186 | 1032 | ||
1187 | return AE_CTRL_TERMINATE; | 1033 | return AE_CTRL_TERMINATE; |
1188 | } | 1034 | } |
@@ -1202,14 +1048,14 @@ static int __init acpi_ec_fake_ecdt(void) | |||
1202 | acpi_status status; | 1048 | acpi_status status; |
1203 | int ret = 0; | 1049 | int ret = 0; |
1204 | 1050 | ||
1205 | printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); | 1051 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT")); |
1206 | 1052 | ||
1207 | ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); | 1053 | ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); |
1208 | if (!ec_ecdt) { | 1054 | if (!ec_ecdt) { |
1209 | ret = -ENOMEM; | 1055 | ret = -ENOMEM; |
1210 | goto error; | 1056 | goto error; |
1211 | } | 1057 | } |
1212 | memset(ec_ecdt, 0, sizeof(union acpi_ec)); | 1058 | memset(ec_ecdt, 0, sizeof(struct acpi_ec)); |
1213 | 1059 | ||
1214 | status = acpi_get_devices(ACPI_EC_HID, | 1060 | status = acpi_get_devices(ACPI_EC_HID, |
1215 | acpi_fake_ecdt_callback, NULL, NULL); | 1061 | acpi_fake_ecdt_callback, NULL, NULL); |
@@ -1217,24 +1063,16 @@ static int __init acpi_ec_fake_ecdt(void) | |||
1217 | kfree(ec_ecdt); | 1063 | kfree(ec_ecdt); |
1218 | ec_ecdt = NULL; | 1064 | ec_ecdt = NULL; |
1219 | ret = -ENODEV; | 1065 | ret = -ENODEV; |
1066 | ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT")); | ||
1220 | goto error; | 1067 | goto error; |
1221 | } | 1068 | } |
1222 | return 0; | 1069 | return 0; |
1223 | error: | 1070 | error: |
1224 | printk(KERN_ERR PREFIX "Can't make an fake ECDT\n"); | ||
1225 | return ret; | 1071 | return ret; |
1226 | } | 1072 | } |
1227 | 1073 | ||
1228 | static int __init acpi_ec_get_real_ecdt(void) | 1074 | static int __init acpi_ec_get_real_ecdt(void) |
1229 | { | 1075 | { |
1230 | if (acpi_ec_poll_mode) | ||
1231 | return acpi_ec_poll_get_real_ecdt(); | ||
1232 | else | ||
1233 | return acpi_ec_intr_get_real_ecdt(); | ||
1234 | } | ||
1235 | |||
1236 | static int __init acpi_ec_poll_get_real_ecdt(void) | ||
1237 | { | ||
1238 | acpi_status status; | 1076 | acpi_status status; |
1239 | struct acpi_table_ecdt *ecdt_ptr; | 1077 | struct acpi_table_ecdt *ecdt_ptr; |
1240 | 1078 | ||
@@ -1244,80 +1082,37 @@ static int __init acpi_ec_poll_get_real_ecdt(void) | |||
1244 | if (ACPI_FAILURE(status)) | 1082 | if (ACPI_FAILURE(status)) |
1245 | return -ENODEV; | 1083 | return -ENODEV; |
1246 | 1084 | ||
1247 | printk(KERN_INFO PREFIX "Found ECDT\n"); | 1085 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT")); |
1248 | 1086 | ||
1249 | /* | 1087 | /* |
1250 | * Generate a temporary ec context to use until the namespace is scanned | 1088 | * Generate a temporary ec context to use until the namespace is scanned |
1251 | */ | 1089 | */ |
1252 | ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); | 1090 | ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); |
1253 | if (!ec_ecdt) | 1091 | if (!ec_ecdt) |
1254 | return -ENOMEM; | 1092 | return -ENOMEM; |
1255 | memset(ec_ecdt, 0, sizeof(union acpi_ec)); | 1093 | memset(ec_ecdt, 0, sizeof(struct acpi_ec)); |
1256 | |||
1257 | ec_ecdt->common.command_addr = ecdt_ptr->ec_control; | ||
1258 | ec_ecdt->common.status_addr = ecdt_ptr->ec_control; | ||
1259 | ec_ecdt->common.data_addr = ecdt_ptr->ec_data; | ||
1260 | ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit; | ||
1261 | init_MUTEX(&ec_ecdt->poll.sem); | ||
1262 | /* use the GL just to be safe */ | ||
1263 | ec_ecdt->common.global_lock = TRUE; | ||
1264 | ec_ecdt->common.uid = ecdt_ptr->uid; | ||
1265 | 1094 | ||
1266 | status = | 1095 | init_MUTEX(&ec_ecdt->sem); |
1267 | acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); | 1096 | if (acpi_ec_mode == EC_INTR) { |
1268 | if (ACPI_FAILURE(status)) { | 1097 | init_waitqueue_head(&ec_ecdt->wait); |
1269 | goto error; | ||
1270 | } | 1098 | } |
1271 | 1099 | ec_ecdt->command_addr = ecdt_ptr->ec_control; | |
1272 | return 0; | 1100 | ec_ecdt->status_addr = ecdt_ptr->ec_control; |
1273 | error: | 1101 | ec_ecdt->data_addr = ecdt_ptr->ec_data; |
1274 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); | 1102 | ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit; |
1275 | kfree(ec_ecdt); | ||
1276 | ec_ecdt = NULL; | ||
1277 | |||
1278 | return -ENODEV; | ||
1279 | } | ||
1280 | |||
1281 | static int __init acpi_ec_intr_get_real_ecdt(void) | ||
1282 | { | ||
1283 | acpi_status status; | ||
1284 | struct acpi_table_ecdt *ecdt_ptr; | ||
1285 | |||
1286 | status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, | ||
1287 | (struct acpi_table_header **) | ||
1288 | &ecdt_ptr); | ||
1289 | if (ACPI_FAILURE(status)) | ||
1290 | return -ENODEV; | ||
1291 | |||
1292 | printk(KERN_INFO PREFIX "Found ECDT\n"); | ||
1293 | |||
1294 | /* | ||
1295 | * Generate a temporary ec context to use until the namespace is scanned | ||
1296 | */ | ||
1297 | ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); | ||
1298 | if (!ec_ecdt) | ||
1299 | return -ENOMEM; | ||
1300 | memset(ec_ecdt, 0, sizeof(union acpi_ec)); | ||
1301 | |||
1302 | init_MUTEX(&ec_ecdt->intr.sem); | ||
1303 | init_waitqueue_head(&ec_ecdt->intr.wait); | ||
1304 | ec_ecdt->common.command_addr = ecdt_ptr->ec_control; | ||
1305 | ec_ecdt->common.status_addr = ecdt_ptr->ec_control; | ||
1306 | ec_ecdt->common.data_addr = ecdt_ptr->ec_data; | ||
1307 | ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit; | ||
1308 | /* use the GL just to be safe */ | 1103 | /* use the GL just to be safe */ |
1309 | ec_ecdt->common.global_lock = TRUE; | 1104 | ec_ecdt->global_lock = TRUE; |
1310 | ec_ecdt->common.uid = ecdt_ptr->uid; | 1105 | ec_ecdt->uid = ecdt_ptr->uid; |
1311 | 1106 | ||
1312 | status = | 1107 | status = |
1313 | acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); | 1108 | acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle); |
1314 | if (ACPI_FAILURE(status)) { | 1109 | if (ACPI_FAILURE(status)) { |
1315 | goto error; | 1110 | goto error; |
1316 | } | 1111 | } |
1317 | 1112 | ||
1318 | return 0; | 1113 | return 0; |
1319 | error: | 1114 | error: |
1320 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); | 1115 | ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT")); |
1321 | kfree(ec_ecdt); | 1116 | kfree(ec_ecdt); |
1322 | ec_ecdt = NULL; | 1117 | ec_ecdt = NULL; |
1323 | 1118 | ||
@@ -1342,14 +1137,14 @@ int __init acpi_ec_ecdt_probe(void) | |||
1342 | /* | 1137 | /* |
1343 | * Install GPE handler | 1138 | * Install GPE handler |
1344 | */ | 1139 | */ |
1345 | status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit, | 1140 | status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe_bit, |
1346 | ACPI_GPE_EDGE_TRIGGERED, | 1141 | ACPI_GPE_EDGE_TRIGGERED, |
1347 | &acpi_ec_gpe_handler, ec_ecdt); | 1142 | &acpi_ec_gpe_handler, ec_ecdt); |
1348 | if (ACPI_FAILURE(status)) { | 1143 | if (ACPI_FAILURE(status)) { |
1349 | goto error; | 1144 | goto error; |
1350 | } | 1145 | } |
1351 | acpi_set_gpe_type(NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); | 1146 | acpi_set_gpe_type(NULL, ec_ecdt->gpe_bit, ACPI_GPE_TYPE_RUNTIME); |
1352 | acpi_enable_gpe(NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR); | 1147 | acpi_enable_gpe(NULL, ec_ecdt->gpe_bit, ACPI_NOT_ISR); |
1353 | 1148 | ||
1354 | status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT, | 1149 | status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT, |
1355 | ACPI_ADR_SPACE_EC, | 1150 | ACPI_ADR_SPACE_EC, |
@@ -1357,7 +1152,7 @@ int __init acpi_ec_ecdt_probe(void) | |||
1357 | &acpi_ec_space_setup, | 1152 | &acpi_ec_space_setup, |
1358 | ec_ecdt); | 1153 | ec_ecdt); |
1359 | if (ACPI_FAILURE(status)) { | 1154 | if (ACPI_FAILURE(status)) { |
1360 | acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, | 1155 | acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, |
1361 | &acpi_ec_gpe_handler); | 1156 | &acpi_ec_gpe_handler); |
1362 | goto error; | 1157 | goto error; |
1363 | } | 1158 | } |
@@ -1365,7 +1160,7 @@ int __init acpi_ec_ecdt_probe(void) | |||
1365 | return 0; | 1160 | return 0; |
1366 | 1161 | ||
1367 | error: | 1162 | error: |
1368 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); | 1163 | ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT")); |
1369 | kfree(ec_ecdt); | 1164 | kfree(ec_ecdt); |
1370 | ec_ecdt = NULL; | 1165 | ec_ecdt = NULL; |
1371 | 1166 | ||
@@ -1424,13 +1219,13 @@ static int __init acpi_ec_set_intr_mode(char *str) | |||
1424 | return 0; | 1219 | return 0; |
1425 | 1220 | ||
1426 | if (intr) { | 1221 | if (intr) { |
1427 | acpi_ec_poll_mode = EC_INTR; | 1222 | acpi_ec_mode = EC_INTR; |
1428 | acpi_ec_driver.ops.add = acpi_ec_intr_add; | ||
1429 | } else { | 1223 | } else { |
1430 | acpi_ec_poll_mode = EC_POLL; | 1224 | acpi_ec_mode = EC_POLL; |
1431 | acpi_ec_driver.ops.add = acpi_ec_poll_add; | ||
1432 | } | 1225 | } |
1433 | printk(KERN_INFO PREFIX "EC %s mode.\n", intr ? "interrupt" : "polling"); | 1226 | acpi_ec_driver.ops.add = acpi_ec_add; |
1227 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "EC %s mode.\n", intr ? "interrupt" : "polling")); | ||
1228 | |||
1434 | return 1; | 1229 | return 1; |
1435 | } | 1230 | } |
1436 | 1231 | ||