Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=69ba91cbd6d79aa197adbdd10a44e71c84044b44
Commit:     69ba91cbd6d79aa197adbdd10a44e71c84044b44
Parent:     88679a15b3a84366e90cee2a84973abef962b727
Author:     Henrique de Moraes Holschuh <[EMAIL PROTECTED]>
AuthorDate: Fri Nov 24 11:47:09 2006 -0200
Committer:  Len Brown <[EMAIL PROTECTED]>
CommitDate: Thu Dec 7 01:38:39 2006 -0500

    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 <[EMAIL PROTECTED]>
---
 drivers/acpi/ibm_acpi.c |   81 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 79 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
index 1703c61..7d0bd61 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -231,6 +231,31 @@ struct ibm_thermal_sensors_struct {
        s32 temp[IBMACPI_MAX_THERMAL_SENSORS];
 };
 
+enum fan_status_access_mode {
+       IBMACPI_FAN_NONE = 0,           /* No fan status or control */
+       IBMACPI_FAN_RD_ACPI_GFAN,       /* Use ACPI GFAN */
+       IBMACPI_FAN_RD_TPEC,            /* Use ACPI EC regs 0x2f, 0x84-0x85 */
+};
+
+enum fan_control_access_mode {
+       IBMACPI_FAN_WR_NONE = 0,        /* No fan control */
+       IBMACPI_FAN_WR_ACPI_SFAN,       /* Use ACPI SFAN */
+       IBMACPI_FAN_WR_TPEC,            /* Use ACPI EC reg 0x2f */
+       IBMACPI_FAN_WR_ACPI_FANS,       /* Use ACPI FANS and EC reg 0x2f */
+};
+
+enum fan_control_commands {
+       IBMACPI_FAN_CMD_SPEED   = 0x0001,       /* speed command */
+       IBMACPI_FAN_CMD_LEVEL   = 0x0002,       /* level command  */
+       IBMACPI_FAN_CMD_ENABLE  = 0x0004,       /* enable/disable cmd */
+};
+
+enum {                                 /* Fan control constants */
+       fan_status_offset = 0x2f,       /* EC register 0x2f */
+       fan_rpm_offset = 0x84,          /* EC register 0x84: LSB, 0x85 MSB (RPM)
+                                        * 0x84 must be read before 0x85 */
+};
+
 static int ibm_thinkpad_ec_found;
 
 struct ibm_struct {
@@ -1659,8 +1684,59 @@ static int volume_write(char *buf)
        return 0;
 }
 
-static int fan_status_offset = 0x2f;
-static int fan_rpm_offset = 0x84;
+static enum fan_status_access_mode fan_status_access_mode;
+static enum fan_control_access_mode fan_control_access_mode;
+static enum fan_control_commands fan_control_commands;
+
+static int fan_init(void)
+{
+       u8 status;
+
+       fan_status_access_mode = IBMACPI_FAN_NONE;
+       fan_control_access_mode = IBMACPI_FAN_WR_NONE;
+       fan_control_commands = 0;
+
+       if (gfan_handle) {
+               /* 570, 600e/x, 770e, 770x */
+               fan_status_access_mode = IBMACPI_FAN_RD_ACPI_GFAN;
+       } else {
+               /* all other ThinkPads: note that even old-style
+                * ThinkPad ECs supports the fan control register */
+               if (likely(acpi_ec_read(fan_status_offset, &status))) {
+                       fan_status_access_mode = IBMACPI_FAN_RD_TPEC;
+               } else {
+                       printk(IBM_ERR
+                              "ThinkPad ACPI EC access misbehaving, "
+                              "fan status and control unavailable\n");
+                       return 0;
+               }
+       }
+
+       if (sfan_handle) {
+               /* 570, 770x-JL */
+               fan_control_access_mode = IBMACPI_FAN_WR_ACPI_SFAN;
+               fan_control_commands |= IBMACPI_FAN_CMD_LEVEL;
+       } else {
+               if (!gfan_handle) {
+                       /* gfan without sfan means no fan control */
+                       /* all other models implement TP EC 0x2f control */
+
+                       if (fans_handle) {
+                               /* X31, X40 */
+                               fan_control_access_mode =
+                                   IBMACPI_FAN_WR_ACPI_FANS;
+                               fan_control_commands |=
+                                   IBMACPI_FAN_CMD_SPEED |
+                                   IBMACPI_FAN_CMD_ENABLE;
+                       } else {
+                               fan_control_access_mode = IBMACPI_FAN_WR_TPEC;
+                               fan_control_commands |= IBMACPI_FAN_CMD_ENABLE;
+                       }
+               }
+       }
+
+       return 0;
+}
 
 static int fan_read(char *p)
 {
@@ -1849,6 +1925,7 @@ static struct ibm_struct ibms[] = {
         .name = "fan",
         .read = fan_read,
         .write = fan_write,
+        .init = fan_init,
         .experimental = 1,
         },
 };
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to