diff options
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r-- | drivers/acpi/ec.c | 1028 |
1 files changed, 443 insertions, 585 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 1ac5731d45e5..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,25 +205,36 @@ 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 | ||
234 | ec->burst.expect_event = event; | 212 | ec->burst.expect_event = event; |
235 | smp_mb(); | 213 | smp_mb(); |
236 | 214 | ||
237 | result = wait_event_interruptible_timeout(ec->burst.wait, | 215 | switch (event) { |
238 | !ec->burst.expect_event, | 216 | case ACPI_EC_EVENT_OBF: |
239 | msecs_to_jiffies(ACPI_EC_DELAY)); | 217 | if (acpi_ec_read_status(ec) & event) { |
240 | 218 | ec->burst.expect_event = 0; | |
241 | ec->burst.expect_event = 0; | 219 | return_VALUE(0); |
242 | smp_mb(); | 220 | } |
221 | break; | ||
243 | 222 | ||
244 | if (result < 0){ | 223 | case ACPI_EC_EVENT_IBE: |
245 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR," result = %d ", result)); | 224 | if (~acpi_ec_read_status(ec) & event) { |
246 | return_VALUE(result); | 225 | ec->burst.expect_event = 0; |
226 | return_VALUE(0); | ||
227 | } | ||
228 | break; | ||
247 | } | 229 | } |
248 | 230 | ||
231 | result = wait_event_timeout(ec->burst.wait, | ||
232 | !ec->burst.expect_event, | ||
233 | msecs_to_jiffies(ACPI_EC_DELAY)); | ||
234 | |||
235 | ec->burst.expect_event = 0; | ||
236 | smp_mb(); | ||
237 | |||
249 | /* | 238 | /* |
250 | * Verify that the event in question has actually happened by | 239 | * Verify that the event in question has actually happened by |
251 | * querying EC status. Do the check even if operation timed-out | 240 | * querying EC status. Do the check even if operation timed-out |
@@ -266,95 +255,65 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) | |||
266 | return_VALUE(-ETIME); | 255 | return_VALUE(-ETIME); |
267 | } | 256 | } |
268 | 257 | ||
269 | 258 | static int acpi_ec_enter_burst_mode(union acpi_ec *ec) | |
270 | |||
271 | static int | ||
272 | acpi_ec_enter_burst_mode ( | ||
273 | union acpi_ec *ec) | ||
274 | { | 259 | { |
275 | u32 tmp = 0; | 260 | u32 tmp = 0; |
276 | int status = 0; | 261 | int status = 0; |
277 | 262 | ||
278 | ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode"); | 263 | ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode"); |
279 | 264 | ||
280 | status = acpi_ec_read_status(ec); | 265 | status = acpi_ec_read_status(ec); |
281 | if (status != -EINVAL && | 266 | if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { |
282 | !(status & ACPI_EC_FLAG_BURST)){ | 267 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
283 | acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr); | 268 | if (status) |
269 | goto end; | ||
270 | acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, | ||
271 | &ec->common.command_addr); | ||
284 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); | 272 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); |
285 | if (status){ | 273 | if (status) |
286 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | ||
287 | return_VALUE(-EINVAL); | 274 | return_VALUE(-EINVAL); |
288 | } | ||
289 | acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); | 275 | acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); |
290 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 276 | if (tmp != 0x90) { /* Burst ACK byte */ |
291 | if(tmp != 0x90 ) {/* Burst ACK byte*/ | ||
292 | return_VALUE(-EINVAL); | 277 | return_VALUE(-EINVAL); |
293 | } | 278 | } |
294 | } | 279 | } |
295 | 280 | ||
296 | atomic_set(&ec->burst.leaving_burst , 0); | 281 | atomic_set(&ec->burst.leaving_burst, 0); |
297 | return_VALUE(0); | 282 | return_VALUE(0); |
283 | end: | ||
284 | printk("Error in acpi_ec_wait\n"); | ||
285 | return_VALUE(-1); | ||
298 | } | 286 | } |
299 | 287 | ||
300 | static int | 288 | static int acpi_ec_leave_burst_mode(union acpi_ec *ec) |
301 | acpi_ec_leave_burst_mode ( | ||
302 | union acpi_ec *ec) | ||
303 | { | 289 | { |
304 | int status =0; | ||
305 | 290 | ||
306 | ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); | 291 | ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); |
307 | 292 | ||
308 | atomic_set(&ec->burst.leaving_burst , 1); | 293 | atomic_set(&ec->burst.leaving_burst, 1); |
309 | status = acpi_ec_read_status(ec); | ||
310 | if (status != -EINVAL && | ||
311 | (status & ACPI_EC_FLAG_BURST)){ | ||
312 | acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr); | ||
313 | status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); | ||
314 | if (status){ | ||
315 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | ||
316 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n")); | ||
317 | return_VALUE(-EINVAL); | ||
318 | } | ||
319 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | ||
320 | status = acpi_ec_read_status(ec); | ||
321 | } | ||
322 | |||
323 | return_VALUE(0); | 294 | return_VALUE(0); |
324 | } | 295 | } |
325 | 296 | ||
326 | static int | 297 | static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data) |
327 | acpi_ec_read ( | ||
328 | union acpi_ec *ec, | ||
329 | u8 address, | ||
330 | u32 *data) | ||
331 | { | 298 | { |
332 | if (acpi_ec_polling_mode) | 299 | if (acpi_ec_polling_mode) |
333 | return acpi_ec_polling_read(ec, address, data); | 300 | return acpi_ec_polling_read(ec, address, data); |
334 | else | 301 | else |
335 | return acpi_ec_burst_read(ec, address, data); | 302 | return acpi_ec_burst_read(ec, address, data); |
336 | } | 303 | } |
337 | static int | 304 | static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data) |
338 | acpi_ec_write ( | ||
339 | union acpi_ec *ec, | ||
340 | u8 address, | ||
341 | u8 data) | ||
342 | { | 305 | { |
343 | if (acpi_ec_polling_mode) | 306 | if (acpi_ec_polling_mode) |
344 | return acpi_ec_polling_write(ec, address, data); | 307 | return acpi_ec_polling_write(ec, address, data); |
345 | else | 308 | else |
346 | return acpi_ec_burst_write(ec, address, data); | 309 | return acpi_ec_burst_write(ec, address, data); |
347 | } | 310 | } |
348 | static int | 311 | static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data) |
349 | acpi_ec_polling_read ( | ||
350 | union acpi_ec *ec, | ||
351 | u8 address, | ||
352 | u32 *data) | ||
353 | { | 312 | { |
354 | acpi_status status = AE_OK; | 313 | acpi_status status = AE_OK; |
355 | int result = 0; | 314 | int result = 0; |
356 | unsigned long flags = 0; | 315 | unsigned long flags = 0; |
357 | u32 glk = 0; | 316 | u32 glk = 0; |
358 | 317 | ||
359 | ACPI_FUNCTION_TRACE("acpi_ec_read"); | 318 | ACPI_FUNCTION_TRACE("acpi_ec_read"); |
360 | 319 | ||
@@ -371,7 +330,8 @@ acpi_ec_polling_read ( | |||
371 | 330 | ||
372 | spin_lock_irqsave(&ec->polling.lock, flags); | 331 | spin_lock_irqsave(&ec->polling.lock, flags); |
373 | 332 | ||
374 | 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); | ||
375 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 335 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
376 | if (result) | 336 | if (result) |
377 | goto end; | 337 | goto end; |
@@ -384,9 +344,9 @@ acpi_ec_polling_read ( | |||
384 | acpi_hw_low_level_read(8, data, &ec->common.data_addr); | 344 | acpi_hw_low_level_read(8, data, &ec->common.data_addr); |
385 | 345 | ||
386 | 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", |
387 | *data, address)); | 347 | *data, address)); |
388 | 348 | ||
389 | end: | 349 | end: |
390 | spin_unlock_irqrestore(&ec->polling.lock, flags); | 350 | spin_unlock_irqrestore(&ec->polling.lock, flags); |
391 | 351 | ||
392 | if (ec->common.global_lock) | 352 | if (ec->common.global_lock) |
@@ -395,17 +355,12 @@ end: | |||
395 | return_VALUE(result); | 355 | return_VALUE(result); |
396 | } | 356 | } |
397 | 357 | ||
398 | 358 | static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data) | |
399 | static int | ||
400 | acpi_ec_polling_write ( | ||
401 | union acpi_ec *ec, | ||
402 | u8 address, | ||
403 | u8 data) | ||
404 | { | 359 | { |
405 | int result = 0; | 360 | int result = 0; |
406 | acpi_status status = AE_OK; | 361 | acpi_status status = AE_OK; |
407 | unsigned long flags = 0; | 362 | unsigned long flags = 0; |
408 | u32 glk = 0; | 363 | u32 glk = 0; |
409 | 364 | ||
410 | ACPI_FUNCTION_TRACE("acpi_ec_write"); | 365 | ACPI_FUNCTION_TRACE("acpi_ec_write"); |
411 | 366 | ||
@@ -420,7 +375,8 @@ acpi_ec_polling_write ( | |||
420 | 375 | ||
421 | spin_lock_irqsave(&ec->polling.lock, flags); | 376 | spin_lock_irqsave(&ec->polling.lock, flags); |
422 | 377 | ||
423 | 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); | ||
424 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 380 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
425 | if (result) | 381 | if (result) |
426 | goto end; | 382 | goto end; |
@@ -436,9 +392,9 @@ acpi_ec_polling_write ( | |||
436 | goto end; | 392 | goto end; |
437 | 393 | ||
438 | 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", |
439 | data, address)); | 395 | data, address)); |
440 | 396 | ||
441 | end: | 397 | end: |
442 | spin_unlock_irqrestore(&ec->polling.lock, flags); | 398 | spin_unlock_irqrestore(&ec->polling.lock, flags); |
443 | 399 | ||
444 | if (ec->common.global_lock) | 400 | if (ec->common.global_lock) |
@@ -447,21 +403,16 @@ end: | |||
447 | return_VALUE(result); | 403 | return_VALUE(result); |
448 | } | 404 | } |
449 | 405 | ||
450 | static int | 406 | static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data) |
451 | acpi_ec_burst_read ( | ||
452 | union acpi_ec *ec, | ||
453 | u8 address, | ||
454 | u32 *data) | ||
455 | { | 407 | { |
456 | int status = 0; | 408 | int status = 0; |
457 | u32 glk; | 409 | u32 glk; |
458 | 410 | ||
459 | ACPI_FUNCTION_TRACE("acpi_ec_read"); | 411 | ACPI_FUNCTION_TRACE("acpi_ec_read"); |
460 | 412 | ||
461 | if (!ec || !data) | 413 | if (!ec || !data) |
462 | return_VALUE(-EINVAL); | 414 | return_VALUE(-EINVAL); |
463 | 415 | ||
464 | retry: | ||
465 | *data = 0; | 416 | *data = 0; |
466 | 417 | ||
467 | if (ec->common.global_lock) { | 418 | if (ec->common.global_lock) { |
@@ -473,64 +424,49 @@ retry: | |||
473 | WARN_ON(in_interrupt()); | 424 | WARN_ON(in_interrupt()); |
474 | down(&ec->burst.sem); | 425 | down(&ec->burst.sem); |
475 | 426 | ||
476 | if(acpi_ec_enter_burst_mode(ec)) | 427 | acpi_ec_enter_burst_mode(ec); |
477 | goto end; | ||
478 | |||
479 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr); | ||
480 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 428 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
481 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | ||
482 | if (status) { | 429 | if (status) { |
430 | printk("read EC, IB not empty\n"); | ||
483 | goto end; | 431 | goto end; |
484 | } | 432 | } |
433 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, | ||
434 | &ec->common.command_addr); | ||
435 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | ||
436 | if (status) { | ||
437 | printk("read EC, IB not empty\n"); | ||
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 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 443 | printk("read EC, OB not full\n"); |
490 | goto end; | 444 | goto end; |
491 | } | 445 | } |
492 | |||
493 | acpi_hw_low_level_read(8, data, &ec->common.data_addr); | 446 | acpi_hw_low_level_read(8, data, &ec->common.data_addr); |
494 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | ||
495 | |||
496 | 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", |
497 | *data, address)); | 448 | *data, address)); |
498 | 449 | ||
499 | end: | 450 | end: |
500 | acpi_ec_leave_burst_mode(ec); | 451 | acpi_ec_leave_burst_mode(ec); |
501 | up(&ec->burst.sem); | 452 | up(&ec->burst.sem); |
502 | 453 | ||
503 | if (ec->common.global_lock) | 454 | if (ec->common.global_lock) |
504 | acpi_release_global_lock(glk); | 455 | acpi_release_global_lock(glk); |
505 | 456 | ||
506 | if(atomic_read(&ec->burst.leaving_burst) == 2){ | ||
507 | ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); | ||
508 | while(atomic_read(&ec->burst.pending_gpe)){ | ||
509 | msleep(1); | ||
510 | } | ||
511 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | ||
512 | goto retry; | ||
513 | } | ||
514 | |||
515 | return_VALUE(status); | 457 | return_VALUE(status); |
516 | } | 458 | } |
517 | 459 | ||
518 | 460 | static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data) | |
519 | static int | ||
520 | acpi_ec_burst_write ( | ||
521 | union acpi_ec *ec, | ||
522 | u8 address, | ||
523 | u8 data) | ||
524 | { | 461 | { |
525 | int status = 0; | 462 | int status = 0; |
526 | u32 glk; | 463 | u32 glk; |
527 | u32 tmp; | ||
528 | 464 | ||
529 | ACPI_FUNCTION_TRACE("acpi_ec_write"); | 465 | ACPI_FUNCTION_TRACE("acpi_ec_write"); |
530 | 466 | ||
531 | if (!ec) | 467 | if (!ec) |
532 | return_VALUE(-EINVAL); | 468 | return_VALUE(-EINVAL); |
533 | retry: | 469 | |
534 | if (ec->common.global_lock) { | 470 | if (ec->common.global_lock) { |
535 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); | 471 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); |
536 | if (ACPI_FAILURE(status)) | 472 | if (ACPI_FAILURE(status)) |
@@ -540,69 +476,43 @@ retry: | |||
540 | WARN_ON(in_interrupt()); | 476 | WARN_ON(in_interrupt()); |
541 | down(&ec->burst.sem); | 477 | down(&ec->burst.sem); |
542 | 478 | ||
543 | if(acpi_ec_enter_burst_mode(ec)) | 479 | acpi_ec_enter_burst_mode(ec); |
544 | goto end; | ||
545 | 480 | ||
546 | status = acpi_ec_read_status(ec); | 481 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
547 | if (status != -EINVAL && | 482 | if (status) { |
548 | !(status & ACPI_EC_FLAG_BURST)){ | 483 | printk("write EC, IB not empty\n"); |
549 | acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr); | ||
550 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); | ||
551 | if (status) | ||
552 | goto end; | ||
553 | acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); | ||
554 | if(tmp != 0x90 ) /* Burst ACK byte*/ | ||
555 | goto end; | ||
556 | } | 484 | } |
557 | /*Now we are in burst mode*/ | 485 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, |
558 | 486 | &ec->common.command_addr); | |
559 | acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr); | ||
560 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 487 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
561 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 488 | if (status) { |
562 | if (status){ | 489 | printk("write EC, IB not empty\n"); |
563 | goto end; | ||
564 | } | 490 | } |
565 | 491 | ||
566 | acpi_hw_low_level_write(8, address, &ec->common.data_addr); | 492 | acpi_hw_low_level_write(8, address, &ec->common.data_addr); |
567 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | 493 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); |
568 | if (status){ | 494 | if (status) { |
569 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 495 | printk("write EC, IB not empty\n"); |
570 | goto end; | ||
571 | } | 496 | } |
572 | 497 | ||
573 | acpi_hw_low_level_write(8, data, &ec->common.data_addr); | 498 | acpi_hw_low_level_write(8, data, &ec->common.data_addr); |
574 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | ||
575 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | ||
576 | if (status) | ||
577 | goto end; | ||
578 | 499 | ||
579 | 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", |
580 | data, address)); | 501 | data, address)); |
581 | 502 | ||
582 | end: | ||
583 | acpi_ec_leave_burst_mode(ec); | 503 | acpi_ec_leave_burst_mode(ec); |
584 | up(&ec->burst.sem); | 504 | up(&ec->burst.sem); |
585 | 505 | ||
586 | if (ec->common.global_lock) | 506 | if (ec->common.global_lock) |
587 | acpi_release_global_lock(glk); | 507 | acpi_release_global_lock(glk); |
588 | 508 | ||
589 | if(atomic_read(&ec->burst.leaving_burst) == 2){ | ||
590 | ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); | ||
591 | while(atomic_read(&ec->burst.pending_gpe)){ | ||
592 | msleep(1); | ||
593 | } | ||
594 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | ||
595 | goto retry; | ||
596 | } | ||
597 | |||
598 | return_VALUE(status); | 509 | return_VALUE(status); |
599 | } | 510 | } |
600 | 511 | ||
601 | /* | 512 | /* |
602 | * Externally callable EC access functions. For now, assume 1 EC only | 513 | * Externally callable EC access functions. For now, assume 1 EC only |
603 | */ | 514 | */ |
604 | int | 515 | int ec_read(u8 addr, u8 * val) |
605 | ec_read(u8 addr, u8 *val) | ||
606 | { | 516 | { |
607 | union acpi_ec *ec; | 517 | union acpi_ec *ec; |
608 | int err; | 518 | int err; |
@@ -618,14 +528,13 @@ ec_read(u8 addr, u8 *val) | |||
618 | if (!err) { | 528 | if (!err) { |
619 | *val = temp_data; | 529 | *val = temp_data; |
620 | return 0; | 530 | return 0; |
621 | } | 531 | } else |
622 | else | ||
623 | return err; | 532 | return err; |
624 | } | 533 | } |
534 | |||
625 | EXPORT_SYMBOL(ec_read); | 535 | EXPORT_SYMBOL(ec_read); |
626 | 536 | ||
627 | int | 537 | int ec_write(u8 addr, u8 val) |
628 | ec_write(u8 addr, u8 val) | ||
629 | { | 538 | { |
630 | union acpi_ec *ec; | 539 | union acpi_ec *ec; |
631 | int err; | 540 | int err; |
@@ -639,27 +548,22 @@ ec_write(u8 addr, u8 val) | |||
639 | 548 | ||
640 | return err; | 549 | return err; |
641 | } | 550 | } |
551 | |||
642 | EXPORT_SYMBOL(ec_write); | 552 | EXPORT_SYMBOL(ec_write); |
643 | 553 | ||
644 | static int | 554 | static int acpi_ec_query(union acpi_ec *ec, u32 * data) |
645 | acpi_ec_query ( | ||
646 | union acpi_ec *ec, | ||
647 | u32 *data) | ||
648 | { | 555 | { |
649 | if (acpi_ec_polling_mode) | 556 | if (acpi_ec_polling_mode) |
650 | return acpi_ec_polling_query(ec, data); | 557 | return acpi_ec_polling_query(ec, data); |
651 | else | 558 | else |
652 | return acpi_ec_burst_query(ec, data); | 559 | return acpi_ec_burst_query(ec, data); |
653 | } | 560 | } |
654 | static int | 561 | static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data) |
655 | acpi_ec_polling_query ( | ||
656 | union acpi_ec *ec, | ||
657 | u32 *data) | ||
658 | { | 562 | { |
659 | int result = 0; | 563 | int result = 0; |
660 | acpi_status status = AE_OK; | 564 | acpi_status status = AE_OK; |
661 | unsigned long flags = 0; | 565 | unsigned long flags = 0; |
662 | u32 glk = 0; | 566 | u32 glk = 0; |
663 | 567 | ||
664 | ACPI_FUNCTION_TRACE("acpi_ec_query"); | 568 | ACPI_FUNCTION_TRACE("acpi_ec_query"); |
665 | 569 | ||
@@ -681,7 +585,8 @@ acpi_ec_polling_query ( | |||
681 | */ | 585 | */ |
682 | spin_lock_irqsave(&ec->polling.lock, flags); | 586 | spin_lock_irqsave(&ec->polling.lock, flags); |
683 | 587 | ||
684 | 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); | ||
685 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); | 590 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); |
686 | if (result) | 591 | if (result) |
687 | goto end; | 592 | goto end; |
@@ -690,7 +595,7 @@ acpi_ec_polling_query ( | |||
690 | if (!*data) | 595 | if (!*data) |
691 | result = -ENODATA; | 596 | result = -ENODATA; |
692 | 597 | ||
693 | end: | 598 | end: |
694 | spin_unlock_irqrestore(&ec->polling.lock, flags); | 599 | spin_unlock_irqrestore(&ec->polling.lock, flags); |
695 | 600 | ||
696 | if (ec->common.global_lock) | 601 | if (ec->common.global_lock) |
@@ -698,13 +603,10 @@ end: | |||
698 | 603 | ||
699 | return_VALUE(result); | 604 | return_VALUE(result); |
700 | } | 605 | } |
701 | static int | 606 | static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data) |
702 | acpi_ec_burst_query ( | ||
703 | union acpi_ec *ec, | ||
704 | u32 *data) | ||
705 | { | 607 | { |
706 | int status = 0; | 608 | int status = 0; |
707 | u32 glk; | 609 | u32 glk; |
708 | 610 | ||
709 | ACPI_FUNCTION_TRACE("acpi_ec_query"); | 611 | ACPI_FUNCTION_TRACE("acpi_ec_query"); |
710 | 612 | ||
@@ -719,70 +621,64 @@ acpi_ec_burst_query ( | |||
719 | } | 621 | } |
720 | 622 | ||
721 | down(&ec->burst.sem); | 623 | down(&ec->burst.sem); |
722 | if(acpi_ec_enter_burst_mode(ec)) | 624 | |
625 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); | ||
626 | if (status) { | ||
627 | printk("query EC, IB not empty\n"); | ||
723 | goto end; | 628 | goto end; |
629 | } | ||
724 | /* | 630 | /* |
725 | * Query the EC to find out which _Qxx method we need to evaluate. | 631 | * Query the EC to find out which _Qxx method we need to evaluate. |
726 | * 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 |
727 | * bit to be cleared (and thus clearing the interrupt source). | 633 | * bit to be cleared (and thus clearing the interrupt source). |
728 | */ | 634 | */ |
729 | 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); | ||
730 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); | 637 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); |
731 | if (status){ | 638 | if (status) { |
732 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 639 | printk("query EC, OB not full\n"); |
733 | goto end; | 640 | goto end; |
734 | } | 641 | } |
735 | 642 | ||
736 | acpi_hw_low_level_read(8, data, &ec->common.data_addr); | 643 | acpi_hw_low_level_read(8, data, &ec->common.data_addr); |
737 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | ||
738 | if (!*data) | 644 | if (!*data) |
739 | status = -ENODATA; | 645 | status = -ENODATA; |
740 | 646 | ||
741 | end: | 647 | end: |
742 | acpi_ec_leave_burst_mode(ec); | ||
743 | up(&ec->burst.sem); | 648 | up(&ec->burst.sem); |
744 | 649 | ||
745 | if (ec->common.global_lock) | 650 | if (ec->common.global_lock) |
746 | acpi_release_global_lock(glk); | 651 | acpi_release_global_lock(glk); |
747 | 652 | ||
748 | if(atomic_read(&ec->burst.leaving_burst) == 2){ | ||
749 | ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); | ||
750 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | ||
751 | status = -ENODATA; | ||
752 | } | ||
753 | return_VALUE(status); | 653 | return_VALUE(status); |
754 | } | 654 | } |
755 | 655 | ||
756 | |||
757 | /* -------------------------------------------------------------------------- | 656 | /* -------------------------------------------------------------------------- |
758 | Event Management | 657 | Event Management |
759 | -------------------------------------------------------------------------- */ | 658 | -------------------------------------------------------------------------- */ |
760 | 659 | ||
761 | union acpi_ec_query_data { | 660 | union acpi_ec_query_data { |
762 | acpi_handle handle; | 661 | acpi_handle handle; |
763 | u8 data; | 662 | u8 data; |
764 | }; | 663 | }; |
765 | 664 | ||
766 | static void | 665 | static void acpi_ec_gpe_query(void *ec_cxt) |
767 | acpi_ec_gpe_query ( | ||
768 | void *ec_cxt) | ||
769 | { | 666 | { |
770 | if (acpi_ec_polling_mode) | 667 | if (acpi_ec_polling_mode) |
771 | acpi_ec_gpe_polling_query(ec_cxt); | 668 | acpi_ec_gpe_polling_query(ec_cxt); |
772 | else | 669 | else |
773 | acpi_ec_gpe_burst_query(ec_cxt); | 670 | acpi_ec_gpe_burst_query(ec_cxt); |
774 | } | 671 | } |
775 | 672 | ||
776 | static void | 673 | static void acpi_ec_gpe_polling_query(void *ec_cxt) |
777 | acpi_ec_gpe_polling_query ( | ||
778 | void *ec_cxt) | ||
779 | { | 674 | { |
780 | union acpi_ec *ec = (union acpi_ec *) ec_cxt; | 675 | union acpi_ec *ec = (union acpi_ec *)ec_cxt; |
781 | u32 value = 0; | 676 | u32 value = 0; |
782 | unsigned long flags = 0; | 677 | unsigned long flags = 0; |
783 | static char object_name[5] = {'_','Q','0','0','\0'}; | 678 | static char object_name[5] = { '_', 'Q', '0', '0', '\0' }; |
784 | const char hex[] = {'0','1','2','3','4','5','6','7', | 679 | const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', |
785 | '8','9','A','B','C','D','E','F'}; | 680 | '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' |
681 | }; | ||
786 | 682 | ||
787 | ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); | 683 | ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); |
788 | 684 | ||
@@ -812,19 +708,18 @@ acpi_ec_gpe_polling_query ( | |||
812 | 708 | ||
813 | acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); | 709 | acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); |
814 | 710 | ||
815 | end: | 711 | end: |
816 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 712 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); |
817 | } | 713 | } |
818 | static void | 714 | static void acpi_ec_gpe_burst_query(void *ec_cxt) |
819 | acpi_ec_gpe_burst_query ( | ||
820 | void *ec_cxt) | ||
821 | { | 715 | { |
822 | union acpi_ec *ec = (union acpi_ec *) ec_cxt; | 716 | union acpi_ec *ec = (union acpi_ec *)ec_cxt; |
823 | u32 value; | 717 | u32 value; |
824 | int result = -ENODATA; | 718 | int result = -ENODATA; |
825 | static char object_name[5] = {'_','Q','0','0','\0'}; | 719 | static char object_name[5] = { '_', 'Q', '0', '0', '\0' }; |
826 | const char hex[] = {'0','1','2','3','4','5','6','7', | 720 | const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', |
827 | '8','9','A','B','C','D','E','F'}; | 721 | '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' |
722 | }; | ||
828 | 723 | ||
829 | ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); | 724 | ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); |
830 | 725 | ||
@@ -840,26 +735,22 @@ acpi_ec_gpe_burst_query ( | |||
840 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); | 735 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); |
841 | 736 | ||
842 | acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); | 737 | acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); |
843 | end: | 738 | end: |
844 | atomic_dec(&ec->burst.pending_gpe); | 739 | atomic_dec(&ec->burst.pending_gpe); |
845 | return; | 740 | return; |
846 | } | 741 | } |
847 | 742 | ||
848 | static u32 | 743 | static u32 acpi_ec_gpe_handler(void *data) |
849 | acpi_ec_gpe_handler ( | ||
850 | void *data) | ||
851 | { | 744 | { |
852 | if (acpi_ec_polling_mode) | 745 | if (acpi_ec_polling_mode) |
853 | return acpi_ec_gpe_polling_handler(data); | 746 | return acpi_ec_gpe_polling_handler(data); |
854 | else | 747 | else |
855 | return acpi_ec_gpe_burst_handler(data); | 748 | return acpi_ec_gpe_burst_handler(data); |
856 | } | 749 | } |
857 | static u32 | 750 | static u32 acpi_ec_gpe_polling_handler(void *data) |
858 | acpi_ec_gpe_polling_handler ( | ||
859 | void *data) | ||
860 | { | 751 | { |
861 | acpi_status status = AE_OK; | 752 | acpi_status status = AE_OK; |
862 | union acpi_ec *ec = (union acpi_ec *) data; | 753 | union acpi_ec *ec = (union acpi_ec *)data; |
863 | 754 | ||
864 | if (!ec) | 755 | if (!ec) |
865 | return ACPI_INTERRUPT_NOT_HANDLED; | 756 | return ACPI_INTERRUPT_NOT_HANDLED; |
@@ -867,61 +758,49 @@ acpi_ec_gpe_polling_handler ( | |||
867 | acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); | 758 | acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); |
868 | 759 | ||
869 | status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, | 760 | status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, |
870 | acpi_ec_gpe_query, ec); | 761 | acpi_ec_gpe_query, ec); |
871 | 762 | ||
872 | if (status == AE_OK) | 763 | if (status == AE_OK) |
873 | return ACPI_INTERRUPT_HANDLED; | 764 | return ACPI_INTERRUPT_HANDLED; |
874 | else | 765 | else |
875 | return ACPI_INTERRUPT_NOT_HANDLED; | 766 | return ACPI_INTERRUPT_NOT_HANDLED; |
876 | } | 767 | } |
877 | static u32 | 768 | static u32 acpi_ec_gpe_burst_handler(void *data) |
878 | acpi_ec_gpe_burst_handler ( | ||
879 | void *data) | ||
880 | { | 769 | { |
881 | acpi_status status = AE_OK; | 770 | acpi_status status = AE_OK; |
882 | u32 value; | 771 | u32 value; |
883 | union acpi_ec *ec = (union acpi_ec *) data; | 772 | union acpi_ec *ec = (union acpi_ec *)data; |
884 | 773 | ||
885 | if (!ec) | 774 | if (!ec) |
886 | return ACPI_INTERRUPT_NOT_HANDLED; | 775 | return ACPI_INTERRUPT_NOT_HANDLED; |
887 | 776 | ||
888 | acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); | 777 | acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); |
889 | |||
890 | value = acpi_ec_read_status(ec); | 778 | value = acpi_ec_read_status(ec); |
891 | 779 | ||
892 | if((value & ACPI_EC_FLAG_IBF) && | 780 | switch (ec->burst.expect_event) { |
893 | !(value & ACPI_EC_FLAG_BURST) && | 781 | case ACPI_EC_EVENT_OBF: |
894 | (atomic_read(&ec->burst.leaving_burst) == 0)) { | 782 | if (!(value & ACPI_EC_FLAG_OBF)) |
895 | /* | 783 | break; |
896 | * the embedded controller disables | 784 | case ACPI_EC_EVENT_IBE: |
897 | * burst mode for any reason other | 785 | if ((value & ACPI_EC_FLAG_IBF)) |
898 | * than the burst disable command | 786 | break; |
899 | * to process critical event. | 787 | ec->burst.expect_event = 0; |
900 | */ | ||
901 | atomic_set(&ec->burst.leaving_burst , 2); /* block current pending transaction | ||
902 | and retry */ | ||
903 | wake_up(&ec->burst.wait); | 788 | wake_up(&ec->burst.wait); |
904 | }else { | 789 | return ACPI_INTERRUPT_HANDLED; |
905 | if ((ec->burst.expect_event == ACPI_EC_EVENT_OBF && | 790 | default: |
906 | (value & ACPI_EC_FLAG_OBF)) || | 791 | break; |
907 | (ec->burst.expect_event == ACPI_EC_EVENT_IBE && | ||
908 | !(value & ACPI_EC_FLAG_IBF))) { | ||
909 | ec->burst.expect_event = 0; | ||
910 | wake_up(&ec->burst.wait); | ||
911 | return ACPI_INTERRUPT_HANDLED; | ||
912 | } | ||
913 | } | 792 | } |
914 | 793 | ||
915 | if (value & ACPI_EC_FLAG_SCI){ | 794 | if (value & ACPI_EC_FLAG_SCI) { |
916 | atomic_add(1, &ec->burst.pending_gpe) ; | 795 | atomic_add(1, &ec->burst.pending_gpe); |
917 | status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, | 796 | status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, |
918 | acpi_ec_gpe_query, ec); | 797 | acpi_ec_gpe_query, ec); |
919 | return status == AE_OK ? | 798 | return status == AE_OK ? |
920 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; | 799 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; |
921 | } | 800 | } |
922 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); | 801 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); |
923 | return status == AE_OK ? | 802 | return status == AE_OK ? |
924 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; | 803 | ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; |
925 | } | 804 | } |
926 | 805 | ||
927 | /* -------------------------------------------------------------------------- | 806 | /* -------------------------------------------------------------------------- |
@@ -929,37 +808,31 @@ acpi_ec_gpe_burst_handler ( | |||
929 | -------------------------------------------------------------------------- */ | 808 | -------------------------------------------------------------------------- */ |
930 | 809 | ||
931 | static acpi_status | 810 | static acpi_status |
932 | acpi_ec_space_setup ( | 811 | acpi_ec_space_setup(acpi_handle region_handle, |
933 | acpi_handle region_handle, | 812 | u32 function, void *handler_context, void **return_context) |
934 | u32 function, | ||
935 | void *handler_context, | ||
936 | void **return_context) | ||
937 | { | 813 | { |
938 | /* | 814 | /* |
939 | * The EC object is in the handler context and is needed | 815 | * The EC object is in the handler context and is needed |
940 | * when calling the acpi_ec_space_handler. | 816 | * when calling the acpi_ec_space_handler. |
941 | */ | 817 | */ |
942 | *return_context = (function != ACPI_REGION_DEACTIVATE) ? | 818 | *return_context = (function != ACPI_REGION_DEACTIVATE) ? |
943 | handler_context : NULL; | 819 | handler_context : NULL; |
944 | 820 | ||
945 | return AE_OK; | 821 | return AE_OK; |
946 | } | 822 | } |
947 | 823 | ||
948 | |||
949 | static acpi_status | 824 | static acpi_status |
950 | acpi_ec_space_handler ( | 825 | acpi_ec_space_handler(u32 function, |
951 | u32 function, | 826 | acpi_physical_address address, |
952 | acpi_physical_address address, | 827 | u32 bit_width, |
953 | u32 bit_width, | 828 | acpi_integer * value, |
954 | acpi_integer *value, | 829 | void *handler_context, void *region_context) |
955 | void *handler_context, | ||
956 | void *region_context) | ||
957 | { | 830 | { |
958 | int result = 0; | 831 | int result = 0; |
959 | union acpi_ec *ec = NULL; | 832 | union acpi_ec *ec = NULL; |
960 | u64 temp = *value; | 833 | u64 temp = *value; |
961 | acpi_integer f_v = 0; | 834 | acpi_integer f_v = 0; |
962 | int i = 0; | 835 | int i = 0; |
963 | 836 | ||
964 | ACPI_FUNCTION_TRACE("acpi_ec_space_handler"); | 837 | ACPI_FUNCTION_TRACE("acpi_ec_space_handler"); |
965 | 838 | ||
@@ -967,17 +840,18 @@ acpi_ec_space_handler ( | |||
967 | return_VALUE(AE_BAD_PARAMETER); | 840 | return_VALUE(AE_BAD_PARAMETER); |
968 | 841 | ||
969 | if (bit_width != 8 && acpi_strict) { | 842 | if (bit_width != 8 && acpi_strict) { |
970 | 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"); | ||
971 | return_VALUE(AE_BAD_PARAMETER); | 845 | return_VALUE(AE_BAD_PARAMETER); |
972 | } | 846 | } |
973 | 847 | ||
974 | ec = (union acpi_ec *) handler_context; | 848 | ec = (union acpi_ec *)handler_context; |
975 | 849 | ||
976 | next_byte: | 850 | next_byte: |
977 | switch (function) { | 851 | switch (function) { |
978 | case ACPI_READ: | 852 | case ACPI_READ: |
979 | temp = 0; | 853 | temp = 0; |
980 | result = acpi_ec_read(ec, (u8) address, (u32 *)&temp); | 854 | result = acpi_ec_read(ec, (u8) address, (u32 *) & temp); |
981 | break; | 855 | break; |
982 | case ACPI_WRITE: | 856 | case ACPI_WRITE: |
983 | result = acpi_ec_write(ec, (u8) address, (u8) temp); | 857 | result = acpi_ec_write(ec, (u8) address, (u8) temp); |
@@ -1004,8 +878,7 @@ next_byte: | |||
1004 | *value = f_v; | 878 | *value = f_v; |
1005 | } | 879 | } |
1006 | 880 | ||
1007 | 881 | out: | |
1008 | out: | ||
1009 | switch (result) { | 882 | switch (result) { |
1010 | case -EINVAL: | 883 | case -EINVAL: |
1011 | return_VALUE(AE_BAD_PARAMETER); | 884 | return_VALUE(AE_BAD_PARAMETER); |
@@ -1021,18 +894,15 @@ out: | |||
1021 | } | 894 | } |
1022 | } | 895 | } |
1023 | 896 | ||
1024 | |||
1025 | /* -------------------------------------------------------------------------- | 897 | /* -------------------------------------------------------------------------- |
1026 | FS Interface (/proc) | 898 | FS Interface (/proc) |
1027 | -------------------------------------------------------------------------- */ | 899 | -------------------------------------------------------------------------- */ |
1028 | 900 | ||
1029 | static struct proc_dir_entry *acpi_ec_dir; | 901 | static struct proc_dir_entry *acpi_ec_dir; |
1030 | |||
1031 | 902 | ||
1032 | static int | 903 | static int acpi_ec_read_info(struct seq_file *seq, void *offset) |
1033 | acpi_ec_read_info (struct seq_file *seq, void *offset) | ||
1034 | { | 904 | { |
1035 | union acpi_ec *ec = (union acpi_ec *) seq->private; | 905 | union acpi_ec *ec = (union acpi_ec *)seq->private; |
1036 | 906 | ||
1037 | ACPI_FUNCTION_TRACE("acpi_ec_read_info"); | 907 | ACPI_FUNCTION_TRACE("acpi_ec_read_info"); |
1038 | 908 | ||
@@ -1040,14 +910,15 @@ acpi_ec_read_info (struct seq_file *seq, void *offset) | |||
1040 | goto end; | 910 | goto end; |
1041 | 911 | ||
1042 | seq_printf(seq, "gpe bit: 0x%02x\n", | 912 | seq_printf(seq, "gpe bit: 0x%02x\n", |
1043 | (u32) ec->common.gpe_bit); | 913 | (u32) ec->common.gpe_bit); |
1044 | seq_printf(seq, "ports: 0x%02x, 0x%02x\n", | 914 | seq_printf(seq, "ports: 0x%02x, 0x%02x\n", |
1045 | (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); | ||
1046 | seq_printf(seq, "use global lock: %s\n", | 917 | seq_printf(seq, "use global lock: %s\n", |
1047 | ec->common.global_lock?"yes":"no"); | 918 | ec->common.global_lock ? "yes" : "no"); |
1048 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 919 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); |
1049 | 920 | ||
1050 | end: | 921 | end: |
1051 | return_VALUE(0); | 922 | return_VALUE(0); |
1052 | } | 923 | } |
1053 | 924 | ||
@@ -1057,34 +928,32 @@ static int acpi_ec_info_open_fs(struct inode *inode, struct file *file) | |||
1057 | } | 928 | } |
1058 | 929 | ||
1059 | static struct file_operations acpi_ec_info_ops = { | 930 | static struct file_operations acpi_ec_info_ops = { |
1060 | .open = acpi_ec_info_open_fs, | 931 | .open = acpi_ec_info_open_fs, |
1061 | .read = seq_read, | 932 | .read = seq_read, |
1062 | .llseek = seq_lseek, | 933 | .llseek = seq_lseek, |
1063 | .release = single_release, | 934 | .release = single_release, |
1064 | .owner = THIS_MODULE, | 935 | .owner = THIS_MODULE, |
1065 | }; | 936 | }; |
1066 | 937 | ||
1067 | static int | 938 | static int acpi_ec_add_fs(struct acpi_device *device) |
1068 | acpi_ec_add_fs ( | ||
1069 | struct acpi_device *device) | ||
1070 | { | 939 | { |
1071 | struct proc_dir_entry *entry = NULL; | 940 | struct proc_dir_entry *entry = NULL; |
1072 | 941 | ||
1073 | ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); | 942 | ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); |
1074 | 943 | ||
1075 | if (!acpi_device_dir(device)) { | 944 | if (!acpi_device_dir(device)) { |
1076 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), | 945 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), |
1077 | acpi_ec_dir); | 946 | acpi_ec_dir); |
1078 | if (!acpi_device_dir(device)) | 947 | if (!acpi_device_dir(device)) |
1079 | return_VALUE(-ENODEV); | 948 | return_VALUE(-ENODEV); |
1080 | } | 949 | } |
1081 | 950 | ||
1082 | entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, | 951 | entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, |
1083 | acpi_device_dir(device)); | 952 | acpi_device_dir(device)); |
1084 | if (!entry) | 953 | if (!entry) |
1085 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, | 954 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, |
1086 | "Unable to create '%s' fs entry\n", | 955 | "Unable to create '%s' fs entry\n", |
1087 | ACPI_EC_FILE_INFO)); | 956 | ACPI_EC_FILE_INFO)); |
1088 | else { | 957 | else { |
1089 | entry->proc_fops = &acpi_ec_info_ops; | 958 | entry->proc_fops = &acpi_ec_info_ops; |
1090 | entry->data = acpi_driver_data(device); | 959 | entry->data = acpi_driver_data(device); |
@@ -1094,10 +963,7 @@ acpi_ec_add_fs ( | |||
1094 | return_VALUE(0); | 963 | return_VALUE(0); |
1095 | } | 964 | } |
1096 | 965 | ||
1097 | 966 | static int acpi_ec_remove_fs(struct acpi_device *device) | |
1098 | static int | ||
1099 | acpi_ec_remove_fs ( | ||
1100 | struct acpi_device *device) | ||
1101 | { | 967 | { |
1102 | ACPI_FUNCTION_TRACE("acpi_ec_remove_fs"); | 968 | ACPI_FUNCTION_TRACE("acpi_ec_remove_fs"); |
1103 | 969 | ||
@@ -1110,20 +976,16 @@ acpi_ec_remove_fs ( | |||
1110 | return_VALUE(0); | 976 | return_VALUE(0); |
1111 | } | 977 | } |
1112 | 978 | ||
1113 | |||
1114 | /* -------------------------------------------------------------------------- | 979 | /* -------------------------------------------------------------------------- |
1115 | Driver Interface | 980 | Driver Interface |
1116 | -------------------------------------------------------------------------- */ | 981 | -------------------------------------------------------------------------- */ |
1117 | 982 | ||
1118 | 983 | static int acpi_ec_polling_add(struct acpi_device *device) | |
1119 | static int | ||
1120 | acpi_ec_polling_add ( | ||
1121 | struct acpi_device *device) | ||
1122 | { | 984 | { |
1123 | int result = 0; | 985 | int result = 0; |
1124 | acpi_status status = AE_OK; | 986 | acpi_status status = AE_OK; |
1125 | union acpi_ec *ec = NULL; | 987 | union acpi_ec *ec = NULL; |
1126 | unsigned long uid; | 988 | unsigned long uid; |
1127 | 989 | ||
1128 | ACPI_FUNCTION_TRACE("acpi_ec_add"); | 990 | ACPI_FUNCTION_TRACE("acpi_ec_add"); |
1129 | 991 | ||
@@ -1143,26 +1005,31 @@ acpi_ec_polling_add ( | |||
1143 | acpi_driver_data(device) = ec; | 1005 | acpi_driver_data(device) = ec; |
1144 | 1006 | ||
1145 | /* Use the global lock for all EC transactions? */ | 1007 | /* Use the global lock for all EC transactions? */ |
1146 | 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); | ||
1147 | 1010 | ||
1148 | /* If our UID matches the UID for the ECDT-enumerated EC, | 1011 | /* If our UID matches the UID for the ECDT-enumerated EC, |
1149 | 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. */ |
1150 | acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); | 1013 | acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); |
1151 | if (ec_ecdt && ec_ecdt->common.uid == uid) { | 1014 | if (ec_ecdt && ec_ecdt->common.uid == uid) { |
1152 | acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, | 1015 | acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, |
1153 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); | 1016 | ACPI_ADR_SPACE_EC, |
1154 | 1017 | &acpi_ec_space_handler); | |
1155 | 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); | ||
1156 | 1021 | ||
1157 | kfree(ec_ecdt); | 1022 | kfree(ec_ecdt); |
1158 | } | 1023 | } |
1159 | 1024 | ||
1160 | /* Get GPE bit assignment (EC events). */ | 1025 | /* Get GPE bit assignment (EC events). */ |
1161 | /* TODO: Add support for _GPE returning a package */ | 1026 | /* TODO: Add support for _GPE returning a package */ |
1162 | 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); | ||
1163 | if (ACPI_FAILURE(status)) { | 1030 | if (ACPI_FAILURE(status)) { |
1164 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 1031 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
1165 | "Error obtaining GPE bit assignment\n")); | 1032 | "Error obtaining GPE bit assignment\n")); |
1166 | result = -ENODEV; | 1033 | result = -ENODEV; |
1167 | goto end; | 1034 | goto end; |
1168 | } | 1035 | } |
@@ -1172,26 +1039,24 @@ acpi_ec_polling_add ( | |||
1172 | goto end; | 1039 | goto end; |
1173 | 1040 | ||
1174 | printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", | 1041 | printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", |
1175 | acpi_device_name(device), acpi_device_bid(device), | 1042 | acpi_device_name(device), acpi_device_bid(device), |
1176 | (u32) ec->common.gpe_bit); | 1043 | (u32) ec->common.gpe_bit); |
1177 | 1044 | ||
1178 | if (!first_ec) | 1045 | if (!first_ec) |
1179 | first_ec = device; | 1046 | first_ec = device; |
1180 | 1047 | ||
1181 | end: | 1048 | end: |
1182 | if (result) | 1049 | if (result) |
1183 | kfree(ec); | 1050 | kfree(ec); |
1184 | 1051 | ||
1185 | return_VALUE(result); | 1052 | return_VALUE(result); |
1186 | } | 1053 | } |
1187 | static int | 1054 | static int acpi_ec_burst_add(struct acpi_device *device) |
1188 | acpi_ec_burst_add ( | ||
1189 | struct acpi_device *device) | ||
1190 | { | 1055 | { |
1191 | int result = 0; | 1056 | int result = 0; |
1192 | acpi_status status = AE_OK; | 1057 | acpi_status status = AE_OK; |
1193 | union acpi_ec *ec = NULL; | 1058 | union acpi_ec *ec = NULL; |
1194 | unsigned long uid; | 1059 | unsigned long uid; |
1195 | 1060 | ||
1196 | ACPI_FUNCTION_TRACE("acpi_ec_add"); | 1061 | ACPI_FUNCTION_TRACE("acpi_ec_add"); |
1197 | 1062 | ||
@@ -1205,35 +1070,40 @@ acpi_ec_burst_add ( | |||
1205 | 1070 | ||
1206 | ec->common.handle = device->handle; | 1071 | ec->common.handle = device->handle; |
1207 | ec->common.uid = -1; | 1072 | ec->common.uid = -1; |
1208 | atomic_set(&ec->burst.pending_gpe, 0); | 1073 | atomic_set(&ec->burst.pending_gpe, 0); |
1209 | atomic_set(&ec->burst.leaving_burst , 1); | 1074 | atomic_set(&ec->burst.leaving_burst, 1); |
1210 | init_MUTEX(&ec->burst.sem); | 1075 | init_MUTEX(&ec->burst.sem); |
1211 | init_waitqueue_head(&ec->burst.wait); | 1076 | init_waitqueue_head(&ec->burst.wait); |
1212 | strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); | 1077 | strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); |
1213 | strcpy(acpi_device_class(device), ACPI_EC_CLASS); | 1078 | strcpy(acpi_device_class(device), ACPI_EC_CLASS); |
1214 | acpi_driver_data(device) = ec; | 1079 | acpi_driver_data(device) = ec; |
1215 | 1080 | ||
1216 | /* Use the global lock for all EC transactions? */ | 1081 | /* Use the global lock for all EC transactions? */ |
1217 | 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); | ||
1218 | 1084 | ||
1219 | /* If our UID matches the UID for the ECDT-enumerated EC, | 1085 | /* If our UID matches the UID for the ECDT-enumerated EC, |
1220 | 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. */ |
1221 | acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); | 1087 | acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); |
1222 | if (ec_ecdt && ec_ecdt->common.uid == uid) { | 1088 | if (ec_ecdt && ec_ecdt->common.uid == uid) { |
1223 | acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, | 1089 | acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, |
1224 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); | 1090 | ACPI_ADR_SPACE_EC, |
1091 | &acpi_ec_space_handler); | ||
1225 | 1092 | ||
1226 | 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); | ||
1227 | 1095 | ||
1228 | kfree(ec_ecdt); | 1096 | kfree(ec_ecdt); |
1229 | } | 1097 | } |
1230 | 1098 | ||
1231 | /* Get GPE bit assignment (EC events). */ | 1099 | /* Get GPE bit assignment (EC events). */ |
1232 | /* TODO: Add support for _GPE returning a package */ | 1100 | /* TODO: Add support for _GPE returning a package */ |
1233 | 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); | ||
1234 | if (ACPI_FAILURE(status)) { | 1104 | if (ACPI_FAILURE(status)) { |
1235 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 1105 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
1236 | "Error obtaining GPE bit assignment\n")); | 1106 | "Error obtaining GPE bit assignment\n")); |
1237 | result = -ENODEV; | 1107 | result = -ENODEV; |
1238 | goto end; | 1108 | goto end; |
1239 | } | 1109 | } |
@@ -1242,27 +1112,24 @@ acpi_ec_burst_add ( | |||
1242 | if (result) | 1112 | if (result) |
1243 | goto end; | 1113 | goto end; |
1244 | 1114 | ||
1115 | printk("burst-mode-ec-10-Aug\n"); | ||
1245 | printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", | 1116 | printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", |
1246 | acpi_device_name(device), acpi_device_bid(device), | 1117 | acpi_device_name(device), acpi_device_bid(device), |
1247 | (u32) ec->common.gpe_bit); | 1118 | (u32) ec->common.gpe_bit); |
1248 | 1119 | ||
1249 | if (!first_ec) | 1120 | if (!first_ec) |
1250 | first_ec = device; | 1121 | first_ec = device; |
1251 | 1122 | ||
1252 | end: | 1123 | end: |
1253 | if (result) | 1124 | if (result) |
1254 | kfree(ec); | 1125 | kfree(ec); |
1255 | 1126 | ||
1256 | return_VALUE(result); | 1127 | return_VALUE(result); |
1257 | } | 1128 | } |
1258 | 1129 | ||
1259 | 1130 | static int acpi_ec_remove(struct acpi_device *device, int type) | |
1260 | static int | ||
1261 | acpi_ec_remove ( | ||
1262 | struct acpi_device *device, | ||
1263 | int type) | ||
1264 | { | 1131 | { |
1265 | union acpi_ec *ec = NULL; | 1132 | union acpi_ec *ec = NULL; |
1266 | 1133 | ||
1267 | ACPI_FUNCTION_TRACE("acpi_ec_remove"); | 1134 | ACPI_FUNCTION_TRACE("acpi_ec_remove"); |
1268 | 1135 | ||
@@ -1278,13 +1145,10 @@ acpi_ec_remove ( | |||
1278 | return_VALUE(0); | 1145 | return_VALUE(0); |
1279 | } | 1146 | } |
1280 | 1147 | ||
1281 | |||
1282 | static acpi_status | 1148 | static acpi_status |
1283 | acpi_ec_io_ports ( | 1149 | acpi_ec_io_ports(struct acpi_resource *resource, void *context) |
1284 | struct acpi_resource *resource, | ||
1285 | void *context) | ||
1286 | { | 1150 | { |
1287 | union acpi_ec *ec = (union acpi_ec *) context; | 1151 | union acpi_ec *ec = (union acpi_ec *)context; |
1288 | struct acpi_generic_address *addr; | 1152 | struct acpi_generic_address *addr; |
1289 | 1153 | ||
1290 | if (resource->id != ACPI_RSTYPE_IO) { | 1154 | if (resource->id != ACPI_RSTYPE_IO) { |
@@ -1312,13 +1176,10 @@ acpi_ec_io_ports ( | |||
1312 | return AE_OK; | 1176 | return AE_OK; |
1313 | } | 1177 | } |
1314 | 1178 | ||
1315 | 1179 | static int acpi_ec_start(struct acpi_device *device) | |
1316 | static int | ||
1317 | acpi_ec_start ( | ||
1318 | struct acpi_device *device) | ||
1319 | { | 1180 | { |
1320 | acpi_status status = AE_OK; | 1181 | acpi_status status = AE_OK; |
1321 | union acpi_ec *ec = NULL; | 1182 | union acpi_ec *ec = NULL; |
1322 | 1183 | ||
1323 | ACPI_FUNCTION_TRACE("acpi_ec_start"); | 1184 | ACPI_FUNCTION_TRACE("acpi_ec_start"); |
1324 | 1185 | ||
@@ -1334,49 +1195,50 @@ acpi_ec_start ( | |||
1334 | * Get I/O port addresses. Convert to GAS format. | 1195 | * Get I/O port addresses. Convert to GAS format. |
1335 | */ | 1196 | */ |
1336 | status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS, | 1197 | status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS, |
1337 | acpi_ec_io_ports, ec); | 1198 | acpi_ec_io_ports, ec); |
1338 | if (ACPI_FAILURE(status) || ec->common.command_addr.register_bit_width == 0) { | 1199 | if (ACPI_FAILURE(status) |
1339 | 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")); | ||
1340 | return_VALUE(-ENODEV); | 1203 | return_VALUE(-ENODEV); |
1341 | } | 1204 | } |
1342 | 1205 | ||
1343 | ec->common.status_addr = ec->common.command_addr; | 1206 | ec->common.status_addr = ec->common.command_addr; |
1344 | 1207 | ||
1345 | 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", |
1346 | (u32) ec->common.gpe_bit, (u32) ec->common.command_addr.address, | 1209 | (u32) ec->common.gpe_bit, |
1347 | (u32) ec->common.data_addr.address)); | 1210 | (u32) ec->common.command_addr.address, |
1348 | 1211 | (u32) ec->common.data_addr.address)); | |
1349 | 1212 | ||
1350 | /* | 1213 | /* |
1351 | * Install GPE handler | 1214 | * Install GPE handler |
1352 | */ | 1215 | */ |
1353 | status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit, | 1216 | status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit, |
1354 | ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec); | 1217 | ACPI_GPE_EDGE_TRIGGERED, |
1218 | &acpi_ec_gpe_handler, ec); | ||
1355 | if (ACPI_FAILURE(status)) { | 1219 | if (ACPI_FAILURE(status)) { |
1356 | return_VALUE(-ENODEV); | 1220 | return_VALUE(-ENODEV); |
1357 | } | 1221 | } |
1358 | 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); |
1359 | acpi_enable_gpe (NULL, ec->common.gpe_bit, ACPI_NOT_ISR); | 1223 | acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); |
1360 | 1224 | ||
1361 | status = acpi_install_address_space_handler (ec->common.handle, | 1225 | status = acpi_install_address_space_handler(ec->common.handle, |
1362 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, | 1226 | ACPI_ADR_SPACE_EC, |
1363 | &acpi_ec_space_setup, ec); | 1227 | &acpi_ec_space_handler, |
1228 | &acpi_ec_space_setup, ec); | ||
1364 | if (ACPI_FAILURE(status)) { | 1229 | if (ACPI_FAILURE(status)) { |
1365 | 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); | ||
1366 | return_VALUE(-ENODEV); | 1232 | return_VALUE(-ENODEV); |
1367 | } | 1233 | } |
1368 | 1234 | ||
1369 | return_VALUE(AE_OK); | 1235 | return_VALUE(AE_OK); |
1370 | } | 1236 | } |
1371 | 1237 | ||
1372 | 1238 | static int acpi_ec_stop(struct acpi_device *device, int type) | |
1373 | static int | ||
1374 | acpi_ec_stop ( | ||
1375 | struct acpi_device *device, | ||
1376 | int type) | ||
1377 | { | 1239 | { |
1378 | acpi_status status = AE_OK; | 1240 | acpi_status status = AE_OK; |
1379 | union acpi_ec *ec = NULL; | 1241 | union acpi_ec *ec = NULL; |
1380 | 1242 | ||
1381 | ACPI_FUNCTION_TRACE("acpi_ec_stop"); | 1243 | ACPI_FUNCTION_TRACE("acpi_ec_stop"); |
1382 | 1244 | ||
@@ -1386,11 +1248,14 @@ acpi_ec_stop ( | |||
1386 | ec = acpi_driver_data(device); | 1248 | ec = acpi_driver_data(device); |
1387 | 1249 | ||
1388 | status = acpi_remove_address_space_handler(ec->common.handle, | 1250 | status = acpi_remove_address_space_handler(ec->common.handle, |
1389 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); | 1251 | ACPI_ADR_SPACE_EC, |
1252 | &acpi_ec_space_handler); | ||
1390 | if (ACPI_FAILURE(status)) | 1253 | if (ACPI_FAILURE(status)) |
1391 | return_VALUE(-ENODEV); | 1254 | return_VALUE(-ENODEV); |
1392 | 1255 | ||
1393 | 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); | ||
1394 | if (ACPI_FAILURE(status)) | 1259 | if (ACPI_FAILURE(status)) |
1395 | return_VALUE(-ENODEV); | 1260 | return_VALUE(-ENODEV); |
1396 | 1261 | ||
@@ -1398,32 +1263,26 @@ acpi_ec_stop ( | |||
1398 | } | 1263 | } |
1399 | 1264 | ||
1400 | static acpi_status __init | 1265 | static acpi_status __init |
1401 | acpi_fake_ecdt_callback ( | 1266 | acpi_fake_ecdt_callback(acpi_handle handle, |
1402 | acpi_handle handle, | 1267 | u32 Level, void *context, void **retval) |
1403 | u32 Level, | ||
1404 | void *context, | ||
1405 | void **retval) | ||
1406 | { | 1268 | { |
1407 | 1269 | ||
1408 | if (acpi_ec_polling_mode) | 1270 | if (acpi_ec_polling_mode) |
1409 | return acpi_fake_ecdt_polling_callback(handle, | 1271 | return acpi_fake_ecdt_polling_callback(handle, |
1410 | Level, context, retval); | 1272 | Level, context, retval); |
1411 | else | 1273 | else |
1412 | return acpi_fake_ecdt_burst_callback(handle, | 1274 | return acpi_fake_ecdt_burst_callback(handle, |
1413 | Level, context, retval); | 1275 | Level, context, retval); |
1414 | } | 1276 | } |
1415 | 1277 | ||
1416 | static acpi_status __init | 1278 | static acpi_status __init |
1417 | acpi_fake_ecdt_polling_callback ( | 1279 | acpi_fake_ecdt_polling_callback(acpi_handle handle, |
1418 | acpi_handle handle, | 1280 | u32 Level, void *context, void **retval) |
1419 | u32 Level, | ||
1420 | void *context, | ||
1421 | void **retval) | ||
1422 | { | 1281 | { |
1423 | acpi_status status; | 1282 | acpi_status status; |
1424 | 1283 | ||
1425 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | 1284 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
1426 | acpi_ec_io_ports, ec_ecdt); | 1285 | acpi_ec_io_ports, ec_ecdt); |
1427 | if (ACPI_FAILURE(status)) | 1286 | if (ACPI_FAILURE(status)) |
1428 | return status; | 1287 | return status; |
1429 | ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; | 1288 | ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; |
@@ -1431,33 +1290,33 @@ acpi_fake_ecdt_polling_callback ( | |||
1431 | ec_ecdt->common.uid = -1; | 1290 | ec_ecdt->common.uid = -1; |
1432 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); | 1291 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); |
1433 | 1292 | ||
1434 | 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); | ||
1435 | if (ACPI_FAILURE(status)) | 1296 | if (ACPI_FAILURE(status)) |
1436 | return status; | 1297 | return status; |
1437 | spin_lock_init(&ec_ecdt->polling.lock); | 1298 | spin_lock_init(&ec_ecdt->polling.lock); |
1438 | ec_ecdt->common.global_lock = TRUE; | 1299 | ec_ecdt->common.global_lock = TRUE; |
1439 | ec_ecdt->common.handle = handle; | 1300 | ec_ecdt->common.handle = handle; |
1440 | 1301 | ||
1441 | 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", |
1442 | (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address, | 1303 | (u32) ec_ecdt->common.gpe_bit, |
1443 | (u32) ec_ecdt->common.data_addr.address); | 1304 | (u32) ec_ecdt->common.command_addr.address, |
1305 | (u32) ec_ecdt->common.data_addr.address); | ||
1444 | 1306 | ||
1445 | return AE_CTRL_TERMINATE; | 1307 | return AE_CTRL_TERMINATE; |
1446 | } | 1308 | } |
1447 | 1309 | ||
1448 | static acpi_status __init | 1310 | static acpi_status __init |
1449 | acpi_fake_ecdt_burst_callback ( | 1311 | acpi_fake_ecdt_burst_callback(acpi_handle handle, |
1450 | acpi_handle handle, | 1312 | u32 Level, void *context, void **retval) |
1451 | u32 Level, | ||
1452 | void *context, | ||
1453 | void **retval) | ||
1454 | { | 1313 | { |
1455 | acpi_status status; | 1314 | acpi_status status; |
1456 | 1315 | ||
1457 | init_MUTEX(&ec_ecdt->burst.sem); | 1316 | init_MUTEX(&ec_ecdt->burst.sem); |
1458 | init_waitqueue_head(&ec_ecdt->burst.wait); | 1317 | init_waitqueue_head(&ec_ecdt->burst.wait); |
1459 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | 1318 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, |
1460 | acpi_ec_io_ports, ec_ecdt); | 1319 | acpi_ec_io_ports, ec_ecdt); |
1461 | if (ACPI_FAILURE(status)) | 1320 | if (ACPI_FAILURE(status)) |
1462 | return status; | 1321 | return status; |
1463 | ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; | 1322 | ec_ecdt->common.status_addr = ec_ecdt->common.command_addr; |
@@ -1465,15 +1324,18 @@ acpi_fake_ecdt_burst_callback ( | |||
1465 | ec_ecdt->common.uid = -1; | 1324 | ec_ecdt->common.uid = -1; |
1466 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); | 1325 | acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); |
1467 | 1326 | ||
1468 | 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); | ||
1469 | if (ACPI_FAILURE(status)) | 1330 | if (ACPI_FAILURE(status)) |
1470 | return status; | 1331 | return status; |
1471 | ec_ecdt->common.global_lock = TRUE; | 1332 | ec_ecdt->common.global_lock = TRUE; |
1472 | ec_ecdt->common.handle = handle; | 1333 | ec_ecdt->common.handle = handle; |
1473 | 1334 | ||
1474 | 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", |
1475 | (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address, | 1336 | (u32) ec_ecdt->common.gpe_bit, |
1476 | (u32) ec_ecdt->common.data_addr.address); | 1337 | (u32) ec_ecdt->common.command_addr.address, |
1338 | (u32) ec_ecdt->common.data_addr.address); | ||
1477 | 1339 | ||
1478 | return AE_CTRL_TERMINATE; | 1340 | return AE_CTRL_TERMINATE; |
1479 | } | 1341 | } |
@@ -1488,11 +1350,10 @@ acpi_fake_ecdt_burst_callback ( | |||
1488 | * 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 |
1489 | * all systems found. | 1351 | * all systems found. |
1490 | */ | 1352 | */ |
1491 | static int __init | 1353 | static int __init acpi_ec_fake_ecdt(void) |
1492 | acpi_ec_fake_ecdt(void) | ||
1493 | { | 1354 | { |
1494 | acpi_status status; | 1355 | acpi_status status; |
1495 | int ret = 0; | 1356 | int ret = 0; |
1496 | 1357 | ||
1497 | printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); | 1358 | printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); |
1498 | 1359 | ||
@@ -1503,10 +1364,8 @@ acpi_ec_fake_ecdt(void) | |||
1503 | } | 1364 | } |
1504 | memset(ec_ecdt, 0, sizeof(union acpi_ec)); | 1365 | memset(ec_ecdt, 0, sizeof(union acpi_ec)); |
1505 | 1366 | ||
1506 | status = acpi_get_devices (ACPI_EC_HID, | 1367 | status = acpi_get_devices(ACPI_EC_HID, |
1507 | acpi_fake_ecdt_callback, | 1368 | acpi_fake_ecdt_callback, NULL, NULL); |
1508 | NULL, | ||
1509 | NULL); | ||
1510 | if (ACPI_FAILURE(status)) { | 1369 | if (ACPI_FAILURE(status)) { |
1511 | kfree(ec_ecdt); | 1370 | kfree(ec_ecdt); |
1512 | ec_ecdt = NULL; | 1371 | ec_ecdt = NULL; |
@@ -1514,13 +1373,12 @@ acpi_ec_fake_ecdt(void) | |||
1514 | goto error; | 1373 | goto error; |
1515 | } | 1374 | } |
1516 | return 0; | 1375 | return 0; |
1517 | error: | 1376 | error: |
1518 | printk(KERN_ERR PREFIX "Can't make an fake ECDT\n"); | 1377 | printk(KERN_ERR PREFIX "Can't make an fake ECDT\n"); |
1519 | return ret; | 1378 | return ret; |
1520 | } | 1379 | } |
1521 | 1380 | ||
1522 | static int __init | 1381 | static int __init acpi_ec_get_real_ecdt(void) |
1523 | acpi_ec_get_real_ecdt(void) | ||
1524 | { | 1382 | { |
1525 | if (acpi_ec_polling_mode) | 1383 | if (acpi_ec_polling_mode) |
1526 | return acpi_ec_polling_get_real_ecdt(); | 1384 | return acpi_ec_polling_get_real_ecdt(); |
@@ -1528,14 +1386,14 @@ acpi_ec_get_real_ecdt(void) | |||
1528 | return acpi_ec_burst_get_real_ecdt(); | 1386 | return acpi_ec_burst_get_real_ecdt(); |
1529 | } | 1387 | } |
1530 | 1388 | ||
1531 | static int __init | 1389 | static int __init acpi_ec_polling_get_real_ecdt(void) |
1532 | acpi_ec_polling_get_real_ecdt(void) | ||
1533 | { | 1390 | { |
1534 | acpi_status status; | 1391 | acpi_status status; |
1535 | struct acpi_table_ecdt *ecdt_ptr; | 1392 | struct acpi_table_ecdt *ecdt_ptr; |
1536 | 1393 | ||
1537 | status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, | 1394 | status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, |
1538 | (struct acpi_table_header **) &ecdt_ptr); | 1395 | (struct acpi_table_header **) |
1396 | &ecdt_ptr); | ||
1539 | if (ACPI_FAILURE(status)) | 1397 | if (ACPI_FAILURE(status)) |
1540 | return -ENODEV; | 1398 | return -ENODEV; |
1541 | 1399 | ||
@@ -1558,13 +1416,14 @@ acpi_ec_polling_get_real_ecdt(void) | |||
1558 | ec_ecdt->common.global_lock = TRUE; | 1416 | ec_ecdt->common.global_lock = TRUE; |
1559 | ec_ecdt->common.uid = ecdt_ptr->uid; | 1417 | ec_ecdt->common.uid = ecdt_ptr->uid; |
1560 | 1418 | ||
1561 | 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); | ||
1562 | if (ACPI_FAILURE(status)) { | 1421 | if (ACPI_FAILURE(status)) { |
1563 | goto error; | 1422 | goto error; |
1564 | } | 1423 | } |
1565 | 1424 | ||
1566 | return 0; | 1425 | return 0; |
1567 | error: | 1426 | error: |
1568 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); | 1427 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); |
1569 | kfree(ec_ecdt); | 1428 | kfree(ec_ecdt); |
1570 | ec_ecdt = NULL; | 1429 | ec_ecdt = NULL; |
@@ -1572,15 +1431,14 @@ error: | |||
1572 | return -ENODEV; | 1431 | return -ENODEV; |
1573 | } | 1432 | } |
1574 | 1433 | ||
1575 | 1434 | static int __init acpi_ec_burst_get_real_ecdt(void) | |
1576 | static int __init | ||
1577 | acpi_ec_burst_get_real_ecdt(void) | ||
1578 | { | 1435 | { |
1579 | acpi_status status; | 1436 | acpi_status status; |
1580 | struct acpi_table_ecdt *ecdt_ptr; | 1437 | struct acpi_table_ecdt *ecdt_ptr; |
1581 | 1438 | ||
1582 | status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, | 1439 | status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING, |
1583 | (struct acpi_table_header **) &ecdt_ptr); | 1440 | (struct acpi_table_header **) |
1441 | &ecdt_ptr); | ||
1584 | if (ACPI_FAILURE(status)) | 1442 | if (ACPI_FAILURE(status)) |
1585 | return -ENODEV; | 1443 | return -ENODEV; |
1586 | 1444 | ||
@@ -1594,8 +1452,8 @@ acpi_ec_burst_get_real_ecdt(void) | |||
1594 | return -ENOMEM; | 1452 | return -ENOMEM; |
1595 | memset(ec_ecdt, 0, sizeof(union acpi_ec)); | 1453 | memset(ec_ecdt, 0, sizeof(union acpi_ec)); |
1596 | 1454 | ||
1597 | init_MUTEX(&ec_ecdt->burst.sem); | 1455 | init_MUTEX(&ec_ecdt->burst.sem); |
1598 | init_waitqueue_head(&ec_ecdt->burst.wait); | 1456 | init_waitqueue_head(&ec_ecdt->burst.wait); |
1599 | ec_ecdt->common.command_addr = ecdt_ptr->ec_control; | 1457 | ec_ecdt->common.command_addr = ecdt_ptr->ec_control; |
1600 | ec_ecdt->common.status_addr = ecdt_ptr->ec_control; | 1458 | ec_ecdt->common.status_addr = ecdt_ptr->ec_control; |
1601 | ec_ecdt->common.data_addr = ecdt_ptr->ec_data; | 1459 | ec_ecdt->common.data_addr = ecdt_ptr->ec_data; |
@@ -1604,13 +1462,14 @@ acpi_ec_burst_get_real_ecdt(void) | |||
1604 | ec_ecdt->common.global_lock = TRUE; | 1462 | ec_ecdt->common.global_lock = TRUE; |
1605 | ec_ecdt->common.uid = ecdt_ptr->uid; | 1463 | ec_ecdt->common.uid = ecdt_ptr->uid; |
1606 | 1464 | ||
1607 | 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); | ||
1608 | if (ACPI_FAILURE(status)) { | 1467 | if (ACPI_FAILURE(status)) { |
1609 | goto error; | 1468 | goto error; |
1610 | } | 1469 | } |
1611 | 1470 | ||
1612 | return 0; | 1471 | return 0; |
1613 | error: | 1472 | error: |
1614 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); | 1473 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); |
1615 | kfree(ec_ecdt); | 1474 | kfree(ec_ecdt); |
1616 | ec_ecdt = NULL; | 1475 | ec_ecdt = NULL; |
@@ -1619,11 +1478,10 @@ error: | |||
1619 | } | 1478 | } |
1620 | 1479 | ||
1621 | static int __initdata acpi_fake_ecdt_enabled; | 1480 | static int __initdata acpi_fake_ecdt_enabled; |
1622 | int __init | 1481 | int __init acpi_ec_ecdt_probe(void) |
1623 | acpi_ec_ecdt_probe (void) | ||
1624 | { | 1482 | { |
1625 | acpi_status status; | 1483 | acpi_status status; |
1626 | int ret; | 1484 | int ret; |
1627 | 1485 | ||
1628 | ret = acpi_ec_get_real_ecdt(); | 1486 | ret = acpi_ec_get_real_ecdt(); |
1629 | /* Try to make a fake ECDT */ | 1487 | /* Try to make a fake ECDT */ |
@@ -1638,26 +1496,28 @@ acpi_ec_ecdt_probe (void) | |||
1638 | * Install GPE handler | 1496 | * Install GPE handler |
1639 | */ | 1497 | */ |
1640 | status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit, | 1498 | status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit, |
1641 | ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, | 1499 | ACPI_GPE_EDGE_TRIGGERED, |
1642 | ec_ecdt); | 1500 | &acpi_ec_gpe_handler, ec_ecdt); |
1643 | if (ACPI_FAILURE(status)) { | 1501 | if (ACPI_FAILURE(status)) { |
1644 | goto error; | 1502 | goto error; |
1645 | } | 1503 | } |
1646 | 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); |
1647 | 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); |
1648 | 1506 | ||
1649 | status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT, | 1507 | status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT, |
1650 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, | 1508 | ACPI_ADR_SPACE_EC, |
1651 | &acpi_ec_space_setup, ec_ecdt); | 1509 | &acpi_ec_space_handler, |
1510 | &acpi_ec_space_setup, | ||
1511 | ec_ecdt); | ||
1652 | if (ACPI_FAILURE(status)) { | 1512 | if (ACPI_FAILURE(status)) { |
1653 | acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, | 1513 | acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, |
1654 | &acpi_ec_gpe_handler); | 1514 | &acpi_ec_gpe_handler); |
1655 | goto error; | 1515 | goto error; |
1656 | } | 1516 | } |
1657 | 1517 | ||
1658 | return 0; | 1518 | return 0; |
1659 | 1519 | ||
1660 | error: | 1520 | error: |
1661 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); | 1521 | printk(KERN_ERR PREFIX "Could not use ECDT\n"); |
1662 | kfree(ec_ecdt); | 1522 | kfree(ec_ecdt); |
1663 | ec_ecdt = NULL; | 1523 | ec_ecdt = NULL; |
@@ -1665,10 +1525,9 @@ error: | |||
1665 | return -ENODEV; | 1525 | return -ENODEV; |
1666 | } | 1526 | } |
1667 | 1527 | ||
1668 | 1528 | static int __init acpi_ec_init(void) | |
1669 | static int __init acpi_ec_init (void) | ||
1670 | { | 1529 | { |
1671 | int result = 0; | 1530 | int result = 0; |
1672 | 1531 | ||
1673 | ACPI_FUNCTION_TRACE("acpi_ec_init"); | 1532 | ACPI_FUNCTION_TRACE("acpi_ec_init"); |
1674 | 1533 | ||
@@ -1693,8 +1552,7 @@ subsys_initcall(acpi_ec_init); | |||
1693 | 1552 | ||
1694 | /* EC driver currently not unloadable */ | 1553 | /* EC driver currently not unloadable */ |
1695 | #if 0 | 1554 | #if 0 |
1696 | static void __exit | 1555 | static void __exit acpi_ec_exit(void) |
1697 | acpi_ec_exit (void) | ||
1698 | { | 1556 | { |
1699 | ACPI_FUNCTION_TRACE("acpi_ec_exit"); | 1557 | ACPI_FUNCTION_TRACE("acpi_ec_exit"); |
1700 | 1558 | ||
@@ -1704,7 +1562,7 @@ acpi_ec_exit (void) | |||
1704 | 1562 | ||
1705 | return_VOID; | 1563 | return_VOID; |
1706 | } | 1564 | } |
1707 | #endif /* 0 */ | 1565 | #endif /* 0 */ |
1708 | 1566 | ||
1709 | static int __init acpi_fake_ecdt_setup(char *str) | 1567 | static int __init acpi_fake_ecdt_setup(char *str) |
1710 | { | 1568 | { |
@@ -1727,8 +1585,8 @@ static int __init acpi_ec_set_polling_mode(char *str) | |||
1727 | acpi_ec_polling_mode = EC_POLLING; | 1585 | acpi_ec_polling_mode = EC_POLLING; |
1728 | acpi_ec_driver.ops.add = acpi_ec_polling_add; | 1586 | acpi_ec_driver.ops.add = acpi_ec_polling_add; |
1729 | } | 1587 | } |
1730 | printk(KERN_INFO PREFIX "EC %s mode.\n", | 1588 | printk(KERN_INFO PREFIX "EC %s mode.\n", burst ? "burst" : "polling"); |
1731 | burst ? "burst": "polling"); | ||
1732 | return 0; | 1589 | return 0; |
1733 | } | 1590 | } |
1591 | |||
1734 | __setup("ec_burst=", acpi_ec_set_polling_mode); | 1592 | __setup("ec_burst=", acpi_ec_set_polling_mode); |