blob: 5b0d3b5c78a0b06c13747047eebf4e486f88ec58 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Sricharan62a86502011-11-15 09:50:00 -05002/*
3 * EMIF programming
4 *
5 * (C) Copyright 2010
6 * Texas Instruments, <www.ti.com>
7 *
8 * Aneesh V <aneesh@ti.com>
Sricharan62a86502011-11-15 09:50:00 -05009 */
10
Sricharan62a86502011-11-15 09:50:00 -050011#include <asm/emif.h>
12#include <asm/arch/sys_proto.h>
13#include <asm/utils.h>
14
15#ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
SRICHARAN R4b1b61c2013-04-24 00:41:22 +000016u32 *const T_num = (u32 *)OMAP_SRAM_SCRATCH_EMIF_T_NUM;
17u32 *const T_den = (u32 *)OMAP_SRAM_SCRATCH_EMIF_T_DEN;
Sricharan62a86502011-11-15 09:50:00 -050018#endif
19
20#ifdef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
21/* Base AC Timing values specified by JESD209-2 for 400MHz operation */
22static const struct lpddr2_ac_timings timings_jedec_400_mhz = {
23 .max_freq = 400000000,
24 .RL = 6,
25 .tRPab = 21,
26 .tRCD = 18,
27 .tWR = 15,
28 .tRASmin = 42,
29 .tRRD = 10,
30 .tWTRx2 = 15,
31 .tXSR = 140,
32 .tXPx2 = 15,
33 .tRFCab = 130,
34 .tRTPx2 = 15,
35 .tCKE = 3,
36 .tCKESR = 15,
37 .tZQCS = 90,
38 .tZQCL = 360,
39 .tZQINIT = 1000,
40 .tDQSCKMAXx2 = 11,
41 .tRASmax = 70,
42 .tFAW = 50
43};
44
45/* Base AC Timing values specified by JESD209-2 for 200 MHz operation */
46static const struct lpddr2_ac_timings timings_jedec_200_mhz = {
47 .max_freq = 200000000,
48 .RL = 3,
49 .tRPab = 21,
50 .tRCD = 18,
51 .tWR = 15,
52 .tRASmin = 42,
53 .tRRD = 10,
54 .tWTRx2 = 20,
55 .tXSR = 140,
56 .tXPx2 = 15,
57 .tRFCab = 130,
58 .tRTPx2 = 15,
59 .tCKE = 3,
60 .tCKESR = 15,
61 .tZQCS = 90,
62 .tZQCL = 360,
63 .tZQINIT = 1000,
64 .tDQSCKMAXx2 = 11,
65 .tRASmax = 70,
66 .tFAW = 50
67};
68
69/*
70 * Min tCK values specified by JESD209-2
71 * Min tCK specifies the minimum duration of some AC timing parameters in terms
72 * of the number of cycles. If the calculated number of cycles based on the
73 * absolute time value is less than the min tCK value, min tCK value should
74 * be used instead. This typically happens at low frequencies.
75 */
76static const struct lpddr2_min_tck min_tck_jedec = {
77 .tRL = 3,
78 .tRP_AB = 3,
79 .tRCD = 3,
80 .tWR = 3,
81 .tRAS_MIN = 3,
82 .tRRD = 2,
83 .tWTR = 2,
84 .tXP = 2,
85 .tRTP = 2,
86 .tCKE = 3,
87 .tCKESR = 3,
88 .tFAW = 8
89};
90
Bin Meng6b453882018-02-12 17:54:36 +080091static const struct lpddr2_ac_timings *jedec_ac_timings[MAX_NUM_SPEEDBINS] = {
Sricharan62a86502011-11-15 09:50:00 -050092 &timings_jedec_200_mhz,
93 &timings_jedec_400_mhz
94};
95
Paul Kocialkowskiebb7b9f2016-02-27 19:18:55 +010096const struct lpddr2_device_timings jedec_default_timings = {
Sricharan62a86502011-11-15 09:50:00 -050097 .ac_timings = jedec_ac_timings,
98 .min_tck = &min_tck_jedec
99};
100
101void emif_get_device_timings(u32 emif_nr,
102 const struct lpddr2_device_timings **cs0_device_timings,
103 const struct lpddr2_device_timings **cs1_device_timings)
104{
105 /* Assume Identical devices on EMIF1 & EMIF2 */
106 *cs0_device_timings = &jedec_default_timings;
107 *cs1_device_timings = &jedec_default_timings;
108}
109#endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */