Commit graph zephyr/drivers/sdhc
Author SHA1 Message Date
David Paul-Beier
e6852c851f drivers: sdhc: support Zynq-7000 in the Xilinx SDHC driver
Teach the Xilinx SDHC driver to also drive the Zynq-7000 PS SD/SDIO
controller (same Arasan 8.9a IP, one generation older). It binds to
"arasan,sdhci-8.9a", the compatible the Linux Zynq-7000 devicetree uses
for this controller.

The data transfer path is selected with Kconfig: XLNX_SDHC_ADMA2 or
XLNX_SDHC_PIO, which moves the data through the Buffer Data Port; the
unused path is compiled out. PIO is the default when a Zynq-7000
controller is enabled, as ADMA2 is not yet supported there. In PIO mode
the buffer-ready and transfer-complete events are taken from the
interrupt handler when the node has an interrupt, as the handler
acknowledges those status bits, and polled otherwise. The handler and
the signal-enable mask now also cover Buffer Write Ready.

Per-SoC differences come from the compatible:

- maximum SD clock: 208 MHz on Versal; 50 MHz on Zynq-7000, which has no
  PHY/tap-delay block and therefore no UHS modes.
- tap delay: the SD input/output tap-delay registers exist only on
  Versal. They lie outside the Zynq-7000 register window, so they are
  not programmed there when switching to High Speed.
- broken slot type: the Zynq-7000 Capabilities register reports an
  embedded slot although carriers wire a removable SD slot. The SD slot
  type is forced so the eMMC command-framing and power paths (which
  reject CMD8/R7 and assert the eMMC reset) are not taken.

A command without a data phase now writes Transfer Mode 0 rather than
leaving the data-transfer bits set. Zynq-7000 rejects the command
otherwise, and 0 is the spec-correct value.

struct reg_base is no longer __packed. A packed struct makes GCC split
the 16-bit interrupt-enable writes into byte stores, which the Zynq-7000
controller drops: status-enable stays 0, so Command-Complete never
latches. Every register is naturally aligned, so the layout does not
change; BUILD_ASSERTs check the offsets. The register interface is
32 bits wide and discards 64-bit accesses, so the three 64-bit registers
(Capabilities, Max Current Capabilities, ADMA System Address) are split
into lower and upper words that are accessed separately.

Tested on a Trenz TE0726 (Zynq-7000, PIO) with a 7.7 GB SDHC card, with
and without the interrupt line. The card comes up at 4-bit High Speed
(50 MHz). Single- and multi-block reads of several sectors, in
alternating order, match reference data written by independent code.
Single-block raw writes read back correctly, and a 66536-byte file
written through FatFs (single- and multi-block writes) reads back intact
after a remount and through an independent SD/FatFs implementation; the
other files on the card are unchanged. The Versal configuration was
built but not run on hardware.

Assisted-by: Claude:claude-opus-5.5
Signed-off-by: David Paul-Beier <david@paul-beier.de>
2026-10-28 22:38:00 -04:00
Yangbo Lu
e6c3abe724 drivers: sdhc: imx_usdhc: use standard driver APIs for host init
Converted imx_usdhc to use standard driver APIs for host properties
and capabilities init.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-10-28 22:27:14 -04:00
Yangbo Lu
3e7ff3e9b4 drivers: sdhc: add standard controller driver
Added standard controller driver per SD Specifications Part A2
SD Host Controller Simplified Specification (Version 3.00) which
matches current sdhc and sd subsystem features support.
It can be updated in the future for example to v4.20 if new
features are required to support.

For now, the driver provided standard registers definition and
access APIs, also provided a sdhc_standard_host_init API for host
properties/capabilities initialization.

Vendor drivers to reuse the standard host driver are required to
use sdhc_standard_host_common_config/sdhc_standard_host_common_data.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-10-28 22:27:14 -04:00
Yangbo Lu
36b4e6a14a drivers: sdhc: add common code
Added sdhc_common.c for common code. For now, it provided
only one common API, for SDHC device tree properties
initialization.

Vendor drivers can convert to use sdhc_common_config and
sdhc_common_dt_props_init API.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-10-28 22:27:14 -04:00
Yangbo Lu
49d9810342 drivers: sdhc: rename sdhc_helpers.h to sdhc_common.h
Renamed sdhc_helpers.h to sdhc_common.h for more usage
in the future. The SDHC needs a common c file for vendor
drivers reusing, and this file can be as its header file.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-10-28 22:27:14 -04:00
Mathieu Choplain
11d46e87bb drivers: sdhc: stm32: prevent enabling driver on incompatible series
The new SDHC API driver for the STM32 SDMMC IP does not work across the
entire family portfolio, as some series (STM32F1/F2/F4/F7/L1) and lines
(STM32L4; but not STM32L4+!) use a different IP from the one which this
driver was tested against. Prevent enabling the driver on such series
since it will not work properly, or in fact build at all, because the
peripheral is called "SDIO" instead of "SDMMC" on most of these series
and the HAL/LL namings follow suit.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-09-24 03:53:55 +02:00
Sara Touqan
5e650049b8 drivers: sdhc: stm32: add heap size for DMA buffer allocation
this commit adds HEAP_MEM_POOL_ADD_SIZE_SDHC_STM32_SDMMC with
a default value of 2048 bytes for sdhc driver.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
2026-09-24 03:52:31 +02:00
Duy Nguyen
37ff7a7f1b drivers: sdhc: Add support for SDIO command for Renesas RA
Add support for CMD5, CMD52, CMD53 for Renesas RA to support
SDIO mode
Add interrupt enable/disable API and support SDIO in-band interrupt
callback

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2026-09-17 07:48:46 -07:00
Kevin Chan
1f7a48fd50 drivers: sdhc: infineon: fix poll timeouts, clock settle and card_busy
Three correctness fixes for the Infineon SDHC driver:

- WAIT_FOR() takes a total timeout in microseconds, not a loop count.
  sdhc_host_poll_transfer_complete(), sdhc_poll_buf_read_ready() and the
  buffer-read-enable poll passed the raw retry count (1000 -> 1 ms), so
  slower cards timed out during the non-DMA PIO reads used by CMD6
  (SWITCH_FUNC) and ACMD51 (SEND_SCR), producing "Buffer read is not
  ready" and ACMD51 timeouts. Pass retries * per-iteration delay, matching
  sdhc_poll_cmd_complete(). Also drop the duplicate IFX_SDHC_RETRY_TIMES
  macro in favour of IFX_SDHC_RETRY_TIME.

- Add a clock-settle delay in sdhc_change_clock() after re-enabling the SD
  clock: 2000 us for the 400 kHz identification clock (cold bring-up) and
  500 us for later speed changes. Fixes intermittent cold-start CMD8
  failures where commands were issued before the divider settled.

- Restrict sdhc_infineon_card_busy() to the DAT[3:0] line level. The
  DAT_LINE_ACTIVE / CMD_INHIBIT_DAT present-state bits reflect host-side
  transfer activity and caused false-positive "busy" reporting, which
  breaks the CMD11 voltage-switch checks in the SD subsystem.

Signed-off-by: Kevin Chan <kevin.chan3@infineon.com>
2026-09-03 18:48:45 -04:00
Ryan Erickson
004ffb498e drivers: sdhc: imx_usdhc: add non-removable devicetree property
Some USDHC instances are permanently wired to a non-removable device,
such as an SDIO Wi-Fi module, with no card-detect GPIO or host
card-detect line available. Previously this relied on falling through
to the "no card detection method configured" warning path and assuming
the card was present. Add an explicit non-removable boolean property so
boards can declare this intent directly; when set, the driver reports
the card as always present and skips card detection.

Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2026-09-03 18:47:49 -04:00
Benjamin Cabé
5b4278c695 drivers: use inclusive SPI terminology in remaining drivers
Use controller/peripheral and SDO/SDI terminology in the remaining
SPI-using drivers (audio, auxdisplay, bluetooth HCI, dac, eeprom,
ethernet, flash, fpga, gpio, haptics, hdlc_rcp_if, ieee802154,
input, led, led_strip, lora, mfd, misc, mux, rtc, sdhc, stepper,
video, watchdog, wifi) and the ec_host_cmd SPI STM32 backend,
following coding guideline rule A.2: switch to
SPI_OP_MODE_CONTROLLER/PERIPHERAL and SPI_SDO_OVERRUN_DT, rename
Zephyr-owned identifiers (the HCI SPI header buffers, the winc1500
bus wrapper transfer parameters), and update comments, log messages
and Kconfig help prose.

Vendor and out-of-scope identifiers keep their names: STM32
LL_SPI_MODE_SLAVE in the ec_host_cmd backend, the ATWINC1500 SDK I2C
SLAVE_ADDRESS definition, and the I2S codec clock-role variable in
tlv320aic26.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-09-01 21:04:50 -04:00
Parthiban Nallathambi
870e496811 license: fix malformed SPDX-FileCopyrightText headers
Two-line copyright notices were wrapped in the SPDX "<text>...</text>"
construct, which is only valid in an SPDX document, not a file header.
The REUSE tool then folds the literal "<text>" into the holder name
and drops the second line from the SBOM.

Remove the markers and tag the continuation line. Holder, year and
e-mail are left unchanged; only the syntax is fixed.

Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
2026-09-01 16:25:23 -04:00
Camille BAUD
d87b17741f drivers: sdhc: Fix bouffalolab include path
The include path for the sdhc driver is wrong, fix it.

Signed-off-by: Camille BAUD <mail@massdriver.space>
2026-08-30 16:43:56 -04:00
Benjamin Cabé
d6c660d619 drivers: sdhc: sam_hsmci: Fix inverted byte mode in manual transfers
The aligned path clears FBYTE and computes a word count but set
byte_mode to true, and the unaligned path did the opposite, so
manual transfers moved a quarter of the data or overran the buffer
fourfold. Swap the two assignments to match the FBYTE setting.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-08-27 21:22:30 +01:00
Francois Ramu
3951c15271 drivers: sdhc: stm32: Fix R2 response data order
Fix the Byte order when receiving a R2 response from the SDcard.
It will give the correct Device Size depending on the CSD structure.
For standard capacity SDSC memory cards, CSD struct if Version 1.0.
For high capacity SDHC and SDXC memory cards, CSD struct is Version 2.0.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2026-08-20 08:09:58 -07:00
Sylvio Alves
2c3a8d29d5 drivers: sdhc: esp32: fix sd card init hang on command write
The sdmmc_ll_set_command helper writes the command register
through memcpy, which the compiler expands into four byte
stores. The peripheral bus only accepts 32-bit accesses, so
the command never reached the card interface unit and the
driver spun forever waiting for it to be taken.

Restore the single word store to the command register. This
is a regression from f4c7092ad6.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-08-19 17:11:57 +01:00
Takumi Ando
3ccde63baa drivers: sdhc: xlnx: Maintain DMA cache coherency
Perform the required cache maintenance before and after ADMA
transfers when the data cache is enabled.

Direct DMA read buffers must be aligned to the data cache line size because
invalidating a partial cache line may discard unrelated dirty data.

Use a cache-line-aligned bounce buffer for small reads whose transfer
size is not a multiple of the cache line size. This allows commands
such as the 4-byte MMC SEND_WRITE_PROT command to use ADMA safely.

Set the SDHC buffer alignment to the greater of the configured
data cache line size and the controller's minimum 32-byte
alignment requirement.

Signed-off-by: Takumi Ando <takumi@spacecubics.com>
2026-08-18 19:14:58 +01:00
Liam Ogletree
b74719a4bf drivers: shdc: Unify runtime PM log messages
Propagates #113545 to SHDC drivers.

Signed-off-by: Liam Ogletree <liam.ogletree@cirrus.com>
2026-08-13 16:21:09 -07:00
Hongquan Li
5208eac86a drivers: sdhc: fix R2 response order in intel_emmc_host and sam_hsmci
The Zephyr SD subsystem expects a 136-bit R2 response in
sdhc_command::response[4] with response[3] holding the most
significant 32 bits and response[0] holding the least significant
32 bits.

intel_emmc_host stored the 32-bit fragments in reverse order, so
resp3 (bits 127:96) was placed in response[0] and resp0 (bits 31:0)
in response[3]. Reverse the assignments.

sam_hsmci read the HSMCI_RSPR FIFO into response[3..0] in the order
the FIFO returns data, but that puts the most significant word in
response[0]. Read the FIFO into response[0..3] instead, matching the
Zephyr layout.

Fixes #112868

Signed-off-by: Hongquan Li <hongquan.li@processmission.com>
2026-08-09 17:43:11 -04:00
Anas Nashif
673151bee9 Revert "drivers: sdhc: set SDHC_INIT_PRIORITY to KERNEL_INIT_PRIORITY_DEVICE"
This reverts commit 713cdff118.

Build error:

ERROR: /soc/mmc@ee140000 <rcar_mmc_init> is initialized before its
  dependency /regulator_1p8v <regulator_fixed_init>
ERROR: ... /regulator_3p3v <regulator_fixed_init>

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-08-06 12:36:04 +02:00
Fin Maaß
713cdff118 drivers: sdhc: set SDHC_INIT_PRIORITY to KERNEL_INIT_PRIORITY_DEVICE
set the default of SDHC_INIT_PRIORITY to
KERNEL_INIT_PRIORITY_DEVICE, just like at the other
driver priorities.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-08-05 23:27:16 +01:00
Cesar Vandevelde
793fddcad5 drivers: sdhc: use K_MSGQ_DEFINE_STATIC_TYPE
This macro eliminates manual size/alignment management and prevents
namespace collisions by moving internal queues to file-private scope.

Signed-off-by: Cesar Vandevelde <cesar.vandevelde@gmail.com>
2026-08-04 18:46:53 +01:00
Sylvio Alves
f4c7092ad6 drivers: sdhc: esp32: use sdmmc ll functions
Replace direct SDMMC register accesses with the equivalent
sdmmc_ll_* low-level helpers from hal_espressif for interrupt
handling, controller and fifo reset, DMA setup, the command
engine, timeout configuration, card data-busy polling and
bus-width selection. The two duplicated local DMA helpers are
dropped in favor of sdmmc_ll_init_dma and sdmmc_ll_stop_dma.
Register accesses with no low-level equivalent (whole-register
interrupt-mask save, restore and set, and the response fifo
read) are left unchanged.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-08-04 06:52:20 -04:00
Sylvio Alves
6661d46a14 drivers: sdhc: esp32: quiet routine bus configuration logs
Every bus width, clock and timing change logged at info level, so
enumerating a card printed a dozen lines of routine progress on
any build with info logging on. An sdio peripheral on the second
slot doubles that.

Drop those messages to debug level. The error paths are
unchanged, so a failure still reports at its original level.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-08-04 06:52:20 -04:00
Sylvio Alves
a2a3910f29 drivers: sdhc: esp32: support two slots on one controller
Both slots are served by a single sdmmc controller: one register
block, one command engine, one dma channel and one interrupt
line. The driver kept that state per instance, so enabling a
second slot had the two fight over the shared registers and the
build asserted on more than one slot.

Move the controller-wide state into a shared struct and run the
bring-up once, on whichever slot initialises first. A controller
mutex serialises transactions across slots and records the owner,
so the interrupt handler routes completion events to the right
queue and the per-slot clock divider is reprogrammed through a
clock update command when the bus changes hands. Restore the
saved interrupt mask on every error path in the clock helper,
which previously left the mask blanked and killed the other
slot's interrupts.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-08-04 06:52:20 -04:00
Sylvio Alves
eebcedc85e drivers: sdhc: esp32: add sdio cmd53 and card interrupt support
The esp32 sdhc driver routed its slot pins directly and had
no path for block-mode CMD53 transfers or for the DAT1 card
interrupt, so an sdio card function could not be driven from
it.

Route the slot pins through the gpio matrix and add CMD53
block and byte transfers plus card interrupt enable and
disable, which an sdio client needs to move frames and to be
woken by the card. The card interrupt is masked in the
handler and re-armed by the consumer, so the enable and
disable helpers avoid sleeping primitives and stay callable
from the callback.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-08-04 06:52:20 -04:00
Fin Maaß
aabf691d12 drivers: cmake: remove redunant conditions
these drivers are already conditionally
included/added in drivers/CMakeLists.txt
so we dont' need another if.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-08-03 15:05:27 -04:00
Benjamin Cabé
ce02f6c10f drivers: sdhc: cdns: Invalidate the whole read buffer
After a read the cache invalidation only covered one block even
for multi-block transfers, leaving the remaining blocks to be read
from stale cache lines. Invalidate the full transfer size, which
matches the range flushed when the DMA descriptors are prepared.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-08-03 15:04:23 -04:00
Benjamin Cabé
61d23e2490 drivers: sdhc: ambiq: Release resources on async transfer timeout
The async completion timeout returned while still holding the
access mutex and the PM runtime reference, wedging the controller
for every subsequent request. Unlock and drop the reference before
returning.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-08-02 11:43:37 -04:00
Hongquan Li
11e1c506ef drivers: sdhc: ambiq: convert Zephyr response type enum to HAL bitmask
Convert cmd->response_type from a Zephyr enum sd_rsp_type value to the
Ambiq HAL's MMC_RSP_* bitmask via a new helper
ambiq_sdio_resp_type_to_hal(). The helper returns false on an
unrecognized response type and the caller propagates -EINVAL to fail
fast at the API boundary.

Remove the redundant CMD-index based ui32RespType overrides, keeping
only the bCheckBusyCmd handling for CMD6 and CMD38, which is a real
HAL-specific semantic not covered by the response type enum.

Also change the helper parameter type from enum sd_rsp_type to
uint32_t to match cmd->response_type, and add an explicit (int) cast
in the LOG_ERR format call.

Fixes zephyrproject-rtos#112220

Signed-off-by: Hongquan Li <hongquan.li@processmission.com>
2026-08-02 11:42:40 -04:00
Flavio Ceolin
5b0516f6fb drivers: sdhc: cdns: combine OR'd response type checks
(op & A) || (op & B) is equivalent to op & (A | B). Collapse the
RES_TYPE_SEL_48 / RES_TYPE_SEL_136 test into a single masked check.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-07-25 11:54:45 -07:00
Mathieu Choplain
0bec25a536 drivers: sdhc: stm32: enable GPIO if card-detect or power GPIOs are used
Enable the GPIO subsystem when cd-gpios or pwr-gpios are used on
any STM32 SDMMC node and the corresponding driver is enabled.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-07-15 15:26:33 +02:00
Fabrice DJIATSA
4a13365ab8 drivers: sdhc: stm32: add GPIO dependency for STM32 series
This is required since isn't no longer enabled by default.

Fix issue issue on GPIO API.

Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
2026-07-08 17:14:03 +01:00
Thomas Hebb
ec46c494a9 drivers: sdhc: imx_usdhc: revert Zephyr-side cache maintenance
NXP's USDHC SDK driver knows how to do its own cache maintenance and
does so on platforms that set HAS_MCUX_CACHE[1]. Recently, a copy of
that cache maintenance logic was added on the Zephyr side because
certain cores, like the Cortex-M33 of the i.MX RT1180, use an external
cache controller and instead set HAS_MCUX_XCACHE.

However, the Zephyr-side cache logic is buggy: it clobbers the response
data in cases when the SDK can't use DMA (specifically, when the RX
buffer isn't 4-byte aligned[2]): in those cases, the SDK code writes to
the buffer, those writes go to cache, then Zephyr invalidates the cache
discarding the written data.

NXP's SDK abstracts over different cache drivers just like Zephyr does,
so it's fine to enable its cache control for platforms with any type of
cache. Do that instead of reimplementing cache maintenance in Zephyr.

This partially reverts commit 0b8babdcc3 ("drivers: sdhc: imx_usdhc:
add cache maintenance on DMA path"), leaving only the new default value
for CONFIG_SDHC_BUFFER_ALIGNMENT.

[1] 2d8b1b1133/modules/hal_nxp/mcux/CMakeLists.txt (L140-L142)
[2] cddb388583/mcux/mcux-sdk-ng/drivers/usdhc/fsl_usdhc.c (L1343-L1346)

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
2026-07-06 10:27:10 +02:00
Jiafei Pan
8edca5b8df drivers: sdhc: imx_usdhc: fix VS18 flasg missing
In case of FSL_FEATURE_USDHC_HAS_NO_VS18 is definied,
kUSDHC_SupportV180Flag is not defined in fsl_usdhc.h, so it will has
compile issue, the fix is to make 1.8v support to be false in case of
FSL_FEATURE_USDHC_HAS_NO_VS18 is definied.

Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
2026-07-03 13:58:29 +02:00
Amneesh Singh
272fe35dbd drivers: sdhc: add TI AM654 SDHCI driver
Add the driver for TI's interrupt based AM654 SD Host Controller that can
be used with both eMMC and SD cards.

Signed-off-by: Amneesh Singh <amneesh@ti.com>
2026-07-01 14:31:30 -04:00
Hongquan Li
40c00ce2c5 drivers: sdhc: ambiq: fix R2 response word ordering
Fix R2 (CID/CSD) response ordering for the Ambiq SDHC driver.

The Ambiq HAL packs 136-bit R2 responses as a big-endian 128-bit
value with bits 127:96 in ui32Resp[0].  Zephyr's SD stack expects
cmd->response[3] to hold the highest 32 bits, matching the SDHCI
register layout used by other SDHC drivers.  The existing memcpy
therefore placed the response words in reverse order, causing
sdmmc_decode_csd() to read sector_count and block_size as zero.

Replace the memcpy with a conditional copy that reverses the word
order for R2 responses and clears the unused response words for
all other response types.

Fixes #111443

Signed-off-by: Hongquan Li <hongquan.li@processmission.com>
2026-06-30 06:47:19 -04:00
Sylvio Alves
c14efdbe7a drivers: sdhc: esp32: enable sdmmc source clock before selecting it
Acquire the SDMMC source clock with esp_clk_tree_enable_src() before
selecting it, so the host has a clock even when the ROM left that
reference-clock gate disabled.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-06-27 00:44:44 +02:00
Sylvio Alves
e6cdf6ce8a drivers: sdhc: esp32: program the data-in sampling phase
sdmmc_host_set_clk_div() enabled the sample clocks via
sdmmc_ll_init_phase_delay() but never programmed the data-in sampling
phase. On SoCs where that register powers up with a value that does not
sample the data lines correctly, reads return a 0x55/0xAA pattern, the
SCR decodes wrong and the card stays in 1-bit default speed where data
transfers fail. Program the nominal phase 0 after init so reads sample
correctly and high-speed/4-bit negotiation succeeds.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-06-27 00:44:44 +02:00
Sylvio Alves
8a87c07b5e drivers: sdhc: esp32: support sd erase commands
The command dispatch had no entries for the SD erase sequence, so
CMD32 returned -ENOTSUP and any erase request failed. Add the three
erase opcodes: CMD32 and CMD33 as addressed commands with an R1
response, and CMD38 with R1b plus SCF_WAIT_BUSY so the driver waits
for the card to finish erasing before returning.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-06-27 00:44:44 +02:00
Enoch Richbert Jebakumar
a1d29d07b1 drivers: sdhc: microchip: Add G1 SDHC Driver
Add G1 SDHC driver for Microchip SDHC Peripheral.

Signed-off-by: Enoch Richbert Jebakumar <enochrichbert.jebakumar@microchip.com>
2026-06-25 22:18:44 +01:00
Fin Maaß
25651127fc drivers: sdhc: intel: select PCIE
select PCIE if the controller is
on a pcie bus.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-06-19 22:39:12 +02:00
Thomas Hebb
9e7c3d7ece drivers: sdhc: imx_usdhc: Replace IMX_USDHC_NOCACHE_TAG with __nocache
These are both gated on CONFIG_NOCACHE_MEMORY and both place the symbol
in a non-cacheable section, so there's no reason to define our own
macro. The only difference is that __nocache uses a file-specific
section name, which helps with debugging but shouldn't affect
functionality.

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
2026-06-10 10:56:45 +02:00
Lucien Zhao
0b8babdcc3 drivers: sdhc: imx_usdhc: add cache maintenance on DMA path
When CONFIG_IMX_USDHC_DMA_SUPPORT is enabled, the USDHC ADMA2
engine DMAs to/from the data buffer supplied by upper layers
(e.g. FAT FS, SD subsystem) which lives in regular cacheable
RAM. Without explicit cache maintenance, on writes the
controller may DMA-read stale RAM while CPU writes are still
in D-cache, and on reads the CPU may consume stale cache lines
after the controller has DMA-written fresh data.

Flush the data buffer before each transfer (correct for TX,
and prevents later dirty-line eviction over DMA-written data
on RX) and invalidate after RX completes. Both scatter-gather
and non-scatter-gather paths are handled.

Raise SDHC_BUFFER_ALIGNMENT to DCACHE_LINE_SIZE when D-cache is
enabled so that DMA buffers (both upper-layer pass-through and
the SD subsystem fallback card_buffer) are cache-line aligned.
Without this, sys_cache_data_invd_range may operate on partial
cache lines and silently discard dirty data of adjacent
allocations sharing the head/tail line.

Fixes #107862

Signed-off-by: Lucien Zhao <lucien.zhao@nxp.com>
2026-06-09 11:55:27 +02:00
Thomas Hebb
dd329ad617 drivers: sdhc: Log SDIO timing mode in more drivers
rcar already had a function to map timing mode to a string. Move that
function into the shared header and use it from multiple drivers. Also
use a shared function to convert voltage to a string instead of open
coding it everywhere.

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
2026-06-08 19:00:27 +02:00
Sylvio Alves
2f7ab3fd4e drivers: sdhc: esp32: add esp32p4 support
Wire ESP32-P4 specific IOMUX paths and status register layout,
use the combined raw interrupt status field, and align the DMA
descriptors to the cache line for coherent flush and invalidate.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-06-03 18:27:15 -04:00
minyuan xue
39725a6068 drivers: sdhc: add ameba sdhc driver
Add realtek ameba sdhc driver.

Signed-off-by: minyuan xue <minyuan_xue@realsil.com.cn>
2026-06-01 18:00:55 -05:00
Amneesh Singh
9969745801 drivers: update interrupt handling to use "flags" instead of "sense"
Update all drivers to use "flags" instead of "sense" when accessing
interrupt properties from device tree. This aligns with the updated
interrupt controller bindings that now consistently use "flags" as
the cell name for the IRQ type field.

Signed-off-by: Amneesh Singh <amneesh@ti.com>
2026-06-01 12:38:26 -04:00
Shan Pen
a62bf26bd7 drivers: sdhc: renesas_ra: copy full CMD6 status
The RA SDHC driver handles SD_SWITCH/CMD6 through

r_sdhi_read_and_block(), then copies the returned status from the

FSP aligned buffer into the Zephyr request buffer.

CMD6 switch status is a 64-byte data block. The driver copied only

8 bytes, which is the SCR size used by ACMD51. This left byte 13

uninitialized or stale, so the SD core could read bus_speed as 0.

With bus_speed misread, the SD core skipped high-speed setup. Since

the current init flow switches to 4-bit width after high-speed setup,

ACMD6 bus-width switching was also skipped despite host and card

both advertising 4-bit support.

Copy ra_cmd.sector_size bytes instead, matching the requested data

block size. For CMD6 this preserves the full 64-byte switch status.

Signed-off-by: Shan Pen <bricle031@gmail.com>
2026-05-22 10:49:03 +02:00
Fin Maaß
7a0ffafec7 sdhc: litex: use dma-coherent dt prop
Use dma-coherent dt prop to determine, if
cache operations are needed before and after
DMA operations.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-05-18 15:19:28 +01:00