Commit 78d42567 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'platform-drivers-x86-v4.1-1' of...

Merge tag 'platform-drivers-x86-v4.1-1' of git://git.infradead.org/users/dvhart/linux-platform-drivers-x86

Pull x86 platform driver updates from Darren Hart:
 "This series includes significant updates to the toshiba_acpi driver
  and the reintroduction of the dell-laptop keyboard backlight additions
  I had to revert previously.  Also included are various fixes for
  typos, warnings, correctness, and minor bugs.

  Specifics:

  dell-laptop:
     - add support for keyboard backlight.

  toshiba_acpi:
     - adaptive keyboard, hotkey, USB sleep and charge, and backlight
       updates.  Update sysfs documentation.

  toshiba_bluetooth:
     - fix enabling/disabling loop on recent devices

  apple-gmux:
     - lock iGP IO to protect from vgaarb changes

  other:
     - Fix typos, clear gcc warnings, clarify pr_* messages, correct
       return types, update MAINTAINERS"

* tag 'platform-drivers-x86-v4.1-1' of git://git.infradead.org/users/dvhart/linux-platform-drivers-x86: (25 commits)
  toshiba_acpi: Do not register vendor backlight when acpi_video bl is available
  MAINTAINERS: Add me on list of Dell laptop drivers
  platform: x86: dell-laptop: Add support for keyboard backlight
  Documentation/ABI: Update sysfs-driver-toshiba_acpi entry
  toshiba_acpi: Fix pr_* messages from USB Sleep Functions
  toshiba_acpi: Update and fix USB Sleep and Charge modes
  wmi: Use bool function return values of true/false not 1/0
  toshiba_bluetooth: Fix enabling/disabling loop on recent devices
  toshiba_bluetooth: Clean up *_add function and disable BT device at removal
  toshiba_bluetooth: Add three new functions to the driver
  toshiba_acpi: Fix the enabling of the Special Functions
  toshiba_acpi: Use the Hotkey Event Type function for keymap choosing
  toshiba_acpi: Add Hotkey Event Type function and definitions
  x86/wmi: delete unused wmi_data_lock mutex causing gcc warning
  apple-gmux: lock iGP IO to protect from vgaarb changes
  MAINTAINERS: Add missing Toshiba devices and add myself as maintainer
  toshiba_acpi: Update events in toshiba_acpi_notify
  intel-oaktrail: Fix trivial typo in comment
  thinkpad_acpi: off by one in adaptive_keyboard_hotkey_notify_hotkey()
  thinkpad_acpi: signedness bugs getting current_mode
  ...
parents 36a8032d 358d6a2c
...@@ -8,9 +8,11 @@ Description: This file controls the keyboard backlight operation mode, valid ...@@ -8,9 +8,11 @@ Description: This file controls the keyboard backlight operation mode, valid
* 0x2 -> AUTO (also called TIMER) * 0x2 -> AUTO (also called TIMER)
* 0x8 -> ON * 0x8 -> ON
* 0x10 -> OFF * 0x10 -> OFF
Note that the kernel 3.16 onwards this file accepts all listed Note that from kernel 3.16 onwards this file accepts all listed
parameters, kernel 3.15 only accepts the first two (FN-Z and parameters, kernel 3.15 only accepts the first two (FN-Z and
AUTO). AUTO).
Also note that toggling this value on type 1 devices, requires
a reboot for changes to take effect.
Users: KToshiba Users: KToshiba
What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/kbd_backlight_timeout What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/kbd_backlight_timeout
...@@ -67,15 +69,72 @@ Description: This file shows the current keyboard backlight type, ...@@ -67,15 +69,72 @@ Description: This file shows the current keyboard backlight type,
* 2 -> Type 2, supporting modes TIMER, ON and OFF * 2 -> Type 2, supporting modes TIMER, ON and OFF
Users: KToshiba Users: KToshiba
What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/usb_sleep_charge
Date: January 23, 2015
KernelVersion: 4.0
Contact: Azael Avalos <coproscefalo@gmail.com>
Description: This file controls the USB Sleep & Charge charging mode, which
can be:
* 0 -> Disabled (0x00)
* 1 -> Alternate (0x09)
* 2 -> Auto (0x21)
* 3 -> Typical (0x11)
Note that from kernel 4.1 onwards this file accepts all listed
values, kernel 4.0 only supports the first three.
Note that this feature only works when connected to power, if
you want to use it under battery, see the entry named
"sleep_functions_on_battery"
Users: KToshiba
What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/sleep_functions_on_battery
Date: January 23, 2015
KernelVersion: 4.0
Contact: Azael Avalos <coproscefalo@gmail.com>
Description: This file controls the USB Sleep Functions under battery, and
set the level at which point they will be disabled, accepted
values can be:
* 0 -> Disabled
* 1-100 -> Battery level to disable sleep functions
Currently it prints two values, the first one indicates if the
feature is enabled or disabled, while the second one shows the
current battery level set.
Note that when the value is set to disabled, the sleep function
will only work when connected to power.
Users: KToshiba
What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/usb_rapid_charge
Date: January 23, 2015
KernelVersion: 4.0
Contact: Azael Avalos <coproscefalo@gmail.com>
Description: This file controls the USB Rapid Charge state, which can be:
* 0 -> Disabled
* 1 -> Enabled
Note that toggling this value requires a reboot for changes to
take effect.
Users: KToshiba
What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/usb_sleep_music
Date: January 23, 2015
KernelVersion: 4.0
Contact: Azael Avalos <coproscefalo@gmail.com>
Description: This file controls the Sleep & Music state, which values can be:
* 0 -> Disabled
* 1 -> Enabled
Note that this feature only works when connected to power, if
you want to use it under battery, see the entry named
"sleep_functions_on_battery"
Users: KToshiba
What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/version What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/version
Date: February, 2015 Date: February 12, 2015
KernelVersion: 3.20 KernelVersion: 4.0
Contact: Azael Avalos <coproscefalo@gmail.com> Contact: Azael Avalos <coproscefalo@gmail.com>
Description: This file shows the current version of the driver Description: This file shows the current version of the driver
Users: KToshiba
What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/fan What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/fan
Date: February, 2015 Date: February 12, 2015
KernelVersion: 3.20 KernelVersion: 4.0
Contact: Azael Avalos <coproscefalo@gmail.com> Contact: Azael Avalos <coproscefalo@gmail.com>
Description: This file controls the state of the internal fan, valid Description: This file controls the state of the internal fan, valid
values are: values are:
...@@ -83,8 +142,8 @@ Description: This file controls the state of the internal fan, valid ...@@ -83,8 +142,8 @@ Description: This file controls the state of the internal fan, valid
* 1 -> ON * 1 -> ON
What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/kbd_function_keys What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/kbd_function_keys
Date: February, 2015 Date: February 12, 2015
KernelVersion: 3.20 KernelVersion: 4.0
Contact: Azael Avalos <coproscefalo@gmail.com> Contact: Azael Avalos <coproscefalo@gmail.com>
Description: This file controls the Special Functions (hotkeys) operation Description: This file controls the Special Functions (hotkeys) operation
mode, valid values are: mode, valid values are:
...@@ -94,21 +153,29 @@ Description: This file controls the Special Functions (hotkeys) operation ...@@ -94,21 +153,29 @@ Description: This file controls the Special Functions (hotkeys) operation
and the hotkeys are accessed via FN-F{1-12}. and the hotkeys are accessed via FN-F{1-12}.
In the "Special Functions" mode, the F{1-12} keys trigger the In the "Special Functions" mode, the F{1-12} keys trigger the
hotkey and the F{1-12} keys are accessed via FN-F{1-12}. hotkey and the F{1-12} keys are accessed via FN-F{1-12}.
Note that toggling this value requires a reboot for changes to
take effect.
Users: KToshiba
What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/panel_power_on What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/panel_power_on
Date: February, 2015 Date: February 12, 2015
KernelVersion: 3.20 KernelVersion: 4.0
Contact: Azael Avalos <coproscefalo@gmail.com> Contact: Azael Avalos <coproscefalo@gmail.com>
Description: This file controls whether the laptop should turn ON whenever Description: This file controls whether the laptop should turn ON whenever
the LID is opened, valid values are: the LID is opened, valid values are:
* 0 -> Disabled * 0 -> Disabled
* 1 -> Enabled * 1 -> Enabled
Note that toggling this value requires a reboot for changes to
take effect.
Users: KToshiba
What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/usb_three What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/usb_three
Date: February, 2015 Date: February 12, 2015
KernelVersion: 3.20 KernelVersion: 4.0
Contact: Azael Avalos <coproscefalo@gmail.com> Contact: Azael Avalos <coproscefalo@gmail.com>
Description: This file controls whether the USB 3 functionality, valid Description: This file controls the USB 3 functionality, valid values are:
values are:
* 0 -> Disabled (Acts as a regular USB 2) * 0 -> Disabled (Acts as a regular USB 2)
* 1 -> Enabled (Full USB 3 functionality) * 1 -> Enabled (Full USB 3 functionality)
Note that toggling this value requires a reboot for changes to
take effect.
Users: KToshiba
What: /sys/class/leds/dell::kbd_backlight/als_enabled
Date: December 2014
KernelVersion: 3.19
Contact: Gabriele Mazzotta <gabriele.mzt@gmail.com>,
Pali Rohár <pali.rohar@gmail.com>
Description:
This file allows to control the automatic keyboard
illumination mode on some systems that have an ambient
light sensor. Write 1 to this file to enable the auto
mode, 0 to disable it.
What: /sys/class/leds/dell::kbd_backlight/als_setting
Date: December 2014
KernelVersion: 3.19
Contact: Gabriele Mazzotta <gabriele.mzt@gmail.com>,
Pali Rohár <pali.rohar@gmail.com>
Description:
This file allows to specifiy the on/off threshold value,
as reported by the ambient light sensor.
What: /sys/class/leds/dell::kbd_backlight/start_triggers
Date: December 2014
KernelVersion: 3.19
Contact: Gabriele Mazzotta <gabriele.mzt@gmail.com>,
Pali Rohár <pali.rohar@gmail.com>
Description:
This file allows to control the input triggers that
turn on the keyboard backlight illumination that is
disabled because of inactivity.
Read the file to see the triggers available. The ones
enabled are preceded by '+', those disabled by '-'.
To enable a trigger, write its name preceded by '+' to
this file. To disable a trigger, write its name preceded
by '-' instead.
For example, to enable the keyboard as trigger run:
echo +keyboard > /sys/class/leds/dell::kbd_backlight/start_triggers
To disable it:
echo -keyboard > /sys/class/leds/dell::kbd_backlight/start_triggers
Note that not all the available triggers can be configured.
What: /sys/class/leds/dell::kbd_backlight/stop_timeout
Date: December 2014
KernelVersion: 3.19
Contact: Gabriele Mazzotta <gabriele.mzt@gmail.com>,
Pali Rohár <pali.rohar@gmail.com>
Description:
This file allows to specify the interval after which the
keyboard illumination is disabled because of inactivity.
The timeouts are expressed in seconds, minutes, hours and
days, for which the symbols are 's', 'm', 'h' and 'd'
respectively.
To configure the timeout, write to this file a value along
with any the above units. If no unit is specified, the value
is assumed to be expressed in seconds.
For example, to set the timeout to 10 minutes run:
echo 10m > /sys/class/leds/dell::kbd_backlight/stop_timeout
Note that when this file is read, the returned value might be
expressed in a different unit than the one used when the timeout
was set.
Also note that only some timeouts are supported and that
some systems might fall back to a specific timeout in case
an invalid timeout is written to this file.
...@@ -1355,6 +1355,24 @@ Sysfs notes: ...@@ -1355,6 +1355,24 @@ Sysfs notes:
rfkill controller switch "tpacpi_uwb_sw": refer to rfkill controller switch "tpacpi_uwb_sw": refer to
Documentation/rfkill.txt for details. Documentation/rfkill.txt for details.
Adaptive keyboard
-----------------
sysfs device attribute: adaptive_kbd_mode
This sysfs attribute controls the keyboard "face" that will be shown on the
Lenovo X1 Carbon 2nd gen (2014)'s adaptive keyboard. The value can be read
and set.
1 = Home mode
2 = Web-browser mode
3 = Web-conference mode
4 = Function mode
5 = Layflat mode
For more details about which buttons will appear depending on the mode, please
review the laptop's user guide:
http://www.lenovo.com/shop/americas/content/user_guides/x1carbon_2_ug_en.pdf
Multiple Commands, Module Parameters Multiple Commands, Module Parameters
------------------------------------ ------------------------------------
......
...@@ -3066,10 +3066,16 @@ F: drivers/net/fddi/defxx.* ...@@ -3066,10 +3066,16 @@ F: drivers/net/fddi/defxx.*
DELL LAPTOP DRIVER DELL LAPTOP DRIVER
M: Matthew Garrett <mjg59@srcf.ucam.org> M: Matthew Garrett <mjg59@srcf.ucam.org>
M: Pali Rohár <pali.rohar@gmail.com>
L: platform-driver-x86@vger.kernel.org L: platform-driver-x86@vger.kernel.org
S: Maintained S: Maintained
F: drivers/platform/x86/dell-laptop.c F: drivers/platform/x86/dell-laptop.c
DELL LAPTOP FREEFALL DRIVER
M: Pali Rohár <pali.rohar@gmail.com>
S: Maintained
F: drivers/platform/x86/dell-smo8800.c
DELL LAPTOP SMM DRIVER DELL LAPTOP SMM DRIVER
M: Guenter Roeck <linux@roeck-us.net> M: Guenter Roeck <linux@roeck-us.net>
S: Maintained S: Maintained
...@@ -3084,6 +3090,7 @@ F: drivers/firmware/dcdbas.* ...@@ -3084,6 +3090,7 @@ F: drivers/firmware/dcdbas.*
DELL WMI EXTRAS DRIVER DELL WMI EXTRAS DRIVER
M: Matthew Garrett <mjg59@srcf.ucam.org> M: Matthew Garrett <mjg59@srcf.ucam.org>
M: Pali Rohár <pali.rohar@gmail.com>
S: Maintained S: Maintained
F: drivers/platform/x86/dell-wmi.c F: drivers/platform/x86/dell-wmi.c
...@@ -9949,10 +9956,23 @@ S: Maintained ...@@ -9949,10 +9956,23 @@ S: Maintained
F: drivers/platform/x86/topstar-laptop.c F: drivers/platform/x86/topstar-laptop.c
TOSHIBA ACPI EXTRAS DRIVER TOSHIBA ACPI EXTRAS DRIVER
M: Azael Avalos <coproscefalo@gmail.com>
L: platform-driver-x86@vger.kernel.org L: platform-driver-x86@vger.kernel.org
S: Orphan S: Maintained
F: drivers/platform/x86/toshiba_acpi.c F: drivers/platform/x86/toshiba_acpi.c
TOSHIBA BLUETOOTH DRIVER
M: Azael Avalos <coproscefalo@gmail.com>
L: platform-driver-x86@vger.kernel.org
S: Maintained
F: drivers/platform/x86/toshiba_bluetooth.c
TOSHIBA HDD ACTIVE PROTECTION SENSOR DRIVER
M: Azael Avalos <coproscefalo@gmail.com>
L: platform-driver-x86@vger.kernel.org
S: Maintained
F: drivers/platform/x86/toshiba_haps.c
TOSHIBA SMM DRIVER TOSHIBA SMM DRIVER
M: Jonathan Buzzard <jonathan@buzzard.org.uk> M: Jonathan Buzzard <jonathan@buzzard.org.uk>
L: tlinux-users@tce.toshiba-dme.co.jp L: tlinux-users@tce.toshiba-dme.co.jp
......
...@@ -614,6 +614,7 @@ config ACPI_TOSHIBA ...@@ -614,6 +614,7 @@ config ACPI_TOSHIBA
depends on INPUT depends on INPUT
depends on RFKILL || RFKILL = n depends on RFKILL || RFKILL = n
depends on SERIO_I8042 || SERIO_I8042 = n depends on SERIO_I8042 || SERIO_I8042 = n
depends on ACPI_VIDEO || ACPI_VIDEO = n
select INPUT_POLLDEV select INPUT_POLLDEV
select INPUT_SPARSEKMAP select INPUT_SPARSEKMAP
---help--- ---help---
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/vga_switcheroo.h> #include <linux/vga_switcheroo.h>
#include <linux/vgaarb.h>
#include <acpi/video.h> #include <acpi/video.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -31,6 +32,7 @@ struct apple_gmux_data { ...@@ -31,6 +32,7 @@ struct apple_gmux_data {
bool indexed; bool indexed;
struct mutex index_lock; struct mutex index_lock;
struct pci_dev *pdev;
struct backlight_device *bdev; struct backlight_device *bdev;
/* switcheroo data */ /* switcheroo data */
...@@ -415,6 +417,23 @@ static int gmux_resume(struct device *dev) ...@@ -415,6 +417,23 @@ static int gmux_resume(struct device *dev)
return 0; return 0;
} }
static struct pci_dev *gmux_get_io_pdev(void)
{
struct pci_dev *pdev = NULL;
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev))) {
u16 cmd;
pci_read_config_word(pdev, PCI_COMMAND, &cmd);
if (!(cmd & PCI_COMMAND_IO))
continue;
return pdev;
}
return NULL;
}
static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
{ {
struct apple_gmux_data *gmux_data; struct apple_gmux_data *gmux_data;
...@@ -425,6 +444,7 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) ...@@ -425,6 +444,7 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
int ret = -ENXIO; int ret = -ENXIO;
acpi_status status; acpi_status status;
unsigned long long gpe; unsigned long long gpe;
struct pci_dev *pdev = NULL;
if (apple_gmux_data) if (apple_gmux_data)
return -EBUSY; return -EBUSY;
...@@ -475,7 +495,7 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) ...@@ -475,7 +495,7 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
ver_minor = (version >> 16) & 0xff; ver_minor = (version >> 16) & 0xff;
ver_release = (version >> 8) & 0xff; ver_release = (version >> 8) & 0xff;
} else { } else {
pr_info("gmux device not present\n"); pr_info("gmux device not present or IO disabled\n");
ret = -ENODEV; ret = -ENODEV;
goto err_release; goto err_release;
} }
...@@ -483,6 +503,23 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) ...@@ -483,6 +503,23 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
pr_info("Found gmux version %d.%d.%d [%s]\n", ver_major, ver_minor, pr_info("Found gmux version %d.%d.%d [%s]\n", ver_major, ver_minor,
ver_release, (gmux_data->indexed ? "indexed" : "classic")); ver_release, (gmux_data->indexed ? "indexed" : "classic"));
/*
* Apple systems with gmux are EFI based and normally don't use
* VGA. In addition changing IO+MEM ownership between IGP and dGPU
* disables IO/MEM used for backlight control on some systems.
* Lock IO+MEM to GPU with active IO to prevent switch.
*/
pdev = gmux_get_io_pdev();
if (pdev && vga_tryget(pdev,
VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM)) {
pr_err("IO+MEM vgaarb-locking for PCI:%s failed\n",
pci_name(pdev));
ret = -EBUSY;
goto err_release;
} else if (pdev)
pr_info("locked IO for PCI:%s\n", pci_name(pdev));
gmux_data->pdev = pdev;
memset(&props, 0, sizeof(props)); memset(&props, 0, sizeof(props));
props.type = BACKLIGHT_PLATFORM; props.type = BACKLIGHT_PLATFORM;
props.max_brightness = gmux_read32(gmux_data, GMUX_PORT_MAX_BRIGHTNESS); props.max_brightness = gmux_read32(gmux_data, GMUX_PORT_MAX_BRIGHTNESS);
...@@ -574,6 +611,10 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) ...@@ -574,6 +611,10 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
err_notify: err_notify:
backlight_device_unregister(bdev); backlight_device_unregister(bdev);
err_release: err_release:
if (gmux_data->pdev)
vga_put(gmux_data->pdev,
VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM);
pci_dev_put(pdev);
release_region(gmux_data->iostart, gmux_data->iolen); release_region(gmux_data->iostart, gmux_data->iolen);
err_free: err_free:
kfree(gmux_data); kfree(gmux_data);
...@@ -593,6 +634,11 @@ static void gmux_remove(struct pnp_dev *pnp) ...@@ -593,6 +634,11 @@ static void gmux_remove(struct pnp_dev *pnp)
&gmux_notify_handler); &gmux_notify_handler);
} }
if (gmux_data->pdev) {
vga_put(gmux_data->pdev,
VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM);
pci_dev_put(gmux_data->pdev);
}
backlight_device_unregister(gmux_data->bdev); backlight_device_unregister(gmux_data->bdev);
release_region(gmux_data->iostart, gmux_data->iolen); release_region(gmux_data->iostart, gmux_data->iolen);
......
This diff is collapsed.
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
* (1 << 1): Bluetooth enable/disable, RW. * (1 << 1): Bluetooth enable/disable, RW.
* (1 << 2): GPS enable/disable, RW. * (1 << 2): GPS enable/disable, RW.
* (1 << 3): WiFi enable/disable, RW. * (1 << 3): WiFi enable/disable, RW.
* (1 << 4): WWAN (3G) enable/disalbe, RW. * (1 << 4): WWAN (3G) enable/disable, RW.
* (1 << 5): Touchscreen enable/disable, Read Only. * (1 << 5): Touchscreen enable/disable, Read Only.
*/ */
#define OT_EC_DEVICE_STATE_ADDRESS 0xD6 #define OT_EC_DEVICE_STATE_ADDRESS 0xD6
......
This diff is collapsed.
This diff is collapsed.
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Toshiba Bluetooth Enable Driver * Toshiba Bluetooth Enable Driver
* *
* Copyright (C) 2009 Jes Sorensen <Jes.Sorensen@gmail.com> * Copyright (C) 2009 Jes Sorensen <Jes.Sorensen@gmail.com>
* Copyright (C) 2015 Azael Avalos <coproscefalo@gmail.com>
* *
* Thanks to Matthew Garrett for background info on ACPI innards which * Thanks to Matthew Garrett for background info on ACPI innards which
* normal people aren't meant to understand :-) * normal people aren't meant to understand :-)
...@@ -25,6 +26,10 @@ ...@@ -25,6 +26,10 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/acpi.h> #include <linux/acpi.h>
#define BT_KILLSWITCH_MASK 0x01
#define BT_PLUGGED_MASK 0x40
#define BT_POWER_MASK 0x80
MODULE_AUTHOR("Jes Sorensen <Jes.Sorensen@gmail.com>"); MODULE_AUTHOR("Jes Sorensen <Jes.Sorensen@gmail.com>");
MODULE_DESCRIPTION("Toshiba Laptop ACPI Bluetooth Enable Driver"); MODULE_DESCRIPTION("Toshiba Laptop ACPI Bluetooth Enable Driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -57,32 +62,107 @@ static struct acpi_driver toshiba_bt_rfkill_driver = { ...@@ -57,32 +62,107 @@ static struct acpi_driver toshiba_bt_rfkill_driver = {
.drv.pm = &toshiba_bt_pm, .drv.pm = &toshiba_bt_pm,
}; };
static int toshiba_bluetooth_present(acpi_handle handle)
{
acpi_status result;
u64 bt_present;
/*
* Some Toshiba laptops may have a fake TOS6205 device in
* their ACPI BIOS, so query the _STA method to see if there
* is really anything there.
*/
result = acpi_evaluate_integer(handle, "_STA", NULL, &bt_present);
if (ACPI_FAILURE(result)) {
pr_err("ACPI call to query Bluetooth presence failed");
return -ENXIO;
} else if (!bt_present) {
pr_info("Bluetooth device not present\n");
return -ENODEV;
}
return 0;
}
static int toshiba_bluetooth_status(acpi_handle handle)
{
acpi_status result;
u64 status;
result = acpi_evaluate_integer(handle, "BTST", NULL, &status);
if (ACPI_FAILURE(result)) {
pr_err("Could not get Bluetooth device status\n");
return -ENXIO;
}
pr_info("Bluetooth status %llu\n", status);
return status;
}
static int toshiba_bluetooth_enable(acpi_handle handle) static int toshiba_bluetooth_enable(acpi_handle handle)
{ {
acpi_status res1, res2; acpi_status result;
u64 result; bool killswitch;
bool powered;
bool plugged;
int status;
/* /*
* Query ACPI to verify RFKill switch is set to 'on'. * Query ACPI to verify RFKill switch is set to 'on'.
* If not, we return silently, no need to report it as * If not, we return silently, no need to report it as
* an error. * an error.
*/ */
res1 = acpi_evaluate_integer(handle, "BTST", NULL, &result); status = toshiba_bluetooth_status(handle);
if (ACPI_FAILURE(res1)) if (status < 0)
return res1; return status;
if (!(result & 0x01))
killswitch = (status & BT_KILLSWITCH_MASK) ? true : false;
powered = (status & BT_POWER_MASK) ? true : false;
plugged = (status & BT_PLUGGED_MASK) ? true : false;
if (!killswitch)
return 0; return 0;
/*
* This check ensures to only enable the device if it is powered
* off or detached, as some recent devices somehow pass the killswitch
* test, causing a loop enabling/disabling the device, see bug 93911.
*/
if (powered || plugged)
return 0;
result = acpi_evaluate_object(handle, "AUSB", NULL, NULL);
if (ACPI_FAILURE(result)) {
pr_err("Could not attach USB Bluetooth device\n");
return -ENXIO;
}
result = acpi_evaluate_object(handle, "BTPO", NULL, NULL);
if (ACPI_FAILURE(result)) {
pr_err("Could not power ON Bluetooth device\n");
return -ENXIO;
}
pr_info("Re-enabling Toshiba Bluetooth\n");
res1 = acpi_evaluate_object(handle, "AUSB", NULL, NULL);
res2 = acpi_evaluate_object(handle, "BTPO", NULL, NULL);
if (!ACPI_FAILURE(res1) || !ACPI_FAILURE(res2))
return 0; return 0;
}
pr_warn("Failed to re-enable Toshiba Bluetooth\n"); static int toshiba_bluetooth_disable(acpi_handle handle)
{
acpi_status result;
return -ENODEV; result = acpi_evaluate_object(handle, "BTPF", NULL, NULL);
if (ACPI_FAILURE(result)) {
pr_err("Could not power OFF Bluetooth device\n");
return -ENXIO;
}
result = acpi_evaluate_object(handle, "DUSB", NULL, NULL);
if (ACPI_FAILURE(result)) {
pr_err("Could not detach USB Bluetooth device\n");
return -ENXIO;
}
return 0;
} }
static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event) static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event)
...@@ -99,23 +179,18 @@ static int toshiba_bt_resume(struct device *dev) ...@@ -99,23 +179,18 @@ static int toshiba_bt_resume(struct device *dev)
static int toshiba_bt_rfkill_add(struct acpi_device *device) static int toshiba_bt_rfkill_add(struct acpi_device *device)
{ {
acpi_status status; int result;
u64 bt_present;
int result = -ENODEV;
/* result = toshiba_bluetooth_present(device->handle);
* Some Toshiba laptops may have a fake TOS6205 device in if (result)
* their ACPI BIOS, so query the _STA method to see if there return result;
* is really anything there, before trying to enable it.
*/ pr_info("Toshiba ACPI Bluetooth device driver\n");
status = acpi_evaluate_integer(device->handle, "_STA", NULL,
&bt_present);
if (!ACPI_FAILURE(status) && bt_present) { /* Enable the BT device */
pr_info("Detected Toshiba ACPI Bluetooth device - "
"installing RFKill handler\n");
result = toshiba_bluetooth_enable(device->handle); result = toshiba_bluetooth_enable(device->handle);
} if (result)
return result;
return result; return result;
} }
...@@ -123,7 +198,7 @@ static int toshiba_bt_rfkill_add(struct acpi_device *device) ...@@ -123,7 +198,7 @@ static int toshiba_bt_rfkill_add(struct acpi_device *device)
static int toshiba_bt_rfkill_remove(struct acpi_device *device) static int toshiba_bt_rfkill_remove(struct acpi_device *device)
{ {
/* clean up */ /* clean up */
return 0; return toshiba_bluetooth_disable(device->handle);
} }
module_acpi_driver(toshiba_bt_rfkill_driver); module_acpi_driver(toshiba_bt_rfkill_driver);
...@@ -45,7 +45,6 @@ MODULE_LICENSE("GPL"); ...@@ -45,7 +45,6 @@ MODULE_LICENSE("GPL");
#define ACPI_WMI_CLASS "wmi" #define ACPI_WMI_CLASS "wmi"
static DEFINE_MUTEX(wmi_data_lock);
static LIST_HEAD(wmi_block_list); static LIST_HEAD(wmi_block_list);
struct guid_block { struct guid_block {
...@@ -240,10 +239,10 @@ static bool find_guid(const char *guid_string, struct wmi_block **out) ...@@ -240,10 +239,10 @@ static bool find_guid(const char *guid_string, struct wmi_block **out)
if (memcmp(block->guid, guid_input, 16) == 0) { if (memcmp(block->guid, guid_input, 16) == 0) {
if (out) if (out)
*out = wblock; *out = wblock;
return 1; return true;
} }
} }
return 0; return false;
} }
static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable) static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment