source: SVN/rincon/u-boot/common/ddr_spd.c @ 55

Last change on this file since 55 was 55, checked in by Tim Harvey, 2 years ago

rincon: added latest u-boot source

restored form server backup

Signed-off-by: Tim Harvey <tharvey@…>

File size: 1.2 KB
Line 
1/*
2 * Copyright 2008 Freescale Semiconductor, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * Version 2 as published by the Free Software Foundation.
7 */
8
9#include <common.h>
10#include <ddr_spd.h>
11
12/* used for ddr1 and ddr2 spd */
13static int
14spd_check(const u8 *buf, u8 spd_rev, u8 spd_cksum)
15{
16        unsigned int cksum = 0;
17        unsigned int i;
18
19        /*
20         * Check SPD revision supported
21         * Rev 1.2 or less supported by this code
22         */
23        if (spd_rev > 0x12) {
24                printf("SPD revision %02X not supported by this code\n",
25                       spd_rev);
26                return 1;
27        }
28
29        /*
30         * Calculate checksum
31         */
32        for (i = 0; i < 63; i++) {
33                cksum += *buf++;
34        }
35        cksum &= 0xFF;
36
37        if (cksum != spd_cksum) {
38                printf("SPD checksum unexpected. "
39                        "Checksum in SPD = %02X, computed SPD = %02X\n",
40                        spd_cksum, cksum);
41                return 1;
42        }
43
44        return 0;
45}
46
47unsigned int
48ddr1_spd_check(const ddr1_spd_eeprom_t *spd)
49{
50        const u8 *p = (const u8 *)spd;
51
52        return spd_check(p, spd->spd_rev, spd->cksum);
53}
54
55unsigned int
56ddr2_spd_check(const ddr2_spd_eeprom_t *spd)
57{
58        const u8 *p = (const u8 *)spd;
59
60        return spd_check(p, spd->spd_rev, spd->cksum);
61}
Note: See TracBrowser for help on using the repository browser.