/* determined physical memory size, not overridden by command line args */ externunsignedlong physical_memsize;
enum mem_map {
MEM_MAP_V1 = 0,
MEM_MAP_V2,
};
#define MAX_MEM_ARRAY_ENTRIES 2
static __init int malta_scon(void)
{ int scon = MIPS_REVISION_SCONID;
if (scon != MIPS_REVISION_SCON_OTHER) return scon;
switch (MIPS_REVISION_CORID) { case MIPS_REVISION_CORID_QED_RM5261: case MIPS_REVISION_CORID_CORE_LV: case MIPS_REVISION_CORID_CORE_FPGA: case MIPS_REVISION_CORID_CORE_FPGAR2: return MIPS_REVISION_SCON_GT64120;
case MIPS_REVISION_CORID_CORE_EMUL_BON: case MIPS_REVISION_CORID_BONITO64: case MIPS_REVISION_CORID_CORE_20K: return MIPS_REVISION_SCON_BONITO;
case MIPS_REVISION_CORID_CORE_MSC: case MIPS_REVISION_CORID_CORE_FPGA2: case MIPS_REVISION_CORID_CORE_24K: return MIPS_REVISION_SCON_SOCIT;
case MIPS_REVISION_CORID_CORE_FPGA3: case MIPS_REVISION_CORID_CORE_FPGA4: case MIPS_REVISION_CORID_CORE_FPGA5: case MIPS_REVISION_CORID_CORE_EMUL_MSC: default: return MIPS_REVISION_SCON_ROCIT;
}
}
entries = 1;
mem_array[0] = cpu_to_be32(PHYS_OFFSET); if (IS_ENABLED(CONFIG_EVA)) { /* * The current Malta EVA configuration is "special" in that it * always makes use of addresses in the upper half of the 32 bit * physical address map, which gives it a contiguous region of * DDR but limits it to 2GB.
*/
mem_array[1] = cpu_to_be32(size); goto done;
}
if (map == MEM_MAP_V2) { /* * We have a flat 32 bit physical memory map with DDR filling * all 4GB of the memory map, apart from the I/O region which * obscures 256MB from 0x10000000-0x1fffffff. * * Therefore we discard the 256MB behind the I/O region.
*/ if (size <= SZ_256M) goto done;
size -= SZ_256M;
/* Make use of the memory following the I/O region */
entries++;
mem_array[2] = cpu_to_be32(PHYS_OFFSET + SZ_512M);
mem_array[3] = cpu_to_be32(size);
} else { /* * We have a 32 bit physical memory map with a 2GB DDR region * aliased in the upper & lower halves of it. The I/O region * obscures 256MB from 0x10000000-0x1fffffff in the low alias * but the DDR it obscures is accessible via the high alias. * * Simply access everything beyond the lowest 256MB of DDR using * the high alias.
*/
entries++;
mem_array[2] = cpu_to_be32(PHYS_OFFSET + SZ_2G + SZ_256M);
mem_array[3] = cpu_to_be32(size);
}
/* if a memory node already exists, leave it alone */
mem_off = fdt_path_offset(fdt, "/memory"); if (mem_off >= 0) return;
/* find memory size from the bootloader environment */ for (i = 0; i < ARRAY_SIZE(var_names); i++) {
var = fw_getenv(var_names[i]); if (!var) continue;
err = kstrtoul(var, 0, &physical_memsize); if (!err) break;
pr_warn("Failed to read the '%s' env variable '%s'\n",
var_names[i], var);
}
if (!physical_memsize) {
pr_warn("The bootloader didn't provide memsize: defaulting to 32MB\n");
physical_memsize = 32 << 20;
}
if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) { /* * SOC-it swaps, or perhaps doesn't swap, when DMA'ing * the last word of physical memory.
*/
physical_memsize -= PAGE_SIZE;
}
/* default to using all available RAM */
memsize = physical_memsize;
/* allow the user to override the usable memory */ for (i = 0; i < ARRAY_SIZE(var_names); i++) {
snprintf(param_name, sizeof(param_name), "%s=", var_names[i]);
var = strstr(arcs_cmdline, param_name); if (!var) continue;
/* if the user says there's more RAM than we thought, believe them */
physical_memsize = max_t(unsignedlong, physical_memsize, memsize);
/* detect the memory map in use */ if (malta_scon() == MIPS_REVISION_SCON_ROCIT) { /* ROCit has a register indicating the memory map in use */
config = readl((void __iomem *)CKSEG1ADDR(ROCIT_CONFIG_GEN1));
mem_map = config & ROCIT_CONFIG_GEN1_MEMMAP_MASK;
mem_map >>= ROCIT_CONFIG_GEN1_MEMMAP_SHIFT;
} else { /* if not using ROCit, presume the v1 memory map */
mem_map = MEM_MAP_V1;
} if (mem_map > MEM_MAP_V2)
panic("Unsupported physical memory map v%u detected",
(unsignedint)mem_map);
/* append memory to the DT */
mem_off = fdt_add_subnode(fdt, root_off, "memory"); if (mem_off < 0)
panic("Unable to add memory node to DT: %d", mem_off);
err = fdt_setprop_string(fdt, mem_off, "device_type", "memory"); if (err)
panic("Unable to set memory node device_type: %d", err);
mem_entries = gen_fdt_mem_array(mem_array, physical_memsize, mem_map);
err = fdt_setprop(fdt, mem_off, "reg", mem_array,
mem_entries * 2 * sizeof(mem_array[0])); if (err)
panic("Unable to set memory regs property: %d", err);
mem_entries = gen_fdt_mem_array(mem_array, memsize, mem_map);
err = fdt_setprop(fdt, mem_off, "linux,usable-memory", mem_array,
mem_entries * 2 * sizeof(mem_array[0])); if (err)
panic("Unable to set linux,usable-memory property: %d", err);
}
/* if we have a CM which reports a GIC is present, leave the DT alone */
err = mips_cm_probe(); if (!err && (read_gcr_gic_status() & CM_GCR_GIC_STATUS_EX)) return;
if (malta_scon() == MIPS_REVISION_SCON_ROCIT) { /* * On systems using the RocIT system controller a GIC may be * present without a CM. Detect whether that is the case.
*/
biu_base = ioremap(MSC01_BIU_REG_BASE,
MSC01_BIU_ADDRSPACE_SZ);
sc_cfg = __raw_readl(biu_base + MSC01_SC_CFG_OFS); if (sc_cfg & MSC01_SC_CFG_GICPRES_MSK) { /* enable the GIC at the system controller level */
sc_cfg |= BIT(MSC01_SC_CFG_GICENA_SHF);
__raw_writel(sc_cfg, biu_base + MSC01_SC_CFG_OFS); return;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.