These patches add five new files to sysfs.
With the first two files we are paving the way to the (hopefully)
future removal of the (now deprecated) proc entries. The remaining
entries were not ported due to the fact that they duplicate existing
kernel functionality (eg.: lcd <-> backlight, keys <-> input).
The rest add support for new features found on recent Toshiba laptops.
And the last one simply bump up the driver version.
Changes since v1:
- Added a pr_info message informing the user that the laptop needs to
reboot
Azael Avalos (6):
toshiba_acpi: Add version entry to sysfs
toshiba_acpi: Add fan entry to sysfs
toshiba_acpi: Add support for Keyboard functions mode
toshiba_acpi: Add support for Panel Power ON
toshiba_acpi: Add support to enable/disable USB 3
toshiba_acpi: Bump version number to 0.21
drivers/platform/x86/toshiba_acpi.c | 370 +++++++++++++++++++++++++++++++++++-
1 file changed, 366 insertions(+), 4 deletions(-)
--
2.2.2
This patch adds a new entry to the sysfs, showing the version of the
driver.
Signed-off-by: Azael Avalos <[email protected]>
---
drivers/platform/x86/toshiba_acpi.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 4e8a8cf..334b65e 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -1514,6 +1514,8 @@ static const struct backlight_ops toshiba_backlight_data = {
/*
* Sysfs files
*/
+static ssize_t toshiba_version_show(struct device *dev,
+ struct device_attribute *attr, char *buf);
static ssize_t toshiba_kbd_bl_mode_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count);
@@ -1566,6 +1568,7 @@ static ssize_t toshiba_usb_sleep_music_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count);
+static DEVICE_ATTR(version, S_IRUGO, toshiba_version_show, NULL);
static DEVICE_ATTR(kbd_backlight_mode, S_IRUGO | S_IWUSR,
toshiba_kbd_bl_mode_show, toshiba_kbd_bl_mode_store);
static DEVICE_ATTR(kbd_type, S_IRUGO, toshiba_kbd_type_show, NULL);
@@ -1590,6 +1593,7 @@ static DEVICE_ATTR(usb_sleep_music, S_IRUGO | S_IWUSR,
toshiba_usb_sleep_music_store);
static struct attribute *toshiba_attributes[] = {
+ &dev_attr_version.attr,
&dev_attr_kbd_backlight_mode.attr,
&dev_attr_kbd_type.attr,
&dev_attr_available_kbd_modes.attr,
@@ -1611,6 +1615,12 @@ static struct attribute_group toshiba_attr_group = {
.attrs = toshiba_attributes,
};
+static ssize_t toshiba_version_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%s\n", TOSHIBA_ACPI_VERSION);
+}
+
static ssize_t toshiba_kbd_bl_mode_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
--
2.2.2
This patch adds a fan entry to sysfs, enabling the user to get and
set the fan status.
Signed-off-by: Azael Avalos <[email protected]>
---
drivers/platform/x86/toshiba_acpi.c | 51 ++++++++++++++++++++++++++++++++++++-
1 file changed, 50 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 334b65e..413af60 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -1516,6 +1516,11 @@ static const struct backlight_ops toshiba_backlight_data = {
*/
static ssize_t toshiba_version_show(struct device *dev,
struct device_attribute *attr, char *buf);
+static ssize_t toshiba_fan_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count);
+static ssize_t toshiba_fan_show(struct device *dev,
+ struct device_attribute *attr, char *buf);
static ssize_t toshiba_kbd_bl_mode_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count);
@@ -1569,6 +1574,8 @@ static ssize_t toshiba_usb_sleep_music_store(struct device *dev,
const char *buf, size_t count);
static DEVICE_ATTR(version, S_IRUGO, toshiba_version_show, NULL);
+static DEVICE_ATTR(fan, S_IRUGO | S_IWUSR,
+ toshiba_fan_show, toshiba_fan_store);
static DEVICE_ATTR(kbd_backlight_mode, S_IRUGO | S_IWUSR,
toshiba_kbd_bl_mode_show, toshiba_kbd_bl_mode_store);
static DEVICE_ATTR(kbd_type, S_IRUGO, toshiba_kbd_type_show, NULL);
@@ -1594,6 +1601,7 @@ static DEVICE_ATTR(usb_sleep_music, S_IRUGO | S_IWUSR,
static struct attribute *toshiba_attributes[] = {
&dev_attr_version.attr,
+ &dev_attr_fan.attr,
&dev_attr_kbd_backlight_mode.attr,
&dev_attr_kbd_type.attr,
&dev_attr_available_kbd_modes.attr,
@@ -1621,6 +1629,45 @@ static ssize_t toshiba_version_show(struct device *dev,
return sprintf(buf, "%s\n", TOSHIBA_ACPI_VERSION);
}
+static ssize_t toshiba_fan_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
+ u32 result;
+ int state;
+ int ret;
+
+ ret = kstrtoint(buf, 0, &state);
+ if (ret)
+ return ret;
+
+ if (state != 0 && state != 1)
+ return -EINVAL;
+
+ result = hci_write1(toshiba, HCI_FAN, state);
+ if (result == TOS_FAILURE)
+ return -EIO;
+ else if (result == TOS_NOT_SUPPORTED)
+ return -ENODEV;
+
+ return count;
+}
+
+static ssize_t toshiba_fan_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
+ u32 value;
+ int ret;
+
+ ret = get_fan_status(toshiba, &value);
+ if (ret)
+ return ret;
+
+ return sprintf(buf, "%d\n", value);
+}
+
static ssize_t toshiba_kbd_bl_mode_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
@@ -2017,7 +2064,9 @@ static umode_t toshiba_sysfs_is_visible(struct kobject *kobj,
struct toshiba_acpi_dev *drv = dev_get_drvdata(dev);
bool exists = true;
- if (attr == &dev_attr_kbd_backlight_mode.attr)
+ if (attr == &dev_attr_fan.attr)
+ exists = (drv->fan_supported) ? true : false;
+ else if (attr == &dev_attr_kbd_backlight_mode.attr)
exists = (drv->kbd_illum_supported) ? true : false;
else if (attr == &dev_attr_kbd_backlight_timeout.attr)
exists = (drv->kbd_mode == SCI_KBD_MODE_AUTO) ? true : false;
--
2.2.2
Recent Toshiba laptops that come with the new keyboard layout have
the Special Functions (hotkeys) enabled by default, which, in order to
access the F{1-12} keys, you need to press the FN-F{1-12} key to
access such key.
This patch adds support to toggle the Keyboard Functions operation
mode by creating the sysfs entry "kbd_functions_keys", accepting only
two parameters, 0 to set the "Normal Operation" mode and 1 to set the
"Special Functions" mode, however, everytime the mode is toggled, a
restart is needed.
In the "Normal Operation" mode, the F{1-12} keys are as usual and
the hotkeys are accessed via FN-F{1-12}.
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}.
Signed-off-by: Azael Avalos <[email protected]>
---
drivers/platform/x86/toshiba_acpi.c | 100 ++++++++++++++++++++++++++++++++++++
1 file changed, 100 insertions(+)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 413af60..13b4a2b 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -126,6 +126,7 @@ MODULE_LICENSE("GPL");
#define SCI_KBD_ILLUM_STATUS 0x015c
#define SCI_USB_SLEEP_MUSIC 0x015e
#define SCI_TOUCHPAD 0x050e
+#define SCI_KBD_FUNCTION_KEYS 0x0522
/* field definitions */
#define HCI_ACCEL_MASK 0x7fff
@@ -192,6 +193,7 @@ struct toshiba_acpi_dev {
unsigned int usb_sleep_charge_supported:1;
unsigned int usb_rapid_charge_supported:1;
unsigned int usb_sleep_music_supported:1;
+ unsigned int kbd_function_keys_supported:1;
unsigned int sysfs_created:1;
struct mutex mutex;
@@ -988,6 +990,47 @@ static int toshiba_usb_sleep_music_set(struct toshiba_acpi_dev *dev, u32 state)
return 0;
}
+/* Keyboard function keys */
+static int toshiba_function_keys_get(struct toshiba_acpi_dev *dev, u32 *mode)
+{
+ u32 result;
+
+ if (!sci_open(dev))
+ return -EIO;
+
+ result = sci_read(dev, SCI_KBD_FUNCTION_KEYS, mode);
+ sci_close(dev);
+ if (result == TOS_FAILURE || result == TOS_INPUT_DATA_ERROR) {
+ pr_err("ACPI call to get KBD function keys failed\n");
+ return -EIO;
+ } else if (result == TOS_NOT_SUPPORTED) {
+ pr_info("KBD function keys not supported\n");
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+static int toshiba_function_keys_set(struct toshiba_acpi_dev *dev, u32 mode)
+{
+ u32 result;
+
+ if (!sci_open(dev))
+ return -EIO;
+
+ result = sci_write(dev, SCI_KBD_FUNCTION_KEYS, mode);
+ sci_close(dev);
+ if (result == TOS_FAILURE || result == TOS_INPUT_DATA_ERROR) {
+ pr_err("ACPI call to set KBD function keys failed\n");
+ return -EIO;
+ } else if (result == TOS_NOT_SUPPORTED) {
+ pr_info("KBD function keys not supported\n");
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
/* Bluetooth rfkill handlers */
static u32 hci_get_bt_present(struct toshiba_acpi_dev *dev, bool *present)
@@ -1572,6 +1615,12 @@ static ssize_t toshiba_usb_sleep_music_show(struct device *dev,
static ssize_t toshiba_usb_sleep_music_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count);
+static ssize_t toshiba_kbd_function_keys_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf);
+static ssize_t toshiba_kbd_function_keys_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count);
static DEVICE_ATTR(version, S_IRUGO, toshiba_version_show, NULL);
static DEVICE_ATTR(fan, S_IRUGO | S_IWUSR,
@@ -1598,6 +1647,9 @@ static DEVICE_ATTR(usb_rapid_charge, S_IRUGO | S_IWUSR,
static DEVICE_ATTR(usb_sleep_music, S_IRUGO | S_IWUSR,
toshiba_usb_sleep_music_show,
toshiba_usb_sleep_music_store);
+static DEVICE_ATTR(kbd_function_keys, S_IRUGO | S_IWUSR,
+ toshiba_kbd_function_keys_show,
+ toshiba_kbd_function_keys_store);
static struct attribute *toshiba_attributes[] = {
&dev_attr_version.attr,
@@ -1612,6 +1664,7 @@ static struct attribute *toshiba_attributes[] = {
&dev_attr_sleep_functions_on_battery.attr,
&dev_attr_usb_rapid_charge.attr,
&dev_attr_usb_sleep_music.attr,
+ &dev_attr_kbd_function_keys.attr,
NULL,
};
@@ -2057,6 +2110,48 @@ static ssize_t toshiba_usb_sleep_music_store(struct device *dev,
return count;
}
+static ssize_t toshiba_kbd_function_keys_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
+ int mode;
+ int ret;
+
+ ret = toshiba_function_keys_get(toshiba, &mode);
+ if (ret < 0)
+ return ret;
+
+ return sprintf(buf, "%d\n", mode);
+}
+
+static ssize_t toshiba_kbd_function_keys_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
+ int mode;
+ int ret;
+
+ ret = kstrtoint(buf, 0, &mode);
+ if (ret)
+ return ret;
+ /* Check for the function keys mode where:
+ * 0 - Normal operation (F{1-12} as usual and hotkeys via FN-F{1-12})
+ * 1 - Special functions (Opposite of the above setting)
+ */
+ if (mode != 0 && mode != 1)
+ return -EINVAL;
+
+ ret = toshiba_function_keys_set(toshiba, mode);
+ if (ret)
+ return ret;
+
+ pr_info("Reboot for changes to KBD Function Keys to take effect");
+
+ return count;
+}
+
static umode_t toshiba_sysfs_is_visible(struct kobject *kobj,
struct attribute *attr, int idx)
{
@@ -2082,6 +2177,8 @@ static umode_t toshiba_sysfs_is_visible(struct kobject *kobj,
exists = (drv->usb_rapid_charge_supported) ? true : false;
else if (attr == &dev_attr_usb_sleep_music.attr)
exists = (drv->usb_sleep_music_supported) ? true : false;
+ else if (attr == &dev_attr_kbd_function_keys.attr)
+ exists = (drv->kbd_function_keys_supported) ? true : false;
return exists ? attr->mode : 0;
}
@@ -2500,6 +2597,9 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
ret = toshiba_usb_sleep_music_get(dev, &dummy);
dev->usb_sleep_music_supported = !ret;
+ ret = toshiba_function_keys_get(dev, &dummy);
+ dev->kbd_function_keys_supported = !ret;
+
/* Determine whether or not BIOS supports fan and video interfaces */
ret = get_video_status(dev, &dummy);
--
2.2.2
Toshiba laptops come with a feature called "Panel Open - Power ON",
which makes the laptop turn on whenever the LID is opened.
This patch adds support for such feature, by creating a sysfs entry
named "panel_power_on", accepting only two values, 0 to disable and
1 to enable such feature, however, a reboot is needed on every mode
change.
Signed-off-by: Azael Avalos <[email protected]>
---
drivers/platform/x86/toshiba_acpi.c | 100 ++++++++++++++++++++++++++++++++++++
1 file changed, 100 insertions(+)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 13b4a2b..41f58f2 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -121,6 +121,7 @@ MODULE_LICENSE("GPL");
#define HCI_KBD_ILLUMINATION 0x0095
#define HCI_ECO_MODE 0x0097
#define HCI_ACCELEROMETER2 0x00a6
+#define SCI_PANEL_POWER_ON 0x010d
#define SCI_ILLUMINATION 0x014e
#define SCI_USB_SLEEP_CHARGE 0x0150
#define SCI_KBD_ILLUM_STATUS 0x015c
@@ -194,6 +195,7 @@ struct toshiba_acpi_dev {
unsigned int usb_rapid_charge_supported:1;
unsigned int usb_sleep_music_supported:1;
unsigned int kbd_function_keys_supported:1;
+ unsigned int panel_power_on_supported:1;
unsigned int sysfs_created:1;
struct mutex mutex;
@@ -1031,6 +1033,51 @@ static int toshiba_function_keys_set(struct toshiba_acpi_dev *dev, u32 mode)
return 0;
}
+/* Panel Power ON */
+static int toshiba_panel_power_on_get(struct toshiba_acpi_dev *dev, u32 *state)
+{
+ u32 result;
+
+ if (!sci_open(dev))
+ return -EIO;
+
+ result = sci_read(dev, SCI_PANEL_POWER_ON, state);
+ sci_close(dev);
+ if (result == TOS_FAILURE) {
+ pr_err("ACPI call to get Panel Power ON failed\n");
+ return -EIO;
+ } else if (result == TOS_NOT_SUPPORTED) {
+ pr_info("Panel Power on not supported\n");
+ return -ENODEV;
+ } else if (result == TOS_INPUT_DATA_ERROR) {
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int toshiba_panel_power_on_set(struct toshiba_acpi_dev *dev, u32 state)
+{
+ u32 result;
+
+ if (!sci_open(dev))
+ return -EIO;
+
+ result = sci_write(dev, SCI_PANEL_POWER_ON, state);
+ sci_close(dev);
+ if (result == TOS_FAILURE) {
+ pr_err("ACPI call to set Panel Power ON failed\n");
+ return -EIO;
+ } else if (result == TOS_NOT_SUPPORTED) {
+ pr_info("Panel Power ON not supported\n");
+ return -ENODEV;
+ } else if (result == TOS_INPUT_DATA_ERROR) {
+ return -EIO;
+ }
+
+ return 0;
+}
+
/* Bluetooth rfkill handlers */
static u32 hci_get_bt_present(struct toshiba_acpi_dev *dev, bool *present)
@@ -1621,6 +1668,12 @@ static ssize_t toshiba_kbd_function_keys_show(struct device *dev,
static ssize_t toshiba_kbd_function_keys_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count);
+static ssize_t toshiba_panel_power_on_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf);
+static ssize_t toshiba_panel_power_on_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count);
static DEVICE_ATTR(version, S_IRUGO, toshiba_version_show, NULL);
static DEVICE_ATTR(fan, S_IRUGO | S_IWUSR,
@@ -1650,6 +1703,9 @@ static DEVICE_ATTR(usb_sleep_music, S_IRUGO | S_IWUSR,
static DEVICE_ATTR(kbd_function_keys, S_IRUGO | S_IWUSR,
toshiba_kbd_function_keys_show,
toshiba_kbd_function_keys_store);
+static DEVICE_ATTR(panel_power_on, S_IRUGO | S_IWUSR,
+ toshiba_panel_power_on_show,
+ toshiba_panel_power_on_store);
static struct attribute *toshiba_attributes[] = {
&dev_attr_version.attr,
@@ -1665,6 +1721,7 @@ static struct attribute *toshiba_attributes[] = {
&dev_attr_usb_rapid_charge.attr,
&dev_attr_usb_sleep_music.attr,
&dev_attr_kbd_function_keys.attr,
+ &dev_attr_panel_power_on.attr,
NULL,
};
@@ -2152,6 +2209,44 @@ static ssize_t toshiba_kbd_function_keys_store(struct device *dev,
return count;
}
+static ssize_t toshiba_panel_power_on_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
+ u32 state;
+ int ret;
+
+ ret = toshiba_panel_power_on_get(toshiba, &state);
+ if (ret < 0)
+ return ret;
+
+ return sprintf(buf, "%d\n", state);
+}
+
+static ssize_t toshiba_panel_power_on_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
+ int state;
+ int ret;
+
+ ret = kstrtoint(buf, 0, &state);
+ if (ret)
+ return ret;
+ if (state != 0 && state != 1)
+ return -EINVAL;
+
+ ret = toshiba_panel_power_on_set(toshiba, state);
+ if (ret)
+ return ret;
+
+ pr_info("Reboot for changes to Panel Power ON to take effect");
+
+ return count;
+}
+
static umode_t toshiba_sysfs_is_visible(struct kobject *kobj,
struct attribute *attr, int idx)
{
@@ -2179,6 +2274,8 @@ static umode_t toshiba_sysfs_is_visible(struct kobject *kobj,
exists = (drv->usb_sleep_music_supported) ? true : false;
else if (attr == &dev_attr_kbd_function_keys.attr)
exists = (drv->kbd_function_keys_supported) ? true : false;
+ else if (attr == &dev_attr_panel_power_on.attr)
+ exists = (drv->panel_power_on_supported) ? true : false;
return exists ? attr->mode : 0;
}
@@ -2600,6 +2697,9 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
ret = toshiba_function_keys_get(dev, &dummy);
dev->kbd_function_keys_supported = !ret;
+ ret = toshiba_panel_power_on_get(dev, &dummy);
+ dev->panel_power_on_supported = !ret;
+
/* Determine whether or not BIOS supports fan and video interfaces */
ret = get_video_status(dev, &dummy);
--
2.2.2
Toshiba laptops that come with USB 3 ports have a feature that lets
them disable USB 3 functionality and act as a regular USB 2 port, and
thus, saving power.
This patch adds support to that feature, by creating a sysfs entry
named "usb_three", acceptig only two parameters, 0 to disable the
USB 3 (acting as a USB 2) and 1 to enable it, however, a reboot is
needed everytime this is toggled.
Signed-off-by: Azael Avalos <[email protected]>
---
drivers/platform/x86/toshiba_acpi.c | 103 ++++++++++++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 41f58f2..09921de 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -126,6 +126,7 @@ MODULE_LICENSE("GPL");
#define SCI_USB_SLEEP_CHARGE 0x0150
#define SCI_KBD_ILLUM_STATUS 0x015c
#define SCI_USB_SLEEP_MUSIC 0x015e
+#define SCI_USB_THREE 0x0169
#define SCI_TOUCHPAD 0x050e
#define SCI_KBD_FUNCTION_KEYS 0x0522
@@ -196,6 +197,7 @@ struct toshiba_acpi_dev {
unsigned int usb_sleep_music_supported:1;
unsigned int kbd_function_keys_supported:1;
unsigned int panel_power_on_supported:1;
+ unsigned int usb_three_supported:1;
unsigned int sysfs_created:1;
struct mutex mutex;
@@ -1078,6 +1080,51 @@ static int toshiba_panel_power_on_set(struct toshiba_acpi_dev *dev, u32 state)
return 0;
}
+/* USB Three */
+static int toshiba_usb_three_get(struct toshiba_acpi_dev *dev, u32 *state)
+{
+ u32 result;
+
+ if (!sci_open(dev))
+ return -EIO;
+
+ result = sci_read(dev, SCI_USB_THREE, state);
+ sci_close(dev);
+ if (result == TOS_FAILURE) {
+ pr_err("ACPI call to get USB 3 failed\n");
+ return -EIO;
+ } else if (result == TOS_NOT_SUPPORTED) {
+ pr_info("USB 3 not supported\n");
+ return -ENODEV;
+ } else if (result == TOS_INPUT_DATA_ERROR) {
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int toshiba_usb_three_set(struct toshiba_acpi_dev *dev, u32 state)
+{
+ u32 result;
+
+ if (!sci_open(dev))
+ return -EIO;
+
+ result = sci_write(dev, SCI_USB_THREE, state);
+ sci_close(dev);
+ if (result == TOS_FAILURE) {
+ pr_err("ACPI call to set USB 3 failed\n");
+ return -EIO;
+ } else if (result == TOS_NOT_SUPPORTED) {
+ pr_info("USB 3 not supported\n");
+ return -ENODEV;
+ } else if (result == TOS_INPUT_DATA_ERROR) {
+ return -EIO;
+ }
+
+ return 0;
+}
+
/* Bluetooth rfkill handlers */
static u32 hci_get_bt_present(struct toshiba_acpi_dev *dev, bool *present)
@@ -1674,6 +1721,12 @@ static ssize_t toshiba_panel_power_on_show(struct device *dev,
static ssize_t toshiba_panel_power_on_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count);
+static ssize_t toshiba_usb_three_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf);
+static ssize_t toshiba_usb_three_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count);
static DEVICE_ATTR(version, S_IRUGO, toshiba_version_show, NULL);
static DEVICE_ATTR(fan, S_IRUGO | S_IWUSR,
@@ -1706,6 +1759,8 @@ static DEVICE_ATTR(kbd_function_keys, S_IRUGO | S_IWUSR,
static DEVICE_ATTR(panel_power_on, S_IRUGO | S_IWUSR,
toshiba_panel_power_on_show,
toshiba_panel_power_on_store);
+static DEVICE_ATTR(usb_three, S_IRUGO | S_IWUSR,
+ toshiba_usb_three_show, toshiba_usb_three_store);
static struct attribute *toshiba_attributes[] = {
&dev_attr_version.attr,
@@ -1722,6 +1777,7 @@ static struct attribute *toshiba_attributes[] = {
&dev_attr_usb_sleep_music.attr,
&dev_attr_kbd_function_keys.attr,
&dev_attr_panel_power_on.attr,
+ &dev_attr_usb_three.attr,
NULL,
};
@@ -2247,6 +2303,48 @@ static ssize_t toshiba_panel_power_on_store(struct device *dev,
return count;
}
+static ssize_t toshiba_usb_three_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
+ u32 state;
+ int ret;
+
+ ret = toshiba_usb_three_get(toshiba, &state);
+ if (ret < 0)
+ return ret;
+
+ return sprintf(buf, "%d\n", state);
+}
+
+static ssize_t toshiba_usb_three_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
+ int state;
+ int ret;
+
+ ret = kstrtoint(buf, 0, &state);
+ if (ret)
+ return ret;
+ /* Check for USB 3 mode where:
+ * 0 - Disabled (Acts like a USB 2 port, saving power)
+ * 1 - Enabled
+ */
+ if (state != 0 && state != 1)
+ return -EINVAL;
+
+ ret = toshiba_usb_three_set(toshiba, state);
+ if (ret)
+ return ret;
+
+ pr_info("Reboot for changes to USB 3 to take effect");
+
+ return count;
+}
+
static umode_t toshiba_sysfs_is_visible(struct kobject *kobj,
struct attribute *attr, int idx)
{
@@ -2276,6 +2374,8 @@ static umode_t toshiba_sysfs_is_visible(struct kobject *kobj,
exists = (drv->kbd_function_keys_supported) ? true : false;
else if (attr == &dev_attr_panel_power_on.attr)
exists = (drv->panel_power_on_supported) ? true : false;
+ else if (attr == &dev_attr_usb_three.attr)
+ exists = (drv->usb_three_supported) ? true : false;
return exists ? attr->mode : 0;
}
@@ -2700,6 +2800,9 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
ret = toshiba_panel_power_on_get(dev, &dummy);
dev->panel_power_on_supported = !ret;
+ ret = toshiba_usb_three_get(dev, &dummy);
+ dev->usb_three_supported = !ret;
+
/* Determine whether or not BIOS supports fan and video interfaces */
ret = get_video_status(dev, &dummy);
--
2.2.2
Several new features were added on previous patches, so lets bump up
the driver version.
And also, update the copyright year.
Signed-off-by: Azael Avalos <[email protected]>
---
drivers/platform/x86/toshiba_acpi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 09921de..52e4647 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -5,7 +5,7 @@
* Copyright (C) 2002-2004 John Belmonte
* Copyright (C) 2008 Philip Langdale
* Copyright (C) 2010 Pierre Ducroquet
- * Copyright (C) 2014 Azael Avalos
+ * Copyright (C) 2014-2015 Azael Avalos
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,7 +38,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-#define TOSHIBA_ACPI_VERSION "0.20"
+#define TOSHIBA_ACPI_VERSION "0.21"
#define PROC_INTERFACE_VERSION 1
#include <linux/kernel.h>
--
2.2.2
On Tue, Feb 10, 2015 at 09:09:15PM -0700, Azael Avalos wrote:
> These patches add five new files to sysfs.
>
> With the first two files we are paving the way to the (hopefully)
> future removal of the (now deprecated) proc entries. The remaining
> entries were not ported due to the fact that they duplicate existing
> kernel functionality (eg.: lcd <-> backlight, keys <-> input).
>
> The rest add support for new features found on recent Toshiba laptops.
>
> And the last one simply bump up the driver version.
>
> Changes since v1:
> - Added a pr_info message informing the user that the laptop needs to
> reboot
Thanks Azael, queued.
--
Darren Hart
Intel Open Source Technology Center