1bb772a59SSricharan /* 2bb772a59SSricharan * OMAP44xx EMIF header 3bb772a59SSricharan * 4bb772a59SSricharan * Copyright (C) 2009-2010 Texas Instruments, Inc. 5bb772a59SSricharan * 6bb772a59SSricharan * Aneesh V <aneesh@ti.com> 7bb772a59SSricharan * 8bb772a59SSricharan * This program is free software; you can redistribute it and/or modify 9bb772a59SSricharan * it under the terms of the GNU General Public License version 2 as 10bb772a59SSricharan * published by the Free Software Foundation. 11bb772a59SSricharan */ 12bb772a59SSricharan 13bb772a59SSricharan #ifndef _EMIF_H_ 14bb772a59SSricharan #define _EMIF_H_ 15bb772a59SSricharan #include <asm/types.h> 16bb772a59SSricharan #include <common.h> 17bb772a59SSricharan 18bb772a59SSricharan /* Base address */ 19bb772a59SSricharan #define EMIF1_BASE 0x4c000000 20bb772a59SSricharan #define EMIF2_BASE 0x4d000000 21bb772a59SSricharan 22bb772a59SSricharan /* Registers shifts and masks */ 23bb772a59SSricharan 24bb772a59SSricharan /* EMIF_MOD_ID_REV */ 25bb772a59SSricharan #define EMIF_REG_SCHEME_SHIFT 30 26bb772a59SSricharan #define EMIF_REG_SCHEME_MASK (0x3 << 30) 27bb772a59SSricharan #define EMIF_REG_MODULE_ID_SHIFT 16 28bb772a59SSricharan #define EMIF_REG_MODULE_ID_MASK (0xfff << 16) 29bb772a59SSricharan #define EMIF_REG_RTL_VERSION_SHIFT 11 30bb772a59SSricharan #define EMIF_REG_RTL_VERSION_MASK (0x1f << 11) 31bb772a59SSricharan #define EMIF_REG_MAJOR_REVISION_SHIFT 8 32bb772a59SSricharan #define EMIF_REG_MAJOR_REVISION_MASK (0x7 << 8) 33bb772a59SSricharan #define EMIF_REG_MINOR_REVISION_SHIFT 0 34bb772a59SSricharan #define EMIF_REG_MINOR_REVISION_MASK (0x3f << 0) 35bb772a59SSricharan 36bb772a59SSricharan /* STATUS */ 37bb772a59SSricharan #define EMIF_REG_BE_SHIFT 31 38bb772a59SSricharan #define EMIF_REG_BE_MASK (1 << 31) 39bb772a59SSricharan #define EMIF_REG_DUAL_CLK_MODE_SHIFT 30 40bb772a59SSricharan #define EMIF_REG_DUAL_CLK_MODE_MASK (1 << 30) 41bb772a59SSricharan #define EMIF_REG_FAST_INIT_SHIFT 29 42bb772a59SSricharan #define EMIF_REG_FAST_INIT_MASK (1 << 29) 43bb772a59SSricharan #define EMIF_REG_PHY_DLL_READY_SHIFT 2 44bb772a59SSricharan #define EMIF_REG_PHY_DLL_READY_MASK (1 << 2) 45bb772a59SSricharan 46bb772a59SSricharan /* SDRAM_CONFIG */ 47bb772a59SSricharan #define EMIF_REG_SDRAM_TYPE_SHIFT 29 48bb772a59SSricharan #define EMIF_REG_SDRAM_TYPE_MASK (0x7 << 29) 49bb772a59SSricharan #define EMIF_REG_IBANK_POS_SHIFT 27 50bb772a59SSricharan #define EMIF_REG_IBANK_POS_MASK (0x3 << 27) 51bb772a59SSricharan #define EMIF_REG_DDR_TERM_SHIFT 24 52bb772a59SSricharan #define EMIF_REG_DDR_TERM_MASK (0x7 << 24) 53bb772a59SSricharan #define EMIF_REG_DDR2_DDQS_SHIFT 23 54bb772a59SSricharan #define EMIF_REG_DDR2_DDQS_MASK (1 << 23) 55bb772a59SSricharan #define EMIF_REG_DYN_ODT_SHIFT 21 56bb772a59SSricharan #define EMIF_REG_DYN_ODT_MASK (0x3 << 21) 57bb772a59SSricharan #define EMIF_REG_DDR_DISABLE_DLL_SHIFT 20 58bb772a59SSricharan #define EMIF_REG_DDR_DISABLE_DLL_MASK (1 << 20) 59bb772a59SSricharan #define EMIF_REG_SDRAM_DRIVE_SHIFT 18 60bb772a59SSricharan #define EMIF_REG_SDRAM_DRIVE_MASK (0x3 << 18) 61bb772a59SSricharan #define EMIF_REG_CWL_SHIFT 16 62bb772a59SSricharan #define EMIF_REG_CWL_MASK (0x3 << 16) 63bb772a59SSricharan #define EMIF_REG_NARROW_MODE_SHIFT 14 64bb772a59SSricharan #define EMIF_REG_NARROW_MODE_MASK (0x3 << 14) 65bb772a59SSricharan #define EMIF_REG_CL_SHIFT 10 66bb772a59SSricharan #define EMIF_REG_CL_MASK (0xf << 10) 67bb772a59SSricharan #define EMIF_REG_ROWSIZE_SHIFT 7 68bb772a59SSricharan #define EMIF_REG_ROWSIZE_MASK (0x7 << 7) 69bb772a59SSricharan #define EMIF_REG_IBANK_SHIFT 4 70bb772a59SSricharan #define EMIF_REG_IBANK_MASK (0x7 << 4) 71bb772a59SSricharan #define EMIF_REG_EBANK_SHIFT 3 72bb772a59SSricharan #define EMIF_REG_EBANK_MASK (1 << 3) 73bb772a59SSricharan #define EMIF_REG_PAGESIZE_SHIFT 0 74bb772a59SSricharan #define EMIF_REG_PAGESIZE_MASK (0x7 << 0) 75bb772a59SSricharan 76bb772a59SSricharan /* SDRAM_CONFIG_2 */ 77bb772a59SSricharan #define EMIF_REG_CS1NVMEN_SHIFT 30 78bb772a59SSricharan #define EMIF_REG_CS1NVMEN_MASK (1 << 30) 79bb772a59SSricharan #define EMIF_REG_EBANK_POS_SHIFT 27 80bb772a59SSricharan #define EMIF_REG_EBANK_POS_MASK (1 << 27) 81bb772a59SSricharan #define EMIF_REG_RDBNUM_SHIFT 4 82bb772a59SSricharan #define EMIF_REG_RDBNUM_MASK (0x3 << 4) 83bb772a59SSricharan #define EMIF_REG_RDBSIZE_SHIFT 0 84bb772a59SSricharan #define EMIF_REG_RDBSIZE_MASK (0x7 << 0) 85bb772a59SSricharan 86bb772a59SSricharan /* SDRAM_REF_CTRL */ 87bb772a59SSricharan #define EMIF_REG_INITREF_DIS_SHIFT 31 88bb772a59SSricharan #define EMIF_REG_INITREF_DIS_MASK (1 << 31) 89bb772a59SSricharan #define EMIF_REG_SRT_SHIFT 29 90bb772a59SSricharan #define EMIF_REG_SRT_MASK (1 << 29) 91bb772a59SSricharan #define EMIF_REG_ASR_SHIFT 28 92bb772a59SSricharan #define EMIF_REG_ASR_MASK (1 << 28) 93bb772a59SSricharan #define EMIF_REG_PASR_SHIFT 24 94bb772a59SSricharan #define EMIF_REG_PASR_MASK (0x7 << 24) 95bb772a59SSricharan #define EMIF_REG_REFRESH_RATE_SHIFT 0 96bb772a59SSricharan #define EMIF_REG_REFRESH_RATE_MASK (0xffff << 0) 97bb772a59SSricharan 98bb772a59SSricharan /* SDRAM_REF_CTRL_SHDW */ 99bb772a59SSricharan #define EMIF_REG_REFRESH_RATE_SHDW_SHIFT 0 100bb772a59SSricharan #define EMIF_REG_REFRESH_RATE_SHDW_MASK (0xffff << 0) 101bb772a59SSricharan 102bb772a59SSricharan /* SDRAM_TIM_1 */ 103bb772a59SSricharan #define EMIF_REG_T_RP_SHIFT 25 104bb772a59SSricharan #define EMIF_REG_T_RP_MASK (0xf << 25) 105bb772a59SSricharan #define EMIF_REG_T_RCD_SHIFT 21 106bb772a59SSricharan #define EMIF_REG_T_RCD_MASK (0xf << 21) 107bb772a59SSricharan #define EMIF_REG_T_WR_SHIFT 17 108bb772a59SSricharan #define EMIF_REG_T_WR_MASK (0xf << 17) 109bb772a59SSricharan #define EMIF_REG_T_RAS_SHIFT 12 110bb772a59SSricharan #define EMIF_REG_T_RAS_MASK (0x1f << 12) 111bb772a59SSricharan #define EMIF_REG_T_RC_SHIFT 6 112bb772a59SSricharan #define EMIF_REG_T_RC_MASK (0x3f << 6) 113bb772a59SSricharan #define EMIF_REG_T_RRD_SHIFT 3 114bb772a59SSricharan #define EMIF_REG_T_RRD_MASK (0x7 << 3) 115bb772a59SSricharan #define EMIF_REG_T_WTR_SHIFT 0 116bb772a59SSricharan #define EMIF_REG_T_WTR_MASK (0x7 << 0) 117bb772a59SSricharan 118bb772a59SSricharan /* SDRAM_TIM_1_SHDW */ 119bb772a59SSricharan #define EMIF_REG_T_RP_SHDW_SHIFT 25 120bb772a59SSricharan #define EMIF_REG_T_RP_SHDW_MASK (0xf << 25) 121bb772a59SSricharan #define EMIF_REG_T_RCD_SHDW_SHIFT 21 122bb772a59SSricharan #define EMIF_REG_T_RCD_SHDW_MASK (0xf << 21) 123bb772a59SSricharan #define EMIF_REG_T_WR_SHDW_SHIFT 17 124bb772a59SSricharan #define EMIF_REG_T_WR_SHDW_MASK (0xf << 17) 125bb772a59SSricharan #define EMIF_REG_T_RAS_SHDW_SHIFT 12 126bb772a59SSricharan #define EMIF_REG_T_RAS_SHDW_MASK (0x1f << 12) 127bb772a59SSricharan #define EMIF_REG_T_RC_SHDW_SHIFT 6 128bb772a59SSricharan #define EMIF_REG_T_RC_SHDW_MASK (0x3f << 6) 129bb772a59SSricharan #define EMIF_REG_T_RRD_SHDW_SHIFT 3 130bb772a59SSricharan #define EMIF_REG_T_RRD_SHDW_MASK (0x7 << 3) 131bb772a59SSricharan #define EMIF_REG_T_WTR_SHDW_SHIFT 0 132bb772a59SSricharan #define EMIF_REG_T_WTR_SHDW_MASK (0x7 << 0) 133bb772a59SSricharan 134bb772a59SSricharan /* SDRAM_TIM_2 */ 135bb772a59SSricharan #define EMIF_REG_T_XP_SHIFT 28 136bb772a59SSricharan #define EMIF_REG_T_XP_MASK (0x7 << 28) 137bb772a59SSricharan #define EMIF_REG_T_ODT_SHIFT 25 138bb772a59SSricharan #define EMIF_REG_T_ODT_MASK (0x7 << 25) 139bb772a59SSricharan #define EMIF_REG_T_XSNR_SHIFT 16 140bb772a59SSricharan #define EMIF_REG_T_XSNR_MASK (0x1ff << 16) 141bb772a59SSricharan #define EMIF_REG_T_XSRD_SHIFT 6 142bb772a59SSricharan #define EMIF_REG_T_XSRD_MASK (0x3ff << 6) 143bb772a59SSricharan #define EMIF_REG_T_RTP_SHIFT 3 144bb772a59SSricharan #define EMIF_REG_T_RTP_MASK (0x7 << 3) 145bb772a59SSricharan #define EMIF_REG_T_CKE_SHIFT 0 146bb772a59SSricharan #define EMIF_REG_T_CKE_MASK (0x7 << 0) 147bb772a59SSricharan 148bb772a59SSricharan /* SDRAM_TIM_2_SHDW */ 149bb772a59SSricharan #define EMIF_REG_T_XP_SHDW_SHIFT 28 150bb772a59SSricharan #define EMIF_REG_T_XP_SHDW_MASK (0x7 << 28) 151bb772a59SSricharan #define EMIF_REG_T_ODT_SHDW_SHIFT 25 152bb772a59SSricharan #define EMIF_REG_T_ODT_SHDW_MASK (0x7 << 25) 153bb772a59SSricharan #define EMIF_REG_T_XSNR_SHDW_SHIFT 16 154bb772a59SSricharan #define EMIF_REG_T_XSNR_SHDW_MASK (0x1ff << 16) 155bb772a59SSricharan #define EMIF_REG_T_XSRD_SHDW_SHIFT 6 156bb772a59SSricharan #define EMIF_REG_T_XSRD_SHDW_MASK (0x3ff << 6) 157bb772a59SSricharan #define EMIF_REG_T_RTP_SHDW_SHIFT 3 158bb772a59SSricharan #define EMIF_REG_T_RTP_SHDW_MASK (0x7 << 3) 159bb772a59SSricharan #define EMIF_REG_T_CKE_SHDW_SHIFT 0 160bb772a59SSricharan #define EMIF_REG_T_CKE_SHDW_MASK (0x7 << 0) 161bb772a59SSricharan 162bb772a59SSricharan /* SDRAM_TIM_3 */ 163bb772a59SSricharan #define EMIF_REG_T_CKESR_SHIFT 21 164bb772a59SSricharan #define EMIF_REG_T_CKESR_MASK (0x7 << 21) 165bb772a59SSricharan #define EMIF_REG_ZQ_ZQCS_SHIFT 15 166bb772a59SSricharan #define EMIF_REG_ZQ_ZQCS_MASK (0x3f << 15) 167bb772a59SSricharan #define EMIF_REG_T_TDQSCKMAX_SHIFT 13 168bb772a59SSricharan #define EMIF_REG_T_TDQSCKMAX_MASK (0x3 << 13) 169bb772a59SSricharan #define EMIF_REG_T_RFC_SHIFT 4 170bb772a59SSricharan #define EMIF_REG_T_RFC_MASK (0x1ff << 4) 171bb772a59SSricharan #define EMIF_REG_T_RAS_MAX_SHIFT 0 172bb772a59SSricharan #define EMIF_REG_T_RAS_MAX_MASK (0xf << 0) 173bb772a59SSricharan 174bb772a59SSricharan /* SDRAM_TIM_3_SHDW */ 175bb772a59SSricharan #define EMIF_REG_T_CKESR_SHDW_SHIFT 21 176bb772a59SSricharan #define EMIF_REG_T_CKESR_SHDW_MASK (0x7 << 21) 177bb772a59SSricharan #define EMIF_REG_ZQ_ZQCS_SHDW_SHIFT 15 178bb772a59SSricharan #define EMIF_REG_ZQ_ZQCS_SHDW_MASK (0x3f << 15) 179bb772a59SSricharan #define EMIF_REG_T_TDQSCKMAX_SHDW_SHIFT 13 180bb772a59SSricharan #define EMIF_REG_T_TDQSCKMAX_SHDW_MASK (0x3 << 13) 181bb772a59SSricharan #define EMIF_REG_T_RFC_SHDW_SHIFT 4 182bb772a59SSricharan #define EMIF_REG_T_RFC_SHDW_MASK (0x1ff << 4) 183bb772a59SSricharan #define EMIF_REG_T_RAS_MAX_SHDW_SHIFT 0 184bb772a59SSricharan #define EMIF_REG_T_RAS_MAX_SHDW_MASK (0xf << 0) 185bb772a59SSricharan 186bb772a59SSricharan /* LPDDR2_NVM_TIM */ 187bb772a59SSricharan #define EMIF_REG_NVM_T_XP_SHIFT 28 188bb772a59SSricharan #define EMIF_REG_NVM_T_XP_MASK (0x7 << 28) 189bb772a59SSricharan #define EMIF_REG_NVM_T_WTR_SHIFT 24 190bb772a59SSricharan #define EMIF_REG_NVM_T_WTR_MASK (0x7 << 24) 191bb772a59SSricharan #define EMIF_REG_NVM_T_RP_SHIFT 20 192bb772a59SSricharan #define EMIF_REG_NVM_T_RP_MASK (0xf << 20) 193bb772a59SSricharan #define EMIF_REG_NVM_T_WRA_SHIFT 16 194bb772a59SSricharan #define EMIF_REG_NVM_T_WRA_MASK (0xf << 16) 195bb772a59SSricharan #define EMIF_REG_NVM_T_RRD_SHIFT 8 196bb772a59SSricharan #define EMIF_REG_NVM_T_RRD_MASK (0xff << 8) 197bb772a59SSricharan #define EMIF_REG_NVM_T_RCDMIN_SHIFT 0 198bb772a59SSricharan #define EMIF_REG_NVM_T_RCDMIN_MASK (0xff << 0) 199bb772a59SSricharan 200bb772a59SSricharan /* LPDDR2_NVM_TIM_SHDW */ 201bb772a59SSricharan #define EMIF_REG_NVM_T_XP_SHDW_SHIFT 28 202bb772a59SSricharan #define EMIF_REG_NVM_T_XP_SHDW_MASK (0x7 << 28) 203bb772a59SSricharan #define EMIF_REG_NVM_T_WTR_SHDW_SHIFT 24 204bb772a59SSricharan #define EMIF_REG_NVM_T_WTR_SHDW_MASK (0x7 << 24) 205bb772a59SSricharan #define EMIF_REG_NVM_T_RP_SHDW_SHIFT 20 206bb772a59SSricharan #define EMIF_REG_NVM_T_RP_SHDW_MASK (0xf << 20) 207bb772a59SSricharan #define EMIF_REG_NVM_T_WRA_SHDW_SHIFT 16 208bb772a59SSricharan #define EMIF_REG_NVM_T_WRA_SHDW_MASK (0xf << 16) 209bb772a59SSricharan #define EMIF_REG_NVM_T_RRD_SHDW_SHIFT 8 210bb772a59SSricharan #define EMIF_REG_NVM_T_RRD_SHDW_MASK (0xff << 8) 211bb772a59SSricharan #define EMIF_REG_NVM_T_RCDMIN_SHDW_SHIFT 0 212bb772a59SSricharan #define EMIF_REG_NVM_T_RCDMIN_SHDW_MASK (0xff << 0) 213bb772a59SSricharan 214bb772a59SSricharan /* PWR_MGMT_CTRL */ 215bb772a59SSricharan #define EMIF_REG_IDLEMODE_SHIFT 30 216bb772a59SSricharan #define EMIF_REG_IDLEMODE_MASK (0x3 << 30) 217bb772a59SSricharan #define EMIF_REG_PD_TIM_SHIFT 12 218bb772a59SSricharan #define EMIF_REG_PD_TIM_MASK (0xf << 12) 219bb772a59SSricharan #define EMIF_REG_DPD_EN_SHIFT 11 220bb772a59SSricharan #define EMIF_REG_DPD_EN_MASK (1 << 11) 221bb772a59SSricharan #define EMIF_REG_LP_MODE_SHIFT 8 222bb772a59SSricharan #define EMIF_REG_LP_MODE_MASK (0x7 << 8) 223bb772a59SSricharan #define EMIF_REG_SR_TIM_SHIFT 4 224bb772a59SSricharan #define EMIF_REG_SR_TIM_MASK (0xf << 4) 225bb772a59SSricharan #define EMIF_REG_CS_TIM_SHIFT 0 226bb772a59SSricharan #define EMIF_REG_CS_TIM_MASK (0xf << 0) 227bb772a59SSricharan 228bb772a59SSricharan /* PWR_MGMT_CTRL_SHDW */ 229*aaec4487SSRICHARAN R #define EMIF_REG_PD_TIM_SHDW_SHIFT 12 230*aaec4487SSRICHARAN R #define EMIF_REG_PD_TIM_SHDW_MASK (0xf << 12) 231bb772a59SSricharan #define EMIF_REG_SR_TIM_SHDW_SHIFT 4 232bb772a59SSricharan #define EMIF_REG_SR_TIM_SHDW_MASK (0xf << 4) 233bb772a59SSricharan #define EMIF_REG_CS_TIM_SHDW_SHIFT 0 234bb772a59SSricharan #define EMIF_REG_CS_TIM_SHDW_MASK (0xf << 0) 235bb772a59SSricharan 236bb772a59SSricharan /* LPDDR2_MODE_REG_DATA */ 237bb772a59SSricharan #define EMIF_REG_VALUE_0_SHIFT 0 238bb772a59SSricharan #define EMIF_REG_VALUE_0_MASK (0x7f << 0) 239bb772a59SSricharan 240bb772a59SSricharan /* LPDDR2_MODE_REG_CFG */ 241bb772a59SSricharan #define EMIF_REG_CS_SHIFT 31 242bb772a59SSricharan #define EMIF_REG_CS_MASK (1 << 31) 243bb772a59SSricharan #define EMIF_REG_REFRESH_EN_SHIFT 30 244bb772a59SSricharan #define EMIF_REG_REFRESH_EN_MASK (1 << 30) 245bb772a59SSricharan #define EMIF_REG_ADDRESS_SHIFT 0 246bb772a59SSricharan #define EMIF_REG_ADDRESS_MASK (0xff << 0) 247bb772a59SSricharan 248bb772a59SSricharan /* OCP_CONFIG */ 249bb772a59SSricharan #define EMIF_REG_SYS_THRESH_MAX_SHIFT 24 250bb772a59SSricharan #define EMIF_REG_SYS_THRESH_MAX_MASK (0xf << 24) 251bb772a59SSricharan #define EMIF_REG_MPU_THRESH_MAX_SHIFT 20 252bb772a59SSricharan #define EMIF_REG_MPU_THRESH_MAX_MASK (0xf << 20) 253bb772a59SSricharan #define EMIF_REG_LL_THRESH_MAX_SHIFT 16 254bb772a59SSricharan #define EMIF_REG_LL_THRESH_MAX_MASK (0xf << 16) 255bb772a59SSricharan #define EMIF_REG_PR_OLD_COUNT_SHIFT 0 256bb772a59SSricharan #define EMIF_REG_PR_OLD_COUNT_MASK (0xff << 0) 257bb772a59SSricharan 258bb772a59SSricharan /* OCP_CFG_VAL_1 */ 259bb772a59SSricharan #define EMIF_REG_SYS_BUS_WIDTH_SHIFT 30 260bb772a59SSricharan #define EMIF_REG_SYS_BUS_WIDTH_MASK (0x3 << 30) 261bb772a59SSricharan #define EMIF_REG_LL_BUS_WIDTH_SHIFT 28 262bb772a59SSricharan #define EMIF_REG_LL_BUS_WIDTH_MASK (0x3 << 28) 263bb772a59SSricharan #define EMIF_REG_WR_FIFO_DEPTH_SHIFT 8 264bb772a59SSricharan #define EMIF_REG_WR_FIFO_DEPTH_MASK (0xff << 8) 265bb772a59SSricharan #define EMIF_REG_CMD_FIFO_DEPTH_SHIFT 0 266bb772a59SSricharan #define EMIF_REG_CMD_FIFO_DEPTH_MASK (0xff << 0) 267bb772a59SSricharan 268bb772a59SSricharan /* OCP_CFG_VAL_2 */ 269bb772a59SSricharan #define EMIF_REG_RREG_FIFO_DEPTH_SHIFT 16 270bb772a59SSricharan #define EMIF_REG_RREG_FIFO_DEPTH_MASK (0xff << 16) 271bb772a59SSricharan #define EMIF_REG_RSD_FIFO_DEPTH_SHIFT 8 272bb772a59SSricharan #define EMIF_REG_RSD_FIFO_DEPTH_MASK (0xff << 8) 273bb772a59SSricharan #define EMIF_REG_RCMD_FIFO_DEPTH_SHIFT 0 274bb772a59SSricharan #define EMIF_REG_RCMD_FIFO_DEPTH_MASK (0xff << 0) 275bb772a59SSricharan 276bb772a59SSricharan /* IODFT_TLGC */ 277bb772a59SSricharan #define EMIF_REG_TLEC_SHIFT 16 278bb772a59SSricharan #define EMIF_REG_TLEC_MASK (0xffff << 16) 279bb772a59SSricharan #define EMIF_REG_MT_SHIFT 14 280bb772a59SSricharan #define EMIF_REG_MT_MASK (1 << 14) 281bb772a59SSricharan #define EMIF_REG_ACT_CAP_EN_SHIFT 13 282bb772a59SSricharan #define EMIF_REG_ACT_CAP_EN_MASK (1 << 13) 283bb772a59SSricharan #define EMIF_REG_OPG_LD_SHIFT 12 284bb772a59SSricharan #define EMIF_REG_OPG_LD_MASK (1 << 12) 285bb772a59SSricharan #define EMIF_REG_RESET_PHY_SHIFT 10 286bb772a59SSricharan #define EMIF_REG_RESET_PHY_MASK (1 << 10) 287bb772a59SSricharan #define EMIF_REG_MMS_SHIFT 8 288bb772a59SSricharan #define EMIF_REG_MMS_MASK (1 << 8) 289bb772a59SSricharan #define EMIF_REG_MC_SHIFT 4 290bb772a59SSricharan #define EMIF_REG_MC_MASK (0x3 << 4) 291bb772a59SSricharan #define EMIF_REG_PC_SHIFT 1 292bb772a59SSricharan #define EMIF_REG_PC_MASK (0x7 << 1) 293bb772a59SSricharan #define EMIF_REG_TM_SHIFT 0 294bb772a59SSricharan #define EMIF_REG_TM_MASK (1 << 0) 295bb772a59SSricharan 296bb772a59SSricharan /* IODFT_CTRL_MISR_RSLT */ 297bb772a59SSricharan #define EMIF_REG_DQM_TLMR_SHIFT 16 298bb772a59SSricharan #define EMIF_REG_DQM_TLMR_MASK (0x3ff << 16) 299bb772a59SSricharan #define EMIF_REG_CTL_TLMR_SHIFT 0 300bb772a59SSricharan #define EMIF_REG_CTL_TLMR_MASK (0x7ff << 0) 301bb772a59SSricharan 302bb772a59SSricharan /* IODFT_ADDR_MISR_RSLT */ 303bb772a59SSricharan #define EMIF_REG_ADDR_TLMR_SHIFT 0 304bb772a59SSricharan #define EMIF_REG_ADDR_TLMR_MASK (0x1fffff << 0) 305bb772a59SSricharan 306bb772a59SSricharan /* IODFT_DATA_MISR_RSLT_1 */ 307bb772a59SSricharan #define EMIF_REG_DATA_TLMR_31_0_SHIFT 0 308bb772a59SSricharan #define EMIF_REG_DATA_TLMR_31_0_MASK (0xffffffff << 0) 309bb772a59SSricharan 310bb772a59SSricharan /* IODFT_DATA_MISR_RSLT_2 */ 311bb772a59SSricharan #define EMIF_REG_DATA_TLMR_63_32_SHIFT 0 312bb772a59SSricharan #define EMIF_REG_DATA_TLMR_63_32_MASK (0xffffffff << 0) 313bb772a59SSricharan 314bb772a59SSricharan /* IODFT_DATA_MISR_RSLT_3 */ 315bb772a59SSricharan #define EMIF_REG_DATA_TLMR_66_64_SHIFT 0 316bb772a59SSricharan #define EMIF_REG_DATA_TLMR_66_64_MASK (0x7 << 0) 317bb772a59SSricharan 318bb772a59SSricharan /* PERF_CNT_1 */ 319bb772a59SSricharan #define EMIF_REG_COUNTER1_SHIFT 0 320bb772a59SSricharan #define EMIF_REG_COUNTER1_MASK (0xffffffff << 0) 321bb772a59SSricharan 322bb772a59SSricharan /* PERF_CNT_2 */ 323bb772a59SSricharan #define EMIF_REG_COUNTER2_SHIFT 0 324bb772a59SSricharan #define EMIF_REG_COUNTER2_MASK (0xffffffff << 0) 325bb772a59SSricharan 326bb772a59SSricharan /* PERF_CNT_CFG */ 327bb772a59SSricharan #define EMIF_REG_CNTR2_MCONNID_EN_SHIFT 31 328bb772a59SSricharan #define EMIF_REG_CNTR2_MCONNID_EN_MASK (1 << 31) 329bb772a59SSricharan #define EMIF_REG_CNTR2_REGION_EN_SHIFT 30 330bb772a59SSricharan #define EMIF_REG_CNTR2_REGION_EN_MASK (1 << 30) 331bb772a59SSricharan #define EMIF_REG_CNTR2_CFG_SHIFT 16 332bb772a59SSricharan #define EMIF_REG_CNTR2_CFG_MASK (0xf << 16) 333bb772a59SSricharan #define EMIF_REG_CNTR1_MCONNID_EN_SHIFT 15 334bb772a59SSricharan #define EMIF_REG_CNTR1_MCONNID_EN_MASK (1 << 15) 335bb772a59SSricharan #define EMIF_REG_CNTR1_REGION_EN_SHIFT 14 336bb772a59SSricharan #define EMIF_REG_CNTR1_REGION_EN_MASK (1 << 14) 337bb772a59SSricharan #define EMIF_REG_CNTR1_CFG_SHIFT 0 338bb772a59SSricharan #define EMIF_REG_CNTR1_CFG_MASK (0xf << 0) 339bb772a59SSricharan 340bb772a59SSricharan /* PERF_CNT_SEL */ 341bb772a59SSricharan #define EMIF_REG_MCONNID2_SHIFT 24 342bb772a59SSricharan #define EMIF_REG_MCONNID2_MASK (0xff << 24) 343bb772a59SSricharan #define EMIF_REG_REGION_SEL2_SHIFT 16 344bb772a59SSricharan #define EMIF_REG_REGION_SEL2_MASK (0x3 << 16) 345bb772a59SSricharan #define EMIF_REG_MCONNID1_SHIFT 8 346bb772a59SSricharan #define EMIF_REG_MCONNID1_MASK (0xff << 8) 347bb772a59SSricharan #define EMIF_REG_REGION_SEL1_SHIFT 0 348bb772a59SSricharan #define EMIF_REG_REGION_SEL1_MASK (0x3 << 0) 349bb772a59SSricharan 350bb772a59SSricharan /* PERF_CNT_TIM */ 351bb772a59SSricharan #define EMIF_REG_TOTAL_TIME_SHIFT 0 352bb772a59SSricharan #define EMIF_REG_TOTAL_TIME_MASK (0xffffffff << 0) 353bb772a59SSricharan 354bb772a59SSricharan /* READ_IDLE_CTRL */ 355bb772a59SSricharan #define EMIF_REG_READ_IDLE_LEN_SHIFT 16 356bb772a59SSricharan #define EMIF_REG_READ_IDLE_LEN_MASK (0xf << 16) 357bb772a59SSricharan #define EMIF_REG_READ_IDLE_INTERVAL_SHIFT 0 358bb772a59SSricharan #define EMIF_REG_READ_IDLE_INTERVAL_MASK (0x1ff << 0) 359bb772a59SSricharan 360bb772a59SSricharan /* READ_IDLE_CTRL_SHDW */ 361bb772a59SSricharan #define EMIF_REG_READ_IDLE_LEN_SHDW_SHIFT 16 362bb772a59SSricharan #define EMIF_REG_READ_IDLE_LEN_SHDW_MASK (0xf << 16) 363bb772a59SSricharan #define EMIF_REG_READ_IDLE_INTERVAL_SHDW_SHIFT 0 364bb772a59SSricharan #define EMIF_REG_READ_IDLE_INTERVAL_SHDW_MASK (0x1ff << 0) 365bb772a59SSricharan 366bb772a59SSricharan /* IRQ_EOI */ 367bb772a59SSricharan #define EMIF_REG_EOI_SHIFT 0 368bb772a59SSricharan #define EMIF_REG_EOI_MASK (1 << 0) 369bb772a59SSricharan 370bb772a59SSricharan /* IRQSTATUS_RAW_SYS */ 371bb772a59SSricharan #define EMIF_REG_DNV_SYS_SHIFT 2 372bb772a59SSricharan #define EMIF_REG_DNV_SYS_MASK (1 << 2) 373bb772a59SSricharan #define EMIF_REG_TA_SYS_SHIFT 1 374bb772a59SSricharan #define EMIF_REG_TA_SYS_MASK (1 << 1) 375bb772a59SSricharan #define EMIF_REG_ERR_SYS_SHIFT 0 376bb772a59SSricharan #define EMIF_REG_ERR_SYS_MASK (1 << 0) 377bb772a59SSricharan 378bb772a59SSricharan /* IRQSTATUS_RAW_LL */ 379bb772a59SSricharan #define EMIF_REG_DNV_LL_SHIFT 2 380bb772a59SSricharan #define EMIF_REG_DNV_LL_MASK (1 << 2) 381bb772a59SSricharan #define EMIF_REG_TA_LL_SHIFT 1 382bb772a59SSricharan #define EMIF_REG_TA_LL_MASK (1 << 1) 383bb772a59SSricharan #define EMIF_REG_ERR_LL_SHIFT 0 384bb772a59SSricharan #define EMIF_REG_ERR_LL_MASK (1 << 0) 385bb772a59SSricharan 386bb772a59SSricharan /* IRQSTATUS_SYS */ 387bb772a59SSricharan 388bb772a59SSricharan /* IRQSTATUS_LL */ 389bb772a59SSricharan 390bb772a59SSricharan /* IRQENABLE_SET_SYS */ 391bb772a59SSricharan #define EMIF_REG_EN_DNV_SYS_SHIFT 2 392bb772a59SSricharan #define EMIF_REG_EN_DNV_SYS_MASK (1 << 2) 393bb772a59SSricharan #define EMIF_REG_EN_TA_SYS_SHIFT 1 394bb772a59SSricharan #define EMIF_REG_EN_TA_SYS_MASK (1 << 1) 395bb772a59SSricharan #define EMIF_REG_EN_ERR_SYS_SHIFT 0 396bb772a59SSricharan #define EMIF_REG_EN_ERR_SYS_MASK (1 << 0) 397bb772a59SSricharan 398bb772a59SSricharan /* IRQENABLE_SET_LL */ 399bb772a59SSricharan #define EMIF_REG_EN_DNV_LL_SHIFT 2 400bb772a59SSricharan #define EMIF_REG_EN_DNV_LL_MASK (1 << 2) 401bb772a59SSricharan #define EMIF_REG_EN_TA_LL_SHIFT 1 402bb772a59SSricharan #define EMIF_REG_EN_TA_LL_MASK (1 << 1) 403bb772a59SSricharan #define EMIF_REG_EN_ERR_LL_SHIFT 0 404bb772a59SSricharan #define EMIF_REG_EN_ERR_LL_MASK (1 << 0) 405bb772a59SSricharan 406bb772a59SSricharan /* IRQENABLE_CLR_SYS */ 407bb772a59SSricharan 408bb772a59SSricharan /* IRQENABLE_CLR_LL */ 409bb772a59SSricharan 410bb772a59SSricharan /* ZQ_CONFIG */ 411bb772a59SSricharan #define EMIF_REG_ZQ_CS1EN_SHIFT 31 412bb772a59SSricharan #define EMIF_REG_ZQ_CS1EN_MASK (1 << 31) 413bb772a59SSricharan #define EMIF_REG_ZQ_CS0EN_SHIFT 30 414bb772a59SSricharan #define EMIF_REG_ZQ_CS0EN_MASK (1 << 30) 415bb772a59SSricharan #define EMIF_REG_ZQ_DUALCALEN_SHIFT 29 416bb772a59SSricharan #define EMIF_REG_ZQ_DUALCALEN_MASK (1 << 29) 417bb772a59SSricharan #define EMIF_REG_ZQ_SFEXITEN_SHIFT 28 418bb772a59SSricharan #define EMIF_REG_ZQ_SFEXITEN_MASK (1 << 28) 419bb772a59SSricharan #define EMIF_REG_ZQ_ZQINIT_MULT_SHIFT 18 420bb772a59SSricharan #define EMIF_REG_ZQ_ZQINIT_MULT_MASK (0x3 << 18) 421bb772a59SSricharan #define EMIF_REG_ZQ_ZQCL_MULT_SHIFT 16 422bb772a59SSricharan #define EMIF_REG_ZQ_ZQCL_MULT_MASK (0x3 << 16) 423bb772a59SSricharan #define EMIF_REG_ZQ_REFINTERVAL_SHIFT 0 424bb772a59SSricharan #define EMIF_REG_ZQ_REFINTERVAL_MASK (0xffff << 0) 425bb772a59SSricharan 426bb772a59SSricharan /* TEMP_ALERT_CONFIG */ 427bb772a59SSricharan #define EMIF_REG_TA_CS1EN_SHIFT 31 428bb772a59SSricharan #define EMIF_REG_TA_CS1EN_MASK (1 << 31) 429bb772a59SSricharan #define EMIF_REG_TA_CS0EN_SHIFT 30 430bb772a59SSricharan #define EMIF_REG_TA_CS0EN_MASK (1 << 30) 431bb772a59SSricharan #define EMIF_REG_TA_SFEXITEN_SHIFT 28 432bb772a59SSricharan #define EMIF_REG_TA_SFEXITEN_MASK (1 << 28) 433bb772a59SSricharan #define EMIF_REG_TA_DEVWDT_SHIFT 26 434bb772a59SSricharan #define EMIF_REG_TA_DEVWDT_MASK (0x3 << 26) 435bb772a59SSricharan #define EMIF_REG_TA_DEVCNT_SHIFT 24 436bb772a59SSricharan #define EMIF_REG_TA_DEVCNT_MASK (0x3 << 24) 437bb772a59SSricharan #define EMIF_REG_TA_REFINTERVAL_SHIFT 0 438bb772a59SSricharan #define EMIF_REG_TA_REFINTERVAL_MASK (0x3fffff << 0) 439bb772a59SSricharan 440bb772a59SSricharan /* OCP_ERR_LOG */ 441bb772a59SSricharan #define EMIF_REG_MADDRSPACE_SHIFT 14 442bb772a59SSricharan #define EMIF_REG_MADDRSPACE_MASK (0x3 << 14) 443bb772a59SSricharan #define EMIF_REG_MBURSTSEQ_SHIFT 11 444bb772a59SSricharan #define EMIF_REG_MBURSTSEQ_MASK (0x7 << 11) 445bb772a59SSricharan #define EMIF_REG_MCMD_SHIFT 8 446bb772a59SSricharan #define EMIF_REG_MCMD_MASK (0x7 << 8) 447bb772a59SSricharan #define EMIF_REG_MCONNID_SHIFT 0 448bb772a59SSricharan #define EMIF_REG_MCONNID_MASK (0xff << 0) 449bb772a59SSricharan 450bb772a59SSricharan /* DDR_PHY_CTRL_1 */ 451bb772a59SSricharan #define EMIF_REG_DDR_PHY_CTRL_1_SHIFT 4 452bb772a59SSricharan #define EMIF_REG_DDR_PHY_CTRL_1_MASK (0xfffffff << 4) 453bb772a59SSricharan #define EMIF_REG_READ_LATENCY_SHIFT 0 454bb772a59SSricharan #define EMIF_REG_READ_LATENCY_MASK (0xf << 0) 455bb772a59SSricharan #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHIFT 4 456bb772a59SSricharan #define EMIF_REG_DLL_SLAVE_DLY_CTRL_MASK (0xFF << 4) 457bb772a59SSricharan #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHIFT 12 458bb772a59SSricharan #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_MASK (0xFFFFF << 12) 459bb772a59SSricharan 460bb772a59SSricharan /* DDR_PHY_CTRL_1_SHDW */ 461bb772a59SSricharan #define EMIF_REG_DDR_PHY_CTRL_1_SHDW_SHIFT 4 462bb772a59SSricharan #define EMIF_REG_DDR_PHY_CTRL_1_SHDW_MASK (0xfffffff << 4) 463bb772a59SSricharan #define EMIF_REG_READ_LATENCY_SHDW_SHIFT 0 464bb772a59SSricharan #define EMIF_REG_READ_LATENCY_SHDW_MASK (0xf << 0) 465bb772a59SSricharan #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHDW_SHIFT 4 466bb772a59SSricharan #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHDW_MASK (0xFF << 4) 467bb772a59SSricharan #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_SHIFT 12 468bb772a59SSricharan #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_MASK (0xFFFFF << 12) 469bb772a59SSricharan 470bb772a59SSricharan /* DDR_PHY_CTRL_2 */ 471bb772a59SSricharan #define EMIF_REG_DDR_PHY_CTRL_2_SHIFT 0 472bb772a59SSricharan #define EMIF_REG_DDR_PHY_CTRL_2_MASK (0xffffffff << 0) 473bb772a59SSricharan 474bb772a59SSricharan /* DMM */ 475bb772a59SSricharan #define DMM_BASE 0x4E000040 476bb772a59SSricharan 477bb772a59SSricharan /* Memory Adapter */ 478bb772a59SSricharan #define MA_BASE 0x482AF040 479bb772a59SSricharan 480bb772a59SSricharan /* DMM_LISA_MAP */ 481bb772a59SSricharan #define EMIF_SYS_ADDR_SHIFT 24 482bb772a59SSricharan #define EMIF_SYS_ADDR_MASK (0xff << 24) 483bb772a59SSricharan #define EMIF_SYS_SIZE_SHIFT 20 484bb772a59SSricharan #define EMIF_SYS_SIZE_MASK (0x7 << 20) 485bb772a59SSricharan #define EMIF_SDRC_INTL_SHIFT 18 486bb772a59SSricharan #define EMIF_SDRC_INTL_MASK (0x3 << 18) 487bb772a59SSricharan #define EMIF_SDRC_ADDRSPC_SHIFT 16 488bb772a59SSricharan #define EMIF_SDRC_ADDRSPC_MASK (0x3 << 16) 489bb772a59SSricharan #define EMIF_SDRC_MAP_SHIFT 8 490bb772a59SSricharan #define EMIF_SDRC_MAP_MASK (0x3 << 8) 491bb772a59SSricharan #define EMIF_SDRC_ADDR_SHIFT 0 492bb772a59SSricharan #define EMIF_SDRC_ADDR_MASK (0xff << 0) 493bb772a59SSricharan 494bb772a59SSricharan /* DMM_LISA_MAP fields */ 495bb772a59SSricharan #define DMM_SDRC_MAP_UNMAPPED 0 496bb772a59SSricharan #define DMM_SDRC_MAP_EMIF1_ONLY 1 497bb772a59SSricharan #define DMM_SDRC_MAP_EMIF2_ONLY 2 498bb772a59SSricharan #define DMM_SDRC_MAP_EMIF1_AND_EMIF2 3 499bb772a59SSricharan 500bb772a59SSricharan #define DMM_SDRC_INTL_NONE 0 501bb772a59SSricharan #define DMM_SDRC_INTL_128B 1 502bb772a59SSricharan #define DMM_SDRC_INTL_256B 2 503bb772a59SSricharan #define DMM_SDRC_INTL_512 3 504bb772a59SSricharan 505bb772a59SSricharan #define DMM_SDRC_ADDR_SPC_SDRAM 0 506bb772a59SSricharan #define DMM_SDRC_ADDR_SPC_NVM 1 507bb772a59SSricharan #define DMM_SDRC_ADDR_SPC_INVALID 2 508bb772a59SSricharan 509bb772a59SSricharan #define DMM_LISA_MAP_INTERLEAVED_BASE_VAL (\ 510bb772a59SSricharan (DMM_SDRC_MAP_EMIF1_AND_EMIF2 << EMIF_SDRC_MAP_SHIFT) |\ 511bb772a59SSricharan (DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT) |\ 512bb772a59SSricharan (DMM_SDRC_INTL_128B << EMIF_SDRC_INTL_SHIFT) |\ 513bb772a59SSricharan (CONFIG_SYS_SDRAM_BASE << EMIF_SYS_ADDR_SHIFT)) 514bb772a59SSricharan 515bb772a59SSricharan #define DMM_LISA_MAP_EMIF1_ONLY_BASE_VAL (\ 516bb772a59SSricharan (DMM_SDRC_MAP_EMIF1_ONLY << EMIF_SDRC_MAP_SHIFT)|\ 517bb772a59SSricharan (DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT)|\ 518bb772a59SSricharan (DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT)) 519bb772a59SSricharan 520bb772a59SSricharan #define DMM_LISA_MAP_EMIF2_ONLY_BASE_VAL (\ 521bb772a59SSricharan (DMM_SDRC_MAP_EMIF2_ONLY << EMIF_SDRC_MAP_SHIFT)|\ 522bb772a59SSricharan (DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT)|\ 523bb772a59SSricharan (DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT)) 524bb772a59SSricharan 525bb772a59SSricharan /* Trap for invalid TILER PAT entries */ 526bb772a59SSricharan #define DMM_LISA_MAP_0_INVAL_ADDR_TRAP (\ 527bb772a59SSricharan (0 << EMIF_SDRC_ADDR_SHIFT) |\ 528bb772a59SSricharan (DMM_SDRC_MAP_EMIF1_ONLY << EMIF_SDRC_MAP_SHIFT)|\ 529bb772a59SSricharan (DMM_SDRC_ADDR_SPC_INVALID << EMIF_SDRC_ADDRSPC_SHIFT)|\ 530bb772a59SSricharan (DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT)|\ 531bb772a59SSricharan (0xFF << EMIF_SYS_ADDR_SHIFT)) 532bb772a59SSricharan 533f4010734SSRICHARAN R #define EMIF_EXT_PHY_CTRL_TIMING_REG 0x5 534f4010734SSRICHARAN R #define EMIF_EXT_PHY_CTRL_CONST_REG 0x13 535bb772a59SSricharan 536bb772a59SSricharan /* Reg mapping structure */ 537bb772a59SSricharan struct emif_reg_struct { 538bb772a59SSricharan u32 emif_mod_id_rev; 539bb772a59SSricharan u32 emif_status; 540bb772a59SSricharan u32 emif_sdram_config; 541bb772a59SSricharan u32 emif_lpddr2_nvm_config; 542bb772a59SSricharan u32 emif_sdram_ref_ctrl; 543bb772a59SSricharan u32 emif_sdram_ref_ctrl_shdw; 544bb772a59SSricharan u32 emif_sdram_tim_1; 545bb772a59SSricharan u32 emif_sdram_tim_1_shdw; 546bb772a59SSricharan u32 emif_sdram_tim_2; 547bb772a59SSricharan u32 emif_sdram_tim_2_shdw; 548bb772a59SSricharan u32 emif_sdram_tim_3; 549bb772a59SSricharan u32 emif_sdram_tim_3_shdw; 550bb772a59SSricharan u32 emif_lpddr2_nvm_tim; 551bb772a59SSricharan u32 emif_lpddr2_nvm_tim_shdw; 552bb772a59SSricharan u32 emif_pwr_mgmt_ctrl; 553bb772a59SSricharan u32 emif_pwr_mgmt_ctrl_shdw; 554bb772a59SSricharan u32 emif_lpddr2_mode_reg_data; 555bb772a59SSricharan u32 padding1[1]; 556bb772a59SSricharan u32 emif_lpddr2_mode_reg_data_es2; 557bb772a59SSricharan u32 padding11[1]; 558bb772a59SSricharan u32 emif_lpddr2_mode_reg_cfg; 559bb772a59SSricharan u32 emif_l3_config; 560bb772a59SSricharan u32 emif_l3_cfg_val_1; 561bb772a59SSricharan u32 emif_l3_cfg_val_2; 562bb772a59SSricharan u32 emif_iodft_tlgc; 563bb772a59SSricharan u32 padding2[7]; 564bb772a59SSricharan u32 emif_perf_cnt_1; 565bb772a59SSricharan u32 emif_perf_cnt_2; 566bb772a59SSricharan u32 emif_perf_cnt_cfg; 567bb772a59SSricharan u32 emif_perf_cnt_sel; 568bb772a59SSricharan u32 emif_perf_cnt_tim; 569bb772a59SSricharan u32 padding3; 570bb772a59SSricharan u32 emif_read_idlectrl; 571bb772a59SSricharan u32 emif_read_idlectrl_shdw; 572bb772a59SSricharan u32 padding4; 573bb772a59SSricharan u32 emif_irqstatus_raw_sys; 574bb772a59SSricharan u32 emif_irqstatus_raw_ll; 575bb772a59SSricharan u32 emif_irqstatus_sys; 576bb772a59SSricharan u32 emif_irqstatus_ll; 577bb772a59SSricharan u32 emif_irqenable_set_sys; 578bb772a59SSricharan u32 emif_irqenable_set_ll; 579bb772a59SSricharan u32 emif_irqenable_clr_sys; 580bb772a59SSricharan u32 emif_irqenable_clr_ll; 581bb772a59SSricharan u32 padding5; 582bb772a59SSricharan u32 emif_zq_config; 583bb772a59SSricharan u32 emif_temp_alert_config; 584bb772a59SSricharan u32 emif_l3_err_log; 585f4010734SSRICHARAN R u32 emif_rd_wr_lvl_rmp_win; 586f4010734SSRICHARAN R u32 emif_rd_wr_lvl_rmp_ctl; 587f4010734SSRICHARAN R u32 emif_rd_wr_lvl_ctl; 588f4010734SSRICHARAN R u32 padding6[1]; 589bb772a59SSricharan u32 emif_ddr_phy_ctrl_1; 590bb772a59SSricharan u32 emif_ddr_phy_ctrl_1_shdw; 591bb772a59SSricharan u32 emif_ddr_phy_ctrl_2; 592f4010734SSRICHARAN R u32 padding7[12]; 593f4010734SSRICHARAN R u32 emif_rd_wr_exec_thresh; 594f4010734SSRICHARAN R u32 padding8[55]; 595f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_1; 596f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_1_shdw; 597f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_2; 598f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_2_shdw; 599f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_3; 600f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_3_shdw; 601f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_4; 602f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_4_shdw; 603f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_5; 604f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_5_shdw; 605f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_6; 606f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_6_shdw; 607f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_7; 608f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_7_shdw; 609f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_8; 610f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_8_shdw; 611f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_9; 612f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_9_shdw; 613f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_10; 614f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_10_shdw; 615f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_11; 616f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_11_shdw; 617f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_12; 618f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_12_shdw; 619f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_13; 620f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_13_shdw; 621f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_14; 622f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_14_shdw; 623f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_15; 624f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_15_shdw; 625f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_16; 626f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_16_shdw; 627f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_17; 628f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_17_shdw; 629f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_18; 630f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_18_shdw; 631f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_19; 632f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_19_shdw; 633f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_20; 634f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_20_shdw; 635f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_21; 636f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_21_shdw; 637f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_22; 638f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_22_shdw; 639f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_23; 640f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_23_shdw; 641f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_24; 642f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_24_shdw; 643bb772a59SSricharan }; 644bb772a59SSricharan 645bb772a59SSricharan struct dmm_lisa_map_regs { 646bb772a59SSricharan u32 dmm_lisa_map_0; 647bb772a59SSricharan u32 dmm_lisa_map_1; 648bb772a59SSricharan u32 dmm_lisa_map_2; 649bb772a59SSricharan u32 dmm_lisa_map_3; 650bb772a59SSricharan }; 651bb772a59SSricharan 652f4010734SSRICHARAN R extern const u32 ext_phy_ctrl_const_base[EMIF_EXT_PHY_CTRL_CONST_REG]; 653f4010734SSRICHARAN R 654bb772a59SSricharan #define CS0 0 655bb772a59SSricharan #define CS1 1 656bb772a59SSricharan /* The maximum frequency at which the LPDDR2 interface can operate in Hz*/ 657bb772a59SSricharan #define MAX_LPDDR2_FREQ 400000000 /* 400 MHz */ 658bb772a59SSricharan 659bb772a59SSricharan /* 660bb772a59SSricharan * The period of DDR clk is represented as numerator and denominator for 661bb772a59SSricharan * better accuracy in integer based calculations. However, if the numerator 662bb772a59SSricharan * and denominator are very huge there may be chances of overflow in 663bb772a59SSricharan * calculations. So, as a trade-off keep denominator(and consequently 664bb772a59SSricharan * numerator) within a limit sacrificing some accuracy - but not much 665bb772a59SSricharan * If denominator and numerator are already small (such as at 400 MHz) 666bb772a59SSricharan * no adjustment is needed 667bb772a59SSricharan */ 668bb772a59SSricharan #define EMIF_PERIOD_DEN_LIMIT 1000 669bb772a59SSricharan /* 670bb772a59SSricharan * Maximum number of different frequencies supported by EMIF driver 671bb772a59SSricharan * Determines the number of entries in the pointer array for register 672bb772a59SSricharan * cache 673bb772a59SSricharan */ 674bb772a59SSricharan #define EMIF_MAX_NUM_FREQUENCIES 6 675bb772a59SSricharan /* 676bb772a59SSricharan * Indices into the Addressing Table array. 677bb772a59SSricharan * One entry each for all the different types of devices with different 678bb772a59SSricharan * addressing schemes 679bb772a59SSricharan */ 680bb772a59SSricharan #define ADDR_TABLE_INDEX64M 0 681bb772a59SSricharan #define ADDR_TABLE_INDEX128M 1 682bb772a59SSricharan #define ADDR_TABLE_INDEX256M 2 683bb772a59SSricharan #define ADDR_TABLE_INDEX512M 3 684bb772a59SSricharan #define ADDR_TABLE_INDEX1GS4 4 685bb772a59SSricharan #define ADDR_TABLE_INDEX2GS4 5 686bb772a59SSricharan #define ADDR_TABLE_INDEX4G 6 687bb772a59SSricharan #define ADDR_TABLE_INDEX8G 7 688bb772a59SSricharan #define ADDR_TABLE_INDEX1GS2 8 689bb772a59SSricharan #define ADDR_TABLE_INDEX2GS2 9 690bb772a59SSricharan #define ADDR_TABLE_INDEXMAX 10 691bb772a59SSricharan 692bb772a59SSricharan /* Number of Row bits */ 693bb772a59SSricharan #define ROW_9 0 694bb772a59SSricharan #define ROW_10 1 695bb772a59SSricharan #define ROW_11 2 696bb772a59SSricharan #define ROW_12 3 697bb772a59SSricharan #define ROW_13 4 698bb772a59SSricharan #define ROW_14 5 699bb772a59SSricharan #define ROW_15 6 700bb772a59SSricharan #define ROW_16 7 701bb772a59SSricharan 702bb772a59SSricharan /* Number of Column bits */ 703bb772a59SSricharan #define COL_8 0 704bb772a59SSricharan #define COL_9 1 705bb772a59SSricharan #define COL_10 2 706bb772a59SSricharan #define COL_11 3 707bb772a59SSricharan #define COL_7 4 /*Not supported by OMAP included for completeness */ 708bb772a59SSricharan 709bb772a59SSricharan /* Number of Banks*/ 710bb772a59SSricharan #define BANKS1 0 711bb772a59SSricharan #define BANKS2 1 712bb772a59SSricharan #define BANKS4 2 713bb772a59SSricharan #define BANKS8 3 714bb772a59SSricharan 715bb772a59SSricharan /* Refresh rate in micro seconds x 10 */ 716bb772a59SSricharan #define T_REFI_15_6 156 717bb772a59SSricharan #define T_REFI_7_8 78 718bb772a59SSricharan #define T_REFI_3_9 39 719bb772a59SSricharan 720bb772a59SSricharan #define EBANK_CS1_DIS 0 721bb772a59SSricharan #define EBANK_CS1_EN 1 722bb772a59SSricharan 723bb772a59SSricharan /* Read Latency used by the device at reset */ 724bb772a59SSricharan #define RL_BOOT 3 725bb772a59SSricharan /* Read Latency for the highest frequency you want to use */ 726bb772a59SSricharan #ifdef CONFIG_OMAP54XX 727bb772a59SSricharan #define RL_FINAL 8 728bb772a59SSricharan #else 729bb772a59SSricharan #define RL_FINAL 6 730bb772a59SSricharan #endif 731bb772a59SSricharan 732bb772a59SSricharan 733bb772a59SSricharan /* Interleaving policies at EMIF level- between banks and Chip Selects */ 734bb772a59SSricharan #define EMIF_INTERLEAVING_POLICY_MAX_INTERLEAVING 0 735bb772a59SSricharan #define EMIF_INTERLEAVING_POLICY_NO_BANK_INTERLEAVING 3 736bb772a59SSricharan 737bb772a59SSricharan /* 738bb772a59SSricharan * Interleaving policy to be used 739bb772a59SSricharan * Currently set to MAX interleaving for better performance 740bb772a59SSricharan */ 741bb772a59SSricharan #define EMIF_INTERLEAVING_POLICY EMIF_INTERLEAVING_POLICY_MAX_INTERLEAVING 742bb772a59SSricharan 743bb772a59SSricharan /* State of the core voltage: 744bb772a59SSricharan * This is important for some parameters such as read idle control and 745bb772a59SSricharan * ZQ calibration timings. Timings are much stricter when voltage ramp 746bb772a59SSricharan * is happening compared to when the voltage is stable. 747bb772a59SSricharan * We need to calculate two sets of values for these parameters and use 748bb772a59SSricharan * them accordingly 749bb772a59SSricharan */ 750bb772a59SSricharan #define LPDDR2_VOLTAGE_STABLE 0 751bb772a59SSricharan #define LPDDR2_VOLTAGE_RAMPING 1 752bb772a59SSricharan 753bb772a59SSricharan /* Length of the forced read idle period in terms of cycles */ 754bb772a59SSricharan #define EMIF_REG_READ_IDLE_LEN_VAL 5 755bb772a59SSricharan 756bb772a59SSricharan /* Interval between forced 'read idles' */ 757bb772a59SSricharan /* To be used when voltage is changed for DPS/DVFS - 1us */ 758bb772a59SSricharan #define READ_IDLE_INTERVAL_DVFS (1*1000) 759bb772a59SSricharan /* 760bb772a59SSricharan * To be used when voltage is not scaled except by Smart Reflex 761bb772a59SSricharan * 50us - or maximum value will do 762bb772a59SSricharan */ 763bb772a59SSricharan #define READ_IDLE_INTERVAL_NORMAL (50*1000) 764bb772a59SSricharan 765bb772a59SSricharan 766bb772a59SSricharan /* 767bb772a59SSricharan * Unless voltage is changing due to DVFS one ZQCS command every 50ms should 768bb772a59SSricharan * be enough. This shoule be enough also in the case when voltage is changing 769bb772a59SSricharan * due to smart-reflex. 770bb772a59SSricharan */ 771bb772a59SSricharan #define EMIF_ZQCS_INTERVAL_NORMAL_IN_US (50*1000) 772bb772a59SSricharan /* 773bb772a59SSricharan * If voltage is changing due to DVFS ZQCS should be performed more 774bb772a59SSricharan * often(every 50us) 775bb772a59SSricharan */ 776bb772a59SSricharan #define EMIF_ZQCS_INTERVAL_DVFS_IN_US 50 777bb772a59SSricharan 778bb772a59SSricharan /* The interval between ZQCL commands as a multiple of ZQCS interval */ 779bb772a59SSricharan #define REG_ZQ_ZQCL_MULT 4 780bb772a59SSricharan /* The interval between ZQINIT commands as a multiple of ZQCL interval */ 781bb772a59SSricharan #define REG_ZQ_ZQINIT_MULT 3 782bb772a59SSricharan /* Enable ZQ Calibration on exiting Self-refresh */ 783bb772a59SSricharan #define REG_ZQ_SFEXITEN_ENABLE 1 784bb772a59SSricharan /* 785bb772a59SSricharan * ZQ Calibration simultaneously on both chip-selects: 786bb772a59SSricharan * Needs one calibration resistor per CS 787bb772a59SSricharan * None of the boards that we know of have this capability 788bb772a59SSricharan * So disabled by default 789bb772a59SSricharan */ 790bb772a59SSricharan #define REG_ZQ_DUALCALEN_DISABLE 0 791bb772a59SSricharan /* 792bb772a59SSricharan * Enable ZQ Calibration by default on CS0. If we are asked to program 793bb772a59SSricharan * the EMIF there will be something connected to CS0 for sure 794bb772a59SSricharan */ 795bb772a59SSricharan #define REG_ZQ_CS0EN_ENABLE 1 796bb772a59SSricharan 797bb772a59SSricharan /* EMIF_PWR_MGMT_CTRL register */ 798bb772a59SSricharan /* Low power modes */ 799bb772a59SSricharan #define LP_MODE_DISABLE 0 800bb772a59SSricharan #define LP_MODE_CLOCK_STOP 1 801bb772a59SSricharan #define LP_MODE_SELF_REFRESH 2 802bb772a59SSricharan #define LP_MODE_PWR_DN 3 803bb772a59SSricharan 804bb772a59SSricharan /* REG_DPD_EN */ 805bb772a59SSricharan #define DPD_DISABLE 0 806bb772a59SSricharan #define DPD_ENABLE 1 807bb772a59SSricharan 808bb772a59SSricharan /* Maximum delay before Low Power Modes */ 809f4010734SSRICHARAN R #ifndef CONFIG_OMAP54XX 810bb772a59SSricharan #define REG_CS_TIM 0xF 811f4010734SSRICHARAN R #else 812f4010734SSRICHARAN R #define REG_CS_TIM 0x0 813f4010734SSRICHARAN R #endif 814bb772a59SSricharan #define REG_SR_TIM 0xF 815bb772a59SSricharan #define REG_PD_TIM 0xF 816bb772a59SSricharan 817bb772a59SSricharan /* EMIF_PWR_MGMT_CTRL register */ 818bb772a59SSricharan #define EMIF_PWR_MGMT_CTRL (\ 819bb772a59SSricharan ((REG_CS_TIM << EMIF_REG_CS_TIM_SHIFT) & EMIF_REG_CS_TIM_MASK)|\ 820bb772a59SSricharan ((REG_SR_TIM << EMIF_REG_SR_TIM_SHIFT) & EMIF_REG_SR_TIM_MASK)|\ 821bb772a59SSricharan ((REG_PD_TIM << EMIF_REG_PD_TIM_SHIFT) & EMIF_REG_PD_TIM_MASK)|\ 822bb772a59SSricharan ((REG_PD_TIM << EMIF_REG_PD_TIM_SHIFT) & EMIF_REG_PD_TIM_MASK)|\ 823bb772a59SSricharan ((LP_MODE_DISABLE << EMIF_REG_LP_MODE_SHIFT)\ 824bb772a59SSricharan & EMIF_REG_LP_MODE_MASK) |\ 825bb772a59SSricharan ((DPD_DISABLE << EMIF_REG_DPD_EN_SHIFT)\ 826bb772a59SSricharan & EMIF_REG_DPD_EN_MASK))\ 827bb772a59SSricharan 828bb772a59SSricharan #define EMIF_PWR_MGMT_CTRL_SHDW (\ 829bb772a59SSricharan ((REG_CS_TIM << EMIF_REG_CS_TIM_SHDW_SHIFT)\ 830bb772a59SSricharan & EMIF_REG_CS_TIM_SHDW_MASK) |\ 831bb772a59SSricharan ((REG_SR_TIM << EMIF_REG_SR_TIM_SHDW_SHIFT)\ 832bb772a59SSricharan & EMIF_REG_SR_TIM_SHDW_MASK) |\ 833bb772a59SSricharan ((REG_PD_TIM << EMIF_REG_PD_TIM_SHDW_SHIFT)\ 834bb772a59SSricharan & EMIF_REG_PD_TIM_SHDW_MASK) |\ 835bb772a59SSricharan ((REG_PD_TIM << EMIF_REG_PD_TIM_SHDW_SHIFT)\ 836bb772a59SSricharan & EMIF_REG_PD_TIM_SHDW_MASK)) 837bb772a59SSricharan 838bb772a59SSricharan /* EMIF_L3_CONFIG register value */ 839bb772a59SSricharan #define EMIF_L3_CONFIG_VAL_SYS_10_LL_0 0x0A0000FF 840bb772a59SSricharan #define EMIF_L3_CONFIG_VAL_SYS_10_MPU_3_LL_0 0x0A300000 841f4010734SSRICHARAN R #define EMIF_L3_CONFIG_VAL_SYS_10_MPU_5_LL_0 0x0A500000 842bb772a59SSricharan 843bb772a59SSricharan /* 844bb772a59SSricharan * Value of bits 12:31 of DDR_PHY_CTRL_1 register: 845bb772a59SSricharan * All these fields have magic values dependent on frequency and 846bb772a59SSricharan * determined by PHY and DLL integration with EMIF. Setting the magic 847bb772a59SSricharan * values suggested by hw team. 848bb772a59SSricharan */ 849bb772a59SSricharan #define EMIF_DDR_PHY_CTRL_1_BASE_VAL 0x049FF 850bb772a59SSricharan #define EMIF_DLL_SLAVE_DLY_CTRL_400_MHZ 0x41 851bb772a59SSricharan #define EMIF_DLL_SLAVE_DLY_CTRL_200_MHZ 0x80 852bb772a59SSricharan #define EMIF_DLL_SLAVE_DLY_CTRL_100_MHZ_AND_LESS 0xFF 853bb772a59SSricharan 854bb772a59SSricharan /* 855bb772a59SSricharan * MR1 value: 856bb772a59SSricharan * Burst length : 8 857bb772a59SSricharan * Burst type : sequential 858bb772a59SSricharan * Wrap : enabled 859bb772a59SSricharan * nWR : 3(default). EMIF does not do pre-charge. 860bb772a59SSricharan * : So nWR is don't care 861bb772a59SSricharan */ 862bb772a59SSricharan #define MR1_BL_8_BT_SEQ_WRAP_EN_NWR_3 0x23 863f4010734SSRICHARAN R #define MR1_BL_8_BT_SEQ_WRAP_EN_NWR_8 0xc3 864bb772a59SSricharan 865bb772a59SSricharan /* MR2 */ 866bb772a59SSricharan #define MR2_RL3_WL1 1 867bb772a59SSricharan #define MR2_RL4_WL2 2 868bb772a59SSricharan #define MR2_RL5_WL2 3 869bb772a59SSricharan #define MR2_RL6_WL3 4 870bb772a59SSricharan 871bb772a59SSricharan /* MR10: ZQ calibration codes */ 872bb772a59SSricharan #define MR10_ZQ_ZQCS 0x56 873bb772a59SSricharan #define MR10_ZQ_ZQCL 0xAB 874bb772a59SSricharan #define MR10_ZQ_ZQINIT 0xFF 875bb772a59SSricharan #define MR10_ZQ_ZQRESET 0xC3 876bb772a59SSricharan 877bb772a59SSricharan /* TEMP_ALERT_CONFIG */ 878bb772a59SSricharan #define TEMP_ALERT_POLL_INTERVAL_MS 360 /* for temp gradient - 5 C/s */ 879bb772a59SSricharan #define TEMP_ALERT_CONFIG_DEVCT_1 0 880bb772a59SSricharan #define TEMP_ALERT_CONFIG_DEVWDT_32 2 881bb772a59SSricharan 882bb772a59SSricharan /* MR16 value: refresh full array(no partial array self refresh) */ 883bb772a59SSricharan #define MR16_REF_FULL_ARRAY 0 884bb772a59SSricharan 885bb772a59SSricharan /* 886bb772a59SSricharan * Maximum number of entries we keep in our array of timing tables 887bb772a59SSricharan * We need not keep all the speed bins supported by the device 888bb772a59SSricharan * We need to keep timing tables for only the speed bins that we 889bb772a59SSricharan * are interested in 890bb772a59SSricharan */ 891bb772a59SSricharan #define MAX_NUM_SPEEDBINS 4 892bb772a59SSricharan 893bb772a59SSricharan /* LPDDR2 Densities */ 894bb772a59SSricharan #define LPDDR2_DENSITY_64Mb 0 895bb772a59SSricharan #define LPDDR2_DENSITY_128Mb 1 896bb772a59SSricharan #define LPDDR2_DENSITY_256Mb 2 897bb772a59SSricharan #define LPDDR2_DENSITY_512Mb 3 898bb772a59SSricharan #define LPDDR2_DENSITY_1Gb 4 899bb772a59SSricharan #define LPDDR2_DENSITY_2Gb 5 900bb772a59SSricharan #define LPDDR2_DENSITY_4Gb 6 901bb772a59SSricharan #define LPDDR2_DENSITY_8Gb 7 902bb772a59SSricharan #define LPDDR2_DENSITY_16Gb 8 903bb772a59SSricharan #define LPDDR2_DENSITY_32Gb 9 904bb772a59SSricharan 905bb772a59SSricharan /* LPDDR2 type */ 906bb772a59SSricharan #define LPDDR2_TYPE_S4 0 907bb772a59SSricharan #define LPDDR2_TYPE_S2 1 908bb772a59SSricharan #define LPDDR2_TYPE_NVM 2 909bb772a59SSricharan 910bb772a59SSricharan /* LPDDR2 IO width */ 911bb772a59SSricharan #define LPDDR2_IO_WIDTH_32 0 912bb772a59SSricharan #define LPDDR2_IO_WIDTH_16 1 913bb772a59SSricharan #define LPDDR2_IO_WIDTH_8 2 914bb772a59SSricharan 915bb772a59SSricharan /* Mode register numbers */ 916bb772a59SSricharan #define LPDDR2_MR0 0 917bb772a59SSricharan #define LPDDR2_MR1 1 918bb772a59SSricharan #define LPDDR2_MR2 2 919bb772a59SSricharan #define LPDDR2_MR3 3 920bb772a59SSricharan #define LPDDR2_MR4 4 921bb772a59SSricharan #define LPDDR2_MR5 5 922bb772a59SSricharan #define LPDDR2_MR6 6 923bb772a59SSricharan #define LPDDR2_MR7 7 924bb772a59SSricharan #define LPDDR2_MR8 8 925bb772a59SSricharan #define LPDDR2_MR9 9 926bb772a59SSricharan #define LPDDR2_MR10 10 927bb772a59SSricharan #define LPDDR2_MR11 11 928bb772a59SSricharan #define LPDDR2_MR16 16 929bb772a59SSricharan #define LPDDR2_MR17 17 930bb772a59SSricharan #define LPDDR2_MR18 18 931bb772a59SSricharan 932bb772a59SSricharan /* MR0 */ 933bb772a59SSricharan #define LPDDR2_MR0_DAI_SHIFT 0 934bb772a59SSricharan #define LPDDR2_MR0_DAI_MASK 1 935bb772a59SSricharan #define LPDDR2_MR0_DI_SHIFT 1 936bb772a59SSricharan #define LPDDR2_MR0_DI_MASK (1 << 1) 937bb772a59SSricharan #define LPDDR2_MR0_DNVI_SHIFT 2 938bb772a59SSricharan #define LPDDR2_MR0_DNVI_MASK (1 << 2) 939bb772a59SSricharan 940bb772a59SSricharan /* MR4 */ 941bb772a59SSricharan #define MR4_SDRAM_REF_RATE_SHIFT 0 942bb772a59SSricharan #define MR4_SDRAM_REF_RATE_MASK 7 943bb772a59SSricharan #define MR4_TUF_SHIFT 7 944bb772a59SSricharan #define MR4_TUF_MASK (1 << 7) 945bb772a59SSricharan 946bb772a59SSricharan /* MR4 SDRAM Refresh Rate field values */ 947bb772a59SSricharan #define SDRAM_TEMP_LESS_LOW_SHUTDOWN 0x0 948bb772a59SSricharan #define SDRAM_TEMP_LESS_4X_REFRESH_AND_TIMINGS 0x1 949bb772a59SSricharan #define SDRAM_TEMP_LESS_2X_REFRESH_AND_TIMINGS 0x2 950bb772a59SSricharan #define SDRAM_TEMP_NOMINAL 0x3 951bb772a59SSricharan #define SDRAM_TEMP_RESERVED_4 0x4 952bb772a59SSricharan #define SDRAM_TEMP_HIGH_DERATE_REFRESH 0x5 953bb772a59SSricharan #define SDRAM_TEMP_HIGH_DERATE_REFRESH_AND_TIMINGS 0x6 954bb772a59SSricharan #define SDRAM_TEMP_VERY_HIGH_SHUTDOWN 0x7 955bb772a59SSricharan 956bb772a59SSricharan #define LPDDR2_MANUFACTURER_SAMSUNG 1 957bb772a59SSricharan #define LPDDR2_MANUFACTURER_QIMONDA 2 958bb772a59SSricharan #define LPDDR2_MANUFACTURER_ELPIDA 3 959bb772a59SSricharan #define LPDDR2_MANUFACTURER_ETRON 4 960bb772a59SSricharan #define LPDDR2_MANUFACTURER_NANYA 5 961bb772a59SSricharan #define LPDDR2_MANUFACTURER_HYNIX 6 962bb772a59SSricharan #define LPDDR2_MANUFACTURER_MOSEL 7 963bb772a59SSricharan #define LPDDR2_MANUFACTURER_WINBOND 8 964bb772a59SSricharan #define LPDDR2_MANUFACTURER_ESMT 9 965bb772a59SSricharan #define LPDDR2_MANUFACTURER_SPANSION 11 966bb772a59SSricharan #define LPDDR2_MANUFACTURER_SST 12 967bb772a59SSricharan #define LPDDR2_MANUFACTURER_ZMOS 13 968bb772a59SSricharan #define LPDDR2_MANUFACTURER_INTEL 14 969bb772a59SSricharan #define LPDDR2_MANUFACTURER_NUMONYX 254 970bb772a59SSricharan #define LPDDR2_MANUFACTURER_MICRON 255 971bb772a59SSricharan 972bb772a59SSricharan /* MR8 register fields */ 973bb772a59SSricharan #define MR8_TYPE_SHIFT 0x0 974bb772a59SSricharan #define MR8_TYPE_MASK 0x3 975bb772a59SSricharan #define MR8_DENSITY_SHIFT 0x2 976bb772a59SSricharan #define MR8_DENSITY_MASK (0xF << 0x2) 977bb772a59SSricharan #define MR8_IO_WIDTH_SHIFT 0x6 978bb772a59SSricharan #define MR8_IO_WIDTH_MASK (0x3 << 0x6) 979bb772a59SSricharan 980bb772a59SSricharan struct lpddr2_addressing { 981bb772a59SSricharan u8 num_banks; 982bb772a59SSricharan u8 t_REFI_us_x10; 983bb772a59SSricharan u8 row_sz[2]; /* One entry each for x32 and x16 */ 984bb772a59SSricharan u8 col_sz[2]; /* One entry each for x32 and x16 */ 985bb772a59SSricharan }; 986bb772a59SSricharan 987bb772a59SSricharan /* Structure for timings from the DDR datasheet */ 988bb772a59SSricharan struct lpddr2_ac_timings { 989bb772a59SSricharan u32 max_freq; 990bb772a59SSricharan u8 RL; 991bb772a59SSricharan u8 tRPab; 992bb772a59SSricharan u8 tRCD; 993bb772a59SSricharan u8 tWR; 994bb772a59SSricharan u8 tRASmin; 995bb772a59SSricharan u8 tRRD; 996bb772a59SSricharan u8 tWTRx2; 997bb772a59SSricharan u8 tXSR; 998bb772a59SSricharan u8 tXPx2; 999bb772a59SSricharan u8 tRFCab; 1000bb772a59SSricharan u8 tRTPx2; 1001bb772a59SSricharan u8 tCKE; 1002bb772a59SSricharan u8 tCKESR; 1003bb772a59SSricharan u8 tZQCS; 1004bb772a59SSricharan u32 tZQCL; 1005bb772a59SSricharan u32 tZQINIT; 1006bb772a59SSricharan u8 tDQSCKMAXx2; 1007bb772a59SSricharan u8 tRASmax; 1008bb772a59SSricharan u8 tFAW; 1009bb772a59SSricharan 1010bb772a59SSricharan }; 1011bb772a59SSricharan 1012bb772a59SSricharan /* 1013bb772a59SSricharan * Min tCK values for some of the parameters: 1014bb772a59SSricharan * If the calculated clock cycles for the respective parameter is 1015bb772a59SSricharan * less than the corresponding min tCK value, we need to set the min 1016bb772a59SSricharan * tCK value. This may happen at lower frequencies. 1017bb772a59SSricharan */ 1018bb772a59SSricharan struct lpddr2_min_tck { 1019bb772a59SSricharan u32 tRL; 1020bb772a59SSricharan u32 tRP_AB; 1021bb772a59SSricharan u32 tRCD; 1022bb772a59SSricharan u32 tWR; 1023bb772a59SSricharan u32 tRAS_MIN; 1024bb772a59SSricharan u32 tRRD; 1025bb772a59SSricharan u32 tWTR; 1026bb772a59SSricharan u32 tXP; 1027bb772a59SSricharan u32 tRTP; 1028bb772a59SSricharan u8 tCKE; 1029bb772a59SSricharan u32 tCKESR; 1030bb772a59SSricharan u32 tFAW; 1031bb772a59SSricharan }; 1032bb772a59SSricharan 1033bb772a59SSricharan struct lpddr2_device_details { 1034bb772a59SSricharan u8 type; 1035bb772a59SSricharan u8 density; 1036bb772a59SSricharan u8 io_width; 1037bb772a59SSricharan u8 manufacturer; 1038bb772a59SSricharan }; 1039bb772a59SSricharan 1040bb772a59SSricharan struct lpddr2_device_timings { 1041bb772a59SSricharan const struct lpddr2_ac_timings **ac_timings; 1042bb772a59SSricharan const struct lpddr2_min_tck *min_tck; 1043bb772a59SSricharan }; 1044bb772a59SSricharan 1045bb772a59SSricharan /* Details of the devices connected to each chip-select of an EMIF instance */ 1046bb772a59SSricharan struct emif_device_details { 1047bb772a59SSricharan const struct lpddr2_device_details *cs0_device_details; 1048bb772a59SSricharan const struct lpddr2_device_details *cs1_device_details; 1049bb772a59SSricharan const struct lpddr2_device_timings *cs0_device_timings; 1050bb772a59SSricharan const struct lpddr2_device_timings *cs1_device_timings; 1051bb772a59SSricharan }; 1052bb772a59SSricharan 1053bb772a59SSricharan /* 1054bb772a59SSricharan * Structure containing shadow of important registers in EMIF 1055bb772a59SSricharan * The calculation function fills in this structure to be later used for 1056bb772a59SSricharan * initialization and DVFS 1057bb772a59SSricharan */ 1058bb772a59SSricharan struct emif_regs { 1059bb772a59SSricharan u32 freq; 1060bb772a59SSricharan u32 sdram_config_init; 1061bb772a59SSricharan u32 sdram_config; 1062bb772a59SSricharan u32 ref_ctrl; 1063bb772a59SSricharan u32 sdram_tim1; 1064bb772a59SSricharan u32 sdram_tim2; 1065bb772a59SSricharan u32 sdram_tim3; 1066bb772a59SSricharan u32 read_idle_ctrl; 1067bb772a59SSricharan u32 zq_config; 1068bb772a59SSricharan u32 temp_alert_config; 1069bb772a59SSricharan u32 emif_ddr_phy_ctlr_1_init; 1070bb772a59SSricharan u32 emif_ddr_phy_ctlr_1; 1071f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_1; 1072f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_2; 1073f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_3; 1074f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_4; 1075f4010734SSRICHARAN R u32 emif_ddr_ext_phy_ctrl_5; 1076bb772a59SSricharan }; 1077bb772a59SSricharan 1078bb772a59SSricharan /* assert macros */ 1079bb772a59SSricharan #if defined(DEBUG) 1080bb772a59SSricharan #define emif_assert(c) ({ if (!(c)) for (;;); }) 1081bb772a59SSricharan #else 1082bb772a59SSricharan #define emif_assert(c) ({ if (0) hang(); }) 1083bb772a59SSricharan #endif 1084bb772a59SSricharan 1085bb772a59SSricharan #ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS 1086bb772a59SSricharan void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs); 1087bb772a59SSricharan void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs); 1088bb772a59SSricharan #else 1089bb772a59SSricharan struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs, 1090bb772a59SSricharan struct lpddr2_device_details *lpddr2_dev_details); 1091bb772a59SSricharan void emif_get_device_timings(u32 emif_nr, 1092bb772a59SSricharan const struct lpddr2_device_timings **cs0_device_timings, 1093bb772a59SSricharan const struct lpddr2_device_timings **cs1_device_timings); 1094bb772a59SSricharan #endif 1095bb772a59SSricharan 1096bb772a59SSricharan #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS 1097bb772a59SSricharan extern u32 *const T_num; 1098bb772a59SSricharan extern u32 *const T_den; 1099bb772a59SSricharan extern u32 *const emif_sizes; 1100bb772a59SSricharan #endif 1101bb772a59SSricharan 1102bb772a59SSricharan 1103bb772a59SSricharan #endif 1104