Skip to content

Commit

Permalink
soc: imx_rt: added support for nxp imx_usdhc SDHC driver to RT600/500
Browse files Browse the repository at this point in the history
added support for NXP iMX RT600/RT500 to use to SDHC driver, with SD
subsystem. Tested with RT685 EVK

Signed-off-by: Daniel DeGrasse <[email protected]>
  • Loading branch information
danieldegrasse authored and dleach02 committed Apr 29, 2022
1 parent d108b64 commit 2fbfed9
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 12 deletions.
6 changes: 6 additions & 0 deletions boards/arm/mimxrt685_evk/mimxrt685_evk_cm33.dts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ i2s1: &flexcomm3 {
/* Quick fix for 1.8V SD cards on RT600- disable 1.8V negotiation */
no-1-8-v;
pwr-gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>;
cd-gpios = <&gpio2 9 GPIO_ACTIVE_LOW>;
mmc {
compatible = "zephyr,sdmmc-disk";
status = "okay";
label = "SDMMC_0";
};
};

&lpadc0 {
Expand Down
2 changes: 1 addition & 1 deletion boards/arm/mimxrt685_evk/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ static int mimxrt685_evk_pinmux_init(const struct device *dev)

#endif

#if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc1), okay) && CONFIG_DISK_DRIVER_SDMMC
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc1), okay) && CONFIG_IMX_USDHC
uint32_t port1_pin30_config = (/* Pin is configured as SD0_CLK */
IOPCTL_PIO_FUNC1 |
/* Disable pull-up / pull-down function */
Expand Down
16 changes: 12 additions & 4 deletions dts/arm/nxp/nxp_rt5xx_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -369,21 +369,29 @@
};

usdhc1: usdhc@136000 {
compatible = "nxp,imx-usdhc";
compatible = "nxp,imx-sdhc";
reg = <0x136000 0x1000>;
status = "disabled";
interrupts = <45 0>;
clocks = <&clkctl1 MCUX_USDHC1_CLK>;
label = "USDHC_1";
label = "SDHC_0";
max-current-330 = <1020>;
max-current-180 = <1020>;
max-bus-freq = <208000000>;
min-bus-freq = <400000>;
};

usdhc2: usdhc@137000 {
compatible = "nxp,imx-usdhc";
compatible = "nxp,imx-sdhc";
reg = <0x137000 0x1000>;
status = "disabled";
interrupts = <46 0>;
clocks = <&clkctl1 MCUX_USDHC2_CLK>;
label = "USDHC_2";
label = "SDHC_1";
max-current-330 = <1020>;
max-current-180 = <1020>;
max-bus-freq = <208000000>;
min-bus-freq = <400000>;
};

lpadc0: lpadc@13A0000 {
Expand Down
16 changes: 12 additions & 4 deletions dts/arm/nxp/nxp_rt6xx_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -321,21 +321,29 @@
};

usdhc1: usdhc@136000 {
compatible = "nxp,imx-usdhc";
compatible = "nxp,imx-sdhc";
reg = <0x136000 0x1000>;
status = "disabled";
interrupts = <45 0>;
clocks = <&clkctl1 MCUX_USDHC1_CLK>;
label = "USDHC_1";
label = "SDHC_0";
max-current-330 = <1020>;
max-current-180 = <1020>;
max-bus-freq = <208000000>;
min-bus-freq = <400000>;
};

usdhc2: usdhc@137000 {
compatible = "nxp,imx-usdhc";
compatible = "nxp,imx-sdhc";
reg = <0x137000 0x1000>;
status = "disabled";
interrupts = <46 0>;
clocks = <&clkctl1 MCUX_USDHC2_CLK>;
label = "USDHC_2";
label = "SDHC_1";
max-current-330 = <1020>;
max-current-180 = <1020>;
max-bus-freq = <208000000>;
min-bus-freq = <400000>;
};

lpadc0: lpadc@13A0000 {
Expand Down
4 changes: 4 additions & 0 deletions soc/arm/nxp_imx/rt6xx/Kconfig.defconfig.mimxrt685_cm33
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ config CLOCK_CONTROL_MCUX_SYSCON
default y if HAS_MCUX_SYSCON
depends on CLOCK_CONTROL

config IMX_USDHC
default y if (HAS_MCUX_USDHC1 || HAS_MCUX_USDHC2)
depends on SDHC

if MCUX_OS_TIMER

config SYS_CLOCK_HW_CYCLES_PER_SEC
Expand Down
4 changes: 2 additions & 2 deletions soc/arm/nxp_imx/rt6xx/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static ALWAYS_INLINE void clock_init(void)
CLOCK_AttachClk(kNONE_to_WDT0_CLK);
#endif

#if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc1), okay) && CONFIG_DISK_DRIVER_SDMMC
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc1), okay) && CONFIG_IMX_USDHC
/* Make sure USDHC ram buffer has been power up*/
POWER_DisablePD(kPDRUNCFG_APD_USDHC0_SRAM);
POWER_DisablePD(kPDRUNCFG_PPD_USDHC0_SRAM);
Expand All @@ -283,7 +283,7 @@ static ALWAYS_INLINE void clock_init(void)
#endif /* CONFIG_SOC_MIMXRT685S_CM33 */
}

#if (DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc1), okay) && CONFIG_DISK_DRIVER_SDMMC)
#if (DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc1), okay) && CONFIG_IMX_USDHC)

void imxrt_usdhc_pinmux(uint16_t nusdhc, bool init,
uint32_t speed, uint32_t strength)
Expand Down
2 changes: 1 addition & 1 deletion soc/arm/nxp_imx/rt6xx/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
extern "C" {
#endif

#if CONFIG_DISK_DRIVER_SDMMC && \
#if CONFIG_IMX_USDHC && \
(DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc1), okay) || \
DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc2), okay))

Expand Down

0 comments on commit 2fbfed9

Please sign in to comment.