diff options
| author | iabdalkader <i.abdalkader@gmail.com> | 2025-02-15 14:00:42 +0100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-04-09 00:22:32 +1000 |
| commit | 182b5f3a12427d3dc21744b0164d546663ea696b (patch) | |
| tree | 8745af5d5ba06d9f640b9f2189189d71f8231355 | |
| parent | b9e5f1ffba8551164374bf732aa165c87519a569 (diff) | |
alif/mpmetalport: Use MHU to notify remote cores.
Unlike HWSEM, the MHU IRQ can wake up cores from low-power modes, making it
better suited for notifying remote cores. Note that no special function is
required to wake up a remote coreāthe act of sending a message alone will
notify it.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
| -rw-r--r-- | ports/alif/mpmetalport.c | 31 | ||||
| -rw-r--r-- | ports/alif/mpmetalport.h | 14 |
2 files changed, 7 insertions, 38 deletions
diff --git a/ports/alif/mpmetalport.c b/ports/alif/mpmetalport.c index a7d402546..b0a017fdd 100644 --- a/ports/alif/mpmetalport.c +++ b/ports/alif/mpmetalport.c @@ -27,8 +27,6 @@ */ #include ALIF_CMSIS_H -#include "hwsem.h" - #include "py/mperrno.h" #include "py/mphal.h" @@ -36,18 +34,14 @@ #include "metal/utilities.h" #include "metal/device.h" +#include "se_services.h" + struct metal_state _metal; static mp_sched_node_t rproc_notify_node; int metal_sys_init(const struct metal_init_params *params) { metal_unused(params); - // Reset the hardware semaphore. - hwsem_reset(METAL_HSEM_DEVICE); - #if MICROPY_PY_OPENAMP_HOST - hwsem_reset(METAL_HSEM_REMOTE); - #endif - // If cache management is not enabled, configure the MPU to disable // caching for the entire Open-AMP shared memory region. #ifndef VIRTIO_USE_DCACHE @@ -59,18 +53,10 @@ int metal_sys_init(const struct metal_init_params *params) { #endif metal_bus_register(&metal_generic_bus); - - // Enable the hardware semaphore IRQ. - NVIC_ClearPendingIRQ(METAL_HSEM_IRQn); - NVIC_SetPriority(METAL_HSEM_IRQn, IRQ_PRI_HWSEM); - NVIC_EnableIRQ(METAL_HSEM_IRQn); return 0; } void metal_sys_finish(void) { - NVIC_DisableIRQ(METAL_HSEM_IRQn); - NVIC_ClearPendingIRQ(METAL_HSEM_IRQn); - hwsem_reset(METAL_HSEM_DEVICE); metal_bus_unregister(&metal_generic_bus); } @@ -99,15 +85,12 @@ void metal_machine_cache_invalidate(void *addr, unsigned int len) { } int metal_rproc_notify(void *priv, uint32_t id) { - // Release the HW semaphore to notify the other core. - hwsem_release(METAL_HSEM_REMOTE, HWSEM_MASTERID); + // Notify the remote core. + se_services_notify(); return 0; } -void METAL_HSEM_IRQ_HANDLER(void) { - // Schedule the node only if the other core released the Semaphore. - if (METAL_HSEM_DEVICE->HWSEM_REL_REG == 0) { - mp_sched_schedule_node(&rproc_notify_node, openamp_remoteproc_notified); - } - hwsem_request(METAL_HSEM_DEVICE, METAL_HSEM_REMOTE_ID); +void metal_rproc_notified(void) { + // The remote core notified this core. + mp_sched_schedule_node(&rproc_notify_node, openamp_remoteproc_notified); } diff --git a/ports/alif/mpmetalport.h b/ports/alif/mpmetalport.h index 7a428dbc6..c11725a1f 100644 --- a/ports/alif/mpmetalport.h +++ b/ports/alif/mpmetalport.h @@ -38,20 +38,6 @@ #define METAL_MAX_DEVICE_REGIONS 2 -#if MICROPY_PY_OPENAMP_HOST -#define METAL_HSEM_DEVICE ((HWSEM_Type *)HWSEM14_BASE) -#define METAL_HSEM_REMOTE ((HWSEM_Type *)HWSEM15_BASE) -#define METAL_HSEM_REMOTE_ID (0x410FD222U) -#define METAL_HSEM_IRQn HWSEM_IRQ14_IRQn -#define METAL_HSEM_IRQ_HANDLER HWSEM_IRQ14Handler -#else -#define METAL_HSEM_DEVICE ((HWSEM_Type *)HWSEM15_BASE) -#define METAL_HSEM_REMOTE ((HWSEM_Type *)HWSEM14_BASE) -#define METAL_HSEM_REMOTE_ID (0x410FD221U) -#define METAL_HSEM_IRQn HWSEM_IRQ15_IRQn -#define METAL_HSEM_IRQ_HANDLER HWSEM_IRQ15Handler -#endif - // Set to 1 to enable log output. #define METAL_LOG_HANDLER_ENABLE 0 |
