Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sd: fix frequency and timing selection logic #72705

Merged
merged 7 commits into from
May 16, 2024

Conversation

danieldegrasse
Copy link
Collaborator

@danieldegrasse danieldegrasse commented May 13, 2024

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

This PR also includes a similar rework for the frequency selection logic in the SDIO framework, as the same issue exists there

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>
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>
Add DEFAULT and HIGH_SPEED bus speeds to SD spec definition, for non UHS
cards.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
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 zephyrproject-rtos#52589
Fixes zephyrproject-rtos#67943

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Reword frequency and timing selection logic for SDIO framework so that
the maximum supported timing mode between the card and host will be
selected, even if the maximum frequency supported by the host is not
equal to the maximum frequency for that mode.

Also, resolve an issue where a host and card combo only supporting HS
mode or worse would still use legacy timing mode, because the CCCR flags
were not being checked when checking if HS bus speed could be used.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Report bus frequency, and use correct names for the timing modes when SD
cards do not support UHS modes.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
RCAR MMC driver previously had to report inaccurate maximum supported
frequency to SD subsystem so that the subsystem would select SDR104 mode
timing. Remove this logic, as it should no longer be needed.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
@danieldegrasse danieldegrasse changed the title sd: sdmmc: rework frequency and timing selection logic sd: sdmmc: frequency and timing selection logic May 13, 2024
Copy link
Contributor

@xakep-amatop xakep-amatop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes have been checked on a real board; everything works as expected.

@danieldegrasse danieldegrasse changed the title sd: sdmmc: frequency and timing selection logic sd: fix frequency and timing selection logic May 14, 2024
@danieldegrasse
Copy link
Collaborator Author

Changes have been checked on a real board; everything works as expected.

Thanks for verifying this- I also checked these changes on an RT1170 (imx_usdhc.c) and LPC55S69 (mcux_sdif.c), and both worked as expected.

@danieldegrasse
Copy link
Collaborator Author

Reassigning, as I can't review my own PR

@aescolar aescolar merged commit 3b718bf into zephyrproject-rtos:main May 16, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants