blob: fe732a574ec2c5774d729248c1ba2a6e3470a00d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _I8042_X86IA64IO_H
2#define _I8042_X86IA64IO_H
3
4/*
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 */
9
10/*
11 * Names.
12 */
13
14#define I8042_KBD_PHYS_DESC "isa0060/serio0"
15#define I8042_AUX_PHYS_DESC "isa0060/serio1"
16#define I8042_MUX_PHYS_DESC "isa0060/serio%d"
17
18/*
19 * IRQs.
20 */
21
22#if defined(__ia64__)
23# define I8042_MAP_IRQ(x) isa_irq_to_vector((x))
24#else
25# define I8042_MAP_IRQ(x) (x)
26#endif
27
28#define I8042_KBD_IRQ i8042_kbd_irq
29#define I8042_AUX_IRQ i8042_aux_irq
30
31static int i8042_kbd_irq;
32static int i8042_aux_irq;
33
34/*
35 * Register numbers.
36 */
37
38#define I8042_COMMAND_REG i8042_command_reg
39#define I8042_STATUS_REG i8042_command_reg
40#define I8042_DATA_REG i8042_data_reg
41
42static int i8042_command_reg = 0x64;
43static int i8042_data_reg = 0x60;
44
45
46static inline int i8042_read_data(void)
47{
48 return inb(I8042_DATA_REG);
49}
50
51static inline int i8042_read_status(void)
52{
53 return inb(I8042_STATUS_REG);
54}
55
56static inline void i8042_write_data(int val)
57{
58 outb(val, I8042_DATA_REG);
59}
60
61static inline void i8042_write_command(int val)
62{
63 outb(val, I8042_COMMAND_REG);
64}
65
Jiri Kosinac3a34f42008-05-28 01:10:52 -040066#ifdef CONFIG_X86
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68#include <linux/dmi.h>
69
70static struct dmi_system_id __initdata i8042_dmi_noloop_table[] = {
71 {
Dmitry Torokhov90245c12007-06-12 00:33:27 -040072 /* AUX LOOP command does not raise AUX IRQ */
Dmitry Torokhov87d91732008-07-19 00:35:43 -040073 .ident = "Arima-Rioworks HDAMB",
74 .matches = {
75 DMI_MATCH(DMI_BOARD_VENDOR, "RIOWORKS"),
76 DMI_MATCH(DMI_BOARD_NAME, "HDAMB"),
77 DMI_MATCH(DMI_BOARD_VERSION, "Rev E"),
78 },
79 },
80 {
81 /* AUX LOOP command does not raise AUX IRQ */
Dmitry Torokhov90245c12007-06-12 00:33:27 -040082 .ident = "ASUS P65UP5",
83 .matches = {
84 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
85 DMI_MATCH(DMI_BOARD_NAME, "P/I-P65UP5"),
86 DMI_MATCH(DMI_BOARD_VERSION, "REV 2.X"),
87 },
88 },
89 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 .ident = "Compaq Proliant 8500",
91 .matches = {
92 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
93 DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
94 DMI_MATCH(DMI_PRODUCT_VERSION, "8500"),
95 },
96 },
97 {
98 .ident = "Compaq Proliant DL760",
99 .matches = {
100 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
101 DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
102 DMI_MATCH(DMI_PRODUCT_VERSION, "DL760"),
103 },
104 },
Ben Collins6020baf2006-01-05 23:00:38 -0500105 {
106 .ident = "OQO Model 01",
107 .matches = {
108 DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
109 DMI_MATCH(DMI_PRODUCT_NAME, "ZEPTO"),
110 DMI_MATCH(DMI_PRODUCT_VERSION, "00"),
111 },
112 },
Dmitry Torokhov8c4df742007-06-12 00:33:32 -0400113 {
114 /* AUX LOOP does not work properly */
115 .ident = "ULI EV4873",
116 .matches = {
117 DMI_MATCH(DMI_SYS_VENDOR, "ULI"),
118 DMI_MATCH(DMI_PRODUCT_NAME, "EV4873"),
119 DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
120 },
121 },
Jiri Kosina8bf42152007-11-21 14:17:38 -0500122 {
123 .ident = "Microsoft Virtual Machine",
124 .matches = {
125 DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
126 DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
127 DMI_MATCH(DMI_PRODUCT_VERSION, "VS2005R2"),
128 },
129 },
Dmitry Torokhov89cdb8c2008-07-03 11:00:28 -0400130 {
131 .ident = "Medion MAM 2070",
132 .matches = {
133 DMI_MATCH(DMI_SYS_VENDOR, "Notebook"),
134 DMI_MATCH(DMI_PRODUCT_NAME, "MAM 2070"),
135 DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
136 },
137 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 { }
139};
140
141/*
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500142 * Some Fujitsu notebooks are having trouble with touchpads if
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 * active multiplexing mode is activated. Luckily they don't have
144 * external PS/2 ports so we can safely disable it.
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500145 * ... apparently some Toshibas don't like MUX mode either and
146 * die horrible death on reboot.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 */
148static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
149 {
150 .ident = "Fujitsu Lifebook P7010/P7010D",
151 .matches = {
152 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
153 DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
154 },
155 },
156 {
Dmitry Torokhovbb06ec3c2006-12-08 01:36:32 -0500157 .ident = "Fujitsu Lifebook P7010",
158 .matches = {
159 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
160 DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
161 },
162 },
163 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 .ident = "Fujitsu Lifebook P5020D",
165 .matches = {
166 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
167 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
168 },
169 },
170 {
171 .ident = "Fujitsu Lifebook S2000",
172 .matches = {
173 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
174 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
175 },
176 },
177 {
Dmitry Torokhovb4ff99b2005-05-28 02:12:10 -0500178 .ident = "Fujitsu Lifebook S6230",
179 .matches = {
180 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
181 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
182 },
183 },
184 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 .ident = "Fujitsu T70H",
186 .matches = {
187 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
188 DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
189 },
190 },
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500191 {
Vojtech Pavlik20f07942005-07-11 01:06:28 -0500192 .ident = "Fujitsu-Siemens Lifebook T3010",
193 .matches = {
194 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
195 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
196 },
197 },
198 {
Dmitry Torokhov7545c242005-09-04 01:42:10 -0500199 .ident = "Fujitsu-Siemens Lifebook E4010",
200 .matches = {
201 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
202 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
203 },
204 },
205 {
Jiri Kosina3f79b1e2008-01-30 16:34:52 -0500206 .ident = "Fujitsu-Siemens Amilo Pro 2010",
207 .matches = {
208 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
209 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2010"),
210 },
211 },
212 {
Jiri Kosinaefd51842008-06-06 00:56:43 -0400213 .ident = "Fujitsu-Siemens Amilo Pro 2030",
214 .matches = {
215 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
216 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
217 },
218 },
219 {
Dmitry Torokhov6e782582007-03-16 00:59:42 -0400220 /*
Dmitry Torokhovcc8310e2007-04-25 00:40:32 -0400221 * No data is coming from the touchscreen unless KBC
222 * is in legacy mode.
223 */
224 .ident = "Panasonic CF-29",
225 .matches = {
226 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
227 DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
228 },
229 },
230 {
231 /*
Dmitry Torokhov6e782582007-03-16 00:59:42 -0400232 * Errors on MUX ports are reported without raising AUXDATA
233 * causing "spurious NAK" messages.
234 */
235 .ident = "HP Pavilion DV4017EA",
236 .matches = {
237 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
238 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
239 },
240 },
241 {
Dmitry Torokhov9d9d50b2007-06-28 00:44:27 -0400242 /*
243 * Like DV4017EA does not raise AUXERR for errors on MUX ports.
244 */
245 .ident = "HP Pavilion ZT1000",
246 .matches = {
247 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
248 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Notebook PC"),
249 DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook ZT1000"),
250 },
251 },
252 {
Elvis Pranskevichus749aea72007-09-04 23:18:21 -0400253 /*
254 * Like DV4017EA does not raise AUXERR for errors on MUX ports.
255 */
256 .ident = "HP Pavilion DV4270ca",
257 .matches = {
258 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
259 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EH476UA#ABL)"),
260 },
261 },
262 {
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500263 .ident = "Toshiba P10",
264 .matches = {
265 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
266 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
267 },
268 },
Dmitry Torokhov865190c2005-07-11 01:06:06 -0500269 {
Dmitry Torokhova91eaa12006-09-14 01:31:06 -0400270 .ident = "Toshiba Equium A110",
271 .matches = {
272 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
273 DMI_MATCH(DMI_PRODUCT_NAME, "EQUIUM A110"),
274 },
275 },
276 {
Dmitry Torokhov865190c2005-07-11 01:06:06 -0500277 .ident = "Alienware Sentia",
278 .matches = {
279 DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
280 DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
281 },
282 },
Dmitry Torokhov4eb38ac2005-12-21 00:51:51 -0500283 {
284 .ident = "Sharp Actius MM20",
285 .matches = {
286 DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
287 DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
288 },
289 },
Vojtech Pavlik3dd01a82006-01-14 00:24:06 -0500290 {
291 .ident = "Sony Vaio FS-115b",
292 .matches = {
293 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
294 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
295 },
296 },
Cjacker Huange2df4522006-08-08 23:38:22 -0400297 {
298 .ident = "Amoi M636/A737",
299 .matches = {
300 DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
301 DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
302 },
303 },
Jiri Kosina2a2dcd62008-03-10 03:08:54 -0700304 {
305 .ident = "Lenovo 3000 n100",
306 .matches = {
307 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
308 DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"),
309 },
310 },
Jiri Kosina0376bce2008-07-03 10:45:38 -0400311 {
312 .ident = "Acer Aspire 1360",
313 .matches = {
314 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
315 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1360"),
316 },
317 },
Jiri Kosina5b5b43d2008-07-03 11:00:28 -0400318 {
319 .ident = "Gericom Bellagio",
320 .matches = {
321 DMI_MATCH(DMI_SYS_VENDOR, "Gericom"),
322 DMI_MATCH(DMI_PRODUCT_NAME, "N34AS6"),
323 },
324 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 { }
326};
327
Jiri Kosinac3a34f42008-05-28 01:10:52 -0400328#ifdef CONFIG_PNP
329static struct dmi_system_id __initdata i8042_dmi_nopnp_table[] = {
330 {
331 .ident = "Intel MBO Desktop D845PESV",
332 .matches = {
333 DMI_MATCH(DMI_BOARD_NAME, "D845PESV"),
334 DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
335 },
336 },
337 { }
338};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339#endif
340
Carlos Corbacho8987fec2008-01-21 01:04:40 -0500341/*
342 * Some Wistron based laptops need us to explicitly enable the 'Dritek
343 * keyboard extension' to make their extra keys start generating scancodes.
344 * Originally, this was just confined to older laptops, but a few Acer laptops
345 * have turned up in 2007 that also need this again.
346 */
347static struct dmi_system_id __initdata i8042_dmi_dritek_table[] = {
348 {
349 .ident = "Acer Aspire 5630",
350 .matches = {
351 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
352 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5630"),
353 },
354 },
355 {
356 .ident = "Acer Aspire 5650",
357 .matches = {
358 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
359 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5650"),
360 },
361 },
362 {
363 .ident = "Acer Aspire 5680",
364 .matches = {
365 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
366 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5680"),
367 },
368 },
369 {
Carlos Corbacho0e7e92f2008-07-07 08:55:31 -0400370 .ident = "Acer Aspire 5720",
371 .matches = {
372 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
373 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5720"),
374 },
375 },
376 {
Carlos Corbacho5799ddb2008-01-30 16:34:12 -0500377 .ident = "Acer Aspire 9110",
378 .matches = {
379 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
380 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 9110"),
381 },
382 },
383 {
Bruno Prémont65e660a2008-05-20 13:47:28 -0400384 .ident = "Acer TravelMate 660",
385 .matches = {
386 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
387 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 660"),
388 },
389 },
390 {
Carlos Corbacho8987fec2008-01-21 01:04:40 -0500391 .ident = "Acer TravelMate 2490",
392 .matches = {
393 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
394 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"),
395 },
396 },
397 { }
398};
399
400#endif /* CONFIG_X86 */
401
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402#ifdef CONFIG_PNP
403#include <linux/pnp.h>
404
405static int i8042_pnp_kbd_registered;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500406static unsigned int i8042_pnp_kbd_devices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407static int i8042_pnp_aux_registered;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500408static unsigned int i8042_pnp_aux_devices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409
410static int i8042_pnp_command_reg;
411static int i8042_pnp_data_reg;
412static int i8042_pnp_kbd_irq;
413static int i8042_pnp_aux_irq;
414
415static char i8042_pnp_kbd_name[32];
416static char i8042_pnp_aux_name[32];
417
418static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
419{
420 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
421 i8042_pnp_data_reg = pnp_port_start(dev,0);
422
423 if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
424 i8042_pnp_command_reg = pnp_port_start(dev, 1);
425
426 if (pnp_irq_valid(dev,0))
427 i8042_pnp_kbd_irq = pnp_irq(dev, 0);
428
Roel Kluin8c6deb92008-04-18 00:25:18 -0400429 strlcpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 if (strlen(pnp_dev_name(dev))) {
Roel Kluin8c6deb92008-04-18 00:25:18 -0400431 strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
432 strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 }
434
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500435 i8042_pnp_kbd_devices++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 return 0;
437}
438
439static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
440{
441 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
442 i8042_pnp_data_reg = pnp_port_start(dev,0);
443
444 if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
445 i8042_pnp_command_reg = pnp_port_start(dev, 1);
446
447 if (pnp_irq_valid(dev, 0))
448 i8042_pnp_aux_irq = pnp_irq(dev, 0);
449
Roel Kluin8c6deb92008-04-18 00:25:18 -0400450 strlcpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 if (strlen(pnp_dev_name(dev))) {
Roel Kluin8c6deb92008-04-18 00:25:18 -0400452 strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
453 strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 }
455
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500456 i8042_pnp_aux_devices++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 return 0;
458}
459
460static struct pnp_device_id pnp_kbd_devids[] = {
461 { .id = "PNP0303", .driver_data = 0 },
462 { .id = "PNP030b", .driver_data = 0 },
463 { .id = "", },
464};
465
466static struct pnp_driver i8042_pnp_kbd_driver = {
467 .name = "i8042 kbd",
468 .id_table = pnp_kbd_devids,
469 .probe = i8042_pnp_kbd_probe,
470};
471
472static struct pnp_device_id pnp_aux_devids[] = {
Dmitry Torokhovb9973952007-04-25 00:40:53 -0400473 { .id = "FJC6000", .driver_data = 0 },
474 { .id = "FJC6001", .driver_data = 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 { .id = "PNP0f03", .driver_data = 0 },
476 { .id = "PNP0f0b", .driver_data = 0 },
477 { .id = "PNP0f0e", .driver_data = 0 },
478 { .id = "PNP0f12", .driver_data = 0 },
479 { .id = "PNP0f13", .driver_data = 0 },
480 { .id = "PNP0f19", .driver_data = 0 },
481 { .id = "PNP0f1c", .driver_data = 0 },
482 { .id = "SYN0801", .driver_data = 0 },
483 { .id = "", },
484};
485
486static struct pnp_driver i8042_pnp_aux_driver = {
487 .name = "i8042 aux",
488 .id_table = pnp_aux_devids,
489 .probe = i8042_pnp_aux_probe,
490};
491
492static void i8042_pnp_exit(void)
493{
Kurt Garloff74af42b2005-05-28 02:11:38 -0500494 if (i8042_pnp_kbd_registered) {
495 i8042_pnp_kbd_registered = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 pnp_unregister_driver(&i8042_pnp_kbd_driver);
Kurt Garloff74af42b2005-05-28 02:11:38 -0500497 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498
Kurt Garloff74af42b2005-05-28 02:11:38 -0500499 if (i8042_pnp_aux_registered) {
500 i8042_pnp_aux_registered = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 pnp_unregister_driver(&i8042_pnp_aux_driver);
Kurt Garloff74af42b2005-05-28 02:11:38 -0500502 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503}
504
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500505static int __init i8042_pnp_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506{
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500507 char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400508 int pnp_data_busted = 0;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500509 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510
Jiri Kosinac3a34f42008-05-28 01:10:52 -0400511#ifdef CONFIG_X86
512 if (dmi_check_system(i8042_dmi_nopnp_table))
513 i8042_nopnp = 1;
514#endif
515
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 if (i8042_nopnp) {
Vojtech Pavlik39fa5802005-05-28 02:11:16 -0500517 printk(KERN_INFO "i8042: PNP detection disabled\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 return 0;
519 }
520
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500521 err = pnp_register_driver(&i8042_pnp_kbd_driver);
522 if (!err)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 i8042_pnp_kbd_registered = 1;
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500524
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500525 err = pnp_register_driver(&i8042_pnp_aux_driver);
526 if (!err)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 i8042_pnp_aux_registered = 1;
528
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500529 if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 i8042_pnp_exit();
531#if defined(__ia64__)
532 return -ENODEV;
533#else
Dmitry Torokhov5a72afc2005-05-28 02:11:32 -0500534 printk(KERN_INFO "PNP: No PS/2 controller found. Probing ports directly.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 return 0;
536#endif
537 }
538
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500539 if (i8042_pnp_kbd_devices)
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500540 snprintf(kbd_irq_str, sizeof(kbd_irq_str),
541 "%d", i8042_pnp_kbd_irq);
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500542 if (i8042_pnp_aux_devices)
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500543 snprintf(aux_irq_str, sizeof(aux_irq_str),
544 "%d", i8042_pnp_aux_irq);
545
546 printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500547 i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500548 i8042_pnp_aux_name,
549 i8042_pnp_data_reg, i8042_pnp_command_reg,
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500550 kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500551 aux_irq_str);
552
553#if defined(__ia64__)
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500554 if (!i8042_pnp_kbd_devices)
Dmitry Torokhov945ef0d2005-09-04 01:42:00 -0500555 i8042_nokbd = 1;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500556 if (!i8042_pnp_aux_devices)
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500557 i8042_noaux = 1;
558#endif
559
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400561 i8042_pnp_data_reg != i8042_data_reg) ||
562 !i8042_pnp_data_reg) {
563 printk(KERN_WARNING
564 "PNP: PS/2 controller has invalid data port %#x; "
565 "using default %#x\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 i8042_pnp_data_reg, i8042_data_reg);
567 i8042_pnp_data_reg = i8042_data_reg;
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400568 pnp_data_busted = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 }
570
571 if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400572 i8042_pnp_command_reg != i8042_command_reg) ||
573 !i8042_pnp_command_reg) {
574 printk(KERN_WARNING
575 "PNP: PS/2 controller has invalid command port %#x; "
576 "using default %#x\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 i8042_pnp_command_reg, i8042_command_reg);
578 i8042_pnp_command_reg = i8042_command_reg;
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400579 pnp_data_busted = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 }
581
Dmitry Torokhov945ef0d2005-09-04 01:42:00 -0500582 if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400583 printk(KERN_WARNING
584 "PNP: PS/2 controller doesn't have KBD irq; "
585 "using default %d\n", i8042_kbd_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 i8042_pnp_kbd_irq = i8042_kbd_irq;
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400587 pnp_data_busted = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 }
589
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500590 if (!i8042_noaux && !i8042_pnp_aux_irq) {
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400591 if (!pnp_data_busted && i8042_pnp_kbd_irq) {
592 printk(KERN_WARNING
593 "PNP: PS/2 appears to have AUX port disabled, "
594 "if this is incorrect please boot with "
595 "i8042.nopnp\n");
596 i8042_noaux = 1;
597 } else {
598 printk(KERN_WARNING
599 "PNP: PS/2 controller doesn't have AUX irq; "
600 "using default %d\n", i8042_aux_irq);
601 i8042_pnp_aux_irq = i8042_aux_irq;
602 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 }
604
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 i8042_data_reg = i8042_pnp_data_reg;
606 i8042_command_reg = i8042_pnp_command_reg;
607 i8042_kbd_irq = i8042_pnp_kbd_irq;
608 i8042_aux_irq = i8042_pnp_aux_irq;
609
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 return 0;
611}
612
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500613#else
614static inline int i8042_pnp_init(void) { return 0; }
615static inline void i8042_pnp_exit(void) { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616#endif
617
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500618static int __init i8042_platform_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619{
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500620 int retval;
621
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622/*
623 * On ix86 platforms touching the i8042 data register region can do really
624 * bad things. Because of this the region is always reserved on ix86 boxes.
625 *
626 * if (!request_region(I8042_DATA_REG, 16, "i8042"))
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500627 * return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 */
629
630 i8042_kbd_irq = I8042_MAP_IRQ(1);
631 i8042_aux_irq = I8042_MAP_IRQ(12);
632
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500633 retval = i8042_pnp_init();
634 if (retval)
635 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636
637#if defined(__ia64__)
638 i8042_reset = 1;
639#endif
640
Jiri Kosinac3a34f42008-05-28 01:10:52 -0400641#ifdef CONFIG_X86
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 if (dmi_check_system(i8042_dmi_noloop_table))
643 i8042_noloop = 1;
644
645 if (dmi_check_system(i8042_dmi_nomux_table))
646 i8042_nomux = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647
Carlos Corbacho8987fec2008-01-21 01:04:40 -0500648 if (dmi_check_system(i8042_dmi_dritek_table))
649 i8042_dritek = 1;
650#endif /* CONFIG_X86 */
651
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500652 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653}
654
655static inline void i8042_platform_exit(void)
656{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 i8042_pnp_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658}
659
660#endif /* _I8042_X86IA64IO_H */