All of lore.kernel.org
 help / color / mirror / Atom feed
* lm77 on national sc1100
@ 2005-05-19  6:25 Andras BALI
  2005-05-19  6:25 ` Andras BALI
                   ` (30 more replies)
  0 siblings, 31 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Hi all,

referencing to #1710 and #1714, I figured out that the LM77
sensor is not compatible with the LM75, though it's similar.

Attached is a driver for the LM77 that works for me. It gives
read access to the temperature register (temp1_input) and
read+write access to t_hyst, t_crit, t_high, t_low. The config
register is not made available, nor are the status bits, but
it should be really easy to add these if required. The code is
a shameless copy of the lm75 module -- all credits go to Frodo
Looijaard.

The detection is a bit problematic: the lm77 module should not
install itself for anything else but an lm77, but the lm75
driver will recognize an lm77 as an lm75. It could be patched to
check if the chip in question is an lm77 (and skip it if yes),
but I'm not sure if it's appropriate. Ideas are welcome.

I have this LM77 sensor on the secondary I2C bus of a National
SC1100 system. The bus is driven by the scx200_acb (stock kernel
2.6.7) module, which I had to patch in order to get it work: on
line 461, the following should be added:
	
	adapter->class = I2C_CLASS_HWMON;

-- otherwise the sensors will not try to detect devices on this
bus (thanks Khali). I also had to change the ACCESS.bus base
addresses from 0x820, 0x840 to 0x810, 0x820 (line 46), but YMMV.

I would be really glad to see this module included in the
lm_sensors package.

Please CC me all replies to this message, I'm not subscribed to
this mailing list.

Best regards,
Andras

-------------- next part --------------
A non-text attachment was scrubbed...
Name: lm77.c
Type: text/x-csrc
Size: 9583 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040701/957be51a/lm77.bin

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (13 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Jean Delvare
                   ` (15 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors


>referencing to #1710 and #1714, I figured out that the LM77
>sensor is not compatible with the LM75, though it's similar.

Interesting. Our docs say that both chips are compatible (although the
LM77 has additional features).

I don't have the datasheets handy. Can you describe what makes them
incompatible?

>Attached is a driver for the LM77 that works for me. It gives
>read access to the temperature register (temp1_input) and
>read+write access to t_hyst, t_crit, t_high, t_low. The config
>register is not made available, nor are the status bits, but
>it should be really easy to add these if required. The code is
>a shameless copy of the lm75 module -- all credits go to Frodo
>Looijaard.
>
>The detection is a bit problematic: the lm77 module should not
>install itself for anything else but an lm77, but the lm75
>driver will recognize an lm77 as an lm75. It could be patched to
>check if the chip in question is an lm77 (and skip it if yes),
>but I'm not sure if it's appropriate. Ideas are welcome.

We usually do not include detection for other chipsets in a driver for
exclusion purposes, but if its needed, we may consider it.

Another approach (which I like better) would be to add support for the
LM77 to the lm75 driver. We know that both chips share a number of
attributes, although they do not seem to be compatible.

In both cases, we would need a way to differenciate between an LM75 and
an LM77. I am not sure we know how to do that (which is why our
sensors-detect script doesn't know about the LM77). Do you have a
proposal? Even a heuristic would be acceptable, since there aren't that
much LM77 out there, so just defaulting to LM75 unless specific
conditions are met sounds acceptable.

>I have this LM77 sensor on the secondary I2C bus of a National
>SC1100 system. The bus is driven by the scx200_acb (stock kernel
>2.6.7) module, which I had to patch in order to get it work: on
>line 461, the following should be added:
>
>	adapter->class = I2C_CLASS_HWMON;
>
>-- otherwise the sensors will not try to detect devices on this
>bus (thanks Khali). I also had to change the ACCESS.bus base
>addresses from 0x820, 0x840 to 0x810, 0x820 (line 46), but YMMV.

I will send a patch to Greg KH for the class issue. I don't know
anything about the base address though, so I won't do anything about
that.

>I would be really glad to see this module included in the
>lm_sensors package.

Well, linux 2.6 drivers don't belong to lm_sensors anyway. But we can
get it into the kernel tree (either as a new driver or as a modification
of the lm75 driver). What belong to lm_sensors are 2,4 drivers and
user-space tools support. Not sure you are interested in userspace since
you're on an embedded system?

Thanks,
Jean "Khali" Delvare

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
@ 2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Mark M. Hoffman
                   ` (29 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Thu, 2004-07-01 at 16:48, Jean Delvare wrote:

> >referencing to #1710 and #1714, I figured out that the LM77
> >sensor is not compatible with the LM75, though it's similar.

> Interesting. Our docs say that both chips are compatible (although the
> LM77 has additional features).

> I don't have the datasheets handy. Can you describe what makes them
> incompatible?

Datasheets are at http://www.national.com/ds/LM/LM75.pdf and 
http://www.national.com/ds/LM/LM77.pdf. The main difference (what makes
the lm75 driver incompatible) is the way the temperature is stored in
the temperature register. The register is a word on both chips, but
whereas lm75 stores the temperature from d14 to d8, lm77 does this from
d10 to d3:

      d15 d14 d13 d12 d11 d10 d9 d8   d7  d6 d5 d4 d3 d2 d1 d0
lm75  msb b7  b6  b5  b4  b3  b2 b1   lsb x  x  x  x  x  x  x
lm77  sgn sgn sgn sgn msb b7  b6 b5   b4  b3 b2 b1 b0 x  x  x

where b1 is bit1, x is unused/used for other purposes. Say, for
example, that the register contains 0x0005, which has to be
swapped, that is 0x0500 (that is the default value for T_crit).
The lm75 driver converts it to temperature with the following
pattern: (reg / 128) * 500. That would be 5000, 5 degrees. Quite
cool for a maximum. :-) The correct method would be to divide it
only by 8, since we have to drop the last 3 bits, not the last 7.
That makes 80000, 80 degrees, which makes sense at last.

> We usually do not include detection for other chipsets in a driver for
> exclusion purposes, but if its needed, we may consider it.

> Another approach (which I like better) would be to add support for the
> LM77 to the lm75 driver. We know that both chips share a number of
> attributes, although they do not seem to be compatible.

That's right, they're quite identical apart from what is mentioned
above (and that differentation can be easily implemented). The LM77
has support for a T_high and T_low, but I'm not sure if anyone would
need that. I separated the source because I thought that it might be
unappropriate to handle two different (though similar, but incompatible)
chips in the same driver.

> In both cases, we would need a way to differenciate between an LM75 and
> an LM77. I am not sure we know how to do that (which is why our
> sensors-detect script doesn't know about the LM77). Do you have a
> proposal? Even a heuristic would be acceptable, since there aren't that
> much LM77 out there, so just defaulting to LM75 unless specific
> conditions are met sounds acceptable.

Maybe we could check for the existence T_high and T_low registers?

> >I have this LM77 sensor on the secondary I2C bus of a National
> >SC1100 system. The bus is driven by the scx200_acb (stock kernel
> >2.6.7) module, which I had to patch in order to get it work:
[...]
> I will send a patch to Greg KH for the class issue. I don't know
> anything about the base address though, so I won't do anything about
> that.

That base address seems to differ on boards from different vendors. The
possible base addresses I have seen are 0x810, 0x820 and 0x840. It is
also possible to try all three addresses by default, but that would mean
that there will always be an error message, as one address would always
fail.

> Well, linux 2.6 drivers don't belong to lm_sensors anyway. But we can
> get it into the kernel tree (either as a new driver or as a modification
> of the lm75 driver). What belong to lm_sensors are 2,4 drivers and
> user-space tools support. Not sure you are interested in userspace since
> you're on an embedded system?

That's right, I'm not interested in user-space tools and can live
without having it in the stock kernel if it turns out that noone needs
it. However these embedded boards seem to be pretty popular nowadays
(see eg. http://www.pcengines.ch for a vendor) and they have quite
complete support in the kernel apart from this one little thing...

Thanks,
Andras

[ Please CC me all followups. ]


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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (8 preceding siblings ...)
  2005-05-19  6:25 ` Andras BALI
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Andras BALI
                   ` (20 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors


>The register is a word on both chips, but
>whereas lm75 stores the temperature from d14 to d8, lm77 does this from
>d10 to d3:
>
>      d15 d14 d13 d12 d11 d10 d9 d8   d7  d6 d5 d4 d3 d2 d1 d0
>lm75  msb b7  b6  b5  b4  b3  b2 b1   lsb x  x  x  x  x  x  x
>lm77  sgn sgn sgn sgn msb b7  b6 b5   b4  b3 b2 b1 b0 x  x  x
>
>where b1 is bit1, x is unused/used for other purposes.

OK, that explains your strange values.

BTW, d15 on lm75 is sign as well. And what's the point in lm77's having
4 bit for sign? If that means that all 4 bits will always be the same,
that's something we can use for identification.

>The LM77
>has support for a T_high and T_low, but I'm not sure if anyone would
>need that.

Well, why not. We have other chips doing this, it perfectly fits in our
interface.

>Maybe we could check for the existence T_high and T_low registers?

We cannot. LM75 chips will not answer with an error if you try to read
these registers. It will return a value, just that this value isn't
relevant. I cannot remember exactly what it returns... Possible the
value of register 0x03.

What we may use OTOH are:
* unused bits in config register if they differ;
* unused bits in temperature registers; they differ, and it should be
sufficent since it's VERY unlikely that ALL 4 low bits of all
temperature values are 0 on a LM77 (while the same bits will read 0 on a
LM75). That should be a good thing to start with;
* try to learn what the LM75 would return for T_high and T_low;

Do we have a dump of a LM75 chip? I think I remember Mark Hoffman has
access to such a chip. Hopefully, LM75 compatible chips such as the DS75
and DS1775 will behave likewise.

>That's right, I'm not interested in user-space tools and can live
>without having it in the stock kernel if it turns out that noone needs
>it. However these embedded boards seem to be pretty popular nowadays
>(see eg. http://www.pcengines.ch for a vendor) and they have quite
>complete support in the kernel apart from this one little thing...

Apart from the fact that you are not interested, will you have the
possibility to test things like sensors-detect (perl script) or i2cdump
on the box?

Thanks,
Jean Delvare

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (9 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Mark M. Hoffman
                   ` (19 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Thu, 2004-07-01 at 17:45, Jean Delvare wrote:

> BTW, d15 on lm75 is sign as well. And what's the point in lm77's having
> 4 bit for sign? If that means that all 4 bits will always be the same,
> that's something we can use for identification.

The high 4 bits can easily be the same for the LM75, too...

> >Maybe we could check for the existence T_high and T_low registers?

> We cannot. LM75 chips will not answer with an error if you try to read
> these registers. It will return a value, just that this value isn't
> relevant. I cannot remember exactly what it returns... Possible the
> value of register 0x03.

I see. Maybe writing could tell us more (write then read back and
compare) but that can be dangerous obviously.

> What we may use OTOH are:
> * unused bits in config register if they differ;

The config register is 0x0 at me by default. Don't know anything about
the LM75 though.

> * unused bits in temperature registers; they differ, and it should be
> sufficent since it's VERY unlikely that ALL 4 low bits of all
> temperature values are 0 on a LM77 (while the same bits will read 0 on a
> LM75). That should be a good thing to start with;

I'm not sure if it's really that unlikely. Some examples: 8, 16, 24,
32 (!), 40 degrees... 

> Apart from the fact that you are not interested, will you have the
> possibility to test things like sensors-detect (perl script) or i2cdump
> on the box?

Yeah, I'd be glad to help.

Thanks,
Andras


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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
  2005-05-19  6:25 ` Andras BALI
@ 2005-05-19  6:25 ` Mark M. Hoffman
  2005-05-19  6:25 ` Jean Delvare
                   ` (28 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Mark M. Hoffman @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

* Jean Delvare <khali@linux-fr.org> [2004-07-01 17:45:29 +0200]:
> Do we have a dump of a LM75 chip? I think I remember Mark Hoffman has
> access to such a chip. Hopefully, LM75 compatible chips such as the DS75
> and DS1775 will behave likewise.

Two of them, actually.  Though they look suspiciously like subclients,
they're not.  I have confirmed by visual inspection that this board
has one LM79 and two LM75s.  Here they are:

[root@earth root]# i2cdump 0 0x4c
No size specified (using byte-data access)
  WARNING! This program can confuse your I2C bus, cause data loss and worse!
  I will probe file /dev/i2c-0, address 0x4c, mode byte
  You have five seconds to reconsider and press CTRL-C!
 
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
10: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
20: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
30: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
40: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
50: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
60: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
70: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
80: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
90: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
a0: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
b0: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
c0: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
d0: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
e0: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
f0: 1c 00 32 3c 3c 3c 3c 3c 1c 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<

[root@earth root]# i2cdump 0 0x4d
No size specified (using byte-data access)
  WARNING! This program can confuse your I2C bus, cause data loss and worse!
  I will probe file /dev/i2c-0, address 0x4d, mode byte
  You have five seconds to reconsider and press CTRL-C!
 
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
10: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
20: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
30: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
40: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
50: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
60: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
70: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
80: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
90: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
a0: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
b0: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
c0: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
d0: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
e0: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<
f0: 1e 00 32 3c 3c 3c 3c 3c 1e 00 32 3c 3c 3c 3c 3c    ?.2<<<<<?.2<<<<<

Regards,

-- 
Mark M. Hoffman
mhoffman@lightlink.com

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
  2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Mark M. Hoffman
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Mark M. Hoffman
                   ` (27 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> has one LM79 and two LM75s.  Here they are:
> 
> [root@earth root]# i2cdump 0 0x4c

Care to dump in word mode? Most registers are 16-bit on this chip.

Thanks.

-- 
Jean Delvare
http://khali.linux-fr.org/

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (4 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Mark M. Hoffman
  2005-05-19  6:25 ` Jean Delvare
                   ` (24 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Mark M. Hoffman @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Hi:

* Jean Delvare <khali@linux-fr.org> [2004-07-01 20:05:51 +0200]:
> Care to dump in word mode? Most registers are 16-bit on this chip.

Sure...

[root@earth root]# i2cdump 0 0x4c w
  WARNING! This program can confuse your I2C bus, cause data loss and worse!
  I will probe file /dev/i2c-0, address 0x4c, mode word
  You have five seconds to reconsider and press CTRL-C!
                                                                                                                                            
     0,8  1,9  2,a  3,b  4,c  5,d  6,e  7,f
00: 801b 8000 0032 003c 003c 003c 003c 003c
08: 801b 8000 0032 003c 003c 003c 003c 003c
10: 801b 8000 0032 003c 003c 003c 003c 003c
18: 801b 8000 0032 003c 003c 003c 003c 003c
20: 801b 8000 0032 003c 003c 003c 003c 003c
28: 801b 8000 0032 003c 003c 003c 003c 003c
30: 801b 8000 0032 003c 003c 003c 003c 003c
38: 801b 8000 0032 003c 003c 003c 003c 003c
40: 801b 8000 0032 003c 003c 003c 003c 003c
48: 801b 8000 0032 003c 003c 003c 003c 003c
50: 801b 8000 0032 003c 003c 003c 003c 003c
58: 801b 8000 0032 003c 003c 003c 003c 003c
60: 801b 8000 0032 003c 003c 003c 003c 003c
68: 801b 8000 0032 003c 003c 003c 003c 003c
70: 801b 8000 0032 003c 003c 003c 003c 003c
78: 801b 8000 0032 003c 003c 003c 003c 003c
80: 801b 8000 0032 003c 003c 003c 003c 003c
88: 801b 8000 0032 003c 003c 003c 003c 003c
90: 801b 8000 0032 003c 003c 003c 003c 003c
98: 801b 8000 0032 003c 003c 003c 003c 003c
a0: 801b 8000 0032 003c 003c 003c 003c 003c
a8: 801b 8000 0032 003c 003c 003c 003c 003c
b0: 801b 8000 0032 003c 003c 003c 003c 003c
b8: 801b 8000 0032 003c 003c 003c 003c 003c
c0: 801b 8000 0032 003c 003c 003c 003c 003c
c8: 801b 8000 0032 003c 003c 003c 003c 003c
d0: 801b 8000 0032 003c 003c 003c 003c 003c
d8: 801b 8000 0032 003c 003c 003c 003c 003c
e0: 801b 8000 0032 003c 003c 003c 003c 003c
e8: 801b 8000 0032 003c 003c 003c 003c 003c
f0: 801b 8000 0032 003c 003c 003c 003c 003c
f8: 801b 8000 0032 003c 003c 003c 003c 003c

[root@earth root]# i2cdump 0 0x4d w
  WARNING! This program can confuse your I2C bus, cause data loss and worse!
  I will probe file /dev/i2c-0, address 0x4d, mode word
  You have five seconds to reconsider and press CTRL-C!
 
     0,8  1,9  2,a  3,b  4,c  5,d  6,e  7,f
00: 801d 8000 0032 003c 003c 003c 003c 003c
08: 801d 8000 0032 003c 003c 003c 003c 003c
10: 801d 8000 0032 003c 003c 003c 003c 003c
18: 801d 8000 0032 003c 003c 003c 003c 003c
20: 801d 8000 0032 003c 003c 003c 003c 003c
28: 801d 8000 0032 003c 003c 003c 003c 003c
30: 801d 8000 0032 003c 003c 003c 003c 003c
38: 801d 8000 0032 003c 003c 003c 003c 003c
40: 801d 8000 0032 003c 003c 003c 003c 003c
48: 801d 8000 0032 003c 003c 003c 003c 003c
50: 801d 8000 0032 003c 003c 003c 003c 003c
58: 801d 8000 0032 003c 003c 003c 003c 003c
60: 801d 8000 0032 003c 003c 003c 003c 003c
68: 801d 8000 0032 003c 003c 003c 003c 003c
70: 801d 8000 0032 003c 003c 003c 003c 003c
78: 801d 8000 0032 003c 003c 003c 003c 003c
80: 801d 8000 0032 003c 003c 003c 003c 003c
88: 801d 8000 0032 003c 003c 003c 003c 003c
90: 801d 8000 0032 003c 003c 003c 003c 003c
98: 801d 8000 0032 003c 003c 003c 003c 003c
a0: 801d 8000 0032 003c 003c 003c 003c 003c
a8: 801d 8000 0032 003c 003c 003c 003c 003c
b0: 801d 8000 0032 003c 003c 003c 003c 003c
b8: 801d 8000 0032 003c 003c 003c 003c 003c
c0: 801d 8000 0032 003c 003c 003c 003c 003c
c8: 801d 8000 0032 003c 003c 003c 003c 003c
d0: 801d 8000 0032 003c 003c 003c 003c 003c
d8: 801d 8000 0032 003c 003c 003c 003c 003c
e0: 801d 8000 0032 003c 003c 003c 003c 003c
e8: 801d 8000 0032 003c 003c 003c 003c 003c
f0: 801d 8000 0032 003c 003c 003c 003c 003c
f8: 801d 8000 0032 003c 003c 003c 003c 003c

Regards,

-- 
Mark M. Hoffman
mhoffman@lightlink.com

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (12 preceding siblings ...)
  2005-05-19  6:25 ` Andras BALI
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Jean Delvare
                   ` (16 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

OK, I added support for the LM77 to sensors-detect and refined the LM75
detection.

Mark, please test and confirm that your LM75s are still detected as
such (with confidence at least 4).

Andras, please test and confirm that your LM77 is correctly detected as
a LM77 (with confidence at least 3).

If it works OK, we will have to do similar changes to the lm75 driver.

I'm still not sure whether we want to do a separate lm77 driver or not.
The two chips are definitely not compatible but handling both in a
single driver gives more control over detection.

Thanks.

-- 
Jean Delvare
http://khali.linux-fr.org/

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (11 preceding siblings ...)
  2005-05-19  6:25 ` Mark M. Hoffman
@ 2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Jean Delvare
                   ` (17 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Thu, 2004-07-01 at 23:19, Jean Delvare wrote:

> Andras, please test and confirm that your LM77 is correctly detected as
> a LM77 (with confidence at least 3).

$ sensors-detect
[...]
Next adapter: SCx200 ACB1
Do you want to scan it? (YES/no/selectively):
Client found at address 0x48
Probing for `National Semiconductor LM75'... Failed!
Probing for `National Semiconductor LM77'... Success!
    (confidence 3, driver `lm75')
Probing for `Dallas Semiconductor DS1621'... Failed!
Probing for `Maxim MAX6650/MAX6651'... Failed!
Probing for `National Semiconductor LM92'... Failed!
Probing for `National Semiconductor LM76'... Success!
    (confidence 2, driver `lm92')
Probing for `Maxim MAX6633/MAX6634/MAX6635'... Failed!
[...]
Driver `lm75' (should be inserted):
  Detects correctly:
  * Bus `SCx200 ACB1' (Algorithm unavailable)
    Busdriver `UNKNOWN', I2C address 0x48
    Chip `National Semiconductor LM77' (confidence: 3)

Driver `lm92' (may not be inserted):
  Misdetects:
  * Bus `SCx200 ACB1' (Algorithm unavailable)
    Busdriver `UNKNOWN', I2C address 0x48
    Chip `National Semiconductor LM76' (confidence: 2)

Just as a thought: if the kernel is compiled w/o modules,
/proc/modules does not exist, so initialize_modules_list()
will fail. Maybe it should just silently return if the
file does not exist...

Thanks,
Andras


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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (2 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Mark M. Hoffman
  2005-05-19  6:25 ` Jean Delvare
                   ` (26 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Mark M. Hoffman @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Hi Jean:

* Jean Delvare <khali@linux-fr.org> [2004-07-01 23:19:29 +0200]:
> OK, I added support for the LM77 to sensors-detect and refined the LM75
> detection.
> 
> Mark, please test and confirm that your LM75s are still detected as
> such (with confidence at least 4).

Exactly 4 for both.  BTW it also claimed this, which is probably expected...

Chip `Maxim MAX6633/MAX6634/MAX6635' (confidence: 2)

> Andras, please test and confirm that your LM77 is correctly detected as
> a LM77 (with confidence at least 3).
> 
> If it works OK, we will have to do similar changes to the lm75 driver.
> 
> I'm still not sure whether we want to do a separate lm77 driver or not.
> The two chips are definitely not compatible but handling both in a
> single driver gives more control over detection.

Regards,

-- 
Mark M. Hoffman
mhoffman@lightlink.com

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (3 preceding siblings ...)
  2005-05-19  6:25 ` Mark M. Hoffman
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Mark M. Hoffman
                   ` (25 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors


>$ sensors-detect
>[...]
>Next adapter: SCx200 ACB1
>Do you want to scan it? (YES/no/selectively):
>Client found at address 0x48
>Probing for `National Semiconductor LM75'... Failed!
>Probing for `National Semiconductor LM77'... Success!
>    (confidence 3, driver `lm75')
>Probing for `Dallas Semiconductor DS1621'... Failed!
>Probing for `Maxim MAX6650/MAX6651'... Failed!
>Probing for `National Semiconductor LM92'... Failed!
>Probing for `National Semiconductor LM76'... Success!
>    (confidence 2, driver `lm92')
>Probing for `Maxim MAX6633/MAX6634/MAX6635'... Failed!
>[...]
>Driver `lm75' (should be inserted):
>  Detects correctly:
>  * Bus `SCx200 ACB1' (Algorithm unavailable)
>    Busdriver `UNKNOWN', I2C address 0x48
>    Chip `National Semiconductor LM77' (confidence: 3)
>
>Driver `lm92' (may not be inserted):
>  Misdetects:
>  * Bus `SCx200 ACB1' (Algorithm unavailable)
>    Busdriver `UNKNOWN', I2C address 0x48
>    Chip `National Semiconductor LM76' (confidence: 2)

OK, it works :) I'll see if I can improve it enough to grant a
confidence of 4 to the LM77. After all, the detection of the LM75 and
LM77 are being quite reliable now (at a price of an awful complexity,
admittedly). OTOH, the LM76 family isn't and I'm not sure that we will
be able to do much better.

Andras, could you please provide a dump of your chip?
i2cdump 1 0x48 w
i2cdump 1 0x48

Mark, could you temporarily hack your local copy of sensors-detect so as
to pretend that the LM77 can live at 0x4c-0x4f? Then give it a try. I
want to check that your LM75s will not be misdetected as LM77s.

I wonder if unused addresses (0x4-0x7 on LM75, 0x6-0x7 on LM77) will
always return the value of the last existing register (0x3 and 0x05,
respectively), or those of the previously read register. It doesn't
matter much because we read them in order almost all the time, but I'm
curious. And in the latter case (which I consider the most probable) it
would be a powerful mean of identification. Could either of you do some
testing in that direction (by hacking either of sensors-detect, i2cdump
or the lm75 or lm77 drivers).

>Just as a thought: if the kernel is compiled w/o modules,
>/proc/modules does not exist, so initialize_modules_list()
>will fail. Maybe it should just silently return if the
>file does not exist...

Ah, you are using a monolithic kernel? This is interesting. We are almost
never doing, and had several complaints about it not working properly
(but that was long time ago). How is it going for you?

Yes, you're right, we should keep silent if /proc/modules does not
exist. Care to provide a patch that does that? We may even remember and
never propose the user to try and load a module after that.

I think that your choice of having a separate driver for the lm77 is
correct. Both chips are definitely not compatible and there's no point
in having a single driver if there's no code nor logic we can share.

Thanks,
Jean Delvare

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (6 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Andras BALI
                   ` (22 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Fri, 2004-07-02 at 10:09, Jean Delvare wrote:

> Andras, could you please provide a dump of your chip?
> i2cdump 1 0x48 w

# i2cdump 1 0x48 w
  WARNING! This program can confuse your I2C bus, cause data loss and
worse!
  I will probe file /dev/i2c-1, address 0x48, mode word
  You have five seconds to reconsider and press CTRL-C!

     0,8  1,9  2,a  3,b  4,c  5,d  6,e  7,f
00: 0802 8800 2000 0005 a000 0004 0004 0004
08: 0802 8800 2000 0005 a000 0004 0004 0004
10: 0802 8800 2000 0005 a000 0004 0004 0004
18: 0802 8800 2000 0005 a000 0004 0004 0004
20: 0802 8800 2000 0005 a000 0004 0004 0004
28: 0802 8800 2000 0005 a000 0004 0004 0004
30: 0802 8800 2000 0005 a000 0004 0004 0004
38: 0802 8800 2000 0005 a000 0004 0004 0004
40: 0802 8800 2000 0005 a000 0004 0004 0004
48: 0802 8800 2000 0005 a000 0004 0004 0004
50: 0802 8800 2000 0005 a000 0004 0004 0004
58: 0802 8800 2000 0005 a000 0004 0004 0004
60: 0802 8800 2000 0005 a000 0004 0004 0004
68: 0802 8800 2000 0005 a000 0004 0004 0004
70: 0802 8800 2000 0005 a000 0004 0004 0004
78: 0802 8800 2000 0005 a000 0004 0004 0004
80: 0802 8800 2000 0005 a000 0004 0004 0004
88: 0802 8800 2000 0005 a000 0004 0004 0004
90: 0802 8800 2000 0005 a000 0004 0004 0004
98: 0802 8800 2000 0005 a000 0004 0004 0004
a0: 0802 8800 2000 0005 a000 0004 0004 0004
a8: 0802 8800 2000 0005 a000 0004 0004 0004
b0: 0802 8800 2000 0005 a000 0004 0004 0004
b8: 0802 8800 2000 0005 a000 0004 0004 0004
c0: 0802 8800 2000 0005 a000 0004 0004 0004
c8: 0802 8800 2000 0005 a000 0004 0004 0004
d0: 0802 8800 2000 0005 a000 0004 0004 0004
d8: 0802 8800 2000 0005 a000 0004 0004 0004
e0: 0802 8800 2000 0005 a000 0004 0004 0004
e8: 0802 8800 2000 0005 a000 0004 0004 0004
f0: 0802 8800 2000 0005 a000 0004 0004 0004
f8: 0802 8800 2000 0005 a000 0004 0004 0004

While dumping, I got this in the logs:

i2c_adapter i2c-1: bus error in state address
i2c_adapter i2c-1: not master in state address

> i2cdump 1 0x48

# i2cdump 1 0x48
No size specified (using byte-data access)
  WARNING! This program can confuse your I2C bus, cause data loss and
worse!
  I will probe file /dev/i2c-1, address 0x48, mode byte
  You have five seconds to reconsider and press CTRL-C!

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 02 XX 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    ?X.X.?X?X..X.?X?
10: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
20: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
30: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
40: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
50: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
60: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
70: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
80: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
90: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
a0: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
b0: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
c0: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
d0: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
e0: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?
f0: XX 00 00 XX 00 04 XX 04 XX 00 00 XX 00 04 XX 04    X..X.?X?X..X.?X?

While dumping, I got a lot of these in the logs:

i2c_adapter i2c-1: bus error in state address

> I wonder if unused addresses (0x4-0x7 on LM75, 0x6-0x7 on LM77) will
> always return the value of the last existing register (0x3 and 0x05,
> respectively), or those of the previously read register.

It's the previously read register on the LM77.

# ./i2clm77
reading from LM77 at 0x48 on /dev/i2c-1

T=         32.50
T_hyst=    2.00
T_6=       2.00
T_7=       2.00
T_crit=    80.00
T_low=     10.00
T_6=       10.00
T_7=       10.00
T_high=    64.00
T_6=       64.00
T_7=       64.00

status=    0x0 crit/high/low
config=    0x0

> Ah, you are using a monolithic kernel? This is interesting. We are almost
> never doing, and had several complaints about it not working properly
> (but that was long time ago). How is it going for you?

I'm using a monolithic kernel because I don't want modules on this
embedded system. It's working fine (as you can see), apart from the
minor inconvenience that I have to recompile it hundred times a day :-)

> Yes, you're right, we should keep silent if /proc/modules does not
> exist. Care to provide a patch that does that? We may even remember and
> never propose the user to try and load a module after that.

--- sensors-detect.old  2004-07-01 23:23:09.000000000 +0200
+++ sensors-detect      2004-07-02 10:34:29.000000000 +0200
@@ -1844,7 +1844,7 @@

 sub initialize_modules_list
 {
-  open INPUTFILE, "/proc/modules" or die "Can't access /proc/modules!";
+  open INPUTFILE, "/proc/modules" or return;
   while (<INPUTFILE>) {
     tr/_/-/;
     $modules_list{$1} = 1 if m/^(\S*)/;

The rest is so much based on the modules that I see no point in
rewriting the whole for those few of us who use a monolithic kernel.
And it's working fine, anyway.

Thanks,
Andras


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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (5 preceding siblings ...)
  2005-05-19  6:25 ` Mark M. Hoffman
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Andras BALI
                   ` (23 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> > I wonder if unused addresses (0x4-0x7 on LM75, 0x6-0x7 on LM77) will
> > always return the value of the last existing register (0x3 and 0x05,
> > respectively), or those of the previously read register.
> 
> It's the previously read register on the LM77.

OK, I reworked both the LM75 and the LM77 detection routines to take
benefit of that singularity. It should make detection of these chips
quite reliable now.

Andras, Mark, can you please test again? Confidence 6 is expected. Mark,
please fake the LM77 address range again, so that the test is even more
interesting.

Thanks.

-- 
Jean Delvare
http://khali.linux-fr.org/

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (10 preceding siblings ...)
  2005-05-19  6:25 ` Andras BALI
@ 2005-05-19  6:25 ` Mark M. Hoffman
  2005-05-19  6:25 ` Andras BALI
                   ` (18 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Mark M. Hoffman @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Hi Jean:

* Jean Delvare <khali@linux-fr.org> [2004-07-02 23:55:08 +0200]:
> OK, I reworked both the LM75 and the LM77 detection routines to take
> benefit of that singularity. It should make detection of these chips
> quite reliable now.
> 
> Andras, Mark, can you please test again? Confidence 6 is expected. Mark,
> please fake the LM77 address range again, so that the test is even more
> interesting.

Confidence 6 as expected on the lm75s, and lm77 was (correctly) not
detected.  I used this:

Index: sensors-detect
=================================RCS file: /home/cvs/lm_sensors2/prog/detect/sensors-detect,v
retrieving revision 1.332
diff -u -r1.332 sensors-detect
--- sensors-detect      2 Jul 2004 22:01:17 -0000       1.332
+++ sensors-detect      2 Jul 2004 22:22:11 -0000
@@ -904,7 +904,7 @@
      {
        name => "National Semiconductor LM77",
        driver => "lm77",
-       i2c_addrs => [0x48..0x4b],
+       i2c_addrs => [0x48..0x4d],
        i2c_detect => sub { lm77_detect @_},
      },
      {

Regards,

-- 
Mark M. Hoffman
mhoffman@lightlink.com

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (15 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Jean Delvare
                   ` (13 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Fri, 2004-07-02 at 23:55, Jean Delvare wrote:

> OK, I reworked both the LM75 and the LM77 detection routines to take
> benefit of that singularity. It should make detection of these chips
> quite reliable now.

> Andras, Mark, can you please test again? Confidence 6 is expected.

It's still confidence 3 there, you forgot this:

--- sensors-detect.old  2004-07-03 00:40:51.000000000 +0200
+++ sensors-detect      2004-07-03 00:42:32.000000000 +0200
@@ -2922,10 +2922,15 @@
     or (($low >> 12) != 0 && ($low >> 12) != 0xf)
     or (($high >> 12) != 0 && ($high >> 12) != 0xf);

+  $cur /= 16;
+  $hyst /= 16;
+  $os /= 16;
+  $high /= 16;
+  $low /= 16;

   # Most probable value ranges
   return 6 if $cur <= 100 and $hyst <= 40
-    and ($os >= 20 && $os <= 127) and ($high >= 20 && $os <= 127);
+    and ($os >= 20 && $os <= 127) and ($high >= 20 && $high <= 127);
   return 3;
 }

I'll be off for the weekend so I won't be able for a while.

Thanks,
Andras


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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (14 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Andras BALI
                   ` (14 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> It's still confidence 3 there, you forgot this:
> 
> --- sensors-detect.old  2004-07-03 00:40:51.000000000 +0200
> +++ sensors-detect      2004-07-03 00:42:32.000000000 +0200
> @@ -2922,10 +2922,15 @@
>      or (($low >> 12) != 0 && ($low >> 12) != 0xf)
>      or (($high >> 12) != 0 && ($high >> 12) != 0xf);
> 
> +  $cur /= 16;
> +  $hyst /= 16;
> +  $os /= 16;
> +  $high /= 16;
> +  $low /= 16;
> 
>    # Most probable value ranges
>    return 6 if $cur <= 100 and $hyst <= 40
> -    and ($os >= 20 && $os <= 127) and ($high >= 20 && $os <= 127);
> +    and ($os >= 20 && $os <= 127) and ($high >= 20 && $high <= 127);
>    return 3;
>  }

Ahhh correct, I missed these. Thanks for the fix, I applied it. If you
get confidence 6 with this changes, it's all OK.

Next steps:
1* Update detection in lm75 driver and docs (CVS/2.4).
2* Update detection in lm75 driver and docs (2.6).
3* Complete your lm77 driver and submit it for integration into Linux 2.6.

Thanks :) (and have a good week-end!)

-- 
Jean Delvare
http://khali.linux-fr.org/

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (7 preceding siblings ...)
  2005-05-19  6:25 ` Andras BALI
@ 2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Jean Delvare
                   ` (21 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Sat, 2004-07-03 at 09:01, Jean Delvare wrote:

> Ahhh correct, I missed these. Thanks for the fix, I applied it. If you
> get confidence 6 with this changes, it's all OK.

Yes, I get confidence 6 with CVS sensors-detect now.

> Next steps:
> 1* Update detection in lm75 driver and docs (CVS/2.4).
> 2* Update detection in lm75 driver and docs (2.6).

I see in the CVS that the detection in the 2.4 module has
already been updated. Should I port it to the 2.6 module,
or has someone else already done that?

> 3* Complete your lm77 driver and submit it for integration into Linux 2.6.

Attached is a new version that has improved detection (mostly based on
the sensors-detect script). It works here (and I see no reason why it
shouldn't work at anywhere else), but could use some testing, especially
against lm75 sensors.

Please let me know what else can I help to get this driver into the
kernel.

Thanks,
Andras


-------------- next part --------------
A non-text attachment was scrubbed...
Name: lm77.c
Type: text/x-csrc
Size: 11218 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040705/33917938/lm77.bin

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (23 preceding siblings ...)
  2005-05-19  6:25 ` Andras BALI
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Andras BALI
                   ` (5 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors


>> Next steps:
>> 1* Update detection in lm75 driver and docs (CVS/2.4).
>> 2* Update detection in lm75 driver and docs (2.6).
>
>I see in the CVS that the detection in the 2.4 module has
>already been updated. Should I port it to the 2.6 module,
>or has someone else already done that?

I already did, sorry for not CC'ing you.

>> 3* Complete your lm77 driver and submit it for integration into Linux 2.6.
>
>Attached is a new version that has improved detection (mostly based on
>the sensors-detect script). It works here (and I see no reason why it
>shouldn't work at anywhere else), but could use some testing, especially
>against lm75 sensors.
>
>Please let me know what else can I help to get this driver into the
>kernel.

I reviewed your code, it's overall good but there are a few things that
should be fixed before submitting it to Greg:

1* Address range is 0x48-0x4b.

2* Detection code could be simplified/accelerated:

>  for (i = 0; i <= 0x1f; i++)
>    if ((i2c_smbus_read_byte_data(new_client, i * 8 + 1) != conf) ||

I think we better do i+=8 instead of multiplying by 8 each time. That's
what I did for the LM75.
http://khali.linux-fr.org/devel/i2c/linux-2.6/linux-2.6.7-mm5-i2c-lm75-detect.diff

You can also start at i=8.

>  if (((swab16(cur)  >> 12) != 0xf && (swab16(cur)  >> 12) != 0x0) ||

This is expensive for no benefit. you can check (cur&0x00f0) directly.

>  cur = i2c_smbus_read_word_data(new_client, 0);
>  if (i2c_smbus_read_word_data(new_client, 6) != cur ||
>      i2c_smbus_read_word_data(new_client, 7) != cur)
>                goto exit_free;

Doesn't look safe to me. We don't know exactly if 6 and 7 return the
last read value or the value of the last read register. The latter
sounds much more probable, and since current reading may change, it's
not safe. Better rely on limit registers (like you do right after).

> static void lm77_init_client(struct i2c_client *client)
> {
> 	/* Initialize the LM77 chip */
> 	lm77_write_value(client, LM77_REG_CONF, 0);
> }

It's a bit agressive. I think there's only one bit which really needs
to be cleared, correct?

The lm75 driver would benefit a similar change.

One more important issue with your driver is the hyst limit. For the
LM77, it is a relative value which applies to all 3 limits. This
doesn't quite fit into our standard intefrace, where all limits must be
absolute. This means that you have to change your driver to provide the
following interface files:

temp1_crit_hyst
temp1_min_hyst
temp1_max_hyst

The first one would be RW, while the two others would be read-only (since
there is a single register in hardware). Oh, and I almost missed it: it
really has to betemp1_min and _max, not _low and _high.

Please update your code to code to comply with my remarks.

Thanks,
Jean Delvare

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (21 preceding siblings ...)
  2005-05-19  6:25 ` Andras BALI
@ 2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Andras BALI
                   ` (7 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Mon, 2004-07-05 at 11:57, Jean Delvare wrote:

> I reviewed your code, it's overall good but there are a few things that
> should be fixed before submitting it to Greg:

> 1* Address range is 0x48-0x4b.

Agreed & fixed. 

> 2* Detection code could be simplified/accelerated:

> >  for (i = 0; i <= 0x1f; i++)
> >    if ((i2c_smbus_read_byte_data(new_client, i * 8 + 1) != conf) ||

> I think we better do i+=8 instead of multiplying by 8 each time.

Agreed & fixed.

> >  if (((swab16(cur)  >> 12) != 0xf && (swab16(cur)  >> 12) != 0x0) ||

> This is expensive for no benefit. you can check (cur&0x00f0) directly.

Agreed (and ashamed :-) ) & fixed.

> >  cur = i2c_smbus_read_word_data(new_client, 0);
> >  if (i2c_smbus_read_word_data(new_client, 6) != cur ||
> >      i2c_smbus_read_word_data(new_client, 7) != cur)
> >                goto exit_free;

> Doesn't look safe to me. We don't know exactly if 6 and 7 return the
> last read value or the value of the last read register. The latter
> sounds much more probable, and since current reading may change, it's
> not safe. Better rely on limit registers (like you do right after).

I actually tested this, and 6 and 7 return the last read value, not the
value of the last read register.

> > static void lm77_init_client(struct i2c_client *client)
> > {
> > 	/* Initialize the LM77 chip */
> > 	lm77_write_value(client, LM77_REG_CONF, 0);
> > }

> It's a bit agressive. I think there's only one bit which really needs
> to be cleared, correct?

From the datasheet:

D0: Shutdown - when set to 1, the LM77 goes to low power shutdown mode.
Power up default of 0.
D1: Interrupt mode - 0 is Comparator Interrupt mode, 1 is Event
Interrupt mode. Power up default of 0.
D2, D3: T_CRIT_A and INT polarity - 0 is active low, 1 is active high.
Outputs are open-drain. Power up default of 0.
D4: Fault Queue - when set to 1, the Fault Queue is enabled. Power up
default of 0.

Since the power up default is 0x0 for the whole configuration register,
maybe this whole initialization can be skipped. What do you think?

> One more important issue with your driver is the hyst limit. For the
> LM77, it is a relative value which applies to all 3 limits. This
> doesn't quite fit into our standard intefrace, where all limits must be
> absolute. This means that you have to change your driver to provide the
> following interface files:

> temp1_crit_hyst
> temp1_min_hyst
> temp1_max_hyst

> The first one would be RW, while the two others would be read-only (since
> there is a single register in hardware).

I understand that the current interface operates with absolute limits,
but are you sure that the hysteresis should be treated the same way as
temperature limits? The way I see it, hysteresis is not a limit, but
rather a "delay", a relative value per se. Quoting Webster:

  Hysteresis (n): A lagging or retardation of the effect, as if 
   from velocity or internal friction; a temporary resistance to
   change from a condition previously induced, observed in magnetism,
   thermoelectricity, etc., on reversal of polarity.

It's just my $0.02 - I think it makes more sense if it's kept as a
relative value (and the interface is more sensible this way, IMHO). But
I'm not a native English speaker, nor do I know much about physics and
stuff like this, so please feel free to correct me. And I can of course
make the change, if you don't agree.

> Oh, and I almost missed it: it really has to be temp1_min and _max, not 
> _low and _high.

Agreed & fixed.

Thanks,
Andras


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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (16 preceding siblings ...)
  2005-05-19  6:25 ` Andras BALI
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Jean Delvare
                   ` (12 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors


>> Doesn't look safe to me. We don't know exactly if 6 and 7 return the
>> last read value or the value of the last read register. The latter
>> sounds much more probable, and since current reading may change, it's
>> not safe. Better rely on limit registers (like you do right after).
>
> I actually tested this, and 6 and 7 return the last read value, not the
> value of the last read register.

Aha, interesting. How can you be sure?

From the datasheet:
>
>D0: Shutdown - when set to 1, the LM77 goes to low power shutdown mode.
>Power up default of 0.
>D1: Interrupt mode - 0 is Comparator Interrupt mode, 1 is Event
>Interrupt mode. Power up default of 0.
>D2, D3: T_CRIT_A and INT polarity - 0 is active low, 1 is active high.
>Outputs are open-drain. Power up default of 0.
>D4: Fault Queue - when set to 1, the Fault Queue is enabled. Power up
>default of 0.
>
>Since the power up default is 0x0 for the whole configuration register,
>maybe this whole initialization can be skipped. What do you think?

Something (BIOS) might have put the chip in "shutdown mode". That same
something may have change some parameters to fit the hardware
configuration (such as polarities) and we want to preserve that. So I'd
suggest you read the config byte, check whether bit 0 is set, and if it
is, rewrite the exact same config byte except for bit 0 which you'd
clear.

>I understand that the current interface operates with absolute limits,
>but are you sure that the hysteresis should be treated the same way as
>temperature limits? The way I see it, hysteresis is not a limit, but
>rather a "delay", a relative value per se. Quoting Webster:
>
>  Hysteresis (n): A lagging or retardation of the effect, as if
>   from velocity or internal friction; a temporary resistance to
>   change from a condition previously induced, observed in magnetism,
>   thermoelectricity, etc., on reversal of polarity.
>
>It's just my $0.02 - I think it makes more sense if it's kept as a
>relative value (and the interface is more sensible this way, IMHO). But
>I'm not a native English speaker, nor do I know much about physics and
>stuff like this, so please feel free to correct me. And I can of course
>make the change, if you don't agree.

We have two dozens other chips which have hysteresis limits, most of
which store them (in their registers) as absolute values. For this
reason, it was first decided (6 years ago or so) that the interface
would use absolute values. Since it is important that every driver
sticks to a common interface, the few chips which use relative values
inside still export absolute values outside. The choice itself didn't
matter much (you always represent the same temperature), what is
important is that a standard had to be defined and needs to be respected.

So, absolute limits for everyone, including hysteresis limits. Of course,
it's of the driver's responsability to do the correct thing when the
user changes a value. Setting the critical limit should preserve (from
the user's absolute point of view) the associated hysteresis limit
(i.e. change the hysteresis register value). The user isn't supposed to
know the driver's internals. Sometimes you cannot hide it entirely, but
we should do as much as we can.

Note that I'm not sure that all our drivers do that properly though.

Thanks,
Jean Delvare

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (22 preceding siblings ...)
  2005-05-19  6:25 ` Andras BALI
@ 2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Jean Delvare
                   ` (6 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Mon, 2004-07-05 at 14:44, Jean Delvare wrote:

> >> Doesn't look safe to me. We don't know exactly if 6 and 7 return the
> >> last read value or the value of the last read register. The latter
> >> sounds much more probable, and since current reading may change, it's
> >> not safe. Better rely on limit registers (like you do right after).

> > I actually tested this, and 6 and 7 return the last read value, not the
> > value of the last read register.

> Aha, interesting. How can you be sure?

Well, I read 0 (that was 32 degrees), heated up the sensor with a
lighter and then read 6, 7 and 0, one straightaway after the other. 6
and 7 returned 32, 0 returned 40 (and after that, 6 and 7 returned 40).
Of course this is by no means a scientific proof, but should be enough I
assume.

> Something (BIOS) might have put the chip in "shutdown mode". That same
> something may have change some parameters to fit the hardware
> configuration (such as polarities) and we want to preserve that. So I'd
> suggest you read the config byte, check whether bit 0 is set, and if it
> is, rewrite the exact same config byte except for bit 0 which you'd
> clear.

Okay (even though there might be some possible uses of leaving the chip
in shutdown mode, as it still allows registers to be read and written,
it just doesn't update the temperature).

> We have two dozens other chips which have hysteresis limits, most of
> which store them (in their registers) as absolute values. For this
> reason, it was first decided (6 years ago or so) that the interface
> would use absolute values. Since it is important that every driver
> sticks to a common interface, the few chips which use relative values
> inside still export absolute values outside. The choice itself didn't
> matter much (you always represent the same temperature), what is
> important is that a standard had to be defined and needs to be respected.

Okay, I concede that consistency is more important than my nitpicking
regarding definitions. But I cannot resist one more comment :-) Here you
are saying that hysteresis should be an absolute value (regarding its
content):

> So, absolute limits for everyone, including hysteresis limits.

Whereas here:

> Setting the critical limit should preserve (from the user's absolute
> point of view) the associated hysteresis limit (i.e. change the hysteresis
> register value). 

you are saying that hysteresis should be relative (regarding its
nature), since it's not the absolute value of it that should be
preserved when a limit is  modified, but its difference to them.
I do not see how this makes more sense than storing the hysteresis as a
relative value (since that is its nature), but I stop arguing here and
accept the fact that this has already been decided, as I agree that
consistency is the most important factor.

Thanks,
Andras


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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (17 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Jean Delvare
                   ` (11 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> Well, I read 0 (that was 32 degrees), heated up the sensor with a
> lighter and then read 6, 7 and 0, one straightaway after the other. 6
> and 7 returned 32, 0 returned 40 (and after that, 6 and 7 returned
> 40). Of course this is by no means a scientific proof, but should be
> enough I assume.

Certainly, I'm myself completely convinced ;)

> Okay, I concede that consistency is more important than my nitpicking
> regarding definitions. But I cannot resist one more comment :-) Here
> you are saying that hysteresis should be an absolute value (regarding
> its content):
> 
> > So, absolute limits for everyone, including hysteresis limits.
> 
> Whereas here:
> 
> > Setting the critical limit should preserve (from the user's absolute
> > point of view) the associated hysteresis limit (i.e. change the
> > hysteresis register value). 
> 
> you are saying that hysteresis should be relative (regarding its
> nature), since it's not the absolute value of it that should be
> preserved when a limit is  modified, but its difference to them.
> I do not see how this makes more sense than storing the hysteresis as
> a relative value (since that is its nature), but I stop arguing here
> and accept the fact that this has already been decided, as I agree
> that consistency is the most important factor.

This simply proves that I misexpressed myself (though reading myself
again I find it clear ;)). When I say "setting the critical limit should
preserve the associated hysteresis limit", I mean that the user should
not see it change, which precisely means that the register value should
be updated. As a concrete example, let's consider that the critical
limit is set to 80 degree and the hysteresis register holds 5. From the
user's point of view, we have temp_crit€ and temp_crit_hystu. Now if
the user asks for temp_crit…, it should *not* seem to affect
temp_crit_hyst which should stay at 75, which means that the driver
would have to both write 85 to crit register and 10 to hyst register. Is
it clearer now?

Anyway I'm almost sure we agree and it was just a matter of expressing
the idea.

Thanks,

-- 
Jean Delvare
http://khali.linux-fr.org/

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (20 preceding siblings ...)
  2005-05-19  6:25 ` Andras BALI
@ 2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Andras BALI
                   ` (8 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Mon, 2004-07-05 at 19:22, Jean Delvare wrote:

> This simply proves that I misexpressed myself (though reading myself
> again I find it clear ;)). When I say "setting the critical limit should
> preserve the associated hysteresis limit", I mean that the user should
> not see it change, which precisely means that the register value should
> be updated. As a concrete example, let's consider that the critical
> limit is set to 80 degree and the hysteresis register holds 5. From the
> user's point of view, we have temp_crit€ and temp_crit_hystu. Now if
> the user asks for temp_crit…, it should *not* seem to affect
> temp_crit_hyst which should stay at 75, which means that the driver
> would have to both write 85 to crit register and 10 to hyst register. Is
> it clearer now?

Yes, it makes sense now. But I'm not sure how to handle the fact that
the hysteresis register applies to three temperature limits in the LM77.
Say, the register value for hysteresis is 2 degrees, T_crit€,
T_high`. So the driver should show T_crit_hystx, T_high_hystX. Now
if the user changes T_crit to 90, T_crit_hyst should be still 78, so the
hysteresis register should hold 12 now. However that would mean that
T_high_hyst will show 68 now. Does it make sense? (I have doubts.) And
what if T_high is changed by the user? Should the hysteresis be updated
accordingly? Does that make sense? I don't think so, that would screw up
the hysteresis for T_crit. What is your suggestion?

Thanks,
Andras


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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (19 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Andras BALI
                   ` (9 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Mon, 2004-07-05 at 21:30, Andras BALI wrote:

> Say, the register value for hysteresis is 2 degrees, T_crit€,
> T_high`. So the driver should show T_crit_hystx, T_high_hystX. Now
> if the user changes T_crit to 90, T_crit_hyst should be still 78, so the
> hysteresis register should hold 12 now. However that would mean that
> T_high_hyst will show 68 now.

Eh, 48 (60-12), not 68, sorry.


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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (18 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Andras BALI
                   ` (10 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> Yes, it makes sense now. But I'm not sure how to handle the fact that
> the hysteresis register applies to three temperature limits in the
> LM77. Say, the register value for hysteresis is 2 degrees, T_crit€,
> T_high`. So the driver should show T_crit_hystx, T_high_hystX.
> Now if the user changes T_crit to 90, T_crit_hyst should be still 78,
> so the hysteresis register should hold 12 now. However that would mean
> that T_high_hyst will show 68 now. Does it make sense? (I have
> doubts.) And what if T_high is changed by the user? Should the
> hysteresis be updated accordingly? Does that make sense? I don't think
> so, that would screw up the hysteresis for T_crit. What is your
> suggestion?

You're correct, there is a kind of probleme here. Don't keep searching,
this problem has no solution. This is the reason why I suggested that
temp1_min_hyst and temp1_max_hyst would be read-only. That way, it
clearly states that these are computed values and user should not assume
anything about these. Of course, having knowledge about the chip and the
way the driver is implemented helps understanding why things are that
way. But the basic rules apply:

- read-write files can be set be the user in any order (although there
may be limitations)
- nothing should be assumed about read-only files

A library or program handling the chips interfaces in a generic way
would always set base limits first and corresponding hysteresis then,
because it always works best that way.

Of course some choices (such as preferring critical limit over min or
max) are arbitrary, but that's the way it goes. You cannot define a
common interface to chips with different designs without some additional
work and limitations. All in all it is believed to be the best tradeoff.

Thanks,

-- 
Jean Delvare
http://khali.linux-fr.org/

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (24 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Jean Delvare
                   ` (4 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

So, here is an updated version of the lm77 driver that exports the
hysteresis for all three limits as an absolute value.

While testing I figured out that the low three bits of the temperature
limit registers are actually not unused: they contain the same status
bits as the temperature registers (and indeed, the datasheet doesn't say
that they should be 0 like it does for the high 3 bits of the config
register, it just declares them as undefined). Therefore I had to remove
the unused bits detection step from the source (apart from the check on
the config register) and I suggest that the same should be done in the
sensors-detect script.

Thanks,
Andras

-------------- next part --------------
A non-text attachment was scrubbed...
Name: lm77.c
Type: text/x-csrc
Size: 12720 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040706/3784598c/lm77.bin

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (25 preceding siblings ...)
  2005-05-19  6:25 ` Andras BALI
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Jean Delvare
                   ` (3 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> So, here is an updated version of the lm77 driver that exports the
> hysteresis for all three limits as an absolute value.

A few additional comments:

1* I guess you could use s16 instead of int to store temperature values.

2* Your "set" functions are not correct. You use temporary variables to
store the values instead of the internal variables. This means that
reading the value right after writing it will return the old value (for
at most HZ + HZ / 2). You also change the value of write min_hyst and
max_hyst (internal variables) at the time you change crit or crit_hyst.
This may make you reconsider your choice of storing 3 different values
for the three hysteresis values instead of computing them on the fly
(not sure, you choose).

3* Your alignment for DEVICE_ATTR calls hardly makes them readable. I
doubt kernel people will like this. Also, please split lines when they
go to long. Same goes for some other places in the code.

4* This comment: "temperature registers: low 3 bits are unused" is
misleading. The bits are not unused, they are just not part of the
temperature value. BTW, what about exporting these three bits in an
"alarm" file? Whould be quite straightforward.

5* Please discard the "which is exactly opposite to the usual practice"
comment about byte ordering. It turns out that high byte first is the
usual practice, and we chose the wrong default in the i2c core (long
time ago). I guess you picked this from lm75.c, which would benefit a
similar update.

6* In lm77_update_device you define a variable in the middle of a block.
I'm surprised it did even compile. At any rate, not all compilers will
accept it, so please don't do that.

All the rest is fine (as far as I can see)!

In the end you'll have to submit your driver as a complete patch
(including changes to Kconfig and Makefile) against the kernel tree. The
base tree for your patch should be 2.6.7-mm5 (or -mm6) +
http://khali.linux-fr.org/devel/i2c/linux-2.6/linux-2.6.7-mm5-i2c.patch.gz.

> While testing I figured out that the low three bits of the temperature
> limit registers are actually not unused: they contain the same status
> bits as the temperature registers (and indeed, the datasheet doesn't
> say that they should be 0 like it does for the high 3 bits of the
> config register, it just declares them as undefined). Therefore I had
> to remove the unused bits detection step from the source (apart from
> the check on the config register) and I suggest that the same should
> be done in the sensors-detect script.

I actually suspected that from the beginning and the sensors-detect
script never made any assumption about these bits. But thanks for
letting us know.

-- 
Jean Delvare
http://khali.linux-fr.org/

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (28 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Andras BALI
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Sorry for the late answer, I didn't receive your mail, just found
it in the mailing list archive.

Attached is a patch against 2.6.7-mm6, reworked to comply with your
comments. I chose to store the temperatures as `int' and not `s16'
because I store the converted values and eg. 80000 would hardly
fit in s16.

I guess it's time to admit that I've never written anything longer
than 10 lines in C before, so this is why it's going so slow. Thanks
for your time and patience :-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: linux-2.6.7-mm6-lm77.patch
Type: text/x-patch
Size: 15506 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040707/1e3b1cb2/linux-2.6.7-mm6-lm77.bin

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (26 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Jean Delvare
                   ` (2 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> Sorry for the late answer, I didn't receive your mail, just found
> it in the mailing list archive.

I was wondering. I got an error on my mail stating:

"<drewie@freemail.hu>: conversation with fmx.freemail.hu[195.228.242.194] timed
    out while sending end of data -- message may be sent more than once"

And I thought "in the worse case he'll get it twice". Looks like I was
wrong...

> Attached is a patch against 2.6.7-mm6, reworked to comply with your
> comments. I chose to store the temperatures as `int' and not `s16'
> because I store the converted values and eg. 80000 would hardly
> fit in s16.

Ah OK. We usually store "raw" register values and convert them right
before "exporting" them. But I admit your way is more efficient. Still
your comment "Register values" is now misleading, you should consider
changing it.

> I guess it's time to admit that I've never written anything longer
> than 10 lines in C before, so this is why it's going so slow. Thanks
> for your time and patience :-)

No problem. You couldn't possibly know the kernel folks (strange)
choices for coding style, nor the common patterns in our chip drivers.
Patience is the way only way i know to learn.

A few more comments:

1* Alignment. Kernel folks are being a bit strict when it comes to
alignment. You are not allowed to use spaces to align your defines, nor
your structure members. I know it's a bit restrictive, but that's the
way it goes.

2* Do you have a personal need for exporting the configuration register
to user-space? Other drivers don't. It's assumed that the chip is
configured for proper operation by either the bios or the driver init
process (or in extreme cases module parameter) and should not need to be
changed in runtime. What's more, the format is chip-dependant, and
changing some bits may be extremely sensible (polarity for example).

3* Watch your indentation. In several places you have 8 spaces instead
of a tab (reading the patch is an easy way to catch them). There are
also problem on "goto exit_free" lines.

4* According to out sysfs-interface standard, the alarms file should be
named "alarms", not "alarm".

5* Is it just me or:
+		if (((cur  & 0x00f0) != 0xf && (cur  & 0x00f0) != 0x0)
+		    || ((hyst & 0x00f0) != 0xf && (hyst & 0x00f0) != 0x0)
+		    || ((crit & 0x00f0) != 0xf && (crit & 0x00f0) != 0x0)
+		    || ((min  & 0x00f0) != 0xf && (min  & 0x00f0) != 0x0)
+		    || ((max  & 0x00f0) != 0xf && (max  & 0x00f0) != 0x0))
is broken? I guess you'd need to test != 0xf0, not 0xf.

6* It's a bit weird that you use a wrapper to read from the smbus and
still read the alarm bits directly. I think that your wrapper should
just do its job, ie get the values. The temperature conversions don't
belong there. See how it is done in the other drivers. I admit that your
code works, but it's not consistent.

7* Don't define an ID for the LM77. It's not needed, you can just omit it.

Sorry to insist on things you might consider are details. They certainly
are, but if I don't have you correct them now, chances are that your
patch will not be accepted by kernel folks. It's also important that all
our drivers are as similar as possible for the ease of maintainance.

Thanks.

-- 
Jean Delvare
http://khali.linux-fr.org/

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (29 preceding siblings ...)
  2005-05-19  6:25 ` Andras BALI
@ 2005-05-19  6:25 ` Andras BALI
  30 siblings, 0 replies; 32+ messages in thread
From: Andras BALI @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Wed, 2004-07-07 at 14:21, Jean Delvare wrote:

> > Sorry for the late answer, I didn't receive your mail, just found
> > it in the mailing list archive.
[...]
> And I thought "in the worse case he'll get it twice". Looks like I was
> wrong...

Anyway, that's my fault. I know that this free mail server sucks, but
I've been using it for quite a long time now.

> Still your comment "Register values" is now misleading, you should
> consider changing it.

Fixed.

> 1* Alignment. Kernel folks are being a bit strict when it comes to
> alignment. You are not allowed to use spaces to align your defines, nor
> your structure members. I know it's a bit restrictive, but that's the
> way it goes.

Okay, I fired up visible-whitespace-mode in emacs, hope I managed to
nuke all the spaces.

> 2* Do you have a personal need for exporting the configuration register
> to user-space?

No, actually I don't - I just thought that if all the registers are
shown, why skip this? But I admit that it might be dangerous so I
removed it.

> 3* Watch your indentation. In several places you have 8 spaces instead
> of a tab (reading the patch is an easy way to catch them). There are
> also problem on "goto exit_free" lines.

I hope that all of these are fixed, too.

> 4* According to out sysfs-interface standard, the alarms file should be
> named "alarms", not "alarm".

Fixed.

> 5* Is it just me or:
> +		if (((cur  & 0x00f0) != 0xf && (cur  & 0x00f0) != 0x0)
> +		    || ((hyst & 0x00f0) != 0xf && (hyst & 0x00f0) != 0x0)
> +		    || ((crit & 0x00f0) != 0xf && (crit & 0x00f0) != 0x0)
> +		    || ((min  & 0x00f0) != 0xf && (min  & 0x00f0) != 0x0)
> +		    || ((max  & 0x00f0) != 0xf && (max  & 0x00f0) != 0x0))
> is broken? I guess you'd need to test != 0xf0, not 0xf.

Correct. I wonder how I missed that... :P

> 6* It's a bit weird that you use a wrapper to read from the smbus and
> still read the alarm bits directly.

Fixed.

> 7* Don't define an ID for the LM77. It's not needed, you can just omit it.

Actually I had no idea what that ID does, I just saw that the LM75
driver had one and that's why I kept it there. Removed.

> Sorry to insist on things you might consider are details. They certainly
> are, but if I don't have you correct them now, chances are that your
> patch will not be accepted by kernel folks. It's also important that all
> our drivers are as similar as possible for the ease of maintainance.

I understand this and do not underestimate the importance of these
details (and of course I like to read well-aligned code - that's one
thing I learnt from Python :-) ). Thanks again for your time and
support, I hope this time I managed to get it right (well, if not, next
time :)

Thanks,
Andras

-------------- next part --------------
A non-text attachment was scrubbed...
Name: linux-2.6.7-mm6-lm77.patch
Type: text/x-patch
Size: 14939 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040707/a099cdb3/linux-2.6.7-mm6-lm77.bin

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

* lm77 on national sc1100
  2005-05-19  6:25 lm77 on national sc1100 Andras BALI
                   ` (27 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Andras BALI
  2005-05-19  6:25 ` Andras BALI
  30 siblings, 0 replies; 32+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> I understand this and do not underestimate the importance of these
> details (and of course I like to read well-aligned code - that's one
> thing I learnt from Python :-) ). Thanks again for your time and
> support, I hope this time I managed to get it right (well, if not,
> next time :)

Almost perfect. Looks like one tab is missing on line 178 of the patch
though ;)

OK, fine with me. We can now send your patch to Greg KH <greg at kroah
dot com>. If possible (i.e. if your mailer won't destroy the patch),
have the patch inlined in your mail. If you cannot do that, Greg accepts
attachements too. Don't forget to sign your patch with a "Signed-off-by:
X <contact info>" line in the mail. You may mention the fact that I
reviewed your code and approved it (it should save Greg some time).
Don't forget to CC this mailing-list too.

Thanks for the good work!

-- 
Jean Delvare
http://khali.linux-fr.org/

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

end of thread, other threads:[~2005-05-19  6:25 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-19  6:25 lm77 on national sc1100 Andras BALI
2005-05-19  6:25 ` Andras BALI
2005-05-19  6:25 ` Mark M. Hoffman
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Mark M. Hoffman
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Mark M. Hoffman
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Andras BALI
2005-05-19  6:25 ` Andras BALI
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Andras BALI
2005-05-19  6:25 ` Mark M. Hoffman
2005-05-19  6:25 ` Andras BALI
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Andras BALI
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Andras BALI
2005-05-19  6:25 ` Andras BALI
2005-05-19  6:25 ` Andras BALI
2005-05-19  6:25 ` Andras BALI
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Andras BALI
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Andras BALI
2005-05-19  6:25 ` Andras BALI

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.