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 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #ifndef _SMDK5250_SETUP_H |
| 26 | #define _SMDK5250_SETUP_H |
| 27 | |
| 28 | #include <config.h> |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 29 | #include <asm/arch/dmc.h> |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 30 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 31 | /* APLL_CON1 */ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 32 | #define APLL_CON1_VAL (0x00203800) |
| 33 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 34 | /* MPLL_CON1 */ |
| 35 | #define MPLL_CON1_VAL (0x00203800) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 36 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 37 | /* CPLL_CON1 */ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 38 | #define CPLL_CON1_VAL (0x00203800) |
| 39 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 40 | /* GPLL_CON1 */ |
| 41 | #define GPLL_CON1_VAL (0x00203800) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 42 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 43 | /* EPLL_CON1, CON2 */ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 44 | #define EPLL_CON1_VAL 0x00000000 |
| 45 | #define EPLL_CON2_VAL 0x00000080 |
| 46 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 47 | /* VPLL_CON1, CON2 */ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 48 | #define VPLL_CON1_VAL 0x00000000 |
| 49 | #define VPLL_CON2_VAL 0x00000080 |
| 50 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 51 | /* BPLL_CON1 */ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 52 | #define BPLL_CON1_VAL 0x00203800 |
| 53 | |
| 54 | /* Set PLL */ |
| 55 | #define set_pll(mdiv, pdiv, sdiv) (1<<31 | mdiv<<16 | pdiv<<8 | sdiv) |
| 56 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 57 | /* CLK_SRC_CPU */ |
| 58 | /* 0 = MOUTAPLL, 1 = SCLKMPLL */ |
| 59 | #define MUX_HPM_SEL 0 |
| 60 | #define MUX_CPU_SEL 0 |
| 61 | #define MUX_APLL_SEL 1 |
| 62 | |
| 63 | #define CLK_SRC_CPU_VAL ((MUX_HPM_SEL << 20) \ |
| 64 | | (MUX_CPU_SEL << 16) \ |
| 65 | | (MUX_APLL_SEL)) |
| 66 | |
| 67 | /* MEMCONTROL register bit fields */ |
| 68 | #define DMC_MEMCONTROL_CLK_STOP_DISABLE (0 << 0) |
| 69 | #define DMC_MEMCONTROL_DPWRDN_DISABLE (0 << 1) |
| 70 | #define DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE (0 << 2) |
| 71 | #define DMC_MEMCONTROL_TP_DISABLE (0 << 4) |
| 72 | #define DMC_MEMCONTROL_DSREF_DISABLE (0 << 5) |
| 73 | #define DMC_MEMCONTROL_DSREF_ENABLE (1 << 5) |
| 74 | #define DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(x) (x << 6) |
| 75 | |
| 76 | #define DMC_MEMCONTROL_MEM_TYPE_LPDDR3 (7 << 8) |
| 77 | #define DMC_MEMCONTROL_MEM_TYPE_DDR3 (6 << 8) |
| 78 | #define DMC_MEMCONTROL_MEM_TYPE_LPDDR2 (5 << 8) |
| 79 | |
| 80 | #define DMC_MEMCONTROL_MEM_WIDTH_32BIT (2 << 12) |
| 81 | |
| 82 | #define DMC_MEMCONTROL_NUM_CHIP_1 (0 << 16) |
| 83 | #define DMC_MEMCONTROL_NUM_CHIP_2 (1 << 16) |
| 84 | |
| 85 | #define DMC_MEMCONTROL_BL_8 (3 << 20) |
| 86 | #define DMC_MEMCONTROL_BL_4 (2 << 20) |
| 87 | |
| 88 | #define DMC_MEMCONTROL_PZQ_DISABLE (0 << 24) |
| 89 | |
| 90 | #define DMC_MEMCONTROL_MRR_BYTE_7_0 (0 << 25) |
| 91 | #define DMC_MEMCONTROL_MRR_BYTE_15_8 (1 << 25) |
| 92 | #define DMC_MEMCONTROL_MRR_BYTE_23_16 (2 << 25) |
| 93 | #define DMC_MEMCONTROL_MRR_BYTE_31_24 (3 << 25) |
| 94 | |
| 95 | /* MEMCONFIG0 register bit fields */ |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 96 | #define DMC_MEMCONFIGX_CHIP_MAP_INTERLEAVED (1 << 12) |
| 97 | #define DMC_MEMCONFIGX_CHIP_COL_10 (3 << 8) |
| 98 | #define DMC_MEMCONFIGX_CHIP_ROW_14 (2 << 4) |
| 99 | #define DMC_MEMCONFIGX_CHIP_ROW_15 (3 << 4) |
| 100 | #define DMC_MEMCONFIGX_CHIP_BANK_8 (3 << 0) |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 101 | |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 102 | #define DMC_MEMBASECONFIGX_CHIP_BASE(x) (x << 16) |
| 103 | #define DMC_MEMBASECONFIGX_CHIP_MASK(x) (x << 0) |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 104 | #define DMC_MEMBASECONFIG_VAL(x) ( \ |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 105 | DMC_MEMBASECONFIGX_CHIP_BASE(x) | \ |
| 106 | DMC_MEMBASECONFIGX_CHIP_MASK(0x780) \ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 107 | ) |
| 108 | |
| 109 | #define DMC_MEMBASECONFIG0_VAL DMC_MEMBASECONFIG_VAL(0x40) |
| 110 | #define DMC_MEMBASECONFIG1_VAL DMC_MEMBASECONFIG_VAL(0x80) |
| 111 | |
| 112 | #define DMC_PRECHCONFIG_VAL 0xFF000000 |
| 113 | #define DMC_PWRDNCONFIG_VAL 0xFFFF00FF |
| 114 | |
| 115 | #define DMC_CONCONTROL_RESET_VAL 0x0FFF0000 |
| 116 | #define DFI_INIT_START (1 << 28) |
| 117 | #define EMPTY (1 << 8) |
| 118 | #define AREF_EN (1 << 5) |
| 119 | |
| 120 | #define DFI_INIT_COMPLETE_CHO (1 << 2) |
| 121 | #define DFI_INIT_COMPLETE_CH1 (1 << 3) |
| 122 | |
| 123 | #define RDLVL_COMPLETE_CHO (1 << 14) |
| 124 | #define RDLVL_COMPLETE_CH1 (1 << 15) |
| 125 | |
| 126 | #define CLK_STOP_EN (1 << 0) |
| 127 | #define DPWRDN_EN (1 << 1) |
| 128 | #define DSREF_EN (1 << 5) |
| 129 | |
| 130 | /* COJCONTROL register bit fields */ |
| 131 | #define DMC_CONCONTROL_IO_PD_CON_DISABLE (0 << 3) |
| 132 | #define DMC_CONCONTROL_AREF_EN_DISABLE (0 << 5) |
| 133 | #define DMC_CONCONTROL_EMPTY_DISABLE (0 << 8) |
| 134 | #define DMC_CONCONTROL_EMPTY_ENABLE (1 << 8) |
| 135 | #define DMC_CONCONTROL_RD_FETCH_DISABLE (0x0 << 12) |
| 136 | #define DMC_CONCONTROL_TIMEOUT_LEVEL0 (0xFFF << 16) |
| 137 | #define DMC_CONCONTROL_DFI_INIT_START_DISABLE (0 << 28) |
| 138 | |
| 139 | /* CLK_DIV_CPU0_VAL */ |
| 140 | #define CLK_DIV_CPU0_VAL ((ARM2_RATIO << 28) \ |
| 141 | | (APLL_RATIO << 24) \ |
| 142 | | (PCLK_DBG_RATIO << 20) \ |
| 143 | | (ATB_RATIO << 16) \ |
| 144 | | (PERIPH_RATIO << 12) \ |
| 145 | | (ACP_RATIO << 8) \ |
| 146 | | (CPUD_RATIO << 4) \ |
| 147 | | (ARM_RATIO)) |
| 148 | |
| 149 | |
| 150 | /* CLK_FSYS */ |
| 151 | #define CLK_SRC_FSYS0_VAL 0x66666 |
| 152 | #define CLK_DIV_FSYS0_VAL 0x0BB00000 |
| 153 | |
| 154 | /* CLK_DIV_CPU1 */ |
| 155 | #define HPM_RATIO 0x2 |
| 156 | #define COPY_RATIO 0x0 |
| 157 | |
| 158 | /* CLK_DIV_CPU1 = 0x00000003 */ |
| 159 | #define CLK_DIV_CPU1_VAL ((HPM_RATIO << 4) \ |
| 160 | | (COPY_RATIO)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 161 | |
| 162 | /* CLK_SRC_CORE0 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 163 | #define CLK_SRC_CORE0_VAL 0x00000000 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 164 | |
| 165 | /* CLK_SRC_CORE1 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 166 | #define CLK_SRC_CORE1_VAL 0x100 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 167 | |
| 168 | /* CLK_DIV_CORE0 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 169 | #define CLK_DIV_CORE0_VAL 0x00120000 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 170 | |
| 171 | /* CLK_DIV_CORE1 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 172 | #define CLK_DIV_CORE1_VAL 0x07070700 |
| 173 | |
| 174 | /* CLK_DIV_SYSRGT */ |
| 175 | #define CLK_DIV_SYSRGT_VAL 0x00000111 |
| 176 | |
| 177 | /* CLK_DIV_ACP */ |
| 178 | #define CLK_DIV_ACP_VAL 0x12 |
| 179 | |
| 180 | /* CLK_DIV_SYSLFT */ |
| 181 | #define CLK_DIV_SYSLFT_VAL 0x00000311 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 182 | |
| 183 | /* CLK_SRC_CDREX */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 184 | #define CLK_SRC_CDREX_VAL 0x1 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 185 | |
| 186 | /* CLK_DIV_CDREX */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 187 | #define MCLK_CDREX2_RATIO 0x0 |
| 188 | #define ACLK_EFCON_RATIO 0x1 |
| 189 | #define MCLK_DPHY_RATIO 0x1 |
| 190 | #define MCLK_CDREX_RATIO 0x1 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 191 | #define ACLK_C2C_200_RATIO 0x1 |
| 192 | #define C2C_CLK_400_RATIO 0x1 |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 193 | #define PCLK_CDREX_RATIO 0x1 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 194 | #define ACLK_CDREX_RATIO 0x1 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 195 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 196 | #define CLK_DIV_CDREX_VAL ((MCLK_DPHY_RATIO << 24) \ |
| 197 | | (C2C_CLK_400_RATIO << 6) \ |
| 198 | | (PCLK_CDREX_RATIO << 4) \ |
| 199 | | (ACLK_CDREX_RATIO)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 200 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 201 | /* CLK_SRC_TOP0 */ |
| 202 | #define MUX_ACLK_300_GSCL_SEL 0x0 |
| 203 | #define MUX_ACLK_300_GSCL_MID_SEL 0x0 |
| 204 | #define MUX_ACLK_400_G3D_MID_SEL 0x0 |
| 205 | #define MUX_ACLK_333_SEL 0x0 |
| 206 | #define MUX_ACLK_300_DISP1_SEL 0x0 |
| 207 | #define MUX_ACLK_300_DISP1_MID_SEL 0x0 |
| 208 | #define MUX_ACLK_200_SEL 0x0 |
| 209 | #define MUX_ACLK_166_SEL 0x0 |
| 210 | #define CLK_SRC_TOP0_VAL ((MUX_ACLK_300_GSCL_SEL << 25) \ |
| 211 | | (MUX_ACLK_300_GSCL_MID_SEL << 24) \ |
| 212 | | (MUX_ACLK_400_G3D_MID_SEL << 20) \ |
| 213 | | (MUX_ACLK_333_SEL << 16) \ |
| 214 | | (MUX_ACLK_300_DISP1_SEL << 15) \ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 215 | | (MUX_ACLK_300_DISP1_MID_SEL << 14) \ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 216 | | (MUX_ACLK_200_SEL << 12) \ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 217 | | (MUX_ACLK_166_SEL << 8)) |
| 218 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 219 | /* CLK_SRC_TOP1 */ |
| 220 | #define MUX_ACLK_400_G3D_SEL 0x1 |
| 221 | #define MUX_ACLK_400_ISP_SEL 0x0 |
| 222 | #define MUX_ACLK_400_IOP_SEL 0x0 |
| 223 | #define MUX_ACLK_MIPI_HSI_TXBASE_SEL 0x0 |
| 224 | #define MUX_ACLK_300_GSCL_MID1_SEL 0x0 |
| 225 | #define MUX_ACLK_300_DISP1_MID1_SEL 0x0 |
| 226 | #define CLK_SRC_TOP1_VAL ((MUX_ACLK_400_G3D_SEL << 28) \ |
| 227 | |(MUX_ACLK_400_ISP_SEL << 24) \ |
| 228 | |(MUX_ACLK_400_IOP_SEL << 20) \ |
| 229 | |(MUX_ACLK_MIPI_HSI_TXBASE_SEL << 16) \ |
| 230 | |(MUX_ACLK_300_GSCL_MID1_SEL << 12) \ |
| 231 | |(MUX_ACLK_300_DISP1_MID1_SEL << 8)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 232 | |
| 233 | /* CLK_SRC_TOP2 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 234 | #define MUX_GPLL_SEL 0x1 |
| 235 | #define MUX_BPLL_USER_SEL 0x0 |
| 236 | #define MUX_MPLL_USER_SEL 0x0 |
| 237 | #define MUX_VPLL_SEL 0x1 |
| 238 | #define MUX_EPLL_SEL 0x1 |
| 239 | #define MUX_CPLL_SEL 0x1 |
| 240 | #define VPLLSRC_SEL 0x0 |
| 241 | #define CLK_SRC_TOP2_VAL ((MUX_GPLL_SEL << 28) \ |
| 242 | | (MUX_BPLL_USER_SEL << 24) \ |
| 243 | | (MUX_MPLL_USER_SEL << 20) \ |
| 244 | | (MUX_VPLL_SEL << 16) \ |
| 245 | | (MUX_EPLL_SEL << 12) \ |
| 246 | | (MUX_CPLL_SEL << 8) \ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 247 | | (VPLLSRC_SEL)) |
| 248 | /* CLK_SRC_TOP3 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 249 | #define MUX_ACLK_333_SUB_SEL 0x1 |
| 250 | #define MUX_ACLK_400_SUB_SEL 0x1 |
| 251 | #define MUX_ACLK_266_ISP_SUB_SEL 0x1 |
| 252 | #define MUX_ACLK_266_GPS_SUB_SEL 0x0 |
| 253 | #define MUX_ACLK_300_GSCL_SUB_SEL 0x1 |
| 254 | #define MUX_ACLK_266_GSCL_SUB_SEL 0x1 |
| 255 | #define MUX_ACLK_300_DISP1_SUB_SEL 0x1 |
| 256 | #define MUX_ACLK_200_DISP1_SUB_SEL 0x1 |
| 257 | #define CLK_SRC_TOP3_VAL ((MUX_ACLK_333_SUB_SEL << 24) \ |
| 258 | | (MUX_ACLK_400_SUB_SEL << 20) \ |
| 259 | | (MUX_ACLK_266_ISP_SUB_SEL << 16) \ |
| 260 | | (MUX_ACLK_266_GPS_SUB_SEL << 12) \ |
| 261 | | (MUX_ACLK_300_GSCL_SUB_SEL << 10) \ |
| 262 | | (MUX_ACLK_266_GSCL_SUB_SEL << 8) \ |
| 263 | | (MUX_ACLK_300_DISP1_SUB_SEL << 6) \ |
| 264 | | (MUX_ACLK_200_DISP1_SUB_SEL << 4)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 265 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 266 | /* CLK_DIV_TOP0 */ |
| 267 | #define ACLK_300_DISP1_RATIO 0x2 |
| 268 | #define ACLK_400_G3D_RATIO 0x0 |
| 269 | #define ACLK_333_RATIO 0x0 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 270 | #define ACLK_266_RATIO 0x2 |
| 271 | #define ACLK_200_RATIO 0x3 |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 272 | #define ACLK_166_RATIO 0x1 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 273 | #define ACLK_133_RATIO 0x1 |
| 274 | #define ACLK_66_RATIO 0x5 |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 275 | |
| 276 | #define CLK_DIV_TOP0_VAL ((ACLK_300_DISP1_RATIO << 28) \ |
| 277 | | (ACLK_400_G3D_RATIO << 24) \ |
| 278 | | (ACLK_333_RATIO << 20) \ |
| 279 | | (ACLK_266_RATIO << 16) \ |
| 280 | | (ACLK_200_RATIO << 12) \ |
| 281 | | (ACLK_166_RATIO << 8) \ |
| 282 | | (ACLK_133_RATIO << 4) \ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 283 | | (ACLK_66_RATIO)) |
| 284 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 285 | /* CLK_DIV_TOP1 */ |
| 286 | #define ACLK_MIPI_HSI_TX_BASE_RATIO 0x3 |
| 287 | #define ACLK_66_PRE_RATIO 0x1 |
| 288 | #define ACLK_400_ISP_RATIO 0x1 |
| 289 | #define ACLK_400_IOP_RATIO 0x1 |
| 290 | #define ACLK_300_GSCL_RATIO 0x2 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 291 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 292 | #define CLK_DIV_TOP1_VAL ((ACLK_MIPI_HSI_TX_BASE_RATIO << 28) \ |
| 293 | | (ACLK_66_PRE_RATIO << 24) \ |
| 294 | | (ACLK_400_ISP_RATIO << 20) \ |
| 295 | | (ACLK_400_IOP_RATIO << 16) \ |
| 296 | | (ACLK_300_GSCL_RATIO << 12)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 297 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 298 | /* APLL_LOCK */ |
| 299 | #define APLL_LOCK_VAL (0x546) |
| 300 | /* MPLL_LOCK */ |
| 301 | #define MPLL_LOCK_VAL (0x546) |
| 302 | /* CPLL_LOCK */ |
| 303 | #define CPLL_LOCK_VAL (0x546) |
| 304 | /* GPLL_LOCK */ |
| 305 | #define GPLL_LOCK_VAL (0x546) |
| 306 | /* EPLL_LOCK */ |
| 307 | #define EPLL_LOCK_VAL (0x3A98) |
| 308 | /* VPLL_LOCK */ |
| 309 | #define VPLL_LOCK_VAL (0x3A98) |
| 310 | /* BPLL_LOCK */ |
| 311 | #define BPLL_LOCK_VAL (0x546) |
| 312 | |
| 313 | #define MUX_APLL_SEL_MASK (1 << 0) |
| 314 | #define MUX_MPLL_SEL_MASK (1 << 8) |
| 315 | #define MPLL_SEL_MOUT_MPLLFOUT (2 << 8) |
| 316 | #define MUX_CPLL_SEL_MASK (1 << 8) |
| 317 | #define MUX_EPLL_SEL_MASK (1 << 12) |
| 318 | #define MUX_VPLL_SEL_MASK (1 << 16) |
| 319 | #define MUX_GPLL_SEL_MASK (1 << 28) |
| 320 | #define MUX_BPLL_SEL_MASK (1 << 0) |
| 321 | #define MUX_HPM_SEL_MASK (1 << 20) |
| 322 | #define HPM_SEL_SCLK_MPLL (1 << 21) |
| 323 | #define APLL_CON0_LOCKED (1 << 29) |
| 324 | #define MPLL_CON0_LOCKED (1 << 29) |
| 325 | #define BPLL_CON0_LOCKED (1 << 29) |
| 326 | #define CPLL_CON0_LOCKED (1 << 29) |
| 327 | #define EPLL_CON0_LOCKED (1 << 29) |
| 328 | #define GPLL_CON0_LOCKED (1 << 29) |
| 329 | #define VPLL_CON0_LOCKED (1 << 29) |
| 330 | #define CLK_REG_DISABLE 0x0 |
| 331 | #define TOP2_VAL 0x0110000 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 332 | |
| 333 | /* CLK_SRC_PERIC0 */ |
Padmavathi Venna | 6fe023b | 2013-03-28 04:32:22 +0000 | [diff] [blame] | 334 | #define PWM_SEL 6 |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 335 | #define UART3_SEL 6 |
| 336 | #define UART2_SEL 6 |
| 337 | #define UART1_SEL 6 |
| 338 | #define UART0_SEL 6 |
| 339 | /* SRC_CLOCK = SCLK_MPLL */ |
| 340 | #define CLK_SRC_PERIC0_VAL ((PWM_SEL << 24) \ |
| 341 | | (UART3_SEL << 12) \ |
| 342 | | (UART2_SEL << 8) \ |
| 343 | | (UART1_SEL << 4) \ |
| 344 | | (UART0_SEL)) |
| 345 | |
| 346 | /* CLK_SRC_PERIC1 */ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 347 | /* SRC_CLOCK = SCLK_MPLL */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 348 | #define SPI0_SEL 6 |
| 349 | #define SPI1_SEL 6 |
| 350 | #define SPI2_SEL 6 |
| 351 | #define CLK_SRC_PERIC1_VAL ((SPI2_SEL << 24) \ |
| 352 | | (SPI1_SEL << 20) \ |
| 353 | | (SPI0_SEL << 16)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 354 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 355 | /* SCLK_SRC_ISP - set SPI0/1 to 6 = SCLK_MPLL_USER */ |
| 356 | #define SPI0_ISP_SEL 6 |
| 357 | #define SPI1_ISP_SEL 6 |
| 358 | #define SCLK_SRC_ISP_VAL (SPI1_ISP_SEL << 4) \ |
| 359 | | (SPI0_ISP_SEL << 0) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 360 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 361 | /* SCLK_DIV_ISP - set SPI0/1 to 0xf = divide by 16 */ |
| 362 | #define SPI0_ISP_RATIO 0xf |
| 363 | #define SPI1_ISP_RATIO 0xf |
| 364 | #define SCLK_DIV_ISP_VAL (SPI1_ISP_RATIO << 12) \ |
| 365 | | (SPI0_ISP_RATIO << 0) |
| 366 | |
| 367 | /* CLK_DIV_PERIL0 */ |
| 368 | #define UART5_RATIO 7 |
| 369 | #define UART4_RATIO 7 |
| 370 | #define UART3_RATIO 7 |
| 371 | #define UART2_RATIO 7 |
| 372 | #define UART1_RATIO 7 |
| 373 | #define UART0_RATIO 7 |
| 374 | |
| 375 | #define CLK_DIV_PERIC0_VAL ((UART3_RATIO << 12) \ |
| 376 | | (UART2_RATIO << 8) \ |
| 377 | | (UART1_RATIO << 4) \ |
| 378 | | (UART0_RATIO)) |
| 379 | /* CLK_DIV_PERIC1 */ |
| 380 | #define SPI1_RATIO 0x7 |
| 381 | #define SPI0_RATIO 0xf |
| 382 | #define SPI1_SUB_RATIO 0x0 |
| 383 | #define SPI0_SUB_RATIO 0x0 |
| 384 | #define CLK_DIV_PERIC1_VAL ((SPI1_SUB_RATIO << 24) \ |
| 385 | | ((SPI1_RATIO << 16) \ |
| 386 | | (SPI0_SUB_RATIO << 8) \ |
| 387 | | (SPI0_RATIO << 0))) |
| 388 | |
| 389 | /* CLK_DIV_PERIC2 */ |
| 390 | #define SPI2_RATIO 0xf |
| 391 | #define SPI2_SUB_RATIO 0x0 |
| 392 | #define CLK_DIV_PERIC2_VAL ((SPI2_SUB_RATIO << 8) \ |
| 393 | | (SPI2_RATIO << 0)) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 394 | |
| 395 | /* CLK_DIV_PERIC3 */ |
| 396 | #define PWM_RATIO 8 |
| 397 | #define CLK_DIV_PERIC3_VAL (PWM_RATIO << 0) |
| 398 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 399 | /* CLK_DIV_FSYS2 */ |
| 400 | #define MMC2_RATIO_MASK 0xf |
| 401 | #define MMC2_RATIO_VAL 0x3 |
| 402 | #define MMC2_RATIO_OFFSET 0 |
| 403 | |
| 404 | #define MMC2_PRE_RATIO_MASK 0xff |
| 405 | #define MMC2_PRE_RATIO_VAL 0x9 |
| 406 | #define MMC2_PRE_RATIO_OFFSET 8 |
| 407 | |
| 408 | #define MMC3_RATIO_MASK 0xf |
| 409 | #define MMC3_RATIO_VAL 0x1 |
| 410 | #define MMC3_RATIO_OFFSET 16 |
| 411 | |
| 412 | #define MMC3_PRE_RATIO_MASK 0xff |
| 413 | #define MMC3_PRE_RATIO_VAL 0x0 |
| 414 | #define MMC3_PRE_RATIO_OFFSET 24 |
| 415 | |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 416 | /* CLK_SRC_LEX */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 417 | #define CLK_SRC_LEX_VAL 0x0 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 418 | |
| 419 | /* CLK_DIV_LEX */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 420 | #define CLK_DIV_LEX_VAL 0x10 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 421 | |
| 422 | /* CLK_DIV_R0X */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 423 | #define CLK_DIV_R0X_VAL 0x10 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 424 | |
| 425 | /* CLK_DIV_L0X */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 426 | #define CLK_DIV_R1X_VAL 0x10 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 427 | |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 428 | /* CLK_DIV_ISP0 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 429 | #define CLK_DIV_ISP0_VAL 0x31 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 430 | |
| 431 | /* CLK_DIV_ISP1 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 432 | #define CLK_DIV_ISP1_VAL 0x0 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 433 | |
| 434 | /* CLK_DIV_ISP2 */ |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 435 | #define CLK_DIV_ISP2_VAL 0x1 |
| 436 | |
| 437 | /* CLK_SRC_DISP1_0 */ |
| 438 | #define CLK_SRC_DISP1_0_VAL 0x6 |
| 439 | |
| 440 | /* |
| 441 | * DIV_DISP1_0 |
| 442 | * For DP, divisor should be 2 |
| 443 | */ |
| 444 | #define CLK_DIV_DISP1_0_FIMD1 (2 << 0) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 445 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 446 | /* CLK_GATE_IP_DISP1 */ |
| 447 | #define CLK_GATE_DP1_ALLOW (1 << 4) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 448 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 449 | #define DDR3PHY_CTRL_PHY_RESET (1 << 0) |
| 450 | #define DDR3PHY_CTRL_PHY_RESET_OFF (0 << 0) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 451 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 452 | #define PHY_CON0_RESET_VAL 0x17020a40 |
| 453 | #define P0_CMD_EN (1 << 14) |
| 454 | #define BYTE_RDLVL_EN (1 << 13) |
| 455 | #define CTRL_SHGATE (1 << 8) |
| 456 | |
| 457 | #define PHY_CON1_RESET_VAL 0x09210100 |
| 458 | #define CTRL_GATEDURADJ_MASK (0xf << 20) |
| 459 | |
| 460 | #define PHY_CON2_RESET_VAL 0x00010004 |
| 461 | #define INIT_DESKEW_EN (1 << 6) |
| 462 | #define RDLVL_GATE_EN (1 << 24) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 463 | |
| 464 | /*ZQ Configurations */ |
| 465 | #define PHY_CON16_RESET_VAL 0x08000304 |
| 466 | |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 467 | #define ZQ_CLK_DIV_EN (1 << 18) |
| 468 | #define ZQ_MANUAL_STR (1 << 1) |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 469 | #define ZQ_DONE (1 << 0) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 470 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 471 | #define CTRL_RDLVL_GATE_ENABLE 1 |
| 472 | #define CTRL_RDLVL_GATE_DISABLE 1 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 473 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 474 | /* Direct Command */ |
| 475 | #define DIRECT_CMD_NOP 0x07000000 |
| 476 | #define DIRECT_CMD_PALL 0x01000000 |
| 477 | #define DIRECT_CMD_ZQINIT 0x0a000000 |
| 478 | #define DIRECT_CMD_CHANNEL_SHIFT 28 |
| 479 | #define DIRECT_CMD_CHIP_SHIFT 20 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 480 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 481 | /* DMC PHY Control0 register */ |
| 482 | #define PHY_CONTROL0_RESET_VAL 0x0 |
| 483 | #define MEM_TERM_EN (1 << 31) /* Termination enable for memory */ |
| 484 | #define PHY_TERM_EN (1 << 30) /* Termination enable for PHY */ |
| 485 | #define DMC_CTRL_SHGATE (1 << 29) /* Duration of DQS gating signal */ |
| 486 | #define FP_RSYNC (1 << 3) /* Force DLL resyncronization */ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 487 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 488 | /* Driver strength for CK, CKE, CS & CA */ |
| 489 | #define IMP_OUTPUT_DRV_40_OHM 0x5 |
| 490 | #define IMP_OUTPUT_DRV_30_OHM 0x7 |
| 491 | #define CA_CK_DRVR_DS_OFFSET 9 |
| 492 | #define CA_CKE_DRVR_DS_OFFSET 6 |
| 493 | #define CA_CS_DRVR_DS_OFFSET 3 |
| 494 | #define CA_ADR_DRVR_DS_OFFSET 0 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 495 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 496 | #define PHY_CON42_CTRL_BSTLEN_SHIFT 8 |
| 497 | #define PHY_CON42_CTRL_RDLAT_SHIFT 0 |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 498 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 499 | struct mem_timings; |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 500 | |
Rajeshwari Shinde | 5f90a4c | 2012-07-03 20:02:55 +0000 | [diff] [blame] | 501 | /* Errors that we can encourter in low-level setup */ |
| 502 | enum { |
| 503 | SETUP_ERR_OK, |
| 504 | SETUP_ERR_RDLV_COMPLETE_TIMEOUT = -1, |
| 505 | SETUP_ERR_ZQ_CALIBRATION_FAILURE = -2, |
| 506 | }; |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 507 | |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 508 | /* |
| 509 | * Memory variant specific initialization code |
| 510 | * |
| 511 | * @param mem Memory timings for this memory type. |
| 512 | * @param mem_iv_size Memory interleaving size is a configurable parameter |
| 513 | * which the DMC uses to decide how to split a memory |
| 514 | * chunk into smaller chunks to support concurrent |
| 515 | * accesses; may vary across boards. |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 516 | * @param reset Reset DDR PHY during initialization. |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 517 | * @return 0 if ok, SETUP_ERR_... if there is a problem |
| 518 | */ |
Rajeshwari Shinde | bed2442 | 2013-07-04 12:29:17 +0530 | [diff] [blame] | 519 | int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size, |
| 520 | int reset); |
Rajeshwari Shinde | 6558d27 | 2012-07-03 20:02:56 +0000 | [diff] [blame] | 521 | |
| 522 | /* |
| 523 | * Configure ZQ I/O interface |
| 524 | * |
| 525 | * @param mem Memory timings for this memory type. |
| 526 | * @param phy0_ctrl Pointer to struct containing PHY0 control reg |
| 527 | * @param phy1_ctrl Pointer to struct containing PHY1 control reg |
| 528 | * @return 0 if ok, -1 on error |
| 529 | */ |
| 530 | int dmc_config_zq(struct mem_timings *mem, |
| 531 | struct exynos5_phy_control *phy0_ctrl, |
| 532 | struct exynos5_phy_control *phy1_ctrl); |
| 533 | |
| 534 | /* |
| 535 | * Send NOP and MRS/EMRS Direct commands |
| 536 | * |
| 537 | * @param mem Memory timings for this memory type. |
| 538 | * @param dmc Pointer to struct of DMC registers |
| 539 | */ |
| 540 | void dmc_config_mrs(struct mem_timings *mem, struct exynos5_dmc *dmc); |
| 541 | |
| 542 | /* |
| 543 | * Send PALL Direct commands |
| 544 | * |
| 545 | * @param mem Memory timings for this memory type. |
| 546 | * @param dmc Pointer to struct of DMC registers |
| 547 | */ |
| 548 | void dmc_config_prech(struct mem_timings *mem, struct exynos5_dmc *dmc); |
| 549 | |
| 550 | /* |
| 551 | * Configure the memconfig and membaseconfig registers |
| 552 | * |
| 553 | * @param mem Memory timings for this memory type. |
| 554 | * @param exynos5_dmc Pointer to struct of DMC registers |
| 555 | */ |
| 556 | void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc); |
| 557 | |
| 558 | /* |
| 559 | * Reset the DLL. This function is common between DDR3 and LPDDR2. |
| 560 | * However, the reset value is different. So we are passing a flag |
| 561 | * ddr_mode to distinguish between LPDDR2 and DDR3. |
| 562 | * |
| 563 | * @param exynos5_dmc Pointer to struct of DMC registers |
| 564 | * @param ddr_mode Type of DDR memory |
| 565 | */ |
| 566 | void update_reset_dll(struct exynos5_dmc *, enum ddr_mode); |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 567 | #endif |