blob: 9fe92ed4d2b968b1f14b1badc2a21727da00064e [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
66#if defined(__i386__)
67
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 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 { }
105};
106
107/*
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500108 * Some Fujitsu notebooks are having trouble with touchpads if
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 * active multiplexing mode is activated. Luckily they don't have
110 * external PS/2 ports so we can safely disable it.
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500111 * ... apparently some Toshibas don't like MUX mode either and
112 * die horrible death on reboot.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 */
114static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
115 {
116 .ident = "Fujitsu Lifebook P7010/P7010D",
117 .matches = {
118 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
119 DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
120 },
121 },
122 {
Dmitry Torokhovbb06ec3c2006-12-08 01:36:32 -0500123 .ident = "Fujitsu Lifebook P7010",
124 .matches = {
125 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
126 DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
127 },
128 },
129 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 .ident = "Fujitsu Lifebook P5020D",
131 .matches = {
132 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
133 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
134 },
135 },
136 {
137 .ident = "Fujitsu Lifebook S2000",
138 .matches = {
139 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
140 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
141 },
142 },
143 {
Dmitry Torokhovb4ff99b2005-05-28 02:12:10 -0500144 .ident = "Fujitsu Lifebook S6230",
145 .matches = {
146 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
147 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
148 },
149 },
150 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 .ident = "Fujitsu T70H",
152 .matches = {
153 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
154 DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
155 },
156 },
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500157 {
Vojtech Pavlik20f07942005-07-11 01:06:28 -0500158 .ident = "Fujitsu-Siemens Lifebook T3010",
159 .matches = {
160 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
161 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
162 },
163 },
164 {
Dmitry Torokhov7545c242005-09-04 01:42:10 -0500165 .ident = "Fujitsu-Siemens Lifebook E4010",
166 .matches = {
167 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
168 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
169 },
170 },
171 {
Dmitry Torokhov6e782582007-03-16 00:59:42 -0400172 /*
Dmitry Torokhovcc8310e2007-04-25 00:40:32 -0400173 * No data is coming from the touchscreen unless KBC
174 * is in legacy mode.
175 */
176 .ident = "Panasonic CF-29",
177 .matches = {
178 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
179 DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
180 },
181 },
182 {
183 /*
Dmitry Torokhov6e782582007-03-16 00:59:42 -0400184 * Errors on MUX ports are reported without raising AUXDATA
185 * causing "spurious NAK" messages.
186 */
187 .ident = "HP Pavilion DV4017EA",
188 .matches = {
189 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
190 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
191 },
192 },
193 {
Dmitry Torokhov59311de2005-05-28 02:12:05 -0500194 .ident = "Toshiba P10",
195 .matches = {
196 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
197 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
198 },
199 },
Dmitry Torokhov865190c2005-07-11 01:06:06 -0500200 {
Dmitry Torokhova91eaa12006-09-14 01:31:06 -0400201 .ident = "Toshiba Equium A110",
202 .matches = {
203 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
204 DMI_MATCH(DMI_PRODUCT_NAME, "EQUIUM A110"),
205 },
206 },
207 {
Dmitry Torokhov865190c2005-07-11 01:06:06 -0500208 .ident = "Alienware Sentia",
209 .matches = {
210 DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
211 DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
212 },
213 },
Dmitry Torokhov4eb38ac2005-12-21 00:51:51 -0500214 {
215 .ident = "Sharp Actius MM20",
216 .matches = {
217 DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
218 DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
219 },
220 },
Vojtech Pavlik3dd01a82006-01-14 00:24:06 -0500221 {
222 .ident = "Sony Vaio FS-115b",
223 .matches = {
224 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
225 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
226 },
227 },
Cjacker Huange2df4522006-08-08 23:38:22 -0400228 {
229 .ident = "Amoi M636/A737",
230 .matches = {
231 DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
232 DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
233 },
234 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 { }
236};
237
238
239
240#endif
241
242
243#ifdef CONFIG_PNP
244#include <linux/pnp.h>
245
246static int i8042_pnp_kbd_registered;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500247static unsigned int i8042_pnp_kbd_devices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248static int i8042_pnp_aux_registered;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500249static unsigned int i8042_pnp_aux_devices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250
251static int i8042_pnp_command_reg;
252static int i8042_pnp_data_reg;
253static int i8042_pnp_kbd_irq;
254static int i8042_pnp_aux_irq;
255
256static char i8042_pnp_kbd_name[32];
257static char i8042_pnp_aux_name[32];
258
259static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
260{
261 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
262 i8042_pnp_data_reg = pnp_port_start(dev,0);
263
264 if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
265 i8042_pnp_command_reg = pnp_port_start(dev, 1);
266
267 if (pnp_irq_valid(dev,0))
268 i8042_pnp_kbd_irq = pnp_irq(dev, 0);
269
270 strncpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
271 if (strlen(pnp_dev_name(dev))) {
272 strncat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
273 strncat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
274 }
275
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500276 i8042_pnp_kbd_devices++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 return 0;
278}
279
280static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
281{
282 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
283 i8042_pnp_data_reg = pnp_port_start(dev,0);
284
285 if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
286 i8042_pnp_command_reg = pnp_port_start(dev, 1);
287
288 if (pnp_irq_valid(dev, 0))
289 i8042_pnp_aux_irq = pnp_irq(dev, 0);
290
291 strncpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
292 if (strlen(pnp_dev_name(dev))) {
293 strncat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
294 strncat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
295 }
296
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500297 i8042_pnp_aux_devices++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 return 0;
299}
300
301static struct pnp_device_id pnp_kbd_devids[] = {
302 { .id = "PNP0303", .driver_data = 0 },
303 { .id = "PNP030b", .driver_data = 0 },
304 { .id = "", },
305};
306
307static struct pnp_driver i8042_pnp_kbd_driver = {
308 .name = "i8042 kbd",
309 .id_table = pnp_kbd_devids,
310 .probe = i8042_pnp_kbd_probe,
311};
312
313static struct pnp_device_id pnp_aux_devids[] = {
Dmitry Torokhovb9973952007-04-25 00:40:53 -0400314 { .id = "FJC6000", .driver_data = 0 },
315 { .id = "FJC6001", .driver_data = 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 { .id = "PNP0f03", .driver_data = 0 },
317 { .id = "PNP0f0b", .driver_data = 0 },
318 { .id = "PNP0f0e", .driver_data = 0 },
319 { .id = "PNP0f12", .driver_data = 0 },
320 { .id = "PNP0f13", .driver_data = 0 },
321 { .id = "PNP0f19", .driver_data = 0 },
322 { .id = "PNP0f1c", .driver_data = 0 },
323 { .id = "SYN0801", .driver_data = 0 },
324 { .id = "", },
325};
326
327static struct pnp_driver i8042_pnp_aux_driver = {
328 .name = "i8042 aux",
329 .id_table = pnp_aux_devids,
330 .probe = i8042_pnp_aux_probe,
331};
332
333static void i8042_pnp_exit(void)
334{
Kurt Garloff74af42b2005-05-28 02:11:38 -0500335 if (i8042_pnp_kbd_registered) {
336 i8042_pnp_kbd_registered = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 pnp_unregister_driver(&i8042_pnp_kbd_driver);
Kurt Garloff74af42b2005-05-28 02:11:38 -0500338 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339
Kurt Garloff74af42b2005-05-28 02:11:38 -0500340 if (i8042_pnp_aux_registered) {
341 i8042_pnp_aux_registered = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 pnp_unregister_driver(&i8042_pnp_aux_driver);
Kurt Garloff74af42b2005-05-28 02:11:38 -0500343 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344}
345
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500346static int __init i8042_pnp_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347{
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500348 char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500349 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350
351 if (i8042_nopnp) {
Vojtech Pavlik39fa5802005-05-28 02:11:16 -0500352 printk(KERN_INFO "i8042: PNP detection disabled\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 return 0;
354 }
355
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500356 err = pnp_register_driver(&i8042_pnp_kbd_driver);
357 if (!err)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 i8042_pnp_kbd_registered = 1;
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500359
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500360 err = pnp_register_driver(&i8042_pnp_aux_driver);
361 if (!err)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 i8042_pnp_aux_registered = 1;
363
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500364 if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 i8042_pnp_exit();
366#if defined(__ia64__)
367 return -ENODEV;
368#else
Dmitry Torokhov5a72afc2005-05-28 02:11:32 -0500369 printk(KERN_INFO "PNP: No PS/2 controller found. Probing ports directly.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 return 0;
371#endif
372 }
373
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500374 if (i8042_pnp_kbd_devices)
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500375 snprintf(kbd_irq_str, sizeof(kbd_irq_str),
376 "%d", i8042_pnp_kbd_irq);
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500377 if (i8042_pnp_aux_devices)
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500378 snprintf(aux_irq_str, sizeof(aux_irq_str),
379 "%d", i8042_pnp_aux_irq);
380
381 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 -0500382 i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500383 i8042_pnp_aux_name,
384 i8042_pnp_data_reg, i8042_pnp_command_reg,
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500385 kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500386 aux_irq_str);
387
388#if defined(__ia64__)
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500389 if (!i8042_pnp_kbd_devices)
Dmitry Torokhov945ef0d2005-09-04 01:42:00 -0500390 i8042_nokbd = 1;
Bjorn Helgaas2bfc3c62006-03-14 00:12:24 -0500391 if (!i8042_pnp_aux_devices)
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500392 i8042_noaux = 1;
393#endif
394
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
396 i8042_pnp_data_reg != i8042_data_reg) || !i8042_pnp_data_reg) {
397 printk(KERN_WARNING "PNP: PS/2 controller has invalid data port %#x; using default %#x\n",
398 i8042_pnp_data_reg, i8042_data_reg);
399 i8042_pnp_data_reg = i8042_data_reg;
400 }
401
402 if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
403 i8042_pnp_command_reg != i8042_command_reg) || !i8042_pnp_command_reg) {
404 printk(KERN_WARNING "PNP: PS/2 controller has invalid command port %#x; using default %#x\n",
405 i8042_pnp_command_reg, i8042_command_reg);
406 i8042_pnp_command_reg = i8042_command_reg;
407 }
408
Dmitry Torokhov945ef0d2005-09-04 01:42:00 -0500409 if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500410 printk(KERN_WARNING "PNP: PS/2 controller doesn't have KBD irq; using default %d\n", i8042_kbd_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 i8042_pnp_kbd_irq = i8042_kbd_irq;
412 }
413
Dmitry Torokhovc3d31e72005-09-04 01:41:51 -0500414 if (!i8042_noaux && !i8042_pnp_aux_irq) {
415 printk(KERN_WARNING "PNP: PS/2 controller doesn't have AUX irq; using default %d\n", i8042_aux_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 i8042_pnp_aux_irq = i8042_aux_irq;
417 }
418
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 i8042_data_reg = i8042_pnp_data_reg;
420 i8042_command_reg = i8042_pnp_command_reg;
421 i8042_kbd_irq = i8042_pnp_kbd_irq;
422 i8042_aux_irq = i8042_pnp_aux_irq;
423
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 return 0;
425}
426
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500427#else
428static inline int i8042_pnp_init(void) { return 0; }
429static inline void i8042_pnp_exit(void) { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430#endif
431
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500432static int __init i8042_platform_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433{
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500434 int retval;
435
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436/*
437 * On ix86 platforms touching the i8042 data register region can do really
438 * bad things. Because of this the region is always reserved on ix86 boxes.
439 *
440 * if (!request_region(I8042_DATA_REG, 16, "i8042"))
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500441 * return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 */
443
444 i8042_kbd_irq = I8042_MAP_IRQ(1);
445 i8042_aux_irq = I8042_MAP_IRQ(12);
446
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500447 retval = i8042_pnp_init();
448 if (retval)
449 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450
451#if defined(__ia64__)
452 i8042_reset = 1;
453#endif
454
455#if defined(__i386__)
456 if (dmi_check_system(i8042_dmi_noloop_table))
457 i8042_noloop = 1;
458
459 if (dmi_check_system(i8042_dmi_nomux_table))
460 i8042_nomux = 1;
461#endif
462
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -0500463 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464}
465
466static inline void i8042_platform_exit(void)
467{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 i8042_pnp_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469}
470
471#endif /* _I8042_X86IA64IO_H */