diff options
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r-- | drivers/acpi/ec.c | 869 |
1 files changed, 389 insertions, 480 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 31067a0a3671..7e1a445955bc 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -38,130 +38,112 @@ | |||
38 | #include <acpi/actypes.h> | 38 | #include <acpi/actypes.h> |
39 | 39 | ||
40 | #define _COMPONENT ACPI_EC_COMPONENT | 40 | #define _COMPONENT ACPI_EC_COMPONENT |
41 | ACPI_MODULE_NAME ("acpi_ec") | 41 | ACPI_MODULE_NAME("acpi_ec") |
42 | |||
43 | #define ACPI_EC_COMPONENT 0x00100000 | 42 | #define ACPI_EC_COMPONENT 0x00100000 |
44 | #define ACPI_EC_CLASS "embedded_controller" | 43 | #define ACPI_EC_CLASS "embedded_controller" |
45 | #define ACPI_EC_HID "PNP0C09" | 44 | #define ACPI_EC_HID "PNP0C09" |
46 | #define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" | 45 | #define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" |
47 | #define ACPI_EC_DEVICE_NAME "Embedded Controller" | 46 | #define ACPI_EC_DEVICE_NAME "Embedded Controller" |
48 | #define ACPI_EC_FILE_INFO "info" | 47 | #define ACPI_EC_FILE_INFO "info" |
49 | |||
50 | |||
51 | #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ | 48 | #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ |
52 | #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ | 49 | #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ |
53 | #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ | 50 | #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ |
54 | #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ | 51 | #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ |
55 | |||
56 | #define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */ | 52 | #define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */ |
57 | #define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */ | 53 | #define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */ |
58 | |||
59 | #define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */ | 54 | #define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */ |
60 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ | 55 | #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ |
61 | 56 | #define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */ | |
62 | #define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */ | 57 | #define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */ |
63 | #define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */ | ||
64 | |||
65 | #define ACPI_EC_COMMAND_READ 0x80 | 58 | #define ACPI_EC_COMMAND_READ 0x80 |
66 | #define ACPI_EC_COMMAND_WRITE 0x81 | 59 | #define ACPI_EC_COMMAND_WRITE 0x81 |
67 | #define ACPI_EC_BURST_ENABLE 0x82 | 60 | #define ACPI_EC_BURST_ENABLE 0x82 |
68 | #define ACPI_EC_BURST_DISABLE 0x83 | 61 | #define ACPI_EC_BURST_DISABLE 0x83 |
69 | #define ACPI_EC_COMMAND_QUERY 0x84 | 62 | #define ACPI_EC_COMMAND_QUERY 0x84 |
70 | |||
71 | #define EC_POLLING 0xFF | 63 | #define EC_POLLING 0xFF |
72 | #define EC_BURST 0x00 | 64 | #define EC_BURST 0x00 |
73 | 65 | static int acpi_ec_remove(struct acpi_device *device, int type); | |
74 | 66 | static int acpi_ec_start(struct acpi_device *device); | |
75 | static int acpi_ec_remove (struct acpi_device *device, int type); | 67 | static int acpi_ec_stop(struct acpi_device *device, int type); |
76 | static int acpi_ec_start (struct acpi_device *device); | 68 | static int acpi_ec_burst_add(struct acpi_device *device); |
77 | static int acpi_ec_stop (struct acpi_device *device, int type); | 69 | static int acpi_ec_polling_add(struct acpi_device *device); |
78 | static int acpi_ec_burst_add ( struct acpi_device *device); | ||
79 | static int acpi_ec_polling_add ( struct acpi_device *device); | ||
80 | 70 | ||
81 | static struct acpi_driver acpi_ec_driver = { | 71 | static struct acpi_driver acpi_ec_driver = { |
82 | .name = ACPI_EC_DRIVER_NAME, | 72 | .name = ACPI_EC_DRIVER_NAME, |
83 | .class = ACPI_EC_CLASS, | 73 | .class = ACPI_EC_CLASS, |
84 | .ids = ACPI_EC_HID, | 74 | .ids = ACPI_EC_HID, |
85 | .ops = { | 75 | .ops = { |
86 | .add = acpi_ec_polling_add, | 76 | .add = acpi_ec_polling_add, |
87 | .remove = acpi_ec_remove, | 77 | .remove = acpi_ec_remove, |
88 | .start = acpi_ec_start, | 78 | .start = acpi_ec_start, |
89 | .stop = acpi_ec_stop, | 79 | .stop = acpi_ec_stop, |
90 | }, | 80 | }, |
91 | }; | 81 | }; |
92 | union acpi_ec { | 82 | union acpi_ec { |
93 | struct { | 83 | struct { |
94 | u32 mode; | 84 | u32 mode; |
95 | acpi_handle handle; | 85 | acpi_handle handle; |
96 | unsigned long uid; | 86 | unsigned long uid; |
97 | unsigned long gpe_bit; | 87 | unsigned long gpe_bit; |
98 | struct acpi_generic_address status_addr; | 88 | struct acpi_generic_address status_addr; |
99 | struct acpi_generic_address command_addr; | 89 | struct acpi_generic_address command_addr; |
100 | struct acpi_generic_address data_addr; | 90 | struct acpi_generic_address data_addr; |
101 | unsigned long global_lock; | 91 | unsigned long global_lock; |
102 | } common; | 92 | } common; |
103 | 93 | ||
104 | struct { | 94 | struct { |
105 | u32 mode; | 95 | u32 mode; |
106 | acpi_handle handle; | 96 | acpi_handle handle; |
107 | unsigned long uid; | 97 | unsigned long uid; |
108 | unsigned long gpe_bit; | 98 | unsigned long gpe_bit; |
109 | struct acpi_generic_address status_addr; | 99 | struct acpi_generic_address status_addr; |
110 | struct acpi_generic_address command_addr; | 100 | struct acpi_generic_address command_addr; |
111 | struct acpi_generic_address data_addr; | 101 | struct acpi_generic_address data_addr; |
112 | unsigned long global_lock; | 102 | unsigned long global_lock; |
113 | unsigned int expect_event; | 103 | unsigned int expect_event; |
114 | atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort*/ | 104 | atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */ |
115 | atomic_t pending_gpe; | 105 | atomic_t pending_gpe; |
116 | struct semaphore sem; | 106 | struct semaphore sem; |
117 | wait_queue_head_t wait; | 107 | wait_queue_head_t wait; |
118 | }burst; | 108 | } burst; |
119 | 109 | ||
120 | struct { | 110 | struct { |
121 | u32 mode; | 111 | u32 mode; |
122 | acpi_handle handle; | 112 | acpi_handle handle; |
123 | unsigned long uid; | 113 | unsigned long uid; |
124 | unsigned long gpe_bit; | 114 | unsigned long gpe_bit; |
125 | struct acpi_generic_address status_addr; | 115 | struct acpi_generic_address status_addr; |
126 | struct acpi_generic_address command_addr; | 116 | struct acpi_generic_address command_addr; |
127 | struct acpi_generic_address data_addr; | 117 | struct acpi_generic_address data_addr; |
128 | unsigned long global_lock; | 118 | unsigned long global_lock; |
129 | spinlock_t lock; | 119 | spinlock_t lock; |
130 | }polling; | 120 | } polling; |
131 | }; | 121 | }; |
132 | 122 | ||
133 | static int acpi_ec_polling_wait ( union acpi_ec *ec, u8 event); | 123 | static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event); |
134 | static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event); | 124 | static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event); |
135 | static int acpi_ec_polling_read ( union acpi_ec *ec, u8 address, u32 *data); | 125 | static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data); |
136 | static int acpi_ec_burst_read( union acpi_ec *ec, u8 address, u32 *data); | 126 | static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data); |
137 | static int acpi_ec_polling_write ( union acpi_ec *ec, u8 address, u8 data); | 127 | static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data); |
138 | static int acpi_ec_burst_write ( union acpi_ec *ec, u8 address, u8 data); | 128 | static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data); |
139 | static int acpi_ec_polling_query ( union acpi_ec *ec, u32 *data); | 129 | static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data); |
140 | static int acpi_ec_burst_query ( union acpi_ec *ec, u32 *data); | 130 | static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data); |
141 | static void acpi_ec_gpe_polling_query ( void *ec_cxt); | 131 | static void acpi_ec_gpe_polling_query(void *ec_cxt); |
142 | static void acpi_ec_gpe_burst_query ( void *ec_cxt); | 132 | static void acpi_ec_gpe_burst_query(void *ec_cxt); |
143 | static u32 acpi_ec_gpe_polling_handler ( void *data); | 133 | static u32 acpi_ec_gpe_polling_handler(void *data); |
144 | static u32 acpi_ec_gpe_burst_handler ( void *data); | 134 | static u32 acpi_ec_gpe_burst_handler(void *data); |
145 | static acpi_status __init | 135 | static acpi_status __init |
146 | acpi_fake_ecdt_polling_callback ( | 136 | acpi_fake_ecdt_polling_callback(acpi_handle handle, |
147 | acpi_handle handle, | 137 | u32 Level, void *context, void **retval); |
148 | u32 Level, | ||
149 | void *context, | ||
150 | void **retval); | ||
151 | 138 | ||
152 | static acpi_status __init | 139 | static acpi_status __init |
153 | acpi_fake_ecdt_burst_callback ( | 140 | acpi_fake_ecdt_burst_callback(acpi_handle handle, |
154 | acpi_handle handle, | 141 | u32 Level, void *context, void **retval); |
155 | u32 Level, | 142 | |
156 | void *context, | 143 | static int __init acpi_ec_polling_get_real_ecdt(void); |
157 | void **retval); | 144 | static int __init acpi_ec_burst_get_real_ecdt(void); |
158 | |||
159 | static int __init | ||
160 | acpi_ec_polling_get_real_ecdt(void); | ||
161 | static int __init | ||
162 | acpi_ec_burst_get_real_ecdt(void); | ||
163 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ | 145 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ |
164 | static union acpi_ec *ec_ecdt; | 146 | static union acpi_ec *ec_ecdt; |
165 | 147 | ||
166 | /* External interfaces use first EC only, so remember */ | 148 | /* External interfaces use first EC only, so remember */ |
167 | static struct acpi_device *first_ec; | 149 | static struct acpi_device *first_ec; |
@@ -173,30 +155,24 @@ static int acpi_ec_polling_mode = EC_POLLING; | |||
173 | 155 | ||
174 | static inline u32 acpi_ec_read_status(union acpi_ec *ec) | 156 | static inline u32 acpi_ec_read_status(union acpi_ec *ec) |
175 | { | 157 | { |
176 | u32 status = 0; | 158 | u32 status = 0; |
177 | 159 | ||
178 | acpi_hw_low_level_read(8, &status, &ec->common.status_addr); | 160 | acpi_hw_low_level_read(8, &status, &ec->common.status_addr); |
179 | return status; | 161 | return status; |
180 | } | 162 | } |
181 | 163 | ||
182 | static int | 164 | static int acpi_ec_wait(union acpi_ec *ec, u8 event) |
183 | acpi_ec_wait ( | ||
184 | union acpi_ec *ec, | ||
185 | u8 event) | ||
186 | { | 165 | { |
187 | if (acpi_ec_polling_mode) | 166 | if (acpi_ec_polling_mode) |
188 | return acpi_ec_polling_wait (ec, event); | 167 | return acpi_ec_polling_wait(ec, event); |
189 | else | 168 | else |
190 | return acpi_ec_burst_wait (ec, event); | 169 | return acpi_ec_burst_wait(ec, event); |
191 | } | 170 | } |
192 | 171 | ||
193 | static int | 172 | static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event) |
194 | acpi_ec_polling_wait ( | ||
195 | union acpi_ec *ec, | ||
196 | u8 event) | ||
197 | { | 173 | { |
198 | u32 acpi_ec_status = 0; | 174 | u32 acpi_ec_status = 0; |
199 | u32 i = ACPI_EC_UDELAY_COUNT; | 175 | u32 i = ACPI_EC_UDELAY_COUNT; |
200 | 176 | ||
201 | if (!ec) | 177 | if (!ec) |
202 | return -EINVAL; | 178 | return -EINVAL; |
@@ -205,19 +181,21 @@ acpi_ec_polling_wait ( | |||
205 | switch (event) { | 181 | switch (event) { |
206 | case ACPI_EC_EVENT_OBF: | 182 | case ACPI_EC_EVENT_OBF: |
207 | do { | 183 | do { |
208 | acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr); | 184 | acpi_hw_low_level_read(8, &acpi_ec_status, |
185 | &ec->common.status_addr); | ||
209 | if (acpi_ec_status & ACPI_EC_FLAG_OBF) | 186 | if (acpi_ec_status & ACPI_EC_FLAG_OBF) |
210 | return 0; | 187 | return 0; |
211 | udelay(ACPI_EC_UDELAY); | 188 | udelay(ACPI_EC_UDELAY); |
212 | } while (--i>0); | 189 | } while (--i > 0); |
213 | break; | 190 | break; |
214 | case ACPI_EC_EVENT_IBE: | 191 | case ACPI_EC_EVENT_IBE: |
215 | do { | 192 | do { |
216 | acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr); | 193 | acpi_hw_low_level_read(8, &acpi_ec_status, |
194 | &ec->common.status_addr); | ||
217 | if (!(acpi_ec_status & ACPI_EC_FLAG_IBF)) | 195 | if (!(acpi_ec_status & ACPI_EC_FLAG_IBF)) |
218 | return 0; | 196 | return 0; |
219 | udelay(ACPI_EC_UDELAY); | 197 | udelay(ACPI_EC_UDELAY); |
220 | } while (--i>0); | 198 | } while (--i > 0); |
221 | break; | 199 | break; |
222 | default: | 200 | default: |
223 | return -EINVAL; | 201 | return -EINVAL; |
@@ -227,7 +205,7 @@ acpi_ec_polling_wait ( | |||
227 | } | 205 | } |
228 | static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) | 206 | static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) |
229 | { | 207 | { |
230 | int result = 0; | 208 | int result = 0; |
231 | 209 | ||
232 | ACPI_FUNCTION_TRACE("acpi_ec_wait"); | 210 | ACPI_FUNCTION_TRACE("acpi_ec_wait"); |
233 | 211 | ||
@@ -251,9 +229,9 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) | |||
251 | } | 229 | } |
252 | 230 | ||
253 | result = wait_event_timeout(ec->burst.wait, | 231 | result = wait_event_timeout(ec->burst.wait, |
254 | !ec->burst.expect_event, | 232 | !ec->burst.expect_event, |
255 | msecs_to_jiffies(ACPI_EC_DELAY)); | 233 | msecs_to_jiffies(ACPI_EC_DELAY)); |
256 | 234 | ||
257 | ec->burst.expect_event = 0; | 235 | ec->burst.expect_event = 0; |
258 | smp_mb(); | 236 | smp_mb(); |
259 | 237 | ||
@@ -277,43 +255,37 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) | |||
277 | return_VALUE(-ETIME); | 255 | return_VALUE(-ETIME); |
278 | } | 256 | } |
279 | 257 | ||
280 | 258 | static int acpi_ec_enter_burst_mode(union acpi_ec *ec) | |
281 | |||
282 | static int | ||
283 | acpi_ec_enter_burst_mode ( | ||
284 | union acpi_ec *ec) | ||
285 | { | 259 | { |
286 | u32 tmp = 0; | 260 | u32 tmp = 0; |
287 | int status = 0; | 261 | int status = 0; |
288 | 262 | ||
289 | ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode"); | 263 | ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode"); |
290 | 264 | ||
291 | status = acpi_ec_read_status(ec); | 265 | status = acpi_ec_read_status(ec); |
292 | if (status != -EINVAL && | 266 | if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { |
293 | !(status & ACPI_EC_FLAG_BURST)){ | ||
294 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 267 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
295 | if(status) | 268 | if (status) |
296 | goto end; | 269 | goto end; |
297 | acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr); | 270 | acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, |
271 | &ec->common.command_addr); | ||
298 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); | 272 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); |
299 | if (status) | 273 | if (status) |
300 | return_VALUE(-EINVAL); | 274 | return_VALUE(-EINVAL); |
301 | acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); | 275 | acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); |
302 | if(tmp != 0x90 ) {/* Burst ACK byte*/ | 276 | if (tmp != 0x90) { /* Burst ACK byte */ |
303 | return_VALUE(-EINVAL); | 277 | return_VALUE(-EINVAL); |
304 | } | 278 | } |
305 | } | 279 | } |
306 | 280 | ||
307 | atomic_set(&ec->burst.leaving_burst , 0); | 281 | atomic_set(&ec->burst.leaving_burst, 0); |
308 | return_VALUE(0); | 282 | return_VALUE(0); |
309 | end: | 283 | end: |
310 | printk("Error in acpi_ec_wait\n"); | 284 | printk("Error in acpi_ec_wait\n"); |
311 | return_VALUE(-1); | 285 | return_VALUE(-1); |
312 | } | 286 | } |
313 | 287 | ||
314 | static int | 288 | static int acpi_ec_leave_burst_mode(union acpi_ec *ec) |
315 | acpi_ec_leave_burst_mode ( | ||
316 | union acpi_ec *ec) | ||
317 | { | 289 | { |
318 | 290 | ||
319 | ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); | 291 | ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); |
@@ -322,38 +294,26 @@ acpi_ec_leave_burst_mode ( | |||
322 | return_VALUE(0); | 294 | return_VALUE(0); |
323 | } | 295 | } |
324 | 296 | ||
325 | static int | 297 | static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data) |
326 | acpi_ec_read ( | ||
327 | union acpi_ec *ec, | ||
328 | u8 address, | ||
329 | u32 *data) | ||
330 | { | 298 | { |
331 | if (acpi_ec_polling_mode) | 299 | if (acpi_ec_polling_mode) |
332 | return acpi_ec_polling_read(ec, address, data); | 300 | return acpi_ec_polling_read(ec, address, data); |
333 | else | 301 | else |
334 | return acpi_ec_burst_read(ec, address, data); | 302 | return acpi_ec_burst_read(ec, address, data); |
335 | } | 303 | } |
336 | static int | 304 | static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data) |
337 | acpi_ec_write ( | ||
338 | union acpi_ec *ec, | ||
339 | u8 address, | ||
340 | u8 data) | ||
341 | { | 305 | { |
342 | if (acpi_ec_polling_mode) | 306 | if (acpi_ec_polling_mode) |
343 | return acpi_ec_polling_write(ec, address, data); | 307 | return acpi_ec_polling_write(ec, address, data); |
344 | else | 308 | else |
345 | return acpi_ec_burst_write(ec, address, data); | 309 | return acpi_ec_burst_write(ec, address, data); |
346 | } | 310 | } |
347 | static int | 311 | static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data) |
348 | acpi_ec_polling_read ( | ||
349 | union acpi_ec *ec, | ||
350 | u8 address, | ||
351 | u32 *data) | ||
352 | { | 312 | { |
353 | acpi_status status = AE_OK; | 313 | acpi_status status = AE_OK; |
354 | int result = 0; | 314 | int result = 0; |
355 | unsigned long flags = 0; | 315 | unsigned long flags = 0; |
356 | u32 glk = 0; | 316 | u32 glk = 0; |
357 | 317 | ||
358 | ACPI_FUNCTION_TRACE("acpi_ec_read"); | 318 | ACPI_FUNCTION_TRACE("acpi_ec_read"); |
359 | 319 | ||
@@ -370,7 +330,8 @@ acpi_ec_polling_read ( | |||
370 | 330 | ||
371 | spin_lock_irqsave(&ec->polling.lock, flags); | 331 | spin_lock_irqsave(&ec->polling.lock, flags); |
372 | 332 | ||
373 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr); | 333 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, |
334 | &ec->common.command_addr); | ||
374 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 335 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
375 | if (result) | 336 | if (result) |
376 | goto end; | 337 | goto end; |
@@ -383,9 +344,9 @@ acpi_ec_polling_read ( | |||
383 | acpi_hw_low_level_read(8, data, &ec->common.data_addr); | 344 | acpi_hw_low_level_read(8, data, &ec->common.data_addr); |
384 | 345 | ||
385 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", | 346 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", |
386 | *data, address)); | 347 | *data, address)); |
387 | 348 | ||
388 | end: | 349 | end: |
389 | spin_unlock_irqrestore(&ec->polling.lock, flags); | 350 | spin_unlock_irqrestore(&ec->polling.lock, flags); |
390 | 351 | ||
391 | if (ec->common.global_lock) | 352 | if (ec->common.global_lock) |
@@ -394,17 +355,12 @@ end: | |||
394 | return_VALUE(result); | 355 | return_VALUE(result); |
395 | } | 356 | } |
396 | 357 | ||
397 | 358 | static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data) | |
398 | static int | ||
399 | acpi_ec_polling_write ( | ||
400 | union acpi_ec *ec, | ||
401 | u8 address, | ||
402 | u8 data) | ||
403 | { | 359 | { |
404 | int result = 0; | 360 | int result = 0; |
405 | acpi_status status = AE_OK; | 361 | acpi_status status = AE_OK; |
406 | unsigned long flags = 0; | 362 | unsigned long flags = 0; |
407 | u32 glk = 0; | 363 | u32 glk = 0; |
408 | 364 | ||
409 | ACPI_FUNCTION_TRACE("acpi_ec_write"); | 365 | ACPI_FUNCTION_TRACE("acpi_ec_write"); |
410 | 366 | ||
@@ -419,7 +375,8 @@ acpi_ec_polling_write ( | |||
419 | 375 | ||
420 | spin_lock_irqsave(&ec->polling.lock, flags); | 376 | spin_lock_irqsave(&ec->polling.lock, flags); |
421 | 377 | ||
422 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr); | 378 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, |
379 | &ec->common.command_addr); | ||
423 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 380 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
424 | if (result) | 381 | if (result) |
425 | goto end; | 382 | goto end; |
@@ -435,9 +392,9 @@ acpi_ec_polling_write ( | |||
435 | goto end; | 392 | goto end; |
436 | 393 | ||
437 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", | 394 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", |
438 | data, address)); | 395 | data, address)); |
439 | 396 | ||
440 | end: | 397 | end: |
441 | spin_unlock_irqrestore(&ec->polling.lock, flags); | 398 | spin_unlock_irqrestore(&ec->polling.lock, flags); |
442 | 399 | ||
443 | if (ec->common.global_lock) | 400 | if (ec->common.global_lock) |
@@ -446,14 +403,10 @@ end: | |||
446 | return_VALUE(result); | 403 | return_VALUE(result); |
447 | } | 404 | } |
448 | 405 | ||
449 | static int | 406 | static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data) |
450 | acpi_ec_burst_read ( | ||
451 | union acpi_ec *ec, | ||
452 | u8 address, | ||
453 | u32 *data) | ||
454 | { | 407 | { |
455 | int status = 0; | 408 | int status = 0; |
456 | u32 glk; | 409 | u32 glk; |
457 | 410 | ||
458 | ACPI_FUNCTION_TRACE("acpi_ec_read"); | 411 | ACPI_FUNCTION_TRACE("acpi_ec_read"); |
459 | 412 | ||
@@ -477,23 +430,24 @@ acpi_ec_burst_read ( | |||
477 | printk("read EC, IB not empty\n"); | 430 | printk("read EC, IB not empty\n"); |
478 | goto end; | 431 | goto end; |
479 | } | 432 | } |
480 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr); | 433 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, |
434 | &ec->common.command_addr); | ||
481 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 435 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
482 | if (status) { | 436 | if (status) { |
483 | printk("read EC, IB not empty\n"); | 437 | printk("read EC, IB not empty\n"); |
484 | } | 438 | } |
485 | 439 | ||
486 | acpi_hw_low_level_write(8, address, &ec->common.data_addr); | 440 | acpi_hw_low_level_write(8, address, &ec->common.data_addr); |
487 | status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); | 441 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); |
488 | if (status){ | 442 | if (status) { |
489 | printk("read EC, OB not full\n"); | 443 | printk("read EC, OB not full\n"); |
490 | goto end; | 444 | goto end; |
491 | } | 445 | } |
492 | acpi_hw_low_level_read(8, data, &ec->common.data_addr); | 446 | acpi_hw_low_level_read(8, data, &ec->common.data_addr); |
493 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", | 447 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", |
494 | *data, address)); | 448 | *data, address)); |
495 | 449 | ||
496 | end: | 450 | end: |
497 | acpi_ec_leave_burst_mode(ec); | 451 | acpi_ec_leave_burst_mode(ec); |
498 | up(&ec->burst.sem); | 452 | up(&ec->burst.sem); |
499 | 453 | ||
@@ -503,15 +457,10 @@ end: | |||
503 | return_VALUE(status); | 457 | return_VALUE(status); |
504 | } | 458 | } |
505 | 459 | ||
506 | 460 | static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data) | |
507 | static int | ||
508 | acpi_ec_burst_write ( | ||
509 | union acpi_ec *ec, | ||
510 | u8 address, | ||
511 | u8 data) | ||
512 | { | 461 | { |
513 | int status = 0; | 462 | int status = 0; |
514 | u32 glk; | 463 | u32 glk; |
515 | 464 | ||
516 | ACPI_FUNCTION_TRACE("acpi_ec_write"); | 465 | ACPI_FUNCTION_TRACE("acpi_ec_write"); |
517 | 466 | ||
@@ -530,25 +479,26 @@ acpi_ec_burst_write ( | |||
530 | acpi_ec_enter_burst_mode(ec); | 479 | acpi_ec_enter_burst_mode(ec); |
531 | 480 | ||
532 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 481 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
533 | if ( status) { | 482 | if (status) { |
534 | printk("write EC, IB not empty\n"); | 483 | printk("write EC, IB not empty\n"); |
535 | } | 484 | } |
536 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr); | 485 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, |
486 | &ec->common.command_addr); | ||
537 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 487 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
538 | if (status) { | 488 | if (status) { |
539 | printk ("write EC, IB not empty\n"); | 489 | printk("write EC, IB not empty\n"); |
540 | } | 490 | } |
541 | 491 | ||
542 | acpi_hw_low_level_write(8, address, &ec->common.data_addr); | 492 | acpi_hw_low_level_write(8, address, &ec->common.data_addr); |
543 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 493 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
544 | if (status){ | 494 | if (status) { |
545 | printk("write EC, IB not empty\n"); | 495 | printk("write EC, IB not empty\n"); |
546 | } | 496 | } |
547 | 497 | ||
548 | acpi_hw_low_level_write(8, data, &ec->common.data_addr); | 498 | acpi_hw_low_level_write(8, data, &ec->common.data_addr); |
549 | 499 | ||
550 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", | 500 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", |
551 | data, address)); | 501 | data, address)); |
552 | 502 | ||
553 | acpi_ec_leave_burst_mode(ec); | 503 | acpi_ec_leave_burst_mode(ec); |
554 | up(&ec->burst.sem); | 504 | up(&ec->burst.sem); |
@@ -562,8 +512,7 @@ acpi_ec_burst_write ( | |||
562 | /* | 512 | /* |
563 | * Externally callable EC access functions. For now, assume 1 EC only | 513 | * Externally callable EC access functions. For now, assume 1 EC only |
564 | */ | 514 | */ |
565 | int | 515 | int ec_read(u8 addr, u8 * val) |
566 | ec_read(u8 addr, u8 *val) | ||
567 | { | 516 | { |
568 | union acpi_ec *ec; | 517 | union acpi_ec *ec; |
569 | int err; | 518 | int err; |
@@ -579,14 +528,13 @@ ec_read(u8 addr, u8 *val) | |||
579 | if (!err) { | 528 | if (!err) { |
580 | *val = temp_data; | 529 | *val = temp_data; |
581 | return 0; | 530 | return 0; |
582 | } | 531 | } else |
583 | else | ||
584 | return err; | 532 | return err; |
585 | } | 533 | } |
534 | |||
586 | EXPORT_SYMBOL(ec_read); | 535 | EXPORT_SYMBOL(ec_read); |
587 | 536 | ||
588 | int | 537 | int ec_write(u8 addr, u8 val) |
589 | ec_write(u8 addr, u8 val) | ||
590 | { | 538 | { |
591 | union acpi_ec *ec; | 539 | union acpi_ec *ec; |
592 | int err; | 540 | int err; |
@@ -600,27 +548,22 @@ ec_write(u8 addr, u8 val) | |||
600 | 548 | ||
601 | return err; | 549 | return err; |
602 | } | 550 | } |
551 | |||
603 | EXPORT_SYMBOL(ec_write); | 552 | EXPORT_SYMBOL(ec_write); |
604 | 553 | ||
605 | static int | 554 | static int acpi_ec_query(union acpi_ec *ec, u32 * data) |
606 | acpi_ec_query ( | ||
607 | union acpi_ec *ec, | ||
608 | u32 *data) | ||
609 | { | 555 | { |
610 | if (acpi_ec_polling_mode) | 556 | if (acpi_ec_polling_mode) |
611 | return acpi_ec_polling_query(ec, data); | 557 | return acpi_ec_polling_query(ec, data); |
612 | else | 558 | else |
613 | return acpi_ec_burst_query(ec, data); | 559 | return acpi_ec_burst_query(ec, data); |
614 | } | 560 | } |
615 | static int | 561 | static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data) |
616 | acpi_ec_polling_query ( | ||
617 | union acpi_ec *ec, | ||
618 | u32 *data) | ||
619 | { | 562 | { |
620 | int result = 0; | 563 | int result = 0; |
621 | acpi_status status = AE_OK; | 564 | acpi_status status = AE_OK; |
622 | unsigned long flags = 0; | 565 | unsigned long flags = 0; |
623 | u32 glk = 0; | 566 | u32 glk = 0; |
624 | 567 | ||
625 | ACPI_FUNCTION_TRACE("acpi_ec_query"); | 568 | ACPI_FUNCTION_TRACE("acpi_ec_query"); |
626 | 569 | ||
@@ -642,7 +585,8 @@ acpi_ec_polling_query ( | |||
642 | */ | 585 | */ |
643 | spin_lock_irqsave(&ec->polling.lock, flags); | 586 | spin_lock_irqsave(&ec->polling.lock, flags); |
644 | 587 | ||
645 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr); | 588 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, |
589 | &ec->common.command_addr); | ||
646 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); | 590 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); |
647 | if (result) | 591 | if (result) |
648 | goto end; | 592 | goto end; |
@@ -651,7 +595,7 @@ acpi_ec_polling_query ( | |||
651 | if (!*data) | 595 | if (!*data) |
652 | result = -ENODATA; | 596 | result = -ENODATA; |
653 | 597 | ||
654 | end: | 598 | end: |
655 | spin_unlock_irqrestore(&ec->polling.lock, flags); | 599 | spin_unlock_irqrestore(&ec->polling.lock, flags); |
656 | 600 | ||
657 | if (ec->common.global_lock) | 601 | if (ec->common.global_lock) |
@@ -659,13 +603,10 @@ end: | |||
659 | 603 | ||
660 | return_VALUE(result); | 604 | return_VALUE(result); |
661 | } | 605 | } |
662 | static int | 606 | static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data) |
663 | acpi_ec_burst_query ( | ||
664 | union acpi_ec *ec, | ||
665 | u32 *data) | ||
666 | { | 607 | { |
667 | int status = 0; | 608 | int status = 0; |
668 | u32 glk; | 609 | u32 glk; |
669 | 610 | ||
670 | ACPI_FUNCTION_TRACE("acpi_ec_query"); | 611 | ACPI_FUNCTION_TRACE("acpi_ec_query"); |
671 | 612 | ||
@@ -691,9 +632,10 @@ acpi_ec_burst_query ( | |||
691 | * Note that successful completion of the query causes the ACPI_EC_SCI | 632 | * Note that successful completion of the query causes the ACPI_EC_SCI |
692 | * bit to be cleared (and thus clearing the interrupt source). | 633 | * bit to be cleared (and thus clearing the interrupt source). |
693 | */ | 634 | */ |
694 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr); | 635 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, |
636 | &ec->common.command_addr); | ||
695 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); | 637 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); |
696 | if (status){ | 638 | if (status) { |
697 | printk("query EC, OB not full\n"); | 639 | printk("query EC, OB not full\n"); |
698 | goto end; | 640 | goto end; |
699 | } | 641 | } |
@@ -702,7 +644,7 @@ acpi_ec_burst_query ( | |||
702 | if (!*data) | 644 | if (!*data) |
703 | status = -ENODATA; | 645 | status = -ENODATA; |
704 | 646 | ||
705 | end: | 647 | end: |
706 | up(&ec->burst.sem); | 648 | up(&ec->burst.sem); |
707 | 649 | ||
708 | if (ec->common.global_lock) | 650 | if (ec->common.global_lock) |
@@ -711,36 +653,32 @@ end: | |||
711 | return_VALUE(status); | 653 | return_VALUE(status); |
712 | } | 654 | } |
713 | 655 | ||
714 | |||
715 | /* -------------------------------------------------------------------------- | 656 | /* -------------------------------------------------------------------------- |
716 | Event Management | 657 | Event Management |
717 | -------------------------------------------------------------------------- */ | 658 | -------------------------------------------------------------------------- */ |
718 | 659 | ||
719 | union acpi_ec_query_data { | 660 | union acpi_ec_query_data { |
720 | acpi_handle handle; | 661 | acpi_handle handle; |
721 | u8 data; | 662 | u8 data; |
722 | }; | 663 | }; |
723 | 664 | ||
724 | static void | 665 | static void acpi_ec_gpe_query(void *ec_cxt) |
725 | acpi_ec_gpe_query ( | ||
726 | void *ec_cxt) | ||
727 | { | 666 | { |
728 | if (acpi_ec_polling_mode) | 667 | if (acpi_ec_polling_mode) |
729 | acpi_ec_gpe_polling_query(ec_cxt); | 668 | acpi_ec_gpe_polling_query(ec_cxt); |
730 | else | 669 | else |
731 | acpi_ec_gpe_burst_query(ec_cxt); | 670 | acpi_ec_gpe_burst_query(ec_cxt); |
732 | } | 671 | } |
733 | 672 | ||
734 | static void | 673 | static void acpi_ec_gpe_polling_query(void *ec_cxt) |
735 | acpi_ec_gpe_polling_query ( | ||
736 | void *ec_cxt) | ||
737 | { | 674 | { |
738 | union acpi_ec *ec = (union acpi_ec *) ec_cxt; | 675 | union acpi_ec *ec = (union acpi_ec *)ec_cxt; |
739 | u32 value = 0; | 676 | u32 value = 0; |
740 | unsigned long flags = 0; | 677 | unsigned long flags = 0; |
741 | static char object_name[5] = {'_','Q','0','0','\0'}; | 678 | static char object_name[5] = { '_', 'Q', '0', '0', '\0' }; |
742 | const char hex[] = {'0','1','2','3','4','5','6','7', | 679 | const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', |
743 | '8','9','A','B','C','D','E','F'}; | 680 | '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' |
681 | }; | ||
744 | 682 | ||
745 | ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); | 683 | ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); |
746 | 684 | ||
@@ -770,19 +708,18 @@ acpi_ec_gpe_polling_query ( | |||
770 | 708 | ||
771 | acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); | 709 | acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); |
772 | 710 | ||
773 | end: | 711 | end: |
774 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 712 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); |
775 | } | 713 | } |
776 | static void | 714 | static void acpi_ec_gpe_burst_query(void *ec_cxt) |
777 | acpi_ec_gpe_burst_query ( | ||
778 | void *ec_cxt) | ||
779 | { | 715 | { |
780 | union acpi_ec *ec = (union acpi_ec *) ec_cxt; | 716 | union acpi_ec *ec = (union acpi_ec *)ec_cxt; |
781 | u32 value; | 717 | u32 value; |
782 | int result = -ENODATA; | 718 | int result = -ENODATA; |
783 | static char object_name[5] = {'_','Q','0','0','\0'}; | 719 | static char object_name[5] = { '_', 'Q', '0', '0', '\0' }; |
784 | const char hex[] = {'0','1','2','3','4','5','6','7', | 720 | const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', |
785 | '8','9','A','B','C','D','E','F'}; | 721 | '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' |
722 | }; | ||
786 | 723 | ||
787 | ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); | 724 | ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); |
788 | 725 | ||
@@ -798,26 +735,22 @@ acpi_ec_gpe_burst_query ( | |||
798 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); | 735 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); |
799 | 736 | ||
800 | acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); | 737 | acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); |
801 | end: | 738 | end: |
802 | atomic_dec(&ec->burst.pending_gpe); | 739 | atomic_dec(&ec->burst.pending_gpe); |
803 | return; | 740 | return; |
804 | } | 741 | } |
805 | 742 | ||
806 | static u32 | 743 | static u32 acpi_ec_gpe_handler(void *data) |
807 | acpi_ec_gpe_handler ( | ||
808 | void *data) | ||
809 | { | 744 | { |
810 | if (acpi_ec_polling_mode) | 745 | if (acpi_ec_polling_mode) |
811 | return acpi_ec_gpe_polling_handler(data); | 746 | return acpi_ec_gpe_polling_handler(data); |
812 | else | 747 | else |
813 | return acpi_ec_gpe_burst_handler(data); | 748 | return acpi_ec_gpe_burst_handler(data); |
814 | } | 749 | } |
815 | static u32 | 750 | static u32 acpi_ec_gpe_polling_handler(void *data) |
816 | acpi_ec_gpe_polling_handler ( | ||
817 | void *data) | ||
818 | { | 751 | { |
819 | acpi_status status = AE_OK; | 752 | acpi_status status = AE_OK; |
820 | union acpi_ec *ec = (union acpi_ec *) data; | 753 | union acpi_ec *ec = (union acpi_ec *)data; |
821 | 754 | ||
822 | if (!ec) | 755 | if (!ec) |
823 | return ACPI_INTERRUPT_NOT_HANDLED; | 756 | return ACPI_INTERRUPT_NOT_HANDLED; |
@@ -825,20 +758,18 @@ acpi_ec_gpe_polling_handler ( | |||
825 | acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); | 758 | acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); |
826 | 759 | ||
827 | status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, | 760 | status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, |
828 | acpi_ec_gpe_query, ec); | 761 | acpi_ec_gpe_query, ec); |
829 | 762 | ||
830 | if (status == AE_OK) | 763 | if (status == AE_OK) |
831 | return ACPI_INTERRUPT_HANDLED; | 764 | return ACPI_INTERRUPT_HANDLED; |
832 | else | 765 | else |
833 | return ACPI_INTERRUPT_NOT_HANDLED; | 766 | return ACPI_INTERRUPT_NOT_HANDLED; |
834 | } | 767 | } |
835 | static u32 | 768 | static u32 acpi_ec_gpe_burst_handler(void *data) |
836 | acpi_ec_gpe_burst_handler ( | ||
837 | void *data) | ||
838 | { | 769 | { |
839 | acpi_status status = AE_OK; | 770 | acpi_status status = AE_OK; |
840 | u32 value; | 771 | u32 value; |
841 | union acpi_ec *ec = (union acpi_ec *) data; | 772 | union acpi_ec *ec = (union acpi_ec *)data; |
842 | 773 | ||
843 | if (!ec) | 774 | if (!ec) |
844 | return ACPI_INTERRUPT_NOT_HANDLED; | 775 | return ACPI_INTERRUPT_NOT_HANDLED; |
@@ -846,7 +777,7 @@ acpi_ec_gpe_burst_handler ( | |||
846 | acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); | 777 | acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); |
847 | value = acpi_ec_read_status(ec); | 778 | value = acpi_ec_read_status(ec); |
848 | 779 | ||
849 | switch ( ec->burst.expect_event) { | 780 | switch (ec->burst.expect_event) { |
850 | case ACPI_EC_EVENT_OBF: | 781 | case ACPI_EC_EVENT_OBF: |
851 | if (!(value & ACPI_EC_FLAG_OBF)) | 782 | if (!(value & ACPI_EC_FLAG_OBF)) |
852 | break; | 783 | break; |
@@ -860,16 +791,16 @@ acpi_ec_gpe_burst_handler ( | |||
860 | break; | 791 | break; |
861 | } | 792 | } |
862 | 793 | ||
863 | if (value & ACPI_EC_FLAG_SCI){ | 794 | if (value & ACPI_EC_FLAG_SCI) { |
864 | atomic_add(1, &ec->burst.pending_gpe) ; | 795 | atomic_add(1, &ec->burst.pending_gpe); |
865 | status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, | 796 | status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, |
866 | acpi_ec_gpe_query, ec); | 797 | acpi_ec_gpe_query, ec); |
867 | return status == AE_OK ? | 798 | return status == AE_OK ? |
868 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; | 799 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; |
869 | } | 800 | } |
870 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); | 801 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); |
871 | return status == AE_OK ? | 802 | return status == AE_OK ? |
872 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; | 803 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; |
873 | } | 804 | } |
874 | 805 | ||
875 | /* -------------------------------------------------------------------------- | 806 | /* -------------------------------------------------------------------------- |
@@ -877,37 +808,31 @@ acpi_ec_gpe_burst_handler ( | |||
877 | -------------------------------------------------------------------------- */ | 808 | -------------------------------------------------------------------------- */ |
878 | 809 | ||
879 | static acpi_status | 810 | static acpi_status |
880 | acpi_ec_space_setup ( | 811 | acpi_ec_space_setup(acpi_handle region_handle, |
881 | acpi_handle region_handle, | 812 | u32 function, void *handler_context, void **return_context) |
882 | u32 function, | ||
883 | void *handler_context, | ||
884 | void **return_context) | ||
885 | { | 813 | { |
886 | /* | 814 | /* |
887 | * The EC object is in the handler context and is needed | 815 | * The EC object is in the handler context and is needed |
888 | * when calling the acpi_ec_space_handler. | 816 | * when calling the acpi_ec_space_handler. |
889 | */ | 817 | */ |
890 | *return_context = (function != ACPI_REGION_DEACTIVATE) ? | 818 | *return_context = (function != ACPI_REGION_DEACTIVATE) ? |
891 | handler_context : NULL; | 819 | handler_context : NULL; |
892 | 820 | ||
893 | return AE_OK; | 821 | return AE_OK; |
894 | } | 822 | } |
895 | 823 | ||
896 | |||
897 | static acpi_status | 824 | static acpi_status |
898 | acpi_ec_space_handler ( | 825 | acpi_ec_space_handler(u32 function, |
899 | u32 function, | 826 | acpi_physical_address address, |
900 | acpi_physical_address address, | 827 | u32 bit_width, |
901 | u32 bit_width, | 828 | acpi_integer * value, |
902 | acpi_integer *value, | 829 | void *handler_context, void *region_context) |
903 | void *handler_context, | ||
904 | void *region_context) | ||
905 | { | 830 | { |
906 | int result = 0; | 831 | int result = 0; |
907 | union acpi_ec *ec = NULL; | 832 | union acpi_ec *ec = NULL; |
908 | u64 temp = *value; | 833 | u64 temp = *value; |
909 | acpi_integer f_v = 0; | 834 | acpi_integer f_v = 0; |
910 | int i = 0; | 835 | int i = 0; |
911 | 836 | ||
912 | ACPI_FUNCTION_TRACE("acpi_ec_space_handler"); | 837 | ACPI_FUNCTION_TRACE("acpi_ec_space_handler"); |
913 | 838 | ||
@@ -915,17 +840,18 @@ acpi_ec_space_handler ( | |||
915 | return_VALUE(AE_BAD_PARAMETER); | 840 | return_VALUE(AE_BAD_PARAMETER); |
916 | 841 | ||
917 | if (bit_width != 8 && acpi_strict) { | 842 | if (bit_width != 8 && acpi_strict) { |
918 | printk(KERN_WARNING PREFIX "acpi_ec_space_handler: bit_width should be 8\n"); | 843 | printk(KERN_WARNING PREFIX |
844 | "acpi_ec_space_handler: bit_width should be 8\n"); | ||
919 | return_VALUE(AE_BAD_PARAMETER); | 845 | return_VALUE(AE_BAD_PARAMETER); |
920 | } | 846 | } |
921 | 847 | ||
922 | ec = (union acpi_ec *) handler_context; | 848 | ec = (union acpi_ec *)handler_context; |
923 | 849 | ||
924 | next_byte: | 850 | next_byte: |
925 | switch (function) { | 851 | switch (function) { |
926 | case ACPI_READ: | 852 | case ACPI_READ: |
927 | temp = 0; | 853 | temp = 0; |
928 | result = acpi_ec_read(ec, (u8) address, (u32 *)&temp); | 854 | result = acpi_ec_read(ec, (u8) address, (u32 *) & temp); |
929 | break; | 855 | break; |
930 | case ACPI_WRITE: | 856 | case ACPI_WRITE: |
931 | result = acpi_ec_write(ec, (u8) address, (u8) temp); | 857 | result = acpi_ec_write(ec, (u8) address, (u8) temp); |
@@ -952,8 +878,7 @@ next_byte: | |||
952 | *value = f_v; | 878 | *value = f_v; |
953 | } | 879 | } |
954 | 880 | ||
955 | 881 | out: | |
956 | out: | ||
957 | switch (result) { | 882 | switch (result) { |
958 | case -EINVAL: | 883 | case -EINVAL: |
959 | return_VALUE(AE_BAD_PARAMETER); | 884 | return_VALUE(AE_BAD_PARAMETER); |
@@ -969,18 +894,15 @@ out: | |||
969 | } | 894 | } |
970 | } | 895 | } |
971 | 896 | ||
972 | |||
973 | /* -------------------------------------------------------------------------- | 897 | /* -------------------------------------------------------------------------- |
974 | FS Interface (/proc) | 898 | FS Interface (/proc) |
975 | -------------------------------------------------------------------------- */ | 899 | -------------------------------------------------------------------------- */ |
976 | 900 | ||
977 | static struct proc_dir_entry *acpi_ec_dir; | 901 | static struct proc_dir_entry *acpi_ec_dir; |
978 | 902 | ||
979 | 903 | static int acpi_ec_read_info(struct seq_file *seq, void *offset) | |
980 | static int | ||
981 | acpi_ec_read_info (struct seq_file *seq, void *offset) | ||
982 | { | 904 | { |
983 | union acpi_ec *ec = (union acpi_ec *) seq->private; | 905 | union acpi_ec *ec = (union acpi_ec *)seq->private; |
984 | 906 | ||
985 | ACPI_FUNCTION_TRACE("acpi_ec_read_info"); | 907 | ACPI_FUNCTION_TRACE("acpi_ec_read_info"); |
986 | 908 | ||
@@ -988,14 +910,15 @@ acpi_ec_read_info (struct seq_file *seq, void *offset) | |||
988 | goto end; | 910 | goto end; |
989 | 911 | ||
990 | seq_printf(seq, "gpe bit: 0x%02x\n", | 912 | seq_printf(seq, "gpe bit: 0x%02x\n", |
991 | (u32) ec->common.gpe_bit); | 913 | (u32) ec->common.gpe_bit); |
992 | seq_printf(seq, "ports: 0x%02x, 0x%02x\n", | 914 | seq_printf(seq, "ports: 0x%02x, 0x%02x\n", |
993 | (u32) ec->common.status_addr.address, (u32) ec->common.data_addr.address); | 915 | (u32) ec->common.status_addr.address, |
916 | (u32) ec->common.data_addr.address); | ||
994 | seq_printf(seq, "use global lock: %s\n", | 917 | seq_printf(seq, "use global lock: %s\n", |
995 | ec->common.global_lock?"yes":"no"); | 918 | ec->common.global_lock ? "yes" : "no"); |
996 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 919 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); |
997 | 920 | ||
998 | end: | 921 | end: |
999 | return_VALUE(0); | 922 | return_VALUE(0); |
1000 | } | 923 | } |
1001 | 924 | ||
@@ -1005,34 +928,32 @@ static int acpi_ec_info_open_fs(struct inode *inode, struct file *file) | |||
1005 | } | 928 | } |
1006 | 929 | ||
1007 | static struct file_operations acpi_ec_info_ops = { | 930 | static struct file_operations acpi_ec_info_ops = { |
1008 | .open = acpi_ec_info_open_fs, | 931 | .open = acpi_ec_info_open_fs, |
1009 | .read = seq_read, | 932 | .read = seq_read, |
1010 | .llseek = seq_lseek, | 933 | .llseek = seq_lseek, |
1011 | .release = single_release, | 934 | .release = single_release, |
1012 | .owner = THIS_MODULE, | 935 | .owner = THIS_MODULE, |
1013 | }; | 936 | }; |
1014 | 937 | ||
1015 | static int | 938 | static int acpi_ec_add_fs(struct acpi_device *device) |
1016 | acpi_ec_add_fs ( | ||
1017 | struct acpi_device *device) | ||
1018 | { | 939 | { |
1019 | struct proc_dir_entry *entry = NULL; | 940 | struct proc_dir_entry *entry = NULL; |
1020 | 941 | ||
1021 | ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); | 942 | ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); |
1022 | 943 | ||
1023 | if (!acpi_device_dir(device)) { | 944 | if (!acpi_device_dir(device)) { |
1024 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), | 945 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), |
1025 | acpi_ec_dir); | 946 | acpi_ec_dir); |
1026 | if (!acpi_device_dir(device)) | 947 | if (!acpi_device_dir(device)) |
1027 | return_VALUE(-ENODEV); | 948 | return_VALUE(-ENODEV); |
1028 | } | 949 | } |
1029 | 950 | ||
1030 | entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, | 951 | entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, |
1031 | acpi_device_dir(device)); | 952 | acpi_device_dir(device)); |
1032 | if (!entry) | 953 | if (!entry) |
1033 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, | 954 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, |
1034 | "Unable to create '%s' fs entry\n", | 955 | "Unable to create '%s' fs entry\n", |
1035 | ACPI_EC_FILE_INFO)); | 956 | ACPI_EC_FILE_INFO)); |
1036 | else { | 957 | else { |
1037 | entry->proc_fops = &acpi_ec_info_ops; | 958 | entry->proc_fops = &acpi_ec_info_ops; |
1038 | entry->data = acpi_driver_data(device); | 959 | entry->data = acpi_driver_data(device); |
@@ -1042,10 +963,7 @@ acpi_ec_add_fs ( | |||
1042 | return_VALUE(0); | 963 | return_VALUE(0); |
1043 | } | 964 | } |
1044 | 965 | ||
1045 | 966 | static int acpi_ec_remove_fs(struct acpi_device *device) | |
1046 | static int | ||
1047 | acpi_ec_remove_fs ( | ||
1048 | struct acpi_device *device) | ||
1049 | { | 967 | { |
1050 | ACPI_FUNCTION_TRACE("acpi_ec_remove_fs"); | 968 | ACPI_FUNCTION_TRACE("acpi_ec_remove_fs"); |
1051 | 969 | ||
@@ -1058,20 +976,16 @@ acpi_ec_remove_fs ( | |||
1058 | return_VALUE(0); | 976 | return_VALUE(0); |
1059 | } | 977 | } |
1060 | 978 | ||
1061 | |||
1062 | /* -------------------------------------------------------------------------- | 979 | /* -------------------------------------------------------------------------- |
1063 | Driver Interface | 980 | Driver Interface |
1064 | -------------------------------------------------------------------------- */ | 981 | -------------------------------------------------------------------------- */ |
1065 | 982 | ||
1066 | 983 | static int acpi_ec_polling_add(struct acpi_device *device) | |
1067 | static int | ||
1068 | acpi_ec_polling_add ( | ||
1069 | struct acpi_device *device) | ||
1070 | { | 984 | { |
1071 | int result = 0; | 985 | int result = 0; |
1072 | acpi_status status = AE_OK; | 986 | acpi_status status = AE_OK; |
1073 | union acpi_ec *ec = NULL; | 987 | union acpi_ec *ec = NULL; |
1074 | unsigned long uid; | 988 | unsigned long uid; |
1075 | 989 | ||
1076 | ACPI_FUNCTION_TRACE("acpi_ec_add"); | 990 | ACPI_FUNCTION_TRACE("acpi_ec_add"); |
1077 | 991 | ||
@@ -1091,26 +1005,31 @@ acpi_ec_polling_add ( | |||
1091 | acpi_driver_data(device) = ec; | 1005 | acpi_driver_data(device) = ec; |
1092 | 1006 | ||
1093 | /* Use the global lock for all EC transactions? */ | 1007 | /* Use the global lock for all EC transactions? */ |
1094 | acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock); | 1008 | acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, |
1009 | &ec->common.global_lock); | ||
1095 | 1010 | ||
1096 | /* If our UID matches the UID for the ECDT-enumerated EC, | 1011 | /* If our UID matches the UID for the ECDT-enumerated EC, |
1097 | we now have the *real* EC info, so kill the makeshift one.*/ | 1012 | we now have the *real* EC info, so kill the makeshift one. */ |
1098 | acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); | 1013 | acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); |
1099 | if (ec_ecdt && ec_ecdt->common.uid == uid) { | 1014 | if (ec_ecdt && ec_ecdt->common.uid == uid) { |
1100 | acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, | 1015 | acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, |
1101 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); | 1016 | ACPI_ADR_SPACE_EC, |
1102 | 1017 | &acpi_ec_space_handler); | |
1103 | acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler); | 1018 | |
1019 | acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, | ||
1020 | &acpi_ec_gpe_handler); | ||
1104 | 1021 | ||
1105 | kfree(ec_ecdt); | 1022 | kfree(ec_ecdt); |
1106 | } | 1023 | } |
1107 | 1024 | ||
1108 | /* Get GPE bit assignment (EC events). */ | 1025 | /* Get GPE bit assignment (EC events). */ |
1109 | /* TODO: Add support for _GPE returning a package */ | 1026 | /* TODO: Add support for _GPE returning a package */ |
1110 | status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); | 1027 | status = |
1028 | acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, | ||
1029 | &ec->common.gpe_bit); | ||
1111 | if (ACPI_FAILURE(status)) { | 1030 | if (ACPI_FAILURE(status)) { |
1112 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 1031 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
1113 | "Error obtaining GPE bit assignment\n")); | 1032 | "Error obtaining GPE bit assignment\n")); |
1114 | result = -ENODEV; | 1033 | result = -ENODEV; |
1115 | goto end; | 1034 | goto end; |
1116 | } | 1035 | } |
@@ -1120,26 +1039,24 @@ acpi_ec_polling_add ( | |||
1120 | goto end; | 1039 | goto end; |
1121 | 1040 | ||
1122 | printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", | 1041 | printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", |
1123 | acpi_device_name(device), acpi_device_bid(device), | 1042 | acpi_device_name(device), acpi_device_bid(device), |
1124 | (u32) ec->common.gpe_bit); | 1043 | (u32) ec->common.gpe_bit); |
1125 | 1044 | ||
1126 | if (!first_ec) | 1045 | if (!first_ec) |
1127 | first_ec = device; | 1046 | first_ec = device; |
1128 | 1047 | ||
1129 | end: | 1048 | end: |
1130 | if (result) | 1049 | if (result) |
1131 | kfree(ec); | 1050 | kfree(ec); |
1132 | 1051 | ||
1133 | return_VALUE(result); | 1052 | return_VALUE(result); |
1134 | } | 1053 | } |
1135 | static int | 1054 | static int acpi_ec_burst_add(struct acpi_device *device) |
1136 | acpi_ec_burst_add ( | ||
1137 | struct acpi_device *device) | ||
1138 | { | 1055 | { |
1139 | int result = 0; | 1056 | int result = 0; |
1140 | acpi_status status = AE_OK; | 1057 | acpi_status status = AE_OK; |
1141 | union acpi_ec *ec = NULL; | 1058 | union acpi_ec *ec = NULL; |
1142 | unsigned long uid; | 1059 | unsigned long uid; |
1143 | 1060 | ||
1144 | ACPI_FUNCTION_TRACE("acpi_ec_add"); | 1061 | ACPI_FUNCTION_TRACE("acpi_ec_add"); |
1145 | 1062 | ||
@@ -1153,35 +1070,40 @@ acpi_ec_burst_add ( | |||
1153 | 1070 | ||
1154 | ec->common.handle = device->handle; | 1071 | ec->common.handle = device->handle; |
1155 | ec->common.uid = -1; | 1072 | ec->common.uid = -1; |
1156 | atomic_set(&ec->burst.pending_gpe, 0); | 1073 | atomic_set(&ec->burst.pending_gpe, 0); |
1157 | atomic_set(&ec->burst.leaving_burst , 1); | 1074 | atomic_set(&ec->burst.leaving_burst, 1); |
1158 | init_MUTEX(&ec->burst.sem); | 1075 | init_MUTEX(&ec->burst.sem); |
1159 | init_waitqueue_head(&ec->burst.wait); | 1076 | init_waitqueue_head(&ec->burst.wait); |
1160 | strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); | 1077 | strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); |
1161 | strcpy(acpi_device_class(device), ACPI_EC_CLASS); | 1078 | strcpy(acpi_device_class(device), ACPI_EC_CLASS); |
1162 | acpi_driver_data(device) = ec; | 1079 | acpi_driver_data(device) = ec; |
1163 | 1080 | ||
1164 | /* Use the global lock for all EC transactions? */ | 1081 | /* Use the global lock for all EC transactions? */ |
1165 | acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock); | 1082 | acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, |
1083 | &ec->common.global_lock); | ||
1166 | 1084 | ||
1167 | /* If our UID matches the UID for the ECDT-enumerated EC, | 1085 | /* If our UID matches the UID for the ECDT-enumerated EC, |
1168 | we now have the *real* EC info, so kill the makeshift one.*/ | 1086 | we now have the *real* EC info, so kill the makeshift one. */ |
1169 | acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); | 1087 | acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); |
1170 | if (ec_ecdt && ec_ecdt->common.uid == uid) { | 1088 | if (ec_ecdt && ec_ecdt->common.uid == uid) { |
1171 | acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, | 1089 | acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, |
1172 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); | 1090 | ACPI_ADR_SPACE_EC, |
1091 | &acpi_ec_space_handler); | ||
1173 | 1092 | ||
1174 | acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler); | 1093 | acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, |
1094 | &acpi_ec_gpe_handler); | ||
1175 | 1095 | ||
1176 | kfree(ec_ecdt); | 1096 | kfree(ec_ecdt); |
1177 | } | 1097 | } |
1178 | 1098 | ||
1179 | /* Get GPE bit assignment (EC events). */ | 1099 | /* Get GPE bit assignment (EC events). */ |
1180 | /* TODO: Add support for _GPE returning a package */ | 1100 | /* TODO: Add support for _GPE returning a package */ |
1181 | status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); | 1101 | status = |
1102 | acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, | ||
1103 | &ec->common.gpe_bit); | ||
1182 | if (ACPI_FAILURE(status)) { | 1104 | if (ACPI_FAILURE(status)) { |
1183 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 1105 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
1184 | "Error obtaining GPE bit assignment\n")); | 1106 | "Error obtaining GPE bit assignment\n")); |
1185 | result = -ENODEV; | 1107 | result = -ENODEV; |
1186 | goto end; | 1108 | goto end; |
1187 | } | 1109 | } |
@@ -1192,26 +1114,22 @@ acpi_ec_burst_add ( | |||
1192 | 1114 | ||
1193 | printk("burst-mode-ec-10-Aug\n"); | 1115 | printk("burst-mode-ec-10-Aug\n"); |
1194 | printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", | 1116 | printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", |
1195 | acpi_device_name(device), acpi_device_bid(device), | 1117 | acpi_device_name(device), acpi_device_bid(device), |
1196 | (u32) ec->common.gpe_bit); | 1118 | (u32) ec->common.gpe_bit); |
1197 | 1119 | ||
1198 | if (!first_ec) | 1120 | if (!first_ec) |
1199 | first_ec = device; | 1121 | first_ec = device; |
1200 | 1122 | ||
1201 | end: | 1123 | end: |
1202 | if (result) | 1124 | if (result) |
1203 | kfree(ec); | 1125 | kfree(ec); |
1204 | 1126 | ||
1205 | return_VALUE(result); | 1127 | return_VALUE(result); |
1206 | } | 1128 | } |
1207 | 1129 | ||
1208 | 1130 | static int acpi_ec_remove(struct acpi_device *device, int type) | |
1209 | static int | ||
1210 | acpi_ec_remove ( | ||
1211 | struct acpi_device *device, | ||
1212 | int type) | ||
1213 | { | 1131 | { |
1214 | union acpi_ec *ec = NULL; | 1132 | union acpi_ec *ec = NULL; |
1215 | 1133 | ||
1216 | ACPI_FUNCTION_TRACE("acpi_ec_remove"); | 1134 | ACPI_FUNCTION_TRACE("acpi_ec_remove"); |
1217 | 1135 | ||
@@ -1227,13 +1145,10 @@ acpi_ec_remove ( | |||
1227 | return_VALUE(0); | 1145 | return_VALUE(0); |
1228 | } | 1146 | } |
1229 | 1147 | ||
1230 | |||
1231 | static acpi_status | 1148 | static acpi_status |
1232 | acpi_ec_io_ports ( | 1149 | acpi_ec_io_ports(struct acpi_resource *resource, void *context) |
1233 | struct acpi_resource *resource, | ||
1234 | void *context) | ||
1235 | { | 1150 | { |
1236 | union acpi_ec *ec = (union acpi_ec *) context; | 1151 | union acpi_ec *ec = (union acpi_ec *)context; |
1237 | struct acpi_generic_address *addr; | 1152 | struct acpi_generic_address *addr; |
1238 | 1153 | ||
1239 | if (resource->id != ACPI_RSTYPE_IO) { | 1154 | if (resource->id != ACPI_RSTYPE_IO) { |
@@ -1261,13 +1176,10 @@ acpi_ec_io_ports ( | |||
1261 | return AE_OK; | 1176 | return AE_OK; |
1262 | } | 1177 | } |
1263 | 1178 | ||
1264 | 1179 | static int acpi_ec_start(struct acpi_device *device) | |
1265 | static int | ||
1266 | acpi_ec_start ( | ||
1267 | struct acpi_device *device) | ||
1268 | { | 1180 | { |
1269 | acpi_status status = AE_OK; | 1181 | acpi_status status = AE_OK; |
1270 | union acpi_ec *ec = NULL; | 1182 | union acpi_ec *ec = NULL; |
1271 | 1183 | ||
1272 | ACPI_FUNCTION_TRACE("acpi_ec_start"); | 1184 | ACPI_FUNCTION_TRACE("acpi_ec_start"); |
1273 | 1185 | ||
@@ -1283,49 +1195,50 @@ acpi_ec_start ( | |||
1283 | * Get I/O port addresses. Convert to GAS format. | 1195 | * Get I/O port addresses. Convert to GAS format. |
1284 | */ | 1196 | */ |
1285 | status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS, | 1197 | status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS, |
1286 | acpi_ec_io_ports, ec); | 1198 | acpi_ec_io_ports, ec); |
1287 | if (ACPI_FAILURE(status) || ec->common.command_addr.register_bit_width == 0) { | 1199 | if (ACPI_FAILURE(status) |
1288 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting I/O port addresses")); | 1200 | || ec->common.command_addr.register_bit_width == 0) { |
1201 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
1202 | "Error getting I/O port addresses")); | ||
1289 | return_VALUE(-ENODEV); | 1203 | return_VALUE(-ENODEV); |
1290 | } | 1204 | } |
1291 | 1205 | ||
1292 | ec->common.status_addr = ec->common.command_addr; | 1206 | ec->common.status_addr = ec->common.command_addr; |
1293 | 1207 | ||
1294 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n", | 1208 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n", |
1295 | (u32) ec->common.gpe_bit, (u32) ec->common.command_addr.address, | 1209 | (u32) ec->common.gpe_bit, |
1296 | (u32) ec->common.data_addr.address)); | 1210 | (u32) ec->common.command_addr.address, |
1297 | 1211 | (u32) ec->common.data_addr.address)); | |
1298 | 1212 | ||
1299 | /* | 1213 | /* |
1300 | * Install GPE handler | 1214 | * Install GPE handler |
1301 | */ | 1215 | */ |
1302 | status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit, | 1216 | status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit, |
1303 | ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec); | 1217 | ACPI_GPE_EDGE_TRIGGERED, |
1218 | &acpi_ec_gpe_handler, ec); | ||
1304 | if (ACPI_FAILURE(status)) { | 1219 | if (ACPI_FAILURE(status)) { |
1305 | return_VALUE(-ENODEV); | 1220 | return_VALUE(-ENODEV); |
1306 | } | 1221 | } |
1307 | acpi_set_gpe_type (NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); | 1222 | acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); |
1308 | acpi_enable_gpe (NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 1223 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); |
1309 | 1224 | ||
1310 | status = acpi_install_address_space_handler (ec->common.handle, | 1225 | status = acpi_install_address_space_handler(ec->common.handle, |
1311 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, | 1226 | ACPI_ADR_SPACE_EC, |
1312 | &acpi_ec_space_setup, ec); | 1227 | &acpi_ec_space_handler, |
1228 | &acpi_ec_space_setup, ec); | ||
1313 | if (ACPI_FAILURE(status)) { | 1229 | if (ACPI_FAILURE(status)) { |
1314 | acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); | 1230 | acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, |
1231 | &acpi_ec_gpe_handler); | ||
1315 | return_VALUE(-ENODEV); | 1232 | return_VALUE(-ENODEV); |
1316 | } | 1233 | } |
1317 | 1234 | ||
1318 | return_VALUE(AE_OK); | 1235 | return_VALUE(AE_OK); |
1319 | } | 1236 | } |
1320 | 1237 | ||
1321 | 1238 | static int acpi_ec_stop(struct acpi_device *device, int type) | |
1322 | static int | ||
1323 | acpi_ec_stop ( | ||
1324 | struct acpi_device *device, | ||
1325 | int type) | ||
1326 | { | 1239 | { |
1327 | acpi_status status = AE_OK; | 1240 | acpi_status status = AE_OK; |
1328 | union acpi_ec *ec = NULL; | 1241 | union acpi_ec *ec = NULL; |
1329 | 1242 | ||
1330 | ACPI_FUNCTION_TRACE("acpi_ec_stop"); | 1243 | ACPI_FUNCTION_TRACE("acpi_ec_stop"); |
1331 | 1244 | ||
@@ -1335,11 +1248,14 @@ acpi_ec_stop ( | |||
1335 | ec = acpi_driver_data(device); | 1248 | ec = acpi_driver_data(device); |
1336 | 1249 | ||
1337 | status = acpi_remove_address_space_handler(ec->common.handle, | 1250 | status = acpi_remove_address_space_handler(ec->common.handle, |
1338 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); | 1251 | ACPI_ADR_SPACE_EC, |
1252 | &acpi_ec_space_handler); | ||
1339 | if (ACPI_FAILURE(status)) | 1253 | if (ACPI_FAILURE(status)) |
1340 | return_VALUE(-ENODEV); | 1254 | return_VALUE(-ENODEV); |
1341 | 1255 | ||
1342 | status = acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); | 1256 | status = |
1257 | acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, | ||
1258 | &acpi_ec_gpe_handler); | ||
1343 | if (ACPI_FAILURE(status)) | 1259 | if (ACPI_FAILURE(status)) |
1344 | return_VALUE(-ENODEV); | 1260 | return_VALUE(-ENODEV); |
1345 | 1261 | ||
@@ -1347,32 +1263,26 @@ acpi_ec_stop ( | |||
1347 | } | 1263 | } |
1348 | 1264 | ||
1349 | static acpi_status __init | 1265 | static acpi_status __init |
1350 | acpi_fake_ecdt_callback ( | 1266 | acpi_fake_ecdt_callback(acpi_handle handle, |
1351 | acpi_handle handle, | 1267 | u32 Level, void *context, void **retval) |
1352 | u32 Level, | ||
1353 | void *context, | ||
1354 | void **retval) | ||
1355 | { | 1268 | { |
1356 | 1269 | ||
1357 | if (acpi_ec_polling_mode) | 1270 | if (acpi_ec_polling_mode) |
1358 | return acpi_fake_ecdt_polling_callback(handle, | 1271 | return acpi_fake_ecdt_polling_callback(handle, |
1359 | Level, context, retval); | 1272 | Level, context, retval); |
1360 | else | 1273 | else |
1361 | return acpi_fake_ecdt_burst_callback(handle, | 1274 | return acpi_fake_ecdt_burst_callback(handle, |
1362 | Level, context, retval); | 1275 | Level, context, retval); |
1363 | } | 1276 | } |
1364 | 1277 | ||
1365 | static acpi_status __init | 1278 | static acpi_status __init |
1366 | acpi_fake_ecdt_polling_callback ( | 1279 | acpi_fake_ecdt_polling_callback(acpi_handle handle, |
1367 | acpi_handle handle, | 1280 | u32 Level, void *context, void **retval) |
1368 | u32 Level, | ||
1369 | void *context, | ||
1370 | void **retval) | ||
1371 | { | 1281 | { |
1372 | acpi_status status; | 1282 | acpi_status status; |
1373 | 1283 | ||
1374 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | 1284 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
1375 | acpi_ec_io_ports, ec_ecdt); | 1285 | acpi_ec_io_ports, ec_ecdt); |
1376 | if (ACPI_FAILURE(status)) | 1286 | if (ACPI_FAILURE(status)) |
1377 | return status; | 1287 | return status; |
1378 | ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; | 1288 | ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; |
@@ -1380,33 +1290,33 @@ acpi_fake_ecdt_polling_callback ( | |||
1380 | ec_ecdt->common.uid = -1; | 1290 | ec_ecdt->common.uid = -1; |
1381 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); | 1291 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); |
1382 | 1292 | ||
1383 | status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit); | 1293 | status = |
1294 | acpi_evaluate_integer(handle, "_GPE", NULL, | ||
1295 | &ec_ecdt->common.gpe_bit); | ||
1384 | if (ACPI_FAILURE(status)) | 1296 | if (ACPI_FAILURE(status)) |
1385 | return status; | 1297 | return status; |
1386 | spin_lock_init(&ec_ecdt->polling.lock); | 1298 | spin_lock_init(&ec_ecdt->polling.lock); |
1387 | ec_ecdt->common.global_lock = TRUE; | 1299 | ec_ecdt->common.global_lock = TRUE; |
1388 | ec_ecdt->common.handle = handle; | 1300 | ec_ecdt->common.handle = handle; |
1389 | 1301 | ||
1390 | printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", | 1302 | printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", |
1391 | (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address, | 1303 | (u32) ec_ecdt->common.gpe_bit, |
1392 | (u32) ec_ecdt->common.data_addr.address); | 1304 | (u32) ec_ecdt->common.command_addr.address, |
1305 | (u32) ec_ecdt->common.data_addr.address); | ||
1393 | 1306 | ||
1394 | return AE_CTRL_TERMINATE; | 1307 | return AE_CTRL_TERMINATE; |
1395 | } | 1308 | } |
1396 | 1309 | ||
1397 | static acpi_status __init | 1310 | static acpi_status __init |
1398 | acpi_fake_ecdt_burst_callback ( | 1311 | acpi_fake_ecdt_burst_callback(acpi_handle handle, |
1399 | acpi_handle handle, | 1312 | u32 Level, void *context, void **retval) |
1400 | u32 Level, | ||
1401 | void *context, | ||
1402 | void **retval) | ||
1403 | { | 1313 | { |
1404 | acpi_status status; | 1314 | acpi_status status; |
1405 | 1315 | ||
1406 | init_MUTEX(&ec_ecdt->burst.sem); | 1316 | init_MUTEX(&ec_ecdt->burst.sem); |
1407 | init_waitqueue_head(&ec_ecdt->burst.wait); | 1317 | init_waitqueue_head(&ec_ecdt->burst.wait); |
1408 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | 1318 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
1409 | acpi_ec_io_ports, ec_ecdt); | 1319 | acpi_ec_io_ports, ec_ecdt); |
1410 | if (ACPI_FAILURE(status)) | 1320 | if (ACPI_FAILURE(status)) |
1411 | return status; | 1321 | return status; |
1412 | ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; | 1322 | ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; |
@@ -1414,15 +1324,18 @@ acpi_fake_ecdt_burst_callback ( | |||
1414 | ec_ecdt->common.uid = -1; | 1324 | ec_ecdt->common.uid = -1; |
1415 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); | 1325 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); |
1416 | 1326 | ||
1417 | status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit); | 1327 | status = |
1328 | acpi_evaluate_integer(handle, "_GPE", NULL, | ||
1329 | &ec_ecdt->common.gpe_bit); | ||
1418 | if (ACPI_FAILURE(status)) | 1330 | if (ACPI_FAILURE(status)) |
1419 | return status; | 1331 | return status; |
1420 | ec_ecdt->common.global_lock = TRUE; | 1332 | ec_ecdt->common.global_lock = TRUE; |
1421 | ec_ecdt->common.handle = handle; | 1333 | ec_ecdt->common.handle = handle; |
1422 | 1334 | ||
1423 | printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", | 1335 | printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", |
1424 | (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address, | 1336 | (u32) ec_ecdt->common.gpe_bit, |
1425 | (u32) ec_ecdt->common.data_addr.address); | 1337 | (u32) ec_ecdt->common.command_addr.address, |
1338 | (u32) ec_ecdt->common.data_addr.address); | ||
1426 | 1339 | ||
1427 | return AE_CTRL_TERMINATE; | 1340 | return AE_CTRL_TERMINATE; |
1428 | } | 1341 | } |
@@ -1437,11 +1350,10 @@ acpi_fake_ecdt_burst_callback ( | |||
1437 | * op region (since _REG isn't invoked yet). The assumption is true for | 1350 | * op region (since _REG isn't invoked yet). The assumption is true for |
1438 | * all systems found. | 1351 | * all systems found. |
1439 | */ | 1352 | */ |
1440 | static int __init | 1353 | static int __init acpi_ec_fake_ecdt(void) |
1441 | acpi_ec_fake_ecdt(void) | ||
1442 | { | 1354 | { |
1443 | acpi_status status; | 1355 | acpi_status status; |
1444 | int ret = 0; | 1356 | int ret = 0; |
1445 | 1357 | ||
1446 | printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); | 1358 | printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); |
1447 | 1359 | ||
@@ -1452,10 +1364,8 @@ acpi_ec_fake_ecdt(void) | |||
1452 | } | 1364 | } |
1453 | memset(ec_ecdt, 0, sizeof(union acpi_ec)); | 1365 | memset(ec_ecdt, 0, sizeof(union acpi_ec)); |
1454 | 1366 | ||
1455 | status = acpi_get_devices (ACPI_EC_HID, | 1367 | status = acpi_get_devices(ACPI_EC_HID, |
1456 | acpi_fake_ecdt_callback, | 1368 | acpi_fake_ecdt_callback, NULL, NULL); |
1457 | NULL, | ||
1458 | NULL); | ||
1459 | if (ACPI_FAILURE(status)) { | 1369 | if (ACPI_FAILURE(status)) { |
1460 | kfree(ec_ecdt); | 1370 | kfree(ec_ecdt); |
1461 | ec_ecdt = NULL; | 1371 | ec_ecdt = NULL; |
@@ -1463,13 +1373,12 @@ acpi_ec_fake_ecdt(void) | |||
1463 | goto error; | 1373 | goto error; |
1464 | } | 1374 | } |
1465 | return 0; | 1375 | return 0; |
1466 | error: | 1376 | error: |
1467 | printk(KERN_ERR PREFIX "Can't make an fake ECDT\n"); | 1377 | printk(KERN_ERR PREFIX "Can't make an fake ECDT\n"); |
1468 | return ret; | 1378 | return ret; |
1469 | } | 1379 | } |
1470 | 1380 | ||
1471 | static int __init | 1381 | static int __init acpi_ec_get_real_ecdt(void) |
1472 | acpi_ec_get_real_ecdt(void) | ||
1473 | { | 1382 | { |
1474 | if (acpi_ec_polling_mode) | 1383 | if (acpi_ec_polling_mode) |
1475 | return acpi_ec_polling_get_real_ecdt(); | 1384 | return acpi_ec_polling_get_real_ecdt(); |
@@ -1477,14 +1386,14 @@ acpi_ec_get_real_ecdt(void) | |||
1477 | return acpi_ec_burst_get_real_ecdt(); | 1386 | return acpi_ec_burst_get_real_ecdt(); |
1478 | } | 1387 | } |
1479 | 1388 | ||
1480 | static int __init | 1389 | static int __init acpi_ec_polling_get_real_ecdt(void) |
1481 | acpi_ec_polling_get_real_ecdt(void) | ||
1482 | { | 1390 | { |
1483 | acpi_status status; | 1391 | acpi_status status; |
1484 | struct acpi_table_ecdt *ecdt_ptr; | 1392 | struct acpi_table_ecdt *ecdt_ptr; |
1485 | 1393 | ||
1486 | status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, | 1394 | status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, |
1487 | (struct acpi_table_header **) &ecdt_ptr); | 1395 | (struct acpi_table_header **) |
1396 | &ecdt_ptr); | ||
1488 | if (ACPI_FAILURE(status)) | 1397 | if (ACPI_FAILURE(status)) |
1489 | return -ENODEV; | 1398 | return -ENODEV; |
1490 | 1399 | ||
@@ -1507,13 +1416,14 @@ acpi_ec_polling_get_real_ecdt(void) | |||
1507 | ec_ecdt->common.global_lock = TRUE; | 1416 | ec_ecdt->common.global_lock = TRUE; |
1508 | ec_ecdt->common.uid = ecdt_ptr->uid; | 1417 | ec_ecdt->common.uid = ecdt_ptr->uid; |
1509 | 1418 | ||
1510 | status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); | 1419 | status = |
1420 | acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); | ||
1511 | if (ACPI_FAILURE(status)) { | 1421 | if (ACPI_FAILURE(status)) { |
1512 | goto error; | 1422 | goto error; |
1513 | } | 1423 | } |
1514 | 1424 | ||
1515 | return 0; | 1425 | return 0; |
1516 | error: | 1426 | error: |
1517 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); | 1427 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); |
1518 | kfree(ec_ecdt); | 1428 | kfree(ec_ecdt); |
1519 | ec_ecdt = NULL; | 1429 | ec_ecdt = NULL; |
@@ -1521,15 +1431,14 @@ error: | |||
1521 | return -ENODEV; | 1431 | return -ENODEV; |
1522 | } | 1432 | } |
1523 | 1433 | ||
1524 | 1434 | static int __init acpi_ec_burst_get_real_ecdt(void) | |
1525 | static int __init | ||
1526 | acpi_ec_burst_get_real_ecdt(void) | ||
1527 | { | 1435 | { |
1528 | acpi_status status; | 1436 | acpi_status status; |
1529 | struct acpi_table_ecdt *ecdt_ptr; | 1437 | struct acpi_table_ecdt *ecdt_ptr; |
1530 | 1438 | ||
1531 | status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, | 1439 | status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, |
1532 | (struct acpi_table_header **) &ecdt_ptr); | 1440 | (struct acpi_table_header **) |
1441 | &ecdt_ptr); | ||
1533 | if (ACPI_FAILURE(status)) | 1442 | if (ACPI_FAILURE(status)) |
1534 | return -ENODEV; | 1443 | return -ENODEV; |
1535 | 1444 | ||
@@ -1543,8 +1452,8 @@ acpi_ec_burst_get_real_ecdt(void) | |||
1543 | return -ENOMEM; | 1452 | return -ENOMEM; |
1544 | memset(ec_ecdt, 0, sizeof(union acpi_ec)); | 1453 | memset(ec_ecdt, 0, sizeof(union acpi_ec)); |
1545 | 1454 | ||
1546 | init_MUTEX(&ec_ecdt->burst.sem); | 1455 | init_MUTEX(&ec_ecdt->burst.sem); |
1547 | init_waitqueue_head(&ec_ecdt->burst.wait); | 1456 | init_waitqueue_head(&ec_ecdt->burst.wait); |
1548 | ec_ecdt->common.command_addr = ecdt_ptr->ec_control; | 1457 | ec_ecdt->common.command_addr = ecdt_ptr->ec_control; |
1549 | ec_ecdt->common.status_addr = ecdt_ptr->ec_control; | 1458 | ec_ecdt->common.status_addr = ecdt_ptr->ec_control; |
1550 | ec_ecdt->common.data_addr = ecdt_ptr->ec_data; | 1459 | ec_ecdt->common.data_addr = ecdt_ptr->ec_data; |
@@ -1553,13 +1462,14 @@ acpi_ec_burst_get_real_ecdt(void) | |||
1553 | ec_ecdt->common.global_lock = TRUE; | 1462 | ec_ecdt->common.global_lock = TRUE; |
1554 | ec_ecdt->common.uid = ecdt_ptr->uid; | 1463 | ec_ecdt->common.uid = ecdt_ptr->uid; |
1555 | 1464 | ||
1556 | status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); | 1465 | status = |
1466 | acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); | ||
1557 | if (ACPI_FAILURE(status)) { | 1467 | if (ACPI_FAILURE(status)) { |
1558 | goto error; | 1468 | goto error; |
1559 | } | 1469 | } |
1560 | 1470 | ||
1561 | return 0; | 1471 | return 0; |
1562 | error: | 1472 | error: |
1563 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); | 1473 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); |
1564 | kfree(ec_ecdt); | 1474 | kfree(ec_ecdt); |
1565 | ec_ecdt = NULL; | 1475 | ec_ecdt = NULL; |
@@ -1568,11 +1478,10 @@ error: | |||
1568 | } | 1478 | } |
1569 | 1479 | ||
1570 | static int __initdata acpi_fake_ecdt_enabled; | 1480 | static int __initdata acpi_fake_ecdt_enabled; |
1571 | int __init | 1481 | int __init acpi_ec_ecdt_probe(void) |
1572 | acpi_ec_ecdt_probe (void) | ||
1573 | { | 1482 | { |
1574 | acpi_status status; | 1483 | acpi_status status; |
1575 | int ret; | 1484 | int ret; |
1576 | 1485 | ||
1577 | ret = acpi_ec_get_real_ecdt(); | 1486 | ret = acpi_ec_get_real_ecdt(); |
1578 | /* Try to make a fake ECDT */ | 1487 | /* Try to make a fake ECDT */ |
@@ -1587,26 +1496,28 @@ acpi_ec_ecdt_probe (void) | |||
1587 | * Install GPE handler | 1496 | * Install GPE handler |
1588 | */ | 1497 | */ |
1589 | status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit, | 1498 | status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit, |
1590 | ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, | 1499 | ACPI_GPE_EDGE_TRIGGERED, |
1591 | ec_ecdt); | 1500 | &acpi_ec_gpe_handler, ec_ecdt); |
1592 | if (ACPI_FAILURE(status)) { | 1501 | if (ACPI_FAILURE(status)) { |
1593 | goto error; | 1502 | goto error; |
1594 | } | 1503 | } |
1595 | acpi_set_gpe_type (NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); | 1504 | acpi_set_gpe_type(NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); |
1596 | acpi_enable_gpe (NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR); | 1505 | acpi_enable_gpe(NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR); |
1597 | 1506 | ||
1598 | status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT, | 1507 | status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT, |
1599 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, | 1508 | ACPI_ADR_SPACE_EC, |
1600 | &acpi_ec_space_setup, ec_ecdt); | 1509 | &acpi_ec_space_handler, |
1510 | &acpi_ec_space_setup, | ||
1511 | ec_ecdt); | ||
1601 | if (ACPI_FAILURE(status)) { | 1512 | if (ACPI_FAILURE(status)) { |
1602 | acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, | 1513 | acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, |
1603 | &acpi_ec_gpe_handler); | 1514 | &acpi_ec_gpe_handler); |
1604 | goto error; | 1515 | goto error; |
1605 | } | 1516 | } |
1606 | 1517 | ||
1607 | return 0; | 1518 | return 0; |
1608 | 1519 | ||
1609 | error: | 1520 | error: |
1610 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); | 1521 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); |
1611 | kfree(ec_ecdt); | 1522 | kfree(ec_ecdt); |
1612 | ec_ecdt = NULL; | 1523 | ec_ecdt = NULL; |
@@ -1614,10 +1525,9 @@ error: | |||
1614 | return -ENODEV; | 1525 | return -ENODEV; |
1615 | } | 1526 | } |
1616 | 1527 | ||
1617 | 1528 | static int __init acpi_ec_init(void) | |
1618 | static int __init acpi_ec_init (void) | ||
1619 | { | 1529 | { |
1620 | int result = 0; | 1530 | int result = 0; |
1621 | 1531 | ||
1622 | ACPI_FUNCTION_TRACE("acpi_ec_init"); | 1532 | ACPI_FUNCTION_TRACE("acpi_ec_init"); |
1623 | 1533 | ||
@@ -1642,8 +1552,7 @@ subsys_initcall(acpi_ec_init); | |||
1642 | 1552 | ||
1643 | /* EC driver currently not unloadable */ | 1553 | /* EC driver currently not unloadable */ |
1644 | #if 0 | 1554 | #if 0 |
1645 | static void __exit | 1555 | static void __exit acpi_ec_exit(void) |
1646 | acpi_ec_exit (void) | ||
1647 | { | 1556 | { |
1648 | ACPI_FUNCTION_TRACE("acpi_ec_exit"); | 1557 | ACPI_FUNCTION_TRACE("acpi_ec_exit"); |
1649 | 1558 | ||
@@ -1653,7 +1562,7 @@ acpi_ec_exit (void) | |||
1653 | 1562 | ||
1654 | return_VOID; | 1563 | return_VOID; |
1655 | } | 1564 | } |
1656 | #endif /* 0 */ | 1565 | #endif /* 0 */ |
1657 | 1566 | ||
1658 | static int __init acpi_fake_ecdt_setup(char *str) | 1567 | static int __init acpi_fake_ecdt_setup(char *str) |
1659 | { | 1568 | { |
@@ -1676,8 +1585,8 @@ static int __init acpi_ec_set_polling_mode(char *str) | |||
1676 | acpi_ec_polling_mode = EC_POLLING; | 1585 | acpi_ec_polling_mode = EC_POLLING; |
1677 | acpi_ec_driver.ops.add = acpi_ec_polling_add; | 1586 | acpi_ec_driver.ops.add = acpi_ec_polling_add; |
1678 | } | 1587 | } |
1679 | printk(KERN_INFO PREFIX "EC %s mode.\n", | 1588 | printk(KERN_INFO PREFIX "EC %s mode.\n", burst ? "burst" : "polling"); |
1680 | burst ? "burst": "polling"); | ||
1681 | return 0; | 1589 | return 0; |
1682 | } | 1590 | } |
1591 | |||
1683 | __setup("ec_burst=", acpi_ec_set_polling_mode); | 1592 | __setup("ec_burst=", acpi_ec_set_polling_mode); |