Lines Matching refs:ddr_ctrl
58 static inline void phy_reset(struct ddr_ctrl_data *ddr_ctrl) in phy_reset() argument
63 DDR_PHY_REG(ddr_ctrl, i) = ddr_phy_settings[i]; in phy_reset()
66 DDR_PHY_REG(ddr_ctrl, i) = ddr_phy_settings[i]; in phy_reset()
70 static inline void ddr_writeregmap(struct ddr_ctrl_data *ddr_ctrl) in ddr_writeregmap() argument
75 DDR_CTL_REG(ddr_ctrl, i) = ddr_ctl_settings[i]; in ddr_writeregmap()
77 phy_reset(ddr_ctrl); in ddr_writeregmap()
80 static inline uint32_t ddr_getdramclass(struct ddr_ctrl_data *ddr_ctrl) in ddr_getdramclass() argument
82 return ((DDR_CTL_REG(ddr_ctrl, 0) >> DRAM_CLASS_OFFSET) & 0xF); in ddr_getdramclass()
122 static inline uint64_t ddr_phy_fixup(struct ddr_ctrl_data *ddr_ctrl) in ddr_phy_fixup() argument
133 updownreg = DDR_PHY_REG(ddr_ctrl, (regbase + reg)); in ddr_phy_fixup()
143 struct ddr_ctrl_data *ddr_ctrl = dev->data; in ddr_init() local
145 LOG_DBG("start: 0x%lx", (uintptr_t)ddr_ctrl->ddr_start); in ddr_init()
146 LOG_DBG("size: 0x%lx", ddr_ctrl->ddr_size); in ddr_init()
148 ddr_writeregmap(ddr_ctrl); in ddr_init()
150 DDR_CTL_REG(ddr_ctrl, 120) |= DISABLE_RD_INTERLEAVE; in ddr_init()
151 DDR_CTL_REG(ddr_ctrl, 21) &= ~OPTIMAL_RMODW_EN; in ddr_init()
152 DDR_CTL_REG(ddr_ctrl, 170) |= WRLVL_EN | DFI_PHY_WRLELV_MODE; in ddr_init()
153 DDR_CTL_REG(ddr_ctrl, 181) |= DFI_PHY_RDLVL_MODE; in ddr_init()
154 DDR_CTL_REG(ddr_ctrl, 260) |= RDLVL_EN; in ddr_init()
155 DDR_CTL_REG(ddr_ctrl, 260) |= RDLVL_GATE_EN; in ddr_init()
156 DDR_CTL_REG(ddr_ctrl, 182) |= DFI_PHY_RDLVL_GATE_MODE; in ddr_init()
158 if (ddr_getdramclass(ddr_ctrl) == DRAM_CLASS_DDR4) { in ddr_init()
159 DDR_CTL_REG(ddr_ctrl, 184) |= VREF_EN; in ddr_init()
162 DDR_CTL_REG(ddr_ctrl, 136) |= LEVELING_OPERATION_COMPLETED; in ddr_init()
163 DDR_CTL_REG(ddr_ctrl, 136) |= MC_INIT_COMPLETE; in ddr_init()
164 DDR_CTL_REG(ddr_ctrl, 136) |= OUT_OF_RANGE | MULTIPLE_OUT_OF_RANGE; in ddr_init()
167 size_t end_addr_16Kblocks = ((ddr_ctrl->ddr_size >> 14) & 0x7FFFFF) - 1; in ddr_init()
169 DDR_CTL_REG(ddr_ctrl, 209) = 0x0; in ddr_init()
170 DDR_CTL_REG(ddr_ctrl, 210) = ((uint32_t) end_addr_16Kblocks); in ddr_init()
171 DDR_CTL_REG(ddr_ctrl, 212) = 0x0; in ddr_init()
172 DDR_CTL_REG(ddr_ctrl, 214) = 0x0; in ddr_init()
173 DDR_CTL_REG(ddr_ctrl, 216) = 0x0; in ddr_init()
174 DDR_CTL_REG(ddr_ctrl, 224) |= AXI0_RANGE_PROT_BITS_0; in ddr_init()
175 DDR_CTL_REG(ddr_ctrl, 225) = 0xFFFFFFFF; in ddr_init()
176 DDR_CTL_REG(ddr_ctrl, 208) |= AXI0_ADDRESS_RANGE_ENABLE; in ddr_init()
177 DDR_CTL_REG(ddr_ctrl, 208) |= PORT_ADDR_PROTECTION_EN; in ddr_init()
180 DDR_CTL_REG(ddr_ctrl, 136) |= PORT_COMMAND_CHANNEL_ERROR; in ddr_init()
182 DDR_CTL_REG(ddr_ctrl, 0) |= 1; in ddr_init()
184 while ((DDR_CTL_REG(ddr_ctrl, 132) & MC_INIT_COMPLETE) != 0) { in ddr_init()
188 uint64_t ddr_end = (uint64_t)ddr_ctrl->ddr_start + ddr_ctrl->ddr_size; in ddr_init()
191 volatile uint64_t *filterreg = (volatile uint64_t *)ddr_ctrl->ddr_physical_filter; in ddr_init()
196 ddr_phy_fixup(ddr_ctrl); in ddr_init()