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.

DRA821U: spi_sync_transfer read data always got 0

Part Number: DRA821U

Dear expert,

We are try to drive a SPI slave device through MCU_SPI1, we send cmd to the device, and we could get the data from slave when we check the oscilloscope, the MISO signal pin show the data already send out from deivce, the channel 2 is MISO signal at below figure.  BUT,  when we check the function spi_sync_transfer(), the rx data buf is 0, there is no data received!  could you pleae help to figure out what's wrong with our below configuration and code ?

DTS: 

mcu_spi1: spi@40310000 {
status="okay";
compatible = "ti,am654-mcspi","ti,omap4-mcspi";
reg = <0x0 0x40310000 0x0 0x400>;
interrupt-parent = <&gic500>;
interrupts = < GIC_SPI 849 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&k3_clks 275 1>;
clock-names = "mcu_mcspi2";
power-domains = <&k3_pds 275 TI_SCI_PD_EXCLUSIVE>;
#address-cells = <1>;
#size-cells = <0>;
};
mcu_spi1_pins_default: mcu-spi1-pins-default {
pinctrl-single,pins = <
J721E_WKUP_IOPAD(0xc0, PIN_INPUT, 0) /* (B18) WKUP_GPIO0_0.MCU_SPI1_CLK */
J721E_WKUP_IOPAD(0xc4, PIN_OUTPUT, 0) /* (B19) WKUP_GPIO0_1.MCU_SPI1_D0 MOSI*/
J721E_WKUP_IOPAD(0xc8, PIN_INPUT, 0) /* (D14) WKUP_GPIO0_2.MCU_SPI1_D1 MISO*/
>;
};
mcu_spi1_cs_pins_default: mcu-spi1-cs-pins-default {
pinctrl-single,pins = <
J721E_WKUP_IOPAD(0xcc, PIN_OUTPUT, 7) /* (B21) WKUP_GPIO0_3.MCU_SPI1_CS0 */
>;
};
&mcu_spi1 {
pinctrl-names = "default";
pinctrl-0 = <&mcu_spi1_pins_default &mcu_spi1_cs_pins_default>;
cs-gpios = <&wkup_gpio0 3 GPIO_ACTIVE_LOW>;
ti,pindir-d0-out-d1-in;
status="okay";
sja1105@0 {
status="okay";
#address-cells = <1>;
#size-cells = <0>;
reg = < 0>;
compatible = "nxp,sja1105q";
spi-max-frequency = <4000000>;
spi-cpha;
};
};
CODE:

spi_sync_transfer(spi, xfers, 2 * num_chunks);
  • Hi,

    Could you please read the value of the pinmux register when Linux is booted up and confirmed that it set for the SPI output? Also are you setting up SPI in TX + RX mode? If it is just TX only mode, then RX will be empty. Can you check SPI register to confirm the settings? 

    Regards,

    Brijesh

  • Hi, 

    we use spi-omap2-mcspi.c as the driver, there is the register set at function omap2_mcspi_transfer_one(), the code list below:

    	chconf = mcspi_cached_chconf0(spi);
    	chconf &= ~OMAP2_MCSPI_CHCONF_TRM_MASK;
    	chconf &= ~OMAP2_MCSPI_CHCONF_TURBO;
    
    	if (t->tx_buf == NULL)
    		chconf |= OMAP2_MCSPI_CHCONF_TRM_RX_ONLY;
    	else if (t->rx_buf == NULL)
    		chconf |= OMAP2_MCSPI_CHCONF_TRM_TX_ONLY;
    
    	if (cd && cd->turbo_mode && t->tx_buf == NULL) {
    		/* Turbo mode is for more than one word */
    		if (t->len > ((cs->word_len + 7) >> 3))
    			chconf |= OMAP2_MCSPI_CHCONF_TURBO;
    	}
    
    	mcspi_write_chconf0(spi, chconf);

    seems the code shall set the reg runtime. 

    or which register should we check ? what is the register name?

  • Hi,

    Can you please  MCSPI_CHCONF_ register for the SPI instance that you are using? In this register, bit12-13 are used to specify transmit/receive mode. 

    Regards,

    Brijesh

  • Hi Brijesh

    the register  MCU_MCPSI1_CFG -> MCSPI_CHCONF_0 is 200603EC after the system powered up. 

    we perform "insmod sja1105.ko",  there is one read command, then the register changed to 200633ED, seems the driver set the register correctly.

    BRs,

    Xiaodong

  • Hi xiaidong,

    It does not look like. Because value 0x3 for bit12-13 is reserved value. It must be set to 0x0 in order to use TX+RX mode. 

    13-12 TRM R/W 0h Transmit/receive modes
    0h (R/W) = Transmit-and-receive mode
    1h (R/W) = Receive-only mode
    2h (R/W) = Transmit-only mode
    3h (R/W) = Reserved

    Regards,

    Brijesh

  • Hi Rrijesh,

    after set the register to 0x20160fed, the same result we got. any other clue could be checked?

    BRs,

    Xiaodong