diff --git a/exosphere/lp0fw/src/cluster.c b/exosphere/lp0fw/src/cluster.c index 0ffd20940..f29239502 100644 --- a/exosphere/lp0fw/src/cluster.c +++ b/exosphere/lp0fw/src/cluster.c @@ -23,6 +23,7 @@ #include "pmc.h" #include "misc.h" #include "i2c.h" +#include "flow.h" #include "sysreg.h" static void cluster_pmc_enable_partition(uint32_t mask, uint32_t toggle) { @@ -129,6 +130,9 @@ void cluster_initialize_cpu(void) { /* Disable clock to CL_DVFS */ CLK_RST_CONTROLLER_CLK_ENB_W_CLR_0 = 0x08000000; + /* Perform RAM repair if necessary. */ + flow_perform_ram_repair(); + /* TODO: This function is enormous */ } diff --git a/exosphere/lp0fw/src/flow.c b/exosphere/lp0fw/src/flow.c new file mode 100644 index 000000000..9fa847936 --- /dev/null +++ b/exosphere/lp0fw/src/flow.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include "utils.h" +#include "flow.h" + +void flow_perform_ram_repair(void) { + /* Perform repair only if not active cluster. */ + if (!(FLOW_CTLR_BPMP_CLUSTER_CONTROL_0 & 1)) { + /* Set REQ, to begin RAM repair. */ + FLOW_CTLR_RAM_REPAIR_0 = 1; + + /* Wait for STS to say RAM repair has completed. */ + while (!(FLOW_CTLR_RAM_REPAIR_0 & 2)) { } + } +} \ No newline at end of file diff --git a/exosphere/lp0fw/src/flow.h b/exosphere/lp0fw/src/flow.h index 559c79716..e0bd86ccd 100644 --- a/exosphere/lp0fw/src/flow.h +++ b/exosphere/lp0fw/src/flow.h @@ -26,6 +26,10 @@ #define MAKE_FLOW_REG(ofs) MAKE_REG32(FLOW_BASE + ofs) -#define FLOW_CTLR_HALT_COP_EVENTS_0 MAKE_FLOW_REG(0x004) +#define FLOW_CTLR_HALT_COP_EVENTS_0 MAKE_FLOW_REG(0x004) +#define FLOW_CTLR_RAM_REPAIR_0 MAKE_FLOW_REG(0x040) +#define FLOW_CTLR_BPMP_CLUSTER_CONTROL_0 MAKE_FLOW_REG(0x098) + +void flow_perform_ram_repair(void); #endif