Skip to contentSkip to conversation

lm75 on a ppc405

lm-sensors Applied Martin Hicks 2 participants 4 messages Dec 7, 2005 – Dec 8, 2005 I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

hi,

I've got a board with an lm75 connected to the iic of a ppc405. Inserting the i2c-ibm_iic and lm75 (and dependent) modules doesn't find the device. I poked around a bit and applying the following patch seemed to make things better (against 2.6.11.x):

Index: kernel/drivers/i2c/chips/lm75.c
=================================RCS file: /opt/targa/src/e-dtu/kernel/drivers/i2c/chips/lm75.c,v retrieving revision 1.1.1.1

drivers/i2c/chips/lm75.c +0 -2
diff -u -p -r1.1.1.1 lm75.c
@@ -104,8 +104,6 @@ static DEVICE_ATTR(temp1_input, S_IRUGO,
 
 static int lm75_attach_adapter(struct i2c_adapter *adapter)
 {
-	if (!(adapter->class & I2C_CLASS_HWMON))
-		return 0;
 	return i2c_detect(adapter, &addr_data, lm75_detect);
 }
 

This may be wrong, but why do we care if the *adapter* (i.e., the ppc's iic) is a HWMON device? We want the i2c adapters to scan their busses for lm75 devices.

Any insight or is this a correct patch? With this patch I see the lm75 at 0x48 and the temperature it reports is reasonable.

mh

Signature · 1 line
Martin Hicks || mort at bork.org || PGP/GnuPG: 0x4C7F2BEE
#1 lore raw

Hi Martin,

Quoted 21 lines

I've got a board with an lm75 connected to the iic of a ppc405. Inserting the and lm75 (and dependent) modules doesn't find the device. I poked around a bit and applying the following patch seemed to make things better (against 2.6.11.x):

Index: kernel/drivers/i2c/chips/lm75.c
=================================> RCS file: /opt/targa/src/e-dtu/kernel/drivers/i2c/chips/lm75.c,v retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 lm75.c

drivers/i2c/chips/lm75.c +0 -2
@@ -104,8 +104,6 @@ static DEVICE_ATTR(temp1_input, S_IRUGO,
 
 static int lm75_attach_adapter(struct i2c_adapter *adapter)
 {
-	if (!(adapter->class & I2C_CLASS_HWMON))
-		return 0;
 	return i2c_detect(adapter, &addr_data, lm75_detect);
 }
 
Quoted 3 lines

This may be wrong, but why do we care if the *adapter* (i.e., the ppc's iic) is a HWMON device? We want the i2c adapters to scan their busses for lm75 devices.

We care in that some adapters do not want to be probed for random chips, for they know exactly which chips they can have. This is frequently the case for media/video devices. The class separation was introduced to prevent useless probing which was said to sometimes confuse chips and busses. We might move to a better approach in the future, but for now we'll just stick to this one as it works rather fine.

Quoted 2 lines

Any insight or is this a correct patch? With this patch I see the lm75 at 0x48 and the temperature it reports is reasonable.

The correct approach is to add I2C_CLASS_HWMON to i2c-ibm_iic's class flags. I'd take a patch doing that.

Signature · 1 line
Jean Delvare
#2 lore raw
In reply to Martin Hicks
Quoted 1 line · Jean Delvare

[snip]

Quoted 8 lines

We care in that some adapters do not want to be probed for random chips, for they know exactly which chips they can have. This is frequently the case for media/video devices. The class separation was introduced to prevent useless probing which was said to sometimes confuse chips and busses. We might move to a better approach in the future, but for now we'll just stick to this one as it works rather fine.

Ah, that explains it pefectly.

Quoted 5 lines
Quoted 2 lines

Any insight or is this a correct patch? With this patch I see the lm75 at 0x48 and the temperature it reports is reasonable.

The correct approach is to add I2C_CLASS_HWMON to i2c-ibm_iic's class flags. I'd take a patch doing that.

Excellent. Tested against 2.6.11.9, and compile tested with Linus' latest git tree.

Thanks
mh

Signature · 17 lines
Martin Hicks || mort at bork.org || PGP/GnuPG: 0x4C7F2BEE


[PATCH] i2c/ibm_iic - Add to HWMON class

Add the ibm_iic driver to the HWMON class so it will scan the
bus for connected hardware monitor sensors.

Signed-off-by:  Martin Hicks <mort at bork.org>

---

 drivers/i2c/busses/i2c-ibm_iic.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

applies-to: 75f680b437862b125cbce00709fcebf57f146b88
72522808f521cb378a1ed6ee490a9ea7c6e977f7
drivers/i2c/busses/i2c-ibm_iic.c +1 -0
index 1a58725..87fae93 100644
@@ -725,6 +725,7 @@ static int __devinit iic_probe(struct oc
 	strcpy(adap->name, "IBM IIC");
 	i2c_set_adapdata(adap, dev);
 	adap->id = I2C_HW_OCP;
+	adap->class = I2C_CLASS_HWMON;
 	adap->algo = &iic_algo;
 	adap->client_register = NULL;
 	adap->client_unregister = NULL;
Applied
#3 lore raw
In reply to Martin Hicks

Hi Martin,

Quoted 5 lines
Quoted 2 lines

The correct approach is to add I2C_CLASS_HWMON to i2c-ibm_iic's class flags. I'd take a patch doing that.

Excellent. Tested against 2.6.11.9, and compile tested with Linus' latest git tree.

Applied, thanks.

Signature · 1 line
Jean Delvare