blob: 8019ffe3d3f50db9480999777b95af2640c8e743 [file] [log] [blame]
Sricharanbb772a52011-11-15 09:50:00 -05001/*
2 * EMIF programming
3 *
4 * (C) Copyright 2010
5 * Texas Instruments, <www.ti.com>
6 *
7 * Aneesh V <aneesh@ti.com> for OMAP4
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27
28#include <common.h>
29#include <asm/emif.h>
30#include <asm/arch/sys_proto.h>
31#include <asm/utils.h>
32
33#ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
34#define print_timing_reg(reg) debug(#reg" - 0x%08x\n", (reg))
35static u32 *const T_num = (u32 *)OMAP5_SRAM_SCRATCH_EMIF_T_NUM;
36static u32 *const T_den = (u32 *)OMAP5_SRAM_SCRATCH_EMIF_T_DEN;
37static u32 *const emif_sizes = (u32 *)OMAP5_SRAM_SCRATCH_EMIF_SIZE;
38#endif
39
40#ifdef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
41/* Base AC Timing values specified by JESD209-2 for 532MHz operation */
42static const struct lpddr2_ac_timings timings_jedec_532_mhz = {
43 .max_freq = 532000000,
44 .RL = 8,
45 .tRPab = 21,
46 .tRCD = 18,
47 .tWR = 15,
48 .tRASmin = 42,
49 .tRRD = 10,
50 .tWTRx2 = 15,
51 .tXSR = 140,
52 .tXPx2 = 15,
53 .tRFCab = 130,
54 .tRTPx2 = 15,
55 .tCKE = 3,
56 .tCKESR = 15,
57 .tZQCS = 90,
58 .tZQCL = 360,
59 .tZQINIT = 1000,
60 .tDQSCKMAXx2 = 11,
61 .tRASmax = 70,
62 .tFAW = 50
63};
64
65/*
66 * Min tCK values specified by JESD209-2
67 * Min tCK specifies the minimum duration of some AC timing parameters in terms
68 * of the number of cycles. If the calculated number of cycles based on the
69 * absolute time value is less than the min tCK value, min tCK value should
70 * be used instead. This typically happens at low frequencies.
71 */
72static const struct lpddr2_min_tck min_tck_jedec = {
73 .tRL = 3,
74 .tRP_AB = 3,
75 .tRCD = 3,
76 .tWR = 3,
77 .tRAS_MIN = 3,
78 .tRRD = 2,
79 .tWTR = 2,
80 .tXP = 2,
81 .tRTP = 2,
82 .tCKE = 3,
83 .tCKESR = 3,
84 .tFAW = 8
85};
86
87static const struct lpddr2_ac_timings const*
88 jedec_ac_timings[MAX_NUM_SPEEDBINS] = {
89 &timings_jedec_532_mhz
90};
91
92static const struct lpddr2_device_timings jedec_default_timings = {
93 .ac_timings = jedec_ac_timings,
94 .min_tck = &min_tck_jedec
95};
96
97void emif_get_device_timings(u32 emif_nr,
98 const struct lpddr2_device_timings **cs0_device_timings,
99 const struct lpddr2_device_timings **cs1_device_timings)
100{
101 /* Assume Identical devices on EMIF1 & EMIF2 */
102 *cs0_device_timings = &jedec_default_timings;
103 *cs1_device_timings = NULL;
104}
105#endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */