2 * Copyright 2016 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/arch/clock.h>
11 #include <asm/arch/fsl_serdes.h>
12 #include <asm/arch/soc.h>
14 #include <environment.h>
18 DECLARE_GLOBAL_DATA_PTR;
20 static void set_wait_for_bits_clear(void *ptr, u32 value, u32 bits)
26 while (in_be32(ptr) & bits) {
31 puts("Error: wait for clear timeout.\n");
36 puts("Board: LS1012AFRDM ");
43 struct mmdc_p_regs *mmdc =
44 (struct mmdc_p_regs *)CONFIG_SYS_FSL_DDR_ADDR;
46 out_be32(&mmdc->mdscr, CONFIGURATION_REQ);
48 /* configure timing parms */
49 out_be32(&mmdc->mdotc, CONFIG_SYS_MMDC_CORE_ODT_TIMING);
50 out_be32(&mmdc->mdcfg0, CONFIG_SYS_MMDC_CORE_TIMING_CFG_0);
51 out_be32(&mmdc->mdcfg1, CONFIG_SYS_MMDC_CORE_TIMING_CFG_1);
52 out_be32(&mmdc->mdcfg2, CONFIG_SYS_MMDC_CORE_TIMING_CFG_2);
55 out_be32(&mmdc->mdmisc, CONFIG_SYS_MMDC_CORE_MISC);
56 out_be32(&mmdc->mpmur0, CONFIG_SYS_MMDC_PHY_MEASURE_UNIT);
57 out_be32(&mmdc->mdrwd, CONFIG_SYS_MMDC_CORE_RDWR_CMD_DELAY);
58 out_be32(&mmdc->mpodtctrl, CONFIG_SYS_MMDC_PHY_ODT_CTRL);
60 /* out of reset delays */
61 out_be32(&mmdc->mdor, CONFIG_SYS_MMDC_CORE_OUT_OF_RESET_DELAY);
64 out_be32(&mmdc->mdctl, CONFIG_SYS_MMDC_CORE_CONTROL_1);
65 out_be32(&mmdc->mdasp, CONFIG_SYS_MMDC_CORE_ADDR_PARTITION);
68 out_be32(&mmdc->mdctl, CONFIG_SYS_MMDC_CORE_CONTROL_2);
70 /* dram init sequence: update MRs */
71 out_be32(&mmdc->mdscr, (CMD_ADDR_LSB_MR_ADDR(0x8) | CONFIGURATION_REQ |
72 CMD_LOAD_MODE_REG | CMD_BANK_ADDR_2));
73 out_be32(&mmdc->mdscr, (CONFIGURATION_REQ | CMD_LOAD_MODE_REG |
75 out_be32(&mmdc->mdscr, (CMD_ADDR_LSB_MR_ADDR(0x4) | CONFIGURATION_REQ |
76 CMD_LOAD_MODE_REG | CMD_BANK_ADDR_1));
77 out_be32(&mmdc->mdscr, (CMD_ADDR_MSB_MR_OP(0x19) |
78 CMD_ADDR_LSB_MR_ADDR(0x30) | CONFIGURATION_REQ |
79 CMD_LOAD_MODE_REG | CMD_BANK_ADDR_0));
81 /* dram init sequence: ZQCL */
82 out_be32(&mmdc->mdscr, (CMD_ADDR_MSB_MR_OP(0x4) | CONFIGURATION_REQ |
83 CMD_ZQ_CALIBRATION | CMD_BANK_ADDR_0));
84 set_wait_for_bits_clear(&mmdc->mpzqhwctrl,
85 CONFIG_SYS_MMDC_PHY_ZQ_HW_CTRL,
86 FORCE_ZQ_AUTO_CALIBRATION);
88 /* Calibrations now: wr lvl */
89 out_be32(&mmdc->mdscr, (CMD_ADDR_LSB_MR_ADDR(0x84) |
90 CONFIGURATION_REQ | CMD_LOAD_MODE_REG |
92 out_be32(&mmdc->mdscr, (CONFIGURATION_REQ | WL_EN | CMD_NORMAL));
93 set_wait_for_bits_clear(&mmdc->mpwlgcr, WR_LVL_HW_EN, WR_LVL_HW_EN);
97 out_be32(&mmdc->mdscr, (CMD_ADDR_LSB_MR_ADDR(0x4) | CONFIGURATION_REQ |
98 CMD_LOAD_MODE_REG | CMD_BANK_ADDR_1));
99 out_be32(&mmdc->mdscr, CONFIGURATION_REQ);
103 /* Calibrations now: Read DQS gating calibration */
104 out_be32(&mmdc->mdscr, (CMD_ADDR_MSB_MR_OP(0x4) | CONFIGURATION_REQ |
105 CMD_PRECHARGE_BANK_OPEN | CMD_BANK_ADDR_0));
106 out_be32(&mmdc->mdscr, (CMD_ADDR_LSB_MR_ADDR(0x4) | CONFIGURATION_REQ |
107 CMD_LOAD_MODE_REG | CMD_BANK_ADDR_3));
108 out_be32(&mmdc->mppdcmpr2, MPR_COMPARE_EN);
109 out_be32(&mmdc->mprddlctl, CONFIG_SYS_MMDC_PHY_RD_DLY_LINES_CFG);
110 set_wait_for_bits_clear(&mmdc->mpdgctrl0,
111 AUTO_RD_DQS_GATING_CALIBRATION_EN,
112 AUTO_RD_DQS_GATING_CALIBRATION_EN);
114 out_be32(&mmdc->mdscr, (CONFIGURATION_REQ | CMD_LOAD_MODE_REG |
117 /* Calibrations now: Read calibration */
118 out_be32(&mmdc->mdscr, (CMD_ADDR_MSB_MR_OP(0x4) | CONFIGURATION_REQ |
119 CMD_PRECHARGE_BANK_OPEN | CMD_BANK_ADDR_0));
120 out_be32(&mmdc->mdscr, (CMD_ADDR_LSB_MR_ADDR(0x4) | CONFIGURATION_REQ |
121 CMD_LOAD_MODE_REG | CMD_BANK_ADDR_3));
122 out_be32(&mmdc->mppdcmpr2, MPR_COMPARE_EN);
123 set_wait_for_bits_clear(&mmdc->mprddlhwctl,
124 AUTO_RD_CALIBRATION_EN,
125 AUTO_RD_CALIBRATION_EN);
127 out_be32(&mmdc->mdscr, (CONFIGURATION_REQ | CMD_LOAD_MODE_REG |
131 out_be32(&mmdc->mdpdc, CONFIG_SYS_MMDC_CORE_PWR_DOWN_CTRL);
132 out_be32(&mmdc->mapsr, CONFIG_SYS_MMDC_CORE_PWR_SAV_CTRL_STAT);
135 set_wait_for_bits_clear(&mmdc->mdref,
136 CONFIG_SYS_MMDC_CORE_REFRESH_CTL,
139 /* disable CON_REQ */
140 out_be32(&mmdc->mdscr, DISABLE_CFG_REQ);
147 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
152 int board_eth_init(bd_t *bis)
154 return pci_eth_init(bis);
157 int board_early_init_f(void)
159 fsl_lsch2_early_init_f();
166 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
168 * Set CCI-400 control override register to enable barrier
171 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
173 #ifdef CONFIG_ENV_IS_NOWHERE
174 gd->env_addr = (ulong)&default_environment[0];
180 int ft_board_setup(void *blob, bd_t *bd)
182 arch_fixup_fdt(blob);
184 ft_cpu_setup(blob, bd);