zephyr/soc/adi/max32/soc.c
Maureen Helm 398d9e3d49 soc: adi: max32: Enable primary core to configure/start secondary core
Adds support for the primary m4 core to configure the boot address and
start the clock for the secondary risc-v core. Unlike the msdk which
defers this function to applications and requires users to copy/paste
code from an msdk example application into their own application, in
zephyr it is implemented in the common soc init routine of the primary
core. It can be enabled/disabled and configured with Kconfig symbols and
a devicetree chosen node, allowing applications to override board-level
defaults if desired using overlays instead of modifying zephyr code.

Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2025-01-29 17:55:32 +01:00

45 lines
939 B
C

/*
* Copyright (c) 2023-2024 Analog Devices, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief System/hardware module for MAX32xxx MCUs
*/
#include <zephyr/device.h>
#include <zephyr/init.h>
#include <wrap_max32_sys.h>
#ifdef CONFIG_MAX32_SECONDARY_RV32
#include <fcr_regs.h>
#endif
#if defined(CONFIG_MAX32_ON_ENTER_CPU_IDLE_HOOK)
bool z_arm_on_enter_cpu_idle(void)
{
/* Returning false prevent device goes to sleep mode */
return false;
}
#endif
/**
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
*/
void soc_early_init_hook(void)
{
/* Apply device related preinit configuration */
max32xx_system_init();
#ifdef CONFIG_MAX32_SECONDARY_RV32
MXC_FCR->urvbootaddr = CONFIG_MAX32_SECONDARY_RV32_BOOT_ADDRESS;
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_CPU1);
MXC_GCR->rst1 |= MXC_F_GCR_RST1_CPU1;
#endif /* CONFIG_MAX32_SECONDARY_RV32 */
}