uboot/arch/arm/mach-exynos/exynos5_setup.h
<<
>>
Prefs
   1/*
   2 * Machine Specific Values for SMDK5250 board based on EXYNOS5
   3 *
   4 * Copyright (C) 2012 Samsung Electronics
   5 *
   6 * SPDX-License-Identifier:     GPL-2.0+
   7 */
   8
   9#ifndef _SMDK5250_SETUP_H
  10#define _SMDK5250_SETUP_H
  11
  12#include <config.h>
  13#include <asm/arch/dmc.h>
  14
  15#define NOT_AVAILABLE           0
  16#define DATA_MASK               0xFFFFF
  17
  18#define ENABLE_BIT              0x1
  19#define DISABLE_BIT             0x0
  20#define CA_SWAP_EN              (1 << 0)
  21
  22/* Set PLL */
  23#define set_pll(mdiv, pdiv, sdiv)       (1<<31 | mdiv<<16 | pdiv<<8 | sdiv)
  24
  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 */
  54#define DMC_MEMCONFIGX_CHIP_MAP_INTERLEAVED     (1 << 12)
  55#define DMC_MEMCONFIG_CHIP_MAP_SPLIT            (2 << 12)
  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)
  60
  61#define DMC_MEMBASECONFIGX_CHIP_BASE(x)         (x << 16)
  62#define DMC_MEMBASECONFIGX_CHIP_MASK(x)         (x << 0)
  63#define DMC_MEMBASECONFIG_VAL(x)        (       \
  64        DMC_MEMBASECONFIGX_CHIP_BASE(x) |       \
  65        DMC_MEMBASECONFIGX_CHIP_MASK(0x780)     \
  66)
  67
  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
  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)
 102#define DMC_CONCONTROL_IO_PD_CON_ENABLE         (1 << 3)
 103#define DMC_CONCONTROL_AREF_EN_DISABLE          (0 << 5)
 104#define DMC_CONCONTROL_AREF_EN_ENABLE           (1 << 5)
 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
 111#define DMC_CONCONTROL_VAL      0x1FFF2101
 112
 113#define DREX_CONCONTROL_VAL     DMC_CONCONTROL_VAL                      \
 114                                | DMC_CONCONTROL_AREF_EN_ENABLE         \
 115                                | DMC_CONCONTROL_IO_PD_CON_ENABLE
 116
 117#define DMC_CONCONTROL_IO_PD_CON(x)             (x << 6)
 118
 119/* CLK_DIV_CPU1 */
 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))
 126
 127/* CLK_SRC_CORE0 */
 128#define CLK_SRC_CORE0_VAL       0x00000000
 129
 130/* CLK_SRC_CORE1 */
 131#define CLK_SRC_CORE1_VAL       0x100
 132
 133/* CLK_DIV_CORE0 */
 134#define CLK_DIV_CORE0_VAL       0x00120000
 135
 136/* CLK_DIV_CORE1 */
 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
 147
 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
 246/* CLK_SRC_CDREX */
 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_LOCK_COARSE_OFFSET 10
 286#define CTRL_LOCK_COARSE_MASK   (0x7F << CTRL_LOCK_COARSE_OFFSET)
 287#define CTRL_LOCK_COARSE(x)     (((x) & CTRL_LOCK_COARSE_MASK) >> \
 288                                 CTRL_LOCK_COARSE_OFFSET)
 289#define CTRL_FORCE_MASK         (0x7F << 8)
 290#define CTRL_FINE_LOCKED        0x7
 291
 292#define CTRL_OFFSETD_RESET_VAL  0x8
 293#define CTRL_OFFSETD_VAL        0x7F
 294
 295#define CTRL_OFFSETR0           0x7F
 296#define CTRL_OFFSETR1           0x7F
 297#define CTRL_OFFSETR2           0x7F
 298#define CTRL_OFFSETR3           0x7F
 299#define PHY_CON4_VAL    (CTRL_OFFSETR0 << 0 | \
 300                                CTRL_OFFSETR1 << 8 | \
 301                                CTRL_OFFSETR2 << 16 | \
 302                                CTRL_OFFSETR3 << 24)
 303#define PHY_CON4_RESET_VAL      0x08080808
 304
 305#define CTRL_OFFSETW0           0x7F
 306#define CTRL_OFFSETW1           0x7F
 307#define CTRL_OFFSETW2           0x7F
 308#define CTRL_OFFSETW3           0x7F
 309#define PHY_CON6_VAL    (CTRL_OFFSETW0 << 0 | \
 310                                CTRL_OFFSETW1 << 8 | \
 311                                CTRL_OFFSETW2 << 16 | \
 312                                CTRL_OFFSETW3 << 24)
 313#define PHY_CON6_RESET_VAL      0x08080808
 314
 315#define PHY_CON14_RESET_VAL     0x001F0000
 316#define CTRL_PULLD_DQS          0xF
 317#define CTRL_PULLD_DQS_OFFSET   0
 318
 319/* ZQ Configurations */
 320#define PHY_CON16_RESET_VAL     0x08000304
 321
 322#define ZQ_CLK_EN               (1 << 27)
 323#define ZQ_CLK_DIV_EN           (1 << 18)
 324#define ZQ_MANUAL_STR           (1 << 1)
 325#define ZQ_DONE                 (1 << 0)
 326#define ZQ_MODE_DDS_OFFSET      24
 327
 328#define CTRL_RDLVL_GATE_ENABLE  1
 329#define CTRL_RDLVL_GATE_DISABLE 0
 330#define CTRL_RDLVL_DATA_ENABLE  2
 331
 332/* Direct Command */
 333#define DIRECT_CMD_NOP                  0x07000000
 334#define DIRECT_CMD_PALL                 0x01000000
 335#define DIRECT_CMD_ZQINIT               0x0a000000
 336#define DIRECT_CMD_CHANNEL_SHIFT        28
 337#define DIRECT_CMD_CHIP_SHIFT           20
 338#define DIRECT_CMD_BANK_SHIFT           16
 339#define DIRECT_CMD_REFA         (5 << 24)
 340#define DIRECT_CMD_MRS1         0x71C00
 341#define DIRECT_CMD_MRS2         0x10BFC
 342#define DIRECT_CMD_MRS3         0x0050C
 343#define DIRECT_CMD_MRS4         0x00868
 344#define DIRECT_CMD_MRS5         0x00C04
 345
 346/* Drive Strength */
 347#define IMPEDANCE_48_OHM        4
 348#define IMPEDANCE_40_OHM        5
 349#define IMPEDANCE_34_OHM        6
 350#define IMPEDANCE_30_OHM        7
 351#define PHY_CON39_VAL_48_OHM    0x09240924
 352#define PHY_CON39_VAL_40_OHM    0x0B6D0B6D
 353#define PHY_CON39_VAL_34_OHM    0x0DB60DB6
 354#define PHY_CON39_VAL_30_OHM    0x0FFF0FFF
 355
 356#define CTRL_BSTLEN_OFFSET      8
 357#define CTRL_RDLAT_OFFSET       0
 358
 359#define CMD_DEFAULT_LPDDR3      0xF
 360#define CMD_DEFUALT_OFFSET      0
 361#define T_WRDATA_EN             0x7
 362#define T_WRDATA_EN_DDR3        0x8
 363#define T_WRDATA_EN_OFFSET      16
 364#define T_WRDATA_EN_MASK        0x1f
 365
 366#define PHY_CON31_VAL   0x0C183060
 367#define PHY_CON32_VAL   0x60C18306
 368#define PHY_CON33_VAL   0x00000030
 369
 370#define PHY_CON31_RESET_VAL     0x0
 371#define PHY_CON32_RESET_VAL     0x0
 372#define PHY_CON33_RESET_VAL     0x0
 373
 374#define SL_DLL_DYN_CON_EN       (1 << 1)
 375#define FP_RESYNC       (1 << 3)
 376#define CTRL_START      (1 << 6)
 377
 378#define DMC_AREF_EN             (1 << 5)
 379#define DMC_CONCONTROL_EMPTY    (1 << 8)
 380#define DFI_INIT_START          (1 << 28)
 381
 382#define DMC_MEMCONTROL_VAL      0x00312700
 383#define CLK_STOP_EN             (1 << 0)
 384#define DPWRDN_EN               (1 << 1)
 385#define DSREF_EN                (1 << 5)
 386
 387#define MEMBASECONFIG_CHIP_MASK_VAL     0x7E0
 388#define MEMBASECONFIG_CHIP_MASK_OFFSET  0
 389#define MEMBASECONFIG0_CHIP_BASE_VAL    0x20
 390#define MEMBASECONFIG1_CHIP_BASE_VAL    0x40
 391#define CHIP_BASE_OFFSET                16
 392
 393#define MEMCONFIG_VAL   0x1323
 394#define PRECHCONFIG_DEFAULT_VAL 0xFF000000
 395#define PWRDNCONFIG_DEFAULT_VAL 0xFFFF00FF
 396
 397#define TIMINGAREF_VAL  0x5d
 398#define TIMINGROW_VAL   0x345A8692
 399#define TIMINGDATA_VAL  0x3630065C
 400#define TIMINGPOWER_VAL 0x50380336
 401#define DFI_INIT_COMPLETE       (1 << 3)
 402
 403#define BRBRSVCONTROL_VAL       0x00000033
 404#define BRBRSVCONFIG_VAL        0x88778877
 405
 406/* Clock Gating Control (CGCONTROL) register */
 407#define MEMIF_CG_EN     (1 << 3) /* Memory interface clock gating */
 408#define SCG_CG_EN       (1 << 2) /* Scheduler clock gating */
 409#define BUSIF_WR_CG_EN  (1 << 1) /* Bus interface write channel clock gating */
 410#define BUSIF_RD_CG_EN  (1 << 0) /* Bus interface read channel clock gating */
 411#define DMC_INTERNAL_CG (MEMIF_CG_EN | SCG_CG_EN | \
 412                                 BUSIF_WR_CG_EN | BUSIF_RD_CG_EN)
 413
 414/* DMC PHY Control0 register */
 415#define PHY_CONTROL0_RESET_VAL  0x0
 416#define MEM_TERM_EN     (1 << 31)       /* Termination enable for memory */
 417#define PHY_TERM_EN     (1 << 30)       /* Termination enable for PHY */
 418#define DMC_CTRL_SHGATE (1 << 29)       /* Duration of DQS gating signal */
 419#define FP_RSYNC        (1 << 3)        /* Force DLL resyncronization */
 420
 421/* Driver strength for CK, CKE, CS & CA */
 422#define IMP_OUTPUT_DRV_40_OHM   0x5
 423#define IMP_OUTPUT_DRV_30_OHM   0x7
 424#define DA_3_DS_OFFSET          25
 425#define DA_2_DS_OFFSET          22
 426#define DA_1_DS_OFFSET          19
 427#define DA_0_DS_OFFSET          16
 428#define CA_CK_DRVR_DS_OFFSET    9
 429#define CA_CKE_DRVR_DS_OFFSET   6
 430#define CA_CS_DRVR_DS_OFFSET    3
 431#define CA_ADR_DRVR_DS_OFFSET   0
 432
 433#define PHY_CON42_CTRL_BSTLEN_SHIFT     8
 434#define PHY_CON42_CTRL_RDLAT_SHIFT      0
 435
 436/*
 437 * Definitions that differ with SoC's.
 438 * Below is the part defining macros for Exynos5250.
 439 * Else part introduces macros for Exynos5420.
 440 */
 441#ifndef CONFIG_EXYNOS5420
 442
 443/* APLL_CON1 */
 444#define APLL_CON1_VAL   (0x00203800)
 445
 446/* MPLL_CON1 */
 447#define MPLL_CON1_VAL   (0x00203800)
 448
 449/* CPLL_CON1 */
 450#define CPLL_CON1_VAL   (0x00203800)
 451
 452/* DPLL_CON1 */
 453#define DPLL_CON1_VAL   (NOT_AVAILABLE)
 454
 455/* GPLL_CON1 */
 456#define GPLL_CON1_VAL   (0x00203800)
 457
 458/* EPLL_CON1, CON2 */
 459#define EPLL_CON1_VAL   0x00000000
 460#define EPLL_CON2_VAL   0x00000080
 461
 462/* VPLL_CON1, CON2 */
 463#define VPLL_CON1_VAL   0x00000000
 464#define VPLL_CON2_VAL   0x00000080
 465
 466/* RPLL_CON1, CON2 */
 467#define RPLL_CON1_VAL   NOT_AVAILABLE
 468#define RPLL_CON2_VAL   NOT_AVAILABLE
 469
 470/* BPLL_CON1 */
 471#define BPLL_CON1_VAL   0x00203800
 472
 473/* SPLL_CON1 */
 474#define SPLL_CON1_VAL   NOT_AVAILABLE
 475
 476/* IPLL_CON1 */
 477#define IPLL_CON1_VAL   NOT_AVAILABLE
 478
 479/* KPLL_CON1 */
 480#define KPLL_CON1_VAL   NOT_AVAILABLE
 481
 482/* CLK_SRC_ISP */
 483#define CLK_SRC_ISP_VAL         NOT_AVAILABLE
 484#define CLK_DIV_ISP0_VAL        0x31
 485#define CLK_DIV_ISP1_VAL        0x0
 486
 487/* CLK_FSYS */
 488#define CLK_SRC_FSYS0_VAL              0x66666
 489#define CLK_DIV_FSYS0_VAL              0x0BB00000
 490#define CLK_DIV_FSYS1_VAL              NOT_AVAILABLE
 491#define CLK_DIV_FSYS2_VAL              NOT_AVAILABLE
 492
 493/* CLK_SRC_CPU */
 494/* 0 = MOUTAPLL,  1 = SCLKMPLL */
 495#define MUX_HPM_SEL             0
 496#define MUX_CPU_SEL             0
 497#define MUX_APLL_SEL            1
 498
 499#define CLK_SRC_CPU_VAL         ((MUX_HPM_SEL << 20)    \
 500                                | (MUX_CPU_SEL << 16)  \
 501                                | (MUX_APLL_SEL))
 502
 503/* CLK_SRC_CDREX */
 504#define CLK_SRC_CDREX_VAL       0x1
 505
 506/* CLK_DIV_CDREX */
 507#define CLK_DIV_CDREX0_VAL      NOT_AVAILABLE
 508#define CLK_DIV_CDREX1_VAL      NOT_AVAILABLE
 509
 510/* CLK_DIV_CPU0_VAL */
 511#define CLK_DIV_CPU0_VAL        NOT_AVAILABLE
 512
 513#define MCLK_CDREX2_RATIO       0x0
 514#define ACLK_EFCON_RATIO        0x1
 515#define MCLK_DPHY_RATIO         0x1
 516#define MCLK_CDREX_RATIO        0x1
 517#define ACLK_C2C_200_RATIO      0x1
 518#define C2C_CLK_400_RATIO       0x1
 519#define PCLK_CDREX_RATIO        0x1
 520#define ACLK_CDREX_RATIO        0x1
 521
 522#define CLK_DIV_CDREX_VAL       ((MCLK_DPHY_RATIO << 24)        \
 523                                | (C2C_CLK_400_RATIO << 6)      \
 524                                | (PCLK_CDREX_RATIO << 4)       \
 525                                | (ACLK_CDREX_RATIO))
 526
 527/* CLK_SRC_TOP0 */
 528#define MUX_ACLK_300_GSCL_SEL           0x0
 529#define MUX_ACLK_300_GSCL_MID_SEL       0x0
 530#define MUX_ACLK_400_G3D_MID_SEL        0x0
 531#define MUX_ACLK_333_SEL                0x0
 532#define MUX_ACLK_300_DISP1_SEL          0x0
 533#define MUX_ACLK_300_DISP1_MID_SEL      0x0
 534#define MUX_ACLK_200_SEL                0x0
 535#define MUX_ACLK_166_SEL                0x0
 536#define CLK_SRC_TOP0_VAL        ((MUX_ACLK_300_GSCL_SEL  << 25)         \
 537                                | (MUX_ACLK_300_GSCL_MID_SEL << 24)     \
 538                                | (MUX_ACLK_400_G3D_MID_SEL << 20)      \
 539                                | (MUX_ACLK_333_SEL << 16)              \
 540                                | (MUX_ACLK_300_DISP1_SEL << 15)        \
 541                                | (MUX_ACLK_300_DISP1_MID_SEL << 14)    \
 542                                | (MUX_ACLK_200_SEL << 12)              \
 543                                | (MUX_ACLK_166_SEL << 8))
 544
 545/* CLK_SRC_TOP1 */
 546#define MUX_ACLK_400_G3D_SEL            0x1
 547#define MUX_ACLK_400_ISP_SEL            0x0
 548#define MUX_ACLK_400_IOP_SEL            0x0
 549#define MUX_ACLK_MIPI_HSI_TXBASE_SEL    0x0
 550#define MUX_ACLK_300_GSCL_MID1_SEL      0x0
 551#define MUX_ACLK_300_DISP1_MID1_SEL     0x0
 552#define CLK_SRC_TOP1_VAL        ((MUX_ACLK_400_G3D_SEL << 28)           \
 553                                |(MUX_ACLK_400_ISP_SEL << 24)           \
 554                                |(MUX_ACLK_400_IOP_SEL << 20)           \
 555                                |(MUX_ACLK_MIPI_HSI_TXBASE_SEL << 16)   \
 556                                |(MUX_ACLK_300_GSCL_MID1_SEL << 12)     \
 557                                |(MUX_ACLK_300_DISP1_MID1_SEL << 8))
 558
 559/* CLK_SRC_TOP2 */
 560#define MUX_GPLL_SEL                    0x1
 561#define MUX_BPLL_USER_SEL               0x0
 562#define MUX_MPLL_USER_SEL               0x0
 563#define MUX_VPLL_SEL                    0x1
 564#define MUX_EPLL_SEL                    0x1
 565#define MUX_CPLL_SEL                    0x1
 566#define VPLLSRC_SEL                     0x0
 567#define CLK_SRC_TOP2_VAL        ((MUX_GPLL_SEL << 28)           \
 568                                | (MUX_BPLL_USER_SEL << 24)     \
 569                                | (MUX_MPLL_USER_SEL << 20)     \
 570                                | (MUX_VPLL_SEL << 16)          \
 571                                | (MUX_EPLL_SEL << 12)          \
 572                                | (MUX_CPLL_SEL << 8)           \
 573                                | (VPLLSRC_SEL))
 574/* CLK_SRC_TOP3 */
 575#define MUX_ACLK_333_SUB_SEL            0x1
 576#define MUX_ACLK_400_SUB_SEL            0x1
 577#define MUX_ACLK_266_ISP_SUB_SEL        0x1
 578#define MUX_ACLK_266_GPS_SUB_SEL        0x0
 579#define MUX_ACLK_300_GSCL_SUB_SEL       0x1
 580#define MUX_ACLK_266_GSCL_SUB_SEL       0x1
 581#define MUX_ACLK_300_DISP1_SUB_SEL      0x1
 582#define MUX_ACLK_200_DISP1_SUB_SEL      0x1
 583#define CLK_SRC_TOP3_VAL        ((MUX_ACLK_333_SUB_SEL << 24)           \
 584                                | (MUX_ACLK_400_SUB_SEL << 20)          \
 585                                | (MUX_ACLK_266_ISP_SUB_SEL << 16)      \
 586                                | (MUX_ACLK_266_GPS_SUB_SEL << 12)      \
 587                                | (MUX_ACLK_300_GSCL_SUB_SEL << 10)     \
 588                                | (MUX_ACLK_266_GSCL_SUB_SEL << 8)      \
 589                                | (MUX_ACLK_300_DISP1_SUB_SEL << 6)     \
 590                                | (MUX_ACLK_200_DISP1_SUB_SEL << 4))
 591
 592#define CLK_SRC_TOP4_VAL        NOT_AVAILABLE
 593#define CLK_SRC_TOP5_VAL        NOT_AVAILABLE
 594#define CLK_SRC_TOP6_VAL        NOT_AVAILABLE
 595#define CLK_SRC_TOP7_VAL        NOT_AVAILABLE
 596
 597/* CLK_DIV_TOP0 */
 598#define ACLK_300_DISP1_RATIO    0x2
 599#define ACLK_400_G3D_RATIO      0x0
 600#define ACLK_333_RATIO          0x0
 601#define ACLK_266_RATIO          0x2
 602#define ACLK_200_RATIO          0x3
 603#define ACLK_166_RATIO          0x1
 604#define ACLK_133_RATIO          0x1
 605#define ACLK_66_RATIO           0x5
 606
 607#define CLK_DIV_TOP0_VAL        ((ACLK_300_DISP1_RATIO << 28)   \
 608                                | (ACLK_400_G3D_RATIO << 24)    \
 609                                | (ACLK_333_RATIO  << 20)       \
 610                                | (ACLK_266_RATIO << 16)        \
 611                                | (ACLK_200_RATIO << 12)        \
 612                                | (ACLK_166_RATIO << 8)         \
 613                                | (ACLK_133_RATIO << 4)         \
 614                                | (ACLK_66_RATIO))
 615
 616/* CLK_DIV_TOP1 */
 617#define ACLK_MIPI_HSI_TX_BASE_RATIO     0x3
 618#define ACLK_66_PRE_RATIO               0x1
 619#define ACLK_400_ISP_RATIO              0x1
 620#define ACLK_400_IOP_RATIO              0x1
 621#define ACLK_300_GSCL_RATIO             0x2
 622
 623#define CLK_DIV_TOP1_VAL        ((ACLK_MIPI_HSI_TX_BASE_RATIO << 28)    \
 624                                | (ACLK_66_PRE_RATIO << 24)             \
 625                                | (ACLK_400_ISP_RATIO  << 20)           \
 626                                | (ACLK_400_IOP_RATIO << 16)            \
 627                                | (ACLK_300_GSCL_RATIO << 12))
 628
 629#define CLK_DIV_TOP2_VAL        NOT_AVAILABLE
 630
 631/* PLL Lock Value Factor */
 632#define PLL_LOCK_FACTOR         250
 633#define PLL_X_LOCK_FACTOR       3000
 634
 635/* CLK_SRC_PERIC0 */
 636#define PWM_SEL         6
 637#define UART3_SEL       6
 638#define UART2_SEL       6
 639#define UART1_SEL       6
 640#define UART0_SEL       6
 641/* SRC_CLOCK = SCLK_MPLL */
 642#define CLK_SRC_PERIC0_VAL      ((PWM_SEL << 24)        \
 643                                | (UART3_SEL << 12)     \
 644                                | (UART2_SEL << 8)       \
 645                                | (UART1_SEL << 4)      \
 646                                | (UART0_SEL))
 647
 648/* CLK_SRC_PERIC1 */
 649/* SRC_CLOCK = SCLK_MPLL */
 650#define SPI0_SEL                6
 651#define SPI1_SEL                6
 652#define SPI2_SEL                6
 653#define CLK_SRC_PERIC1_VAL      ((SPI2_SEL << 24) \
 654                                | (SPI1_SEL << 20) \
 655                                | (SPI0_SEL << 16))
 656
 657/* CLK_DIV_PERIL0       */
 658#define UART5_RATIO     7
 659#define UART4_RATIO     7
 660#define UART3_RATIO     7
 661#define UART2_RATIO     7
 662#define UART1_RATIO     7
 663#define UART0_RATIO     7
 664
 665#define CLK_DIV_PERIC0_VAL      ((UART3_RATIO << 12)    \
 666                                | (UART2_RATIO << 8)    \
 667                                | (UART1_RATIO << 4)    \
 668                                | (UART0_RATIO))
 669/* CLK_DIV_PERIC1 */
 670#define SPI1_RATIO              0x7
 671#define SPI0_RATIO              0xf
 672#define SPI1_SUB_RATIO          0x0
 673#define SPI0_SUB_RATIO          0x0
 674#define CLK_DIV_PERIC1_VAL      ((SPI1_SUB_RATIO << 24) \
 675                                | ((SPI1_RATIO << 16) \
 676                                | (SPI0_SUB_RATIO << 8) \
 677                                | (SPI0_RATIO << 0)))
 678
 679/* CLK_DIV_PERIC2 */
 680#define SPI2_RATIO              0xf
 681#define SPI2_SUB_RATIO          0x0
 682#define CLK_DIV_PERIC2_VAL      ((SPI2_SUB_RATIO << 8) \
 683                                | (SPI2_RATIO << 0))
 684
 685/* CLK_DIV_PERIC3 */
 686#define PWM_RATIO               8
 687#define CLK_DIV_PERIC3_VAL      (PWM_RATIO << 0)
 688
 689
 690/* CLK_DIV_PERIC4 */
 691#define CLK_DIV_PERIC4_VAL      NOT_AVAILABLE
 692
 693/* CLK_SRC_DISP1_0 */
 694#define CLK_SRC_DISP1_0_VAL     0x6
 695#define CLK_DIV_DISP1_0_VAL     NOT_AVAILABLE
 696
 697#define APLL_FOUT               (1 << 0)
 698#define KPLL_FOUT               NOT_AVAILABLE
 699
 700#define CLK_DIV_CPERI1_VAL      NOT_AVAILABLE
 701
 702#else
 703
 704#define CPU_CONFIG_STATUS_OFFSET        0x80
 705#define CPU_RST_FLAG_VAL                0xFCBA0D10
 706#define PAD_RETENTION_DRAM_COREBLK_VAL  0x10000000
 707
 708/* APLL_CON1 */
 709#define APLL_CON1_VAL   (0x0020F300)
 710
 711/* MPLL_CON1 */
 712#define MPLL_CON1_VAL   (0x0020F300)
 713
 714
 715/* CPLL_CON1 */
 716#define CPLL_CON1_VAL   0x0020f300
 717
 718/* DPLL_CON1 */
 719#define DPLL_CON1_VAL   (0x0020F300)
 720
 721/* GPLL_CON1 */
 722#define GPLL_CON1_VAL   (NOT_AVAILABLE)
 723
 724
 725/* EPLL_CON1, CON2 */
 726#define EPLL_CON1_VAL   0x00000000
 727#define EPLL_CON2_VAL   0x00000080
 728
 729/* VPLL_CON1, CON2 */
 730#define VPLL_CON1_VAL   0x0020f300
 731#define VPLL_CON2_VAL   NOT_AVAILABLE
 732
 733/* RPLL_CON1, CON2 */
 734#define RPLL_CON1_VAL   0x00000000
 735#define RPLL_CON2_VAL   0x00000080
 736
 737/* BPLL_CON1 */
 738#define BPLL_CON1_VAL   0x0020f300
 739
 740/* SPLL_CON1 */
 741#define SPLL_CON1_VAL   0x0020f300
 742
 743/* IPLL_CON1 */
 744#define IPLL_CON1_VAL   0x00000080
 745
 746/* KPLL_CON1 */
 747#define KPLL_CON1_VAL   0x200000
 748
 749/* CLK_SRC_ISP */
 750#define CLK_SRC_ISP_VAL         0x33366000
 751#define CLK_DIV_ISP0_VAL        0x13131300
 752#define CLK_DIV_ISP1_VAL        0xbb110202
 753
 754
 755/* CLK_FSYS */
 756#define CLK_SRC_FSYS0_VAL              0x33033300
 757#define CLK_DIV_FSYS0_VAL              0x0
 758#define CLK_DIV_FSYS1_VAL              0x04f13c4f
 759#define CLK_DIV_FSYS2_VAL              0x041d0000
 760
 761/* CLK_SRC_CPU */
 762/* 0 = MOUTAPLL,  1 = SCLKMPLL */
 763#define MUX_HPM_SEL             1
 764#define MUX_CPU_SEL             0
 765#define MUX_APLL_SEL            1
 766
 767#define CLK_SRC_CPU_VAL         ((MUX_HPM_SEL << 20)    \
 768                                | (MUX_CPU_SEL << 16)  \
 769                                | (MUX_APLL_SEL))
 770
 771/* CLK_SRC_CDREX */
 772#define CLK_SRC_CDREX_VAL       0x00000011
 773
 774/* CLK_DIV_CDREX */
 775#define CLK_DIV_CDREX0_VAL      0x30010100
 776#define CLK_DIV_CDREX1_VAL      0x300
 777
 778#define CLK_DIV_CDREX_VAL       0x17010100
 779
 780/* CLK_DIV_CPU0_VAL */
 781#define CLK_DIV_CPU0_VAL        0x01440020
 782
 783/* CLK_SRC_TOP */
 784#define CLK_SRC_TOP0_VAL        0x12221222
 785#define CLK_SRC_TOP1_VAL        0x00100200
 786#define CLK_SRC_TOP2_VAL        0x11101000
 787#define CLK_SRC_TOP3_VAL        0x11111111
 788#define CLK_SRC_TOP4_VAL        0x11110111
 789#define CLK_SRC_TOP5_VAL        0x11111101
 790#define CLK_SRC_TOP6_VAL        0x11110111
 791#define CLK_SRC_TOP7_VAL        0x00022200
 792
 793/* CLK_DIV_TOP */
 794#define CLK_DIV_TOP0_VAL        0x23712311
 795#define CLK_DIV_TOP1_VAL        0x13100B00
 796#define CLK_DIV_TOP2_VAL        0x11101100
 797
 798/* PLL Lock Value Factor */
 799#define PLL_LOCK_FACTOR         200
 800#define PLL_X_LOCK_FACTOR       3000
 801
 802/* CLK_SRC_PERIC0 */
 803#define SPDIF_SEL       1
 804#define PWM_SEL         3
 805#define UART4_SEL       3
 806#define UART3_SEL       3
 807#define UART2_SEL       3
 808#define UART1_SEL       3
 809#define UART0_SEL       3
 810/* SRC_CLOCK = SCLK_RPLL */
 811#define CLK_SRC_PERIC0_VAL      ((SPDIF_SEL << 28)      \
 812                                | (PWM_SEL << 24)       \
 813                                | (UART4_SEL << 20)     \
 814                                | (UART3_SEL << 16)     \
 815                                | (UART2_SEL << 12)     \
 816                                | (UART1_SEL << 8)      \
 817                                | (UART0_SEL << 4))
 818
 819/* CLK_SRC_PERIC1 */
 820/* SRC_CLOCK = SCLK_EPLL */
 821#define SPI0_SEL                6
 822#define SPI1_SEL                6
 823#define SPI2_SEL                6
 824#define AUDIO0_SEL              6
 825#define AUDIO1_SEL              6
 826#define AUDIO2_SEL              6
 827#define CLK_SRC_PERIC1_VAL      ((SPI2_SEL << 28)       \
 828                                | (SPI1_SEL << 24)      \
 829                                | (SPI0_SEL << 20)      \
 830                                | (AUDIO2_SEL << 16)    \
 831                                | (AUDIO2_SEL << 12)    \
 832                                | (AUDIO2_SEL << 8))
 833
 834/* CLK_DIV_PERIC0 */
 835#define PWM_RATIO       8
 836#define UART4_RATIO     9
 837#define UART3_RATIO     9
 838#define UART2_RATIO     9
 839#define UART1_RATIO     9
 840#define UART0_RATIO     9
 841
 842#define CLK_DIV_PERIC0_VAL      ((PWM_RATIO << 28)      \
 843                                | (UART4_RATIO << 24)   \
 844                                | (UART3_RATIO << 20)    \
 845                                | (UART2_RATIO << 16)    \
 846                                | (UART1_RATIO << 12)    \
 847                                | (UART0_RATIO << 8))
 848/* CLK_DIV_PERIC1 */
 849#define SPI2_RATIO              0x1
 850#define SPI1_RATIO              0x1
 851#define SPI0_RATIO              0x1
 852#define CLK_DIV_PERIC1_VAL      ((SPI2_RATIO << 28)     \
 853                                | (SPI1_RATIO << 24)    \
 854                                | (SPI0_RATIO << 20))
 855
 856/* CLK_DIV_PERIC2 */
 857#define PCM2_RATIO              0x3
 858#define PCM1_RATIO              0x3
 859#define CLK_DIV_PERIC2_VAL      ((PCM2_RATIO << 24) \
 860                                | (PCM1_RATIO << 16))
 861
 862/* CLK_DIV_PERIC3 */
 863#define AUDIO2_RATIO            0x5
 864#define AUDIO1_RATIO            0x5
 865#define AUDIO0_RATIO            0x5
 866#define CLK_DIV_PERIC3_VAL      ((AUDIO2_RATIO << 28)   \
 867                                | (AUDIO1_RATIO << 24)  \
 868                                | (AUDIO0_RATIO << 20))
 869
 870/* CLK_DIV_PERIC4 */
 871#define SPI2_PRE_RATIO          0x2
 872#define SPI1_PRE_RATIO          0x2
 873#define SPI0_PRE_RATIO          0x2
 874#define CLK_DIV_PERIC4_VAL      ((SPI2_PRE_RATIO << 24) \
 875                                | (SPI1_PRE_RATIO << 16) \
 876                                | (SPI0_PRE_RATIO << 8))
 877
 878/* CLK_SRC_DISP1_0 */
 879#define CLK_SRC_DISP1_0_VAL     0x10666600
 880#define CLK_DIV_DISP1_0_VAL     0x01050211
 881
 882#define APLL_FOUT               (1 << 0)
 883#define KPLL_FOUT               (1 << 0)
 884
 885#define CLK_DIV_CPERI1_VAL      0x3f3f0000
 886#endif
 887
 888struct mem_timings;
 889
 890/* Errors that we can encourter in low-level setup */
 891enum {
 892        SETUP_ERR_OK,
 893        SETUP_ERR_RDLV_COMPLETE_TIMEOUT = -1,
 894        SETUP_ERR_ZQ_CALIBRATION_FAILURE = -2,
 895};
 896
 897/*
 898 * Memory variant specific initialization code for DDR3
 899 *
 900 * @param mem          Memory timings for this memory type.
 901 * @param reset         Reset DDR PHY during initialization.
 902 * @return 0 if ok, SETUP_ERR_... if there is a problem
 903 */
 904int ddr3_mem_ctrl_init(struct mem_timings *mem, int reset);
 905
 906/* Memory variant specific initialization code for LPDDR3 */
 907void lpddr3_mem_ctrl_init(void);
 908
 909/*
 910 * Configure ZQ I/O interface
 911 *
 912 * @param mem           Memory timings for this memory type.
 913 * @param phy0_con16    Register address for dmc_phy0->phy_con16
 914 * @param phy1_con16    Register address for dmc_phy1->phy_con16
 915 * @param phy0_con17    Register address for dmc_phy0->phy_con17
 916 * @param phy1_con17    Register address for dmc_phy1->phy_con17
 917 * @return 0 if ok, -1 on error
 918 */
 919int dmc_config_zq(struct mem_timings *mem, uint32_t *phy0_con16,
 920                        uint32_t *phy1_con16, uint32_t *phy0_con17,
 921                        uint32_t *phy1_con17);
 922/*
 923 * Send NOP and MRS/EMRS Direct commands
 924 *
 925 * @param mem           Memory timings for this memory type.
 926 * @param directcmd     Register address for dmc_phy->directcmd
 927 */
 928void dmc_config_mrs(struct mem_timings *mem, uint32_t *directcmd);
 929
 930/*
 931 * Send PALL Direct commands
 932 *
 933 * @param mem           Memory timings for this memory type.
 934 * @param directcmd     Register address for dmc_phy->directcmd
 935 */
 936void dmc_config_prech(struct mem_timings *mem, uint32_t *directcmd);
 937
 938/*
 939 * Reset the DLL. This function is common between DDR3 and LPDDR2.
 940 * However, the reset value is different. So we are passing a flag
 941 * ddr_mode to distinguish between LPDDR2 and DDR3.
 942 *
 943 * @param phycontrol0   Register address for dmc_phy->phycontrol0
 944 * @param ddr_mode      Type of DDR memory
 945 */
 946void update_reset_dll(uint32_t *phycontrol0, enum ddr_mode);
 947#endif
 948