Commit graph

150 commits

Author SHA1 Message Date
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
Mohammad Odeh
914678e717 drivers: sdhc: add support for reading EXT_CSD from MMC cards
- Add sdhc_stm32_mmc_read_ext_csd() to perform MMC EXT_CSD reads
- Add MMC_SEND_OP_COND to request handling
- Handle SD_SWITCH/MMC_SWITCH distinction

Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-18 10:20:46 +01:00
Sara Touqan
f794886ba7 drivers: sdhc: stm32: fix unused variable warning
This commit fixes #108916
It wraps assert variables in CONFIG_ASSERT to avoid
unused variable warnings when assertions are disabled.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
2026-05-15 12:58:01 +02:00
Sara Touqan
c7bfe425d8 drivers: sdhc: stm32: use SDMMC_HALFFIFOBYTES for half FIFO transfers
this commit replaces SDMMC_FIFO_SIZE usages related to
RXFIFOHF/TXFIFOHE handling with SDMMC_HALFFIFOBYTES.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
2026-05-13 19:00:41 +01:00
Sara Touqan
761b0e0fcd drivers: sdhc: stm32: fix buffer handling in FIFO read/write
This commit fixes #108757.
It adds NULL pointer checks in FIFO read/write functions to avoid crashes
and fixes buffer offset handling in the switch speed path.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
2026-05-13 19:00:41 +01:00
Davide Di Lello
82741b2614 drivers: infineon: Update copyright for Infineon
Update structure of the copyright

Signed-off-by: Davide Di Lello <Davide.Dilello@Infineon.com>
2026-05-12 22:19:02 +02:00
Camille BAUD
4acfc0039b drivers: sdhc: Introduce BFLB SDHC driver
Introduce Bouffalolab SDHC. Applies to BL61x currently.

Co-authored-by: William Markezana <william.markezana@gmail.com>
Signed-off-by: Camille BAUD <mail@massdriver.space>
2026-05-11 04:02:01 +02:00
Mohammad Odeh
a98f0fdba2 drivers: sdhc: stm32: add SDMMC support using LL-implementation
Extend the STM32 SDHC driver to support SD memory cards in
addition to SDIO. This adds handling for the following commands:
- SD_SEND_IF_COND (CMD8)
- SD_APP_CMD (CMD55)
- SD_APP_SEND_OP_COND (ACMD41)
- SD_ALL_SEND_CID (CMD2)
- SD_SEND_CSD (CMD9)
- SD_APP_SEND_SCR (ACMD51)
- SD_SET_BLOCK_SIZE (CMD16)
- SD_READ_SINGLE_BLOCK/SD_READ_MULTIPLE_BLOCK (CMD17/CMD18)
- SD_WRITE_SINGLE_BLOCK/SD_WRITE_MULTIPLE_BLOCK (CMD24/CMD25)
- SD_ERASE_BLOCK_START/END/OPERATION (CMD32/CMD33/CMD38)
- SD_SWITCH (CMD6)
- SD_SEND_STATUS (CMD13)

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
Signed-off-by: Sarah Younis <zephyr@exalt.ps>
Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Mohammad Odeh
a1a60fc99c drivers: sdhc: stm32: replace HAL_SDIO with LL-based implementation
Replace STM32 HAL SDIO API calls with custom LL-based wrapper
functions. This removes the dependency on the STM32 HAL SDIO driver.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
Signed-off-by: Sarah Younis <zephyr@exalt.ps>
Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Mohammad Odeh
75ddd2276c drivers: sdhc: stm32: Rename SDHC polling config option
Renamed the Kconfig and code references from SDHC_STM32_POLLING_SUPPORT
to SDHC_STM32_DMA_MODE for clarity.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
Signed-off-by: Sarah Younis <zephyr@exalt.ps>
Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Sara Touqan
766e06adb4 drivers: sdhc: stm32: drop 1.8V support check
Remove 1.8V capability check from
sdhc_stm32_switch_to_1_8v() since this
validation is expected to be handled by
zephyr subsystem.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Mohammad Odeh
59ffd1269e drivers: sdhc: stm32: use data timeout for rw_extended
Replace CONFIG_SD_CMD_TIMEOUT with the actual timeout value
from the sdhc_data structure (data->timeout_ms) for waiting
on DMA completion semaphore.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
Signed-off-by: Sarah Younis <zephyr@exalt.ps>
Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Mohammad Odeh
ff7d4a207f drivers: sdhc: stm32: refactor error logging
- Replace multiple individual if statements in sdhc_stm32_log_err_type()
with a static const array of error masks and messages.
- Add some error log messages to improve visibility of SDMMC error
conditions.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
Signed-off-by: Sarah Younis <zephyr@exalt.ps>
Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Mohammad Odeh
e073330766 drivers: sdhc: stm32: Refactor SDMMC ISR
- Extracted SDMMC interrupt flag clearing into a new helper function.
- Enhanced the event ISR to log errors, call error logging helpers.
- Deferred PM release to ISR only when a DMA-based command is
  successfully launched

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
Signed-off-by: Sarah Younis <zephyr@exalt.ps>
Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Mohammad Odeh
09453bb181 drivers: sdhc: stm32: refactor request error handling and code organization
- Consolidate sdmmc_res error handling into a single check
  at the end of the switch block, removing redundant per-case checks
- Rename goto label 'out' to 'end' in sdhc_stm32_set_io()
- Move DEVICE_API definition after sdhc_stm32_init() for better
  code organization

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
Signed-off-by: Sarah Younis <zephyr@exalt.ps>
Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Mohammad Odeh
1c811ecd8b drivers: sdhc: stm32: improve code formatting
Fix whitespace, indentation, and alignment issues throughout
the driver

Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Mohammad Odeh
81626ed71d drivers: sdhc: stm32: remove unused cmd_index from data struct
Remove unused cmd_index from sdhc_stm32_data structure

Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Mohammad Odeh
3ddfec7912 drivers: sdhc: stm32: remove card reset from host reset function
The reset function should reset the host controller only, not the card.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
Signed-off-by: Sarah Younis <zephyr@exalt.ps>
Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Mohammad Odeh
0773400548 drivers: sdhc: stm32: simplify card presence detection
When no CD GPIO is configured, assume the card is present instead
of sending commands to probe, to avoids sending unexpected commands
that the SD subsystem doesn't expect.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
Signed-off-by: Sarah Younis <zephyr@exalt.ps>
Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Mohammad Odeh
e6998c7496 drivers: sdhc: stm32: fix PM device registration in DEVICE_DT_INST_DEFINE
The PM_DEVICE_DT_INST_GET macro was defined but not passed to
DEVICE_DT_INST_DEFINE, meaning PM callbacks were not properly
registered.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
Signed-off-by: Sarah Younis <zephyr@exalt.ps>
Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-05-07 18:03:20 -05:00
Zhaoxiang Jin
8cef371272 sdhc: imx_usdhc: add reset controller support
Add optional devicetree reset support to the i.MX USDHC
driver and deassert the reset line before controller
initialization.

Keep existing behavior unchanged when no reset is described.

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2026-05-01 09:42:15 +02:00
Lucien Zhao
c8512077b8 drivers: sdhc: imx_usdhc: support no-3-3-v and no-3-0-v voltage options
Add support for the no-3-3-v and no-3-0-v devicetree properties in the
IMX USDHC driver. When both are set, the driver overrides the host
capability flags to disable 3.3V and 3.0V support, and sets the USDHC
VSELECT bit at init time to configure the data line sampling threshold
for 1.8V I/O without triggering the SD voltage switch protocol.

Update the reset function to respect the voltage configuration: when
both no-3-3-v and no-3-0-v are set, the reset path now restores 1.8V
signaling instead of unconditionally switching to 3.3V, ensuring correct
behavior after card re-initialization on fixed 1.8V I/O boards.

This is required for boards like the MIMXRT700-EVK where the USDHC1
I/O voltage domain (VDDIO_0) is fixed at 1.8V.

Signed-off-by: Lucien Zhao <lucien.zhao@nxp.com>
2026-04-24 12:59:09 +02:00
Fabian Blatz
04cfca3141 drivers: sdhc: sam_hsmci: Initialize variables in sam_hsmci_request_inner
Initialize `transfer_count`, `is_write`, and `byte_mode` variables to
prevent potential use of uninitialized variables.

Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
2026-04-19 16:44:56 +01:00
Fabian Otto
289ea35e30 drivers: sdhc: mcux_sdif: optional GPIO card-detect via cd-gpios
When present, configure the pin as input and use GPIO for card presence
instead of SDIF_DetectCardInsert(). Useful if the board uses a pin other
than SD0_CARD_DET_N for card detection.

On the LPC55S28 we needed it to work around an issue where configuring
PIO1_13 as SD0_CARD_DET_N stalled Flexcomm6 I2C transfers. The same pin
works when muxed as GPIO.

Signed-off-by: Fabian Otto <fabian.otto@rohde-schwarz.com>
2026-04-17 12:34:45 +01:00
Hake Huang
8c036b2ae8 drivers: sdhc: remove unused fsl_cache.h include from imx_usdhc
imx_usdhc.c does not use any symbols from fsl_cache.h, and
fsl_usdhc.h does not require it transitively.

Remove the unused include to avoid build failures on targets where
the cache HAL header is not available, such as MCXN947 CPU1 virtual
board builds.

Signed-off-by: Hake Huang <hake.huang@nxp.com>
2026-04-16 10:12:21 +02:00
Chun-Chieh Li
090564c80a drivers: sdhc: numaker: support NuMaker M55M1X SDHC
Add support for Nuvoton NuMaker M55M1X SD host controller

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-04-14 22:16:29 -04:00
Pisit Sawangvonganan
4f9a85e80a drivers: fix typo in (rtc, sdhc, sensor)
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `drivers/rtc`
- `drivers/sdhc`
- `drivers/sensor`

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-03-27 20:21:24 -04:00
Sylvio Alves
c64a74e711 espressif: adapt to hal_espressif IDF master sync
Adapt all Espressif SoC and driver code to the updated
hal_espressif module synced with IDF master branch.

Main changes:
- clock control: delegate peripheral clock gating to HAL
  layer using new clock/reset APIs
- SPI/GDMA: adapt to restructured DMA HAL with new channel
  allocation and configuration interfaces
- ethernet: add RMII clock configuration and PHY management
- GPIO: simplify using direct HAL function calls
- flash: adapt to updated SPI flash HAL interfaces
- linker scripts: update IRAM/DRAM mappings for new HAL
  object files
- DTS: fix ESP32-S2 PSRAM dcache1 address to match actual
  MMU mapping region (0x3f800000 DRAM1 instead of 0x3f500000
  DPORT which lacks 8-bit access capability)
- west.yml: update hal_espressif revision

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-03-13 11:38:18 +01:00
Fin Maaß
068569a268 drivers: sdhc: litex: add litesdcard driver
add litex litesdcard driver.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-10 12:33:41 +01:00
Jack Lee
a6e71a4861 drivers: sdhc: add support for cmd52 and cmd53 commands
Currently, the Xilinx SDHC driver does not support data
transmission with SDIO devices, requiring the addition
of CMD52 and CMD53 related functionalities.

Signed-off-by: Jack Lee <lhjhit@126.com>
2026-02-26 16:53:26 +00:00
Mathieu Choplain
a11688fab5 drivers: *: stm32: don't check if clock device is ready
If the clock device (i.e., RCC) failed to initialize, we have bigger
problems than trying to call clock_control_{off,on,configure} on it.
Don't bother checking to save some footprint.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-13 18:59:16 +00:00
Gaetan Perrot
c0e8822a94 drivers: sdhc: renesas_ra: remove dead error check
Remove a dead error check which check ret but ret wasn't even
assigned before the test.

Remove the useless condition to make the intent explicit and clean
up the code.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-02-06 22:19:52 +01:00
Kevin Chan
7c1725b949 drivers: wifi: change WIFI_INIT_PRIORITY value
Wifi chip module may depend on SDHC(SDIO) module.
Currnetly, default init. priority is
CONFIG_WIFI_INIT_PRIORITY(80) & CONFIG_SDHC_INIT_PRIORITY(85).
It causes the issue.

Signed-off-by: Kevin Chan <kevin.chan3@infineon.com>
2026-01-28 08:30:56 +01:00
Thomas Hebb
477568a2ae drivers: sdhc: imx_usdhc: Automatically mask SDIO interrupt
There are currently two other sdhc drivers that support this interrupt:
Infineon and Ambiq. Both those vendor HALs automatically mask the
interrupt after invoking the callback[1][2], expecting the user to
unmask it asynchronously once they've cleared the card's interrupt
condition.

The NXP usdhc driver doesn't do this and so is inconsistent with the
other two. This has caused bugs with higher-level drivers, such as the
AIROC Wi-Fi driver (#101100). Fix the issue by masking the interrupt
ourselves.

[1] 470f874ce4/mtb-hal-cat1/source/cyhal_sdhc.c (L1251-L1260)
[2] 5efc022852/mcu/apollo510/hal/mcu/am_hal_sdhc.c (L2256)

Fixes #101100

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
2026-01-27 08:06:52 +01:00
John Batch
594dc62f8e drivers: infineon: sdhc: adds clock assignment to sdhc device init
Adds making a peripheral clock connection to the initialization for
SDHC.  Other updates to use the clk_dst field from the binding.

Signed-off-by: John Batch <john.batch@infineon.com>
2026-01-27 08:06:28 +01:00
Amneesh Singh
03ba08615a drivers: sdhc: split caps into standard and extra
Make sure the capability bitfields fit the standard SD Association
specification and move the extra capabilities to props.

Affected Drivers:
- sdhc_infineon
- imx_usdhc
- intel_emmc_host
- rcar_mmc
- sam_sdmmc
- sdhc_ambiq
- sdhc_esp32
- sdhc_max32
- sdhc_renesas_ra
- sdhc_stm32
- xlnx_sdhc

Affected Subsys
- sd

Reference: 2.2.26, SD Specifications, Part A2, SD Host Controller
           Simplified Specification, Version 4.20
           URL: https://www.sdcard.org/downloads/pls/pdf/?p=PartA2_SD%20Host_Controller_Simplified_Specification_Ver4.20.jpg

Signed-off-by: Amneesh Singh <amneesh@ti.com>
2026-01-26 13:53:51 -06:00
Kevin Chan
0c950801d3 drivers: sdhc: add SDHC driver for PSE84 & cy8cproto_062_4343w
- add SDHC driver code to support both SDMMC and SDIO fucntion
- add SDHC dts node and Kconfig
- add clock configuration for SDHC

Signed-off-by: Kevin Chan <kevin.chan3@infineon.com>
2026-01-23 10:41:07 +01:00
Thomas Hebb
21cd98a5e1 drivers: sdhc: imx_usdhc: Extend all reset timeouts
commit bf61a47887 ("drivers: sdhc: imx_usdhc: extend reset timeout
duration") extended the timeout from 100 iterations to 1000 iterations
for the USDHC_Reset() call in imx_usdhc_reset() but not in the other
places it's called. I have observed a "usdhc: Failed to reset command
line" error from imx_usdhc_error_recovery() on an i.MX RT1061, which
goes away if I extend the timeout. Do so there and also at other call
sites for good measure.

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
2026-01-19 10:03:39 +01:00
Ibrahim Abdalkader
ca6aed203c drivers: sdhc: stm32: skip semaphore wait on HAL error
When HAL_SDIO_WriteExtended_DMA or HAL_SDIO_ReadExtended_DMA returns
an error, interrupts are not enabled so the semaphore would never be
given, and it will always timeout.

Some drivers expect certain functions to fail during normal operation.
For example, WHD calls whd_kso_enable during sleep/wakeup cycles which
can fail. This would waste 200ms (CONFIG_SD_CMD_TIMEOUT default) on
every such failure.

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
2026-01-05 17:16:36 +00:00
Maochen Wang
a8137baf65 drivers: sdhc: imx_usdhc: add retry for DAT3 card detection
DAT3-based card detection can return a false negative on the first read
due to transient signal states after enabling detection. Add a bounded
retry loop (limited by IMX_USDHC_DAT3_DETECT_RETRY) with a short delay
between attempts to improve robustness.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2025-12-26 10:17:10 -06:00
Yangbo Lu
c3a3c2bd99 drivers: sdhc: imx_usdhc: support scatter gather DMA transfer
Supported scatter gather DMA transfer.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-12-23 05:04:25 +01:00
Yangbo Lu
f45e1d528b drivers: sdhc: introduce scatter gather transfer support
Introduced scatter gather transfer support.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-12-23 05:04:25 +01:00
Sreeram Tatapudi
0a06f5b91a dts: bindings: Drop cat1 from the infineon binding files
Drop cat1 from the binding files to enable reuse by other
category devices as well.

Fixes #99174

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2025-12-17 13:58:09 -05:00
Sreeram Tatapudi
5ecf248ba3 drivers: infineon: Drop cat1 from the files names
Drop cat1 from the file names to enable reuse by other
category devices as well

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2025-12-07 21:19:38 -05:00
Josuah Demangeon
30950b888d style: drivers: sort Kconfig and CMake includes
Use the "zephyr-keep-sorted-start/stop" comment to have CI check
the alphabetical order of includes, to help reducing the chance
of conflicts while contributing drivers.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-11-17 13:48:03 -05:00
Siddhant Modi
904e34c41a drivers: sdhc: sdhc_spi: Adding support for cd_gpio
1. This commit adds support for the cd-gpios property
   to the dts binding for the sdhc_spi driver.
2. The _init function is updated to initialize the GPIO
   pin if it is found.
3. The _get _card_present function is updated to check
   the GPIO pin state if the pin has been initialized.

Signed-off-by: Siddhant Modi <siddhant.modi@gmail.com>
2025-11-13 20:43:12 -05:00
Raffael Rostagno
75395b86dc drivers: shdc: esp32: Remove unnecessary timeout
Remove unnecessary timeout. Queue event fetch already has
timeout control.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2025-11-13 23:20:08 +02:00
Raffael Rostagno
97fb97b047 drivers: sdhc: esp32: Remove pinctrl as required
Adjust driver so that pinctrl property is not required in device
tree. Remove card init functions from driver init, as set_io()
function is meant to power cycle the card (if pin is used) and
initialize card clock and bit width. If card is not inserted
while driver init runs, init() will fail unreasonably, so
card init should take place at set_io() calls.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2025-11-13 23:20:08 +02:00
Anas Nashif
303af992e5 style: fix 'if (' usage in cmake files
Replace with 'if(' and 'else(' per the cmake style guidelines.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-29 11:44:13 +02:00