This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

求助:AM437X的SPI2无法正常工作,搞不定了



网上找了很多问题贴,已经搞不清PIN的设置了。以下是我的设置,可以排除其他引脚功能占用。
spi2_pins_default: spi2_pins_default {
		pinctrl-single,pins = <
			0x260 (PIN_INPUT_PULLUP | INPUT_EN | MUX_MODE0) /* spi_sclk */
            0x264 (PIN_OUTPUT_PULLUP | MUX_MODE0) /* spi_MOSI */
            0x268 (PIN_INPUT_PULLUP | MUX_MODE0)  /* spi_MISO */
            0x26c (PIN_OUTPUT_PULLUP | MUX_MODE0) /* spi_cs   */
		>;
	};

	/* Optional sleep pin settings. Must manually enter values in the below skeleton. */
	spi2_pins_sleep: spi2_pins_sleep {
		pinctrl-single,pins = <
			0x260 (PIN_INPUT_PULLUP | INPUT_EN | MUX_MODE0) /* spi_sclk */
            0x264 (PIN_OUTPUT_PULLUP | MUX_MODE0) /* spi_MOSI */
            0x268 (PIN_INPUT_PULLUP | MUX_MODE0)  /* spi_MISO */
            0x26c (PIN_OUTPUT_PULLUP | MUX_MODE0) /* spi_cs   */
		>;
	};
&spi2 {
		compatible = "ti,am4372-mcspi","ti,omap4-mcspi";
		reg = <0x481a2000 0x400>;
		interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>;
		ti,hwmods = "spi2";
		#address-cells = <1>;
		#size-cells = <0>;
		status = "okay";
		pinctrl-names = "default", "sleep";
		pinctrl-0 = <&spi2_pins_default>;
		pinctrl-1 = <&spi2_pins_sleep>;
		spidev@0{
		    compatible        = "linux,spidev";
		    reg               = <0>;
		    spi-max-frequency = <10000000>;
		};
};

目前情况:在/dev下有spidev1.0,spidev_test能正常运行,但接收数据全为0。示波器能检测到时钟CLK,信号正确;MISO、MOSI、CS无信号;

  • 自己结帖!

    原因:TI默认D0为MISO,D1为MOSI,修改dts文件,再加上cs选择就可以了。

    &spi2 {
    		compatible = "ti,am4372-mcspi","ti,omap4-mcspi";
    		reg = <0x481a2000 0x400>;
    		#interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>;
    		ti,hwmods = "spi2";
     ti,pindir-d0-out-d1-in = <1>; ti,spi-num-cs = <2>;
    		#address-cells = <1>;
    		#size-cells = <0>;
    		status = "okay";
    		pinctrl-names = "default";
    		pinctrl-0 = <&spi2_pins_default>;
    		spidev@0{
    		    compatible        = "rohm,dh2228fv";
    		    reg               = <0>;
    		    spi-max-frequency = <48000000>;
    		};
    };
  • &spi2 {
    		compatible = "ti,am4372-mcspi","ti,omap4-mcspi";
    		reg = <0x481a2000 0x400>;
    		#interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>;
    		ti,hwmods = "spi2";
    		ti,pindir-d0-out-d1-in = <1>;  
    		ti,spi-num-cs = <2>;
    		#address-cells = <1>;
    		#size-cells = <0>;
    		status = "okay";
    		pinctrl-names = "default";
    		pinctrl-0 = <&spi2_pins_default>;
    		spidev@0{
    		    compatible        = "rohm,dh2228fv";
    		    reg               = <0>;
    		    spi-max-frequency = <48000000>;
    		};
    };