echoplayer: move system_init() out of generic stm32 code

With only one target, it doesn't make sense to have a
common system_init() yet.

Change-Id: I0f6d37709d60bb309fb16ecb9b0870297a189cc4
This commit is contained in:
Aidan MacDonald 2026-01-16 14:35:57 +00:00
parent 386be9dfcc
commit eea0c128f4
3 changed files with 35 additions and 43 deletions

View file

@ -19,9 +19,12 @@
*
****************************************************************************/
#include "system.h"
#include "button.h"
#include "clock-stm32h7.h"
#include "gpio-stm32h7.h"
#include "regs/stm32h743/rcc.h"
#include "regs/stm32h743/fmc.h"
#include "regs/stm32h743/rcc.h"
#include "regs/cortex-m/cm_scb.h"
#define F_INPUT GPIOF_INPUT(GPIO_PULL_DISABLED)
#define F_INPUT_PU GPIOF_INPUT(GPIO_PULL_UP)
@ -117,7 +120,7 @@ static const struct pingroup_setting pingroups[] = {
STM_DEFPINS(GPIO_I, 0x06e7, F_LCD_AF14),
};
void gpio_init(void)
INIT_ATTR static void gpio_init(void)
{
/* Enable clocks for all used GPIO banks */
reg_writef(RCC_AHB4ENR,
@ -135,7 +138,7 @@ void gpio_init(void)
pingroups, ARRAYLEN(pingroups));
}
void fmc_init(void)
INIT_ATTR static void fmc_init(void)
{
/* configure clock */
reg_writef(RCC_D1CCIPR, FMCSEL_V(AHB));
@ -181,3 +184,32 @@ void fmc_init(void)
*/
reg_writef(FMC_SDRTR, REIE(0), COUNT(917), CRE(0));
}
void system_init(void)
{
/* Set vector table address */
extern char __vectors_arm[];
reg_var(CM_SCB_VTOR) = (uint32_t)__vectors_arm;
#if defined(DEBUG)
system_debug_enable(true);
#endif
/* Enable CPU cache */
stm32_enable_caches();
/* Initialize system clocks */
stm_clock_init();
/* Enable systick early due to udelay() needed for FMC init */
stm32_systick_enable();
/* Configure GPIOs and start FMC */
gpio_init();
fmc_init();
}
void system_exception_wait(void)
{
while (button_read_device() != (BUTTON_POWER | BUTTON_START));
}

View file

@ -49,9 +49,6 @@
static uint32_t systick_per_ms = CPUFREQ_TO_SYSTICK_PER_MS(CPUFREQ_INITIAL);
static uint32_t systick_interval_in_ms = SYSTICK_INTERVAL_INITIAL;
/* Base address of vector table */
extern char __vectors_arm[];
void stm32_enable_caches(void)
{
__discard_idcache();
@ -101,30 +98,6 @@ void stm32_systick_disable(void)
reg_writef(CM_SYSTICK_CSR, ENABLE(0), TICKINT(0));
}
void system_init(void)
{
#if defined(DEBUG)
system_debug_enable(true);
#endif
/* Ensure IRQs are disabled and set vector table address */
disable_irq();
reg_var(CM_SCB_VTOR) = (uint32_t)__vectors_arm;
/* Enable CPU caches */
stm32_enable_caches();
/* Initialize system clocks */
stm_clock_init();
/* Initialize systick */
stm32_systick_enable();
/* Call target-specific initialization */
gpio_init();
fmc_init();
}
void system_debug_enable(bool enable)
{
/*
@ -185,15 +158,6 @@ void udelay(uint32_t us)
}
}
void system_exception_wait(void)
{
#if defined(ECHO_R1)
while (button_read_device() != (BUTTON_POWER | BUTTON_START));
#else
while (1);
#endif
}
int system_memory_guard(int newmode)
{
/* TODO -- maybe use MPU here to give some basic protection */

View file

@ -40,10 +40,6 @@ void stm32_systick_set_cpu_freq(uint32_t freq);
/* Enable/disable debug clock domain during sleep mode. */
void system_debug_enable(bool enable);
/* Implemented by the target -- can be a no-op if not needed */
void gpio_init(void) INIT_ATTR;
void fmc_init(void) INIT_ATTR;
/* Busy loop delay based on systick */
void udelay(uint32_t us);