1 From 69ba91cbd6d79aa197adbdd10a44e71c84044b44 Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Fri, 24 Nov 2006 11:47:09 -0200
4 Subject: [PATCH 8/28] ACPI: ibm-acpi: prepare to cleanup fan_read and fan_write
6 This patch lays some groundwork for a fan_read and fan_write cleanup in the
7 next patches. To do so, it provides a new fan_init initializer, and also some
8 constants (through enums).
10 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
12 drivers/acpi/ibm_acpi.c | 81 +++++++++++++++++++++++++++++++++++++++++++++-
13 1 files changed, 79 insertions(+), 2 deletions(-)
15 diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
16 index 1703c61..7d0bd61 100644
17 --- a/drivers/acpi/ibm_acpi.c
18 +++ b/drivers/acpi/ibm_acpi.c
19 @@ -231,6 +231,31 @@ struct ibm_thermal_sensors_struct {
20 s32 temp[IBMACPI_MAX_THERMAL_SENSORS];
23 +enum fan_status_access_mode {
24 + IBMACPI_FAN_NONE = 0, /* No fan status or control */
25 + IBMACPI_FAN_RD_ACPI_GFAN, /* Use ACPI GFAN */
26 + IBMACPI_FAN_RD_TPEC, /* Use ACPI EC regs 0x2f, 0x84-0x85 */
29 +enum fan_control_access_mode {
30 + IBMACPI_FAN_WR_NONE = 0, /* No fan control */
31 + IBMACPI_FAN_WR_ACPI_SFAN, /* Use ACPI SFAN */
32 + IBMACPI_FAN_WR_TPEC, /* Use ACPI EC reg 0x2f */
33 + IBMACPI_FAN_WR_ACPI_FANS, /* Use ACPI FANS and EC reg 0x2f */
36 +enum fan_control_commands {
37 + IBMACPI_FAN_CMD_SPEED = 0x0001, /* speed command */
38 + IBMACPI_FAN_CMD_LEVEL = 0x0002, /* level command */
39 + IBMACPI_FAN_CMD_ENABLE = 0x0004, /* enable/disable cmd */
42 +enum { /* Fan control constants */
43 + fan_status_offset = 0x2f, /* EC register 0x2f */
44 + fan_rpm_offset = 0x84, /* EC register 0x84: LSB, 0x85 MSB (RPM)
45 + * 0x84 must be read before 0x85 */
48 static int ibm_thinkpad_ec_found;
51 @@ -1659,8 +1684,59 @@ static int volume_write(char *buf)
55 -static int fan_status_offset = 0x2f;
56 -static int fan_rpm_offset = 0x84;
57 +static enum fan_status_access_mode fan_status_access_mode;
58 +static enum fan_control_access_mode fan_control_access_mode;
59 +static enum fan_control_commands fan_control_commands;
61 +static int fan_init(void)
65 + fan_status_access_mode = IBMACPI_FAN_NONE;
66 + fan_control_access_mode = IBMACPI_FAN_WR_NONE;
67 + fan_control_commands = 0;
70 + /* 570, 600e/x, 770e, 770x */
71 + fan_status_access_mode = IBMACPI_FAN_RD_ACPI_GFAN;
73 + /* all other ThinkPads: note that even old-style
74 + * ThinkPad ECs supports the fan control register */
75 + if (likely(acpi_ec_read(fan_status_offset, &status))) {
76 + fan_status_access_mode = IBMACPI_FAN_RD_TPEC;
79 + "ThinkPad ACPI EC access misbehaving, "
80 + "fan status and control unavailable\n");
87 + fan_control_access_mode = IBMACPI_FAN_WR_ACPI_SFAN;
88 + fan_control_commands |= IBMACPI_FAN_CMD_LEVEL;
91 + /* gfan without sfan means no fan control */
92 + /* all other models implement TP EC 0x2f control */
96 + fan_control_access_mode =
97 + IBMACPI_FAN_WR_ACPI_FANS;
98 + fan_control_commands |=
99 + IBMACPI_FAN_CMD_SPEED |
100 + IBMACPI_FAN_CMD_ENABLE;
102 + fan_control_access_mode = IBMACPI_FAN_WR_TPEC;
103 + fan_control_commands |= IBMACPI_FAN_CMD_ENABLE;
111 static int fan_read(char *p)
113 @@ -1849,6 +1925,7 @@ static struct ibm_struct ibms[] = {