blob: d1ee6f775c6013813c0fc96e29bcf21fa6a85ddd [file] [log] [blame]
Angel Pons32859fc2020-04-02 23:48:27 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Naresh G Solanki335781a2016-10-26 19:43:14 +05302
3#ifndef SPD_BIN_H
4#define SPD_BIN_H
5
Naresh G Solanki335781a2016-10-26 19:43:14 +05306#include <stdint.h>
7#include <commonlib/region.h>
8
9#define SPD_PAGE_LEN 256
10#define SPD_PAGE_LEN_DDR4 512
11#define SPD_PAGE_0 (0x6C >> 1)
12#define SPD_PAGE_1 (0x6E >> 1)
13#define SPD_DRAM_TYPE 2
14#define SPD_DRAM_DDR3 0x0B
15#define SPD_DRAM_LPDDR3_INTEL 0xF1
16#define SPD_DRAM_LPDDR3_JEDEC 0x0F
17#define SPD_DRAM_DDR4 0x0C
Eric Laid0ee8702020-03-06 21:18:30 +080018#define SPD_DRAM_LPDDR4 0x10
Eric Laicb1e3862020-03-13 17:16:20 +080019#define SPD_DRAM_LPDDR4X 0x11
20#define SPD_DRAM_DDR5 0x12
21#define SPD_DRAM_LPDDR5 0x13
Naresh G Solanki335781a2016-10-26 19:43:14 +053022#define SPD_DENSITY_BANKS 4
23#define SPD_ADDRESSING 5
Eric Laiaa8d7722019-09-02 15:01:56 +080024#define DDR3_ORGANIZATION 7
25#define DDR3_BUS_DEV_WIDTH 8
26#define DDR4_ORGANIZATION 12
27#define DDR4_BUS_DEV_WIDTH 13
Naresh G Solanki335781a2016-10-26 19:43:14 +053028#define DDR3_SPD_PART_OFF 128
29#define DDR3_SPD_PART_LEN 18
30#define LPDDR3_SPD_PART_OFF 128
31#define LPDDR3_SPD_PART_LEN 18
32#define DDR4_SPD_PART_OFF 329
33#define DDR4_SPD_PART_LEN 20
Naresh G Solanki335781a2016-10-26 19:43:14 +053034
35struct spd_block {
Nico Huber5f9c6732017-06-28 16:42:51 +020036 u8 addr_map[CONFIG_DIMM_MAX]; /* 7 bit I2C addresses */
Naresh G Solanki335781a2016-10-26 19:43:14 +053037 u8 *spd_array[CONFIG_DIMM_MAX];
38 /* Length of each dimm */
39 u16 len;
40};
41
42void print_spd_info(uint8_t spd[]);
43/* Return 0 on success & -1 on failure */
44int get_spd_cbfs_rdev(struct region_device *spd_rdev, u8 spd_index);
45void dump_spd_info(struct spd_block *blk);
46void get_spd_smbus(struct spd_block *blk);
47
Patrick Georgi0e3c59e2017-01-28 15:59:25 +010048/* expects SPD size to be 128 bytes, reads from "spd.bin" in CBFS and
49 verifies the checksum. Only available if CONFIG_DIMM_SPD_SIZE == 128. */
50int read_ddr3_spd_from_cbfs(u8 *buf, int idx);
Naresh G Solanki335781a2016-10-26 19:43:14 +053051#endif