blob: 5d46d6491bf86a48169c465ad627c1a9a8a5ee23 [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 */
73 .ident = "ASUS P65UP5",
74 .matches = {
75 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
76 DMI_MATCH(DMI_BOARD_NAME, "P/I-P65UP5"),
77 DMI_MATCH(DMI_BOARD_VERSION, "REV 2.X"),
78 },
79 },
80 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 .ident = "Compaq Proliant 8500",
82 .matches = {
83 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
84 DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
85 DMI_MATCH(DMI_PRODUCT_VERSION, "8500"),
86 },
87 },
88 {
89 .ident = "Compaq Proliant DL760",
90 .matches = {
91 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
92 DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
93 DMI_MATCH(DMI_PRODUCT_VERSION, "DL760"),
94 },
95 },
Ben Collins6020baf2006-01-05 23:00:38 -050096 {
97 .ident = "OQO Model 01",
98 .matches = {
99 DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
100 DMI_MATCH(DMI_PRODUCT_NAME, "ZEPTO"),
101 DMI_MATCH(DMI_PRODUCT_VERSION, "00"),
102 },
103 },
Dmitry Torokhov8c4df742007-06-12 00:33:32 -0400104 {
105 /* AUX LOOP does not work properly */
106 .ident = "ULI EV4873",
107 .matches = {
108 DMI_MATCH(DMI_SYS_VENDOR, "ULI"),
109 DMI_MATCH(DMI_PRODUCT_NAME, "EV4873"),
110 DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
111 },
112 },
Jiri Kosina8bf42152007-11-21 14:17:38 -0500113 {
114 .ident = "Microsoft Virtual Machine",
115 .matches = {
116 DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
117 DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
118 DMI_MATCH(DMI_PRODUCT_VERSION, "VS2005R2"),
119 },
120 },
Dmitry Torokhov89cdb8c2008-07-03 11:00:28 -0400121 {
122 .ident = "Medion MAM 2070",
123 .matches = {
124 DMI_MATCH(DMI_SYS_VENDOR, "Notebook"),
125 DMI_MATCH(DMI_PRODUCT_NAME, "MAM 2070"),
126 DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
127 },
128 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 { }
130};
131
132/*
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500133 * Some Fujitsu notebooks are having trouble with touchpads if
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 * active multiplexing mode is activated. Luckily they don't have
135 * external PS/2 ports so we can safely disable it.
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500136 * ... apparently some Toshibas don't like MUX mode either and
137 * die horrible death on reboot.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 */
139static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
140 {
141 .ident = "Fujitsu Lifebook P7010/P7010D",
142 .matches = {
143 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
144 DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
145 },
146 },
147 {
Dmitry Torokhovbb06ec32006-12-08 01:36:32 -0500148 .ident = "Fujitsu Lifebook P7010",
149 .matches = {
150 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
151 DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
152 },
153 },
154 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 .ident = "Fujitsu Lifebook P5020D",
156 .matches = {
157 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
158 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
159 },
160 },
161 {
162 .ident = "Fujitsu Lifebook S2000",
163 .matches = {
164 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
165 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
166 },
167 },
168 {
Dmitry Torokhovb4ff99b2005-05-28 02:12:10 -0500169 .ident = "Fujitsu Lifebook S6230",
170 .matches = {
171 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
172 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
173 },
174 },
175 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 .ident = "Fujitsu T70H",
177 .matches = {
178 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
179 DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
180 },
181 },
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500182 {
Vojtech Pavlik20f07942005-07-11 01:06:28 -0500183 .ident = "Fujitsu-Siemens Lifebook T3010",
184 .matches = {
185 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
186 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
187 },
188 },
189 {
Dmitry Torokhov7545c242005-09-04 01:42:10 -0500190 .ident = "Fujitsu-Siemens Lifebook E4010",
191 .matches = {
192 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
193 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
194 },
195 },
196 {
Jiri Kosina3f79b1e2008-01-30 16:34:52 -0500197 .ident = "Fujitsu-Siemens Amilo Pro 2010",
198 .matches = {
199 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
200 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2010"),
201 },
202 },
203 {
Jiri Kosinaefd51842008-06-06 00:56:43 -0400204 .ident = "Fujitsu-Siemens Amilo Pro 2030",
205 .matches = {
206 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
207 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
208 },
209 },
210 {
Dmitry Torokhov6e782582007-03-16 00:59:42 -0400211 /*
Dmitry Torokhovcc8310e2007-04-25 00:40:32 -0400212 * No data is coming from the touchscreen unless KBC
213 * is in legacy mode.
214 */
215 .ident = "Panasonic CF-29",
216 .matches = {
217 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
218 DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
219 },
220 },
221 {
222 /*
Dmitry Torokhov6e782582007-03-16 00:59:42 -0400223 * Errors on MUX ports are reported without raising AUXDATA
224 * causing "spurious NAK" messages.
225 */
226 .ident = "HP Pavilion DV4017EA",
227 .matches = {
228 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
229 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
230 },
231 },
232 {
Dmitry Torokhov9d9d50b2007-06-28 00:44:27 -0400233 /*
234 * Like DV4017EA does not raise AUXERR for errors on MUX ports.
235 */
236 .ident = "HP Pavilion ZT1000",
237 .matches = {
238 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
239 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Notebook PC"),
240 DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook ZT1000"),
241 },
242 },
243 {
Elvis Pranskevichus749aea72007-09-04 23:18:21 -0400244 /*
245 * Like DV4017EA does not raise AUXERR for errors on MUX ports.
246 */
247 .ident = "HP Pavilion DV4270ca",
248 .matches = {
249 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
250 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EH476UA#ABL)"),
251 },
252 },
253 {
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500254 .ident = "Toshiba P10",
255 .matches = {
256 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
257 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
258 },
259 },
Dmitry Torokhov865190c2005-07-11 01:06:06 -0500260 {
Dmitry Torokhova91eaa12006-09-14 01:31:06 -0400261 .ident = "Toshiba Equium A110",
262 .matches = {
263 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
264 DMI_MATCH(DMI_PRODUCT_NAME, "EQUIUM A110"),
265 },
266 },
267 {
Dmitry Torokhov865190c2005-07-11 01:06:06 -0500268 .ident = "Alienware Sentia",
269 .matches = {
270 DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
271 DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
272 },
273 },
Dmitry Torokhov4eb38ac2005-12-21 00:51:51 -0500274 {
275 .ident = "Sharp Actius MM20",
276 .matches = {
277 DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
278 DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
279 },
280 },
Vojtech Pavlik3dd01a82006-01-14 00:24:06 -0500281 {
282 .ident = "Sony Vaio FS-115b",
283 .matches = {
284 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
285 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
286 },
287 },
Cjacker Huange2df4522006-08-08 23:38:22 -0400288 {
289 .ident = "Amoi M636/A737",
290 .matches = {
291 DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
292 DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
293 },
294 },
Jiri Kosina2a2dcd62008-03-10 03:08:54 -0700295 {
296 .ident = "Lenovo 3000 n100",
297 .matches = {
298 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
299 DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"),
300 },
301 },
Jiri Kosina0376bce2008-07-03 10:45:38 -0400302 {
303 .ident = "Acer Aspire 1360",
304 .matches = {
305 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
306 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1360"),
307 },
308 },
Jiri Kosina5b5b43d2008-07-03 11:00:28 -0400309 {
310 .ident = "Gericom Bellagio",
311 .matches = {
312 DMI_MATCH(DMI_SYS_VENDOR, "Gericom"),
313 DMI_MATCH(DMI_PRODUCT_NAME, "N34AS6"),
314 },
315 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 { }
317};
318
Jiri Kosinac3a34f42008-05-28 01:10:52 -0400319#ifdef CONFIG_PNP
320static struct dmi_system_id __initdata i8042_dmi_nopnp_table[] = {
321 {
322 .ident = "Intel MBO Desktop D845PESV",
323 .matches = {
324 DMI_MATCH(DMI_BOARD_NAME, "D845PESV"),
325 DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
326 },
327 },
328 { }
329};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330#endif
331
Carlos Corbacho8987fec2008-01-21 01:04:40 -0500332/*
333 * Some Wistron based laptops need us to explicitly enable the 'Dritek
334 * keyboard extension' to make their extra keys start generating scancodes.
335 * Originally, this was just confined to older laptops, but a few Acer laptops
336 * have turned up in 2007 that also need this again.
337 */
338static struct dmi_system_id __initdata i8042_dmi_dritek_table[] = {
339 {
340 .ident = "Acer Aspire 5630",
341 .matches = {
342 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
343 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5630"),
344 },
345 },
346 {
347 .ident = "Acer Aspire 5650",
348 .matches = {
349 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
350 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5650"),
351 },
352 },
353 {
354 .ident = "Acer Aspire 5680",
355 .matches = {
356 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
357 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5680"),
358 },
359 },
360 {
Carlos Corbacho0e7e92f2008-07-07 08:55:31 -0400361 .ident = "Acer Aspire 5720",
362 .matches = {
363 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
364 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5720"),
365 },
366 },
367 {
Carlos Corbacho5799ddb2008-01-30 16:34:12 -0500368 .ident = "Acer Aspire 9110",
369 .matches = {
370 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
371 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 9110"),
372 },
373 },
374 {
Bruno Prémont65e660a2008-05-20 13:47:28 -0400375 .ident = "Acer TravelMate 660",
376 .matches = {
377 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
378 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 660"),
379 },
380 },
381 {
Carlos Corbacho8987fec2008-01-21 01:04:40 -0500382 .ident = "Acer TravelMate 2490",
383 .matches = {
384 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
385 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"),
386 },
387 },
388 { }
389};
390
391#endif /* CONFIG_X86 */
392
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393#ifdef CONFIG_PNP
394#include <linux/pnp.h>
395
396static int i8042_pnp_kbd_registered;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500397static unsigned int i8042_pnp_kbd_devices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398static int i8042_pnp_aux_registered;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500399static unsigned int i8042_pnp_aux_devices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
401static int i8042_pnp_command_reg;
402static int i8042_pnp_data_reg;
403static int i8042_pnp_kbd_irq;
404static int i8042_pnp_aux_irq;
405
406static char i8042_pnp_kbd_name[32];
407static char i8042_pnp_aux_name[32];
408
409static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
410{
411 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
412 i8042_pnp_data_reg = pnp_port_start(dev,0);
413
414 if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
415 i8042_pnp_command_reg = pnp_port_start(dev, 1);
416
417 if (pnp_irq_valid(dev,0))
418 i8042_pnp_kbd_irq = pnp_irq(dev, 0);
419
Roel Kluin8c6deb92008-04-18 00:25:18 -0400420 strlcpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 if (strlen(pnp_dev_name(dev))) {
Roel Kluin8c6deb92008-04-18 00:25:18 -0400422 strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
423 strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 }
425
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500426 i8042_pnp_kbd_devices++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 return 0;
428}
429
430static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
431{
432 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
433 i8042_pnp_data_reg = pnp_port_start(dev,0);
434
435 if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
436 i8042_pnp_command_reg = pnp_port_start(dev, 1);
437
438 if (pnp_irq_valid(dev, 0))
439 i8042_pnp_aux_irq = pnp_irq(dev, 0);
440
Roel Kluin8c6deb92008-04-18 00:25:18 -0400441 strlcpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 if (strlen(pnp_dev_name(dev))) {
Roel Kluin8c6deb92008-04-18 00:25:18 -0400443 strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
444 strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 }
446
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500447 i8042_pnp_aux_devices++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 return 0;
449}
450
451static struct pnp_device_id pnp_kbd_devids[] = {
452 { .id = "PNP0303", .driver_data = 0 },
453 { .id = "PNP030b", .driver_data = 0 },
454 { .id = "", },
455};
456
457static struct pnp_driver i8042_pnp_kbd_driver = {
458 .name = "i8042 kbd",
459 .id_table = pnp_kbd_devids,
460 .probe = i8042_pnp_kbd_probe,
461};
462
463static struct pnp_device_id pnp_aux_devids[] = {
Dmitry Torokhovb9973952007-04-25 00:40:53 -0400464 { .id = "FJC6000", .driver_data = 0 },
465 { .id = "FJC6001", .driver_data = 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 { .id = "PNP0f03", .driver_data = 0 },
467 { .id = "PNP0f0b", .driver_data = 0 },
468 { .id = "PNP0f0e", .driver_data = 0 },
469 { .id = "PNP0f12", .driver_data = 0 },
470 { .id = "PNP0f13", .driver_data = 0 },
471 { .id = "PNP0f19", .driver_data = 0 },
472 { .id = "PNP0f1c", .driver_data = 0 },
473 { .id = "SYN0801", .driver_data = 0 },
474 { .id = "", },
475};
476
477static struct pnp_driver i8042_pnp_aux_driver = {
478 .name = "i8042 aux",
479 .id_table = pnp_aux_devids,
480 .probe = i8042_pnp_aux_probe,
481};
482
483static void i8042_pnp_exit(void)
484{
Kurt Garloff74af42b2005-05-28 02:11:38 -0500485 if (i8042_pnp_kbd_registered) {
486 i8042_pnp_kbd_registered = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 pnp_unregister_driver(&i8042_pnp_kbd_driver);
Kurt Garloff74af42b2005-05-28 02:11:38 -0500488 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489
Kurt Garloff74af42b2005-05-28 02:11:38 -0500490 if (i8042_pnp_aux_registered) {
491 i8042_pnp_aux_registered = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 pnp_unregister_driver(&i8042_pnp_aux_driver);
Kurt Garloff74af42b2005-05-28 02:11:38 -0500493 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494}
495
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500496static int __init i8042_pnp_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497{
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500498 char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400499 int pnp_data_busted = 0;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500500 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501
Jiri Kosinac3a34f42008-05-28 01:10:52 -0400502#ifdef CONFIG_X86
503 if (dmi_check_system(i8042_dmi_nopnp_table))
504 i8042_nopnp = 1;
505#endif
506
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 if (i8042_nopnp) {
Vojtech Pavlik39fa5802005-05-28 02:11:16 -0500508 printk(KERN_INFO "i8042: PNP detection disabled\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 return 0;
510 }
511
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500512 err = pnp_register_driver(&i8042_pnp_kbd_driver);
513 if (!err)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 i8042_pnp_kbd_registered = 1;
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500515
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500516 err = pnp_register_driver(&i8042_pnp_aux_driver);
517 if (!err)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 i8042_pnp_aux_registered = 1;
519
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500520 if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 i8042_pnp_exit();
522#if defined(__ia64__)
523 return -ENODEV;
524#else
Dmitry Torokhov5a72afc2005-05-28 02:11:32 -0500525 printk(KERN_INFO "PNP: No PS/2 controller found. Probing ports directly.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 return 0;
527#endif
528 }
529
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500530 if (i8042_pnp_kbd_devices)
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500531 snprintf(kbd_irq_str, sizeof(kbd_irq_str),
532 "%d", i8042_pnp_kbd_irq);
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500533 if (i8042_pnp_aux_devices)
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500534 snprintf(aux_irq_str, sizeof(aux_irq_str),
535 "%d", i8042_pnp_aux_irq);
536
537 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 -0500538 i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500539 i8042_pnp_aux_name,
540 i8042_pnp_data_reg, i8042_pnp_command_reg,
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500541 kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500542 aux_irq_str);
543
544#if defined(__ia64__)
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500545 if (!i8042_pnp_kbd_devices)
Dmitry Torokhov945ef0d2005-09-04 01:42:00 -0500546 i8042_nokbd = 1;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500547 if (!i8042_pnp_aux_devices)
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500548 i8042_noaux = 1;
549#endif
550
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400552 i8042_pnp_data_reg != i8042_data_reg) ||
553 !i8042_pnp_data_reg) {
554 printk(KERN_WARNING
555 "PNP: PS/2 controller has invalid data port %#x; "
556 "using default %#x\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 i8042_pnp_data_reg, i8042_data_reg);
558 i8042_pnp_data_reg = i8042_data_reg;
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400559 pnp_data_busted = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 }
561
562 if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400563 i8042_pnp_command_reg != i8042_command_reg) ||
564 !i8042_pnp_command_reg) {
565 printk(KERN_WARNING
566 "PNP: PS/2 controller has invalid command port %#x; "
567 "using default %#x\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 i8042_pnp_command_reg, i8042_command_reg);
569 i8042_pnp_command_reg = i8042_command_reg;
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400570 pnp_data_busted = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 }
572
Dmitry Torokhov945ef0d2005-09-04 01:42:00 -0500573 if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400574 printk(KERN_WARNING
575 "PNP: PS/2 controller doesn't have KBD irq; "
576 "using default %d\n", i8042_kbd_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 i8042_pnp_kbd_irq = i8042_kbd_irq;
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400578 pnp_data_busted = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 }
580
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500581 if (!i8042_noaux && !i8042_pnp_aux_irq) {
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400582 if (!pnp_data_busted && i8042_pnp_kbd_irq) {
583 printk(KERN_WARNING
584 "PNP: PS/2 appears to have AUX port disabled, "
585 "if this is incorrect please boot with "
586 "i8042.nopnp\n");
587 i8042_noaux = 1;
588 } else {
589 printk(KERN_WARNING
590 "PNP: PS/2 controller doesn't have AUX irq; "
591 "using default %d\n", i8042_aux_irq);
592 i8042_pnp_aux_irq = i8042_aux_irq;
593 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 }
595
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 i8042_data_reg = i8042_pnp_data_reg;
597 i8042_command_reg = i8042_pnp_command_reg;
598 i8042_kbd_irq = i8042_pnp_kbd_irq;
599 i8042_aux_irq = i8042_pnp_aux_irq;
600
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 return 0;
602}
603
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500604#else
605static inline int i8042_pnp_init(void) { return 0; }
606static inline void i8042_pnp_exit(void) { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607#endif
608
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500609static int __init i8042_platform_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610{
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500611 int retval;
612
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613/*
614 * On ix86 platforms touching the i8042 data register region can do really
615 * bad things. Because of this the region is always reserved on ix86 boxes.
616 *
617 * if (!request_region(I8042_DATA_REG, 16, "i8042"))
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500618 * return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 */
620
621 i8042_kbd_irq = I8042_MAP_IRQ(1);
622 i8042_aux_irq = I8042_MAP_IRQ(12);
623
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500624 retval = i8042_pnp_init();
625 if (retval)
626 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627
628#if defined(__ia64__)
629 i8042_reset = 1;
630#endif
631
Jiri Kosinac3a34f42008-05-28 01:10:52 -0400632#ifdef CONFIG_X86
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 if (dmi_check_system(i8042_dmi_noloop_table))
634 i8042_noloop = 1;
635
636 if (dmi_check_system(i8042_dmi_nomux_table))
637 i8042_nomux = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638
Carlos Corbacho8987fec2008-01-21 01:04:40 -0500639 if (dmi_check_system(i8042_dmi_dritek_table))
640 i8042_dritek = 1;
641#endif /* CONFIG_X86 */
642
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500643 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644}
645
646static inline void i8042_platform_exit(void)
647{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 i8042_pnp_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649}
650
651#endif /* _I8042_X86IA64IO_H */