* [PATCH 0/3] toshiba_acpi: Add support for Cooling Method
@ 2016-01-25 18:29 Azael Avalos
2016-01-25 18:29 ` [PATCH 1/3] toshiba_acpi: Add support for cooling method feature Azael Avalos
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Azael Avalos @ 2016-01-25 18:29 UTC (permalink / raw)
To: Darren Hart, platform-driver-x86, linux-kernel; +Cc: Azael Avalos
These patches add support for the Cooling Method feature found in most
Toshiba laptops, allowing userspace to control the desired cooling method,
which are the following:
0 - Maximum Performance
1 - Peformance
2 - Battery Optimized
The Cooling Method feature basically controls the speed of the system fan,
setting the speed (and quietness) according to the selected method.
The default value at every boot is zero (Maximum Performance), on Windows,
Toshiba provides hooks to the power management system, allowing
the user to change it according to their needs and/or the AC adapter state.
Azael Avalos (3):
toshiba_acpi: Add support for cooling method feature
toshiba_acpi: Add sysfs entries for th Cooling Method feature
Documentation/ABI: Update sysfs-driver-toshiba_acpi file
.../ABI/testing/sysfs-driver-toshiba_acpi | 16 ++++
drivers/platform/x86/toshiba_acpi.c | 105 +++++++++++++++++++++
2 files changed, 121 insertions(+)
--
2.7.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] toshiba_acpi: Add support for cooling method feature
2016-01-25 18:29 [PATCH 0/3] toshiba_acpi: Add support for Cooling Method Azael Avalos
@ 2016-01-25 18:29 ` Azael Avalos
2016-01-25 18:29 ` [PATCH 2/2] toshiba_acpi: Add sysfs entries for the Cooling Method feature Azael Avalos
2016-02-07 20:24 ` [PATCH 0/3] toshiba_acpi: Add support for Cooling Method Darren Hart
2 siblings, 0 replies; 4+ messages in thread
From: Azael Avalos @ 2016-01-25 18:29 UTC (permalink / raw)
To: Darren Hart, platform-driver-x86, linux-kernel; +Cc: Azael Avalos
This patch adds support to query and set the "Cooling Method" feature,
which basically changes how the system fan behaves, depending on the
supported cooling methods.
Depending on the laptop model, these are the (so far...) available
cooling methods:
- Maximum Performance
- Performance
- Battery Optimized
Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
---
drivers/platform/x86/toshiba_acpi.c | 54 +++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 7383307..c6f92ec 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -117,6 +117,7 @@ MODULE_LICENSE("GPL");
#define HCI_LCD_BRIGHTNESS 0x002a
#define HCI_WIRELESS 0x0056
#define HCI_ACCELEROMETER 0x006d
+#define HCI_COOLING_METHOD 0x007f
#define HCI_KBD_ILLUMINATION 0x0095
#define HCI_ECO_MODE 0x0097
#define HCI_ACCELEROMETER2 0x00a6
@@ -186,6 +187,7 @@ struct toshiba_acpi_dev {
int usbsc_bat_level;
int usbsc_mode_base;
int hotkey_event_type;
+ int max_cooling_method;
unsigned int illumination_supported:1;
unsigned int video_supported:1;
@@ -205,6 +207,7 @@ struct toshiba_acpi_dev {
unsigned int panel_power_on_supported:1;
unsigned int usb_three_supported:1;
unsigned int wwan_supported:1;
+ unsigned int cooling_method_supported:1;
unsigned int sysfs_created:1;
unsigned int special_functions;
@@ -1194,6 +1197,53 @@ static int toshiba_wwan_set(struct toshiba_acpi_dev *dev, u32 state)
return out[0] == TOS_SUCCESS ? 0 : -EIO;
}
+/* Cooling Method */
+static void toshiba_cooling_method_available(struct toshiba_acpi_dev *dev)
+{
+ u32 in[TCI_WORDS] = { HCI_GET, HCI_COOLING_METHOD, 0, 0, 0, 0 };
+ u32 out[TCI_WORDS];
+ acpi_status status;
+
+ dev->cooling_method_supported = 0;
+ dev->max_cooling_method = 0;
+
+ status = tci_raw(dev, in, out);
+ if (ACPI_FAILURE(status))
+ pr_err("ACPI call to get Cooling Method failed\n");
+
+ if (out[0] != TOS_SUCCESS && out[0] != TOS_SUCCESS2)
+ return;
+
+ dev->cooling_method_supported = 1;
+ dev->max_cooling_method = out[3];
+}
+
+static int toshiba_cooling_method_get(struct toshiba_acpi_dev *dev, u32 *state)
+{
+ u32 result = hci_read(dev, HCI_COOLING_METHOD, state);
+
+ if (result == TOS_FAILURE)
+ pr_err("ACPI call to get Cooling Method failed\n");
+
+ if (result == TOS_NOT_SUPPORTED)
+ return -ENODEV;
+
+ return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO;
+}
+
+static int toshiba_cooling_method_set(struct toshiba_acpi_dev *dev, u32 state)
+{
+ u32 result = hci_write(dev, HCI_COOLING_METHOD, state);
+
+ if (result == TOS_FAILURE)
+ pr_err("ACPI call to get Cooling Method failed\n");
+
+ if (result == TOS_NOT_SUPPORTED)
+ return -ENODEV;
+
+ return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO;
+}
+
/* Transflective Backlight */
static int get_tr_backlight_status(struct toshiba_acpi_dev *dev, u32 *status)
{
@@ -2779,6 +2829,8 @@ static void print_supported_features(struct toshiba_acpi_dev *dev)
pr_cont(" usb3");
if (dev->wwan_supported)
pr_cont(" wwan");
+ if (dev->cooling_method_supported)
+ pr_cont(" cooling-method");
pr_cont("\n");
}
@@ -2963,6 +3015,8 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
if (dev->wwan_supported)
toshiba_acpi_setup_wwan_rfkill(dev);
+ toshiba_cooling_method_available(dev);
+
print_supported_features(dev);
ret = sysfs_create_group(&dev->acpi_dev->dev.kobj,
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] toshiba_acpi: Add sysfs entries for the Cooling Method feature
2016-01-25 18:29 [PATCH 0/3] toshiba_acpi: Add support for Cooling Method Azael Avalos
2016-01-25 18:29 ` [PATCH 1/3] toshiba_acpi: Add support for cooling method feature Azael Avalos
@ 2016-01-25 18:29 ` Azael Avalos
2016-02-07 20:24 ` [PATCH 0/3] toshiba_acpi: Add support for Cooling Method Darren Hart
2 siblings, 0 replies; 4+ messages in thread
From: Azael Avalos @ 2016-01-25 18:29 UTC (permalink / raw)
To: Darren Hart, platform-driver-x86, linux-kernel; +Cc: Azael Avalos
This patch adds the sysfs entry
Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
---
drivers/platform/x86/toshiba_acpi.c | 51 +++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index c6f92ec..5ace1e0 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -2289,6 +2289,54 @@ static ssize_t usb_three_store(struct device *dev,
}
static DEVICE_ATTR_RW(usb_three);
+static ssize_t cooling_method_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
+ int state;
+ int ret;
+
+ ret = toshiba_cooling_method_get(toshiba, &state);
+ if (ret < 0)
+ return ret;
+
+ return sprintf(buf, "%d %d\n", state, toshiba->max_cooling_method);
+}
+
+static ssize_t cooling_method_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 supported values
+ * Depending on the laptop model, some only support these two:
+ * 0 - Maximum Performance
+ * 1 - Battery Optimized
+ *
+ * While some others support all three methods:
+ * 0 - Maximum Performance
+ * 1 - Performance
+ * 2 - Battery Optimized
+ */
+ if (state < 0 || state > toshiba->max_cooling_method)
+ return -EINVAL;
+
+ ret = toshiba_cooling_method_set(toshiba, state);
+ if (ret)
+ return ret;
+
+ return count;
+}
+static DEVICE_ATTR_RW(cooling_method);
+
static struct attribute *toshiba_attributes[] = {
&dev_attr_version.attr,
&dev_attr_fan.attr,
@@ -2305,6 +2353,7 @@ static struct attribute *toshiba_attributes[] = {
&dev_attr_kbd_function_keys.attr,
&dev_attr_panel_power_on.attr,
&dev_attr_usb_three.attr,
+ &dev_attr_cooling_method.attr,
NULL,
};
@@ -2339,6 +2388,8 @@ static umode_t toshiba_sysfs_is_visible(struct kobject *kobj,
exists = (drv->panel_power_on_supported) ? true : false;
else if (attr == &dev_attr_usb_three.attr)
exists = (drv->usb_three_supported) ? true : false;
+ else if (attr == &dev_attr_cooling_method.attr)
+ exists = (drv->cooling_method_supported) ? true : false;
return exists ? attr->mode : 0;
}
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/3] toshiba_acpi: Add support for Cooling Method
2016-01-25 18:29 [PATCH 0/3] toshiba_acpi: Add support for Cooling Method Azael Avalos
2016-01-25 18:29 ` [PATCH 1/3] toshiba_acpi: Add support for cooling method feature Azael Avalos
2016-01-25 18:29 ` [PATCH 2/2] toshiba_acpi: Add sysfs entries for the Cooling Method feature Azael Avalos
@ 2016-02-07 20:24 ` Darren Hart
2 siblings, 0 replies; 4+ messages in thread
From: Darren Hart @ 2016-02-07 20:24 UTC (permalink / raw)
To: Azael Avalos; +Cc: platform-driver-x86, linux-kernel
On Mon, Jan 25, 2016 at 11:29:09AM -0700, Azael Avalos wrote:
> These patches add support for the Cooling Method feature found in most
> Toshiba laptops, allowing userspace to control the desired cooling method,
> which are the following:
> 0 - Maximum Performance
> 1 - Peformance
> 2 - Battery Optimized
>
> The Cooling Method feature basically controls the speed of the system fan,
> setting the speed (and quietness) according to the selected method.
>
> The default value at every boot is zero (Maximum Performance), on Windows,
> Toshiba provides hooks to the power management system, allowing
> the user to change it according to their needs and/or the AC adapter state.
>
>
> Azael Avalos (3):
> toshiba_acpi: Add support for cooling method feature
> toshiba_acpi: Add sysfs entries for th Cooling Method feature
> Documentation/ABI: Update sysfs-driver-toshiba_acpi file
Queued to testing, thank you Azael.
--
Darren Hart
Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-07 20:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-25 18:29 [PATCH 0/3] toshiba_acpi: Add support for Cooling Method Azael Avalos
2016-01-25 18:29 ` [PATCH 1/3] toshiba_acpi: Add support for cooling method feature Azael Avalos
2016-01-25 18:29 ` [PATCH 2/2] toshiba_acpi: Add sysfs entries for the Cooling Method feature Azael Avalos
2016-02-07 20:24 ` [PATCH 0/3] toshiba_acpi: Add support for Cooling Method Darren Hart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).