ARM: DTS: stm32: add MMC nodes for stm32f746-disco and stm32f769-disco

Add DT nodes to enable ARM_PL180_MMCI IP support for STM32F746
and STM32F769 discovery boards

There is a hardware issue on these boards, it misses a pullup on the GPIO line
used as card detect to allow correct SD card detection.
As workaround, cd-gpios property is not present in DT.
So SD card is always considered present in the slot.

Signed-off-by: Christophe Priouzeau <christophe.priouzeau@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/arch/arm/dts/stm32f746-disco.dts b/arch/arm/dts/stm32f746-disco.dts
index c92c2e2..9e8d2a0 100644
--- a/arch/arm/dts/stm32f746-disco.dts
+++ b/arch/arm/dts/stm32f746-disco.dts
@@ -65,6 +65,7 @@
 	aliases {
 		serial0 = &usart1;
 		spi0 = &qspi;
+		mmc0 = &sdio;
 		/* Aliases for gpios so as to use sequence */
 		gpio0 = &gpioa;
 		gpio1 = &gpiob;
@@ -238,3 +239,14 @@
 			reg = <0>;
 	};
 };
+
+&sdio {
+	status = "okay";
+	cd-gpios = <&gpioc 13 0>;
+	cd-inverted;
+	pinctrl-names = "default", "opendrain";
+	pinctrl-0 = <&sdio_pins>;
+	pinctrl-1 = <&sdio_pins_od>;
+	bus-width = <4>;
+	max-frequency = <25000000>;
+};
diff --git a/arch/arm/dts/stm32f746.dtsi b/arch/arm/dts/stm32f746.dtsi
index f62360f..929bf82 100644
--- a/arch/arm/dts/stm32f746.dtsi
+++ b/arch/arm/dts/stm32f746.dtsi
@@ -234,6 +234,91 @@
 				u-boot,dm-pre-reloc;
 			};
 
+			sdio_pins: sdio_pins@0 {
+				pins {
+					pinmux = <STM32F746_PC8_FUNC_SDMMC1_D0>,
+						 <STM32F746_PC9_FUNC_SDMMC1_D1>,
+						 <STM32F746_PC10_FUNC_SDMMC1_D2>,
+						 <STM32F746_PC11_FUNC_SDMMC1_D3>,
+						 <STM32F746_PC12_FUNC_SDMMC1_CK>,
+						 <STM32F746_PD2_FUNC_SDMMC1_CMD>;
+					drive-push-pull;
+					slew-rate = <2>;
+				};
+			};
+
+			sdio_pins_od: sdio_pins_od@0 {
+				pins1 {
+					pinmux = <STM32F746_PC8_FUNC_SDMMC1_D0>,
+						 <STM32F746_PC9_FUNC_SDMMC1_D1>,
+						 <STM32F746_PC10_FUNC_SDMMC1_D2>,
+						 <STM32F746_PC11_FUNC_SDMMC1_D3>,
+						 <STM32F746_PC12_FUNC_SDMMC1_CK>;
+					drive-push-pull;
+					slew-rate = <2>;
+				};
+
+				pins2 {
+					pinmux = <STM32F746_PD2_FUNC_SDMMC1_CMD>;
+					drive-open-drain;
+					slew-rate = <2>;
+				};
+			};
+
+			sdio_pins_b: sdio_pins_b@0 {
+				pins {
+					pinmux = <STM32F769_PG9_FUNC_SDMMC2_D0>,
+						 <STM32F769_PG10_FUNC_SDMMC2_D1>,
+						 <STM32F769_PB3_FUNC_SDMMC2_D2>,
+						 <STM32F769_PB4_FUNC_SDMMC2_D3>,
+						 <STM32F769_PD6_FUNC_SDMMC2_CLK>,
+						 <STM32F769_PD7_FUNC_SDMMC2_CMD>;
+					drive-push-pull;
+					slew-rate = <2>;
+				};
+			};
+
+			sdio_pins_od_b: sdio_pins_od_b@0 {
+				pins1 {
+					pinmux = <STM32F769_PG9_FUNC_SDMMC2_D0>,
+						 <STM32F769_PG10_FUNC_SDMMC2_D1>,
+						 <STM32F769_PB3_FUNC_SDMMC2_D2>,
+						 <STM32F769_PB4_FUNC_SDMMC2_D3>,
+						 <STM32F769_PD6_FUNC_SDMMC2_CLK>;
+					drive-push-pull;
+					slew-rate = <2>;
+				};
+
+				pins2 {
+					pinmux = <STM32F769_PD7_FUNC_SDMMC2_CMD>;
+					drive-open-drain;
+					slew-rate = <2>;
+				};
+			};
+
+		};
+		sdio: sdio@40012c00 {
+			compatible = "st,stm32f4xx-sdio";
+			reg = <0x40012c00 0x400>;
+			clocks = <&rcc 0 171>;
+			interrupts = <49>;
+			status = "disabled";
+			pinctrl-0 = <&sdio_pins>;
+			pinctrl-1 = <&sdio_pins_od>;
+			pinctrl-names = "default", "opendrain";
+			max-frequency = <48000000>;
+		};
+
+		sdio2: sdio2@40011c00 {
+			compatible = "st,stm32f4xx-sdio";
+			reg = <0x40011c00 0x400>;
+			clocks = <&rcc 0 167>;
+			interrupts = <103>;
+			status = "disabled";
+			pinctrl-0 = <&sdio_pins_b>;
+			pinctrl-1 = <&sdio_pins_od_b>;
+			pinctrl-names = "default", "opendrain";
+			max-frequency = <48000000>;
 		};
 	};
 };
diff --git a/arch/arm/dts/stm32f769-disco.dts b/arch/arm/dts/stm32f769-disco.dts
index f34ffcc..59c9d31 100644
--- a/arch/arm/dts/stm32f769-disco.dts
+++ b/arch/arm/dts/stm32f769-disco.dts
@@ -60,6 +60,7 @@
 	aliases {
 		serial0 = &usart1;
 		spi0 = &qspi;
+		mmc0 = &sdio2;
 		/* Aliases for gpios so as to use sequence */
 		gpio0 = &gpioa;
 		gpio1 = &gpiob;
@@ -252,3 +253,14 @@
 			reg = <0>;
 	};
 };
+
+&sdio2 {
+	status = "okay";
+	cd-gpios = <&gpioi 15 0>;
+	cd-inverted;
+	pinctrl-names = "default", "opendrain";
+	pinctrl-0 = <&sdio_pins_b>;
+	pinctrl-1 = <&sdio_pins_od_b>;
+	bus-width = <4>;
+	max-frequency = <25000000>;
+};