Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Arthur Heymans | fc31e44 | 2018-02-12 15:12:34 +0100 | [diff] [blame] | 2 | |
| 3 | #ifndef DEVICE_DRAM_COMMON_H |
| 4 | #define DEVICE_DRAM_COMMON_H |
| 5 | |
Elyes HAOUAS | bec78e3 | 2019-10-20 19:39:20 +0200 | [diff] [blame] | 6 | #include <console/console.h> |
Elyes HAOUAS | 749c395 | 2019-10-20 19:55:56 +0200 | [diff] [blame] | 7 | #include <stdint.h> |
| 8 | |
Arthur Heymans | fc31e44 | 2018-02-12 15:12:34 +0100 | [diff] [blame] | 9 | /** |
| 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 Roth | f48acbd | 2020-07-24 12:24:27 -0600 | [diff] [blame] | 36 | * \brief Convenience macro for enabling printk with CONFIG(DEBUG_RAM_SETUP) |
Arthur Heymans | fc31e44 | 2018-02-12 15:12:34 +0100 | [diff] [blame] | 37 | * |
| 38 | * Use this macro instead of printk(); for verbose RAM initialization messages. |
Martin Roth | f48acbd | 2020-07-24 12:24:27 -0600 | [diff] [blame] | 39 | * When CONFIG(DEBUG_RAM_SETUP) is not selected, these messages are automatically |
Arthur Heymans | fc31e44 | 2018-02-12 15:12:34 +0100 | [diff] [blame] | 40 | * disabled. |
| 41 | * @{ |
| 42 | */ |
Arthur Heymans | 4beeb90 | 2022-03-23 22:47:06 +0100 | [diff] [blame] | 43 | #define printram(x, ...) \ |
| 44 | do { \ |
| 45 | if (CONFIG(DEBUG_RAM_SETUP)) \ |
| 46 | printk(BIOS_DEBUG, x, ##__VA_ARGS__); \ |
| 47 | } while (0) |
Arthur Heymans | fc31e44 | 2018-02-12 15:12:34 +0100 | [diff] [blame] | 48 | /** @} */ |
| 49 | |
| 50 | /** Result of the SPD decoding process */ |
| 51 | enum spd_status { |
| 52 | SPD_STATUS_OK = 0, |
| 53 | SPD_STATUS_INVALID, |
| 54 | SPD_STATUS_CRC_ERROR, |
| 55 | SPD_STATUS_INVALID_FIELD, |
| 56 | }; |
| 57 | |
Andrey Petrov | 3f85edb | 2019-08-01 14:18:06 -0700 | [diff] [blame] | 58 | u16 ddr_crc16(const u8 *ptr, int n_crc); |
Arthur Heymans | 97b337b | 2018-01-22 01:26:53 +0100 | [diff] [blame] | 59 | |
Arthur Heymans | fc31e44 | 2018-02-12 15:12:34 +0100 | [diff] [blame] | 60 | #endif /* DEVICE_DRAM_COMMON_H */ |