mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: Alexander Smirnov <alllecs@yandex.ru>
Cc: barebox@lists.infradead.org
Subject: Re: [RFC V4 2/3] ddr_spd: add routune for printing SPD contents in human readable format
Date: Thu, 2 Jul 2015 12:09:16 +0300	[thread overview]
Message-ID: <20150702120916.b6082f00f7ae0186670d065a@gmail.com> (raw)
In-Reply-To: <1435827017-1999-3-git-send-email-alllecs@yandex.ru>

On Thu,  2 Jul 2015 11:50:16 +0300
Alexander Smirnov <alllecs@yandex.ru> wrote:

> Signed-off-by: Alexander Smirnov <alllecs@yandex.ru>
> ---
>  common/ddr_spd.c  | 290 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/ddr_spd.h |   1 +
>  2 files changed, 291 insertions(+)
> 
> diff --git a/common/ddr_spd.c b/common/ddr_spd.c
> index ea0b529..6757d58 100644
> --- a/common/ddr_spd.c
> +++ b/common/ddr_spd.c
> @@ -61,3 +61,293 @@ uint32_t ddr3_spd_checksum_pass(const struct ddr3_spd_eeprom_s *spd)
>  
>  	return 0;
>  }
> +
> +static char *heights[] = {
> +	"<25.4",
> +	"25.4",
> +	"25.4 - 30.0",
> +	"30.0",
> +	"30.5",
> +	"> 30.5",
> +};
> +
> +static char *sdram_voltage_interface_level[] = {
> +	"TTL (5V tolerant)",
> +	"LVTTL (not 5V tolerant)",
> +	"HSTL 1.5V",
> +	"SSTL 3.3V",
> +	"SSTL 2.5V",
> +	"SSTL 1.8V",
> +};
> +
> +static char *ddr2_module_types[] = {
> +	"RDIMM (133.35 mm)",
> +	"UDIMM (133.25 mm)",
> +	"SO-DIMM (67.6 mm)",
> +	"Micro-DIMM (45.5 mm)",
> +	"Mini-RDIMM (82.0 mm)",
> +	"Mini-UDIMM (82.0 mm)",
> +};
> +
> +static char *refresh[] = {
> +	"15.625",
> +	"3.9",
> +	"7.8",
> +	"31.3",
> +	"62.5",
> +	"125",
> +};
> +
> +static char *type_list[] = {
> +	"Reserved",
> +	"FPM DRAM",
> +	"EDO",
> +	"Pipelined Nibble",
> +	"SDR SDRAM",
> +	"Multiplexed ROM",
> +	"DDR SGRAM",
> +	"DDR SDRAM",
> +	[SPD_MEMTYPE_DDR2] = "DDR2 SDRAM",
> +	"FB-DIMM",
> +	"FB-DIMM Probe",
> +	[SPD_MEMTYPE_DDR3] = "DDR3 SDRAM",
> +};
> +
> +static int funct(uint8_t addr)
> +{
> +	int t;
> +
> +	t = ((addr >> 4) * 10 + (addr & 0xf));
> +
> +	return t;
> +}
> +
> +static int des(uint8_t byte)
> +{
> +	int k;
> +
> +	k = (byte & 0x3) * 10 / 4;
> +
> +	return k;
> +}
> +
> +static int integ(uint8_t byte)
> +{
> +	int k;
> +
> +	k = (byte >> 2);
> +
> +	return k;
> +}
> +
> +static int ddr2_sdram_ctime(uint8_t byte)
> +{
> +	int ctime;
> +
> +	ctime = (byte >> 4) * 100;
> +	if ((byte & 0xf) <= 9)
> +		ctime += (byte & 0xf) * 10;
> +	else if ((byte & 0xf) == 10)
> +		ctime += 25;
> +	else if ((byte & 0xf) == 11)
> +		ctime += 33;
> +	else if ((byte & 0xf) == 12)
> +		ctime += 66;
> +	else if ((byte & 0xf) == 13)
> +		ctime += 75;
> +
> +	return ctime;
> +}
> +
> +void ddr_spd_print(uint8_t *record)
> +{
> +	int highestCAS = 0;
> +	int cas[256];
> +	int i, i_i, k, x, y;
> +	int ddrclk, tbits, pcclk;
> +	int trcd, trp, tras;
> +	int ctime;
> +	uint8_t parity;
> +	char *ref, *sum;
> +	struct ddr2_spd_eeprom_s *s = (struct ddr2_spd_eeprom_s *)record;
> +
> +	ctime = ddr2_sdram_ctime(s->clk_cycle);
> +	ddrclk = 2 * (1000 / ctime) * 100;
> +	tbits = (s->res_7 << 8) + (s->dataw);
> +	if ((s->config & 0x03) == 1)
> +		tbits = tbits - 8;
> +
> +	pcclk = ddrclk * tbits / 8;
> +	pcclk = pcclk - (pcclk % 100);
> +	i_i = (s->nrow_addr & 0x0f) + (s->ncol_addr & 0x0f) - 17;
> +	k = ((s->mod_ranks & 0x7) + 1) * s->nbanks;
> +	trcd = ((s->trcd >> 2) + ((s->trcd & 3) * 0.25)) / ctime * 100;
> +	trp = ((s->trp >> 2) + ((s->trp & 3) * 0.25)) / ctime * 100;
> +	tras = s->tras * 100 / ctime ;
> +	x = (int)(ctime / 100);
> +	y = (ctime - (int)((ctime / 100) * 100)) / 10;
> +
> +	for (i_i = 2; i_i < 7; i_i++) {
> +		if (s->cas_lat & 1 << i_i) {
> +			highestCAS = i_i;
> +			cas[highestCAS]++;
> +		}
> +	}
> +
> +	if (ddr2_spd_checksum_pass(s))
> +		sum = "ERR";
> +	else
> +		sum = "OK";
> +

Please check mem_type here too. You use ddr2_spd_checksum_pass() for any type memory.

> +	printf("---=== SPD EEPROM Information ===---\n");
> +	printf("%-50s %s (0x%0X)\n", "EEPROM Checksum of bytes 0-62",
> +		sum, s->cksum);
> +	printf("%-50s %d\n", "# of bytes written to SDRAM EEPROM",
> +		s->info_size);
> +	printf("%-50s %d\n", "Total number of bytes in EEPROM",
> +		1 << (s->chip_size));
> +
> +	if (s->mem_type < ARRAY_SIZE(type_list))
> +		printf("%-50s %s\n", "Fundamental Memory type",
> +			type_list[s->mem_type]);
> +	else
> +		printf("%-50s (%02x)\n", "Warning: unknown memory type",
> +			s->mem_type);
> +
> +	printf("%-50s %x.%x\n", "SPD Revision", s->spd_rev >> 4,
> +		s->spd_rev & 0x0f);
> +	if (s->mem_type != SPD_MEMTYPE_DDR2) {
> +		printf("Can't dump extended information for non-DDR2 memory\n");
> +		return;
> +	}
> +
> +	printf("\n---=== Memory Characteristics ===---\n");
> +	printf("%-50s %d MHz (PC2-%d)\n", "Maximum module speed",
> +		ddrclk, pcclk);
> +	if (i_i > 0 && i_i <= 12 && k > 0)
> +		printf("%-50s %d MB\n", "Size", (1 << i_i) * k);
> +	else
> +		printf("%-50s INVALID: %02x %02x %02x %02x\n", "Size",
> +			s->nrow_addr, s->ncol_addr, s->mod_ranks, s->nbanks);
> +
> +	printf("%-50s %d x %d x %d x %d\n", "Banks x Rows x Columns x Bits",
> +		s->nbanks, s->nrow_addr, s->ncol_addr, s->dataw);
> +	printf("%-50s %d\n", "Ranks", (s->mod_ranks & 0x7) + 1);
> +	printf("%-50s %d bits\n", "SDRAM Device Width", s->primw);
> +
> +	if (s->mod_ranks >> 5 < ARRAY_SIZE(heights))
> +		printf("%-50s %s mm\n", "Module Height",
> +			heights[s->mod_ranks >> 5]);
> +	else
> +		printf("Error height\n");
> +
> +	if ((fls(s->dimm_type) - 1) < ARRAY_SIZE(ddr2_module_types))
> +		printf("%-50s %s\n", "Module Type",
> +			ddr2_module_types[fls(s->dimm_type) - 1]);
> +	else
> +		printf("Error module type\n");
> +
> +	printf("%-50s ", "DRAM Package ");
> +	if ((s->mod_ranks & 0x10) == 1)
> +		printf("Stack\n");
> +	else
> +		printf("Planar\n");
> +	if (s->voltage < 7)

use ARRAY_SIZE here

-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2015-07-02  9:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-02  8:50 [RFC V4 0/3] add decode command (SPD EEPROM data decoder) Alexander Smirnov
2015-07-02  8:50 ` [RFC V4 1/3] common: move DDR_SPD to common/Kconfig Alexander Smirnov
2015-07-02  8:50 ` [RFC V4 2/3] ddr_spd: add routune for printing SPD contents in human readable format Alexander Smirnov
2015-07-02  9:09   ` Antony Pavlov [this message]
2015-07-03  4:17   ` Sascha Hauer
2015-07-02  8:50 ` [RFC V4 3/3] add decode command (SPD EEPROM data decoder) Alexander Smirnov
2015-07-03  4:16   ` Sascha Hauer

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=20150702120916.b6082f00f7ae0186670d065a@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=alllecs@yandex.ru \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox