Add support for LM75A.
Hi Lennart,
Please send hwmon patches to the lm-sensors list, as specified in MAINTAINERS.
Quoted 8 lines · Lennart Sorensen
The LM75A can not be detected with the same logic as previous LM75 designs. Previous designs would return the last value read when an unused register was read. The LM75 returns
0xffwhen an usesed register is read and it also has a new identity register.This patch adds the new detection logic for the LM75A, allowing the lm75 driver to correctly detect the presence of an LM75A as well as older LM75 designs.
Do you actually need to _detect_ an LM75A device? The only reason why the lm75 driver originally detected the LM75 was because it was very popular as a hardware monitoring chip on PC mainboards. This was in years 1998-2001, the LM75 is no longer used for this purpose on modern PC mainboards. So I would be very surprised if an LM75A was used on PC mainboards.
For embedded systems, or graphics cards, the preferred way is to explicitly instantiate the I2C device. Can't just you do this?
Quoted 8 lines
Signed-off-by Len Sorensen <[email protected]>drivers/hwmon/lm75.c +0
-0
drivers/hwmon/lm75.c static int lm75_detect(struct i2c_client *new_client, · line 257
Quoted 9 lines
drivers/hwmon/lm75.c +5
-1@@ -250,23 +250,40 @@ static int lm75_detect(struct i2c_client *new_client,addresses 0x04-0x07 returning the last read value. The cycling+unused addresses combination is not tested, since it would significantly slow the detection down and would -hardly add any value. */ +hardly add any value. + +The LM75A is different. It has an id byte of 0xaX (where +X is the chip revision) in register 7, and unused registers +return 0xff rather than the last read value. */
Maybe this holds for the National Semiconductor LM75A, but not for the Philips/NXP variant, at least according to the datasheet (no device ID register.)
Quoted 11 lines
drivers/hwmon/lm75.c +0
-8-/* Unused addresses */ cur =i2c_smbus_read_word_data (new_client,0 ); conf =i2c_smbus_read_byte_data (new_client,1 ); - hyst =i2c_smbus_read_word_data (new_client,2 ); -if (i2c_smbus_read_word_data (new_client,4 ) != hyst - ||i2c_smbus_read_word_data (new_client,5 ) != hyst - ||i2c_smbus_read_word_data (new_client,6 ) != hyst - ||i2c_smbus_read_word_data (new_client,7 ) != hyst) -return -ENODEV ; - os =i2c_smbus_read_word_data (new_client,3 );
drivers/hwmon/lm75.c static int lm75_detect(struct i2c_client *new_client, · line 264
Quoted 10 lines
drivers/hwmon/lm75.c +5
-5-if (i2c_smbus_read_word_data (new_client,4 ) != os - ||i2c_smbus_read_word_data (new_client,5 ) != os - ||i2c_smbus_read_word_data (new_client,6 ) != os - ||i2c_smbus_read_word_data (new_client,7 ) != os) -return -ENODEV ; + +/* First check for LM75A */ +if ((i2c_smbus_read_byte_data (new_client,7 ) &0xf0 ) =0xa0 ) { +/* LM 75A returns 0xff on unused registers so +just to be sure we check for that too. */
This is definitely a good idea. 4 bits for the device ID is weak, other devices could match. In fact I think we should check all 8 bits for value 0xa1, as this is what is documented in the datasheet.
Quoted 15 lines
drivers/hwmon/lm75.c +15
-0+if (i2c_smbus_read_byte_data (new_client,4 ) !=0xff + ||i2c_smbus_read_byte_data (new_client,5 ) !=0xff + ||i2c_smbus_read_byte_data (new_client,6 ) !=0xff ) +return -ENODEV ; + hyst =i2c_smbus_read_word_data (new_client,2 ); + os =i2c_smbus_read_word_data (new_client,3 ); + }else {/* Traditional style LM75 detection */ +/* Unused addresses */ + hyst =i2c_smbus_read_word_data (new_client,2 ); +if (i2c_smbus_read_word_data (new_client,4 ) != hyst + ||i2c_smbus_read_word_data (new_client,5 ) != hyst + ||i2c_smbus_read_word_data (new_client,6 ) != hyst + ||i2c_smbus_read_word_data (new_client,7 ) != hyst) +return -ENODEV ; + os =i2c_smbus_read_word_data (new_client,3 );
drivers/hwmon/lm75.c static int lm75_detect(struct i2c_client *new_client, · line 289
Quoted 10 lines
drivers/hwmon/lm75.c +6
-0+if (i2c_smbus_read_word_data (new_client,4 ) != os + ||i2c_smbus_read_word_data (new_client,5 ) != os + ||i2c_smbus_read_word_data (new_client,6 ) != os + ||i2c_smbus_read_word_data (new_client,7 ) != os) +return -ENODEV ; + }/* Unused bits */ if (conf &0xe0 )
Your patch is incomplete, it should set the name to "lm75a" for the LM75A. Also, later in the detection routine, address cycling is tested of offsets 1, 2 and 3, it would make sense to do the same for offset 7 (device ID) for the LM75A.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 4 lines · Jean Delvare
Hi Lennart,
Please send hwmon patches to the lm-sensors list, as specified in
MAINTAINERS.
Hmm, I looked through there and thought I had found the right address.
Quoted 10 lines · Lennart Sorensen
Quoted 8 lines
The LM75A can not be detected with the same logic as previous LM75 designs. Previous designs would return the last value read when an unused register was read. The LM75 returns
0xffwhen an usesed register is read and it also has a new identity register.This patch adds the new detection logic for the LM75A, allowing the lm75 driver to correctly detect the presence of an LM75A as well as older LM75 designs.
Quoted 6 lines
Do you actually need to _detect_ an LM75A device? The only reason why the lm75 driver originally detected the LM75 was because it was very popular as a hardware monitoring chip on PC mainboards. This was in years 1998-2001, the LM75 is no longer used for this purpose on modern PC mainboards. So I would be very surprised if an LM75A was used on PC mainboards.
Not everything is a PC. It is still a very common chip on embedded systems.
Quoted 2 lines
For embedded systems, or graphics cards, the preferred way is to explicitly instantiate the I2C device. Can't just you do this?
No, not really. Auto detection just works, and the only reason I did this patch is that natsemi is apparently discontinuing the original LM75s ands starting to ship this new one, so existing designs now have to start using this new slightly different one. The coldfire (m68knommu) doesn't have any board info to specify chips, unlike say powerpc where it is easy. I wish we didn't have to go to a new chip, but apparently we get no choice. I really don't want to have to design a bunch of new code to handle detection and registration of lm75 chips with the driver in user space, when this used to just work before the new chip version happened.
Quoted 12 lines
Quoted 12 lines
Signed-off-by Len Sorensen <[email protected]>drivers/hwmon/lm75.c +1
-1@@ -250,23 +250,40 @@ static int lm75_detect(struct i2c_client *new_client, addresses 0x04-0x07 returning the last read value. The cycling+unused addresses combination is not tested, since it would significantly slow the detection down and would -hardly add any value. */ + hardly add any value.
Quoted 8 lines
drivers/hwmon/lm75.c static int lm75_detect(struct i2c_client *new_client, · line 257
Quoted 4 lines
drivers/hwmon/lm75.c +4
-0+ +The LM75A is different. It has an id byte of 0xaX (where +X is the chip revision) in register 7, and unused registers +return 0xff rather than the last read value. */ Maybe this holds for the National Semiconductor LM75A, but not for the Philips/NXP variant, at least according to the datasheet (no device ID register.)
Well the LM75B and LM75C didn't have one either, and they still work fine given I did not remove the old detection method.
Quoted 17 lines
Quoted 17 lines
drivers/hwmon/lm75.c +1
-13-/* Unused addresses */ cur =i2c_smbus_read_word_data (new_client,0 ); conf =i2c_smbus_read_byte_data (new_client,1 ); - hyst =i2c_smbus_read_word_data (new_client,2 ); -if (i2c_smbus_read_word_data (new_client,4 ) != hyst - ||i2c_smbus_read_word_data (new_client,5 ) != hyst - ||i2c_smbus_read_word_data (new_client,6 ) != hyst - ||i2c_smbus_read_word_data (new_client,7 ) != hyst) -return -ENODEV ; - os =i2c_smbus_read_word_data (new_client,3 ); -if (i2c_smbus_read_word_data (new_client,4 ) != os - ||i2c_smbus_read_word_data (new_client,5 ) != os - ||i2c_smbus_read_word_data (new_client,6 ) != os - ||i2c_smbus_read_word_data (new_client,7 ) != os) -return -ENODEV ; +
Quoted 8 lines
drivers/hwmon/lm75.c static int lm75_detect(struct i2c_client *new_client, · line 264
Quoted 4 lines
drivers/hwmon/lm75.c +4
-0+/* First check for LM75A */ +if ((i2c_smbus_read_byte_data (new_client,7 ) &0xf0 ) =0xa0 ) { +/* LM 75A returns 0xff on unused registers so +just to be sure we check for that too. */ This is definitely a good idea. 4 bits for the device ID is weak, other devices could match. In fact I think we should check all 8 bits for value
0xa1, as this is what is documented in the datasheet.
Well the datasheet says 0xa is the ID, and 1 is a revision. If you want to fail as soon as they make a new revision, well fine, but I consider that a bad idea. The ID really is only the first 4 bits though. I can change that if you want, but I am not personally in favour of it, just in case they do ever update the revision.
I am a bit peeved at natsemi for claiming to have a fully compatible chip, when the new chip is completely incompatible with how people have detected their existing chip for years. Now existing software releases won't work with new hardware builds because I have to update this driver first. How annoying.
Quoted 22 lines
Quoted 22 lines
drivers/hwmon/lm75.c +21
-0+if (i2c_smbus_read_byte_data (new_client,4 ) !=0xff + ||i2c_smbus_read_byte_data (new_client,5 ) !=0xff + ||i2c_smbus_read_byte_data (new_client,6 ) !=0xff ) +return -ENODEV ; + hyst =i2c_smbus_read_word_data (new_client,2 ); + os =i2c_smbus_read_word_data (new_client,3 ); + }else {/* Traditional style LM75 detection */ +/* Unused addresses */ + hyst =i2c_smbus_read_word_data (new_client,2 ); +if (i2c_smbus_read_word_data (new_client,4 ) != hyst + ||i2c_smbus_read_word_data (new_client,5 ) != hyst + ||i2c_smbus_read_word_data (new_client,6 ) != hyst + ||i2c_smbus_read_word_data (new_client,7 ) != hyst) +return -ENODEV ; + os =i2c_smbus_read_word_data (new_client,3 ); +if (i2c_smbus_read_word_data (new_client,4 ) != os + ||i2c_smbus_read_word_data (new_client,5 ) != os + ||i2c_smbus_read_word_data (new_client,6 ) != os + ||i2c_smbus_read_word_data (new_client,7 ) != os) +return -ENODEV ; + }
Quoted 8 lines
drivers/hwmon/lm75.c static int lm75_detect(struct i2c_client *new_client, · line 289
Quoted 3 lines
drivers/hwmon/lm75.c +0
-0/* Unused bits */ if (conf &0xe0 )Your patch is incomplete, it should set the name to "lm75a" for the LM75A. Also, later in the detection routine, address cycling is tested of offsets 1, 2 and 3, it would make sense to do the same for offset 7 (device ID) for the LM75A.
Hmm, good point. I can fix that. I wasn't sure if the name was supposed to indicate the driver or the chip. So if I fix the address cycling check, and change the name to lm75a when detected, and possibly fix the ID/rev check to include both, would that help?
Signature · 6 lines
Len Sorensen _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Lennart,
Quoted 10 lines · Lennart Sorensen
Quoted 6 lines · Jean Delvare
Do you actually need to _detect_ an LM75A device? The only reason why the lm75 driver originally detected the LM75 was because it was very popular as a hardware monitoring chip on PC mainboards. This was in years 1998-2001, the LM75 is no longer used for this purpose on modern PC mainboards. So I would be very surprised if an LM75A was used on PC mainboards.
Not everything is a PC. It is still a very common chip on embedded systems.
But embedded systems (arm, blackfin, cris) typically instantiate it explicitly.
Quoted 4 lines
Quoted 2 lines
For embedded systems, or graphics cards, the preferred way is to explicitly instantiate the I2C device. Can't just you do this?
No, not really. Auto detection just works,
You have an interesting definition of "just works", given that you're sending a patch to fix a problem you've hit ;)
Quoted 6 lines
and the only reason I did
this patch is that natsemi is apparently discontinuing the original LM75s ands starting to ship this new one, so existing designs now have to start using this new slightly different one. The coldfire (m68knommu) doesn't have any board info to specify chips, unlike say powerpc where it is easy.
Can't it be added? This would be the sanest approach, protecting you against similar issues in the future.
Quoted 5 lines
I wish we didn't have to go to a new chip, but apparently we get no choice. I really don't want to have to design a bunch of new code to handle detection and registration of lm75 chips with the driver in user space, when this used to just work before the new chip version happened.
A bunch of new code? I don't expect this to need much code (but I admit I never wrote this - I am not into embedded systems.) Did you only try?
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Signed-off-by Len Sorensen <[email protected]>drivers/hwmon/lm75.c +1
-1@@ -250,23 +250,40 @@ static int lm75_detect(struct i2c_client *new_client, addresses 0x04-0x07 returning the last read value. The cycling+unused addresses combination is not tested, since it would significantly slow the detection down and would -hardly add any value. */ + hardly add any value.Quoted 8 lines
drivers/hwmon/lm75.c static int lm75_detect(struct i2c_client *new_client, · line 257
Quoted 4 lines
drivers/hwmon/lm75.c +4
-0+ +The LM75A is different. It has an id byte of 0xaX (where +X is the chip revision) in register 7, and unused registers +return 0xff rather than the last read value. */ Maybe this holds for the National Semiconductor LM75A, but not for the Philips/NXP variant, at least according to the datasheet (no device ID register.)
Quoted 2 lines
Well the LM75B and LM75C didn't have one either, and they still work fine given I did not remove the old detection method.
My point was that you should say "National Semiconductor LM75A" and not just LM75A, to avoid confusion with other brands.
Quoted 26 lines
Quoted 17 lines
Quoted 17 lines
drivers/hwmon/lm75.c +1
-13-/* Unused addresses */ cur =i2c_smbus_read_word_data (new_client,0 ); conf =i2c_smbus_read_byte_data (new_client,1 ); - hyst =i2c_smbus_read_word_data (new_client,2 ); -if (i2c_smbus_read_word_data (new_client,4 ) != hyst - ||i2c_smbus_read_word_data (new_client,5 ) != hyst - ||i2c_smbus_read_word_data (new_client,6 ) != hyst - ||i2c_smbus_read_word_data (new_client,7 ) != hyst) -return -ENODEV ; - os =i2c_smbus_read_word_data (new_client,3 ); -if (i2c_smbus_read_word_data (new_client,4 ) != os - ||i2c_smbus_read_word_data (new_client,5 ) != os - ||i2c_smbus_read_word_data (new_client,6 ) != os - ||i2c_smbus_read_word_data (new_client,7 ) != os) -return -ENODEV ; +Quoted 8 lines
drivers/hwmon/lm75.c static int lm75_detect(struct i2c_client *new_client, · line 264
Quoted 4 lines
drivers/hwmon/lm75.c +4
-0+/* First check for LM75A */ +if ((i2c_smbus_read_byte_data (new_client,7 ) &0xf0 ) =0xa0 ) { +/* LM 75A returns 0xff on unused registers so +just to be sure we check for that too. */ This is definitely a good idea. 4 bits for the device ID is weak, other devices could match. In fact I think we should check all 8 bits for value
0xa1, as this is what is documented in the datasheet.
Quoted 5 lines
Well the datasheet says
0xais the ID, and 1 is a revision. If you want to fail as soon as they make a new revision, well fine, but I consider that a bad idea. The ID really is only the first 4 bits though. I can change that if you want, but I am not personally in favour of it, just in case they do ever update the revision.
My experience with ID registers in I2C devices is that the revision rarely changes, and when it does, it often requires other driver changes to properly support the new device revision. So it is preferable to only support the known revisions, and add new revisions as they spotted in the wild or datasheets are updated to mention them.
Please keep in mind that there is no standard ID registers in I2C devices, neither address nor values. So it is perfectly possible for other devices to match your detection routine if you aren't strict enough. It is preferable to miss a detection than to have a false positive and accidentally bind to a totally different device. This is what I want to avoid.
If you still disagree, a middle ground would be to reject revision = 0 and only accept reasonable revisions (that is revision = 2 may happen in the future, but I don't expect say revision = 10 any time soon.)
Quoted 5 lines
I am a bit peeved at natsemi for claiming to have a fully compatible chip, when the new chip is completely incompatible with how people have detected their existing chip for years. Now existing software releases won't work with new hardware builds because I have to update this driver first. How annoying.
This is certainly annoying, but you can't blame National Semiconductor for this. Instead, blame yourself for still relying on automatic device detection in 2011 when mechanisms to cleanly instantiate I2C devices exist since mid-2008. The original LM75 was never meant to be detected, it doesn't even have an ID register.
Quoted 32 lines
Quoted 23 lines
Quoted 23 lines
drivers/hwmon/lm75.c +21
-0+if (i2c_smbus_read_byte_data (new_client,4 ) !=0xff + ||i2c_smbus_read_byte_data (new_client,5 ) !=0xff + ||i2c_smbus_read_byte_data (new_client,6 ) !=0xff ) +return -ENODEV ; + hyst =i2c_smbus_read_word_data (new_client,2 ); + os =i2c_smbus_read_word_data (new_client,3 ); + }else {/* Traditional style LM75 detection */ +/* Unused addresses */ + hyst =i2c_smbus_read_word_data (new_client,2 ); +if (i2c_smbus_read_word_data (new_client,4 ) != hyst + ||i2c_smbus_read_word_data (new_client,5 ) != hyst + ||i2c_smbus_read_word_data (new_client,6 ) != hyst + ||i2c_smbus_read_word_data (new_client,7 ) != hyst) +return -ENODEV ; + os =i2c_smbus_read_word_data (new_client,3 ); +if (i2c_smbus_read_word_data (new_client,4 ) != os + ||i2c_smbus_read_word_data (new_client,5 ) != os + ||i2c_smbus_read_word_data (new_client,6 ) != os + ||i2c_smbus_read_word_data (new_client,7 ) != os) +return -ENODEV ; + }Quoted 8 lines
drivers/hwmon/lm75.c static int lm75_detect(struct i2c_client *new_client, · line 289
Quoted 3 lines
drivers/hwmon/lm75.c +0
-0/* Unused bits */ if (conf &0xe0 )Your patch is incomplete, it should set the name to "lm75a" for the LM75A. Also, later in the detection routine, address cycling is tested of offsets 1, 2 and 3, it would make sense to do the same for offset 7 (device ID) for the LM75A.
Quoted 2 lines
Hmm, good point. I can fix that. I wasn't sure if the name was supposed to indicate the driver or the chip.
Chip.
Quoted 3 lines
So if I fix the address cycling
check, and change the name to lm75a when detected, and possibly fix the ID/rev check to include both, would that help?
Yes it would.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 2 lines · Jean Delvare
But embedded systems (arm, blackfin, cris) typically instantiate it explicitly.
Certainly some do. We happen to boot a single fairly generic coldfire kernel on multiple similar boards, with slight differences in hardware. The number of LM75's for example varies. So far that had worked fine with nothing really having to worry about which exact board it was booting on.
Quoted 2 lines
You have an interesting definition of "just works", given that you're sending a patch to fix a problem you've hit ;)
Well it just worked before, using prior LM75 chips. The new chips are the problem for us.
Quoted 2 lines
Can't it be added? This would be the sanest approach, protecting you against similar issues in the future.
Well I can certainly start looking into that. Adding command line argument passing for the coldfire certainly made a lot of things nicer, so perhaps adding some dtb like thing could too. Sounds like a bigger job though.
Quoted 2 lines
A bunch of new code? I don't expect this to need much code (but I admit I never wrote this - I am not into embedded systems.) Did you only try?
When you have a uclinux user space with very little in it, adding more code to handle detection of LM75 variants and adding them to the driver would be more code for sure. Maybe not that much, but still.
Quoted 2 lines
My point was that you should say "National Semiconductor LM75A" and not just LM75A, to avoid confusion with other brands.
Ah, I see. I thought the LMxx was always National Semiconductor and that others used different letters.
Quoted 5 lines
My experience with ID registers in I2C devices is that the revision rarely changes, and when it does, it often requires other driver changes to properly support the new device revision. So it is preferable to only support the known revisions, and add new revisions as they spotted in the wild or datasheets are updated to mention them.
Well I can do that. Either way it is more accurate detection than the older style LM75 detection ever had. Once detected the new one is completely compatible with the old one.
Quoted 6 lines
Please keep in mind that there is no standard ID registers in I2C devices, neither address nor values. So it is perfectly possible for other devices to match your detection routine if you aren't strict enough. It is preferable to miss a detection than to have a false positive and accidentally bind to a totally different device. This is what I want to avoid.
Of course. I am amazed how the old detection code has managed to not be a problem.
Quoted 3 lines
If you still disagree, a middle ground would be to reject revision = 0 and only accept reasonable revisions (that is revision = 2 may happen in the future, but I don't expect say revision = 10 any time soon.)
Well I will just match on the current revision for now then.
Quoted 5 lines
This is certainly annoying, but you can't blame National Semiconductor for this. Instead, blame yourself for still relying on automatic device detection in 2011 when mechanisms to cleanly instantiate I2C devices exist since mid-2008. The original LM75 was never meant to be detected, it doesn't even have an ID register.
Well at least the LM75A does have an ID register, so supporting detection of it seems fair enough.
Quoted 1 line
Chip.
OK, that makes sense. Easily done.
Quoted 1 line
Yes it would.
I will do that. I hope to have an updated patch in a couple of hours.
Signature · 6 lines
Len Sorensen _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 71 lines · Lennart Sorensen
Quoted 2 lines · Jean Delvare
But embedded systems (arm, blackfin, cris) typically instantiate it explicitly.
Certainly some do. We happen to boot a single fairly generic coldfire kernel on multiple similar boards, with slight differences in hardware. The number of LM75's for example varies. So far that had worked fine with nothing really having to worry about which exact board it was booting on.
Quoted 2 lines
You have an interesting definition of "just works", given that you're sending a patch to fix a problem you've hit ;)
Well it just worked before, using prior LM75 chips. The new chips are the problem for us.
Quoted 2 lines
Can't it be added? This would be the sanest approach, protecting you against similar issues in the future.
Well I can certainly start looking into that. Adding command line argument passing for the coldfire certainly made a lot of things nicer, so perhaps adding some dtb like thing could too. Sounds like a bigger job though.
Quoted 2 lines
A bunch of new code? I don't expect this to need much code (but I admit I never wrote this - I am not into embedded systems.) Did you only try?
When you have a uclinux user space with very little in it, adding more code to handle detection of LM75 variants and adding them to the driver would be more code for sure. Maybe not that much, but still.
Quoted 2 lines
My point was that you should say "National Semiconductor LM75A" and not just LM75A, to avoid confusion with other brands.
Ah, I see. I thought the LMxx was always National Semiconductor and that others used different letters.
Quoted 5 lines
My experience with ID registers in I2C devices is that the revision rarely changes, and when it does, it often requires other driver changes to properly support the new device revision. So it is preferable to only support the known revisions, and add new revisions as they spotted in the wild or datasheets are updated to mention them.
Well I can do that. Either way it is more accurate detection than the older style LM75 detection ever had. Once detected the new one is completely compatible with the old one.
Quoted 6 lines
Please keep in mind that there is no standard ID registers in I2C devices, neither address nor values. So it is perfectly possible for other devices to match your detection routine if you aren't strict enough. It is preferable to miss a detection than to have a false positive and accidentally bind to a totally different device. This is what I want to avoid.
Of course. I am amazed how the old detection code has managed to not be a problem.
Quoted 3 lines
If you still disagree, a middle ground would be to reject revision = 0 and only accept reasonable revisions (that is revision = 2 may happen in the future, but I don't expect say revision = 10 any time soon.)
Well I will just match on the current revision for now then.
Quoted 5 lines
This is certainly annoying, but you can't blame National Semiconductor for this. Instead, blame yourself for still relying on automatic device detection in 2011 when mechanisms to cleanly instantiate I2C devices exist since mid-2008. The original LM75 was never meant to be detected, it doesn't even have an ID register.
Well at least the LM75A does have an ID register, so supporting detection of it seems fair enough.
Quoted 8 lines
Quoted 1 line
Chip.
OK, that makes sense. Easily done.
Quoted 1 line
Yes it would.
I will do that. I hope to have an updated patch in a couple of hours.
Fwiw, I have a system with TI TMP75AIDGKT (per HW spec). Detection code doesn't work for it, since it always returns 0xff when reading registers 0x4..0x7. So the lm75 detection code is really of limited value and can not be expected to work for all chips supported by the driver.
Here is a register dump:
root# i2cdump -y 70 0x48
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 00: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 10: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 20: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 30: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 40: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 50: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 60: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 70: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 80: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 90: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... a0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... b0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... c0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... d0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... e0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... f0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP....
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Guenter,
Quoted 4 lines · Guenter Roeck
Fwiw, I have a system with TI TMP75AIDGKT (per HW spec). Detection code doesn't work for it, since it always returns
0xffwhen reading registers 0x4..0x7. So the lm75 detection code is really of limited value and can not be expected to work for all chips supported by the driver.
And it was never meant to. As said before, the detection of the LM75 proper is there only because the chip was once popular on PC mainboards. None of the other chips supported by the lm75 driver was as far as I know.
Quoted 13 lines
Here is a register dump:
root# i2cdump -y 70
0x48
No size specified (using byte-data access)0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 00: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 10: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 20: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 30: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 40: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 50: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 60: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 70: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP....
Quoted 8 lines
80: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 90: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... a0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... b0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... c0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... d0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... e0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... f0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP....
Added to my collection, thanks :) But there is no way to detect this chip reliably.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 4 lines · Jean Delvare
And it was never meant to. As said before, the detection of the LM75 proper is there only because the chip was once popular on PC mainboards. None of the other chips supported by the lm75 driver was as far as I know.
Actually one of the products we will have the LM75A in is an x86 industrial PC, so I guess that counts as being in a PC. Up until now they were LM75Cs (the old ones), so autodetection was handy.
Signature · 6 lines
Len Sorensen _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 35 lines · Jean Delvare
Hi Guenter,
Quoted 4 lines · Guenter Roeck
Fwiw, I have a system with TI TMP75AIDGKT (per HW spec). Detection code doesn't work for it, since it always returns
0xffwhen reading registers 0x4..0x7. So the lm75 detection code is really of limited value and can not be expected to work for all chips supported by the driver.And it was never meant to. As said before, the detection of the LM75 proper is there only because the chip was once popular on PC mainboards. None of the other chips supported by the lm75 driver was as far as I know.
Quoted 13 lines
Here is a register dump:
root# i2cdump -y 70
0x48
No size specified (using byte-data access)0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 00: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 10: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 20: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 30: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 40: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 50: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 60: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 70: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP....Quoted 8 lines
80: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... 90: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... a0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... b0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... c0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... d0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... e0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP.... f0: 13 00 4b 50 ff ff ff ff 13 00 4b 50 ff ff ff ff ?.KP....?.KP....
Quoted 3 lines
Added to my collection, thanks :) But there is no way to detect this chip reliably.
I didn't expect it to; our code uses i2c_register_board_info(). Just trying to show how unreliable chip detection is for this chip.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Lennart,
Quoted 6 lines · Lennart Sorensen
Quoted 2 lines · Jean Delvare
My point was that you should say "National Semiconductor LM75A" and not just LM75A, to avoid confusion with other brands.
Ah, I see. I thought the LMxx was always National Semiconductor and that others used different letters.
This is generally true, so much that we did not bother including the vendor name in i2c device IDs (matching is done on the name string alone.) But apparently the LM75 is such a popular device that is has more clones than any other I2C device I know of, including, sadly, some with the exact same name, but not 100% compatible, from other vendors.
Quoted 8 lines
Quoted 5 lines
My experience with ID registers in I2C devices is that the revision rarely changes, and when it does, it often requires other driver changes to properly support the new device revision. So it is preferable to only support the known revisions, and add new revisions as they spotted in the wild or datasheets are updated to mention them.
Well I can do that. Either way it is more accurate detection than the older style LM75 detection ever had.
I beg to disagree. I would say that both detections are comparable. The LM75-specific behavior of "registers" (or lack thereof) 0x04-0x07, coupled with their cycling, is an almost unique characteristic (which is why we decided to use it for detection purpose.) If you ask me, I would say that a random chip at an LM75-compatible address is less likely to implement this characteristic than to have value 0xA as the high nibble of register 0x07.
Quoted 2 lines
Once detected the new one is
completely compatible with the old one.
Thankfully, yes :)
Quoted 9 lines
Quoted 6 lines
Please keep in mind that there is no standard ID registers in I2C devices, neither address nor values. So it is perfectly possible for other devices to match your detection routine if you aren't strict enough. It is preferable to miss a detection than to have a false positive and accidentally bind to a totally different device. This is what I want to avoid.
Of course. I am amazed how the old detection code has managed to not be a problem.
It has been problematic, and was improved over time. You can see the first version of the detection code here:
http://www.lm-sensors.org/browser/lm-sensors/trunk/kernel/chips/lm75.c?rev38
Quoted 5 lines
Quoted 3 lines
If you still disagree, a middle ground would be to reject revision = 0 and only accept reasonable revisions (that is revision = 2 may happen in the future, but I don't expect say revision = 10 any time soon.)
Well I will just match on the current revision for now then.
OK, fine with me.
Quoted 8 lines
Quoted 5 lines
This is certainly annoying, but you can't blame National Semiconductor for this. Instead, blame yourself for still relying on automatic device detection in 2011 when mechanisms to cleanly instantiate I2C devices exist since mid-2008. The original LM75 was never meant to be detected, it doesn't even have an ID register.
Well at least the LM75A does have an ID register, so supporting detection of it seems fair enough.
Yes and no. 4 bits for the device ID is weak, especially when in a random register (which is why I insisted in using the whole 8 bits, including the revision.) "Good" devices have 8 bits of vendor ID + 8 bits of device ID at semi-standard addresses, and even this is not bullet proof.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 1 line · Lennart Sorensen
I will do that. I hope to have an updated patch in a couple of hours.
OK, here is an updated one:
Add support for detection of LM75A using the ID register value.
drivers/hwmon/lm75.c +43 -15
@@ -232,6 +232,8 @@ static const struct i2c_device_id lm75_ids[] = { };MODULE_DEVICE_TABLE (i2c, lm75_ids); +#define LM75A_ID 0xA1 +/* Return 0 if detection is successful, -ENODEV otherwise */ static int lm75_detect (struct i2c_client *new_client,struct i2c_board_info *info)
@@ -239,6 +241,7 @@ static int lm75_detect(struct i2c_client *new_client,struct i2c_adapter *adapter = new_client->adapter;int i;int cur, conf, hyst, os; +bool is_lm75a =0 ;if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA |I2C_FUNC_SMBUS_WORD_DATA ))
@@ -250,23 +253,43 @@ static int lm75_detect(struct i2c_client *new_client,addresses 0x04-0x07 returning the last read value. The cycling+unused addresses combination is not tested, since it would significantly slow the detection down and would -hardly add any value. */ +hardly add any value. + +The National Semiconductor LM75A is different than earlier +LM75s. It has an ID byte of 0xaX (where X is the chip +revision, with 1 being the only revision in existance) in +register 7, and unused registers return 0xff rather than the +last read value. */ -/* Unused addresses */ cur =i2c_smbus_read_word_data (new_client,0 ); conf =i2c_smbus_read_byte_data (new_client,1 ); - hyst =i2c_smbus_read_word_data (new_client,2 ); -if (i2c_smbus_read_word_data (new_client,4 ) != hyst - ||i2c_smbus_read_word_data (new_client,5 ) != hyst - ||i2c_smbus_read_word_data (new_client,6 ) != hyst - ||i2c_smbus_read_word_data (new_client,7 ) != hyst) -return -ENODEV ; - os =i2c_smbus_read_word_data (new_client,3 ); -if (i2c_smbus_read_word_data (new_client,4 ) != os - ||i2c_smbus_read_word_data (new_client,5 ) != os - ||i2c_smbus_read_word_data (new_client,6 ) != os - ||i2c_smbus_read_word_data (new_client,7 ) != os) -return -ENODEV ; + +/* First check for LM75A */ +if (i2c_smbus_read_byte_data (new_client,7 ) =LM75A_ID ) { +/* LM 75A returns 0xff on unused registers so +just to be sure we check for that too. */ +if (i2c_smbus_read_byte_data (new_client,4 ) !=0xff + ||i2c_smbus_read_byte_data (new_client,5 ) !=0xff + ||i2c_smbus_read_byte_data (new_client,6 ) !=0xff ) +return -ENODEV ; + is_lm75a =1 ; + hyst =i2c_smbus_read_word_data (new_client,2 ); + os =i2c_smbus_read_word_data (new_client,3 ); + }else {/* Traditional style LM75 detection */ +/* Unused addresses */ + hyst =i2c_smbus_read_word_data (new_client,2 ); +if (i2c_smbus_read_word_data (new_client,4 ) != hyst + ||i2c_smbus_read_word_data (new_client,5 ) != hyst + ||i2c_smbus_read_word_data (new_client,6 ) != hyst + ||i2c_smbus_read_word_data (new_client,7 ) != hyst) +return -ENODEV ; + os =i2c_smbus_read_word_data (new_client,3 ); +if (i2c_smbus_read_word_data (new_client,4 ) != os + ||i2c_smbus_read_word_data (new_client,5 ) != os + ||i2c_smbus_read_word_data (new_client,6 ) != os + ||i2c_smbus_read_word_data (new_client,7 ) != os) +return -ENODEV ; + }/* Unused bits */ if (conf &0xe0 )
@@ -278,9 +301,14 @@ static int lm75_detect(struct i2c_client *new_client, || i2c_smbus_read_word_data(new_client, i + 2) != hyst || i2c_smbus_read_word_data(new_client, i + 3) != os)return -ENODEV ; +if (is_lm75a &&i2c_smbus_read_byte_data (new_client, i +7 ) !=LM75A_ID ) +return -ENODEV ; } -strlcpy (info->type,"lm75" ,I2C_NAME_SIZE ); +if (is_lm75a) +strlcpy (info->type,"lm75a" ,I2C_NAME_SIZE ); +else +strlcpy (info->type,"lm75" ,I2C_NAME_SIZE );return 0 ; }
Signature · 6 lines
Len Sorensen _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 5 lines · Jean Delvare
This is generally true, so much that we did not bother including the vendor name in i2c device IDs (matching is done on the name string alone.) But apparently the LM75 is such a popular device that is has more clones than any other I2C device I know of, including, sadly, some with the exact same name, but not 100% compatible, from other vendors.
What a mess.
Quoted 7 lines
I beg to disagree. I would say that both detections are comparable. The LM75-specific behavior of "registers" (or lack thereof) 0x04-0x07, coupled with their cycling, is an almost unique characteristic (which is why we decided to use it for detection purpose.) If you ask me, I would say that a random chip at an LM75-compatible address is less likely to implement this characteristic than to have value
0xAas the high nibble of register0x07.
It isn't that unique, that's true. But combined with address cycling and the other checks?
Quoted 3 lines
It has been problematic, and was improved over time. You can see the first version of the detection code here:
http://www.lm-sensors.org/browser/lm-sensors/trunk/kernel/chips/lm75.c?rev38
Certainly a bit simpler than the current one.
Quoted 1 line
OK, fine with me.
Done in the new version.
Quoted 5 lines
Yes and no. 4 bits for the device ID is weak, especially when in a random register (which is why I insisted in using the whole 8 bits, including the revision.) "Good" devices have 8 bits of vendor ID + 8 bits of device ID at semi-standard addresses, and even this is not bullet proof.
Given they support 16 bit register on the LM75 already, I must admit I am amazed they didn't do an 8 bit ID and 8 bit revision using a 16bit register.
Signature · 6 lines
Len Sorensen _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 10 lines · Lennart Sorensen
Quoted 5 lines · Jean Delvare
Yes and no. 4 bits for the device ID is weak, especially when in a random register (which is why I insisted in using the whole 8 bits, including the revision.) "Good" devices have 8 bits of vendor ID + 8 bits of device ID at semi-standard addresses, and even this is not bullet proof.
Given they support 16 bit register on the LM75 already, I must admit I am amazed they didn't do an 8 bit ID and 8 bit revision using a 16bit register.
True. And they could have put an 8-bit manufacturer ID register at 0x06 too. But I guess it would have been too simple and straightforward and they preferred to have some fun with us :/
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 1 line
True. And they could have put an 8-bit manufacturer ID register at
0x06
Which the clones would have promptly imitated. Not the concept, mind you, they'd use the same _value_.
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 4 lines · On Wed, Feb 23, 2011 at 04:04:53PM -0600, [email protected] wrote:
Quoted 1 line
True. And they could have put an 8-bit manufacturer ID register at
0x06Which the clones would have promptly imitated. Not the concept, mind you, they'd use the same _value_.
At least detection would work then.
Signature · 6 lines
Len Sorensen _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 7 lines · Lennart Sorensen
Quoted 4 lines · On Wed, Feb 23, 2011 at 04:04:53PM -0600, [email protected] wrote:
Quoted 1 line
True. And they could have put an 8-bit manufacturer ID register at
0x06Which the clones would have promptly imitated. Â Not the concept, mind you, they'd use the same _value_.
At least detection would work then.
But the clones would assuredly use the other registers in incompatible ways. (assured by Murphy's Law)
Quoted 4 lines
--
Len Sorensen
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 95 lines · Lennart Sorensen
Quoted 1 line · Lennart Sorensen
I will do that. I hope to have an updated patch in a couple of hours.
OK, here is an updated one:
Add support for detection of LM75A using the ID register value.
Signed-off-by Len Sorensen <[email protected]>drivers/hwmon/lm75.c +39
-14@@ -232,6 +232,8 @@ static const struct i2c_device_id lm75_ids[] = { };MODULE_DEVICE_TABLE (i2c, lm75_ids); +#define LM75A_ID 0xA1 +/* Return 0 if detection is successful, -ENODEV otherwise */ static int lm75_detect (struct i2c_client *new_client,struct i2c_board_info *info)@@ -239,6 +241,7 @@ static int lm75_detect(struct i2c_client *new_client,struct i2c_adapter *adapter = new_client->adapter;int i;int cur, conf, hyst, os; +bool is_lm75a =0 ;if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA |I2C_FUNC_SMBUS_WORD_DATA ))@@ -250,23 +253,43 @@ static int lm75_detect(struct i2c_client *new_client,addresses 0x04-0x07 returning the last read value. The cycling+unused addresses combination is not tested, since it would significantly slow the detection down and would -hardly add any value. */ +hardly add any value. + +The National Semiconductor LM75A is different than earlier +LM75s. It has an ID byte of 0xaX (where X is the chip +revision, with 1 being the only revision in existance) in +register 7, and unused registers return 0xff rather than the +last read value. */ -/* Unused addresses */ cur =i2c_smbus_read_word_data (new_client,0 ); conf =i2c_smbus_read_byte_data (new_client,1 ); - hyst =i2c_smbus_read_word_data (new_client,2 ); -if (i2c_smbus_read_word_data (new_client,4 ) != hyst - ||i2c_smbus_read_word_data (new_client,5 ) != hyst - ||i2c_smbus_read_word_data (new_client,6 ) != hyst - ||i2c_smbus_read_word_data (new_client,7 ) != hyst) -return -ENODEV ; - os =i2c_smbus_read_word_data (new_client,3 ); -if (i2c_smbus_read_word_data (new_client,4 ) != os - ||i2c_smbus_read_word_data (new_client,5 ) != os - ||i2c_smbus_read_word_data (new_client,6 ) != os - ||i2c_smbus_read_word_data (new_client,7 ) != os) -return -ENODEV ; + +/* First check for LM75A */ +if (i2c_smbus_read_byte_data (new_client,7 ) =LM75A_ID ) { +/* LM 75A returns 0xff on unused registers so +just to be sure we check for that too. */ +if (i2c_smbus_read_byte_data (new_client,4 ) !=0xff + ||i2c_smbus_read_byte_data (new_client,5 ) !=0xff + ||i2c_smbus_read_byte_data (new_client,6 ) !=0xff ) +return -ENODEV ; + is_lm75a =1 ; + hyst =i2c_smbus_read_word_data (new_client,2 ); + os =i2c_smbus_read_word_data (new_client,3 ); + }else {/* Traditional style LM75 detection */ +/* Unused addresses */ + hyst =i2c_smbus_read_word_data (new_client,2 ); +if (i2c_smbus_read_word_data (new_client,4 ) != hyst + ||i2c_smbus_read_word_data (new_client,5 ) != hyst + ||i2c_smbus_read_word_data (new_client,6 ) != hyst + ||i2c_smbus_read_word_data (new_client,7 ) != hyst) +return -ENODEV ; + os =i2c_smbus_read_word_data (new_client,3 ); +if (i2c_smbus_read_word_data (new_client,4 ) != os + ||i2c_smbus_read_word_data (new_client,5 ) != os + ||i2c_smbus_read_word_data (new_client,6 ) != os + ||i2c_smbus_read_word_data (new_client,7 ) != os) +return -ENODEV ; + }/* Unused bits */ if (conf &0xe0 )@@ -278,9 +301,14 @@ static int lm75_detect(struct i2c_client *new_client, || i2c_smbus_read_word_data(new_client, i + 2) != hyst || i2c_smbus_read_word_data(new_client, i + 3) != os)return -ENODEV ; +if (is_lm75a &&i2c_smbus_read_byte_data (new_client, i +7 ) !=LM75A_ID ) +return -ENODEV ;
drivers/hwmon/lm75.c static int lm75_detect(struct i2c_client *new_client, · line 314
Quoted 10 lines
drivers/hwmon/lm75.c +4
-1} -strlcpy (info->type,"lm75" ,I2C_NAME_SIZE ); +if (is_lm75a) +strlcpy (info->type,"lm75a" ,I2C_NAME_SIZE ); +else +strlcpy (info->type,"lm75" ,I2C_NAME_SIZE );return 0 ; }
Applied with minor style fixes, thank you.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 103 lines · Jean Delvare
Quoted 102 lines · Lennart Sorensen
Quoted 1 line · Lennart Sorensen
I will do that. I hope to have an updated patch in a couple of hours.
OK, here is an updated one:
Add support for detection of LM75A using the ID register value.
Signed-off-by Len Sorensen <[email protected]>drivers/hwmon/lm75.c +43
-15@@ -232,6 +232,8 @@ static const struct i2c_device_id lm75_ids[] = { };MODULE_DEVICE_TABLE (i2c, lm75_ids); +#define LM75A_ID 0xA1 +/* Return 0 if detection is successful, -ENODEV otherwise */ static int lm75_detect (struct i2c_client *new_client,struct i2c_board_info *info)@@ -239,6 +241,7 @@ static int lm75_detect(struct i2c_client *new_client,struct i2c_adapter *adapter = new_client->adapter;int i;int cur, conf, hyst, os; +bool is_lm75a =0 ;if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA |I2C_FUNC_SMBUS_WORD_DATA ))@@ -250,23 +253,43 @@ static int lm75_detect(struct i2c_client *new_client,addresses 0x04-0x07 returning the last read value. The cycling+unused addresses combination is not tested, since it would significantly slow the detection down and would -hardly add any value. */ +hardly add any value. + +The National Semiconductor LM75A is different than earlier +LM75s. It has an ID byte of 0xaX (where X is the chip +revision, with 1 being the only revision in existance) in +register 7, and unused registers return 0xff rather than the +last read value. */ -/* Unused addresses */ cur =i2c_smbus_read_word_data (new_client,0 ); conf =i2c_smbus_read_byte_data (new_client,1 ); - hyst =i2c_smbus_read_word_data (new_client,2 ); -if (i2c_smbus_read_word_data (new_client,4 ) != hyst - ||i2c_smbus_read_word_data (new_client,5 ) != hyst - ||i2c_smbus_read_word_data (new_client,6 ) != hyst - ||i2c_smbus_read_word_data (new_client,7 ) != hyst) -return -ENODEV ; - os =i2c_smbus_read_word_data (new_client,3 ); -if (i2c_smbus_read_word_data (new_client,4 ) != os - ||i2c_smbus_read_word_data (new_client,5 ) != os - ||i2c_smbus_read_word_data (new_client,6 ) != os - ||i2c_smbus_read_word_data (new_client,7 ) != os) -return -ENODEV ; + +/* First check for LM75A */ +if (i2c_smbus_read_byte_data (new_client,7 ) =LM75A_ID ) { +/* LM 75A returns 0xff on unused registers so +just to be sure we check for that too. */ +if (i2c_smbus_read_byte_data (new_client,4 ) !=0xff + ||i2c_smbus_read_byte_data (new_client,5 ) !=0xff + ||i2c_smbus_read_byte_data (new_client,6 ) !=0xff ) +return -ENODEV ; + is_lm75a =1 ; + hyst =i2c_smbus_read_word_data (new_client,2 ); + os =i2c_smbus_read_word_data (new_client,3 ); + }else {/* Traditional style LM75 detection */ +/* Unused addresses */ + hyst =i2c_smbus_read_word_data (new_client,2 ); +if (i2c_smbus_read_word_data (new_client,4 ) != hyst + ||i2c_smbus_read_word_data (new_client,5 ) != hyst + ||i2c_smbus_read_word_data (new_client,6 ) != hyst + ||i2c_smbus_read_word_data (new_client,7 ) != hyst) +return -ENODEV ; + os =i2c_smbus_read_word_data (new_client,3 ); +if (i2c_smbus_read_word_data (new_client,4 ) != os + ||i2c_smbus_read_word_data (new_client,5 ) != os + ||i2c_smbus_read_word_data (new_client,6 ) != os + ||i2c_smbus_read_word_data (new_client,7 ) != os) +return -ENODEV ; + }/* Unused bits */ if (conf &0xe0 )@@ -278,9 +301,14 @@ static int lm75_detect(struct i2c_client *new_client, || i2c_smbus_read_word_data(new_client, i + 2) != hyst || i2c_smbus_read_word_data(new_client, i + 3) != os)return -ENODEV ; +if (is_lm75a &&i2c_smbus_read_byte_data (new_client, i +7 ) !=LM75A_ID ) +return -ENODEV ; } -strlcpy (info->type,"lm75" ,I2C_NAME_SIZE ); +if (is_lm75a) +strlcpy (info->type,"lm75a" ,I2C_NAME_SIZE ); +else +strlcpy (info->type,"lm75" ,I2C_NAME_SIZE );
Quoted 5 lines
drivers/hwmon/lm75.c static int lm75_detect(struct i2c_client *new_client, · line 314
Quoted 3 lines
drivers/hwmon/lm75.c +0
-0return 0 ; }Applied with minor style fixes, thank you.
I will have to go see what that entails. I thought I had done a decent job following the existing style. :)
Signature · 6 lines
Len Sorensen _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 5 lines · Lennart Sorensen
Quoted 1 line · Jean Delvare
Applied with minor style fixes, thank you.
I will have to go see what that entails. I thought I had done a decent job following the existing style. :)
See for yourself:
ftp://ftp.kernel.org/pub/linux/kernel/people/jdelvare/linux-2.6/jdelvare-hwmon/hwmon-lm75-01-add-support-for-lm75a.patch
You did a nice job, but I'm a nitpicker ;)
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 5 lines · Jean Delvare
See for yourself:
ftp://ftp.kernel.org/pub/linux/kernel/people/jdelvare/linux-2.6/jdelvare-hwmon/hwmon-lm75-01-add-support-for-lm75a.patch
You did a nice job, but I'm a nitpicker ;)
I see the changes, and I do like the improvements.
Signature · 6 lines
Len Sorensen _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors