Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 1 | /* |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 2 | * Machine Specific Values for SMDK5250 board based on EXYNOS5 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2012 Samsung Electronics |
| 5 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef _SMDK5250_SETUP_H |
| 10 | #define _SMDK5250_SETUP_H |
| 11 | |
| 12 | #include <config.h> |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 13 | #include <asm/arch/dmc.h> |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 14 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 15 | #define NOT_AVAILABLE 0 |
| 16 | #define DATA_MASK 0xFFFFF |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 17 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 18 | #define ENABLE_BIT 0x1 |
| 19 | #define DISABLE_BIT 0x0 |
| 20 | #define CA_SWAP_EN (1 << 0) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 21 | |
| 22 | /* Set PLL */ |
| 23 | #define set_pll(mdiv, pdiv, sdiv) (1<<31 | mdiv<<16 | pdiv<<8 | sdiv) |
| 24 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 25 | /* MEMCONTROL register bit fields */ |
| 26 | #define DMC_MEMCONTROL_CLK_STOP_DISABLE (0 << 0) |
| 27 | #define DMC_MEMCONTROL_DPWRDN_DISABLE (0 << 1) |
| 28 | #define DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE (0 << 2) |
| 29 | #define DMC_MEMCONTROL_TP_DISABLE (0 << 4) |
| 30 | #define DMC_MEMCONTROL_DSREF_DISABLE (0 << 5) |
| 31 | #define DMC_MEMCONTROL_DSREF_ENABLE (1 << 5) |
| 32 | #define DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(x) (x << 6) |
| 33 | |
| 34 | #define DMC_MEMCONTROL_MEM_TYPE_LPDDR3 (7 << 8) |
| 35 | #define DMC_MEMCONTROL_MEM_TYPE_DDR3 (6 << 8) |
| 36 | #define DMC_MEMCONTROL_MEM_TYPE_LPDDR2 (5 << 8) |
| 37 | |
| 38 | #define DMC_MEMCONTROL_MEM_WIDTH_32BIT (2 << 12) |
| 39 | |
| 40 | #define DMC_MEMCONTROL_NUM_CHIP_1 (0 << 16) |
| 41 | #define DMC_MEMCONTROL_NUM_CHIP_2 (1 << 16) |
| 42 | |
| 43 | #define DMC_MEMCONTROL_BL_8 (3 << 20) |
| 44 | #define DMC_MEMCONTROL_BL_4 (2 << 20) |
| 45 | |
| 46 | #define DMC_MEMCONTROL_PZQ_DISABLE (0 << 24) |
| 47 | |
| 48 | #define DMC_MEMCONTROL_MRR_BYTE_7_0 (0 << 25) |
| 49 | #define DMC_MEMCONTROL_MRR_BYTE_15_8 (1 << 25) |
| 50 | #define DMC_MEMCONTROL_MRR_BYTE_23_16 (2 << 25) |
| 51 | #define DMC_MEMCONTROL_MRR_BYTE_31_24 (3 << 25) |
| 52 | |
| 53 | /* MEMCONFIG0 register bit fields */ |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 54 | #define DMC_MEMCONFIGX_CHIP_MAP_INTERLEAVED (1 << 12) |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 55 | #define DMC_MEMCONFIG_CHIP_MAP_SPLIT (2 << 12) |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 56 | #define DMC_MEMCONFIGX_CHIP_COL_10 (3 << 8) |
| 57 | #define DMC_MEMCONFIGX_CHIP_ROW_14 (2 << 4) |
| 58 | #define DMC_MEMCONFIGX_CHIP_ROW_15 (3 << 4) |
| 59 | #define DMC_MEMCONFIGX_CHIP_BANK_8 (3 << 0) |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 60 | |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 61 | #define DMC_MEMBASECONFIGX_CHIP_BASE(x) (x << 16) |
| 62 | #define DMC_MEMBASECONFIGX_CHIP_MASK(x) (x << 0) |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 63 | #define DMC_MEMBASECONFIG_VAL(x) ( \ |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 64 | DMC_MEMBASECONFIGX_CHIP_BASE(x) | \ |
| 65 | DMC_MEMBASECONFIGX_CHIP_MASK(0x780) \ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 66 | ) |
| 67 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 68 | /* |
| 69 | * As we use channel interleaving, therefore value of the base address |
| 70 | * register must be set as half of the bus base address |
| 71 | * RAM start addess is 0x2000_0000 which means chip_base is 0x20, so |
| 72 | * we need to set half 0x10 to the membaseconfigx registers |
| 73 | * see exynos5420 UM section 17.17.3.21 for more. |
| 74 | */ |
| 75 | #define DMC_CHIP_BASE_0 0x10 |
| 76 | #define DMC_CHIP_BASE_1 0x50 |
| 77 | #define DMC_CHIP_MASK 0x7C0 |
| 78 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 79 | #define DMC_MEMBASECONFIG0_VAL DMC_MEMBASECONFIG_VAL(0x40) |
| 80 | #define DMC_MEMBASECONFIG1_VAL DMC_MEMBASECONFIG_VAL(0x80) |
| 81 | |
| 82 | #define DMC_PRECHCONFIG_VAL 0xFF000000 |
| 83 | #define DMC_PWRDNCONFIG_VAL 0xFFFF00FF |
| 84 | |
| 85 | #define DMC_CONCONTROL_RESET_VAL 0x0FFF0000 |
| 86 | #define DFI_INIT_START (1 << 28) |
| 87 | #define EMPTY (1 << 8) |
| 88 | #define AREF_EN (1 << 5) |
| 89 | |
| 90 | #define DFI_INIT_COMPLETE_CHO (1 << 2) |
| 91 | #define DFI_INIT_COMPLETE_CH1 (1 << 3) |
| 92 | |
| 93 | #define RDLVL_COMPLETE_CHO (1 << 14) |
| 94 | #define RDLVL_COMPLETE_CH1 (1 << 15) |
| 95 | |
| 96 | #define CLK_STOP_EN (1 << 0) |
| 97 | #define DPWRDN_EN (1 << 1) |
| 98 | #define DSREF_EN (1 << 5) |
| 99 | |
| 100 | /* COJCONTROL register bit fields */ |
| 101 | #define DMC_CONCONTROL_IO_PD_CON_DISABLE (0 << 3) |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 102 | #define DMC_CONCONTROL_IO_PD_CON_ENABLE (1 << 3) |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 103 | #define DMC_CONCONTROL_AREF_EN_DISABLE (0 << 5) |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 104 | #define DMC_CONCONTROL_AREF_EN_ENABLE (1 << 5) |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 105 | #define DMC_CONCONTROL_EMPTY_DISABLE (0 << 8) |
| 106 | #define DMC_CONCONTROL_EMPTY_ENABLE (1 << 8) |
| 107 | #define DMC_CONCONTROL_RD_FETCH_DISABLE (0x0 << 12) |
| 108 | #define DMC_CONCONTROL_TIMEOUT_LEVEL0 (0xFFF << 16) |
| 109 | #define DMC_CONCONTROL_DFI_INIT_START_DISABLE (0 << 28) |
| 110 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 111 | #define DMC_CONCONTROL_VAL 0x1FFF2101 |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 112 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 113 | #define DREX_CONCONTROL_VAL DMC_CONCONTROL_VAL \ |
| 114 | | DMC_CONCONTROL_AREF_EN_ENABLE \ |
| 115 | | DMC_CONCONTROL_IO_PD_CON_ENABLE |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 116 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 117 | #define DMC_CONCONTROL_IO_PD_CON(x) (x << 6) |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 118 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 119 | /* CLK_DIV_CPU1 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 120 | #define HPM_RATIO 0x2 |
| 121 | #define COPY_RATIO 0x0 |
| 122 | |
| 123 | /* CLK_DIV_CPU1 = 0x00000003 */ |
| 124 | #define CLK_DIV_CPU1_VAL ((HPM_RATIO << 4) \ |
| 125 | | (COPY_RATIO)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 126 | |
| 127 | /* CLK_SRC_CORE0 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 128 | #define CLK_SRC_CORE0_VAL 0x00000000 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 129 | |
| 130 | /* CLK_SRC_CORE1 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 131 | #define CLK_SRC_CORE1_VAL 0x100 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 132 | |
| 133 | /* CLK_DIV_CORE0 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 134 | #define CLK_DIV_CORE0_VAL 0x00120000 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 135 | |
| 136 | /* CLK_DIV_CORE1 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 137 | #define CLK_DIV_CORE1_VAL 0x07070700 |
| 138 | |
| 139 | /* CLK_DIV_SYSRGT */ |
| 140 | #define CLK_DIV_SYSRGT_VAL 0x00000111 |
| 141 | |
| 142 | /* CLK_DIV_ACP */ |
| 143 | #define CLK_DIV_ACP_VAL 0x12 |
| 144 | |
| 145 | /* CLK_DIV_SYSLFT */ |
| 146 | #define CLK_DIV_SYSLFT_VAL 0x00000311 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 147 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 148 | #define MUX_APLL_SEL_MASK (1 << 0) |
| 149 | #define MUX_MPLL_SEL_MASK (1 << 8) |
| 150 | #define MPLL_SEL_MOUT_MPLLFOUT (2 << 8) |
| 151 | #define MUX_CPLL_SEL_MASK (1 << 8) |
| 152 | #define MUX_EPLL_SEL_MASK (1 << 12) |
| 153 | #define MUX_VPLL_SEL_MASK (1 << 16) |
| 154 | #define MUX_GPLL_SEL_MASK (1 << 28) |
| 155 | #define MUX_BPLL_SEL_MASK (1 << 0) |
| 156 | #define MUX_HPM_SEL_MASK (1 << 20) |
| 157 | #define HPM_SEL_SCLK_MPLL (1 << 21) |
| 158 | #define PLL_LOCKED (1 << 29) |
| 159 | #define APLL_CON0_LOCKED (1 << 29) |
| 160 | #define MPLL_CON0_LOCKED (1 << 29) |
| 161 | #define BPLL_CON0_LOCKED (1 << 29) |
| 162 | #define CPLL_CON0_LOCKED (1 << 29) |
| 163 | #define EPLL_CON0_LOCKED (1 << 29) |
| 164 | #define GPLL_CON0_LOCKED (1 << 29) |
| 165 | #define VPLL_CON0_LOCKED (1 << 29) |
| 166 | #define CLK_REG_DISABLE 0x0 |
| 167 | #define TOP2_VAL 0x0110000 |
| 168 | |
| 169 | /* SCLK_SRC_ISP - set SPI0/1 to 6 = SCLK_MPLL_USER */ |
| 170 | #define SPI0_ISP_SEL 6 |
| 171 | #define SPI1_ISP_SEL 6 |
| 172 | #define SCLK_SRC_ISP_VAL (SPI1_ISP_SEL << 4) \ |
| 173 | | (SPI0_ISP_SEL << 0) |
| 174 | |
| 175 | /* SCLK_DIV_ISP - set SPI0/1 to 0xf = divide by 16 */ |
| 176 | #define SPI0_ISP_RATIO 0xf |
| 177 | #define SPI1_ISP_RATIO 0xf |
| 178 | #define SCLK_DIV_ISP_VAL (SPI1_ISP_RATIO << 12) \ |
| 179 | | (SPI0_ISP_RATIO << 0) |
| 180 | |
| 181 | /* CLK_DIV_FSYS2 */ |
| 182 | #define MMC2_RATIO_MASK 0xf |
| 183 | #define MMC2_RATIO_VAL 0x3 |
| 184 | #define MMC2_RATIO_OFFSET 0 |
| 185 | |
| 186 | #define MMC2_PRE_RATIO_MASK 0xff |
| 187 | #define MMC2_PRE_RATIO_VAL 0x9 |
| 188 | #define MMC2_PRE_RATIO_OFFSET 8 |
| 189 | |
| 190 | #define MMC3_RATIO_MASK 0xf |
| 191 | #define MMC3_RATIO_VAL 0x1 |
| 192 | #define MMC3_RATIO_OFFSET 16 |
| 193 | |
| 194 | #define MMC3_PRE_RATIO_MASK 0xff |
| 195 | #define MMC3_PRE_RATIO_VAL 0x0 |
| 196 | #define MMC3_PRE_RATIO_OFFSET 24 |
| 197 | |
| 198 | /* CLK_SRC_LEX */ |
| 199 | #define CLK_SRC_LEX_VAL 0x0 |
| 200 | |
| 201 | /* CLK_DIV_LEX */ |
| 202 | #define CLK_DIV_LEX_VAL 0x10 |
| 203 | |
| 204 | /* CLK_DIV_R0X */ |
| 205 | #define CLK_DIV_R0X_VAL 0x10 |
| 206 | |
| 207 | /* CLK_DIV_L0X */ |
| 208 | #define CLK_DIV_R1X_VAL 0x10 |
| 209 | |
| 210 | /* CLK_DIV_ISP2 */ |
| 211 | #define CLK_DIV_ISP2_VAL 0x1 |
| 212 | |
| 213 | /* CLK_SRC_KFC */ |
| 214 | #define SRC_KFC_HPM_SEL (1 << 15) |
| 215 | |
| 216 | /* CLK_SRC_KFC */ |
| 217 | #define CLK_SRC_KFC_VAL 0x00008001 |
| 218 | |
| 219 | /* CLK_DIV_KFC */ |
| 220 | #define CLK_DIV_KFC_VAL 0x03300110 |
| 221 | |
| 222 | /* CLK_DIV2_RATIO */ |
| 223 | #define CLK_DIV2_RATIO 0x10111150 |
| 224 | |
| 225 | /* CLK_DIV4_RATIO */ |
| 226 | #define CLK_DIV4_RATIO 0x00000003 |
| 227 | |
| 228 | /* CLK_DIV_G2D */ |
| 229 | #define CLK_DIV_G2D 0x00000010 |
| 230 | |
| 231 | /* |
| 232 | * DIV_DISP1_0 |
| 233 | * For DP, divisor should be 2 |
| 234 | */ |
| 235 | #define CLK_DIV_DISP1_0_FIMD1 (2 << 0) |
| 236 | |
| 237 | /* CLK_GATE_IP_DISP1 */ |
| 238 | #define CLK_GATE_DP1_ALLOW (1 << 4) |
| 239 | |
| 240 | /* AUDIO CLK SEL */ |
| 241 | #define AUDIO0_SEL_EPLL (0x6 << 28) |
| 242 | #define AUDIO0_RATIO 0x5 |
| 243 | #define PCM0_RATIO 0x3 |
| 244 | #define DIV_MAU_VAL (PCM0_RATIO << 24 | AUDIO0_RATIO << 20) |
| 245 | |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 246 | /* CLK_SRC_CDREX */ |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 247 | #define MUX_MCLK_CDR_MSPLL (1 << 4) |
| 248 | #define MUX_BPLL_SEL_FOUTBPLL (1 << 0) |
| 249 | #define BPLL_SEL_MASK 0x7 |
| 250 | #define FOUTBPLL 2 |
| 251 | |
| 252 | #define DDR3PHY_CTRL_PHY_RESET (1 << 0) |
| 253 | #define DDR3PHY_CTRL_PHY_RESET_OFF (0 << 0) |
| 254 | |
| 255 | #define PHY_CON0_RESET_VAL 0x17020a40 |
| 256 | #define P0_CMD_EN (1 << 14) |
| 257 | #define BYTE_RDLVL_EN (1 << 13) |
| 258 | #define CTRL_SHGATE (1 << 8) |
| 259 | |
| 260 | #define PHY_CON1_RESET_VAL 0x09210100 |
| 261 | #define RDLVL_PASS_ADJ_VAL 0x6 |
| 262 | #define RDLVL_PASS_ADJ_OFFSET 16 |
| 263 | #define CTRL_GATEDURADJ_MASK (0xf << 20) |
| 264 | #define READ_LEVELLING_DDR3 0x0100 |
| 265 | |
| 266 | #define PHY_CON2_RESET_VAL 0x00010004 |
| 267 | #define INIT_DESKEW_EN (1 << 6) |
| 268 | #define DLL_DESKEW_EN (1 << 12) |
| 269 | #define RDLVL_GATE_EN (1 << 24) |
| 270 | #define RDLVL_EN (1 << 25) |
| 271 | #define RDLVL_INCR_ADJ (0x1 << 16) |
| 272 | |
| 273 | /* DREX_PAUSE */ |
| 274 | #define DREX_PAUSE_EN (1 << 0) |
| 275 | |
| 276 | #define BYPASS_EN (1 << 22) |
| 277 | |
| 278 | /* MEMMORY VAL */ |
| 279 | #define PHY_CON0_VAL 0x17021A00 |
| 280 | |
| 281 | #define PHY_CON12_RESET_VAL 0x10100070 |
| 282 | #define PHY_CON12_VAL 0x10107F50 |
| 283 | #define CTRL_START (1 << 6) |
| 284 | #define CTRL_DLL_ON (1 << 5) |
| 285 | #define CTRL_FORCE_MASK (0x7F << 8) |
| 286 | #define CTRL_LOCK_COARSE_MASK (0x7F << 10) |
| 287 | |
| 288 | #define CTRL_OFFSETD_RESET_VAL 0x8 |
| 289 | #define CTRL_OFFSETD_VAL 0x7F |
| 290 | |
| 291 | #define CTRL_OFFSETR0 0x7F |
| 292 | #define CTRL_OFFSETR1 0x7F |
| 293 | #define CTRL_OFFSETR2 0x7F |
| 294 | #define CTRL_OFFSETR3 0x7F |
| 295 | #define PHY_CON4_VAL (CTRL_OFFSETR0 << 0 | \ |
| 296 | CTRL_OFFSETR1 << 8 | \ |
| 297 | CTRL_OFFSETR2 << 16 | \ |
| 298 | CTRL_OFFSETR3 << 24) |
| 299 | #define PHY_CON4_RESET_VAL 0x08080808 |
| 300 | |
| 301 | #define CTRL_OFFSETW0 0x7F |
| 302 | #define CTRL_OFFSETW1 0x7F |
| 303 | #define CTRL_OFFSETW2 0x7F |
| 304 | #define CTRL_OFFSETW3 0x7F |
| 305 | #define PHY_CON6_VAL (CTRL_OFFSETW0 << 0 | \ |
| 306 | CTRL_OFFSETW1 << 8 | \ |
| 307 | CTRL_OFFSETW2 << 16 | \ |
| 308 | CTRL_OFFSETW3 << 24) |
| 309 | #define PHY_CON6_RESET_VAL 0x08080808 |
| 310 | |
| 311 | #define PHY_CON14_RESET_VAL 0x001F0000 |
| 312 | #define CTRL_PULLD_DQS 0xF |
| 313 | #define CTRL_PULLD_DQS_OFFSET 0 |
| 314 | |
| 315 | /* ZQ Configurations */ |
| 316 | #define PHY_CON16_RESET_VAL 0x08000304 |
| 317 | |
| 318 | #define ZQ_CLK_EN (1 << 27) |
| 319 | #define ZQ_CLK_DIV_EN (1 << 18) |
| 320 | #define ZQ_MANUAL_STR (1 << 1) |
| 321 | #define ZQ_DONE (1 << 0) |
| 322 | #define ZQ_MODE_DDS_OFFSET 24 |
| 323 | |
| 324 | #define CTRL_RDLVL_GATE_ENABLE 1 |
| 325 | #define CTRL_RDLVL_GATE_DISABLE 0 |
| 326 | #define CTRL_RDLVL_DATA_ENABLE 2 |
| 327 | |
| 328 | /* Direct Command */ |
| 329 | #define DIRECT_CMD_NOP 0x07000000 |
| 330 | #define DIRECT_CMD_PALL 0x01000000 |
| 331 | #define DIRECT_CMD_ZQINIT 0x0a000000 |
| 332 | #define DIRECT_CMD_CHANNEL_SHIFT 28 |
| 333 | #define DIRECT_CMD_CHIP_SHIFT 20 |
| 334 | #define DIRECT_CMD_BANK_SHIFT 16 |
| 335 | #define DIRECT_CMD_REFA (5 << 24) |
| 336 | #define DIRECT_CMD_MRS1 0x71C00 |
| 337 | #define DIRECT_CMD_MRS2 0x10BFC |
| 338 | #define DIRECT_CMD_MRS3 0x0050C |
| 339 | #define DIRECT_CMD_MRS4 0x00868 |
| 340 | #define DIRECT_CMD_MRS5 0x00C04 |
| 341 | |
| 342 | /* Drive Strength */ |
| 343 | #define IMPEDANCE_48_OHM 4 |
| 344 | #define IMPEDANCE_40_OHM 5 |
| 345 | #define IMPEDANCE_34_OHM 6 |
| 346 | #define IMPEDANCE_30_OHM 7 |
| 347 | #define PHY_CON39_VAL_48_OHM 0x09240924 |
| 348 | #define PHY_CON39_VAL_40_OHM 0x0B6D0B6D |
| 349 | #define PHY_CON39_VAL_34_OHM 0x0DB60DB6 |
| 350 | #define PHY_CON39_VAL_30_OHM 0x0FFF0FFF |
| 351 | |
| 352 | #define CTRL_BSTLEN_OFFSET 8 |
| 353 | #define CTRL_RDLAT_OFFSET 0 |
| 354 | |
| 355 | #define CMD_DEFAULT_LPDDR3 0xF |
| 356 | #define CMD_DEFUALT_OFFSET 0 |
| 357 | #define T_WRDATA_EN 0x7 |
| 358 | #define T_WRDATA_EN_DDR3 0x8 |
| 359 | #define T_WRDATA_EN_OFFSET 16 |
| 360 | #define T_WRDATA_EN_MASK 0x1f |
| 361 | |
| 362 | #define PHY_CON31_VAL 0x0C183060 |
| 363 | #define PHY_CON32_VAL 0x60C18306 |
| 364 | #define PHY_CON33_VAL 0x00000030 |
| 365 | |
| 366 | #define PHY_CON31_RESET_VAL 0x0 |
| 367 | #define PHY_CON32_RESET_VAL 0x0 |
| 368 | #define PHY_CON33_RESET_VAL 0x0 |
| 369 | |
| 370 | #define SL_DLL_DYN_CON_EN (1 << 1) |
| 371 | #define FP_RESYNC (1 << 3) |
| 372 | #define CTRL_START (1 << 6) |
| 373 | |
| 374 | #define DMC_AREF_EN (1 << 5) |
| 375 | #define DMC_CONCONTROL_EMPTY (1 << 8) |
| 376 | #define DFI_INIT_START (1 << 28) |
| 377 | |
| 378 | #define DMC_MEMCONTROL_VAL 0x00312700 |
| 379 | #define CLK_STOP_EN (1 << 0) |
| 380 | #define DPWRDN_EN (1 << 1) |
| 381 | #define DSREF_EN (1 << 5) |
| 382 | |
| 383 | #define MEMBASECONFIG_CHIP_MASK_VAL 0x7E0 |
| 384 | #define MEMBASECONFIG_CHIP_MASK_OFFSET 0 |
| 385 | #define MEMBASECONFIG0_CHIP_BASE_VAL 0x20 |
| 386 | #define MEMBASECONFIG1_CHIP_BASE_VAL 0x40 |
| 387 | #define CHIP_BASE_OFFSET 16 |
| 388 | |
| 389 | #define MEMCONFIG_VAL 0x1323 |
| 390 | #define PRECHCONFIG_DEFAULT_VAL 0xFF000000 |
| 391 | #define PWRDNCONFIG_DEFAULT_VAL 0xFFFF00FF |
| 392 | |
| 393 | #define TIMINGAREF_VAL 0x5d |
| 394 | #define TIMINGROW_VAL 0x345A8692 |
| 395 | #define TIMINGDATA_VAL 0x3630065C |
| 396 | #define TIMINGPOWER_VAL 0x50380336 |
| 397 | #define DFI_INIT_COMPLETE (1 << 3) |
| 398 | |
| 399 | #define BRBRSVCONTROL_VAL 0x00000033 |
| 400 | #define BRBRSVCONFIG_VAL 0x88778877 |
| 401 | |
| 402 | /* Clock Gating Control (CGCONTROL) register */ |
| 403 | #define MEMIF_CG_EN (1 << 3) /* Memory interface clock gating */ |
| 404 | #define SCG_CG_EN (1 << 2) /* Scheduler clock gating */ |
| 405 | #define BUSIF_WR_CG_EN (1 << 1) /* Bus interface write channel clock gating */ |
| 406 | #define BUSIF_RD_CG_EN (1 << 0) /* Bus interface read channel clock gating */ |
| 407 | #define DMC_INTERNAL_CG (MEMIF_CG_EN | SCG_CG_EN | \ |
| 408 | BUSIF_WR_CG_EN | BUSIF_RD_CG_EN) |
| 409 | |
| 410 | /* DMC PHY Control0 register */ |
| 411 | #define PHY_CONTROL0_RESET_VAL 0x0 |
| 412 | #define MEM_TERM_EN (1 << 31) /* Termination enable for memory */ |
| 413 | #define PHY_TERM_EN (1 << 30) /* Termination enable for PHY */ |
| 414 | #define DMC_CTRL_SHGATE (1 << 29) /* Duration of DQS gating signal */ |
| 415 | #define FP_RSYNC (1 << 3) /* Force DLL resyncronization */ |
| 416 | |
| 417 | /* Driver strength for CK, CKE, CS & CA */ |
| 418 | #define IMP_OUTPUT_DRV_40_OHM 0x5 |
| 419 | #define IMP_OUTPUT_DRV_30_OHM 0x7 |
| 420 | #define DA_3_DS_OFFSET 25 |
| 421 | #define DA_2_DS_OFFSET 22 |
| 422 | #define DA_1_DS_OFFSET 19 |
| 423 | #define DA_0_DS_OFFSET 16 |
| 424 | #define CA_CK_DRVR_DS_OFFSET 9 |
| 425 | #define CA_CKE_DRVR_DS_OFFSET 6 |
| 426 | #define CA_CS_DRVR_DS_OFFSET 3 |
| 427 | #define CA_ADR_DRVR_DS_OFFSET 0 |
| 428 | |
| 429 | #define PHY_CON42_CTRL_BSTLEN_SHIFT 8 |
| 430 | #define PHY_CON42_CTRL_RDLAT_SHIFT 0 |
| 431 | |
| 432 | /* |
| 433 | * Definitions that differ with SoC's. |
| 434 | * Below is the part defining macros for smdk5250. |
| 435 | * Else part introduces macros for smdk5420. |
| 436 | */ |
| 437 | #ifndef CONFIG_SMDK5420 |
| 438 | |
| 439 | /* APLL_CON1 */ |
| 440 | #define APLL_CON1_VAL (0x00203800) |
| 441 | |
| 442 | /* MPLL_CON1 */ |
| 443 | #define MPLL_CON1_VAL (0x00203800) |
| 444 | |
| 445 | /* CPLL_CON1 */ |
| 446 | #define CPLL_CON1_VAL (0x00203800) |
| 447 | |
| 448 | /* DPLL_CON1 */ |
| 449 | #define DPLL_CON1_VAL (NOT_AVAILABLE) |
| 450 | |
| 451 | /* GPLL_CON1 */ |
| 452 | #define GPLL_CON1_VAL (0x00203800) |
| 453 | |
| 454 | /* EPLL_CON1, CON2 */ |
| 455 | #define EPLL_CON1_VAL 0x00000000 |
| 456 | #define EPLL_CON2_VAL 0x00000080 |
| 457 | |
| 458 | /* VPLL_CON1, CON2 */ |
| 459 | #define VPLL_CON1_VAL 0x00000000 |
| 460 | #define VPLL_CON2_VAL 0x00000080 |
| 461 | |
| 462 | /* RPLL_CON1, CON2 */ |
| 463 | #define RPLL_CON1_VAL NOT_AVAILABLE |
| 464 | #define RPLL_CON2_VAL NOT_AVAILABLE |
| 465 | |
| 466 | /* BPLL_CON1 */ |
| 467 | #define BPLL_CON1_VAL 0x00203800 |
| 468 | |
| 469 | /* SPLL_CON1 */ |
| 470 | #define SPLL_CON1_VAL NOT_AVAILABLE |
| 471 | |
| 472 | /* IPLL_CON1 */ |
| 473 | #define IPLL_CON1_VAL NOT_AVAILABLE |
| 474 | |
| 475 | /* KPLL_CON1 */ |
| 476 | #define KPLL_CON1_VAL NOT_AVAILABLE |
| 477 | |
| 478 | /* CLK_SRC_ISP */ |
| 479 | #define CLK_SRC_ISP_VAL NOT_AVAILABLE |
| 480 | #define CLK_DIV_ISP0_VAL 0x31 |
| 481 | #define CLK_DIV_ISP1_VAL 0x0 |
| 482 | |
| 483 | /* CLK_FSYS */ |
| 484 | #define CLK_SRC_FSYS0_VAL 0x66666 |
| 485 | #define CLK_DIV_FSYS0_VAL 0x0BB00000 |
| 486 | #define CLK_DIV_FSYS1_VAL NOT_AVAILABLE |
| 487 | #define CLK_DIV_FSYS2_VAL NOT_AVAILABLE |
| 488 | |
| 489 | /* CLK_SRC_CPU */ |
| 490 | /* 0 = MOUTAPLL, 1 = SCLKMPLL */ |
| 491 | #define MUX_HPM_SEL 0 |
| 492 | #define MUX_CPU_SEL 0 |
| 493 | #define MUX_APLL_SEL 1 |
| 494 | |
| 495 | #define CLK_SRC_CPU_VAL ((MUX_HPM_SEL << 20) \ |
| 496 | | (MUX_CPU_SEL << 16) \ |
| 497 | | (MUX_APLL_SEL)) |
| 498 | |
| 499 | /* CLK_SRC_CDREX */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 500 | #define CLK_SRC_CDREX_VAL 0x1 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 501 | |
| 502 | /* CLK_DIV_CDREX */ |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 503 | #define CLK_DIV_CDREX0_VAL NOT_AVAILABLE |
| 504 | #define CLK_DIV_CDREX1_VAL NOT_AVAILABLE |
| 505 | |
| 506 | /* CLK_DIV_CPU0_VAL */ |
| 507 | #define CLK_DIV_CPU0_VAL NOT_AVAILABLE |
| 508 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 509 | #define MCLK_CDREX2_RATIO 0x0 |
| 510 | #define ACLK_EFCON_RATIO 0x1 |
| 511 | #define MCLK_DPHY_RATIO 0x1 |
| 512 | #define MCLK_CDREX_RATIO 0x1 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 513 | #define ACLK_C2C_200_RATIO 0x1 |
| 514 | #define C2C_CLK_400_RATIO 0x1 |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 515 | #define PCLK_CDREX_RATIO 0x1 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 516 | #define ACLK_CDREX_RATIO 0x1 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 517 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 518 | #define CLK_DIV_CDREX_VAL ((MCLK_DPHY_RATIO << 24) \ |
| 519 | | (C2C_CLK_400_RATIO << 6) \ |
| 520 | | (PCLK_CDREX_RATIO << 4) \ |
| 521 | | (ACLK_CDREX_RATIO)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 522 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 523 | /* CLK_SRC_TOP0 */ |
| 524 | #define MUX_ACLK_300_GSCL_SEL 0x0 |
| 525 | #define MUX_ACLK_300_GSCL_MID_SEL 0x0 |
| 526 | #define MUX_ACLK_400_G3D_MID_SEL 0x0 |
| 527 | #define MUX_ACLK_333_SEL 0x0 |
| 528 | #define MUX_ACLK_300_DISP1_SEL 0x0 |
| 529 | #define MUX_ACLK_300_DISP1_MID_SEL 0x0 |
| 530 | #define MUX_ACLK_200_SEL 0x0 |
| 531 | #define MUX_ACLK_166_SEL 0x0 |
| 532 | #define CLK_SRC_TOP0_VAL ((MUX_ACLK_300_GSCL_SEL << 25) \ |
| 533 | | (MUX_ACLK_300_GSCL_MID_SEL << 24) \ |
| 534 | | (MUX_ACLK_400_G3D_MID_SEL << 20) \ |
| 535 | | (MUX_ACLK_333_SEL << 16) \ |
| 536 | | (MUX_ACLK_300_DISP1_SEL << 15) \ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 537 | | (MUX_ACLK_300_DISP1_MID_SEL << 14) \ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 538 | | (MUX_ACLK_200_SEL << 12) \ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 539 | | (MUX_ACLK_166_SEL << 8)) |
| 540 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 541 | /* CLK_SRC_TOP1 */ |
| 542 | #define MUX_ACLK_400_G3D_SEL 0x1 |
| 543 | #define MUX_ACLK_400_ISP_SEL 0x0 |
| 544 | #define MUX_ACLK_400_IOP_SEL 0x0 |
| 545 | #define MUX_ACLK_MIPI_HSI_TXBASE_SEL 0x0 |
| 546 | #define MUX_ACLK_300_GSCL_MID1_SEL 0x0 |
| 547 | #define MUX_ACLK_300_DISP1_MID1_SEL 0x0 |
| 548 | #define CLK_SRC_TOP1_VAL ((MUX_ACLK_400_G3D_SEL << 28) \ |
| 549 | |(MUX_ACLK_400_ISP_SEL << 24) \ |
| 550 | |(MUX_ACLK_400_IOP_SEL << 20) \ |
| 551 | |(MUX_ACLK_MIPI_HSI_TXBASE_SEL << 16) \ |
| 552 | |(MUX_ACLK_300_GSCL_MID1_SEL << 12) \ |
| 553 | |(MUX_ACLK_300_DISP1_MID1_SEL << 8)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 554 | |
| 555 | /* CLK_SRC_TOP2 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 556 | #define MUX_GPLL_SEL 0x1 |
| 557 | #define MUX_BPLL_USER_SEL 0x0 |
| 558 | #define MUX_MPLL_USER_SEL 0x0 |
| 559 | #define MUX_VPLL_SEL 0x1 |
| 560 | #define MUX_EPLL_SEL 0x1 |
| 561 | #define MUX_CPLL_SEL 0x1 |
| 562 | #define VPLLSRC_SEL 0x0 |
| 563 | #define CLK_SRC_TOP2_VAL ((MUX_GPLL_SEL << 28) \ |
| 564 | | (MUX_BPLL_USER_SEL << 24) \ |
| 565 | | (MUX_MPLL_USER_SEL << 20) \ |
| 566 | | (MUX_VPLL_SEL << 16) \ |
| 567 | | (MUX_EPLL_SEL << 12) \ |
| 568 | | (MUX_CPLL_SEL << 8) \ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 569 | | (VPLLSRC_SEL)) |
| 570 | /* CLK_SRC_TOP3 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 571 | #define MUX_ACLK_333_SUB_SEL 0x1 |
| 572 | #define MUX_ACLK_400_SUB_SEL 0x1 |
| 573 | #define MUX_ACLK_266_ISP_SUB_SEL 0x1 |
| 574 | #define MUX_ACLK_266_GPS_SUB_SEL 0x0 |
| 575 | #define MUX_ACLK_300_GSCL_SUB_SEL 0x1 |
| 576 | #define MUX_ACLK_266_GSCL_SUB_SEL 0x1 |
| 577 | #define MUX_ACLK_300_DISP1_SUB_SEL 0x1 |
| 578 | #define MUX_ACLK_200_DISP1_SUB_SEL 0x1 |
| 579 | #define CLK_SRC_TOP3_VAL ((MUX_ACLK_333_SUB_SEL << 24) \ |
| 580 | | (MUX_ACLK_400_SUB_SEL << 20) \ |
| 581 | | (MUX_ACLK_266_ISP_SUB_SEL << 16) \ |
| 582 | | (MUX_ACLK_266_GPS_SUB_SEL << 12) \ |
| 583 | | (MUX_ACLK_300_GSCL_SUB_SEL << 10) \ |
| 584 | | (MUX_ACLK_266_GSCL_SUB_SEL << 8) \ |
| 585 | | (MUX_ACLK_300_DISP1_SUB_SEL << 6) \ |
| 586 | | (MUX_ACLK_200_DISP1_SUB_SEL << 4)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 587 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 588 | #define CLK_SRC_TOP4_VAL NOT_AVAILABLE |
| 589 | #define CLK_SRC_TOP5_VAL NOT_AVAILABLE |
| 590 | #define CLK_SRC_TOP6_VAL NOT_AVAILABLE |
| 591 | #define CLK_SRC_TOP7_VAL NOT_AVAILABLE |
| 592 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 593 | /* CLK_DIV_TOP0 */ |
| 594 | #define ACLK_300_DISP1_RATIO 0x2 |
| 595 | #define ACLK_400_G3D_RATIO 0x0 |
| 596 | #define ACLK_333_RATIO 0x0 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 597 | #define ACLK_266_RATIO 0x2 |
| 598 | #define ACLK_200_RATIO 0x3 |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 599 | #define ACLK_166_RATIO 0x1 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 600 | #define ACLK_133_RATIO 0x1 |
| 601 | #define ACLK_66_RATIO 0x5 |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 602 | |
| 603 | #define CLK_DIV_TOP0_VAL ((ACLK_300_DISP1_RATIO << 28) \ |
| 604 | | (ACLK_400_G3D_RATIO << 24) \ |
| 605 | | (ACLK_333_RATIO << 20) \ |
| 606 | | (ACLK_266_RATIO << 16) \ |
| 607 | | (ACLK_200_RATIO << 12) \ |
| 608 | | (ACLK_166_RATIO << 8) \ |
| 609 | | (ACLK_133_RATIO << 4) \ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 610 | | (ACLK_66_RATIO)) |
| 611 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 612 | /* CLK_DIV_TOP1 */ |
| 613 | #define ACLK_MIPI_HSI_TX_BASE_RATIO 0x3 |
| 614 | #define ACLK_66_PRE_RATIO 0x1 |
| 615 | #define ACLK_400_ISP_RATIO 0x1 |
| 616 | #define ACLK_400_IOP_RATIO 0x1 |
| 617 | #define ACLK_300_GSCL_RATIO 0x2 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 618 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 619 | #define CLK_DIV_TOP1_VAL ((ACLK_MIPI_HSI_TX_BASE_RATIO << 28) \ |
| 620 | | (ACLK_66_PRE_RATIO << 24) \ |
| 621 | | (ACLK_400_ISP_RATIO << 20) \ |
| 622 | | (ACLK_400_IOP_RATIO << 16) \ |
| 623 | | (ACLK_300_GSCL_RATIO << 12)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 624 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 625 | #define CLK_DIV_TOP2_VAL NOT_AVAILABLE |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 626 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 627 | /* PLL Lock Value Factor */ |
| 628 | #define PLL_LOCK_FACTOR 250 |
| 629 | #define PLL_X_LOCK_FACTOR 3000 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 630 | |
| 631 | /* CLK_SRC_PERIC0 */ |
Padmavathi Venna | 6fe023b | 2013-03-28 04:32:22 +0000 | [diff] [blame] | 632 | #define PWM_SEL 6 |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 633 | #define UART3_SEL 6 |
| 634 | #define UART2_SEL 6 |
| 635 | #define UART1_SEL 6 |
| 636 | #define UART0_SEL 6 |
| 637 | /* SRC_CLOCK = SCLK_MPLL */ |
| 638 | #define CLK_SRC_PERIC0_VAL ((PWM_SEL << 24) \ |
| 639 | | (UART3_SEL << 12) \ |
| 640 | | (UART2_SEL << 8) \ |
| 641 | | (UART1_SEL << 4) \ |
| 642 | | (UART0_SEL)) |
| 643 | |
| 644 | /* CLK_SRC_PERIC1 */ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 645 | /* SRC_CLOCK = SCLK_MPLL */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 646 | #define SPI0_SEL 6 |
| 647 | #define SPI1_SEL 6 |
| 648 | #define SPI2_SEL 6 |
| 649 | #define CLK_SRC_PERIC1_VAL ((SPI2_SEL << 24) \ |
| 650 | | (SPI1_SEL << 20) \ |
| 651 | | (SPI0_SEL << 16)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 652 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 653 | /* CLK_DIV_PERIL0 */ |
| 654 | #define UART5_RATIO 7 |
| 655 | #define UART4_RATIO 7 |
| 656 | #define UART3_RATIO 7 |
| 657 | #define UART2_RATIO 7 |
| 658 | #define UART1_RATIO 7 |
| 659 | #define UART0_RATIO 7 |
| 660 | |
| 661 | #define CLK_DIV_PERIC0_VAL ((UART3_RATIO << 12) \ |
| 662 | | (UART2_RATIO << 8) \ |
| 663 | | (UART1_RATIO << 4) \ |
| 664 | | (UART0_RATIO)) |
| 665 | /* CLK_DIV_PERIC1 */ |
| 666 | #define SPI1_RATIO 0x7 |
| 667 | #define SPI0_RATIO 0xf |
| 668 | #define SPI1_SUB_RATIO 0x0 |
| 669 | #define SPI0_SUB_RATIO 0x0 |
| 670 | #define CLK_DIV_PERIC1_VAL ((SPI1_SUB_RATIO << 24) \ |
| 671 | | ((SPI1_RATIO << 16) \ |
| 672 | | (SPI0_SUB_RATIO << 8) \ |
| 673 | | (SPI0_RATIO << 0))) |
| 674 | |
| 675 | /* CLK_DIV_PERIC2 */ |
| 676 | #define SPI2_RATIO 0xf |
| 677 | #define SPI2_SUB_RATIO 0x0 |
| 678 | #define CLK_DIV_PERIC2_VAL ((SPI2_SUB_RATIO << 8) \ |
| 679 | | (SPI2_RATIO << 0)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 680 | |
| 681 | /* CLK_DIV_PERIC3 */ |
| 682 | #define PWM_RATIO 8 |
| 683 | #define CLK_DIV_PERIC3_VAL (PWM_RATIO << 0) |
| 684 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 685 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 686 | /* CLK_DIV_PERIC4 */ |
| 687 | #define CLK_DIV_PERIC4_VAL NOT_AVAILABLE |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 688 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 689 | /* CLK_SRC_DISP1_0 */ |
| 690 | #define CLK_SRC_DISP1_0_VAL 0x6 |
| 691 | #define CLK_DIV_DISP1_0_VAL NOT_AVAILABLE |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 692 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 693 | #define APLL_FOUT (1 << 0) |
| 694 | #define KPLL_FOUT NOT_AVAILABLE |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 695 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 696 | #define CLK_DIV_CPERI1_VAL NOT_AVAILABLE |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 697 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 698 | #else |
Rajeshwari Birje | 2d7f08c | 2013-12-26 09:44:22 +0530 | [diff] [blame] | 699 | #define PAD_RETENTION_DRAM_COREBLK_VAL 0x10000000 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 700 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 701 | /* APLL_CON1 */ |
| 702 | #define APLL_CON1_VAL (0x0020F300) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 703 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 704 | /* MPLL_CON1 */ |
| 705 | #define MPLL_CON1_VAL (0x0020F300) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 706 | |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 707 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 708 | /* CPLL_CON1 */ |
| 709 | #define CPLL_CON1_VAL 0x0020f300 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 710 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 711 | /* DPLL_CON1 */ |
| 712 | #define DPLL_CON1_VAL (0x0020F300) |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 713 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 714 | /* GPLL_CON1 */ |
| 715 | #define GPLL_CON1_VAL (NOT_AVAILABLE) |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 716 | |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 717 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 718 | /* EPLL_CON1, CON2 */ |
| 719 | #define EPLL_CON1_VAL 0x00000000 |
| 720 | #define EPLL_CON2_VAL 0x00000080 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 721 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 722 | /* VPLL_CON1, CON2 */ |
| 723 | #define VPLL_CON1_VAL 0x0020f300 |
| 724 | #define VPLL_CON2_VAL NOT_AVAILABLE |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 725 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 726 | /* RPLL_CON1, CON2 */ |
| 727 | #define RPLL_CON1_VAL 0x00000000 |
| 728 | #define RPLL_CON2_VAL 0x00000080 |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 729 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 730 | /* BPLL_CON1 */ |
| 731 | #define BPLL_CON1_VAL 0x0020f300 |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 732 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 733 | /* SPLL_CON1 */ |
| 734 | #define SPLL_CON1_VAL 0x0020f300 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 735 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 736 | /* IPLL_CON1 */ |
| 737 | #define IPLL_CON1_VAL 0x00000080 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 738 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 739 | /* KPLL_CON1 */ |
| 740 | #define KPLL_CON1_VAL 0x200000 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 741 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 742 | /* CLK_SRC_ISP */ |
| 743 | #define CLK_SRC_ISP_VAL 0x33366000 |
| 744 | #define CLK_DIV_ISP0_VAL 0x13131300 |
| 745 | #define CLK_DIV_ISP1_VAL 0xbb110202 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 746 | |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 747 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 748 | /* CLK_FSYS */ |
| 749 | #define CLK_SRC_FSYS0_VAL 0x33033300 |
| 750 | #define CLK_DIV_FSYS0_VAL 0x0 |
| 751 | #define CLK_DIV_FSYS1_VAL 0x04f13c4f |
| 752 | #define CLK_DIV_FSYS2_VAL 0x041d0000 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 753 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 754 | /* CLK_SRC_CPU */ |
| 755 | /* 0 = MOUTAPLL, 1 = SCLKMPLL */ |
| 756 | #define MUX_HPM_SEL 1 |
| 757 | #define MUX_CPU_SEL 0 |
| 758 | #define MUX_APLL_SEL 1 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 759 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 760 | #define CLK_SRC_CPU_VAL ((MUX_HPM_SEL << 20) \ |
| 761 | | (MUX_CPU_SEL << 16) \ |
| 762 | | (MUX_APLL_SEL)) |
| 763 | |
| 764 | /* CLK_SRC_CDREX */ |
| 765 | #define CLK_SRC_CDREX_VAL 0x00000011 |
| 766 | |
| 767 | /* CLK_DIV_CDREX */ |
| 768 | #define CLK_DIV_CDREX0_VAL 0x30010100 |
| 769 | #define CLK_DIV_CDREX1_VAL 0x300 |
| 770 | |
| 771 | #define CLK_DIV_CDREX_VAL 0x17010100 |
| 772 | |
| 773 | /* CLK_DIV_CPU0_VAL */ |
| 774 | #define CLK_DIV_CPU0_VAL 0x01440020 |
| 775 | |
| 776 | /* CLK_SRC_TOP */ |
| 777 | #define CLK_SRC_TOP0_VAL 0x12221222 |
| 778 | #define CLK_SRC_TOP1_VAL 0x00100200 |
| 779 | #define CLK_SRC_TOP2_VAL 0x11101000 |
| 780 | #define CLK_SRC_TOP3_VAL 0x11111111 |
| 781 | #define CLK_SRC_TOP4_VAL 0x11110111 |
| 782 | #define CLK_SRC_TOP5_VAL 0x11111100 |
| 783 | #define CLK_SRC_TOP6_VAL 0x11110111 |
| 784 | #define CLK_SRC_TOP7_VAL 0x00022200 |
| 785 | |
| 786 | /* CLK_DIV_TOP */ |
| 787 | #define CLK_DIV_TOP0_VAL 0x23712311 |
| 788 | #define CLK_DIV_TOP1_VAL 0x13100B00 |
| 789 | #define CLK_DIV_TOP2_VAL 0x11101100 |
| 790 | |
| 791 | /* PLL Lock Value Factor */ |
| 792 | #define PLL_LOCK_FACTOR 200 |
| 793 | #define PLL_X_LOCK_FACTOR 3000 |
| 794 | |
| 795 | /* CLK_SRC_PERIC0 */ |
| 796 | #define SPDIF_SEL 1 |
| 797 | #define PWM_SEL 3 |
| 798 | #define UART4_SEL 3 |
| 799 | #define UART3_SEL 3 |
| 800 | #define UART2_SEL 3 |
| 801 | #define UART1_SEL 3 |
| 802 | #define UART0_SEL 3 |
| 803 | /* SRC_CLOCK = SCLK_RPLL */ |
| 804 | #define CLK_SRC_PERIC0_VAL ((SPDIF_SEL << 28) \ |
| 805 | | (PWM_SEL << 24) \ |
| 806 | | (UART4_SEL << 20) \ |
| 807 | | (UART3_SEL << 16) \ |
| 808 | | (UART2_SEL << 12) \ |
| 809 | | (UART1_SEL << 8) \ |
| 810 | | (UART0_SEL << 4)) |
| 811 | |
| 812 | /* CLK_SRC_PERIC1 */ |
| 813 | /* SRC_CLOCK = SCLK_EPLL */ |
| 814 | #define SPI0_SEL 6 |
| 815 | #define SPI1_SEL 6 |
| 816 | #define SPI2_SEL 6 |
| 817 | #define AUDIO0_SEL 6 |
| 818 | #define AUDIO1_SEL 6 |
| 819 | #define AUDIO2_SEL 6 |
| 820 | #define CLK_SRC_PERIC1_VAL ((SPI2_SEL << 28) \ |
| 821 | | (SPI1_SEL << 24) \ |
| 822 | | (SPI0_SEL << 20) \ |
| 823 | | (AUDIO2_SEL << 16) \ |
| 824 | | (AUDIO2_SEL << 12) \ |
| 825 | | (AUDIO2_SEL << 8)) |
| 826 | |
| 827 | /* CLK_DIV_PERIC0 */ |
| 828 | #define PWM_RATIO 8 |
| 829 | #define UART4_RATIO 9 |
| 830 | #define UART3_RATIO 9 |
| 831 | #define UART2_RATIO 9 |
| 832 | #define UART1_RATIO 9 |
| 833 | #define UART0_RATIO 9 |
| 834 | |
| 835 | #define CLK_DIV_PERIC0_VAL ((PWM_RATIO << 28) \ |
| 836 | | (UART4_RATIO << 24) \ |
| 837 | | (UART3_RATIO << 20) \ |
| 838 | | (UART2_RATIO << 16) \ |
| 839 | | (UART1_RATIO << 12) \ |
| 840 | | (UART0_RATIO << 8)) |
| 841 | /* CLK_DIV_PERIC1 */ |
| 842 | #define SPI2_RATIO 0x1 |
| 843 | #define SPI1_RATIO 0x1 |
| 844 | #define SPI0_RATIO 0x1 |
| 845 | #define CLK_DIV_PERIC1_VAL ((SPI2_RATIO << 28) \ |
| 846 | | (SPI1_RATIO << 24) \ |
| 847 | | (SPI0_RATIO << 20)) |
| 848 | |
| 849 | /* CLK_DIV_PERIC2 */ |
| 850 | #define PCM2_RATIO 0x3 |
| 851 | #define PCM1_RATIO 0x3 |
| 852 | #define CLK_DIV_PERIC2_VAL ((PCM2_RATIO << 24) \ |
| 853 | | (PCM1_RATIO << 16)) |
| 854 | |
| 855 | /* CLK_DIV_PERIC3 */ |
| 856 | #define AUDIO2_RATIO 0x5 |
| 857 | #define AUDIO1_RATIO 0x5 |
| 858 | #define AUDIO0_RATIO 0x5 |
| 859 | #define CLK_DIV_PERIC3_VAL ((AUDIO2_RATIO << 28) \ |
| 860 | | (AUDIO1_RATIO << 24) \ |
| 861 | | (AUDIO0_RATIO << 20)) |
| 862 | |
| 863 | /* CLK_DIV_PERIC4 */ |
| 864 | #define SPI2_PRE_RATIO 0x2 |
| 865 | #define SPI1_PRE_RATIO 0x2 |
| 866 | #define SPI0_PRE_RATIO 0x2 |
| 867 | #define CLK_DIV_PERIC4_VAL ((SPI2_PRE_RATIO << 24) \ |
| 868 | | (SPI1_PRE_RATIO << 16) \ |
| 869 | | (SPI0_PRE_RATIO << 8)) |
| 870 | |
| 871 | /* CLK_SRC_DISP1_0 */ |
| 872 | #define CLK_SRC_DISP1_0_VAL 0x10666600 |
| 873 | #define CLK_DIV_DISP1_0_VAL 0x01050211 |
| 874 | |
| 875 | #define APLL_FOUT (1 << 0) |
| 876 | #define KPLL_FOUT (1 << 0) |
| 877 | |
| 878 | #define CLK_DIV_CPERI1_VAL 0x3f3f0000 |
| 879 | #endif |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 880 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 881 | struct mem_timings; |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 882 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 883 | /* Errors that we can encourter in low-level setup */ |
| 884 | enum { |
| 885 | SETUP_ERR_OK, |
| 886 | SETUP_ERR_RDLV_COMPLETE_TIMEOUT = -1, |
| 887 | SETUP_ERR_ZQ_CALIBRATION_FAILURE = -2, |
| 888 | }; |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 889 | |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 890 | /* |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 891 | * Memory variant specific initialization code for DDR3 |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 892 | * |
| 893 | * @param mem Memory timings for this memory type. |
| 894 | * @param mem_iv_size Memory interleaving size is a configurable parameter |
| 895 | * which the DMC uses to decide how to split a memory |
| 896 | * chunk into smaller chunks to support concurrent |
| 897 | * accesses; may vary across boards. |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 898 | * @param reset Reset DDR PHY during initialization. |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 899 | * @return 0 if ok, SETUP_ERR_... if there is a problem |
| 900 | */ |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 901 | int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size, |
| 902 | int reset); |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 903 | |
Rajeshwari Birje | ac892d0 | 2013-12-26 09:44:21 +0530 | [diff] [blame] | 904 | /* Memory variant specific initialization code for LPDDR3 */ |
| 905 | void lpddr3_mem_ctrl_init(void); |
| 906 | |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 907 | /* |
| 908 | * Configure ZQ I/O interface |
| 909 | * |
| 910 | * @param mem Memory timings for this memory type. |
Rajeshwari Birje | 2d7f08c | 2013-12-26 09:44:22 +0530 | [diff] [blame] | 911 | * @param phy0_con16 Register address for dmc_phy0->phy_con16 |
| 912 | * @param phy1_con16 Register address for dmc_phy1->phy_con16 |
| 913 | * @param phy0_con17 Register address for dmc_phy0->phy_con17 |
| 914 | * @param phy1_con17 Register address for dmc_phy1->phy_con17 |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 915 | * @return 0 if ok, -1 on error |
| 916 | */ |
Rajeshwari Birje | 2d7f08c | 2013-12-26 09:44:22 +0530 | [diff] [blame] | 917 | int dmc_config_zq(struct mem_timings *mem, uint32_t *phy0_con16, |
| 918 | uint32_t *phy1_con16, uint32_t *phy0_con17, |
| 919 | uint32_t *phy1_con17); |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 920 | /* |
| 921 | * Send NOP and MRS/EMRS Direct commands |
| 922 | * |
| 923 | * @param mem Memory timings for this memory type. |
Rajeshwari Birje | 2d7f08c | 2013-12-26 09:44:22 +0530 | [diff] [blame] | 924 | * @param directcmd Register address for dmc_phy->directcmd |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 925 | */ |
Rajeshwari Birje | 2d7f08c | 2013-12-26 09:44:22 +0530 | [diff] [blame] | 926 | void dmc_config_mrs(struct mem_timings *mem, uint32_t *directcmd); |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 927 | |
| 928 | /* |
| 929 | * Send PALL Direct commands |
| 930 | * |
| 931 | * @param mem Memory timings for this memory type. |
Rajeshwari Birje | 2d7f08c | 2013-12-26 09:44:22 +0530 | [diff] [blame] | 932 | * @param directcmd Register address for dmc_phy->directcmd |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 933 | */ |
Rajeshwari Birje | 2d7f08c | 2013-12-26 09:44:22 +0530 | [diff] [blame] | 934 | void dmc_config_prech(struct mem_timings *mem, uint32_t *directcmd); |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 935 | |
| 936 | /* |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 937 | * Reset the DLL. This function is common between DDR3 and LPDDR2. |
| 938 | * However, the reset value is different. So we are passing a flag |
| 939 | * ddr_mode to distinguish between LPDDR2 and DDR3. |
| 940 | * |
Rajeshwari Birje | 2d7f08c | 2013-12-26 09:44:22 +0530 | [diff] [blame] | 941 | * @param phycontrol0 Register address for dmc_phy->phycontrol0 |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 942 | * @param ddr_mode Type of DDR memory |
| 943 | */ |
Rajeshwari Birje | 2d7f08c | 2013-12-26 09:44:22 +0530 | [diff] [blame] | 944 | void update_reset_dll(uint32_t *phycontrol0, enum ddr_mode); |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 945 | #endif |