2 * WMI Thunderbolt driver
4 * Copyright (C) 2017 Dell Inc. All Rights Reserved.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18 #include <linux/acpi.h>
19 #include <linux/device.h>
21 #include <linux/kernel.h>
22 #include <linux/module.h>
23 #include <linux/string.h>
24 #include <linux/sysfs.h>
25 #include <linux/types.h>
26 #include <linux/wmi.h>
28 #define INTEL_WMI_THUNDERBOLT_GUID "86CCFD48-205E-4A77-9C48-2021CBEDE341"
30 static ssize_t
force_power_store(struct device
*dev
,
31 struct device_attribute
*attr
,
32 const char *buf
, size_t count
)
34 struct acpi_buffer input
;
38 input
.length
= sizeof(u8
);
39 input
.pointer
= &mode
;
40 mode
= hex_to_bin(buf
[0]);
41 if (mode
== 0 || mode
== 1) {
42 status
= wmi_evaluate_method(INTEL_WMI_THUNDERBOLT_GUID
, 0, 1,
44 if (ACPI_FAILURE(status
))
52 static DEVICE_ATTR_WO(force_power
);
54 static struct attribute
*tbt_attrs
[] = {
55 &dev_attr_force_power
.attr
,
59 static const struct attribute_group tbt_attribute_group
= {
63 static int intel_wmi_thunderbolt_probe(struct wmi_device
*wdev
)
67 ret
= sysfs_create_group(&wdev
->dev
.kobj
, &tbt_attribute_group
);
68 kobject_uevent(&wdev
->dev
.kobj
, KOBJ_CHANGE
);
72 static int intel_wmi_thunderbolt_remove(struct wmi_device
*wdev
)
74 sysfs_remove_group(&wdev
->dev
.kobj
, &tbt_attribute_group
);
75 kobject_uevent(&wdev
->dev
.kobj
, KOBJ_CHANGE
);
79 static const struct wmi_device_id intel_wmi_thunderbolt_id_table
[] = {
80 { .guid_string
= INTEL_WMI_THUNDERBOLT_GUID
},
84 static struct wmi_driver intel_wmi_thunderbolt_driver
= {
86 .name
= "intel-wmi-thunderbolt",
88 .probe
= intel_wmi_thunderbolt_probe
,
89 .remove
= intel_wmi_thunderbolt_remove
,
90 .id_table
= intel_wmi_thunderbolt_id_table
,
93 module_wmi_driver(intel_wmi_thunderbolt_driver
);
95 MODULE_ALIAS("wmi:" INTEL_WMI_THUNDERBOLT_GUID
);
96 MODULE_AUTHOR("Mario Limonciello <mario.limonciello@dell.com>");
97 MODULE_DESCRIPTION("Intel WMI Thunderbolt force power driver");
98 MODULE_LICENSE("GPL");