All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolaus Schulz <mail@microschulz.de>
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] [PATCH 2/6] hwmon: (f75375s) Fix writes to the pwm* attribute for the F75387
Date: Wed, 22 Feb 2012 22:18:45 +0000	[thread overview]
Message-ID: <1329949129-4265-3-git-send-email-mail@microschulz.de> (raw)

For the F75387, the register holding the current PWM duty cycle value is
r/o; changing it requires writing to the fan expect register instead.

Signed-off-by: Nikolaus Schulz <mail@microschulz.de>
---
 drivers/hwmon/f75375s.c |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index 5dae122..fc6444d 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -308,8 +308,14 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		return err;
 
 	mutex_lock(&data->update_lock);
+	/* TODO: Improve representation in the register cache for the F75387 */
 	data->pwm[nr] = SENSORS_LIMIT(val, 0, 255);
-	f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr), data->pwm[nr]);
+	if (data->kind = f75387)
+		f75375_write16(client, F75375_REG_FAN_EXP(nr),
+				data->pwm[nr]);
+	else
+		f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
+				data->pwm[nr]);
 	mutex_unlock(&data->update_lock);
 	return count;
 }
@@ -373,9 +379,14 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
 
 	f75375_write8(client, F75375_REG_FAN_TIMER, fanmode);
 	data->pwm_enable[nr] = val;
-	if (val = 0)
-		f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
-				data->pwm[nr]);
+	if (val = 0) {
+		if (data->kind = f75387)
+			f75375_write16(client, F75375_REG_FAN_EXP(nr),
+					data->pwm[nr]);
+		else
+			f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
+					data->pwm[nr]);
+	}
 	return 0;
 }
 
@@ -759,8 +770,12 @@ static void f75375_init(struct i2c_client *client, struct f75375_data *data,
 	set_pwm_enable_direct(client, 1, f75375s_pdata->pwm_enable[1]);
 	for (nr = 0; nr < 2; nr++) {
 		data->pwm[nr] = SENSORS_LIMIT(f75375s_pdata->pwm[nr], 0, 255);
-		f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
-			data->pwm[nr]);
+		if (data->kind = f75387)
+			f75375_write16(client, F75375_REG_FAN_EXP(nr),
+					data->pwm[nr]);
+		else
+			f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
+					data->pwm[nr]);
 	}
 
 }
-- 
1.7.9.1


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

             reply	other threads:[~2012-02-22 22:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-22 22:18 Nikolaus Schulz [this message]
2012-02-23  1:17 ` [lm-sensors] [PATCH 2/6] hwmon: (f75375s) Fix writes to the pwm* attribute for the F75387 Guenter Roeck
2012-02-23 18:43 ` Nikolaus Schulz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329949129-4265-3-git-send-email-mail@microschulz.de \
    --to=mail@microschulz.de \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.