MCPcopy Create free account
hub / github.com/F-Stack/f-stack / decode_win_sdram_fixup

Function decode_win_sdram_fixup

freebsd/arm/mv/mv_common.c:1243–1283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1241}
1242
1243static int
1244decode_win_sdram_fixup(void)
1245{
1246 struct mem_region mr[FDT_MEM_REGIONS];
1247 uint8_t window_valid[MV_WIN_DDR_MAX];
1248 int mr_cnt, err, i, j;
1249 uint32_t valid_win_num = 0;
1250
1251 /* Grab physical memory regions information from device tree. */
1252 err = fdt_get_mem_regions(mr, &mr_cnt, NULL);
1253 if (err != 0)
1254 return (err);
1255
1256 for (i = 0; i < MV_WIN_DDR_MAX; i++)
1257 window_valid[i] = 0;
1258
1259 /* Try to match entries from device tree with settings from u-boot */
1260 for (i = 0; i < mr_cnt; i++) {
1261 for (j = 0; j < MV_WIN_DDR_MAX; j++) {
1262 if (ddr_is_active(j) &&
1263 (ddr_base(j) == mr[i].mr_start) &&
1264 (ddr_size(j) == mr[i].mr_size)) {
1265 window_valid[j] = 1;
1266 valid_win_num++;
1267 }
1268 }
1269 }
1270
1271 if (mr_cnt != valid_win_num)
1272 return (EINVAL);
1273
1274 /* Destroy windows without corresponding device tree entry */
1275 for (j = 0; j < MV_WIN_DDR_MAX; j++) {
1276 if (ddr_is_active(j) && (window_valid[j] != 1)) {
1277 printf("Disabling SDRAM decoding window: %d\n", j);
1278 ddr_disable(j);
1279 }
1280 }
1281
1282 return (0);
1283}
1284/*
1285 * Check if we're able to cover all active DDR banks.
1286 */

Callers 1

soc_decode_winFunction · 0.85

Calls 5

ddr_is_activeFunction · 0.85
ddr_baseFunction · 0.85
ddr_sizeFunction · 0.85
ddr_disableFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected