All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <guenter.roeck@ericsson.com>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] sensors-detect: Add detection of MAX6642
Date: Thu, 26 May 2011 04:09:28 +0000	[thread overview]
Message-ID: <20110526040928.GA27381@ericsson.com> (raw)
In-Reply-To: <20110217195640.GA20934@ericsson.com>

Hi Per,

On Wed, May 25, 2011 at 12:56:01PM -0400, Per Dalén wrote:
> This patch adds detection of MAX6642 to sensors-detect.
> 
> Signed-off-by: Per Dalen <per.dalen@appeartv.com>
> ---
> 
> --- prog/detect/sensors-detect  (revision 5975)
> +++ prog/detect/sensors-detect  (working copy)
> @@ -848,6 +848,11 @@
>                 i2c_addrs => [0x2c, 0x2e, 0x2f],
>                 i2c_detect => sub { max6639_detect(@_); },
>         }, {
> +               name => "Maxim MAX6642",
> +               driver => "max6642",
> +               i2c_addrs => [0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
> 0x4f],
> +               i2c_detect => sub { max6642_detect(@_); },
> +       }, {
>                 name => "Maxim MAX6655/MAX6656",
>                 driver => "max6655",
>                 i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
> @@ -5779,6 +5784,36 @@
>         return 6;
>  }
> 
> +# Chip to detect: MAX6642
> +# Registers used:
> +#   0x02: Status register
> +#   0x03: Configuration register
> +#   0xfe: Manufacturer ID
> +#   0x04,0x06,0xff: No registers
> +# We use the 0x04,0x06 and 0xff addresses (unused) to improve the
> reliability.
> +# These are not real registers and will always return the last returned
> value.
> +# This isn't documented.
> +sub max6642_detect
> +{
> +       my ($file, $addr) = @_;
> +       my ($man_id, $conf, $status);
> +
> +       $man_id = i2c_smbus_read_byte_data($file, 0xfe, NO_CACHE);

You might want to more the check for $man_id = 0x4d to here, 
to avoid reading the other registers if you don't have to.

> +       return if i2c_smbus_read_byte_data($file, 0x04, NO_CACHE) !> $man_id;

I think it would be better to read the other non-existing registers here, 
because if those are real registers they are more unlikely to return 0x4d
than to return the same value as the status and configuration registers.

Something like

	$man_id = i2c_smbus_read_byte_data($file, 0xfe, NO_CACHE);
	return unless $man_id = 0x4d;  # Maxim
	return if i2c_smbus_read_byte_data($file, 0xff, NO_CACHE) != $man_id;
	return if i2c_smbus_read_byte_data($file, 0x04, NO_CACHE) != $man_id;
	return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) != $man_id;

	...

Thanks,
Guenter

> +       $status = i2c_smbus_read_byte_data($file, 0x02, NO_CACHE);
> +       return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) !> $status;
> +       $conf = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE);
> +       return if i2c_smbus_read_byte_data($file, 0xff, NO_CACHE) != $conf;
> +
> +       return unless $man_id = 0x4d;  # Maxim
> +       # Bit 5, 3, 1 and 0 should be zero
> +       return unless ($status & 0x2b) = 0x00;
> +       # The 4 lower bits should be zero
> +       return unless ($conf & 0x0f) = 0x00;
> +
> +       return 6;
> +}
> +
>  sub max6655_detect
>  {
>         my ($file, $addr) = @_;

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

  parent reply	other threads:[~2011-05-26  4:09 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 [this message]
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
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=20110526040928.GA27381@ericsson.com \
    --to=guenter.roeck@ericsson.com \
    --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.