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: DDR3 SPD EEPROM support
Date: Tue, 15 Feb 2011 01:23:52 +0000	[thread overview]
Message-ID: <20110215012352.GA28194@ericsson.com> (raw)
In-Reply-To: <4D54FC00.1010600@ladisch.de>

On Fri, Feb 11, 2011 at 04:06:08AM -0500, Clemens Ladisch wrote:
> This adds CRC-16 calculation, needed to correctly detect DDR3 SPD EEPROMs.
> 
For DDR3: Tested-by: Guenter Roeck <guenter.roeck@ericsson.com>

> --- a/prog/detect/sensors-detect
> +++ b/prog/detect/sensors-detect
> @@ -5265,18 +5265,43 @@
>  
>  # Registers used:
>  #   0-63: SPD Data and Checksum
> +#   0-127: SPD data and CRC (DDR3)
>  sub eeprom_detect
>  {
>  	my ($file, $addr) = @_;
> +	my $device_type = i2c_smbus_read_byte_data($file, 2);
>  	my $checksum = 0;
>  
>  	# Check the checksum for validity (works for most DIMMs and RIMMs)
> -	for (my $i = 0; $i <= 62; $i++) {
> -		$checksum += i2c_smbus_read_byte_data($file, $i);
> +	if ($device_type >= 1 and $device_type <= 10) {
> +		for (my $i = 0; $i <= 62; $i++) {
> +			$checksum += i2c_smbus_read_byte_data($file, $i);
> +		}
> +		$checksum &= 255;
> +
> +		return 8 if $checksum = i2c_smbus_read_byte_data($file, 63);
> +	} elsif ($device_type = 11) {
> +		# see JEDEC 21-C 4.1.2.11 2.4
> +		my $crc_coverage = i2c_smbus_read_byte_data($file, 0);
> +		$crc_coverage = ($crc_coverage & 0x80) ? 117 : 126;
> +		for (my $i = 0; $i < $crc_coverage; $i++) {
> +			$checksum ^= i2c_smbus_read_byte_data($file, $i) << 8;
> +			for (my $bit = 0; $bit < 8; $bit++) {
> +				if ($checksum & 0x8000) {
> +					$checksum = ($checksum << 1) ^ 0x1021;
> +				} else {
> +					$checksum <<= 1;
> +				}
> +			}
> +		}
> +		$checksum &= 0xffff;
> +
> +		return 8 if ($checksum & 0xff) = i2c_smbus_read_byte_data($file, 126) and
> +			    ($checksum >> 8) = i2c_smbus_read_byte_data($file, 127);
> +
> +		# note: if bit 7 of byte 32 is set, a jc42 sensor is at $addr-0x38
>  	}
> -	$checksum &= 255;
>  
> -	return 8 if $checksum = i2c_smbus_read_byte_data($file, 63);
>  	return;
>  }
>  
> 
> _______________________________________________
> lm-sensors mailing list
> lm-sensors@lm-sensors.org
> http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

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

  reply	other threads:[~2011-02-15  1:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-11  9:06 [lm-sensors] [PATCH] sensors-detect: DDR3 SPD EEPROM support Clemens Ladisch
2011-02-15  1:23 ` Guenter Roeck [this message]
2011-02-16 15:11 ` Jean Delvare
2011-02-16 15:25 ` Clemens Ladisch

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=20110215012352.GA28194@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.