Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1 | /*-*-linux-c-*-*/ |
| 2 | |
| 3 | /* |
Jonathan Woithe | 409a3e9 | 2012-03-27 13:01:01 +1030 | [diff] [blame] | 4 | Copyright (C) 2007,2008 Jonathan Woithe <jwoithe@just42.net> |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 5 | Copyright (C) 2008 Peter Gruber <nokos@gmx.net> |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 6 | Copyright (C) 2008 Tony Vroon <tony@linx.net> |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 7 | Based on earlier work: |
| 8 | Copyright (C) 2003 Shane Spencer <shane@bogomip.com> |
| 9 | Adrian Yee <brewt-fujitsu@brewt.org> |
| 10 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 11 | Templated from msi-laptop.c and thinkpad_acpi.c which is copyright |
| 12 | by its respective authors. |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 13 | |
| 14 | This program is free software; you can redistribute it and/or modify |
| 15 | it under the terms of the GNU General Public License as published by |
| 16 | the Free Software Foundation; either version 2 of the License, or |
| 17 | (at your option) any later version. |
| 18 | |
| 19 | This program is distributed in the hope that it will be useful, but |
| 20 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | General Public License for more details. |
| 23 | |
| 24 | You should have received a copy of the GNU General Public License |
| 25 | along with this program; if not, write to the Free Software |
| 26 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 27 | 02110-1301, USA. |
| 28 | */ |
| 29 | |
| 30 | /* |
| 31 | * fujitsu-laptop.c - Fujitsu laptop support, providing access to additional |
| 32 | * features made available on a range of Fujitsu laptops including the |
| 33 | * P2xxx/P5xxx/S6xxx/S7xxx series. |
| 34 | * |
| 35 | * This driver exports a few files in /sys/devices/platform/fujitsu-laptop/; |
| 36 | * others may be added at a later date. |
| 37 | * |
| 38 | * lcd_level - Screen brightness: contains a single integer in the |
| 39 | * range 0..7. (rw) |
| 40 | * |
| 41 | * In addition to these platform device attributes the driver |
| 42 | * registers itself in the Linux backlight control subsystem and is |
| 43 | * available to userspace under /sys/class/backlight/fujitsu-laptop/. |
| 44 | * |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 45 | * Hotkeys present on certain Fujitsu laptops (eg: the S6xxx series) are |
| 46 | * also supported by this driver. |
| 47 | * |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 48 | * This driver has been tested on a Fujitsu Lifebook S6410, S7020 and |
| 49 | * P8010. It should work on most P-series and S-series Lifebooks, but |
| 50 | * YMMV. |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 51 | * |
| 52 | * The module parameter use_alt_lcd_levels switches between different ACPI |
| 53 | * brightness controls which are used by different Fujitsu laptops. In most |
| 54 | * cases the correct method is automatically detected. "use_alt_lcd_levels=1" |
| 55 | * is applicable for a Fujitsu Lifebook S6410 if autodetection fails. |
| 56 | * |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 57 | */ |
| 58 | |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 59 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 60 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 61 | #include <linux/module.h> |
| 62 | #include <linux/kernel.h> |
| 63 | #include <linux/init.h> |
| 64 | #include <linux/acpi.h> |
| 65 | #include <linux/dmi.h> |
| 66 | #include <linux/backlight.h> |
Michael Karcher | e8549e2 | 2015-01-18 20:28:46 +0100 | [diff] [blame] | 67 | #include <linux/fb.h> |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 68 | #include <linux/input.h> |
| 69 | #include <linux/kfifo.h> |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 70 | #include <linux/platform_device.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 71 | #include <linux/slab.h> |
Stephen Gildea | 1e384cb | 2009-08-25 14:41:52 +0930 | [diff] [blame] | 72 | #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 73 | #include <linux/leds.h> |
| 74 | #endif |
Hans de Goede | 413226f | 2015-06-16 16:28:03 +0200 | [diff] [blame] | 75 | #include <acpi/video.h> |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 76 | |
Jonathan Woithe | 84a6ce2 | 2009-07-31 18:16:59 +0930 | [diff] [blame] | 77 | #define FUJITSU_DRIVER_VERSION "0.6.0" |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 78 | |
| 79 | #define FUJITSU_LCD_N_LEVELS 8 |
| 80 | |
| 81 | #define ACPI_FUJITSU_CLASS "fujitsu" |
| 82 | #define ACPI_FUJITSU_HID "FUJ02B1" |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 83 | #define ACPI_FUJITSU_DRIVER_NAME "Fujitsu laptop FUJ02B1 ACPI brightness driver" |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 84 | #define ACPI_FUJITSU_DEVICE_NAME "Fujitsu FUJ02B1" |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 85 | #define ACPI_FUJITSU_HOTKEY_HID "FUJ02E3" |
| 86 | #define ACPI_FUJITSU_HOTKEY_DRIVER_NAME "Fujitsu laptop FUJ02E3 ACPI hotkeys driver" |
| 87 | #define ACPI_FUJITSU_HOTKEY_DEVICE_NAME "Fujitsu FUJ02E3" |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 88 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 89 | #define ACPI_FUJITSU_NOTIFY_CODE1 0x80 |
| 90 | |
| 91 | #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86 |
| 92 | #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87 |
| 93 | |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 94 | /* FUNC interface - command values */ |
| 95 | #define FUNC_RFKILL 0x1000 |
| 96 | #define FUNC_LEDS 0x1001 |
| 97 | #define FUNC_BUTTONS 0x1002 |
| 98 | #define FUNC_BACKLIGHT 0x1004 |
| 99 | |
| 100 | /* FUNC interface - responses */ |
| 101 | #define UNSUPPORTED_CMD 0x80000000 |
| 102 | |
Stephen Gildea | 1e384cb | 2009-08-25 14:41:52 +0930 | [diff] [blame] | 103 | #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 104 | /* FUNC interface - LED control */ |
| 105 | #define FUNC_LED_OFF 0x1 |
| 106 | #define FUNC_LED_ON 0x30001 |
| 107 | #define KEYBOARD_LAMPS 0x100 |
| 108 | #define LOGOLAMP_POWERON 0x2000 |
| 109 | #define LOGOLAMP_ALWAYS 0x4000 |
Michał Kępień | 4f62568 | 2016-04-12 22:06:34 +0930 | [diff] [blame^] | 110 | #define RADIO_LED_ON 0x20 |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 111 | #endif |
| 112 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 113 | /* Hotkey details */ |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 114 | #define KEY1_CODE 0x410 /* codes for the keys in the GIRB register */ |
| 115 | #define KEY2_CODE 0x411 |
| 116 | #define KEY3_CODE 0x412 |
| 117 | #define KEY4_CODE 0x413 |
Michał Kępień | b5df36c | 2016-02-24 14:23:32 +0100 | [diff] [blame] | 118 | #define KEY5_CODE 0x420 |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 119 | |
| 120 | #define MAX_HOTKEY_RINGBUFFER_SIZE 100 |
| 121 | #define RINGBUFFERSIZE 40 |
| 122 | |
| 123 | /* Debugging */ |
| 124 | #define FUJLAPTOP_LOG ACPI_FUJITSU_HID ": " |
| 125 | #define FUJLAPTOP_ERR KERN_ERR FUJLAPTOP_LOG |
| 126 | #define FUJLAPTOP_NOTICE KERN_NOTICE FUJLAPTOP_LOG |
| 127 | #define FUJLAPTOP_INFO KERN_INFO FUJLAPTOP_LOG |
| 128 | #define FUJLAPTOP_DEBUG KERN_DEBUG FUJLAPTOP_LOG |
| 129 | |
| 130 | #define FUJLAPTOP_DBG_ALL 0xffff |
| 131 | #define FUJLAPTOP_DBG_ERROR 0x0001 |
| 132 | #define FUJLAPTOP_DBG_WARN 0x0002 |
| 133 | #define FUJLAPTOP_DBG_INFO 0x0004 |
| 134 | #define FUJLAPTOP_DBG_TRACE 0x0008 |
| 135 | |
Jean Delvare | c4960cf | 2014-06-16 11:55:13 +0200 | [diff] [blame] | 136 | #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG |
| 137 | #define vdbg_printk(a_dbg_level, format, arg...) \ |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 138 | do { if (dbg_level & a_dbg_level) \ |
| 139 | printk(FUJLAPTOP_DEBUG "%s: " format, __func__ , ## arg); \ |
| 140 | } while (0) |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 141 | #else |
Jean Delvare | c4960cf | 2014-06-16 11:55:13 +0200 | [diff] [blame] | 142 | #define vdbg_printk(a_dbg_level, format, arg...) \ |
| 143 | do { } while (0) |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 144 | #endif |
| 145 | |
| 146 | /* Device controlling the backlight and associated keys */ |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 147 | struct fujitsu_t { |
| 148 | acpi_handle acpi_handle; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 149 | struct acpi_device *dev; |
| 150 | struct input_dev *input; |
| 151 | char phys[32]; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 152 | struct backlight_device *bl_device; |
| 153 | struct platform_device *pf_device; |
Michał Kępień | b5df36c | 2016-02-24 14:23:32 +0100 | [diff] [blame] | 154 | int keycode1, keycode2, keycode3, keycode4, keycode5; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 155 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 156 | unsigned int max_brightness; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 157 | unsigned int brightness_changed; |
| 158 | unsigned int brightness_level; |
| 159 | }; |
| 160 | |
| 161 | static struct fujitsu_t *fujitsu; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 162 | static int use_alt_lcd_levels = -1; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 163 | static int disable_brightness_adjust = -1; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 164 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 165 | /* Device used to access other hotkeys on the laptop */ |
| 166 | struct fujitsu_hotkey_t { |
| 167 | acpi_handle acpi_handle; |
| 168 | struct acpi_device *dev; |
| 169 | struct input_dev *input; |
| 170 | char phys[32]; |
| 171 | struct platform_device *pf_device; |
Stefani Seibold | 4546548 | 2009-12-21 14:37:26 -0800 | [diff] [blame] | 172 | struct kfifo fifo; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 173 | spinlock_t fifo_lock; |
Tony Vroon | 4898c2b | 2009-02-02 11:11:10 +0000 | [diff] [blame] | 174 | int rfkill_supported; |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 175 | int rfkill_state; |
| 176 | int logolamp_registered; |
| 177 | int kblamps_registered; |
Michał Kępień | 4f62568 | 2016-04-12 22:06:34 +0930 | [diff] [blame^] | 178 | int radio_led_registered; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | static struct fujitsu_hotkey_t *fujitsu_hotkey; |
| 182 | |
Bjorn Helgaas | b4ec027 | 2009-04-07 15:37:22 +0000 | [diff] [blame] | 183 | static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 184 | |
Stephen Gildea | 1e384cb | 2009-08-25 14:41:52 +0930 | [diff] [blame] | 185 | #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 186 | static enum led_brightness logolamp_get(struct led_classdev *cdev); |
| 187 | static void logolamp_set(struct led_classdev *cdev, |
| 188 | enum led_brightness brightness); |
| 189 | |
Axel Lin | 67af711 | 2010-07-20 15:19:45 -0700 | [diff] [blame] | 190 | static struct led_classdev logolamp_led = { |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 191 | .name = "fujitsu::logolamp", |
| 192 | .brightness_get = logolamp_get, |
| 193 | .brightness_set = logolamp_set |
| 194 | }; |
| 195 | |
| 196 | static enum led_brightness kblamps_get(struct led_classdev *cdev); |
| 197 | static void kblamps_set(struct led_classdev *cdev, |
| 198 | enum led_brightness brightness); |
| 199 | |
Axel Lin | 67af711 | 2010-07-20 15:19:45 -0700 | [diff] [blame] | 200 | static struct led_classdev kblamps_led = { |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 201 | .name = "fujitsu::kblamps", |
| 202 | .brightness_get = kblamps_get, |
| 203 | .brightness_set = kblamps_set |
| 204 | }; |
Michał Kępień | 4f62568 | 2016-04-12 22:06:34 +0930 | [diff] [blame^] | 205 | |
| 206 | static enum led_brightness radio_led_get(struct led_classdev *cdev); |
| 207 | static void radio_led_set(struct led_classdev *cdev, |
| 208 | enum led_brightness brightness); |
| 209 | |
| 210 | static struct led_classdev radio_led = { |
| 211 | .name = "fujitsu::radio_led", |
| 212 | .brightness_get = radio_led_get, |
| 213 | .brightness_set = radio_led_set |
| 214 | }; |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 215 | #endif |
| 216 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 217 | #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG |
| 218 | static u32 dbg_level = 0x03; |
| 219 | #endif |
| 220 | |
Bjorn Helgaas | 700b672 | 2009-04-07 15:37:16 +0000 | [diff] [blame] | 221 | static void acpi_fujitsu_notify(struct acpi_device *device, u32 event); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 222 | |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 223 | /* Fujitsu ACPI interface function */ |
| 224 | |
| 225 | static int call_fext_func(int cmd, int arg0, int arg1, int arg2) |
| 226 | { |
| 227 | acpi_status status = AE_OK; |
| 228 | union acpi_object params[4] = { |
| 229 | { .type = ACPI_TYPE_INTEGER }, |
| 230 | { .type = ACPI_TYPE_INTEGER }, |
| 231 | { .type = ACPI_TYPE_INTEGER }, |
| 232 | { .type = ACPI_TYPE_INTEGER } |
| 233 | }; |
| 234 | struct acpi_object_list arg_list = { 4, ¶ms[0] }; |
Zhang Rui | 29c29a9 | 2013-09-03 08:32:12 +0800 | [diff] [blame] | 235 | unsigned long long value; |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 236 | acpi_handle handle = NULL; |
| 237 | |
| 238 | status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle); |
| 239 | if (ACPI_FAILURE(status)) { |
| 240 | vdbg_printk(FUJLAPTOP_DBG_ERROR, |
| 241 | "FUNC interface is not present\n"); |
| 242 | return -ENODEV; |
| 243 | } |
| 244 | |
| 245 | params[0].integer.value = cmd; |
| 246 | params[1].integer.value = arg0; |
| 247 | params[2].integer.value = arg1; |
| 248 | params[3].integer.value = arg2; |
| 249 | |
Zhang Rui | 29c29a9 | 2013-09-03 08:32:12 +0800 | [diff] [blame] | 250 | status = acpi_evaluate_integer(handle, NULL, &arg_list, &value); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 251 | if (ACPI_FAILURE(status)) { |
| 252 | vdbg_printk(FUJLAPTOP_DBG_WARN, |
| 253 | "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) call failed\n", |
| 254 | cmd, arg0, arg1, arg2); |
| 255 | return -ENODEV; |
| 256 | } |
| 257 | |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 258 | vdbg_printk(FUJLAPTOP_DBG_TRACE, |
| 259 | "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n", |
Zhang Rui | 29c29a9 | 2013-09-03 08:32:12 +0800 | [diff] [blame] | 260 | cmd, arg0, arg1, arg2, (int)value); |
| 261 | return value; |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 262 | } |
| 263 | |
Stephen Gildea | 1e384cb | 2009-08-25 14:41:52 +0930 | [diff] [blame] | 264 | #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 265 | /* LED class callbacks */ |
| 266 | |
| 267 | static void logolamp_set(struct led_classdev *cdev, |
| 268 | enum led_brightness brightness) |
| 269 | { |
| 270 | if (brightness >= LED_FULL) { |
| 271 | call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON); |
| 272 | call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_ON); |
| 273 | } else if (brightness >= LED_HALF) { |
| 274 | call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON); |
| 275 | call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_OFF); |
| 276 | } else { |
| 277 | call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_OFF); |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | static void kblamps_set(struct led_classdev *cdev, |
| 282 | enum led_brightness brightness) |
| 283 | { |
| 284 | if (brightness >= LED_FULL) |
| 285 | call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_ON); |
| 286 | else |
| 287 | call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_OFF); |
| 288 | } |
| 289 | |
Michał Kępień | 4f62568 | 2016-04-12 22:06:34 +0930 | [diff] [blame^] | 290 | static void radio_led_set(struct led_classdev *cdev, |
| 291 | enum led_brightness brightness) |
| 292 | { |
| 293 | if (brightness >= LED_FULL) |
| 294 | call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, RADIO_LED_ON); |
| 295 | else |
| 296 | call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, 0x0); |
| 297 | } |
| 298 | |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 299 | static enum led_brightness logolamp_get(struct led_classdev *cdev) |
| 300 | { |
| 301 | enum led_brightness brightness = LED_OFF; |
| 302 | int poweron, always; |
| 303 | |
| 304 | poweron = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0); |
| 305 | if (poweron == FUNC_LED_ON) { |
| 306 | brightness = LED_HALF; |
| 307 | always = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0); |
| 308 | if (always == FUNC_LED_ON) |
| 309 | brightness = LED_FULL; |
| 310 | } |
| 311 | return brightness; |
| 312 | } |
| 313 | |
| 314 | static enum led_brightness kblamps_get(struct led_classdev *cdev) |
| 315 | { |
| 316 | enum led_brightness brightness = LED_OFF; |
| 317 | |
| 318 | if (call_fext_func(FUNC_LEDS, 0x2, KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON) |
| 319 | brightness = LED_FULL; |
| 320 | |
| 321 | return brightness; |
| 322 | } |
Michał Kępień | 4f62568 | 2016-04-12 22:06:34 +0930 | [diff] [blame^] | 323 | |
| 324 | static enum led_brightness radio_led_get(struct led_classdev *cdev) |
| 325 | { |
| 326 | enum led_brightness brightness = LED_OFF; |
| 327 | |
| 328 | if (call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0) & RADIO_LED_ON) |
| 329 | brightness = LED_FULL; |
| 330 | |
| 331 | return brightness; |
| 332 | } |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 333 | #endif |
| 334 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 335 | /* Hardware access for LCD brightness control */ |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 336 | |
| 337 | static int set_lcd_level(int level) |
| 338 | { |
| 339 | acpi_status status = AE_OK; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 340 | acpi_handle handle = NULL; |
| 341 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 342 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBLL [%d]\n", |
| 343 | level); |
| 344 | |
| 345 | if (level < 0 || level >= fujitsu->max_brightness) |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 346 | return -EINVAL; |
| 347 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 348 | status = acpi_get_handle(fujitsu->acpi_handle, "SBLL", &handle); |
| 349 | if (ACPI_FAILURE(status)) { |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 350 | vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBLL not present\n"); |
| 351 | return -ENODEV; |
| 352 | } |
| 353 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 354 | |
Zhang Rui | 6c7fe47a | 2013-09-03 08:31:52 +0800 | [diff] [blame] | 355 | status = acpi_execute_simple_method(handle, NULL, level); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 356 | if (ACPI_FAILURE(status)) |
| 357 | return -ENODEV; |
| 358 | |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | static int set_lcd_level_alt(int level) |
| 363 | { |
| 364 | acpi_status status = AE_OK; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 365 | acpi_handle handle = NULL; |
| 366 | |
| 367 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBL2 [%d]\n", |
| 368 | level); |
| 369 | |
| 370 | if (level < 0 || level >= fujitsu->max_brightness) |
| 371 | return -EINVAL; |
| 372 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 373 | status = acpi_get_handle(fujitsu->acpi_handle, "SBL2", &handle); |
| 374 | if (ACPI_FAILURE(status)) { |
| 375 | vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBL2 not present\n"); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 376 | return -ENODEV; |
| 377 | } |
| 378 | |
Zhang Rui | 6c7fe47a | 2013-09-03 08:31:52 +0800 | [diff] [blame] | 379 | status = acpi_execute_simple_method(handle, NULL, level); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 380 | if (ACPI_FAILURE(status)) |
| 381 | return -ENODEV; |
| 382 | |
| 383 | return 0; |
| 384 | } |
| 385 | |
| 386 | static int get_lcd_level(void) |
| 387 | { |
Matthew Wilcox | 27663c5 | 2008-10-10 02:22:59 -0400 | [diff] [blame] | 388 | unsigned long long state = 0; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 389 | acpi_status status = AE_OK; |
| 390 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 391 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLL\n"); |
| 392 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 393 | status = |
| 394 | acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state); |
Jonathan Woithe | 3b1c37c | 2009-12-23 09:19:42 +1030 | [diff] [blame] | 395 | if (ACPI_FAILURE(status)) |
| 396 | return 0; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 397 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 398 | fujitsu->brightness_level = state & 0x0fffffff; |
| 399 | |
| 400 | if (state & 0x80000000) |
| 401 | fujitsu->brightness_changed = 1; |
| 402 | else |
| 403 | fujitsu->brightness_changed = 0; |
| 404 | |
| 405 | return fujitsu->brightness_level; |
| 406 | } |
| 407 | |
| 408 | static int get_max_brightness(void) |
| 409 | { |
Matthew Wilcox | 27663c5 | 2008-10-10 02:22:59 -0400 | [diff] [blame] | 410 | unsigned long long state = 0; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 411 | acpi_status status = AE_OK; |
| 412 | |
| 413 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "get max lcd level via RBLL\n"); |
| 414 | |
| 415 | status = |
| 416 | acpi_evaluate_integer(fujitsu->acpi_handle, "RBLL", NULL, &state); |
Jonathan Woithe | 3b1c37c | 2009-12-23 09:19:42 +1030 | [diff] [blame] | 417 | if (ACPI_FAILURE(status)) |
| 418 | return -1; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 419 | |
| 420 | fujitsu->max_brightness = state; |
| 421 | |
| 422 | return fujitsu->max_brightness; |
| 423 | } |
| 424 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 425 | /* Backlight device stuff */ |
| 426 | |
| 427 | static int bl_get_brightness(struct backlight_device *b) |
| 428 | { |
Tony Vroon | f87a1a5 | 2009-01-07 10:11:24 +0000 | [diff] [blame] | 429 | return get_lcd_level(); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | static int bl_update_status(struct backlight_device *b) |
| 433 | { |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 434 | int ret; |
Michael Karcher | e8549e2 | 2015-01-18 20:28:46 +0100 | [diff] [blame] | 435 | if (b->props.power == FB_BLANK_POWERDOWN) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 436 | ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x3); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 437 | else |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 438 | ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x0); |
| 439 | if (ret != 0) |
| 440 | vdbg_printk(FUJLAPTOP_DBG_ERROR, |
| 441 | "Unable to adjust backlight power, error code %i\n", |
| 442 | ret); |
| 443 | |
| 444 | if (use_alt_lcd_levels) |
| 445 | ret = set_lcd_level_alt(b->props.brightness); |
| 446 | else |
| 447 | ret = set_lcd_level(b->props.brightness); |
| 448 | if (ret != 0) |
| 449 | vdbg_printk(FUJLAPTOP_DBG_ERROR, |
| 450 | "Unable to adjust LCD brightness, error code %i\n", |
| 451 | ret); |
| 452 | return ret; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 453 | } |
| 454 | |
Lionel Debroux | acc2472 | 2010-11-16 14:14:02 +0100 | [diff] [blame] | 455 | static const struct backlight_ops fujitsubl_ops = { |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 456 | .get_brightness = bl_get_brightness, |
| 457 | .update_status = bl_update_status, |
| 458 | }; |
| 459 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 460 | /* Platform LCD brightness device */ |
| 461 | |
| 462 | static ssize_t |
| 463 | show_max_brightness(struct device *dev, |
| 464 | struct device_attribute *attr, char *buf) |
| 465 | { |
| 466 | |
| 467 | int ret; |
| 468 | |
| 469 | ret = get_max_brightness(); |
| 470 | if (ret < 0) |
| 471 | return ret; |
| 472 | |
| 473 | return sprintf(buf, "%i\n", ret); |
| 474 | } |
| 475 | |
| 476 | static ssize_t |
| 477 | show_brightness_changed(struct device *dev, |
| 478 | struct device_attribute *attr, char *buf) |
| 479 | { |
| 480 | |
| 481 | int ret; |
| 482 | |
| 483 | ret = fujitsu->brightness_changed; |
| 484 | if (ret < 0) |
| 485 | return ret; |
| 486 | |
| 487 | return sprintf(buf, "%i\n", ret); |
| 488 | } |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 489 | |
| 490 | static ssize_t show_lcd_level(struct device *dev, |
| 491 | struct device_attribute *attr, char *buf) |
| 492 | { |
| 493 | |
| 494 | int ret; |
| 495 | |
Tony Vroon | f87a1a5 | 2009-01-07 10:11:24 +0000 | [diff] [blame] | 496 | ret = get_lcd_level(); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 497 | if (ret < 0) |
| 498 | return ret; |
| 499 | |
| 500 | return sprintf(buf, "%i\n", ret); |
| 501 | } |
| 502 | |
| 503 | static ssize_t store_lcd_level(struct device *dev, |
| 504 | struct device_attribute *attr, const char *buf, |
| 505 | size_t count) |
| 506 | { |
| 507 | |
| 508 | int level, ret; |
| 509 | |
| 510 | if (sscanf(buf, "%i", &level) != 1 |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 511 | || (level < 0 || level >= fujitsu->max_brightness)) |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 512 | return -EINVAL; |
| 513 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 514 | if (use_alt_lcd_levels) |
| 515 | ret = set_lcd_level_alt(level); |
| 516 | else |
| 517 | ret = set_lcd_level(level); |
| 518 | if (ret < 0) |
| 519 | return ret; |
| 520 | |
Tony Vroon | f87a1a5 | 2009-01-07 10:11:24 +0000 | [diff] [blame] | 521 | ret = get_lcd_level(); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 522 | if (ret < 0) |
| 523 | return ret; |
| 524 | |
| 525 | return count; |
| 526 | } |
| 527 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 528 | static ssize_t |
| 529 | ignore_store(struct device *dev, |
| 530 | struct device_attribute *attr, const char *buf, size_t count) |
| 531 | { |
| 532 | return count; |
| 533 | } |
| 534 | |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 535 | static ssize_t |
| 536 | show_lid_state(struct device *dev, |
| 537 | struct device_attribute *attr, char *buf) |
| 538 | { |
Tony Vroon | 4898c2b | 2009-02-02 11:11:10 +0000 | [diff] [blame] | 539 | if (!(fujitsu_hotkey->rfkill_supported & 0x100)) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 540 | return sprintf(buf, "unknown\n"); |
| 541 | if (fujitsu_hotkey->rfkill_state & 0x100) |
| 542 | return sprintf(buf, "open\n"); |
| 543 | else |
| 544 | return sprintf(buf, "closed\n"); |
| 545 | } |
| 546 | |
| 547 | static ssize_t |
| 548 | show_dock_state(struct device *dev, |
| 549 | struct device_attribute *attr, char *buf) |
| 550 | { |
Tony Vroon | 4898c2b | 2009-02-02 11:11:10 +0000 | [diff] [blame] | 551 | if (!(fujitsu_hotkey->rfkill_supported & 0x200)) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 552 | return sprintf(buf, "unknown\n"); |
| 553 | if (fujitsu_hotkey->rfkill_state & 0x200) |
| 554 | return sprintf(buf, "docked\n"); |
| 555 | else |
| 556 | return sprintf(buf, "undocked\n"); |
| 557 | } |
| 558 | |
| 559 | static ssize_t |
| 560 | show_radios_state(struct device *dev, |
| 561 | struct device_attribute *attr, char *buf) |
| 562 | { |
Tony Vroon | 4898c2b | 2009-02-02 11:11:10 +0000 | [diff] [blame] | 563 | if (!(fujitsu_hotkey->rfkill_supported & 0x20)) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 564 | return sprintf(buf, "unknown\n"); |
| 565 | if (fujitsu_hotkey->rfkill_state & 0x20) |
| 566 | return sprintf(buf, "on\n"); |
| 567 | else |
| 568 | return sprintf(buf, "killed\n"); |
| 569 | } |
| 570 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 571 | static DEVICE_ATTR(max_brightness, 0444, show_max_brightness, ignore_store); |
| 572 | static DEVICE_ATTR(brightness_changed, 0444, show_brightness_changed, |
| 573 | ignore_store); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 574 | static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 575 | static DEVICE_ATTR(lid, 0444, show_lid_state, ignore_store); |
| 576 | static DEVICE_ATTR(dock, 0444, show_dock_state, ignore_store); |
| 577 | static DEVICE_ATTR(radios, 0444, show_radios_state, ignore_store); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 578 | |
| 579 | static struct attribute *fujitsupf_attributes[] = { |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 580 | &dev_attr_brightness_changed.attr, |
| 581 | &dev_attr_max_brightness.attr, |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 582 | &dev_attr_lcd_level.attr, |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 583 | &dev_attr_lid.attr, |
| 584 | &dev_attr_dock.attr, |
| 585 | &dev_attr_radios.attr, |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 586 | NULL |
| 587 | }; |
| 588 | |
| 589 | static struct attribute_group fujitsupf_attribute_group = { |
| 590 | .attrs = fujitsupf_attributes |
| 591 | }; |
| 592 | |
| 593 | static struct platform_driver fujitsupf_driver = { |
| 594 | .driver = { |
| 595 | .name = "fujitsu-laptop", |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 596 | } |
| 597 | }; |
| 598 | |
Mathias Krause | fbe9b79 | 2014-07-16 19:43:11 +0200 | [diff] [blame] | 599 | static void __init dmi_check_cb_common(const struct dmi_system_id *id) |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 600 | { |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 601 | pr_info("Identified laptop model '%s'\n", id->ident); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 602 | if (use_alt_lcd_levels == -1) { |
Zhang Rui | dd13b9a | 2013-09-03 08:32:03 +0800 | [diff] [blame] | 603 | if (acpi_has_method(NULL, |
| 604 | "\\_SB.PCI0.LPCB.FJEX.SBL2")) |
Tony Vroon | f87a1a5 | 2009-01-07 10:11:24 +0000 | [diff] [blame] | 605 | use_alt_lcd_levels = 1; |
| 606 | else |
| 607 | use_alt_lcd_levels = 0; |
| 608 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as " |
| 609 | "%i\n", use_alt_lcd_levels); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 610 | } |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 611 | } |
| 612 | |
Mathias Krause | fbe9b79 | 2014-07-16 19:43:11 +0200 | [diff] [blame] | 613 | static int __init dmi_check_cb_s6410(const struct dmi_system_id *id) |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 614 | { |
| 615 | dmi_check_cb_common(id); |
| 616 | fujitsu->keycode1 = KEY_SCREENLOCK; /* "Lock" */ |
| 617 | fujitsu->keycode2 = KEY_HELP; /* "Mobility Center" */ |
Axel Lin | 80183a4 | 2010-07-20 15:19:40 -0700 | [diff] [blame] | 618 | return 1; |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 619 | } |
| 620 | |
Mathias Krause | fbe9b79 | 2014-07-16 19:43:11 +0200 | [diff] [blame] | 621 | static int __init dmi_check_cb_s6420(const struct dmi_system_id *id) |
Tony Vroon | 56960b5 | 2008-11-09 04:20:05 +0000 | [diff] [blame] | 622 | { |
| 623 | dmi_check_cb_common(id); |
| 624 | fujitsu->keycode1 = KEY_SCREENLOCK; /* "Lock" */ |
| 625 | fujitsu->keycode2 = KEY_HELP; /* "Mobility Center" */ |
Axel Lin | 80183a4 | 2010-07-20 15:19:40 -0700 | [diff] [blame] | 626 | return 1; |
Tony Vroon | 56960b5 | 2008-11-09 04:20:05 +0000 | [diff] [blame] | 627 | } |
| 628 | |
Mathias Krause | fbe9b79 | 2014-07-16 19:43:11 +0200 | [diff] [blame] | 629 | static int __init dmi_check_cb_p8010(const struct dmi_system_id *id) |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 630 | { |
| 631 | dmi_check_cb_common(id); |
| 632 | fujitsu->keycode1 = KEY_HELP; /* "Support" */ |
| 633 | fujitsu->keycode3 = KEY_SWITCHVIDEOMODE; /* "Presentation" */ |
| 634 | fujitsu->keycode4 = KEY_WWW; /* "Internet" */ |
Axel Lin | 80183a4 | 2010-07-20 15:19:40 -0700 | [diff] [blame] | 635 | return 1; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 636 | } |
| 637 | |
Mathias Krause | fbe9b79 | 2014-07-16 19:43:11 +0200 | [diff] [blame] | 638 | static const struct dmi_system_id fujitsu_dmi_table[] __initconst = { |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 639 | { |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 640 | .ident = "Fujitsu Siemens S6410", |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 641 | .matches = { |
| 642 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), |
| 643 | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6410"), |
| 644 | }, |
| 645 | .callback = dmi_check_cb_s6410}, |
Jonathan Woithe | d8196a9 | 2008-08-29 11:06:21 +0930 | [diff] [blame] | 646 | { |
Tony Vroon | 56960b5 | 2008-11-09 04:20:05 +0000 | [diff] [blame] | 647 | .ident = "Fujitsu Siemens S6420", |
| 648 | .matches = { |
| 649 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), |
| 650 | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6420"), |
| 651 | }, |
| 652 | .callback = dmi_check_cb_s6420}, |
| 653 | { |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 654 | .ident = "Fujitsu LifeBook P8010", |
Jonathan Woithe | d8196a9 | 2008-08-29 11:06:21 +0930 | [diff] [blame] | 655 | .matches = { |
| 656 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), |
| 657 | DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P8010"), |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 658 | }, |
| 659 | .callback = dmi_check_cb_p8010}, |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 660 | {} |
| 661 | }; |
| 662 | |
| 663 | /* ACPI device for LCD brightness control */ |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 664 | |
Adrian Bunk | b6f03ae | 2007-10-24 18:23:16 +0200 | [diff] [blame] | 665 | static int acpi_fujitsu_add(struct acpi_device *device) |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 666 | { |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 667 | int state = 0; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 668 | struct input_dev *input; |
| 669 | int error; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 670 | |
| 671 | if (!device) |
| 672 | return -EINVAL; |
| 673 | |
| 674 | fujitsu->acpi_handle = device->handle; |
| 675 | sprintf(acpi_device_name(device), "%s", ACPI_FUJITSU_DEVICE_NAME); |
| 676 | sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS); |
Pavel Machek | db89b4f | 2008-09-22 14:37:34 -0700 | [diff] [blame] | 677 | device->driver_data = fujitsu; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 678 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 679 | fujitsu->input = input = input_allocate_device(); |
| 680 | if (!input) { |
| 681 | error = -ENOMEM; |
Bjorn Helgaas | 700b672 | 2009-04-07 15:37:16 +0000 | [diff] [blame] | 682 | goto err_stop; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | snprintf(fujitsu->phys, sizeof(fujitsu->phys), |
| 686 | "%s/video/input0", acpi_device_hid(device)); |
| 687 | |
| 688 | input->name = acpi_device_name(device); |
| 689 | input->phys = fujitsu->phys; |
| 690 | input->id.bustype = BUS_HOST; |
| 691 | input->id.product = 0x06; |
| 692 | input->dev.parent = &device->dev; |
| 693 | input->evbit[0] = BIT(EV_KEY); |
| 694 | set_bit(KEY_BRIGHTNESSUP, input->keybit); |
| 695 | set_bit(KEY_BRIGHTNESSDOWN, input->keybit); |
| 696 | set_bit(KEY_UNKNOWN, input->keybit); |
| 697 | |
| 698 | error = input_register_device(input); |
| 699 | if (error) |
| 700 | goto err_free_input_dev; |
| 701 | |
Julia Lawall | b30bb89 | 2013-12-29 23:47:36 +0100 | [diff] [blame] | 702 | error = acpi_bus_update_power(fujitsu->acpi_handle, &state); |
| 703 | if (error) { |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 704 | pr_err("Error reading power state\n"); |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 705 | goto err_unregister_input_dev; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 706 | } |
| 707 | |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 708 | pr_info("ACPI: %s [%s] (%s)\n", |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 709 | acpi_device_name(device), acpi_device_bid(device), |
| 710 | !device->power.state ? "on" : "off"); |
| 711 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 712 | fujitsu->dev = device; |
| 713 | |
Zhang Rui | dd13b9a | 2013-09-03 08:32:03 +0800 | [diff] [blame] | 714 | if (acpi_has_method(device->handle, METHOD_NAME__INI)) { |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 715 | vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n"); |
| 716 | if (ACPI_FAILURE |
| 717 | (acpi_evaluate_object |
| 718 | (device->handle, METHOD_NAME__INI, NULL, NULL))) |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 719 | pr_err("_INI Method failed\n"); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | /* do config (detect defaults) */ |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 723 | use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 724 | disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0; |
| 725 | vdbg_printk(FUJLAPTOP_DBG_INFO, |
Tony Vroon | f87a1a5 | 2009-01-07 10:11:24 +0000 | [diff] [blame] | 726 | "config: [alt interface: %d], [adjust disable: %d]\n", |
| 727 | use_alt_lcd_levels, disable_brightness_adjust); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 728 | |
| 729 | if (get_max_brightness() <= 0) |
| 730 | fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS; |
Tony Vroon | f87a1a5 | 2009-01-07 10:11:24 +0000 | [diff] [blame] | 731 | get_lcd_level(); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 732 | |
Julia Lawall | b30bb89 | 2013-12-29 23:47:36 +0100 | [diff] [blame] | 733 | return 0; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 734 | |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 735 | err_unregister_input_dev: |
| 736 | input_unregister_device(input); |
Axel Lin | 8e4e2ef | 2010-07-20 15:19:34 -0700 | [diff] [blame] | 737 | input = NULL; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 738 | err_free_input_dev: |
| 739 | input_free_device(input); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 740 | err_stop: |
Julia Lawall | b30bb89 | 2013-12-29 23:47:36 +0100 | [diff] [blame] | 741 | return error; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 742 | } |
| 743 | |
Rafael J. Wysocki | 51fac83 | 2013-01-24 00:24:48 +0100 | [diff] [blame] | 744 | static int acpi_fujitsu_remove(struct acpi_device *device) |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 745 | { |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 746 | struct fujitsu_t *fujitsu = acpi_driver_data(device); |
| 747 | struct input_dev *input = fujitsu->input; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 748 | |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 749 | input_unregister_device(input); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 750 | |
Al Viro | 5cf83b9 | 2008-03-29 03:07:48 +0000 | [diff] [blame] | 751 | fujitsu->acpi_handle = NULL; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 752 | |
| 753 | return 0; |
| 754 | } |
| 755 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 756 | /* Brightness notify */ |
| 757 | |
Bjorn Helgaas | 700b672 | 2009-04-07 15:37:16 +0000 | [diff] [blame] | 758 | static void acpi_fujitsu_notify(struct acpi_device *device, u32 event) |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 759 | { |
| 760 | struct input_dev *input; |
| 761 | int keycode; |
| 762 | int oldb, newb; |
| 763 | |
| 764 | input = fujitsu->input; |
| 765 | |
| 766 | switch (event) { |
| 767 | case ACPI_FUJITSU_NOTIFY_CODE1: |
| 768 | keycode = 0; |
| 769 | oldb = fujitsu->brightness_level; |
Tony Vroon | f87a1a5 | 2009-01-07 10:11:24 +0000 | [diff] [blame] | 770 | get_lcd_level(); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 771 | newb = fujitsu->brightness_level; |
| 772 | |
| 773 | vdbg_printk(FUJLAPTOP_DBG_TRACE, |
| 774 | "brightness button event [%i -> %i (%i)]\n", |
| 775 | oldb, newb, fujitsu->brightness_changed); |
| 776 | |
Tony Vroon | f87a1a5 | 2009-01-07 10:11:24 +0000 | [diff] [blame] | 777 | if (oldb < newb) { |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 778 | if (disable_brightness_adjust != 1) { |
| 779 | if (use_alt_lcd_levels) |
| 780 | set_lcd_level_alt(newb); |
| 781 | else |
| 782 | set_lcd_level(newb); |
| 783 | } |
Tony Vroon | f87a1a5 | 2009-01-07 10:11:24 +0000 | [diff] [blame] | 784 | keycode = KEY_BRIGHTNESSUP; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 785 | } else if (oldb > newb) { |
| 786 | if (disable_brightness_adjust != 1) { |
| 787 | if (use_alt_lcd_levels) |
| 788 | set_lcd_level_alt(newb); |
| 789 | else |
| 790 | set_lcd_level(newb); |
| 791 | } |
Tony Vroon | f87a1a5 | 2009-01-07 10:11:24 +0000 | [diff] [blame] | 792 | keycode = KEY_BRIGHTNESSDOWN; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 793 | } |
| 794 | break; |
| 795 | default: |
| 796 | keycode = KEY_UNKNOWN; |
| 797 | vdbg_printk(FUJLAPTOP_DBG_WARN, |
| 798 | "unsupported event [0x%x]\n", event); |
| 799 | break; |
| 800 | } |
| 801 | |
| 802 | if (keycode != 0) { |
| 803 | input_report_key(input, keycode, 1); |
| 804 | input_sync(input); |
| 805 | input_report_key(input, keycode, 0); |
| 806 | input_sync(input); |
| 807 | } |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 808 | } |
| 809 | |
| 810 | /* ACPI device for hotkey handling */ |
| 811 | |
| 812 | static int acpi_fujitsu_hotkey_add(struct acpi_device *device) |
| 813 | { |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 814 | int result = 0; |
| 815 | int state = 0; |
| 816 | struct input_dev *input; |
| 817 | int error; |
| 818 | int i; |
| 819 | |
| 820 | if (!device) |
| 821 | return -EINVAL; |
| 822 | |
| 823 | fujitsu_hotkey->acpi_handle = device->handle; |
| 824 | sprintf(acpi_device_name(device), "%s", |
| 825 | ACPI_FUJITSU_HOTKEY_DEVICE_NAME); |
| 826 | sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS); |
Pavel Machek | db89b4f | 2008-09-22 14:37:34 -0700 | [diff] [blame] | 827 | device->driver_data = fujitsu_hotkey; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 828 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 829 | /* kfifo */ |
| 830 | spin_lock_init(&fujitsu_hotkey->fifo_lock); |
Stefani Seibold | 4546548 | 2009-12-21 14:37:26 -0800 | [diff] [blame] | 831 | error = kfifo_alloc(&fujitsu_hotkey->fifo, RINGBUFFERSIZE * sizeof(int), |
Stefani Seibold | c1e13f2 | 2009-12-21 14:37:27 -0800 | [diff] [blame] | 832 | GFP_KERNEL); |
Stefani Seibold | 4546548 | 2009-12-21 14:37:26 -0800 | [diff] [blame] | 833 | if (error) { |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 834 | pr_err("kfifo_alloc failed\n"); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 835 | goto err_stop; |
| 836 | } |
| 837 | |
| 838 | fujitsu_hotkey->input = input = input_allocate_device(); |
| 839 | if (!input) { |
| 840 | error = -ENOMEM; |
Bjorn Helgaas | b4ec027 | 2009-04-07 15:37:22 +0000 | [diff] [blame] | 841 | goto err_free_fifo; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | snprintf(fujitsu_hotkey->phys, sizeof(fujitsu_hotkey->phys), |
| 845 | "%s/video/input0", acpi_device_hid(device)); |
| 846 | |
| 847 | input->name = acpi_device_name(device); |
| 848 | input->phys = fujitsu_hotkey->phys; |
| 849 | input->id.bustype = BUS_HOST; |
| 850 | input->id.product = 0x06; |
| 851 | input->dev.parent = &device->dev; |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 852 | |
| 853 | set_bit(EV_KEY, input->evbit); |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 854 | set_bit(fujitsu->keycode1, input->keybit); |
| 855 | set_bit(fujitsu->keycode2, input->keybit); |
| 856 | set_bit(fujitsu->keycode3, input->keybit); |
| 857 | set_bit(fujitsu->keycode4, input->keybit); |
Michał Kępień | b5df36c | 2016-02-24 14:23:32 +0100 | [diff] [blame] | 858 | set_bit(fujitsu->keycode5, input->keybit); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 859 | set_bit(KEY_UNKNOWN, input->keybit); |
| 860 | |
| 861 | error = input_register_device(input); |
| 862 | if (error) |
| 863 | goto err_free_input_dev; |
| 864 | |
Julia Lawall | b30bb89 | 2013-12-29 23:47:36 +0100 | [diff] [blame] | 865 | error = acpi_bus_update_power(fujitsu_hotkey->acpi_handle, &state); |
| 866 | if (error) { |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 867 | pr_err("Error reading power state\n"); |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 868 | goto err_unregister_input_dev; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 869 | } |
| 870 | |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 871 | pr_info("ACPI: %s [%s] (%s)\n", |
| 872 | acpi_device_name(device), acpi_device_bid(device), |
| 873 | !device->power.state ? "on" : "off"); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 874 | |
| 875 | fujitsu_hotkey->dev = device; |
| 876 | |
Zhang Rui | dd13b9a | 2013-09-03 08:32:03 +0800 | [diff] [blame] | 877 | if (acpi_has_method(device->handle, METHOD_NAME__INI)) { |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 878 | vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n"); |
| 879 | if (ACPI_FAILURE |
| 880 | (acpi_evaluate_object |
| 881 | (device->handle, METHOD_NAME__INI, NULL, NULL))) |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 882 | pr_err("_INI Method failed\n"); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 883 | } |
| 884 | |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 885 | i = 0; |
| 886 | while (call_fext_func(FUNC_BUTTONS, 0x1, 0x0, 0x0) != 0 |
| 887 | && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) |
| 888 | ; /* No action, result is discarded */ |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 889 | vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i); |
| 890 | |
Tony Vroon | 4898c2b | 2009-02-02 11:11:10 +0000 | [diff] [blame] | 891 | fujitsu_hotkey->rfkill_supported = |
| 892 | call_fext_func(FUNC_RFKILL, 0x0, 0x0, 0x0); |
| 893 | |
| 894 | /* Make sure our bitmask of supported functions is cleared if the |
| 895 | RFKILL function block is not implemented, like on the S7020. */ |
| 896 | if (fujitsu_hotkey->rfkill_supported == UNSUPPORTED_CMD) |
| 897 | fujitsu_hotkey->rfkill_supported = 0; |
| 898 | |
| 899 | if (fujitsu_hotkey->rfkill_supported) |
| 900 | fujitsu_hotkey->rfkill_state = |
| 901 | call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 902 | |
| 903 | /* Suspect this is a keymap of the application panel, print it */ |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 904 | pr_info("BTNI: [0x%x]\n", call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0)); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 905 | |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 906 | #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 907 | if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) { |
| 908 | result = led_classdev_register(&fujitsu->pf_device->dev, |
| 909 | &logolamp_led); |
| 910 | if (result == 0) { |
| 911 | fujitsu_hotkey->logolamp_registered = 1; |
| 912 | } else { |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 913 | pr_err("Could not register LED handler for logo lamp, error %i\n", |
| 914 | result); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 915 | } |
| 916 | } |
| 917 | |
| 918 | if ((call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) && |
| 919 | (call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) { |
| 920 | result = led_classdev_register(&fujitsu->pf_device->dev, |
| 921 | &kblamps_led); |
| 922 | if (result == 0) { |
| 923 | fujitsu_hotkey->kblamps_registered = 1; |
| 924 | } else { |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 925 | pr_err("Could not register LED handler for keyboard lamps, error %i\n", |
| 926 | result); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 927 | } |
| 928 | } |
Michał Kępień | 4f62568 | 2016-04-12 22:06:34 +0930 | [diff] [blame^] | 929 | |
| 930 | /* |
| 931 | * BTNI bit 24 seems to indicate the presence of a radio toggle |
| 932 | * button in place of a slide switch, and all such machines appear |
| 933 | * to also have an RF LED. Therefore use bit 24 as an indicator |
| 934 | * that an RF LED is present. |
| 935 | */ |
| 936 | if (call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) & BIT(24)) { |
| 937 | result = led_classdev_register(&fujitsu->pf_device->dev, |
| 938 | &radio_led); |
| 939 | if (result == 0) { |
| 940 | fujitsu_hotkey->radio_led_registered = 1; |
| 941 | } else { |
| 942 | pr_err("Could not register LED handler for radio LED, error %i\n", |
| 943 | result); |
| 944 | } |
| 945 | } |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 946 | #endif |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 947 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 948 | return result; |
| 949 | |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 950 | err_unregister_input_dev: |
| 951 | input_unregister_device(input); |
Axel Lin | 8e4e2ef | 2010-07-20 15:19:34 -0700 | [diff] [blame] | 952 | input = NULL; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 953 | err_free_input_dev: |
| 954 | input_free_device(input); |
Bjorn Helgaas | b4ec027 | 2009-04-07 15:37:22 +0000 | [diff] [blame] | 955 | err_free_fifo: |
Stefani Seibold | 4546548 | 2009-12-21 14:37:26 -0800 | [diff] [blame] | 956 | kfifo_free(&fujitsu_hotkey->fifo); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 957 | err_stop: |
Julia Lawall | b30bb89 | 2013-12-29 23:47:36 +0100 | [diff] [blame] | 958 | return error; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 959 | } |
| 960 | |
Rafael J. Wysocki | 51fac83 | 2013-01-24 00:24:48 +0100 | [diff] [blame] | 961 | static int acpi_fujitsu_hotkey_remove(struct acpi_device *device) |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 962 | { |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 963 | struct fujitsu_hotkey_t *fujitsu_hotkey = acpi_driver_data(device); |
| 964 | struct input_dev *input = fujitsu_hotkey->input; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 965 | |
Jonathan Woithe | 2906206 | 2009-10-08 13:19:12 +0930 | [diff] [blame] | 966 | #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 967 | if (fujitsu_hotkey->logolamp_registered) |
| 968 | led_classdev_unregister(&logolamp_led); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 969 | |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 970 | if (fujitsu_hotkey->kblamps_registered) |
| 971 | led_classdev_unregister(&kblamps_led); |
Michał Kępień | 4f62568 | 2016-04-12 22:06:34 +0930 | [diff] [blame^] | 972 | |
| 973 | if (fujitsu_hotkey->radio_led_registered) |
| 974 | led_classdev_unregister(&radio_led); |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 975 | #endif |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 976 | |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 977 | input_unregister_device(input); |
| 978 | |
Stefani Seibold | 4546548 | 2009-12-21 14:37:26 -0800 | [diff] [blame] | 979 | kfifo_free(&fujitsu_hotkey->fifo); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 980 | |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 981 | fujitsu_hotkey->acpi_handle = NULL; |
| 982 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 983 | return 0; |
| 984 | } |
| 985 | |
Bjorn Helgaas | b4ec027 | 2009-04-07 15:37:22 +0000 | [diff] [blame] | 986 | static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event) |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 987 | { |
| 988 | struct input_dev *input; |
| 989 | int keycode, keycode_r; |
| 990 | unsigned int irb = 1; |
| 991 | int i, status; |
| 992 | |
| 993 | input = fujitsu_hotkey->input; |
| 994 | |
Tony Vroon | 4898c2b | 2009-02-02 11:11:10 +0000 | [diff] [blame] | 995 | if (fujitsu_hotkey->rfkill_supported) |
| 996 | fujitsu_hotkey->rfkill_state = |
| 997 | call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 998 | |
| 999 | switch (event) { |
| 1000 | case ACPI_FUJITSU_NOTIFY_CODE1: |
| 1001 | i = 0; |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 1002 | while ((irb = |
| 1003 | call_fext_func(FUNC_BUTTONS, 0x1, 0x0, 0x0)) != 0 |
| 1004 | && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) { |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1005 | switch (irb & 0x4ff) { |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 1006 | case KEY1_CODE: |
| 1007 | keycode = fujitsu->keycode1; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1008 | break; |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 1009 | case KEY2_CODE: |
| 1010 | keycode = fujitsu->keycode2; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1011 | break; |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 1012 | case KEY3_CODE: |
| 1013 | keycode = fujitsu->keycode3; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1014 | break; |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 1015 | case KEY4_CODE: |
| 1016 | keycode = fujitsu->keycode4; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1017 | break; |
Michał Kępień | b5df36c | 2016-02-24 14:23:32 +0100 | [diff] [blame] | 1018 | case KEY5_CODE: |
| 1019 | keycode = fujitsu->keycode5; |
| 1020 | break; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1021 | case 0: |
| 1022 | keycode = 0; |
| 1023 | break; |
| 1024 | default: |
| 1025 | vdbg_printk(FUJLAPTOP_DBG_WARN, |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 1026 | "Unknown GIRB result [%x]\n", irb); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1027 | keycode = -1; |
| 1028 | break; |
| 1029 | } |
| 1030 | if (keycode > 0) { |
| 1031 | vdbg_printk(FUJLAPTOP_DBG_TRACE, |
| 1032 | "Push keycode into ringbuffer [%d]\n", |
| 1033 | keycode); |
Stefani Seibold | 7acd72e | 2009-12-21 14:37:28 -0800 | [diff] [blame] | 1034 | status = kfifo_in_locked(&fujitsu_hotkey->fifo, |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 1035 | (unsigned char *)&keycode, |
Stefani Seibold | c1e13f2 | 2009-12-21 14:37:27 -0800 | [diff] [blame] | 1036 | sizeof(keycode), |
| 1037 | &fujitsu_hotkey->fifo_lock); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1038 | if (status != sizeof(keycode)) { |
| 1039 | vdbg_printk(FUJLAPTOP_DBG_WARN, |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 1040 | "Could not push keycode [0x%x]\n", |
| 1041 | keycode); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1042 | } else { |
| 1043 | input_report_key(input, keycode, 1); |
| 1044 | input_sync(input); |
| 1045 | } |
| 1046 | } else if (keycode == 0) { |
| 1047 | while ((status = |
Stefani Seibold | 7acd72e | 2009-12-21 14:37:28 -0800 | [diff] [blame] | 1048 | kfifo_out_locked( |
Stefani Seibold | c1e13f2 | 2009-12-21 14:37:27 -0800 | [diff] [blame] | 1049 | &fujitsu_hotkey->fifo, |
| 1050 | (unsigned char *) &keycode_r, |
| 1051 | sizeof(keycode_r), |
| 1052 | &fujitsu_hotkey->fifo_lock)) |
| 1053 | == sizeof(keycode_r)) { |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1054 | input_report_key(input, keycode_r, 0); |
| 1055 | input_sync(input); |
| 1056 | vdbg_printk(FUJLAPTOP_DBG_TRACE, |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 1057 | "Pop keycode from ringbuffer [%d]\n", |
| 1058 | keycode_r); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1059 | } |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | break; |
| 1064 | default: |
| 1065 | keycode = KEY_UNKNOWN; |
| 1066 | vdbg_printk(FUJLAPTOP_DBG_WARN, |
| 1067 | "Unsupported event [0x%x]\n", event); |
| 1068 | input_report_key(input, keycode, 1); |
| 1069 | input_sync(input); |
| 1070 | input_report_key(input, keycode, 0); |
| 1071 | input_sync(input); |
| 1072 | break; |
| 1073 | } |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1074 | } |
| 1075 | |
| 1076 | /* Initialization */ |
| 1077 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1078 | static const struct acpi_device_id fujitsu_device_ids[] = { |
| 1079 | {ACPI_FUJITSU_HID, 0}, |
| 1080 | {"", 0}, |
| 1081 | }; |
| 1082 | |
| 1083 | static struct acpi_driver acpi_fujitsu_driver = { |
| 1084 | .name = ACPI_FUJITSU_DRIVER_NAME, |
| 1085 | .class = ACPI_FUJITSU_CLASS, |
| 1086 | .ids = fujitsu_device_ids, |
| 1087 | .ops = { |
| 1088 | .add = acpi_fujitsu_add, |
| 1089 | .remove = acpi_fujitsu_remove, |
Bjorn Helgaas | 700b672 | 2009-04-07 15:37:16 +0000 | [diff] [blame] | 1090 | .notify = acpi_fujitsu_notify, |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1091 | }, |
| 1092 | }; |
| 1093 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1094 | static const struct acpi_device_id fujitsu_hotkey_device_ids[] = { |
| 1095 | {ACPI_FUJITSU_HOTKEY_HID, 0}, |
| 1096 | {"", 0}, |
| 1097 | }; |
| 1098 | |
| 1099 | static struct acpi_driver acpi_fujitsu_hotkey_driver = { |
| 1100 | .name = ACPI_FUJITSU_HOTKEY_DRIVER_NAME, |
| 1101 | .class = ACPI_FUJITSU_CLASS, |
| 1102 | .ids = fujitsu_hotkey_device_ids, |
| 1103 | .ops = { |
| 1104 | .add = acpi_fujitsu_hotkey_add, |
| 1105 | .remove = acpi_fujitsu_hotkey_remove, |
Bjorn Helgaas | b4ec027 | 2009-04-07 15:37:22 +0000 | [diff] [blame] | 1106 | .notify = acpi_fujitsu_hotkey_notify, |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1107 | }, |
| 1108 | }; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1109 | |
Zhang Rui | 4990141 | 2014-09-09 00:21:59 +0200 | [diff] [blame] | 1110 | static const struct acpi_device_id fujitsu_ids[] __used = { |
| 1111 | {ACPI_FUJITSU_HID, 0}, |
| 1112 | {ACPI_FUJITSU_HOTKEY_HID, 0}, |
| 1113 | {"", 0} |
| 1114 | }; |
| 1115 | MODULE_DEVICE_TABLE(acpi, fujitsu_ids); |
| 1116 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1117 | static int __init fujitsu_init(void) |
| 1118 | { |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1119 | int ret, result, max_brightness; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1120 | |
| 1121 | if (acpi_disabled) |
| 1122 | return -ENODEV; |
| 1123 | |
Julia Lawall | 6c75dd0 | 2010-05-13 22:06:20 +0200 | [diff] [blame] | 1124 | fujitsu = kzalloc(sizeof(struct fujitsu_t), GFP_KERNEL); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1125 | if (!fujitsu) |
| 1126 | return -ENOMEM; |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 1127 | fujitsu->keycode1 = KEY_PROG1; |
| 1128 | fujitsu->keycode2 = KEY_PROG2; |
| 1129 | fujitsu->keycode3 = KEY_PROG3; |
| 1130 | fujitsu->keycode4 = KEY_PROG4; |
Michał Kępień | b5df36c | 2016-02-24 14:23:32 +0100 | [diff] [blame] | 1131 | fujitsu->keycode5 = KEY_RFKILL; |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 1132 | dmi_check_system(fujitsu_dmi_table); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1133 | |
| 1134 | result = acpi_bus_register_driver(&acpi_fujitsu_driver); |
| 1135 | if (result < 0) { |
| 1136 | ret = -ENODEV; |
| 1137 | goto fail_acpi; |
| 1138 | } |
| 1139 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1140 | /* Register platform stuff */ |
| 1141 | |
| 1142 | fujitsu->pf_device = platform_device_alloc("fujitsu-laptop", -1); |
| 1143 | if (!fujitsu->pf_device) { |
| 1144 | ret = -ENOMEM; |
| 1145 | goto fail_platform_driver; |
| 1146 | } |
| 1147 | |
| 1148 | ret = platform_device_add(fujitsu->pf_device); |
| 1149 | if (ret) |
| 1150 | goto fail_platform_device1; |
| 1151 | |
| 1152 | ret = |
| 1153 | sysfs_create_group(&fujitsu->pf_device->dev.kobj, |
| 1154 | &fujitsupf_attribute_group); |
| 1155 | if (ret) |
| 1156 | goto fail_platform_device2; |
| 1157 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1158 | /* Register backlight stuff */ |
| 1159 | |
Hans de Goede | 413226f | 2015-06-16 16:28:03 +0200 | [diff] [blame] | 1160 | if (acpi_video_get_backlight_type() == acpi_backlight_vendor) { |
Matthew Garrett | a19a6ee | 2010-02-17 16:39:44 -0500 | [diff] [blame] | 1161 | struct backlight_properties props; |
| 1162 | |
| 1163 | memset(&props, 0, sizeof(struct backlight_properties)); |
| 1164 | max_brightness = fujitsu->max_brightness; |
Matthew Garrett | bb7ca74 | 2011-03-22 16:30:21 -0700 | [diff] [blame] | 1165 | props.type = BACKLIGHT_PLATFORM; |
Matthew Garrett | a19a6ee | 2010-02-17 16:39:44 -0500 | [diff] [blame] | 1166 | props.max_brightness = max_brightness - 1; |
| 1167 | fujitsu->bl_device = backlight_device_register("fujitsu-laptop", |
| 1168 | NULL, NULL, |
| 1169 | &fujitsubl_ops, |
| 1170 | &props); |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 1171 | if (IS_ERR(fujitsu->bl_device)) { |
| 1172 | ret = PTR_ERR(fujitsu->bl_device); |
| 1173 | fujitsu->bl_device = NULL; |
| 1174 | goto fail_sysfs_group; |
| 1175 | } |
Thomas Renninger | 7d5c89a | 2008-08-01 17:38:00 +0200 | [diff] [blame] | 1176 | fujitsu->bl_device->props.brightness = fujitsu->brightness_level; |
| 1177 | } |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1178 | |
| 1179 | ret = platform_driver_register(&fujitsupf_driver); |
| 1180 | if (ret) |
| 1181 | goto fail_backlight; |
| 1182 | |
| 1183 | /* Register hotkey driver */ |
| 1184 | |
Julia Lawall | 6c75dd0 | 2010-05-13 22:06:20 +0200 | [diff] [blame] | 1185 | fujitsu_hotkey = kzalloc(sizeof(struct fujitsu_hotkey_t), GFP_KERNEL); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1186 | if (!fujitsu_hotkey) { |
| 1187 | ret = -ENOMEM; |
| 1188 | goto fail_hotkey; |
| 1189 | } |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1190 | |
| 1191 | result = acpi_bus_register_driver(&acpi_fujitsu_hotkey_driver); |
| 1192 | if (result < 0) { |
| 1193 | ret = -ENODEV; |
| 1194 | goto fail_hotkey1; |
| 1195 | } |
| 1196 | |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 1197 | /* Sync backlight power status (needs FUJ02E3 device, hence deferred) */ |
Hans de Goede | 413226f | 2015-06-16 16:28:03 +0200 | [diff] [blame] | 1198 | if (acpi_video_get_backlight_type() == acpi_backlight_vendor) { |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 1199 | if (call_fext_func(FUNC_BACKLIGHT, 0x2, 0x4, 0x0) == 3) |
Michael Karcher | e8549e2 | 2015-01-18 20:28:46 +0100 | [diff] [blame] | 1200 | fujitsu->bl_device->props.power = FB_BLANK_POWERDOWN; |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 1201 | else |
Michael Karcher | e8549e2 | 2015-01-18 20:28:46 +0100 | [diff] [blame] | 1202 | fujitsu->bl_device->props.power = FB_BLANK_UNBLANK; |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 1203 | } |
| 1204 | |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 1205 | pr_info("driver " FUJITSU_DRIVER_VERSION " successfully loaded\n"); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1206 | |
| 1207 | return 0; |
| 1208 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1209 | fail_hotkey1: |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1210 | kfree(fujitsu_hotkey); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1211 | fail_hotkey: |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1212 | platform_driver_unregister(&fujitsupf_driver); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1213 | fail_backlight: |
Markus Elfring | 0098181 | 2014-11-24 20:30:29 +0100 | [diff] [blame] | 1214 | backlight_device_unregister(fujitsu->bl_device); |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 1215 | fail_sysfs_group: |
| 1216 | sysfs_remove_group(&fujitsu->pf_device->dev.kobj, |
| 1217 | &fujitsupf_attribute_group); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1218 | fail_platform_device2: |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1219 | platform_device_del(fujitsu->pf_device); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1220 | fail_platform_device1: |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1221 | platform_device_put(fujitsu->pf_device); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1222 | fail_platform_driver: |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1223 | acpi_bus_unregister_driver(&acpi_fujitsu_driver); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1224 | fail_acpi: |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1225 | kfree(fujitsu); |
| 1226 | |
| 1227 | return ret; |
| 1228 | } |
| 1229 | |
| 1230 | static void __exit fujitsu_cleanup(void) |
| 1231 | { |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 1232 | acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 1233 | |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 1234 | kfree(fujitsu_hotkey); |
| 1235 | |
| 1236 | platform_driver_unregister(&fujitsupf_driver); |
| 1237 | |
Markus Elfring | 0098181 | 2014-11-24 20:30:29 +0100 | [diff] [blame] | 1238 | backlight_device_unregister(fujitsu->bl_device); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 1239 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1240 | sysfs_remove_group(&fujitsu->pf_device->dev.kobj, |
| 1241 | &fujitsupf_attribute_group); |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 1242 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1243 | platform_device_unregister(fujitsu->pf_device); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1244 | |
| 1245 | acpi_bus_unregister_driver(&acpi_fujitsu_driver); |
| 1246 | |
| 1247 | kfree(fujitsu); |
| 1248 | |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 1249 | pr_info("driver unloaded\n"); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1250 | } |
| 1251 | |
| 1252 | module_init(fujitsu_init); |
| 1253 | module_exit(fujitsu_cleanup); |
| 1254 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1255 | module_param(use_alt_lcd_levels, uint, 0644); |
| 1256 | MODULE_PARM_DESC(use_alt_lcd_levels, |
| 1257 | "Use alternative interface for lcd_levels (needed for Lifebook s6410)."); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1258 | module_param(disable_brightness_adjust, uint, 0644); |
| 1259 | MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment ."); |
| 1260 | #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG |
| 1261 | module_param_named(debug, dbg_level, uint, 0644); |
| 1262 | MODULE_PARM_DESC(debug, "Sets debug level bit-mask"); |
| 1263 | #endif |
| 1264 | |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 1265 | MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon"); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1266 | MODULE_DESCRIPTION("Fujitsu laptop extras support"); |
| 1267 | MODULE_VERSION(FUJITSU_DRIVER_VERSION); |
| 1268 | MODULE_LICENSE("GPL"); |
Dan Williams | a361a82 | 2008-06-05 22:46:08 -0700 | [diff] [blame] | 1269 | |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 1270 | MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*"); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 1271 | MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1E6:*:cvrS6420:*"); |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 1272 | MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*"); |