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>
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>
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>
this commit replaces SDMMC_FIFO_SIZE usages related to
RXFIFOHF/TXFIFOHE handling with SDMMC_HALFFIFOBYTES.
Signed-off-by: Sara Touqan <zephyr@exalt.ps>
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>
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>
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>
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>
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>
- 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>
- 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>
- 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>
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>
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>
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>
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>
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>
Initialize `transfer_count`, `is_write`, and `byte_mode` variables to
prevent potential use of uninitialized variables.
Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>