Combination of several commits from Chromium tree: 3b875a2 [Lars: Update Memory ID for DVT board] b6d7c63 [Lili: Update Memory IDs] f203f99 [Lili: Add new SPD for Hynix H9CCNNN8GTALAR-NUD] a6571bf [Lili: Update Memory IDs] 80e1841 [Lili: Update Memory IDs] 58d4487 [Lili: Fix memory string show error in spd data] These commits bring lars' SPD data in line with the Chromium tree. Original-Change-Id: I54d0e6d2bbe86d5dc2ee5825f332d36abfa99084 Original-Change-Id: I9431393f369a1d2870bdabba1fc55d9cefae5c39 Original-Change-Id: I3b325a1801f49109429eb647d8d98a5537ce1b7b Original-Change-Id: Ie8a32d8a26ea1054e2df8432084a95d1cb03f991 Original-Change-Id: I64c73950e3bea57b6c5a90257211b3d6d7f1baab Original-Change-Id: I0e425fa4f0bae544680d5522c2e05a4f7a3be95a Original-Signed-off-by: David Wu <David_Wu@quantatw.com> Original-Signed-off-by: Ren Kuo <Ren.Kuo@quantatw.com> Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Original-Reviewed-by: Duncan Laurie <dlaurie@google.com> Original-Tested-by: David Wu <david_wu@quantatw.com> Original-Tested-by: Ren Kuo <ren.kuo@quanta.corp-partner.google.com> Change-Id: I7cc9b01012b0b9ed72804192bb5953243fc859b4 Signed-off-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-on: https://review.coreboot.org/23569 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
121 lines
3.8 KiB
C
121 lines
3.8 KiB
C
/*
|
|
* This file is part of the coreboot project.
|
|
*
|
|
* Copyright (C) 2014 Google Inc.
|
|
* Copyright (C) 2015 Intel Corporation.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; version 2 of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include <arch/byteorder.h>
|
|
#include <cbfs.h>
|
|
#include <console/console.h>
|
|
#include <soc/pei_data.h>
|
|
#include <soc/romstage.h>
|
|
#include <string.h>
|
|
|
|
#include "spd.h"
|
|
|
|
static void mainboard_print_spd_info(uint8_t spd[])
|
|
{
|
|
const int spd_banks[8] = { 8, 16, 32, 64, -1, -1, -1, -1 };
|
|
const int spd_capmb[8] = { 1, 2, 4, 8, 16, 32, 64, 0 };
|
|
const int spd_rows[8] = { 12, 13, 14, 15, 16, -1, -1, -1 };
|
|
const int spd_cols[8] = { 9, 10, 11, 12, -1, -1, -1, -1 };
|
|
const int spd_ranks[8] = { 1, 2, 3, 4, -1, -1, -1, -1 };
|
|
const int spd_devw[8] = { 4, 8, 16, 32, -1, -1, -1, -1 };
|
|
const int spd_busw[8] = { 8, 16, 32, 64, -1, -1, -1, -1 };
|
|
char spd_name[SPD_PART_LEN+1] = { 0 };
|
|
|
|
int banks = spd_banks[(spd[SPD_DENSITY_BANKS] >> 4) & 7];
|
|
int capmb = spd_capmb[spd[SPD_DENSITY_BANKS] & 7] * 256;
|
|
int rows = spd_rows[(spd[SPD_ADDRESSING] >> 3) & 7];
|
|
int cols = spd_cols[spd[SPD_ADDRESSING] & 7];
|
|
int ranks = spd_ranks[(spd[SPD_ORGANIZATION] >> 3) & 7];
|
|
int devw = spd_devw[spd[SPD_ORGANIZATION] & 7];
|
|
int busw = spd_busw[spd[SPD_BUS_DEV_WIDTH] & 7];
|
|
|
|
/* Module type */
|
|
printk(BIOS_INFO, "SPD: module type is ");
|
|
switch (spd[SPD_DRAM_TYPE]) {
|
|
case SPD_DRAM_DDR3:
|
|
printk(BIOS_INFO, "DDR3\n");
|
|
break;
|
|
case SPD_DRAM_LPDDR3:
|
|
printk(BIOS_INFO, "LPDDR3\n");
|
|
break;
|
|
default:
|
|
printk(BIOS_INFO, "Unknown (%02x)\n", spd[SPD_DRAM_TYPE]);
|
|
break;
|
|
}
|
|
|
|
/* Module Part Number */
|
|
memcpy(spd_name, &spd[SPD_PART_OFF], SPD_PART_LEN);
|
|
spd_name[SPD_PART_LEN] = 0;
|
|
printk(BIOS_INFO, "SPD: module part is %s\n", spd_name);
|
|
|
|
printk(BIOS_INFO,
|
|
"SPD: banks %d, ranks %d, rows %d, columns %d, density %d Mb\n",
|
|
banks, ranks, rows, cols, capmb);
|
|
printk(BIOS_INFO, "SPD: device width %d bits, bus width %d bits\n",
|
|
devw, busw);
|
|
|
|
if (capmb > 0 && busw > 0 && devw > 0 && ranks > 0) {
|
|
/* SIZE = DENSITY / 8 * BUS_WIDTH / SDRAM_WIDTH * RANKS */
|
|
printk(BIOS_INFO, "SPD: module size is %u MB (per channel)\n",
|
|
capmb / 8 * busw / devw * ranks);
|
|
}
|
|
}
|
|
|
|
/* Copy SPD data for on-board memory */
|
|
void mainboard_fill_spd_data(struct pei_data *pei_data)
|
|
{
|
|
char *spd_file;
|
|
size_t spd_file_len;
|
|
int spd_index, spd_span;
|
|
|
|
|
|
spd_index = pei_data->mem_cfg_id;
|
|
printk(BIOS_INFO, "SPD index %d\n", spd_index);
|
|
|
|
/* Load SPD data from CBFS */
|
|
spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD,
|
|
&spd_file_len);
|
|
if (!spd_file)
|
|
die("SPD data not found.");
|
|
|
|
/* make sure we have at least one SPD in the file. */
|
|
if (spd_file_len < SPD_LEN)
|
|
die("Missing SPD data.");
|
|
|
|
/* Make sure we did not overrun the buffer */
|
|
if (spd_file_len < ((spd_index + 1) * SPD_LEN)) {
|
|
printk(BIOS_ERR, "SPD index override to 0 - old hardware?\n");
|
|
spd_index = 0;
|
|
}
|
|
|
|
/* Assume same memory in both channels */
|
|
spd_span = spd_index * SPD_LEN;
|
|
memcpy(pei_data->spd_data[0][0], spd_file + spd_span, SPD_LEN);
|
|
|
|
if (spd_index != MEM_SINGLE_CHAN0 && spd_index != MEM_SINGLE_CHAN3
|
|
&& spd_index != MEM_SINGLE_CHAN4 && spd_index != MEM_SINGLE_CHAN7
|
|
&& spd_index != MEM_SINGLE_CHANB && spd_index != MEM_SINGLE_CHANC) {
|
|
memcpy(pei_data->spd_data[1][0], spd_file + spd_span, SPD_LEN);
|
|
printk(BIOS_INFO, "Dual channel SPD detected writing second channel\n");
|
|
}
|
|
|
|
/* Make sure a valid SPD was found */
|
|
if (pei_data->spd_data[0][0][0] == 0)
|
|
die("Invalid SPD data.");
|
|
|
|
mainboard_print_spd_info(pei_data->spd_data[0][0]);
|
|
}
|