1*cd71b1d5SPaul Burton /* SPDX-License-Identifier: GPL-2.0+ */ 2*cd71b1d5SPaul Burton /* 3*cd71b1d5SPaul Burton * JZ4780 DDR initialization - parameters definitions 4*cd71b1d5SPaul Burton * 5*cd71b1d5SPaul Burton * Copyright (c) 2015 Imagination Technologies 6*cd71b1d5SPaul Burton * Author: Matt Redfearn <matt.redfearn.com> 7*cd71b1d5SPaul Burton */ 8*cd71b1d5SPaul Burton 9*cd71b1d5SPaul Burton #ifndef __JZ4780_DRAM_H__ 10*cd71b1d5SPaul Burton #define __JZ4780_DRAM_H__ 11*cd71b1d5SPaul Burton 12*cd71b1d5SPaul Burton /* 13*cd71b1d5SPaul Burton * DDR 14*cd71b1d5SPaul Burton */ 15*cd71b1d5SPaul Burton #define DDRC_ST 0x0 16*cd71b1d5SPaul Burton #define DDRC_CFG 0x4 17*cd71b1d5SPaul Burton #define DDRC_CTRL 0x8 18*cd71b1d5SPaul Burton #define DDRC_LMR 0xc 19*cd71b1d5SPaul Burton #define DDRC_REFCNT 0x18 20*cd71b1d5SPaul Burton #define DDRC_DQS 0x1c 21*cd71b1d5SPaul Burton #define DDRC_DQS_ADJ 0x20 22*cd71b1d5SPaul Burton #define DDRC_MMAP0 0x24 23*cd71b1d5SPaul Burton #define DDRC_MMAP1 0x28 24*cd71b1d5SPaul Burton #define DDRC_MDELAY 0x2c 25*cd71b1d5SPaul Burton #define DDRC_CKEL 0x30 26*cd71b1d5SPaul Burton #define DDRC_PMEMCTRL0 0x54 27*cd71b1d5SPaul Burton #define DDRC_PMEMCTRL1 0x50 28*cd71b1d5SPaul Burton #define DDRC_PMEMCTRL2 0x58 29*cd71b1d5SPaul Burton #define DDRC_PMEMCTRL3 0x5c 30*cd71b1d5SPaul Burton 31*cd71b1d5SPaul Burton #define DDRC_TIMING(n) (0x60 + 4 * (n)) 32*cd71b1d5SPaul Burton #define DDRC_REMMAP(n) (0x9c + 4 * (n)) 33*cd71b1d5SPaul Burton 34*cd71b1d5SPaul Burton /* 35*cd71b1d5SPaul Burton * DDR PHY 36*cd71b1d5SPaul Burton */ 37*cd71b1d5SPaul Burton #define DDR_MEM_PHY_BASE 0x20000000 38*cd71b1d5SPaul Burton #define DDR_PHY_OFFSET 0x1000 39*cd71b1d5SPaul Burton 40*cd71b1d5SPaul Burton #define DDRP_PIR 0x4 41*cd71b1d5SPaul Burton #define DDRP_PGCR 0x8 42*cd71b1d5SPaul Burton #define DDRP_PGSR 0xc 43*cd71b1d5SPaul Burton 44*cd71b1d5SPaul Burton #define DDRP_PTR0 0x18 45*cd71b1d5SPaul Burton #define DDRP_PTR1 0x1c 46*cd71b1d5SPaul Burton #define DDRP_PTR2 0x20 47*cd71b1d5SPaul Burton 48*cd71b1d5SPaul Burton #define DDRP_ACIOCR 0x24 49*cd71b1d5SPaul Burton #define DDRP_DXCCR 0x28 50*cd71b1d5SPaul Burton #define DDRP_DSGCR 0x2c 51*cd71b1d5SPaul Burton #define DDRP_DCR 0x30 52*cd71b1d5SPaul Burton 53*cd71b1d5SPaul Burton #define DDRP_DTPR0 0x34 54*cd71b1d5SPaul Burton #define DDRP_DTPR1 0x38 55*cd71b1d5SPaul Burton #define DDRP_DTPR2 0x3c 56*cd71b1d5SPaul Burton #define DDRP_MR0 0x40 57*cd71b1d5SPaul Burton #define DDRP_MR1 0x44 58*cd71b1d5SPaul Burton #define DDRP_MR2 0x48 59*cd71b1d5SPaul Burton #define DDRP_MR3 0x4c 60*cd71b1d5SPaul Burton 61*cd71b1d5SPaul Burton #define DDRP_ODTCR 0x50 62*cd71b1d5SPaul Burton #define DDRP_DTAR 0x54 63*cd71b1d5SPaul Burton #define DDRP_DTDR0 0x58 64*cd71b1d5SPaul Burton #define DDRP_DTDR1 0x5c 65*cd71b1d5SPaul Burton 66*cd71b1d5SPaul Burton #define DDRP_DCUAR 0xc0 67*cd71b1d5SPaul Burton #define DDRP_DCUDR 0xc4 68*cd71b1d5SPaul Burton #define DDRP_DCURR 0xc8 69*cd71b1d5SPaul Burton #define DDRP_DCULR 0xcc 70*cd71b1d5SPaul Burton #define DDRP_DCUGCR 0xd0 71*cd71b1d5SPaul Burton #define DDRP_DCUTPR 0xd4 72*cd71b1d5SPaul Burton #define DDRP_DCUSR0 0xd8 73*cd71b1d5SPaul Burton #define DDRP_DCUSR1 0xdc 74*cd71b1d5SPaul Burton 75*cd71b1d5SPaul Burton #define DDRP_ZQXCR0(n) (0x180 + ((n) * 0x10)) 76*cd71b1d5SPaul Burton #define DDRP_ZQXCR1(n) (0x184 + ((n) * 0x10)) 77*cd71b1d5SPaul Burton #define DDRP_ZQXSR0(n) (0x188 + ((n) * 0x10)) 78*cd71b1d5SPaul Burton #define DDRP_ZQXSR1(n) (0x18c + ((n) * 0x10)) 79*cd71b1d5SPaul Burton 80*cd71b1d5SPaul Burton #define DDRP_DXGCR(n) (0x1c0 + ((n) * 0x40)) 81*cd71b1d5SPaul Burton #define DDRP_DXGSR0(n) (0x1c4 + ((n) * 0x40)) 82*cd71b1d5SPaul Burton #define DDRP_DXGSR1(n) (0x1c8 + ((n) * 0x40)) 83*cd71b1d5SPaul Burton #define DDRP_DXDQSTR(n) (0x1d4 + ((n) * 0x40)) 84*cd71b1d5SPaul Burton 85*cd71b1d5SPaul Burton /* DDRC Status Register */ 86*cd71b1d5SPaul Burton #define DDRC_ST_ENDIAN BIT(7) 87*cd71b1d5SPaul Burton #define DDRC_ST_DPDN BIT(5) 88*cd71b1d5SPaul Burton #define DDRC_ST_PDN BIT(4) 89*cd71b1d5SPaul Burton #define DDRC_ST_AREF BIT(3) 90*cd71b1d5SPaul Burton #define DDRC_ST_SREF BIT(2) 91*cd71b1d5SPaul Burton #define DDRC_ST_CKE1 BIT(1) 92*cd71b1d5SPaul Burton #define DDRC_ST_CKE0 BIT(0) 93*cd71b1d5SPaul Burton 94*cd71b1d5SPaul Burton /* DDRC Configure Register */ 95*cd71b1d5SPaul Burton #define DDRC_CFG_ROW1_BIT 27 96*cd71b1d5SPaul Burton #define DDRC_CFG_ROW1_MASK (0x7 << DDRC_CFG_ROW1_BIT) 97*cd71b1d5SPaul Burton #define DDRC_CFG_COL1_BIT 24 98*cd71b1d5SPaul Burton #define DDRC_CFG_COL1_MASK (0x7 << DDRC_CFG_COL1_BIT) 99*cd71b1d5SPaul Burton #define DDRC_CFG_BA1 BIT(23) 100*cd71b1d5SPaul Burton #define DDRC_CFG_IMBA BIT(22) 101*cd71b1d5SPaul Burton #define DDRC_CFG_BL_8 BIT(21) 102*cd71b1d5SPaul Burton 103*cd71b1d5SPaul Burton #define DDRC_CFG_TYPE_BIT 17 104*cd71b1d5SPaul Burton #define DDRC_CFG_TYPE_MASK (0x7 << DDRC_CFG_TYPE_BIT) 105*cd71b1d5SPaul Burton #define DDRC_CFG_TYPE_DDR1 (2 << DDRC_CFG_TYPE_BIT) 106*cd71b1d5SPaul Burton #define DDRC_CFG_TYPE_MDDR (3 << DDRC_CFG_TYPE_BIT) 107*cd71b1d5SPaul Burton #define DDRC_CFG_TYPE_DDR2 (4 << DDRC_CFG_TYPE_BIT) 108*cd71b1d5SPaul Burton #define DDRC_CFG_TYPE_LPDDR2 (5 << DDRC_CFG_TYPE_BIT) 109*cd71b1d5SPaul Burton #define DDRC_CFG_TYPE_DDR3 (6 << DDRC_CFG_TYPE_BIT) 110*cd71b1d5SPaul Burton 111*cd71b1d5SPaul Burton #define DDRC_CFG_ODT_EN BIT(16) 112*cd71b1d5SPaul Burton 113*cd71b1d5SPaul Burton #define DDRC_CFG_MPRT BIT(15) 114*cd71b1d5SPaul Burton 115*cd71b1d5SPaul Burton #define DDRC_CFG_ROW_BIT 11 116*cd71b1d5SPaul Burton #define DDRC_CFG_ROW_MASK (0x7 << DDRC_CFG_ROW_BIT) 117*cd71b1d5SPaul Burton #define DDRC_CFG_ROW_12 (0 << DDRC_CFG_ROW_BIT) 118*cd71b1d5SPaul Burton #define DDRC_CFG_ROW_13 (1 << DDRC_CFG_ROW_BIT) 119*cd71b1d5SPaul Burton #define DDRC_CFG_ROW_14 (2 << DDRC_CFG_ROW_BIT) 120*cd71b1d5SPaul Burton 121*cd71b1d5SPaul Burton #define DDRC_CFG_COL_BIT 8 122*cd71b1d5SPaul Burton #define DDRC_CFG_COL_MASK (0x7 << DDRC_CFG_COL_BIT) 123*cd71b1d5SPaul Burton #define DDRC_CFG_COL_8 (0 << DDRC_CFG_COL_BIT) 124*cd71b1d5SPaul Burton #define DDRC_CFG_COL_9 (1 << DDRC_CFG_COL_BIT) 125*cd71b1d5SPaul Burton #define DDRC_CFG_COL_10 (2 << DDRC_CFG_COL_BIT) 126*cd71b1d5SPaul Burton #define DDRC_CFG_COL_11 (3 << DDRC_CFG_COL_BIT) 127*cd71b1d5SPaul Burton 128*cd71b1d5SPaul Burton #define DDRC_CFG_CS1EN BIT(7) 129*cd71b1d5SPaul Burton #define DDRC_CFG_CS0EN BIT(6) 130*cd71b1d5SPaul Burton #define DDRC_CFG_CL_BIT 2 131*cd71b1d5SPaul Burton #define DDRC_CFG_CL_MASK (0xf << DDRC_CFG_CL_BIT) 132*cd71b1d5SPaul Burton #define DDRC_CFG_CL_3 (0 << DDRC_CFG_CL_BIT) 133*cd71b1d5SPaul Burton #define DDRC_CFG_CL_4 (1 << DDRC_CFG_CL_BIT) 134*cd71b1d5SPaul Burton #define DDRC_CFG_CL_5 (2 << DDRC_CFG_CL_BIT) 135*cd71b1d5SPaul Burton #define DDRC_CFG_CL_6 (3 << DDRC_CFG_CL_BIT) 136*cd71b1d5SPaul Burton 137*cd71b1d5SPaul Burton #define DDRC_CFG_BA BIT(1) 138*cd71b1d5SPaul Burton #define DDRC_CFG_DW BIT(0) 139*cd71b1d5SPaul Burton 140*cd71b1d5SPaul Burton /* DDRC Control Register */ 141*cd71b1d5SPaul Burton #define DDRC_CTRL_DFI_RST BIT(23) 142*cd71b1d5SPaul Burton #define DDRC_CTRL_DLL_RST BIT(22) 143*cd71b1d5SPaul Burton #define DDRC_CTRL_CTL_RST BIT(21) 144*cd71b1d5SPaul Burton #define DDRC_CTRL_CFG_RST BIT(20) 145*cd71b1d5SPaul Burton #define DDRC_CTRL_ACTPD BIT(15) 146*cd71b1d5SPaul Burton #define DDRC_CTRL_PDT_BIT 12 147*cd71b1d5SPaul Burton #define DDRC_CTRL_PDT_MASK (0x7 << DDRC_CTRL_PDT_BIT) 148*cd71b1d5SPaul Burton #define DDRC_CTRL_PDT_DIS (0 << DDRC_CTRL_PDT_BIT) 149*cd71b1d5SPaul Burton #define DDRC_CTRL_PDT_8 (1 << DDRC_CTRL_PDT_BIT) 150*cd71b1d5SPaul Burton #define DDRC_CTRL_PDT_16 (2 << DDRC_CTRL_PDT_BIT) 151*cd71b1d5SPaul Burton #define DDRC_CTRL_PDT_32 (3 << DDRC_CTRL_PDT_BIT) 152*cd71b1d5SPaul Burton #define DDRC_CTRL_PDT_64 (4 << DDRC_CTRL_PDT_BIT) 153*cd71b1d5SPaul Burton #define DDRC_CTRL_PDT_128 (5 << DDRC_CTRL_PDT_BIT) 154*cd71b1d5SPaul Burton 155*cd71b1d5SPaul Burton #define DDRC_CTRL_PRET_BIT 8 156*cd71b1d5SPaul Burton #define DDRC_CTRL_PRET_MASK (0x7 << DDRC_CTRL_PRET_BIT) 157*cd71b1d5SPaul Burton #define DDRC_CTRL_PRET_DIS (0 << DDRC_CTRL_PRET_BIT) 158*cd71b1d5SPaul Burton #define DDRC_CTRL_PRET_8 (1 << DDRC_CTRL_PRET_BIT) 159*cd71b1d5SPaul Burton #define DDRC_CTRL_PRET_16 (2 << DDRC_CTRL_PRET_BIT) 160*cd71b1d5SPaul Burton #define DDRC_CTRL_PRET_32 (3 << DDRC_CTRL_PRET_BIT) 161*cd71b1d5SPaul Burton #define DDRC_CTRL_PRET_64 (4 << DDRC_CTRL_PRET_BIT) 162*cd71b1d5SPaul Burton #define DDRC_CTRL_PRET_128 (5 << DDRC_CTRL_PRET_BIT) 163*cd71b1d5SPaul Burton 164*cd71b1d5SPaul Burton #define DDRC_CTRL_DPD BIT(6) 165*cd71b1d5SPaul Burton #define DDRC_CTRL_SR BIT(5) 166*cd71b1d5SPaul Burton #define DDRC_CTRL_UNALIGN BIT(4) 167*cd71b1d5SPaul Burton #define DDRC_CTRL_ALH BIT(3) 168*cd71b1d5SPaul Burton #define DDRC_CTRL_RDC BIT(2) 169*cd71b1d5SPaul Burton #define DDRC_CTRL_CKE BIT(1) 170*cd71b1d5SPaul Burton #define DDRC_CTRL_RESET BIT(0) 171*cd71b1d5SPaul Burton 172*cd71b1d5SPaul Burton /* DDRC Load-Mode-Register */ 173*cd71b1d5SPaul Burton #define DDRC_LMR_DDR_ADDR_BIT 16 174*cd71b1d5SPaul Burton #define DDRC_LMR_DDR_ADDR_MASK (0x3fff << DDRC_LMR_DDR_ADDR_BIT) 175*cd71b1d5SPaul Burton 176*cd71b1d5SPaul Burton #define DDRC_LMR_BA_BIT 8 177*cd71b1d5SPaul Burton #define DDRC_LMR_BA_MASK (0x7 << DDRC_LMR_BA_BIT) 178*cd71b1d5SPaul Burton /* For DDR2 */ 179*cd71b1d5SPaul Burton #define DDRC_LMR_BA_MRS (0 << DDRC_LMR_BA_BIT) 180*cd71b1d5SPaul Burton #define DDRC_LMR_BA_EMRS1 (1 << DDRC_LMR_BA_BIT) 181*cd71b1d5SPaul Burton #define DDRC_LMR_BA_EMRS2 (2 << DDRC_LMR_BA_BIT) 182*cd71b1d5SPaul Burton #define DDRC_LMR_BA_EMRS3 (3 << DDRC_LMR_BA_BIT) 183*cd71b1d5SPaul Burton /* For mobile DDR */ 184*cd71b1d5SPaul Burton #define DDRC_LMR_BA_M_MRS (0 << DDRC_LMR_BA_BIT) 185*cd71b1d5SPaul Burton #define DDRC_LMR_BA_M_EMRS (2 << DDRC_LMR_BA_BIT) 186*cd71b1d5SPaul Burton #define DDRC_LMR_BA_M_SR (1 << DDRC_LMR_BA_BIT) 187*cd71b1d5SPaul Burton /* For Normal DDR1 */ 188*cd71b1d5SPaul Burton #define DDRC_LMR_BA_N_MRS (0 << DDRC_LMR_BA_BIT) 189*cd71b1d5SPaul Burton #define DDRC_LMR_BA_N_EMRS (1 << DDRC_LMR_BA_BIT) 190*cd71b1d5SPaul Burton 191*cd71b1d5SPaul Burton #define DDRC_LMR_CMD_BIT 4 192*cd71b1d5SPaul Burton #define DDRC_LMR_CMD_MASK (0x3 << DDRC_LMR_CMD_BIT) 193*cd71b1d5SPaul Burton #define DDRC_LMR_CMD_PREC (0 << DDRC_LMR_CMD_BIT) 194*cd71b1d5SPaul Burton #define DDRC_LMR_CMD_AUREF (1 << DDRC_LMR_CMD_BIT) 195*cd71b1d5SPaul Burton #define DDRC_LMR_CMD_LMR (2 << DDRC_LMR_CMD_BIT) 196*cd71b1d5SPaul Burton 197*cd71b1d5SPaul Burton #define DDRC_LMR_START BIT(0) 198*cd71b1d5SPaul Burton 199*cd71b1d5SPaul Burton /* DDRC Timing Config Register 1 */ 200*cd71b1d5SPaul Burton #define DDRC_TIMING1_TRTP_BIT 24 201*cd71b1d5SPaul Burton #define DDRC_TIMING1_TRTP_MASK (0x3f << DDRC_TIMING1_TRTP_BIT) 202*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWTR_BIT 16 203*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWTR_MASK (0x3f << DDRC_TIMING1_TWTR_BIT) 204*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWTR_1 (0 << DDRC_TIMING1_TWTR_BIT) 205*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWTR_2 (1 << DDRC_TIMING1_TWTR_BIT) 206*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWTR_3 (2 << DDRC_TIMING1_TWTR_BIT) 207*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWTR_4 (3 << DDRC_TIMING1_TWTR_BIT) 208*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWR_BIT 8 209*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWR_MASK (0x3f << DDRC_TIMING1_TWR_BIT) 210*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWR_1 (0 << DDRC_TIMING1_TWR_BIT) 211*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWR_2 (1 << DDRC_TIMING1_TWR_BIT) 212*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWR_3 (2 << DDRC_TIMING1_TWR_BIT) 213*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWR_4 (3 << DDRC_TIMING1_TWR_BIT) 214*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWR_5 (4 << DDRC_TIMING1_TWR_BIT) 215*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWR_6 (5 << DDRC_TIMING1_TWR_BIT) 216*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWL_BIT 0 217*cd71b1d5SPaul Burton #define DDRC_TIMING1_TWL_MASK (0x3f << DDRC_TIMING1_TWL_BIT) 218*cd71b1d5SPaul Burton 219*cd71b1d5SPaul Burton /* DDRC Timing Config Register 2 */ 220*cd71b1d5SPaul Burton #define DDRC_TIMING2_TCCD_BIT 24 221*cd71b1d5SPaul Burton #define DDRC_TIMING2_TCCD_MASK (0x3f << DDRC_TIMING2_TCCD_BIT) 222*cd71b1d5SPaul Burton #define DDRC_TIMING2_TRAS_BIT 16 223*cd71b1d5SPaul Burton #define DDRC_TIMING2_TRAS_MASK (0x3f << DDRC_TIMING2_TRAS_BIT) 224*cd71b1d5SPaul Burton #define DDRC_TIMING2_TRCD_BIT 8 225*cd71b1d5SPaul Burton #define DDRC_TIMING2_TRCD_MASK (0x3f << DDRC_TIMING2_TRCD_BIT) 226*cd71b1d5SPaul Burton #define DDRC_TIMING2_TRL_BIT 0 227*cd71b1d5SPaul Burton #define DDRC_TIMING2_TRL_MASK (0x3f << DDRC_TIMING2_TRL_BIT) 228*cd71b1d5SPaul Burton 229*cd71b1d5SPaul Burton /* DDRC Timing Config Register 3 */ 230*cd71b1d5SPaul Burton #define DDRC_TIMING3_ONUM 27 231*cd71b1d5SPaul Burton #define DDRC_TIMING3_TCKSRE_BIT 24 232*cd71b1d5SPaul Burton #define DDRC_TIMING3_TCKSRE_MASK (0x3f << DDRC_TIMING3_TCKSRE_BIT) 233*cd71b1d5SPaul Burton #define DDRC_TIMING3_TRP_BIT 16 234*cd71b1d5SPaul Burton #define DDRC_TIMING3_TRP_MASK (0x3f << DDRC_TIMING3_TRP_BIT) 235*cd71b1d5SPaul Burton #define DDRC_TIMING3_TRRD_BIT 8 236*cd71b1d5SPaul Burton #define DDRC_TIMING3_TRRD_MASK (0x3f << DDRC_TIMING3_TRRD_BIT) 237*cd71b1d5SPaul Burton #define DDRC_TIMING3_TRRD_DISABLE (0 << DDRC_TIMING3_TRRD_BIT) 238*cd71b1d5SPaul Burton #define DDRC_TIMING3_TRRD_2 (1 << DDRC_TIMING3_TRRD_BIT) 239*cd71b1d5SPaul Burton #define DDRC_TIMING3_TRRD_3 (2 << DDRC_TIMING3_TRRD_BIT) 240*cd71b1d5SPaul Burton #define DDRC_TIMING3_TRRD_4 (3 << DDRC_TIMING3_TRRD_BIT) 241*cd71b1d5SPaul Burton #define DDRC_TIMING3_TRC_BIT 0 242*cd71b1d5SPaul Burton #define DDRC_TIMING3_TRC_MASK (0x3f << DDRC_TIMING3_TRC_BIT) 243*cd71b1d5SPaul Burton 244*cd71b1d5SPaul Burton /* DDRC Timing Config Register 4 */ 245*cd71b1d5SPaul Burton #define DDRC_TIMING4_TRFC_BIT 24 246*cd71b1d5SPaul Burton #define DDRC_TIMING4_TRFC_MASK (0x3f << DDRC_TIMING4_TRFC_BIT) 247*cd71b1d5SPaul Burton #define DDRC_TIMING4_TEXTRW_BIT 21 248*cd71b1d5SPaul Burton #define DDRC_TIMING4_TEXTRW_MASK (0x7 << DDRC_TIMING4_TEXTRW_BIT) 249*cd71b1d5SPaul Burton #define DDRC_TIMING4_TRWCOV_BIT 19 250*cd71b1d5SPaul Burton #define DDRC_TIMING4_TRWCOV_MASK (0x3 << DDRC_TIMING4_TRWCOV_BIT) 251*cd71b1d5SPaul Burton #define DDRC_TIMING4_TCKE_BIT 16 252*cd71b1d5SPaul Burton #define DDRC_TIMING4_TCKE_MASK (0x7 << DDRC_TIMING4_TCKE_BIT) 253*cd71b1d5SPaul Burton #define DDRC_TIMING4_TMINSR_BIT 8 254*cd71b1d5SPaul Burton #define DDRC_TIMING4_TMINSR_MASK (0xf << DDRC_TIMING4_TMINSR_BIT) 255*cd71b1d5SPaul Burton #define DDRC_TIMING4_TXP_BIT 4 256*cd71b1d5SPaul Burton #define DDRC_TIMING4_TXP_MASK (0x7 << DDRC_TIMING4_TXP_BIT) 257*cd71b1d5SPaul Burton #define DDRC_TIMING4_TMRD_BIT 0 258*cd71b1d5SPaul Burton #define DDRC_TIMING4_TMRD_MASK (0x3 << DDRC_TIMING4_TMRD_BIT) 259*cd71b1d5SPaul Burton 260*cd71b1d5SPaul Burton /* DDRC Timing Config Register 5 */ 261*cd71b1d5SPaul Burton #define DDRC_TIMING5_TCTLUPD_BIT 24 262*cd71b1d5SPaul Burton #define DDRC_TIMING4_TCTLUPD_MASK (0x3f << DDRC_TIMING5_TCTLUDP_BIT) 263*cd71b1d5SPaul Burton #define DDRC_TIMING5_TRTW_BIT 16 264*cd71b1d5SPaul Burton #define DDRC_TIMING5_TRTW_MASK (0x3f << DDRC_TIMING5_TRTW_BIT) 265*cd71b1d5SPaul Burton #define DDRC_TIMING5_TRDLAT_BIT 8 266*cd71b1d5SPaul Burton #define DDRC_TIMING5_TRDLAT_MASK (0x3f << DDRC_TIMING5_TRDLAT_BIT) 267*cd71b1d5SPaul Burton #define DDRC_TIMING5_TWDLAT_BIT 0 268*cd71b1d5SPaul Burton #define DDRC_TIMING5_TWDLAT_MASK (0x3f << DDRC_TIMING5_TWDLAT_BIT) 269*cd71b1d5SPaul Burton 270*cd71b1d5SPaul Burton /* DDRC Timing Config Register 6 */ 271*cd71b1d5SPaul Burton #define DDRC_TIMING6_TXSRD_BIT 24 272*cd71b1d5SPaul Burton #define DDRC_TIMING6_TXSRD_MASK (0x3f << DDRC_TIMING6_TXSRD_BIT) 273*cd71b1d5SPaul Burton #define DDRC_TIMING6_TFAW_BIT 16 274*cd71b1d5SPaul Burton #define DDRC_TIMING6_TFAW_MASK (0x3f << DDRC_TIMING6_TFAW_BIT) 275*cd71b1d5SPaul Burton #define DDRC_TIMING6_TCFGW_BIT 8 276*cd71b1d5SPaul Burton #define DDRC_TIMING6_TCFGW_MASK (0x3f << DDRC_TIMING6_TCFGW_BIT) 277*cd71b1d5SPaul Burton #define DDRC_TIMING6_TCFGR_BIT 0 278*cd71b1d5SPaul Burton #define DDRC_TIMING6_TCFGR_MASK (0x3f << DDRC_TIMING6_TCFGR_BIT) 279*cd71b1d5SPaul Burton 280*cd71b1d5SPaul Burton /* DDRC Auto-Refresh Counter */ 281*cd71b1d5SPaul Burton #define DDRC_REFCNT_CON_BIT 16 282*cd71b1d5SPaul Burton #define DDRC_REFCNT_CON_MASK (0xff << DDRC_REFCNT_CON_BIT) 283*cd71b1d5SPaul Burton #define DDRC_REFCNT_CNT_BIT 8 284*cd71b1d5SPaul Burton #define DDRC_REFCNT_CNT_MASK (0xff << DDRC_REFCNT_CNT_BIT) 285*cd71b1d5SPaul Burton #define DDRC_REFCNT_CLKDIV_BIT 1 286*cd71b1d5SPaul Burton #define DDRC_REFCNT_CLKDIV_MASK (0x7 << DDRC_REFCNT_CLKDIV_BIT) 287*cd71b1d5SPaul Burton #define DDRC_REFCNT_REF_EN BIT(0) 288*cd71b1d5SPaul Burton 289*cd71b1d5SPaul Burton /* DDRC DQS Delay Control Register */ 290*cd71b1d5SPaul Burton #define DDRC_DQS_ERROR BIT(29) 291*cd71b1d5SPaul Burton #define DDRC_DQS_READY BIT(28) 292*cd71b1d5SPaul Burton #define DDRC_DQS_AUTO BIT(23) 293*cd71b1d5SPaul Burton #define DDRC_DQS_DET BIT(24) 294*cd71b1d5SPaul Burton #define DDRC_DQS_SRDET BIT(25) 295*cd71b1d5SPaul Burton #define DDRC_DQS_CLKD_BIT 16 296*cd71b1d5SPaul Burton #define DDRC_DQS_CLKD_MASK (0x3f << DDRC_DQS_CLKD_BIT) 297*cd71b1d5SPaul Burton #define DDRC_DQS_WDQS_BIT 8 298*cd71b1d5SPaul Burton #define DDRC_DQS_WDQS_MASK (0x3f << DDRC_DQS_WDQS_BIT) 299*cd71b1d5SPaul Burton #define DDRC_DQS_RDQS_BIT 0 300*cd71b1d5SPaul Burton #define DDRC_DQS_RDQS_MASK (0x3f << DDRC_DQS_RDQS_BIT) 301*cd71b1d5SPaul Burton 302*cd71b1d5SPaul Burton /* DDRC DQS Delay Adjust Register */ 303*cd71b1d5SPaul Burton #define DDRC_DQS_ADJWDQS_BIT 8 304*cd71b1d5SPaul Burton #define DDRC_DQS_ADJWDQS_MASK (0x1f << DDRC_DQS_ADJWDQS_BIT) 305*cd71b1d5SPaul Burton #define DDRC_DQS_ADJRDQS_BIT 0 306*cd71b1d5SPaul Burton #define DDRC_DQS_ADJRDQS_MASK (0x1f << DDRC_DQS_ADJRDQS_BIT) 307*cd71b1d5SPaul Burton 308*cd71b1d5SPaul Burton /* DDRC Memory Map Config Register */ 309*cd71b1d5SPaul Burton #define DDRC_MMAP_BASE_BIT 8 310*cd71b1d5SPaul Burton #define DDRC_MMAP_BASE_MASK (0xff << DDRC_MMAP_BASE_BIT) 311*cd71b1d5SPaul Burton #define DDRC_MMAP_MASK_BIT 0 312*cd71b1d5SPaul Burton #define DDRC_MMAP_MASK_MASK (0xff << DDRC_MMAP_MASK_BIT) 313*cd71b1d5SPaul Burton 314*cd71b1d5SPaul Burton #define DDRC_MMAP0_BASE (0x20 << DDRC_MMAP_BASE_BIT) 315*cd71b1d5SPaul Burton #define DDRC_MMAP1_BASE_64M (0x24 << DDRC_MMAP_BASE_BIT) 316*cd71b1d5SPaul Burton #define DDRC_MMAP1_BASE_128M (0x28 << DDRC_MMAP_BASE_BIT) 317*cd71b1d5SPaul Burton #define DDRC_MMAP1_BASE_256M (0x30 << DDRC_MMAP_BASE_BIT) 318*cd71b1d5SPaul Burton 319*cd71b1d5SPaul Burton #define DDRC_MMAP_MASK_64_64 (0xfc << DDRC_MMAP_MASK_BIT) 320*cd71b1d5SPaul Burton #define DDRC_MMAP_MASK_128_128 (0xf8 << DDRC_MMAP_MASK_BIT) 321*cd71b1d5SPaul Burton #define DDRC_MMAP_MASK_256_256 (0xf0 << DDRC_MMAP_MASK_BIT) 322*cd71b1d5SPaul Burton 323*cd71b1d5SPaul Burton /* DDRP PHY Initialization Register */ 324*cd71b1d5SPaul Burton #define DDRP_PIR_INIT BIT(0) 325*cd71b1d5SPaul Burton #define DDRP_PIR_DLLSRST BIT(1) 326*cd71b1d5SPaul Burton #define DDRP_PIR_DLLLOCK BIT(2) 327*cd71b1d5SPaul Burton #define DDRP_PIR_ZCAL BIT(3) 328*cd71b1d5SPaul Burton #define DDRP_PIR_ITMSRST BIT(4) 329*cd71b1d5SPaul Burton #define DDRP_PIR_DRAMRST BIT(5) 330*cd71b1d5SPaul Burton #define DDRP_PIR_DRAMINT BIT(6) 331*cd71b1d5SPaul Burton #define DDRP_PIR_QSTRN BIT(7) 332*cd71b1d5SPaul Burton #define DDRP_PIR_EYETRN BIT(8) 333*cd71b1d5SPaul Burton #define DDRP_PIR_DLLBYP BIT(17) 334*cd71b1d5SPaul Burton /* DDRP PHY General Configurate Register */ 335*cd71b1d5SPaul Burton #define DDRP_PGCR_ITMDMD BIT(0) 336*cd71b1d5SPaul Burton #define DDRP_PGCR_DQSCFG BIT(1) 337*cd71b1d5SPaul Burton #define DDRP_PGCR_DFTCMP BIT(2) 338*cd71b1d5SPaul Burton #define DDRP_PGCR_DFTLMT_BIT 3 339*cd71b1d5SPaul Burton #define DDRP_PGCR_DTOSEL_BIT 5 340*cd71b1d5SPaul Burton #define DDRP_PGCR_CKEN_BIT 9 341*cd71b1d5SPaul Burton #define DDRP_PGCR_CKDV_BIT 12 342*cd71b1d5SPaul Burton #define DDRP_PGCR_CKINV BIT(14) 343*cd71b1d5SPaul Burton #define DDRP_PGCR_RANKEN_BIT 18 344*cd71b1d5SPaul Burton #define DDRP_PGCR_ZCKSEL_32 (2 << 22) 345*cd71b1d5SPaul Burton #define DDRP_PGCR_PDDISDX BIT(24) 346*cd71b1d5SPaul Burton /* DDRP PHY General Status Register */ 347*cd71b1d5SPaul Burton #define DDRP_PGSR_IDONE BIT(0) 348*cd71b1d5SPaul Burton #define DDRP_PGSR_DLDONE BIT(1) 349*cd71b1d5SPaul Burton #define DDRP_PGSR_ZCDONE BIT(2) 350*cd71b1d5SPaul Burton #define DDRP_PGSR_DIDONE BIT(3) 351*cd71b1d5SPaul Burton #define DDRP_PGSR_DTDONE BIT(4) 352*cd71b1d5SPaul Burton #define DDRP_PGSR_DTERR BIT(5) 353*cd71b1d5SPaul Burton #define DDRP_PGSR_DTIERR BIT(6) 354*cd71b1d5SPaul Burton #define DDRP_PGSR_DFTEERR BIT(7) 355*cd71b1d5SPaul Burton /* DDRP DRAM Configuration Register */ 356*cd71b1d5SPaul Burton #define DDRP_DCR_TYPE_BIT 0 357*cd71b1d5SPaul Burton #define DDRP_DCR_TYPE_MASK (0x7 << DDRP_DCR_TYPE_BIT) 358*cd71b1d5SPaul Burton #define DDRP_DCR_TYPE_MDDR (0 << DDRP_DCR_TYPE_BIT) 359*cd71b1d5SPaul Burton #define DDRP_DCR_TYPE_DDR (1 << DDRP_DCR_TYPE_BIT) 360*cd71b1d5SPaul Burton #define DDRP_DCR_TYPE_DDR2 (2 << DDRP_DCR_TYPE_BIT) 361*cd71b1d5SPaul Burton #define DDRP_DCR_TYPE_DDR3 (3 << DDRP_DCR_TYPE_BIT) 362*cd71b1d5SPaul Burton #define DDRP_DCR_TYPE_LPDDR2 (4 << DDRP_DCR_TYPE_BIT) 363*cd71b1d5SPaul Burton #define DDRP_DCR_DDR8BNK_BIT 3 364*cd71b1d5SPaul Burton #define DDRP_DCR_DDR8BNK_MASK (1 << DDRP_DCR_DDR8BNK_BIT) 365*cd71b1d5SPaul Burton #define DDRP_DCR_DDR8BNK (1 << DDRP_DCR_DDR8BNK_BIT) 366*cd71b1d5SPaul Burton #define DDRP_DCR_DDR8BNK_DIS (0 << DDRP_DCR_DDR8BNK_BIT) 367*cd71b1d5SPaul Burton 368*cd71b1d5SPaul Burton #define DRP_DTRP1_RTODT BIT(11) 369*cd71b1d5SPaul Burton 370*cd71b1d5SPaul Burton #define DDRP_DXGCR_DXEN BIT(0) 371*cd71b1d5SPaul Burton 372*cd71b1d5SPaul Burton #define DDRP_ZQXCR_ZDEN_BIT 28 373*cd71b1d5SPaul Burton #define DDRP_ZQXCR_ZDEN (1 << DDRP_ZQXCR_ZDEN_BIT) 374*cd71b1d5SPaul Burton #define DDRP_ZQXCR_PULLUP_IMPE_BIT 5 375*cd71b1d5SPaul Burton #define DDRP_ZQXCR_PULLDOWN_IMPE_BIT 0 376*cd71b1d5SPaul Burton 377*cd71b1d5SPaul Burton /* DDR3 Mode Register Set */ 378*cd71b1d5SPaul Burton #define DDR3_MR0_BL_BIT 0 379*cd71b1d5SPaul Burton #define DDR3_MR0_BL_MASK (3 << DDR3_MR0_BL_BIT) 380*cd71b1d5SPaul Burton #define DDR3_MR0_BL_8 (0 << DDR3_MR0_BL_BIT) 381*cd71b1d5SPaul Burton #define DDR3_MR0_BL_fly (1 << DDR3_MR0_BL_BIT) 382*cd71b1d5SPaul Burton #define DDR3_MR0_BL_4 (2 << DDR3_MR0_BL_BIT) 383*cd71b1d5SPaul Burton #define DDR3_MR0_BT_BIT 3 384*cd71b1d5SPaul Burton #define DDR3_MR0_BT_MASK (1 << DDR3_MR0_BT_BIT) 385*cd71b1d5SPaul Burton #define DDR3_MR0_BT_SEQ (0 << DDR3_MR0_BT_BIT) 386*cd71b1d5SPaul Burton #define DDR3_MR0_BT_INTER (1 << DDR3_MR0_BT_BIT) 387*cd71b1d5SPaul Burton #define DDR3_MR0_WR_BIT 9 388*cd71b1d5SPaul Burton 389*cd71b1d5SPaul Burton #define DDR3_MR1_DLL_DISABLE 1 390*cd71b1d5SPaul Burton #define DDR3_MR1_DIC_6 (0 << 5 | 0 << 1) 391*cd71b1d5SPaul Burton #define DDR3_MR1_DIC_7 (0 << 5 | BIT(1)) 392*cd71b1d5SPaul Burton #define DDR3_MR1_RTT_DIS (0 << 9 | 0 << 6 | 0 << 2) 393*cd71b1d5SPaul Burton #define DDR3_MR1_RTT_4 (0 << 9 | 0 << 6 | BIT(2)) 394*cd71b1d5SPaul Burton #define DDR3_MR1_RTT_2 (0 << 9 | BIT(6) | 0 << 2) 395*cd71b1d5SPaul Burton #define DDR3_MR1_RTT_6 (0 << 9 | BIT(6) | BIT(2)) 396*cd71b1d5SPaul Burton #define DDR3_MR1_RTT_12 (BIT(9) | 0 << 6 | 0 << 2) 397*cd71b1d5SPaul Burton #define DDR3_MR1_RTT_8 (BIT(9) | 0 << 6 | BIT(2)) 398*cd71b1d5SPaul Burton 399*cd71b1d5SPaul Burton #define DDR3_MR2_CWL_BIT 3 400*cd71b1d5SPaul Burton 401*cd71b1d5SPaul Burton /* Parameters common to all RAM devices used */ 402*cd71b1d5SPaul Burton 403*cd71b1d5SPaul Burton /* Chip Select */ 404*cd71b1d5SPaul Burton /* CSEN : whether a ddr chip exists 0 - un-used, 1 - used */ 405*cd71b1d5SPaul Burton #define DDR_CS0EN 1 406*cd71b1d5SPaul Burton /* CSEN : whether a ddr chip exists 0 - un-used, 1 - used */ 407*cd71b1d5SPaul Burton #define DDR_CS1EN 0 408*cd71b1d5SPaul Burton 409*cd71b1d5SPaul Burton /* ROW : 12 to 18 row address, 1G only 512MB */ 410*cd71b1d5SPaul Burton #define DDR_ROW 15 411*cd71b1d5SPaul Burton /* COL : 8 to 14 column address */ 412*cd71b1d5SPaul Burton #define DDR_COL 10 413*cd71b1d5SPaul Burton /* Banks each chip: 0-4bank, 1-8bank */ 414*cd71b1d5SPaul Burton #define DDR_BANK8 1 415*cd71b1d5SPaul Burton /* 0 - 16-bit data width, 1 - 32-bit data width */ 416*cd71b1d5SPaul Burton #define DDR_DW32 1 417*cd71b1d5SPaul Burton 418*cd71b1d5SPaul Burton /* Refresh period: 64ms / 32768 = 1.95 us , 2 ^ 15 = 32768 */ 419*cd71b1d5SPaul Burton #define DDR_tREFI 7800 420*cd71b1d5SPaul Burton /* Clock Divider */ 421*cd71b1d5SPaul Burton #define DDR_CLK_DIV 1 422*cd71b1d5SPaul Burton 423*cd71b1d5SPaul Burton /* DDR3 Burst length: 0 - 8 burst, 2 - 4 burst , 1 - 4 or 8 (on the fly) */ 424*cd71b1d5SPaul Burton #define DDR_BL 8 425*cd71b1d5SPaul Burton 426*cd71b1d5SPaul Burton /* CAS latency: 5 to 14, tCK */ 427*cd71b1d5SPaul Burton #define DDR_CL 6 428*cd71b1d5SPaul Burton /* DDR3 only: CAS Write Latency, 5 to 8 */ 429*cd71b1d5SPaul Burton #define DDR_tCWL (DDR_CL - 1) 430*cd71b1d5SPaul Burton 431*cd71b1d5SPaul Burton /* Structure representing per-RAM type configuration */ 432*cd71b1d5SPaul Burton 433*cd71b1d5SPaul Burton struct jz4780_ddr_config { 434*cd71b1d5SPaul Burton u32 timing[6]; /* Timing1..6 register value */ 435*cd71b1d5SPaul Burton 436*cd71b1d5SPaul Burton /* DDR PHY control */ 437*cd71b1d5SPaul Burton u16 mr0; /* Mode Register 0 */ 438*cd71b1d5SPaul Burton u16 mr1; /* Mode Register 1 */ 439*cd71b1d5SPaul Burton 440*cd71b1d5SPaul Burton u32 ptr0; /* PHY Timing Register 0 */ 441*cd71b1d5SPaul Burton u32 ptr1; /* PHY Timing Register 1 */ 442*cd71b1d5SPaul Burton u32 ptr2; /* PHY Timing Register 1 */ 443*cd71b1d5SPaul Burton 444*cd71b1d5SPaul Burton u32 dtpr0; /* DRAM Timing Parameters Register 0 */ 445*cd71b1d5SPaul Burton u32 dtpr1; /* DRAM Timing Parameters Register 1 */ 446*cd71b1d5SPaul Burton u32 dtpr2; /* DRAM Timing Parameters Register 2 */ 447*cd71b1d5SPaul Burton 448*cd71b1d5SPaul Burton u8 pullup; /* PHY pullup impedance */ 449*cd71b1d5SPaul Burton u8 pulldn; /* PHY pulldown impedance */ 450*cd71b1d5SPaul Burton }; 451*cd71b1d5SPaul Burton 452*cd71b1d5SPaul Burton void pll_init(void); 453*cd71b1d5SPaul Burton void sdram_init(void); 454*cd71b1d5SPaul Burton 455*cd71b1d5SPaul Burton #endif /* __JZ4780_DRAM_H__ */ 456*cd71b1d5SPaul Burton 457