18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Definitions for DDR memories based on JEDEC specs 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2012 Texas Instruments, Inc. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Aneesh V <aneesh@ti.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci#ifndef __JEDEC_DDR_H 108c2ecf20Sopenharmony_ci#define __JEDEC_DDR_H 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/types.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* DDR Densities */ 158c2ecf20Sopenharmony_ci#define DDR_DENSITY_64Mb 1 168c2ecf20Sopenharmony_ci#define DDR_DENSITY_128Mb 2 178c2ecf20Sopenharmony_ci#define DDR_DENSITY_256Mb 3 188c2ecf20Sopenharmony_ci#define DDR_DENSITY_512Mb 4 198c2ecf20Sopenharmony_ci#define DDR_DENSITY_1Gb 5 208c2ecf20Sopenharmony_ci#define DDR_DENSITY_2Gb 6 218c2ecf20Sopenharmony_ci#define DDR_DENSITY_4Gb 7 228c2ecf20Sopenharmony_ci#define DDR_DENSITY_8Gb 8 238c2ecf20Sopenharmony_ci#define DDR_DENSITY_16Gb 9 248c2ecf20Sopenharmony_ci#define DDR_DENSITY_32Gb 10 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* DDR type */ 278c2ecf20Sopenharmony_ci#define DDR_TYPE_DDR2 1 288c2ecf20Sopenharmony_ci#define DDR_TYPE_DDR3 2 298c2ecf20Sopenharmony_ci#define DDR_TYPE_LPDDR2_S4 3 308c2ecf20Sopenharmony_ci#define DDR_TYPE_LPDDR2_S2 4 318c2ecf20Sopenharmony_ci#define DDR_TYPE_LPDDR2_NVM 5 328c2ecf20Sopenharmony_ci#define DDR_TYPE_LPDDR3 6 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* DDR IO width */ 358c2ecf20Sopenharmony_ci#define DDR_IO_WIDTH_4 1 368c2ecf20Sopenharmony_ci#define DDR_IO_WIDTH_8 2 378c2ecf20Sopenharmony_ci#define DDR_IO_WIDTH_16 3 388c2ecf20Sopenharmony_ci#define DDR_IO_WIDTH_32 4 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* Number of Row bits */ 418c2ecf20Sopenharmony_ci#define R9 9 428c2ecf20Sopenharmony_ci#define R10 10 438c2ecf20Sopenharmony_ci#define R11 11 448c2ecf20Sopenharmony_ci#define R12 12 458c2ecf20Sopenharmony_ci#define R13 13 468c2ecf20Sopenharmony_ci#define R14 14 478c2ecf20Sopenharmony_ci#define R15 15 488c2ecf20Sopenharmony_ci#define R16 16 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* Number of Column bits */ 518c2ecf20Sopenharmony_ci#define C7 7 528c2ecf20Sopenharmony_ci#define C8 8 538c2ecf20Sopenharmony_ci#define C9 9 548c2ecf20Sopenharmony_ci#define C10 10 558c2ecf20Sopenharmony_ci#define C11 11 568c2ecf20Sopenharmony_ci#define C12 12 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* Number of Banks */ 598c2ecf20Sopenharmony_ci#define B1 0 608c2ecf20Sopenharmony_ci#define B2 1 618c2ecf20Sopenharmony_ci#define B4 2 628c2ecf20Sopenharmony_ci#define B8 3 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* Refresh rate in nano-seconds */ 658c2ecf20Sopenharmony_ci#define T_REFI_15_6 15600 668c2ecf20Sopenharmony_ci#define T_REFI_7_8 7800 678c2ecf20Sopenharmony_ci#define T_REFI_3_9 3900 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* tRFC values */ 708c2ecf20Sopenharmony_ci#define T_RFC_90 90000 718c2ecf20Sopenharmony_ci#define T_RFC_110 110000 728c2ecf20Sopenharmony_ci#define T_RFC_130 130000 738c2ecf20Sopenharmony_ci#define T_RFC_160 160000 748c2ecf20Sopenharmony_ci#define T_RFC_210 210000 758c2ecf20Sopenharmony_ci#define T_RFC_300 300000 768c2ecf20Sopenharmony_ci#define T_RFC_350 350000 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/* Mode register numbers */ 798c2ecf20Sopenharmony_ci#define DDR_MR0 0 808c2ecf20Sopenharmony_ci#define DDR_MR1 1 818c2ecf20Sopenharmony_ci#define DDR_MR2 2 828c2ecf20Sopenharmony_ci#define DDR_MR3 3 838c2ecf20Sopenharmony_ci#define DDR_MR4 4 848c2ecf20Sopenharmony_ci#define DDR_MR5 5 858c2ecf20Sopenharmony_ci#define DDR_MR6 6 868c2ecf20Sopenharmony_ci#define DDR_MR7 7 878c2ecf20Sopenharmony_ci#define DDR_MR8 8 888c2ecf20Sopenharmony_ci#define DDR_MR9 9 898c2ecf20Sopenharmony_ci#define DDR_MR10 10 908c2ecf20Sopenharmony_ci#define DDR_MR11 11 918c2ecf20Sopenharmony_ci#define DDR_MR16 16 928c2ecf20Sopenharmony_ci#define DDR_MR17 17 938c2ecf20Sopenharmony_ci#define DDR_MR18 18 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/* 968c2ecf20Sopenharmony_ci * LPDDR2 related defines 978c2ecf20Sopenharmony_ci */ 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci/* MR4 register fields */ 1008c2ecf20Sopenharmony_ci#define MR4_SDRAM_REF_RATE_SHIFT 0 1018c2ecf20Sopenharmony_ci#define MR4_SDRAM_REF_RATE_MASK 7 1028c2ecf20Sopenharmony_ci#define MR4_TUF_SHIFT 7 1038c2ecf20Sopenharmony_ci#define MR4_TUF_MASK (1 << 7) 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci/* MR4 SDRAM Refresh Rate field values */ 1068c2ecf20Sopenharmony_ci#define SDRAM_TEMP_NOMINAL 0x3 1078c2ecf20Sopenharmony_ci#define SDRAM_TEMP_RESERVED_4 0x4 1088c2ecf20Sopenharmony_ci#define SDRAM_TEMP_HIGH_DERATE_REFRESH 0x5 1098c2ecf20Sopenharmony_ci#define SDRAM_TEMP_HIGH_DERATE_REFRESH_AND_TIMINGS 0x6 1108c2ecf20Sopenharmony_ci#define SDRAM_TEMP_VERY_HIGH_SHUTDOWN 0x7 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci#define NUM_DDR_ADDR_TABLE_ENTRIES 11 1138c2ecf20Sopenharmony_ci#define NUM_DDR_TIMING_TABLE_ENTRIES 4 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci/* Structure for DDR addressing info from the JEDEC spec */ 1168c2ecf20Sopenharmony_cistruct lpddr2_addressing { 1178c2ecf20Sopenharmony_ci u32 num_banks; 1188c2ecf20Sopenharmony_ci u32 tREFI_ns; 1198c2ecf20Sopenharmony_ci u32 tRFCab_ps; 1208c2ecf20Sopenharmony_ci}; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci/* 1238c2ecf20Sopenharmony_ci * Structure for timings from the LPDDR2 datasheet 1248c2ecf20Sopenharmony_ci * All parameters are in pico seconds(ps) unless explicitly indicated 1258c2ecf20Sopenharmony_ci * with a suffix like tRAS_max_ns below 1268c2ecf20Sopenharmony_ci */ 1278c2ecf20Sopenharmony_cistruct lpddr2_timings { 1288c2ecf20Sopenharmony_ci u32 max_freq; 1298c2ecf20Sopenharmony_ci u32 min_freq; 1308c2ecf20Sopenharmony_ci u32 tRPab; 1318c2ecf20Sopenharmony_ci u32 tRCD; 1328c2ecf20Sopenharmony_ci u32 tWR; 1338c2ecf20Sopenharmony_ci u32 tRAS_min; 1348c2ecf20Sopenharmony_ci u32 tRRD; 1358c2ecf20Sopenharmony_ci u32 tWTR; 1368c2ecf20Sopenharmony_ci u32 tXP; 1378c2ecf20Sopenharmony_ci u32 tRTP; 1388c2ecf20Sopenharmony_ci u32 tCKESR; 1398c2ecf20Sopenharmony_ci u32 tDQSCK_max; 1408c2ecf20Sopenharmony_ci u32 tDQSCK_max_derated; 1418c2ecf20Sopenharmony_ci u32 tFAW; 1428c2ecf20Sopenharmony_ci u32 tZQCS; 1438c2ecf20Sopenharmony_ci u32 tZQCL; 1448c2ecf20Sopenharmony_ci u32 tZQinit; 1458c2ecf20Sopenharmony_ci u32 tRAS_max_ns; 1468c2ecf20Sopenharmony_ci}; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci/* 1498c2ecf20Sopenharmony_ci * Min value for some parameters in terms of number of tCK cycles(nCK) 1508c2ecf20Sopenharmony_ci * Please set to zero parameters that are not valid for a given memory 1518c2ecf20Sopenharmony_ci * type 1528c2ecf20Sopenharmony_ci */ 1538c2ecf20Sopenharmony_cistruct lpddr2_min_tck { 1548c2ecf20Sopenharmony_ci u32 tRPab; 1558c2ecf20Sopenharmony_ci u32 tRCD; 1568c2ecf20Sopenharmony_ci u32 tWR; 1578c2ecf20Sopenharmony_ci u32 tRASmin; 1588c2ecf20Sopenharmony_ci u32 tRRD; 1598c2ecf20Sopenharmony_ci u32 tWTR; 1608c2ecf20Sopenharmony_ci u32 tXP; 1618c2ecf20Sopenharmony_ci u32 tRTP; 1628c2ecf20Sopenharmony_ci u32 tCKE; 1638c2ecf20Sopenharmony_ci u32 tCKESR; 1648c2ecf20Sopenharmony_ci u32 tFAW; 1658c2ecf20Sopenharmony_ci}; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ciextern const struct lpddr2_addressing 1688c2ecf20Sopenharmony_ci lpddr2_jedec_addressing_table[NUM_DDR_ADDR_TABLE_ENTRIES]; 1698c2ecf20Sopenharmony_ciextern const struct lpddr2_timings 1708c2ecf20Sopenharmony_ci lpddr2_jedec_timings[NUM_DDR_TIMING_TABLE_ENTRIES]; 1718c2ecf20Sopenharmony_ciextern const struct lpddr2_min_tck lpddr2_jedec_min_tck; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci/* 1748c2ecf20Sopenharmony_ci * Structure for timings for LPDDR3 based on LPDDR2 plus additional fields. 1758c2ecf20Sopenharmony_ci * All parameters are in pico seconds(ps) excluding max_freq, min_freq which 1768c2ecf20Sopenharmony_ci * are in Hz. 1778c2ecf20Sopenharmony_ci */ 1788c2ecf20Sopenharmony_cistruct lpddr3_timings { 1798c2ecf20Sopenharmony_ci u32 max_freq; 1808c2ecf20Sopenharmony_ci u32 min_freq; 1818c2ecf20Sopenharmony_ci u32 tRFC; 1828c2ecf20Sopenharmony_ci u32 tRRD; 1838c2ecf20Sopenharmony_ci u32 tRPab; 1848c2ecf20Sopenharmony_ci u32 tRPpb; 1858c2ecf20Sopenharmony_ci u32 tRCD; 1868c2ecf20Sopenharmony_ci u32 tRC; 1878c2ecf20Sopenharmony_ci u32 tRAS; 1888c2ecf20Sopenharmony_ci u32 tWTR; 1898c2ecf20Sopenharmony_ci u32 tWR; 1908c2ecf20Sopenharmony_ci u32 tRTP; 1918c2ecf20Sopenharmony_ci u32 tW2W_C2C; 1928c2ecf20Sopenharmony_ci u32 tR2R_C2C; 1938c2ecf20Sopenharmony_ci u32 tWL; 1948c2ecf20Sopenharmony_ci u32 tDQSCK; 1958c2ecf20Sopenharmony_ci u32 tRL; 1968c2ecf20Sopenharmony_ci u32 tFAW; 1978c2ecf20Sopenharmony_ci u32 tXSR; 1988c2ecf20Sopenharmony_ci u32 tXP; 1998c2ecf20Sopenharmony_ci u32 tCKE; 2008c2ecf20Sopenharmony_ci u32 tCKESR; 2018c2ecf20Sopenharmony_ci u32 tMRD; 2028c2ecf20Sopenharmony_ci}; 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci/* 2058c2ecf20Sopenharmony_ci * Min value for some parameters in terms of number of tCK cycles(nCK) 2068c2ecf20Sopenharmony_ci * Please set to zero parameters that are not valid for a given memory 2078c2ecf20Sopenharmony_ci * type 2088c2ecf20Sopenharmony_ci */ 2098c2ecf20Sopenharmony_cistruct lpddr3_min_tck { 2108c2ecf20Sopenharmony_ci u32 tRFC; 2118c2ecf20Sopenharmony_ci u32 tRRD; 2128c2ecf20Sopenharmony_ci u32 tRPab; 2138c2ecf20Sopenharmony_ci u32 tRPpb; 2148c2ecf20Sopenharmony_ci u32 tRCD; 2158c2ecf20Sopenharmony_ci u32 tRC; 2168c2ecf20Sopenharmony_ci u32 tRAS; 2178c2ecf20Sopenharmony_ci u32 tWTR; 2188c2ecf20Sopenharmony_ci u32 tWR; 2198c2ecf20Sopenharmony_ci u32 tRTP; 2208c2ecf20Sopenharmony_ci u32 tW2W_C2C; 2218c2ecf20Sopenharmony_ci u32 tR2R_C2C; 2228c2ecf20Sopenharmony_ci u32 tWL; 2238c2ecf20Sopenharmony_ci u32 tDQSCK; 2248c2ecf20Sopenharmony_ci u32 tRL; 2258c2ecf20Sopenharmony_ci u32 tFAW; 2268c2ecf20Sopenharmony_ci u32 tXSR; 2278c2ecf20Sopenharmony_ci u32 tXP; 2288c2ecf20Sopenharmony_ci u32 tCKE; 2298c2ecf20Sopenharmony_ci u32 tCKESR; 2308c2ecf20Sopenharmony_ci u32 tMRD; 2318c2ecf20Sopenharmony_ci}; 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci#endif /* __JEDEC_DDR_H */ 234