Stefan Reinauer | 9fe20cb | 2012-12-07 17:18:43 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Clock setup for SMDK5250 board based on EXYNOS5 |
| 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 | #if 0 |
| 26 | #include <common.h> |
| 27 | #include <config.h> |
| 28 | //#include <fdtdec.h> |
| 29 | #include <arch/io.h> |
| 30 | #include <asm/arch/board.h> |
| 31 | #include <asm/arch/clk.h> |
| 32 | #include <asm/arch/clock.h> |
| 33 | #include <cpu/samsung/exynos5250/cpu.h> |
| 34 | #include <asm/arch/gpio.h> |
| 35 | #include <asm/arch-exynos/spl.h> |
| 36 | #endif |
| 37 | #include <delay.h> |
| 38 | #include <stdlib.h> |
| 39 | #include <types.h> |
| 40 | #include <system.h> |
| 41 | |
| 42 | #include <console/console.h> |
| 43 | |
| 44 | #include <cpu/samsung/exynos5-common/spl.h> |
| 45 | #include <cpu/samsung/exynos5250/clk.h> |
| 46 | #include <cpu/samsung/exynos5250/cpu.h> |
| 47 | #include <cpu/samsung/exynos5250/dmc.h> |
| 48 | #include <cpu/samsung/exynos5250/s5p-dp.h> |
| 49 | #include <cpu/samsung/s5p-common/clk.h> |
| 50 | |
| 51 | #include "clock_init.h" |
| 52 | #include "setup.h" |
| 53 | |
| 54 | //DECLARE_GLOBAL_DATA_PTR; |
| 55 | |
| 56 | struct arm_clk_ratios arm_clk_ratios[] = { |
| 57 | { |
| 58 | .arm_freq_mhz = 600, |
| 59 | |
| 60 | .apll_mdiv = 0xc8, |
| 61 | .apll_pdiv = 0x4, |
| 62 | .apll_sdiv = 0x1, |
| 63 | |
| 64 | .arm2_ratio = 0x0, |
| 65 | .apll_ratio = 0x1, |
| 66 | .pclk_dbg_ratio = 0x1, |
| 67 | .atb_ratio = 0x2, |
| 68 | .periph_ratio = 0x7, |
| 69 | .acp_ratio = 0x7, |
| 70 | .cpud_ratio = 0x1, |
| 71 | .arm_ratio = 0x0, |
| 72 | }, { |
| 73 | .arm_freq_mhz = 800, |
| 74 | |
| 75 | .apll_mdiv = 0x64, |
| 76 | .apll_pdiv = 0x3, |
| 77 | .apll_sdiv = 0x0, |
| 78 | |
| 79 | .arm2_ratio = 0x0, |
| 80 | .apll_ratio = 0x1, |
| 81 | .pclk_dbg_ratio = 0x1, |
| 82 | .atb_ratio = 0x3, |
| 83 | .periph_ratio = 0x7, |
| 84 | .acp_ratio = 0x7, |
| 85 | .cpud_ratio = 0x2, |
| 86 | .arm_ratio = 0x0, |
| 87 | }, { |
| 88 | .arm_freq_mhz = 1000, |
| 89 | |
| 90 | .apll_mdiv = 0x7d, |
| 91 | .apll_pdiv = 0x3, |
| 92 | .apll_sdiv = 0x0, |
| 93 | |
| 94 | .arm2_ratio = 0x0, |
| 95 | .apll_ratio = 0x1, |
| 96 | .pclk_dbg_ratio = 0x1, |
| 97 | .atb_ratio = 0x4, |
| 98 | .periph_ratio = 0x7, |
| 99 | .acp_ratio = 0x7, |
| 100 | .cpud_ratio = 0x2, |
| 101 | .arm_ratio = 0x0, |
| 102 | }, { |
| 103 | .arm_freq_mhz = 1200, |
| 104 | |
| 105 | .apll_mdiv = 0x96, |
| 106 | .apll_pdiv = 0x3, |
| 107 | .apll_sdiv = 0x0, |
| 108 | |
| 109 | .arm2_ratio = 0x0, |
| 110 | .apll_ratio = 0x3, |
| 111 | .pclk_dbg_ratio = 0x1, |
| 112 | .atb_ratio = 0x5, |
| 113 | .periph_ratio = 0x7, |
| 114 | .acp_ratio = 0x7, |
| 115 | .cpud_ratio = 0x3, |
| 116 | .arm_ratio = 0x0, |
| 117 | }, { |
| 118 | .arm_freq_mhz = 1400, |
| 119 | |
| 120 | .apll_mdiv = 0xaf, |
| 121 | .apll_pdiv = 0x3, |
| 122 | .apll_sdiv = 0x0, |
| 123 | |
| 124 | .arm2_ratio = 0x0, |
| 125 | .apll_ratio = 0x3, |
| 126 | .pclk_dbg_ratio = 0x1, |
| 127 | .atb_ratio = 0x6, |
| 128 | .periph_ratio = 0x7, |
| 129 | .acp_ratio = 0x7, |
| 130 | .cpud_ratio = 0x3, |
| 131 | .arm_ratio = 0x0, |
| 132 | }, { |
| 133 | .arm_freq_mhz = 1700, |
| 134 | |
| 135 | .apll_mdiv = 0x1a9, |
| 136 | .apll_pdiv = 0x6, |
| 137 | .apll_sdiv = 0x0, |
| 138 | |
| 139 | .arm2_ratio = 0x0, |
| 140 | .apll_ratio = 0x3, |
| 141 | .pclk_dbg_ratio = 0x1, |
| 142 | .atb_ratio = 0x6, |
| 143 | .periph_ratio = 0x7, |
| 144 | .acp_ratio = 0x7, |
| 145 | .cpud_ratio = 0x3, |
| 146 | .arm_ratio = 0x0, |
| 147 | } |
| 148 | }; |
| 149 | |
| 150 | struct mem_timings mem_timings[] = { |
| 151 | { |
| 152 | .mem_manuf = MEM_MANUF_ELPIDA, |
| 153 | .mem_type = DDR_MODE_DDR3, |
| 154 | .frequency_mhz = 800, |
| 155 | .mpll_mdiv = 0x64, |
| 156 | .mpll_pdiv = 0x3, |
| 157 | .mpll_sdiv = 0x0, |
| 158 | .cpll_mdiv = 0xde, |
| 159 | .cpll_pdiv = 0x4, |
| 160 | .cpll_sdiv = 0x2, |
| 161 | .gpll_mdiv = 0x215, |
| 162 | .gpll_pdiv = 0xc, |
| 163 | .gpll_sdiv = 0x1, |
| 164 | .epll_mdiv = 0x60, |
| 165 | .epll_pdiv = 0x3, |
| 166 | .epll_sdiv = 0x3, |
| 167 | .vpll_mdiv = 0x96, |
| 168 | .vpll_pdiv = 0x3, |
| 169 | .vpll_sdiv = 0x2, |
| 170 | |
| 171 | .bpll_mdiv = 0x64, |
| 172 | .bpll_pdiv = 0x3, |
| 173 | .bpll_sdiv = 0x0, |
| 174 | .use_bpll = 0, |
| 175 | .pclk_cdrex_ratio = 0x5, |
| 176 | .direct_cmd_msr = { |
| 177 | 0x00020018, 0x00030000, 0x00010042, 0x00000d70 |
| 178 | }, |
| 179 | .timing_ref = 0x000000bb, |
| 180 | .timing_row = 0x8c36660f, |
| 181 | .timing_data = 0x3630580b, |
| 182 | .timing_power = 0x41000a44, |
| 183 | .phy0_dqs = 0x08080808, |
| 184 | .phy1_dqs = 0x08080808, |
| 185 | .phy0_dq = 0x08080808, |
| 186 | .phy1_dq = 0x08080808, |
| 187 | .phy0_tFS = 0x4, |
| 188 | .phy1_tFS = 0x4, |
| 189 | .phy0_pulld_dqs = 0xf, |
| 190 | .phy1_pulld_dqs = 0xf, |
| 191 | |
| 192 | .lpddr3_ctrl_phy_reset = 0x1, |
| 193 | .ctrl_start_point = 0x10, |
| 194 | .ctrl_inc = 0x10, |
| 195 | .ctrl_start = 0x1, |
| 196 | .ctrl_dll_on = 0x1, |
| 197 | .ctrl_ref = 0x8, |
| 198 | |
| 199 | .ctrl_force = 0x1a, |
| 200 | .ctrl_rdlat = 0x0b, |
| 201 | .ctrl_bstlen = 0x08, |
| 202 | |
| 203 | .fp_resync = 0x8, |
| 204 | .iv_size = 0x7, |
| 205 | .dfi_init_start = 1, |
| 206 | .aref_en = 1, |
| 207 | |
| 208 | .rd_fetch = 0x3, |
| 209 | |
| 210 | .zq_mode_dds = 0x7, |
| 211 | .zq_mode_term = 0x1, |
| 212 | .zq_mode_noterm = 0, |
| 213 | |
| 214 | /* |
| 215 | * Dynamic Clock: Always Running |
| 216 | * Memory Burst length: 8 |
| 217 | * Number of chips: 1 |
| 218 | * Memory Bus width: 32 bit |
| 219 | * Memory Type: DDR3 |
| 220 | * Additional Latancy for PLL: 0 Cycle |
| 221 | */ |
| 222 | .memcontrol = DMC_MEMCONTROL_CLK_STOP_DISABLE | |
| 223 | DMC_MEMCONTROL_DPWRDN_DISABLE | |
| 224 | DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE | |
| 225 | DMC_MEMCONTROL_TP_DISABLE | |
| 226 | DMC_MEMCONTROL_DSREF_ENABLE | |
| 227 | DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) | |
| 228 | DMC_MEMCONTROL_MEM_TYPE_DDR3 | |
| 229 | DMC_MEMCONTROL_MEM_WIDTH_32BIT | |
| 230 | DMC_MEMCONTROL_NUM_CHIP_1 | |
| 231 | DMC_MEMCONTROL_BL_8 | |
| 232 | DMC_MEMCONTROL_PZQ_DISABLE | |
| 233 | DMC_MEMCONTROL_MRR_BYTE_7_0, |
| 234 | .memconfig = DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED | |
| 235 | DMC_MEMCONFIGx_CHIP_COL_10 | |
| 236 | DMC_MEMCONFIGx_CHIP_ROW_15 | |
| 237 | DMC_MEMCONFIGx_CHIP_BANK_8, |
| 238 | .membaseconfig0 = DMC_MEMBASECONFIG_VAL(0x40), |
| 239 | .membaseconfig1 = DMC_MEMBASECONFIG_VAL(0x80), |
| 240 | .prechconfig_tp_cnt = 0xff, |
| 241 | .dpwrdn_cyc = 0xff, |
| 242 | .dsref_cyc = 0xffff, |
| 243 | .concontrol = DMC_CONCONTROL_DFI_INIT_START_DISABLE | |
| 244 | DMC_CONCONTROL_TIMEOUT_LEVEL0 | |
| 245 | DMC_CONCONTROL_RD_FETCH_DISABLE | |
| 246 | DMC_CONCONTROL_EMPTY_DISABLE | |
| 247 | DMC_CONCONTROL_AREF_EN_DISABLE | |
| 248 | DMC_CONCONTROL_IO_PD_CON_DISABLE, |
| 249 | .dmc_channels = 2, |
| 250 | .chips_per_channel = 2, |
| 251 | .chips_to_configure = 1, |
| 252 | .send_zq_init = 1, |
| 253 | .impedance = IMP_OUTPUT_DRV_30_OHM, |
| 254 | .gate_leveling_enable = 0, |
| 255 | }, { |
| 256 | .mem_manuf = MEM_MANUF_SAMSUNG, |
| 257 | .mem_type = DDR_MODE_DDR3, |
| 258 | .frequency_mhz = 800, |
| 259 | .mpll_mdiv = 0x64, |
| 260 | .mpll_pdiv = 0x3, |
| 261 | .mpll_sdiv = 0x0, |
| 262 | .cpll_mdiv = 0xde, |
| 263 | .cpll_pdiv = 0x4, |
| 264 | .cpll_sdiv = 0x2, |
| 265 | .gpll_mdiv = 0x215, |
| 266 | .gpll_pdiv = 0xc, |
| 267 | .gpll_sdiv = 0x1, |
| 268 | .epll_mdiv = 0x60, |
| 269 | .epll_pdiv = 0x3, |
| 270 | .epll_sdiv = 0x3, |
| 271 | .vpll_mdiv = 0x96, |
| 272 | .vpll_pdiv = 0x3, |
| 273 | .vpll_sdiv = 0x2, |
| 274 | |
| 275 | .bpll_mdiv = 0x64, |
| 276 | .bpll_pdiv = 0x3, |
| 277 | .bpll_sdiv = 0x0, |
| 278 | .use_bpll = 0, |
| 279 | .pclk_cdrex_ratio = 0x5, |
| 280 | .direct_cmd_msr = { |
| 281 | 0x00020018, 0x00030000, 0x00010000, 0x00000d70 |
| 282 | }, |
| 283 | .timing_ref = 0x000000bb, |
| 284 | .timing_row = 0x8c36660f, |
| 285 | .timing_data = 0x3630580b, |
| 286 | .timing_power = 0x41000a44, |
| 287 | .phy0_dqs = 0x08080808, |
| 288 | .phy1_dqs = 0x08080808, |
| 289 | .phy0_dq = 0x08080808, |
| 290 | .phy1_dq = 0x08080808, |
| 291 | .phy0_tFS = 0x8, |
| 292 | .phy1_tFS = 0x8, |
| 293 | .phy0_pulld_dqs = 0xf, |
| 294 | .phy1_pulld_dqs = 0xf, |
| 295 | |
| 296 | .lpddr3_ctrl_phy_reset = 0x1, |
| 297 | .ctrl_start_point = 0x10, |
| 298 | .ctrl_inc = 0x10, |
| 299 | .ctrl_start = 0x1, |
| 300 | .ctrl_dll_on = 0x1, |
| 301 | .ctrl_ref = 0x8, |
| 302 | |
| 303 | .ctrl_force = 0x1a, |
| 304 | .ctrl_rdlat = 0x0b, |
| 305 | .ctrl_bstlen = 0x08, |
| 306 | |
| 307 | .fp_resync = 0x8, |
| 308 | .iv_size = 0x7, |
| 309 | .dfi_init_start = 1, |
| 310 | .aref_en = 1, |
| 311 | |
| 312 | .rd_fetch = 0x3, |
| 313 | |
| 314 | .zq_mode_dds = 0x5, |
| 315 | .zq_mode_term = 0x1, |
| 316 | .zq_mode_noterm = 1, |
| 317 | |
| 318 | /* |
| 319 | * Dynamic Clock: Always Running |
| 320 | * Memory Burst length: 8 |
| 321 | * Number of chips: 1 |
| 322 | * Memory Bus width: 32 bit |
| 323 | * Memory Type: DDR3 |
| 324 | * Additional Latancy for PLL: 0 Cycle |
| 325 | */ |
| 326 | .memcontrol = DMC_MEMCONTROL_CLK_STOP_DISABLE | |
| 327 | DMC_MEMCONTROL_DPWRDN_DISABLE | |
| 328 | DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE | |
| 329 | DMC_MEMCONTROL_TP_DISABLE | |
| 330 | DMC_MEMCONTROL_DSREF_ENABLE | |
| 331 | DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) | |
| 332 | DMC_MEMCONTROL_MEM_TYPE_DDR3 | |
| 333 | DMC_MEMCONTROL_MEM_WIDTH_32BIT | |
| 334 | DMC_MEMCONTROL_NUM_CHIP_1 | |
| 335 | DMC_MEMCONTROL_BL_8 | |
| 336 | DMC_MEMCONTROL_PZQ_DISABLE | |
| 337 | DMC_MEMCONTROL_MRR_BYTE_7_0, |
| 338 | .memconfig = DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED | |
| 339 | DMC_MEMCONFIGx_CHIP_COL_10 | |
| 340 | DMC_MEMCONFIGx_CHIP_ROW_15 | |
| 341 | DMC_MEMCONFIGx_CHIP_BANK_8, |
| 342 | .membaseconfig0 = DMC_MEMBASECONFIG_VAL(0x40), |
| 343 | .membaseconfig1 = DMC_MEMBASECONFIG_VAL(0x80), |
| 344 | .prechconfig_tp_cnt = 0xff, |
| 345 | .dpwrdn_cyc = 0xff, |
| 346 | .dsref_cyc = 0xffff, |
| 347 | .concontrol = DMC_CONCONTROL_DFI_INIT_START_DISABLE | |
| 348 | DMC_CONCONTROL_TIMEOUT_LEVEL0 | |
| 349 | DMC_CONCONTROL_RD_FETCH_DISABLE | |
| 350 | DMC_CONCONTROL_EMPTY_DISABLE | |
| 351 | DMC_CONCONTROL_AREF_EN_DISABLE | |
| 352 | DMC_CONCONTROL_IO_PD_CON_DISABLE, |
| 353 | .dmc_channels = 2, |
| 354 | .chips_per_channel = 2, |
| 355 | .chips_to_configure = 1, |
| 356 | .send_zq_init = 1, |
| 357 | .impedance = IMP_OUTPUT_DRV_40_OHM, |
| 358 | .gate_leveling_enable = 1, |
| 359 | }, |
| 360 | { |
| 361 | .mem_manuf = MEM_MANUF_ELPIDA, |
| 362 | .mem_type = DDR_MODE_DDR3, |
| 363 | .frequency_mhz = 780, |
| 364 | .mpll_mdiv = 0x64, |
| 365 | .mpll_pdiv = 0x3, |
| 366 | .mpll_sdiv = 0x0, |
| 367 | .cpll_mdiv = 0xde, |
| 368 | .cpll_pdiv = 0x4, |
| 369 | .cpll_sdiv = 0x2, |
| 370 | .gpll_mdiv = 0x215, |
| 371 | .gpll_pdiv = 0xc, |
| 372 | .gpll_sdiv = 0x1, |
| 373 | .epll_mdiv = 0x60, |
| 374 | .epll_pdiv = 0x3, |
| 375 | .epll_sdiv = 0x3, |
| 376 | .vpll_mdiv = 0x96, |
| 377 | .vpll_pdiv = 0x3, |
| 378 | .vpll_sdiv = 0x2, |
| 379 | |
| 380 | .bpll_mdiv = 0x82, |
| 381 | .bpll_pdiv = 0x4, |
| 382 | .bpll_sdiv = 0x0, |
| 383 | .use_bpll = 1, |
| 384 | .pclk_cdrex_ratio = 0x5, |
| 385 | .direct_cmd_msr = { |
| 386 | 0x00020018, 0x00030000, 0x00010042, 0x00000d70 |
| 387 | }, |
| 388 | .timing_ref = 0x000000bb, |
| 389 | .timing_row = 0x8c36660f, |
| 390 | .timing_data = 0x3630580b, |
| 391 | .timing_power = 0x41000a44, |
| 392 | .phy0_dqs = 0x08080808, |
| 393 | .phy1_dqs = 0x08080808, |
| 394 | .phy0_dq = 0x08080808, |
| 395 | .phy1_dq = 0x08080808, |
| 396 | .phy0_tFS = 0x4, |
| 397 | .phy1_tFS = 0x4, |
| 398 | .phy0_pulld_dqs = 0xf, |
| 399 | .phy1_pulld_dqs = 0xf, |
| 400 | |
| 401 | .lpddr3_ctrl_phy_reset = 0x1, |
| 402 | .ctrl_start_point = 0x10, |
| 403 | .ctrl_inc = 0x10, |
| 404 | .ctrl_start = 0x1, |
| 405 | .ctrl_dll_on = 0x1, |
| 406 | .ctrl_ref = 0x8, |
| 407 | |
| 408 | .ctrl_force = 0x1a, |
| 409 | .ctrl_rdlat = 0x0b, |
| 410 | .ctrl_bstlen = 0x08, |
| 411 | |
| 412 | .fp_resync = 0x8, |
| 413 | .iv_size = 0x7, |
| 414 | .dfi_init_start = 1, |
| 415 | .aref_en = 1, |
| 416 | |
| 417 | .rd_fetch = 0x3, |
| 418 | |
| 419 | .zq_mode_dds = 0x7, |
| 420 | .zq_mode_term = 0x1, |
| 421 | .zq_mode_noterm = 0, |
| 422 | |
| 423 | /* |
| 424 | * Dynamic Clock: Always Running |
| 425 | * Memory Burst length: 8 |
| 426 | * Number of chips: 1 |
| 427 | * Memory Bus width: 32 bit |
| 428 | * Memory Type: DDR3 |
| 429 | * Additional Latancy for PLL: 0 Cycle |
| 430 | */ |
| 431 | .memcontrol = DMC_MEMCONTROL_CLK_STOP_DISABLE | |
| 432 | DMC_MEMCONTROL_DPWRDN_DISABLE | |
| 433 | DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE | |
| 434 | DMC_MEMCONTROL_TP_DISABLE | |
| 435 | DMC_MEMCONTROL_DSREF_ENABLE | |
| 436 | DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) | |
| 437 | DMC_MEMCONTROL_MEM_TYPE_DDR3 | |
| 438 | DMC_MEMCONTROL_MEM_WIDTH_32BIT | |
| 439 | DMC_MEMCONTROL_NUM_CHIP_1 | |
| 440 | DMC_MEMCONTROL_BL_8 | |
| 441 | DMC_MEMCONTROL_PZQ_DISABLE | |
| 442 | DMC_MEMCONTROL_MRR_BYTE_7_0, |
| 443 | .memconfig = DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED | |
| 444 | DMC_MEMCONFIGx_CHIP_COL_10 | |
| 445 | DMC_MEMCONFIGx_CHIP_ROW_15 | |
| 446 | DMC_MEMCONFIGx_CHIP_BANK_8, |
| 447 | .membaseconfig0 = DMC_MEMBASECONFIG_VAL(0x40), |
| 448 | .membaseconfig1 = DMC_MEMBASECONFIG_VAL(0x80), |
| 449 | .prechconfig_tp_cnt = 0xff, |
| 450 | .dpwrdn_cyc = 0xff, |
| 451 | .dsref_cyc = 0xffff, |
| 452 | .concontrol = DMC_CONCONTROL_DFI_INIT_START_DISABLE | |
| 453 | DMC_CONCONTROL_TIMEOUT_LEVEL0 | |
| 454 | DMC_CONCONTROL_RD_FETCH_DISABLE | |
| 455 | DMC_CONCONTROL_EMPTY_DISABLE | |
| 456 | DMC_CONCONTROL_AREF_EN_DISABLE | |
| 457 | DMC_CONCONTROL_IO_PD_CON_DISABLE, |
| 458 | .dmc_channels = 2, |
| 459 | .chips_per_channel = 2, |
| 460 | .chips_to_configure = 1, |
| 461 | .send_zq_init = 1, |
| 462 | .impedance = IMP_OUTPUT_DRV_30_OHM, |
| 463 | .gate_leveling_enable = 0, |
| 464 | }, { |
| 465 | .mem_manuf = MEM_MANUF_SAMSUNG, |
| 466 | .mem_type = DDR_MODE_DDR3, |
| 467 | .frequency_mhz = 780, |
| 468 | .mpll_mdiv = 0x64, |
| 469 | .mpll_pdiv = 0x3, |
| 470 | .mpll_sdiv = 0x0, |
| 471 | .cpll_mdiv = 0xde, |
| 472 | .cpll_pdiv = 0x4, |
| 473 | .cpll_sdiv = 0x2, |
| 474 | .gpll_mdiv = 0x215, |
| 475 | .gpll_pdiv = 0xc, |
| 476 | .gpll_sdiv = 0x1, |
| 477 | .epll_mdiv = 0x60, |
| 478 | .epll_pdiv = 0x3, |
| 479 | .epll_sdiv = 0x3, |
| 480 | .vpll_mdiv = 0x96, |
| 481 | .vpll_pdiv = 0x3, |
| 482 | .vpll_sdiv = 0x2, |
| 483 | |
| 484 | .bpll_mdiv = 0x82, |
| 485 | .bpll_pdiv = 0x4, |
| 486 | .bpll_sdiv = 0x0, |
| 487 | .use_bpll = 1, |
| 488 | .pclk_cdrex_ratio = 0x5, |
| 489 | .direct_cmd_msr = { |
| 490 | 0x00020018, 0x00030000, 0x00010000, 0x00000d70 |
| 491 | }, |
| 492 | .timing_ref = 0x000000bb, |
| 493 | .timing_row = 0x8c36660f, |
| 494 | .timing_data = 0x3630580b, |
| 495 | .timing_power = 0x41000a44, |
| 496 | .phy0_dqs = 0x08080808, |
| 497 | .phy1_dqs = 0x08080808, |
| 498 | .phy0_dq = 0x08080808, |
| 499 | .phy1_dq = 0x08080808, |
| 500 | .phy0_tFS = 0x8, |
| 501 | .phy1_tFS = 0x8, |
| 502 | .phy0_pulld_dqs = 0xf, |
| 503 | .phy1_pulld_dqs = 0xf, |
| 504 | |
| 505 | .lpddr3_ctrl_phy_reset = 0x1, |
| 506 | .ctrl_start_point = 0x10, |
| 507 | .ctrl_inc = 0x10, |
| 508 | .ctrl_start = 0x1, |
| 509 | .ctrl_dll_on = 0x1, |
| 510 | .ctrl_ref = 0x8, |
| 511 | |
| 512 | .ctrl_force = 0x1a, |
| 513 | .ctrl_rdlat = 0x0b, |
| 514 | .ctrl_bstlen = 0x08, |
| 515 | |
| 516 | .fp_resync = 0x8, |
| 517 | .iv_size = 0x7, |
| 518 | .dfi_init_start = 1, |
| 519 | .aref_en = 1, |
| 520 | |
| 521 | .rd_fetch = 0x3, |
| 522 | |
| 523 | .zq_mode_dds = 0x5, |
| 524 | .zq_mode_term = 0x1, |
| 525 | .zq_mode_noterm = 1, |
| 526 | |
| 527 | /* |
| 528 | * Dynamic Clock: Always Running |
| 529 | * Memory Burst length: 8 |
| 530 | * Number of chips: 1 |
| 531 | * Memory Bus width: 32 bit |
| 532 | * Memory Type: DDR3 |
| 533 | * Additional Latancy for PLL: 0 Cycle |
| 534 | */ |
| 535 | .memcontrol = DMC_MEMCONTROL_CLK_STOP_DISABLE | |
| 536 | DMC_MEMCONTROL_DPWRDN_DISABLE | |
| 537 | DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE | |
| 538 | DMC_MEMCONTROL_TP_DISABLE | |
| 539 | DMC_MEMCONTROL_DSREF_ENABLE | |
| 540 | DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) | |
| 541 | DMC_MEMCONTROL_MEM_TYPE_DDR3 | |
| 542 | DMC_MEMCONTROL_MEM_WIDTH_32BIT | |
| 543 | DMC_MEMCONTROL_NUM_CHIP_1 | |
| 544 | DMC_MEMCONTROL_BL_8 | |
| 545 | DMC_MEMCONTROL_PZQ_DISABLE | |
| 546 | DMC_MEMCONTROL_MRR_BYTE_7_0, |
| 547 | .memconfig = DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED | |
| 548 | DMC_MEMCONFIGx_CHIP_COL_10 | |
| 549 | DMC_MEMCONFIGx_CHIP_ROW_15 | |
| 550 | DMC_MEMCONFIGx_CHIP_BANK_8, |
| 551 | .membaseconfig0 = DMC_MEMBASECONFIG_VAL(0x40), |
| 552 | .membaseconfig1 = DMC_MEMBASECONFIG_VAL(0x80), |
| 553 | .prechconfig_tp_cnt = 0xff, |
| 554 | .dpwrdn_cyc = 0xff, |
| 555 | .dsref_cyc = 0xffff, |
| 556 | .concontrol = DMC_CONCONTROL_DFI_INIT_START_DISABLE | |
| 557 | DMC_CONCONTROL_TIMEOUT_LEVEL0 | |
| 558 | DMC_CONCONTROL_RD_FETCH_DISABLE | |
| 559 | DMC_CONCONTROL_EMPTY_DISABLE | |
| 560 | DMC_CONCONTROL_AREF_EN_DISABLE | |
| 561 | DMC_CONCONTROL_IO_PD_CON_DISABLE, |
| 562 | .dmc_channels = 2, |
| 563 | .chips_per_channel = 2, |
| 564 | .chips_to_configure = 1, |
| 565 | .send_zq_init = 1, |
| 566 | .impedance = IMP_OUTPUT_DRV_40_OHM, |
| 567 | .gate_leveling_enable = 1, |
| 568 | } |
| 569 | }; |
| 570 | |
| 571 | /** |
| 572 | * Detect what memory is present based on board strappings |
| 573 | * |
| 574 | * Boards have various resistor stuff options that are supposed to match |
| 575 | * which SDRAM is present (and which revision of the board this is). This |
| 576 | * uses the resistor stuff options to figure out what memory manufacturer |
| 577 | * to use for matching in the memory tables. |
| 578 | * |
| 579 | * @return A MEM_MANUF_XXX constant, or -1 if an error occurred. |
| 580 | */ |
| 581 | /* |
| 582 | * FIXME(dhendrix): This unwinds into a mess of board-specific code. The |
| 583 | * board's romstage.c file should detect the memory type and pass in |
| 584 | * appropriate parameters to whatever calls this. |
| 585 | */ |
| 586 | #define BOARD_REV_ELPIDA_MEMORY 3 |
| 587 | #define BOARD_REV_SAMSUNG_MEMORY 4 |
| 588 | static int autodetect_memory(void) |
| 589 | { |
| 590 | // int board_rev = board_get_revision(); |
| 591 | int board_rev = BOARD_REV_ELPIDA_MEMORY; |
| 592 | |
| 593 | if (board_rev == -1) |
| 594 | return -1; |
| 595 | |
| 596 | switch (board_rev) { |
| 597 | case BOARD_REV_SAMSUNG_MEMORY: |
| 598 | return MEM_MANUF_SAMSUNG; |
| 599 | case BOARD_REV_ELPIDA_MEMORY: |
| 600 | return MEM_MANUF_ELPIDA; |
| 601 | } |
| 602 | |
| 603 | return -1; |
| 604 | } |
| 605 | |
| 606 | #ifdef CONFIG_SPL_BUILD |
| 607 | |
| 608 | /** |
| 609 | * Get the required memory type and speed (SPL version). |
| 610 | * |
| 611 | * In SPL we have no device tree, so we use the machine parameters |
| 612 | */ |
| 613 | int clock_get_mem_selection(enum ddr_mode *mem_type, |
| 614 | unsigned *frequency_mhz, unsigned *arm_freq, |
| 615 | enum mem_manuf *mem_manuf) |
| 616 | { |
| 617 | struct spl_machine_param *params; |
| 618 | |
| 619 | params = spl_get_machine_params(); |
| 620 | *mem_type = params->mem_type; |
| 621 | *frequency_mhz = params->frequency_mhz; |
| 622 | *arm_freq = params->arm_freq_mhz; |
| 623 | if (params->mem_manuf == MEM_MANUF_AUTODETECT) { |
| 624 | *mem_manuf = autodetect_memory(); |
| 625 | if (*mem_manuf == -1) |
| 626 | return -1; |
| 627 | } else { |
| 628 | *mem_manuf = params->mem_manuf; |
| 629 | } |
| 630 | |
| 631 | return 0; |
| 632 | } |
| 633 | |
| 634 | #else |
| 635 | |
| 636 | static const char *mem_types[DDR_MODE_COUNT] = { |
| 637 | "DDR2", "DDR3", "LPDDR2", "LPDDR3" |
| 638 | }; |
| 639 | |
| 640 | static const char *mem_manufs[MEM_MANUF_COUNT] = { |
| 641 | "autodetect", "Elpida", "Samsung" |
| 642 | }; |
| 643 | |
| 644 | int clock_get_mem_selection(enum ddr_mode *mem_type, |
| 645 | unsigned *frequency_mhz, unsigned *arm_freq, |
| 646 | enum mem_manuf *mem_manuf) |
| 647 | { |
| 648 | const char *typestr; |
| 649 | int node, i; |
| 650 | |
| 651 | node = fdtdec_next_compatible(gd->fdt_blob, 0, |
| 652 | COMPAT_SAMSUNG_EXYNOS_DMC); |
| 653 | if (node < 0) |
| 654 | die("No memory information available in device tree"); |
| 655 | typestr = fdt_getprop(gd->fdt_blob, node, "mem-type", NULL); |
| 656 | for (i = 0; i < DDR_MODE_COUNT; i++) { |
| 657 | if (!stricmp(typestr, mem_types[i])) |
| 658 | break; |
| 659 | } |
| 660 | if (i == DDR_MODE_COUNT) |
| 661 | die("Invalid memory type in device tree"); |
| 662 | *mem_type = i; |
| 663 | |
| 664 | typestr = fdt_getprop(gd->fdt_blob, node, "mem-manuf", NULL); |
| 665 | for (i = 0; i < MEM_MANUF_COUNT; i++) { |
| 666 | if (!stricmp(typestr, mem_manufs[i])) |
| 667 | break; |
| 668 | } |
| 669 | if (i == MEM_MANUF_COUNT) |
| 670 | die("Invalid memory manufacturer in device tree"); |
| 671 | |
| 672 | if (i == MEM_MANUF_AUTODETECT) { |
| 673 | *mem_manuf = autodetect_memory(); |
| 674 | if (*mem_manuf == -1) |
| 675 | return -1; |
| 676 | } else { |
| 677 | *mem_manuf = i; |
| 678 | } |
| 679 | |
| 680 | *frequency_mhz = fdtdec_get_int(gd->fdt_blob, node, "clock-frequency", |
| 681 | 0); |
| 682 | if (!*frequency_mhz) |
| 683 | die("Invalid memory frequency in device tree"); |
| 684 | |
| 685 | *arm_freq = fdtdec_get_int(gd->fdt_blob, node, "arm-frequency", 0); |
| 686 | /* TODO: Remove all these panics/dies, and just return an error code */ |
| 687 | if (!*arm_freq) |
| 688 | die("Invalid ARM frequency in device tree"); |
| 689 | |
| 690 | return 0; |
| 691 | } |
| 692 | |
| 693 | const char *clock_get_mem_type_name(enum ddr_mode mem_type) |
| 694 | { |
| 695 | if (mem_type >= 0 && mem_type < DDR_MODE_COUNT) |
| 696 | return mem_types[mem_type]; |
| 697 | |
| 698 | return "<unknown>"; |
| 699 | } |
| 700 | |
| 701 | const char *clock_get_mem_manuf_name(enum mem_manuf mem_manuf) |
| 702 | { |
| 703 | if (mem_manuf >= 0 && mem_manuf < MEM_MANUF_COUNT) |
| 704 | return mem_manufs[mem_manuf]; |
| 705 | |
| 706 | return "<unknown>"; |
| 707 | } |
| 708 | #endif |
| 709 | |
| 710 | /* Get the ratios for setting ARM clock */ |
| 711 | struct arm_clk_ratios *get_arm_ratios(void); /* FIXME: silence compiler... */ |
| 712 | struct arm_clk_ratios *get_arm_ratios(void) |
| 713 | { |
| 714 | struct arm_clk_ratios *arm_ratio; |
| 715 | enum ddr_mode mem_type; |
| 716 | enum mem_manuf mem_manuf; |
| 717 | unsigned frequency_mhz, arm_freq; |
| 718 | int i; |
| 719 | |
| 720 | /* TODO(sjg@chromium.org): Return NULL and have caller deal with it */ |
| 721 | if (clock_get_mem_selection(&mem_type, &frequency_mhz, |
| 722 | &arm_freq, &mem_manuf)) |
| 723 | ; |
| 724 | for (i = 0, arm_ratio = arm_clk_ratios; i < ARRAY_SIZE(arm_clk_ratios); |
| 725 | i++, arm_ratio++) { |
| 726 | if (arm_ratio->arm_freq_mhz == arm_freq) |
| 727 | return arm_ratio; |
| 728 | } |
| 729 | |
| 730 | die("get_arm_ratios: Failed to find ratio\n"); |
| 731 | return NULL; |
| 732 | } |
| 733 | |
| 734 | struct mem_timings *clock_get_mem_timings(void) |
| 735 | { |
| 736 | struct mem_timings *mem; |
| 737 | enum ddr_mode mem_type; |
| 738 | enum mem_manuf mem_manuf; |
| 739 | unsigned frequency_mhz, arm_freq; |
| 740 | int i; |
| 741 | |
| 742 | if (!clock_get_mem_selection(&mem_type, &frequency_mhz, |
| 743 | &arm_freq, &mem_manuf)) { |
| 744 | for (i = 0, mem = mem_timings; i < ARRAY_SIZE(mem_timings); |
| 745 | i++, mem++) { |
| 746 | if (mem->mem_type == mem_type && |
| 747 | mem->frequency_mhz == frequency_mhz && |
| 748 | mem->mem_manuf == mem_manuf) |
| 749 | return mem; |
| 750 | } |
| 751 | } |
| 752 | /* TODO: Call panic() here */ |
| 753 | while (1) |
| 754 | ; |
| 755 | return NULL; |
| 756 | } |
| 757 | |
| 758 | void system_clock_init() |
| 759 | { |
| 760 | struct exynos5_clock *clk = (struct exynos5_clock *)EXYNOS5_CLOCK_BASE; |
| 761 | struct exynos5_mct_regs *mct_regs = |
| 762 | (struct exynos5_mct_regs *)EXYNOS5_MULTI_CORE_TIMER_BASE; |
| 763 | struct mem_timings *mem; |
| 764 | struct arm_clk_ratios *arm_clk_ratio; |
| 765 | u32 val, tmp; |
| 766 | |
| 767 | /* Turn on the MCT as early as possible. */ |
| 768 | mct_regs->g_tcon |= (1 << 8); |
| 769 | |
| 770 | mem = clock_get_mem_timings(); |
| 771 | arm_clk_ratio = get_arm_ratios(); |
| 772 | |
| 773 | clrbits_le32(&clk->src_cpu, MUX_APLL_SEL_MASK); |
| 774 | do { |
| 775 | val = readl(&clk->mux_stat_cpu); |
| 776 | } while ((val | MUX_APLL_SEL_MASK) != val); |
| 777 | |
| 778 | clrbits_le32(&clk->src_core1, MUX_MPLL_SEL_MASK); |
| 779 | do { |
| 780 | val = readl(&clk->mux_stat_core1); |
| 781 | } while ((val | MUX_MPLL_SEL_MASK) != val); |
| 782 | |
| 783 | clrbits_le32(&clk->src_top2, MUX_CPLL_SEL_MASK); |
| 784 | clrbits_le32(&clk->src_top2, MUX_EPLL_SEL_MASK); |
| 785 | clrbits_le32(&clk->src_top2, MUX_VPLL_SEL_MASK); |
| 786 | clrbits_le32(&clk->src_top2, MUX_GPLL_SEL_MASK); |
| 787 | tmp = MUX_CPLL_SEL_MASK | MUX_EPLL_SEL_MASK | MUX_VPLL_SEL_MASK |
| 788 | | MUX_GPLL_SEL_MASK; |
| 789 | do { |
| 790 | val = readl(&clk->mux_stat_top2); |
| 791 | } while ((val | tmp) != val); |
| 792 | |
| 793 | clrbits_le32(&clk->src_cdrex, MUX_BPLL_SEL_MASK); |
| 794 | do { |
| 795 | val = readl(&clk->mux_stat_cdrex); |
| 796 | } while ((val | MUX_BPLL_SEL_MASK) != val); |
| 797 | |
| 798 | /* PLL locktime */ |
| 799 | writel(APLL_LOCK_VAL, &clk->apll_lock); |
| 800 | |
| 801 | writel(MPLL_LOCK_VAL, &clk->mpll_lock); |
| 802 | |
| 803 | writel(BPLL_LOCK_VAL, &clk->bpll_lock); |
| 804 | |
| 805 | writel(CPLL_LOCK_VAL, &clk->cpll_lock); |
| 806 | |
| 807 | writel(GPLL_LOCK_VAL, &clk->gpll_lock); |
| 808 | |
| 809 | writel(EPLL_LOCK_VAL, &clk->epll_lock); |
| 810 | |
| 811 | writel(VPLL_LOCK_VAL, &clk->vpll_lock); |
| 812 | |
| 813 | writel(CLK_REG_DISABLE, &clk->pll_div2_sel); |
| 814 | |
| 815 | writel(MUX_HPM_SEL_MASK, &clk->src_cpu); |
| 816 | do { |
| 817 | val = readl(&clk->mux_stat_cpu); |
| 818 | } while ((val | HPM_SEL_SCLK_MPLL) != val); |
| 819 | |
| 820 | val = arm_clk_ratio->arm2_ratio << 28 |
| 821 | | arm_clk_ratio->apll_ratio << 24 |
| 822 | | arm_clk_ratio->pclk_dbg_ratio << 20 |
| 823 | | arm_clk_ratio->atb_ratio << 16 |
| 824 | | arm_clk_ratio->periph_ratio << 12 |
| 825 | | arm_clk_ratio->acp_ratio << 8 |
| 826 | | arm_clk_ratio->cpud_ratio << 4 |
| 827 | | arm_clk_ratio->arm_ratio; |
| 828 | writel(val, &clk->div_cpu0); |
| 829 | do { |
| 830 | val = readl(&clk->div_stat_cpu0); |
| 831 | } while (0 != val); |
| 832 | |
| 833 | writel(CLK_DIV_CPU1_VAL, &clk->div_cpu1); |
| 834 | do { |
| 835 | val = readl(&clk->div_stat_cpu1); |
| 836 | } while (0 != val); |
| 837 | |
| 838 | /* Set APLL */ |
| 839 | writel(APLL_CON1_VAL, &clk->apll_con1); |
| 840 | val = set_pll(arm_clk_ratio->apll_mdiv, arm_clk_ratio->apll_pdiv, |
| 841 | arm_clk_ratio->apll_sdiv); |
| 842 | writel(val, &clk->apll_con0); |
| 843 | while ((readl(&clk->apll_con0) & APLL_CON0_LOCKED) == 0) |
| 844 | ; |
| 845 | |
| 846 | /* Set MPLL */ |
| 847 | writel(MPLL_CON1_VAL, &clk->mpll_con1); |
| 848 | val = set_pll(mem->mpll_mdiv, mem->mpll_pdiv, mem->mpll_sdiv); |
| 849 | writel(val, &clk->mpll_con0); |
| 850 | while ((readl(&clk->mpll_con0) & MPLL_CON0_LOCKED) == 0) |
| 851 | ; |
| 852 | |
| 853 | /* |
| 854 | * Configure MUX_MPLL_FOUT to choose the direct clock source |
| 855 | * path and avoid the fixed DIV/2 block to save power |
| 856 | */ |
| 857 | setbits_le32(&clk->pll_div2_sel, MUX_MPLL_FOUT_SEL); |
| 858 | |
| 859 | /* Set BPLL */ |
| 860 | if (mem->use_bpll) { |
| 861 | writel(BPLL_CON1_VAL, &clk->bpll_con1); |
| 862 | val = set_pll(mem->bpll_mdiv, mem->bpll_pdiv, mem->bpll_sdiv); |
| 863 | writel(val, &clk->bpll_con0); |
| 864 | while ((readl(&clk->bpll_con0) & BPLL_CON0_LOCKED) == 0) |
| 865 | ; |
| 866 | |
| 867 | setbits_le32(&clk->pll_div2_sel, MUX_BPLL_FOUT_SEL); |
| 868 | } |
| 869 | |
| 870 | /* Set CPLL */ |
| 871 | writel(CPLL_CON1_VAL, &clk->cpll_con1); |
| 872 | val = set_pll(mem->cpll_mdiv, mem->cpll_pdiv, mem->cpll_sdiv); |
| 873 | writel(val, &clk->cpll_con0); |
| 874 | while ((readl(&clk->cpll_con0) & CPLL_CON0_LOCKED) == 0) |
| 875 | ; |
| 876 | |
| 877 | /* Set GPLL */ |
| 878 | writel(GPLL_CON1_VAL, &clk->gpll_con1); |
| 879 | val = set_pll(mem->gpll_mdiv, mem->gpll_pdiv, mem->gpll_sdiv); |
| 880 | writel(val, &clk->gpll_con0); |
| 881 | while ((readl(&clk->gpll_con0) & GPLL_CON0_LOCKED) == 0) |
| 882 | ; |
| 883 | |
| 884 | /* Set EPLL */ |
| 885 | writel(EPLL_CON2_VAL, &clk->epll_con2); |
| 886 | writel(EPLL_CON1_VAL, &clk->epll_con1); |
| 887 | val = set_pll(mem->epll_mdiv, mem->epll_pdiv, mem->epll_sdiv); |
| 888 | writel(val, &clk->epll_con0); |
| 889 | while ((readl(&clk->epll_con0) & EPLL_CON0_LOCKED) == 0) |
| 890 | ; |
| 891 | |
| 892 | /* Set VPLL */ |
| 893 | writel(VPLL_CON2_VAL, &clk->vpll_con2); |
| 894 | writel(VPLL_CON1_VAL, &clk->vpll_con1); |
| 895 | val = set_pll(mem->vpll_mdiv, mem->vpll_pdiv, mem->vpll_sdiv); |
| 896 | writel(val, &clk->vpll_con0); |
| 897 | while ((readl(&clk->vpll_con0) & VPLL_CON0_LOCKED) == 0) |
| 898 | ; |
| 899 | |
| 900 | writel(CLK_SRC_CORE0_VAL, &clk->src_core0); |
| 901 | writel(CLK_DIV_CORE0_VAL, &clk->div_core0); |
| 902 | while (readl(&clk->div_stat_core0) != 0) |
| 903 | ; |
| 904 | |
| 905 | writel(CLK_DIV_CORE1_VAL, &clk->div_core1); |
| 906 | while (readl(&clk->div_stat_core1) != 0) |
| 907 | ; |
| 908 | |
| 909 | writel(CLK_DIV_SYSRGT_VAL, &clk->div_sysrgt); |
| 910 | while (readl(&clk->div_stat_sysrgt) != 0) |
| 911 | ; |
| 912 | |
| 913 | writel(CLK_DIV_ACP_VAL, &clk->div_acp); |
| 914 | while (readl(&clk->div_stat_acp) != 0) |
| 915 | ; |
| 916 | |
| 917 | writel(CLK_DIV_SYSLFT_VAL, &clk->div_syslft); |
| 918 | while (readl(&clk->div_stat_syslft) != 0) |
| 919 | ; |
| 920 | |
| 921 | writel(CLK_SRC_TOP0_VAL, &clk->src_top0); |
| 922 | writel(CLK_SRC_TOP1_VAL, &clk->src_top1); |
| 923 | writel(TOP2_VAL, &clk->src_top2); |
| 924 | writel(CLK_SRC_TOP3_VAL, &clk->src_top3); |
| 925 | |
| 926 | writel(CLK_DIV_TOP0_VAL, &clk->div_top0); |
| 927 | while (readl(&clk->div_stat_top0)) |
| 928 | ; |
| 929 | |
| 930 | writel(CLK_DIV_TOP1_VAL, &clk->div_top1); |
| 931 | while (readl(&clk->div_stat_top1)) |
| 932 | ; |
| 933 | |
| 934 | writel(CLK_SRC_LEX_VAL, &clk->src_lex); |
| 935 | while (1) { |
| 936 | val = readl(&clk->mux_stat_lex); |
| 937 | if (val == (val | 1)) |
| 938 | break; |
| 939 | } |
| 940 | |
| 941 | writel(CLK_DIV_LEX_VAL, &clk->div_lex); |
| 942 | while (readl(&clk->div_stat_lex)) |
| 943 | ; |
| 944 | |
| 945 | writel(CLK_DIV_R0X_VAL, &clk->div_r0x); |
| 946 | while (readl(&clk->div_stat_r0x)) |
| 947 | ; |
| 948 | |
| 949 | writel(CLK_DIV_R0X_VAL, &clk->div_r0x); |
| 950 | while (readl(&clk->div_stat_r0x)) |
| 951 | ; |
| 952 | |
| 953 | writel(CLK_DIV_R1X_VAL, &clk->div_r1x); |
| 954 | while (readl(&clk->div_stat_r1x)) |
| 955 | ; |
| 956 | |
| 957 | if (mem->use_bpll) { |
| 958 | writel(MUX_BPLL_SEL_MASK | MUX_MCLK_CDREX_SEL | |
| 959 | MUX_MCLK_DPHY_SEL, &clk->src_cdrex); |
| 960 | } else { |
| 961 | writel(CLK_REG_DISABLE, &clk->src_cdrex); |
| 962 | } |
| 963 | |
| 964 | writel(CLK_DIV_CDREX_VAL, &clk->div_cdrex); |
| 965 | while (readl(&clk->div_stat_cdrex)) |
| 966 | ; |
| 967 | |
| 968 | val = readl(&clk->src_cpu); |
| 969 | val |= CLK_SRC_CPU_VAL; |
| 970 | writel(val, &clk->src_cpu); |
| 971 | |
| 972 | val = readl(&clk->src_top2); |
| 973 | val |= CLK_SRC_TOP2_VAL; |
| 974 | writel(val, &clk->src_top2); |
| 975 | |
| 976 | val = readl(&clk->src_core1); |
| 977 | val |= CLK_SRC_CORE1_VAL; |
| 978 | writel(val, &clk->src_core1); |
| 979 | |
| 980 | writel(CLK_SRC_FSYS0_VAL, &clk->src_fsys); |
| 981 | writel(CLK_DIV_FSYS0_VAL, &clk->div_fsys0); |
| 982 | while (readl(&clk->div_stat_fsys0)) |
| 983 | ; |
| 984 | |
| 985 | writel(CLK_REG_DISABLE, &clk->clkout_cmu_cpu); |
| 986 | writel(CLK_REG_DISABLE, &clk->clkout_cmu_core); |
| 987 | writel(CLK_REG_DISABLE, &clk->clkout_cmu_acp); |
| 988 | writel(CLK_REG_DISABLE, &clk->clkout_cmu_top); |
| 989 | writel(CLK_REG_DISABLE, &clk->clkout_cmu_lex); |
| 990 | writel(CLK_REG_DISABLE, &clk->clkout_cmu_r0x); |
| 991 | writel(CLK_REG_DISABLE, &clk->clkout_cmu_r1x); |
| 992 | writel(CLK_REG_DISABLE, &clk->clkout_cmu_cdrex); |
| 993 | |
| 994 | writel(CLK_SRC_PERIC0_VAL, &clk->src_peric0); |
| 995 | writel(CLK_DIV_PERIC0_VAL, &clk->div_peric0); |
| 996 | |
| 997 | writel(CLK_SRC_PERIC1_VAL, &clk->src_peric1); |
| 998 | writel(CLK_DIV_PERIC1_VAL, &clk->div_peric1); |
| 999 | writel(CLK_DIV_PERIC2_VAL, &clk->div_peric2); |
| 1000 | writel(SCLK_SRC_ISP_VAL, &clk->sclk_src_isp); |
| 1001 | writel(SCLK_DIV_ISP_VAL, &clk->sclk_div_isp); |
| 1002 | writel(CLK_DIV_ISP0_VAL, &clk->div_isp0); |
| 1003 | writel(CLK_DIV_ISP1_VAL, &clk->div_isp1); |
| 1004 | writel(CLK_DIV_ISP2_VAL, &clk->div_isp2); |
| 1005 | |
| 1006 | /* FIMD1 SRC CLK SELECTION */ |
| 1007 | writel(CLK_SRC_DISP1_0_VAL, &clk->src_disp1_0); |
| 1008 | |
| 1009 | val = MMC2_PRE_RATIO_VAL << MMC2_PRE_RATIO_OFFSET |
| 1010 | | MMC2_RATIO_VAL << MMC2_RATIO_OFFSET |
| 1011 | | MMC3_PRE_RATIO_VAL << MMC3_PRE_RATIO_OFFSET |
| 1012 | | MMC3_RATIO_VAL << MMC3_RATIO_OFFSET; |
| 1013 | writel(val, &clk->div_fsys2); |
| 1014 | } |
| 1015 | |
| 1016 | void clock_gate(void) |
| 1017 | { |
| 1018 | struct exynos5_clock *clk = (struct exynos5_clock *)EXYNOS5_CLOCK_BASE; |
| 1019 | |
| 1020 | /* CLK_GATE_IP_SYSRGT */ |
| 1021 | clrbits_le32(&clk->gate_ip_sysrgt, CLK_C2C_MASK); |
| 1022 | |
| 1023 | /* CLK_GATE_IP_ACP */ |
| 1024 | clrbits_le32(&clk->gate_ip_acp, CLK_SMMUG2D_MASK | |
| 1025 | CLK_SMMUSSS_MASK | |
| 1026 | CLK_SMMUMDMA_MASK | |
| 1027 | CLK_ID_REMAPPER_MASK | |
| 1028 | CLK_G2D_MASK | |
| 1029 | CLK_SSS_MASK | |
| 1030 | CLK_MDMA_MASK | |
| 1031 | CLK_SECJTAG_MASK); |
| 1032 | |
| 1033 | /* CLK_GATE_BUS_SYSLFT */ |
| 1034 | clrbits_le32(&clk->gate_bus_syslft, CLK_EFCLK_MASK); |
| 1035 | |
| 1036 | /* CLK_GATE_IP_ISP0 */ |
| 1037 | clrbits_le32(&clk->gate_ip_isp0, CLK_UART_ISP_MASK | |
| 1038 | CLK_WDT_ISP_MASK | |
| 1039 | CLK_PWM_ISP_MASK | |
| 1040 | CLK_MTCADC_ISP_MASK | |
| 1041 | CLK_I2C1_ISP_MASK | |
| 1042 | CLK_I2C0_ISP_MASK | |
| 1043 | CLK_MPWM_ISP_MASK | |
| 1044 | CLK_MCUCTL_ISP_MASK | |
| 1045 | CLK_INT_COMB_ISP_MASK | |
| 1046 | CLK_SMMU_MCUISP_MASK | |
| 1047 | CLK_SMMU_SCALERP_MASK | |
| 1048 | CLK_SMMU_SCALERC_MASK | |
| 1049 | CLK_SMMU_FD_MASK | |
| 1050 | CLK_SMMU_DRC_MASK | |
| 1051 | CLK_SMMU_ISP_MASK | |
| 1052 | CLK_GICISP_MASK | |
| 1053 | CLK_ARM9S_MASK | |
| 1054 | CLK_MCUISP_MASK | |
| 1055 | CLK_SCALERP_MASK | |
| 1056 | CLK_SCALERC_MASK | |
| 1057 | CLK_FD_MASK | |
| 1058 | CLK_DRC_MASK | |
| 1059 | CLK_ISP_MASK); |
| 1060 | |
| 1061 | /* CLK_GATE_IP_ISP1 */ |
| 1062 | clrbits_le32(&clk->gate_ip_isp1, CLK_SPI1_ISP_MASK | |
| 1063 | CLK_SPI0_ISP_MASK | |
| 1064 | CLK_SMMU3DNR_MASK | |
| 1065 | CLK_SMMUDIS1_MASK | |
| 1066 | CLK_SMMUDIS0_MASK | |
| 1067 | CLK_SMMUODC_MASK | |
| 1068 | CLK_3DNR_MASK | |
| 1069 | CLK_DIS_MASK | |
| 1070 | CLK_ODC_MASK); |
| 1071 | |
| 1072 | /* CLK_GATE_SCLK_ISP */ |
| 1073 | clrbits_le32(&clk->gate_sclk_isp, SCLK_MPWM_ISP_MASK); |
| 1074 | |
| 1075 | /* CLK_GATE_IP_GSCL */ |
| 1076 | clrbits_le32(&clk->gate_ip_gscl, CLK_SMMUFIMC_LITE2_MASK | |
| 1077 | CLK_SMMUFIMC_LITE1_MASK | |
| 1078 | CLK_SMMUFIMC_LITE0_MASK | |
| 1079 | CLK_SMMUGSCL3_MASK | |
| 1080 | CLK_SMMUGSCL2_MASK | |
| 1081 | CLK_SMMUGSCL1_MASK | |
| 1082 | CLK_SMMUGSCL0_MASK | |
| 1083 | CLK_GSCL_WRAP_B_MASK | |
| 1084 | CLK_GSCL_WRAP_A_MASK | |
| 1085 | CLK_CAMIF_TOP_MASK | |
| 1086 | CLK_GSCL3_MASK | |
| 1087 | CLK_GSCL2_MASK | |
| 1088 | CLK_GSCL1_MASK | |
| 1089 | CLK_GSCL0_MASK); |
| 1090 | |
| 1091 | /* CLK_GATE_IP_DISP1 */ |
| 1092 | clrbits_le32(&clk->gate_ip_disp1, CLK_SMMUTVX_MASK | |
| 1093 | CLK_ASYNCTVX_MASK | |
| 1094 | CLK_HDMI_MASK | |
| 1095 | CLK_MIXER_MASK | |
| 1096 | CLK_DSIM1_MASK); |
| 1097 | |
| 1098 | /* CLK_GATE_IP_MFC */ |
| 1099 | clrbits_le32(&clk->gate_ip_mfc, CLK_SMMUMFCR_MASK | |
| 1100 | CLK_SMMUMFCL_MASK | |
| 1101 | CLK_MFC_MASK); |
| 1102 | |
| 1103 | /* CLK_GATE_IP_GEN */ |
| 1104 | clrbits_le32(&clk->gate_ip_gen, CLK_SMMUMDMA1_MASK | |
| 1105 | CLK_SMMUJPEG_MASK | |
| 1106 | CLK_SMMUROTATOR_MASK | |
| 1107 | CLK_MDMA1_MASK | |
| 1108 | CLK_JPEG_MASK | |
| 1109 | CLK_ROTATOR_MASK); |
| 1110 | |
| 1111 | /* CLK_GATE_IP_FSYS */ |
| 1112 | clrbits_le32(&clk->gate_ip_fsys, CLK_WDT_IOP_MASK | |
| 1113 | CLK_SMMUMCU_IOP_MASK | |
| 1114 | CLK_SATA_PHY_I2C_MASK | |
| 1115 | CLK_SATA_PHY_CTRL_MASK | |
| 1116 | CLK_MCUCTL_MASK | |
| 1117 | CLK_NFCON_MASK | |
| 1118 | CLK_SMMURTIC_MASK | |
| 1119 | CLK_RTIC_MASK | |
| 1120 | CLK_MIPI_HSI_MASK | |
| 1121 | CLK_USBOTG_MASK | |
| 1122 | CLK_SATA_MASK | |
| 1123 | CLK_PDMA1_MASK | |
| 1124 | CLK_PDMA0_MASK | |
| 1125 | CLK_MCU_IOP_MASK); |
| 1126 | |
| 1127 | /* CLK_GATE_IP_PERIC */ |
| 1128 | clrbits_le32(&clk->gate_ip_peric, CLK_HS_I2C3_MASK | |
| 1129 | CLK_HS_I2C2_MASK | |
| 1130 | CLK_HS_I2C1_MASK | |
| 1131 | CLK_HS_I2C0_MASK | |
| 1132 | CLK_AC97_MASK | |
| 1133 | CLK_SPDIF_MASK | |
| 1134 | CLK_PCM2_MASK | |
| 1135 | CLK_PCM1_MASK | |
| 1136 | CLK_I2S2_MASK | |
| 1137 | CLK_SPI2_MASK | |
| 1138 | CLK_SPI0_MASK); |
| 1139 | |
| 1140 | /* CLK_GATE_IP_PERIS */ |
| 1141 | clrbits_le32(&clk->gate_ip_peris, CLK_RTC_MASK | |
| 1142 | CLK_TZPC9_MASK | |
| 1143 | CLK_TZPC8_MASK | |
| 1144 | CLK_TZPC7_MASK | |
| 1145 | CLK_TZPC6_MASK | |
| 1146 | CLK_TZPC5_MASK | |
| 1147 | CLK_TZPC4_MASK | |
| 1148 | CLK_TZPC3_MASK | |
| 1149 | CLK_TZPC2_MASK | |
| 1150 | CLK_TZPC1_MASK | |
| 1151 | CLK_TZPC0_MASK | |
| 1152 | CLK_CHIPID_MASK); |
| 1153 | |
| 1154 | /* CLK_GATE_BLOCK */ |
| 1155 | clrbits_le32(&clk->gate_block, CLK_ACP_MASK); |
| 1156 | |
| 1157 | /* CLK_GATE_IP_CDREX */ |
| 1158 | clrbits_le32(&clk->gate_ip_cdrex, CLK_DPHY0_MASK | |
| 1159 | CLK_DPHY1_MASK | |
| 1160 | CLK_TZASC_DRBXR_MASK); |
| 1161 | |
| 1162 | } |
| 1163 | |
| 1164 | void clock_init_dp_clock(void) |
| 1165 | { |
| 1166 | struct exynos5_clock *clk = (struct exynos5_clock *)EXYNOS5_CLOCK_BASE; |
| 1167 | |
| 1168 | /* DP clock enable */ |
| 1169 | setbits_le32(&clk->gate_ip_disp1, CLK_GATE_DP1_ALLOW); |
| 1170 | |
| 1171 | /* We run DP at 267 Mhz */ |
| 1172 | setbits_le32(&clk->div_disp1_0, CLK_DIV_DISP1_0_FIMD1); |
| 1173 | } |
| 1174 | |
| 1175 | #ifdef CONFIG_SPL_BUILD |
| 1176 | /* |
| 1177 | * This is a custom implementation for the udelay(), as we do not the timer |
| 1178 | * initialise during the SPL boot. We are assuming the cpu takes 3 instruction |
| 1179 | * pre cycle. This is based on the implementation of sdelay() function. |
| 1180 | */ |
| 1181 | void udelay(unsigned usec) |
| 1182 | { |
| 1183 | unsigned long count; |
| 1184 | |
| 1185 | /* TODO(alim.akhtar@samsung.com): Comment on why divided by 30000000 */ |
| 1186 | count = usec * (get_pll_clk(APLL) / (3 * 10000000)); |
| 1187 | sdelay(count); |
| 1188 | } |
| 1189 | #endif |