Skip to content

Commit c26526b

Browse files
drivers: disk: sdmmc_stm32: Add support for F1 series
Extend sdmmc driver to support the F1 series. This includes removing the RCC peripheral reset when building for F1 since this series doensn't have reset register for AHB peripherals. Therefore, it was neccesary to add an F1 specific compatible that removes the required resets property, as well as if-def the usage of reset in the device driver. Signed-off-by: Benjamin Björnsson <[email protected]>
1 parent 9146cd4 commit c26526b

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

drivers/disk/Kconfig.sdmmc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ config SDMMC_STM32
3737
select USE_STM32_HAL_MMC if SDMMC_STM32_EMMC
3838
select USE_STM32_HAL_MMC_EX if SDMMC_STM32_EMMC && SOC_SERIES_STM32L4X
3939
select USE_STM32_LL_SDMMC
40-
select USE_STM32_HAL_DMA if (SOC_SERIES_STM32L4X || SOC_SERIES_STM32F7X || SOC_SERIES_STM32F4X)
40+
select USE_STM32_HAL_DMA if (SOC_SERIES_STM32L4X || SOC_SERIES_STM32F7X || SOC_SERIES_STM32F4X || SOC_SERIES_STM32F1X)
4141
select DMA if $(DT_STM32_SDMMC_HAS_DMA) && (SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X)
4242
select PINCTRL
4343
select RESET

drivers/disk/sdmmc_stm32.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
LOG_MODULE_REGISTER(stm32_sdmmc, CONFIG_SDMMC_LOG_LEVEL);
2222

2323
#define STM32_SDMMC_USE_DMA DT_NODE_HAS_PROP(DT_DRV_INST(0), dmas)
24+
#define STM32_SDMMC_USE_RESET !DT_NODE_HAS_COMPAT(DT_DRV_INST(0), st_stm32f1_sdmmc)
2425

2526
#if STM32_SDMMC_USE_DMA
2627
#include <zephyr/drivers/dma.h>
@@ -84,7 +85,9 @@ struct stm32_sdmmc_priv {
8485
struct gpio_dt_spec pe;
8586
struct stm32_pclken *pclken;
8687
const struct pinctrl_dev_config *pcfg;
88+
#if STM32_SDMMC_USE_RESET
8789
const struct reset_dt_spec reset;
90+
#endif
8891

8992
#if STM32_SDMMC_USE_DMA
9093
struct sdmmc_dma_stream dma_rx;
@@ -302,11 +305,13 @@ static int stm32_sdmmc_access_init(struct disk_info *disk)
302305
return err;
303306
}
304307

308+
#if STM32_SDMMC_USE_RESET
305309
err = reset_line_toggle_dt(&priv->reset);
306310
if (err) {
307311
LOG_ERR("failed to reset peripheral");
308312
return err;
309313
}
314+
#endif
310315

311316
#ifdef CONFIG_SDMMC_STM32_EMMC
312317
err = HAL_MMC_Init(&priv->hsd);
@@ -690,10 +695,12 @@ static int disk_stm32_sdmmc_init(const struct device *dev)
690695
return -ENODEV;
691696
}
692697

698+
#if STM32_SDMMC_USE_RESET
693699
if (!device_is_ready(priv->reset.dev)) {
694700
LOG_ERR("reset control device not ready");
695701
return -ENODEV;
696702
}
703+
#endif
697704

698705
/* Configure dt provided device signals when available */
699706
err = pinctrl_apply_state(priv->pcfg, PINCTRL_STATE_DEFAULT);
@@ -812,7 +819,9 @@ static struct stm32_sdmmc_priv stm32_sdmmc_priv_1 = {
812819
#endif
813820
.pclken = pclken_sdmmc,
814821
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
822+
#if STM32_SDMMC_USE_RESET
815823
.reset = RESET_DT_SPEC_INST_GET(0),
824+
#endif
816825
SDMMC_DMA_CHANNEL(rx, RX)
817826
SDMMC_DMA_CHANNEL(tx, TX)
818827
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2024 Benjamin Björnsson [email protected]
2+
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
description: |
6+
ST STM32F1 family SDIO
7+
Remove the resets property since there's no reset register
8+
for AHB peripherals on F1 series.
9+
10+
compatible: "st,stm32f1-sdmmc"
11+
12+
include:
13+
- name: st,stm32-sdmmc.yaml
14+
property-blocklist:
15+
- resets

0 commit comments

Comments
 (0)