blob: cd95b6f3a06405835edadfc6ea92a5b46bab591f [file] [log] [blame]
Jonathan Woithed0482532007-08-29 15:58:19 +09301/*-*-linux-c-*-*/
2
3/*
Jonathan Woithe409a3e92012-03-27 13:01:01 +10304 Copyright (C) 2007,2008 Jonathan Woithe <jwoithe@just42.net>
Jonathan Woithe20b93732008-06-11 10:14:56 +09305 Copyright (C) 2008 Peter Gruber <nokos@gmx.net>
Tony Vroon3a407082008-12-31 18:19:59 +00006 Copyright (C) 2008 Tony Vroon <tony@linx.net>
Jonathan Woithed0482532007-08-29 15:58:19 +09307 Based on earlier work:
8 Copyright (C) 2003 Shane Spencer <shane@bogomip.com>
9 Adrian Yee <brewt-fujitsu@brewt.org>
10
Jonathan Woithe20b93732008-06-11 10:14:56 +093011 Templated from msi-laptop.c and thinkpad_acpi.c which is copyright
12 by its respective authors.
Jonathan Woithed0482532007-08-29 15:58:19 +093013
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ń78b26022017-03-14 11:26:27 +010035 * 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 Woithe20b93732008-06-11 10:14:56 +093038 *
Jonathan Woithe0e6a66e2008-10-09 13:44:40 +093039 * 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 Woithe20b93732008-06-11 10:14:56 +093042 *
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 Woithed0482532007-08-29 15:58:19 +093048 */
49
Joe Perches77bad7c2011-03-29 15:21:39 -070050#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
51
Jonathan Woithed0482532007-08-29 15:58:19 +093052#include <linux/module.h>
53#include <linux/kernel.h>
54#include <linux/init.h>
55#include <linux/acpi.h>
Michał Kępień819cdda2018-02-20 06:24:54 +010056#include <linux/bitops.h>
Jonathan Woithed0482532007-08-29 15:58:19 +093057#include <linux/dmi.h>
58#include <linux/backlight.h>
Michael Karchere8549e22015-01-18 20:28:46 +010059#include <linux/fb.h>
Jonathan Woithe20b93732008-06-11 10:14:56 +093060#include <linux/input.h>
Michał Kępieńf2252672017-03-20 10:32:19 +010061#include <linux/input/sparse-keymap.h>
Jonathan Woithe20b93732008-06-11 10:14:56 +093062#include <linux/kfifo.h>
Michał Kępieńd89bcc82017-04-07 15:07:08 +020063#include <linux/leds.h>
Jonathan Woithed0482532007-08-29 15:58:19 +093064#include <linux/platform_device.h>
Hans de Goede413226f2015-06-16 16:28:03 +020065#include <acpi/video.h>
Jonathan Woithed0482532007-08-29 15:58:19 +093066
Michał Kępień819cdda2018-02-20 06:24:54 +010067#define FUJITSU_DRIVER_VERSION "0.6.0"
Jonathan Woithed0482532007-08-29 15:58:19 +093068
Michał Kępień819cdda2018-02-20 06:24:54 +010069#define FUJITSU_LCD_N_LEVELS 8
Jonathan Woithed0482532007-08-29 15:58:19 +093070
Alan Jenkins9fc5cf62017-02-08 14:46:24 +010071#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 Jenkins6942eab2017-02-08 14:46:25 +010075#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 Woithed0482532007-08-29 15:58:19 +093078
Michał Kępień819cdda2018-02-20 06:24:54 +010079#define ACPI_FUJITSU_NOTIFY_CODE 0x80
Jonathan Woithe20b93732008-06-11 10:14:56 +093080
Tony Vroon3a407082008-12-31 18:19:59 +000081/* FUNC interface - command values */
Michał Kępień819cdda2018-02-20 06:24:54 +010082#define FUNC_FLAGS BIT(12)
83#define FUNC_LEDS (BIT(12) | BIT(0))
84#define FUNC_BUTTONS (BIT(12) | BIT(1))
85#define FUNC_BACKLIGHT (BIT(12) | BIT(2))
Tony Vroon3a407082008-12-31 18:19:59 +000086
87/* FUNC interface - responses */
Michał Kępień502ab002018-03-10 21:43:53 +010088#define UNSUPPORTED_CMD 0x80000000
Tony Vroon3a407082008-12-31 18:19:59 +000089
Alan Jenkinsd3dd4482017-02-08 14:46:28 +010090/* FUNC interface - status flags */
Michał Kępień819cdda2018-02-20 06:24:54 +010091#define FLAG_RFKILL BIT(5)
92#define FLAG_LID BIT(8)
93#define FLAG_DOCK BIT(9)
Alan Jenkinsd3dd4482017-02-08 14:46:28 +010094
Tony Vroon3a407082008-12-31 18:19:59 +000095/* FUNC interface - LED control */
Michał Kępień819cdda2018-02-20 06:24:54 +010096#define FUNC_LED_OFF BIT(0)
97#define FUNC_LED_ON (BIT(0) | BIT(16) | BIT(17))
98#define LOGOLAMP_POWERON BIT(13)
99#define LOGOLAMP_ALWAYS BIT(14)
100#define KEYBOARD_LAMPS BIT(8)
101#define RADIO_LED_ON BIT(5)
102#define ECO_LED BIT(16)
103#define ECO_LED_ON BIT(19)
Tony Vroon3a407082008-12-31 18:19:59 +0000104
Michał Kępień2f60efa2018-02-20 06:24:53 +0100105/* FUNC interface - backlight power control */
Michał Kępień819cdda2018-02-20 06:24:54 +0100106#define BACKLIGHT_PARAM_POWER BIT(2)
107#define BACKLIGHT_OFF (BIT(0) | BIT(1))
108#define BACKLIGHT_ON 0
Michał Kępień2f60efa2018-02-20 06:24:53 +0100109
Michał Kępień819cdda2018-02-20 06:24:54 +0100110/* Scancodes read from the GIRB register */
111#define KEY1_CODE 0x410
112#define KEY2_CODE 0x411
113#define KEY3_CODE 0x412
114#define KEY4_CODE 0x413
115#define KEY5_CODE 0x420
Jonathan Woithe20b93732008-06-11 10:14:56 +0930116
Michał Kępień819cdda2018-02-20 06:24:54 +0100117/* Hotkey ringbuffer limits */
118#define MAX_HOTKEY_RINGBUFFER_SIZE 100
119#define RINGBUFFERSIZE 40
Jonathan Woithe20b93732008-06-11 10:14:56 +0930120
Michał Kępień6cb11922018-02-11 22:07:24 +0100121/* Module parameters */
122static int use_alt_lcd_levels = -1;
123static bool disable_brightness_adjust;
124
Jonathan Woithe20b93732008-06-11 10:14:56 +0930125/* Device controlling the backlight and associated keys */
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100126struct fujitsu_bl {
Jonathan Woithe20b93732008-06-11 10:14:56 +0930127 struct input_dev *input;
128 char phys[32];
Jonathan Woithed0482532007-08-29 15:58:19 +0930129 struct backlight_device *bl_device;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930130 unsigned int max_brightness;
Jonathan Woithed0482532007-08-29 15:58:19 +0930131 unsigned int brightness_level;
132};
133
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100134static struct fujitsu_bl *fujitsu_bl;
Jonathan Woithed0482532007-08-29 15:58:19 +0930135
Alan Jenkins6942eab2017-02-08 14:46:25 +0100136/* Device used to access hotkeys and other features on the laptop */
137struct fujitsu_laptop {
Jonathan Woithe20b93732008-06-11 10:14:56 +0930138 struct input_dev *input;
139 char phys[32];
140 struct platform_device *pf_device;
Stefani Seibold45465482009-12-21 14:37:26 -0800141 struct kfifo fifo;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930142 spinlock_t fifo_lock;
Alan Jenkins8ef27bd2017-02-08 14:46:27 +0100143 int flags_supported;
144 int flags_state;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930145};
146
Michał Kępieńca0d9ea2017-05-19 09:44:45 +0200147static struct acpi_device *fext;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930148
Tony Vroon3a407082008-12-31 18:19:59 +0000149/* Fujitsu ACPI interface function */
150
Michał Kępień84631e02017-05-19 09:44:46 +0200151static int call_fext_func(struct acpi_device *device,
152 int func, int op, int feature, int state)
Tony Vroon3a407082008-12-31 18:19:59 +0000153{
Tony Vroon3a407082008-12-31 18:19:59 +0000154 union acpi_object params[4] = {
Michał Kępieńf68e4922017-04-03 11:38:59 +0200155 { .integer.type = ACPI_TYPE_INTEGER, .integer.value = func },
156 { .integer.type = ACPI_TYPE_INTEGER, .integer.value = op },
157 { .integer.type = ACPI_TYPE_INTEGER, .integer.value = feature },
158 { .integer.type = ACPI_TYPE_INTEGER, .integer.value = state }
Tony Vroon3a407082008-12-31 18:19:59 +0000159 };
Michał Kępieńb1066412017-04-03 11:38:57 +0200160 struct acpi_object_list arg_list = { 4, params };
Zhang Rui29c29a92013-09-03 08:32:12 +0800161 unsigned long long value;
Michał Kępieńb1066412017-04-03 11:38:57 +0200162 acpi_status status;
Tony Vroon3a407082008-12-31 18:19:59 +0000163
Michał Kępień84631e02017-05-19 09:44:46 +0200164 status = acpi_evaluate_integer(device->handle, "FUNC", &arg_list,
165 &value);
Tony Vroon3a407082008-12-31 18:19:59 +0000166 if (ACPI_FAILURE(status)) {
Michał Kępieńeee77da12017-06-16 06:40:58 +0200167 acpi_handle_err(device->handle, "Failed to evaluate FUNC\n");
Tony Vroon3a407082008-12-31 18:19:59 +0000168 return -ENODEV;
169 }
170
Michał Kępieńeee77da12017-06-16 06:40:58 +0200171 acpi_handle_debug(device->handle,
172 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n",
173 func, op, feature, state, (int)value);
Zhang Rui29c29a92013-09-03 08:32:12 +0800174 return value;
Tony Vroon3a407082008-12-31 18:19:59 +0000175}
176
Jonathan Woithe20b93732008-06-11 10:14:56 +0930177/* Hardware access for LCD brightness control */
Jonathan Woithed0482532007-08-29 15:58:19 +0930178
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200179static int set_lcd_level(struct acpi_device *device, int level)
Jonathan Woithed0482532007-08-29 15:58:19 +0930180{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200181 struct fujitsu_bl *priv = acpi_driver_data(device);
Michał Kępieńa8779c32017-04-05 08:49:03 +0200182 acpi_status status;
Michał Kępieńe32c50b2017-04-05 08:49:02 +0200183 char *method;
Jonathan Woithed0482532007-08-29 15:58:19 +0930184
Michał Kępieńe32c50b2017-04-05 08:49:02 +0200185 switch (use_alt_lcd_levels) {
Michał Kępieńe06e4832017-04-05 08:49:05 +0200186 case -1:
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200187 if (acpi_has_method(device->handle, "SBL2"))
Michał Kępieńe06e4832017-04-05 08:49:05 +0200188 method = "SBL2";
189 else
190 method = "SBLL";
191 break;
Michał Kępieńe32c50b2017-04-05 08:49:02 +0200192 case 1:
193 method = "SBL2";
194 break;
195 default:
196 method = "SBLL";
197 break;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930198 }
199
Michał Kępieńeee77da12017-06-16 06:40:58 +0200200 acpi_handle_debug(device->handle, "set lcd level via %s [%d]\n", method,
201 level);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930202
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200203 if (level < 0 || level >= priv->max_brightness)
Jonathan Woithe20b93732008-06-11 10:14:56 +0930204 return -EINVAL;
205
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200206 status = acpi_execute_simple_method(device->handle, method, level);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930207 if (ACPI_FAILURE(status)) {
Michał Kępieńeee77da12017-06-16 06:40:58 +0200208 acpi_handle_err(device->handle, "Failed to evaluate %s\n",
209 method);
Jonathan Woithed0482532007-08-29 15:58:19 +0930210 return -ENODEV;
211 }
212
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200213 priv->brightness_level = level;
Michał Kępieńbd079a22017-04-05 08:49:04 +0200214
Jonathan Woithed0482532007-08-29 15:58:19 +0930215 return 0;
216}
217
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200218static int get_lcd_level(struct acpi_device *device)
Jonathan Woithed0482532007-08-29 15:58:19 +0930219{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200220 struct fujitsu_bl *priv = acpi_driver_data(device);
Matthew Wilcox27663c52008-10-10 02:22:59 -0400221 unsigned long long state = 0;
Jonathan Woithed0482532007-08-29 15:58:19 +0930222 acpi_status status = AE_OK;
223
Michał Kępieńeee77da12017-06-16 06:40:58 +0200224 acpi_handle_debug(device->handle, "get lcd level via GBLL\n");
Jonathan Woithe20b93732008-06-11 10:14:56 +0930225
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200226 status = acpi_evaluate_integer(device->handle, "GBLL", NULL, &state);
Jonathan Woithe3b1c37c2009-12-23 09:19:42 +1030227 if (ACPI_FAILURE(status))
228 return 0;
Jonathan Woithed0482532007-08-29 15:58:19 +0930229
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200230 priv->brightness_level = state & 0x0fffffff;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930231
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200232 return priv->brightness_level;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930233}
234
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200235static int get_max_brightness(struct acpi_device *device)
Jonathan Woithe20b93732008-06-11 10:14:56 +0930236{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200237 struct fujitsu_bl *priv = acpi_driver_data(device);
Matthew Wilcox27663c52008-10-10 02:22:59 -0400238 unsigned long long state = 0;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930239 acpi_status status = AE_OK;
240
Michał Kępieńeee77da12017-06-16 06:40:58 +0200241 acpi_handle_debug(device->handle, "get max lcd level via RBLL\n");
Jonathan Woithe20b93732008-06-11 10:14:56 +0930242
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200243 status = acpi_evaluate_integer(device->handle, "RBLL", NULL, &state);
Jonathan Woithe3b1c37c2009-12-23 09:19:42 +1030244 if (ACPI_FAILURE(status))
245 return -1;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930246
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200247 priv->max_brightness = state;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930248
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200249 return priv->max_brightness;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930250}
251
Jonathan Woithed0482532007-08-29 15:58:19 +0930252/* Backlight device stuff */
253
254static int bl_get_brightness(struct backlight_device *b)
255{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200256 struct acpi_device *device = bl_get_data(b);
257
258 return b->props.power == FB_BLANK_POWERDOWN ? 0 : get_lcd_level(device);
Jonathan Woithed0482532007-08-29 15:58:19 +0930259}
260
261static int bl_update_status(struct backlight_device *b)
262{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200263 struct acpi_device *device = bl_get_data(b);
264
Ville Syrjäläcd6bf772017-09-18 23:00:59 +0300265 if (fext) {
266 if (b->props.power == FB_BLANK_POWERDOWN)
Michał Kępień2f60efa2018-02-20 06:24:53 +0100267 call_fext_func(fext, FUNC_BACKLIGHT, 0x1,
268 BACKLIGHT_PARAM_POWER, BACKLIGHT_OFF);
Ville Syrjäläcd6bf772017-09-18 23:00:59 +0300269 else
Michał Kępień2f60efa2018-02-20 06:24:53 +0100270 call_fext_func(fext, FUNC_BACKLIGHT, 0x1,
271 BACKLIGHT_PARAM_POWER, BACKLIGHT_ON);
Ville Syrjäläcd6bf772017-09-18 23:00:59 +0300272 }
Tony Vroon3a407082008-12-31 18:19:59 +0000273
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200274 return set_lcd_level(device, b->props.brightness);
Jonathan Woithed0482532007-08-29 15:58:19 +0930275}
276
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100277static const struct backlight_ops fujitsu_bl_ops = {
Jonathan Woithed0482532007-08-29 15:58:19 +0930278 .get_brightness = bl_get_brightness,
279 .update_status = bl_update_status,
280};
281
Michał Kępieńb0c4b9c2017-03-14 11:26:28 +0100282static ssize_t lid_show(struct device *dev, struct device_attribute *attr,
283 char *buf)
Tony Vroon3a407082008-12-31 18:19:59 +0000284{
Michał Kępieńd659d112017-05-19 09:44:48 +0200285 struct fujitsu_laptop *priv = dev_get_drvdata(dev);
286
287 if (!(priv->flags_supported & FLAG_LID))
Tony Vroon3a407082008-12-31 18:19:59 +0000288 return sprintf(buf, "unknown\n");
Michał Kępieńd659d112017-05-19 09:44:48 +0200289 if (priv->flags_state & FLAG_LID)
Tony Vroon3a407082008-12-31 18:19:59 +0000290 return sprintf(buf, "open\n");
291 else
292 return sprintf(buf, "closed\n");
293}
294
Michał Kępieńb0c4b9c2017-03-14 11:26:28 +0100295static ssize_t dock_show(struct device *dev, struct device_attribute *attr,
296 char *buf)
Tony Vroon3a407082008-12-31 18:19:59 +0000297{
Michał Kępieńd659d112017-05-19 09:44:48 +0200298 struct fujitsu_laptop *priv = dev_get_drvdata(dev);
299
300 if (!(priv->flags_supported & FLAG_DOCK))
Tony Vroon3a407082008-12-31 18:19:59 +0000301 return sprintf(buf, "unknown\n");
Michał Kępieńd659d112017-05-19 09:44:48 +0200302 if (priv->flags_state & FLAG_DOCK)
Tony Vroon3a407082008-12-31 18:19:59 +0000303 return sprintf(buf, "docked\n");
304 else
305 return sprintf(buf, "undocked\n");
306}
307
Michał Kępieńb0c4b9c2017-03-14 11:26:28 +0100308static ssize_t radios_show(struct device *dev, struct device_attribute *attr,
309 char *buf)
Tony Vroon3a407082008-12-31 18:19:59 +0000310{
Michał Kępieńd659d112017-05-19 09:44:48 +0200311 struct fujitsu_laptop *priv = dev_get_drvdata(dev);
312
313 if (!(priv->flags_supported & FLAG_RFKILL))
Tony Vroon3a407082008-12-31 18:19:59 +0000314 return sprintf(buf, "unknown\n");
Michał Kępieńd659d112017-05-19 09:44:48 +0200315 if (priv->flags_state & FLAG_RFKILL)
Tony Vroon3a407082008-12-31 18:19:59 +0000316 return sprintf(buf, "on\n");
317 else
318 return sprintf(buf, "killed\n");
319}
320
Michał Kępieńb0c4b9c2017-03-14 11:26:28 +0100321static DEVICE_ATTR_RO(lid);
322static DEVICE_ATTR_RO(dock);
323static DEVICE_ATTR_RO(radios);
Jonathan Woithed0482532007-08-29 15:58:19 +0930324
Alan Jenkins16506022017-02-08 14:46:26 +0100325static struct attribute *fujitsu_pf_attributes[] = {
Tony Vroon3a407082008-12-31 18:19:59 +0000326 &dev_attr_lid.attr,
327 &dev_attr_dock.attr,
328 &dev_attr_radios.attr,
Jonathan Woithed0482532007-08-29 15:58:19 +0930329 NULL
330};
331
Arvind Yadavee56ff72017-07-11 16:18:14 +0530332static const struct attribute_group fujitsu_pf_attribute_group = {
Alan Jenkins16506022017-02-08 14:46:26 +0100333 .attrs = fujitsu_pf_attributes
Jonathan Woithed0482532007-08-29 15:58:19 +0930334};
335
Alan Jenkins16506022017-02-08 14:46:26 +0100336static struct platform_driver fujitsu_pf_driver = {
Jonathan Woithed0482532007-08-29 15:58:19 +0930337 .driver = {
338 .name = "fujitsu-laptop",
Jonathan Woithed0482532007-08-29 15:58:19 +0930339 }
340};
341
Jonathan Woithe20b93732008-06-11 10:14:56 +0930342/* ACPI device for LCD brightness control */
Jonathan Woithed0482532007-08-29 15:58:19 +0930343
Michał Kępieńf2252672017-03-20 10:32:19 +0100344static const struct key_entry keymap_backlight[] = {
345 { KE_KEY, true, { KEY_BRIGHTNESSUP } },
346 { KE_KEY, false, { KEY_BRIGHTNESSDOWN } },
347 { KE_END, 0 }
348};
349
Michał Kępień7d134e42017-03-20 10:32:17 +0100350static int acpi_fujitsu_bl_input_setup(struct acpi_device *device)
351{
Michał Kępień7ec3b542017-05-19 09:44:41 +0200352 struct fujitsu_bl *priv = acpi_driver_data(device);
Michał Kępieńf2252672017-03-20 10:32:19 +0100353 int ret;
Michał Kępień7d134e42017-03-20 10:32:17 +0100354
Michał Kępień7ec3b542017-05-19 09:44:41 +0200355 priv->input = devm_input_allocate_device(&device->dev);
356 if (!priv->input)
Michał Kępień7d134e42017-03-20 10:32:17 +0100357 return -ENOMEM;
358
Michał Kępień7ec3b542017-05-19 09:44:41 +0200359 snprintf(priv->phys, sizeof(priv->phys), "%s/video/input0",
360 acpi_device_hid(device));
Michał Kępień7d134e42017-03-20 10:32:17 +0100361
Michał Kępień7ec3b542017-05-19 09:44:41 +0200362 priv->input->name = acpi_device_name(device);
363 priv->input->phys = priv->phys;
364 priv->input->id.bustype = BUS_HOST;
365 priv->input->id.product = 0x06;
Michał Kępieńf2252672017-03-20 10:32:19 +0100366
Michał Kępień7ec3b542017-05-19 09:44:41 +0200367 ret = sparse_keymap_setup(priv->input, keymap_backlight, NULL);
Michał Kępieńf2252672017-03-20 10:32:19 +0100368 if (ret)
369 return ret;
Michał Kępień7d134e42017-03-20 10:32:17 +0100370
Michał Kępień7ec3b542017-05-19 09:44:41 +0200371 return input_register_device(priv->input);
Michał Kępień7d134e42017-03-20 10:32:17 +0100372}
373
Michał Kępieńa1aabd52017-04-05 08:49:01 +0200374static int fujitsu_backlight_register(struct acpi_device *device)
Michał Kępieńb8d69c12017-03-10 11:50:33 +0100375{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200376 struct fujitsu_bl *priv = acpi_driver_data(device);
Michał Kępieńa1aabd52017-04-05 08:49:01 +0200377 const struct backlight_properties props = {
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200378 .brightness = priv->brightness_level,
379 .max_brightness = priv->max_brightness - 1,
Michał Kępieńb8d69c12017-03-10 11:50:33 +0100380 .type = BACKLIGHT_PLATFORM
381 };
382 struct backlight_device *bd;
383
Michał Kępieńa1aabd52017-04-05 08:49:01 +0200384 bd = devm_backlight_device_register(&device->dev, "fujitsu-laptop",
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200385 &device->dev, device,
Michał Kępieńa1aabd52017-04-05 08:49:01 +0200386 &fujitsu_bl_ops, &props);
Michał Kępieńb8d69c12017-03-10 11:50:33 +0100387 if (IS_ERR(bd))
388 return PTR_ERR(bd);
389
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200390 priv->bl_device = bd;
Michał Kępieńb8d69c12017-03-10 11:50:33 +0100391
392 return 0;
393}
394
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100395static int acpi_fujitsu_bl_add(struct acpi_device *device)
Jonathan Woithed0482532007-08-29 15:58:19 +0930396{
Michał Kępień679374e2017-05-19 09:44:42 +0200397 struct fujitsu_bl *priv;
Michał Kępień14966e02018-02-11 22:07:21 +0100398 int ret;
Jonathan Woithed0482532007-08-29 15:58:19 +0930399
Michał Kępień07acf622017-04-05 08:49:00 +0200400 if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
401 return -ENODEV;
402
Michał Kępień679374e2017-05-19 09:44:42 +0200403 priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL);
404 if (!priv)
405 return -ENOMEM;
406
407 fujitsu_bl = priv;
Michał Kępieńd6a298a2017-06-16 06:40:54 +0200408 strcpy(acpi_device_name(device), ACPI_FUJITSU_BL_DEVICE_NAME);
409 strcpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
Michał Kępień679374e2017-05-19 09:44:42 +0200410 device->driver_data = priv;
Jonathan Woithed0482532007-08-29 15:58:19 +0930411
Michał Kępień1c194622017-06-16 06:40:56 +0200412 pr_info("ACPI: %s [%s]\n",
413 acpi_device_name(device), acpi_device_bid(device));
Jonathan Woithed0482532007-08-29 15:58:19 +0930414
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200415 if (get_max_brightness(device) <= 0)
416 priv->max_brightness = FUJITSU_LCD_N_LEVELS;
417 get_lcd_level(device);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930418
Michał Kępieńa7a1ccbe2018-02-11 22:07:22 +0100419 ret = acpi_fujitsu_bl_input_setup(device);
420 if (ret)
421 return ret;
422
Michał Kępień7f83d412018-02-11 22:07:23 +0100423 return fujitsu_backlight_register(device);
Jonathan Woithed0482532007-08-29 15:58:19 +0930424}
425
Jonathan Woithe20b93732008-06-11 10:14:56 +0930426/* Brightness notify */
427
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100428static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event)
Jonathan Woithe20b93732008-06-11 10:14:56 +0930429{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200430 struct fujitsu_bl *priv = acpi_driver_data(device);
Michał Kępieńf2252672017-03-20 10:32:19 +0100431 int oldb, newb;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930432
Michał Kępień819cdda2018-02-20 06:24:54 +0100433 if (event != ACPI_FUJITSU_NOTIFY_CODE) {
Michał Kępieńeee77da12017-06-16 06:40:58 +0200434 acpi_handle_info(device->handle, "unsupported event [0x%x]\n",
435 event);
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200436 sparse_keymap_report_event(priv->input, -1, 1, true);
Michał Kępień5efc8002017-03-01 07:42:53 +0100437 return;
438 }
439
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200440 oldb = priv->brightness_level;
441 get_lcd_level(device);
442 newb = priv->brightness_level;
Michał Kępień5efc8002017-03-01 07:42:53 +0100443
Michał Kępieńeee77da12017-06-16 06:40:58 +0200444 acpi_handle_debug(device->handle,
445 "brightness button event [%i -> %i]\n", oldb, newb);
Michał Kępień5efc8002017-03-01 07:42:53 +0100446
Michał Kępieńd2aa3ae2017-03-01 07:42:54 +0100447 if (oldb == newb)
448 return;
449
Michał Kępieńb4bb0cf2017-04-05 08:49:06 +0200450 if (!disable_brightness_adjust)
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200451 set_lcd_level(device, newb);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930452
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200453 sparse_keymap_report_event(priv->input, oldb < newb, 1, true);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930454}
455
456/* ACPI device for hotkey handling */
457
Michał Kępień527483a2017-03-20 10:32:22 +0100458static const struct key_entry keymap_default[] = {
459 { KE_KEY, KEY1_CODE, { KEY_PROG1 } },
460 { KE_KEY, KEY2_CODE, { KEY_PROG2 } },
461 { KE_KEY, KEY3_CODE, { KEY_PROG3 } },
462 { KE_KEY, KEY4_CODE, { KEY_PROG4 } },
463 { KE_KEY, KEY5_CODE, { KEY_RFKILL } },
Jan-Marek Glogowski797195a2018-02-12 13:08:51 +0100464 { KE_KEY, BIT(5), { KEY_RFKILL } },
Michał Kępień527483a2017-03-20 10:32:22 +0100465 { KE_KEY, BIT(26), { KEY_TOUCHPAD_TOGGLE } },
Jan-Marek Glogowski797195a2018-02-12 13:08:51 +0100466 { KE_KEY, BIT(29), { KEY_MICMUTE } },
Michał Kępień527483a2017-03-20 10:32:22 +0100467 { KE_END, 0 }
468};
469
Michał Kępieńf8c94ec2017-03-20 10:32:23 +0100470static const struct key_entry keymap_s64x0[] = {
471 { KE_KEY, KEY1_CODE, { KEY_SCREENLOCK } }, /* "Lock" */
472 { KE_KEY, KEY2_CODE, { KEY_HELP } }, /* "Mobility Center */
473 { KE_KEY, KEY3_CODE, { KEY_PROG3 } },
474 { KE_KEY, KEY4_CODE, { KEY_PROG4 } },
475 { KE_END, 0 }
476};
477
478static const struct key_entry keymap_p8010[] = {
479 { KE_KEY, KEY1_CODE, { KEY_HELP } }, /* "Support" */
480 { KE_KEY, KEY2_CODE, { KEY_PROG2 } },
481 { KE_KEY, KEY3_CODE, { KEY_SWITCHVIDEOMODE } }, /* "Presentation" */
482 { KE_KEY, KEY4_CODE, { KEY_WWW } }, /* "WWW" */
483 { KE_END, 0 }
484};
485
Michał Kępień527483a2017-03-20 10:32:22 +0100486static const struct key_entry *keymap = keymap_default;
487
Michał Kępieńf8c94ec2017-03-20 10:32:23 +0100488static int fujitsu_laptop_dmi_keymap_override(const struct dmi_system_id *id)
489{
490 pr_info("Identified laptop model '%s'\n", id->ident);
491 keymap = id->driver_data;
492 return 1;
493}
494
495static const struct dmi_system_id fujitsu_laptop_dmi_table[] = {
496 {
497 .callback = fujitsu_laptop_dmi_keymap_override,
498 .ident = "Fujitsu Siemens S6410",
499 .matches = {
500 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
501 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6410"),
502 },
503 .driver_data = (void *)keymap_s64x0
504 },
505 {
506 .callback = fujitsu_laptop_dmi_keymap_override,
507 .ident = "Fujitsu Siemens S6420",
508 .matches = {
509 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
510 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6420"),
511 },
512 .driver_data = (void *)keymap_s64x0
513 },
514 {
515 .callback = fujitsu_laptop_dmi_keymap_override,
516 .ident = "Fujitsu LifeBook P8010",
517 .matches = {
518 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
519 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P8010"),
520 },
521 .driver_data = (void *)keymap_p8010
522 },
523 {}
524};
525
Michał Kępień11182db2017-03-20 10:32:20 +0100526static int acpi_fujitsu_laptop_input_setup(struct acpi_device *device)
527{
Michał Kępień7ec3b542017-05-19 09:44:41 +0200528 struct fujitsu_laptop *priv = acpi_driver_data(device);
Michał Kępień527483a2017-03-20 10:32:22 +0100529 int ret;
Michał Kępień11182db2017-03-20 10:32:20 +0100530
Michał Kępień7ec3b542017-05-19 09:44:41 +0200531 priv->input = devm_input_allocate_device(&device->dev);
532 if (!priv->input)
Michał Kępień11182db2017-03-20 10:32:20 +0100533 return -ENOMEM;
534
Michał Kępieńc1f51f12017-06-16 06:40:55 +0200535 snprintf(priv->phys, sizeof(priv->phys), "%s/input0",
Michał Kępień7ec3b542017-05-19 09:44:41 +0200536 acpi_device_hid(device));
Michał Kępień11182db2017-03-20 10:32:20 +0100537
Michał Kępień7ec3b542017-05-19 09:44:41 +0200538 priv->input->name = acpi_device_name(device);
539 priv->input->phys = priv->phys;
540 priv->input->id.bustype = BUS_HOST;
Michał Kępień11182db2017-03-20 10:32:20 +0100541
Michał Kępieńf8c94ec2017-03-20 10:32:23 +0100542 dmi_check_system(fujitsu_laptop_dmi_table);
Michał Kępień7ec3b542017-05-19 09:44:41 +0200543 ret = sparse_keymap_setup(priv->input, keymap, NULL);
Michał Kępień527483a2017-03-20 10:32:22 +0100544 if (ret)
545 return ret;
Michał Kępień11182db2017-03-20 10:32:20 +0100546
Michał Kępień7ec3b542017-05-19 09:44:41 +0200547 return input_register_device(priv->input);
Michał Kępień11182db2017-03-20 10:32:20 +0100548}
549
Michał Kępieńd659d112017-05-19 09:44:48 +0200550static int fujitsu_laptop_platform_add(struct acpi_device *device)
Michał Kępieńd811b512017-03-14 11:26:29 +0100551{
Michał Kępieńd659d112017-05-19 09:44:48 +0200552 struct fujitsu_laptop *priv = acpi_driver_data(device);
Michał Kępieńd811b512017-03-14 11:26:29 +0100553 int ret;
554
Michał Kępieńd659d112017-05-19 09:44:48 +0200555 priv->pf_device = platform_device_alloc("fujitsu-laptop", -1);
556 if (!priv->pf_device)
Michał Kępieńd811b512017-03-14 11:26:29 +0100557 return -ENOMEM;
558
Michał Kępieńd659d112017-05-19 09:44:48 +0200559 platform_set_drvdata(priv->pf_device, priv);
560
561 ret = platform_device_add(priv->pf_device);
Michał Kępieńd811b512017-03-14 11:26:29 +0100562 if (ret)
563 goto err_put_platform_device;
564
Michał Kępieńd659d112017-05-19 09:44:48 +0200565 ret = sysfs_create_group(&priv->pf_device->dev.kobj,
Michał Kępieńd811b512017-03-14 11:26:29 +0100566 &fujitsu_pf_attribute_group);
567 if (ret)
568 goto err_del_platform_device;
569
570 return 0;
571
572err_del_platform_device:
Michał Kępieńd659d112017-05-19 09:44:48 +0200573 platform_device_del(priv->pf_device);
Michał Kępieńd811b512017-03-14 11:26:29 +0100574err_put_platform_device:
Michał Kępieńd659d112017-05-19 09:44:48 +0200575 platform_device_put(priv->pf_device);
Michał Kępieńd811b512017-03-14 11:26:29 +0100576
577 return ret;
578}
579
Michał Kępieńd659d112017-05-19 09:44:48 +0200580static void fujitsu_laptop_platform_remove(struct acpi_device *device)
Michał Kępieńd811b512017-03-14 11:26:29 +0100581{
Michał Kępieńd659d112017-05-19 09:44:48 +0200582 struct fujitsu_laptop *priv = acpi_driver_data(device);
583
584 sysfs_remove_group(&priv->pf_device->dev.kobj,
Michał Kępieńd811b512017-03-14 11:26:29 +0100585 &fujitsu_pf_attribute_group);
Michał Kępieńd659d112017-05-19 09:44:48 +0200586 platform_device_unregister(priv->pf_device);
Michał Kępieńd811b512017-03-14 11:26:29 +0100587}
588
Michał Kępieńe33ca452017-04-07 15:07:10 +0200589static int logolamp_set(struct led_classdev *cdev,
590 enum led_brightness brightness)
591{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200592 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200593 int poweron = FUNC_LED_ON, always = FUNC_LED_ON;
594 int ret;
595
596 if (brightness < LED_HALF)
597 poweron = FUNC_LED_OFF;
598
599 if (brightness < LED_FULL)
600 always = FUNC_LED_OFF;
601
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200602 ret = call_fext_func(device, FUNC_LEDS, 0x1, LOGOLAMP_POWERON, poweron);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200603 if (ret < 0)
604 return ret;
605
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200606 return call_fext_func(device, FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, always);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200607}
608
609static enum led_brightness logolamp_get(struct led_classdev *cdev)
610{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200611 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200612 int ret;
613
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200614 ret = call_fext_func(device, FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200615 if (ret == FUNC_LED_ON)
616 return LED_FULL;
617
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200618 ret = call_fext_func(device, FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200619 if (ret == FUNC_LED_ON)
620 return LED_HALF;
621
622 return LED_OFF;
623}
624
Michał Kępieńe33ca452017-04-07 15:07:10 +0200625static int kblamps_set(struct led_classdev *cdev,
626 enum led_brightness brightness)
627{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200628 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
629
Michał Kępieńe33ca452017-04-07 15:07:10 +0200630 if (brightness >= LED_FULL)
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200631 return call_fext_func(device, FUNC_LEDS, 0x1, KEYBOARD_LAMPS,
Michał Kępieńe33ca452017-04-07 15:07:10 +0200632 FUNC_LED_ON);
633 else
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200634 return call_fext_func(device, FUNC_LEDS, 0x1, KEYBOARD_LAMPS,
Michał Kępieńe33ca452017-04-07 15:07:10 +0200635 FUNC_LED_OFF);
636}
637
638static enum led_brightness kblamps_get(struct led_classdev *cdev)
639{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200640 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200641 enum led_brightness brightness = LED_OFF;
642
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200643 if (call_fext_func(device,
Michał Kępień84631e02017-05-19 09:44:46 +0200644 FUNC_LEDS, 0x2, KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON)
Michał Kępieńe33ca452017-04-07 15:07:10 +0200645 brightness = LED_FULL;
646
647 return brightness;
648}
649
Michał Kępieńe33ca452017-04-07 15:07:10 +0200650static int radio_led_set(struct led_classdev *cdev,
651 enum led_brightness brightness)
652{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200653 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
654
Michał Kępieńe33ca452017-04-07 15:07:10 +0200655 if (brightness >= LED_FULL)
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200656 return call_fext_func(device, FUNC_FLAGS, 0x5, RADIO_LED_ON,
Michał Kępieńe33ca452017-04-07 15:07:10 +0200657 RADIO_LED_ON);
658 else
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200659 return call_fext_func(device, FUNC_FLAGS, 0x5, RADIO_LED_ON,
Michał Kępień84631e02017-05-19 09:44:46 +0200660 0x0);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200661}
662
663static enum led_brightness radio_led_get(struct led_classdev *cdev)
664{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200665 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200666 enum led_brightness brightness = LED_OFF;
667
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200668 if (call_fext_func(device, FUNC_FLAGS, 0x4, 0x0, 0x0) & RADIO_LED_ON)
Michał Kępieńe33ca452017-04-07 15:07:10 +0200669 brightness = LED_FULL;
670
671 return brightness;
672}
673
Michał Kępieńe33ca452017-04-07 15:07:10 +0200674static int eco_led_set(struct led_classdev *cdev,
675 enum led_brightness brightness)
676{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200677 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200678 int curr;
679
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200680 curr = call_fext_func(device, FUNC_LEDS, 0x2, ECO_LED, 0x0);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200681 if (brightness >= LED_FULL)
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200682 return call_fext_func(device, FUNC_LEDS, 0x1, ECO_LED,
Michał Kępieńe33ca452017-04-07 15:07:10 +0200683 curr | ECO_LED_ON);
684 else
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200685 return call_fext_func(device, FUNC_LEDS, 0x1, ECO_LED,
Michał Kępieńe33ca452017-04-07 15:07:10 +0200686 curr & ~ECO_LED_ON);
687}
688
689static enum led_brightness eco_led_get(struct led_classdev *cdev)
690{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200691 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200692 enum led_brightness brightness = LED_OFF;
693
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200694 if (call_fext_func(device, FUNC_LEDS, 0x2, ECO_LED, 0x0) & ECO_LED_ON)
Michał Kępieńe33ca452017-04-07 15:07:10 +0200695 brightness = LED_FULL;
696
697 return brightness;
698}
699
Michał Kępień81f68212017-04-07 15:07:11 +0200700static int acpi_fujitsu_laptop_leds_register(struct acpi_device *device)
Jonathan Woithe20b93732008-06-11 10:14:56 +0930701{
Michał Kępieńc7b3e982017-10-25 06:29:46 +0200702 struct fujitsu_laptop *priv = acpi_driver_data(device);
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200703 struct led_classdev *led;
Michał Kępień14966e02018-02-11 22:07:21 +0100704 int ret;
Michał Kępień7adb7b12017-04-07 15:07:09 +0200705
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200706 if (call_fext_func(device,
Michał Kępień84631e02017-05-19 09:44:46 +0200707 FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) {
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200708 led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL);
Gustavo A. R. Silvab77a5372017-07-06 17:19:02 -0500709 if (!led)
710 return -ENOMEM;
711
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200712 led->name = "fujitsu::logolamp";
713 led->brightness_set_blocking = logolamp_set;
714 led->brightness_get = logolamp_get;
Michał Kępień14966e02018-02-11 22:07:21 +0100715 ret = devm_led_classdev_register(&device->dev, led);
716 if (ret)
717 return ret;
Michał Kępień7adb7b12017-04-07 15:07:09 +0200718 }
719
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200720 if ((call_fext_func(device,
Michał Kępień84631e02017-05-19 09:44:46 +0200721 FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) &&
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200722 (call_fext_func(device, FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) {
723 led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL);
Gustavo A. R. Silvab77a5372017-07-06 17:19:02 -0500724 if (!led)
725 return -ENOMEM;
726
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200727 led->name = "fujitsu::kblamps";
728 led->brightness_set_blocking = kblamps_set;
729 led->brightness_get = kblamps_get;
Michał Kępień14966e02018-02-11 22:07:21 +0100730 ret = devm_led_classdev_register(&device->dev, led);
731 if (ret)
732 return ret;
Michał Kępień7adb7b12017-04-07 15:07:09 +0200733 }
734
735 /*
Michał Kępieńc7b3e982017-10-25 06:29:46 +0200736 * Some Fujitsu laptops have a radio toggle button in place of a slide
737 * switch and all such machines appear to also have an RF LED. Based on
738 * comparing DSDT tables of four Fujitsu Lifebook models (E744, E751,
739 * S7110, S8420; the first one has a radio toggle button, the other
740 * three have slide switches), bit 17 of flags_supported (the value
741 * returned by method S000 of ACPI device FUJ02E3) seems to indicate
742 * whether given model has a radio toggle button.
Michał Kępień7adb7b12017-04-07 15:07:09 +0200743 */
Michał Kępieńc7b3e982017-10-25 06:29:46 +0200744 if (priv->flags_supported & BIT(17)) {
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200745 led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL);
Gustavo A. R. Silvab77a5372017-07-06 17:19:02 -0500746 if (!led)
747 return -ENOMEM;
748
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200749 led->name = "fujitsu::radio_led";
750 led->brightness_set_blocking = radio_led_set;
751 led->brightness_get = radio_led_get;
752 led->default_trigger = "rfkill-any";
Michał Kępień14966e02018-02-11 22:07:21 +0100753 ret = devm_led_classdev_register(&device->dev, led);
754 if (ret)
755 return ret;
Michał Kępień7adb7b12017-04-07 15:07:09 +0200756 }
757
758 /* Support for eco led is not always signaled in bit corresponding
759 * to the bit used to control the led. According to the DSDT table,
760 * bit 14 seems to indicate presence of said led as well.
761 * Confirm by testing the status.
762 */
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200763 if ((call_fext_func(device, FUNC_LEDS, 0x0, 0x0, 0x0) & BIT(14)) &&
764 (call_fext_func(device,
Michał Kępień84631e02017-05-19 09:44:46 +0200765 FUNC_LEDS, 0x2, ECO_LED, 0x0) != UNSUPPORTED_CMD)) {
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200766 led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL);
Gustavo A. R. Silvab77a5372017-07-06 17:19:02 -0500767 if (!led)
768 return -ENOMEM;
769
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200770 led->name = "fujitsu::eco_led";
771 led->brightness_set_blocking = eco_led_set;
772 led->brightness_get = eco_led_get;
Michał Kępień14966e02018-02-11 22:07:21 +0100773 ret = devm_led_classdev_register(&device->dev, led);
774 if (ret)
775 return ret;
Michał Kępień7adb7b12017-04-07 15:07:09 +0200776 }
777
Michał Kępień30943e12017-04-07 15:07:12 +0200778 return 0;
Michał Kępień7adb7b12017-04-07 15:07:09 +0200779}
780
781static int acpi_fujitsu_laptop_add(struct acpi_device *device)
782{
Michał Kępieńa4b176e2017-05-19 09:44:44 +0200783 struct fujitsu_laptop *priv;
Michał Kępień14966e02018-02-11 22:07:21 +0100784 int ret, i = 0;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930785
Michał Kępieńa4b176e2017-05-19 09:44:44 +0200786 priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL);
787 if (!priv)
788 return -ENOMEM;
789
Michał Kępieńca0d9ea2017-05-19 09:44:45 +0200790 WARN_ONCE(fext, "More than one FUJ02E3 ACPI device was found. Driver may not work as intended.");
791 fext = device;
792
Michał Kępieńd6a298a2017-06-16 06:40:54 +0200793 strcpy(acpi_device_name(device), ACPI_FUJITSU_LAPTOP_DEVICE_NAME);
794 strcpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
Michał Kępieńa4b176e2017-05-19 09:44:44 +0200795 device->driver_data = priv;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930796
Jonathan Woithe20b93732008-06-11 10:14:56 +0930797 /* kfifo */
Michał Kępieńd659d112017-05-19 09:44:48 +0200798 spin_lock_init(&priv->fifo_lock);
Michał Kępień14966e02018-02-11 22:07:21 +0100799 ret = kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int),
800 GFP_KERNEL);
Michał Kępień7f83d412018-02-11 22:07:23 +0100801 if (ret)
802 return ret;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930803
Michał Kępień1c194622017-06-16 06:40:56 +0200804 pr_info("ACPI: %s [%s]\n",
805 acpi_device_name(device), acpi_device_bid(device));
Jonathan Woithe20b93732008-06-11 10:14:56 +0930806
Michał Kępień14966e02018-02-11 22:07:21 +0100807 while (call_fext_func(device, FUNC_BUTTONS, 0x1, 0x0, 0x0) != 0 &&
808 i++ < MAX_HOTKEY_RINGBUFFER_SIZE)
Tony Vroon3a407082008-12-31 18:19:59 +0000809 ; /* No action, result is discarded */
Michał Kępieńeee77da12017-06-16 06:40:58 +0200810 acpi_handle_debug(device->handle, "Discarded %i ringbuffer entries\n",
811 i);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930812
Michał Kępieńd659d112017-05-19 09:44:48 +0200813 priv->flags_supported = call_fext_func(device, FUNC_FLAGS, 0x0, 0x0,
814 0x0);
Tony Vroon4898c2b2009-02-02 11:11:10 +0000815
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ńd659d112017-05-19 09:44:48 +0200818 if (priv->flags_supported == UNSUPPORTED_CMD)
819 priv->flags_supported = 0;
Tony Vroon4898c2b2009-02-02 11:11:10 +0000820
Michał Kępieńd659d112017-05-19 09:44:48 +0200821 if (priv->flags_supported)
822 priv->flags_state = call_fext_func(device, FUNC_FLAGS, 0x4, 0x0,
823 0x0);
Tony Vroon3a407082008-12-31 18:19:59 +0000824
825 /* Suspect this is a keymap of the application panel, print it */
Michał Kępieńeee77da12017-06-16 06:40:58 +0200826 acpi_handle_info(device->handle, "BTNI: [0x%x]\n",
827 call_fext_func(device, FUNC_BUTTONS, 0x0, 0x0, 0x0));
Tony Vroon3a407082008-12-31 18:19:59 +0000828
Michał Kępień1877e262017-03-10 11:50:34 +0100829 /* Sync backlight power status */
Michał Kępień679374e2017-05-19 09:44:42 +0200830 if (fujitsu_bl && fujitsu_bl->bl_device &&
Michał Kępieńaea31372017-03-10 11:50:35 +0100831 acpi_video_get_backlight_type() == acpi_backlight_vendor) {
Michał Kępień2f60efa2018-02-20 06:24:53 +0100832 if (call_fext_func(fext, FUNC_BACKLIGHT, 0x2,
833 BACKLIGHT_PARAM_POWER, 0x0) == BACKLIGHT_OFF)
Michał Kępień1877e262017-03-10 11:50:34 +0100834 fujitsu_bl->bl_device->props.power = FB_BLANK_POWERDOWN;
835 else
836 fujitsu_bl->bl_device->props.power = FB_BLANK_UNBLANK;
837 }
838
Michał Kępieńa7a1ccbe2018-02-11 22:07:22 +0100839 ret = acpi_fujitsu_laptop_input_setup(device);
840 if (ret)
841 goto err_free_fifo;
842
Michał Kępień14966e02018-02-11 22:07:21 +0100843 ret = acpi_fujitsu_laptop_leds_register(device);
844 if (ret)
Michał Kępieńd1c70732017-04-07 15:07:13 +0200845 goto err_free_fifo;
846
Michał Kępień14966e02018-02-11 22:07:21 +0100847 ret = fujitsu_laptop_platform_add(device);
848 if (ret)
Michał Kępieńf66735f2017-03-20 10:32:21 +0100849 goto err_free_fifo;
Michał Kępieńc33f4c02017-03-14 11:26:30 +0100850
Michał Kępień7adb7b12017-04-07 15:07:09 +0200851 return 0;
Michał Kępień4f625682016-04-12 22:06:34 +0930852
Bjorn Helgaasb4ec0272009-04-07 15:37:22 +0000853err_free_fifo:
Michał Kępieńd659d112017-05-19 09:44:48 +0200854 kfifo_free(&priv->fifo);
Michał Kępień7f83d412018-02-11 22:07:23 +0100855
Michał Kępień14966e02018-02-11 22:07:21 +0100856 return ret;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930857}
858
Alan Jenkins6942eab2017-02-08 14:46:25 +0100859static int acpi_fujitsu_laptop_remove(struct acpi_device *device)
Jonathan Woithe20b93732008-06-11 10:14:56 +0930860{
Michał Kępień7ec3b542017-05-19 09:44:41 +0200861 struct fujitsu_laptop *priv = acpi_driver_data(device);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930862
Michał Kępieńd659d112017-05-19 09:44:48 +0200863 fujitsu_laptop_platform_remove(device);
Michał Kępieńc33f4c02017-03-14 11:26:30 +0100864
Michał Kępień7ec3b542017-05-19 09:44:41 +0200865 kfifo_free(&priv->fifo);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930866
867 return 0;
868}
869
Michał Kępieńd659d112017-05-19 09:44:48 +0200870static void acpi_fujitsu_laptop_press(struct acpi_device *device, int scancode)
Michał Kępień2451d192017-01-11 09:59:31 +0100871{
Michał Kępieńd659d112017-05-19 09:44:48 +0200872 struct fujitsu_laptop *priv = acpi_driver_data(device);
Michał Kępień14966e02018-02-11 22:07:21 +0100873 int ret;
Michał Kępień2451d192017-01-11 09:59:31 +0100874
Michał Kępień14966e02018-02-11 22:07:21 +0100875 ret = kfifo_in_locked(&priv->fifo, (unsigned char *)&scancode,
876 sizeof(scancode), &priv->fifo_lock);
877 if (ret != sizeof(scancode)) {
Michał Kępieńeee77da12017-06-16 06:40:58 +0200878 dev_info(&priv->input->dev, "Could not push scancode [0x%x]\n",
879 scancode);
Michał Kępieńa28c7e92017-01-11 09:59:33 +0100880 return;
Michał Kępień2451d192017-01-11 09:59:31 +0100881 }
Michał Kępieńd659d112017-05-19 09:44:48 +0200882 sparse_keymap_report_event(priv->input, scancode, 1, false);
Michał Kępieńeee77da12017-06-16 06:40:58 +0200883 dev_dbg(&priv->input->dev, "Push scancode into ringbuffer [0x%x]\n",
884 scancode);
Michał Kępień2451d192017-01-11 09:59:31 +0100885}
886
Michał Kępieńd659d112017-05-19 09:44:48 +0200887static void acpi_fujitsu_laptop_release(struct acpi_device *device)
Michał Kępień2451d192017-01-11 09:59:31 +0100888{
Michał Kępieńd659d112017-05-19 09:44:48 +0200889 struct fujitsu_laptop *priv = acpi_driver_data(device);
Michał Kępień14966e02018-02-11 22:07:21 +0100890 int scancode, ret;
Michał Kępień2451d192017-01-11 09:59:31 +0100891
Michał Kępień29544f02017-01-11 09:59:32 +0100892 while (true) {
Michał Kępień14966e02018-02-11 22:07:21 +0100893 ret = kfifo_out_locked(&priv->fifo, (unsigned char *)&scancode,
894 sizeof(scancode), &priv->fifo_lock);
895 if (ret != sizeof(scancode))
Michał Kępień29544f02017-01-11 09:59:32 +0100896 return;
Michał Kępieńd659d112017-05-19 09:44:48 +0200897 sparse_keymap_report_event(priv->input, scancode, 0, false);
Michał Kępieńeee77da12017-06-16 06:40:58 +0200898 dev_dbg(&priv->input->dev,
899 "Pop scancode from ringbuffer [0x%x]\n", scancode);
Michał Kępień2451d192017-01-11 09:59:31 +0100900 }
901}
902
Alan Jenkins6942eab2017-02-08 14:46:25 +0100903static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event)
Jonathan Woithe20b93732008-06-11 10:14:56 +0930904{
Michał Kępieńd659d112017-05-19 09:44:48 +0200905 struct fujitsu_laptop *priv = acpi_driver_data(device);
Jan-Marek Glogowski797195a2018-02-12 13:08:51 +0100906 int scancode, i = 0, ret;
Michał Kępień527483a2017-03-20 10:32:22 +0100907 unsigned int irb;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930908
Michał Kępień819cdda2018-02-20 06:24:54 +0100909 if (event != ACPI_FUJITSU_NOTIFY_CODE) {
Michał Kępieńeee77da12017-06-16 06:40:58 +0200910 acpi_handle_info(device->handle, "Unsupported event [0x%x]\n",
911 event);
Michał Kępieńd659d112017-05-19 09:44:48 +0200912 sparse_keymap_report_event(priv->input, -1, 1, true);
Michał Kępieńeb357cb2017-01-11 09:59:30 +0100913 return;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930914 }
Michał Kępieńeb357cb2017-01-11 09:59:30 +0100915
Michał Kępieńd659d112017-05-19 09:44:48 +0200916 if (priv->flags_supported)
917 priv->flags_state = call_fext_func(device, FUNC_FLAGS, 0x4, 0x0,
918 0x0);
Michał Kępieńeb357cb2017-01-11 09:59:30 +0100919
Michał Kępieńd659d112017-05-19 09:44:48 +0200920 while ((irb = call_fext_func(device,
Michał Kępień84631e02017-05-19 09:44:46 +0200921 FUNC_BUTTONS, 0x1, 0x0, 0x0)) != 0 &&
Michał Kępień527483a2017-03-20 10:32:22 +0100922 i++ < MAX_HOTKEY_RINGBUFFER_SIZE) {
923 scancode = irb & 0x4ff;
Michał Kępieńd659d112017-05-19 09:44:48 +0200924 if (sparse_keymap_entry_from_scancode(priv->input, scancode))
925 acpi_fujitsu_laptop_press(device, scancode);
Michał Kępień527483a2017-03-20 10:32:22 +0100926 else if (scancode == 0)
Michał Kępieńd659d112017-05-19 09:44:48 +0200927 acpi_fujitsu_laptop_release(device);
Michał Kępień527483a2017-03-20 10:32:22 +0100928 else
Michał Kępieńeee77da12017-06-16 06:40:58 +0200929 acpi_handle_info(device->handle,
930 "Unknown GIRB result [%x]\n", irb);
Michał Kępieńeb357cb2017-01-11 09:59:30 +0100931 }
932
933 /* On some models (first seen on the Skylake-based Lifebook
934 * E736/E746/E756), the touchpad toggle hotkey (Fn+F4) is
Alan Jenkins8ef27bd2017-02-08 14:46:27 +0100935 * handled in software; its state is queried using FUNC_FLAGS
Michał Kępieńeb357cb2017-01-11 09:59:30 +0100936 */
Jan-Marek Glogowski797195a2018-02-12 13:08:51 +0100937 if (priv->flags_supported & (BIT(5) | BIT(26) | BIT(29))) {
938 ret = call_fext_func(device, FUNC_FLAGS, 0x1, 0x0, 0x0);
939 if (ret & BIT(5))
940 sparse_keymap_report_event(priv->input,
941 BIT(5), 1, true);
942 if (ret & BIT(26))
943 sparse_keymap_report_event(priv->input,
944 BIT(26), 1, true);
945 if (ret & BIT(29))
946 sparse_keymap_report_event(priv->input,
947 BIT(29), 1, true);
948 }
Jonathan Woithe20b93732008-06-11 10:14:56 +0930949}
950
951/* Initialization */
952
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100953static const struct acpi_device_id fujitsu_bl_device_ids[] = {
954 {ACPI_FUJITSU_BL_HID, 0},
Jonathan Woithed0482532007-08-29 15:58:19 +0930955 {"", 0},
956};
957
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100958static struct acpi_driver acpi_fujitsu_bl_driver = {
959 .name = ACPI_FUJITSU_BL_DRIVER_NAME,
Jonathan Woithed0482532007-08-29 15:58:19 +0930960 .class = ACPI_FUJITSU_CLASS,
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100961 .ids = fujitsu_bl_device_ids,
Jonathan Woithed0482532007-08-29 15:58:19 +0930962 .ops = {
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100963 .add = acpi_fujitsu_bl_add,
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100964 .notify = acpi_fujitsu_bl_notify,
Jonathan Woithed0482532007-08-29 15:58:19 +0930965 },
966};
967
Alan Jenkins6942eab2017-02-08 14:46:25 +0100968static const struct acpi_device_id fujitsu_laptop_device_ids[] = {
969 {ACPI_FUJITSU_LAPTOP_HID, 0},
Jonathan Woithe20b93732008-06-11 10:14:56 +0930970 {"", 0},
971};
972
Alan Jenkins6942eab2017-02-08 14:46:25 +0100973static struct acpi_driver acpi_fujitsu_laptop_driver = {
974 .name = ACPI_FUJITSU_LAPTOP_DRIVER_NAME,
Jonathan Woithe20b93732008-06-11 10:14:56 +0930975 .class = ACPI_FUJITSU_CLASS,
Alan Jenkins6942eab2017-02-08 14:46:25 +0100976 .ids = fujitsu_laptop_device_ids,
Jonathan Woithe20b93732008-06-11 10:14:56 +0930977 .ops = {
Alan Jenkins6942eab2017-02-08 14:46:25 +0100978 .add = acpi_fujitsu_laptop_add,
979 .remove = acpi_fujitsu_laptop_remove,
980 .notify = acpi_fujitsu_laptop_notify,
Jonathan Woithe20b93732008-06-11 10:14:56 +0930981 },
982};
Jonathan Woithed0482532007-08-29 15:58:19 +0930983
Zhang Rui49901412014-09-09 00:21:59 +0200984static const struct acpi_device_id fujitsu_ids[] __used = {
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100985 {ACPI_FUJITSU_BL_HID, 0},
Alan Jenkins6942eab2017-02-08 14:46:25 +0100986 {ACPI_FUJITSU_LAPTOP_HID, 0},
Zhang Rui49901412014-09-09 00:21:59 +0200987 {"", 0}
988};
989MODULE_DEVICE_TABLE(acpi, fujitsu_ids);
990
Jonathan Woithed0482532007-08-29 15:58:19 +0930991static int __init fujitsu_init(void)
992{
Michał Kępieńb8d69c12017-03-10 11:50:33 +0100993 int ret;
Jonathan Woithed0482532007-08-29 15:58:19 +0930994
Alan Jenkinsc1d1e8a2017-02-08 14:46:30 +0100995 ret = acpi_bus_register_driver(&acpi_fujitsu_bl_driver);
996 if (ret)
Michał Kępień679374e2017-05-19 09:44:42 +0200997 return ret;
Jonathan Woithed0482532007-08-29 15:58:19 +0930998
Jonathan Woithed0482532007-08-29 15:58:19 +0930999 /* Register platform stuff */
1000
Alan Jenkins16506022017-02-08 14:46:26 +01001001 ret = platform_driver_register(&fujitsu_pf_driver);
Jonathan Woithe20b93732008-06-11 10:14:56 +09301002 if (ret)
Michał Kępieńc33f4c02017-03-14 11:26:30 +01001003 goto err_unregister_acpi;
Jonathan Woithe20b93732008-06-11 10:14:56 +09301004
Alan Jenkins6942eab2017-02-08 14:46:25 +01001005 /* Register laptop driver */
Jonathan Woithe20b93732008-06-11 10:14:56 +09301006
Alan Jenkinsc1d1e8a2017-02-08 14:46:30 +01001007 ret = acpi_bus_register_driver(&acpi_fujitsu_laptop_driver);
1008 if (ret)
Michał Kępieńa4b176e2017-05-19 09:44:44 +02001009 goto err_unregister_platform_driver;
Jonathan Woithe20b93732008-06-11 10:14:56 +09301010
Joe Perches77bad7c2011-03-29 15:21:39 -07001011 pr_info("driver " FUJITSU_DRIVER_VERSION " successfully loaded\n");
Jonathan Woithed0482532007-08-29 15:58:19 +09301012
1013 return 0;
1014
Michał Kępieńc2cddd42017-03-10 11:50:36 +01001015err_unregister_platform_driver:
Alan Jenkins16506022017-02-08 14:46:26 +01001016 platform_driver_unregister(&fujitsu_pf_driver);
Michał Kępieńc2cddd42017-03-10 11:50:36 +01001017err_unregister_acpi:
Alan Jenkins9fc5cf62017-02-08 14:46:24 +01001018 acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver);
Jonathan Woithed0482532007-08-29 15:58:19 +09301019
1020 return ret;
1021}
1022
1023static void __exit fujitsu_cleanup(void)
1024{
Alan Jenkins6942eab2017-02-08 14:46:25 +01001025 acpi_bus_unregister_driver(&acpi_fujitsu_laptop_driver);
Tony Vroon3a407082008-12-31 18:19:59 +00001026
Alan Jenkins16506022017-02-08 14:46:26 +01001027 platform_driver_unregister(&fujitsu_pf_driver);
Bartlomiej Zolnierkiewicz72afeea2009-07-31 18:16:02 +09301028
Alan Jenkins9fc5cf62017-02-08 14:46:24 +01001029 acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver);
Jonathan Woithed0482532007-08-29 15:58:19 +09301030
Joe Perches77bad7c2011-03-29 15:21:39 -07001031 pr_info("driver unloaded\n");
Jonathan Woithed0482532007-08-29 15:58:19 +09301032}
1033
1034module_init(fujitsu_init);
1035module_exit(fujitsu_cleanup);
1036
Michał Kępieńe06e4832017-04-05 08:49:05 +02001037module_param(use_alt_lcd_levels, int, 0644);
1038MODULE_PARM_DESC(use_alt_lcd_levels, "Interface used for setting LCD brightness level (-1 = auto, 0 = force SBLL, 1 = force SBL2)");
Michał Kępieńb4bb0cf2017-04-05 08:49:06 +02001039module_param(disable_brightness_adjust, bool, 0644);
1040MODULE_PARM_DESC(disable_brightness_adjust, "Disable LCD brightness adjustment");
Jonathan Woithe20b93732008-06-11 10:14:56 +09301041
Tony Vroon3a407082008-12-31 18:19:59 +00001042MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon");
Jonathan Woithed0482532007-08-29 15:58:19 +09301043MODULE_DESCRIPTION("Fujitsu laptop extras support");
1044MODULE_VERSION(FUJITSU_DRIVER_VERSION);
1045MODULE_LICENSE("GPL");