toshiba_acpi: Add new features plus some procfs ports
Subsystems (2)
Azael Avalos
maintainercover toshiba_acpi: Add new features plus some procfs ports
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.
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 | 364 +++++++++++++++++++++++++++++++++++- 1 file changed, 360 insertions(+), 4 deletions(-)
Signature · 1 line
2.2.2
Azael Avalos
maintainerPATCH RESEND 1/6 toshiba_acpi: Add version entry to sysfs
This patch adds a new entry to the sysfs, showing the version of the driver.
--- drivers/platform/x86/toshiba_acpi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/platform/x86/toshiba_acpi.c +10 -0
@@ -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)
Signature · 1 line
2.2.2
Azael Avalos
maintainerPATCH RESEND 2/6 toshiba_acpi: Add fan entry to sysfs
In reply to Azael AvalosThis patch adds a fan entry to sysfs, enabling the user to get and set the fan status.
--- drivers/platform/x86/toshiba_acpi.c | 51 ++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-)
drivers/platform/x86/toshiba_acpi.c +50 -1
@@ -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;
Signature · 1 line
2.2.2
Re: [PATCH resend 2/6] toshiba_acpi: Add fan entry to sysfs
Quoted 3 lines · Azael Avalos
This patch adds a fan entry to sysfs, enabling the user to get and set the fan status.
Hi Azael,
I was finally getting around to these when you resent them. Apologies for the delay. Travel and still fighting a cold/flu/bug. Sigh. Anyway... on to patch review :-)
Quoted 22 lines
Signed-off-by Azael Avalos <[email protected]>--- drivers/platform/x86/toshiba_acpi.c | 51 ++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-)drivers/platform/x86/toshiba_acpi.c +5
-0@@ -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);
drivers/platform/x86/toshiba_acpi.c static ssize_t toshiba_usb_sleep_music_store(struct device *dev, · line 1581
Quoted 8 lines
drivers/platform/x86/toshiba_acpi.c +2
-0@@ -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);
At some point, before we add too much more, it would be nice to convert these over to DEVICE_ATTR_RW and DEVICE_ATTR_RO. Any reason not to do this sooner rather than later?
Quoted 24 lines
drivers/platform/x86/toshiba_acpi.c +13
-0@@ -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;
drivers/platform/x86/toshiba_acpi.c static ssize_t toshiba_version_show(struct device *dev, · line 1653
Quoted 10 lines
drivers/platform/x86/toshiba_acpi.c +10
-0+ +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 ; +
A quick scan of hci_write1 makes me wonder if there are more than two possible failures. Should we also have an "else if (result)" or "else if (result != WHATEVER_SUCCESS_IS)" before we assume success and return count?
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Azael Avalos
maintainerRe: [PATCH resend 2/6] toshiba_acpi: Add fan entry to sysfs
Hi Darren,
2015-02-09 21:02 GMT-07:00 Darren Hart <[email protected]>:
Quoted 10 lines · Azael Avalos
Quoted 3 lines
This patch adds a fan entry to sysfs, enabling the user to get and set the fan status.
Hi Azael,
I was finally getting around to these when you resent them. Apologies for the delay. Travel and still fighting a cold/flu/bug. Sigh. Anyway... on to patch review :-)
Sorry for the rushing of the patches, hope you're better now, in case you're still in recovery, take my motto "la cerveza cura todo" into account XD
Quoted 25 lines
Quoted 25 lines
Signed-off-by Azael Avalos <[email protected]>--- drivers/platform/x86/toshiba_acpi.c | 51 ++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-)drivers/platform/x86/toshiba_acpi.c +5
-0@@ -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);
Quoted 10 lines
drivers/platform/x86/toshiba_acpi.c static ssize_t toshiba_usb_sleep_music_store(struct device *dev, · line 1581
Quoted 6 lines
drivers/platform/x86/toshiba_acpi.c +2
-0static 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);At some point, before we add too much more, it would be nice to convert these over to
DEVICE_ATTR_RWandDEVICE_ATTR_RO. Any reason not to do this sooner rather than later?
I have patches ready for all the functions in sysfs regarding this change, I just wanted the patches to land in you tree (or next) to send them for 3.21, I'll be in janitor mode after these patches, cleaning the driver according to coding style, add files to Documentation/ABI, etc..
Quoted 31 lines
Quoted 31 lines
drivers/platform/x86/toshiba_acpi.c +19
-0@@ -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 )
Quoted 8 lines
drivers/platform/x86/toshiba_acpi.c static ssize_t toshiba_version_show(struct device *dev, · line 1653
Quoted 4 lines
drivers/platform/x86/toshiba_acpi.c +4
-0+return -EIO ; + else if (result == TOS_NOT_SUPPORTED) + return -ENODEV; +A quick scan of
hci_write1makes me wonder if there are more than two possible failures. Should we also have an "else if (result)" or "else if (result !=WHATEVER_SUCCESS_IS)" before we assume success and return count?
Can't really tell you, I just ported the code "as-is" from the procfs files, and to be honest, I haven't seen this function in any recent Toshiba laptop out there,
I just wanted to port this in case some old laptop/app/script/etc. is still using this.
Quoted 4 lines
--
Darren Hart
Intel Open Source Technology Center
Cheers
Azael
Signature · 1 line
-- El mundo apesta y vosotros apestais tambien --
Azael Avalos
maintainerPATCH RESEND 3/6 toshiba_acpi: Add support for Keyboard functions mode
In reply to Azael AvalosRecent 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}.
--- drivers/platform/x86/toshiba_acpi.c | 98 +++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+)
drivers/platform/x86/toshiba_acpi.c +98 -0
@@ -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,46 @@ 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; + +return count; +} +static umode_t toshiba_sysfs_is_visible (struct kobject *kobj,struct attribute *attr,int idx) {
@@ -2082,6 +2175,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 +2595,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);
Signature · 1 line
2.2.2
Re: [PATCH resend 3/6] toshiba_acpi: Add support for Keyboard functions mode
Quoted 10 lines · Azael Avalos
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.
Erm... that's kinda horrible :-/
A couple of questions then.
1) Does the system BIOS offer a way to select one mode or the other? If so, no point in adding it here if a reboot is required.
2) Where Toshiba supports this (Windows?) is a reboot required?
Rather than having to reboot, would a userspace mapping possibly be preferable? Could be done without a reboot.
Finally, if we keep this, we need to print something to the system log indicating success - and that a reboot is required to take effect.
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Azael Avalos
maintainerRe: [PATCH resend 3/6] toshiba_acpi: Add support for Keyboard functions mode
Hi Darren,
2015-02-09 21:08 GMT-07:00 Darren Hart <[email protected]>:
Quoted 12 lines · Azael Avalos
Quoted 10 lines
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.
Quoted 6 lines
Erm... that's kinda horrible :-/
A couple of questions then.
1) Does the system BIOS offer a way to select one mode or the other? If so, no point in adding it here if a reboot is required.
Yes, I just wanted to make the driver on Linux on par with its Windows counterpart.
Quoted 2 lines
2) Where Toshiba supports this (Windows?) is a reboot required?
Windows 7 and up, and yes, a reboot is required on Windows too.
Quoted 3 lines
Rather than having to reboot, would a userspace mapping possibly be preferable? Could be done without a reboot.
Nope, it sets some value into a BIOS variable (register?), not even unloading/loading
the module helps.
Quoted 3 lines
Finally, if we keep this, we need to print something to the system log indicating success - and that a reboot is required to take effect.
Sure, that's no problem, its your call to keep it or drop it, just let me know as to send an updated version.
Quoted 4 lines
--
Darren Hart
Intel Open Source Technology Center
Cheers
Azael
Signature · 1 line
-- El mundo apesta y vosotros apestais tambien --
Azael Avalos
maintainerPATCH RESEND 4/6 toshiba_acpi: Add support for Panel Power ON
In reply to Azael AvalosToshiba 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.
--- drivers/platform/x86/toshiba_acpi.c | 98 +++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+)
drivers/platform/x86/toshiba_acpi.c +98 -0
@@ -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, };
@@ -2150,6 +2207,42 @@ 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; + +return count; +} +static umode_t toshiba_sysfs_is_visible (struct kobject *kobj,struct attribute *attr,int idx) {
@@ -2177,6 +2270,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 ; }
@@ -2598,6 +2693,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);
Signature · 1 line
2.2.2
Azael Avalos
maintainerPATCH RESEND 5/6 toshiba_acpi: Add support to enable/disable USB 3
In reply to Azael AvalosToshiba 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.
--- drivers/platform/x86/toshiba_acpi.c | 101 ++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+)
drivers/platform/x86/toshiba_acpi.c +101 -0
@@ -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, };
@@ -2243,6 +2299,46 @@ 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; + +return count; +} +static umode_t toshiba_sysfs_is_visible (struct kobject *kobj,struct attribute *attr,int idx) {
@@ -2272,6 +2368,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 ; }
@@ -2696,6 +2794,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);
Signature · 1 line
2.2.2
Re: [PATCH resend 5/6] toshiba_acpi: Add support to enable/disable USB 3
Quoted 8 lines · Azael Avalos
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.
Similar question, does the system BIOS allow you to configure this setting? If so, what would be the value for enabling it in the OS directly?
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Azael Avalos
maintainerRe: [PATCH resend 5/6] toshiba_acpi: Add support to enable/disable USB 3
Hi Darren,
2015-02-09 21:11 GMT-07:00 Darren Hart <[email protected]>:
Quoted 5 lines · Azael Avalos
Quoted 4 lines
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.
Quoted 7 lines
Quoted 4 lines
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.Similar question, does the system BIOS allow you to configure this setting? If so, what would be the value for enabling it in the OS directly?
Yes.
A Toshiba provided app lets you configure all these parameters from Windows, and so, I'm developing a similar app for this, a few clicks and your settings are
changed on the next reboot :-)
Quoted 4 lines
--
Darren Hart
Intel Open Source Technology Center
Cheers
Azael
Signature · 1 line
-- El mundo apesta y vosotros apestais tambien --
Re: [PATCH resend 5/6] toshiba_acpi: Add support to enable/disable USB 3
Quoted 13 lines · Azael Avalos
Hi Darren,
2015-02-09 21:11 GMT-07:00 Darren Hart <[email protected]>:
Quoted 10 lines · Azael Avalos
Quoted 8 lines
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.
Quoted 4 lines
Quoted 2 lines
Similar question, does the system BIOS allow you to configure this setting? If so, what would be the value for enabling it in the OS directly?
Yes.
Yes it's available in the BIOS?
Quoted 5 lines
A Toshiba provided app lets you configure all these parameters from Windows, and so, I'm developing a similar app for this, a few clicks and your settings are
changed on the next reboot :-)
And I understand now that independent of the BIOS question, Windows has a program to make these changes. Blech. Going to think on these overnight and get back to you.
I'd welcome the thoughts of the previous maintainers as to whether we want to include these kinds of OS-parity changes in the kernel. I'm probably leaning toward taking them.
Matthew, Len, is there some kind of precedent I need to be aware of here?
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Azael Avalos
maintainerRe: [PATCH resend 5/6] toshiba_acpi: Add support to enable/disable USB 3
Hi Darren,
2015-02-09 21:55 GMT-07:00 Darren Hart <[email protected]>:
Quoted 14 lines · Azael Avalos
Quoted 13 lines
Hi Darren,
2015-02-09 21:11 GMT-07:00 Darren Hart <[email protected]>:
Quoted 10 lines · Azael Avalos
Quoted 8 lines
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.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Similar question, does the system BIOS allow you to configure this setting? If so, what would be the value for enabling it in the OS directly?
Yes.
Yes it's available in the BIOS?
Yes, it is available in the BIOS, sorry for not making that clear.
Quoted 7 lines
Quoted 6 lines
A Toshiba provided app lets you configure all these parameters from Windows, and so, I'm developing a similar app for this, a few clicks and your settings are
changed on the next reboot :-)
Quoted 7 lines
And I understand now that independent of the BIOS question, Windows has a program to make these changes. Blech. Going to think on these overnight and get back to you.
I'd welcome the thoughts of the previous maintainers as to whether we want to include these kinds of OS-parity changes in the kernel. I'm probably leaning toward taking them.
Just let me know as to send a refreshed set of patches.
Quoted 6 lines
Matthew, Len, is there some kind of precedent I need to be aware of here?
--
Darren Hart
Intel Open Source Technology Center
Cheers
Azael
Signature · 1 line
-- El mundo apesta y vosotros apestais tambien --
Re: [PATCH resend 5/6] toshiba_acpi: Add support to enable/disable USB 3
Quoted 3 lines · Azael Avalos
Hi Darren,
Just let me know as to send a refreshed set of patches.
Go ahead and resend this series and I'll take them in.
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Re: [PATCH resend 5/6] toshiba_acpi: Add support to enable/disable USB 3
In reply to Darren HartQuoted 3 lines · Darren Hart
I'd welcome the thoughts of the previous maintainers as to whether we want to include these kinds of OS-parity changes in the kernel. I'm probably leaning toward taking them.
The only real thing is whether there's any way to create a generic interface for it. In this case, I suspect not and that this is fine.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH resend 5/6] toshiba_acpi: Add support to enable/disable USB 3
Quoted 8 lines · Matthew Garrett
Quoted 3 lines · Darren Hart
I'd welcome the thoughts of the previous maintainers as to whether we want to include these kinds of OS-parity changes in the kernel. I'm probably leaning toward taking them.
The only real thing is whether there's any way to create a generic interface for it. In this case, I suspect not and that this is fine.
Agreed, thanks Matthew.
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Azael Avalos
maintainerPATCH RESEND 6/6 toshiba_acpi: Bump version number to 0.21
In reply to Azael AvalosSeveral new features were added on previous patches, so lets bump up the driver version.
And also, update the copyright year.
--- drivers/platform/x86/toshiba_acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/toshiba_acpi.c +2 -2
@@ -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>
Signature · 1 line
2.2.2