Enabling DSPI in LS1012a

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Enabling DSPI in LS1012a

8,366 次查看
twalsh
Contributor I

Hi,

I'm currently developing on an ls1012a-frwy board, and trying to enable the DSPI driver in Linux.

I've tried the approach described in the solution to this post: https://community.nxp.com/t5/QorIQ/spidev-test-on-ls1012a/m-p/924573

But I'm not having any luck getting the "spidev" device to appear under /dev with those edits to my device tree.

I just need to be able to make raw reads/writes to the SPI bus, I'm assuming we treat the spidev device like a normal serial port in terms of how we interact with it in C/C++ code (open a file handle to it for reading/writing).

My project partner has configured our RCW with the following data, with SDHC2 configured for SPI operation:

 00000000: 0800000a 00000000 00000000 00000000
 00000010: 33050000 c000000c 40000000 00001800
 00000020: 00000000 00000000 00000000 000c47f2
 00000030: 00000000 1082a120 00000096 00000000

0 项奖励
回复
8 回复数

8,345 次查看
yipingwang
NXP TechSupport
NXP TechSupport

To use spidev, please open CONFIG_SPI, CONFIG_SPI_FSL_DSPI and CONFIG_SPI_SPIDEV in Kernel configuration file. 

Moreover, dts need modification, as below, under dspi node:

spidev0: spi@0

{

reg = <0>;

compatible = "rohm,dh2228fv";

spi-max-frequency = <3000000>;

};

8,270 次查看
twalsh
Contributor I

Hi @yipingwang ,

 

Wanted to check again if you had any additional ideas; I'm still unable to get this working with the changes described in my device tree. What do you think?

 

Thanks,

Taylor

0 项奖励
回复

8,191 次查看
yipingwang
NXP TechSupport
NXP TechSupport

This feature is tested and can be enabled in Linux4.14 kernel by following the below listed steps

enable config

CONFIG_GPIO_MPC8XXX=y

CONFIG_SERIAL_SC16IS7XX_CORE=y

CONFIG_SERIAL_SC16IS7XX=y

CONFIG_SERIAL_SC16IS7XX_SPI=y

Disable , CONFIG_SERIAL_DEV_CTRL_TTYPORT

CONFIG_SERIAL_DEV_CTRL_TTYPORT is not set

 

Apply dts patch

0001-arm64-dts-ls1012afrwy-add-spi-to-uart-enablement.patch

 

Test step:

  1. Flash RCW

tftp 0x81000000 <path/to/file>PBL_swapped_CRC_not_swapped.bin

sf probe 0:0; sf erase 0 10000; sf write 0x81000000 0x0 10000

  1. Append ramdisk_size in bootargs

console=ttyS0,115200 root=/dev/ram0 ramdisk_size=0x3000000 earlycon=uart8250,mmio,0x21c0500 lpj=250000

  1. tftp kernel image and boot

tftp 96000000 <path/of/image>kernel-ls1012a-frwy.itb && bootm 96000000

  1. Check if the device file is created for serial driver

ls /dev/ttySC0

  1. set baud rate

stty -F /dev/ttySC0 115200

  1. send some data on ttySC0

echo test1 > /dev/ttySC0

echo 12345 > /dev/ttySC0

same data should be seen on the other end via MIKRO-bus adaptor connected to serial-to-usb and finally to laptop.

  1. To receive some data on ttySC0

cat /dev/ttySC0

wait for the data to receive. Ctrl +C to break out of listening mode.

0 项奖励
回复

8,110 次查看
twalsh
Contributor I

@yipingwang 

After running through these instructions, I'm afraid I still am not able to get this working. ttySC0 does not appear in /dev/ after applying your patch and flashing that RCW data.

 

Also, isn't the sc16is7XX the uart-to-spi/i2c chip? I just need to be able to read and write raw data onto the DSPI bus.

0 项奖励
回复

8,050 次查看
yipingwang
NXP TechSupport
NXP TechSupport

Please enable CONFIG_SPI, CONFIG_SPI_FSL_DSPI and CONFIG_SPI_SPIDEV in Kernel configuration file.

Then add the following in arch/arm64/boot/dts/freescale/fsl-ls1012a-frwy.dts

&dspi {
bus-num = <0>;
status = "okay";
spidev0: spi@0

{

reg = <0>;

compatible = "rohm,dh2228fv";

spi-max-frequency = <3000000>;

};

};

I checked the above modification in LSDK 21.08, it worked, device /dev/spidev0.0 was created.

I uploaded lsdk2108_yocto_tiny_LS_arm64.itb here https://support.nxp.com/s/case/5002p00002s7Y5iAAE/community-enabling-dspi-in-ls1012a?language=en_US

You could use it to do verification on your target board.

=>tftp 0xa0000000 lsdk2108_yocto_tiny_LS_arm64.itb

=>bootm 0xa0000000#ls1012afrwy

0 项奖励
回复

8,041 次查看
twalsh
Contributor I

Thanks for the reply @yipingwang ,

 

I noticed last Friday that I was using an outdated version of the LSDK, so I updated to 21.08 (previously was still on 17.12); that has lead me to another problem now that I am trying to use your file to verify.

After following the instructions in docs/flexbuilder_usage.md to build the firmware, boot partition, and rootfs, and then flex-installer to load them onto my microSD card, my board is unable to boot, as if it is unable to read the microSD. I've attached a log of my serial console output. It is able to detect the card itself, but no kernel image. Plugging the card back into my Linux machine, the partitions showed up totally empty, despite flex-installer claiming to have successfully written/partitioned the card.

(Due to network restrictions in our office, I am unable to use tftp to load over ethernet at the moment)

I built and loaded using the following commands from docs/build_and_deploy.md, with your provided *.itb file copied into build/images/:

$ flex-builder -i mkrfs -r ubuntu:lite
$ flex-builder -i mkboot
$ flex-builder -i merge-component -r ubuntu:lite
$ flex-builder -i packrfs -r ubuntu:lite
$ cd build/images
$ flex-installer -r rootfs_2108_ubuntu_lite_arm64.tgz -b boot_LS_arm64_lts_5.10.tgz -d /dev/sdb (where /dev/sdb is my microSD card in a card-reader)

Thanks,

Taylor

0 项奖励
回复

8,013 次查看
yipingwang
NXP TechSupport
NXP TechSupport

You need to upgrade bootloader image to LSDK 21.08.

Please download pre-built firmware image with the following command.

$ wget https://www.nxp.com/lgfiles/sdk/lsdk2108/firmware_ls1012afrwy_qspiboot.img

Then copy the firmware image to SD card or USB device, use the following command to load image to DDR memory in u-boot.

=> ext2load mmc 0:2 0xa0000000  firmware_ls1012afrwy_qspiboot.img

=> sf probe 0:0

=> sf erase 0 +$filesize

=>sf write 0xa0000000 0 $filesize

0 项奖励
回复

8,329 次查看
twalsh
Contributor I

Thank you very much for the response. 

I was able to verify that those components/options are enabled in my kernel config, and I modified my device tree to include that entry under the dspi node, but I'm still unable to find spidev in my system. Running "modprobe spidev" generates no error messages, but it does not appear under /dev. I can see an entry for spidev in /sys/bus/spi/drivers/, though. I also don't see any kernel errors on boot regarding SPI or DSPI. 

Including the change you suggested, this is what my &dspi node currently looks like in my fsl-ls1012a-frwy.dts file:

&dspi {
        bus-num = <0>;
        status = "okay";

        spidev0: spi@0 {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "rohm,dh2228fv";
                reg = <0>;
                spi-max-frequency = <3000000>;
        };

        sc16is740: sc16is740@0 {
                compatible = "nxp,sc16is740";
                reg = <0>;
                spi-max-frequency = <4000000>;
                clocks = <&clk24m>;
                interrupt-parent = <&gpio1>;
                interrupts = <13 2>;
                clk24m: oscillator {
                        #clock-cells = <0>;
                        compatible = "fixed-clock";
                        clock-frequency = <24000000>;
                };

        };
};

(located in <SDK_ROOT>/flexbuild-ls1012afrwy/packages/linux/linux/arch/arm64/boot/dts/freescale/fsl-ls1012a-frwy.dts)

 

Is there something else that needs to be added/configured/changed in my device tree in order for this to work?

 

Thanks,

Taylor

0 项奖励
回复