2 * ACPI Sony Notebook Control Driver (SNC and SPIC)
4 * Copyright (C) 2004-2005 Stelian Pop <stelian@popies.net>
5 * Copyright (C) 2007 Mattia Dongili <malattia@linux.it>
7 * Parts of this driver inspired from asus_acpi.c and ibm_acpi.c
8 * which are copyrighted by their respective authors.
10 * The SNY6001 driver part is based on the sonypi driver which includes
13 * Copyright (C) 2001-2005 Stelian Pop <stelian@popies.net>
15 * Copyright (C) 2005 Narayanan R S <nars@kadamba.org>
17 * Copyright (C) 2001-2002 AlcĂ´ve <www.alcove.com>
19 * Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au>
21 * Copyright (C) 2001 Junichi Morita <jun1m@mars.dti.ne.jp>
23 * Copyright (C) 2000 Takaya Kinjo <t-kinjo@tc4.so-net.ne.jp>
25 * Copyright (C) 2000 Andrew Tridgell <tridge@valinux.com>
27 * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras.
29 * This program is free software; you can redistribute it and/or modify
30 * it under the terms of the GNU General Public License as published by
31 * the Free Software Foundation; either version 2 of the License, or
32 * (at your option) any later version.
34 * This program is distributed in the hope that it will be useful,
35 * but WITHOUT ANY WARRANTY; without even the implied warranty of
36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 * GNU General Public License for more details.
39 * You should have received a copy of the GNU General Public License
40 * along with this program; if not, write to the Free Software
41 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
45 #include <linux/kernel.h>
46 #include <linux/module.h>
47 #include <linux/moduleparam.h>
48 #include <linux/init.h>
49 #include <linux/types.h>
50 #include <linux/backlight.h>
51 #include <linux/platform_device.h>
52 #include <linux/err.h>
53 #include <linux/dmi.h>
54 #include <linux/pci.h>
55 #include <linux/interrupt.h>
56 #include <linux/delay.h>
57 #include <linux/input.h>
58 #include <linux/kfifo.h>
59 #include <linux/workqueue.h>
60 #include <linux/acpi.h>
61 #include <acpi/acpi_drivers.h>
62 #include <acpi/acpi_bus.h>
63 #include <asm/uaccess.h>
64 #include <linux/sonypi.h>
65 #include <linux/sony-laptop.h>
66 #ifdef CONFIG_SONYPI_COMPAT
67 #include <linux/poll.h>
68 #include <linux/miscdevice.h>
71 #define DRV_PFX "sony-laptop: "
72 #define dprintk(msg...) do { \
73 if (debug) printk(KERN_WARNING DRV_PFX msg); \
76 #define SONY_LAPTOP_DRIVER_VERSION "0.6"
78 #define SONY_NC_CLASS "sony-nc"
79 #define SONY_NC_HID "SNY5001"
80 #define SONY_NC_DRIVER_NAME "Sony Notebook Control Driver"
82 #define SONY_PIC_CLASS "sony-pic"
83 #define SONY_PIC_HID "SNY6001"
84 #define SONY_PIC_DRIVER_NAME "Sony Programmable IO Control Driver"
86 MODULE_AUTHOR("Stelian Pop, Mattia Dongili");
87 MODULE_DESCRIPTION("Sony laptop extras driver (SPIC and SNC ACPI device)");
88 MODULE_LICENSE("GPL");
89 MODULE_VERSION(SONY_LAPTOP_DRIVER_VERSION
);
92 module_param(debug
, int, 0);
93 MODULE_PARM_DESC(debug
, "set this to 1 (and RTFM) if you want to help "
94 "the development of this driver");
96 static int no_spic
; /* = 0 */
97 module_param(no_spic
, int, 0444);
98 MODULE_PARM_DESC(no_spic
,
99 "set this if you don't want to enable the SPIC device");
101 static int compat
; /* = 0 */
102 module_param(compat
, int, 0444);
103 MODULE_PARM_DESC(compat
,
104 "set this if you want to enable backward compatibility mode");
106 static unsigned long mask
= 0xffffffff;
107 module_param(mask
, ulong
, 0644);
108 MODULE_PARM_DESC(mask
,
109 "set this to the mask of event you want to enable (see doc)");
111 static int camera
; /* = 0 */
112 module_param(camera
, int, 0444);
113 MODULE_PARM_DESC(camera
,
114 "set this to 1 to enable Motion Eye camera controls "
115 "(only use it if you have a C1VE or C1VN model)");
117 #ifdef CONFIG_SONYPI_COMPAT
118 static int minor
= -1;
119 module_param(minor
, int, 0);
120 MODULE_PARM_DESC(minor
,
121 "minor number of the misc device for the SPIC compatibility code, "
122 "default is -1 (automatic)");
125 /*********** Input Devices ***********/
127 #define SONY_LAPTOP_BUF_SIZE 128
128 struct sony_laptop_input_s
{
130 struct input_dev
*jog_dev
;
131 struct input_dev
*key_dev
;
133 spinlock_t fifo_lock
;
134 struct workqueue_struct
*wq
;
136 static struct sony_laptop_input_s sony_laptop_input
= {
137 .users
= ATOMIC_INIT(0),
140 struct sony_laptop_keypress
{
141 struct input_dev
*dev
;
145 /* Correspondance table between sonypi events
146 * and input layer indexes in the keymap
148 static int sony_laptop_input_index
[] = {
150 -1, /* 1 SONYPI_EVENT_JOGDIAL_DOWN */
151 -1, /* 2 SONYPI_EVENT_JOGDIAL_UP */
152 -1, /* 3 SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */
153 -1, /* 4 SONYPI_EVENT_JOGDIAL_UP_PRESSED */
154 -1, /* 5 SONYPI_EVENT_JOGDIAL_PRESSED */
155 -1, /* 6 SONYPI_EVENT_JOGDIAL_RELEASED */
156 0, /* 7 SONYPI_EVENT_CAPTURE_PRESSED */
157 1, /* 8 SONYPI_EVENT_CAPTURE_RELEASED */
158 2, /* 9 SONYPI_EVENT_CAPTURE_PARTIALPRESSED */
159 3, /* 10 SONYPI_EVENT_CAPTURE_PARTIALRELEASED */
160 4, /* 11 SONYPI_EVENT_FNKEY_ESC */
161 5, /* 12 SONYPI_EVENT_FNKEY_F1 */
162 6, /* 13 SONYPI_EVENT_FNKEY_F2 */
163 7, /* 14 SONYPI_EVENT_FNKEY_F3 */
164 8, /* 15 SONYPI_EVENT_FNKEY_F4 */
165 9, /* 16 SONYPI_EVENT_FNKEY_F5 */
166 10, /* 17 SONYPI_EVENT_FNKEY_F6 */
167 11, /* 18 SONYPI_EVENT_FNKEY_F7 */
168 12, /* 19 SONYPI_EVENT_FNKEY_F8 */
169 13, /* 20 SONYPI_EVENT_FNKEY_F9 */
170 14, /* 21 SONYPI_EVENT_FNKEY_F10 */
171 15, /* 22 SONYPI_EVENT_FNKEY_F11 */
172 16, /* 23 SONYPI_EVENT_FNKEY_F12 */
173 17, /* 24 SONYPI_EVENT_FNKEY_1 */
174 18, /* 25 SONYPI_EVENT_FNKEY_2 */
175 19, /* 26 SONYPI_EVENT_FNKEY_D */
176 20, /* 27 SONYPI_EVENT_FNKEY_E */
177 21, /* 28 SONYPI_EVENT_FNKEY_F */
178 22, /* 29 SONYPI_EVENT_FNKEY_S */
179 23, /* 30 SONYPI_EVENT_FNKEY_B */
180 24, /* 31 SONYPI_EVENT_BLUETOOTH_PRESSED */
181 25, /* 32 SONYPI_EVENT_PKEY_P1 */
182 26, /* 33 SONYPI_EVENT_PKEY_P2 */
183 27, /* 34 SONYPI_EVENT_PKEY_P3 */
184 28, /* 35 SONYPI_EVENT_BACK_PRESSED */
185 -1, /* 36 SONYPI_EVENT_LID_CLOSED */
186 -1, /* 37 SONYPI_EVENT_LID_OPENED */
187 29, /* 38 SONYPI_EVENT_BLUETOOTH_ON */
188 30, /* 39 SONYPI_EVENT_BLUETOOTH_OFF */
189 31, /* 40 SONYPI_EVENT_HELP_PRESSED */
190 32, /* 41 SONYPI_EVENT_FNKEY_ONLY */
191 33, /* 42 SONYPI_EVENT_JOGDIAL_FAST_DOWN */
192 34, /* 43 SONYPI_EVENT_JOGDIAL_FAST_UP */
193 35, /* 44 SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */
194 36, /* 45 SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */
195 37, /* 46 SONYPI_EVENT_JOGDIAL_VFAST_DOWN */
196 38, /* 47 SONYPI_EVENT_JOGDIAL_VFAST_UP */
197 39, /* 48 SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */
198 40, /* 49 SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */
199 41, /* 50 SONYPI_EVENT_ZOOM_PRESSED */
200 42, /* 51 SONYPI_EVENT_THUMBPHRASE_PRESSED */
201 43, /* 52 SONYPI_EVENT_MEYE_FACE */
202 44, /* 53 SONYPI_EVENT_MEYE_OPPOSITE */
203 45, /* 54 SONYPI_EVENT_MEMORYSTICK_INSERT */
204 46, /* 55 SONYPI_EVENT_MEMORYSTICK_EJECT */
205 -1, /* 56 SONYPI_EVENT_ANYBUTTON_RELEASED */
206 -1, /* 57 SONYPI_EVENT_BATTERY_INSERT */
207 -1, /* 58 SONYPI_EVENT_BATTERY_REMOVE */
208 -1, /* 59 SONYPI_EVENT_FNKEY_RELEASED */
209 47, /* 60 SONYPI_EVENT_WIRELESS_ON */
210 48, /* 61 SONYPI_EVENT_WIRELESS_OFF */
211 49, /* 62 SONYPI_EVENT_ZOOM_IN_PRESSED */
212 50, /* 63 SONYPI_EVENT_ZOOM_OUT_PRESSED */
215 static int sony_laptop_input_keycode_map
[] = {
216 KEY_CAMERA
, /* 0 SONYPI_EVENT_CAPTURE_PRESSED */
217 KEY_RESERVED
, /* 1 SONYPI_EVENT_CAPTURE_RELEASED */
218 KEY_RESERVED
, /* 2 SONYPI_EVENT_CAPTURE_PARTIALPRESSED */
219 KEY_RESERVED
, /* 3 SONYPI_EVENT_CAPTURE_PARTIALRELEASED */
220 KEY_FN_ESC
, /* 4 SONYPI_EVENT_FNKEY_ESC */
221 KEY_FN_F1
, /* 5 SONYPI_EVENT_FNKEY_F1 */
222 KEY_FN_F2
, /* 6 SONYPI_EVENT_FNKEY_F2 */
223 KEY_FN_F3
, /* 7 SONYPI_EVENT_FNKEY_F3 */
224 KEY_FN_F4
, /* 8 SONYPI_EVENT_FNKEY_F4 */
225 KEY_FN_F5
, /* 9 SONYPI_EVENT_FNKEY_F5 */
226 KEY_FN_F6
, /* 10 SONYPI_EVENT_FNKEY_F6 */
227 KEY_FN_F7
, /* 11 SONYPI_EVENT_FNKEY_F7 */
228 KEY_FN_F8
, /* 12 SONYPI_EVENT_FNKEY_F8 */
229 KEY_FN_F9
, /* 13 SONYPI_EVENT_FNKEY_F9 */
230 KEY_FN_F10
, /* 14 SONYPI_EVENT_FNKEY_F10 */
231 KEY_FN_F11
, /* 15 SONYPI_EVENT_FNKEY_F11 */
232 KEY_FN_F12
, /* 16 SONYPI_EVENT_FNKEY_F12 */
233 KEY_FN_F1
, /* 17 SONYPI_EVENT_FNKEY_1 */
234 KEY_FN_F2
, /* 18 SONYPI_EVENT_FNKEY_2 */
235 KEY_FN_D
, /* 19 SONYPI_EVENT_FNKEY_D */
236 KEY_FN_E
, /* 20 SONYPI_EVENT_FNKEY_E */
237 KEY_FN_F
, /* 21 SONYPI_EVENT_FNKEY_F */
238 KEY_FN_S
, /* 22 SONYPI_EVENT_FNKEY_S */
239 KEY_FN_B
, /* 23 SONYPI_EVENT_FNKEY_B */
240 KEY_BLUETOOTH
, /* 24 SONYPI_EVENT_BLUETOOTH_PRESSED */
241 KEY_PROG1
, /* 25 SONYPI_EVENT_PKEY_P1 */
242 KEY_PROG2
, /* 26 SONYPI_EVENT_PKEY_P2 */
243 KEY_PROG3
, /* 27 SONYPI_EVENT_PKEY_P3 */
244 KEY_BACK
, /* 28 SONYPI_EVENT_BACK_PRESSED */
245 KEY_BLUETOOTH
, /* 29 SONYPI_EVENT_BLUETOOTH_ON */
246 KEY_BLUETOOTH
, /* 30 SONYPI_EVENT_BLUETOOTH_OFF */
247 KEY_HELP
, /* 31 SONYPI_EVENT_HELP_PRESSED */
248 KEY_FN
, /* 32 SONYPI_EVENT_FNKEY_ONLY */
249 KEY_RESERVED
, /* 33 SONYPI_EVENT_JOGDIAL_FAST_DOWN */
250 KEY_RESERVED
, /* 34 SONYPI_EVENT_JOGDIAL_FAST_UP */
251 KEY_RESERVED
, /* 35 SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */
252 KEY_RESERVED
, /* 36 SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */
253 KEY_RESERVED
, /* 37 SONYPI_EVENT_JOGDIAL_VFAST_DOWN */
254 KEY_RESERVED
, /* 38 SONYPI_EVENT_JOGDIAL_VFAST_UP */
255 KEY_RESERVED
, /* 39 SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */
256 KEY_RESERVED
, /* 40 SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */
257 KEY_ZOOM
, /* 41 SONYPI_EVENT_ZOOM_PRESSED */
258 BTN_THUMB
, /* 42 SONYPI_EVENT_THUMBPHRASE_PRESSED */
259 KEY_RESERVED
, /* 43 SONYPI_EVENT_MEYE_FACE */
260 KEY_RESERVED
, /* 44 SONYPI_EVENT_MEYE_OPPOSITE */
261 KEY_RESERVED
, /* 45 SONYPI_EVENT_MEMORYSTICK_INSERT */
262 KEY_RESERVED
, /* 46 SONYPI_EVENT_MEMORYSTICK_EJECT */
263 KEY_WLAN
, /* 47 SONYPI_EVENT_WIRELESS_ON */
264 KEY_WLAN
, /* 48 SONYPI_EVENT_WIRELESS_OFF */
265 KEY_ZOOMIN
, /* 49 SONYPI_EVENT_ZOOM_IN_PRESSED */
266 KEY_ZOOMOUT
/* 50 SONYPI_EVENT_ZOOM_OUT_PRESSED */
269 /* release buttons after a short delay if pressed */
270 static void do_sony_laptop_release_key(struct work_struct
*work
)
272 struct sony_laptop_keypress kp
;
274 while (kfifo_get(sony_laptop_input
.fifo
, (unsigned char *)&kp
,
275 sizeof(kp
)) == sizeof(kp
)) {
277 input_report_key(kp
.dev
, kp
.key
, 0);
281 static DECLARE_WORK(sony_laptop_release_key_work
,
282 do_sony_laptop_release_key
);
284 /* forward event to the input subsystem */
285 static void sony_laptop_report_input_event(u8 event
)
287 struct input_dev
*jog_dev
= sony_laptop_input
.jog_dev
;
288 struct input_dev
*key_dev
= sony_laptop_input
.key_dev
;
289 struct sony_laptop_keypress kp
= { NULL
};
291 if (event
== SONYPI_EVENT_FNKEY_RELEASED
) {
292 /* Nothing, not all VAIOs generate this event */
299 case SONYPI_EVENT_JOGDIAL_UP
:
300 case SONYPI_EVENT_JOGDIAL_UP_PRESSED
:
301 input_report_rel(jog_dev
, REL_WHEEL
, 1);
305 case SONYPI_EVENT_JOGDIAL_DOWN
:
306 case SONYPI_EVENT_JOGDIAL_DOWN_PRESSED
:
307 input_report_rel(jog_dev
, REL_WHEEL
, -1);
312 case SONYPI_EVENT_JOGDIAL_PRESSED
:
318 <<<<<<< HEAD
:drivers
/misc
/sony
-laptop
.c
319 if (event
> ARRAY_SIZE(sony_laptop_input_index
)) {
321 if (event
>= ARRAY_SIZE(sony_laptop_input_index
)) {
322 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/misc
/sony
-laptop
.c
323 dprintk("sony_laptop_report_input_event, event not known: %d\n", event
);
326 if (sony_laptop_input_index
[event
] != -1) {
327 kp
.key
= sony_laptop_input_keycode_map
[sony_laptop_input_index
[event
]];
328 if (kp
.key
!= KEY_UNKNOWN
)
335 input_report_key(kp
.dev
, kp
.key
, 1);
336 /* we emit the scancode so we can always remap the key */
337 input_event(kp
.dev
, EV_MSC
, MSC_SCAN
, event
);
339 kfifo_put(sony_laptop_input
.fifo
,
340 (unsigned char *)&kp
, sizeof(kp
));
342 if (!work_pending(&sony_laptop_release_key_work
))
343 queue_work(sony_laptop_input
.wq
,
344 &sony_laptop_release_key_work
);
346 dprintk("unknown input event %.2x\n", event
);
349 static int sony_laptop_setup_input(struct acpi_device
*acpi_device
)
351 struct input_dev
*jog_dev
;
352 struct input_dev
*key_dev
;
356 /* don't run again if already initialized */
357 if (atomic_add_return(1, &sony_laptop_input
.users
) > 1)
361 spin_lock_init(&sony_laptop_input
.fifo_lock
);
362 sony_laptop_input
.fifo
=
363 kfifo_alloc(SONY_LAPTOP_BUF_SIZE
, GFP_KERNEL
,
364 &sony_laptop_input
.fifo_lock
);
365 if (IS_ERR(sony_laptop_input
.fifo
)) {
366 printk(KERN_ERR DRV_PFX
"kfifo_alloc failed\n");
367 error
= PTR_ERR(sony_laptop_input
.fifo
);
372 sony_laptop_input
.wq
= create_singlethread_workqueue("sony-laptop");
373 if (!sony_laptop_input
.wq
) {
374 printk(KERN_ERR DRV_PFX
375 "Unabe to create workqueue.\n");
381 key_dev
= input_allocate_device();
387 key_dev
->name
= "Sony Vaio Keys";
388 key_dev
->id
.bustype
= BUS_ISA
;
389 key_dev
->id
.vendor
= PCI_VENDOR_ID_SONY
;
390 key_dev
->dev
.parent
= &acpi_device
->dev
;
392 /* Initialize the Input Drivers: special keys */
393 set_bit(EV_KEY
, key_dev
->evbit
);
394 set_bit(EV_MSC
, key_dev
->evbit
);
395 set_bit(MSC_SCAN
, key_dev
->mscbit
);
396 key_dev
->keycodesize
= sizeof(sony_laptop_input_keycode_map
[0]);
397 key_dev
->keycodemax
= ARRAY_SIZE(sony_laptop_input_keycode_map
);
398 key_dev
->keycode
= &sony_laptop_input_keycode_map
;
399 for (i
= 0; i
< ARRAY_SIZE(sony_laptop_input_keycode_map
); i
++) {
400 if (sony_laptop_input_keycode_map
[i
] != KEY_RESERVED
) {
401 set_bit(sony_laptop_input_keycode_map
[i
],
406 error
= input_register_device(key_dev
);
408 goto err_free_keydev
;
410 sony_laptop_input
.key_dev
= key_dev
;
413 jog_dev
= input_allocate_device();
416 goto err_unregister_keydev
;
419 jog_dev
->name
= "Sony Vaio Jogdial";
420 jog_dev
->id
.bustype
= BUS_ISA
;
421 jog_dev
->id
.vendor
= PCI_VENDOR_ID_SONY
;
422 key_dev
->dev
.parent
= &acpi_device
->dev
;
424 jog_dev
->evbit
[0] = BIT_MASK(EV_KEY
) | BIT_MASK(EV_REL
);
425 jog_dev
->keybit
[BIT_WORD(BTN_MOUSE
)] = BIT_MASK(BTN_MIDDLE
);
426 jog_dev
->relbit
[0] = BIT_MASK(REL_WHEEL
);
428 error
= input_register_device(jog_dev
);
430 goto err_free_jogdev
;
432 sony_laptop_input
.jog_dev
= jog_dev
;
437 input_free_device(jog_dev
);
439 err_unregister_keydev
:
440 input_unregister_device(key_dev
);
441 /* to avoid kref underflow below at input_free_device */
445 input_free_device(key_dev
);
448 destroy_workqueue(sony_laptop_input
.wq
);
451 kfifo_free(sony_laptop_input
.fifo
);
454 atomic_dec(&sony_laptop_input
.users
);
458 static void sony_laptop_remove_input(void)
460 /* cleanup only after the last user has gone */
461 if (!atomic_dec_and_test(&sony_laptop_input
.users
))
464 /* flush workqueue first */
465 flush_workqueue(sony_laptop_input
.wq
);
467 /* destroy input devs */
468 input_unregister_device(sony_laptop_input
.key_dev
);
469 sony_laptop_input
.key_dev
= NULL
;
471 if (sony_laptop_input
.jog_dev
) {
472 input_unregister_device(sony_laptop_input
.jog_dev
);
473 sony_laptop_input
.jog_dev
= NULL
;
476 destroy_workqueue(sony_laptop_input
.wq
);
477 kfifo_free(sony_laptop_input
.fifo
);
480 /*********** Platform Device ***********/
482 static atomic_t sony_pf_users
= ATOMIC_INIT(0);
483 static struct platform_driver sony_pf_driver
= {
485 .name
= "sony-laptop",
486 .owner
= THIS_MODULE
,
489 static struct platform_device
*sony_pf_device
;
491 static int sony_pf_add(void)
495 /* don't run again if already initialized */
496 if (atomic_add_return(1, &sony_pf_users
) > 1)
499 ret
= platform_driver_register(&sony_pf_driver
);
503 sony_pf_device
= platform_device_alloc("sony-laptop", -1);
504 if (!sony_pf_device
) {
506 goto out_platform_registered
;
509 ret
= platform_device_add(sony_pf_device
);
511 goto out_platform_alloced
;
515 out_platform_alloced
:
516 platform_device_put(sony_pf_device
);
517 sony_pf_device
= NULL
;
518 out_platform_registered
:
519 platform_driver_unregister(&sony_pf_driver
);
521 atomic_dec(&sony_pf_users
);
525 static void sony_pf_remove(void)
527 /* deregister only after the last user has gone */
528 if (!atomic_dec_and_test(&sony_pf_users
))
531 platform_device_del(sony_pf_device
);
532 platform_device_put(sony_pf_device
);
533 platform_driver_unregister(&sony_pf_driver
);
536 /*********** SNC (SNY5001) Device ***********/
538 /* the device uses 1-based values, while the backlight subsystem uses
540 #define SONY_MAX_BRIGHTNESS 8
542 #define SNC_VALIDATE_IN 0
543 #define SNC_VALIDATE_OUT 1
545 static ssize_t
sony_nc_sysfs_show(struct device
*, struct device_attribute
*,
547 static ssize_t
sony_nc_sysfs_store(struct device
*, struct device_attribute
*,
548 const char *, size_t);
549 static int boolean_validate(const int, const int);
550 static int brightness_default_validate(const int, const int);
552 struct sony_nc_value
{
553 char *name
; /* name of the entry */
554 char **acpiget
; /* names of the ACPI get function */
555 char **acpiset
; /* names of the ACPI set function */
556 int (*validate
)(const int, const int); /* input/output validation */
557 int value
; /* current setting */
558 int valid
; /* Has ever been set */
559 int debug
; /* active only in debug mode ? */
560 struct device_attribute devattr
; /* sysfs atribute */
563 #define SNC_HANDLE_NAMES(_name, _values...) \
564 static char *snc_##_name[] = { _values, NULL }
566 #define SNC_HANDLE(_name, _getters, _setters, _validate, _debug) \
568 .name = __stringify(_name), \
569 .acpiget = _getters, \
570 .acpiset = _setters, \
571 .validate = _validate, \
573 .devattr = __ATTR(_name, 0, sony_nc_sysfs_show, sony_nc_sysfs_store), \
576 #define SNC_HANDLE_NULL { .name = NULL }
578 SNC_HANDLE_NAMES(fnkey_get
, "GHKE");
580 SNC_HANDLE_NAMES(brightness_def_get
, "GPBR");
581 SNC_HANDLE_NAMES(brightness_def_set
, "SPBR");
583 SNC_HANDLE_NAMES(cdpower_get
, "GCDP");
584 SNC_HANDLE_NAMES(cdpower_set
, "SCDP", "CDPW");
586 SNC_HANDLE_NAMES(audiopower_get
, "GAZP");
587 SNC_HANDLE_NAMES(audiopower_set
, "AZPW");
589 SNC_HANDLE_NAMES(lanpower_get
, "GLNP");
590 SNC_HANDLE_NAMES(lanpower_set
, "LNPW");
592 SNC_HANDLE_NAMES(lidstate_get
, "GLID");
594 SNC_HANDLE_NAMES(indicatorlamp_get
, "GILS");
595 SNC_HANDLE_NAMES(indicatorlamp_set
, "SILS");
597 SNC_HANDLE_NAMES(gainbass_get
, "GMGB");
598 SNC_HANDLE_NAMES(gainbass_set
, "CMGB");
600 SNC_HANDLE_NAMES(PID_get
, "GPID");
602 SNC_HANDLE_NAMES(CTR_get
, "GCTR");
603 SNC_HANDLE_NAMES(CTR_set
, "SCTR");
605 SNC_HANDLE_NAMES(PCR_get
, "GPCR");
606 SNC_HANDLE_NAMES(PCR_set
, "SPCR");
608 SNC_HANDLE_NAMES(CMI_get
, "GCMI");
609 SNC_HANDLE_NAMES(CMI_set
, "SCMI");
611 static struct sony_nc_value sony_nc_values
[] = {
612 SNC_HANDLE(brightness_default
, snc_brightness_def_get
,
613 snc_brightness_def_set
, brightness_default_validate
, 0),
614 SNC_HANDLE(fnkey
, snc_fnkey_get
, NULL
, NULL
, 0),
615 SNC_HANDLE(cdpower
, snc_cdpower_get
, snc_cdpower_set
, boolean_validate
, 0),
616 SNC_HANDLE(audiopower
, snc_audiopower_get
, snc_audiopower_set
,
617 boolean_validate
, 0),
618 SNC_HANDLE(lanpower
, snc_lanpower_get
, snc_lanpower_set
,
619 boolean_validate
, 1),
620 SNC_HANDLE(lidstate
, snc_lidstate_get
, NULL
,
621 boolean_validate
, 0),
622 SNC_HANDLE(indicatorlamp
, snc_indicatorlamp_get
, snc_indicatorlamp_set
,
623 boolean_validate
, 0),
624 SNC_HANDLE(gainbass
, snc_gainbass_get
, snc_gainbass_set
,
625 boolean_validate
, 0),
626 /* unknown methods */
627 SNC_HANDLE(PID
, snc_PID_get
, NULL
, NULL
, 1),
628 SNC_HANDLE(CTR
, snc_CTR_get
, snc_CTR_set
, NULL
, 1),
629 SNC_HANDLE(PCR
, snc_PCR_get
, snc_PCR_set
, NULL
, 1),
630 SNC_HANDLE(CMI
, snc_CMI_get
, snc_CMI_set
, NULL
, 1),
634 static acpi_handle sony_nc_acpi_handle
;
635 static struct acpi_device
*sony_nc_acpi_device
= NULL
;
638 * acpi_evaluate_object wrappers
640 static int acpi_callgetfunc(acpi_handle handle
, char *name
, int *result
)
642 struct acpi_buffer output
;
643 union acpi_object out_obj
;
646 output
.length
= sizeof(out_obj
);
647 output
.pointer
= &out_obj
;
649 status
= acpi_evaluate_object(handle
, name
, NULL
, &output
);
650 if ((status
== AE_OK
) && (out_obj
.type
== ACPI_TYPE_INTEGER
)) {
651 *result
= out_obj
.integer
.value
;
655 printk(KERN_WARNING DRV_PFX
"acpi_callreadfunc failed\n");
660 static int acpi_callsetfunc(acpi_handle handle
, char *name
, int value
,
663 struct acpi_object_list params
;
664 union acpi_object in_obj
;
665 struct acpi_buffer output
;
666 union acpi_object out_obj
;
670 params
.pointer
= &in_obj
;
671 in_obj
.type
= ACPI_TYPE_INTEGER
;
672 in_obj
.integer
.value
= value
;
674 output
.length
= sizeof(out_obj
);
675 output
.pointer
= &out_obj
;
677 status
= acpi_evaluate_object(handle
, name
, ¶ms
, &output
);
678 if (status
== AE_OK
) {
679 if (result
!= NULL
) {
680 if (out_obj
.type
!= ACPI_TYPE_INTEGER
) {
681 printk(KERN_WARNING DRV_PFX
"acpi_evaluate_object bad "
685 *result
= out_obj
.integer
.value
;
690 printk(KERN_WARNING DRV_PFX
"acpi_evaluate_object failed\n");
696 * sony_nc_values input/output validate functions
699 /* brightness_default_validate:
701 * manipulate input output values to keep consistency with the
702 * backlight framework for which brightness values are 0-based.
704 static int brightness_default_validate(const int direction
, const int value
)
707 case SNC_VALIDATE_OUT
:
709 case SNC_VALIDATE_IN
:
710 if (value
>= 0 && value
< SONY_MAX_BRIGHTNESS
)
718 * on input validate boolean values 0/1, on output just pass the
721 static int boolean_validate(const int direction
, const int value
)
723 if (direction
== SNC_VALIDATE_IN
) {
724 if (value
!= 0 && value
!= 1)
731 * Sysfs show/store common to all sony_nc_values
733 static ssize_t
sony_nc_sysfs_show(struct device
*dev
, struct device_attribute
*attr
,
737 struct sony_nc_value
*item
=
738 container_of(attr
, struct sony_nc_value
, devattr
);
743 if (acpi_callgetfunc(sony_nc_acpi_handle
, *item
->acpiget
, &value
) < 0)
747 value
= item
->validate(SNC_VALIDATE_OUT
, value
);
749 return snprintf(buffer
, PAGE_SIZE
, "%d\n", value
);
752 static ssize_t
sony_nc_sysfs_store(struct device
*dev
,
753 struct device_attribute
*attr
,
754 const char *buffer
, size_t count
)
757 struct sony_nc_value
*item
=
758 container_of(attr
, struct sony_nc_value
, devattr
);
766 value
= simple_strtoul(buffer
, NULL
, 10);
769 value
= item
->validate(SNC_VALIDATE_IN
, value
);
774 if (acpi_callsetfunc(sony_nc_acpi_handle
, *item
->acpiset
, value
, NULL
) < 0)
785 static int sony_backlight_update_status(struct backlight_device
*bd
)
787 return acpi_callsetfunc(sony_nc_acpi_handle
, "SBRT",
788 bd
->props
.brightness
+ 1, NULL
);
791 static int sony_backlight_get_brightness(struct backlight_device
*bd
)
795 if (acpi_callgetfunc(sony_nc_acpi_handle
, "GBRT", &value
))
797 /* brightness levels are 1-based, while backlight ones are 0-based */
801 static struct backlight_device
*sony_backlight_device
;
802 static struct backlight_ops sony_backlight_ops
= {
803 .update_status
= sony_backlight_update_status
,
804 .get_brightness
= sony_backlight_get_brightness
,
808 * New SNC-only Vaios event mapping to driver known keys
810 struct sony_nc_event
{
815 static struct sony_nc_event
*sony_nc_events
;
817 /* Vaio C* --maybe also FE*, N* and AR* ?-- special init sequence
820 static int sony_nc_C_enable(const struct dmi_system_id
*id
)
824 printk(KERN_NOTICE DRV_PFX
"detected %s\n", id
->ident
);
826 sony_nc_events
= id
->driver_data
;
828 if (acpi_callsetfunc(sony_nc_acpi_handle
, "SN02", 0x4, &result
) < 0
829 || acpi_callsetfunc(sony_nc_acpi_handle
, "SN07", 0x2, &result
) < 0
830 || acpi_callsetfunc(sony_nc_acpi_handle
, "SN02", 0x10, &result
) < 0
831 || acpi_callsetfunc(sony_nc_acpi_handle
, "SN07", 0x0, &result
) < 0
832 || acpi_callsetfunc(sony_nc_acpi_handle
, "SN03", 0x2, &result
) < 0
833 || acpi_callsetfunc(sony_nc_acpi_handle
, "SN07", 0x101, &result
) < 0) {
834 printk(KERN_WARNING DRV_PFX
"failed to initialize SNC, some "
835 "functionalities may be missing\n");
841 static struct sony_nc_event sony_C_events
[] = {
842 { 0x81, SONYPI_EVENT_FNKEY_F1
},
843 { 0x01, SONYPI_EVENT_FNKEY_RELEASED
},
844 { 0x85, SONYPI_EVENT_FNKEY_F5
},
845 { 0x05, SONYPI_EVENT_FNKEY_RELEASED
},
846 { 0x86, SONYPI_EVENT_FNKEY_F6
},
847 { 0x06, SONYPI_EVENT_FNKEY_RELEASED
},
848 { 0x87, SONYPI_EVENT_FNKEY_F7
},
849 { 0x07, SONYPI_EVENT_FNKEY_RELEASED
},
850 { 0x8A, SONYPI_EVENT_FNKEY_F10
},
851 { 0x0A, SONYPI_EVENT_FNKEY_RELEASED
},
852 { 0x8C, SONYPI_EVENT_FNKEY_F12
},
853 { 0x0C, SONYPI_EVENT_FNKEY_RELEASED
},
857 /* SNC-only model map */
858 static const struct dmi_system_id sony_nc_ids
[] = {
860 .ident
= "Sony Vaio FE Series",
861 .callback
= sony_nc_C_enable
,
862 .driver_data
= sony_C_events
,
864 DMI_MATCH(DMI_SYS_VENDOR
, "Sony Corporation"),
865 DMI_MATCH(DMI_PRODUCT_NAME
, "VGN-FE"),
869 .ident
= "Sony Vaio FZ Series",
870 .callback
= sony_nc_C_enable
,
871 .driver_data
= sony_C_events
,
873 DMI_MATCH(DMI_SYS_VENDOR
, "Sony Corporation"),
874 DMI_MATCH(DMI_PRODUCT_NAME
, "VGN-FZ"),
878 .ident
= "Sony Vaio C Series",
879 .callback
= sony_nc_C_enable
,
880 .driver_data
= sony_C_events
,
882 DMI_MATCH(DMI_SYS_VENDOR
, "Sony Corporation"),
883 DMI_MATCH(DMI_PRODUCT_NAME
, "VGN-C"),
887 .ident
= "Sony Vaio N Series",
888 .callback
= sony_nc_C_enable
,
889 .driver_data
= sony_C_events
,
891 DMI_MATCH(DMI_SYS_VENDOR
, "Sony Corporation"),
892 DMI_MATCH(DMI_PRODUCT_NAME
, "VGN-N"),
901 static void sony_acpi_notify(acpi_handle handle
, u32 event
, void *data
)
903 struct sony_nc_event
*evmap
;
908 /* read the key pressed from EC.GECR
909 * A call to SN07 with 0x0202 will do it as well respecting
910 * the current protocol on different OSes
912 * Note: the path for GECR may be
913 * \_SB.PCI0.LPCB.EC (C, FE, AR, N and friends)
914 * \_SB.PCI0.PIB.EC0 (VGN-FR notifications are sent directly, no GECR)
916 * TODO: we may want to do the same for the older GHKE -need
917 * dmi list- so this snippet may become one more callback.
919 if (acpi_callsetfunc(handle
, "SN07", 0x0202, &result
) < 0)
920 dprintk("sony_acpi_notify, unable to decode event 0x%.2x\n", ev
);
926 for (evmap
= sony_nc_events
; evmap
->event
; evmap
++) {
927 if (evmap
->data
== ev
) {
933 dprintk("sony_acpi_notify, event: 0x%.2x\n", ev
);
934 sony_laptop_report_input_event(ev
);
935 acpi_bus_generate_proc_event(sony_nc_acpi_device
, 1, ev
);
938 static acpi_status
sony_walk_callback(acpi_handle handle
, u32 level
,
939 void *context
, void **return_value
)
941 struct acpi_namespace_node
*node
;
942 union acpi_operand_object
*operand
;
944 node
= (struct acpi_namespace_node
*)handle
;
945 operand
= (union acpi_operand_object
*)node
->object
;
947 printk(KERN_WARNING DRV_PFX
"method: name: %4.4s, args %X\n", node
->name
.ascii
,
948 (u32
) operand
->method
.param_count
);
956 static int sony_nc_resume(struct acpi_device
*device
)
958 struct sony_nc_value
*item
;
960 for (item
= sony_nc_values
; item
->name
; item
++) {
965 ret
= acpi_callsetfunc(sony_nc_acpi_handle
, *item
->acpiset
,
968 printk("%s: %d\n", __FUNCTION__
, ret
);
973 /* set the last requested brightness level */
974 if (sony_backlight_device
&&
975 !sony_backlight_update_status(sony_backlight_device
))
976 printk(KERN_WARNING DRV_PFX
"unable to restore brightness level");
978 /* re-initialize models with specific requirements */
979 dmi_check_system(sony_nc_ids
);
984 static int sony_nc_add(struct acpi_device
*device
)
989 struct sony_nc_value
*item
;
991 printk(KERN_INFO DRV_PFX
"%s v%s.\n",
992 SONY_NC_DRIVER_NAME
, SONY_LAPTOP_DRIVER_VERSION
);
994 sony_nc_acpi_device
= device
;
995 strcpy(acpi_device_class(device
), "sony/hotkey");
997 sony_nc_acpi_handle
= device
->handle
;
999 /* read device status */
1000 result
= acpi_bus_get_status(device
);
1001 /* bail IFF the above call was successful and the device is not present */
1002 if (!result
&& !device
->status
.present
) {
1003 dprintk("Device not present\n");
1009 status
= acpi_walk_namespace(ACPI_TYPE_METHOD
, sony_nc_acpi_handle
,
1010 1, sony_walk_callback
, NULL
, NULL
);
1011 if (ACPI_FAILURE(status
)) {
1012 printk(KERN_WARNING DRV_PFX
"unable to walk acpi resources\n");
1018 /* try to _INI the device if such method exists (ACPI spec 3.0-6.5.1
1019 * should be respected as we already checked for the device presence above */
1020 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle
, METHOD_NAME__INI
, &handle
))) {
1021 dprintk("Invoking _INI\n");
1022 if (ACPI_FAILURE(acpi_evaluate_object(sony_nc_acpi_handle
, METHOD_NAME__INI
,
1024 dprintk("_INI Method failed\n");
1027 /* setup input devices and helper fifo */
1028 result
= sony_laptop_setup_input(device
);
1030 printk(KERN_ERR DRV_PFX
1031 "Unabe to create input devices.\n");
1035 status
= acpi_install_notify_handler(sony_nc_acpi_handle
,
1037 sony_acpi_notify
, NULL
);
1038 if (ACPI_FAILURE(status
)) {
1039 printk(KERN_WARNING DRV_PFX
"unable to install notify handler (%u)\n", status
);
1044 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle
, "GBRT", &handle
))) {
1045 sony_backlight_device
= backlight_device_register("sony", NULL
,
1047 &sony_backlight_ops
);
1049 if (IS_ERR(sony_backlight_device
)) {
1050 printk(KERN_WARNING DRV_PFX
"unable to register backlight device\n");
1051 sony_backlight_device
= NULL
;
1053 sony_backlight_device
->props
.brightness
=
1054 sony_backlight_get_brightness
1055 (sony_backlight_device
);
1056 sony_backlight_device
->props
.max_brightness
=
1057 SONY_MAX_BRIGHTNESS
- 1;
1062 /* initialize models with specific requirements */
1063 dmi_check_system(sony_nc_ids
);
1065 result
= sony_pf_add();
1069 /* create sony_pf sysfs attributes related to the SNC device */
1070 for (item
= sony_nc_values
; item
->name
; ++item
) {
1072 if (!debug
&& item
->debug
)
1075 /* find the available acpiget as described in the DSDT */
1076 for (; item
->acpiget
&& *item
->acpiget
; ++item
->acpiget
) {
1077 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle
,
1080 dprintk("Found %s getter: %s\n",
1081 item
->name
, *item
->acpiget
);
1082 item
->devattr
.attr
.mode
|= S_IRUGO
;
1087 /* find the available acpiset as described in the DSDT */
1088 for (; item
->acpiset
&& *item
->acpiset
; ++item
->acpiset
) {
1089 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle
,
1092 dprintk("Found %s setter: %s\n",
1093 item
->name
, *item
->acpiset
);
1094 item
->devattr
.attr
.mode
|= S_IWUSR
;
1099 if (item
->devattr
.attr
.mode
!= 0) {
1101 device_create_file(&sony_pf_device
->dev
,
1111 for (item
= sony_nc_values
; item
->name
; ++item
) {
1112 device_remove_file(&sony_pf_device
->dev
, &item
->devattr
);
1117 if (sony_backlight_device
)
1118 backlight_device_unregister(sony_backlight_device
);
1120 status
= acpi_remove_notify_handler(sony_nc_acpi_handle
,
1123 if (ACPI_FAILURE(status
))
1124 printk(KERN_WARNING DRV_PFX
"unable to remove notify handler\n");
1127 sony_laptop_remove_input();
1133 static int sony_nc_remove(struct acpi_device
*device
, int type
)
1136 struct sony_nc_value
*item
;
1138 if (sony_backlight_device
)
1139 backlight_device_unregister(sony_backlight_device
);
1141 sony_nc_acpi_device
= NULL
;
1143 status
= acpi_remove_notify_handler(sony_nc_acpi_handle
,
1146 if (ACPI_FAILURE(status
))
1147 printk(KERN_WARNING DRV_PFX
"unable to remove notify handler\n");
1149 for (item
= sony_nc_values
; item
->name
; ++item
) {
1150 device_remove_file(&sony_pf_device
->dev
, &item
->devattr
);
1154 sony_laptop_remove_input();
1155 dprintk(SONY_NC_DRIVER_NAME
" removed.\n");
1160 static const struct acpi_device_id sony_device_ids
[] = {
1165 MODULE_DEVICE_TABLE(acpi
, sony_device_ids
);
1167 static const struct acpi_device_id sony_nc_device_ids
[] = {
1172 static struct acpi_driver sony_nc_driver
= {
1173 .name
= SONY_NC_DRIVER_NAME
,
1174 .class = SONY_NC_CLASS
,
1175 .ids
= sony_nc_device_ids
,
1176 .owner
= THIS_MODULE
,
1179 .remove
= sony_nc_remove
,
1180 .resume
= sony_nc_resume
,
1184 /*********** SPIC (SNY6001) Device ***********/
1186 #define SONYPI_DEVICE_TYPE1 0x00000001
1187 #define SONYPI_DEVICE_TYPE2 0x00000002
1188 #define SONYPI_DEVICE_TYPE3 0x00000004
1189 #define SONYPI_DEVICE_TYPE4 0x00000008
1191 #define SONYPI_TYPE1_OFFSET 0x04
1192 #define SONYPI_TYPE2_OFFSET 0x12
1193 #define SONYPI_TYPE3_OFFSET 0x12
1194 #define SONYPI_TYPE4_OFFSET 0x12
1196 struct sony_pic_ioport
{
1197 struct acpi_resource_io io1
;
1198 struct acpi_resource_io io2
;
1199 struct list_head list
;
1202 struct sony_pic_irq
{
1203 struct acpi_resource_irq irq
;
1204 struct list_head list
;
1207 struct sonypi_eventtypes
{
1210 struct sonypi_event
*events
;
1213 struct device_ctrl
{
1215 int (*handle_irq
)(const u8
, const u8
);
1220 struct sonypi_eventtypes
*event_types
;
1223 struct sony_pic_dev
{
1224 struct device_ctrl
*control
;
1225 struct acpi_device
*acpi_dev
;
1226 struct sony_pic_irq
*cur_irq
;
1227 struct sony_pic_ioport
*cur_ioport
;
1228 struct list_head interrupts
;
1229 struct list_head ioports
;
1236 static struct sony_pic_dev spic_dev
= {
1237 .interrupts
= LIST_HEAD_INIT(spic_dev
.interrupts
),
1238 .ioports
= LIST_HEAD_INIT(spic_dev
.ioports
),
1242 #define SONYPI_JOGGER_MASK 0x00000001
1243 #define SONYPI_CAPTURE_MASK 0x00000002
1244 #define SONYPI_FNKEY_MASK 0x00000004
1245 #define SONYPI_BLUETOOTH_MASK 0x00000008
1246 #define SONYPI_PKEY_MASK 0x00000010
1247 #define SONYPI_BACK_MASK 0x00000020
1248 #define SONYPI_HELP_MASK 0x00000040
1249 #define SONYPI_LID_MASK 0x00000080
1250 #define SONYPI_ZOOM_MASK 0x00000100
1251 #define SONYPI_THUMBPHRASE_MASK 0x00000200
1252 #define SONYPI_MEYE_MASK 0x00000400
1253 #define SONYPI_MEMORYSTICK_MASK 0x00000800
1254 #define SONYPI_BATTERY_MASK 0x00001000
1255 #define SONYPI_WIRELESS_MASK 0x00002000
1257 struct sonypi_event
{
1262 /* The set of possible button release events */
1263 static struct sonypi_event sonypi_releaseev
[] = {
1264 { 0x00, SONYPI_EVENT_ANYBUTTON_RELEASED
},
1268 /* The set of possible jogger events */
1269 static struct sonypi_event sonypi_joggerev
[] = {
1270 { 0x1f, SONYPI_EVENT_JOGDIAL_UP
},
1271 { 0x01, SONYPI_EVENT_JOGDIAL_DOWN
},
1272 { 0x5f, SONYPI_EVENT_JOGDIAL_UP_PRESSED
},
1273 { 0x41, SONYPI_EVENT_JOGDIAL_DOWN_PRESSED
},
1274 { 0x1e, SONYPI_EVENT_JOGDIAL_FAST_UP
},
1275 { 0x02, SONYPI_EVENT_JOGDIAL_FAST_DOWN
},
1276 { 0x5e, SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED
},
1277 { 0x42, SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED
},
1278 { 0x1d, SONYPI_EVENT_JOGDIAL_VFAST_UP
},
1279 { 0x03, SONYPI_EVENT_JOGDIAL_VFAST_DOWN
},
1280 { 0x5d, SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED
},
1281 { 0x43, SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED
},
1282 { 0x40, SONYPI_EVENT_JOGDIAL_PRESSED
},
1286 /* The set of possible capture button events */
1287 static struct sonypi_event sonypi_captureev
[] = {
1288 { 0x05, SONYPI_EVENT_CAPTURE_PARTIALPRESSED
},
1289 { 0x07, SONYPI_EVENT_CAPTURE_PRESSED
},
1290 { 0x40, SONYPI_EVENT_CAPTURE_PRESSED
},
1291 { 0x01, SONYPI_EVENT_CAPTURE_PARTIALRELEASED
},
1295 /* The set of possible fnkeys events */
1296 static struct sonypi_event sonypi_fnkeyev
[] = {
1297 { 0x10, SONYPI_EVENT_FNKEY_ESC
},
1298 { 0x11, SONYPI_EVENT_FNKEY_F1
},
1299 { 0x12, SONYPI_EVENT_FNKEY_F2
},
1300 { 0x13, SONYPI_EVENT_FNKEY_F3
},
1301 { 0x14, SONYPI_EVENT_FNKEY_F4
},
1302 { 0x15, SONYPI_EVENT_FNKEY_F5
},
1303 { 0x16, SONYPI_EVENT_FNKEY_F6
},
1304 { 0x17, SONYPI_EVENT_FNKEY_F7
},
1305 { 0x18, SONYPI_EVENT_FNKEY_F8
},
1306 { 0x19, SONYPI_EVENT_FNKEY_F9
},
1307 { 0x1a, SONYPI_EVENT_FNKEY_F10
},
1308 { 0x1b, SONYPI_EVENT_FNKEY_F11
},
1309 { 0x1c, SONYPI_EVENT_FNKEY_F12
},
1310 { 0x1f, SONYPI_EVENT_FNKEY_RELEASED
},
1311 { 0x21, SONYPI_EVENT_FNKEY_1
},
1312 { 0x22, SONYPI_EVENT_FNKEY_2
},
1313 { 0x31, SONYPI_EVENT_FNKEY_D
},
1314 { 0x32, SONYPI_EVENT_FNKEY_E
},
1315 { 0x33, SONYPI_EVENT_FNKEY_F
},
1316 { 0x34, SONYPI_EVENT_FNKEY_S
},
1317 { 0x35, SONYPI_EVENT_FNKEY_B
},
1318 { 0x36, SONYPI_EVENT_FNKEY_ONLY
},
1322 /* The set of possible program key events */
1323 static struct sonypi_event sonypi_pkeyev
[] = {
1324 { 0x01, SONYPI_EVENT_PKEY_P1
},
1325 { 0x02, SONYPI_EVENT_PKEY_P2
},
1326 { 0x04, SONYPI_EVENT_PKEY_P3
},
1330 /* The set of possible bluetooth events */
1331 static struct sonypi_event sonypi_blueev
[] = {
1332 { 0x55, SONYPI_EVENT_BLUETOOTH_PRESSED
},
1333 { 0x59, SONYPI_EVENT_BLUETOOTH_ON
},
1334 { 0x5a, SONYPI_EVENT_BLUETOOTH_OFF
},
1338 /* The set of possible wireless events */
1339 static struct sonypi_event sonypi_wlessev
[] = {
1340 { 0x59, SONYPI_EVENT_WIRELESS_ON
},
1341 { 0x5a, SONYPI_EVENT_WIRELESS_OFF
},
1345 /* The set of possible back button events */
1346 static struct sonypi_event sonypi_backev
[] = {
1347 { 0x20, SONYPI_EVENT_BACK_PRESSED
},
1351 /* The set of possible help button events */
1352 static struct sonypi_event sonypi_helpev
[] = {
1353 { 0x3b, SONYPI_EVENT_HELP_PRESSED
},
1358 /* The set of possible lid events */
1359 static struct sonypi_event sonypi_lidev
[] = {
1360 { 0x51, SONYPI_EVENT_LID_CLOSED
},
1361 { 0x50, SONYPI_EVENT_LID_OPENED
},
1365 /* The set of possible zoom events */
1366 static struct sonypi_event sonypi_zoomev
[] = {
1367 { 0x39, SONYPI_EVENT_ZOOM_PRESSED
},
1368 { 0x10, SONYPI_EVENT_ZOOM_IN_PRESSED
},
1369 { 0x20, SONYPI_EVENT_ZOOM_OUT_PRESSED
},
1373 /* The set of possible thumbphrase events */
1374 static struct sonypi_event sonypi_thumbphraseev
[] = {
1375 { 0x3a, SONYPI_EVENT_THUMBPHRASE_PRESSED
},
1379 /* The set of possible motioneye camera events */
1380 static struct sonypi_event sonypi_meyeev
[] = {
1381 { 0x00, SONYPI_EVENT_MEYE_FACE
},
1382 { 0x01, SONYPI_EVENT_MEYE_OPPOSITE
},
1386 /* The set of possible memorystick events */
1387 static struct sonypi_event sonypi_memorystickev
[] = {
1388 { 0x53, SONYPI_EVENT_MEMORYSTICK_INSERT
},
1389 { 0x54, SONYPI_EVENT_MEMORYSTICK_EJECT
},
1393 /* The set of possible battery events */
1394 static struct sonypi_event sonypi_batteryev
[] = {
1395 { 0x20, SONYPI_EVENT_BATTERY_INSERT
},
1396 { 0x30, SONYPI_EVENT_BATTERY_REMOVE
},
1400 static struct sonypi_eventtypes type1_events
[] = {
1401 { 0, 0xffffffff, sonypi_releaseev
},
1402 { 0x70, SONYPI_MEYE_MASK
, sonypi_meyeev
},
1403 { 0x30, SONYPI_LID_MASK
, sonypi_lidev
},
1404 { 0x60, SONYPI_CAPTURE_MASK
, sonypi_captureev
},
1405 { 0x10, SONYPI_JOGGER_MASK
, sonypi_joggerev
},
1406 { 0x20, SONYPI_FNKEY_MASK
, sonypi_fnkeyev
},
1407 { 0x30, SONYPI_BLUETOOTH_MASK
, sonypi_blueev
},
1408 { 0x40, SONYPI_PKEY_MASK
, sonypi_pkeyev
},
1409 { 0x30, SONYPI_MEMORYSTICK_MASK
, sonypi_memorystickev
},
1410 { 0x40, SONYPI_BATTERY_MASK
, sonypi_batteryev
},
1413 static struct sonypi_eventtypes type2_events
[] = {
1414 { 0, 0xffffffff, sonypi_releaseev
},
1415 { 0x38, SONYPI_LID_MASK
, sonypi_lidev
},
1416 { 0x11, SONYPI_JOGGER_MASK
, sonypi_joggerev
},
1417 { 0x61, SONYPI_CAPTURE_MASK
, sonypi_captureev
},
1418 { 0x21, SONYPI_FNKEY_MASK
, sonypi_fnkeyev
},
1419 { 0x31, SONYPI_BLUETOOTH_MASK
, sonypi_blueev
},
1420 { 0x08, SONYPI_PKEY_MASK
, sonypi_pkeyev
},
1421 { 0x11, SONYPI_BACK_MASK
, sonypi_backev
},
1422 { 0x21, SONYPI_HELP_MASK
, sonypi_helpev
},
1423 { 0x21, SONYPI_ZOOM_MASK
, sonypi_zoomev
},
1424 { 0x20, SONYPI_THUMBPHRASE_MASK
, sonypi_thumbphraseev
},
1425 { 0x31, SONYPI_MEMORYSTICK_MASK
, sonypi_memorystickev
},
1426 { 0x41, SONYPI_BATTERY_MASK
, sonypi_batteryev
},
1427 { 0x31, SONYPI_PKEY_MASK
, sonypi_pkeyev
},
1430 static struct sonypi_eventtypes type3_events
[] = {
1431 { 0, 0xffffffff, sonypi_releaseev
},
1432 { 0x21, SONYPI_FNKEY_MASK
, sonypi_fnkeyev
},
1433 { 0x31, SONYPI_WIRELESS_MASK
, sonypi_wlessev
},
1434 { 0x31, SONYPI_MEMORYSTICK_MASK
, sonypi_memorystickev
},
1435 { 0x41, SONYPI_BATTERY_MASK
, sonypi_batteryev
},
1436 { 0x31, SONYPI_PKEY_MASK
, sonypi_pkeyev
},
1439 static struct sonypi_eventtypes type4_events
[] = {
1440 { 0, 0xffffffff, sonypi_releaseev
},
1441 { 0x21, SONYPI_FNKEY_MASK
, sonypi_fnkeyev
},
1442 { 0x31, SONYPI_WIRELESS_MASK
, sonypi_wlessev
},
1443 { 0x31, SONYPI_MEMORYSTICK_MASK
, sonypi_memorystickev
},
1444 { 0x41, SONYPI_BATTERY_MASK
, sonypi_batteryev
},
1445 { 0x05, SONYPI_PKEY_MASK
, sonypi_pkeyev
},
1446 { 0x05, SONYPI_ZOOM_MASK
, sonypi_zoomev
},
1447 { 0x05, SONYPI_CAPTURE_MASK
, sonypi_captureev
},
1451 /* low level spic calls */
1452 #define ITERATIONS_LONG 10000
1453 #define ITERATIONS_SHORT 10
1454 #define wait_on_command(command, iterations) { \
1455 unsigned int n = iterations; \
1456 while (--n && (command)) \
1459 dprintk("command failed at %s : %s (line %d)\n", \
1460 __FILE__, __FUNCTION__, __LINE__); \
1463 static u8
sony_pic_call1(u8 dev
)
1467 wait_on_command(inb_p(spic_dev
.cur_ioport
->io1
.minimum
+ 4) & 2,
1469 outb(dev
, spic_dev
.cur_ioport
->io1
.minimum
+ 4);
1470 v1
= inb_p(spic_dev
.cur_ioport
->io1
.minimum
+ 4);
1471 v2
= inb_p(spic_dev
.cur_ioport
->io1
.minimum
);
1472 dprintk("sony_pic_call1(0x%.2x): 0x%.4x\n", dev
, (v2
<< 8) | v1
);
1476 static u8
sony_pic_call2(u8 dev
, u8 fn
)
1480 wait_on_command(inb_p(spic_dev
.cur_ioport
->io1
.minimum
+ 4) & 2,
1482 outb(dev
, spic_dev
.cur_ioport
->io1
.minimum
+ 4);
1483 wait_on_command(inb_p(spic_dev
.cur_ioport
->io1
.minimum
+ 4) & 2,
1485 outb(fn
, spic_dev
.cur_ioport
->io1
.minimum
);
1486 v1
= inb_p(spic_dev
.cur_ioport
->io1
.minimum
);
1487 dprintk("sony_pic_call2(0x%.2x - 0x%.2x): 0x%.4x\n", dev
, fn
, v1
);
1491 static u8
sony_pic_call3(u8 dev
, u8 fn
, u8 v
)
1495 wait_on_command(inb_p(spic_dev
.cur_ioport
->io1
.minimum
+ 4) & 2, ITERATIONS_LONG
);
1496 outb(dev
, spic_dev
.cur_ioport
->io1
.minimum
+ 4);
1497 wait_on_command(inb_p(spic_dev
.cur_ioport
->io1
.minimum
+ 4) & 2, ITERATIONS_LONG
);
1498 outb(fn
, spic_dev
.cur_ioport
->io1
.minimum
);
1499 wait_on_command(inb_p(spic_dev
.cur_ioport
->io1
.minimum
+ 4) & 2, ITERATIONS_LONG
);
1500 outb(v
, spic_dev
.cur_ioport
->io1
.minimum
);
1501 v1
= inb_p(spic_dev
.cur_ioport
->io1
.minimum
);
1502 dprintk("sony_pic_call3(0x%.2x - 0x%.2x - 0x%.2x): 0x%.4x\n",
1508 * minidrivers for SPIC models
1510 static int type4_handle_irq(const u8 data_mask
, const u8 ev
)
1513 * 0x31 could mean we have to take some extra action and wait for
1514 * the next irq for some Type4 models, it will generate a new
1515 * irq and we can read new data from the device:
1516 * - 0x5c and 0x5f requires 0xA0
1517 * - 0x61 requires 0xB3
1519 if (data_mask
== 0x31) {
1520 if (ev
== 0x5c || ev
== 0x5f)
1521 sony_pic_call1(0xA0);
1522 else if (ev
== 0x61)
1523 sony_pic_call1(0xB3);
1529 static struct device_ctrl spic_types
[] = {
1531 .model
= SONYPI_DEVICE_TYPE1
,
1533 .evport_offset
= SONYPI_TYPE1_OFFSET
,
1534 .event_types
= type1_events
,
1537 .model
= SONYPI_DEVICE_TYPE2
,
1539 .evport_offset
= SONYPI_TYPE2_OFFSET
,
1540 .event_types
= type2_events
,
1543 .model
= SONYPI_DEVICE_TYPE3
,
1545 .evport_offset
= SONYPI_TYPE3_OFFSET
,
1546 .event_types
= type3_events
,
1549 .model
= SONYPI_DEVICE_TYPE4
,
1550 .handle_irq
= type4_handle_irq
,
1551 .evport_offset
= SONYPI_TYPE4_OFFSET
,
1552 .event_types
= type4_events
,
1556 static void sony_pic_detect_device_type(struct sony_pic_dev
*dev
)
1558 struct pci_dev
*pcidev
;
1560 pcidev
= pci_get_device(PCI_VENDOR_ID_INTEL
,
1561 PCI_DEVICE_ID_INTEL_82371AB_3
, NULL
);
1563 dev
->control
= &spic_types
[0];
1567 pcidev
= pci_get_device(PCI_VENDOR_ID_INTEL
,
1568 PCI_DEVICE_ID_INTEL_ICH6_1
, NULL
);
1570 dev
->control
= &spic_types
[2];
1574 pcidev
= pci_get_device(PCI_VENDOR_ID_INTEL
,
1575 PCI_DEVICE_ID_INTEL_ICH7_1
, NULL
);
1577 dev
->control
= &spic_types
[3];
1581 pcidev
= pci_get_device(PCI_VENDOR_ID_INTEL
,
1582 PCI_DEVICE_ID_INTEL_ICH8_4
, NULL
);
1584 dev
->control
= &spic_types
[3];
1589 dev
->control
= &spic_types
[1];
1593 pci_dev_put(pcidev
);
1595 printk(KERN_INFO DRV_PFX
"detected Type%d model\n",
1596 dev
->control
->model
== SONYPI_DEVICE_TYPE1
? 1 :
1597 dev
->control
->model
== SONYPI_DEVICE_TYPE2
? 2 :
1598 dev
->control
->model
== SONYPI_DEVICE_TYPE3
? 3 : 4);
1601 /* camera tests and poweron/poweroff */
1602 #define SONYPI_CAMERA_PICTURE 5
1603 #define SONYPI_CAMERA_CONTROL 0x10
1605 #define SONYPI_CAMERA_BRIGHTNESS 0
1606 #define SONYPI_CAMERA_CONTRAST 1
1607 #define SONYPI_CAMERA_HUE 2
1608 #define SONYPI_CAMERA_COLOR 3
1609 #define SONYPI_CAMERA_SHARPNESS 4
1611 #define SONYPI_CAMERA_EXPOSURE_MASK 0xC
1612 #define SONYPI_CAMERA_WHITE_BALANCE_MASK 0x3
1613 #define SONYPI_CAMERA_PICTURE_MODE_MASK 0x30
1614 #define SONYPI_CAMERA_MUTE_MASK 0x40
1616 /* the rest don't need a loop until not 0xff */
1617 #define SONYPI_CAMERA_AGC 6
1618 #define SONYPI_CAMERA_AGC_MASK 0x30
1619 #define SONYPI_CAMERA_SHUTTER_MASK 0x7
1621 #define SONYPI_CAMERA_SHUTDOWN_REQUEST 7
1622 #define SONYPI_CAMERA_CONTROL 0x10
1624 #define SONYPI_CAMERA_STATUS 7
1625 #define SONYPI_CAMERA_STATUS_READY 0x2
1626 #define SONYPI_CAMERA_STATUS_POSITION 0x4
1628 #define SONYPI_DIRECTION_BACKWARDS 0x4
1630 #define SONYPI_CAMERA_REVISION 8
1631 #define SONYPI_CAMERA_ROMVERSION 9
1633 static int __sony_pic_camera_ready(void)
1637 v
= sony_pic_call2(0x8f, SONYPI_CAMERA_STATUS
);
1638 return (v
!= 0xff && (v
& SONYPI_CAMERA_STATUS_READY
));
1641 static int __sony_pic_camera_off(void)
1644 printk(KERN_WARNING DRV_PFX
"camera control not enabled\n");
1648 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_PICTURE
,
1649 SONYPI_CAMERA_MUTE_MASK
),
1652 if (spic_dev
.camera_power
) {
1653 sony_pic_call2(0x91, 0);
1654 spic_dev
.camera_power
= 0;
1659 static int __sony_pic_camera_on(void)
1664 printk(KERN_WARNING DRV_PFX
"camera control not enabled\n");
1668 if (spic_dev
.camera_power
)
1671 for (j
= 5; j
> 0; j
--) {
1673 for (x
= 0; x
< 100 && sony_pic_call2(0x91, 0x1); x
++)
1675 sony_pic_call1(0x93);
1677 for (i
= 400; i
> 0; i
--) {
1678 if (__sony_pic_camera_ready())
1687 printk(KERN_WARNING DRV_PFX
"failed to power on camera\n");
1691 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_CONTROL
,
1695 spic_dev
.camera_power
= 1;
1699 /* External camera command (exported to the motion eye v4l driver) */
1700 int sony_pic_camera_command(int command
, u8 value
)
1705 mutex_lock(&spic_dev
.lock
);
1708 case SONY_PIC_COMMAND_SETCAMERA
:
1710 __sony_pic_camera_on();
1712 __sony_pic_camera_off();
1714 case SONY_PIC_COMMAND_SETCAMERABRIGHTNESS
:
1715 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_BRIGHTNESS
, value
),
1718 case SONY_PIC_COMMAND_SETCAMERACONTRAST
:
1719 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_CONTRAST
, value
),
1722 case SONY_PIC_COMMAND_SETCAMERAHUE
:
1723 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_HUE
, value
),
1726 case SONY_PIC_COMMAND_SETCAMERACOLOR
:
1727 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_COLOR
, value
),
1730 case SONY_PIC_COMMAND_SETCAMERASHARPNESS
:
1731 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_SHARPNESS
, value
),
1734 case SONY_PIC_COMMAND_SETCAMERAPICTURE
:
1735 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_PICTURE
, value
),
1738 case SONY_PIC_COMMAND_SETCAMERAAGC
:
1739 wait_on_command(sony_pic_call3(0x90, SONYPI_CAMERA_AGC
, value
),
1743 printk(KERN_ERR DRV_PFX
"sony_pic_camera_command invalid: %d\n",
1747 mutex_unlock(&spic_dev
.lock
);
1750 EXPORT_SYMBOL(sony_pic_camera_command
);
1752 /* gprs/edge modem (SZ460N and SZ210P), thanks to Joshua Wise */
1753 static void sony_pic_set_wwanpower(u8 state
)
1756 mutex_lock(&spic_dev
.lock
);
1757 if (spic_dev
.wwan_power
== state
) {
1758 mutex_unlock(&spic_dev
.lock
);
1761 sony_pic_call2(0xB0, state
);
1762 spic_dev
.wwan_power
= state
;
1763 mutex_unlock(&spic_dev
.lock
);
1766 static ssize_t
sony_pic_wwanpower_store(struct device
*dev
,
1767 struct device_attribute
*attr
,
1768 const char *buffer
, size_t count
)
1770 unsigned long value
;
1774 value
= simple_strtoul(buffer
, NULL
, 10);
1775 sony_pic_set_wwanpower(value
);
1780 static ssize_t
sony_pic_wwanpower_show(struct device
*dev
,
1781 struct device_attribute
*attr
, char *buffer
)
1784 mutex_lock(&spic_dev
.lock
);
1785 count
= snprintf(buffer
, PAGE_SIZE
, "%d\n", spic_dev
.wwan_power
);
1786 mutex_unlock(&spic_dev
.lock
);
1790 /* bluetooth subsystem power state */
1791 static void __sony_pic_set_bluetoothpower(u8 state
)
1794 if (spic_dev
.bluetooth_power
== state
)
1796 sony_pic_call2(0x96, state
);
1797 sony_pic_call1(0x82);
1798 spic_dev
.bluetooth_power
= state
;
1801 static ssize_t
sony_pic_bluetoothpower_store(struct device
*dev
,
1802 struct device_attribute
*attr
,
1803 const char *buffer
, size_t count
)
1805 unsigned long value
;
1809 value
= simple_strtoul(buffer
, NULL
, 10);
1810 mutex_lock(&spic_dev
.lock
);
1811 __sony_pic_set_bluetoothpower(value
);
1812 mutex_unlock(&spic_dev
.lock
);
1817 static ssize_t
sony_pic_bluetoothpower_show(struct device
*dev
,
1818 struct device_attribute
*attr
, char *buffer
)
1821 mutex_lock(&spic_dev
.lock
);
1822 count
= snprintf(buffer
, PAGE_SIZE
, "%d\n", spic_dev
.bluetooth_power
);
1823 mutex_unlock(&spic_dev
.lock
);
1828 /* FAN0 information (reverse engineered from ACPI tables) */
1829 #define SONY_PIC_FAN0_STATUS 0x93
1830 static int sony_pic_set_fanspeed(unsigned long value
)
1832 return ec_write(SONY_PIC_FAN0_STATUS
, value
);
1835 static int sony_pic_get_fanspeed(u8
*value
)
1837 return ec_read(SONY_PIC_FAN0_STATUS
, value
);
1840 static ssize_t
sony_pic_fanspeed_store(struct device
*dev
,
1841 struct device_attribute
*attr
,
1842 const char *buffer
, size_t count
)
1844 unsigned long value
;
1848 value
= simple_strtoul(buffer
, NULL
, 10);
1849 if (sony_pic_set_fanspeed(value
))
1855 static ssize_t
sony_pic_fanspeed_show(struct device
*dev
,
1856 struct device_attribute
*attr
, char *buffer
)
1859 if (sony_pic_get_fanspeed(&value
))
1862 return snprintf(buffer
, PAGE_SIZE
, "%d\n", value
);
1865 #define SPIC_ATTR(_name, _mode) \
1866 struct device_attribute spic_attr_##_name = __ATTR(_name, \
1867 _mode, sony_pic_## _name ##_show, \
1868 sony_pic_## _name ##_store)
1870 static SPIC_ATTR(bluetoothpower
, 0644);
1871 static SPIC_ATTR(wwanpower
, 0644);
1872 static SPIC_ATTR(fanspeed
, 0644);
1874 static struct attribute
*spic_attributes
[] = {
1875 &spic_attr_bluetoothpower
.attr
,
1876 &spic_attr_wwanpower
.attr
,
1877 &spic_attr_fanspeed
.attr
,
1881 static struct attribute_group spic_attribute_group
= {
1882 .attrs
= spic_attributes
1885 /******** SONYPI compatibility **********/
1886 #ifdef CONFIG_SONYPI_COMPAT
1888 /* battery / brightness / temperature addresses */
1889 #define SONYPI_BAT_FLAGS 0x81
1890 #define SONYPI_LCD_LIGHT 0x96
1891 #define SONYPI_BAT1_PCTRM 0xa0
1892 #define SONYPI_BAT1_LEFT 0xa2
1893 #define SONYPI_BAT1_MAXRT 0xa4
1894 #define SONYPI_BAT2_PCTRM 0xa8
1895 #define SONYPI_BAT2_LEFT 0xaa
1896 #define SONYPI_BAT2_MAXRT 0xac
1897 #define SONYPI_BAT1_MAXTK 0xb0
1898 #define SONYPI_BAT1_FULL 0xb2
1899 #define SONYPI_BAT2_MAXTK 0xb8
1900 #define SONYPI_BAT2_FULL 0xba
1901 #define SONYPI_TEMP_STATUS 0xC1
1903 struct sonypi_compat_s
{
1904 struct fasync_struct
*fifo_async
;
1906 spinlock_t fifo_lock
;
1907 wait_queue_head_t fifo_proc_list
;
1908 atomic_t open_count
;
1910 static struct sonypi_compat_s sonypi_compat
= {
1911 .open_count
= ATOMIC_INIT(0),
1914 static int sonypi_misc_fasync(int fd
, struct file
*filp
, int on
)
1918 retval
= fasync_helper(fd
, filp
, on
, &sonypi_compat
.fifo_async
);
1924 static int sonypi_misc_release(struct inode
*inode
, struct file
*file
)
1926 sonypi_misc_fasync(-1, file
, 0);
1927 atomic_dec(&sonypi_compat
.open_count
);
1931 static int sonypi_misc_open(struct inode
*inode
, struct file
*file
)
1933 /* Flush input queue on first open */
1934 if (atomic_inc_return(&sonypi_compat
.open_count
) == 1)
1935 kfifo_reset(sonypi_compat
.fifo
);
1939 static ssize_t
sonypi_misc_read(struct file
*file
, char __user
*buf
,
1940 size_t count
, loff_t
*pos
)
1945 if ((kfifo_len(sonypi_compat
.fifo
) == 0) &&
1946 (file
->f_flags
& O_NONBLOCK
))
1949 ret
= wait_event_interruptible(sonypi_compat
.fifo_proc_list
,
1950 kfifo_len(sonypi_compat
.fifo
) != 0);
1954 while (ret
< count
&&
1955 (kfifo_get(sonypi_compat
.fifo
, &c
, sizeof(c
)) == sizeof(c
))) {
1956 if (put_user(c
, buf
++))
1962 struct inode
*inode
= file
->f_path
.dentry
->d_inode
;
1963 inode
->i_atime
= current_fs_time(inode
->i_sb
);
1969 static unsigned int sonypi_misc_poll(struct file
*file
, poll_table
*wait
)
1971 poll_wait(file
, &sonypi_compat
.fifo_proc_list
, wait
);
1972 if (kfifo_len(sonypi_compat
.fifo
))
1973 return POLLIN
| POLLRDNORM
;
1977 static int ec_read16(u8 addr
, u16
*value
)
1980 if (ec_read(addr
, &val_lb
))
1982 if (ec_read(addr
+ 1, &val_hb
))
1984 *value
= val_lb
| (val_hb
<< 8);
1988 static int sonypi_misc_ioctl(struct inode
*ip
, struct file
*fp
,
1989 unsigned int cmd
, unsigned long arg
)
1992 void __user
*argp
= (void __user
*)arg
;
1997 mutex_lock(&spic_dev
.lock
);
1999 case SONYPI_IOCGBRT
:
2000 if (sony_backlight_device
== NULL
) {
2004 if (acpi_callgetfunc(sony_nc_acpi_handle
, "GBRT", &value
)) {
2008 val8
= ((value
& 0xff) - 1) << 5;
2009 if (copy_to_user(argp
, &val8
, sizeof(val8
)))
2012 case SONYPI_IOCSBRT
:
2013 if (sony_backlight_device
== NULL
) {
2017 if (copy_from_user(&val8
, argp
, sizeof(val8
))) {
2021 if (acpi_callsetfunc(sony_nc_acpi_handle
, "SBRT",
2022 (val8
>> 5) + 1, NULL
)) {
2026 /* sync the backlight device status */
2027 sony_backlight_device
->props
.brightness
=
2028 sony_backlight_get_brightness(sony_backlight_device
);
2030 case SONYPI_IOCGBAT1CAP
:
2031 if (ec_read16(SONYPI_BAT1_FULL
, &val16
)) {
2035 if (copy_to_user(argp
, &val16
, sizeof(val16
)))
2038 case SONYPI_IOCGBAT1REM
:
2039 if (ec_read16(SONYPI_BAT1_LEFT
, &val16
)) {
2043 if (copy_to_user(argp
, &val16
, sizeof(val16
)))
2046 case SONYPI_IOCGBAT2CAP
:
2047 if (ec_read16(SONYPI_BAT2_FULL
, &val16
)) {
2051 if (copy_to_user(argp
, &val16
, sizeof(val16
)))
2054 case SONYPI_IOCGBAT2REM
:
2055 if (ec_read16(SONYPI_BAT2_LEFT
, &val16
)) {
2059 if (copy_to_user(argp
, &val16
, sizeof(val16
)))
2062 case SONYPI_IOCGBATFLAGS
:
2063 if (ec_read(SONYPI_BAT_FLAGS
, &val8
)) {
2068 if (copy_to_user(argp
, &val8
, sizeof(val8
)))
2071 case SONYPI_IOCGBLUE
:
2072 val8
= spic_dev
.bluetooth_power
;
2073 if (copy_to_user(argp
, &val8
, sizeof(val8
)))
2076 case SONYPI_IOCSBLUE
:
2077 if (copy_from_user(&val8
, argp
, sizeof(val8
))) {
2081 __sony_pic_set_bluetoothpower(val8
);
2084 case SONYPI_IOCGFAN
:
2085 if (sony_pic_get_fanspeed(&val8
)) {
2089 if (copy_to_user(argp
, &val8
, sizeof(val8
)))
2092 case SONYPI_IOCSFAN
:
2093 if (copy_from_user(&val8
, argp
, sizeof(val8
))) {
2097 if (sony_pic_set_fanspeed(val8
))
2100 /* GET Temperature (useful under APM) */
2101 case SONYPI_IOCGTEMP
:
2102 if (ec_read(SONYPI_TEMP_STATUS
, &val8
)) {
2106 if (copy_to_user(argp
, &val8
, sizeof(val8
)))
2112 mutex_unlock(&spic_dev
.lock
);
2116 static const struct file_operations sonypi_misc_fops
= {
2117 .owner
= THIS_MODULE
,
2118 .read
= sonypi_misc_read
,
2119 .poll
= sonypi_misc_poll
,
2120 .open
= sonypi_misc_open
,
2121 .release
= sonypi_misc_release
,
2122 .fasync
= sonypi_misc_fasync
,
2123 .ioctl
= sonypi_misc_ioctl
,
2126 static struct miscdevice sonypi_misc_device
= {
2127 .minor
= MISC_DYNAMIC_MINOR
,
2129 .fops
= &sonypi_misc_fops
,
2132 static void sonypi_compat_report_event(u8 event
)
2134 kfifo_put(sonypi_compat
.fifo
, (unsigned char *)&event
, sizeof(event
));
2135 kill_fasync(&sonypi_compat
.fifo_async
, SIGIO
, POLL_IN
);
2136 wake_up_interruptible(&sonypi_compat
.fifo_proc_list
);
2139 static int sonypi_compat_init(void)
2143 spin_lock_init(&sonypi_compat
.fifo_lock
);
2144 sonypi_compat
.fifo
= kfifo_alloc(SONY_LAPTOP_BUF_SIZE
, GFP_KERNEL
,
2145 &sonypi_compat
.fifo_lock
);
2146 if (IS_ERR(sonypi_compat
.fifo
)) {
2147 printk(KERN_ERR DRV_PFX
"kfifo_alloc failed\n");
2148 return PTR_ERR(sonypi_compat
.fifo
);
2151 init_waitqueue_head(&sonypi_compat
.fifo_proc_list
);
2154 sonypi_misc_device
.minor
= minor
;
2155 error
= misc_register(&sonypi_misc_device
);
2157 printk(KERN_ERR DRV_PFX
"misc_register failed\n");
2158 goto err_free_kfifo
;
2161 printk(KERN_INFO DRV_PFX
"device allocated minor is %d\n",
2162 sonypi_misc_device
.minor
);
2167 kfifo_free(sonypi_compat
.fifo
);
2171 static void sonypi_compat_exit(void)
2173 misc_deregister(&sonypi_misc_device
);
2174 kfifo_free(sonypi_compat
.fifo
);
2177 static int sonypi_compat_init(void) { return 0; }
2178 static void sonypi_compat_exit(void) { }
2179 static void sonypi_compat_report_event(u8 event
) { }
2180 #endif /* CONFIG_SONYPI_COMPAT */
2186 sony_pic_read_possible_resource(struct acpi_resource
*resource
, void *context
)
2189 struct sony_pic_dev
*dev
= (struct sony_pic_dev
*)context
;
2191 switch (resource
->type
) {
2192 case ACPI_RESOURCE_TYPE_START_DEPENDENT
:
2194 /* start IO enumeration */
2195 struct sony_pic_ioport
*ioport
= kzalloc(sizeof(*ioport
), GFP_KERNEL
);
2199 list_add(&ioport
->list
, &dev
->ioports
);
2203 case ACPI_RESOURCE_TYPE_END_DEPENDENT
:
2204 /* end IO enumeration */
2207 case ACPI_RESOURCE_TYPE_IRQ
:
2209 struct acpi_resource_irq
*p
= &resource
->data
.irq
;
2210 struct sony_pic_irq
*interrupt
= NULL
;
2211 if (!p
|| !p
->interrupt_count
) {
2213 * IRQ descriptors may have no IRQ# bits set,
2214 * particularly those those w/ _STA disabled
2216 dprintk("Blank IRQ resource\n");
2219 for (i
= 0; i
< p
->interrupt_count
; i
++) {
2220 if (!p
->interrupts
[i
]) {
2221 printk(KERN_WARNING DRV_PFX
2226 interrupt
= kzalloc(sizeof(*interrupt
),
2231 list_add(&interrupt
->list
, &dev
->interrupts
);
2232 interrupt
->irq
.triggering
= p
->triggering
;
2233 interrupt
->irq
.polarity
= p
->polarity
;
2234 interrupt
->irq
.sharable
= p
->sharable
;
2235 interrupt
->irq
.interrupt_count
= 1;
2236 interrupt
->irq
.interrupts
[0] = p
->interrupts
[i
];
2240 case ACPI_RESOURCE_TYPE_IO
:
2242 struct acpi_resource_io
*io
= &resource
->data
.io
;
2243 struct sony_pic_ioport
*ioport
=
2244 list_first_entry(&dev
->ioports
, struct sony_pic_ioport
, list
);
2246 dprintk("Blank IO resource\n");
2250 if (!ioport
->io1
.minimum
) {
2251 memcpy(&ioport
->io1
, io
, sizeof(*io
));
2252 dprintk("IO1 at 0x%.4x (0x%.2x)\n", ioport
->io1
.minimum
,
2253 ioport
->io1
.address_length
);
2255 else if (!ioport
->io2
.minimum
) {
2256 memcpy(&ioport
->io2
, io
, sizeof(*io
));
2257 dprintk("IO2 at 0x%.4x (0x%.2x)\n", ioport
->io2
.minimum
,
2258 ioport
->io2
.address_length
);
2261 printk(KERN_ERR DRV_PFX
"Unknown SPIC Type, more than 2 IO Ports\n");
2267 dprintk("Resource %d isn't an IRQ nor an IO port\n",
2270 case ACPI_RESOURCE_TYPE_END_TAG
:
2273 return AE_CTRL_TERMINATE
;
2276 static int sony_pic_possible_resources(struct acpi_device
*device
)
2279 acpi_status status
= AE_OK
;
2284 /* get device status */
2285 /* see acpi_pci_link_get_current acpi_pci_link_get_possible */
2286 dprintk("Evaluating _STA\n");
2287 result
= acpi_bus_get_status(device
);
2289 printk(KERN_WARNING DRV_PFX
"Unable to read status\n");
2293 if (!device
->status
.enabled
)
2294 dprintk("Device disabled\n");
2296 dprintk("Device enabled\n");
2299 * Query and parse 'method'
2301 dprintk("Evaluating %s\n", METHOD_NAME__PRS
);
2302 status
= acpi_walk_resources(device
->handle
, METHOD_NAME__PRS
,
2303 sony_pic_read_possible_resource
, &spic_dev
);
2304 if (ACPI_FAILURE(status
)) {
2305 printk(KERN_WARNING DRV_PFX
2306 "Failure evaluating %s\n",
2315 * Disable the spic device by calling its _DIS method
2317 static int sony_pic_disable(struct acpi_device
*device
)
2319 if (ACPI_FAILURE(acpi_evaluate_object(device
->handle
,
2320 "_DIS", NULL
, NULL
)))
2323 dprintk("Device disabled\n");
2329 * Based on drivers/acpi/pci_link.c:acpi_pci_link_set
2331 * Call _SRS to set current resources
2333 static int sony_pic_enable(struct acpi_device
*device
,
2334 struct sony_pic_ioport
*ioport
, struct sony_pic_irq
*irq
)
2338 /* Type 1 resource layout is:
2344 * Type 2 and 3 resource layout is:
2350 struct acpi_resource res1
;
2351 struct acpi_resource res2
;
2352 struct acpi_resource res3
;
2353 struct acpi_resource res4
;
2355 struct acpi_buffer buffer
= { 0, NULL
};
2357 if (!ioport
|| !irq
)
2360 /* init acpi_buffer */
2361 resource
= kzalloc(sizeof(*resource
) + 1, GFP_KERNEL
);
2365 buffer
.length
= sizeof(*resource
) + 1;
2366 buffer
.pointer
= resource
;
2368 /* setup Type 1 resources */
2369 if (spic_dev
.control
->model
== SONYPI_DEVICE_TYPE1
) {
2371 /* setup io resources */
2372 resource
->res1
.type
= ACPI_RESOURCE_TYPE_IO
;
2373 resource
->res1
.length
= sizeof(struct acpi_resource
);
2374 memcpy(&resource
->res1
.data
.io
, &ioport
->io1
,
2375 sizeof(struct acpi_resource_io
));
2377 resource
->res2
.type
= ACPI_RESOURCE_TYPE_IO
;
2378 resource
->res2
.length
= sizeof(struct acpi_resource
);
2379 memcpy(&resource
->res2
.data
.io
, &ioport
->io2
,
2380 sizeof(struct acpi_resource_io
));
2382 /* setup irq resource */
2383 resource
->res3
.type
= ACPI_RESOURCE_TYPE_IRQ
;
2384 resource
->res3
.length
= sizeof(struct acpi_resource
);
2385 memcpy(&resource
->res3
.data
.irq
, &irq
->irq
,
2386 sizeof(struct acpi_resource_irq
));
2387 /* we requested a shared irq */
2388 resource
->res3
.data
.irq
.sharable
= ACPI_SHARED
;
2390 resource
->res4
.type
= ACPI_RESOURCE_TYPE_END_TAG
;
2393 /* setup Type 2/3 resources */
2395 /* setup io resource */
2396 resource
->res1
.type
= ACPI_RESOURCE_TYPE_IO
;
2397 resource
->res1
.length
= sizeof(struct acpi_resource
);
2398 memcpy(&resource
->res1
.data
.io
, &ioport
->io1
,
2399 sizeof(struct acpi_resource_io
));
2401 /* setup irq resource */
2402 resource
->res2
.type
= ACPI_RESOURCE_TYPE_IRQ
;
2403 resource
->res2
.length
= sizeof(struct acpi_resource
);
2404 memcpy(&resource
->res2
.data
.irq
, &irq
->irq
,
2405 sizeof(struct acpi_resource_irq
));
2406 /* we requested a shared irq */
2407 resource
->res2
.data
.irq
.sharable
= ACPI_SHARED
;
2409 resource
->res3
.type
= ACPI_RESOURCE_TYPE_END_TAG
;
2412 /* Attempt to set the resource */
2413 dprintk("Evaluating _SRS\n");
2414 status
= acpi_set_current_resources(device
->handle
, &buffer
);
2416 /* check for total failure */
2417 if (ACPI_FAILURE(status
)) {
2418 printk(KERN_ERR DRV_PFX
"Error evaluating _SRS\n");
2423 /* Necessary device initializations calls (from sonypi) */
2424 sony_pic_call1(0x82);
2425 sony_pic_call2(0x81, 0xff);
2426 sony_pic_call1(compat
? 0x92 : 0x82);
2435 * ISR: some event is available
2438 static irqreturn_t
sony_pic_irq(int irq
, void *dev_id
)
2443 u8 device_event
= 0;
2445 struct sony_pic_dev
*dev
= (struct sony_pic_dev
*) dev_id
;
2447 ev
= inb_p(dev
->cur_ioport
->io1
.minimum
);
2448 if (dev
->cur_ioport
->io2
.minimum
)
2449 data_mask
= inb_p(dev
->cur_ioport
->io2
.minimum
);
2451 data_mask
= inb_p(dev
->cur_ioport
->io1
.minimum
+
2452 dev
->control
->evport_offset
);
2454 dprintk("event ([%.2x] [%.2x]) at port 0x%.4x(+0x%.2x)\n",
2455 ev
, data_mask
, dev
->cur_ioport
->io1
.minimum
,
2456 dev
->control
->evport_offset
);
2458 if (ev
== 0x00 || ev
== 0xff)
2461 for (i
= 0; dev
->control
->event_types
[i
].mask
; i
++) {
2463 if ((data_mask
& dev
->control
->event_types
[i
].data
) !=
2464 dev
->control
->event_types
[i
].data
)
2467 if (!(mask
& dev
->control
->event_types
[i
].mask
))
2470 for (j
= 0; dev
->control
->event_types
[i
].events
[j
].event
; j
++) {
2471 if (ev
== dev
->control
->event_types
[i
].events
[j
].data
) {
2474 event_types
[i
].events
[j
].event
;
2479 /* Still not able to decode the event try to pass
2480 * it over to the minidriver
2482 if (dev
->control
->handle_irq
&&
2483 dev
->control
->handle_irq(data_mask
, ev
) == 0)
2486 dprintk("unknown event ([%.2x] [%.2x]) at port 0x%.4x(+0x%.2x)\n",
2487 ev
, data_mask
, dev
->cur_ioport
->io1
.minimum
,
2488 dev
->control
->evport_offset
);
2492 sony_laptop_report_input_event(device_event
);
2493 acpi_bus_generate_proc_event(dev
->acpi_dev
, 1, device_event
);
2494 sonypi_compat_report_event(device_event
);
2504 static int sony_pic_remove(struct acpi_device
*device
, int type
)
2506 struct sony_pic_ioport
*io
, *tmp_io
;
2507 struct sony_pic_irq
*irq
, *tmp_irq
;
2509 if (sony_pic_disable(device
)) {
2510 printk(KERN_ERR DRV_PFX
"Couldn't disable device.\n");
2514 free_irq(spic_dev
.cur_irq
->irq
.interrupts
[0], &spic_dev
);
2515 release_region(spic_dev
.cur_ioport
->io1
.minimum
,
2516 spic_dev
.cur_ioport
->io1
.address_length
);
2517 if (spic_dev
.cur_ioport
->io2
.minimum
)
2518 release_region(spic_dev
.cur_ioport
->io2
.minimum
,
2519 spic_dev
.cur_ioport
->io2
.address_length
);
2521 sonypi_compat_exit();
2523 sony_laptop_remove_input();
2526 sysfs_remove_group(&sony_pf_device
->dev
.kobj
, &spic_attribute_group
);
2529 list_for_each_entry_safe(io
, tmp_io
, &spic_dev
.ioports
, list
) {
2530 list_del(&io
->list
);
2533 list_for_each_entry_safe(irq
, tmp_irq
, &spic_dev
.interrupts
, list
) {
2534 list_del(&irq
->list
);
2537 spic_dev
.cur_ioport
= NULL
;
2538 spic_dev
.cur_irq
= NULL
;
2540 dprintk(SONY_PIC_DRIVER_NAME
" removed.\n");
2544 static int sony_pic_add(struct acpi_device
*device
)
2547 struct sony_pic_ioport
*io
, *tmp_io
;
2548 struct sony_pic_irq
*irq
, *tmp_irq
;
2550 printk(KERN_INFO DRV_PFX
"%s v%s.\n",
2551 SONY_PIC_DRIVER_NAME
, SONY_LAPTOP_DRIVER_VERSION
);
2553 spic_dev
.acpi_dev
= device
;
2554 strcpy(acpi_device_class(device
), "sony/hotkey");
2555 sony_pic_detect_device_type(&spic_dev
);
2556 mutex_init(&spic_dev
.lock
);
2558 /* read _PRS resources */
2559 result
= sony_pic_possible_resources(device
);
2561 printk(KERN_ERR DRV_PFX
2562 "Unabe to read possible resources.\n");
2563 goto err_free_resources
;
2566 /* setup input devices and helper fifo */
2567 result
= sony_laptop_setup_input(device
);
2569 printk(KERN_ERR DRV_PFX
2570 "Unabe to create input devices.\n");
2571 goto err_free_resources
;
2574 if (sonypi_compat_init())
2575 goto err_remove_input
;
2577 /* request io port */
2578 list_for_each_entry_reverse(io
, &spic_dev
.ioports
, list
) {
2579 if (request_region(io
->io1
.minimum
, io
->io1
.address_length
,
2580 "Sony Programable I/O Device")) {
2581 dprintk("I/O port1: 0x%.4x (0x%.4x) + 0x%.2x\n",
2582 io
->io1
.minimum
, io
->io1
.maximum
,
2583 io
->io1
.address_length
);
2584 /* Type 1 have 2 ioports */
2585 if (io
->io2
.minimum
) {
2586 if (request_region(io
->io2
.minimum
,
2587 io
->io2
.address_length
,
2588 "Sony Programable I/O Device")) {
2589 dprintk("I/O port2: 0x%.4x (0x%.4x) + 0x%.2x\n",
2590 io
->io2
.minimum
, io
->io2
.maximum
,
2591 io
->io2
.address_length
);
2592 spic_dev
.cur_ioport
= io
;
2596 dprintk("Unable to get I/O port2: "
2597 "0x%.4x (0x%.4x) + 0x%.2x\n",
2598 io
->io2
.minimum
, io
->io2
.maximum
,
2599 io
->io2
.address_length
);
2600 release_region(io
->io1
.minimum
,
2601 io
->io1
.address_length
);
2605 spic_dev
.cur_ioport
= io
;
2610 if (!spic_dev
.cur_ioport
) {
2611 printk(KERN_ERR DRV_PFX
"Failed to request_region.\n");
2613 goto err_remove_compat
;
2617 list_for_each_entry_reverse(irq
, &spic_dev
.interrupts
, list
) {
2618 if (!request_irq(irq
->irq
.interrupts
[0], sony_pic_irq
,
2619 IRQF_SHARED
, "sony-laptop", &spic_dev
)) {
2620 dprintk("IRQ: %d - triggering: %d - "
2621 "polarity: %d - shr: %d\n",
2622 irq
->irq
.interrupts
[0],
2623 irq
->irq
.triggering
,
2626 spic_dev
.cur_irq
= irq
;
2630 if (!spic_dev
.cur_irq
) {
2631 printk(KERN_ERR DRV_PFX
"Failed to request_irq.\n");
2633 goto err_release_region
;
2636 /* set resource status _SRS */
2637 result
= sony_pic_enable(device
, spic_dev
.cur_ioport
, spic_dev
.cur_irq
);
2639 printk(KERN_ERR DRV_PFX
"Couldn't enable device.\n");
2643 spic_dev
.bluetooth_power
= -1;
2644 /* create device attributes */
2645 result
= sony_pf_add();
2647 goto err_disable_device
;
2649 result
= sysfs_create_group(&sony_pf_device
->dev
.kobj
, &spic_attribute_group
);
2659 sony_pic_disable(device
);
2662 free_irq(spic_dev
.cur_irq
->irq
.interrupts
[0], &spic_dev
);
2665 release_region(spic_dev
.cur_ioport
->io1
.minimum
,
2666 spic_dev
.cur_ioport
->io1
.address_length
);
2667 if (spic_dev
.cur_ioport
->io2
.minimum
)
2668 release_region(spic_dev
.cur_ioport
->io2
.minimum
,
2669 spic_dev
.cur_ioport
->io2
.address_length
);
2672 sonypi_compat_exit();
2675 sony_laptop_remove_input();
2678 list_for_each_entry_safe(io
, tmp_io
, &spic_dev
.ioports
, list
) {
2679 list_del(&io
->list
);
2682 list_for_each_entry_safe(irq
, tmp_irq
, &spic_dev
.interrupts
, list
) {
2683 list_del(&irq
->list
);
2686 spic_dev
.cur_ioport
= NULL
;
2687 spic_dev
.cur_irq
= NULL
;
2692 static int sony_pic_suspend(struct acpi_device
*device
, pm_message_t state
)
2694 if (sony_pic_disable(device
))
2699 static int sony_pic_resume(struct acpi_device
*device
)
2701 sony_pic_enable(device
, spic_dev
.cur_ioport
, spic_dev
.cur_irq
);
2705 static const struct acpi_device_id sony_pic_device_ids
[] = {
2710 static struct acpi_driver sony_pic_driver
= {
2711 .name
= SONY_PIC_DRIVER_NAME
,
2712 .class = SONY_PIC_CLASS
,
2713 .ids
= sony_pic_device_ids
,
2714 .owner
= THIS_MODULE
,
2716 .add
= sony_pic_add
,
2717 .remove
= sony_pic_remove
,
2718 .suspend
= sony_pic_suspend
,
2719 .resume
= sony_pic_resume
,
2723 static struct dmi_system_id __initdata sonypi_dmi_table
[] = {
2725 .ident
= "Sony Vaio",
2727 DMI_MATCH(DMI_SYS_VENDOR
, "Sony Corporation"),
2728 DMI_MATCH(DMI_PRODUCT_NAME
, "PCG-"),
2732 .ident
= "Sony Vaio",
2734 DMI_MATCH(DMI_SYS_VENDOR
, "Sony Corporation"),
2735 DMI_MATCH(DMI_PRODUCT_NAME
, "VGN-"),
2741 static int __init
sony_laptop_init(void)
2745 if (!no_spic
&& dmi_check_system(sonypi_dmi_table
)) {
2746 result
= acpi_bus_register_driver(&sony_pic_driver
);
2748 printk(KERN_ERR DRV_PFX
2749 "Unable to register SPIC driver.");
2754 result
= acpi_bus_register_driver(&sony_nc_driver
);
2756 printk(KERN_ERR DRV_PFX
"Unable to register SNC driver.");
2757 goto out_unregister_pic
;
2764 acpi_bus_unregister_driver(&sony_pic_driver
);
2769 static void __exit
sony_laptop_exit(void)
2771 acpi_bus_unregister_driver(&sony_nc_driver
);
2773 acpi_bus_unregister_driver(&sony_pic_driver
);
2776 module_init(sony_laptop_init
);
2777 module_exit(sony_laptop_exit
);