mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Acerhdf: fix fan control for BIOS 3309
@ 2009-07-05 13:58 Borislav Petkov
  2009-07-05 16:51 ` Peter Feuerer
  0 siblings, 1 reply; 7+ messages in thread
From: Borislav Petkov @ 2009-07-05 13:58 UTC (permalink / raw)
  To: Len Brown; +Cc: Peter Feuerer, linux-kernel

Hi Len,

please apply.

---
From: Borislav Petkov <petkovbb@gmail.com>
Date: Sun, 5 Jul 2009 14:35:01 +0200
Subject: [PATCH] Acerhdf: fix fan control for BIOS 3309

With BIOS update v3309, the Aspire One has had some changes to how
the fan is being controlled. Reads to the fanreg (0x55) do not simply
return the on/off values of the fan anymore but rather a different
fan stage based on the current temperature. Empirically, I could
observe the fan stage being 0x1 when booting the machine, then the
temperature went up and the BIOS switched the fan to stage 0x2, making
it rotate faster with final stage being fan state 0x3, aka max.

This requires some changes to the controlling code so that it can still
be done adequately. Also, the OFF switch has changed from 0x21 to 0x20.
It seems almost as if they're using the least significant nibble of the
command written to the ioport for the different fan stages.

While at it, convert the fancmd[] array to a real struct thus
disambiguating command handling and making code more readable.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 drivers/platform/x86/acerhdf.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index bdfee17..b2ef9f5 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -108,13 +108,18 @@ MODULE_PARM_DESC(verbose, "Enable verbose dmesg output");
 module_param_string(force_bios, force_bios, 16, 0);
 MODULE_PARM_DESC(force_bios, "Force BIOS version and omit BIOS check");
 
+struct fancmd {
+	u8 cmd_off;
+	u8 cmd_auto;
+};
+
 /* BIOS settings */
 struct bios_settings_t {
 	const char *vendor;
 	const char *version;
 	unsigned char fanreg;
 	unsigned char tempreg;
-	unsigned char fancmd[2]; /* fan off and auto commands */
+	struct fancmd cmd;
 };
 
 /* Register addresses and values for different BIOS versions */
@@ -125,7 +130,7 @@ static const struct bios_settings_t bios_tbl[] = {
 	{"Acer", "v0.3304", 0x55, 0x58, {0xaf, 0x00} },
 	{"Acer", "v0.3305", 0x55, 0x58, {0xaf, 0x00} },
 	{"Acer", "v0.3308", 0x55, 0x58, {0x21, 0x00} },
-	{"Acer", "v0.3309", 0x55, 0x58, {0x21, 0x00} },
+	{"Acer", "v0.3309", 0x55, 0x58, {0x20, 0x00} },
 	{"Acer", "v0.3310", 0x55, 0x58, {0x21, 0x00} },
 	{"Gateway", "v0.3103", 0x55, 0x58, {0x21, 0x00} },
 	{"Packard Bell", "v0.3105", 0x55, 0x58, {0x21, 0x00} },
@@ -134,7 +139,6 @@ static const struct bios_settings_t bios_tbl[] = {
 
 static const struct bios_settings_t *bios_cfg __read_mostly;
 
-
 static int acerhdf_get_temp(int *temp)
 {
 	u8 read_temp;
@@ -150,13 +154,14 @@ static int acerhdf_get_temp(int *temp)
 static int acerhdf_get_fanstate(int *state)
 {
 	u8 fan;
-	bool tmp;
 
 	if (ec_read(bios_cfg->fanreg, &fan))
 		return -EINVAL;
 
-	tmp = (fan == bios_cfg->fancmd[ACERHDF_FAN_OFF]);
-	*state = tmp ? ACERHDF_FAN_OFF : ACERHDF_FAN_AUTO;
+	if (fan != bios_cfg->cmd.cmd_off)
+		*state = ACERHDF_FAN_AUTO;
+	else
+		*state = ACERHDF_FAN_OFF;
 
 	return 0;
 }
@@ -175,7 +180,8 @@ static void acerhdf_change_fanstate(int state)
 		state = ACERHDF_FAN_AUTO;
 	}
 
-	cmd = bios_cfg->fancmd[state];
+	cmd = (state == ACERHDF_FAN_OFF) ? bios_cfg->cmd.cmd_off
+					 : bios_cfg->cmd.cmd_auto;
 	fanstate = state;
 
 	ec_write(bios_cfg->fanreg, cmd);
-- 
1.6.3.1

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-07-08 20:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-05 13:58 [PATCH] Acerhdf: fix fan control for BIOS 3309 Borislav Petkov
2009-07-05 16:51 ` Peter Feuerer
2009-07-05 19:08   ` Andreas Mohr
2009-07-06  7:49     ` Borislav Petkov
2009-07-06  7:43   ` Borislav Petkov
2009-07-07 20:07     ` Peter Feuerer
2009-07-08 20:10       ` [PATCH] Acerhdf: 0.5.15-2 Peter Feuerer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome