blob: 80929380ec7e33cf8af0a4a1ea1dcfea41ea2986 [file] [log] [blame]
Thomas Gleixner16216332019-05-19 15:51:31 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Jonathan Woithed0482532007-08-29 15:58:19 +09302/*-*-linux-c-*-*/
3
4/*
Jonathan Woithe409a3e92012-03-27 13:01:01 +10305 Copyright (C) 2007,2008 Jonathan Woithe <jwoithe@just42.net>
Jonathan Woithe20b93732008-06-11 10:14:56 +09306 Copyright (C) 2008 Peter Gruber <nokos@gmx.net>
Tony Vroon3a407082008-12-31 18:19:59 +00007 Copyright (C) 2008 Tony Vroon <tony@linx.net>
Jonathan Woithed0482532007-08-29 15:58:19 +09308 Based on earlier work:
9 Copyright (C) 2003 Shane Spencer <shane@bogomip.com>
10 Adrian Yee <brewt-fujitsu@brewt.org>
11
Jonathan Woithe20b93732008-06-11 10:14:56 +093012 Templated from msi-laptop.c and thinkpad_acpi.c which is copyright
13 by its respective authors.
Jonathan Woithed0482532007-08-29 15:58:19 +093014
Jonathan Woithed0482532007-08-29 15:58:19 +093015 */
16
17/*
18 * fujitsu-laptop.c - Fujitsu laptop support, providing access to additional
19 * features made available on a range of Fujitsu laptops including the
20 * P2xxx/P5xxx/S6xxx/S7xxx series.
21 *
Michał Kępień78b26022017-03-14 11:26:27 +010022 * This driver implements a vendor-specific backlight control interface for
23 * Fujitsu laptops and provides support for hotkeys present on certain Fujitsu
24 * laptops.
Jonathan Woithe20b93732008-06-11 10:14:56 +093025 *
Jonathan Woithe0e6a66e2008-10-09 13:44:40 +093026 * This driver has been tested on a Fujitsu Lifebook S6410, S7020 and
27 * P8010. It should work on most P-series and S-series Lifebooks, but
28 * YMMV.
Jonathan Woithe20b93732008-06-11 10:14:56 +093029 *
30 * The module parameter use_alt_lcd_levels switches between different ACPI
31 * brightness controls which are used by different Fujitsu laptops. In most
32 * cases the correct method is automatically detected. "use_alt_lcd_levels=1"
33 * is applicable for a Fujitsu Lifebook S6410 if autodetection fails.
34 *
Jonathan Woithed0482532007-08-29 15:58:19 +093035 */
36
Joe Perches77bad7c2011-03-29 15:21:39 -070037#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
38
Jonathan Woithed0482532007-08-29 15:58:19 +093039#include <linux/module.h>
40#include <linux/kernel.h>
41#include <linux/init.h>
42#include <linux/acpi.h>
Michał Kępień819cdda2018-02-20 06:24:54 +010043#include <linux/bitops.h>
Jonathan Woithed0482532007-08-29 15:58:19 +093044#include <linux/dmi.h>
45#include <linux/backlight.h>
Michael Karchere8549e22015-01-18 20:28:46 +010046#include <linux/fb.h>
Jonathan Woithe20b93732008-06-11 10:14:56 +093047#include <linux/input.h>
Michał Kępieńf2252672017-03-20 10:32:19 +010048#include <linux/input/sparse-keymap.h>
Jonathan Woithe20b93732008-06-11 10:14:56 +093049#include <linux/kfifo.h>
Michał Kępieńd89bcc82017-04-07 15:07:08 +020050#include <linux/leds.h>
Jonathan Woithed0482532007-08-29 15:58:19 +093051#include <linux/platform_device.h>
Hans de Goede413226f2015-06-16 16:28:03 +020052#include <acpi/video.h>
Jonathan Woithed0482532007-08-29 15:58:19 +093053
Michał Kępień819cdda2018-02-20 06:24:54 +010054#define FUJITSU_DRIVER_VERSION "0.6.0"
Jonathan Woithed0482532007-08-29 15:58:19 +093055
Michał Kępień819cdda2018-02-20 06:24:54 +010056#define FUJITSU_LCD_N_LEVELS 8
Jonathan Woithed0482532007-08-29 15:58:19 +093057
Alan Jenkins9fc5cf62017-02-08 14:46:24 +010058#define ACPI_FUJITSU_CLASS "fujitsu"
59#define ACPI_FUJITSU_BL_HID "FUJ02B1"
60#define ACPI_FUJITSU_BL_DRIVER_NAME "Fujitsu laptop FUJ02B1 ACPI brightness driver"
61#define ACPI_FUJITSU_BL_DEVICE_NAME "Fujitsu FUJ02B1"
Alan Jenkins6942eab2017-02-08 14:46:25 +010062#define ACPI_FUJITSU_LAPTOP_HID "FUJ02E3"
63#define ACPI_FUJITSU_LAPTOP_DRIVER_NAME "Fujitsu laptop FUJ02E3 ACPI hotkeys driver"
64#define ACPI_FUJITSU_LAPTOP_DEVICE_NAME "Fujitsu FUJ02E3"
Jonathan Woithed0482532007-08-29 15:58:19 +093065
Michał Kępień819cdda2018-02-20 06:24:54 +010066#define ACPI_FUJITSU_NOTIFY_CODE 0x80
Jonathan Woithe20b93732008-06-11 10:14:56 +093067
Tony Vroon3a407082008-12-31 18:19:59 +000068/* FUNC interface - command values */
Michał Kępień819cdda2018-02-20 06:24:54 +010069#define FUNC_FLAGS BIT(12)
70#define FUNC_LEDS (BIT(12) | BIT(0))
71#define FUNC_BUTTONS (BIT(12) | BIT(1))
72#define FUNC_BACKLIGHT (BIT(12) | BIT(2))
Tony Vroon3a407082008-12-31 18:19:59 +000073
74/* FUNC interface - responses */
Michał Kępień502ab002018-03-10 21:43:53 +010075#define UNSUPPORTED_CMD 0x80000000
Tony Vroon3a407082008-12-31 18:19:59 +000076
Alan Jenkinsd3dd4482017-02-08 14:46:28 +010077/* FUNC interface - status flags */
Michał Kępień819cdda2018-02-20 06:24:54 +010078#define FLAG_RFKILL BIT(5)
79#define FLAG_LID BIT(8)
80#define FLAG_DOCK BIT(9)
Darren Hart (VMware)de15b942018-03-22 18:11:22 -070081#define FLAG_TOUCHPAD_TOGGLE BIT(26)
82#define FLAG_MICMUTE BIT(29)
83#define FLAG_SOFTKEYS (FLAG_RFKILL | FLAG_TOUCHPAD_TOGGLE | FLAG_MICMUTE)
Alan Jenkinsd3dd4482017-02-08 14:46:28 +010084
Tony Vroon3a407082008-12-31 18:19:59 +000085/* FUNC interface - LED control */
Michał Kępień819cdda2018-02-20 06:24:54 +010086#define FUNC_LED_OFF BIT(0)
87#define FUNC_LED_ON (BIT(0) | BIT(16) | BIT(17))
88#define LOGOLAMP_POWERON BIT(13)
89#define LOGOLAMP_ALWAYS BIT(14)
90#define KEYBOARD_LAMPS BIT(8)
91#define RADIO_LED_ON BIT(5)
92#define ECO_LED BIT(16)
93#define ECO_LED_ON BIT(19)
Tony Vroon3a407082008-12-31 18:19:59 +000094
Michał Kępień2f60efa2018-02-20 06:24:53 +010095/* FUNC interface - backlight power control */
Michał Kępień819cdda2018-02-20 06:24:54 +010096#define BACKLIGHT_PARAM_POWER BIT(2)
97#define BACKLIGHT_OFF (BIT(0) | BIT(1))
98#define BACKLIGHT_ON 0
Michał Kępień2f60efa2018-02-20 06:24:53 +010099
Michał Kępień819cdda2018-02-20 06:24:54 +0100100/* Scancodes read from the GIRB register */
101#define KEY1_CODE 0x410
102#define KEY2_CODE 0x411
103#define KEY3_CODE 0x412
104#define KEY4_CODE 0x413
105#define KEY5_CODE 0x420
Jonathan Woithe20b93732008-06-11 10:14:56 +0930106
Michał Kępień819cdda2018-02-20 06:24:54 +0100107/* Hotkey ringbuffer limits */
108#define MAX_HOTKEY_RINGBUFFER_SIZE 100
109#define RINGBUFFERSIZE 40
Jonathan Woithe20b93732008-06-11 10:14:56 +0930110
Michał Kępień6cb11922018-02-11 22:07:24 +0100111/* Module parameters */
112static int use_alt_lcd_levels = -1;
113static bool disable_brightness_adjust;
114
Jonathan Woithe20b93732008-06-11 10:14:56 +0930115/* Device controlling the backlight and associated keys */
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100116struct fujitsu_bl {
Jonathan Woithe20b93732008-06-11 10:14:56 +0930117 struct input_dev *input;
118 char phys[32];
Jonathan Woithed0482532007-08-29 15:58:19 +0930119 struct backlight_device *bl_device;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930120 unsigned int max_brightness;
Jonathan Woithed0482532007-08-29 15:58:19 +0930121 unsigned int brightness_level;
122};
123
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100124static struct fujitsu_bl *fujitsu_bl;
Jonathan Woithed0482532007-08-29 15:58:19 +0930125
Alan Jenkins6942eab2017-02-08 14:46:25 +0100126/* Device used to access hotkeys and other features on the laptop */
127struct fujitsu_laptop {
Jonathan Woithe20b93732008-06-11 10:14:56 +0930128 struct input_dev *input;
129 char phys[32];
130 struct platform_device *pf_device;
Stefani Seibold45465482009-12-21 14:37:26 -0800131 struct kfifo fifo;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930132 spinlock_t fifo_lock;
Alan Jenkins8ef27bd2017-02-08 14:46:27 +0100133 int flags_supported;
134 int flags_state;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930135};
136
Michał Kępieńca0d9ea2017-05-19 09:44:45 +0200137static struct acpi_device *fext;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930138
Tony Vroon3a407082008-12-31 18:19:59 +0000139/* Fujitsu ACPI interface function */
140
Michał Kępień84631e02017-05-19 09:44:46 +0200141static int call_fext_func(struct acpi_device *device,
142 int func, int op, int feature, int state)
Tony Vroon3a407082008-12-31 18:19:59 +0000143{
Tony Vroon3a407082008-12-31 18:19:59 +0000144 union acpi_object params[4] = {
Michał Kępieńf68e4922017-04-03 11:38:59 +0200145 { .integer.type = ACPI_TYPE_INTEGER, .integer.value = func },
146 { .integer.type = ACPI_TYPE_INTEGER, .integer.value = op },
147 { .integer.type = ACPI_TYPE_INTEGER, .integer.value = feature },
148 { .integer.type = ACPI_TYPE_INTEGER, .integer.value = state }
Tony Vroon3a407082008-12-31 18:19:59 +0000149 };
Michał Kępieńb1066412017-04-03 11:38:57 +0200150 struct acpi_object_list arg_list = { 4, params };
Zhang Rui29c29a92013-09-03 08:32:12 +0800151 unsigned long long value;
Michał Kępieńb1066412017-04-03 11:38:57 +0200152 acpi_status status;
Tony Vroon3a407082008-12-31 18:19:59 +0000153
Michał Kępień84631e02017-05-19 09:44:46 +0200154 status = acpi_evaluate_integer(device->handle, "FUNC", &arg_list,
155 &value);
Tony Vroon3a407082008-12-31 18:19:59 +0000156 if (ACPI_FAILURE(status)) {
Michał Kępieńeee77da12017-06-16 06:40:58 +0200157 acpi_handle_err(device->handle, "Failed to evaluate FUNC\n");
Tony Vroon3a407082008-12-31 18:19:59 +0000158 return -ENODEV;
159 }
160
Michał Kępieńeee77da12017-06-16 06:40:58 +0200161 acpi_handle_debug(device->handle,
162 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n",
163 func, op, feature, state, (int)value);
Zhang Rui29c29a92013-09-03 08:32:12 +0800164 return value;
Tony Vroon3a407082008-12-31 18:19:59 +0000165}
166
Jonathan Woithe20b93732008-06-11 10:14:56 +0930167/* Hardware access for LCD brightness control */
Jonathan Woithed0482532007-08-29 15:58:19 +0930168
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200169static int set_lcd_level(struct acpi_device *device, int level)
Jonathan Woithed0482532007-08-29 15:58:19 +0930170{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200171 struct fujitsu_bl *priv = acpi_driver_data(device);
Michał Kępieńa8779c32017-04-05 08:49:03 +0200172 acpi_status status;
Michał Kępieńe32c50b2017-04-05 08:49:02 +0200173 char *method;
Jonathan Woithed0482532007-08-29 15:58:19 +0930174
Michał Kępieńe32c50b2017-04-05 08:49:02 +0200175 switch (use_alt_lcd_levels) {
Michał Kępieńe06e4832017-04-05 08:49:05 +0200176 case -1:
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200177 if (acpi_has_method(device->handle, "SBL2"))
Michał Kępieńe06e4832017-04-05 08:49:05 +0200178 method = "SBL2";
179 else
180 method = "SBLL";
181 break;
Michał Kępieńe32c50b2017-04-05 08:49:02 +0200182 case 1:
183 method = "SBL2";
184 break;
185 default:
186 method = "SBLL";
187 break;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930188 }
189
Michał Kępieńeee77da12017-06-16 06:40:58 +0200190 acpi_handle_debug(device->handle, "set lcd level via %s [%d]\n", method,
191 level);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930192
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200193 if (level < 0 || level >= priv->max_brightness)
Jonathan Woithe20b93732008-06-11 10:14:56 +0930194 return -EINVAL;
195
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200196 status = acpi_execute_simple_method(device->handle, method, level);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930197 if (ACPI_FAILURE(status)) {
Michał Kępieńeee77da12017-06-16 06:40:58 +0200198 acpi_handle_err(device->handle, "Failed to evaluate %s\n",
199 method);
Jonathan Woithed0482532007-08-29 15:58:19 +0930200 return -ENODEV;
201 }
202
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200203 priv->brightness_level = level;
Michał Kępieńbd079a22017-04-05 08:49:04 +0200204
Jonathan Woithed0482532007-08-29 15:58:19 +0930205 return 0;
206}
207
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200208static int get_lcd_level(struct acpi_device *device)
Jonathan Woithed0482532007-08-29 15:58:19 +0930209{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200210 struct fujitsu_bl *priv = acpi_driver_data(device);
Matthew Wilcox27663c52008-10-10 02:22:59 -0400211 unsigned long long state = 0;
Jonathan Woithed0482532007-08-29 15:58:19 +0930212 acpi_status status = AE_OK;
213
Michał Kępieńeee77da12017-06-16 06:40:58 +0200214 acpi_handle_debug(device->handle, "get lcd level via GBLL\n");
Jonathan Woithe20b93732008-06-11 10:14:56 +0930215
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200216 status = acpi_evaluate_integer(device->handle, "GBLL", NULL, &state);
Jonathan Woithe3b1c37c2009-12-23 09:19:42 +1030217 if (ACPI_FAILURE(status))
218 return 0;
Jonathan Woithed0482532007-08-29 15:58:19 +0930219
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200220 priv->brightness_level = state & 0x0fffffff;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930221
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200222 return priv->brightness_level;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930223}
224
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200225static int get_max_brightness(struct acpi_device *device)
Jonathan Woithe20b93732008-06-11 10:14:56 +0930226{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200227 struct fujitsu_bl *priv = acpi_driver_data(device);
Matthew Wilcox27663c52008-10-10 02:22:59 -0400228 unsigned long long state = 0;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930229 acpi_status status = AE_OK;
230
Michał Kępieńeee77da12017-06-16 06:40:58 +0200231 acpi_handle_debug(device->handle, "get max lcd level via RBLL\n");
Jonathan Woithe20b93732008-06-11 10:14:56 +0930232
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200233 status = acpi_evaluate_integer(device->handle, "RBLL", NULL, &state);
Jonathan Woithe3b1c37c2009-12-23 09:19:42 +1030234 if (ACPI_FAILURE(status))
235 return -1;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930236
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200237 priv->max_brightness = state;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930238
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200239 return priv->max_brightness;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930240}
241
Jonathan Woithed0482532007-08-29 15:58:19 +0930242/* Backlight device stuff */
243
244static int bl_get_brightness(struct backlight_device *b)
245{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200246 struct acpi_device *device = bl_get_data(b);
247
248 return b->props.power == FB_BLANK_POWERDOWN ? 0 : get_lcd_level(device);
Jonathan Woithed0482532007-08-29 15:58:19 +0930249}
250
251static int bl_update_status(struct backlight_device *b)
252{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200253 struct acpi_device *device = bl_get_data(b);
254
Ville Syrjäläcd6bf772017-09-18 23:00:59 +0300255 if (fext) {
256 if (b->props.power == FB_BLANK_POWERDOWN)
Michał Kępień2f60efa2018-02-20 06:24:53 +0100257 call_fext_func(fext, FUNC_BACKLIGHT, 0x1,
258 BACKLIGHT_PARAM_POWER, BACKLIGHT_OFF);
Ville Syrjäläcd6bf772017-09-18 23:00:59 +0300259 else
Michał Kępień2f60efa2018-02-20 06:24:53 +0100260 call_fext_func(fext, FUNC_BACKLIGHT, 0x1,
261 BACKLIGHT_PARAM_POWER, BACKLIGHT_ON);
Ville Syrjäläcd6bf772017-09-18 23:00:59 +0300262 }
Tony Vroon3a407082008-12-31 18:19:59 +0000263
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200264 return set_lcd_level(device, b->props.brightness);
Jonathan Woithed0482532007-08-29 15:58:19 +0930265}
266
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100267static const struct backlight_ops fujitsu_bl_ops = {
Jonathan Woithed0482532007-08-29 15:58:19 +0930268 .get_brightness = bl_get_brightness,
269 .update_status = bl_update_status,
270};
271
Michał Kępieńb0c4b9c2017-03-14 11:26:28 +0100272static ssize_t lid_show(struct device *dev, struct device_attribute *attr,
273 char *buf)
Tony Vroon3a407082008-12-31 18:19:59 +0000274{
Michał Kępieńd659d112017-05-19 09:44:48 +0200275 struct fujitsu_laptop *priv = dev_get_drvdata(dev);
276
277 if (!(priv->flags_supported & FLAG_LID))
Tony Vroon3a407082008-12-31 18:19:59 +0000278 return sprintf(buf, "unknown\n");
Michał Kępieńd659d112017-05-19 09:44:48 +0200279 if (priv->flags_state & FLAG_LID)
Tony Vroon3a407082008-12-31 18:19:59 +0000280 return sprintf(buf, "open\n");
281 else
282 return sprintf(buf, "closed\n");
283}
284
Michał Kępieńb0c4b9c2017-03-14 11:26:28 +0100285static ssize_t dock_show(struct device *dev, struct device_attribute *attr,
286 char *buf)
Tony Vroon3a407082008-12-31 18:19:59 +0000287{
Michał Kępieńd659d112017-05-19 09:44:48 +0200288 struct fujitsu_laptop *priv = dev_get_drvdata(dev);
289
290 if (!(priv->flags_supported & FLAG_DOCK))
Tony Vroon3a407082008-12-31 18:19:59 +0000291 return sprintf(buf, "unknown\n");
Michał Kępieńd659d112017-05-19 09:44:48 +0200292 if (priv->flags_state & FLAG_DOCK)
Tony Vroon3a407082008-12-31 18:19:59 +0000293 return sprintf(buf, "docked\n");
294 else
295 return sprintf(buf, "undocked\n");
296}
297
Michał Kępieńb0c4b9c2017-03-14 11:26:28 +0100298static ssize_t radios_show(struct device *dev, struct device_attribute *attr,
299 char *buf)
Tony Vroon3a407082008-12-31 18:19:59 +0000300{
Michał Kępieńd659d112017-05-19 09:44:48 +0200301 struct fujitsu_laptop *priv = dev_get_drvdata(dev);
302
303 if (!(priv->flags_supported & FLAG_RFKILL))
Tony Vroon3a407082008-12-31 18:19:59 +0000304 return sprintf(buf, "unknown\n");
Michał Kępieńd659d112017-05-19 09:44:48 +0200305 if (priv->flags_state & FLAG_RFKILL)
Tony Vroon3a407082008-12-31 18:19:59 +0000306 return sprintf(buf, "on\n");
307 else
308 return sprintf(buf, "killed\n");
309}
310
Michał Kępieńb0c4b9c2017-03-14 11:26:28 +0100311static DEVICE_ATTR_RO(lid);
312static DEVICE_ATTR_RO(dock);
313static DEVICE_ATTR_RO(radios);
Jonathan Woithed0482532007-08-29 15:58:19 +0930314
Alan Jenkins16506022017-02-08 14:46:26 +0100315static struct attribute *fujitsu_pf_attributes[] = {
Tony Vroon3a407082008-12-31 18:19:59 +0000316 &dev_attr_lid.attr,
317 &dev_attr_dock.attr,
318 &dev_attr_radios.attr,
Jonathan Woithed0482532007-08-29 15:58:19 +0930319 NULL
320};
321
Arvind Yadavee56ff72017-07-11 16:18:14 +0530322static const struct attribute_group fujitsu_pf_attribute_group = {
Alan Jenkins16506022017-02-08 14:46:26 +0100323 .attrs = fujitsu_pf_attributes
Jonathan Woithed0482532007-08-29 15:58:19 +0930324};
325
Alan Jenkins16506022017-02-08 14:46:26 +0100326static struct platform_driver fujitsu_pf_driver = {
Jonathan Woithed0482532007-08-29 15:58:19 +0930327 .driver = {
328 .name = "fujitsu-laptop",
Jonathan Woithed0482532007-08-29 15:58:19 +0930329 }
330};
331
Jonathan Woithe20b93732008-06-11 10:14:56 +0930332/* ACPI device for LCD brightness control */
Jonathan Woithed0482532007-08-29 15:58:19 +0930333
Michał Kępieńf2252672017-03-20 10:32:19 +0100334static 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ń7d134e42017-03-20 10:32:17 +0100340static int acpi_fujitsu_bl_input_setup(struct acpi_device *device)
341{
Michał Kępień7ec3b542017-05-19 09:44:41 +0200342 struct fujitsu_bl *priv = acpi_driver_data(device);
Michał Kępieńf2252672017-03-20 10:32:19 +0100343 int ret;
Michał Kępień7d134e42017-03-20 10:32:17 +0100344
Michał Kępień7ec3b542017-05-19 09:44:41 +0200345 priv->input = devm_input_allocate_device(&device->dev);
346 if (!priv->input)
Michał Kępień7d134e42017-03-20 10:32:17 +0100347 return -ENOMEM;
348
Michał Kępień7ec3b542017-05-19 09:44:41 +0200349 snprintf(priv->phys, sizeof(priv->phys), "%s/video/input0",
350 acpi_device_hid(device));
Michał Kępień7d134e42017-03-20 10:32:17 +0100351
Michał Kępień7ec3b542017-05-19 09:44:41 +0200352 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ńf2252672017-03-20 10:32:19 +0100356
Michał Kępień7ec3b542017-05-19 09:44:41 +0200357 ret = sparse_keymap_setup(priv->input, keymap_backlight, NULL);
Michał Kępieńf2252672017-03-20 10:32:19 +0100358 if (ret)
359 return ret;
Michał Kępień7d134e42017-03-20 10:32:17 +0100360
Michał Kępień7ec3b542017-05-19 09:44:41 +0200361 return input_register_device(priv->input);
Michał Kępień7d134e42017-03-20 10:32:17 +0100362}
363
Michał Kępieńa1aabd52017-04-05 08:49:01 +0200364static int fujitsu_backlight_register(struct acpi_device *device)
Michał Kępieńb8d69c12017-03-10 11:50:33 +0100365{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200366 struct fujitsu_bl *priv = acpi_driver_data(device);
Michał Kępieńa1aabd52017-04-05 08:49:01 +0200367 const struct backlight_properties props = {
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200368 .brightness = priv->brightness_level,
369 .max_brightness = priv->max_brightness - 1,
Michał Kępieńb8d69c12017-03-10 11:50:33 +0100370 .type = BACKLIGHT_PLATFORM
371 };
372 struct backlight_device *bd;
373
Michał Kępieńa1aabd52017-04-05 08:49:01 +0200374 bd = devm_backlight_device_register(&device->dev, "fujitsu-laptop",
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200375 &device->dev, device,
Michał Kępieńa1aabd52017-04-05 08:49:01 +0200376 &fujitsu_bl_ops, &props);
Michał Kępieńb8d69c12017-03-10 11:50:33 +0100377 if (IS_ERR(bd))
378 return PTR_ERR(bd);
379
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200380 priv->bl_device = bd;
Michał Kępieńb8d69c12017-03-10 11:50:33 +0100381
382 return 0;
383}
384
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100385static int acpi_fujitsu_bl_add(struct acpi_device *device)
Jonathan Woithed0482532007-08-29 15:58:19 +0930386{
Michał Kępień679374e2017-05-19 09:44:42 +0200387 struct fujitsu_bl *priv;
Michał Kępień14966e02018-02-11 22:07:21 +0100388 int ret;
Jonathan Woithed0482532007-08-29 15:58:19 +0930389
Michał Kępień07acf622017-04-05 08:49:00 +0200390 if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
391 return -ENODEV;
392
Michał Kępień679374e2017-05-19 09:44:42 +0200393 priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL);
394 if (!priv)
395 return -ENOMEM;
396
397 fujitsu_bl = priv;
Michał Kępieńd6a298a2017-06-16 06:40:54 +0200398 strcpy(acpi_device_name(device), ACPI_FUJITSU_BL_DEVICE_NAME);
399 strcpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
Michał Kępień679374e2017-05-19 09:44:42 +0200400 device->driver_data = priv;
Jonathan Woithed0482532007-08-29 15:58:19 +0930401
Michał Kępień1c194622017-06-16 06:40:56 +0200402 pr_info("ACPI: %s [%s]\n",
403 acpi_device_name(device), acpi_device_bid(device));
Jonathan Woithed0482532007-08-29 15:58:19 +0930404
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200405 if (get_max_brightness(device) <= 0)
406 priv->max_brightness = FUJITSU_LCD_N_LEVELS;
407 get_lcd_level(device);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930408
Michał Kępieńa7a1ccbe2018-02-11 22:07:22 +0100409 ret = acpi_fujitsu_bl_input_setup(device);
410 if (ret)
411 return ret;
412
Michał Kępień7f83d412018-02-11 22:07:23 +0100413 return fujitsu_backlight_register(device);
Jonathan Woithed0482532007-08-29 15:58:19 +0930414}
415
Jonathan Woithe20b93732008-06-11 10:14:56 +0930416/* Brightness notify */
417
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100418static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event)
Jonathan Woithe20b93732008-06-11 10:14:56 +0930419{
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200420 struct fujitsu_bl *priv = acpi_driver_data(device);
Michał Kępieńf2252672017-03-20 10:32:19 +0100421 int oldb, newb;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930422
Michał Kępień819cdda2018-02-20 06:24:54 +0100423 if (event != ACPI_FUJITSU_NOTIFY_CODE) {
Michał Kępieńeee77da12017-06-16 06:40:58 +0200424 acpi_handle_info(device->handle, "unsupported event [0x%x]\n",
425 event);
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200426 sparse_keymap_report_event(priv->input, -1, 1, true);
Michał Kępień5efc8002017-03-01 07:42:53 +0100427 return;
428 }
429
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200430 oldb = priv->brightness_level;
431 get_lcd_level(device);
432 newb = priv->brightness_level;
Michał Kępień5efc8002017-03-01 07:42:53 +0100433
Michał Kępieńeee77da12017-06-16 06:40:58 +0200434 acpi_handle_debug(device->handle,
435 "brightness button event [%i -> %i]\n", oldb, newb);
Michał Kępień5efc8002017-03-01 07:42:53 +0100436
Michał Kępieńd2aa3ae2017-03-01 07:42:54 +0100437 if (oldb == newb)
438 return;
439
Michał Kępieńb4bb0cf2017-04-05 08:49:06 +0200440 if (!disable_brightness_adjust)
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200441 set_lcd_level(device, newb);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930442
Michał Kępieńf2db7c62017-05-19 09:44:43 +0200443 sparse_keymap_report_event(priv->input, oldb < newb, 1, true);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930444}
445
446/* ACPI device for hotkey handling */
447
Michał Kępień527483a2017-03-20 10:32:22 +0100448static const struct key_entry keymap_default[] = {
Darren Hart (VMware)de15b942018-03-22 18:11:22 -0700449 { KE_KEY, KEY1_CODE, { KEY_PROG1 } },
450 { KE_KEY, KEY2_CODE, { KEY_PROG2 } },
451 { KE_KEY, KEY3_CODE, { KEY_PROG3 } },
452 { KE_KEY, KEY4_CODE, { KEY_PROG4 } },
453 { KE_KEY, KEY5_CODE, { KEY_RFKILL } },
454 /* Soft keys read from status flags */
455 { KE_KEY, FLAG_RFKILL, { KEY_RFKILL } },
456 { KE_KEY, FLAG_TOUCHPAD_TOGGLE, { KEY_TOUCHPAD_TOGGLE } },
457 { KE_KEY, FLAG_MICMUTE, { KEY_MICMUTE } },
Michał Kępień527483a2017-03-20 10:32:22 +0100458 { KE_END, 0 }
459};
460
Michał Kępieńf8c94ec2017-03-20 10:32:23 +0100461static const struct key_entry keymap_s64x0[] = {
462 { KE_KEY, KEY1_CODE, { KEY_SCREENLOCK } }, /* "Lock" */
463 { KE_KEY, KEY2_CODE, { KEY_HELP } }, /* "Mobility Center */
464 { KE_KEY, KEY3_CODE, { KEY_PROG3 } },
465 { KE_KEY, KEY4_CODE, { KEY_PROG4 } },
466 { KE_END, 0 }
467};
468
469static const struct key_entry keymap_p8010[] = {
470 { KE_KEY, KEY1_CODE, { KEY_HELP } }, /* "Support" */
471 { KE_KEY, KEY2_CODE, { KEY_PROG2 } },
472 { KE_KEY, KEY3_CODE, { KEY_SWITCHVIDEOMODE } }, /* "Presentation" */
473 { KE_KEY, KEY4_CODE, { KEY_WWW } }, /* "WWW" */
474 { KE_END, 0 }
475};
476
Michał Kępień527483a2017-03-20 10:32:22 +0100477static const struct key_entry *keymap = keymap_default;
478
Michał Kępieńf8c94ec2017-03-20 10:32:23 +0100479static int fujitsu_laptop_dmi_keymap_override(const struct dmi_system_id *id)
480{
481 pr_info("Identified laptop model '%s'\n", id->ident);
482 keymap = id->driver_data;
483 return 1;
484}
485
486static const struct dmi_system_id fujitsu_laptop_dmi_table[] = {
487 {
488 .callback = fujitsu_laptop_dmi_keymap_override,
489 .ident = "Fujitsu Siemens S6410",
490 .matches = {
491 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
492 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6410"),
493 },
494 .driver_data = (void *)keymap_s64x0
495 },
496 {
497 .callback = fujitsu_laptop_dmi_keymap_override,
498 .ident = "Fujitsu Siemens S6420",
499 .matches = {
500 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
501 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6420"),
502 },
503 .driver_data = (void *)keymap_s64x0
504 },
505 {
506 .callback = fujitsu_laptop_dmi_keymap_override,
507 .ident = "Fujitsu LifeBook P8010",
508 .matches = {
509 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
510 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P8010"),
511 },
512 .driver_data = (void *)keymap_p8010
513 },
514 {}
515};
516
Michał Kępień11182db2017-03-20 10:32:20 +0100517static int acpi_fujitsu_laptop_input_setup(struct acpi_device *device)
518{
Michał Kępień7ec3b542017-05-19 09:44:41 +0200519 struct fujitsu_laptop *priv = acpi_driver_data(device);
Michał Kępień527483a2017-03-20 10:32:22 +0100520 int ret;
Michał Kępień11182db2017-03-20 10:32:20 +0100521
Michał Kępień7ec3b542017-05-19 09:44:41 +0200522 priv->input = devm_input_allocate_device(&device->dev);
523 if (!priv->input)
Michał Kępień11182db2017-03-20 10:32:20 +0100524 return -ENOMEM;
525
Michał Kępieńc1f51f12017-06-16 06:40:55 +0200526 snprintf(priv->phys, sizeof(priv->phys), "%s/input0",
Michał Kępień7ec3b542017-05-19 09:44:41 +0200527 acpi_device_hid(device));
Michał Kępień11182db2017-03-20 10:32:20 +0100528
Michał Kępień7ec3b542017-05-19 09:44:41 +0200529 priv->input->name = acpi_device_name(device);
530 priv->input->phys = priv->phys;
531 priv->input->id.bustype = BUS_HOST;
Michał Kępień11182db2017-03-20 10:32:20 +0100532
Michał Kępieńf8c94ec2017-03-20 10:32:23 +0100533 dmi_check_system(fujitsu_laptop_dmi_table);
Michał Kępień7ec3b542017-05-19 09:44:41 +0200534 ret = sparse_keymap_setup(priv->input, keymap, NULL);
Michał Kępień527483a2017-03-20 10:32:22 +0100535 if (ret)
536 return ret;
Michał Kępień11182db2017-03-20 10:32:20 +0100537
Michał Kępień7ec3b542017-05-19 09:44:41 +0200538 return input_register_device(priv->input);
Michał Kępień11182db2017-03-20 10:32:20 +0100539}
540
Michał Kępieńd659d112017-05-19 09:44:48 +0200541static int fujitsu_laptop_platform_add(struct acpi_device *device)
Michał Kępieńd811b512017-03-14 11:26:29 +0100542{
Michał Kępieńd659d112017-05-19 09:44:48 +0200543 struct fujitsu_laptop *priv = acpi_driver_data(device);
Michał Kępieńd811b512017-03-14 11:26:29 +0100544 int ret;
545
Michał Kępieńd659d112017-05-19 09:44:48 +0200546 priv->pf_device = platform_device_alloc("fujitsu-laptop", -1);
547 if (!priv->pf_device)
Michał Kępieńd811b512017-03-14 11:26:29 +0100548 return -ENOMEM;
549
Michał Kępieńd659d112017-05-19 09:44:48 +0200550 platform_set_drvdata(priv->pf_device, priv);
551
552 ret = platform_device_add(priv->pf_device);
Michał Kępieńd811b512017-03-14 11:26:29 +0100553 if (ret)
554 goto err_put_platform_device;
555
Michał Kępieńd659d112017-05-19 09:44:48 +0200556 ret = sysfs_create_group(&priv->pf_device->dev.kobj,
Michał Kępieńd811b512017-03-14 11:26:29 +0100557 &fujitsu_pf_attribute_group);
558 if (ret)
559 goto err_del_platform_device;
560
561 return 0;
562
563err_del_platform_device:
Michał Kępieńd659d112017-05-19 09:44:48 +0200564 platform_device_del(priv->pf_device);
Michał Kępieńd811b512017-03-14 11:26:29 +0100565err_put_platform_device:
Michał Kępieńd659d112017-05-19 09:44:48 +0200566 platform_device_put(priv->pf_device);
Michał Kępieńd811b512017-03-14 11:26:29 +0100567
568 return ret;
569}
570
Michał Kępieńd659d112017-05-19 09:44:48 +0200571static void fujitsu_laptop_platform_remove(struct acpi_device *device)
Michał Kępieńd811b512017-03-14 11:26:29 +0100572{
Michał Kępieńd659d112017-05-19 09:44:48 +0200573 struct fujitsu_laptop *priv = acpi_driver_data(device);
574
575 sysfs_remove_group(&priv->pf_device->dev.kobj,
Michał Kępieńd811b512017-03-14 11:26:29 +0100576 &fujitsu_pf_attribute_group);
Michał Kępieńd659d112017-05-19 09:44:48 +0200577 platform_device_unregister(priv->pf_device);
Michał Kępieńd811b512017-03-14 11:26:29 +0100578}
579
Michał Kępieńe33ca452017-04-07 15:07:10 +0200580static int logolamp_set(struct led_classdev *cdev,
581 enum led_brightness brightness)
582{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200583 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200584 int poweron = FUNC_LED_ON, always = FUNC_LED_ON;
585 int ret;
586
587 if (brightness < LED_HALF)
588 poweron = FUNC_LED_OFF;
589
590 if (brightness < LED_FULL)
591 always = FUNC_LED_OFF;
592
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200593 ret = call_fext_func(device, FUNC_LEDS, 0x1, LOGOLAMP_POWERON, poweron);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200594 if (ret < 0)
595 return ret;
596
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200597 return call_fext_func(device, FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, always);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200598}
599
600static enum led_brightness logolamp_get(struct led_classdev *cdev)
601{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200602 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200603 int ret;
604
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200605 ret = call_fext_func(device, FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200606 if (ret == FUNC_LED_ON)
607 return LED_FULL;
608
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200609 ret = call_fext_func(device, FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200610 if (ret == FUNC_LED_ON)
611 return LED_HALF;
612
613 return LED_OFF;
614}
615
Michał Kępieńe33ca452017-04-07 15:07:10 +0200616static int kblamps_set(struct led_classdev *cdev,
617 enum led_brightness brightness)
618{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200619 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
620
Michał Kępieńe33ca452017-04-07 15:07:10 +0200621 if (brightness >= LED_FULL)
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200622 return call_fext_func(device, FUNC_LEDS, 0x1, KEYBOARD_LAMPS,
Michał Kępieńe33ca452017-04-07 15:07:10 +0200623 FUNC_LED_ON);
624 else
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200625 return call_fext_func(device, FUNC_LEDS, 0x1, KEYBOARD_LAMPS,
Michał Kępieńe33ca452017-04-07 15:07:10 +0200626 FUNC_LED_OFF);
627}
628
629static enum led_brightness kblamps_get(struct led_classdev *cdev)
630{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200631 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200632 enum led_brightness brightness = LED_OFF;
633
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200634 if (call_fext_func(device,
Michał Kępień84631e02017-05-19 09:44:46 +0200635 FUNC_LEDS, 0x2, KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON)
Michał Kępieńe33ca452017-04-07 15:07:10 +0200636 brightness = LED_FULL;
637
638 return brightness;
639}
640
Michał Kępieńe33ca452017-04-07 15:07:10 +0200641static int radio_led_set(struct led_classdev *cdev,
642 enum led_brightness brightness)
643{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200644 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
645
Michał Kępieńe33ca452017-04-07 15:07:10 +0200646 if (brightness >= LED_FULL)
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200647 return call_fext_func(device, FUNC_FLAGS, 0x5, RADIO_LED_ON,
Michał Kępieńe33ca452017-04-07 15:07:10 +0200648 RADIO_LED_ON);
649 else
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200650 return call_fext_func(device, FUNC_FLAGS, 0x5, RADIO_LED_ON,
Michał Kępień84631e02017-05-19 09:44:46 +0200651 0x0);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200652}
653
654static enum led_brightness radio_led_get(struct led_classdev *cdev)
655{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200656 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200657 enum led_brightness brightness = LED_OFF;
658
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200659 if (call_fext_func(device, FUNC_FLAGS, 0x4, 0x0, 0x0) & RADIO_LED_ON)
Michał Kępieńe33ca452017-04-07 15:07:10 +0200660 brightness = LED_FULL;
661
662 return brightness;
663}
664
Michał Kępieńe33ca452017-04-07 15:07:10 +0200665static int eco_led_set(struct led_classdev *cdev,
666 enum led_brightness brightness)
667{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200668 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200669 int curr;
670
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200671 curr = call_fext_func(device, FUNC_LEDS, 0x2, ECO_LED, 0x0);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200672 if (brightness >= LED_FULL)
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200673 return call_fext_func(device, FUNC_LEDS, 0x1, ECO_LED,
Michał Kępieńe33ca452017-04-07 15:07:10 +0200674 curr | ECO_LED_ON);
675 else
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200676 return call_fext_func(device, FUNC_LEDS, 0x1, ECO_LED,
Michał Kępieńe33ca452017-04-07 15:07:10 +0200677 curr & ~ECO_LED_ON);
678}
679
680static enum led_brightness eco_led_get(struct led_classdev *cdev)
681{
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200682 struct acpi_device *device = to_acpi_device(cdev->dev->parent);
Michał Kępieńe33ca452017-04-07 15:07:10 +0200683 enum led_brightness brightness = LED_OFF;
684
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200685 if (call_fext_func(device, FUNC_LEDS, 0x2, ECO_LED, 0x0) & ECO_LED_ON)
Michał Kępieńe33ca452017-04-07 15:07:10 +0200686 brightness = LED_FULL;
687
688 return brightness;
689}
690
Michał Kępień81f68212017-04-07 15:07:11 +0200691static int acpi_fujitsu_laptop_leds_register(struct acpi_device *device)
Jonathan Woithe20b93732008-06-11 10:14:56 +0930692{
Michał Kępieńc7b3e982017-10-25 06:29:46 +0200693 struct fujitsu_laptop *priv = acpi_driver_data(device);
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200694 struct led_classdev *led;
Michał Kępień14966e02018-02-11 22:07:21 +0100695 int ret;
Michał Kępień7adb7b12017-04-07 15:07:09 +0200696
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200697 if (call_fext_func(device,
Michał Kępień84631e02017-05-19 09:44:46 +0200698 FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) {
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200699 led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL);
Gustavo A. R. Silvab77a5372017-07-06 17:19:02 -0500700 if (!led)
701 return -ENOMEM;
702
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200703 led->name = "fujitsu::logolamp";
704 led->brightness_set_blocking = logolamp_set;
705 led->brightness_get = logolamp_get;
Michał Kępień14966e02018-02-11 22:07:21 +0100706 ret = devm_led_classdev_register(&device->dev, led);
707 if (ret)
708 return ret;
Michał Kępień7adb7b12017-04-07 15:07:09 +0200709 }
710
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200711 if ((call_fext_func(device,
Michał Kępień84631e02017-05-19 09:44:46 +0200712 FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) &&
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200713 (call_fext_func(device, FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) {
714 led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL);
Gustavo A. R. Silvab77a5372017-07-06 17:19:02 -0500715 if (!led)
716 return -ENOMEM;
717
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200718 led->name = "fujitsu::kblamps";
719 led->brightness_set_blocking = kblamps_set;
720 led->brightness_get = kblamps_get;
Michał Kępień14966e02018-02-11 22:07:21 +0100721 ret = devm_led_classdev_register(&device->dev, led);
722 if (ret)
723 return ret;
Michał Kępień7adb7b12017-04-07 15:07:09 +0200724 }
725
726 /*
Michał Kępieńc7b3e982017-10-25 06:29:46 +0200727 * Some Fujitsu laptops have a radio toggle button in place of a slide
728 * switch and all such machines appear to also have an RF LED. Based on
729 * comparing DSDT tables of four Fujitsu Lifebook models (E744, E751,
730 * S7110, S8420; the first one has a radio toggle button, the other
731 * three have slide switches), bit 17 of flags_supported (the value
732 * returned by method S000 of ACPI device FUJ02E3) seems to indicate
733 * whether given model has a radio toggle button.
Michał Kępień7adb7b12017-04-07 15:07:09 +0200734 */
Michał Kępieńc7b3e982017-10-25 06:29:46 +0200735 if (priv->flags_supported & BIT(17)) {
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200736 led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL);
Gustavo A. R. Silvab77a5372017-07-06 17:19:02 -0500737 if (!led)
738 return -ENOMEM;
739
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200740 led->name = "fujitsu::radio_led";
741 led->brightness_set_blocking = radio_led_set;
742 led->brightness_get = radio_led_get;
743 led->default_trigger = "rfkill-any";
Michał Kępień14966e02018-02-11 22:07:21 +0100744 ret = devm_led_classdev_register(&device->dev, led);
745 if (ret)
746 return ret;
Michał Kępień7adb7b12017-04-07 15:07:09 +0200747 }
748
749 /* Support for eco led is not always signaled in bit corresponding
750 * to the bit used to control the led. According to the DSDT table,
751 * bit 14 seems to indicate presence of said led as well.
752 * Confirm by testing the status.
753 */
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200754 if ((call_fext_func(device, FUNC_LEDS, 0x0, 0x0, 0x0) & BIT(14)) &&
755 (call_fext_func(device,
Michał Kępień84631e02017-05-19 09:44:46 +0200756 FUNC_LEDS, 0x2, ECO_LED, 0x0) != UNSUPPORTED_CMD)) {
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200757 led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL);
Gustavo A. R. Silvab77a5372017-07-06 17:19:02 -0500758 if (!led)
759 return -ENOMEM;
760
Michał Kępieńa823f8e2017-05-19 09:44:47 +0200761 led->name = "fujitsu::eco_led";
762 led->brightness_set_blocking = eco_led_set;
763 led->brightness_get = eco_led_get;
Michał Kępień14966e02018-02-11 22:07:21 +0100764 ret = devm_led_classdev_register(&device->dev, led);
765 if (ret)
766 return ret;
Michał Kępień7adb7b12017-04-07 15:07:09 +0200767 }
768
Michał Kępień30943e12017-04-07 15:07:12 +0200769 return 0;
Michał Kępień7adb7b12017-04-07 15:07:09 +0200770}
771
772static int acpi_fujitsu_laptop_add(struct acpi_device *device)
773{
Michał Kępieńa4b176e2017-05-19 09:44:44 +0200774 struct fujitsu_laptop *priv;
Michał Kępień14966e02018-02-11 22:07:21 +0100775 int ret, i = 0;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930776
Michał Kępieńa4b176e2017-05-19 09:44:44 +0200777 priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL);
778 if (!priv)
779 return -ENOMEM;
780
Michał Kępieńca0d9ea2017-05-19 09:44:45 +0200781 WARN_ONCE(fext, "More than one FUJ02E3 ACPI device was found. Driver may not work as intended.");
782 fext = device;
783
Michał Kępieńd6a298a2017-06-16 06:40:54 +0200784 strcpy(acpi_device_name(device), ACPI_FUJITSU_LAPTOP_DEVICE_NAME);
785 strcpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
Michał Kępieńa4b176e2017-05-19 09:44:44 +0200786 device->driver_data = priv;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930787
Jonathan Woithe20b93732008-06-11 10:14:56 +0930788 /* kfifo */
Michał Kępieńd659d112017-05-19 09:44:48 +0200789 spin_lock_init(&priv->fifo_lock);
Michał Kępień14966e02018-02-11 22:07:21 +0100790 ret = kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int),
791 GFP_KERNEL);
Michał Kępień7f83d412018-02-11 22:07:23 +0100792 if (ret)
793 return ret;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930794
Michał Kępień1c194622017-06-16 06:40:56 +0200795 pr_info("ACPI: %s [%s]\n",
796 acpi_device_name(device), acpi_device_bid(device));
Jonathan Woithe20b93732008-06-11 10:14:56 +0930797
Michał Kępień14966e02018-02-11 22:07:21 +0100798 while (call_fext_func(device, FUNC_BUTTONS, 0x1, 0x0, 0x0) != 0 &&
799 i++ < MAX_HOTKEY_RINGBUFFER_SIZE)
Tony Vroon3a407082008-12-31 18:19:59 +0000800 ; /* No action, result is discarded */
Michał Kępieńeee77da12017-06-16 06:40:58 +0200801 acpi_handle_debug(device->handle, "Discarded %i ringbuffer entries\n",
802 i);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930803
Michał Kępieńd659d112017-05-19 09:44:48 +0200804 priv->flags_supported = call_fext_func(device, FUNC_FLAGS, 0x0, 0x0,
805 0x0);
Tony Vroon4898c2b2009-02-02 11:11:10 +0000806
807 /* Make sure our bitmask of supported functions is cleared if the
808 RFKILL function block is not implemented, like on the S7020. */
Michał Kępieńd659d112017-05-19 09:44:48 +0200809 if (priv->flags_supported == UNSUPPORTED_CMD)
810 priv->flags_supported = 0;
Tony Vroon4898c2b2009-02-02 11:11:10 +0000811
Michał Kępieńd659d112017-05-19 09:44:48 +0200812 if (priv->flags_supported)
813 priv->flags_state = call_fext_func(device, FUNC_FLAGS, 0x4, 0x0,
814 0x0);
Tony Vroon3a407082008-12-31 18:19:59 +0000815
816 /* Suspect this is a keymap of the application panel, print it */
Michał Kępieńeee77da12017-06-16 06:40:58 +0200817 acpi_handle_info(device->handle, "BTNI: [0x%x]\n",
818 call_fext_func(device, FUNC_BUTTONS, 0x0, 0x0, 0x0));
Tony Vroon3a407082008-12-31 18:19:59 +0000819
Michał Kępień1877e262017-03-10 11:50:34 +0100820 /* Sync backlight power status */
Michał Kępień679374e2017-05-19 09:44:42 +0200821 if (fujitsu_bl && fujitsu_bl->bl_device &&
Michał Kępieńaea31372017-03-10 11:50:35 +0100822 acpi_video_get_backlight_type() == acpi_backlight_vendor) {
Michał Kępień2f60efa2018-02-20 06:24:53 +0100823 if (call_fext_func(fext, FUNC_BACKLIGHT, 0x2,
824 BACKLIGHT_PARAM_POWER, 0x0) == BACKLIGHT_OFF)
Michał Kępień1877e262017-03-10 11:50:34 +0100825 fujitsu_bl->bl_device->props.power = FB_BLANK_POWERDOWN;
826 else
827 fujitsu_bl->bl_device->props.power = FB_BLANK_UNBLANK;
828 }
829
Michał Kępieńa7a1ccbe2018-02-11 22:07:22 +0100830 ret = acpi_fujitsu_laptop_input_setup(device);
831 if (ret)
832 goto err_free_fifo;
833
Michał Kępień14966e02018-02-11 22:07:21 +0100834 ret = acpi_fujitsu_laptop_leds_register(device);
835 if (ret)
Michał Kępieńd1c70732017-04-07 15:07:13 +0200836 goto err_free_fifo;
837
Michał Kępień14966e02018-02-11 22:07:21 +0100838 ret = fujitsu_laptop_platform_add(device);
839 if (ret)
Michał Kępieńf66735f2017-03-20 10:32:21 +0100840 goto err_free_fifo;
Michał Kępieńc33f4c02017-03-14 11:26:30 +0100841
Michał Kępień7adb7b12017-04-07 15:07:09 +0200842 return 0;
Michał Kępień4f625682016-04-12 22:06:34 +0930843
Bjorn Helgaasb4ec0272009-04-07 15:37:22 +0000844err_free_fifo:
Michał Kępieńd659d112017-05-19 09:44:48 +0200845 kfifo_free(&priv->fifo);
Michał Kępień7f83d412018-02-11 22:07:23 +0100846
Michał Kępień14966e02018-02-11 22:07:21 +0100847 return ret;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930848}
849
Alan Jenkins6942eab2017-02-08 14:46:25 +0100850static int acpi_fujitsu_laptop_remove(struct acpi_device *device)
Jonathan Woithe20b93732008-06-11 10:14:56 +0930851{
Michał Kępień7ec3b542017-05-19 09:44:41 +0200852 struct fujitsu_laptop *priv = acpi_driver_data(device);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930853
Michał Kępieńd659d112017-05-19 09:44:48 +0200854 fujitsu_laptop_platform_remove(device);
Michał Kępieńc33f4c02017-03-14 11:26:30 +0100855
Michał Kępień7ec3b542017-05-19 09:44:41 +0200856 kfifo_free(&priv->fifo);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930857
858 return 0;
859}
860
Michał Kępieńd659d112017-05-19 09:44:48 +0200861static void acpi_fujitsu_laptop_press(struct acpi_device *device, int scancode)
Michał Kępień2451d192017-01-11 09:59:31 +0100862{
Michał Kępieńd659d112017-05-19 09:44:48 +0200863 struct fujitsu_laptop *priv = acpi_driver_data(device);
Michał Kępień14966e02018-02-11 22:07:21 +0100864 int ret;
Michał Kępień2451d192017-01-11 09:59:31 +0100865
Michał Kępień14966e02018-02-11 22:07:21 +0100866 ret = kfifo_in_locked(&priv->fifo, (unsigned char *)&scancode,
867 sizeof(scancode), &priv->fifo_lock);
868 if (ret != sizeof(scancode)) {
Michał Kępieńeee77da12017-06-16 06:40:58 +0200869 dev_info(&priv->input->dev, "Could not push scancode [0x%x]\n",
870 scancode);
Michał Kępieńa28c7e92017-01-11 09:59:33 +0100871 return;
Michał Kępień2451d192017-01-11 09:59:31 +0100872 }
Michał Kępieńd659d112017-05-19 09:44:48 +0200873 sparse_keymap_report_event(priv->input, scancode, 1, false);
Michał Kępieńeee77da12017-06-16 06:40:58 +0200874 dev_dbg(&priv->input->dev, "Push scancode into ringbuffer [0x%x]\n",
875 scancode);
Michał Kępień2451d192017-01-11 09:59:31 +0100876}
877
Michał Kępieńd659d112017-05-19 09:44:48 +0200878static void acpi_fujitsu_laptop_release(struct acpi_device *device)
Michał Kępień2451d192017-01-11 09:59:31 +0100879{
Michał Kępieńd659d112017-05-19 09:44:48 +0200880 struct fujitsu_laptop *priv = acpi_driver_data(device);
Michał Kępień14966e02018-02-11 22:07:21 +0100881 int scancode, ret;
Michał Kępień2451d192017-01-11 09:59:31 +0100882
Michał Kępień29544f02017-01-11 09:59:32 +0100883 while (true) {
Michał Kępień14966e02018-02-11 22:07:21 +0100884 ret = kfifo_out_locked(&priv->fifo, (unsigned char *)&scancode,
885 sizeof(scancode), &priv->fifo_lock);
886 if (ret != sizeof(scancode))
Michał Kępień29544f02017-01-11 09:59:32 +0100887 return;
Michał Kępieńd659d112017-05-19 09:44:48 +0200888 sparse_keymap_report_event(priv->input, scancode, 0, false);
Michał Kępieńeee77da12017-06-16 06:40:58 +0200889 dev_dbg(&priv->input->dev,
890 "Pop scancode from ringbuffer [0x%x]\n", scancode);
Michał Kępień2451d192017-01-11 09:59:31 +0100891 }
892}
893
Alan Jenkins6942eab2017-02-08 14:46:25 +0100894static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event)
Jonathan Woithe20b93732008-06-11 10:14:56 +0930895{
Michał Kępieńd659d112017-05-19 09:44:48 +0200896 struct fujitsu_laptop *priv = acpi_driver_data(device);
Darren Hart (VMware)de15b942018-03-22 18:11:22 -0700897 unsigned long flags;
898 int scancode, i = 0;
Michał Kępień527483a2017-03-20 10:32:22 +0100899 unsigned int irb;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930900
Michał Kępień819cdda2018-02-20 06:24:54 +0100901 if (event != ACPI_FUJITSU_NOTIFY_CODE) {
Michał Kępieńeee77da12017-06-16 06:40:58 +0200902 acpi_handle_info(device->handle, "Unsupported event [0x%x]\n",
903 event);
Michał Kępieńd659d112017-05-19 09:44:48 +0200904 sparse_keymap_report_event(priv->input, -1, 1, true);
Michał Kępieńeb357cb2017-01-11 09:59:30 +0100905 return;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930906 }
Michał Kępieńeb357cb2017-01-11 09:59:30 +0100907
Michał Kępieńd659d112017-05-19 09:44:48 +0200908 if (priv->flags_supported)
909 priv->flags_state = call_fext_func(device, FUNC_FLAGS, 0x4, 0x0,
910 0x0);
Michał Kępieńeb357cb2017-01-11 09:59:30 +0100911
Michał Kępieńd659d112017-05-19 09:44:48 +0200912 while ((irb = call_fext_func(device,
Michał Kępień84631e02017-05-19 09:44:46 +0200913 FUNC_BUTTONS, 0x1, 0x0, 0x0)) != 0 &&
Michał Kępień527483a2017-03-20 10:32:22 +0100914 i++ < MAX_HOTKEY_RINGBUFFER_SIZE) {
915 scancode = irb & 0x4ff;
Michał Kępieńd659d112017-05-19 09:44:48 +0200916 if (sparse_keymap_entry_from_scancode(priv->input, scancode))
917 acpi_fujitsu_laptop_press(device, scancode);
Michał Kępień527483a2017-03-20 10:32:22 +0100918 else if (scancode == 0)
Michał Kępieńd659d112017-05-19 09:44:48 +0200919 acpi_fujitsu_laptop_release(device);
Michał Kępień527483a2017-03-20 10:32:22 +0100920 else
Michał Kępieńeee77da12017-06-16 06:40:58 +0200921 acpi_handle_info(device->handle,
922 "Unknown GIRB result [%x]\n", irb);
Michał Kępieńeb357cb2017-01-11 09:59:30 +0100923 }
924
Darren Hart (VMware)de15b942018-03-22 18:11:22 -0700925 /*
926 * First seen on the Skylake-based Lifebook E736/E746/E756), the
927 * touchpad toggle hotkey (Fn+F4) is handled in software. Other models
928 * have since added additional "soft keys". These are reported in the
929 * status flags queried using FUNC_FLAGS.
Michał Kępieńeb357cb2017-01-11 09:59:30 +0100930 */
Darren Hart (VMware)de15b942018-03-22 18:11:22 -0700931 if (priv->flags_supported & (FLAG_SOFTKEYS)) {
932 flags = call_fext_func(device, FUNC_FLAGS, 0x1, 0x0, 0x0);
933 flags &= (FLAG_SOFTKEYS);
934 for_each_set_bit(i, &flags, BITS_PER_LONG)
935 sparse_keymap_report_event(priv->input, BIT(i), 1, true);
Jan-Marek Glogowski797195a2018-02-12 13:08:51 +0100936 }
Jonathan Woithe20b93732008-06-11 10:14:56 +0930937}
938
939/* Initialization */
940
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100941static const struct acpi_device_id fujitsu_bl_device_ids[] = {
942 {ACPI_FUJITSU_BL_HID, 0},
Jonathan Woithed0482532007-08-29 15:58:19 +0930943 {"", 0},
944};
945
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100946static struct acpi_driver acpi_fujitsu_bl_driver = {
947 .name = ACPI_FUJITSU_BL_DRIVER_NAME,
Jonathan Woithed0482532007-08-29 15:58:19 +0930948 .class = ACPI_FUJITSU_CLASS,
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100949 .ids = fujitsu_bl_device_ids,
Jonathan Woithed0482532007-08-29 15:58:19 +0930950 .ops = {
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100951 .add = acpi_fujitsu_bl_add,
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100952 .notify = acpi_fujitsu_bl_notify,
Jonathan Woithed0482532007-08-29 15:58:19 +0930953 },
954};
955
Alan Jenkins6942eab2017-02-08 14:46:25 +0100956static const struct acpi_device_id fujitsu_laptop_device_ids[] = {
957 {ACPI_FUJITSU_LAPTOP_HID, 0},
Jonathan Woithe20b93732008-06-11 10:14:56 +0930958 {"", 0},
959};
960
Alan Jenkins6942eab2017-02-08 14:46:25 +0100961static struct acpi_driver acpi_fujitsu_laptop_driver = {
962 .name = ACPI_FUJITSU_LAPTOP_DRIVER_NAME,
Jonathan Woithe20b93732008-06-11 10:14:56 +0930963 .class = ACPI_FUJITSU_CLASS,
Alan Jenkins6942eab2017-02-08 14:46:25 +0100964 .ids = fujitsu_laptop_device_ids,
Jonathan Woithe20b93732008-06-11 10:14:56 +0930965 .ops = {
Alan Jenkins6942eab2017-02-08 14:46:25 +0100966 .add = acpi_fujitsu_laptop_add,
967 .remove = acpi_fujitsu_laptop_remove,
968 .notify = acpi_fujitsu_laptop_notify,
Jonathan Woithe20b93732008-06-11 10:14:56 +0930969 },
970};
Jonathan Woithed0482532007-08-29 15:58:19 +0930971
Zhang Rui49901412014-09-09 00:21:59 +0200972static const struct acpi_device_id fujitsu_ids[] __used = {
Alan Jenkins9fc5cf62017-02-08 14:46:24 +0100973 {ACPI_FUJITSU_BL_HID, 0},
Alan Jenkins6942eab2017-02-08 14:46:25 +0100974 {ACPI_FUJITSU_LAPTOP_HID, 0},
Zhang Rui49901412014-09-09 00:21:59 +0200975 {"", 0}
976};
977MODULE_DEVICE_TABLE(acpi, fujitsu_ids);
978
Jonathan Woithed0482532007-08-29 15:58:19 +0930979static int __init fujitsu_init(void)
980{
Michał Kępieńb8d69c12017-03-10 11:50:33 +0100981 int ret;
Jonathan Woithed0482532007-08-29 15:58:19 +0930982
Alan Jenkinsc1d1e8a2017-02-08 14:46:30 +0100983 ret = acpi_bus_register_driver(&acpi_fujitsu_bl_driver);
984 if (ret)
Michał Kępień679374e2017-05-19 09:44:42 +0200985 return ret;
Jonathan Woithed0482532007-08-29 15:58:19 +0930986
Jonathan Woithed0482532007-08-29 15:58:19 +0930987 /* Register platform stuff */
988
Alan Jenkins16506022017-02-08 14:46:26 +0100989 ret = platform_driver_register(&fujitsu_pf_driver);
Jonathan Woithe20b93732008-06-11 10:14:56 +0930990 if (ret)
Michał Kępieńc33f4c02017-03-14 11:26:30 +0100991 goto err_unregister_acpi;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930992
Alan Jenkins6942eab2017-02-08 14:46:25 +0100993 /* Register laptop driver */
Jonathan Woithe20b93732008-06-11 10:14:56 +0930994
Alan Jenkinsc1d1e8a2017-02-08 14:46:30 +0100995 ret = acpi_bus_register_driver(&acpi_fujitsu_laptop_driver);
996 if (ret)
Michał Kępieńa4b176e2017-05-19 09:44:44 +0200997 goto err_unregister_platform_driver;
Jonathan Woithe20b93732008-06-11 10:14:56 +0930998
Joe Perches77bad7c2011-03-29 15:21:39 -0700999 pr_info("driver " FUJITSU_DRIVER_VERSION " successfully loaded\n");
Jonathan Woithed0482532007-08-29 15:58:19 +09301000
1001 return 0;
1002
Michał Kępieńc2cddd42017-03-10 11:50:36 +01001003err_unregister_platform_driver:
Alan Jenkins16506022017-02-08 14:46:26 +01001004 platform_driver_unregister(&fujitsu_pf_driver);
Michał Kępieńc2cddd42017-03-10 11:50:36 +01001005err_unregister_acpi:
Alan Jenkins9fc5cf62017-02-08 14:46:24 +01001006 acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver);
Jonathan Woithed0482532007-08-29 15:58:19 +09301007
1008 return ret;
1009}
1010
1011static void __exit fujitsu_cleanup(void)
1012{
Alan Jenkins6942eab2017-02-08 14:46:25 +01001013 acpi_bus_unregister_driver(&acpi_fujitsu_laptop_driver);
Tony Vroon3a407082008-12-31 18:19:59 +00001014
Alan Jenkins16506022017-02-08 14:46:26 +01001015 platform_driver_unregister(&fujitsu_pf_driver);
Bartlomiej Zolnierkiewicz72afeea2009-07-31 18:16:02 +09301016
Alan Jenkins9fc5cf62017-02-08 14:46:24 +01001017 acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver);
Jonathan Woithed0482532007-08-29 15:58:19 +09301018
Joe Perches77bad7c2011-03-29 15:21:39 -07001019 pr_info("driver unloaded\n");
Jonathan Woithed0482532007-08-29 15:58:19 +09301020}
1021
1022module_init(fujitsu_init);
1023module_exit(fujitsu_cleanup);
1024
Michał Kępieńe06e4832017-04-05 08:49:05 +02001025module_param(use_alt_lcd_levels, int, 0644);
1026MODULE_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 +02001027module_param(disable_brightness_adjust, bool, 0644);
1028MODULE_PARM_DESC(disable_brightness_adjust, "Disable LCD brightness adjustment");
Jonathan Woithe20b93732008-06-11 10:14:56 +09301029
Tony Vroon3a407082008-12-31 18:19:59 +00001030MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon");
Jonathan Woithed0482532007-08-29 15:58:19 +09301031MODULE_DESCRIPTION("Fujitsu laptop extras support");
1032MODULE_VERSION(FUJITSU_DRIVER_VERSION);
1033MODULE_LICENSE("GPL");