diff options
-rw-r--r-- | drivers/acpi/ibm_acpi.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c index b6ad2ed5fd6c..ecb5ece79a37 100644 --- a/drivers/acpi/ibm_acpi.c +++ b/drivers/acpi/ibm_acpi.c | |||
@@ -1820,7 +1820,8 @@ static int fan_init(void) | |||
1820 | if (sfan_handle) { | 1820 | if (sfan_handle) { |
1821 | /* 570, 770x-JL */ | 1821 | /* 570, 770x-JL */ |
1822 | fan_control_access_mode = IBMACPI_FAN_WR_ACPI_SFAN; | 1822 | fan_control_access_mode = IBMACPI_FAN_WR_ACPI_SFAN; |
1823 | fan_control_commands |= IBMACPI_FAN_CMD_LEVEL; | 1823 | fan_control_commands |= |
1824 | IBMACPI_FAN_CMD_LEVEL | IBMACPI_FAN_CMD_ENABLE; | ||
1824 | } else { | 1825 | } else { |
1825 | if (!gfan_handle) { | 1826 | if (!gfan_handle) { |
1826 | /* gfan without sfan means no fan control */ | 1827 | /* gfan without sfan means no fan control */ |
@@ -1980,10 +1981,34 @@ static int fan_set_level(int level) | |||
1980 | 1981 | ||
1981 | static int fan_set_enable(void) | 1982 | static int fan_set_enable(void) |
1982 | { | 1983 | { |
1984 | u8 s; | ||
1985 | int rc; | ||
1986 | |||
1983 | switch (fan_control_access_mode) { | 1987 | switch (fan_control_access_mode) { |
1984 | case IBMACPI_FAN_WR_ACPI_FANS: | 1988 | case IBMACPI_FAN_WR_ACPI_FANS: |
1985 | case IBMACPI_FAN_WR_TPEC: | 1989 | case IBMACPI_FAN_WR_TPEC: |
1986 | if (!acpi_ec_write(fan_status_offset, 0x80)) | 1990 | if ((rc = fan_get_status(&s)) < 0) |
1991 | return rc; | ||
1992 | |||
1993 | /* Don't go out of emergency fan mode */ | ||
1994 | if (s != 7) | ||
1995 | s = IBMACPI_FAN_EC_AUTO; | ||
1996 | |||
1997 | if (!acpi_ec_write(fan_status_offset, s)) | ||
1998 | return -EIO; | ||
1999 | break; | ||
2000 | |||
2001 | case IBMACPI_FAN_WR_ACPI_SFAN: | ||
2002 | if ((rc = fan_get_status(&s)) < 0) | ||
2003 | return rc; | ||
2004 | |||
2005 | s &= 0x07; | ||
2006 | |||
2007 | /* Set fan to at least level 4 */ | ||
2008 | if (s < 4) | ||
2009 | s = 4; | ||
2010 | |||
2011 | if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", s)) | ||
1987 | return -EIO; | 2012 | return -EIO; |
1988 | break; | 2013 | break; |
1989 | 2014 | ||
@@ -2002,6 +2027,11 @@ static int fan_set_disable(void) | |||
2002 | return -EIO; | 2027 | return -EIO; |
2003 | break; | 2028 | break; |
2004 | 2029 | ||
2030 | case IBMACPI_FAN_WR_ACPI_SFAN: | ||
2031 | if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", 0x00)) | ||
2032 | return -EIO; | ||
2033 | break; | ||
2034 | |||
2005 | default: | 2035 | default: |
2006 | return -ENXIO; | 2036 | return -ENXIO; |
2007 | } | 2037 | } |