Aneesh V | cc56558 | 2011-07-21 09:10:09 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Timing and Organization details of the Elpida parts used in OMAP4 |
| 3 | * SDPs and Panda |
| 4 | * |
| 5 | * (C) Copyright 2010 |
| 6 | * Texas Instruments, <www.ti.com> |
| 7 | * |
| 8 | * Aneesh V <aneesh@ti.com> |
| 9 | * |
| 10 | * See file CREDITS for list of people who contributed to this |
| 11 | * project. |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or |
| 14 | * modify it under the terms of the GNU General Public License as |
| 15 | * published by the Free Software Foundation; either version 2 of |
| 16 | * the License, or (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program; if not, write to the Free Software |
| 25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 26 | * MA 02111-1307 USA |
| 27 | */ |
| 28 | |
Sricharan | 62a8650 | 2011-11-15 09:50:00 -0500 | [diff] [blame] | 29 | #include <asm/emif.h> |
Aneesh V | cc56558 | 2011-07-21 09:10:09 -0400 | [diff] [blame] | 30 | #include <asm/arch/sys_proto.h> |
| 31 | |
| 32 | /* |
| 33 | * This file provides details of the LPDDR2 SDRAM parts used on OMAP4430 |
| 34 | * SDP and Panda. Since the parts used and geometry are identical for |
| 35 | * SDP and Panda for a given OMAP4 revision, this information is kept |
| 36 | * here instead of being in board directory. However the key functions |
| 37 | * exported are weakly linked so that they can be over-ridden in the board |
| 38 | * directory if there is a OMAP4 board in the future that uses a different |
| 39 | * memory device or geometry. |
| 40 | * |
| 41 | * For any new board with different memory devices over-ride one or more |
| 42 | * of the following functions as per the CONFIG flags you intend to enable: |
| 43 | * - emif_get_reg_dump() |
| 44 | * - emif_get_dmm_regs() |
| 45 | * - emif_get_device_details() |
| 46 | * - emif_get_device_timings() |
| 47 | */ |
| 48 | |
Aneesh V | c0e8852 | 2011-07-21 09:10:12 -0400 | [diff] [blame] | 49 | #ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS |
| 50 | |
Aneesh V | cc56558 | 2011-07-21 09:10:09 -0400 | [diff] [blame] | 51 | static const struct emif_regs emif_regs_elpida_200_mhz_2cs = { |
| 52 | .sdram_config_init = 0x80000eb9, |
| 53 | .sdram_config = 0x80001ab9, |
| 54 | .ref_ctrl = 0x0000030c, |
| 55 | .sdram_tim1 = 0x08648311, |
| 56 | .sdram_tim2 = 0x101b06ca, |
| 57 | .sdram_tim3 = 0x0048a19f, |
| 58 | .read_idle_ctrl = 0x000501ff, |
| 59 | .zq_config = 0x500b3214, |
| 60 | .temp_alert_config = 0xd8016893, |
| 61 | .emif_ddr_phy_ctlr_1_init = 0x049ffff5, |
| 62 | .emif_ddr_phy_ctlr_1 = 0x049ff808 |
| 63 | }; |
| 64 | |
| 65 | static const struct emif_regs emif_regs_elpida_380_mhz_1cs = { |
| 66 | .sdram_config_init = 0x80000eb1, |
| 67 | .sdram_config = 0x80001ab1, |
| 68 | .ref_ctrl = 0x000005cd, |
| 69 | .sdram_tim1 = 0x10cb0622, |
| 70 | .sdram_tim2 = 0x20350d52, |
| 71 | .sdram_tim3 = 0x00b1431f, |
| 72 | .read_idle_ctrl = 0x000501ff, |
| 73 | .zq_config = 0x500b3214, |
| 74 | .temp_alert_config = 0x58016893, |
| 75 | .emif_ddr_phy_ctlr_1_init = 0x049ffff5, |
| 76 | .emif_ddr_phy_ctlr_1 = 0x049ff418 |
| 77 | }; |
| 78 | |
| 79 | const struct emif_regs emif_regs_elpida_400_mhz_2cs = { |
| 80 | .sdram_config_init = 0x80000eb9, |
| 81 | .sdram_config = 0x80001ab9, |
| 82 | .ref_ctrl = 0x00000618, |
| 83 | .sdram_tim1 = 0x10eb0662, |
| 84 | .sdram_tim2 = 0x20370dd2, |
| 85 | .sdram_tim3 = 0x00b1c33f, |
| 86 | .read_idle_ctrl = 0x000501ff, |
| 87 | .zq_config = 0xd00b3214, |
| 88 | .temp_alert_config = 0xd8016893, |
| 89 | .emif_ddr_phy_ctlr_1_init = 0x049ffff5, |
| 90 | .emif_ddr_phy_ctlr_1 = 0x049ff418 |
| 91 | }; |
SRICHARAN R | 3d53496 | 2012-03-12 02:25:37 +0000 | [diff] [blame^] | 92 | |
| 93 | /* Dummy registers for OMAP44xx */ |
| 94 | const u32 ext_phy_ctrl_const_base[EMIF_EXT_PHY_CTRL_CONST_REG]; |
| 95 | |
Aneesh V | cc56558 | 2011-07-21 09:10:09 -0400 | [diff] [blame] | 96 | const struct dmm_lisa_map_regs lisa_map_2G_x_1_x_2 = { |
| 97 | .dmm_lisa_map_0 = 0xFF020100, |
| 98 | .dmm_lisa_map_1 = 0, |
| 99 | .dmm_lisa_map_2 = 0, |
| 100 | .dmm_lisa_map_3 = 0x80540300 |
| 101 | }; |
| 102 | |
| 103 | const struct dmm_lisa_map_regs lisa_map_2G_x_2_x_2 = { |
| 104 | .dmm_lisa_map_0 = 0xFF020100, |
| 105 | .dmm_lisa_map_1 = 0, |
| 106 | .dmm_lisa_map_2 = 0, |
| 107 | .dmm_lisa_map_3 = 0x80640300 |
| 108 | }; |
| 109 | |
| 110 | static void emif_get_reg_dump_sdp(u32 emif_nr, const struct emif_regs **regs) |
| 111 | { |
| 112 | u32 omap4_rev = omap_revision(); |
| 113 | |
| 114 | /* Same devices and geometry on both EMIFs */ |
| 115 | if (omap4_rev == OMAP4430_ES1_0) |
| 116 | *regs = &emif_regs_elpida_380_mhz_1cs; |
| 117 | else if (omap4_rev == OMAP4430_ES2_0) |
| 118 | *regs = &emif_regs_elpida_200_mhz_2cs; |
| 119 | else |
| 120 | *regs = &emif_regs_elpida_400_mhz_2cs; |
| 121 | } |
| 122 | void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs) |
| 123 | __attribute__((weak, alias("emif_get_reg_dump_sdp"))); |
| 124 | |
| 125 | static void emif_get_dmm_regs_sdp(const struct dmm_lisa_map_regs |
| 126 | **dmm_lisa_regs) |
| 127 | { |
| 128 | u32 omap_rev = omap_revision(); |
| 129 | |
| 130 | if (omap_rev == OMAP4430_ES1_0) |
| 131 | *dmm_lisa_regs = &lisa_map_2G_x_1_x_2; |
| 132 | else |
| 133 | *dmm_lisa_regs = &lisa_map_2G_x_2_x_2; |
| 134 | } |
| 135 | |
| 136 | void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs) |
| 137 | __attribute__((weak, alias("emif_get_dmm_regs_sdp"))); |
Aneesh V | c0e8852 | 2011-07-21 09:10:12 -0400 | [diff] [blame] | 138 | |
| 139 | #else |
| 140 | |
| 141 | static const struct lpddr2_device_details elpida_2G_S4_details = { |
| 142 | .type = LPDDR2_TYPE_S4, |
| 143 | .density = LPDDR2_DENSITY_2Gb, |
| 144 | .io_width = LPDDR2_IO_WIDTH_32, |
| 145 | .manufacturer = LPDDR2_MANUFACTURER_ELPIDA |
| 146 | }; |
| 147 | |
Aneesh V | 14f821a | 2011-09-08 11:05:53 -0400 | [diff] [blame] | 148 | struct lpddr2_device_details *emif_get_device_details_sdp(u32 emif_nr, u8 cs, |
| 149 | struct lpddr2_device_details *lpddr2_dev_details) |
Aneesh V | c0e8852 | 2011-07-21 09:10:12 -0400 | [diff] [blame] | 150 | { |
| 151 | u32 omap_rev = omap_revision(); |
| 152 | |
| 153 | /* EMIF1 & EMIF2 have identical configuration */ |
Aneesh V | 14f821a | 2011-09-08 11:05:53 -0400 | [diff] [blame] | 154 | if ((omap_rev == OMAP4430_ES1_0) && (cs == CS1)) { |
| 155 | /* Nothing connected on CS1 for ES1.0 */ |
| 156 | return NULL; |
| 157 | } else { |
| 158 | /* In all other cases Elpida 2G device */ |
| 159 | *lpddr2_dev_details = elpida_2G_S4_details; |
| 160 | return lpddr2_dev_details; |
| 161 | } |
Aneesh V | c0e8852 | 2011-07-21 09:10:12 -0400 | [diff] [blame] | 162 | } |
| 163 | |
Aneesh V | 14f821a | 2011-09-08 11:05:53 -0400 | [diff] [blame] | 164 | struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs, |
| 165 | struct lpddr2_device_details *lpddr2_dev_details) |
Aneesh V | c0e8852 | 2011-07-21 09:10:12 -0400 | [diff] [blame] | 166 | __attribute__((weak, alias("emif_get_device_details_sdp"))); |
| 167 | |
| 168 | #endif /* CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS */ |
| 169 | |
| 170 | #ifndef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS |
| 171 | static const struct lpddr2_ac_timings timings_elpida_400_mhz = { |
| 172 | .max_freq = 400000000, |
| 173 | .RL = 6, |
| 174 | .tRPab = 21, |
| 175 | .tRCD = 18, |
| 176 | .tWR = 15, |
| 177 | .tRASmin = 42, |
| 178 | .tRRD = 10, |
| 179 | .tWTRx2 = 15, |
| 180 | .tXSR = 140, |
| 181 | .tXPx2 = 15, |
| 182 | .tRFCab = 130, |
| 183 | .tRTPx2 = 15, |
| 184 | .tCKE = 3, |
| 185 | .tCKESR = 15, |
| 186 | .tZQCS = 90, |
| 187 | .tZQCL = 360, |
| 188 | .tZQINIT = 1000, |
| 189 | .tDQSCKMAXx2 = 11, |
| 190 | .tRASmax = 70, |
| 191 | .tFAW = 50 |
| 192 | }; |
| 193 | |
| 194 | static const struct lpddr2_ac_timings timings_elpida_333_mhz = { |
| 195 | .max_freq = 333000000, |
| 196 | .RL = 5, |
| 197 | .tRPab = 21, |
| 198 | .tRCD = 18, |
| 199 | .tWR = 15, |
| 200 | .tRASmin = 42, |
| 201 | .tRRD = 10, |
| 202 | .tWTRx2 = 15, |
| 203 | .tXSR = 140, |
| 204 | .tXPx2 = 15, |
| 205 | .tRFCab = 130, |
| 206 | .tRTPx2 = 15, |
| 207 | .tCKE = 3, |
| 208 | .tCKESR = 15, |
| 209 | .tZQCS = 90, |
| 210 | .tZQCL = 360, |
| 211 | .tZQINIT = 1000, |
| 212 | .tDQSCKMAXx2 = 11, |
| 213 | .tRASmax = 70, |
| 214 | .tFAW = 50 |
| 215 | }; |
| 216 | |
| 217 | static const struct lpddr2_ac_timings timings_elpida_200_mhz = { |
| 218 | .max_freq = 200000000, |
| 219 | .RL = 3, |
| 220 | .tRPab = 21, |
| 221 | .tRCD = 18, |
| 222 | .tWR = 15, |
| 223 | .tRASmin = 42, |
| 224 | .tRRD = 10, |
| 225 | .tWTRx2 = 20, |
| 226 | .tXSR = 140, |
| 227 | .tXPx2 = 15, |
| 228 | .tRFCab = 130, |
| 229 | .tRTPx2 = 15, |
| 230 | .tCKE = 3, |
| 231 | .tCKESR = 15, |
| 232 | .tZQCS = 90, |
| 233 | .tZQCL = 360, |
| 234 | .tZQINIT = 1000, |
| 235 | .tDQSCKMAXx2 = 11, |
| 236 | .tRASmax = 70, |
| 237 | .tFAW = 50 |
| 238 | }; |
| 239 | |
| 240 | static const struct lpddr2_min_tck min_tck_elpida = { |
| 241 | .tRL = 3, |
| 242 | .tRP_AB = 3, |
| 243 | .tRCD = 3, |
| 244 | .tWR = 3, |
| 245 | .tRAS_MIN = 3, |
| 246 | .tRRD = 2, |
| 247 | .tWTR = 2, |
| 248 | .tXP = 2, |
| 249 | .tRTP = 2, |
| 250 | .tCKE = 3, |
| 251 | .tCKESR = 3, |
| 252 | .tFAW = 8 |
| 253 | }; |
| 254 | |
| 255 | static const struct lpddr2_ac_timings *elpida_ac_timings[MAX_NUM_SPEEDBINS] = { |
| 256 | &timings_elpida_200_mhz, |
| 257 | &timings_elpida_333_mhz, |
| 258 | &timings_elpida_400_mhz |
| 259 | }; |
| 260 | |
| 261 | static const struct lpddr2_device_timings elpida_2G_S4_timings = { |
| 262 | .ac_timings = elpida_ac_timings, |
| 263 | .min_tck = &min_tck_elpida, |
| 264 | }; |
| 265 | |
| 266 | void emif_get_device_timings_sdp(u32 emif_nr, |
| 267 | const struct lpddr2_device_timings **cs0_device_timings, |
| 268 | const struct lpddr2_device_timings **cs1_device_timings) |
| 269 | { |
| 270 | u32 omap_rev = omap_revision(); |
| 271 | |
| 272 | /* Identical devices on EMIF1 & EMIF2 */ |
| 273 | *cs0_device_timings = &elpida_2G_S4_timings; |
| 274 | |
| 275 | if (omap_rev == OMAP4430_ES1_0) |
| 276 | *cs1_device_timings = NULL; |
| 277 | else |
| 278 | *cs1_device_timings = &elpida_2G_S4_timings; |
| 279 | } |
| 280 | |
| 281 | void emif_get_device_timings(u32 emif_nr, |
| 282 | const struct lpddr2_device_timings **cs0_device_timings, |
| 283 | const struct lpddr2_device_timings **cs1_device_timings) |
| 284 | __attribute__((weak, alias("emif_get_device_timings_sdp"))); |
| 285 | |
| 286 | #endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */ |