echoplayer: initialize I2C bus

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 4af17687959b7ae3929ddb95666a536ee6cc289c
Author: Aidan MacDonald <[email protected]>
Date:   Sun Feb 8 18:08:18 2026 +0000

    echoplayer: initialize I2C bus
    
    Change-Id: I159d1a2c97b02b5e7aa61452098b05d9d854dc89

diff --git a/firmware/SOURCES b/firmware/SOURCES
index fbd92742ba..16209d3f78 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1953,6 +1953,7 @@ target/arm/stm32/echoplayer/audiohw-echoplayer.c
 target/arm/stm32/echoplayer/backlight-echoplayer.c
 target/arm/stm32/echoplayer/button-echoplayer.c
 target/arm/stm32/echoplayer/clock-echoplayer.c
+target/arm/stm32/echoplayer/i2c-echoplayer.c
 target/arm/stm32/echoplayer/lcd-echoplayer.c
 target/arm/stm32/echoplayer/power-echoplayer.c
 target/arm/stm32/echoplayer/sdmmc-echoplayer.c
diff --git a/firmware/target/arm/stm32/echoplayer/clock-echoplayer.c b/firmware/target/arm/stm32/echoplayer/clock-echoplayer.c
index d42c12ae5f..f83314a2e6 100644
--- a/firmware/target/arm/stm32/echoplayer/clock-echoplayer.c
+++ b/firmware/target/arm/stm32/echoplayer/clock-echoplayer.c
@@ -165,6 +165,7 @@ INIT_ATTR static void init_periph_clock(void)
 {
     reg_writef(RCC_D1CCIPR, SDMMCSEL_V(PLL1Q));
     reg_writef(RCC_D2CCIP1R, SPI45SEL_V(HSE));
+    reg_writef(RCC_D2CCIP2R, I2C123SEL_V(HSI));
 
     /* Enable AXI SRAM in sleep mode to allow DMA'ing out of it */
     reg_writef(RCC_AHB3LPENR, AXISRAMEN(1));
@@ -203,3 +204,11 @@ const struct stm32_clock spi5_ker_clock = {
     .lpen_reg = ITA_RCC_APB2LPENR,
     .lpen_bit = BM_RCC_APB2ENR_SPI5EN,
 };
+
+const struct stm32_clock i2c1_ker_clock = {
+    .frequency = STM32_HSI_FREQ,
+    .en_reg = ITA_RCC_APB1LENR,
+    .en_bit = BM_RCC_APB1LENR_I2C1EN,
+    .lpen_reg = ITA_RCC_APB1LLPENR,
+    .lpen_bit = BM_RCC_APB1LENR_I2C1EN,
+};
diff --git a/firmware/target/arm/stm32/echoplayer/clock-echoplayer.h b/firmware/target/arm/stm32/echoplayer/clock-echoplayer.h
index e6f3624537..d75b294e93 100644
--- a/firmware/target/arm/stm32/echoplayer/clock-echoplayer.h
+++ b/firmware/target/arm/stm32/echoplayer/clock-echoplayer.h
@@ -28,5 +28,6 @@ void echoplayer_clock_init(void) INIT_ATTR;
 extern struct stm32_clock sdmmc1_ker_clock;
 extern struct stm32_clock ltdc_ker_clock;
 extern struct stm32_clock spi5_ker_clock;
+extern struct stm32_clock i2c1_ker_clock;
 
 #endif /* __CLOCK_ECHOPLAYER_H__ */
diff --git a/firmware/target/arm/stm32/echoplayer/i2c-echoplayer.c b/firmware/target/arm/stm32/echoplayer/i2c-echoplayer.c
new file mode 100644
index 0000000000..39cdea33ab
--- /dev/null
+++ b/firmware/target/arm/stm32/echoplayer/i2c-echoplayer.c
@@ -0,0 +1,50 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (C) 2026 by Aidan MacDonald
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "i2c-stm32h7.h"
+#include "clock-echoplayer.h"
+#include "nvic-arm.h"
+#include "regs/stm32h743/i2c.h"
+
+static const struct stm32_i2c_config i2c1_conf INITDATA_ATTR = {
+    .instance = ITA_I2C1,
+    .ker_clock = &i2c1_ker_clock,
+    .bus_freq_hz = 400000,
+    .scl_low_min_ns = 1300,
+    .scl_high_min_ns = 600,
+    .t_vd_dat_max_ns = 900,
+    .t_su_dat_max_ns = 100,
+    .rise_time_max_ns = 300,
+    .fall_time_max_ns = 300,
+};
+
+struct stm32_i2c_controller i2c1_ctl;
+
+void i2c_init(void)
+{
+    stm32_i2c_init(&i2c1_ctl, &i2c1_conf);
+    nvic_enable_irq(NVIC_IRQN_I2C1_EV);
+    nvic_enable_irq(NVIC_IRQN_I2C1_ER);
+}
+
+void i2c1_irq_handler(void)
+{
+    stm32_i2c_irq_handler(&i2c1_ctl);
+}
diff --git a/firmware/target/arm/stm32/echoplayer/i2c-echoplayer.h b/firmware/target/arm/stm32/echoplayer/i2c-echoplayer.h
new file mode 100644
index 0000000000..7b0ef57eeb
--- /dev/null
+++ b/firmware/target/arm/stm32/echoplayer/i2c-echoplayer.h
@@ -0,0 +1,28 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (C) 2026 by Aidan MacDonald
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef __I2C_ECHOPLAYER_H__
+#define __I2C_ECHOPLAYER_H__
+
+#include "i2c-stm32h7.h"
+
+extern struct stm32_i2c_controller i2c1_ctl;
+
+#endif /* __I2C_ECHOPLAYER_H__ */
diff --git a/firmware/target/arm/stm32/i2c-stm32h7.c b/firmware/target/arm/stm32/i2c-stm32h7.c
index 73435663c4..1d06290f03 100644
--- a/firmware/target/arm/stm32/i2c-stm32h7.c
+++ b/firmware/target/arm/stm32/i2c-stm32h7.c
@@ -306,8 +306,3 @@ void stm32_i2c_irq_handler(struct stm32_i2c_controller *ctl)
         }
     }
 }
-
-/* TODO: move to target */
-void i2c_init(void)
-{
-}
-- 
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.