34 #define pr_fmt(fmt) "acerhdf: " fmt
36 #include <linux/kernel.h>
37 #include <linux/module.h>
51 #undef START_IN_KERNEL_MODE
53 #define DRV_VER "0.5.26"
62 #define ACERHDF_TEMP_CRIT 89000
63 #define ACERHDF_FAN_OFF 0
64 #define ACERHDF_FAN_AUTO 1
70 #define ACERHDF_MAX_FANON 80000
77 #define ACERHDF_MAX_INTERVAL 15
79 #ifdef START_IN_KERNEL_MODE
80 static int kernelmode = 1;
82 static int kernelmode;
86 static unsigned int fanon = 60000;
87 static unsigned int fanoff = 53000;
90 static char force_bios[16];
91 static char force_product[16];
92 static unsigned int prev_interval;
135 {
"Acer",
"AOA110",
"v0.3109", 0x55, 0x58, {0x1f, 0x00} },
136 {
"Acer",
"AOA110",
"v0.3114", 0x55, 0x58, {0x1f, 0x00} },
137 {
"Acer",
"AOA110",
"v0.3301", 0x55, 0x58, {0xaf, 0x00} },
138 {
"Acer",
"AOA110",
"v0.3304", 0x55, 0x58, {0xaf, 0x00} },
139 {
"Acer",
"AOA110",
"v0.3305", 0x55, 0x58, {0xaf, 0x00} },
140 {
"Acer",
"AOA110",
"v0.3307", 0x55, 0x58, {0xaf, 0x00} },
141 {
"Acer",
"AOA110",
"v0.3308", 0x55, 0x58, {0x21, 0x00} },
142 {
"Acer",
"AOA110",
"v0.3309", 0x55, 0x58, {0x21, 0x00} },
143 {
"Acer",
"AOA110",
"v0.3310", 0x55, 0x58, {0x21, 0x00} },
145 {
"Acer",
"AOA150",
"v0.3114", 0x55, 0x58, {0x1f, 0x00} },
146 {
"Acer",
"AOA150",
"v0.3301", 0x55, 0x58, {0x20, 0x00} },
147 {
"Acer",
"AOA150",
"v0.3304", 0x55, 0x58, {0x20, 0x00} },
148 {
"Acer",
"AOA150",
"v0.3305", 0x55, 0x58, {0x20, 0x00} },
149 {
"Acer",
"AOA150",
"v0.3307", 0x55, 0x58, {0x20, 0x00} },
150 {
"Acer",
"AOA150",
"v0.3308", 0x55, 0x58, {0x20, 0x00} },
151 {
"Acer",
"AOA150",
"v0.3309", 0x55, 0x58, {0x20, 0x00} },
152 {
"Acer",
"AOA150",
"v0.3310", 0x55, 0x58, {0x20, 0x00} },
154 {
"Acer",
"LT-10Q",
"v0.3310", 0x55, 0x58, {0x20, 0x00} },
156 {
"Acer",
"Aspire 1410",
"v0.3108", 0x55, 0x58, {0x9e, 0x00} },
157 {
"Acer",
"Aspire 1410",
"v0.3113", 0x55, 0x58, {0x9e, 0x00} },
158 {
"Acer",
"Aspire 1410",
"v0.3115", 0x55, 0x58, {0x9e, 0x00} },
159 {
"Acer",
"Aspire 1410",
"v0.3117", 0x55, 0x58, {0x9e, 0x00} },
160 {
"Acer",
"Aspire 1410",
"v0.3119", 0x55, 0x58, {0x9e, 0x00} },
161 {
"Acer",
"Aspire 1410",
"v0.3120", 0x55, 0x58, {0x9e, 0x00} },
162 {
"Acer",
"Aspire 1410",
"v1.3204", 0x55, 0x58, {0x9e, 0x00} },
163 {
"Acer",
"Aspire 1410",
"v1.3303", 0x55, 0x58, {0x9e, 0x00} },
164 {
"Acer",
"Aspire 1410",
"v1.3308", 0x55, 0x58, {0x9e, 0x00} },
165 {
"Acer",
"Aspire 1410",
"v1.3310", 0x55, 0x58, {0x9e, 0x00} },
166 {
"Acer",
"Aspire 1410",
"v1.3314", 0x55, 0x58, {0x9e, 0x00} },
168 {
"Acer",
"Aspire 1810TZ",
"v0.3108", 0x55, 0x58, {0x9e, 0x00} },
169 {
"Acer",
"Aspire 1810T",
"v0.3108", 0x55, 0x58, {0x9e, 0x00} },
170 {
"Acer",
"Aspire 1810TZ",
"v0.3113", 0x55, 0x58, {0x9e, 0x00} },
171 {
"Acer",
"Aspire 1810T",
"v0.3113", 0x55, 0x58, {0x9e, 0x00} },
172 {
"Acer",
"Aspire 1810TZ",
"v0.3115", 0x55, 0x58, {0x9e, 0x00} },
173 {
"Acer",
"Aspire 1810T",
"v0.3115", 0x55, 0x58, {0x9e, 0x00} },
174 {
"Acer",
"Aspire 1810TZ",
"v0.3117", 0x55, 0x58, {0x9e, 0x00} },
175 {
"Acer",
"Aspire 1810T",
"v0.3117", 0x55, 0x58, {0x9e, 0x00} },
176 {
"Acer",
"Aspire 1810TZ",
"v0.3119", 0x55, 0x58, {0x9e, 0x00} },
177 {
"Acer",
"Aspire 1810T",
"v0.3119", 0x55, 0x58, {0x9e, 0x00} },
178 {
"Acer",
"Aspire 1810TZ",
"v0.3120", 0x55, 0x58, {0x9e, 0x00} },
179 {
"Acer",
"Aspire 1810T",
"v0.3120", 0x55, 0x58, {0x9e, 0x00} },
180 {
"Acer",
"Aspire 1810TZ",
"v1.3204", 0x55, 0x58, {0x9e, 0x00} },
181 {
"Acer",
"Aspire 1810T",
"v1.3204", 0x55, 0x58, {0x9e, 0x00} },
182 {
"Acer",
"Aspire 1810TZ",
"v1.3303", 0x55, 0x58, {0x9e, 0x00} },
183 {
"Acer",
"Aspire 1810T",
"v1.3303", 0x55, 0x58, {0x9e, 0x00} },
184 {
"Acer",
"Aspire 1810TZ",
"v1.3308", 0x55, 0x58, {0x9e, 0x00} },
185 {
"Acer",
"Aspire 1810T",
"v1.3308", 0x55, 0x58, {0x9e, 0x00} },
186 {
"Acer",
"Aspire 1810TZ",
"v1.3310", 0x55, 0x58, {0x9e, 0x00} },
187 {
"Acer",
"Aspire 1810T",
"v1.3310", 0x55, 0x58, {0x9e, 0x00} },
188 {
"Acer",
"Aspire 1810TZ",
"v1.3314", 0x55, 0x58, {0x9e, 0x00} },
189 {
"Acer",
"Aspire 1810T",
"v1.3314", 0x55, 0x58, {0x9e, 0x00} },
191 {
"Acer",
"AO531h",
"v0.3104", 0x55, 0x58, {0x20, 0x00} },
192 {
"Acer",
"AO531h",
"v0.3201", 0x55, 0x58, {0x20, 0x00} },
193 {
"Acer",
"AO531h",
"v0.3304", 0x55, 0x58, {0x20, 0x00} },
195 {
"Acer",
"AO751h",
"V0.3212", 0x55, 0x58, {0x21, 0x00} },
197 {
"Acer",
"Aspire 1825PTZ",
"V1.3118", 0x55, 0x58, {0x9e, 0x00} },
198 {
"Acer",
"Aspire 1825PTZ",
"V1.3127", 0x55, 0x58, {0x9e, 0x00} },
200 {
"Acer",
"TravelMate 7730G",
"v0.3509", 0x55, 0x58, {0xaf, 0x00} },
202 {
"Gateway",
"AOA110",
"v0.3103", 0x55, 0x58, {0x21, 0x00} },
203 {
"Gateway",
"AOA150",
"v0.3103", 0x55, 0x58, {0x20, 0x00} },
204 {
"Gateway",
"LT31",
"v1.3103", 0x55, 0x58, {0x9e, 0x00} },
205 {
"Gateway",
"LT31",
"v1.3201", 0x55, 0x58, {0x9e, 0x00} },
206 {
"Gateway",
"LT31",
"v1.3302", 0x55, 0x58, {0x9e, 0x00} },
207 {
"Gateway",
"LT31",
"v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
209 {
"Packard Bell",
"DOA150",
"v0.3104", 0x55, 0x58, {0x21, 0x00} },
210 {
"Packard Bell",
"DOA150",
"v0.3105", 0x55, 0x58, {0x20, 0x00} },
211 {
"Packard Bell",
"AOA110",
"v0.3105", 0x55, 0x58, {0x21, 0x00} },
212 {
"Packard Bell",
"AOA150",
"v0.3105", 0x55, 0x58, {0x20, 0x00} },
213 {
"Packard Bell",
"ENBFT",
"V1.3118", 0x55, 0x58, {0x9e, 0x00} },
214 {
"Packard Bell",
"ENBFT",
"V1.3127", 0x55, 0x58, {0x9e, 0x00} },
215 {
"Packard Bell",
"DOTMU",
"v1.3303", 0x55, 0x58, {0x9e, 0x00} },
216 {
"Packard Bell",
"DOTMU",
"v0.3120", 0x55, 0x58, {0x9e, 0x00} },
217 {
"Packard Bell",
"DOTMU",
"v0.3108", 0x55, 0x58, {0x9e, 0x00} },
218 {
"Packard Bell",
"DOTMU",
"v0.3113", 0x55, 0x58, {0x9e, 0x00} },
219 {
"Packard Bell",
"DOTMU",
"v0.3115", 0x55, 0x58, {0x9e, 0x00} },
220 {
"Packard Bell",
"DOTMU",
"v0.3117", 0x55, 0x58, {0x9e, 0x00} },
221 {
"Packard Bell",
"DOTMU",
"v0.3119", 0x55, 0x58, {0x9e, 0x00} },
222 {
"Packard Bell",
"DOTMU",
"v1.3204", 0x55, 0x58, {0x9e, 0x00} },
223 {
"Packard Bell",
"DOTMA",
"v1.3201", 0x55, 0x58, {0x9e, 0x00} },
224 {
"Packard Bell",
"DOTMA",
"v1.3302", 0x55, 0x58, {0x9e, 0x00} },
225 {
"Packard Bell",
"DOTMA",
"v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
226 {
"Packard Bell",
"DOTVR46",
"v1.3308", 0x55, 0x58, {0x9e, 0x00} },
228 {
"",
"",
"", 0, 0, {0, 0} }
233 static int acerhdf_get_temp(
int *
temp)
237 if (
ec_read(bios_cfg->tempreg, &read_temp))
240 *temp = read_temp * 1000;
245 static int acerhdf_get_fanstate(
int *
state)
249 if (
ec_read(bios_cfg->fanreg, &fan))
252 if (fan != bios_cfg->cmd.cmd_off)
260 static void acerhdf_change_fanstate(
int state)
268 pr_err(
"invalid fan state %d requested, setting to auto!\n",
274 : bios_cfg->cmd.cmd_auto;
283 pr_err(
"fanon temperature too high, set to %d\n",
288 if (kernelmode && prev_interval !=
interval) {
290 pr_err(
"interval too high, set to %d\n",
312 acerhdf_check_param(thermal);
314 err = acerhdf_get_temp(&temp);
334 pr_err(
"error binding cooling dev\n");
347 pr_err(
"error unbinding cooling dev\n");
353 static inline void acerhdf_revert_to_bios_mode(
void)
359 pr_notice(
"kernel mode fan control OFF\n");
361 static inline void acerhdf_enable_kernelmode(
void)
367 pr_notice(
"kernel mode fan control ON\n");
374 pr_notice(
"kernel mode fan control %d\n", kernelmode);
392 acerhdf_revert_to_bios_mode();
394 acerhdf_enable_kernelmode();
426 .bind = acerhdf_bind,
427 .unbind = acerhdf_unbind,
428 .get_temp = acerhdf_get_ec_temp,
429 .get_mode = acerhdf_get_mode,
430 .set_mode = acerhdf_set_mode,
431 .get_trip_type = acerhdf_get_trip_type,
432 .get_trip_temp = acerhdf_get_trip_temp,
433 .get_crit_temp = acerhdf_get_crit_temp,
442 unsigned long *state)
450 unsigned long *state)
454 err = acerhdf_get_fanstate(&
tmp);
466 int cur_temp, cur_state, err = 0;
471 err = acerhdf_get_temp(&cur_temp);
473 pr_err(
"error reading temperature, hand off control to BIOS\n");
477 err = acerhdf_get_fanstate(&cur_state);
479 pr_err(
"error reading fan state, hand off control to BIOS\n");
495 acerhdf_revert_to_bios_mode();
501 .get_max_state = acerhdf_get_max_state,
502 .get_cur_state = acerhdf_get_cur_state,
503 .set_cur_state = acerhdf_set_cur_state,
507 static int acerhdf_suspend(
struct device *
dev)
528 static const struct dev_pm_ops acerhdf_pm_ops = {
529 .suspend = acerhdf_suspend,
530 .freeze = acerhdf_suspend,
537 .pm = &acerhdf_pm_ops,
539 .probe = acerhdf_probe,
540 .remove = acerhdf_remove,
544 static int str_starts_with(
const char *
str,
const char *
start)
546 unsigned long str_len = 0, start_len = 0;
549 start_len =
strlen(start);
551 if (str_len >= start_len &&
552 !
strncmp(str, start, start_len))
559 static int acerhdf_check_hardware(
void)
569 if (!vendor || !version || !product) {
570 pr_err(
"error getting hardware information\n");
577 version = force_bios;
578 pr_info(
"forcing BIOS version: %s\n", version);
582 if (force_product[0]) {
583 product = force_product;
584 pr_info(
"forcing BIOS product: %s\n", product);
589 pr_info(
"BIOS info: %s %s, product: %s\n",
590 vendor, version, product);
593 for (bt = bios_tbl; bt->
vendor[0]; bt++) {
598 if (str_starts_with(vendor, bt->
vendor) &&
599 str_starts_with(product, bt->
product) &&
600 str_starts_with(version, bt->
version)) {
607 pr_err(
"unknown (unsupported) BIOS version %s/%s/%s, please report, aborting!\n",
608 vendor, product, version);
617 pr_notice(
"Fan control off, to enable do:\n");
618 pr_notice(
"echo -n \"enabled\" > /sys/class/thermal/thermal_zone0/mode\n");
624 static int acerhdf_register_platform(
void)
635 goto err_device_alloc;
650 static void acerhdf_unregister_platform(
void)
656 static int acerhdf_register_thermal(
void)
659 &acerhdf_cooling_ops);
673 static void acerhdf_unregister_thermal(
void)
686 static int __init acerhdf_init(
void)
690 err = acerhdf_check_hardware();
694 err = acerhdf_register_platform();
698 err = acerhdf_register_thermal();
705 acerhdf_unregister_thermal();
706 acerhdf_unregister_platform();
712 static void __exit acerhdf_exit(
void)
715 acerhdf_unregister_thermal();
716 acerhdf_unregister_platform();