uint32_t i, offset;
uint32_t pstate_num = dram_info.num_fsp;
+ /* only support maximum 3 setpoints */
+ pstate_num = (pstate_num > MAX_FSP_NUM) ? MAX_FSP_NUM : pstate_num;
+
for (i = 0U; i < pstate_num; i++) {
offset = i ? (i + 1) * 0x1000 : 0U;
dram_info.rank_setting[i][0] = mmio_read_32(DDRC_DRAMTMG2(0) + offset);
}
idx = i;
}
- dram_info.num_fsp = i;
+
+ /* only support maximum 3 setpoints */
+ dram_info.num_fsp = (i > MAX_FSP_NUM) ? MAX_FSP_NUM : i;
+
+ /* no valid fsp table, return directly */
+ if (i == 0U) {
+ return;
+ }
/* save the DRAMTMG2/9 for rank to rank workaround */
save_rank_setting();
SMC_RET1(handle, dram_info.num_fsp);
} else if (x1 == IMX_SIP_DDR_DVFS_GET_FREQ_INFO) {
return dram_dvfs_get_freq_info(handle, x2);
- } else if (x1 < 4) {
+ } else if (x1 < 3U) {
wait_ddrc_hwffc_done = true;
dsb();
uint32_t i, offset;
uint32_t pstate_num = dram_info.num_fsp;
+ /* only support maximum 3 setpoints */
+ pstate_num = (pstate_num > MAX_FSP_NUM) ? MAX_FSP_NUM : pstate_num;
+
for (i = 0U; i < pstate_num; i++) {
offset = i ? (i + 1) * 0x1000 : 0U;
mmio_write_32(DDRC_DRAMTMG2(0) + offset, dram_info.rank_setting[i][0]);