169041723SEric Nelson /* 269041723SEric Nelson * Copyright (C) 2013 Boundary Devices Inc. 369041723SEric Nelson * 41a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 569041723SEric Nelson */ 669041723SEric Nelson #ifndef __ASM_ARCH_MX6_DDR_H__ 769041723SEric Nelson #define __ASM_ARCH_MX6_DDR_H__ 869041723SEric Nelson 98d05b161STim Harvey #ifndef CONFIG_SPL_BUILD 1069041723SEric Nelson #ifdef CONFIG_MX6Q 1169041723SEric Nelson #include "mx6q-ddr.h" 1269041723SEric Nelson #else 1369041723SEric Nelson #if defined(CONFIG_MX6DL) || defined(CONFIG_MX6S) 1469041723SEric Nelson #include "mx6dl-ddr.h" 1569041723SEric Nelson #else 1605d54b82SFabio Estevam #ifdef CONFIG_MX6SX 1705d54b82SFabio Estevam #include "mx6sx-ddr.h" 1805d54b82SFabio Estevam #else 19a462c346SPeng Fan #ifdef CONFIG_MX6UL 20a462c346SPeng Fan #include "mx6ul-ddr.h" 21a462c346SPeng Fan #else 221b811e28SPeng Fan #ifdef CONFIG_MX6SL 231b811e28SPeng Fan #include "mx6sl-ddr.h" 241b811e28SPeng Fan #else 2569041723SEric Nelson #error "Please select cpu" 261b811e28SPeng Fan #endif /* CONFIG_MX6SL */ 27a462c346SPeng Fan #endif /* CONFIG_MX6UL */ 2805d54b82SFabio Estevam #endif /* CONFIG_MX6SX */ 2969041723SEric Nelson #endif /* CONFIG_MX6DL or CONFIG_MX6S */ 3069041723SEric Nelson #endif /* CONFIG_MX6Q */ 318d05b161STim Harvey #else 328d05b161STim Harvey 33003fa83cSPeng Fan enum { 34003fa83cSPeng Fan DDR_TYPE_DDR3, 35003fa83cSPeng Fan DDR_TYPE_LPDDR2, 36003fa83cSPeng Fan }; 37003fa83cSPeng Fan 388d05b161STim Harvey /* MMDC P0/P1 Registers */ 398d05b161STim Harvey struct mmdc_p_regs { 408d05b161STim Harvey u32 mdctl; 418d05b161STim Harvey u32 mdpdc; 428d05b161STim Harvey u32 mdotc; 438d05b161STim Harvey u32 mdcfg0; 448d05b161STim Harvey u32 mdcfg1; 458d05b161STim Harvey u32 mdcfg2; 468d05b161STim Harvey u32 mdmisc; 478d05b161STim Harvey u32 mdscr; 488d05b161STim Harvey u32 mdref; 498d05b161STim Harvey u32 res1[2]; 508d05b161STim Harvey u32 mdrwd; 518d05b161STim Harvey u32 mdor; 5243d9dc41SPeng Fan u32 mdmrr; 5343d9dc41SPeng Fan u32 mdcfg3lp; 5443d9dc41SPeng Fan u32 mdmr4; 558d05b161STim Harvey u32 mdasp; 5643d9dc41SPeng Fan u32 res2[239]; 5743d9dc41SPeng Fan u32 maarcr; 588d05b161STim Harvey u32 mapsr; 5943d9dc41SPeng Fan u32 maexidr0; 6043d9dc41SPeng Fan u32 maexidr1; 6143d9dc41SPeng Fan u32 madpcr0; 6243d9dc41SPeng Fan u32 madpcr1; 6343d9dc41SPeng Fan u32 madpsr0; 6443d9dc41SPeng Fan u32 madpsr1; 6543d9dc41SPeng Fan u32 madpsr2; 6643d9dc41SPeng Fan u32 madpsr3; 6743d9dc41SPeng Fan u32 madpsr4; 6843d9dc41SPeng Fan u32 madpsr5; 6943d9dc41SPeng Fan u32 masbs0; 7043d9dc41SPeng Fan u32 masbs1; 7143d9dc41SPeng Fan u32 res3[2]; 7243d9dc41SPeng Fan u32 magenp; 7343d9dc41SPeng Fan u32 res4[239]; 748d05b161STim Harvey u32 mpzqhwctrl; 7543d9dc41SPeng Fan u32 mpzqswctrl; 7643d9dc41SPeng Fan u32 mpwlgcr; 778d05b161STim Harvey u32 mpwldectrl0; 788d05b161STim Harvey u32 mpwldectrl1; 7943d9dc41SPeng Fan u32 mpwldlst; 808d05b161STim Harvey u32 mpodtctrl; 818d05b161STim Harvey u32 mprddqby0dl; 828d05b161STim Harvey u32 mprddqby1dl; 838d05b161STim Harvey u32 mprddqby2dl; 848d05b161STim Harvey u32 mprddqby3dl; 8543d9dc41SPeng Fan u32 mpwrdqby0dl; 8643d9dc41SPeng Fan u32 mpwrdqby1dl; 8743d9dc41SPeng Fan u32 mpwrdqby2dl; 8843d9dc41SPeng Fan u32 mpwrdqby3dl; 898d05b161STim Harvey u32 mpdgctrl0; 908d05b161STim Harvey u32 mpdgctrl1; 9143d9dc41SPeng Fan u32 mpdgdlst0; 928d05b161STim Harvey u32 mprddlctl; 9343d9dc41SPeng Fan u32 mprddlst; 948d05b161STim Harvey u32 mpwrdlctl; 9543d9dc41SPeng Fan u32 mpwrdlst; 9643d9dc41SPeng Fan u32 mpsdctrl; 9743d9dc41SPeng Fan u32 mpzqlp2ctl; 9843d9dc41SPeng Fan u32 mprddlhwctl; 9943d9dc41SPeng Fan u32 mpwrdlhwctl; 10043d9dc41SPeng Fan u32 mprddlhwst0; 10143d9dc41SPeng Fan u32 mprddlhwst1; 10243d9dc41SPeng Fan u32 mpwrdlhwst0; 10343d9dc41SPeng Fan u32 mpwrdlhwst1; 10443d9dc41SPeng Fan u32 mpwlhwerr; 10543d9dc41SPeng Fan u32 mpdghwst0; 10643d9dc41SPeng Fan u32 mpdghwst1; 10743d9dc41SPeng Fan u32 mpdghwst2; 10843d9dc41SPeng Fan u32 mpdghwst3; 10943d9dc41SPeng Fan u32 mppdcmpr1; 11043d9dc41SPeng Fan u32 mppdcmpr2; 11143d9dc41SPeng Fan u32 mpswdar0; 11243d9dc41SPeng Fan u32 mpswdrdr0; 11343d9dc41SPeng Fan u32 mpswdrdr1; 11443d9dc41SPeng Fan u32 mpswdrdr2; 11543d9dc41SPeng Fan u32 mpswdrdr3; 11643d9dc41SPeng Fan u32 mpswdrdr4; 11743d9dc41SPeng Fan u32 mpswdrdr5; 11843d9dc41SPeng Fan u32 mpswdrdr6; 11943d9dc41SPeng Fan u32 mpswdrdr7; 1208d05b161STim Harvey u32 mpmur0; 12143d9dc41SPeng Fan u32 mpwrcadl; 12243d9dc41SPeng Fan u32 mpdccr; 1238d05b161STim Harvey }; 1248d05b161STim Harvey 1251b811e28SPeng Fan #define MX6SL_IOM_DDR_BASE 0x020e0300 1261b811e28SPeng Fan struct mx6sl_iomux_ddr_regs { 1271b811e28SPeng Fan u32 dram_cas; 1281b811e28SPeng Fan u32 dram_cs0_b; 1291b811e28SPeng Fan u32 dram_cs1_b; 1301b811e28SPeng Fan u32 dram_dqm0; 1311b811e28SPeng Fan u32 dram_dqm1; 1321b811e28SPeng Fan u32 dram_dqm2; 1331b811e28SPeng Fan u32 dram_dqm3; 1341b811e28SPeng Fan u32 dram_ras; 1351b811e28SPeng Fan u32 dram_reset; 1361b811e28SPeng Fan u32 dram_sdba0; 1371b811e28SPeng Fan u32 dram_sdba1; 1381b811e28SPeng Fan u32 dram_sdba2; 1391b811e28SPeng Fan u32 dram_sdcke0; 1401b811e28SPeng Fan u32 dram_sdcke1; 1411b811e28SPeng Fan u32 dram_sdclk_0; 1421b811e28SPeng Fan u32 dram_odt0; 1431b811e28SPeng Fan u32 dram_odt1; 1441b811e28SPeng Fan u32 dram_sdqs0; 1451b811e28SPeng Fan u32 dram_sdqs1; 1461b811e28SPeng Fan u32 dram_sdqs2; 1471b811e28SPeng Fan u32 dram_sdqs3; 1481b811e28SPeng Fan u32 dram_sdwe_b; 1491b811e28SPeng Fan }; 1501b811e28SPeng Fan 1511b811e28SPeng Fan #define MX6SL_IOM_GRP_BASE 0x020e0500 1521b811e28SPeng Fan struct mx6sl_iomux_grp_regs { 1531b811e28SPeng Fan u32 res1[43]; 1541b811e28SPeng Fan u32 grp_addds; 1551b811e28SPeng Fan u32 grp_ddrmode_ctl; 1561b811e28SPeng Fan u32 grp_ddrpke; 1571b811e28SPeng Fan u32 grp_ddrpk; 1581b811e28SPeng Fan u32 grp_ddrhys; 1591b811e28SPeng Fan u32 grp_ddrmode; 1601b811e28SPeng Fan u32 grp_b0ds; 1611b811e28SPeng Fan u32 grp_ctlds; 1621b811e28SPeng Fan u32 grp_b1ds; 1631b811e28SPeng Fan u32 grp_ddr_type; 1641b811e28SPeng Fan u32 grp_b2ds; 1651b811e28SPeng Fan u32 grp_b3ds; 1661b811e28SPeng Fan }; 1671b811e28SPeng Fan 168a462c346SPeng Fan #define MX6UL_IOM_DDR_BASE 0x020e0200 169a462c346SPeng Fan struct mx6ul_iomux_ddr_regs { 170a462c346SPeng Fan u32 res1[17]; 171a462c346SPeng Fan u32 dram_dqm0; 172a462c346SPeng Fan u32 dram_dqm1; 173a462c346SPeng Fan u32 dram_ras; 174a462c346SPeng Fan u32 dram_cas; 175a462c346SPeng Fan u32 dram_cs0; 176a462c346SPeng Fan u32 dram_cs1; 177a462c346SPeng Fan u32 dram_sdwe_b; 178a462c346SPeng Fan u32 dram_odt0; 179a462c346SPeng Fan u32 dram_odt1; 180a462c346SPeng Fan u32 dram_sdba0; 181a462c346SPeng Fan u32 dram_sdba1; 182a462c346SPeng Fan u32 dram_sdba2; 183a462c346SPeng Fan u32 dram_sdcke0; 184a462c346SPeng Fan u32 dram_sdcke1; 185a462c346SPeng Fan u32 dram_sdclk_0; 186a462c346SPeng Fan u32 dram_sdqs0; 187a462c346SPeng Fan u32 dram_sdqs1; 188a462c346SPeng Fan u32 dram_reset; 189a462c346SPeng Fan }; 190a462c346SPeng Fan 191a462c346SPeng Fan #define MX6UL_IOM_GRP_BASE 0x020e0400 192a462c346SPeng Fan struct mx6ul_iomux_grp_regs { 193a462c346SPeng Fan u32 res1[36]; 194a462c346SPeng Fan u32 grp_addds; 195a462c346SPeng Fan u32 grp_ddrmode_ctl; 196a462c346SPeng Fan u32 grp_b0ds; 197a462c346SPeng Fan u32 grp_ddrpk; 198a462c346SPeng Fan u32 grp_ctlds; 199a462c346SPeng Fan u32 grp_b1ds; 200a462c346SPeng Fan u32 grp_ddrhys; 201a462c346SPeng Fan u32 grp_ddrpke; 202a462c346SPeng Fan u32 grp_ddrmode; 203a462c346SPeng Fan u32 grp_ddr_type; 204a462c346SPeng Fan }; 205a462c346SPeng Fan 206d9efd47cSPeng Fan #define MX6SX_IOM_DDR_BASE 0x020e0200 207d9efd47cSPeng Fan struct mx6sx_iomux_ddr_regs { 208d9efd47cSPeng Fan u32 res1[59]; 209d9efd47cSPeng Fan u32 dram_dqm0; 210d9efd47cSPeng Fan u32 dram_dqm1; 211d9efd47cSPeng Fan u32 dram_dqm2; 212d9efd47cSPeng Fan u32 dram_dqm3; 213d9efd47cSPeng Fan u32 dram_ras; 214d9efd47cSPeng Fan u32 dram_cas; 215d9efd47cSPeng Fan u32 res2[2]; 216d9efd47cSPeng Fan u32 dram_sdwe_b; 217d9efd47cSPeng Fan u32 dram_odt0; 218d9efd47cSPeng Fan u32 dram_odt1; 219d9efd47cSPeng Fan u32 dram_sdba0; 220d9efd47cSPeng Fan u32 dram_sdba1; 221d9efd47cSPeng Fan u32 dram_sdba2; 222d9efd47cSPeng Fan u32 dram_sdcke0; 223d9efd47cSPeng Fan u32 dram_sdcke1; 224d9efd47cSPeng Fan u32 dram_sdclk_0; 225d9efd47cSPeng Fan u32 dram_sdqs0; 226d9efd47cSPeng Fan u32 dram_sdqs1; 227d9efd47cSPeng Fan u32 dram_sdqs2; 228d9efd47cSPeng Fan u32 dram_sdqs3; 229d9efd47cSPeng Fan u32 dram_reset; 230d9efd47cSPeng Fan }; 231d9efd47cSPeng Fan 232d9efd47cSPeng Fan #define MX6SX_IOM_GRP_BASE 0x020e0500 233d9efd47cSPeng Fan struct mx6sx_iomux_grp_regs { 234d9efd47cSPeng Fan u32 res1[61]; 235d9efd47cSPeng Fan u32 grp_addds; 236d9efd47cSPeng Fan u32 grp_ddrmode_ctl; 237d9efd47cSPeng Fan u32 grp_ddrpke; 238d9efd47cSPeng Fan u32 grp_ddrpk; 239d9efd47cSPeng Fan u32 grp_ddrhys; 240d9efd47cSPeng Fan u32 grp_ddrmode; 241d9efd47cSPeng Fan u32 grp_b0ds; 242d9efd47cSPeng Fan u32 grp_b1ds; 243d9efd47cSPeng Fan u32 grp_ctlds; 244d9efd47cSPeng Fan u32 grp_ddr_type; 245d9efd47cSPeng Fan u32 grp_b2ds; 246d9efd47cSPeng Fan u32 grp_b3ds; 247d9efd47cSPeng Fan }; 248d9efd47cSPeng Fan 2498d05b161STim Harvey /* 2508d05b161STim Harvey * MMDC iomux registers (pinctl/padctl) - (different for IMX6DQ vs IMX6SDL) 2518d05b161STim Harvey */ 2528d05b161STim Harvey #define MX6DQ_IOM_DDR_BASE 0x020e0500 2538d05b161STim Harvey struct mx6dq_iomux_ddr_regs { 2548d05b161STim Harvey u32 res1[3]; 2558d05b161STim Harvey u32 dram_sdqs5; 2568d05b161STim Harvey u32 dram_dqm5; 2578d05b161STim Harvey u32 dram_dqm4; 2588d05b161STim Harvey u32 dram_sdqs4; 2598d05b161STim Harvey u32 dram_sdqs3; 2608d05b161STim Harvey u32 dram_dqm3; 2618d05b161STim Harvey u32 dram_sdqs2; 2628d05b161STim Harvey u32 dram_dqm2; 2638d05b161STim Harvey u32 res2[16]; 2648d05b161STim Harvey u32 dram_cas; 2658d05b161STim Harvey u32 res3[2]; 2668d05b161STim Harvey u32 dram_ras; 2678d05b161STim Harvey u32 dram_reset; 2688d05b161STim Harvey u32 res4[2]; 2698d05b161STim Harvey u32 dram_sdclk_0; 2708d05b161STim Harvey u32 dram_sdba2; 2718d05b161STim Harvey u32 dram_sdcke0; 2728d05b161STim Harvey u32 dram_sdclk_1; 2738d05b161STim Harvey u32 dram_sdcke1; 2748d05b161STim Harvey u32 dram_sdodt0; 2758d05b161STim Harvey u32 dram_sdodt1; 2768d05b161STim Harvey u32 res5; 2778d05b161STim Harvey u32 dram_sdqs0; 2788d05b161STim Harvey u32 dram_dqm0; 2798d05b161STim Harvey u32 dram_sdqs1; 2808d05b161STim Harvey u32 dram_dqm1; 2818d05b161STim Harvey u32 dram_sdqs6; 2828d05b161STim Harvey u32 dram_dqm6; 2838d05b161STim Harvey u32 dram_sdqs7; 2848d05b161STim Harvey u32 dram_dqm7; 2858d05b161STim Harvey }; 2868d05b161STim Harvey 2878d05b161STim Harvey #define MX6DQ_IOM_GRP_BASE 0x020e0700 2888d05b161STim Harvey struct mx6dq_iomux_grp_regs { 2898d05b161STim Harvey u32 res1[18]; 2908d05b161STim Harvey u32 grp_b7ds; 2918d05b161STim Harvey u32 grp_addds; 2928d05b161STim Harvey u32 grp_ddrmode_ctl; 2938d05b161STim Harvey u32 res2; 2948d05b161STim Harvey u32 grp_ddrpke; 2958d05b161STim Harvey u32 res3[6]; 2968d05b161STim Harvey u32 grp_ddrmode; 2978d05b161STim Harvey u32 res4[3]; 2988d05b161STim Harvey u32 grp_b0ds; 2998d05b161STim Harvey u32 grp_b1ds; 3008d05b161STim Harvey u32 grp_ctlds; 3018d05b161STim Harvey u32 res5; 3028d05b161STim Harvey u32 grp_b2ds; 3038d05b161STim Harvey u32 grp_ddr_type; 3048d05b161STim Harvey u32 grp_b3ds; 3058d05b161STim Harvey u32 grp_b4ds; 3068d05b161STim Harvey u32 grp_b5ds; 3078d05b161STim Harvey u32 grp_b6ds; 3088d05b161STim Harvey }; 3098d05b161STim Harvey 3108d05b161STim Harvey #define MX6SDL_IOM_DDR_BASE 0x020e0400 3118d05b161STim Harvey struct mx6sdl_iomux_ddr_regs { 3128d05b161STim Harvey u32 res1[25]; 3138d05b161STim Harvey u32 dram_cas; 3148d05b161STim Harvey u32 res2[2]; 3158d05b161STim Harvey u32 dram_dqm0; 3168d05b161STim Harvey u32 dram_dqm1; 3178d05b161STim Harvey u32 dram_dqm2; 3188d05b161STim Harvey u32 dram_dqm3; 3198d05b161STim Harvey u32 dram_dqm4; 3208d05b161STim Harvey u32 dram_dqm5; 3218d05b161STim Harvey u32 dram_dqm6; 3228d05b161STim Harvey u32 dram_dqm7; 3238d05b161STim Harvey u32 dram_ras; 3248d05b161STim Harvey u32 dram_reset; 3258d05b161STim Harvey u32 res3[2]; 3268d05b161STim Harvey u32 dram_sdba2; 3278d05b161STim Harvey u32 dram_sdcke0; 3288d05b161STim Harvey u32 dram_sdcke1; 3298d05b161STim Harvey u32 dram_sdclk_0; 3308d05b161STim Harvey u32 dram_sdclk_1; 3318d05b161STim Harvey u32 dram_sdodt0; 3328d05b161STim Harvey u32 dram_sdodt1; 3338d05b161STim Harvey u32 dram_sdqs0; 3348d05b161STim Harvey u32 dram_sdqs1; 3358d05b161STim Harvey u32 dram_sdqs2; 3368d05b161STim Harvey u32 dram_sdqs3; 3378d05b161STim Harvey u32 dram_sdqs4; 3388d05b161STim Harvey u32 dram_sdqs5; 3398d05b161STim Harvey u32 dram_sdqs6; 3408d05b161STim Harvey u32 dram_sdqs7; 3418d05b161STim Harvey }; 3428d05b161STim Harvey 3438d05b161STim Harvey #define MX6SDL_IOM_GRP_BASE 0x020e0700 3448d05b161STim Harvey struct mx6sdl_iomux_grp_regs { 3458d05b161STim Harvey u32 res1[18]; 3468d05b161STim Harvey u32 grp_b7ds; 3478d05b161STim Harvey u32 grp_addds; 3488d05b161STim Harvey u32 grp_ddrmode_ctl; 3498d05b161STim Harvey u32 grp_ddrpke; 3508d05b161STim Harvey u32 res2[2]; 3518d05b161STim Harvey u32 grp_ddrmode; 3528d05b161STim Harvey u32 grp_b0ds; 3538d05b161STim Harvey u32 res3; 3548d05b161STim Harvey u32 grp_ctlds; 3558d05b161STim Harvey u32 grp_b1ds; 3568d05b161STim Harvey u32 grp_ddr_type; 3578d05b161STim Harvey u32 grp_b2ds; 3588d05b161STim Harvey u32 grp_b3ds; 3598d05b161STim Harvey u32 grp_b4ds; 3608d05b161STim Harvey u32 grp_b5ds; 3618d05b161STim Harvey u32 res4; 3628d05b161STim Harvey u32 grp_b6ds; 3638d05b161STim Harvey }; 364fe0f7f78STim Harvey 365fe0f7f78STim Harvey /* Device Information: Varies per DDR3 part number and speed grade */ 366fe0f7f78STim Harvey struct mx6_ddr3_cfg { 367fe0f7f78STim Harvey u16 mem_speed; /* ie 1600 for DDR3-1600 (800,1066,1333,1600) */ 368fe0f7f78STim Harvey u8 density; /* chip density (Gb) (1,2,4,8) */ 369fe0f7f78STim Harvey u8 width; /* bus width (bits) (4,8,16) */ 370fe0f7f78STim Harvey u8 banks; /* number of banks */ 371fe0f7f78STim Harvey u8 rowaddr; /* row address bits (11-16)*/ 372fe0f7f78STim Harvey u8 coladdr; /* col address bits (9-12) */ 373fe0f7f78STim Harvey u8 pagesz; /* page size (K) (1-2) */ 374fe0f7f78STim Harvey u16 trcd; /* tRCD=tRP=CL (ns*100) */ 375fe0f7f78STim Harvey u16 trcmin; /* tRC min (ns*100) */ 376fe0f7f78STim Harvey u16 trasmin; /* tRAS min (ns*100) */ 377fe0f7f78STim Harvey u8 SRT; /* self-refresh temperature: 0=normal, 1=extended */ 378fe0f7f78STim Harvey }; 379fe0f7f78STim Harvey 380eb796cbbSPeng Fan /* Device Information: Varies per LPDDR2 part number and speed grade */ 381eb796cbbSPeng Fan struct mx6_lpddr2_cfg { 382eb796cbbSPeng Fan u16 mem_speed; /* ie 800 for LPDDR2-800 */ 383eb796cbbSPeng Fan u8 density; /* chip density (Gb) (1,2,4,8) */ 384eb796cbbSPeng Fan u8 width; /* bus width (bits) (4,8,16) */ 385eb796cbbSPeng Fan u8 banks; /* number of banks */ 386eb796cbbSPeng Fan u8 rowaddr; /* row address bits (11-16)*/ 387eb796cbbSPeng Fan u8 coladdr; /* col address bits (9-12) */ 388eb796cbbSPeng Fan u16 trcd_lp; 389eb796cbbSPeng Fan u16 trppb_lp; 390eb796cbbSPeng Fan u16 trpab_lp; 391eb796cbbSPeng Fan u16 trcmin; /* tRC min (ns*100) */ 392eb796cbbSPeng Fan u16 trasmin; /* tRAS min (ns*100) */ 393eb796cbbSPeng Fan }; 394eb796cbbSPeng Fan 395fe0f7f78STim Harvey /* System Information: Varies per board design, layout, and term choices */ 396fe0f7f78STim Harvey struct mx6_ddr_sysinfo { 397fe0f7f78STim Harvey u8 dsize; /* size of bus (in dwords: 0=16bit,1=32bit,2=64bit) */ 398fe0f7f78STim Harvey u8 cs_density; /* density per chip select (Gb) */ 399fe0f7f78STim Harvey u8 ncs; /* number chip selects used (1|2) */ 400fe0f7f78STim Harvey char cs1_mirror;/* enable address mirror (0|1) */ 401fe0f7f78STim Harvey char bi_on; /* Bank interleaving enable */ 402fe0f7f78STim Harvey u8 rtt_nom; /* Rtt_Nom (DDR3_RTT_*) */ 403fe0f7f78STim Harvey u8 rtt_wr; /* Rtt_Wr (DDR3_RTT_*) */ 404fe0f7f78STim Harvey u8 ralat; /* Read Additional Latency (0-7) */ 405fe0f7f78STim Harvey u8 walat; /* Write Additional Latency (0-3) */ 406fe0f7f78STim Harvey u8 mif3_mode; /* Command prediction working mode */ 407fe0f7f78STim Harvey u8 rst_to_cke; /* Time from SDE enable to CKE rise */ 408fe0f7f78STim Harvey u8 sde_to_rst; /* Time from SDE enable until DDR reset# is high */ 40978c5a180STim Harvey u8 pd_fast_exit;/* enable precharge powerdown fast-exit */ 410003fa83cSPeng Fan u8 ddr_type; /* DDR type: DDR3(0) or LPDDR2(1) */ 411edf00937SFabio Estevam u8 refsel; /* REF_SEL field of register MDREF */ 412edf00937SFabio Estevam u8 refr; /* REFR field of register MDREF */ 413fe0f7f78STim Harvey }; 414fe0f7f78STim Harvey 415fe0f7f78STim Harvey /* 416fe0f7f78STim Harvey * Board specific calibration: 417fe0f7f78STim Harvey * This includes write leveling calibration values as well as DQS gating 418fe0f7f78STim Harvey * and read/write delays. These values are board/layout/device specific. 419fe0f7f78STim Harvey * Freescale recommends using the i.MX6 DDR Stress Test Tool V1.0.2 420fe0f7f78STim Harvey * (DOC-96412) to determine these values over a range of boards and 421fe0f7f78STim Harvey * temperatures. 422fe0f7f78STim Harvey */ 423fe0f7f78STim Harvey struct mx6_mmdc_calibration { 424fe0f7f78STim Harvey /* write leveling calibration */ 425fe0f7f78STim Harvey u32 p0_mpwldectrl0; 426fe0f7f78STim Harvey u32 p0_mpwldectrl1; 427fe0f7f78STim Harvey u32 p1_mpwldectrl0; 428fe0f7f78STim Harvey u32 p1_mpwldectrl1; 429fe0f7f78STim Harvey /* read DQS gating */ 430fe0f7f78STim Harvey u32 p0_mpdgctrl0; 431fe0f7f78STim Harvey u32 p0_mpdgctrl1; 432fe0f7f78STim Harvey u32 p1_mpdgctrl0; 433fe0f7f78STim Harvey u32 p1_mpdgctrl1; 434fe0f7f78STim Harvey /* read delay */ 435fe0f7f78STim Harvey u32 p0_mprddlctl; 436fe0f7f78STim Harvey u32 p1_mprddlctl; 437fe0f7f78STim Harvey /* write delay */ 438fe0f7f78STim Harvey u32 p0_mpwrdlctl; 439fe0f7f78STim Harvey u32 p1_mpwrdlctl; 440775d591fSPeng Fan /* lpddr2 zq hw calibration */ 441775d591fSPeng Fan u32 mpzqlp2ctl; 442fe0f7f78STim Harvey }; 443fe0f7f78STim Harvey 444fe0f7f78STim Harvey /* configure iomux (pinctl/padctl) */ 445fe0f7f78STim Harvey void mx6dq_dram_iocfg(unsigned width, 446fe0f7f78STim Harvey const struct mx6dq_iomux_ddr_regs *, 447fe0f7f78STim Harvey const struct mx6dq_iomux_grp_regs *); 448fe0f7f78STim Harvey void mx6sdl_dram_iocfg(unsigned width, 449fe0f7f78STim Harvey const struct mx6sdl_iomux_ddr_regs *, 450fe0f7f78STim Harvey const struct mx6sdl_iomux_grp_regs *); 451d9efd47cSPeng Fan void mx6sx_dram_iocfg(unsigned width, 452d9efd47cSPeng Fan const struct mx6sx_iomux_ddr_regs *, 453d9efd47cSPeng Fan const struct mx6sx_iomux_grp_regs *); 454a462c346SPeng Fan void mx6ul_dram_iocfg(unsigned width, 455a462c346SPeng Fan const struct mx6ul_iomux_ddr_regs *, 456a462c346SPeng Fan const struct mx6ul_iomux_grp_regs *); 4571b811e28SPeng Fan void mx6sl_dram_iocfg(unsigned width, 4581b811e28SPeng Fan const struct mx6sl_iomux_ddr_regs *, 4591b811e28SPeng Fan const struct mx6sl_iomux_grp_regs *); 460fe0f7f78STim Harvey 461*a425bf72SEric Nelson #if defined(CONFIG_MX6_DDRCAL) 4627f17fb74SEric Nelson int mmdc_do_write_level_calibration(struct mx6_ddr_sysinfo const *sysinfo); 4637f17fb74SEric Nelson int mmdc_do_dqs_calibration(struct mx6_ddr_sysinfo const *sysinfo); 46448c7d437SEric Nelson void mmdc_read_calibration(struct mx6_ddr_sysinfo const *sysinfo, 46548c7d437SEric Nelson struct mx6_mmdc_calibration *calib); 466d339f169SMarek Vasut #endif 467d339f169SMarek Vasut 468fe0f7f78STim Harvey /* configure mx6 mmdc registers */ 469fe0f7f78STim Harvey void mx6_dram_cfg(const struct mx6_ddr_sysinfo *, 470fe0f7f78STim Harvey const struct mx6_mmdc_calibration *, 471f2ff8343SPeng Fan const void *); 472fe0f7f78STim Harvey 4738d05b161STim Harvey #endif /* CONFIG_SPL_BUILD */ 47469041723SEric Nelson 47569041723SEric Nelson #define MX6_MMDC_P0_MDCTL 0x021b0000 47669041723SEric Nelson #define MX6_MMDC_P0_MDPDC 0x021b0004 47769041723SEric Nelson #define MX6_MMDC_P0_MDOTC 0x021b0008 47869041723SEric Nelson #define MX6_MMDC_P0_MDCFG0 0x021b000c 47969041723SEric Nelson #define MX6_MMDC_P0_MDCFG1 0x021b0010 48069041723SEric Nelson #define MX6_MMDC_P0_MDCFG2 0x021b0014 48169041723SEric Nelson #define MX6_MMDC_P0_MDMISC 0x021b0018 48269041723SEric Nelson #define MX6_MMDC_P0_MDSCR 0x021b001c 48369041723SEric Nelson #define MX6_MMDC_P0_MDREF 0x021b0020 48469041723SEric Nelson #define MX6_MMDC_P0_MDRWD 0x021b002c 48569041723SEric Nelson #define MX6_MMDC_P0_MDOR 0x021b0030 48669041723SEric Nelson #define MX6_MMDC_P0_MDASP 0x021b0040 48769041723SEric Nelson #define MX6_MMDC_P0_MAPSR 0x021b0404 48869041723SEric Nelson #define MX6_MMDC_P0_MPZQHWCTRL 0x021b0800 48969041723SEric Nelson #define MX6_MMDC_P0_MPWLDECTRL0 0x021b080c 49069041723SEric Nelson #define MX6_MMDC_P0_MPWLDECTRL1 0x021b0810 49169041723SEric Nelson #define MX6_MMDC_P0_MPODTCTRL 0x021b0818 49269041723SEric Nelson #define MX6_MMDC_P0_MPRDDQBY0DL 0x021b081c 49369041723SEric Nelson #define MX6_MMDC_P0_MPRDDQBY1DL 0x021b0820 49469041723SEric Nelson #define MX6_MMDC_P0_MPRDDQBY2DL 0x021b0824 49569041723SEric Nelson #define MX6_MMDC_P0_MPRDDQBY3DL 0x021b0828 49669041723SEric Nelson #define MX6_MMDC_P0_MPDGCTRL0 0x021b083c 49769041723SEric Nelson #define MX6_MMDC_P0_MPDGCTRL1 0x021b0840 49869041723SEric Nelson #define MX6_MMDC_P0_MPRDDLCTL 0x021b0848 49969041723SEric Nelson #define MX6_MMDC_P0_MPWRDLCTL 0x021b0850 500c8c35155SEric Nelson #define MX6_MMDC_P0_MPZQLP2CTL 0x021b085C 50169041723SEric Nelson #define MX6_MMDC_P0_MPMUR0 0x021b08b8 50269041723SEric Nelson 50369041723SEric Nelson #define MX6_MMDC_P1_MDCTL 0x021b4000 50469041723SEric Nelson #define MX6_MMDC_P1_MDPDC 0x021b4004 50569041723SEric Nelson #define MX6_MMDC_P1_MDOTC 0x021b4008 50669041723SEric Nelson #define MX6_MMDC_P1_MDCFG0 0x021b400c 50769041723SEric Nelson #define MX6_MMDC_P1_MDCFG1 0x021b4010 50869041723SEric Nelson #define MX6_MMDC_P1_MDCFG2 0x021b4014 50969041723SEric Nelson #define MX6_MMDC_P1_MDMISC 0x021b4018 51069041723SEric Nelson #define MX6_MMDC_P1_MDSCR 0x021b401c 51169041723SEric Nelson #define MX6_MMDC_P1_MDREF 0x021b4020 51269041723SEric Nelson #define MX6_MMDC_P1_MDRWD 0x021b402c 51369041723SEric Nelson #define MX6_MMDC_P1_MDOR 0x021b4030 51469041723SEric Nelson #define MX6_MMDC_P1_MDASP 0x021b4040 51569041723SEric Nelson #define MX6_MMDC_P1_MAPSR 0x021b4404 51669041723SEric Nelson #define MX6_MMDC_P1_MPZQHWCTRL 0x021b4800 51769041723SEric Nelson #define MX6_MMDC_P1_MPWLDECTRL0 0x021b480c 51869041723SEric Nelson #define MX6_MMDC_P1_MPWLDECTRL1 0x021b4810 51969041723SEric Nelson #define MX6_MMDC_P1_MPODTCTRL 0x021b4818 52069041723SEric Nelson #define MX6_MMDC_P1_MPRDDQBY0DL 0x021b481c 52169041723SEric Nelson #define MX6_MMDC_P1_MPRDDQBY1DL 0x021b4820 52269041723SEric Nelson #define MX6_MMDC_P1_MPRDDQBY2DL 0x021b4824 52369041723SEric Nelson #define MX6_MMDC_P1_MPRDDQBY3DL 0x021b4828 52469041723SEric Nelson #define MX6_MMDC_P1_MPDGCTRL0 0x021b483c 52569041723SEric Nelson #define MX6_MMDC_P1_MPDGCTRL1 0x021b4840 52669041723SEric Nelson #define MX6_MMDC_P1_MPRDDLCTL 0x021b4848 52769041723SEric Nelson #define MX6_MMDC_P1_MPWRDLCTL 0x021b4850 528c8c35155SEric Nelson #define MX6_MMDC_P1_MPZQLP2CTL 0x021b485C 52969041723SEric Nelson #define MX6_MMDC_P1_MPMUR0 0x021b48b8 53069041723SEric Nelson 53169041723SEric Nelson #endif /*__ASM_ARCH_MX6_DDR_H__ */ 532