Skip to content

Commit 6aaa2b5

Browse files
danieldegrassedleach02
authored andcommitted
drivers: sdhc: Implement NXP USDHC SDHC driver
Implement SDHC driver for NXP USDHC peripheral, supporting all api calls available in the sdhc driver. This implementation leverages NXP's HAL, and simply implements a shim layer over the HAL itself. Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 3f3a593 commit 6aaa2b5

File tree

8 files changed

+1014
-2
lines changed

8 files changed

+1014
-2
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@
399399
/drivers/spi/*b91* @yurvyn
400400
/drivers/spi/spi_rv32m1_lpspi* @karstenkoenig
401401
/drivers/spi/*esp32* @glaubermaroto
402+
/drivers/sdhc/ @danieldegrasse
402403
/drivers/timer/*apic* @dcpleung @nashif
403404
/drivers/timer/apic_tsc.c @andyross
404405
/drivers/timer/*arm_arch* @carlocaione

drivers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ add_subdirectory_ifdef(CONFIG_PINMUX pinmux)
3131
add_subdirectory_ifdef(CONFIG_PWM pwm)
3232
add_subdirectory_ifdef(CONFIG_SENSOR sensor)
3333
add_subdirectory_ifdef(CONFIG_SPI spi)
34+
add_subdirectory_ifdef(CONFIG_SDHC sdhc)
3435
add_subdirectory_ifdef(CONFIG_WATCHDOG watchdog)
3536
add_subdirectory_ifdef(CONFIG_WIFI wifi)
3637
add_subdirectory_ifdef(CONFIG_CAN can)

drivers/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ source "drivers/interrupt_controller/Kconfig.shared_irq"
3939

4040
source "drivers/spi/Kconfig"
4141

42+
source "drivers/sdhc/Kconfig"
43+
4244
source "drivers/i2c/Kconfig"
4345

4446
source "drivers/i2s/Kconfig"

drivers/clock_control/clock_control_mcux_ccm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ static int mcux_ccm_get_subsys_rate(const struct device *dev,
9696
break;
9797
#endif
9898

99-
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc1), okay) && CONFIG_DISK_DRIVER_SDMMC
99+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc1), okay) && CONFIG_IMX_USDHC
100100
case IMX_CCM_USDHC1_CLK:
101101
*rate = CLOCK_GetSysPfdFreq(kCLOCK_Pfd0) /
102102
(CLOCK_GetDiv(kCLOCK_Usdhc1Div) + 1U);
103103
break;
104104
#endif
105105

106-
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc2), okay) && CONFIG_DISK_DRIVER_SDMMC
106+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc2), okay) && CONFIG_IMX_USDHC
107107
case IMX_CCM_USDHC2_CLK:
108108
*rate = CLOCK_GetSysPfdFreq(kCLOCK_Pfd0) /
109109
(CLOCK_GetDiv(kCLOCK_Usdhc2Div) + 1U);

drivers/sdhc/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2022 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
if (CONFIG_SDHC)
4+
5+
zephyr_library()
6+
zephyr_library_sources_ifdef(CONFIG_IMX_USDHC imx_usdhc.c)
7+
endif()

drivers/sdhc/Kconfig

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2022 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
menuconfig SDHC
5+
bool "SDHC drivers"
6+
help
7+
Include drivers for SD host controller
8+
9+
if SDHC
10+
11+
source "drivers/sdhc/Kconfig.imx"
12+
13+
config SDHC_INIT_PRIORITY
14+
int "SDHC driver init priority"
15+
default 85
16+
help
17+
SDHC driver system init priority
18+
19+
config SDHC_BUFFER_ALIGNMENT
20+
int
21+
default 1
22+
help
23+
Some SD host controllers require alignment of their data buffers
24+
in order to DMA to work correctly. Devices should change default of
25+
this value if they require alignment. This represents the alignment
26+
of buffers required in bytes
27+
28+
config SDHC_SUPPORTS_UHS
29+
bool
30+
help
31+
Selected by host controller driver if UHS support is present. required
32+
to enable UHS portion of protocol stack.
33+
34+
config SDHC_SUPPORTS_SPI_MODE
35+
bool
36+
help
37+
Selected by host controller driver if SPI mode support is required.
38+
Enables SPI protocol in SD protocol stack
39+
40+
config SDHC_SUPPORTS_NATIVE_MODE
41+
bool
42+
help
43+
Selected by host controller driver if native SD mode support is
44+
required. Enables native protocol in SD protocol stack.
45+
46+
module = SDHC
47+
module-str = sdhc
48+
source "subsys/logging/Kconfig.template.log_config"
49+
50+
51+
endif # SDHC

drivers/sdhc/Kconfig.imx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright (c) 2022, NXP
2+
# SPDX -License-Identifier: Apache-2.0
3+
4+
config IMX_USDHC
5+
bool "NXP IMX USDHC Driver"
6+
depends on (HAS_MCUX_USDHC1 || HAS_MCUX_USDHC2)
7+
select SDHC_SUPPORTS_UHS
8+
select SDHC_SUPPORTS_NATIVE_MODE
9+
help
10+
Enable the NXP IMX SD Host controller driver
11+
12+
if IMX_USDHC
13+
14+
config IMX_USDHC_DAT3_PWR_TOGGLE
15+
bool "Toggle power when pulling DAT3 line low"
16+
default y
17+
help
18+
Toggle power to SD card to clear DAT3 pull when pulling line low
19+
20+
config IMX_USDHC_DMA_SUPPORT
21+
bool
22+
depends on ARCH_HAS_NOCACHE_MEMORY_SUPPORT
23+
default y
24+
select NOCACHE_MEMORY
25+
26+
if IMX_USDHC_DMA_SUPPORT
27+
28+
# USDHC DMA needs 32 bit aligned buffers
29+
config SDHC_BUFFER_ALIGNMENT
30+
default 4
31+
32+
config IMX_USDHC_DMA_BUFFER_SIZE
33+
int "Size of DMA descriptor buffer in bytes"
34+
default 128
35+
help
36+
Size of USDHC ADMA descriptor buffer in bytes
37+
38+
endif # IMX_USDHC_DMA_SUPPORT
39+
40+
41+
42+
endif

0 commit comments

Comments
 (0)