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.

Linux/PROCESSOR-SDK-AM437X: SPI communication issue

Part Number: PROCESSOR-SDK-AM437X
Other Parts Discussed in Thread: AM4372,

Tool/software: Linux

we are using AM437x sdk 4.03.05 as our reference design. And we want to utilize the SPI1 as specified below on EMV.

aliases {
i2c0 = &i2c0;
i2c1 = &i2c1;
i2c2 = &i2c2;
serial0 = &uart0;
serial1 = &uart1;
serial2 = &uart2;
serial3 = &uart3;
serial4 = &uart4;
serial5 = &uart5;
ethernet0 = &cpsw_emac0;
ethernet1 = &cpsw_emac1;
spi0 = &qspi;
spi1 = &spi1;
};

spi1_pins: pinmux_spi1_pins {
pinctrl-single,pins = <
AM4372_IOPAD(0x990, MUX_MODE3) /* spi2_clk */
AM4372_IOPAD(0x994, MUX_MODE3) /* spi2_d0 */
AM4372_IOPAD(0x998, MUX_MODE3) /* spi2_d1 */
AM4372_IOPAD(0x99c, MUX_MODE3) /* spi2_cs0 */
>;
};

&spi1 {
pinctrl-0 = <&spi1_pins>;
status = "okay";

spidev@0 {
compatible = "ti,tianma";
spi-max-frequency = <24000000>;
reg = <0>;
};

and in our newly added .c file we have

static const struct of_device_id tianma_of_match[] = {
{ .compatible = "ti,tianma", },
{},
};

static struct spi_driver tianma_spi_driver = {
.driver = {
.name = DRIVER_NAME,
.of_match_table = of_match_ptr(tianma_of_match),
},
.probe = tianma_probe,
.remove = tianma_remove,
};

The device is mounted and probe works fine. However, we do not see the spi pins working as expected. no signals generated on any of the spi pin. What do I miss?

Thanks.

  • Hi Wang,

    You can check with devmem2 tool if you have the correct and expected values in SPI1 pinmux registers. Check the pins in user space, as these pins might be overwrite by another driver.

    Regards,
    Pavel
  • Part Number: PROCESSOR-SDK-AM437X

    Tool/software: Linux

    HI,

    we have a module defined as:

    spi@481a0000 {
    compatible = "ti,am4372-mcspi", "ti,omap4-mcspi";
    reg = <0x481a0000 0x400>;
    interrupts = <0x0 0x7d 0x4>;
    ti,hwmods = "spi1";
    #address-cells = <0x1>;
    #size-cells = <0x0>;
    status = "okay";
    #address-cell = <0x1>;
    pinctrl-0 = <0x5d>;

    spidev@0 {
    reg = <0x0>;
    compatible = "ti,tianma";
    spi-max-frequency = <0x16e3600>;
    lcdreset-gpios = <0x4f 0xd 0x1>;
    };
    };

    and in our module, the piece of code return errors is:

    gpio = devm_gpiod_get(&spi->dev, "lcdreset", GPIOD_OUT_HIGH);
    if (IS_ERR(gpio))
    {
    dev_err(&spi->dev, "%%%%%%%%%% Failed to get lcdreset GPIO! %%%%%%%%%%%%%%%\n");
    dev_err(&spi->dev, "The gpio is: %d, return error is %d\n", gpio, PTR_ERR(gpio));
    return PTR_ERR(gpio);
    }

    The error log message are below:

    [ 1.140312] tianma spi1.0: Start tianma probe: %%%%%%%%%%%%%%%%%%%%%%%
    [ 1.146986] tianma spi1.0: GPIO lookup for consumer lcdreset
    [ 1.146991] tianma spi1.0: using device tree for GPIO lookup
    [ 1.147057] tianma spi1.0: lookup for GPIO lcdreset failed
    [ 1.147240] tianma spi1.0: %%%%% Failed to get lcdreset GPIO! %%%%%%%

    Why the code can not find the symbol "lcdreset"?

    Thanks

  • Hi, Pavel,

    I have double checked the pin mux registers and they are set correctly. And currently they are not used in SDK by any other applications. In other words, the pin assignment is correct.

    Please advise other thoughts. Thanks

    Jerry
  • Zhiwei Wang said:

    &spi1 {
    pinctrl-0 = <&spi1_pins>;
    status = "okay";

    spidev@0 {
    compatible = "ti,tianma";
    spi-max-frequency = <24000000>;
    reg = <0>;
    };

    Note that SPIDev is user space interface. In situations where a premade SPI driver doesn't exist or a user wants a simple means to send and receive SPI messages the spidev driver can be used. Spidev provides a user space accessible means to communicate with the SPI interface.

    So you need to use either Tianma kernel driver or spiedev userspace driver, but not both at the same time.

    When using spidev userspace driver, for compatible string you need to use: "spidev" or "rohm,dh2228fv" or "lineartechnology,ltc2488", not "ti,tianma". See below pointers for more info regarding spidev usage:

    linux-4.9.69/drivers/spi/spidev.c

    linux-4.9.69/Documentation/spi/spidev

    linux-4.9.69/arch/arm/boot/dts/am335x-boneblack-spi0.dtsi

    http://processors.wiki.ti.com/index.php/Linux_Core_SPI_User's_Guide#Linux_Userspace_Interface

    Regards,
    Pavel