aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2006-11-24 08:47:09 -0500
committerLen Brown <len.brown@intel.com>2006-12-07 01:38:39 -0500
commit69ba91cbd6d79aa197adbdd10a44e71c84044b44 (patch)
tree06793c38456d7b84b1757eac44cafb64199030dd
parent88679a15b3a84366e90cee2a84973abef962b727 (diff)
ACPI: ibm-acpi: prepare to cleanup fan_read and fan_write
This patch lays some groundwork for a fan_read and fan_write cleanup in the next patches. To do so, it provides a new fan_init initializer, and also some constants (through enums). Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
-rw-r--r--drivers/acpi/ibm_acpi.c81
1 files changed, 79 insertions, 2 deletions
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
index 1703c617c0e8..7d0bd61eebc7 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -231,6 +231,31 @@ struct ibm_thermal_sensors_struct {
231 s32 temp[IBMACPI_MAX_THERMAL_SENSORS]; 231 s32 temp[IBMACPI_MAX_THERMAL_SENSORS];
232}; 232};
233 233
234enum fan_status_access_mode {
235 IBMACPI_FAN_NONE = 0, /* No fan status or control */
236 IBMACPI_FAN_RD_ACPI_GFAN, /* Use ACPI GFAN */
237 IBMACPI_FAN_RD_TPEC, /* Use ACPI EC regs 0x2f, 0x84-0x85 */
238};
239
240enum fan_control_access_mode {
241 IBMACPI_FAN_WR_NONE = 0, /* No fan control */
242 IBMACPI_FAN_WR_ACPI_SFAN, /* Use ACPI SFAN */
243 IBMACPI_FAN_WR_TPEC, /* Use ACPI EC reg 0x2f */
244 IBMACPI_FAN_WR_ACPI_FANS, /* Use ACPI FANS and EC reg 0x2f */
245};
246
247enum fan_control_commands {
248 IBMACPI_FAN_CMD_SPEED = 0x0001, /* speed command */
249 IBMACPI_FAN_CMD_LEVEL = 0x0002, /* level command */
250 IBMACPI_FAN_CMD_ENABLE = 0x0004, /* enable/disable cmd */
251};
252
253enum { /* Fan control constants */
254 fan_status_offset = 0x2f, /* EC register 0x2f */
255 fan_rpm_offset = 0x84, /* EC register 0x84: LSB, 0x85 MSB (RPM)
256 * 0x84 must be read before 0x85 */
257};
258
234static int ibm_thinkpad_ec_found; 259static int ibm_thinkpad_ec_found;
235 260
236struct ibm_struct { 261struct ibm_struct {
@@ -1659,8 +1684,59 @@ static int volume_write(char *buf)
1659 return 0; 1684 return 0;
1660} 1685}
1661 1686
1662static int fan_status_offset = 0x2f; 1687static enum fan_status_access_mode fan_status_access_mode;
1663static int fan_rpm_offset = 0x84; 1688static enum fan_control_access_mode fan_control_access_mode;
1689static enum fan_control_commands fan_control_commands;
1690
1691static int fan_init(void)
1692{
1693 u8 status;
1694
1695 fan_status_access_mode = IBMACPI_FAN_NONE;
1696 fan_control_access_mode = IBMACPI_FAN_WR_NONE;
1697 fan_control_commands = 0;
1698
1699 if (gfan_handle) {
1700 /* 570, 600e/x, 770e, 770x */
1701 fan_status_access_mode = IBMACPI_FAN_RD_ACPI_GFAN;
1702 } else {
1703 /* all other ThinkPads: note that even old-style
1704 * ThinkPad ECs supports the fan control register */
1705 if (likely(acpi_ec_read(fan_status_offset, &status))) {
1706 fan_status_access_mode = IBMACPI_FAN_RD_TPEC;
1707 } else {
1708 printk(IBM_ERR
1709 "ThinkPad ACPI EC access misbehaving, "
1710 "fan status and control unavailable\n");
1711 return 0;
1712 }
1713 }
1714
1715 if (sfan_handle) {
1716 /* 570, 770x-JL */
1717 fan_control_access_mode = IBMACPI_FAN_WR_ACPI_SFAN;
1718 fan_control_commands |= IBMACPI_FAN_CMD_LEVEL;
1719 } else {
1720 if (!gfan_handle) {
1721 /* gfan without sfan means no fan control */
1722 /* all other models implement TP EC 0x2f control */
1723
1724 if (fans_handle) {
1725 /* X31, X40 */
1726 fan_control_access_mode =
1727 IBMACPI_FAN_WR_ACPI_FANS;
1728 fan_control_commands |=
1729 IBMACPI_FAN_CMD_SPEED |
1730 IBMACPI_FAN_CMD_ENABLE;
1731 } else {
1732 fan_control_access_mode = IBMACPI_FAN_WR_TPEC;
1733 fan_control_commands |= IBMACPI_FAN_CMD_ENABLE;
1734 }
1735 }
1736 }
1737
1738 return 0;
1739}
1664 1740
1665static int fan_read(char *p) 1741static int fan_read(char *p)
1666{ 1742{
@@ -1849,6 +1925,7 @@ static struct ibm_struct ibms[] = {
1849 .name = "fan", 1925 .name = "fan",
1850 .read = fan_read, 1926 .read = fan_read,
1851 .write = fan_write, 1927 .write = fan_write,
1928 .init = fan_init,
1852 .experimental = 1, 1929 .experimental = 1,
1853 }, 1930 },
1854}; 1931};