From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, sensors@Stimpy.netroedge.com
Cc: khali@linux-fr.org
Subject: [PATCH] I2C: Allow it87 pwm reconfiguration
Date: Fri, 4 Mar 2005 12:36:33 -0800 [thread overview]
Message-ID: <1109968592905@kroah.com> (raw)
In-Reply-To: <11099685921394@kroah.com>
ChangeSet 1.2081, 2005/03/02 11:50:10-08:00, khali@linux-fr.org
[PATCH] I2C: Allow it87 pwm reconfiguration
Quoting myself:
> As soon as you will have confirmed that everything worked as expected,
> Jonas and I will provide a patch adding a pwm polarity reconfiguration
> module parameter for you to test. This should give you access to the
> PWM features of your it87 chip again, but in a safe way for a change
> ;)
Here comes this patch. The new "fix_pwm_polarity" module parameter
allows one to force the it87 chip reconfiguration. This is only
supported in the case the original PWM configuration is suspected to be
bogus, and only if we think that reconfiguring the chip is safe.
I wish to thank Rudolf Marek and Jonas Munsin again for their testing
and review of my code.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/i2c/chips/it87.c | 71 +++++++++++++++++++++++++++++++++++++++--------
1 files changed, 59 insertions(+), 12 deletions(-)
diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
--- a/drivers/i2c/chips/it87.c 2005-03-04 12:26:39 -08:00
+++ b/drivers/i2c/chips/it87.c 2005-03-04 12:26:39 -08:00
@@ -104,6 +104,9 @@
/* Update battery voltage after every reading if true */
static int update_vbat;
+/* Not all BIOSes properly configure the PWM registers */
+static int fix_pwm_polarity;
+
/* Chip Type */
static u16 chip_type;
@@ -224,6 +227,7 @@
static int it87_write_value(struct i2c_client *client, u8 register,
u8 value);
static struct it87_data *it87_update_device(struct device *dev);
+static int it87_check_pwm(struct i2c_client *client);
static void it87_init_client(struct i2c_client *client, struct it87_data *data);
@@ -718,7 +722,6 @@
const char *name = "";
int is_isa = i2c_is_isa_adapter(adapter);
int enable_pwm_interface;
- int tmp;
if (!is_isa &&
!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
@@ -822,20 +825,12 @@
if ((err = i2c_attach_client(new_client)))
goto ERROR2;
+ /* Check PWM configuration */
+ enable_pwm_interface = it87_check_pwm(new_client);
+
/* Initialize the IT87 chip */
it87_init_client(new_client, data);
- /* Some BIOSes fail to correctly configure the IT87 fans. All fans off
- * and polarity set to active low is sign that this is the case so we
- * disable pwm control to protect the user. */
- enable_pwm_interface = 1;
- tmp = it87_read_value(new_client, IT87_REG_FAN_CTL);
- if ((tmp & 0x87) == 0) {
- enable_pwm_interface = 0;
- dev_info(&new_client->dev,
- "detected broken BIOS defaults, disabling pwm interface");
- }
-
/* Register sysfs hooks */
device_create_file(&new_client->dev, &dev_attr_in0_input);
device_create_file(&new_client->dev, &dev_attr_in1_input);
@@ -966,6 +961,56 @@
return i2c_smbus_write_byte_data(client, reg, value);
}
+/* Return 1 if and only if the PWM interface is safe to use */
+static int it87_check_pwm(struct i2c_client *client)
+{
+ /* Some BIOSes fail to correctly configure the IT87 fans. All fans off
+ * and polarity set to active low is sign that this is the case so we
+ * disable pwm control to protect the user. */
+ int tmp = it87_read_value(client, IT87_REG_FAN_CTL);
+ if ((tmp & 0x87) == 0) {
+ if (fix_pwm_polarity) {
+ /* The user asks us to attempt a chip reconfiguration.
+ * This means switching to active high polarity and
+ * inverting all fan speed values. */
+ int i;
+ u8 pwm[3];
+
+ for (i = 0; i < 3; i++)
+ pwm[i] = it87_read_value(client,
+ IT87_REG_PWM(i));
+
+ /* If any fan is in automatic pwm mode, the polarity
+ * might be correct, as suspicious as it seems, so we
+ * better don't change anything (but still disable the
+ * PWM interface). */
+ if (!((pwm[0] | pwm[1] | pwm[2]) & 0x80)) {
+ dev_info(&client->dev, "Reconfiguring PWM to "
+ "active high polarity\n");
+ it87_write_value(client, IT87_REG_FAN_CTL,
+ tmp | 0x87);
+ for (i = 0; i < 3; i++)
+ it87_write_value(client,
+ IT87_REG_PWM(i),
+ 0x7f & ~pwm[i]);
+ return 1;
+ }
+
+ dev_info(&client->dev, "PWM configuration is "
+ "too broken to be fixed\n");
+ }
+
+ dev_info(&client->dev, "Detected broken BIOS "
+ "defaults, disabling PWM interface\n");
+ return 0;
+ } else if (fix_pwm_polarity) {
+ dev_info(&client->dev, "PWM configuration looks "
+ "sane, won't touch\n");
+ }
+
+ return 1;
+}
+
/* Called when we have found a new IT87. */
static void it87_init_client(struct i2c_client *client, struct it87_data *data)
{
@@ -1126,6 +1171,8 @@
MODULE_DESCRIPTION("IT8705F, IT8712F, Sis950 driver");
module_param(update_vbat, bool, 0);
MODULE_PARM_DESC(update_vbat, "Update vbat if set else return powerup value");
+module_param(fix_pwm_polarity, bool, 0);
+MODULE_PARM_DESC(fix_pwm_polarity, "Force PWM polarity to active high (DANGEROUS)");
MODULE_LICENSE("GPL");
module_init(sm_it87_init);
next prev parent reply other threads:[~2005-03-04 21:07 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-04 20:35 [BK PATCH] I2C patches for 2.6.11 Greg KH
2005-03-04 20:36 ` [PATCH] I2C: add fscpos chip driver Greg KH
2005-03-04 20:36 ` Greg KH [this message]
2005-03-04 20:36 ` [PATCH] I2C: Fix up some build warnings in the fscpos driver Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Kill i2c_client.id (1/5) Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Kill i2c_client.id (2/5) Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Kill i2c_client.id (3/5) Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Kill i2c_client.id (4/5) Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Kill i2c_client.id (5/5) Greg KH
2005-03-04 20:36 ` [PATCH] I2C: just delete the id field, let's not delay it any longer Greg KH
2005-03-04 20:36 ` [PATCH] I2C: fix for fscpos voltage values Greg KH
2005-03-04 20:36 ` [PATCH] I2C: i2c-dev namespace cleanup Greg KH
2005-03-04 20:36 ` [PATCH] I2C: lm78 driver improvement Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Enable w83781d and w83627hf temperature channels Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Kill unused includes in i2c-sensor-detect.c Greg KH
2005-03-04 20:36 ` [PATCH] I2C: unnecessary #includes in asb100.c Greg KH
2005-03-04 20:36 ` [PATCH] I2C: lm80 driver improvement Greg KH
2005-03-04 20:36 ` [PATCH] i2c-core.c: make some code static Greg KH
2005-03-04 20:36 ` [PATCH] I2C: use time_after instead of comparing jiffies Greg KH
2005-03-04 20:36 ` [PATCH] I2C: add ST M41T00 I2C RTC chip driver Greg KH
2005-03-04 20:36 ` [PATCH] I2C: New chip driver: sis5595 Greg KH
2005-03-04 20:36 ` [PATCH] I2C: add Marvell mv64xxx i2c driver Greg KH
2005-03-04 20:36 ` [PATCH] I2C: add GL520SM Sensor Chip driver Greg KH
2005-03-04 20:36 ` [PATCH] I2C: improve debugging output Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Enable I2C_PIIX4 for 64-bit platforms Greg KH
2005-03-04 20:36 ` [PATCH] I2C: fix typo in drivers/i2c/busses/i2c-ixp4xx.c Greg KH
2005-03-04 20:36 ` [PATCH] I2C i2c-nforce2: add support for nForce4 (patch against 2.6.11-rc4) Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Remove NULL client checks in rtc8564 driver Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Make i2c list terminators explicitely unsigned Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Fix some gcc 4.0 compile failures and warnings Greg KH
2005-03-04 20:36 ` [PATCH] I2C: S3C2410 missing I2C_CLASS_HWMON Greg KH
2005-03-04 20:36 ` [PATCH] I2C: minor I2C cleanups Greg KH
2005-03-04 20:36 ` [PATCH] Add class definition to the elektor bus driver Greg KH
2005-03-04 20:36 ` [PATCH] I2C: saa7146 build fix Greg KH
2005-03-04 20:36 ` [PATCH] I2C: w83627hf needs i2c-isa Greg KH
2005-03-04 20:36 ` [PATCH] I2C: fixed up the i2c-id.h algo ids Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Change of i2c co-maintainer Greg KH
2005-03-04 20:36 ` [PATCH] I2C: Trivial indentation fix in i2c/chips/Kconfig Greg KH
2005-03-04 22:55 ` [PATCH] I2C: Fix some gcc 4.0 compile failures and warnings Mickey Stein
2005-03-04 23:02 ` Greg KH
2005-03-05 5:57 ` [RFQ] Rules for accepting patches into the linux-releases tree Shawn Starr
2005-03-05 6:11 ` Randy.Dunlap
2005-03-05 16:33 ` Greg KH
2005-03-24 6:39 ` [2.6.11.5][BUILD] i2c.h breakage in 2.6.12-rc1 + -mm only Shawn Starr
2005-03-24 8:03 ` Greg KH
2005-03-05 11:59 ` [BK PATCH] I2C patches for 2.6.11 Jean Delvare
2005-03-06 6:55 ` Greg KH
2005-03-07 8:50 ` Adrian Bunk
2005-03-08 8:41 ` Domen Puncer
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=1109968592905@kroah.com \
--to=greg@kroah.com \
--cc=khali@linux-fr.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sensors@Stimpy.netroedge.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox