From f0af6aa8b296c3aae4105d333cc6d013a5b2fa6a Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Fri, 10 May 2024 22:07:45 +0000 Subject: [PATCH] boards: nxp: frdm_mcxn947: add support for USDHC0 Add support for USDHC0 controller on FRDM_MCXN947 board. This support was verified using the `tests/subsys/sd/sdmmc` and `tests/subsys/sd/sdio` testcases. Note that this board does not ship with the SD header (J12) populated by default, so the user must populate one. Signed-off-by: Daniel DeGrasse --- boards/nxp/frdm_mcxn947/Kconfig.defconfig | 8 ++++++++ boards/nxp/frdm_mcxn947/board.c | 5 +++++ boards/nxp/frdm_mcxn947/doc/index.rst | 2 ++ .../frdm_mcxn947/frdm_mcxn947-pinctrl.dtsi | 19 +++++++++++++++++++ boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi | 10 ++++++++++ .../frdm_mcxn947_mcxn947_cpu0.dts | 12 ++++++++++++ .../frdm_mcxn947_mcxn947_cpu0.yaml | 1 + 7 files changed, 57 insertions(+) diff --git a/boards/nxp/frdm_mcxn947/Kconfig.defconfig b/boards/nxp/frdm_mcxn947/Kconfig.defconfig index 72cc76170b9..461a4ed6286 100644 --- a/boards/nxp/frdm_mcxn947/Kconfig.defconfig +++ b/boards/nxp/frdm_mcxn947/Kconfig.defconfig @@ -6,4 +6,12 @@ if BOARD_FRDM_MCXN947 config NET_L2_ETHERNET default y if NETWORKING +if SD_STACK + +# SD stack requires larger main stack size +config MAIN_STACK_SIZE + default 1536 + +endif + endif diff --git a/boards/nxp/frdm_mcxn947/board.c b/boards/nxp/frdm_mcxn947/board.c index 29b4bbf8461..0481fafddf5 100644 --- a/boards/nxp/frdm_mcxn947/board.c +++ b/boards/nxp/frdm_mcxn947/board.c @@ -192,6 +192,11 @@ static int frdm_mcxn947_init(void) CLOCK_AttachClk(kPLL0_to_CTIMER4); #endif +#if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc0), okay) + CLOCK_SetClkDiv(kCLOCK_DivUSdhcClk, 1u); + CLOCK_AttachClk(kFRO_HF_to_USDHC); +#endif + #if CONFIG_FLASH_MCUX_FLEXSPI_NOR /* We downclock the FlexSPI to 50MHz, it will be set to the * optimum speed supported by the Flash device during FLEXSPI diff --git a/boards/nxp/frdm_mcxn947/doc/index.rst b/boards/nxp/frdm_mcxn947/doc/index.rst index cf63ab6abff..9dd884e0728 100644 --- a/boards/nxp/frdm_mcxn947/doc/index.rst +++ b/boards/nxp/frdm_mcxn947/doc/index.rst @@ -82,6 +82,8 @@ The FRDM-MCXN947 board configuration supports the following hardware features: +-----------+------------+-------------------------------------+ | CTIMER | on-chip | counter | +-----------+------------+-------------------------------------+ +| USDHC | on-chip | sdhc | ++-----------+------------+-------------------------------------+ Targets available ================== diff --git a/boards/nxp/frdm_mcxn947/frdm_mcxn947-pinctrl.dtsi b/boards/nxp/frdm_mcxn947/frdm_mcxn947-pinctrl.dtsi index 11bb253d66a..4d3e9771382 100644 --- a/boards/nxp/frdm_mcxn947/frdm_mcxn947-pinctrl.dtsi +++ b/boards/nxp/frdm_mcxn947/frdm_mcxn947-pinctrl.dtsi @@ -129,4 +129,23 @@ }; }; + pinmux_usdhc0: pinmux_usdhc0 { + group0 { + pinmux = , + , + , + , + ; + slew-rate = "fast"; + drive-strength = "low"; + bias-pull-up; + input-enable; + }; + group1 { + pinmux = ; + slew-rate = "fast"; + drive-strength = "low"; + input-enable; + }; + }; }; diff --git a/boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi b/boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi index e1543f19692..0634ddcae56 100644 --- a/boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi +++ b/boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi @@ -14,6 +14,7 @@ led2 = &blue_led; sw0 = &user_button_2; sw1 = &user_button_3; + sdhc0 = &usdhc0; }; leds { @@ -173,3 +174,12 @@ pinctrl-0 = <&pinmux_flexpwm1_pwm0>; pinctrl-names = "default"; }; + +&usdhc0 { + pinctrl-0 = <&pinmux_usdhc0>; + pinctrl-1 = <&pinmux_usdhc0>; + pinctrl-2 = <&pinmux_usdhc0>; + cd-gpios = <&gpio2 1 GPIO_ACTIVE_LOW>; + pinctrl-names = "default", "slow", "med"; + no-1-8-v; +}; diff --git a/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.dts b/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.dts index 4865e16784e..462edb3332b 100644 --- a/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.dts +++ b/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.dts @@ -58,6 +58,10 @@ status = "okay"; }; +&gpio2 { + status = "okay"; +}; + &green_led { status = "okay"; }; @@ -141,3 +145,11 @@ &ctimer0 { status = "okay"; }; + +&usdhc0 { + status = "okay"; + sdmmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; +}; diff --git a/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.yaml b/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.yaml index 2e9c4f6c283..a1c2b1c2da1 100644 --- a/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.yaml +++ b/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.yaml @@ -23,4 +23,5 @@ supported: - watchdog - pwm - counter + - sdhc vendor: nxp