2 * Sony Programmable I/O Control Device driver for VAIO
4 * Copyright (C) 2001-2005 Stelian Pop <stelian@popies.net>
6 * Copyright (C) 2005 Narayanan R S <nars@kadamba.org>
8 * Copyright (C) 2001-2002 AlcĂ´ve <www.alcove.com>
10 * Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au>
12 * Copyright (C) 2001 Junichi Morita <jun1m@mars.dti.ne.jp>
14 * Copyright (C) 2000 Takaya Kinjo <t-kinjo@tc4.so-net.ne.jp>
16 * Copyright (C) 2000 Andrew Tridgell <tridge@valinux.com>
18 * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras.
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36 #include <linux/config.h>
37 #include <linux/module.h>
38 #include <linux/input.h>
39 #include <linux/pci.h>
40 #include <linux/sched.h>
41 #include <linux/init.h>
42 #include <linux/interrupt.h>
43 #include <linux/miscdevice.h>
44 #include <linux/poll.h>
45 #include <linux/delay.h>
46 #include <linux/wait.h>
47 #include <linux/acpi.h>
48 #include <linux/dmi.h>
49 #include <linux/err.h>
50 #include <linux/kfifo.h>
52 #include <asm/uaccess.h>
54 #include <asm/system.h>
56 #include <linux/sonypi.h>
58 #define SONYPI_DRIVER_VERSION "1.26"
60 MODULE_AUTHOR("Stelian Pop <stelian@popies.net>");
61 MODULE_DESCRIPTION("Sony Programmable I/O Control Device driver");
62 MODULE_LICENSE("GPL");
63 MODULE_VERSION(SONYPI_DRIVER_VERSION);
65 static int minor = -1;
66 module_param(minor, int, 0);
67 MODULE_PARM_DESC(minor,
68 "minor number of the misc device, default is -1 (automatic)");
70 static int verbose; /* = 0 */
71 module_param(verbose, int, 0644);
72 MODULE_PARM_DESC(verbose, "be verbose, default is 0 (no)");
74 static int fnkeyinit; /* = 0 */
75 module_param(fnkeyinit, int, 0444);
76 MODULE_PARM_DESC(fnkeyinit,
77 "set this if your Fn keys do not generate any event");
79 static int camera; /* = 0 */
80 module_param(camera, int, 0444);
81 MODULE_PARM_DESC(camera,
82 "set this if you have a MotionEye camera (PictureBook series)");
84 static int compat; /* = 0 */
85 module_param(compat, int, 0444);
86 MODULE_PARM_DESC(compat,
87 "set this if you want to enable backward compatibility mode");
89 static unsigned long mask = 0xffffffff;
90 module_param(mask, ulong, 0644);
91 MODULE_PARM_DESC(mask,
92 "set this to the mask of event you want to enable (see doc)");
94 static int useinput = 1;
95 module_param(useinput, int, 0444);
96 MODULE_PARM_DESC(useinput,
97 "set this if you would like sonypi to feed events to the input subsystem");
99 #define SONYPI_DEVICE_MODEL_TYPE1 1
100 #define SONYPI_DEVICE_MODEL_TYPE2 2
102 /* type1 models use those */
103 #define SONYPI_IRQ_PORT 0x8034
104 #define SONYPI_IRQ_SHIFT 22
105 #define SONYPI_BASE 0x50
106 #define SONYPI_G10A (SONYPI_BASE+0x14)
107 #define SONYPI_TYPE1_REGION_SIZE 0x08
108 #define SONYPI_TYPE1_EVTYPE_OFFSET 0x04
110 /* type2 series specifics */
111 #define SONYPI_SIRQ 0x9b
112 #define SONYPI_SLOB 0x9c
113 #define SONYPI_SHIB 0x9d
114 #define SONYPI_TYPE2_REGION_SIZE 0x20
115 #define SONYPI_TYPE2_EVTYPE_OFFSET 0x12
117 /* battery / brightness addresses */
118 #define SONYPI_BAT_FLAGS 0x81
119 #define SONYPI_LCD_LIGHT 0x96
120 #define SONYPI_BAT1_PCTRM 0xa0
121 #define SONYPI_BAT1_LEFT 0xa2
122 #define SONYPI_BAT1_MAXRT 0xa4
123 #define SONYPI_BAT2_PCTRM 0xa8
124 #define SONYPI_BAT2_LEFT 0xaa
125 #define SONYPI_BAT2_MAXRT 0xac
126 #define SONYPI_BAT1_MAXTK 0xb0
127 #define SONYPI_BAT1_FULL 0xb2
128 #define SONYPI_BAT2_MAXTK 0xb8
129 #define SONYPI_BAT2_FULL 0xba
131 /* FAN0 information (reverse engineered from ACPI tables) */
132 #define SONYPI_FAN0_STATUS 0x93
133 #define SONYPI_TEMP_STATUS 0xC1
135 /* ioports used for brightness and type2 events */
136 #define SONYPI_DATA_IOPORT 0x62
137 #define SONYPI_CST_IOPORT 0x66
139 /* The set of possible ioports */
140 struct sonypi_ioport_list {
145 static struct sonypi_ioport_list sonypi_type1_ioport_list[] = {
146 { 0x10c0, 0x10c4 }, /* looks like the default on C1Vx */
154 static struct sonypi_ioport_list sonypi_type2_ioport_list[] = {
162 /* The set of possible interrupts */
163 struct sonypi_irq_list {
168 static struct sonypi_irq_list sonypi_type1_irq_list[] = {
169 { 11, 0x2 }, /* IRQ 11, GO22=0,GO23=1 in AML */
170 { 10, 0x1 }, /* IRQ 10, GO22=1,GO23=0 in AML */
171 { 5, 0x0 }, /* IRQ 5, GO22=0,GO23=0 in AML */
172 { 0, 0x3 } /* no IRQ, GO22=1,GO23=1 in AML */
175 static struct sonypi_irq_list sonypi_type2_irq_list[] = {
176 { 11, 0x80 }, /* IRQ 11, 0x80 in SIRQ in AML */
177 { 10, 0x40 }, /* IRQ 10, 0x40 in SIRQ in AML */
178 { 9, 0x20 }, /* IRQ 9, 0x20 in SIRQ in AML */
179 { 6, 0x10 }, /* IRQ 6, 0x10 in SIRQ in AML */
180 { 0, 0x00 } /* no IRQ, 0x00 in SIRQ in AML */
183 #define SONYPI_CAMERA_BRIGHTNESS 0
184 #define SONYPI_CAMERA_CONTRAST 1
185 #define SONYPI_CAMERA_HUE 2
186 #define SONYPI_CAMERA_COLOR 3
187 #define SONYPI_CAMERA_SHARPNESS 4
189 #define SONYPI_CAMERA_PICTURE 5
190 #define SONYPI_CAMERA_EXPOSURE_MASK 0xC
191 #define SONYPI_CAMERA_WHITE_BALANCE_MASK 0x3
192 #define SONYPI_CAMERA_PICTURE_MODE_MASK 0x30
193 #define SONYPI_CAMERA_MUTE_MASK 0x40
195 /* the rest don't need a loop until not 0xff */
196 #define SONYPI_CAMERA_AGC 6
197 #define SONYPI_CAMERA_AGC_MASK 0x30
198 #define SONYPI_CAMERA_SHUTTER_MASK 0x7
200 #define SONYPI_CAMERA_SHUTDOWN_REQUEST 7
201 #define SONYPI_CAMERA_CONTROL 0x10
203 #define SONYPI_CAMERA_STATUS 7
204 #define SONYPI_CAMERA_STATUS_READY 0x2
205 #define SONYPI_CAMERA_STATUS_POSITION 0x4
207 #define SONYPI_DIRECTION_BACKWARDS 0x4
209 #define SONYPI_CAMERA_REVISION 8
210 #define SONYPI_CAMERA_ROMVERSION 9
213 #define SONYPI_JOGGER_MASK 0x00000001
214 #define SONYPI_CAPTURE_MASK 0x00000002
215 #define SONYPI_FNKEY_MASK 0x00000004
216 #define SONYPI_BLUETOOTH_MASK 0x00000008
217 #define SONYPI_PKEY_MASK 0x00000010
218 #define SONYPI_BACK_MASK 0x00000020
219 #define SONYPI_HELP_MASK 0x00000040
220 #define SONYPI_LID_MASK 0x00000080
221 #define SONYPI_ZOOM_MASK 0x00000100
222 #define SONYPI_THUMBPHRASE_MASK 0x00000200
223 #define SONYPI_MEYE_MASK 0x00000400
224 #define SONYPI_MEMORYSTICK_MASK 0x00000800
225 #define SONYPI_BATTERY_MASK 0x00001000
227 struct sonypi_event {
232 /* The set of possible button release events */
233 static struct sonypi_event sonypi_releaseev[] = {
234 { 0x00, SONYPI_EVENT_ANYBUTTON_RELEASED },
238 /* The set of possible jogger events */
239 static struct sonypi_event sonypi_joggerev[] = {
240 { 0x1f, SONYPI_EVENT_JOGDIAL_UP },
241 { 0x01, SONYPI_EVENT_JOGDIAL_DOWN },
242 { 0x5f, SONYPI_EVENT_JOGDIAL_UP_PRESSED },
243 { 0x41, SONYPI_EVENT_JOGDIAL_DOWN_PRESSED },
244 { 0x1e, SONYPI_EVENT_JOGDIAL_FAST_UP },
245 { 0x02, SONYPI_EVENT_JOGDIAL_FAST_DOWN },
246 { 0x5e, SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED },
247 { 0x42, SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED },
248 { 0x1d, SONYPI_EVENT_JOGDIAL_VFAST_UP },
249 { 0x03, SONYPI_EVENT_JOGDIAL_VFAST_DOWN },
250 { 0x5d, SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED },
251 { 0x43, SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED },
252 { 0x40, SONYPI_EVENT_JOGDIAL_PRESSED },
256 /* The set of possible capture button events */
257 static struct sonypi_event sonypi_captureev[] = {
258 { 0x05, SONYPI_EVENT_CAPTURE_PARTIALPRESSED },
259 { 0x07, SONYPI_EVENT_CAPTURE_PRESSED },
260 { 0x01, SONYPI_EVENT_CAPTURE_PARTIALRELEASED },
264 /* The set of possible fnkeys events */
265 static struct sonypi_event sonypi_fnkeyev[] = {
266 { 0x10, SONYPI_EVENT_FNKEY_ESC },
267 { 0x11, SONYPI_EVENT_FNKEY_F1 },
268 { 0x12, SONYPI_EVENT_FNKEY_F2 },
269 { 0x13, SONYPI_EVENT_FNKEY_F3 },
270 { 0x14, SONYPI_EVENT_FNKEY_F4 },
271 { 0x15, SONYPI_EVENT_FNKEY_F5 },
272 { 0x16, SONYPI_EVENT_FNKEY_F6 },
273 { 0x17, SONYPI_EVENT_FNKEY_F7 },
274 { 0x18, SONYPI_EVENT_FNKEY_F8 },
275 { 0x19, SONYPI_EVENT_FNKEY_F9 },
276 { 0x1a, SONYPI_EVENT_FNKEY_F10 },
277 { 0x1b, SONYPI_EVENT_FNKEY_F11 },
278 { 0x1c, SONYPI_EVENT_FNKEY_F12 },
279 { 0x1f, SONYPI_EVENT_FNKEY_RELEASED },
280 { 0x21, SONYPI_EVENT_FNKEY_1 },
281 { 0x22, SONYPI_EVENT_FNKEY_2 },
282 { 0x31, SONYPI_EVENT_FNKEY_D },
283 { 0x32, SONYPI_EVENT_FNKEY_E },
284 { 0x33, SONYPI_EVENT_FNKEY_F },
285 { 0x34, SONYPI_EVENT_FNKEY_S },
286 { 0x35, SONYPI_EVENT_FNKEY_B },
287 { 0x36, SONYPI_EVENT_FNKEY_ONLY },
291 /* The set of possible program key events */
292 static struct sonypi_event sonypi_pkeyev[] = {
293 { 0x01, SONYPI_EVENT_PKEY_P1 },
294 { 0x02, SONYPI_EVENT_PKEY_P2 },
295 { 0x04, SONYPI_EVENT_PKEY_P3 },
296 { 0x5c, SONYPI_EVENT_PKEY_P1 },
300 /* The set of possible bluetooth events */
301 static struct sonypi_event sonypi_blueev[] = {
302 { 0x55, SONYPI_EVENT_BLUETOOTH_PRESSED },
303 { 0x59, SONYPI_EVENT_BLUETOOTH_ON },
304 { 0x5a, SONYPI_EVENT_BLUETOOTH_OFF },
308 /* The set of possible back button events */
309 static struct sonypi_event sonypi_backev[] = {
310 { 0x20, SONYPI_EVENT_BACK_PRESSED },
314 /* The set of possible help button events */
315 static struct sonypi_event sonypi_helpev[] = {
316 { 0x3b, SONYPI_EVENT_HELP_PRESSED },
321 /* The set of possible lid events */
322 static struct sonypi_event sonypi_lidev[] = {
323 { 0x51, SONYPI_EVENT_LID_CLOSED },
324 { 0x50, SONYPI_EVENT_LID_OPENED },
328 /* The set of possible zoom events */
329 static struct sonypi_event sonypi_zoomev[] = {
330 { 0x39, SONYPI_EVENT_ZOOM_PRESSED },
334 /* The set of possible thumbphrase events */
335 static struct sonypi_event sonypi_thumbphraseev[] = {
336 { 0x3a, SONYPI_EVENT_THUMBPHRASE_PRESSED },
340 /* The set of possible motioneye camera events */
341 static struct sonypi_event sonypi_meyeev[] = {
342 { 0x00, SONYPI_EVENT_MEYE_FACE },
343 { 0x01, SONYPI_EVENT_MEYE_OPPOSITE },
347 /* The set of possible memorystick events */
348 static struct sonypi_event sonypi_memorystickev[] = {
349 { 0x53, SONYPI_EVENT_MEMORYSTICK_INSERT },
350 { 0x54, SONYPI_EVENT_MEMORYSTICK_EJECT },
354 /* The set of possible battery events */
355 static struct sonypi_event sonypi_batteryev[] = {
356 { 0x20, SONYPI_EVENT_BATTERY_INSERT },
357 { 0x30, SONYPI_EVENT_BATTERY_REMOVE },
361 static struct sonypi_eventtypes {
365 struct sonypi_event * events;
366 } sonypi_eventtypes[] = {
367 { SONYPI_DEVICE_MODEL_TYPE1, 0, 0xffffffff, sonypi_releaseev },
368 { SONYPI_DEVICE_MODEL_TYPE1, 0x70, SONYPI_MEYE_MASK, sonypi_meyeev },
369 { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_LID_MASK, sonypi_lidev },
370 { SONYPI_DEVICE_MODEL_TYPE1, 0x60, SONYPI_CAPTURE_MASK, sonypi_captureev },
371 { SONYPI_DEVICE_MODEL_TYPE1, 0x10, SONYPI_JOGGER_MASK, sonypi_joggerev },
372 { SONYPI_DEVICE_MODEL_TYPE1, 0x20, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
373 { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
374 { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_PKEY_MASK, sonypi_pkeyev },
375 { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
376 { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_BATTERY_MASK, sonypi_batteryev },
378 { SONYPI_DEVICE_MODEL_TYPE2, 0, 0xffffffff, sonypi_releaseev },
379 { SONYPI_DEVICE_MODEL_TYPE2, 0x38, SONYPI_LID_MASK, sonypi_lidev },
380 { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_JOGGER_MASK, sonypi_joggerev },
381 { SONYPI_DEVICE_MODEL_TYPE2, 0x61, SONYPI_CAPTURE_MASK, sonypi_captureev },
382 { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
383 { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
384 { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_PKEY_MASK, sonypi_pkeyev },
385 { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_BACK_MASK, sonypi_backev },
386 { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_HELP_MASK, sonypi_helpev },
387 { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_HELP_MASK, sonypi_helpev },
388 { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_ZOOM_MASK, sonypi_zoomev },
389 { SONYPI_DEVICE_MODEL_TYPE2, 0x20, SONYPI_THUMBPHRASE_MASK, sonypi_thumbphraseev },
390 { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
391 { SONYPI_DEVICE_MODEL_TYPE2, 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev },
392 { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_PKEY_MASK, sonypi_pkeyev },
397 #define SONYPI_BUF_SIZE 128
399 /* The name of the devices for the input device drivers */
400 #define SONYPI_JOG_INPUTNAME "Sony Vaio Jogdial"
401 #define SONYPI_KEY_INPUTNAME "Sony Vaio Keys"
403 /* Correspondance table between sonypi events and input layer events */
407 } sonypi_inputkeys[] = {
408 { SONYPI_EVENT_CAPTURE_PRESSED, KEY_CAMERA },
409 { SONYPI_EVENT_FNKEY_ONLY, KEY_FN },
410 { SONYPI_EVENT_FNKEY_ESC, KEY_FN_ESC },
411 { SONYPI_EVENT_FNKEY_F1, KEY_FN_F1 },
412 { SONYPI_EVENT_FNKEY_F2, KEY_FN_F2 },
413 { SONYPI_EVENT_FNKEY_F3, KEY_FN_F3 },
414 { SONYPI_EVENT_FNKEY_F4, KEY_FN_F4 },
415 { SONYPI_EVENT_FNKEY_F5, KEY_FN_F5 },
416 { SONYPI_EVENT_FNKEY_F6, KEY_FN_F6 },
417 { SONYPI_EVENT_FNKEY_F7, KEY_FN_F7 },
418 { SONYPI_EVENT_FNKEY_F8, KEY_FN_F8 },
419 { SONYPI_EVENT_FNKEY_F9, KEY_FN_F9 },
420 { SONYPI_EVENT_FNKEY_F10, KEY_FN_F10 },
421 { SONYPI_EVENT_FNKEY_F11, KEY_FN_F11 },
422 { SONYPI_EVENT_FNKEY_F12, KEY_FN_F12 },
423 { SONYPI_EVENT_FNKEY_1, KEY_FN_1 },
424 { SONYPI_EVENT_FNKEY_2, KEY_FN_2 },
425 { SONYPI_EVENT_FNKEY_D, KEY_FN_D },
426 { SONYPI_EVENT_FNKEY_E, KEY_FN_E },
427 { SONYPI_EVENT_FNKEY_F, KEY_FN_F },
428 { SONYPI_EVENT_FNKEY_S, KEY_FN_S },
429 { SONYPI_EVENT_FNKEY_B, KEY_FN_B },
430 { SONYPI_EVENT_BLUETOOTH_PRESSED, KEY_BLUE },
431 { SONYPI_EVENT_BLUETOOTH_ON, KEY_BLUE },
432 { SONYPI_EVENT_PKEY_P1, KEY_PROG1 },
433 { SONYPI_EVENT_PKEY_P2, KEY_PROG2 },
434 { SONYPI_EVENT_PKEY_P3, KEY_PROG3 },
435 { SONYPI_EVENT_BACK_PRESSED, KEY_BACK },
436 { SONYPI_EVENT_HELP_PRESSED, KEY_HELP },
437 { SONYPI_EVENT_ZOOM_PRESSED, KEY_ZOOM },
438 { SONYPI_EVENT_THUMBPHRASE_PRESSED, BTN_THUMB },
442 struct sonypi_keypress {
443 struct input_dev *dev;
447 static struct sonypi_device {
449 struct platform_device *pdev;
458 struct semaphore lock;
460 spinlock_t fifo_lock;
461 wait_queue_head_t fifo_proc_list;
462 struct fasync_struct *fifo_async;
465 struct input_dev input_jog_dev;
466 struct input_dev input_key_dev;
467 struct work_struct input_work;
468 struct kfifo *input_fifo;
469 spinlock_t input_fifo_lock;
472 #define ITERATIONS_LONG 10000
473 #define ITERATIONS_SHORT 10
475 #define wait_on_command(quiet, command, iterations) { \
476 unsigned int n = iterations; \
477 while (--n && (command)) \
479 if (!n && (verbose || !quiet)) \
480 printk(KERN_WARNING "sonypi command failed at %s : %s (line %d)\n", __FILE__, __FUNCTION__, __LINE__); \
484 #define SONYPI_ACPI_ACTIVE (!acpi_disabled)
486 #define SONYPI_ACPI_ACTIVE 0
487 #endif /* CONFIG_ACPI */
489 static int sonypi_ec_write(u8 addr, u8 value)
491 #ifdef CONFIG_ACPI_EC
492 if (SONYPI_ACPI_ACTIVE)
493 return ec_write(addr, value);
495 wait_on_command(1, inb_p(SONYPI_CST_IOPORT) & 3, ITERATIONS_LONG);
496 outb_p(0x81, SONYPI_CST_IOPORT);
497 wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
498 outb_p(addr, SONYPI_DATA_IOPORT);
499 wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
500 outb_p(value, SONYPI_DATA_IOPORT);
501 wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
505 static int sonypi_ec_read(u8 addr, u8 *value)
507 #ifdef CONFIG_ACPI_EC
508 if (SONYPI_ACPI_ACTIVE)
509 return ec_read(addr, value);
511 wait_on_command(1, inb_p(SONYPI_CST_IOPORT) & 3, ITERATIONS_LONG);
512 outb_p(0x80, SONYPI_CST_IOPORT);
513 wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
514 outb_p(addr, SONYPI_DATA_IOPORT);
515 wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
516 *value = inb_p(SONYPI_DATA_IOPORT);
520 static int ec_read16(u8 addr, u16 *value)
523 if (sonypi_ec_read(addr, &val_lb))
525 if (sonypi_ec_read(addr + 1, &val_hb))
527 *value = val_lb | (val_hb << 8);
531 /* Initializes the device - this comes from the AML code in the ACPI bios */
532 static void sonypi_type1_srs(void)
536 pci_read_config_dword(sonypi_device.dev, SONYPI_G10A, &v);
537 v = (v & 0xFFFF0000) | ((u32) sonypi_device.ioport1);
538 pci_write_config_dword(sonypi_device.dev, SONYPI_G10A, v);
540 pci_read_config_dword(sonypi_device.dev, SONYPI_G10A, &v);
541 v = (v & 0xFFF0FFFF) |
542 (((u32) sonypi_device.ioport1 ^ sonypi_device.ioport2) << 16);
543 pci_write_config_dword(sonypi_device.dev, SONYPI_G10A, v);
545 v = inl(SONYPI_IRQ_PORT);
546 v &= ~(((u32) 0x3) << SONYPI_IRQ_SHIFT);
547 v |= (((u32) sonypi_device.bits) << SONYPI_IRQ_SHIFT);
548 outl(v, SONYPI_IRQ_PORT);
550 pci_read_config_dword(sonypi_device.dev, SONYPI_G10A, &v);
551 v = (v & 0xFF1FFFFF) | 0x00C00000;
552 pci_write_config_dword(sonypi_device.dev, SONYPI_G10A, v);
555 static void sonypi_type2_srs(void)
557 if (sonypi_ec_write(SONYPI_SHIB, (sonypi_device.ioport1 & 0xFF00) >> 8))
558 printk(KERN_WARNING "ec_write failed\n");
559 if (sonypi_ec_write(SONYPI_SLOB, sonypi_device.ioport1 & 0x00FF))
560 printk(KERN_WARNING "ec_write failed\n");
561 if (sonypi_ec_write(SONYPI_SIRQ, sonypi_device.bits))
562 printk(KERN_WARNING "ec_write failed\n");
566 /* Disables the device - this comes from the AML code in the ACPI bios */
567 static void sonypi_type1_dis(void)
571 pci_read_config_dword(sonypi_device.dev, SONYPI_G10A, &v);
573 pci_write_config_dword(sonypi_device.dev, SONYPI_G10A, v);
575 v = inl(SONYPI_IRQ_PORT);
576 v |= (0x3 << SONYPI_IRQ_SHIFT);
577 outl(v, SONYPI_IRQ_PORT);
580 static void sonypi_type2_dis(void)
582 if (sonypi_ec_write(SONYPI_SHIB, 0))
583 printk(KERN_WARNING "ec_write failed\n");
584 if (sonypi_ec_write(SONYPI_SLOB, 0))
585 printk(KERN_WARNING "ec_write failed\n");
586 if (sonypi_ec_write(SONYPI_SIRQ, 0))
587 printk(KERN_WARNING "ec_write failed\n");
590 static u8 sonypi_call1(u8 dev)
594 wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG);
595 outb(dev, sonypi_device.ioport2);
596 v1 = inb_p(sonypi_device.ioport2);
597 v2 = inb_p(sonypi_device.ioport1);
601 static u8 sonypi_call2(u8 dev, u8 fn)
605 wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG);
606 outb(dev, sonypi_device.ioport2);
607 wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG);
608 outb(fn, sonypi_device.ioport1);
609 v1 = inb_p(sonypi_device.ioport1);
613 static u8 sonypi_call3(u8 dev, u8 fn, u8 v)
617 wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG);
618 outb(dev, sonypi_device.ioport2);
619 wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG);
620 outb(fn, sonypi_device.ioport1);
621 wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG);
622 outb(v, sonypi_device.ioport1);
623 v1 = inb_p(sonypi_device.ioport1);
628 /* Get brightness, hue etc. Unreliable... */
629 static u8 sonypi_read(u8 fn)
635 v1 = sonypi_call2(0x8f, fn);
636 v2 = sonypi_call2(0x8f, fn);
637 if (v1 == v2 && v1 != 0xff)
644 /* Set brightness, hue etc */
645 static void sonypi_set(u8 fn, u8 v)
647 wait_on_command(0, sonypi_call3(0x90, fn, v), ITERATIONS_SHORT);
650 /* Tests if the camera is ready */
651 static int sonypi_camera_ready(void)
655 v = sonypi_call2(0x8f, SONYPI_CAMERA_STATUS);
656 return (v != 0xff && (v & SONYPI_CAMERA_STATUS_READY));
659 /* Turns the camera off */
660 static void sonypi_camera_off(void)
662 sonypi_set(SONYPI_CAMERA_PICTURE, SONYPI_CAMERA_MUTE_MASK);
664 if (!sonypi_device.camera_power)
667 sonypi_call2(0x91, 0);
668 sonypi_device.camera_power = 0;
671 /* Turns the camera on */
672 static void sonypi_camera_on(void)
676 if (sonypi_device.camera_power)
679 for (j = 5; j > 0; j--) {
681 while (sonypi_call2(0x91, 0x1))
685 for (i = 400; i > 0; i--) {
686 if (sonypi_camera_ready())
695 printk(KERN_WARNING "sonypi: failed to power on camera\n");
699 sonypi_set(0x10, 0x5a);
700 sonypi_device.camera_power = 1;
703 /* sets the bluetooth subsystem power state */
704 static void sonypi_setbluetoothpower(u8 state)
708 if (sonypi_device.bluetooth_power == state)
711 sonypi_call2(0x96, state);
713 sonypi_device.bluetooth_power = state;
716 static void input_keyrelease(void *data)
718 struct sonypi_keypress kp;
720 while (kfifo_get(sonypi_device.input_fifo, (unsigned char *)&kp,
721 sizeof(kp)) == sizeof(kp)) {
723 input_report_key(kp.dev, kp.key, 0);
728 static void sonypi_report_input_event(u8 event)
730 struct input_dev *jog_dev = &sonypi_device.input_jog_dev;
731 struct input_dev *key_dev = &sonypi_device.input_key_dev;
732 struct sonypi_keypress kp = { NULL };
736 case SONYPI_EVENT_JOGDIAL_UP:
737 case SONYPI_EVENT_JOGDIAL_UP_PRESSED:
738 input_report_rel(jog_dev, REL_WHEEL, 1);
742 case SONYPI_EVENT_JOGDIAL_DOWN:
743 case SONYPI_EVENT_JOGDIAL_DOWN_PRESSED:
744 input_report_rel(jog_dev, REL_WHEEL, -1);
748 case SONYPI_EVENT_JOGDIAL_PRESSED:
753 case SONYPI_EVENT_FNKEY_RELEASED:
754 /* Nothing, not all VAIOs generate this event */
758 for (i = 0; sonypi_inputkeys[i].sonypiev; i++)
759 if (event == sonypi_inputkeys[i].sonypiev) {
761 kp.key = sonypi_inputkeys[i].inputev;
768 input_report_key(kp.dev, kp.key, 1);
770 kfifo_put(sonypi_device.input_fifo,
771 (unsigned char *)&kp, sizeof(kp));
772 schedule_work(&sonypi_device.input_work);
776 /* Interrupt handler: some event is available */
777 static irqreturn_t sonypi_irq(int irq, void *dev_id, struct pt_regs *regs)
779 u8 v1, v2, event = 0;
782 v1 = inb_p(sonypi_device.ioport1);
783 v2 = inb_p(sonypi_device.ioport1 + sonypi_device.evtype_offset);
785 for (i = 0; sonypi_eventtypes[i].model; i++) {
786 if (sonypi_device.model != sonypi_eventtypes[i].model)
788 if ((v2 & sonypi_eventtypes[i].data) !=
789 sonypi_eventtypes[i].data)
791 if (!(mask & sonypi_eventtypes[i].mask))
793 for (j = 0; sonypi_eventtypes[i].events[j].event; j++) {
794 if (v1 == sonypi_eventtypes[i].events[j].data) {
795 event = sonypi_eventtypes[i].events[j].event;
803 "sonypi: unknown event port1=0x%02x,port2=0x%02x\n",
805 /* We need to return IRQ_HANDLED here because there *are*
806 * events belonging to the sonypi device we don't know about,
807 * but we still don't want those to pollute the logs... */
813 "sonypi: event port1=0x%02x,port2=0x%02x\n", v1, v2);
816 sonypi_report_input_event(event);
818 kfifo_put(sonypi_device.fifo, (unsigned char *)&event, sizeof(event));
819 kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN);
820 wake_up_interruptible(&sonypi_device.fifo_proc_list);
825 /* External camera command (exported to the motion eye v4l driver) */
826 int sonypi_camera_command(int command, u8 value)
831 down(&sonypi_device.lock);
834 case SONYPI_COMMAND_SETCAMERA:
840 case SONYPI_COMMAND_SETCAMERABRIGHTNESS:
841 sonypi_set(SONYPI_CAMERA_BRIGHTNESS, value);
843 case SONYPI_COMMAND_SETCAMERACONTRAST:
844 sonypi_set(SONYPI_CAMERA_CONTRAST, value);
846 case SONYPI_COMMAND_SETCAMERAHUE:
847 sonypi_set(SONYPI_CAMERA_HUE, value);
849 case SONYPI_COMMAND_SETCAMERACOLOR:
850 sonypi_set(SONYPI_CAMERA_COLOR, value);
852 case SONYPI_COMMAND_SETCAMERASHARPNESS:
853 sonypi_set(SONYPI_CAMERA_SHARPNESS, value);
855 case SONYPI_COMMAND_SETCAMERAPICTURE:
856 sonypi_set(SONYPI_CAMERA_PICTURE, value);
858 case SONYPI_COMMAND_SETCAMERAAGC:
859 sonypi_set(SONYPI_CAMERA_AGC, value);
862 printk(KERN_ERR "sonypi: sonypi_camera_command invalid: %d\n",
866 up(&sonypi_device.lock);
870 EXPORT_SYMBOL(sonypi_camera_command);
872 static int sonypi_misc_fasync(int fd, struct file *filp, int on)
876 retval = fasync_helper(fd, filp, on, &sonypi_device.fifo_async);
882 static int sonypi_misc_release(struct inode *inode, struct file *file)
884 sonypi_misc_fasync(-1, file, 0);
885 down(&sonypi_device.lock);
886 sonypi_device.open_count--;
887 up(&sonypi_device.lock);
891 static int sonypi_misc_open(struct inode *inode, struct file *file)
893 down(&sonypi_device.lock);
894 /* Flush input queue on first open */
895 if (!sonypi_device.open_count)
896 kfifo_reset(sonypi_device.fifo);
897 sonypi_device.open_count++;
898 up(&sonypi_device.lock);
902 static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
903 size_t count, loff_t *pos)
908 if ((kfifo_len(sonypi_device.fifo) == 0) &&
909 (file->f_flags & O_NONBLOCK))
912 ret = wait_event_interruptible(sonypi_device.fifo_proc_list,
913 kfifo_len(sonypi_device.fifo) != 0);
917 while (ret < count &&
918 (kfifo_get(sonypi_device.fifo, &c, sizeof(c)) == sizeof(c))) {
919 if (put_user(c, buf++))
925 struct inode *inode = file->f_dentry->d_inode;
926 inode->i_atime = current_fs_time(inode->i_sb);
932 static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait)
934 poll_wait(file, &sonypi_device.fifo_proc_list, wait);
935 if (kfifo_len(sonypi_device.fifo))
936 return POLLIN | POLLRDNORM;
940 static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
941 unsigned int cmd, unsigned long arg)
944 void __user *argp = (void __user *)arg;
948 down(&sonypi_device.lock);
951 if (sonypi_ec_read(SONYPI_LCD_LIGHT, &val8)) {
955 if (copy_to_user(argp, &val8, sizeof(val8)))
959 if (copy_from_user(&val8, argp, sizeof(val8))) {
963 if (sonypi_ec_write(SONYPI_LCD_LIGHT, val8))
966 case SONYPI_IOCGBAT1CAP:
967 if (ec_read16(SONYPI_BAT1_FULL, &val16)) {
971 if (copy_to_user(argp, &val16, sizeof(val16)))
974 case SONYPI_IOCGBAT1REM:
975 if (ec_read16(SONYPI_BAT1_LEFT, &val16)) {
979 if (copy_to_user(argp, &val16, sizeof(val16)))
982 case SONYPI_IOCGBAT2CAP:
983 if (ec_read16(SONYPI_BAT2_FULL, &val16)) {
987 if (copy_to_user(argp, &val16, sizeof(val16)))
990 case SONYPI_IOCGBAT2REM:
991 if (ec_read16(SONYPI_BAT2_LEFT, &val16)) {
995 if (copy_to_user(argp, &val16, sizeof(val16)))
998 case SONYPI_IOCGBATFLAGS:
999 if (sonypi_ec_read(SONYPI_BAT_FLAGS, &val8)) {
1004 if (copy_to_user(argp, &val8, sizeof(val8)))
1007 case SONYPI_IOCGBLUE:
1008 val8 = sonypi_device.bluetooth_power;
1009 if (copy_to_user(argp, &val8, sizeof(val8)))
1012 case SONYPI_IOCSBLUE:
1013 if (copy_from_user(&val8, argp, sizeof(val8))) {
1017 sonypi_setbluetoothpower(val8);
1020 case SONYPI_IOCGFAN:
1021 if (sonypi_ec_read(SONYPI_FAN0_STATUS, &val8)) {
1025 if (copy_to_user(argp, &val8, sizeof(val8)))
1028 case SONYPI_IOCSFAN:
1029 if (copy_from_user(&val8, argp, sizeof(val8))) {
1033 if (sonypi_ec_write(SONYPI_FAN0_STATUS, val8))
1036 /* GET Temperature (useful under APM) */
1037 case SONYPI_IOCGTEMP:
1038 if (sonypi_ec_read(SONYPI_TEMP_STATUS, &val8)) {
1042 if (copy_to_user(argp, &val8, sizeof(val8)))
1048 up(&sonypi_device.lock);
1052 static struct file_operations sonypi_misc_fops = {
1053 .owner = THIS_MODULE,
1054 .read = sonypi_misc_read,
1055 .poll = sonypi_misc_poll,
1056 .open = sonypi_misc_open,
1057 .release = sonypi_misc_release,
1058 .fasync = sonypi_misc_fasync,
1059 .ioctl = sonypi_misc_ioctl,
1062 static struct miscdevice sonypi_misc_device = {
1063 .minor = MISC_DYNAMIC_MINOR,
1065 .fops = &sonypi_misc_fops,
1068 static void sonypi_enable(unsigned int camera_on)
1070 if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2)
1076 sonypi_call2(0x81, 0xff);
1077 sonypi_call1(compat ? 0x92 : 0x82);
1079 /* Enable ACPI mode to get Fn key events */
1080 if (!SONYPI_ACPI_ACTIVE && fnkeyinit)
1083 if (camera && camera_on)
1087 static int sonypi_disable(void)
1089 sonypi_call2(0x81, 0); /* make sure we don't get any more events */
1091 sonypi_camera_off();
1093 /* disable ACPI mode */
1094 if (!SONYPI_ACPI_ACTIVE && fnkeyinit)
1097 if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2)
1105 static int old_camera_power;
1107 static int sonypi_suspend(struct device *dev, pm_message_t state, u32 level)
1109 if (level == SUSPEND_DISABLE) {
1110 old_camera_power = sonypi_device.camera_power;
1116 static int sonypi_resume(struct device *dev, u32 level)
1118 if (level == RESUME_ENABLE)
1119 sonypi_enable(old_camera_power);
1124 static void sonypi_shutdown(struct device *dev)
1129 static struct device_driver sonypi_driver = {
1131 .bus = &platform_bus_type,
1133 .suspend = sonypi_suspend,
1134 .resume = sonypi_resume,
1136 .shutdown = sonypi_shutdown,
1139 static int __devinit sonypi_probe(void)
1142 struct sonypi_ioport_list *ioport_list;
1143 struct sonypi_irq_list *irq_list;
1144 struct pci_dev *pcidev;
1146 pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
1147 PCI_DEVICE_ID_INTEL_82371AB_3, NULL);
1149 sonypi_device.dev = pcidev;
1150 sonypi_device.model = pcidev ?
1151 SONYPI_DEVICE_MODEL_TYPE1 : SONYPI_DEVICE_MODEL_TYPE2;
1153 spin_lock_init(&sonypi_device.fifo_lock);
1154 sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,
1155 &sonypi_device.fifo_lock);
1156 if (IS_ERR(sonypi_device.fifo)) {
1157 printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
1158 ret = PTR_ERR(sonypi_device.fifo);
1162 init_waitqueue_head(&sonypi_device.fifo_proc_list);
1163 init_MUTEX(&sonypi_device.lock);
1164 sonypi_device.bluetooth_power = -1;
1166 if (pcidev && pci_enable_device(pcidev)) {
1167 printk(KERN_ERR "sonypi: pci_enable_device failed\n");
1173 sonypi_misc_device.minor = minor;
1174 if ((ret = misc_register(&sonypi_misc_device))) {
1175 printk(KERN_ERR "sonypi: misc_register failed\n");
1179 if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) {
1180 ioport_list = sonypi_type2_ioport_list;
1181 sonypi_device.region_size = SONYPI_TYPE2_REGION_SIZE;
1182 sonypi_device.evtype_offset = SONYPI_TYPE2_EVTYPE_OFFSET;
1183 irq_list = sonypi_type2_irq_list;
1185 ioport_list = sonypi_type1_ioport_list;
1186 sonypi_device.region_size = SONYPI_TYPE1_REGION_SIZE;
1187 sonypi_device.evtype_offset = SONYPI_TYPE1_EVTYPE_OFFSET;
1188 irq_list = sonypi_type1_irq_list;
1191 for (i = 0; ioport_list[i].port1; i++) {
1192 if (request_region(ioport_list[i].port1,
1193 sonypi_device.region_size,
1194 "Sony Programable I/O Device")) {
1195 /* get the ioport */
1196 sonypi_device.ioport1 = ioport_list[i].port1;
1197 sonypi_device.ioport2 = ioport_list[i].port2;
1201 if (!sonypi_device.ioport1) {
1202 printk(KERN_ERR "sonypi: request_region failed\n");
1207 for (i = 0; irq_list[i].irq; i++) {
1209 sonypi_device.irq = irq_list[i].irq;
1210 sonypi_device.bits = irq_list[i].bits;
1212 if (!request_irq(sonypi_device.irq, sonypi_irq,
1213 SA_SHIRQ, "sonypi", sonypi_irq))
1217 if (!irq_list[i].irq) {
1218 printk(KERN_ERR "sonypi: request_irq failed\n");
1224 /* Initialize the Input Drivers: jogdial */
1226 sonypi_device.input_jog_dev.evbit[0] =
1227 BIT(EV_KEY) | BIT(EV_REL);
1228 sonypi_device.input_jog_dev.keybit[LONG(BTN_MOUSE)] =
1230 sonypi_device.input_jog_dev.relbit[0] = BIT(REL_WHEEL);
1231 sonypi_device.input_jog_dev.name = SONYPI_JOG_INPUTNAME;
1232 sonypi_device.input_jog_dev.id.bustype = BUS_ISA;
1233 sonypi_device.input_jog_dev.id.vendor = PCI_VENDOR_ID_SONY;
1235 input_register_device(&sonypi_device.input_jog_dev);
1236 printk(KERN_INFO "%s input method installed.\n",
1237 sonypi_device.input_jog_dev.name);
1239 /* Initialize the Input Drivers: special keys */
1240 sonypi_device.input_key_dev.evbit[0] = BIT(EV_KEY);
1241 for (i = 0; sonypi_inputkeys[i].sonypiev; i++)
1242 if (sonypi_inputkeys[i].inputev)
1243 set_bit(sonypi_inputkeys[i].inputev,
1244 sonypi_device.input_key_dev.keybit);
1245 sonypi_device.input_key_dev.name = SONYPI_KEY_INPUTNAME;
1246 sonypi_device.input_key_dev.id.bustype = BUS_ISA;
1247 sonypi_device.input_key_dev.id.vendor = PCI_VENDOR_ID_SONY;
1249 input_register_device(&sonypi_device.input_key_dev);
1250 printk(KERN_INFO "%s input method installed.\n",
1251 sonypi_device.input_key_dev.name);
1253 spin_lock_init(&sonypi_device.input_fifo_lock);
1254 sonypi_device.input_fifo =
1255 kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,
1256 &sonypi_device.input_fifo_lock);
1257 if (IS_ERR(sonypi_device.input_fifo)) {
1258 printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
1259 ret = PTR_ERR(sonypi_device.input_fifo);
1263 INIT_WORK(&sonypi_device.input_work, input_keyrelease, NULL);
1266 sonypi_device.pdev = platform_device_register_simple("sonypi", -1,
1268 if (IS_ERR(sonypi_device.pdev)) {
1269 ret = PTR_ERR(sonypi_device.pdev);
1270 goto out_platformdev;
1275 printk(KERN_INFO "sonypi: Sony Programmable I/O Controller Driver"
1276 "v%s.\n", SONYPI_DRIVER_VERSION);
1277 printk(KERN_INFO "sonypi: detected %s model, "
1278 "verbose = %d, fnkeyinit = %s, camera = %s, "
1279 "compat = %s, mask = 0x%08lx, useinput = %s, acpi = %s\n",
1280 (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE1) ?
1283 fnkeyinit ? "on" : "off",
1284 camera ? "on" : "off",
1285 compat ? "on" : "off",
1287 useinput ? "on" : "off",
1288 SONYPI_ACPI_ACTIVE ? "on" : "off");
1289 printk(KERN_INFO "sonypi: enabled at irq=%d, port1=0x%x, port2=0x%x\n",
1291 sonypi_device.ioport1, sonypi_device.ioport2);
1294 printk(KERN_INFO "sonypi: device allocated minor is %d\n",
1295 sonypi_misc_device.minor);
1300 kfifo_free(sonypi_device.input_fifo);
1302 input_unregister_device(&sonypi_device.input_key_dev);
1303 input_unregister_device(&sonypi_device.input_jog_dev);
1304 free_irq(sonypi_device.irq, sonypi_irq);
1306 release_region(sonypi_device.ioport1, sonypi_device.region_size);
1308 misc_deregister(&sonypi_misc_device);
1311 pci_disable_device(pcidev);
1313 kfifo_free(sonypi_device.fifo);
1315 pci_dev_put(sonypi_device.dev);
1319 static void __devexit sonypi_remove(void)
1323 synchronize_sched(); /* Allow sonypi interrupt to complete. */
1324 flush_scheduled_work();
1326 platform_device_unregister(sonypi_device.pdev);
1329 input_unregister_device(&sonypi_device.input_key_dev);
1330 input_unregister_device(&sonypi_device.input_jog_dev);
1331 kfifo_free(sonypi_device.input_fifo);
1334 free_irq(sonypi_device.irq, sonypi_irq);
1335 release_region(sonypi_device.ioport1, sonypi_device.region_size);
1336 misc_deregister(&sonypi_misc_device);
1337 if (sonypi_device.dev)
1338 pci_disable_device(sonypi_device.dev);
1339 kfifo_free(sonypi_device.fifo);
1340 pci_dev_put(sonypi_device.dev);
1341 printk(KERN_INFO "sonypi: removed.\n");
1344 static struct dmi_system_id __initdata sonypi_dmi_table[] = {
1346 .ident = "Sony Vaio",
1348 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
1349 DMI_MATCH(DMI_PRODUCT_NAME, "PCG-"),
1353 .ident = "Sony Vaio",
1355 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
1356 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-"),
1362 static int __init sonypi_init(void)
1366 if (!dmi_check_system(sonypi_dmi_table))
1369 ret = driver_register(&sonypi_driver);
1373 ret = sonypi_probe();
1375 driver_unregister(&sonypi_driver);
1380 static void __exit sonypi_exit(void)
1382 driver_unregister(&sonypi_driver);
1386 module_init(sonypi_init);
1387 module_exit(sonypi_exit);