Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
95384b3
Documentation
LICENSES
arch
block
certs
crypto
drivers
accessibility
acpi
amba
android
ata
atm
auxdisplay
base
bcma
block
bluetooth
bus
cdrom
char
clk
clocksource
comedi
connector
counter
cpufreq
cpuidle
crypto
cxl
dax
dca
devfreq
dio
dma-buf
dma
edac
eisa
extcon
firewire
firmware
fpga
fsi
gnss
gpio
gpu
greybus
hid
hsi
hv
hwmon
hwspinlock
hwtracing
i2c
i3c
idle
iio
infiniband
input
interconnect
iommu
ipack
irqchip
isdn
leds
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
most
mtd
mux
net
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
opp
parisc
parport
pci
pcmcia
perf
phy
pinctrl
platform
chrome
goldfish
mellanox
mips
olpc
surface
x86
dell
intel
Kconfig
Makefile
acer-wireless.c
acer-wmi.c
acerhdf.c
adv_swbutton.c
amd-pmc.c
amilo-rfkill.c
apple-gmux.c
asus-laptop.c
asus-nb-wmi.c
asus-wireless.c
asus-wmi.c
asus-wmi.h
classmate-laptop.c
compal-laptop.c
dual_accel_detect.h
eeepc-laptop.c
eeepc-wmi.c
firmware_attributes_class.c
firmware_attributes_class.h
fujitsu-laptop.c
fujitsu-tablet.c
gigabyte-wmi.c
gpd-pocket-fan.c
hdaps.c
hp-wmi.c
hp_accel.c
huawei-wmi.c
i2c-multi-instantiate.c
ibm_rtl.c
ideapad-laptop.c
intel_ips.c
intel_ips.h
intel_scu_ipc.c
intel_scu_ipcutil.c
intel_scu_pcidrv.c
intel_scu_pltdrv.c
intel_scu_wdt.c
lg-laptop.c
meraki-mx100.c
mlx-platform.c
msi-laptop.c
msi-wmi.c
mxm-wmi.c
nvidia-wmi-ec-backlight.c
panasonic-laptop.c
pcengines-apuv2.c
peaq-wmi.c
pmc_atom.c
samsung-laptop.c
samsung-q10.c
sony-laptop.c
system76_acpi.c
tc1100-wmi.c
think-lmi.c
think-lmi.h
thinkpad_acpi.c
topstar-laptop.c
toshiba-wmi.c
toshiba_acpi.c
toshiba_bluetooth.c
toshiba_haps.c
touchscreen_dmi.c
uv_sysfs.c
wireless-hotkey.c
wmi-bmof.c
wmi.c
xiaomi-wmi.c
xo1-rfkill.c
xo15-ebook.c
Kconfig
Makefile
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi
sh
siox
slimbus
soc
soundwire
spi
spmi
ssb
staging
target
tc
tee
thermal
thunderbolt
tty
uio
usb
vdpa
vfio
vhost
video
virt
virtio
visorbus
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
drivers
/
platform
/
x86
/
gigabyte-wmi.c
Copy path
Blame
Blame
Latest commit
History
History
198 lines (166 loc) · 5.33 KB
Breadcrumbs
linux
/
drivers
/
platform
/
x86
/
gigabyte-wmi.c
Top
File metadata and controls
Code
Blame
198 lines (166 loc) · 5.33 KB
Raw
// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2021 Thomas Weißschuh <thomas@weissschuh.net> */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/acpi.h> #include <linux/dmi.h> #include <linux/hwmon.h> #include <linux/module.h> #include <linux/wmi.h> #define GIGABYTE_WMI_GUID "DEADBEEF-2001-0000-00A0-C90629100000" #define NUM_TEMPERATURE_SENSORS 6 static bool force_load; module_param(force_load, bool, 0444); MODULE_PARM_DESC(force_load, "Force loading on unknown platform"); static u8 usable_sensors_mask; enum gigabyte_wmi_commandtype { GIGABYTE_WMI_BUILD_DATE_QUERY = 0x1, GIGABYTE_WMI_MAINBOARD_TYPE_QUERY = 0x2, GIGABYTE_WMI_FIRMWARE_VERSION_QUERY = 0x4, GIGABYTE_WMI_MAINBOARD_NAME_QUERY = 0x5, GIGABYTE_WMI_TEMPERATURE_QUERY = 0x125, }; struct gigabyte_wmi_args { u32 arg1; }; static int gigabyte_wmi_perform_query(struct wmi_device *wdev, enum gigabyte_wmi_commandtype command, struct gigabyte_wmi_args *args, struct acpi_buffer *out) { const struct acpi_buffer in = { .length = sizeof(*args), .pointer = args, }; acpi_status ret = wmidev_evaluate_method(wdev, 0x0, command, &in, out); if (ACPI_FAILURE(ret)) return -EIO; return 0; } static int gigabyte_wmi_query_integer(struct wmi_device *wdev, enum gigabyte_wmi_commandtype command, struct gigabyte_wmi_args *args, u64 *res) { union acpi_object *obj; struct acpi_buffer result = { ACPI_ALLOCATE_BUFFER, NULL }; int ret; ret = gigabyte_wmi_perform_query(wdev, command, args, &result); if (ret) return ret; obj = result.pointer; if (obj && obj->type == ACPI_TYPE_INTEGER) *res = obj->integer.value; else ret = -EIO; kfree(result.pointer); return ret; } static int gigabyte_wmi_temperature(struct wmi_device *wdev, u8 sensor, long *res) { struct gigabyte_wmi_args args = { .arg1 = sensor, }; u64 temp; acpi_status ret; ret = gigabyte_wmi_query_integer(wdev, GIGABYTE_WMI_TEMPERATURE_QUERY, &args, &temp); if (ret == 0) { if (temp == 0) return -ENODEV; *res = (s8)temp * 1000; // value is a signed 8-bit integer } return ret; } static int gigabyte_wmi_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long *val) { struct wmi_device *wdev = dev_get_drvdata(dev); return gigabyte_wmi_temperature(wdev, channel, val); } static umode_t gigabyte_wmi_hwmon_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr, int channel) { return usable_sensors_mask & BIT(channel) ? 0444 : 0; } static const struct hwmon_channel_info *gigabyte_wmi_hwmon_info[] = { HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT, HWMON_T_INPUT, HWMON_T_INPUT, HWMON_T_INPUT, HWMON_T_INPUT, HWMON_T_INPUT), NULL }; static const struct hwmon_ops gigabyte_wmi_hwmon_ops = { .read = gigabyte_wmi_hwmon_read, .is_visible = gigabyte_wmi_hwmon_is_visible, }; static const struct hwmon_chip_info gigabyte_wmi_hwmon_chip_info = { .ops = &gigabyte_wmi_hwmon_ops, .info = gigabyte_wmi_hwmon_info, }; static u8 gigabyte_wmi_detect_sensor_usability(struct wmi_device *wdev) { int i; long temp; u8 r = 0; for (i = 0; i < NUM_TEMPERATURE_SENSORS; i++) { if (!gigabyte_wmi_temperature(wdev, i, &temp)) r |= BIT(i); } return r; } #define DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME(name) \ { .matches = { \ DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."), \ DMI_EXACT_MATCH(DMI_BOARD_NAME, name), \ }} static const struct dmi_system_id gigabyte_wmi_known_working_platforms[] = { DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B450M S2H V2"), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550 AORUS ELITE AX V2"), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550 AORUS ELITE"), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550 AORUS ELITE V2"), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550 GAMING X V2"), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550I AORUS PRO AX"), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550M AORUS PRO-P"), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550M DS3H"), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("Z390 I AORUS PRO WIFI-CF"), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("X570 AORUS ELITE"), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("X570 GAMING X"), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("X570 I AORUS PRO WIFI"), DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("X570 UD"), { } }; static int gigabyte_wmi_probe(struct wmi_device *wdev, const void *context) { struct device *hwmon_dev; if (!dmi_check_system(gigabyte_wmi_known_working_platforms)) { if (!force_load) return -ENODEV; dev_warn(&wdev->dev, "Forcing load on unknown platform"); } usable_sensors_mask = gigabyte_wmi_detect_sensor_usability(wdev); if (!usable_sensors_mask) { dev_info(&wdev->dev, "No temperature sensors usable"); return -ENODEV; } hwmon_dev = devm_hwmon_device_register_with_info(&wdev->dev, "gigabyte_wmi", wdev, &gigabyte_wmi_hwmon_chip_info, NULL); return PTR_ERR_OR_ZERO(hwmon_dev); } static const struct wmi_device_id gigabyte_wmi_id_table[] = { { GIGABYTE_WMI_GUID, NULL }, { } }; static struct wmi_driver gigabyte_wmi_driver = { .driver = { .name = "gigabyte-wmi", }, .id_table = gigabyte_wmi_id_table, .probe = gigabyte_wmi_probe, }; module_wmi_driver(gigabyte_wmi_driver); MODULE_DEVICE_TABLE(wmi, gigabyte_wmi_id_table); MODULE_AUTHOR("Thomas Weißschuh <thomas@weissschuh.net>"); MODULE_DESCRIPTION("Gigabyte WMI temperature driver"); MODULE_LICENSE("GPL");
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
You can’t perform that action at this time.