summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2021-02-06 12:38:55 -0700
committerGitHub <noreply@github.com>2021-02-06 12:38:55 -0700
commitaf7847795c9096067c976901a6149350534ae42c (patch)
tree424151cc3ba60c44b2c9ff311cb2666030b44a27
parentf96664d95bc3654ae719df2d8143a1195267d471 (diff)
downloadbcm5719-ortega-af7847795c9096067c976901a6149350534ae42c.tar.gz
bcm5719-ortega-af7847795c9096067c976901a6149350534ae42c.zip
ape: Switch from polling to interrupts for vmain state changes. (#207)
-rw-r--r--ape/main.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/ape/main.c b/ape/main.c
index 4846f00..f0dc6d5 100644
--- a/ape/main.c
+++ b/ape/main.c
@@ -250,18 +250,23 @@ void handleBMCPacket(void)
}
}
-void checkSupply(void)
+void __attribute__((interrupt)) IRQ_VoltageSource()
{
- if (NVIC.InterruptClearPending.r32 & NVIC_INTERRUPT_CLEAR_PENDING_CLRPEND_VMAIN)
- {
- NVIC.InterruptClearPending.r32 = NVIC_INTERRUPT_CLEAR_PENDING_CLRPEND_VMAIN;
+ NVIC.InterruptClearPending.r32 = NVIC_INTERRUPT_CLEAR_PENDING_CLRPEND_VMAIN;
- printf("Power State Changed.\n");
+ NetworkPort_t *port = gPort;
- wait_for_all_rx();
- RMU_init();
- NCSI_reload(AS_NEEDED);
+ if (port->device->Status.bits.VMAINPowerStatus)
+ {
+ printf("Vsrc: Main\n");
+ }
+ else
+ {
+ printf("Vsrc: Aux\n");
}
+
+ // Ensure we reinitialize hardware as needed.
+ gResetOccurred = true;
}
void __attribute__((interrupt)) IRQ_PowerStatusChanged(void)
@@ -319,8 +324,8 @@ void __attribute__((noreturn)) loaderLoop(void)
initSHM(&SHM2);
initSHM(&SHM3);
- // Enable GRC Reset / Power Status Changed interrupt
- NVIC.InterruptSetEnable.r32 = NVIC_INTERRUPT_SET_ENABLE_SETENA_GENERAL_RESET;
+ // Enable GRC Reset / Power Status Changed and Vsrc interrupts
+ NVIC.InterruptSetEnable.r32 = NVIC_INTERRUPT_SET_ENABLE_SETENA_VMAIN | NVIC_INTERRUPT_SET_ENABLE_SETENA_GENERAL_RESET;
for (;;)
{
@@ -357,7 +362,6 @@ void __attribute__((noreturn)) loaderLoop(void)
handleCommand(&SHM1);
handleCommand(&SHM2);
handleCommand(&SHM3);
- checkSupply();
if (host_state != SHM.HostDriverState.bits.State)
{
@@ -480,8 +484,6 @@ void __attribute__((noreturn)) __start()
NCSI_usePort(gPort);
- checkSupply();
-
RMU_init();
if (full_init)
OpenPOWER on IntegriCloud