All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] sensors-detect: Add detection of TI ADC128D818
Date: Sun, 26 Jan 2014 18:33:31 +0000	[thread overview]
Message-ID: <52E554FB.1080908@roeck-us.net> (raw)
In-Reply-To: <20110217195640.GA20934@ericsson.com>

On 01/26/2014 05:22 AM, Jean Delvare wrote:
> Hi Guenter,
>
> On Sat, 25 Jan 2014 16:13:51 -0800, Guenter Roeck wrote:
>> On 01/25/2014 02:05 PM, Jean Delvare wrote:
>>> On Sat, 25 Jan 2014 09:54:51 -0800, Guenter Roeck wrote:
>>>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>>>> ---
>>>>    CHANGES                    |    3 +++
>>>>    prog/detect/sensors-detect |   26 +++++++++++++++++++++-----
>>>>    2 files changed, 24 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/CHANGES b/CHANGES
>>>> index e1347a6..970dd67 100644
>>>> --- a/CHANGES
>>>> +++ b/CHANGES
>>>> @@ -1,6 +1,9 @@
>>>>    lm-sensors CHANGES file
>>>>    -----------------------
>>>>
>>>> +SVN HEAD
>>>> +  sensors-detect: Add detection of ADC128D818
>>>> +
>>>>    3.3.5 "Happy Birthday Beddy" (2014-01-22)
>>>>      libsensors: Improve documentation of two functions
>>>>                  Increase MAX_SENSORS_PER_TYPE to 33
>>>> diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect
>>>> index a2093f3..2136b76 100755
>>>> --- a/prog/detect/sensors-detect
>>>> +++ b/prog/detect/sensors-detect
>>>> @@ -547,6 +547,11 @@ use vars qw(@i2c_adapter_names);
>>>>    		i2c_addrs => [0x28..0x2f],
>>>>    		i2c_detect => sub { lm80_detect(@_, 1); },
>>>>    	}, {
>>>> +		name => "TI / National Semiconductor ADC128D818",
>>>> +		driver => "adc128d818",
>>>> +		i2c_addrs => [0x1d, 0x1e, 0x1f, 0x2d, 0x2e, 0x2f, 0x35, 0x36, 0x37],
>>>> +		i2c_detect => sub { lm80_detect(@_, 2); },
>>>
>>> How does this relate to the LM80?
>>>
>>> Is this chip really something people will need sensors-detect for (i.e.
>>> it is found in PC-like computers) or something which will be always
>>> declared in DT-like declarations anyway?
>>
>> No idea, really. I was asked by someone from TI to write a driver some time ago,
>> and finally found the time to actually do it. I recall they had a request
>> from a customer, but I did not ask for the use case.
>>
>> The chip is a close relative to LM80 and LM96080. Register addresses are
>> almost the same, but the sensor registers are 16 bit wide instead of 8,
>> and there are no fan registers. I didn't use the lm80 driver because of
>> the 16 bit registers, but decided to write a new one.
>
> Then I suggest using a different detect function in sensors-detect.
> There isn't enough in common with detect_lm80 to reuse it, and having a
> 1:1 mapping between sensors-detect functions and drivers has advantages.
>
Ok.

>>> I'm asking because I am worried about the address list. I'm fine with
>>> 0x1d..0x1f and 0x2d..0x2f (you can declare them that way in perl BTW,
>>> it's more compact) but addresses 0x35..0x37 we don't currently scan.
>>> Adding a new address to the scan list is always a risk, as you may start
>>> probing a whole new class of devices and the effects can be very bad.
>>>
>>> Actually we used to scan address 0x37 until r3233 / 2006-01-16. Commit
>>> message was:
>>>
>>> "Lower the confidence of ITE overclocking chips. Do not scan
>>> address 0x37 for these chips, as it may cause problem with some
>>> eeproms."
>>>
>>> Addresses 0x35 and 0x36 I don't think we ever scanned, but EEPROMs can
>>> reply to these as well so I'd rather not add them.
>>
>> Ok with me to take out those three addresses ... or drop the entire detection
>> if you think it isn't worth it.
>
> I am fine with the detection function. Please just drop the 3 addresses
> in the 0x30-0x37 range.
>
Ok.

>> Question is what I should do in the driver. Any thoughts on that ?
>> For my part I am fine with dropping the detect function entirely from it;
>> I suspect you are right and it will mostly be used from DT type systems,
>> and from what you said it sounds a bit risky to scan the 0x35..0x37
>> address range.
>
> You can keep the detect function in the driver as long as you remove
> the 0x35..0x37 addresses from the scan list. Just document it properly
> and that should be fine.
>
> About the code itself:
>
>> @@ -4436,11 +4441,13 @@ sub lm92_detect
>>   # Chip to detect: 0 = LM80, 1 = LM96080
>>   # Registers used:
>>   #   0x00: Configuration register
>> -#   0x02: Interrupt state register
>> -#   0x07: Converstion rate register (LM96080 only)
>> +#   0x02: Interrupt state register (LM80, LM96080 only)
>> +#   0x07: Converstion rate register (LM96080, ADC128D818 only)
>> +#   0x08: Oneshot register (ADC128D818 only)
>> +#   0x09: Shutdown register (ADC128D818 only)
>
> The datasheet I have states that 0x09 is the One-Shot register and 0x0a
> is the Deep Shutdown register.
>
Funny, in the driver I got that right :-)

>>   #   0x2a-0x3d: Limits registers (LM80 only)
>> -#   0x3e: Manufacturer's ID register (LM96080 only)
>> -#   0x3f: Stepping/die revision ID register (LM96080 only)
>> +#   0x3e: Manufacturer's ID register (LM96080, ADC128D818 only)
>> +#   0x3f: Stepping/die revision ID register (LM96080, ADC128D818 only)
>>   # The LM80 is easily misdetected since it doesn't provide identification
>>   # registers. So we have to use some tricks:
>>   #   - 6-bit addressing, so limits readings modulo 0x40 should be unchanged
>> @@ -4458,9 +4465,9 @@ sub lm80_detect
>>   	my ($i, $reg);
>>
>>   	return if (i2c_smbus_read_byte_data($file, 0x00) & 0x80) != 0;
>
> For the ADC128D818 you can even mask with 0xf4, slightly improving the
> reliability.
>
Ok.

>> -	return if (i2c_smbus_read_byte_data($file, 0x02) & 0xc0) != 0;
>>
>>   	if ($chip = 0) {
>> +		return if (i2c_smbus_read_byte_data($file, 0x02) & 0xc0) != 0;
>>   		for ($i = 0x2a; $i <= 0x3d; $i++) {
>>   			$reg = i2c_smbus_read_byte_data($file, $i);
>>   			return if i2c_smbus_read_byte_data($file, $i+0x40) != $reg;
>> @@ -4493,11 +4500,20 @@ sub lm80_detect
>>   		return unless $confidence > 0;
>>   		return $confidence;
>>   	} elsif ($chip = 1) {
>> +		return if (i2c_smbus_read_byte_data($file, 0x02) & 0xc0) != 0;
>>   		return if (i2c_smbus_read_byte_data($file, 0x07) & 0xfe) != 0;
>>   		return if i2c_smbus_read_byte_data($file, 0x3e) != 0x01;
>>   		return if i2c_smbus_read_byte_data($file, 0x3f) != 0x08;
>>
>>   		return 6;
>> +	} elsif ($chip = 2) {
>> +		return if (i2c_smbus_read_byte_data($file, 0x07) & 0xfe) != 0;
>> +		return if (i2c_smbus_read_byte_data($file, 0x08) & 0xfe) != 0;
>> +		return if (i2c_smbus_read_byte_data($file, 0x09) & 0xfe) != 0;
>
> You could also check register 0x0c, which as 6 unused bits.
>
As well as 0x0b.

>> +		return if i2c_smbus_read_byte_data($file, 0x3e) != 0x01;
>> +		return if i2c_smbus_read_byte_data($file, 0x3f) != 0x09;
>> +
>> +		return 6;

If I do all that, is that worth a higher rating ?

Thanks,
Guenter


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

  parent reply	other threads:[~2014-01-26 18:33 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-17 19:56 [lm-sensors] [PATCH] sensors-detect: Add detection of AMD family Guenter Roeck
2011-02-18 12:09 ` [lm-sensors] [PATCH] sensors-detect: Add detection of AMD Jean Delvare
2011-02-18 12:29 ` Clemens Ladisch
2011-02-18 12:39 ` Guenter Roeck
2011-05-25 16:56 ` [lm-sensors] [PATCH] sensors-detect: Add detection of MAX6642 Per Dalén
2011-05-26  4:09 ` Guenter Roeck
2012-01-22 23:31 ` [lm-sensors] [PATCH] sensors-detect: Add detection of G781 and G781-1 Guenter Roeck
2012-01-23  9:16 ` Jean Delvare
2012-01-23 16:35 ` [lm-sensors] [PATCH] sensors-detect: Add detection of G781 Guenter Roeck
2012-01-23 16:58 ` Jean Delvare
2012-01-28 18:37 ` [lm-sensors] [PATCH] sensors-detect: Add detection of LM96080 Jean Delvare
2012-01-28 19:23 ` Guenter Roeck
2012-01-28 20:04 ` Jean Delvare
2012-01-28 20:31 ` Frans Meulenbroeks
2012-01-30 17:03 ` Guenter Roeck
2012-01-30 19:03 ` Guenter Roeck
2012-01-30 19:49 ` Jean Delvare
2012-01-30 20:08 ` Guenter Roeck
2012-01-31  7:37 ` Frans Meulenbroeks
2012-01-31  8:08 ` Jean Delvare
2012-03-04 15:59 ` [lm-sensors] [PATCH] sensors-detect: Add detection of ITE IT8510E, IT8511E, IT8513E, and IT8518E Guenter Roeck
2012-03-04 17:11 ` Jean Delvare
2012-03-05 13:29 ` [lm-sensors] [PATCH] sensors-detect: Add detection of ST Mircoelectronics STTS2002 and STTS3000 Jean Delvare
2012-03-05 16:32 ` Guenter Roeck
2012-03-05 17:00 ` Jean Delvare
2012-03-05 17:23 ` Guenter Roeck
2012-05-21  0:59 ` [lm-sensors] [PATCH] sensors-detect: Add detection of NCT6779D and NCT6102D/NCT6106D Guenter Roeck
2012-05-31 18:00 ` [lm-sensors] [PATCH] sensors-detect: Add detection of SMSC LPC47N217 and SIO10N268 Guenter Roeck
2012-05-31 19:53 ` Jean Delvare
2012-05-31 20:52 ` Guenter Roeck
2013-06-24 20:19 ` [lm-sensors] [PATCH] sensors-detect: Add detection of NCT6791D Guenter Roeck
2013-07-01  5:05 ` [lm-sensors] [PATCH] sensors-detect: Add detection of NCT6681D, NCT6682D, and NCT6683D Guenter Roeck
2013-07-02  8:24 ` [lm-sensors] [PATCH] sensors-detect: Add detection of NCT6791D Jean Delvare
2013-07-02  8:35 ` [lm-sensors] [PATCH] sensors-detect: Add detection of NCT6681D, NCT6682D, and NCT6683D Jean Delvare
2013-07-02 14:36 ` [lm-sensors] [PATCH] sensors-detect: Add detection of NCT6791D Guenter Roeck
2013-07-02 14:36 ` [lm-sensors] [PATCH] sensors-detect: Add detection of NCT6681D, NCT6682D, and NCT6683D Guenter Roeck
2013-07-02 16:10 ` [lm-sensors] [PATCH] sensors-detect: Add detection of NCT6791D David Bartley
2013-07-03  2:52 ` Guenter Roeck
2013-07-03  2:56 ` killghost
2013-07-03  4:02 ` Guenter Roeck
2013-07-03  6:23 ` Jean Delvare
2013-07-03  6:32 ` killghost
2013-07-03  6:42 ` David Bartley
2013-07-03  8:26 ` killghost
2013-07-05  7:16 ` David Bartley
2013-07-05 10:08 ` killghost
2014-01-25 17:54 ` [lm-sensors] [PATCH] sensors-detect: Add detection of TI ADC128D818 Guenter Roeck
2014-01-25 22:05 ` Jean Delvare
2014-01-26  0:13 ` Guenter Roeck
2014-01-26 13:22 ` Jean Delvare
2014-01-26 18:33 ` Guenter Roeck [this message]
2014-01-26 18:55 ` Jean Delvare
2015-01-16 21:45 ` [lm-sensors] [PATCH] sensors-detect: Add detection of IT8786E Guenter Roeck
2015-01-18 18:34 ` [lm-sensors] [PATCH] sensors-detect: Add detection of IT8780F Guenter Roeck
2015-01-18 22:48 ` [lm-sensors] [PATCH] sensors-detect: Add detection of IT8731F and IT8732F Guenter Roeck
2015-01-23  6:58 ` [lm-sensors] [PATCH] sensors-detect: Add detection of IT8786E Jean Delvare
2015-01-23  6:59 ` [lm-sensors] [PATCH] sensors-detect: Add detection of IT8780F Jean Delvare
2015-01-23  7:04 ` [lm-sensors] [PATCH] sensors-detect: Add detection of IT8731F and IT8732F Jean Delvare
2015-08-31  3:57 ` [lm-sensors] [PATCH] sensors-detect: Add detection of Novoton NCT6793D Guenter Roeck
2015-08-31  7:26 ` Jean Delvare
2015-08-31  7:38 ` Jean Delvare

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=52E554FB.1080908@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

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

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