blob: 1d09ff4cb1ba7d421daa3a5a57f8554790dc6253 [file] [log] [blame]
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +05301/*
2 * Copyright 2016 Freescale Semiconductor, Inc.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#ifndef FSL_MMDC_H
8#define FSL_MMDC_H
9
Shengzhou Liucb7fb122016-08-26 18:30:39 +080010/* PHY Write Leveling Configuration and Error Status Register (MPWLGCR) */
11#define MPWLGCR_HW_WL_EN (1 << 0)
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +053012
13/* PHY Pre-defined Compare and CA delay-line Configuration (MPPDCMPR2) */
Shengzhou Liucb7fb122016-08-26 18:30:39 +080014#define MPPDCMPR2_MPR_COMPARE_EN (1 << 0)
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +053015
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +053016
17/* MMDC PHY Read DQS gating control register 0 (MPDGCTRL0) */
Shengzhou Liucb7fb122016-08-26 18:30:39 +080018#define AUTO_RD_DQS_GATING_CALIBRATION_EN (1 << 28)
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +053019
20/* MMDC PHY Read Delay HW Calibration Control Register (MPRDDLHWCTL) */
Shengzhou Liucb7fb122016-08-26 18:30:39 +080021#define MPRDDLHWCTL_AUTO_RD_CALIBRATION_EN (1 << 4)
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +053022
Shengzhou Liucb7fb122016-08-26 18:30:39 +080023/* MMDC Core Power Saving Control and Status Register (MMDC_MAPSR) */
24#define MMDC_MAPSR_PWR_SAV_CTRL_STAT 0x00001067
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +053025
Shengzhou Liucb7fb122016-08-26 18:30:39 +080026/* MMDC Core Refresh Control Register (MMDC_MDREF) */
27#define MDREF_START_REFRESH (1 << 0)
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +053028
29/* MMDC Core Special Command Register (MDSCR) */
Shengzhou Liucb7fb122016-08-26 18:30:39 +080030#define CMD_ADDR_MSB_MR_OP(x) (x << 24)
31#define CMD_ADDR_LSB_MR_ADDR(x) (x << 16)
32#define MDSCR_DISABLE_CFG_REQ (0 << 15)
33#define MDSCR_ENABLE_CON_REQ (1 << 15)
34#define MDSCR_CON_ACK (1 << 14)
35#define MDSCR_WL_EN (1 << 9)
36#define CMD_NORMAL (0 << 4)
37#define CMD_PRECHARGE (1 << 4)
38#define CMD_AUTO_REFRESH (2 << 4)
39#define CMD_LOAD_MODE_REG (3 << 4)
40#define CMD_ZQ_CALIBRATION (4 << 4)
41#define CMD_PRECHARGE_BANK_OPEN (5 << 4)
42#define CMD_MRR (6 << 4)
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +053043#define CMD_BANK_ADDR_0 0x0
44#define CMD_BANK_ADDR_1 0x1
45#define CMD_BANK_ADDR_2 0x2
46#define CMD_BANK_ADDR_3 0x3
47#define CMD_BANK_ADDR_4 0x4
48#define CMD_BANK_ADDR_5 0x5
49#define CMD_BANK_ADDR_6 0x6
50#define CMD_BANK_ADDR_7 0x7
51
Shengzhou Liucb7fb122016-08-26 18:30:39 +080052/* MMDC Core Control Register (MDCTL) */
53#define MDCTL_SDE0 (1 << 31)
54#define MDCTL_SDE1 (1 << 30)
55
56/* MMDC PHY ZQ HW control register (MMDC_MPZQHWCTRL) */
57#define MPZQHWCTRL_ZQ_HW_FORCE (1 << 16)
58
59/* MMDC PHY Measure Unit Register (MMDC_MPMUR0) */
60#define MMDC_MPMUR0_FRC_MSR (1 << 11)
61
62/* MMDC PHY Read delay-lines Configuration Register (MMDC_MPRDDLCTL) */
63/* default 64 for a quarter cycle delay */
64#define MMDC_MPRDDLCTL_DEFAULT_DELAY 0x40404040
65
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +053066/* MMDC Registers */
Shengzhou Liucb7fb122016-08-26 18:30:39 +080067struct mmdc_regs {
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +053068 u32 mdctl;
69 u32 mdpdc;
70 u32 mdotc;
71 u32 mdcfg0;
72 u32 mdcfg1;
73 u32 mdcfg2;
74 u32 mdmisc;
75 u32 mdscr;
76 u32 mdref;
77 u32 res1[2];
78 u32 mdrwd;
79 u32 mdor;
80 u32 mdmrr;
81 u32 mdcfg3lp;
82 u32 mdmr4;
83 u32 mdasp;
84 u32 res2[239];
85 u32 maarcr;
86 u32 mapsr;
87 u32 maexidr0;
88 u32 maexidr1;
89 u32 madpcr0;
90 u32 madpcr1;
91 u32 madpsr0;
92 u32 madpsr1;
93 u32 madpsr2;
94 u32 madpsr3;
95 u32 madpsr4;
96 u32 madpsr5;
97 u32 masbs0;
98 u32 masbs1;
99 u32 res3[2];
100 u32 magenp;
101 u32 res4[239];
102 u32 mpzqhwctrl;
103 u32 mpzqswctrl;
104 u32 mpwlgcr;
105 u32 mpwldectrl0;
106 u32 mpwldectrl1;
107 u32 mpwldlst;
108 u32 mpodtctrl;
109 u32 mprddqby0dl;
110 u32 mprddqby1dl;
111 u32 mprddqby2dl;
112 u32 mprddqby3dl;
Shengzhou Liucb7fb122016-08-26 18:30:39 +0800113 u32 mpwrdqby0dl;
114 u32 mpwrdqby1dl;
115 u32 mpwrdqby2dl;
116 u32 mpwrdqby3dl;
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +0530117 u32 mpdgctrl0;
118 u32 mpdgctrl1;
119 u32 mpdgdlst0;
120 u32 mprddlctl;
121 u32 mprddlst;
122 u32 mpwrdlctl;
123 u32 mpwrdlst;
124 u32 mpsdctrl;
125 u32 mpzqlp2ctl;
126 u32 mprddlhwctl;
127 u32 mpwrdlhwctl;
128 u32 mprddlhwst0;
129 u32 mprddlhwst1;
130 u32 mpwrdlhwst0;
131 u32 mpwrdlhwst1;
132 u32 mpwlhwerr;
133 u32 mpdghwst0;
134 u32 mpdghwst1;
135 u32 mpdghwst2;
136 u32 mpdghwst3;
137 u32 mppdcmpr1;
138 u32 mppdcmpr2;
139 u32 mpswdar0;
140 u32 mpswdrdr0;
141 u32 mpswdrdr1;
142 u32 mpswdrdr2;
143 u32 mpswdrdr3;
144 u32 mpswdrdr4;
145 u32 mpswdrdr5;
146 u32 mpswdrdr6;
147 u32 mpswdrdr7;
148 u32 mpmur0;
149 u32 mpwrcadl;
150 u32 mpdccr;
151};
152
Shengzhou Liucb7fb122016-08-26 18:30:39 +0800153void mmdc_init(void);
154
155#if !defined(CONFIG_MMDC_MDCTL)
156#error Must configure board-specific timing CONFIG_MMDC_* in <board>.h for MMDC
157#endif
158
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +0530159#endif /* FSL_MMDC_H */