acerhdf.c (7438d9905a18527e4020e810fa61b4d016c8b476) | acerhdf.c (48c8dd64345ba2a8c41556095c7adacb1c8af7c1) |
---|---|
1/* 2 * acerhdf - A driver which monitors the temperature 3 * of the aspire one netbook, turns on/off the fan 4 * as soon as the upper/lower threshold is reached. 5 * 6 * (C) 2009 - Peter Feuerer peter (a) piie.net 7 * http://piie.net 8 * 2009 Borislav Petkov bp (a) alien8.de --- 36 unchanged lines hidden (view full) --- 45 * is still in control of the fan. In this mode the driver allows to read the 46 * temperature of the cpu and a userspace tool may take over control of the fan. 47 * If the driver is switched to "kernel mode" (e.g. via module parameter) the 48 * driver is in full control of the fan. If you want the module to be started in 49 * kernel mode by default, define the following: 50 */ 51#undef START_IN_KERNEL_MODE 52 | 1/* 2 * acerhdf - A driver which monitors the temperature 3 * of the aspire one netbook, turns on/off the fan 4 * as soon as the upper/lower threshold is reached. 5 * 6 * (C) 2009 - Peter Feuerer peter (a) piie.net 7 * http://piie.net 8 * 2009 Borislav Petkov bp (a) alien8.de --- 36 unchanged lines hidden (view full) --- 45 * is still in control of the fan. In this mode the driver allows to read the 46 * temperature of the cpu and a userspace tool may take over control of the fan. 47 * If the driver is switched to "kernel mode" (e.g. via module parameter) the 48 * driver is in full control of the fan. If you want the module to be started in 49 * kernel mode by default, define the following: 50 */ 51#undef START_IN_KERNEL_MODE 52 |
53#define DRV_VER "0.5.30" | 53#define DRV_VER "0.7.0" |
54 55/* 56 * According to the Atom N270 datasheet, 57 * (http://download.intel.com/design/processor/datashts/320032.pdf) the 58 * CPU's optimal operating limits denoted in junction temperature as 59 * measured by the on-die thermal monitor are within 0 <= Tj <= 90. So, 60 * assume 89°C is critical temperature. 61 */ --- 191 unchanged lines hidden (view full) --- 253 {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, 0}, 254 {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0}, 255 /* pewpew-terminator */ 256 {"", "", "", 0, 0, {0, 0}, 0} 257}; 258 259static const struct bios_settings_t *bios_cfg __read_mostly; 260 | 54 55/* 56 * According to the Atom N270 datasheet, 57 * (http://download.intel.com/design/processor/datashts/320032.pdf) the 58 * CPU's optimal operating limits denoted in junction temperature as 59 * measured by the on-die thermal monitor are within 0 <= Tj <= 90. So, 60 * assume 89°C is critical temperature. 61 */ --- 191 unchanged lines hidden (view full) --- 253 {"Packard Bell", "DOTMA", "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, 0}, 254 {"Packard Bell", "DOTVR46", "v1.3308", 0x55, 0x58, {0x9e, 0x00}, 0}, 255 /* pewpew-terminator */ 256 {"", "", "", 0, 0, {0, 0}, 0} 257}; 258 259static const struct bios_settings_t *bios_cfg __read_mostly; 260 |
261/* 262 * this struct is used to instruct thermal layer to use bang_bang instead of 263 * default governor for acerhdf 264 */ 265static struct thermal_zone_params acerhdf_zone_params = { 266 .governor_name = "bang_bang", 267}; 268 |
|
261static int acerhdf_get_temp(int *temp) 262{ 263 u8 read_temp; 264 265 if (ec_read(bios_cfg->tempreg, &read_temp)) 266 return -EINVAL; 267 268 *temp = read_temp * 1000; --- 165 unchanged lines hidden (view full) --- 434 enum thermal_trip_type *type) 435{ 436 if (trip == 0) 437 *type = THERMAL_TRIP_ACTIVE; 438 439 return 0; 440} 441 | 269static int acerhdf_get_temp(int *temp) 270{ 271 u8 read_temp; 272 273 if (ec_read(bios_cfg->tempreg, &read_temp)) 274 return -EINVAL; 275 276 *temp = read_temp * 1000; --- 165 unchanged lines hidden (view full) --- 442 enum thermal_trip_type *type) 443{ 444 if (trip == 0) 445 *type = THERMAL_TRIP_ACTIVE; 446 447 return 0; 448} 449 |
450static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip, 451 unsigned long *temp) 452{ 453 if (trip != 0) 454 return -EINVAL; 455 456 *temp = fanon - fanoff; 457 458 return 0; 459} 460 |
|
442static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip, 443 unsigned long *temp) 444{ 445 if (trip == 0) 446 *temp = fanon; 447 448 return 0; 449} --- 8 unchanged lines hidden (view full) --- 458/* bind callback functions to thermalzone */ 459static struct thermal_zone_device_ops acerhdf_dev_ops = { 460 .bind = acerhdf_bind, 461 .unbind = acerhdf_unbind, 462 .get_temp = acerhdf_get_ec_temp, 463 .get_mode = acerhdf_get_mode, 464 .set_mode = acerhdf_set_mode, 465 .get_trip_type = acerhdf_get_trip_type, | 461static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip, 462 unsigned long *temp) 463{ 464 if (trip == 0) 465 *temp = fanon; 466 467 return 0; 468} --- 8 unchanged lines hidden (view full) --- 477/* bind callback functions to thermalzone */ 478static struct thermal_zone_device_ops acerhdf_dev_ops = { 479 .bind = acerhdf_bind, 480 .unbind = acerhdf_unbind, 481 .get_temp = acerhdf_get_ec_temp, 482 .get_mode = acerhdf_get_mode, 483 .set_mode = acerhdf_set_mode, 484 .get_trip_type = acerhdf_get_trip_type, |
485 .get_trip_hyst = acerhdf_get_trip_hyst, |
|
466 .get_trip_temp = acerhdf_get_trip_temp, 467 .get_crit_temp = acerhdf_get_crit_temp, 468}; 469 470 471/* 472 * cooling device callback functions 473 * get maximal fan cooling state --- 36 unchanged lines hidden (view full) --- 510 511 err = acerhdf_get_fanstate(&cur_state); 512 if (err) { 513 pr_err("error reading fan state, hand off control to BIOS\n"); 514 goto err_out; 515 } 516 517 if (state == 0) { | 486 .get_trip_temp = acerhdf_get_trip_temp, 487 .get_crit_temp = acerhdf_get_crit_temp, 488}; 489 490 491/* 492 * cooling device callback functions 493 * get maximal fan cooling state --- 36 unchanged lines hidden (view full) --- 530 531 err = acerhdf_get_fanstate(&cur_state); 532 if (err) { 533 pr_err("error reading fan state, hand off control to BIOS\n"); 534 goto err_out; 535 } 536 537 if (state == 0) { |
518 /* turn fan off only if below fanoff temperature */ 519 if ((cur_state == ACERHDF_FAN_AUTO) && 520 (cur_temp < fanoff)) | 538 if (cur_state == ACERHDF_FAN_AUTO) |
521 acerhdf_change_fanstate(ACERHDF_FAN_OFF); 522 } else { 523 if (cur_state == ACERHDF_FAN_OFF) 524 acerhdf_change_fanstate(ACERHDF_FAN_AUTO); 525 } 526 return 0; 527 528err_out: --- 162 unchanged lines hidden (view full) --- 691{ 692 cl_dev = thermal_cooling_device_register("acerhdf-fan", NULL, 693 &acerhdf_cooling_ops); 694 695 if (IS_ERR(cl_dev)) 696 return -EINVAL; 697 698 thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL, | 539 acerhdf_change_fanstate(ACERHDF_FAN_OFF); 540 } else { 541 if (cur_state == ACERHDF_FAN_OFF) 542 acerhdf_change_fanstate(ACERHDF_FAN_AUTO); 543 } 544 return 0; 545 546err_out: --- 162 unchanged lines hidden (view full) --- 709{ 710 cl_dev = thermal_cooling_device_register("acerhdf-fan", NULL, 711 &acerhdf_cooling_ops); 712 713 if (IS_ERR(cl_dev)) 714 return -EINVAL; 715 716 thz_dev = thermal_zone_device_register("acerhdf", 1, 0, NULL, |
699 &acerhdf_dev_ops, NULL, 0, | 717 &acerhdf_dev_ops, 718 &acerhdf_zone_params, 0, |
700 (kernelmode) ? interval*1000 : 0); 701 if (IS_ERR(thz_dev)) 702 return -EINVAL; 703 | 719 (kernelmode) ? interval*1000 : 0); 720 if (IS_ERR(thz_dev)) 721 return -EINVAL; 722 |
723 if (strcmp(thz_dev->governor->name, 724 acerhdf_zone_params.governor_name)) { 725 pr_err("Didn't get thermal governor %s, perhaps not compiled into thermal subsystem.\n", 726 acerhdf_zone_params.governor_name); 727 return -EINVAL; 728 } 729 |
|
704 return 0; 705} 706 707static void acerhdf_unregister_thermal(void) 708{ 709 if (cl_dev) { 710 thermal_cooling_device_unregister(cl_dev); 711 cl_dev = NULL; --- 69 unchanged lines hidden --- | 730 return 0; 731} 732 733static void acerhdf_unregister_thermal(void) 734{ 735 if (cl_dev) { 736 thermal_cooling_device_unregister(cl_dev); 737 cl_dev = NULL; --- 69 unchanged lines hidden --- |