xref: /openbmc/u-boot/arch/arm/mach-socfpga/wrap_sdram_config.c (revision 6d4a3ff2649faa2cf2739e332557f256cc34831e)
183d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2ca62d2e1SMarek Vasut /*
3ca62d2e1SMarek Vasut  * Copyright (C) 2015 Marek Vasut <marex@denx.de>
4ca62d2e1SMarek Vasut  */
5ca62d2e1SMarek Vasut 
6ca62d2e1SMarek Vasut #include <common.h>
7ca62d2e1SMarek Vasut #include <errno.h>
8ca62d2e1SMarek Vasut #include <asm/arch/sdram.h>
9ca62d2e1SMarek Vasut 
10f6badb0dSMarek Vasut /* Board-specific header. */
11f6badb0dSMarek Vasut #include <qts/sdram_config.h>
12ca62d2e1SMarek Vasut 
13ca62d2e1SMarek Vasut static const struct socfpga_sdram_config sdram_config = {
14ca62d2e1SMarek Vasut 	.ctrl_cfg =
15ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CTRLCFG_MEMTYPE <<
16ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CTRLCFG_MEMTYPE_LSB)		|
17ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CTRLCFG_MEMBL <<
18ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CTRLCFG_MEMBL_LSB)			|
19ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CTRLCFG_ADDRORDER <<
20ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CTRLCFG_ADDRORDER_LSB)		|
21ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CTRLCFG_ECCEN <<
22ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CTRLCFG_ECCEN_LSB)			|
23ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CTRLCFG_ECCCORREN <<
24ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CTRLCFG_ECCCORREN_LSB)		|
25ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CTRLCFG_REORDEREN <<
26ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CTRLCFG_REORDEREN_LSB)		|
27ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CTRLCFG_STARVELIMIT <<
28ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CTRLCFG_STARVELIMIT_LSB)		|
29ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CTRLCFG_DQSTRKEN <<
30ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CTRLCFG_DQSTRKEN_LSB)		|
31ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CTRLCFG_NODMPINS <<
32ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CTRLCFG_NODMPINS_LSB),
33ca62d2e1SMarek Vasut 	.dram_timing1 =
34ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING1_TCWL <<
35ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING1_TCWL_LSB)		|
36ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING1_AL <<
37ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING1_TAL_LSB)		|
38ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING1_TCL <<
39ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING1_TCL_LSB)		|
40ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING1_TRRD <<
41ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING1_TRRD_LSB)		|
42ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING1_TFAW <<
43ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING1_TFAW_LSB)		|
44ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING1_TRFC <<
45ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING1_TRFC_LSB),
46ca62d2e1SMarek Vasut 	.dram_timing2 =
47ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING2_IF_TREFI <<
48ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING2_TREFI_LSB)		|
49ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING2_IF_TRCD <<
50ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING2_TRCD_LSB)		|
51ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING2_IF_TRP <<
52ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING2_TRP_LSB)		|
53ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING2_IF_TWR <<
54ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING2_TWR_LSB)		|
55ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING2_IF_TWTR <<
56ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING2_TWTR_LSB),
57ca62d2e1SMarek Vasut 	.dram_timing3 =
58ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING3_TRTP <<
59ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING3_TRTP_LSB)		|
60ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING3_TRAS <<
61ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING3_TRAS_LSB)		|
62ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING3_TRC <<
63ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING3_TRC_LSB)		|
64ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING3_TMRD <<
65ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING3_TMRD_LSB)		|
66ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING3_TCCD <<
67ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING3_TCCD_LSB),
68ca62d2e1SMarek Vasut 	.dram_timing4 =
69ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING4_SELFRFSHEXIT <<
70ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING4_SELFRFSHEXIT_LSB)	|
71ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMTIMING4_PWRDOWNEXIT <<
72ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMTIMING4_PWRDOWNEXIT_LSB),
73ca62d2e1SMarek Vasut 	.lowpwr_timing =
74ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_LOWPWRTIMING_AUTOPDCYCLES <<
75ca62d2e1SMarek Vasut 			SDR_CTRLGRP_LOWPWRTIMING_AUTOPDCYCLES_LSB)	|
76ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_LOWPWRTIMING_CLKDISABLECYCLES <<
77ca62d2e1SMarek Vasut 			SDR_CTRLGRP_LOWPWRTIMING_CLKDISABLECYCLES_LSB),
78ca62d2e1SMarek Vasut 	.dram_odt =
79ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMODT_READ <<
80ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMODT_READ_LSB)			|
81ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMODT_WRITE <<
82ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMODT_WRITE_LSB),
8389a54abfSChin Liang See 	.extratime1 =
8489a54abfSChin Liang See 	(CONFIG_HPS_SDR_CTRLCFG_EXTRATIME1_CFG_EXTRA_CTL_CLK_RD_TO_WR <<
8589a54abfSChin Liang See 			SDR_CTRLGRP_EXTRATIME1_RD_TO_WR_LSB)		|
8689a54abfSChin Liang See 	(CONFIG_HPS_SDR_CTRLCFG_EXTRATIME1_CFG_EXTRA_CTL_CLK_RD_TO_WR_BC <<
8789a54abfSChin Liang See 			SDR_CTRLGRP_EXTRATIME1_RD_TO_WR_BC_LSB)		|
8889a54abfSChin Liang See (CONFIG_HPS_SDR_CTRLCFG_EXTRATIME1_CFG_EXTRA_CTL_CLK_RD_TO_WR_DIFF_CHIP <<
8989a54abfSChin Liang See 			SDR_CTRLGRP_EXTRATIME1_RD_TO_WR_DIFF_LSB),
90ca62d2e1SMarek Vasut 	.dram_addrw =
91ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMADDRW_COLBITS <<
92ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMADDRW_COLBITS_LSB)		|
93ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMADDRW_ROWBITS <<
94ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMADDRW_ROWBITS_LSB)		|
95ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMADDRW_BANKBITS <<
96ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMADDRW_BANKBITS_LSB)		|
97ca62d2e1SMarek Vasut 		((CONFIG_HPS_SDR_CTRLCFG_DRAMADDRW_CSBITS - 1) <<
98ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMADDRW_CSBITS_LSB),
99ca62d2e1SMarek Vasut 	.dram_if_width =
100ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMIFWIDTH_IFWIDTH <<
101ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMIFWIDTH_IFWIDTH_LSB),
102ca62d2e1SMarek Vasut 	.dram_dev_width =
103ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMDEVWIDTH_DEVWIDTH <<
104ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMDEVWIDTH_DEVWIDTH_LSB),
105ca62d2e1SMarek Vasut 	.dram_intr =
106ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_DRAMINTR_INTREN <<
107ca62d2e1SMarek Vasut 			SDR_CTRLGRP_DRAMINTR_INTREN_LSB),
108ca62d2e1SMarek Vasut 	.lowpwr_eq =
109ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_LOWPWREQ_SELFRFSHMASK <<
110ca62d2e1SMarek Vasut 			SDR_CTRLGRP_LOWPWREQ_SELFRFSHMASK_LSB),
111ca62d2e1SMarek Vasut 	.static_cfg =
112ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_STATICCFG_MEMBL <<
113ca62d2e1SMarek Vasut 			SDR_CTRLGRP_STATICCFG_MEMBL_LSB)		|
114ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_STATICCFG_USEECCASDATA <<
115ca62d2e1SMarek Vasut 			SDR_CTRLGRP_STATICCFG_USEECCASDATA_LSB),
116ca62d2e1SMarek Vasut 	.ctrl_width =
117ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CTRLWIDTH_CTRLWIDTH <<
118ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CTRLWIDTH_CTRLWIDTH_LSB),
119ca62d2e1SMarek Vasut 	.cport_width =
120ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CPORTWIDTH_CPORTWIDTH <<
121ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CPORTWIDTH_CMDPORTWIDTH_LSB),
122ca62d2e1SMarek Vasut 	.cport_wmap =
123ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CPORTWMAP_CPORTWMAP <<
124ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CPORTWMAP_CPORTWFIFOMAP_LSB),
125ca62d2e1SMarek Vasut 	.cport_rmap =
126ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CPORTRMAP_CPORTRMAP <<
127ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CPORTRMAP_CPORTRFIFOMAP_LSB),
128ca62d2e1SMarek Vasut 	.rfifo_cmap =
129ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_RFIFOCMAP_RFIFOCMAP <<
130ca62d2e1SMarek Vasut 			SDR_CTRLGRP_RFIFOCMAP_RFIFOCPORTMAP_LSB),
131ca62d2e1SMarek Vasut 	.wfifo_cmap =
132ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_WFIFOCMAP_WFIFOCMAP <<
133ca62d2e1SMarek Vasut 			SDR_CTRLGRP_WFIFOCMAP_WFIFOCPORTMAP_LSB),
134ca62d2e1SMarek Vasut 	.cport_rdwr =
135ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_CPORTRDWR_CPORTRDWR <<
136ca62d2e1SMarek Vasut 			SDR_CTRLGRP_CPORTRDWR_CPORTRDWR_LSB),
137ca62d2e1SMarek Vasut 	.port_cfg =
138ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_PORTCFG_AUTOPCHEN <<
139ca62d2e1SMarek Vasut 			SDR_CTRLGRP_PORTCFG_AUTOPCHEN_LSB),
140ca62d2e1SMarek Vasut 	.fpgaport_rst = CONFIG_HPS_SDR_CTRLCFG_FPGAPORTRST,
141ca62d2e1SMarek Vasut 	.fifo_cfg =
142ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_FIFOCFG_SYNCMODE <<
143ca62d2e1SMarek Vasut 			SDR_CTRLGRP_FIFOCFG_SYNCMODE_LSB)		|
144ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_FIFOCFG_INCSYNC <<
145ca62d2e1SMarek Vasut 			SDR_CTRLGRP_FIFOCFG_INCSYNC_LSB),
146ca62d2e1SMarek Vasut 	.mp_priority =
147ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPPRIORITY_USERPRIORITY <<
148ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPPRIORITY_USERPRIORITY_LSB),
149ca62d2e1SMarek Vasut 	.mp_weight0 =
150ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPWIEIGHT_0_STATICWEIGHT_31_0 <<
151ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_0_STATICWEIGHT_31_0_LSB),
152ca62d2e1SMarek Vasut 	.mp_weight1 =
153ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPWIEIGHT_1_STATICWEIGHT_49_32 <<
154ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_1_STATICWEIGHT_49_32_LSB) |
155ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPWIEIGHT_1_SUMOFWEIGHT_13_0 <<
156ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_1_SUMOFWEIGHTS_13_0_LSB),
157ca62d2e1SMarek Vasut 	.mp_weight2 =
158ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPWIEIGHT_2_SUMOFWEIGHT_45_14 <<
159ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_2_SUMOFWEIGHTS_45_14_LSB),
160ca62d2e1SMarek Vasut 	.mp_weight3 =
161ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPWIEIGHT_3_SUMOFWEIGHT_63_46 <<
162ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_3_SUMOFWEIGHTS_63_46_LSB),
163ca62d2e1SMarek Vasut 	.mp_pacing0 =
164ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPPACING_0_THRESHOLD1_31_0 <<
165ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPPACING_MPPACING_0_THRESHOLD1_31_0_LSB),
166ca62d2e1SMarek Vasut 	.mp_pacing1 =
167ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPPACING_1_THRESHOLD1_59_32 <<
168ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPPACING_MPPACING_1_THRESHOLD1_59_32_LSB) |
169ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPPACING_1_THRESHOLD2_3_0 <<
170ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPPACING_MPPACING_1_THRESHOLD2_3_0_LSB),
171ca62d2e1SMarek Vasut 	.mp_pacing2 =
172ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPPACING_2_THRESHOLD2_35_4 <<
173ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPPACING_MPPACING_2_THRESHOLD2_35_4_LSB),
174ca62d2e1SMarek Vasut 	.mp_pacing3 =
175ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPPACING_3_THRESHOLD2_59_36 <<
176ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPPACING_MPPACING_3_THRESHOLD2_59_36_LSB),
177ca62d2e1SMarek Vasut 	.mp_threshold0 =
178ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPTHRESHOLDRST_0_THRESHOLDRSTCYCLES_31_0 <<
179ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPTHRESHOLDRST_0_THRESHOLDRSTCYCLES_31_0_LSB),
180ca62d2e1SMarek Vasut 	.mp_threshold1 =
181ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPTHRESHOLDRST_1_THRESHOLDRSTCYCLES_63_32 <<
182ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPTHRESHOLDRST_1_THRESHOLDRSTCYCLES_63_32_LSB),
183ca62d2e1SMarek Vasut 	.mp_threshold2 =
184ca62d2e1SMarek Vasut 		(CONFIG_HPS_SDR_CTRLCFG_MPTHRESHOLDRST_2_THRESHOLDRSTCYCLES_79_64 <<
185ca62d2e1SMarek Vasut 			SDR_CTRLGRP_MPTHRESHOLDRST_2_THRESHOLDRSTCYCLES_79_64_LSB),
186ca62d2e1SMarek Vasut 	.phy_ctrl0 = CONFIG_HPS_SDR_CTRLCFG_PHYCTRL_PHYCTRL_0,
187ca62d2e1SMarek Vasut };
188ca62d2e1SMarek Vasut 
189ca62d2e1SMarek Vasut static const struct socfpga_sdram_rw_mgr_config rw_mgr_config = {
190ca62d2e1SMarek Vasut 	.activate_0_and_1		= RW_MGR_ACTIVATE_0_AND_1,
191ca62d2e1SMarek Vasut 	.activate_0_and_1_wait1		= RW_MGR_ACTIVATE_0_AND_1_WAIT1,
192ca62d2e1SMarek Vasut 	.activate_0_and_1_wait2		= RW_MGR_ACTIVATE_0_AND_1_WAIT2,
193ca62d2e1SMarek Vasut 	.activate_1			= RW_MGR_ACTIVATE_1,
194ca62d2e1SMarek Vasut 	.clear_dqs_enable		= RW_MGR_CLEAR_DQS_ENABLE,
195ca62d2e1SMarek Vasut 	.guaranteed_read		= RW_MGR_GUARANTEED_READ,
196ca62d2e1SMarek Vasut 	.guaranteed_read_cont		= RW_MGR_GUARANTEED_READ_CONT,
197ca62d2e1SMarek Vasut 	.guaranteed_write		= RW_MGR_GUARANTEED_WRITE,
198ca62d2e1SMarek Vasut 	.guaranteed_write_wait0		= RW_MGR_GUARANTEED_WRITE_WAIT0,
199ca62d2e1SMarek Vasut 	.guaranteed_write_wait1		= RW_MGR_GUARANTEED_WRITE_WAIT1,
200ca62d2e1SMarek Vasut 	.guaranteed_write_wait2		= RW_MGR_GUARANTEED_WRITE_WAIT2,
201ca62d2e1SMarek Vasut 	.guaranteed_write_wait3		= RW_MGR_GUARANTEED_WRITE_WAIT3,
202ca62d2e1SMarek Vasut 	.idle				= RW_MGR_IDLE,
203ca62d2e1SMarek Vasut 	.idle_loop1			= RW_MGR_IDLE_LOOP1,
204ca62d2e1SMarek Vasut 	.idle_loop2			= RW_MGR_IDLE_LOOP2,
205ca62d2e1SMarek Vasut 	.init_reset_0_cke_0		= RW_MGR_INIT_RESET_0_CKE_0,
206ca62d2e1SMarek Vasut 	.init_reset_1_cke_0		= RW_MGR_INIT_RESET_1_CKE_0,
207ca62d2e1SMarek Vasut 	.lfsr_wr_rd_bank_0		= RW_MGR_LFSR_WR_RD_BANK_0,
208ca62d2e1SMarek Vasut 	.lfsr_wr_rd_bank_0_data		= RW_MGR_LFSR_WR_RD_BANK_0_DATA,
209ca62d2e1SMarek Vasut 	.lfsr_wr_rd_bank_0_dqs		= RW_MGR_LFSR_WR_RD_BANK_0_DQS,
210ca62d2e1SMarek Vasut 	.lfsr_wr_rd_bank_0_nop		= RW_MGR_LFSR_WR_RD_BANK_0_NOP,
211ca62d2e1SMarek Vasut 	.lfsr_wr_rd_bank_0_wait		= RW_MGR_LFSR_WR_RD_BANK_0_WAIT,
212ca62d2e1SMarek Vasut 	.lfsr_wr_rd_bank_0_wl_1		= RW_MGR_LFSR_WR_RD_BANK_0_WL_1,
213ca62d2e1SMarek Vasut 	.lfsr_wr_rd_dm_bank_0		= RW_MGR_LFSR_WR_RD_DM_BANK_0,
214ca62d2e1SMarek Vasut 	.lfsr_wr_rd_dm_bank_0_data	= RW_MGR_LFSR_WR_RD_DM_BANK_0_DATA,
215ca62d2e1SMarek Vasut 	.lfsr_wr_rd_dm_bank_0_dqs	= RW_MGR_LFSR_WR_RD_DM_BANK_0_DQS,
216ca62d2e1SMarek Vasut 	.lfsr_wr_rd_dm_bank_0_nop	= RW_MGR_LFSR_WR_RD_DM_BANK_0_NOP,
217ca62d2e1SMarek Vasut 	.lfsr_wr_rd_dm_bank_0_wait	= RW_MGR_LFSR_WR_RD_DM_BANK_0_WAIT,
218ca62d2e1SMarek Vasut 	.lfsr_wr_rd_dm_bank_0_wl_1	= RW_MGR_LFSR_WR_RD_DM_BANK_0_WL_1,
219ca62d2e1SMarek Vasut 	.mrs0_dll_reset			= RW_MGR_MRS0_DLL_RESET,
220ca62d2e1SMarek Vasut 	.mrs0_dll_reset_mirr		= RW_MGR_MRS0_DLL_RESET_MIRR,
221ca62d2e1SMarek Vasut 	.mrs0_user			= RW_MGR_MRS0_USER,
222ca62d2e1SMarek Vasut 	.mrs0_user_mirr			= RW_MGR_MRS0_USER_MIRR,
223ca62d2e1SMarek Vasut 	.mrs1				= RW_MGR_MRS1,
224ca62d2e1SMarek Vasut 	.mrs1_mirr			= RW_MGR_MRS1_MIRR,
225ca62d2e1SMarek Vasut 	.mrs2				= RW_MGR_MRS2,
226ca62d2e1SMarek Vasut 	.mrs2_mirr			= RW_MGR_MRS2_MIRR,
227ca62d2e1SMarek Vasut 	.mrs3				= RW_MGR_MRS3,
228ca62d2e1SMarek Vasut 	.mrs3_mirr			= RW_MGR_MRS3_MIRR,
229ca62d2e1SMarek Vasut 	.precharge_all			= RW_MGR_PRECHARGE_ALL,
230ca62d2e1SMarek Vasut 	.read_b2b			= RW_MGR_READ_B2B,
231ca62d2e1SMarek Vasut 	.read_b2b_wait1			= RW_MGR_READ_B2B_WAIT1,
232ca62d2e1SMarek Vasut 	.read_b2b_wait2			= RW_MGR_READ_B2B_WAIT2,
233ca62d2e1SMarek Vasut 	.refresh_all			= RW_MGR_REFRESH_ALL,
234ca62d2e1SMarek Vasut 	.rreturn			= RW_MGR_RETURN,
235ca62d2e1SMarek Vasut 	.sgle_read			= RW_MGR_SGLE_READ,
236ca62d2e1SMarek Vasut 	.zqcl				= RW_MGR_ZQCL,
237ca62d2e1SMarek Vasut 
238ca62d2e1SMarek Vasut 	.true_mem_data_mask_width	= RW_MGR_TRUE_MEM_DATA_MASK_WIDTH,
239ca62d2e1SMarek Vasut 	.mem_address_mirroring		= RW_MGR_MEM_ADDRESS_MIRRORING,
240ca62d2e1SMarek Vasut 	.mem_data_mask_width		= RW_MGR_MEM_DATA_MASK_WIDTH,
241ca62d2e1SMarek Vasut 	.mem_data_width			= RW_MGR_MEM_DATA_WIDTH,
242ca62d2e1SMarek Vasut 	.mem_dq_per_read_dqs		= RW_MGR_MEM_DQ_PER_READ_DQS,
243ca62d2e1SMarek Vasut 	.mem_dq_per_write_dqs		= RW_MGR_MEM_DQ_PER_WRITE_DQS,
244ca62d2e1SMarek Vasut 	.mem_if_read_dqs_width		= RW_MGR_MEM_IF_READ_DQS_WIDTH,
245ca62d2e1SMarek Vasut 	.mem_if_write_dqs_width		= RW_MGR_MEM_IF_WRITE_DQS_WIDTH,
246ca62d2e1SMarek Vasut 	.mem_number_of_cs_per_dimm	= RW_MGR_MEM_NUMBER_OF_CS_PER_DIMM,
247ca62d2e1SMarek Vasut 	.mem_number_of_ranks		= RW_MGR_MEM_NUMBER_OF_RANKS,
248ca62d2e1SMarek Vasut 	.mem_virtual_groups_per_read_dqs =
249ca62d2e1SMarek Vasut 		RW_MGR_MEM_VIRTUAL_GROUPS_PER_READ_DQS,
250ca62d2e1SMarek Vasut 	.mem_virtual_groups_per_write_dqs =
251ca62d2e1SMarek Vasut 		RW_MGR_MEM_VIRTUAL_GROUPS_PER_WRITE_DQS,
252ca62d2e1SMarek Vasut };
253ca62d2e1SMarek Vasut 
254*dd8ee8eaSSimon Goldschmidt static const struct socfpga_sdram_io_config io_config = {
255ca62d2e1SMarek Vasut 	.delay_per_dchain_tap		= IO_DELAY_PER_DCHAIN_TAP,
256ca62d2e1SMarek Vasut 	.delay_per_dqs_en_dchain_tap	= IO_DELAY_PER_DQS_EN_DCHAIN_TAP,
257ca62d2e1SMarek Vasut 	.delay_per_opa_tap		= IO_DELAY_PER_OPA_TAP,
258ca62d2e1SMarek Vasut 	.dll_chain_length		= IO_DLL_CHAIN_LENGTH,
259ca62d2e1SMarek Vasut 	.dqdqs_out_phase_max		= IO_DQDQS_OUT_PHASE_MAX,
260ca62d2e1SMarek Vasut 	.dqs_en_delay_max		= IO_DQS_EN_DELAY_MAX,
261ca62d2e1SMarek Vasut 	.dqs_en_delay_offset		= IO_DQS_EN_DELAY_OFFSET,
262ca62d2e1SMarek Vasut 	.dqs_en_phase_max		= IO_DQS_EN_PHASE_MAX,
263ca62d2e1SMarek Vasut 	.dqs_in_delay_max		= IO_DQS_IN_DELAY_MAX,
264ca62d2e1SMarek Vasut 	.dqs_in_reserve			= IO_DQS_IN_RESERVE,
265ca62d2e1SMarek Vasut 	.dqs_out_reserve		= IO_DQS_OUT_RESERVE,
266ca62d2e1SMarek Vasut 	.io_in_delay_max		= IO_IO_IN_DELAY_MAX,
267ca62d2e1SMarek Vasut 	.io_out1_delay_max		= IO_IO_OUT1_DELAY_MAX,
268ca62d2e1SMarek Vasut 	.io_out2_delay_max		= IO_IO_OUT2_DELAY_MAX,
269ca62d2e1SMarek Vasut 	.shift_dqs_en_when_shift_dqs	= IO_SHIFT_DQS_EN_WHEN_SHIFT_DQS,
270ca62d2e1SMarek Vasut };
271ca62d2e1SMarek Vasut 
272*dd8ee8eaSSimon Goldschmidt static const struct socfpga_sdram_misc_config misc_config = {
273ca62d2e1SMarek Vasut 	.afi_rate_ratio			= AFI_RATE_RATIO,
274ca62d2e1SMarek Vasut 	.calib_lfifo_offset		= CALIB_LFIFO_OFFSET,
275ca62d2e1SMarek Vasut 	.calib_vfifo_offset		= CALIB_VFIFO_OFFSET,
276ca62d2e1SMarek Vasut 	.enable_super_quick_calibration	= ENABLE_SUPER_QUICK_CALIBRATION,
277ca62d2e1SMarek Vasut 	.max_latency_count_width	= MAX_LATENCY_COUNT_WIDTH,
278ca62d2e1SMarek Vasut 	.read_valid_fifo_size		= READ_VALID_FIFO_SIZE,
279ca62d2e1SMarek Vasut 	.reg_file_init_seq_signature	= REG_FILE_INIT_SEQ_SIGNATURE,
280ca62d2e1SMarek Vasut 	.tinit_cntr0_val		= TINIT_CNTR0_VAL,
281ca62d2e1SMarek Vasut 	.tinit_cntr1_val		= TINIT_CNTR1_VAL,
282ca62d2e1SMarek Vasut 	.tinit_cntr2_val		= TINIT_CNTR2_VAL,
283ca62d2e1SMarek Vasut 	.treset_cntr0_val		= TRESET_CNTR0_VAL,
284ca62d2e1SMarek Vasut 	.treset_cntr1_val		= TRESET_CNTR1_VAL,
285ca62d2e1SMarek Vasut 	.treset_cntr2_val		= TRESET_CNTR2_VAL,
286ca62d2e1SMarek Vasut };
287ca62d2e1SMarek Vasut 
socfpga_get_sdram_config(void)288ca62d2e1SMarek Vasut const struct socfpga_sdram_config *socfpga_get_sdram_config(void)
289ca62d2e1SMarek Vasut {
290ca62d2e1SMarek Vasut 	return &sdram_config;
291ca62d2e1SMarek Vasut }
292ca62d2e1SMarek Vasut 
socfpga_get_seq_ac_init(const u32 ** init,unsigned int * nelem)293ca62d2e1SMarek Vasut void socfpga_get_seq_ac_init(const u32 **init, unsigned int *nelem)
294ca62d2e1SMarek Vasut {
295ca62d2e1SMarek Vasut 	*init = ac_rom_init;
296ca62d2e1SMarek Vasut 	*nelem = ARRAY_SIZE(ac_rom_init);
297ca62d2e1SMarek Vasut }
298ca62d2e1SMarek Vasut 
socfpga_get_seq_inst_init(const u32 ** init,unsigned int * nelem)299ca62d2e1SMarek Vasut void socfpga_get_seq_inst_init(const u32 **init, unsigned int *nelem)
300ca62d2e1SMarek Vasut {
301ca62d2e1SMarek Vasut 	*init = inst_rom_init;
302ca62d2e1SMarek Vasut 	*nelem = ARRAY_SIZE(inst_rom_init);
303ca62d2e1SMarek Vasut }
304ca62d2e1SMarek Vasut 
socfpga_get_sdram_rwmgr_config(void)305ca62d2e1SMarek Vasut const struct socfpga_sdram_rw_mgr_config *socfpga_get_sdram_rwmgr_config(void)
306ca62d2e1SMarek Vasut {
307ca62d2e1SMarek Vasut 	return &rw_mgr_config;
308ca62d2e1SMarek Vasut }
309ca62d2e1SMarek Vasut 
socfpga_get_sdram_io_config(void)310ca62d2e1SMarek Vasut const struct socfpga_sdram_io_config *socfpga_get_sdram_io_config(void)
311ca62d2e1SMarek Vasut {
312ca62d2e1SMarek Vasut 	return &io_config;
313ca62d2e1SMarek Vasut }
314ca62d2e1SMarek Vasut 
socfpga_get_sdram_misc_config(void)315ca62d2e1SMarek Vasut const struct socfpga_sdram_misc_config *socfpga_get_sdram_misc_config(void)
316ca62d2e1SMarek Vasut {
317ca62d2e1SMarek Vasut 	return &misc_config;
318ca62d2e1SMarek Vasut }
319