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