/* 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;
}
}
/* 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;
}
/* 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) { /* *OnsystemsusingtheRocITsystemcontrolleraGICmaybe *presentwithoutaCM.Detectwhetherthatisthecase.
*/
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.