1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2026-01-01 01:41:18 +01:00

drivers: add periph_sdmmc support

This commit is contained in:
Gunar Schorcht 2023-06-08 09:51:28 +02:00
parent 7c320055a1
commit 556ef5235c
12 changed files with 3715 additions and 7 deletions

View File

@ -161,6 +161,7 @@ rsource "mtd_sdcard/Kconfig"
rsource "nvram/Kconfig"
rsource "nvram_spi/Kconfig"
rsource "sdcard_spi/Kconfig"
rsource "sdmmc/Kconfig"
endmenu # Storage Device Drivers
endmenu # Drivers

File diff suppressed because it is too large Load Diff

View File

@ -38,6 +38,21 @@ config HAVE_MTD_SDCARD
help
Indicates that a sdcard MTD is present
config HAVE_MTD_SDMMC_DEFAULT
bool
depends on HAS_PERIPH_SDMMC
imply MODULE_MTD_SDMMC if MODULE_MTD
imply MODULE_MTD_SDMMC_DEFAULT if MODULE_MTD
help
Indicates that a SD/MMC MTD is present with generic configuration
config HAVE_MTD_SDMMC
bool
depends on HAS_PERIPH_SDMMC
imply MODULE_MTD_SDMMC if MODULE_MTD
help
Indicates that a SD/MMC MTD is present
config HAVE_MTD_SPI_NOR
bool
imply MODULE_MTD_SPI_NOR if MODULE_MTD
@ -46,13 +61,13 @@ config HAVE_MTD_SPI_NOR
config HAVE_SAM0_SDHC
bool
imply MODULE_SAM0_SDHC if MODULE_MTD
imply MODULE_SAM0_SDHC if MODULE_MTD && !MODULE_MTD_SDMMC
help
Indicates that a SAM0 SD Host Controller MTD is present
config HAVE_MTD_SPI_MCI
bool
imply MODULE_MTD_MCI if MODULE_MTD
imply MODULE_MTD_MCI if MODULE_MTD && !MODULE_MTD_SDMMC
help
Indicates that a Multimedia Card Interface (MCI) MTD is present
@ -62,7 +77,7 @@ menuconfig MODULE_MTD
if MODULE_MTD
menu "MTD Interefaces"
menu "MTD Interfaces"
config MODULE_MTD_SPI_NOR
bool "MTD interface for SPI NOR Flash"
@ -95,22 +110,33 @@ config MODULE_MTD_MCI
depends on CPU_FAM_LPC23XX
select MODULE_MCI
config MODULE_MTD_SDCARD
bool "MTD interface for SPI SD-Card"
depends on MODULE_SDCARD_SPI
config MODULE_MTD_SDCARD_DEFAULT
bool "Use Generic SD card configuration"
depends on MODULE_MTD_SDCARD
help
Automatically create a MTD device and mount point for the SD card.
config MODULE_MTD_SDCARD
bool "MTD interface for SPI SD-Card"
depends on MODULE_SDCARD_SPI
config MODULE_MTD_SDMMC
bool "MTD interface for SD/MMC"
depends on HAS_PERIPH_SDMMC
select MODULE_PERIPH_SDMMC
config MODULE_MTD_SDMMC_DEFAULT
bool "Use Generic SD/MMC card configuration"
depends on MODULE_MTD_SDMMC
help
Automatically create a MTD device and mount point for the SD/MMC card.
config MODULE_MTD_EMULATED
bool "MTD interface for MTD emulated in RAM"
config MODULE_SAM0_SDHC
bool "MTD interface for SAM0 SD Host Controller"
depends on CPU_COMMON_SAM0
depends on CPU_COMMON_SAM0 && HAVE_SAM0_SDHC && !MODULE_PERIPH_SDMMC
endmenu # MTD Interfacs

View File

@ -153,6 +153,7 @@ config MODULE_PERIPH_INIT_RTT
default y if MODULE_PERIPH_INIT
depends on MODULE_PERIPH_RTT
rsource "Kconfig.sdmmc"
rsource "Kconfig.spi"
config MODULE_PERIPH_TEMPERATURE

View File

@ -0,0 +1,62 @@
# Copyright (c) 2020 HAW Hamburg
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
menuconfig MODULE_PERIPH_SDMMC
bool "SDIO/SD/MMC peripheral driver"
depends on HAS_PERIPH_SDMMC
select MODULE_PERIPH_COMMON
if MODULE_PERIPH_SDMMC
config MODULE_PERIPH_INIT_SDMMC
bool "Auto initialize SDIO/SD/MMC peripheral"
default y if MODULE_PERIPH_INIT
config MODULE_PERIPH_SDMMC_8BIT
bool "8 Bit data bus support"
depends on HAS_PERIPH_SDMMC_8BIT
default y
help
If the SDIO/SD/MMC peripheral supports the 8-bit bus width, it can be
used by enabling this option. If the option is disabled, the driver
requires less RAM and ROM.
config MODULE_PERIPH_INIT_SDMMC_8BIT
bool
depends on MODULE_PERIPH_SDMMC_8BIT
default y if MODULE_PERIPH_INIT
config MODULE_PERIPH_SDMMC_HS
bool "High speed access"
depends on HAS_PERIPH_SDMMC_HS
default y
help
If the SDIO/SD/MMC peripheral supports the high speed access, i.e. 50
MHz for SD and 52 MHz for MMC, it can be used by enabling this option.
If the option is disabled, the driver requires less RAM and ROM.
config MODULE_PERIPH_INIT_SDMMC_HS
bool
depends on MODULE_PERIPH_SDMMC_HS
default y if MODULE_PERIPH_INIT
config MODULE_PERIPH_SDMMC_AUTO_CLK
bool
depends on HAS_PERIPH_SDMMC_AUTO_CLK
default y
help
If the SDIO/SD/MMC peripheral supports the Auto-CLK feature, i.e.
the automatic activation and deactivation of the SD CLK signal,
it is enabled automatically by this option. Otherwise, the activation
and deactivation is controlled by SDIO/SD/MMC high-level functions.
config MODULE_PERIPH_INIT_SDMMC_AUTO_CLK
bool
depends on MODULE_PERIPH_SDMMC_AUTO_CLK
default y if MODULE_PERIPH_INIT
endif # MODULE_PERIPH_SDMMC

View File

@ -57,6 +57,9 @@
#ifdef MODULE_PERIPH_INIT_PIO
#include "periph/pio.h"
#endif
#ifdef MODULE_PERIPH_INIT_SDMMC
#include "sdmmc/sdmmc.h"
#endif
#endif /* MODULE_PERIPH_INIT */
void periph_init(void)
@ -133,5 +136,11 @@ void periph_init(void)
pio_start_programs();
#endif
#if defined(MODULE_PERIPH_INIT_SDMMC)
for (unsigned i = 0; i < SDMMC_NUMOF; i++) {
sdmmc_init(sdmmc_get_dev(i));
}
#endif
#endif /* MODULE_PERIPH_INIT */
}

22
drivers/sdmmc/Kconfig Normal file
View File

@ -0,0 +1,22 @@
# Copyright (c) 2020 HAW Hamburg
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
config MODULE_SDMMC
bool "SDIO/SD/MMC interface"
depends on HAS_PERIPH_SDMMC
select MODULE_PERIPH_SDMMC
select MODULE_ZTIMER_MSEC if !ZTIMER_USEC
if MODULE_SDMMC
config MODULE_SDMMC_MMC
bool "MMC support"
depends on HAS_PERIPH_SDMMC_MMC
help
Say y to support MMCs/eMMCs.
endif # MODULE_SDMMC

3
drivers/sdmmc/Makefile Normal file
View File

@ -0,0 +1,3 @@
MODULE = sdmmc
include $(RIOTBASE)/Makefile.base

View File

@ -0,0 +1,13 @@
FEATURES_REQUIRED += periph_sdmmc
FEATURES_OPTIONAL += periph_sdmmc_auto_clk
FEATURES_OPTIONAL += periph_sdmmc_auto_cmd12
FEATURES_OPTIONAL += periph_sdmmc_hs
ifneq (,$(filter sdmmc_mmc,$(USEMODULE)))
FEATURES_REQUIRED += periph_sdmmc_mmc
endif
ifeq (,$(filter ztimer_usec,$(USEMODULE)))
# enable ztimer_msec backend if ztimer_usec is not enabled
USEMODULE += ztimer_msec
endif

View File

@ -0,0 +1 @@
PSEUDOMODULES += sdmmc_mmc

1612
drivers/sdmmc/sdmmc.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -410,6 +410,55 @@ config HAS_PERIPH_RTT_OVERFLOW
help
Indicates that the RTT provides an overflow callback.
config HAS_PERIPH_SDMMC
bool
help
Indicates that an SDIO/SD/MMC peripheral is present and used by the
board. This feature shall be provided by the board configuration,
if available.
config HAS_PERIPH_SDMMC_8BIT
bool
help
Indicates that the SDIO/SD/MMC peripheral supports the 8-bit bus width
and at least one component of the board is connected with 8 data lines.
This feature shall be provided by the board configuration, if available.
config HAS_PERIPH_SDMMC_AUTO_CLK
bool
help
Indicates that the SDIO/SD/MMC peripheral supports the Auto-CLK
feature, i.e. the automatic activation and deactivation of the SD CLK
signal when required. This feature shall be provided by the MCU
if supported.
config HAS_PERIPH_SDMMC_AUTO_CMD12
bool
help
Indicates that the SDIO/SD/MMC peripheral supports the Auto-CMD12
feature, i.e. CMD12 is sent automatically to stop the transmission in
multiple block operations. This feature shall be provided by the MCU
if supported.
config HAS_PERIPH_SDMMC_CLK
bool
help
Indicates that the SDIO/SD/MMC peripheral has special clock
functionality used by the peripheral driver.
config HAS_PERIPH_SDMMC_HS
bool
help
Indicates that the SDIO/SD/MMC peripheral supports the high speed
access, that is 50 MHz for SD and 52 MHz for MMC. This feature shall be
provided by the MCU.
config HAS_PERIPH_SDMMC_MMC
bool
help
Indicates that the SDIO/SD/MMC peripheral supports MMC/eMMCs. This
feature shall be provided by the MCU.
config HAS_PERIPH_SPI
bool
help