blob: 876b3b0fd09c486d8bbef2f55bb3567500abe545 [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 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 { }
122};
123
124/*
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500125 * Some Fujitsu notebooks are having trouble with touchpads if
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 * active multiplexing mode is activated. Luckily they don't have
127 * external PS/2 ports so we can safely disable it.
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500128 * ... apparently some Toshibas don't like MUX mode either and
129 * die horrible death on reboot.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 */
131static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
132 {
133 .ident = "Fujitsu Lifebook P7010/P7010D",
134 .matches = {
135 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
136 DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
137 },
138 },
139 {
Dmitry Torokhovbb06ec32006-12-08 01:36:32 -0500140 .ident = "Fujitsu Lifebook P7010",
141 .matches = {
142 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
143 DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
144 },
145 },
146 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 .ident = "Fujitsu Lifebook P5020D",
148 .matches = {
149 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
150 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
151 },
152 },
153 {
154 .ident = "Fujitsu Lifebook S2000",
155 .matches = {
156 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
157 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
158 },
159 },
160 {
Dmitry Torokhovb4ff99b2005-05-28 02:12:10 -0500161 .ident = "Fujitsu Lifebook S6230",
162 .matches = {
163 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
164 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
165 },
166 },
167 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 .ident = "Fujitsu T70H",
169 .matches = {
170 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
171 DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
172 },
173 },
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500174 {
Vojtech Pavlik20f07942005-07-11 01:06:28 -0500175 .ident = "Fujitsu-Siemens Lifebook T3010",
176 .matches = {
177 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
178 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
179 },
180 },
181 {
Dmitry Torokhov7545c242005-09-04 01:42:10 -0500182 .ident = "Fujitsu-Siemens Lifebook E4010",
183 .matches = {
184 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
185 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
186 },
187 },
188 {
Jiri Kosina3f79b1e2008-01-30 16:34:52 -0500189 .ident = "Fujitsu-Siemens Amilo Pro 2010",
190 .matches = {
191 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
192 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2010"),
193 },
194 },
195 {
Jiri Kosinaefd51842008-06-06 00:56:43 -0400196 .ident = "Fujitsu-Siemens Amilo Pro 2030",
197 .matches = {
198 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
199 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
200 },
201 },
202 {
Dmitry Torokhov6e782582007-03-16 00:59:42 -0400203 /*
Dmitry Torokhovcc8310e2007-04-25 00:40:32 -0400204 * No data is coming from the touchscreen unless KBC
205 * is in legacy mode.
206 */
207 .ident = "Panasonic CF-29",
208 .matches = {
209 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
210 DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
211 },
212 },
213 {
214 /*
Dmitry Torokhov6e782582007-03-16 00:59:42 -0400215 * Errors on MUX ports are reported without raising AUXDATA
216 * causing "spurious NAK" messages.
217 */
218 .ident = "HP Pavilion DV4017EA",
219 .matches = {
220 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
221 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
222 },
223 },
224 {
Dmitry Torokhov9d9d50b2007-06-28 00:44:27 -0400225 /*
226 * Like DV4017EA does not raise AUXERR for errors on MUX ports.
227 */
228 .ident = "HP Pavilion ZT1000",
229 .matches = {
230 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
231 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Notebook PC"),
232 DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook ZT1000"),
233 },
234 },
235 {
Elvis Pranskevichus749aea72007-09-04 23:18:21 -0400236 /*
237 * Like DV4017EA does not raise AUXERR for errors on MUX ports.
238 */
239 .ident = "HP Pavilion DV4270ca",
240 .matches = {
241 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
242 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EH476UA#ABL)"),
243 },
244 },
245 {
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500246 .ident = "Toshiba P10",
247 .matches = {
248 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
249 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
250 },
251 },
Dmitry Torokhov865190c2005-07-11 01:06:06 -0500252 {
Dmitry Torokhova91eaa12006-09-14 01:31:06 -0400253 .ident = "Toshiba Equium A110",
254 .matches = {
255 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
256 DMI_MATCH(DMI_PRODUCT_NAME, "EQUIUM A110"),
257 },
258 },
259 {
Dmitry Torokhov865190c2005-07-11 01:06:06 -0500260 .ident = "Alienware Sentia",
261 .matches = {
262 DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
263 DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
264 },
265 },
Dmitry Torokhov4eb38ac2005-12-21 00:51:51 -0500266 {
267 .ident = "Sharp Actius MM20",
268 .matches = {
269 DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
270 DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
271 },
272 },
Vojtech Pavlik3dd01a82006-01-14 00:24:06 -0500273 {
274 .ident = "Sony Vaio FS-115b",
275 .matches = {
276 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
277 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
278 },
279 },
Cjacker Huange2df4522006-08-08 23:38:22 -0400280 {
281 .ident = "Amoi M636/A737",
282 .matches = {
283 DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
284 DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
285 },
286 },
Jiri Kosina2a2dcd62008-03-10 03:08:54 -0700287 {
288 .ident = "Lenovo 3000 n100",
289 .matches = {
290 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
291 DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"),
292 },
293 },
Jiri Kosina0376bce2008-07-03 10:45:38 -0400294 {
295 .ident = "Acer Aspire 1360",
296 .matches = {
297 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
298 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1360"),
299 },
300 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 { }
302};
303
Jiri Kosinac3a34f42008-05-28 01:10:52 -0400304#ifdef CONFIG_PNP
305static struct dmi_system_id __initdata i8042_dmi_nopnp_table[] = {
306 {
307 .ident = "Intel MBO Desktop D845PESV",
308 .matches = {
309 DMI_MATCH(DMI_BOARD_NAME, "D845PESV"),
310 DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
311 },
312 },
313 { }
314};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315#endif
316
Carlos Corbacho8987fec2008-01-21 01:04:40 -0500317/*
318 * Some Wistron based laptops need us to explicitly enable the 'Dritek
319 * keyboard extension' to make their extra keys start generating scancodes.
320 * Originally, this was just confined to older laptops, but a few Acer laptops
321 * have turned up in 2007 that also need this again.
322 */
323static struct dmi_system_id __initdata i8042_dmi_dritek_table[] = {
324 {
325 .ident = "Acer Aspire 5630",
326 .matches = {
327 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
328 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5630"),
329 },
330 },
331 {
332 .ident = "Acer Aspire 5650",
333 .matches = {
334 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
335 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5650"),
336 },
337 },
338 {
339 .ident = "Acer Aspire 5680",
340 .matches = {
341 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
342 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5680"),
343 },
344 },
345 {
Carlos Corbacho5799ddb2008-01-30 16:34:12 -0500346 .ident = "Acer Aspire 9110",
347 .matches = {
348 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
349 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 9110"),
350 },
351 },
352 {
Bruno Prémont65e660a2008-05-20 13:47:28 -0400353 .ident = "Acer TravelMate 660",
354 .matches = {
355 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
356 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 660"),
357 },
358 },
359 {
Carlos Corbacho8987fec2008-01-21 01:04:40 -0500360 .ident = "Acer TravelMate 2490",
361 .matches = {
362 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
363 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"),
364 },
365 },
366 { }
367};
368
369#endif /* CONFIG_X86 */
370
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371#ifdef CONFIG_PNP
372#include <linux/pnp.h>
373
374static int i8042_pnp_kbd_registered;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500375static unsigned int i8042_pnp_kbd_devices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376static int i8042_pnp_aux_registered;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500377static unsigned int i8042_pnp_aux_devices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378
379static int i8042_pnp_command_reg;
380static int i8042_pnp_data_reg;
381static int i8042_pnp_kbd_irq;
382static int i8042_pnp_aux_irq;
383
384static char i8042_pnp_kbd_name[32];
385static char i8042_pnp_aux_name[32];
386
387static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
388{
389 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
390 i8042_pnp_data_reg = pnp_port_start(dev,0);
391
392 if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
393 i8042_pnp_command_reg = pnp_port_start(dev, 1);
394
395 if (pnp_irq_valid(dev,0))
396 i8042_pnp_kbd_irq = pnp_irq(dev, 0);
397
Roel Kluin8c6deb92008-04-18 00:25:18 -0400398 strlcpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 if (strlen(pnp_dev_name(dev))) {
Roel Kluin8c6deb92008-04-18 00:25:18 -0400400 strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
401 strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 }
403
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500404 i8042_pnp_kbd_devices++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 return 0;
406}
407
408static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
409{
410 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
411 i8042_pnp_data_reg = pnp_port_start(dev,0);
412
413 if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
414 i8042_pnp_command_reg = pnp_port_start(dev, 1);
415
416 if (pnp_irq_valid(dev, 0))
417 i8042_pnp_aux_irq = pnp_irq(dev, 0);
418
Roel Kluin8c6deb92008-04-18 00:25:18 -0400419 strlcpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 if (strlen(pnp_dev_name(dev))) {
Roel Kluin8c6deb92008-04-18 00:25:18 -0400421 strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
422 strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 }
424
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500425 i8042_pnp_aux_devices++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 return 0;
427}
428
429static struct pnp_device_id pnp_kbd_devids[] = {
430 { .id = "PNP0303", .driver_data = 0 },
431 { .id = "PNP030b", .driver_data = 0 },
432 { .id = "", },
433};
434
435static struct pnp_driver i8042_pnp_kbd_driver = {
436 .name = "i8042 kbd",
437 .id_table = pnp_kbd_devids,
438 .probe = i8042_pnp_kbd_probe,
439};
440
441static struct pnp_device_id pnp_aux_devids[] = {
Dmitry Torokhovb9973952007-04-25 00:40:53 -0400442 { .id = "FJC6000", .driver_data = 0 },
443 { .id = "FJC6001", .driver_data = 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 { .id = "PNP0f03", .driver_data = 0 },
445 { .id = "PNP0f0b", .driver_data = 0 },
446 { .id = "PNP0f0e", .driver_data = 0 },
447 { .id = "PNP0f12", .driver_data = 0 },
448 { .id = "PNP0f13", .driver_data = 0 },
449 { .id = "PNP0f19", .driver_data = 0 },
450 { .id = "PNP0f1c", .driver_data = 0 },
451 { .id = "SYN0801", .driver_data = 0 },
452 { .id = "", },
453};
454
455static struct pnp_driver i8042_pnp_aux_driver = {
456 .name = "i8042 aux",
457 .id_table = pnp_aux_devids,
458 .probe = i8042_pnp_aux_probe,
459};
460
461static void i8042_pnp_exit(void)
462{
Kurt Garloff74af42b2005-05-28 02:11:38 -0500463 if (i8042_pnp_kbd_registered) {
464 i8042_pnp_kbd_registered = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 pnp_unregister_driver(&i8042_pnp_kbd_driver);
Kurt Garloff74af42b2005-05-28 02:11:38 -0500466 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467
Kurt Garloff74af42b2005-05-28 02:11:38 -0500468 if (i8042_pnp_aux_registered) {
469 i8042_pnp_aux_registered = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 pnp_unregister_driver(&i8042_pnp_aux_driver);
Kurt Garloff74af42b2005-05-28 02:11:38 -0500471 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472}
473
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500474static int __init i8042_pnp_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475{
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500476 char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400477 int pnp_data_busted = 0;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500478 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
Jiri Kosinac3a34f42008-05-28 01:10:52 -0400480#ifdef CONFIG_X86
481 if (dmi_check_system(i8042_dmi_nopnp_table))
482 i8042_nopnp = 1;
483#endif
484
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 if (i8042_nopnp) {
Vojtech Pavlik39fa5802005-05-28 02:11:16 -0500486 printk(KERN_INFO "i8042: PNP detection disabled\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 return 0;
488 }
489
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500490 err = pnp_register_driver(&i8042_pnp_kbd_driver);
491 if (!err)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 i8042_pnp_kbd_registered = 1;
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500493
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500494 err = pnp_register_driver(&i8042_pnp_aux_driver);
495 if (!err)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 i8042_pnp_aux_registered = 1;
497
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500498 if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 i8042_pnp_exit();
500#if defined(__ia64__)
501 return -ENODEV;
502#else
Dmitry Torokhov5a72afc2005-05-28 02:11:32 -0500503 printk(KERN_INFO "PNP: No PS/2 controller found. Probing ports directly.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 return 0;
505#endif
506 }
507
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500508 if (i8042_pnp_kbd_devices)
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500509 snprintf(kbd_irq_str, sizeof(kbd_irq_str),
510 "%d", i8042_pnp_kbd_irq);
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500511 if (i8042_pnp_aux_devices)
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500512 snprintf(aux_irq_str, sizeof(aux_irq_str),
513 "%d", i8042_pnp_aux_irq);
514
515 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 -0500516 i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500517 i8042_pnp_aux_name,
518 i8042_pnp_data_reg, i8042_pnp_command_reg,
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500519 kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500520 aux_irq_str);
521
522#if defined(__ia64__)
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500523 if (!i8042_pnp_kbd_devices)
Dmitry Torokhov945ef0d2005-09-04 01:42:00 -0500524 i8042_nokbd = 1;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500525 if (!i8042_pnp_aux_devices)
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500526 i8042_noaux = 1;
527#endif
528
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400530 i8042_pnp_data_reg != i8042_data_reg) ||
531 !i8042_pnp_data_reg) {
532 printk(KERN_WARNING
533 "PNP: PS/2 controller has invalid data port %#x; "
534 "using default %#x\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 i8042_pnp_data_reg, i8042_data_reg);
536 i8042_pnp_data_reg = i8042_data_reg;
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400537 pnp_data_busted = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 }
539
540 if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400541 i8042_pnp_command_reg != i8042_command_reg) ||
542 !i8042_pnp_command_reg) {
543 printk(KERN_WARNING
544 "PNP: PS/2 controller has invalid command port %#x; "
545 "using default %#x\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 i8042_pnp_command_reg, i8042_command_reg);
547 i8042_pnp_command_reg = i8042_command_reg;
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400548 pnp_data_busted = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 }
550
Dmitry Torokhov945ef0d2005-09-04 01:42:00 -0500551 if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400552 printk(KERN_WARNING
553 "PNP: PS/2 controller doesn't have KBD irq; "
554 "using default %d\n", i8042_kbd_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 i8042_pnp_kbd_irq = i8042_kbd_irq;
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400556 pnp_data_busted = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 }
558
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500559 if (!i8042_noaux && !i8042_pnp_aux_irq) {
Dmitry Torokhov080c6522007-07-18 00:38:01 -0400560 if (!pnp_data_busted && i8042_pnp_kbd_irq) {
561 printk(KERN_WARNING
562 "PNP: PS/2 appears to have AUX port disabled, "
563 "if this is incorrect please boot with "
564 "i8042.nopnp\n");
565 i8042_noaux = 1;
566 } else {
567 printk(KERN_WARNING
568 "PNP: PS/2 controller doesn't have AUX irq; "
569 "using default %d\n", i8042_aux_irq);
570 i8042_pnp_aux_irq = i8042_aux_irq;
571 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 }
573
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 i8042_data_reg = i8042_pnp_data_reg;
575 i8042_command_reg = i8042_pnp_command_reg;
576 i8042_kbd_irq = i8042_pnp_kbd_irq;
577 i8042_aux_irq = i8042_pnp_aux_irq;
578
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 return 0;
580}
581
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500582#else
583static inline int i8042_pnp_init(void) { return 0; }
584static inline void i8042_pnp_exit(void) { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585#endif
586
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500587static int __init i8042_platform_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588{
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500589 int retval;
590
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591/*
592 * On ix86 platforms touching the i8042 data register region can do really
593 * bad things. Because of this the region is always reserved on ix86 boxes.
594 *
595 * if (!request_region(I8042_DATA_REG, 16, "i8042"))
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500596 * return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 */
598
599 i8042_kbd_irq = I8042_MAP_IRQ(1);
600 i8042_aux_irq = I8042_MAP_IRQ(12);
601
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500602 retval = i8042_pnp_init();
603 if (retval)
604 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605
606#if defined(__ia64__)
607 i8042_reset = 1;
608#endif
609
Jiri Kosinac3a34f42008-05-28 01:10:52 -0400610#ifdef CONFIG_X86
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 if (dmi_check_system(i8042_dmi_noloop_table))
612 i8042_noloop = 1;
613
614 if (dmi_check_system(i8042_dmi_nomux_table))
615 i8042_nomux = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616
Carlos Corbacho8987fec2008-01-21 01:04:40 -0500617 if (dmi_check_system(i8042_dmi_dritek_table))
618 i8042_dritek = 1;
619#endif /* CONFIG_X86 */
620
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500621 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622}
623
624static inline void i8042_platform_exit(void)
625{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 i8042_pnp_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627}
628
629#endif /* _I8042_X86IA64IO_H */