Commit graph

13 commits

Author SHA1 Message Date
Daniel DeGrasse 82ce2b412d sd: sdmmc: rework frequency and timing selection logic
SDMMC framework frequency and timing selection logic has several
longstanding issues, including:
- requiring that SD hosts support the maximum frequency possible for a
  given UHS mode in order to apply that timing
- selecting SDHC_TIMING_SDR25 for high speed mode, when SDHC_TIMING_HS
  would be correct

Rework the frequency and timing selection logic within the SD framework
to resolve these issues.

Fixes #52589
Fixes #67943

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 09:21:03 +02:00
Daniel DeGrasse 87030f4cbf sd: sdmmc: add DEFAULT and HIGH_SPEED bus speeds
Add DEFAULT and HIGH_SPEED bus speeds to SD spec definition, for non UHS
cards.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 09:21:03 +02:00
Daniel DeGrasse 06f3574685 include: zephyr: sd: sd_spec: add UNSUPPORTED frequency for HS mode
Add UNSUPPORTED frequency macro for HS mode frequencies, used when a
card does not support any high speed mode frequencies

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 09:21:03 +02:00
Daniel DeGrasse 771451f616 include: zephyr: sd: sd_spec: use frequency macros
Use frequency macros to define SD frequencies, this should increase
readability of the file and reduce errors.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 09:21:03 +02:00
Attie Grande a97b61e7ed include: sd: revise the minimum alignment of card_buffer to 4-bytes
Since a85ffa8, `struct sd_card.card_buffer` has naturally fallen at an
offset that is unaligned. This meant that on systems without support for
unaligned access (e.g: Cortex-M0), a hard fault would present when
executing code that casts the buffer to `uint32_t` (such as
`sdmmc_spi_read_cxd()`, `card_query_written()`, etc...)

Historically, it appears that the alignment of the `card_buffer` member
was good and operational only by chance.

Altering the default value of `CONFIG_SDHC_BUFFER_ALIGNMENT` was
rejected, as this has wider implications.

Fixes #62619

Signed-off-by: Attie Grande <attie.grande@argentum-systems.co.uk>
2024-01-18 20:04:50 +01:00
Daniel DeGrasse 64878aa115 sd: add sdio header file
Add SDIO header file, defining functions supported by SDIO subsystem

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-11-06 19:01:08 -05:00
Daniel DeGrasse f9216f0d63 sd: add SDIO specification definitions
Add SDIO specification definitions, including SDIO commands.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-11-06 19:01:08 -05:00
Mourad Kharrazi a85ffa8130 drivers: sdhc: allow bandwidth selection
The current implementation uses both, host and card capabilites to derive
the maximum bus width to be used. However, in cases where a MMC device is
not connected to the host via shdc using the full bus width of 8 lines,
device initialization fails. Introducing the `bus-width` property
circumvents this by reducing the host bus capabilites and forcing
communication with the MMC device using 1, 4 or 8 lines.

Signed-off-by: Mourad Kharrazi <mourad.kharrazi@ithinx.io>
2023-09-13 16:20:59 +02:00
Daniel DeGrasse b2172a97d8 sd: clean up sizes of some SD data fields
Clean up sizes of some SD data fields, as the max value of these fields
is limited by the SD specification

Specifically, the limits are as follows:
num_io: 0-7, 3 bits (SDIO only)
relative_addr: 16 bits (SDMMC/MMC)
block_size: 12 bits (Max of 2KB, uint16_t used)
sd_version: 8 bits (currently at version 3)
card_speed: 8 bits (could potentially be reduced in size)

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-08-31 10:19:37 +02:00
Declan Snyder 3bc095a810 sd: MMC API, and MMC Spec
- Adds the declaration of the MMC API
- Adds MMC spec related declarations
- Adds some properties to sdhc dts binding for mmc

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-01-14 09:22:22 +01:00
Gerard Marull-Paretas 6a0f554ffa include: add missing kernel.h include
Some files make use of Kernel APIs without including kernel.h, fix this
problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Daniel DeGrasse d90a16f591 include: sd: Add SD subsystem header files
Add SD subsystem headers. SD subsystem contains generic header for SD
initialization, and headers for SDIO and SDMMC cards.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-04-29 14:21:36 -05:00
Daniel DeGrasse c8041e87c9 include: sd: Add SD specification definition
SD specification definition required for SD host controller headers.
Add header file with SD specification definitions.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-04-29 14:21:36 -05:00