ec.c 25.2 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/*
 *  acpi_ec.c - ACPI Embedded Controller Driver ($Revision: 38 $)
 *
 *  Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
 *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
 *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or (at
 *  your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/delay.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
D
Dmitry Torokhov 已提交
34
#include <linux/interrupt.h>
L
Linus Torvalds 已提交
35 36 37 38 39 40
#include <asm/io.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#include <acpi/actypes.h>

#define _COMPONENT		ACPI_EC_COMPONENT
L
Len Brown 已提交
41
ACPI_MODULE_NAME("acpi_ec")
L
Linus Torvalds 已提交
42 43 44 45 46 47
#define ACPI_EC_COMPONENT		0x00100000
#define ACPI_EC_CLASS			"embedded_controller"
#define ACPI_EC_HID			"PNP0C09"
#define ACPI_EC_DRIVER_NAME		"ACPI Embedded Controller Driver"
#define ACPI_EC_DEVICE_NAME		"Embedded Controller"
#define ACPI_EC_FILE_INFO		"info"
48 49

/* EC status register */
L
Linus Torvalds 已提交
50 51
#define ACPI_EC_FLAG_OBF	0x01	/* Output buffer full */
#define ACPI_EC_FLAG_IBF	0x02	/* Input buffer full */
D
Dmitry Torokhov 已提交
52
#define ACPI_EC_FLAG_BURST	0x10	/* burst mode */
L
Linus Torvalds 已提交
53
#define ACPI_EC_FLAG_SCI	0x20	/* EC-SCI occurred */
54 55

/* EC commands */
L
Linus Torvalds 已提交
56 57
#define ACPI_EC_COMMAND_READ	0x80
#define ACPI_EC_COMMAND_WRITE	0x81
D
Dmitry Torokhov 已提交
58 59
#define ACPI_EC_BURST_ENABLE	0x82
#define ACPI_EC_BURST_DISABLE	0x83
L
Linus Torvalds 已提交
60
#define ACPI_EC_COMMAND_QUERY	0x84
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

/* EC events */
enum {
	ACPI_EC_EVENT_OBF_1 = 1,	/* Output buffer full */
	ACPI_EC_EVENT_IBF_0,		/* Input buffer empty */
};

#define ACPI_EC_DELAY		50	/* Wait 50ms max. during EC ops */
#define ACPI_EC_UDELAY_GLK	1000	/* Wait 1ms max. to get global lock */
#define ACPI_EC_UDELAY         100	/* Poll @ 100us increments */
#define ACPI_EC_UDELAY_COUNT   1000	/* Wait 10ms max. during EC ops */

enum {
	EC_INTR = 1,	/* Output buffer full */
	EC_POLL,		/* Input buffer empty */
};

L
Len Brown 已提交
78 79 80
static int acpi_ec_remove(struct acpi_device *device, int type);
static int acpi_ec_start(struct acpi_device *device);
static int acpi_ec_stop(struct acpi_device *device, int type);
81
static int acpi_ec_add(struct acpi_device *device);
L
Linus Torvalds 已提交
82 83

static struct acpi_driver acpi_ec_driver = {
L
Len Brown 已提交
84 85 86 87
	.name = ACPI_EC_DRIVER_NAME,
	.class = ACPI_EC_CLASS,
	.ids = ACPI_EC_HID,
	.ops = {
88
		.add = acpi_ec_add,
L
Len Brown 已提交
89 90 91 92
		.remove = acpi_ec_remove,
		.start = acpi_ec_start,
		.stop = acpi_ec_stop,
		},
L
Linus Torvalds 已提交
93
};
94 95 96 97 98 99 100 101 102 103 104 105
struct acpi_ec {
	acpi_handle handle;
	unsigned long uid;
	unsigned long gpe_bit;
	struct acpi_generic_address status_addr;
	struct acpi_generic_address command_addr;
	struct acpi_generic_address data_addr;
	unsigned long global_lock;
	struct semaphore sem;
	unsigned int expect_event;
	atomic_t leaving_burst;	/* 0 : No, 1 : Yes, 2: abort */
	wait_queue_head_t wait;
L
Linus Torvalds 已提交
106 107
};

108 109 110 111 112 113 114
/* If we find an EC via the ECDT, we need to keep a ptr to its context */
static struct acpi_ec *ec_ecdt;

/* External interfaces use first EC only, so remember */
static struct acpi_device *first_ec;
static int acpi_ec_mode = EC_INTR;

L
Linus Torvalds 已提交
115 116 117 118
/* --------------------------------------------------------------------------
                             Transaction Management
   -------------------------------------------------------------------------- */

119
static u32 acpi_ec_read_status(struct acpi_ec *ec)
L
Linus Torvalds 已提交
120
{
L
Len Brown 已提交
121
	u32 status = 0;
L
Linus Torvalds 已提交
122

123
	acpi_hw_low_level_read(8, &status, &ec->status_addr);
D
Dmitry Torokhov 已提交
124 125 126
	return status;
}

127 128 129
static u32 acpi_ec_read_data(struct acpi_ec *ec)
{
	u32 data = 0;
130

131 132
	acpi_hw_low_level_read(8, &data, &ec->data_addr);
	return data;
133 134
}

135
static void acpi_ec_write_cmd(struct acpi_ec *ec, u32 command)
L
Luming Yu 已提交
136
{
137
	acpi_hw_low_level_write(8, command, &ec->command_addr);
L
Luming Yu 已提交
138 139
}

140
static void acpi_ec_write_data(struct acpi_ec *ec, u32 data)
L
Luming Yu 已提交
141
{
142 143
	acpi_hw_low_level_write(8, data, &ec->data_addr);
}
L
Luming Yu 已提交
144

145
static int acpi_ec_check_status(u32 status, u8 event) {
L
Luming Yu 已提交
146 147

	switch (event) {
148 149 150
	case ACPI_EC_EVENT_OBF_1:
		if (status & ACPI_EC_FLAG_OBF)
			return 1;
L
Luming Yu 已提交
151
		break;
152 153 154
	case ACPI_EC_EVENT_IBF_0:
		if (!(status & ACPI_EC_FLAG_IBF))
			return 1;
L
Luming Yu 已提交
155 156
		break;
	default:
157
		break;
L
Luming Yu 已提交
158 159
	}

160
	return 0;
L
Luming Yu 已提交
161
}
D
Dmitry Torokhov 已提交
162

163
static int acpi_ec_wait(struct acpi_ec *ec, u8 event)
164
{
165 166
	int i = (acpi_ec_mode == EC_POLL) ? ACPI_EC_UDELAY_COUNT : 0;
	long time_left;
D
Dmitry Torokhov 已提交
167

168
	ec->expect_event = event;
169
	if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) {
170 171
		ec->expect_event = 0;
		return 0;
172 173
	}

174 175 176 177 178 179 180 181 182
	do {
		if (acpi_ec_mode == EC_POLL) {
			udelay(ACPI_EC_UDELAY);
		} else {
			time_left = wait_event_timeout(ec->wait,
				    !ec->expect_event,
				    msecs_to_jiffies(ACPI_EC_DELAY));
			if (time_left > 0) {
				ec->expect_event = 0;
183
				return 0;
184
			}
185
		}
186 187 188 189 190 191 192
		if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) {
			ec->expect_event = 0;
			return 0;
		}
	} while (--i > 0);

	ec->expect_event = 0;
L
Linus Torvalds 已提交
193

194
	return -ETIME;
L
Linus Torvalds 已提交
195 196
}

197
#ifdef ACPI_FUTURE_USAGE
198 199 200 201
/*
 * Note: samsung nv5000 doesn't work with ec burst mode.
 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
 */
202
int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
D
Dmitry Torokhov 已提交
203
{
L
Len Brown 已提交
204
	u32 tmp = 0;
205
	u32 status = 0;
D
Dmitry Torokhov 已提交
206 207 208


	status = acpi_ec_read_status(ec);
L
Len Brown 已提交
209
	if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
210
		status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
L
Len Brown 已提交
211
		if (status)
212
			goto end;
213 214 215
		acpi_ec_write_cmd(ec, ACPI_EC_BURST_ENABLE);
		status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
		tmp = acpi_ec_read_data(ec);
L
Len Brown 已提交
216
		if (tmp != 0x90) {	/* Burst ACK byte */
217
			return -EINVAL;
D
Dmitry Torokhov 已提交
218
		}
219 220
	}

221
	atomic_set(&ec->leaving_burst, 0);
222
	return 0;
223 224
  end:
	ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode"));
225
	return -1;
D
Dmitry Torokhov 已提交
226 227
}

228
int acpi_ec_leave_burst_mode(struct acpi_ec *ec)
D
Dmitry Torokhov 已提交
229
{
230
	u32 status = 0;
D
Dmitry Torokhov 已提交
231 232


233 234
	status = acpi_ec_read_status(ec);
	if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){
235
		status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
236 237
		if(status)
			goto end;
238 239
		acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE);
		acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
240
	}
241
	atomic_set(&ec->leaving_burst, 1);
242
	return 0;
243 244
  end:
	ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"));
245
	return -1;
D
Dmitry Torokhov 已提交
246
}
247
#endif /* ACPI_FUTURE_USAGE */
D
Dmitry Torokhov 已提交
248

249
static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
250 251
					const u8 *wdata, unsigned wdata_len,
					u8 *rdata, unsigned rdata_len)
L
Luming Yu 已提交
252
{
253
	int result;
L
Luming Yu 已提交
254

255
	acpi_ec_write_cmd(ec, command);
L
Luming Yu 已提交
256

257
	for (; wdata_len > 0; wdata_len --) {
258
		result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
259 260
		if (result)
			return result;
261
		acpi_ec_write_data(ec, *(wdata++));
262
	}
L
Luming Yu 已提交
263

264
	if (command == ACPI_EC_COMMAND_WRITE) {
265
		result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
266 267 268
		if (result)
			return result;
	}
L
Luming Yu 已提交
269

270 271
	for (; rdata_len > 0; rdata_len --) {
		u32 d;
L
Luming Yu 已提交
272

273
		result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
274 275
		if (result)
			return result;
L
Len Brown 已提交
276

277
		d = acpi_ec_read_data(ec);
278 279
		*(rdata++) = (u8) d;
	}
L
Luming Yu 已提交
280

281
	return 0;
L
Luming Yu 已提交
282 283
}

284 285 286
static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
				const u8 *wdata, unsigned wdata_len,
				u8 *rdata, unsigned rdata_len)
L
Linus Torvalds 已提交
287
{
288
	int status;
L
Len Brown 已提交
289
	u32 glk;
L
Linus Torvalds 已提交
290

291
	if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
292
		return -EINVAL;
L
Linus Torvalds 已提交
293

294 295
        if (rdata)
                memset(rdata, 0, rdata_len);
L
Linus Torvalds 已提交
296

297
	if (ec->global_lock) {
L
Linus Torvalds 已提交
298 299
		status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
		if (ACPI_FAILURE(status))
300
			return -ENODEV;
L
Linus Torvalds 已提交
301
	}
302
	down(&ec->sem);
D
Dmitry Torokhov 已提交
303

304
	status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
305
	if (status) {
306
		printk(KERN_DEBUG PREFIX "read EC, IB not empty\n");
D
Dmitry Torokhov 已提交
307
		goto end;
308
	}
L
Linus Torvalds 已提交
309

310 311 312
        status = acpi_ec_transaction_unlocked(ec, command,
                                              wdata, wdata_len,
                                              rdata, rdata_len);
L
Linus Torvalds 已提交
313

314
end:
315
	up(&ec->sem);
L
Linus Torvalds 已提交
316

317
	if (ec->global_lock)
L
Linus Torvalds 已提交
318 319
		acpi_release_global_lock(glk);

320
	return status;
L
Linus Torvalds 已提交
321 322
}

323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
static int acpi_ec_read(struct acpi_ec *ec, u8 address, u32 * data)
{
	int result;
	u8 d;

	result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
				     &address, 1, &d, 1);
	*data = d;
	return result;
}
static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
{
        u8 wdata[2] = { address, data };
        return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
				   wdata, 2, NULL, 0);
}

L
Linus Torvalds 已提交
340 341 342
/*
 * Externally callable EC access functions. For now, assume 1 EC only
 */
L
Len Brown 已提交
343
int ec_read(u8 addr, u8 * val)
L
Linus Torvalds 已提交
344
{
345
	struct acpi_ec *ec;
L
Linus Torvalds 已提交
346 347 348 349 350 351 352 353 354 355 356 357 358
	int err;
	u32 temp_data;

	if (!first_ec)
		return -ENODEV;

	ec = acpi_driver_data(first_ec);

	err = acpi_ec_read(ec, addr, &temp_data);

	if (!err) {
		*val = temp_data;
		return 0;
L
Len Brown 已提交
359
	} else
L
Linus Torvalds 已提交
360 361
		return err;
}
L
Len Brown 已提交
362

L
Linus Torvalds 已提交
363 364
EXPORT_SYMBOL(ec_read);

L
Len Brown 已提交
365
int ec_write(u8 addr, u8 val)
L
Linus Torvalds 已提交
366
{
367
	struct acpi_ec *ec;
L
Linus Torvalds 已提交
368 369 370 371 372 373 374 375 376 377 378
	int err;

	if (!first_ec)
		return -ENODEV;

	ec = acpi_driver_data(first_ec);

	err = acpi_ec_write(ec, addr, val);

	return err;
}
L
Len Brown 已提交
379

L
Linus Torvalds 已提交
380 381
EXPORT_SYMBOL(ec_write);

382 383 384
extern int ec_transaction(u8 command,
                          const u8 *wdata, unsigned wdata_len,
                          u8 *rdata, unsigned rdata_len)
L
Luming Yu 已提交
385
{
386
	struct acpi_ec *ec;
L
Luming Yu 已提交
387

388 389
	if (!first_ec)
		return -ENODEV;
L
Luming Yu 已提交
390

391
	ec = acpi_driver_data(first_ec);
L
Luming Yu 已提交
392

393 394
	return acpi_ec_transaction(ec, command, wdata,
				   wdata_len, rdata, rdata_len);
L
Luming Yu 已提交
395
}
L
Linus Torvalds 已提交
396

397 398 399
static int acpi_ec_query(struct acpi_ec *ec, u32 * data)
{
	int result;
400
        u8 d;
L
Linus Torvalds 已提交
401

402 403
        if (!ec || !data)
                return -EINVAL;
L
Linus Torvalds 已提交
404

405 406 407 408 409
        /*
         * Query the EC to find out which _Qxx method we need to evaluate.
         * Note that successful completion of the query causes the ACPI_EC_SCI
         * bit to be cleared (and thus clearing the interrupt source).
         */
410

411 412 413
        result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
        if (result)
                return result;
L
Linus Torvalds 已提交
414

415 416
        if (!d)
                return -ENODATA;
L
Linus Torvalds 已提交
417

418 419
        *data = d;
        return 0;
L
Linus Torvalds 已提交
420 421 422 423 424 425
}

/* --------------------------------------------------------------------------
                                Event Management
   -------------------------------------------------------------------------- */

426
struct acpi_ec_query_data {
L
Len Brown 已提交
427 428
	acpi_handle handle;
	u8 data;
L
Linus Torvalds 已提交
429 430
};

L
Len Brown 已提交
431
static void acpi_ec_gpe_query(void *ec_cxt)
L
Luming Yu 已提交
432
{
433
	struct acpi_ec *ec = (struct acpi_ec *)ec_cxt;
L
Len Brown 已提交
434 435 436 437 438
	u32 value = 0;
	static char object_name[5] = { '_', 'Q', '0', '0', '\0' };
	const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
		'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
	};
L
Luming Yu 已提交
439 440 441 442 443


	if (!ec_cxt)
		goto end;

444
	value = acpi_ec_read_status(ec);
L
Luming Yu 已提交
445 446 447 448 449 450 451 452 453 454

	if (!(value & ACPI_EC_FLAG_SCI))
		goto end;

	if (acpi_ec_query(ec, &value))
		goto end;

	object_name[2] = hex[((value >> 4) & 0x0F)];
	object_name[3] = hex[(value & 0x0F)];

455
	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name));
L
Luming Yu 已提交
456

457
	acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
L
Luming Yu 已提交
458

L
Len Brown 已提交
459
      end:
460
	acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
L
Luming Yu 已提交
461
}
L
Linus Torvalds 已提交
462

L
Len Brown 已提交
463
static u32 acpi_ec_gpe_handler(void *data)
L
Linus Torvalds 已提交
464
{
L
Len Brown 已提交
465 466
	acpi_status status = AE_OK;
	u32 value;
467
	u8 exec_mode;
468
	struct acpi_ec *ec = (struct acpi_ec *)data;
L
Linus Torvalds 已提交
469

470
	acpi_clear_gpe(NULL, ec->gpe_bit, ACPI_ISR);
D
Dmitry Torokhov 已提交
471
	value = acpi_ec_read_status(ec);
L
Linus Torvalds 已提交
472

473 474 475 476 477 478 479 480
	if (acpi_ec_mode == EC_INTR) {
		if (acpi_ec_check_status(value, ec->expect_event)) {
			ec->expect_event = 0;
			wake_up(&ec->wait);
		}
		exec_mode = OSL_EC_BURST_HANDLER;
	} else {
		exec_mode = OSL_EC_POLL_HANDLER;
D
Dmitry Torokhov 已提交
481 482
	}

L
Len Brown 已提交
483
	if (value & ACPI_EC_FLAG_SCI) {
484
		status = acpi_os_execute(exec_mode, acpi_ec_gpe_query, ec);
L
Luming Yu 已提交
485
		return status == AE_OK ?
L
Len Brown 已提交
486 487
		    ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
	}
488
	acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_ISR);
D
Dmitry Torokhov 已提交
489
	return status == AE_OK ?
L
Len Brown 已提交
490
	    ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
L
Linus Torvalds 已提交
491 492 493 494 495 496 497
}

/* --------------------------------------------------------------------------
                             Address Space Management
   -------------------------------------------------------------------------- */

static acpi_status
L
Len Brown 已提交
498 499
acpi_ec_space_setup(acpi_handle region_handle,
		    u32 function, void *handler_context, void **return_context)
L
Linus Torvalds 已提交
500 501 502 503 504
{
	/*
	 * The EC object is in the handler context and is needed
	 * when calling the acpi_ec_space_handler.
	 */
L
Len Brown 已提交
505 506
	*return_context = (function != ACPI_REGION_DEACTIVATE) ?
	    handler_context : NULL;
L
Linus Torvalds 已提交
507 508 509 510 511

	return AE_OK;
}

static acpi_status
L
Len Brown 已提交
512 513 514 515 516
acpi_ec_space_handler(u32 function,
		      acpi_physical_address address,
		      u32 bit_width,
		      acpi_integer * value,
		      void *handler_context, void *region_context)
L
Linus Torvalds 已提交
517
{
L
Len Brown 已提交
518
	int result = 0;
519
	struct acpi_ec *ec = NULL;
L
Len Brown 已提交
520 521 522
	u64 temp = *value;
	acpi_integer f_v = 0;
	int i = 0;
L
Linus Torvalds 已提交
523 524 525


	if ((address > 0xFF) || !value || !handler_context)
526
		return AE_BAD_PARAMETER;
L
Linus Torvalds 已提交
527

L
Luming Yu 已提交
528
	if (bit_width != 8 && acpi_strict) {
529
		return AE_BAD_PARAMETER;
L
Linus Torvalds 已提交
530 531
	}

532
	ec = (struct acpi_ec *)handler_context;
L
Linus Torvalds 已提交
533

L
Len Brown 已提交
534
      next_byte:
L
Linus Torvalds 已提交
535 536
	switch (function) {
	case ACPI_READ:
L
Luming Yu 已提交
537
		temp = 0;
L
Len Brown 已提交
538
		result = acpi_ec_read(ec, (u8) address, (u32 *) & temp);
L
Linus Torvalds 已提交
539 540
		break;
	case ACPI_WRITE:
L
Luming Yu 已提交
541
		result = acpi_ec_write(ec, (u8) address, (u8) temp);
L
Linus Torvalds 已提交
542 543 544 545 546 547 548 549
		break;
	default:
		result = -EINVAL;
		goto out;
		break;
	}

	bit_width -= 8;
L
Luming Yu 已提交
550 551 552 553 554
	if (bit_width) {
		if (function == ACPI_READ)
			f_v |= temp << 8 * i;
		if (function == ACPI_WRITE)
			temp >>= 8;
L
Linus Torvalds 已提交
555
		i++;
A
Andrew Morton 已提交
556
		address++;
L
Linus Torvalds 已提交
557 558 559
		goto next_byte;
	}

L
Luming Yu 已提交
560 561
	if (function == ACPI_READ) {
		f_v |= temp << 8 * i;
L
Linus Torvalds 已提交
562 563 564
		*value = f_v;
	}

L
Len Brown 已提交
565
      out:
L
Linus Torvalds 已提交
566 567
	switch (result) {
	case -EINVAL:
568
		return AE_BAD_PARAMETER;
L
Linus Torvalds 已提交
569 570
		break;
	case -ENODEV:
571
		return AE_NOT_FOUND;
L
Linus Torvalds 已提交
572 573
		break;
	case -ETIME:
574
		return AE_TIME;
L
Linus Torvalds 已提交
575 576
		break;
	default:
577
		return AE_OK;
L
Linus Torvalds 已提交
578 579 580 581 582 583 584
	}
}

/* --------------------------------------------------------------------------
                              FS Interface (/proc)
   -------------------------------------------------------------------------- */

L
Len Brown 已提交
585
static struct proc_dir_entry *acpi_ec_dir;
L
Linus Torvalds 已提交
586

L
Len Brown 已提交
587
static int acpi_ec_read_info(struct seq_file *seq, void *offset)
L
Linus Torvalds 已提交
588
{
589
	struct acpi_ec *ec = (struct acpi_ec *)seq->private;
L
Linus Torvalds 已提交
590 591 592 593 594 595


	if (!ec)
		goto end;

	seq_printf(seq, "gpe bit:                 0x%02x\n",
596
		   (u32) ec->gpe_bit);
L
Linus Torvalds 已提交
597
	seq_printf(seq, "ports:                   0x%02x, 0x%02x\n",
598 599
		   (u32) ec->status_addr.address,
		   (u32) ec->data_addr.address);
L
Linus Torvalds 已提交
600
	seq_printf(seq, "use global lock:         %s\n",
601 602
		   ec->global_lock ? "yes" : "no");
	acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
L
Linus Torvalds 已提交
603

L
Len Brown 已提交
604
      end:
605
	return 0;
L
Linus Torvalds 已提交
606 607 608 609 610 611 612
}

static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
{
	return single_open(file, acpi_ec_read_info, PDE(inode)->data);
}

613
static struct file_operations acpi_ec_info_ops = {
L
Len Brown 已提交
614 615 616 617
	.open = acpi_ec_info_open_fs,
	.read = seq_read,
	.llseek = seq_lseek,
	.release = single_release,
L
Linus Torvalds 已提交
618 619 620
	.owner = THIS_MODULE,
};

L
Len Brown 已提交
621
static int acpi_ec_add_fs(struct acpi_device *device)
L
Linus Torvalds 已提交
622
{
L
Len Brown 已提交
623
	struct proc_dir_entry *entry = NULL;
L
Linus Torvalds 已提交
624 625 626 627


	if (!acpi_device_dir(device)) {
		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
L
Len Brown 已提交
628
						     acpi_ec_dir);
L
Linus Torvalds 已提交
629
		if (!acpi_device_dir(device))
630
			return -ENODEV;
L
Linus Torvalds 已提交
631 632 633
	}

	entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
L
Len Brown 已提交
634
				  acpi_device_dir(device));
L
Linus Torvalds 已提交
635
	if (!entry)
636
		return -ENODEV;
L
Linus Torvalds 已提交
637 638 639 640 641 642
	else {
		entry->proc_fops = &acpi_ec_info_ops;
		entry->data = acpi_driver_data(device);
		entry->owner = THIS_MODULE;
	}

643
	return 0;
L
Linus Torvalds 已提交
644 645
}

L
Len Brown 已提交
646
static int acpi_ec_remove_fs(struct acpi_device *device)
L
Linus Torvalds 已提交
647 648 649 650 651 652 653 654
{

	if (acpi_device_dir(device)) {
		remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
		remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
		acpi_device_dir(device) = NULL;
	}

655
	return 0;
L
Linus Torvalds 已提交
656 657 658 659 660 661
}

/* --------------------------------------------------------------------------
                               Driver Interface
   -------------------------------------------------------------------------- */

662
static int acpi_ec_add(struct acpi_device *device)
L
Linus Torvalds 已提交
663
{
L
Len Brown 已提交
664 665
	int result = 0;
	acpi_status status = AE_OK;
666
	struct acpi_ec *ec = NULL;
L
Luming Yu 已提交
667 668 669


	if (!device)
670
		return -EINVAL;
L
Luming Yu 已提交
671

672
	ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
L
Luming Yu 已提交
673
	if (!ec)
674
		return -ENOMEM;
675 676 677 678 679 680 681 682
	memset(ec, 0, sizeof(struct acpi_ec));

	ec->handle = device->handle;
	ec->uid = -1;
	init_MUTEX(&ec->sem);
	if (acpi_ec_mode == EC_INTR) {
		atomic_set(&ec->leaving_burst, 1);
		init_waitqueue_head(&ec->wait);
L
Luming Yu 已提交
683
	}
L
Linus Torvalds 已提交
684 685 686 687 688
	strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
	strcpy(acpi_device_class(device), ACPI_EC_CLASS);
	acpi_driver_data(device) = ec;

	/* Use the global lock for all EC transactions? */
689 690
	acpi_evaluate_integer(ec->handle, "_GLK", NULL,
			      &ec->global_lock);
L
Linus Torvalds 已提交
691

J
Jiri Slaby 已提交
692 693 694
	/* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
	   http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
	if (ec_ecdt) {
L
Linus Torvalds 已提交
695
		acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
L
Len Brown 已提交
696 697
						  ACPI_ADR_SPACE_EC,
						  &acpi_ec_space_handler);
D
Dmitry Torokhov 已提交
698

699
		acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit,
L
Len Brown 已提交
700
					&acpi_ec_gpe_handler);
L
Linus Torvalds 已提交
701 702 703 704 705 706

		kfree(ec_ecdt);
	}

	/* Get GPE bit assignment (EC events). */
	/* TODO: Add support for _GPE returning a package */
L
Len Brown 已提交
707
	status =
708 709
	    acpi_evaluate_integer(ec->handle, "_GPE", NULL,
				  &ec->gpe_bit);
L
Linus Torvalds 已提交
710
	if (ACPI_FAILURE(status)) {
711
		ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit assignment"));
L
Linus Torvalds 已提交
712 713 714 715 716 717 718 719
		result = -ENODEV;
		goto end;
	}

	result = acpi_ec_add_fs(device);
	if (result)
		goto end;

720
	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
L
Len Brown 已提交
721
	       acpi_device_name(device), acpi_device_bid(device),
722
	       (u32) ec->gpe_bit));
L
Linus Torvalds 已提交
723 724 725 726

	if (!first_ec)
		first_ec = device;

727
  end:
L
Linus Torvalds 已提交
728 729 730
	if (result)
		kfree(ec);

731
	return result;
L
Linus Torvalds 已提交
732 733
}

L
Len Brown 已提交
734
static int acpi_ec_remove(struct acpi_device *device, int type)
L
Linus Torvalds 已提交
735
{
736
	struct acpi_ec *ec = NULL;
L
Linus Torvalds 已提交
737 738 739


	if (!device)
740
		return -EINVAL;
L
Linus Torvalds 已提交
741 742 743 744 745 746 747

	ec = acpi_driver_data(device);

	acpi_ec_remove_fs(device);

	kfree(ec);

748
	return 0;
L
Linus Torvalds 已提交
749 750 751
}

static acpi_status
L
Len Brown 已提交
752
acpi_ec_io_ports(struct acpi_resource *resource, void *context)
L
Linus Torvalds 已提交
753
{
754
	struct acpi_ec *ec = (struct acpi_ec *)context;
L
Linus Torvalds 已提交
755 756
	struct acpi_generic_address *addr;

B
Bob Moore 已提交
757
	if (resource->type != ACPI_RESOURCE_TYPE_IO) {
L
Linus Torvalds 已提交
758 759 760 761 762 763 764 765
		return AE_OK;
	}

	/*
	 * The first address region returned is the data port, and
	 * the second address region returned is the status/command
	 * port.
	 */
766 767 768 769
	if (ec->data_addr.register_bit_width == 0) {
		addr = &ec->data_addr;
	} else if (ec->command_addr.register_bit_width == 0) {
		addr = &ec->command_addr;
L
Linus Torvalds 已提交
770 771 772 773 774 775 776
	} else {
		return AE_CTRL_TERMINATE;
	}

	addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
	addr->register_bit_width = 8;
	addr->register_bit_offset = 0;
B
Bob Moore 已提交
777
	addr->address = resource->data.io.minimum;
L
Linus Torvalds 已提交
778 779 780 781

	return AE_OK;
}

L
Len Brown 已提交
782
static int acpi_ec_start(struct acpi_device *device)
L
Linus Torvalds 已提交
783
{
L
Len Brown 已提交
784
	acpi_status status = AE_OK;
785
	struct acpi_ec *ec = NULL;
L
Linus Torvalds 已提交
786 787 788


	if (!device)
789
		return -EINVAL;
L
Linus Torvalds 已提交
790 791 792 793

	ec = acpi_driver_data(device);

	if (!ec)
794
		return -EINVAL;
L
Linus Torvalds 已提交
795 796 797 798

	/*
	 * Get I/O port addresses. Convert to GAS format.
	 */
799
	status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
L
Len Brown 已提交
800 801
				     acpi_ec_io_ports, ec);
	if (ACPI_FAILURE(status)
802 803 804
	    || ec->command_addr.register_bit_width == 0) {
		ACPI_EXCEPTION((AE_INFO, status,
				"Error getting I/O port addresses"));
805
		return -ENODEV;
L
Linus Torvalds 已提交
806 807
	}

808
	ec->status_addr = ec->command_addr;
L
Linus Torvalds 已提交
809

810 811 812 813
	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x",
			  (u32) ec->gpe_bit,
			  (u32) ec->command_addr.address,
			  (u32) ec->data_addr.address));
L
Linus Torvalds 已提交
814 815 816 817

	/*
	 * Install GPE handler
	 */
818
	status = acpi_install_gpe_handler(NULL, ec->gpe_bit,
L
Len Brown 已提交
819 820
					  ACPI_GPE_EDGE_TRIGGERED,
					  &acpi_ec_gpe_handler, ec);
L
Linus Torvalds 已提交
821
	if (ACPI_FAILURE(status)) {
822
		return -ENODEV;
L
Linus Torvalds 已提交
823
	}
824 825
	acpi_set_gpe_type(NULL, ec->gpe_bit, ACPI_GPE_TYPE_RUNTIME);
	acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
L
Linus Torvalds 已提交
826

827
	status = acpi_install_address_space_handler(ec->handle,
L
Len Brown 已提交
828 829 830
						    ACPI_ADR_SPACE_EC,
						    &acpi_ec_space_handler,
						    &acpi_ec_space_setup, ec);
L
Linus Torvalds 已提交
831
	if (ACPI_FAILURE(status)) {
832
		acpi_remove_gpe_handler(NULL, ec->gpe_bit,
L
Len Brown 已提交
833
					&acpi_ec_gpe_handler);
834
		return -ENODEV;
L
Linus Torvalds 已提交
835 836
	}

837
	return AE_OK;
L
Linus Torvalds 已提交
838 839
}

L
Len Brown 已提交
840
static int acpi_ec_stop(struct acpi_device *device, int type)
L
Linus Torvalds 已提交
841
{
L
Len Brown 已提交
842
	acpi_status status = AE_OK;
843
	struct acpi_ec *ec = NULL;
L
Linus Torvalds 已提交
844 845 846


	if (!device)
847
		return -EINVAL;
L
Linus Torvalds 已提交
848 849 850

	ec = acpi_driver_data(device);

851
	status = acpi_remove_address_space_handler(ec->handle,
L
Len Brown 已提交
852 853
						   ACPI_ADR_SPACE_EC,
						   &acpi_ec_space_handler);
L
Linus Torvalds 已提交
854
	if (ACPI_FAILURE(status))
855
		return -ENODEV;
L
Linus Torvalds 已提交
856

L
Len Brown 已提交
857
	status =
858
	    acpi_remove_gpe_handler(NULL, ec->gpe_bit,
L
Len Brown 已提交
859
				    &acpi_ec_gpe_handler);
L
Linus Torvalds 已提交
860
	if (ACPI_FAILURE(status))
861
		return -ENODEV;
L
Linus Torvalds 已提交
862

863
	return 0;
L
Linus Torvalds 已提交
864 865 866
}

static acpi_status __init
L
Len Brown 已提交
867 868
acpi_fake_ecdt_callback(acpi_handle handle,
			u32 Level, void *context, void **retval)
L
Linus Torvalds 已提交
869
{
L
Len Brown 已提交
870
	acpi_status status;
L
Linus Torvalds 已提交
871

872 873 874 875
	init_MUTEX(&ec_ecdt->sem);
	if (acpi_ec_mode == EC_INTR) {
		init_waitqueue_head(&ec_ecdt->wait);
	}
L
Linus Torvalds 已提交
876
	status = acpi_walk_resources(handle, METHOD_NAME__CRS,
L
Len Brown 已提交
877
				     acpi_ec_io_ports, ec_ecdt);
L
Linus Torvalds 已提交
878 879
	if (ACPI_FAILURE(status))
		return status;
880
	ec_ecdt->status_addr = ec_ecdt->command_addr;
L
Linus Torvalds 已提交
881

882 883
	ec_ecdt->uid = -1;
	acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
L
Linus Torvalds 已提交
884

L
Len Brown 已提交
885 886
	status =
	    acpi_evaluate_integer(handle, "_GPE", NULL,
887
				  &ec_ecdt->gpe_bit);
L
Linus Torvalds 已提交
888 889
	if (ACPI_FAILURE(status))
		return status;
890 891
	ec_ecdt->global_lock = TRUE;
	ec_ecdt->handle = handle;
L
Linus Torvalds 已提交
892

893 894 895 896
	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02x, ports=0x%2x, 0x%2x",
	       (u32) ec_ecdt->gpe_bit,
	       (u32) ec_ecdt->command_addr.address,
	       (u32) ec_ecdt->data_addr.address));
L
Linus Torvalds 已提交
897 898 899 900 901 902 903 904 905 906 907 908 909 910

	return AE_CTRL_TERMINATE;
}

/*
 * Some BIOS (such as some from Gateway laptops) access EC region very early
 * such as in BAT0._INI or EC._INI before an EC device is found and
 * do not provide an ECDT. According to ACPI spec, ECDT isn't mandatorily
 * required, but if EC regison is accessed early, it is required.
 * The routine tries to workaround the BIOS bug by pre-scan EC device
 * It assumes that _CRS, _HID, _GPE, _UID methods of EC don't touch any
 * op region (since _REG isn't invoked yet). The assumption is true for
 * all systems found.
 */
L
Len Brown 已提交
911
static int __init acpi_ec_fake_ecdt(void)
L
Linus Torvalds 已提交
912
{
L
Len Brown 已提交
913 914
	acpi_status status;
	int ret = 0;
L
Linus Torvalds 已提交
915

916
	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
L
Linus Torvalds 已提交
917

918
	ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
L
Linus Torvalds 已提交
919 920 921 922
	if (!ec_ecdt) {
		ret = -ENOMEM;
		goto error;
	}
923
	memset(ec_ecdt, 0, sizeof(struct acpi_ec));
L
Linus Torvalds 已提交
924

L
Len Brown 已提交
925 926
	status = acpi_get_devices(ACPI_EC_HID,
				  acpi_fake_ecdt_callback, NULL, NULL);
L
Linus Torvalds 已提交
927 928 929 930
	if (ACPI_FAILURE(status)) {
		kfree(ec_ecdt);
		ec_ecdt = NULL;
		ret = -ENODEV;
931
		ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
L
Linus Torvalds 已提交
932 933 934
		goto error;
	}
	return 0;
935
  error:
L
Linus Torvalds 已提交
936 937 938
	return ret;
}

L
Len Brown 已提交
939
static int __init acpi_ec_get_real_ecdt(void)
L
Luming Yu 已提交
940
{
L
Len Brown 已提交
941 942
	acpi_status status;
	struct acpi_table_ecdt *ecdt_ptr;
L
Luming Yu 已提交
943

L
Len Brown 已提交
944 945 946
	status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
					 (struct acpi_table_header **)
					 &ecdt_ptr);
L
Luming Yu 已提交
947 948 949
	if (ACPI_FAILURE(status))
		return -ENODEV;

950
	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
L
Luming Yu 已提交
951 952 953 954

	/*
	 * Generate a temporary ec context to use until the namespace is scanned
	 */
955
	ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
L
Luming Yu 已提交
956 957
	if (!ec_ecdt)
		return -ENOMEM;
958
	memset(ec_ecdt, 0, sizeof(struct acpi_ec));
L
Luming Yu 已提交
959

960 961 962
	init_MUTEX(&ec_ecdt->sem);
	if (acpi_ec_mode == EC_INTR) {
		init_waitqueue_head(&ec_ecdt->wait);
L
Luming Yu 已提交
963
	}
964 965 966 967
	ec_ecdt->command_addr = ecdt_ptr->ec_control;
	ec_ecdt->status_addr = ecdt_ptr->ec_control;
	ec_ecdt->data_addr = ecdt_ptr->ec_data;
	ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit;
L
Linus Torvalds 已提交
968
	/* use the GL just to be safe */
969 970
	ec_ecdt->global_lock = TRUE;
	ec_ecdt->uid = ecdt_ptr->uid;
L
Linus Torvalds 已提交
971

L
Len Brown 已提交
972
	status =
973
	    acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle);
L
Linus Torvalds 已提交
974 975 976 977 978
	if (ACPI_FAILURE(status)) {
		goto error;
	}

	return 0;
979 980
  error:
	ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
L
Linus Torvalds 已提交
981 982 983 984 985 986 987
	kfree(ec_ecdt);
	ec_ecdt = NULL;

	return -ENODEV;
}

static int __initdata acpi_fake_ecdt_enabled;
L
Len Brown 已提交
988
int __init acpi_ec_ecdt_probe(void)
L
Linus Torvalds 已提交
989
{
L
Len Brown 已提交
990 991
	acpi_status status;
	int ret;
L
Linus Torvalds 已提交
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004

	ret = acpi_ec_get_real_ecdt();
	/* Try to make a fake ECDT */
	if (ret && acpi_fake_ecdt_enabled) {
		ret = acpi_ec_fake_ecdt();
	}

	if (ret)
		return 0;

	/*
	 * Install GPE handler
	 */
1005
	status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe_bit,
L
Len Brown 已提交
1006 1007
					  ACPI_GPE_EDGE_TRIGGERED,
					  &acpi_ec_gpe_handler, ec_ecdt);
L
Linus Torvalds 已提交
1008 1009 1010
	if (ACPI_FAILURE(status)) {
		goto error;
	}
1011 1012
	acpi_set_gpe_type(NULL, ec_ecdt->gpe_bit, ACPI_GPE_TYPE_RUNTIME);
	acpi_enable_gpe(NULL, ec_ecdt->gpe_bit, ACPI_NOT_ISR);
L
Len Brown 已提交
1013 1014 1015 1016 1017 1018

	status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
						    ACPI_ADR_SPACE_EC,
						    &acpi_ec_space_handler,
						    &acpi_ec_space_setup,
						    ec_ecdt);
L
Linus Torvalds 已提交
1019
	if (ACPI_FAILURE(status)) {
1020
		acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit,
L
Len Brown 已提交
1021
					&acpi_ec_gpe_handler);
L
Linus Torvalds 已提交
1022 1023 1024 1025 1026
		goto error;
	}

	return 0;

L
Len Brown 已提交
1027
      error:
1028
	ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
L
Linus Torvalds 已提交
1029 1030 1031 1032 1033 1034
	kfree(ec_ecdt);
	ec_ecdt = NULL;

	return -ENODEV;
}

L
Len Brown 已提交
1035
static int __init acpi_ec_init(void)
L
Linus Torvalds 已提交
1036
{
L
Len Brown 已提交
1037
	int result = 0;
L
Linus Torvalds 已提交
1038 1039 1040


	if (acpi_disabled)
1041
		return 0;
L
Linus Torvalds 已提交
1042 1043 1044

	acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
	if (!acpi_ec_dir)
1045
		return -ENODEV;
L
Linus Torvalds 已提交
1046 1047 1048 1049 1050

	/* Now register the driver for the EC */
	result = acpi_bus_register_driver(&acpi_ec_driver);
	if (result < 0) {
		remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1051
		return -ENODEV;
L
Linus Torvalds 已提交
1052 1053
	}

1054
	return result;
L
Linus Torvalds 已提交
1055 1056 1057 1058 1059 1060
}

subsys_initcall(acpi_ec_init);

/* EC driver currently not unloadable */
#if 0
L
Len Brown 已提交
1061
static void __exit acpi_ec_exit(void)
L
Linus Torvalds 已提交
1062 1063 1064 1065 1066 1067
{

	acpi_bus_unregister_driver(&acpi_ec_driver);

	remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);

1068
	return;
L
Linus Torvalds 已提交
1069
}
L
Len Brown 已提交
1070
#endif				/* 0 */
L
Linus Torvalds 已提交
1071 1072 1073 1074

static int __init acpi_fake_ecdt_setup(char *str)
{
	acpi_fake_ecdt_enabled = 1;
1075
	return 1;
L
Linus Torvalds 已提交
1076
}
1077

L
Linus Torvalds 已提交
1078
__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
1079
static int __init acpi_ec_set_intr_mode(char *str)
L
Luming Yu 已提交
1080
{
1081
	int intr;
1082

1083
	if (!get_option(&str, &intr))
1084 1085
		return 0;

1086
	if (intr) {
1087
		acpi_ec_mode = EC_INTR;
1088
	} else {
1089
		acpi_ec_mode = EC_POLL;
1090
	}
1091 1092 1093
	acpi_ec_driver.ops.add = acpi_ec_add;
	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "EC %s mode.\n", intr ? "interrupt" : "polling"));

1094
	return 1;
L
Luming Yu 已提交
1095
}
L
Len Brown 已提交
1096

1097
__setup("ec_intr=", acpi_ec_set_intr_mode);