cancel
Showing results for 
Search instead for 
Did you mean: 

spi communication problem

nesnes
Associate II

Hi again @Erwan SZYMANSKI . Im trying to communicate between my nucleo-G431RB board as master and stm32mp157f-dk2 board as slave. The first problem ı have is that stm32mp157f-dk2.dts file doesn't have the spi configurations and I tried adding them with patching but that caused trouble, can u help me adjusting my dts file

(unmodified file)

 

 

// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-3-Clause)
/*
 * Copyright (C) STMicroelectronics 2022 - All Rights Reserved
 * Author: Alexandre Torgue <alexandre.torgue@foss.st.com> for STMicroelectronics.
 */

/dts-v1/;

#include "stm32mp157.dtsi"
#include "stm32mp15xf.dtsi"
#include "stm32mp15-pinctrl.dtsi"
#include "stm32mp15xxac-pinctrl.dtsi"
#include "stm32mp15xx-dkx.dtsi"
#include "stm32mp157c-dk2-scmi.dtsi"
#include <dt-bindings/rtc/rtc-stm32.h>

/ {
	model = "STMicroelectronics STM32MP157F-DK2 Discovery Board";
	compatible = "st,stm32mp157f-dk2", "st,stm32mp157";

	aliases {
		serial3 = &usart2;
	};

	chosen {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;
		stdout-path = "serial0:115200n8";

		framebuffer {
			compatible = "simple-framebuffer";
			clocks = <&rcc LTDC_PX>, <&rcc DSI>, <&rcc DSI_PX>;
			status = "disabled";
		};
	};

	wifi_pwrseq: wifi-pwrseq {
		compatible = "mmc-pwrseq-simple";
		reset-gpios = <&gpioh 4 GPIO_ACTIVE_LOW>;
	};
};

&cryp1 {
	status = "okay";
};

&dsi {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			dsi_in: endpoint {
				remote-endpoint = <&ltdc_ep1_out>;
			};
		};

		port@1 {
			reg = <1>;
			dsi_out: endpoint {
				remote-endpoint = <&panel_in>;
			};
		};
	};

	panel_otm8009a: panel-otm8009a@0 {
		compatible = "orisetech,otm8009a";
		reg = <0>;
		reset-gpios = <&gpioe 4 GPIO_ACTIVE_LOW>;
		power-supply = <&v3v3>;
		status = "okay";

		port {
			panel_in: endpoint {
				remote-endpoint = <&dsi_out>;
			};
		};
	};
};

&hdp {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&hdp2_gpo &hdp2_pins_a>;
	pinctrl-1 = <&hdp2_sleep_pins_a>;
	status = "disabled";
};

&i2c1 {
	touchscreen@38 {
		compatible = "focaltech,ft6236";
		reg = <0x38>;
		interrupts = <2 2>;
		interrupt-parent = <&gpiof>;
		interrupt-controller;
		touchscreen-size-x = <480>;
		touchscreen-size-y = <800>;
		vcc-supply = <&v3v3>;
		iovcc-supply = <&v3v3>;
		panel = <&panel_otm8009a>;
		status = "okay";
	};
};

&ltdc {
	default-on;
	status = "okay";

	port {
		#address-cells = <1>;
		#size-cells = <0>;

		ltdc_ep1_out: endpoint@1 {
			reg = <1>;
			remote-endpoint = <&dsi_in>;
		};
	};
};

&rtc {
	st,lsco = <RTC_OUT2_RMP>;
	pinctrl-0 = <&rtc_out2_rmp_pins_a>;
	pinctrl-names = "default";
};

/* Wifi */
&sdmmc2 {
	pinctrl-names = "default", "opendrain", "sleep";
	pinctrl-0 = <&sdmmc2_b4_pins_a>;
	pinctrl-1 = <&sdmmc2_b4_od_pins_a>;
	pinctrl-2 = <&sdmmc2_b4_sleep_pins_a>;
	non-removable;
	cap-sdio-irq;
	st,neg-edge;
	bus-width = <4>;
	vmmc-supply = <&v3v3>;
	mmc-pwrseq = <&wifi_pwrseq>;
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	brcmf: bcrmf@1 {
		reg = <1>;
		compatible = "brcm,bcm4329-fmac";
	};
};

/* Bluetooth */
&usart2 {
	pinctrl-names = "default", "sleep", "idle";
	pinctrl-0 = <&usart2_pins_c>;
	pinctrl-1 = <&usart2_sleep_pins_c>;
	pinctrl-2 = <&usart2_idle_pins_c>;
	uart-has-rtscts;
	status = "okay";

	bluetooth {
		shutdown-gpios = <&gpioz 6 GPIO_ACTIVE_HIGH>;
		compatible = "brcm,bcm43438-bt";
		max-speed = <3000000>;
		vbat-supply = <&v3v3>;
		vddio-supply = <&v3v3>;
	};
};

 

patch file

 

diff --git a/stm32mp157f-dk2.dts.orig b/stm32mp157f-dk2.dts.spi
index 2462656..e10ff10 100644
--- a/arch/arm/boot/dts/stm32mp157f-dk2.dts
+++ b/arch/arm/boot/dts/stm32mp157f-dk2.dts
@@ -41,6 +41,55 @@
 	};
 };
 
+&pinctrl {
+    spi5_pins: spi5-pins {
+        pins = "spi5_sck", "spi5_miso", "spi5_mosi", "spi5_nss";
+        function = "spi";
+    };
+};
+
+&spi5 {
+    status = "okay";
+    pinctrl-names = "default";
+    pinctrl-0 = <&spi5_pins>;
+    #address-cells = <1>;
+    #size-cells = <0>;
+
+    device@0 {
+        compatible = "spi-device";
+        reg = <0>;
+        spi-max-frequency = <10000000>;
+        status = "okay";
+    };
+};
+
+&gpio {
+    spi5_nss {
+        compatible = "gpio";
+        gpios = <&gpioa 8 GPIO_ACTIVE_LOW>; // EXP_GPIO8
+        status = "okay";
+    };
+
+    spi5_miso {
+        compatible = "gpio";
+        gpios = <&gpioa 9 GPIO_ACTIVE_HIGH>; // EXP_GPIO9
+        status = "okay";
+    };
+
+    spi5_mosi {
+        compatible = "gpio";
+        gpios = <&gpioa 10 GPIO_ACTIVE_HIGH>; // EXP_GPIO10
+        status = "okay";
+    };
+
+    spi5_sck {
+        compatible = "gpio";
+        gpios = <&gpioa 11 GPIO_ACTIVE_HIGH>; // EXP_GPIO11
+        status = "okay";
+    };
+};
+
+
 &cryp1 {
 	status = "okay";
 };

 (modified file)

// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-3-Clause)
/*
 * Copyright (C) STMicroelectronics 2022 - All Rights Reserved
 * Author: Alexandre Torgue <alexandre.torgue@foss.st.com> for STMicroelectronics.
 */

/dts-v1/;

#include "stm32mp157.dtsi"
#include "stm32mp15xf.dtsi"
#include "stm32mp15-pinctrl.dtsi"
#include "stm32mp15xxac-pinctrl.dtsi"
#include "stm32mp15xx-dkx.dtsi"
#include "stm32mp157c-dk2-scmi.dtsi"
#include <dt-bindings/rtc/rtc-stm32.h>

/ {
	model = "STMicroelectronics STM32MP157F-DK2 Discovery Board";
	compatible = "st,stm32mp157f-dk2", "st,stm32mp157";

	aliases {
		serial3 = &usart2;
	};

	chosen {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;
		stdout-path = "serial0:115200n8";

		framebuffer {
			compatible = "simple-framebuffer";
			clocks = <&rcc LTDC_PX>, <&rcc DSI>, <&rcc DSI_PX>;
			status = "disabled";
		};
	};

	wifi_pwrseq: wifi-pwrseq {
		compatible = "mmc-pwrseq-simple";
		reset-gpios = <&gpioh 4 GPIO_ACTIVE_LOW>;
	};
};

&pinctrl {
    spi5_pins: spi5-pins {
        pins = "spi5_sck", "spi5_miso", "spi5_mosi", "spi5_nss";
        function = "spi";
    };
};

&spi5 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&spi5_pins>;
    #address-cells = <1>;
    #size-cells = <0>;

    device@0 {
        compatible = "spi-device";
        reg = <0>;
        spi-max-frequency = <10000000>;
        status = "okay";
    };
};

&gpio {
    spi5_nss {
        compatible = "gpio";
        gpios = <&gpioa 8 GPIO_ACTIVE_LOW>; // EXP_GPIO8
        status = "okay";
    };

    spi5_miso {
        compatible = "gpio";
        gpios = <&gpioa 9 GPIO_ACTIVE_HIGH>; // EXP_GPIO9
        status = "okay";
    };

    spi5_mosi {
        compatible = "gpio";
        gpios = <&gpioa 10 GPIO_ACTIVE_HIGH>; // EXP_GPIO10
        status = "okay";
    };

    spi5_sck {
        compatible = "gpio";
        gpios = <&gpioa 11 GPIO_ACTIVE_HIGH>; // EXP_GPIO11
        status = "okay";
    };
};


&cryp1 {
	status = "okay";
};

&dsi {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			dsi_in: endpoint {
				remote-endpoint = <&ltdc_ep1_out>;
			};
		};

		port@1 {
			reg = <1>;
			dsi_out: endpoint {
				remote-endpoint = <&panel_in>;
			};
		};
	};

	panel_otm8009a: panel-otm8009a@0 {
		compatible = "orisetech,otm8009a";
		reg = <0>;
		reset-gpios = <&gpioe 4 GPIO_ACTIVE_LOW>;
		power-supply = <&v3v3>;
		status = "okay";

		port {
			panel_in: endpoint {
				remote-endpoint = <&dsi_out>;
			};
		};
	};
};

&hdp {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&hdp2_gpo &hdp2_pins_a>;
	pinctrl-1 = <&hdp2_sleep_pins_a>;
	status = "disabled";
};

&i2c1 {
	touchscreen@38 {
		compatible = "focaltech,ft6236";
		reg = <0x38>;
		interrupts = <2 2>;
		interrupt-parent = <&gpiof>;
		interrupt-controller;
		touchscreen-size-x = <480>;
		touchscreen-size-y = <800>;
		vcc-supply = <&v3v3>;
		iovcc-supply = <&v3v3>;
		panel = <&panel_otm8009a>;
		status = "okay";
	};
};

&ltdc {
	default-on;
	status = "okay";

	port {
		#address-cells = <1>;
		#size-cells = <0>;

		ltdc_ep1_out: endpoint@1 {
			reg = <1>;
			remote-endpoint = <&dsi_in>;
		};
	};
};

&rtc {
	st,lsco = <RTC_OUT2_RMP>;
	pinctrl-0 = <&rtc_out2_rmp_pins_a>;
	pinctrl-names = "default";
};

/* Wifi */
&sdmmc2 {
	pinctrl-names = "default", "opendrain", "sleep";
	pinctrl-0 = <&sdmmc2_b4_pins_a>;
	pinctrl-1 = <&sdmmc2_b4_od_pins_a>;
	pinctrl-2 = <&sdmmc2_b4_sleep_pins_a>;
	non-removable;
	cap-sdio-irq;
	st,neg-edge;
	bus-width = <4>;
	vmmc-supply = <&v3v3>;
	mmc-pwrseq = <&wifi_pwrseq>;
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	brcmf: bcrmf@1 {
		reg = <1>;
		compatible = "brcm,bcm4329-fmac";
	};
};

/* Bluetooth */
&usart2 {
	pinctrl-names = "default", "sleep", "idle";
	pinctrl-0 = <&usart2_pins_c>;
	pinctrl-1 = <&usart2_sleep_pins_c>;
	pinctrl-2 = <&usart2_idle_pins_c>;
	uart-has-rtscts;
	status = "okay";

	bluetooth {
		shutdown-gpios = <&gpioz 6 GPIO_ACTIVE_HIGH>;
		compatible = "brcm,bcm43438-bt";
		max-speed = <3000000>;
		vbat-supply = <&v3v3>;
		vddio-supply = <&v3v3>;
	};
};

 

 

0 REPLIES 0