blob: 8d8a8b870ca507f9fb8e43b08cfac94daea883c7 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Arthur Heymansfc31e442018-02-12 15:12:34 +01002
3#ifndef DEVICE_DRAM_COMMON_H
4#define DEVICE_DRAM_COMMON_H
5
Elyes HAOUASbec78e32019-10-20 19:39:20 +02006#include <console/console.h>
Elyes HAOUAS749c3952019-10-20 19:55:56 +02007#include <stdint.h>
8
Arthur Heymansfc31e442018-02-12 15:12:34 +01009/**
10 * \brief Convenience definitions for TCK values
11 *
12 * Different values for tCK, representing standard DDR3 frequencies.
13 * These values are in 1/256 ns units.
14 * @{
15 */
16#define NS2MHZ_DIV256 (1000 << 8)
17
18#define TCK_1333MHZ 192
19#define TCK_1200MHZ 212
20#define TCK_1100MHZ 232
21#define TCK_1066MHZ 240
22#define TCK_1000MHZ 256
23#define TCK_933MHZ 274
24#define TCK_900MHZ 284
25#define TCK_800MHZ 320
26#define TCK_700MHZ 365
27#define TCK_666MHZ 384
28#define TCK_533MHZ 480
29#define TCK_400MHZ 640
30#define TCK_333MHZ 768
31#define TCK_266MHZ 960
32#define TCK_200MHZ 1280
33/** @} */
34
35/**
Martin Rothf48acbd2020-07-24 12:24:27 -060036 * \brief Convenience macro for enabling printk with CONFIG(DEBUG_RAM_SETUP)
Arthur Heymansfc31e442018-02-12 15:12:34 +010037 *
38 * Use this macro instead of printk(); for verbose RAM initialization messages.
Martin Rothf48acbd2020-07-24 12:24:27 -060039 * When CONFIG(DEBUG_RAM_SETUP) is not selected, these messages are automatically
Arthur Heymansfc31e442018-02-12 15:12:34 +010040 * disabled.
41 * @{
42 */
Arthur Heymans4beeb902022-03-23 22:47:06 +010043#define printram(x, ...) \
44 do { \
45 if (CONFIG(DEBUG_RAM_SETUP)) \
46 printk(BIOS_DEBUG, x, ##__VA_ARGS__); \
47 } while (0)
Arthur Heymansfc31e442018-02-12 15:12:34 +010048/** @} */
49
50/** Result of the SPD decoding process */
51enum spd_status {
52 SPD_STATUS_OK = 0,
53 SPD_STATUS_INVALID,
54 SPD_STATUS_CRC_ERROR,
55 SPD_STATUS_INVALID_FIELD,
56};
57
Andrey Petrov3f85edb2019-08-01 14:18:06 -070058u16 ddr_crc16(const u8 *ptr, int n_crc);
Arthur Heymans97b337b2018-01-22 01:26:53 +010059
Arthur Heymansfc31e442018-02-12 15:12:34 +010060#endif /* DEVICE_DRAM_COMMON_H */