Access to Configuration registers for SPI

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Access to Configuration registers for SPI

799 Views
jgutierrez
Contributor I

Hello,

How can I access directly to the configuration registers for the SPI module?

For example, register SPIx_MCR, for configure Fast Continuous Selection Format.

I have tried with IOCTL functions, but SPIDev library only have a few configuration parameters (mode, lsb_first, bits_per_word, max_speed,..,), and it dont allow advanced configurations.

- Kernel 4.14.78

- Yocto Warrior.

- C code.

Thank you.

Regards.

Labels (1)
0 Kudos
4 Replies

697 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please refer to tools/spi/spidev_test.c, ioctl() requests let your driver read or override the device's current settings for data transfer parameters.

 fd = open(device, O_RDWR);
        if (fd < 0)
                pabort("can't open device");

        /*
         * spi mode
         */
        ret = ioctl(fd, SPI_IOC_WR_MODE32, &mode);
        if (ret == -1)
                pabort("can't set spi mode");

        ret = ioctl(fd, SPI_IOC_RD_MODE32, &mode);
        if (ret == -1)
                pabort("can't get spi mode");

        /*
         * bits per word
         */
        ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
        if (ret == -1)
                pabort("can't set bits per word");

        ret = ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits);
        if (ret == -1)
                pabort("can't get bits per word");

0 Kudos

697 Views
jgutierrez
Contributor I

Hello Yiping, thank you for your response.

But I already knew those confgurations parameters and I use them succesfully.

I would like to modify specific configurations, for example, to set Fast Continuous Selection Format, the 29th bit of Module Configuration Register (MCR), as it is mentioned in LS1021A reference Manual, charapter 34.4.1.

I wonder if it is possible to modify from user space, using IOCT function.

Or if there is any other way to do it.

Thanks.

Kind regards.

0 Kudos

697 Views
yipingwang
NXP TechSupport
NXP TechSupport

spidev only provides limited userspace APIs. You have to modify SPI driver to set advanced registers.

0 Kudos

697 Views
jgutierrez
Contributor I

Thank you yipingwang‌.

I will try then with the modification of the driver.

Kind regards.

0 Kudos