Add patches accepted for 2.6.29-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.29-rc2 / 0012-ACPI-thinkpad-acpi-clean-up-fan-subdriver-quirk.patch
blobdf158811ca2faf42153942da1ad06ce970f97e85
1 From 1c2ece758a36b48133717e4db060fbe8fa52c5cd Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Sun, 11 Jan 2009 03:01:08 -0200
4 Subject: ACPI: thinkpad-acpi: clean-up fan subdriver quirk
6 Better document the Unitialized HFSP quirk, and modularize it a bit.
7 This makes the code flow easier to read and reduces LOC.
9 Apply the Unitialized HFSP closer to the source (i.e. inside the
10 get_fan_status()), this fixes a harmless buglet where at driver init
11 with the quirk active, the user could set the hwmon pwm1 attribute and
12 switch out of pwm1_mode=2 to pwm1_mode=0 without changing pwm1_mode
13 directly.
15 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
16 Cc: Tino Keitel <tino.keitel@tikei.de>
17 Signed-off-by: Len Brown <len.brown@intel.com>
18 ---
19 drivers/platform/x86/thinkpad_acpi.c | 109 ++++++++++++++++++----------------
20 1 files changed, 58 insertions(+), 51 deletions(-)
22 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
23 index d7d41ae..213219d 100644
24 --- a/drivers/platform/x86/thinkpad_acpi.c
25 +++ b/drivers/platform/x86/thinkpad_acpi.c
26 @@ -5897,6 +5897,60 @@ TPACPI_HANDLE(sfan, ec, "SFAN", /* 570 */
27 ); /* all others */
30 + * Unitialized HFSP quirk: ACPI DSDT and EC fail to initialize the
31 + * HFSP register at boot, so it contains 0x07 but the Thinkpad could
32 + * be in auto mode (0x80).
33 + *
34 + * This is corrected by any write to HFSP either by the driver, or
35 + * by the firmware.
36 + *
37 + * We assume 0x07 really means auto mode while this quirk is active,
38 + * as this is far more likely than the ThinkPad being in level 7,
39 + * which is only used by the firmware during thermal emergencies.
40 + */
42 +static void fan_quirk1_detect(void)
44 + /* In some ThinkPads, neither the EC nor the ACPI
45 + * DSDT initialize the HFSP register, and it ends up
46 + * being initially set to 0x07 when it *could* be
47 + * either 0x07 or 0x80.
48 + *
49 + * Enable for TP-1Y (T43), TP-78 (R51e),
50 + * TP-76 (R52), TP-70 (T43, R52), which are known
51 + * to be buggy. */
52 + if (fan_control_initial_status == 0x07) {
53 + switch (thinkpad_id.ec_model) {
54 + case 0x5931: /* TP-1Y */
55 + case 0x3837: /* TP-78 */
56 + case 0x3637: /* TP-76 */
57 + case 0x3037: /* TP-70 */
58 + printk(TPACPI_NOTICE
59 + "fan_init: initial fan status is unknown, "
60 + "assuming it is in auto mode\n");
61 + tp_features.fan_ctrl_status_undef = 1;
62 + ;;
63 + }
64 + }
67 +static void fan_quirk1_handle(u8 *fan_status)
69 + if (unlikely(tp_features.fan_ctrl_status_undef)) {
70 + if (*fan_status != fan_control_initial_status) {
71 + /* something changed the HFSP regisnter since
72 + * driver init time, so it is not undefined
73 + * anymore */
74 + tp_features.fan_ctrl_status_undef = 0;
75 + } else {
76 + /* Return most likely status. In fact, it
77 + * might be the only possible status */
78 + *fan_status = TP_EC_FAN_AUTO;
79 + }
80 + }
83 +/*
84 * Call with fan_mutex held
86 static void fan_update_desired_level(u8 status)
87 @@ -5934,8 +5988,10 @@ static int fan_get_status(u8 *status)
88 if (unlikely(!acpi_ec_read(fan_status_offset, &s)))
89 return -EIO;
91 - if (likely(status))
92 + if (likely(status)) {
93 *status = s;
94 + fan_quirk1_handle(status);
95 + }
97 break;
99 @@ -6245,16 +6301,6 @@ static ssize_t fan_pwm1_enable_show(struct device *dev,
100 if (res)
101 return res;
103 - if (unlikely(tp_features.fan_ctrl_status_undef)) {
104 - if (status != fan_control_initial_status) {
105 - tp_features.fan_ctrl_status_undef = 0;
106 - } else {
107 - /* Return most likely status. In fact, it
108 - * might be the only possible status */
109 - status = TP_EC_FAN_AUTO;
113 if (status & TP_EC_FAN_FULLSPEED) {
114 mode = 0;
115 } else if (status & TP_EC_FAN_AUTO) {
116 @@ -6319,14 +6365,6 @@ static ssize_t fan_pwm1_show(struct device *dev,
117 if (res)
118 return res;
120 - if (unlikely(tp_features.fan_ctrl_status_undef)) {
121 - if (status != fan_control_initial_status) {
122 - tp_features.fan_ctrl_status_undef = 0;
123 - } else {
124 - status = TP_EC_FAN_AUTO;
128 if ((status &
129 (TP_EC_FAN_AUTO | TP_EC_FAN_FULLSPEED)) != 0)
130 status = fan_control_desired_level;
131 @@ -6458,29 +6496,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)
132 if (likely(acpi_ec_read(fan_status_offset,
133 &fan_control_initial_status))) {
134 fan_status_access_mode = TPACPI_FAN_RD_TPEC;
136 - /* In some ThinkPads, neither the EC nor the ACPI
137 - * DSDT initialize the fan status, and it ends up
138 - * being set to 0x07 when it *could* be either
139 - * 0x07 or 0x80.
141 - * Enable for TP-1Y (T43), TP-78 (R51e),
142 - * TP-76 (R52), TP-70 (T43, R52), which are known
143 - * to be buggy. */
144 - if (fan_control_initial_status == 0x07) {
145 - switch (thinkpad_id.ec_model) {
146 - case 0x5931: /* TP-1Y */
147 - case 0x3837: /* TP-78 */
148 - case 0x3637: /* TP-76 */
149 - case 0x3037: /* TP-70 */
150 - printk(TPACPI_NOTICE
151 - "fan_init: initial fan status "
152 - "is unknown, assuming it is "
153 - "in auto mode\n");
154 - tp_features.fan_ctrl_status_undef = 1;
155 - ;;
158 + fan_quirk1_detect();
159 } else {
160 printk(TPACPI_ERR
161 "ThinkPad ACPI EC access misbehaving, "
162 @@ -6669,15 +6685,6 @@ static int fan_read(char *p)
163 if (rc < 0)
164 return rc;
166 - if (unlikely(tp_features.fan_ctrl_status_undef)) {
167 - if (status != fan_control_initial_status)
168 - tp_features.fan_ctrl_status_undef = 0;
169 - else
170 - /* Return most likely status. In fact, it
171 - * might be the only possible status */
172 - status = TP_EC_FAN_AUTO;
175 len += sprintf(p + len, "status:\t\t%s\n",
176 (status != 0) ? "enabled" : "disabled");
179 1.5.6.5