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.

AM5728: sspi cmd in U-boot can not work

Part Number: AM5728
Other Parts Discussed in Thread: TSC2046

Hi Expert

In kernel our tsc2046 is working on MCSPI2 fine, but we would like to read it by sspi cmd in U-boot.

The cmd sspi is not working,

Hit any key to stop autoboot:  0
=>            
=> sspi 2:0.0 16 d0
Invalid bus 2 (err=-19)
=>
can you help on this error?
In \u-boot-2018.01\arch\arm\dts\am571x-idk.dts we have
    aliases {
        spi0 = &mcspi2;
    };
&mcspi2 {
    status = "okay";
    ti,pindir-d0-out-d1-in;
    tsc2046@0 {
        interrupt-parent = <&gpio1>;
        interrupts = <25 0>;          /* gpio1_25=25 */
        pendown-gpio = <&gpio1 25 GPIO_ACTIVE_HIGH>;
        reg = <0>;                        /* CS0 */
        compatible = "spidev";
        spi-max-frequency = <1500000>;
        vcc-supply = <&ldousb_reg>;
        ti,x-min = /bits/ 16 <0>;
        ti,x-max = /bits/ 16 <8000>;
        ti,y-min = /bits/ 16 <0>;
        ti,y-max = /bits/ 16 <4800>;
        ti,x-plate-ohms = /bits/ 16 <40>;
        ti,pressure-max = /bits/ 16 <255>;
        ti,swap-xy;
        wakeup-source;
    };
};
In u-boot-2018.01\configs\am57xx_evm_defconfig we have
CONFIG_DM_SPI=y
CONFIG_TI_QSPI=y
In u-boot-2018.01\arch\arm\mach-omap2\omap5\hw_data.c we have
void enable_basic_clocks(void)
+       (*prcm)->cm_l4per_i2c2_clkctrl,
+       (*prcm)->cm_l4per_mcspi2_clkctrl,
void enable_basic_uboot_clocks(void)
+       (*prcm)->cm_l4per_mcspi2_clkctrl,
  • Hi Daniel,

    I will get back to you with details on this in couple of days.

    Best Regards,
    Keerthy

  • Hi Daniel,

    sspi has never been validated on AM57xx u-boot. So that might not work.
    That said CONFIG_TI_QSPI is for QSPI and for MCSPI you need to be enabling CONFIG_OMAP3_SPI
    if not already enabled.

    sspi 2:0.0 16 d0


    The above command also seems wrong as there is this alias: 

    spi0 = &mcspi2;

    So
    sspi 0:0.0 16 d0


    Let me know if that helps but we have not tried sspi.


    Best Regards,
    Keerthy

  • Hi Keerthy

    the config setting in \u-boot-2018.01\am57xx_evm\.config is

    #
    # SPI Support
    #
    CONFIG_DM_SPI=y
    # CONFIG_ALTERA_SPI is not set
    # CONFIG_CADENCE_QSPI is not set
    # CONFIG_DESIGNWARE_SPI is not set
    # CONFIG_EXYNOS_SPI is not set
    # CONFIG_FSL_DSPI is not set
    # CONFIG_ICH_SPI is not set
    # CONFIG_MVEBU_A3700_SPI is not set
    # CONFIG_ROCKCHIP_SPI is not set
    # CONFIG_TEGRA114_SPI is not set
    # CONFIG_TEGRA20_SFLASH is not set
    # CONFIG_TEGRA20_SLINK is not set
    # CONFIG_TEGRA210_QSPI is not set
    # CONFIG_XILINX_SPI is not set
    # CONFIG_SOFT_SPI is not set
    # CONFIG_FSL_ESPI is not set
    # CONFIG_FSL_QSPI is not set
    # CONFIG_ATCSPI200_SPI is not set
    # CONFIG_TI_QSPI is not set
    CONFIG_OMAP3_SPI=y

    we can use => sspi 0:0.0 16 D0 without Invalid bus 2 (err=-19)

    but the return value is always 0000

    => sspi 0:0.0 16 d0
    uclass_find_device_by_seq: 0 0
    - 0 -1 'spi@4809a000'
    - -1 -1 'tsc2046@0'
    - not found
    uclass_find_device_by_seq: 1 0
    - 0 -1 'spi@4809a000'
    - found
    uclass_find_device_by_seq: 0 0
    - 0 -1 'spi@4809a000'
    - -1 -1 'tsc2046@0'
    - not found
    OF: ** translation for device spi@4809a000 **
    OF: bus is default (na=1, ns=1) on ocp
    OF: translating address: 00a00948
    OF: parent bus is default (na=2, ns=2) on
    OF: walking ranges...
    OF: default map, cp=0, s=3221225472, da=1208590336
    OF: parent translation for: 00000000 00000000
    OF: with offset: 1208590336
    OF: one level translation: 00000000 00a00948
    OF: reached root node
    fdtdec_get_uint: ti,pindir-d0-out-d1-in: (not found)
    ofnode_read_u32: spi-max-frequency: (not found)
    spi_find_chip_select: plat=bdf1c5b0, cs=0
    uclass_find_device_by_seq: 0 -1
    uclass_find_device_by_seq: 0 0
    - 0 0 'spi@4809a000'
    - found
    uclass_find_device_by_seq: 0 1
    - 0 0 'spi@4809a000'
    - -1 -1 'tsc2046@0'
    - not found
    OF: ** translation for device tsc2046@0 **
    __of_translate_address: Bad cell count for tsc2046@0
    fdtdec_get_uint: ti,pindir-d0-out-d1-in: (not found)
    ofnode_read_u32: spi-max-frequency: 0x16e360 (1500000)
    spi_get_bus_and_cs: bus=bdf1c500, slave=bdf1e4c0
    0000
    =>

    config anything wrong about SPI function ?

    change am571x-idk.dts to

    &mcspi2 {
    status = "okay";
    ti,pindir-d0-out-d1-in;
        tsc2046@0 {
            interrupt-parent = <&gpio1>;
            interrupts = <25 0>; /* gpio1_25=25 */
            pendown-gpio = <&gpio1 25 GPIO_ACTIVE_HIGH>;
            reg = <0>; /* CS0 */
            compatible = "ti,omap4-mcspi";
            ti,pindir-d0-out-d1-in;
            spi-max-frequency = <1500000>;
            vcc-supply = <&ldousb_reg>;
            ti,x-min = /bits/ 16 <0>;
            ti,x-max = /bits/ 16 <8000>;
            ti,y-min = /bits/ 16 <0>;
            ti,y-max = /bits/ 16 <4800>;
            ti,x-plate-ohms = /bits/ 16 <40>;
            ti,pressure-max = /bits/ 16 <255>;
            ti,swap-xy;
            wakeup-source;
        };
    };

  • Hi Keerthy

    We try to set and unset ti,pindir-d0-out-d1-in; in DTB

    but the result are same.

  • Hi Keerthy

    Could you help to reply?

    Thanks

    Daniel

  • Hi Keerthy

    We have another problem is SPI bus error in SPL(MLO)

    although we can use sspi cmd without bus error, but the SPI bus is still error in SPL(MLO)

    U-Boot SPL 2018.01 (Oct 29 2020 - 16:03:20)
    DRA722-GP ES2.1
    omap24_i2c_findpsc: speed [kHz]: 100 psc: 0x17 sscl: 0xd ssch: 0xf
    Trying to boot from MMC1
    uclass_find_device_by_seq: 0 0
    - -1 -1 'mmc@4809c000'
    - -1 -1 'mmc@480b4000'
    - not found
    uclass_find_device_by_seq: 1 0
    - -1 -1 'mmc@4809c000'
    - -1 -1 'mmc@480b4000'
    - not found
    malloc_simple: size=6c, ptr=94, limit=100000: 81f00028
    malloc_simple: size=4, ptr=98, limit=100000: 81f00094
    uclass_find_device_by_seq: 0 -1
    uclass_find_device_by_seq: 0 0
    - -1 -1 'mmc@4809c000'
    - -1 -1 'mmc@480b4000'
    - not found
    OF: ** translation for device mmc@4809c000 **
    OF: bus is default (na=1, ns=1) on ocp
    OF: translating address: 00c00948
    OF: parent bus is default (na=2, ns=2) on
    OF: walking ranges...
    OF: default map, cp=0, s=3221225472, da=1208598528
    OF: parent translation for: 00000000 00000000
    OF: with offset: 1208598528
    OF: one level translation: 00000000 00c00948
    OF: reached root node
    ofnode_read_u32: bus-width: 0x4 (4)
    ofnode_read_u32: max-frequency: 0xb71b000 (192000000)
    ofnode_read_bool: cap-sd-highspeed: false
    ofnode_read_bool: cap-mmc-highspeed: false
    ofnode_read_bool: sd-uhs-sdr12: true
    ofnode_read_bool: sd-uhs-sdr25: true
    ofnode_read_bool: sd-uhs-sdr50: true
    ofnode_read_bool: sd-uhs-sdr104: true
    ofnode_read_bool: sd-uhs-ddr50: true
    ofnode_read_bool: mmc-ddr-1_8v: false
    ofnode_read_bool: mmc-ddr-1_2v: false
    ofnode_read_bool: mmc-hs200-1_8v: false
    ofnode_read_bool: mmc-hs200-1_2v: false
    fdtdec_get_bool: ti,dual-volt
    fdtdec_get_bool: no-1-8-v
    OF: ** translation for device mmc@4809c000 **
    OF: bus is default (na=1, ns=1) on ocp
    OF: translating address: 00c00948
    OF: parent bus is default (na=2, ns=2) on
    OF: walking ranges...
    OF: default map, cp=0, s=3221225472, da=1208598528
    OF: parent translation for: 00000000 00000000
    OF: with offset: 1208598528
    OF: one level translation: 00000000 00c00948
    OF: reached root node
    fdtdec_get_bool: cd-inverted
    malloc_simple: size=170, ptr=208, limit=100000: 81f00098
    fdtdec_get_int: #gpio-cells: 0x2 (2)
    malloc_simple: size=16, ptr=21e, limit=100000: 81f00208
    gpio_request_tail: Node 'mmc@4809c000', property 'wp-gpios', failed to request GPIO index 0: -2
    malloc_simple: size=10, ptr=230, limit=100000: 81f00220
    fail to find default mode FDT_ERR_NOTFOUND
    no pinctrl state for default mode
    malloc_simple: size=6c, ptr=29c, limit=100000: 81f00230
    malloc_simple: size=4, ptr=2a0, limit=100000: 81f0029c
    uclass_find_device_by_seq: 0 -1
    uclass_find_device_by_seq: 0 0
    - -1 0 'mmc@4809c000'
    - found
    uclass_find_device_by_seq: 0 1
    - -1 0 'mmc@4809c000'
    - -1 -1 'mmc@480b4000'
    - not found
    OF: ** translation for device mmc@480b4000 **
    OF: bus is default (na=1, ns=1) on ocp
    OF: translating address: 00400b48
    OF: parent bus is default (na=2, ns=2) on
    OF: walking ranges...
    OF: default map, cp=0, s=3221225472, da=1208696832
    OF: parent translation for: 00000000 00000000
    OF: with offset: 1208696832
    OF: one level translation: 00000000 00400b48
    OF: reached root node
    ofnode_read_u32: bus-width: 0x8 (8)
    ofnode_read_u32: max-frequency: 0x5b8d800 (96000000)
    ofnode_read_bool: cap-sd-highspeed: false
    ofnode_read_bool: cap-mmc-highspeed: false
    ofnode_read_bool: sd-uhs-sdr12: true
    ofnode_read_bool: sd-uhs-sdr25: true
    ofnode_read_bool: sd-uhs-sdr50: false
    ofnode_read_bool: sd-uhs-sdr104: false
    ofnode_read_bool: sd-uhs-ddr50: false
    ofnode_read_bool: mmc-ddr-1_8v: true
    ofnode_read_bool: mmc-ddr-1_2v: false
    ofnode_read_bool: mmc-hs200-1_8v: false
    ofnode_read_bool: mmc-hs200-1_2v: false
    fdtdec_get_bool: ti,dual-volt
    fdtdec_get_bool: no-1-8-v
    OF: ** translation for device mmc@480b4000 **
    OF: bus is default (na=1, ns=1) on ocp
    OF: translating address: 00400b48
    OF: parent bus is default (na=2, ns=2) on
    OF: walking ranges...
    OF: default map, cp=0, s=3221225472, da=1208696832
    OF: parent translation for: 00000000 00000000
    OF: with offset: 1208696832
    OF: one level translation: 00000000 00400b48
    OF: reached root node
    fdtdec_get_bool: cd-inverted
    malloc_simple: size=170, ptr=410, limit=100000: 81f002a0
    gpio_request_tail: Node 'mmc@480b4000', property 'cd-gpios', failed to request GPIO index 0: -2
    gpio_request_tail: Node 'mmc@480b4000', property 'wp-gpios', failed to request GPIO index 0: -2
    malloc_simple: size=10, ptr=420, limit=100000: 81f00410
    fail to find default mode FDT_ERR_NOTFOUND
    no pinctrl state for default mode
    81f00440
    81f00480
    81f004c0
    81f00500
    part_init: try 'EFI': ret=-1
    81f00540
    part_init: try 'DOS': ret=0
    spl: mmc boot mode: fs
    malloc_simple: size=b, ptr=553, limit=100000: 81f00548
    malloc_simple: size=10, ptr=564, limit=100000: 81f00554
    malloc_simple: size=c, ptr=570, limit=100000: 81f00564
    uclass_find_device_by_seq: 0 2
    malloc_simple: size=18, ptr=588, limit=100000: 81f00570
    - not found
    uclass_find_device_by_seq: 1 2
    - not found
    Invalid bus 2 (err=-19)
    Error using spi_get_bus_and_cs
    load uboot from FAT fs...
    81f005c0
    81f00600

    SPI bus is fine under U-boot. Is there any difference when using SPI bus?

    Regards,

    Scott

  • Hi Scott,

    sspi as mentioned earlier is not validated.

    Scott Lin2 said:
    SPI bus is fine under U-boot. Is there any difference when using SPI bus?



    Can you check the device tree nodes for SPI and dependent ones have u-boot,dm-spl flag is set.

    Also DIN is not toggling so there might be issues with the slave side or DIN pinmux could be the issue.
    Since at kernel it is working can you just ensure that same configurations are done?

    Best Regards,
    Keerthy

  • Hi Keerthy

    We tried to add u-boot,dm-spl in \u-boot-2018.01\arch\arm\dts\am571x-idk.dts

    &mcspi2 {
    	status = "okay";
    	ti,pindir-d0-out-d1-in;
    	u-boot,dm-spl;
    	tsc2046@0 {
    		interrupt-parent = <&gpio1>;
    		interrupts = <25 0>; /* gpio1_25=25 */
    		pendown-gpio = <&gpio1 25 GPIO_ACTIVE_HIGH>;
    		reg = <0>; /* CS0 */
    		compatible = "ti,omap4-mcspi";
    		ti,pindir-d0-out-d1-in;
    		u-boot,dm-spl;
    		spi-max-frequency = <1500000>;
    		vcc-supply = <&ldousb_reg>;
    		ti,x-min = /bits/ 16 <0>;
    		ti,x-max = /bits/ 16 <8000>;
    		ti,y-min = /bits/ 16 <0>;
    		ti,y-max = /bits/ 16 <4800>;
    		ti,x-plate-ohms = /bits/ 16 <40>;
    		ti,pressure-max = /bits/ 16 <255>;
    		ti,swap-xy;
    		wakeup-source;
    	};
    };

    => sspi 2:0.0 16 d0
    __of_translate_address: Bad cell count for tsc2046@0
    0000
    => sspi 2:0.0 16 d3
    0000
    =>

    In \u-boot-2018.01\board\ti\am57xx\mux_data.h we have
    	{SPI2_SCLK, (M0 | PIN_INPUT)},	/* spi2_sclk.spi2_sclk */                                       /* spi2_sclk.spi2_sclk */
    	{SPI2_D1, (M0 | PIN_INPUT | SLEWCONTROL)},	/* spi2_d1.spi2_d1 */                               /* spi2_d1.spi2_d1 */
    	{SPI2_D0, (M0 | PIN_INPUT | SLEWCONTROL)},	/* spi2_d0.spi2_d0 */                               /* spi2_d0.spi2_d0 */
    	{SPI2_CS0, (M0 | PIN_INPUT | SLEWCONTROL)},	/* spi2_cs0.spi2_cs0 */                             /* spi2_cs0.spi2_cs0 */

    and this is the only pinmux file we had modified and tsc2046 is working fine in Kernel dmesg

    [    1.843940] of_get_named_gpiod_flags: parsed 'pendown-gpio' property of node '/ocp/spi@4809a000/tsc2046@0[0]' - status (0)
    [    1.844400] ads7846 spi1.0: touchscreen, irq 167
    [    1.849509] input: ADS7846 Touchscreen as /devices/platform/44000000.ocp/4809a000.spi/spi_master/spi1/spi1.0/input/input0

    Regards,

    Scott

  • Scott Lin2 said:
     tsc2046@0 {
            interrupt-parent = <&gpio1>;
            interrupts = <25 0>; /* gpio1_25=25 */
            pendown-gpio = <&gpio1 25 GPIO_ACTIVE_HIGH>;
            reg = <0>; /* CS0 */
            compatible = "ti,omap4-mcspi";
            ti,pindir-d0-out-d1-in;
            u-boot,dm-spl;
            spi-max-frequency = <1500000>;
            vcc-supply = <&ldousb_reg>;
            ti,x-min = /bits/ 16 <0>;

    You are using ldousb_reg & gpio1 nodes in your node. Do they have u-boot,dm-spl set? If not please
    add the below lines:

    &ldousb_reg{
    u-boot,dm-spl
    };
    
    &gpio1{
    u-boot,dm-spl
    };
    
    

    Best Regards,
    Keerthy

  • Hi Keerthy

    / {
    	model = "TI AM5718 IDK";
    	compatible = "ti,am5718-idk", "ti,am5718", "ti,dra7";
    
    	memory@80000000 {
    		device_type = "memory";
    		reg = <0x0 0x80000000 0x0 0x40000000>;
    	};
    
    	aliases {
    		spi2 = &mcspi2;
    	};
    
    	ads7846reg: fixedregulator-ads7846-reg {
    		compatible = "regulator-fixed";
    		regulator-name = "ads7846-reg";
    		regulator-min-microvolt = <3300000>;
    		regulator-max-microvolt = <3300000>;
    		regulator-always-on;
    		regulator-boot-on;
    	};
    };
    
    &mcspi2 {
    	status = "okay";
    	ti,pindir-d0-out-d1-in;
    	u-boot,dm-spl;
    	tsc2046@0 {
    		interrupt-parent = <&gpio1>;
    		interrupts = <25 0>; /* gpio1_25=25 */
    		pendown-gpio = <&gpio1 25 GPIO_ACTIVE_HIGH>;
    		reg = <0>; /* CS0 */
    		compatible = "ti,omap4-mcspi";
    		ti,pindir-d0-out-d1-in;
    		u-boot,dm-spl;
    		spi-max-frequency = <1500000>;
    		vcc-supply = <&ads7846reg>;
    		ti,x-min = /bits/ 16 <0>;
    		ti,x-max = /bits/ 16 <8000>;
    		ti,y-min = /bits/ 16 <0>;
    		ti,y-max = /bits/ 16 <4800>;
    		ti,x-plate-ohms = /bits/ 16 <40>;
    		ti,pressure-max = /bits/ 16 <255>;
    		ti,swap-xy;
    		wakeup-source;
    	};
    };
    
    &ads7846reg{
    	u-boot,dm-spl;
    };
    
    &gpio1{
    	u-boot,dm-spl;
    };
    

    the value from cmd "sspi 2:0.0 16 d0" is still 0000

    Regards,

    Scott 

  • Scott Lin2 said:
    the value from cmd "sspi 2:0.0 16 d0" is still 0000



    Scott,

    Adding u-boot,dm-spl was for the SPL issue that you were mentioning: .

    As i have been mentioning the sspi is never supported/validated on SDK.

    Best Regards,
    Keerthy

  • Hi Keerthy

    In SPL(MLO), using spi bus is still error please see the following log

    U-Boot SPL 2018.01 (Nov 03 2020 - 12:04:35)
    DRA722-GP ES2.1
    Trying to boot from MMC1
    no pinctrl state for default mode
    no pinctrl state for default mode
    Invalid bus 2 (err=-19)
    Error using spi_get_bus_and_cs
    load uboot from FAT fs...
    
    
    U-Boot 2018.01 (Nov 03 2020 - 12:04:35 +0800)
    
    CPU  : DRA722-GP ES2.1
    Model: TI AM5718 IDK FTK
    Board: AM571x IDK REV 0.1
    DRAM:  1 GiB
    MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
    *** Warning - bad CRC, using default environment
    
    GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
    part_get_info_efi: *** ERROR: Invalid GPT ***
    GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
    part_get_info_efi: *** ERROR: Invalid Backup GPT ***
    SCSI:  SATA link 0 timeout.
    AHCI 0001.0300 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
    flags: 64bit ncq stag pm led clo only pmp pio slum part ccc apst 
    scanning bus for devices...
    Found 0 device(s).
    Net:   RMII External clock is not supported
    
    Warning: ethernet@48484000 using MAC address from ROM
    eth0: ethernet@48484000
    Hit any key to stop autoboot:  0 
    => sspi 2:0.0 16 d3
    __of_translate_address: Bad cell count for tsc2046@0
    0000
    => 

    Regards,

    Scott

  • Hi Scott,

    Can you share the code changes done for SPI enabling in SPL?

    Best Regards,
    Keerthy

  • Hi Keerthy 

    Support SPI in both U-boot and SPL the only change we have done are DTB and cm_l4per_mcspi2_clkctrl 

    In u-boot-2018.01\arch\arm\mach-omap2\omap5\hw_data.c we have
    void enable_basic_clocks(void)
    +       (*prcm)->cm_l4per_i2c2_clkctrl,
    +       (*prcm)->cm_l4per_mcspi2_clkctrl,
    void enable_basic_uboot_clocks(void)
    +       (*prcm)->cm_l4per_mcspi2_clkctrl,

    Regards,

    Scott

  • Hi Keerthy

    Could you help to reply?

    Thanks

    Scott

  • Hi Daniel,

    Apologies for the long silence. There is not much support for sspi in u-boot & even SPL side.
    The experts advice was to try on Linux. I believe that is already functional for you.

    Best Regards,
    Keerthy