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 | * |
Michał Kępień | 78b2602 | 2017-03-14 11:26:27 +0100 | [diff] [blame] | 35 | * This driver implements a vendor-specific backlight control interface for |
| 36 | * Fujitsu laptops and provides support for hotkeys present on certain Fujitsu |
| 37 | * laptops. |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 38 | * |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 39 | * This driver has been tested on a Fujitsu Lifebook S6410, S7020 and |
| 40 | * P8010. It should work on most P-series and S-series Lifebooks, but |
| 41 | * YMMV. |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 42 | * |
| 43 | * The module parameter use_alt_lcd_levels switches between different ACPI |
| 44 | * brightness controls which are used by different Fujitsu laptops. In most |
| 45 | * cases the correct method is automatically detected. "use_alt_lcd_levels=1" |
| 46 | * is applicable for a Fujitsu Lifebook S6410 if autodetection fails. |
| 47 | * |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 48 | */ |
| 49 | |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 50 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 51 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 52 | #include <linux/module.h> |
| 53 | #include <linux/kernel.h> |
| 54 | #include <linux/init.h> |
| 55 | #include <linux/acpi.h> |
| 56 | #include <linux/dmi.h> |
| 57 | #include <linux/backlight.h> |
Michael Karcher | e8549e2 | 2015-01-18 20:28:46 +0100 | [diff] [blame] | 58 | #include <linux/fb.h> |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 59 | #include <linux/input.h> |
Michał Kępień | f225267 | 2017-03-20 10:32:19 +0100 | [diff] [blame] | 60 | #include <linux/input/sparse-keymap.h> |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 61 | #include <linux/kfifo.h> |
Michał Kępień | d89bcc8 | 2017-04-07 15:07:08 +0200 | [diff] [blame] | 62 | #include <linux/leds.h> |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 63 | #include <linux/platform_device.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 64 | #include <linux/slab.h> |
Hans de Goede | 413226f | 2015-06-16 16:28:03 +0200 | [diff] [blame] | 65 | #include <acpi/video.h> |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 66 | |
Jonathan Woithe | 84a6ce2 | 2009-07-31 18:16:59 +0930 | [diff] [blame] | 67 | #define FUJITSU_DRIVER_VERSION "0.6.0" |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 68 | |
| 69 | #define FUJITSU_LCD_N_LEVELS 8 |
| 70 | |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 71 | #define ACPI_FUJITSU_CLASS "fujitsu" |
| 72 | #define ACPI_FUJITSU_BL_HID "FUJ02B1" |
| 73 | #define ACPI_FUJITSU_BL_DRIVER_NAME "Fujitsu laptop FUJ02B1 ACPI brightness driver" |
| 74 | #define ACPI_FUJITSU_BL_DEVICE_NAME "Fujitsu FUJ02B1" |
Alan Jenkins | 6942eab | 2017-02-08 14:46:25 +0100 | [diff] [blame] | 75 | #define ACPI_FUJITSU_LAPTOP_HID "FUJ02E3" |
| 76 | #define ACPI_FUJITSU_LAPTOP_DRIVER_NAME "Fujitsu laptop FUJ02E3 ACPI hotkeys driver" |
| 77 | #define ACPI_FUJITSU_LAPTOP_DEVICE_NAME "Fujitsu FUJ02E3" |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 78 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 79 | #define ACPI_FUJITSU_NOTIFY_CODE1 0x80 |
| 80 | |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 81 | /* FUNC interface - command values */ |
Alan Jenkins | 8ef27bd | 2017-02-08 14:46:27 +0100 | [diff] [blame] | 82 | #define FUNC_FLAGS 0x1000 |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 83 | #define FUNC_LEDS 0x1001 |
| 84 | #define FUNC_BUTTONS 0x1002 |
| 85 | #define FUNC_BACKLIGHT 0x1004 |
| 86 | |
| 87 | /* FUNC interface - responses */ |
| 88 | #define UNSUPPORTED_CMD 0x80000000 |
| 89 | |
Alan Jenkins | d3dd448 | 2017-02-08 14:46:28 +0100 | [diff] [blame] | 90 | /* FUNC interface - status flags */ |
| 91 | #define FLAG_RFKILL 0x020 |
| 92 | #define FLAG_LID 0x100 |
| 93 | #define FLAG_DOCK 0x200 |
| 94 | |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 95 | /* FUNC interface - LED control */ |
| 96 | #define FUNC_LED_OFF 0x1 |
| 97 | #define FUNC_LED_ON 0x30001 |
| 98 | #define KEYBOARD_LAMPS 0x100 |
| 99 | #define LOGOLAMP_POWERON 0x2000 |
| 100 | #define LOGOLAMP_ALWAYS 0x4000 |
Michał Kępień | 4f62568 | 2016-04-12 22:06:34 +0930 | [diff] [blame] | 101 | #define RADIO_LED_ON 0x20 |
Matej Groma | d6b88f6 | 2016-06-21 10:09:21 +0200 | [diff] [blame] | 102 | #define ECO_LED 0x10000 |
| 103 | #define ECO_LED_ON 0x80000 |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 104 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 105 | /* Hotkey details */ |
Jonathan Woithe | 0e6a66e | 2008-10-09 13:44:40 +0930 | [diff] [blame] | 106 | #define KEY1_CODE 0x410 /* codes for the keys in the GIRB register */ |
| 107 | #define KEY2_CODE 0x411 |
| 108 | #define KEY3_CODE 0x412 |
| 109 | #define KEY4_CODE 0x413 |
Michał Kępień | b5df36c | 2016-02-24 14:23:32 +0100 | [diff] [blame] | 110 | #define KEY5_CODE 0x420 |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 111 | |
| 112 | #define MAX_HOTKEY_RINGBUFFER_SIZE 100 |
| 113 | #define RINGBUFFERSIZE 40 |
| 114 | |
Michał Kępień | 6cb1192 | 2018-02-11 22:07:24 +0100 | [diff] [blame^] | 115 | /* Module parameters */ |
| 116 | static int use_alt_lcd_levels = -1; |
| 117 | static bool disable_brightness_adjust; |
| 118 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 119 | /* Device controlling the backlight and associated keys */ |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 120 | struct fujitsu_bl { |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 121 | struct input_dev *input; |
| 122 | char phys[32]; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 123 | struct backlight_device *bl_device; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 124 | unsigned int max_brightness; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 125 | unsigned int brightness_level; |
| 126 | }; |
| 127 | |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 128 | static struct fujitsu_bl *fujitsu_bl; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 129 | |
Alan Jenkins | 6942eab | 2017-02-08 14:46:25 +0100 | [diff] [blame] | 130 | /* Device used to access hotkeys and other features on the laptop */ |
| 131 | struct fujitsu_laptop { |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 132 | struct input_dev *input; |
| 133 | char phys[32]; |
| 134 | struct platform_device *pf_device; |
Stefani Seibold | 4546548 | 2009-12-21 14:37:26 -0800 | [diff] [blame] | 135 | struct kfifo fifo; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 136 | spinlock_t fifo_lock; |
Alan Jenkins | 8ef27bd | 2017-02-08 14:46:27 +0100 | [diff] [blame] | 137 | int flags_supported; |
| 138 | int flags_state; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 139 | }; |
| 140 | |
Michał Kępień | ca0d9ea | 2017-05-19 09:44:45 +0200 | [diff] [blame] | 141 | static struct acpi_device *fext; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 142 | |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 143 | /* Fujitsu ACPI interface function */ |
| 144 | |
Michał Kępień | 84631e0 | 2017-05-19 09:44:46 +0200 | [diff] [blame] | 145 | static int call_fext_func(struct acpi_device *device, |
| 146 | int func, int op, int feature, int state) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 147 | { |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 148 | union acpi_object params[4] = { |
Michał Kępień | f68e492 | 2017-04-03 11:38:59 +0200 | [diff] [blame] | 149 | { .integer.type = ACPI_TYPE_INTEGER, .integer.value = func }, |
| 150 | { .integer.type = ACPI_TYPE_INTEGER, .integer.value = op }, |
| 151 | { .integer.type = ACPI_TYPE_INTEGER, .integer.value = feature }, |
| 152 | { .integer.type = ACPI_TYPE_INTEGER, .integer.value = state } |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 153 | }; |
Michał Kępień | b106641 | 2017-04-03 11:38:57 +0200 | [diff] [blame] | 154 | struct acpi_object_list arg_list = { 4, params }; |
Zhang Rui | 29c29a9 | 2013-09-03 08:32:12 +0800 | [diff] [blame] | 155 | unsigned long long value; |
Michał Kępień | b106641 | 2017-04-03 11:38:57 +0200 | [diff] [blame] | 156 | acpi_status status; |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 157 | |
Michał Kępień | 84631e0 | 2017-05-19 09:44:46 +0200 | [diff] [blame] | 158 | status = acpi_evaluate_integer(device->handle, "FUNC", &arg_list, |
| 159 | &value); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 160 | if (ACPI_FAILURE(status)) { |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 161 | acpi_handle_err(device->handle, "Failed to evaluate FUNC\n"); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 162 | return -ENODEV; |
| 163 | } |
| 164 | |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 165 | acpi_handle_debug(device->handle, |
| 166 | "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n", |
| 167 | func, op, feature, state, (int)value); |
Zhang Rui | 29c29a9 | 2013-09-03 08:32:12 +0800 | [diff] [blame] | 168 | return value; |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 169 | } |
| 170 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 171 | /* Hardware access for LCD brightness control */ |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 172 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 173 | static int set_lcd_level(struct acpi_device *device, int level) |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 174 | { |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 175 | struct fujitsu_bl *priv = acpi_driver_data(device); |
Michał Kępień | a8779c3 | 2017-04-05 08:49:03 +0200 | [diff] [blame] | 176 | acpi_status status; |
Michał Kępień | e32c50b | 2017-04-05 08:49:02 +0200 | [diff] [blame] | 177 | char *method; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 178 | |
Michał Kępień | e32c50b | 2017-04-05 08:49:02 +0200 | [diff] [blame] | 179 | switch (use_alt_lcd_levels) { |
Michał Kępień | e06e483 | 2017-04-05 08:49:05 +0200 | [diff] [blame] | 180 | case -1: |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 181 | if (acpi_has_method(device->handle, "SBL2")) |
Michał Kępień | e06e483 | 2017-04-05 08:49:05 +0200 | [diff] [blame] | 182 | method = "SBL2"; |
| 183 | else |
| 184 | method = "SBLL"; |
| 185 | break; |
Michał Kępień | e32c50b | 2017-04-05 08:49:02 +0200 | [diff] [blame] | 186 | case 1: |
| 187 | method = "SBL2"; |
| 188 | break; |
| 189 | default: |
| 190 | method = "SBLL"; |
| 191 | break; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 192 | } |
| 193 | |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 194 | acpi_handle_debug(device->handle, "set lcd level via %s [%d]\n", method, |
| 195 | level); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 196 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 197 | if (level < 0 || level >= priv->max_brightness) |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 198 | return -EINVAL; |
| 199 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 200 | status = acpi_execute_simple_method(device->handle, method, level); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 201 | if (ACPI_FAILURE(status)) { |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 202 | acpi_handle_err(device->handle, "Failed to evaluate %s\n", |
| 203 | method); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 204 | return -ENODEV; |
| 205 | } |
| 206 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 207 | priv->brightness_level = level; |
Michał Kępień | bd079a2 | 2017-04-05 08:49:04 +0200 | [diff] [blame] | 208 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 209 | return 0; |
| 210 | } |
| 211 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 212 | static int get_lcd_level(struct acpi_device *device) |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 213 | { |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 214 | struct fujitsu_bl *priv = acpi_driver_data(device); |
Matthew Wilcox | 27663c5 | 2008-10-10 02:22:59 -0400 | [diff] [blame] | 215 | unsigned long long state = 0; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 216 | acpi_status status = AE_OK; |
| 217 | |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 218 | acpi_handle_debug(device->handle, "get lcd level via GBLL\n"); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 219 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 220 | status = acpi_evaluate_integer(device->handle, "GBLL", NULL, &state); |
Jonathan Woithe | 3b1c37c | 2009-12-23 09:19:42 +1030 | [diff] [blame] | 221 | if (ACPI_FAILURE(status)) |
| 222 | return 0; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 223 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 224 | priv->brightness_level = state & 0x0fffffff; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 225 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 226 | return priv->brightness_level; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 227 | } |
| 228 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 229 | static int get_max_brightness(struct acpi_device *device) |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 230 | { |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 231 | struct fujitsu_bl *priv = acpi_driver_data(device); |
Matthew Wilcox | 27663c5 | 2008-10-10 02:22:59 -0400 | [diff] [blame] | 232 | unsigned long long state = 0; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 233 | acpi_status status = AE_OK; |
| 234 | |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 235 | acpi_handle_debug(device->handle, "get max lcd level via RBLL\n"); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 236 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 237 | status = acpi_evaluate_integer(device->handle, "RBLL", NULL, &state); |
Jonathan Woithe | 3b1c37c | 2009-12-23 09:19:42 +1030 | [diff] [blame] | 238 | if (ACPI_FAILURE(status)) |
| 239 | return -1; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 240 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 241 | priv->max_brightness = state; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 242 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 243 | return priv->max_brightness; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 244 | } |
| 245 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 246 | /* Backlight device stuff */ |
| 247 | |
| 248 | static int bl_get_brightness(struct backlight_device *b) |
| 249 | { |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 250 | struct acpi_device *device = bl_get_data(b); |
| 251 | |
| 252 | return b->props.power == FB_BLANK_POWERDOWN ? 0 : get_lcd_level(device); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | static int bl_update_status(struct backlight_device *b) |
| 256 | { |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 257 | struct acpi_device *device = bl_get_data(b); |
| 258 | |
Ville Syrjälä | cd6bf77 | 2017-09-18 23:00:59 +0300 | [diff] [blame] | 259 | if (fext) { |
| 260 | if (b->props.power == FB_BLANK_POWERDOWN) |
| 261 | call_fext_func(fext, FUNC_BACKLIGHT, 0x1, 0x4, 0x3); |
| 262 | else |
| 263 | call_fext_func(fext, FUNC_BACKLIGHT, 0x1, 0x4, 0x0); |
| 264 | } |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 265 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 266 | return set_lcd_level(device, b->props.brightness); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 267 | } |
| 268 | |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 269 | static const struct backlight_ops fujitsu_bl_ops = { |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 270 | .get_brightness = bl_get_brightness, |
| 271 | .update_status = bl_update_status, |
| 272 | }; |
| 273 | |
Michał Kępień | b0c4b9c | 2017-03-14 11:26:28 +0100 | [diff] [blame] | 274 | static ssize_t lid_show(struct device *dev, struct device_attribute *attr, |
| 275 | char *buf) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 276 | { |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 277 | struct fujitsu_laptop *priv = dev_get_drvdata(dev); |
| 278 | |
| 279 | if (!(priv->flags_supported & FLAG_LID)) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 280 | return sprintf(buf, "unknown\n"); |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 281 | if (priv->flags_state & FLAG_LID) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 282 | return sprintf(buf, "open\n"); |
| 283 | else |
| 284 | return sprintf(buf, "closed\n"); |
| 285 | } |
| 286 | |
Michał Kępień | b0c4b9c | 2017-03-14 11:26:28 +0100 | [diff] [blame] | 287 | static ssize_t dock_show(struct device *dev, struct device_attribute *attr, |
| 288 | char *buf) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 289 | { |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 290 | struct fujitsu_laptop *priv = dev_get_drvdata(dev); |
| 291 | |
| 292 | if (!(priv->flags_supported & FLAG_DOCK)) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 293 | return sprintf(buf, "unknown\n"); |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 294 | if (priv->flags_state & FLAG_DOCK) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 295 | return sprintf(buf, "docked\n"); |
| 296 | else |
| 297 | return sprintf(buf, "undocked\n"); |
| 298 | } |
| 299 | |
Michał Kępień | b0c4b9c | 2017-03-14 11:26:28 +0100 | [diff] [blame] | 300 | static ssize_t radios_show(struct device *dev, struct device_attribute *attr, |
| 301 | char *buf) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 302 | { |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 303 | struct fujitsu_laptop *priv = dev_get_drvdata(dev); |
| 304 | |
| 305 | if (!(priv->flags_supported & FLAG_RFKILL)) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 306 | return sprintf(buf, "unknown\n"); |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 307 | if (priv->flags_state & FLAG_RFKILL) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 308 | return sprintf(buf, "on\n"); |
| 309 | else |
| 310 | return sprintf(buf, "killed\n"); |
| 311 | } |
| 312 | |
Michał Kępień | b0c4b9c | 2017-03-14 11:26:28 +0100 | [diff] [blame] | 313 | static DEVICE_ATTR_RO(lid); |
| 314 | static DEVICE_ATTR_RO(dock); |
| 315 | static DEVICE_ATTR_RO(radios); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 316 | |
Alan Jenkins | 1650602 | 2017-02-08 14:46:26 +0100 | [diff] [blame] | 317 | static struct attribute *fujitsu_pf_attributes[] = { |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 318 | &dev_attr_lid.attr, |
| 319 | &dev_attr_dock.attr, |
| 320 | &dev_attr_radios.attr, |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 321 | NULL |
| 322 | }; |
| 323 | |
Arvind Yadav | ee56ff7 | 2017-07-11 16:18:14 +0530 | [diff] [blame] | 324 | static const struct attribute_group fujitsu_pf_attribute_group = { |
Alan Jenkins | 1650602 | 2017-02-08 14:46:26 +0100 | [diff] [blame] | 325 | .attrs = fujitsu_pf_attributes |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 326 | }; |
| 327 | |
Alan Jenkins | 1650602 | 2017-02-08 14:46:26 +0100 | [diff] [blame] | 328 | static struct platform_driver fujitsu_pf_driver = { |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 329 | .driver = { |
| 330 | .name = "fujitsu-laptop", |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 331 | } |
| 332 | }; |
| 333 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 334 | /* ACPI device for LCD brightness control */ |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 335 | |
Michał Kępień | f225267 | 2017-03-20 10:32:19 +0100 | [diff] [blame] | 336 | static const struct key_entry keymap_backlight[] = { |
| 337 | { KE_KEY, true, { KEY_BRIGHTNESSUP } }, |
| 338 | { KE_KEY, false, { KEY_BRIGHTNESSDOWN } }, |
| 339 | { KE_END, 0 } |
| 340 | }; |
| 341 | |
Michał Kępień | 7d134e4 | 2017-03-20 10:32:17 +0100 | [diff] [blame] | 342 | static int acpi_fujitsu_bl_input_setup(struct acpi_device *device) |
| 343 | { |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 344 | struct fujitsu_bl *priv = acpi_driver_data(device); |
Michał Kępień | f225267 | 2017-03-20 10:32:19 +0100 | [diff] [blame] | 345 | int ret; |
Michał Kępień | 7d134e4 | 2017-03-20 10:32:17 +0100 | [diff] [blame] | 346 | |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 347 | priv->input = devm_input_allocate_device(&device->dev); |
| 348 | if (!priv->input) |
Michał Kępień | 7d134e4 | 2017-03-20 10:32:17 +0100 | [diff] [blame] | 349 | return -ENOMEM; |
| 350 | |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 351 | snprintf(priv->phys, sizeof(priv->phys), "%s/video/input0", |
| 352 | acpi_device_hid(device)); |
Michał Kępień | 7d134e4 | 2017-03-20 10:32:17 +0100 | [diff] [blame] | 353 | |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 354 | priv->input->name = acpi_device_name(device); |
| 355 | priv->input->phys = priv->phys; |
| 356 | priv->input->id.bustype = BUS_HOST; |
| 357 | priv->input->id.product = 0x06; |
Michał Kępień | f225267 | 2017-03-20 10:32:19 +0100 | [diff] [blame] | 358 | |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 359 | ret = sparse_keymap_setup(priv->input, keymap_backlight, NULL); |
Michał Kępień | f225267 | 2017-03-20 10:32:19 +0100 | [diff] [blame] | 360 | if (ret) |
| 361 | return ret; |
Michał Kępień | 7d134e4 | 2017-03-20 10:32:17 +0100 | [diff] [blame] | 362 | |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 363 | return input_register_device(priv->input); |
Michał Kępień | 7d134e4 | 2017-03-20 10:32:17 +0100 | [diff] [blame] | 364 | } |
| 365 | |
Michał Kępień | a1aabd5 | 2017-04-05 08:49:01 +0200 | [diff] [blame] | 366 | static int fujitsu_backlight_register(struct acpi_device *device) |
Michał Kępień | b8d69c1 | 2017-03-10 11:50:33 +0100 | [diff] [blame] | 367 | { |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 368 | struct fujitsu_bl *priv = acpi_driver_data(device); |
Michał Kępień | a1aabd5 | 2017-04-05 08:49:01 +0200 | [diff] [blame] | 369 | const struct backlight_properties props = { |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 370 | .brightness = priv->brightness_level, |
| 371 | .max_brightness = priv->max_brightness - 1, |
Michał Kępień | b8d69c1 | 2017-03-10 11:50:33 +0100 | [diff] [blame] | 372 | .type = BACKLIGHT_PLATFORM |
| 373 | }; |
| 374 | struct backlight_device *bd; |
| 375 | |
Michał Kępień | a1aabd5 | 2017-04-05 08:49:01 +0200 | [diff] [blame] | 376 | bd = devm_backlight_device_register(&device->dev, "fujitsu-laptop", |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 377 | &device->dev, device, |
Michał Kępień | a1aabd5 | 2017-04-05 08:49:01 +0200 | [diff] [blame] | 378 | &fujitsu_bl_ops, &props); |
Michał Kępień | b8d69c1 | 2017-03-10 11:50:33 +0100 | [diff] [blame] | 379 | if (IS_ERR(bd)) |
| 380 | return PTR_ERR(bd); |
| 381 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 382 | priv->bl_device = bd; |
Michał Kępień | b8d69c1 | 2017-03-10 11:50:33 +0100 | [diff] [blame] | 383 | |
| 384 | return 0; |
| 385 | } |
| 386 | |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 387 | static int acpi_fujitsu_bl_add(struct acpi_device *device) |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 388 | { |
Michał Kępień | 679374e | 2017-05-19 09:44:42 +0200 | [diff] [blame] | 389 | struct fujitsu_bl *priv; |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 390 | int ret; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 391 | |
Michał Kępień | 07acf62 | 2017-04-05 08:49:00 +0200 | [diff] [blame] | 392 | if (acpi_video_get_backlight_type() != acpi_backlight_vendor) |
| 393 | return -ENODEV; |
| 394 | |
Michał Kępień | 679374e | 2017-05-19 09:44:42 +0200 | [diff] [blame] | 395 | priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL); |
| 396 | if (!priv) |
| 397 | return -ENOMEM; |
| 398 | |
| 399 | fujitsu_bl = priv; |
Michał Kępień | d6a298a | 2017-06-16 06:40:54 +0200 | [diff] [blame] | 400 | strcpy(acpi_device_name(device), ACPI_FUJITSU_BL_DEVICE_NAME); |
| 401 | strcpy(acpi_device_class(device), ACPI_FUJITSU_CLASS); |
Michał Kępień | 679374e | 2017-05-19 09:44:42 +0200 | [diff] [blame] | 402 | device->driver_data = priv; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 403 | |
Michał Kępień | 1c19462 | 2017-06-16 06:40:56 +0200 | [diff] [blame] | 404 | pr_info("ACPI: %s [%s]\n", |
| 405 | acpi_device_name(device), acpi_device_bid(device)); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 406 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 407 | if (get_max_brightness(device) <= 0) |
| 408 | priv->max_brightness = FUJITSU_LCD_N_LEVELS; |
| 409 | get_lcd_level(device); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 410 | |
Michał Kępień | a7a1ccbe | 2018-02-11 22:07:22 +0100 | [diff] [blame] | 411 | ret = acpi_fujitsu_bl_input_setup(device); |
| 412 | if (ret) |
| 413 | return ret; |
| 414 | |
Michał Kępień | 7f83d41 | 2018-02-11 22:07:23 +0100 | [diff] [blame] | 415 | return fujitsu_backlight_register(device); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 416 | } |
| 417 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 418 | /* Brightness notify */ |
| 419 | |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 420 | static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event) |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 421 | { |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 422 | struct fujitsu_bl *priv = acpi_driver_data(device); |
Michał Kępień | f225267 | 2017-03-20 10:32:19 +0100 | [diff] [blame] | 423 | int oldb, newb; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 424 | |
Michał Kępień | 5efc800 | 2017-03-01 07:42:53 +0100 | [diff] [blame] | 425 | if (event != ACPI_FUJITSU_NOTIFY_CODE1) { |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 426 | acpi_handle_info(device->handle, "unsupported event [0x%x]\n", |
| 427 | event); |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 428 | sparse_keymap_report_event(priv->input, -1, 1, true); |
Michał Kępień | 5efc800 | 2017-03-01 07:42:53 +0100 | [diff] [blame] | 429 | return; |
| 430 | } |
| 431 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 432 | oldb = priv->brightness_level; |
| 433 | get_lcd_level(device); |
| 434 | newb = priv->brightness_level; |
Michał Kępień | 5efc800 | 2017-03-01 07:42:53 +0100 | [diff] [blame] | 435 | |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 436 | acpi_handle_debug(device->handle, |
| 437 | "brightness button event [%i -> %i]\n", oldb, newb); |
Michał Kępień | 5efc800 | 2017-03-01 07:42:53 +0100 | [diff] [blame] | 438 | |
Michał Kępień | d2aa3ae | 2017-03-01 07:42:54 +0100 | [diff] [blame] | 439 | if (oldb == newb) |
| 440 | return; |
| 441 | |
Michał Kępień | b4bb0cf | 2017-04-05 08:49:06 +0200 | [diff] [blame] | 442 | if (!disable_brightness_adjust) |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 443 | set_lcd_level(device, newb); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 444 | |
Michał Kępień | f2db7c6 | 2017-05-19 09:44:43 +0200 | [diff] [blame] | 445 | sparse_keymap_report_event(priv->input, oldb < newb, 1, true); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | /* ACPI device for hotkey handling */ |
| 449 | |
Michał Kępień | 527483a | 2017-03-20 10:32:22 +0100 | [diff] [blame] | 450 | static const struct key_entry keymap_default[] = { |
| 451 | { KE_KEY, KEY1_CODE, { KEY_PROG1 } }, |
| 452 | { KE_KEY, KEY2_CODE, { KEY_PROG2 } }, |
| 453 | { KE_KEY, KEY3_CODE, { KEY_PROG3 } }, |
| 454 | { KE_KEY, KEY4_CODE, { KEY_PROG4 } }, |
| 455 | { KE_KEY, KEY5_CODE, { KEY_RFKILL } }, |
| 456 | { KE_KEY, BIT(26), { KEY_TOUCHPAD_TOGGLE } }, |
| 457 | { KE_END, 0 } |
| 458 | }; |
| 459 | |
Michał Kępień | f8c94ec | 2017-03-20 10:32:23 +0100 | [diff] [blame] | 460 | static const struct key_entry keymap_s64x0[] = { |
| 461 | { KE_KEY, KEY1_CODE, { KEY_SCREENLOCK } }, /* "Lock" */ |
| 462 | { KE_KEY, KEY2_CODE, { KEY_HELP } }, /* "Mobility Center */ |
| 463 | { KE_KEY, KEY3_CODE, { KEY_PROG3 } }, |
| 464 | { KE_KEY, KEY4_CODE, { KEY_PROG4 } }, |
| 465 | { KE_END, 0 } |
| 466 | }; |
| 467 | |
| 468 | static const struct key_entry keymap_p8010[] = { |
| 469 | { KE_KEY, KEY1_CODE, { KEY_HELP } }, /* "Support" */ |
| 470 | { KE_KEY, KEY2_CODE, { KEY_PROG2 } }, |
| 471 | { KE_KEY, KEY3_CODE, { KEY_SWITCHVIDEOMODE } }, /* "Presentation" */ |
| 472 | { KE_KEY, KEY4_CODE, { KEY_WWW } }, /* "WWW" */ |
| 473 | { KE_END, 0 } |
| 474 | }; |
| 475 | |
Michał Kępień | 527483a | 2017-03-20 10:32:22 +0100 | [diff] [blame] | 476 | static const struct key_entry *keymap = keymap_default; |
| 477 | |
Michał Kępień | f8c94ec | 2017-03-20 10:32:23 +0100 | [diff] [blame] | 478 | static int fujitsu_laptop_dmi_keymap_override(const struct dmi_system_id *id) |
| 479 | { |
| 480 | pr_info("Identified laptop model '%s'\n", id->ident); |
| 481 | keymap = id->driver_data; |
| 482 | return 1; |
| 483 | } |
| 484 | |
| 485 | static const struct dmi_system_id fujitsu_laptop_dmi_table[] = { |
| 486 | { |
| 487 | .callback = fujitsu_laptop_dmi_keymap_override, |
| 488 | .ident = "Fujitsu Siemens S6410", |
| 489 | .matches = { |
| 490 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), |
| 491 | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6410"), |
| 492 | }, |
| 493 | .driver_data = (void *)keymap_s64x0 |
| 494 | }, |
| 495 | { |
| 496 | .callback = fujitsu_laptop_dmi_keymap_override, |
| 497 | .ident = "Fujitsu Siemens S6420", |
| 498 | .matches = { |
| 499 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), |
| 500 | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6420"), |
| 501 | }, |
| 502 | .driver_data = (void *)keymap_s64x0 |
| 503 | }, |
| 504 | { |
| 505 | .callback = fujitsu_laptop_dmi_keymap_override, |
| 506 | .ident = "Fujitsu LifeBook P8010", |
| 507 | .matches = { |
| 508 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), |
| 509 | DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P8010"), |
| 510 | }, |
| 511 | .driver_data = (void *)keymap_p8010 |
| 512 | }, |
| 513 | {} |
| 514 | }; |
| 515 | |
Michał Kępień | 11182db | 2017-03-20 10:32:20 +0100 | [diff] [blame] | 516 | static int acpi_fujitsu_laptop_input_setup(struct acpi_device *device) |
| 517 | { |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 518 | struct fujitsu_laptop *priv = acpi_driver_data(device); |
Michał Kępień | 527483a | 2017-03-20 10:32:22 +0100 | [diff] [blame] | 519 | int ret; |
Michał Kępień | 11182db | 2017-03-20 10:32:20 +0100 | [diff] [blame] | 520 | |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 521 | priv->input = devm_input_allocate_device(&device->dev); |
| 522 | if (!priv->input) |
Michał Kępień | 11182db | 2017-03-20 10:32:20 +0100 | [diff] [blame] | 523 | return -ENOMEM; |
| 524 | |
Michał Kępień | c1f51f1 | 2017-06-16 06:40:55 +0200 | [diff] [blame] | 525 | snprintf(priv->phys, sizeof(priv->phys), "%s/input0", |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 526 | acpi_device_hid(device)); |
Michał Kępień | 11182db | 2017-03-20 10:32:20 +0100 | [diff] [blame] | 527 | |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 528 | priv->input->name = acpi_device_name(device); |
| 529 | priv->input->phys = priv->phys; |
| 530 | priv->input->id.bustype = BUS_HOST; |
Michał Kępień | 11182db | 2017-03-20 10:32:20 +0100 | [diff] [blame] | 531 | |
Michał Kępień | f8c94ec | 2017-03-20 10:32:23 +0100 | [diff] [blame] | 532 | dmi_check_system(fujitsu_laptop_dmi_table); |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 533 | ret = sparse_keymap_setup(priv->input, keymap, NULL); |
Michał Kępień | 527483a | 2017-03-20 10:32:22 +0100 | [diff] [blame] | 534 | if (ret) |
| 535 | return ret; |
Michał Kępień | 11182db | 2017-03-20 10:32:20 +0100 | [diff] [blame] | 536 | |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 537 | return input_register_device(priv->input); |
Michał Kępień | 11182db | 2017-03-20 10:32:20 +0100 | [diff] [blame] | 538 | } |
| 539 | |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 540 | static int fujitsu_laptop_platform_add(struct acpi_device *device) |
Michał Kępień | d811b51 | 2017-03-14 11:26:29 +0100 | [diff] [blame] | 541 | { |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 542 | struct fujitsu_laptop *priv = acpi_driver_data(device); |
Michał Kępień | d811b51 | 2017-03-14 11:26:29 +0100 | [diff] [blame] | 543 | int ret; |
| 544 | |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 545 | priv->pf_device = platform_device_alloc("fujitsu-laptop", -1); |
| 546 | if (!priv->pf_device) |
Michał Kępień | d811b51 | 2017-03-14 11:26:29 +0100 | [diff] [blame] | 547 | return -ENOMEM; |
| 548 | |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 549 | platform_set_drvdata(priv->pf_device, priv); |
| 550 | |
| 551 | ret = platform_device_add(priv->pf_device); |
Michał Kępień | d811b51 | 2017-03-14 11:26:29 +0100 | [diff] [blame] | 552 | if (ret) |
| 553 | goto err_put_platform_device; |
| 554 | |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 555 | ret = sysfs_create_group(&priv->pf_device->dev.kobj, |
Michał Kępień | d811b51 | 2017-03-14 11:26:29 +0100 | [diff] [blame] | 556 | &fujitsu_pf_attribute_group); |
| 557 | if (ret) |
| 558 | goto err_del_platform_device; |
| 559 | |
| 560 | return 0; |
| 561 | |
| 562 | err_del_platform_device: |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 563 | platform_device_del(priv->pf_device); |
Michał Kępień | d811b51 | 2017-03-14 11:26:29 +0100 | [diff] [blame] | 564 | err_put_platform_device: |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 565 | platform_device_put(priv->pf_device); |
Michał Kępień | d811b51 | 2017-03-14 11:26:29 +0100 | [diff] [blame] | 566 | |
| 567 | return ret; |
| 568 | } |
| 569 | |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 570 | static void fujitsu_laptop_platform_remove(struct acpi_device *device) |
Michał Kępień | d811b51 | 2017-03-14 11:26:29 +0100 | [diff] [blame] | 571 | { |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 572 | struct fujitsu_laptop *priv = acpi_driver_data(device); |
| 573 | |
| 574 | sysfs_remove_group(&priv->pf_device->dev.kobj, |
Michał Kępień | d811b51 | 2017-03-14 11:26:29 +0100 | [diff] [blame] | 575 | &fujitsu_pf_attribute_group); |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 576 | platform_device_unregister(priv->pf_device); |
Michał Kępień | d811b51 | 2017-03-14 11:26:29 +0100 | [diff] [blame] | 577 | } |
| 578 | |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 579 | static int logolamp_set(struct led_classdev *cdev, |
| 580 | enum led_brightness brightness) |
| 581 | { |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 582 | struct acpi_device *device = to_acpi_device(cdev->dev->parent); |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 583 | int poweron = FUNC_LED_ON, always = FUNC_LED_ON; |
| 584 | int ret; |
| 585 | |
| 586 | if (brightness < LED_HALF) |
| 587 | poweron = FUNC_LED_OFF; |
| 588 | |
| 589 | if (brightness < LED_FULL) |
| 590 | always = FUNC_LED_OFF; |
| 591 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 592 | ret = call_fext_func(device, FUNC_LEDS, 0x1, LOGOLAMP_POWERON, poweron); |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 593 | if (ret < 0) |
| 594 | return ret; |
| 595 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 596 | return call_fext_func(device, FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, always); |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | static enum led_brightness logolamp_get(struct led_classdev *cdev) |
| 600 | { |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 601 | struct acpi_device *device = to_acpi_device(cdev->dev->parent); |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 602 | int ret; |
| 603 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 604 | ret = call_fext_func(device, FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0); |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 605 | if (ret == FUNC_LED_ON) |
| 606 | return LED_FULL; |
| 607 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 608 | ret = call_fext_func(device, FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0); |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 609 | if (ret == FUNC_LED_ON) |
| 610 | return LED_HALF; |
| 611 | |
| 612 | return LED_OFF; |
| 613 | } |
| 614 | |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 615 | static int kblamps_set(struct led_classdev *cdev, |
| 616 | enum led_brightness brightness) |
| 617 | { |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 618 | struct acpi_device *device = to_acpi_device(cdev->dev->parent); |
| 619 | |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 620 | if (brightness >= LED_FULL) |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 621 | return call_fext_func(device, FUNC_LEDS, 0x1, KEYBOARD_LAMPS, |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 622 | FUNC_LED_ON); |
| 623 | else |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 624 | return call_fext_func(device, FUNC_LEDS, 0x1, KEYBOARD_LAMPS, |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 625 | FUNC_LED_OFF); |
| 626 | } |
| 627 | |
| 628 | static enum led_brightness kblamps_get(struct led_classdev *cdev) |
| 629 | { |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 630 | struct acpi_device *device = to_acpi_device(cdev->dev->parent); |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 631 | enum led_brightness brightness = LED_OFF; |
| 632 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 633 | if (call_fext_func(device, |
Michał Kępień | 84631e0 | 2017-05-19 09:44:46 +0200 | [diff] [blame] | 634 | FUNC_LEDS, 0x2, KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON) |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 635 | brightness = LED_FULL; |
| 636 | |
| 637 | return brightness; |
| 638 | } |
| 639 | |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 640 | static int radio_led_set(struct led_classdev *cdev, |
| 641 | enum led_brightness brightness) |
| 642 | { |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 643 | struct acpi_device *device = to_acpi_device(cdev->dev->parent); |
| 644 | |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 645 | if (brightness >= LED_FULL) |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 646 | return call_fext_func(device, FUNC_FLAGS, 0x5, RADIO_LED_ON, |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 647 | RADIO_LED_ON); |
| 648 | else |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 649 | return call_fext_func(device, FUNC_FLAGS, 0x5, RADIO_LED_ON, |
Michał Kępień | 84631e0 | 2017-05-19 09:44:46 +0200 | [diff] [blame] | 650 | 0x0); |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | static enum led_brightness radio_led_get(struct led_classdev *cdev) |
| 654 | { |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 655 | struct acpi_device *device = to_acpi_device(cdev->dev->parent); |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 656 | enum led_brightness brightness = LED_OFF; |
| 657 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 658 | if (call_fext_func(device, FUNC_FLAGS, 0x4, 0x0, 0x0) & RADIO_LED_ON) |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 659 | brightness = LED_FULL; |
| 660 | |
| 661 | return brightness; |
| 662 | } |
| 663 | |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 664 | static int eco_led_set(struct led_classdev *cdev, |
| 665 | enum led_brightness brightness) |
| 666 | { |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 667 | struct acpi_device *device = to_acpi_device(cdev->dev->parent); |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 668 | int curr; |
| 669 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 670 | curr = call_fext_func(device, FUNC_LEDS, 0x2, ECO_LED, 0x0); |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 671 | if (brightness >= LED_FULL) |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 672 | return call_fext_func(device, FUNC_LEDS, 0x1, ECO_LED, |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 673 | curr | ECO_LED_ON); |
| 674 | else |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 675 | return call_fext_func(device, FUNC_LEDS, 0x1, ECO_LED, |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 676 | curr & ~ECO_LED_ON); |
| 677 | } |
| 678 | |
| 679 | static enum led_brightness eco_led_get(struct led_classdev *cdev) |
| 680 | { |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 681 | struct acpi_device *device = to_acpi_device(cdev->dev->parent); |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 682 | enum led_brightness brightness = LED_OFF; |
| 683 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 684 | if (call_fext_func(device, FUNC_LEDS, 0x2, ECO_LED, 0x0) & ECO_LED_ON) |
Michał Kępień | e33ca45 | 2017-04-07 15:07:10 +0200 | [diff] [blame] | 685 | brightness = LED_FULL; |
| 686 | |
| 687 | return brightness; |
| 688 | } |
| 689 | |
Michał Kępień | 81f6821 | 2017-04-07 15:07:11 +0200 | [diff] [blame] | 690 | static int acpi_fujitsu_laptop_leds_register(struct acpi_device *device) |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 691 | { |
Michał Kępień | c7b3e98 | 2017-10-25 06:29:46 +0200 | [diff] [blame] | 692 | struct fujitsu_laptop *priv = acpi_driver_data(device); |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 693 | struct led_classdev *led; |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 694 | int ret; |
Michał Kępień | 7adb7b1 | 2017-04-07 15:07:09 +0200 | [diff] [blame] | 695 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 696 | if (call_fext_func(device, |
Michał Kępień | 84631e0 | 2017-05-19 09:44:46 +0200 | [diff] [blame] | 697 | FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) { |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 698 | led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); |
Gustavo A. R. Silva | b77a537 | 2017-07-06 17:19:02 -0500 | [diff] [blame] | 699 | if (!led) |
| 700 | return -ENOMEM; |
| 701 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 702 | led->name = "fujitsu::logolamp"; |
| 703 | led->brightness_set_blocking = logolamp_set; |
| 704 | led->brightness_get = logolamp_get; |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 705 | ret = devm_led_classdev_register(&device->dev, led); |
| 706 | if (ret) |
| 707 | return ret; |
Michał Kępień | 7adb7b1 | 2017-04-07 15:07:09 +0200 | [diff] [blame] | 708 | } |
| 709 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 710 | if ((call_fext_func(device, |
Michał Kępień | 84631e0 | 2017-05-19 09:44:46 +0200 | [diff] [blame] | 711 | FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) && |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 712 | (call_fext_func(device, FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) { |
| 713 | led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); |
Gustavo A. R. Silva | b77a537 | 2017-07-06 17:19:02 -0500 | [diff] [blame] | 714 | if (!led) |
| 715 | return -ENOMEM; |
| 716 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 717 | led->name = "fujitsu::kblamps"; |
| 718 | led->brightness_set_blocking = kblamps_set; |
| 719 | led->brightness_get = kblamps_get; |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 720 | ret = devm_led_classdev_register(&device->dev, led); |
| 721 | if (ret) |
| 722 | return ret; |
Michał Kępień | 7adb7b1 | 2017-04-07 15:07:09 +0200 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | /* |
Michał Kępień | c7b3e98 | 2017-10-25 06:29:46 +0200 | [diff] [blame] | 726 | * Some Fujitsu laptops have a radio toggle button in place of a slide |
| 727 | * switch and all such machines appear to also have an RF LED. Based on |
| 728 | * comparing DSDT tables of four Fujitsu Lifebook models (E744, E751, |
| 729 | * S7110, S8420; the first one has a radio toggle button, the other |
| 730 | * three have slide switches), bit 17 of flags_supported (the value |
| 731 | * returned by method S000 of ACPI device FUJ02E3) seems to indicate |
| 732 | * whether given model has a radio toggle button. |
Michał Kępień | 7adb7b1 | 2017-04-07 15:07:09 +0200 | [diff] [blame] | 733 | */ |
Michał Kępień | c7b3e98 | 2017-10-25 06:29:46 +0200 | [diff] [blame] | 734 | if (priv->flags_supported & BIT(17)) { |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 735 | led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); |
Gustavo A. R. Silva | b77a537 | 2017-07-06 17:19:02 -0500 | [diff] [blame] | 736 | if (!led) |
| 737 | return -ENOMEM; |
| 738 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 739 | led->name = "fujitsu::radio_led"; |
| 740 | led->brightness_set_blocking = radio_led_set; |
| 741 | led->brightness_get = radio_led_get; |
| 742 | led->default_trigger = "rfkill-any"; |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 743 | ret = devm_led_classdev_register(&device->dev, led); |
| 744 | if (ret) |
| 745 | return ret; |
Michał Kępień | 7adb7b1 | 2017-04-07 15:07:09 +0200 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | /* Support for eco led is not always signaled in bit corresponding |
| 749 | * to the bit used to control the led. According to the DSDT table, |
| 750 | * bit 14 seems to indicate presence of said led as well. |
| 751 | * Confirm by testing the status. |
| 752 | */ |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 753 | if ((call_fext_func(device, FUNC_LEDS, 0x0, 0x0, 0x0) & BIT(14)) && |
| 754 | (call_fext_func(device, |
Michał Kępień | 84631e0 | 2017-05-19 09:44:46 +0200 | [diff] [blame] | 755 | FUNC_LEDS, 0x2, ECO_LED, 0x0) != UNSUPPORTED_CMD)) { |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 756 | led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); |
Gustavo A. R. Silva | b77a537 | 2017-07-06 17:19:02 -0500 | [diff] [blame] | 757 | if (!led) |
| 758 | return -ENOMEM; |
| 759 | |
Michał Kępień | a823f8e | 2017-05-19 09:44:47 +0200 | [diff] [blame] | 760 | led->name = "fujitsu::eco_led"; |
| 761 | led->brightness_set_blocking = eco_led_set; |
| 762 | led->brightness_get = eco_led_get; |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 763 | ret = devm_led_classdev_register(&device->dev, led); |
| 764 | if (ret) |
| 765 | return ret; |
Michał Kępień | 7adb7b1 | 2017-04-07 15:07:09 +0200 | [diff] [blame] | 766 | } |
| 767 | |
Michał Kępień | 30943e1 | 2017-04-07 15:07:12 +0200 | [diff] [blame] | 768 | return 0; |
Michał Kępień | 7adb7b1 | 2017-04-07 15:07:09 +0200 | [diff] [blame] | 769 | } |
| 770 | |
| 771 | static int acpi_fujitsu_laptop_add(struct acpi_device *device) |
| 772 | { |
Michał Kępień | a4b176e | 2017-05-19 09:44:44 +0200 | [diff] [blame] | 773 | struct fujitsu_laptop *priv; |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 774 | int ret, i = 0; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 775 | |
Michał Kępień | a4b176e | 2017-05-19 09:44:44 +0200 | [diff] [blame] | 776 | priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL); |
| 777 | if (!priv) |
| 778 | return -ENOMEM; |
| 779 | |
Michał Kępień | ca0d9ea | 2017-05-19 09:44:45 +0200 | [diff] [blame] | 780 | WARN_ONCE(fext, "More than one FUJ02E3 ACPI device was found. Driver may not work as intended."); |
| 781 | fext = device; |
| 782 | |
Michał Kępień | d6a298a | 2017-06-16 06:40:54 +0200 | [diff] [blame] | 783 | strcpy(acpi_device_name(device), ACPI_FUJITSU_LAPTOP_DEVICE_NAME); |
| 784 | strcpy(acpi_device_class(device), ACPI_FUJITSU_CLASS); |
Michał Kępień | a4b176e | 2017-05-19 09:44:44 +0200 | [diff] [blame] | 785 | device->driver_data = priv; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 786 | |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 787 | /* kfifo */ |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 788 | spin_lock_init(&priv->fifo_lock); |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 789 | ret = kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int), |
| 790 | GFP_KERNEL); |
Michał Kępień | 7f83d41 | 2018-02-11 22:07:23 +0100 | [diff] [blame] | 791 | if (ret) |
| 792 | return ret; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 793 | |
Michał Kępień | 1c19462 | 2017-06-16 06:40:56 +0200 | [diff] [blame] | 794 | pr_info("ACPI: %s [%s]\n", |
| 795 | acpi_device_name(device), acpi_device_bid(device)); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 796 | |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 797 | while (call_fext_func(device, FUNC_BUTTONS, 0x1, 0x0, 0x0) != 0 && |
| 798 | i++ < MAX_HOTKEY_RINGBUFFER_SIZE) |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 799 | ; /* No action, result is discarded */ |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 800 | acpi_handle_debug(device->handle, "Discarded %i ringbuffer entries\n", |
| 801 | i); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 802 | |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 803 | priv->flags_supported = call_fext_func(device, FUNC_FLAGS, 0x0, 0x0, |
| 804 | 0x0); |
Tony Vroon | 4898c2b | 2009-02-02 11:11:10 +0000 | [diff] [blame] | 805 | |
| 806 | /* Make sure our bitmask of supported functions is cleared if the |
| 807 | RFKILL function block is not implemented, like on the S7020. */ |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 808 | if (priv->flags_supported == UNSUPPORTED_CMD) |
| 809 | priv->flags_supported = 0; |
Tony Vroon | 4898c2b | 2009-02-02 11:11:10 +0000 | [diff] [blame] | 810 | |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 811 | if (priv->flags_supported) |
| 812 | priv->flags_state = call_fext_func(device, FUNC_FLAGS, 0x4, 0x0, |
| 813 | 0x0); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 814 | |
| 815 | /* Suspect this is a keymap of the application panel, print it */ |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 816 | acpi_handle_info(device->handle, "BTNI: [0x%x]\n", |
| 817 | call_fext_func(device, FUNC_BUTTONS, 0x0, 0x0, 0x0)); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 818 | |
Michał Kępień | 1877e26 | 2017-03-10 11:50:34 +0100 | [diff] [blame] | 819 | /* Sync backlight power status */ |
Michał Kępień | 679374e | 2017-05-19 09:44:42 +0200 | [diff] [blame] | 820 | if (fujitsu_bl && fujitsu_bl->bl_device && |
Michał Kępień | aea3137 | 2017-03-10 11:50:35 +0100 | [diff] [blame] | 821 | acpi_video_get_backlight_type() == acpi_backlight_vendor) { |
Michał Kępień | 84631e0 | 2017-05-19 09:44:46 +0200 | [diff] [blame] | 822 | if (call_fext_func(fext, FUNC_BACKLIGHT, 0x2, 0x4, 0x0) == 3) |
Michał Kępień | 1877e26 | 2017-03-10 11:50:34 +0100 | [diff] [blame] | 823 | fujitsu_bl->bl_device->props.power = FB_BLANK_POWERDOWN; |
| 824 | else |
| 825 | fujitsu_bl->bl_device->props.power = FB_BLANK_UNBLANK; |
| 826 | } |
| 827 | |
Michał Kępień | a7a1ccbe | 2018-02-11 22:07:22 +0100 | [diff] [blame] | 828 | ret = acpi_fujitsu_laptop_input_setup(device); |
| 829 | if (ret) |
| 830 | goto err_free_fifo; |
| 831 | |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 832 | ret = acpi_fujitsu_laptop_leds_register(device); |
| 833 | if (ret) |
Michał Kępień | d1c7073 | 2017-04-07 15:07:13 +0200 | [diff] [blame] | 834 | goto err_free_fifo; |
| 835 | |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 836 | ret = fujitsu_laptop_platform_add(device); |
| 837 | if (ret) |
Michał Kępień | f66735f | 2017-03-20 10:32:21 +0100 | [diff] [blame] | 838 | goto err_free_fifo; |
Michał Kępień | c33f4c0 | 2017-03-14 11:26:30 +0100 | [diff] [blame] | 839 | |
Michał Kępień | 7adb7b1 | 2017-04-07 15:07:09 +0200 | [diff] [blame] | 840 | return 0; |
Michał Kępień | 4f62568 | 2016-04-12 22:06:34 +0930 | [diff] [blame] | 841 | |
Bjorn Helgaas | b4ec027 | 2009-04-07 15:37:22 +0000 | [diff] [blame] | 842 | err_free_fifo: |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 843 | kfifo_free(&priv->fifo); |
Michał Kępień | 7f83d41 | 2018-02-11 22:07:23 +0100 | [diff] [blame] | 844 | |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 845 | return ret; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 846 | } |
| 847 | |
Alan Jenkins | 6942eab | 2017-02-08 14:46:25 +0100 | [diff] [blame] | 848 | static int acpi_fujitsu_laptop_remove(struct acpi_device *device) |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 849 | { |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 850 | struct fujitsu_laptop *priv = acpi_driver_data(device); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 851 | |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 852 | fujitsu_laptop_platform_remove(device); |
Michał Kępień | c33f4c0 | 2017-03-14 11:26:30 +0100 | [diff] [blame] | 853 | |
Michał Kępień | 7ec3b54 | 2017-05-19 09:44:41 +0200 | [diff] [blame] | 854 | kfifo_free(&priv->fifo); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 855 | |
| 856 | return 0; |
| 857 | } |
| 858 | |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 859 | static void acpi_fujitsu_laptop_press(struct acpi_device *device, int scancode) |
Michał Kępień | 2451d19 | 2017-01-11 09:59:31 +0100 | [diff] [blame] | 860 | { |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 861 | struct fujitsu_laptop *priv = acpi_driver_data(device); |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 862 | int ret; |
Michał Kępień | 2451d19 | 2017-01-11 09:59:31 +0100 | [diff] [blame] | 863 | |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 864 | ret = kfifo_in_locked(&priv->fifo, (unsigned char *)&scancode, |
| 865 | sizeof(scancode), &priv->fifo_lock); |
| 866 | if (ret != sizeof(scancode)) { |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 867 | dev_info(&priv->input->dev, "Could not push scancode [0x%x]\n", |
| 868 | scancode); |
Michał Kępień | a28c7e9 | 2017-01-11 09:59:33 +0100 | [diff] [blame] | 869 | return; |
Michał Kępień | 2451d19 | 2017-01-11 09:59:31 +0100 | [diff] [blame] | 870 | } |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 871 | sparse_keymap_report_event(priv->input, scancode, 1, false); |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 872 | dev_dbg(&priv->input->dev, "Push scancode into ringbuffer [0x%x]\n", |
| 873 | scancode); |
Michał Kępień | 2451d19 | 2017-01-11 09:59:31 +0100 | [diff] [blame] | 874 | } |
| 875 | |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 876 | static void acpi_fujitsu_laptop_release(struct acpi_device *device) |
Michał Kępień | 2451d19 | 2017-01-11 09:59:31 +0100 | [diff] [blame] | 877 | { |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 878 | struct fujitsu_laptop *priv = acpi_driver_data(device); |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 879 | int scancode, ret; |
Michał Kępień | 2451d19 | 2017-01-11 09:59:31 +0100 | [diff] [blame] | 880 | |
Michał Kępień | 29544f0 | 2017-01-11 09:59:32 +0100 | [diff] [blame] | 881 | while (true) { |
Michał Kępień | 14966e0 | 2018-02-11 22:07:21 +0100 | [diff] [blame] | 882 | ret = kfifo_out_locked(&priv->fifo, (unsigned char *)&scancode, |
| 883 | sizeof(scancode), &priv->fifo_lock); |
| 884 | if (ret != sizeof(scancode)) |
Michał Kępień | 29544f0 | 2017-01-11 09:59:32 +0100 | [diff] [blame] | 885 | return; |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 886 | sparse_keymap_report_event(priv->input, scancode, 0, false); |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 887 | dev_dbg(&priv->input->dev, |
| 888 | "Pop scancode from ringbuffer [0x%x]\n", scancode); |
Michał Kępień | 2451d19 | 2017-01-11 09:59:31 +0100 | [diff] [blame] | 889 | } |
| 890 | } |
| 891 | |
Alan Jenkins | 6942eab | 2017-02-08 14:46:25 +0100 | [diff] [blame] | 892 | static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event) |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 893 | { |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 894 | struct fujitsu_laptop *priv = acpi_driver_data(device); |
Michał Kępień | 527483a | 2017-03-20 10:32:22 +0100 | [diff] [blame] | 895 | int scancode, i = 0; |
| 896 | unsigned int irb; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 897 | |
Michał Kępień | eb357cb | 2017-01-11 09:59:30 +0100 | [diff] [blame] | 898 | if (event != ACPI_FUJITSU_NOTIFY_CODE1) { |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 899 | acpi_handle_info(device->handle, "Unsupported event [0x%x]\n", |
| 900 | event); |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 901 | sparse_keymap_report_event(priv->input, -1, 1, true); |
Michał Kępień | eb357cb | 2017-01-11 09:59:30 +0100 | [diff] [blame] | 902 | return; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 903 | } |
Michał Kępień | eb357cb | 2017-01-11 09:59:30 +0100 | [diff] [blame] | 904 | |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 905 | if (priv->flags_supported) |
| 906 | priv->flags_state = call_fext_func(device, FUNC_FLAGS, 0x4, 0x0, |
| 907 | 0x0); |
Michał Kępień | eb357cb | 2017-01-11 09:59:30 +0100 | [diff] [blame] | 908 | |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 909 | while ((irb = call_fext_func(device, |
Michał Kępień | 84631e0 | 2017-05-19 09:44:46 +0200 | [diff] [blame] | 910 | FUNC_BUTTONS, 0x1, 0x0, 0x0)) != 0 && |
Michał Kępień | 527483a | 2017-03-20 10:32:22 +0100 | [diff] [blame] | 911 | i++ < MAX_HOTKEY_RINGBUFFER_SIZE) { |
| 912 | scancode = irb & 0x4ff; |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 913 | if (sparse_keymap_entry_from_scancode(priv->input, scancode)) |
| 914 | acpi_fujitsu_laptop_press(device, scancode); |
Michał Kępień | 527483a | 2017-03-20 10:32:22 +0100 | [diff] [blame] | 915 | else if (scancode == 0) |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 916 | acpi_fujitsu_laptop_release(device); |
Michał Kępień | 527483a | 2017-03-20 10:32:22 +0100 | [diff] [blame] | 917 | else |
Michał Kępień | eee77da1 | 2017-06-16 06:40:58 +0200 | [diff] [blame] | 918 | acpi_handle_info(device->handle, |
| 919 | "Unknown GIRB result [%x]\n", irb); |
Michał Kępień | eb357cb | 2017-01-11 09:59:30 +0100 | [diff] [blame] | 920 | } |
| 921 | |
| 922 | /* On some models (first seen on the Skylake-based Lifebook |
| 923 | * E736/E746/E756), the touchpad toggle hotkey (Fn+F4) is |
Alan Jenkins | 8ef27bd | 2017-02-08 14:46:27 +0100 | [diff] [blame] | 924 | * handled in software; its state is queried using FUNC_FLAGS |
Michał Kępień | eb357cb | 2017-01-11 09:59:30 +0100 | [diff] [blame] | 925 | */ |
Michał Kępień | d659d11 | 2017-05-19 09:44:48 +0200 | [diff] [blame] | 926 | if ((priv->flags_supported & BIT(26)) && |
| 927 | (call_fext_func(device, FUNC_FLAGS, 0x1, 0x0, 0x0) & BIT(26))) |
| 928 | sparse_keymap_report_event(priv->input, BIT(26), 1, true); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | /* Initialization */ |
| 932 | |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 933 | static const struct acpi_device_id fujitsu_bl_device_ids[] = { |
| 934 | {ACPI_FUJITSU_BL_HID, 0}, |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 935 | {"", 0}, |
| 936 | }; |
| 937 | |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 938 | static struct acpi_driver acpi_fujitsu_bl_driver = { |
| 939 | .name = ACPI_FUJITSU_BL_DRIVER_NAME, |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 940 | .class = ACPI_FUJITSU_CLASS, |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 941 | .ids = fujitsu_bl_device_ids, |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 942 | .ops = { |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 943 | .add = acpi_fujitsu_bl_add, |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 944 | .notify = acpi_fujitsu_bl_notify, |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 945 | }, |
| 946 | }; |
| 947 | |
Alan Jenkins | 6942eab | 2017-02-08 14:46:25 +0100 | [diff] [blame] | 948 | static const struct acpi_device_id fujitsu_laptop_device_ids[] = { |
| 949 | {ACPI_FUJITSU_LAPTOP_HID, 0}, |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 950 | {"", 0}, |
| 951 | }; |
| 952 | |
Alan Jenkins | 6942eab | 2017-02-08 14:46:25 +0100 | [diff] [blame] | 953 | static struct acpi_driver acpi_fujitsu_laptop_driver = { |
| 954 | .name = ACPI_FUJITSU_LAPTOP_DRIVER_NAME, |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 955 | .class = ACPI_FUJITSU_CLASS, |
Alan Jenkins | 6942eab | 2017-02-08 14:46:25 +0100 | [diff] [blame] | 956 | .ids = fujitsu_laptop_device_ids, |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 957 | .ops = { |
Alan Jenkins | 6942eab | 2017-02-08 14:46:25 +0100 | [diff] [blame] | 958 | .add = acpi_fujitsu_laptop_add, |
| 959 | .remove = acpi_fujitsu_laptop_remove, |
| 960 | .notify = acpi_fujitsu_laptop_notify, |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 961 | }, |
| 962 | }; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 963 | |
Zhang Rui | 4990141 | 2014-09-09 00:21:59 +0200 | [diff] [blame] | 964 | static const struct acpi_device_id fujitsu_ids[] __used = { |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 965 | {ACPI_FUJITSU_BL_HID, 0}, |
Alan Jenkins | 6942eab | 2017-02-08 14:46:25 +0100 | [diff] [blame] | 966 | {ACPI_FUJITSU_LAPTOP_HID, 0}, |
Zhang Rui | 4990141 | 2014-09-09 00:21:59 +0200 | [diff] [blame] | 967 | {"", 0} |
| 968 | }; |
| 969 | MODULE_DEVICE_TABLE(acpi, fujitsu_ids); |
| 970 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 971 | static int __init fujitsu_init(void) |
| 972 | { |
Michał Kępień | b8d69c1 | 2017-03-10 11:50:33 +0100 | [diff] [blame] | 973 | int ret; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 974 | |
Alan Jenkins | c1d1e8a | 2017-02-08 14:46:30 +0100 | [diff] [blame] | 975 | ret = acpi_bus_register_driver(&acpi_fujitsu_bl_driver); |
| 976 | if (ret) |
Michał Kępień | 679374e | 2017-05-19 09:44:42 +0200 | [diff] [blame] | 977 | return ret; |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 978 | |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 979 | /* Register platform stuff */ |
| 980 | |
Alan Jenkins | 1650602 | 2017-02-08 14:46:26 +0100 | [diff] [blame] | 981 | ret = platform_driver_register(&fujitsu_pf_driver); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 982 | if (ret) |
Michał Kępień | c33f4c0 | 2017-03-14 11:26:30 +0100 | [diff] [blame] | 983 | goto err_unregister_acpi; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 984 | |
Alan Jenkins | 6942eab | 2017-02-08 14:46:25 +0100 | [diff] [blame] | 985 | /* Register laptop driver */ |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 986 | |
Alan Jenkins | c1d1e8a | 2017-02-08 14:46:30 +0100 | [diff] [blame] | 987 | ret = acpi_bus_register_driver(&acpi_fujitsu_laptop_driver); |
| 988 | if (ret) |
Michał Kępień | a4b176e | 2017-05-19 09:44:44 +0200 | [diff] [blame] | 989 | goto err_unregister_platform_driver; |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 990 | |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 991 | pr_info("driver " FUJITSU_DRIVER_VERSION " successfully loaded\n"); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 992 | |
| 993 | return 0; |
| 994 | |
Michał Kępień | c2cddd4 | 2017-03-10 11:50:36 +0100 | [diff] [blame] | 995 | err_unregister_platform_driver: |
Alan Jenkins | 1650602 | 2017-02-08 14:46:26 +0100 | [diff] [blame] | 996 | platform_driver_unregister(&fujitsu_pf_driver); |
Michał Kępień | c2cddd4 | 2017-03-10 11:50:36 +0100 | [diff] [blame] | 997 | err_unregister_acpi: |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 998 | acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 999 | |
| 1000 | return ret; |
| 1001 | } |
| 1002 | |
| 1003 | static void __exit fujitsu_cleanup(void) |
| 1004 | { |
Alan Jenkins | 6942eab | 2017-02-08 14:46:25 +0100 | [diff] [blame] | 1005 | acpi_bus_unregister_driver(&acpi_fujitsu_laptop_driver); |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 1006 | |
Alan Jenkins | 1650602 | 2017-02-08 14:46:26 +0100 | [diff] [blame] | 1007 | platform_driver_unregister(&fujitsu_pf_driver); |
Bartlomiej Zolnierkiewicz | 72afeea | 2009-07-31 18:16:02 +0930 | [diff] [blame] | 1008 | |
Alan Jenkins | 9fc5cf6 | 2017-02-08 14:46:24 +0100 | [diff] [blame] | 1009 | acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1010 | |
Joe Perches | 77bad7c | 2011-03-29 15:21:39 -0700 | [diff] [blame] | 1011 | pr_info("driver unloaded\n"); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | module_init(fujitsu_init); |
| 1015 | module_exit(fujitsu_cleanup); |
| 1016 | |
Michał Kępień | e06e483 | 2017-04-05 08:49:05 +0200 | [diff] [blame] | 1017 | module_param(use_alt_lcd_levels, int, 0644); |
| 1018 | MODULE_PARM_DESC(use_alt_lcd_levels, "Interface used for setting LCD brightness level (-1 = auto, 0 = force SBLL, 1 = force SBL2)"); |
Michał Kępień | b4bb0cf | 2017-04-05 08:49:06 +0200 | [diff] [blame] | 1019 | module_param(disable_brightness_adjust, bool, 0644); |
| 1020 | MODULE_PARM_DESC(disable_brightness_adjust, "Disable LCD brightness adjustment"); |
Jonathan Woithe | 20b9373 | 2008-06-11 10:14:56 +0930 | [diff] [blame] | 1021 | |
Tony Vroon | 3a40708 | 2008-12-31 18:19:59 +0000 | [diff] [blame] | 1022 | MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon"); |
Jonathan Woithe | d048253 | 2007-08-29 15:58:19 +0930 | [diff] [blame] | 1023 | MODULE_DESCRIPTION("Fujitsu laptop extras support"); |
| 1024 | MODULE_VERSION(FUJITSU_DRIVER_VERSION); |
| 1025 | MODULE_LICENSE("GPL"); |