echoplayer: move system_init() out of generic stm32 code

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit eea0c128f48330850002f97ab589ab843f43a083
Author: Aidan MacDonald <[email protected]>
Date:   Fri Jan 16 14:35:57 2026 +0000

    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

diff --git a/firmware/target/arm/stm32/echoplayer/system-echoplayer.c b/firmware/target/arm/stm32/echoplayer/system-echoplayer.c
index c624569241..e2fb89e719 100644
--- a/firmware/target/arm/stm32/echoplayer/system-echoplayer.c
+++ b/firmware/target/arm/stm32/echoplayer/system-echoplayer.c
@@ -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));
+}
diff --git a/firmware/target/arm/stm32/system-stm32h7.c b/firmware/target/arm/stm32/system-stm32h7.c
index 410eab045a..06639664b3 100644
--- a/firmware/target/arm/stm32/system-stm32h7.c
+++ b/firmware/target/arm/stm32/system-stm32h7.c
@@ -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 */
diff --git a/firmware/target/arm/stm32/system-target.h b/firmware/target/arm/stm32/system-target.h
index 20a7621add..ac0fab226a 100644
--- a/firmware/target/arm/stm32/system-target.h
+++ b/firmware/target/arm/stm32/system-target.h
@@ -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);
 
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.