SAMA5D27-SOM1-EK1 spidev not mounted

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

linux4es
Posts: 2
Joined: Sun Oct 18, 2020 3:03 pm

SAMA5D27-SOM1-EK1 spidev not mounted

Sun Oct 18, 2020 3:42 pm

Dear experts,

I'm following the AN_3253_How-to-Use-SAMA5D2-SPI-Under-Linux-00003253a.pdf to enable the spidev on SAMA5D27-SOM1-EK board. What I did change was :

1. sama5d2.dtsi

Code: Select all

                        flx4: flexcom@fc018000 {
                                compatible = "atmel,sama5d2-flexcom";
                                reg = <0xfc018000 0x200>;
//                              clocks = <&pmc PMC_TYPE_PERIPHERAL 23>;
                                clocks = <&flx4_clk>;
                                #address-cells = <1>;
                                #size-cells = <1>;
                                ranges = <0x0 0xfc018000 0x800>;
                                status = "okay";
                        };

                        flx4_clk: flx4_clk {
                                #clock-cells = <0>;
                                reg = <23>;
                                atmel,clk-output-range = <0 83000000>;
                        };
2. at91-sama5d27_som1_ek.dts

Code: Select all

                       flx4: flexcom@fc018000 {
                                atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_SPI>;
                                status = "okay";

                                uart6: serial@200 {
                                        compatible = "atmel,at91sam9260-usart";
                                        ...
                                        status = "disabled"; /* Conflict with spi3 and i2c3. */
                                };

                                spi3: spi@400 {
                                        compatible = "atmel,at91rm9200-spi";
                                        reg = <0x400 0x200>;
                                        interrupts = <23 IRQ_TYPE_LEVEL_HIGH 7>;
//                                      clocks = <&pmc PMC_TYPE_PERIPHERAL 23>;
                                        clocks = <&flx4_clk>;
                                        clock-names = "spi_clk";
                                        pinctrl-names = "default";
                                        pinctrl-0 = <&pinctrl_mikrobus_spi &pinctrl_mikrobus1_spi_cs &pinctrl_mikrobus2_spi_cs>;
                                        atmel,fifo-size = <16>;
                                        status = "okay"; /* Conflict with uart6 and i2c3. */

                                        spidev@1 {
                                                compatible = "atmel,at91rm9200-spidev";
                                                reg = <1>;
                                                spi-max-frequency = <1000000>;
                                        };
                                };

                                i2c3: i2c@600 {
                                        compatible = "atmel,sama5d2-i2c";
                                        ...
                                        status = "disabled"; /* Conflict with uart6 and spi3. */
                                };

Code: Select all

                                pinctrl_mikrobus1_spi_cs: mikrobus1_spi_cs {
                                        pinmux = <PIN_PD0__FLEXCOM4_IO4>;
                                        bias-disable;
                                };

                                pinctrl_mikrobus2_spi_cs: mikrobus2_spi_cs {
                                        pinmux = <PIN_PC31__FLEXCOM4_IO3>;
                                        bias-disable;
                                };

                                pinctrl_mikrobus_spi: mikrobus_spi {
                                        pinmux = <PIN_PC28__FLEXCOM4_IO0>,
                                                 <PIN_PC29__FLEXCOM4_IO1>,
                                                 <PIN_PC30__FLEXCOM4_IO2>;
                                        bias-disable;
                                };
3. spidev.c

Code: Select all

#ifdef CONFIG_OF
static const struct of_device_id spidev_dt_ids[] = {
        { .compatible = "rohm,dh2228fv" },
        { .compatible = "lineartechnology,ltc2488" },
        { .compatible = "ge,achc" },
        { .compatible = "semtech,sx1301" },
        { .compatible = "lwn,bk4" },
        { .compatible = "dh,dhcom-board" },
        { .compatible = "menlo,m53cpld" },
        { .compatible = "atmel,at91rm9200-spidev" },
        {},
};
MODULE_DEVICE_TABLE(of, spidev_dt_ids);
#endif

4. Also, in sama5_defconfig

Code: Select all

..
CONFIG_SPI_SPIDEV=y 
...


But, there's no spidev in /dev folder. And dmesg | grep spi gave :

Code: Select all

# dmesg | grep spi                                                             
atmel_spi f8000000.spi: No TX DMA channel, DMA is disabled                     
atmel_spi f8000000.spi: Atmel SPI Controller using PIO only                    
atmel_spi f8000000.spi: Using FIFO (16 data)                                   
atmel_spi f8000000.spi: Atmel SPI Controller version 0x311 at 0xf8000000 (irq )
atmel_spi fc018400.spi: No TX DMA channel, DMA is disabled                     
atmel_spi fc018400.spi: Atmel SPI Controller using PIO only                    
atmel_spi fc018400.spi: Using FIFO (16 data)                                   
atmel_spi fc018400.spi: Atmel SPI Controller version 0x311 at 0xfc018400 (irq )
spi-nor spi2.0: unrecognized JEDEC id bytes: ff ff ff ff ff ff                 
spi-nor: probe of spi2.0 failed with error -2  
If I remove the J13 (DBOOT Control CS of SOM1 QSPI), the unrecognized JEDEC error disappears :

Code: Select all

 
# dmesg | grep spi
atmel_spi f8000000.spi: No TX DMA channel, DMA is disabled
atmel_spi f8000000.spi: Atmel SPI Controller using PIO only
atmel_spi f8000000.spi: Using FIFO (16 data)
atmel_spi f8000000.spi: Atmel SPI Controller version 0x311 at 0xf8000000 (irq )
atmel_spi fc018400.spi: No TX DMA channel, DMA is disabled
atmel_spi fc018400.spi: Atmel SPI Controller using PIO only
atmel_spi fc018400.spi: Using FIFO (16 data)
atmel_spi fc018400.spi: Atmel SPI Controller version 0x311 at 0xfc018400 (irq )
spi-nor spi2.0: sst26vf064b (8192 Kbytes)
6 fixed-partitions partitions found on MTD device spi2
Creating 6 MTD partitions on "spi2":
However, there's still no spidev :

Code: Select all

# ls /dev/ | grep spi                                                          
# 

I then find any information related to spi in the system by issuing the following command :

Code: Select all

# find / -name "*spi*"
/sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018400.spi
/sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018400.spi/spi_master
/sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018400.spi/spi_master/spi1
/sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018400.spi/spi_master/spi1/statistics/spi_sync
/sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018400.spi/spi_master/spi1/statistics/spi_async
/sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018400.spi/spi_master/spi1/statistics/spi_sync_immediate
/sys/devices/platform/ahb/ahb:apb/f0024000.spi
/sys/devices/platform/ahb/ahb:apb/f0024000.spi/spi_master
/sys/devices/platform/ahb/ahb:apb/f0024000.spi/spi_master/spi2
/sys/devices/platform/ahb/ahb:apb/f0024000.spi/spi_master/spi2/statistics/spi_sync
/sys/devices/platform/ahb/ahb:apb/f0024000.spi/spi_master/spi2/statistics/spi_async
/sys/devices/platform/ahb/ahb:apb/f0024000.spi/spi_master/spi2/statistics/spi_sync_immediate
/sys/devices/platform/ahb/ahb:apb/f0024000.spi/spi_master/spi2/spi2.0
/sys/devices/platform/ahb/ahb:apb/f0024000.spi/spi_master/spi2/spi2.0/statistics/spi_sync
/sys/devices/platform/ahb/ahb:apb/f0024000.spi/spi_master/spi2/spi2.0/statistics/spi_async
/sys/devices/platform/ahb/ahb:apb/f0024000.spi/spi_master/spi2/spi2.0/statistics/spi_sync_immediate
/sys/devices/platform/ahb/ahb:apb/f8000000.spi
/sys/devices/platform/ahb/ahb:apb/f8000000.spi/spi_master
/sys/devices/platform/ahb/ahb:apb/f8000000.spi/spi_master/spi0
/sys/devices/platform/ahb/ahb:apb/f8000000.spi/spi_master/spi0/statistics/spi_sync
/sys/devices/platform/ahb/ahb:apb/f8000000.spi/spi_master/spi0/statistics/spi_async
/sys/devices/platform/ahb/ahb:apb/f8000000.spi/spi_master/spi0/statistics/spi_sync_immediate
/sys/class/spi_master
/sys/class/spi_master/spi2
/sys/class/spi_master/spi0
/sys/class/spi_master/spi1
/sys/firmware/devicetree/base/__symbols__/qspi1
/sys/firmware/devicetree/base/__symbols__/pinctrl_qspi1_default
/sys/firmware/devicetree/base/__symbols__/spi2
/sys/firmware/devicetree/base/__symbols__/spi0
/sys/firmware/devicetree/base/__symbols__/pinctrl_mikrobus_spi
/sys/firmware/devicetree/base/__symbols__/pinctrl_spi0_default
/sys/firmware/devicetree/base/__symbols__/pinctrl_mikrobus2_spi_cs
/sys/firmware/devicetree/base/__symbols__/spi3
/sys/firmware/devicetree/base/__symbols__/qspi0
/sys/firmware/devicetree/base/__symbols__/spi1
/sys/firmware/devicetree/base/__symbols__/pinctrl_mikrobus1_spi_cs
/sys/firmware/devicetree/base/ahb/apb/flexcom@fc018000/spi@400
/sys/firmware/devicetree/base/ahb/apb/spi@f0020000
/sys/firmware/devicetree/base/ahb/apb/flexcom@fc014000/spi@400
/sys/firmware/devicetree/base/ahb/apb/spi@fc000000
/sys/firmware/devicetree/base/ahb/apb/spi@f8000000
/sys/firmware/devicetree/base/ahb/apb/pinctrl@fc038000/qspi1_default
/sys/firmware/devicetree/base/ahb/apb/pinctrl@fc038000/mikrobus2_spi_cs
/sys/firmware/devicetree/base/ahb/apb/pinctrl@fc038000/mikrobus_spi
/sys/firmware/devicetree/base/ahb/apb/pinctrl@fc038000/mikrobus1_spi_cs
/sys/firmware/devicetree/base/ahb/apb/pinctrl@fc038000/spi0_default
/sys/firmware/devicetree/base/ahb/apb/spi@f0024000
/sys/firmware/devicetree/base/ahb/apb/spi@f0024000/flash@0/spi-rx-bus-width
/sys/firmware/devicetree/base/ahb/apb/spi@f0024000/flash@0/spi-tx-bus-width
/sys/firmware/devicetree/base/ahb/apb/spi@f0024000/flash@0/spi-max-frequency
/sys/bus/platform/devices/fc018400.spi
/sys/bus/platform/devices/f0024000.spi
/sys/bus/platform/devices/f8000000.spi
/sys/bus/platform/drivers/spi_gpio
/sys/bus/platform/drivers/atmel_spi
/sys/bus/platform/drivers/atmel_spi/fc018400.spi
/sys/bus/platform/drivers/atmel_spi/f8000000.spi
/sys/bus/platform/drivers/atmel_qspi
/sys/bus/platform/drivers/atmel_qspi/f0024000.spi
/sys/bus/spi
/sys/bus/spi/devices/spi2.0
/sys/bus/spi/drivers/spi-nor
/usr/bin/spi-config
/usr/bin/spi-pipe
/usr/lib/node_modules/npm/node_modules/gauge/spin.js
/usr/lib/python3.8/site-packages/spidev-3.4-py3.8.egg-info
/usr/lib/python3.8/site-packages/spidev.cpython-38-arm-linux-gnueabihf.so
/usr/lib/python3.8/site-packages/mpio/spi.pyc
/usr/lib/python3.8/site-packages/mpio/spi.py
/usr/share/egt/samples/layout/icons/spinprogress.png
/usr/share/vim/vim81/ftplugin/slpspi.vim
/usr/share/vim/vim81/syntax/slpspi.vim
/usr/share/vim/vim81/syntax/spice.vim
/usr/sbin/spidev_test
/lib/modules/5.4.41-linux4sam-2020.04/kernel/drivers/staging/wilc1000/wilc-spi.ko
/lib/modules/5.4.41-linux4sam-2020.04/kernel/drivers/net/dsa/microchip/ksz9477_spi.ko
/proc/irq/27/f0024000.spi
/proc/irq/30/f8000000.spi
/proc/irq/180/fc018400.spi

I have the impression that the spi node within the flx4: flexcom@fc018000 node is spi1, not the spi3 as expected :

Code: Select all

/sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018400.spi
/sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018400.spi/spi_master
/sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018400.spi/spi_master/spi1
/sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018400.spi/spi_master/spi1/statistics/spi_sync
/sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018400.spi/spi_master/spi1/statistics/spi_async
/sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018400.spi/spi_master/spi1/statistics/spi_sync_immediate
And does this seem to be in conflict the other spi1 node defined in sama5d2.dtsi ?

Code: Select all

                        spi1: spi@fc000000 {
                                compatible = "atmel,at91rm9200-spi";
                                reg = <0xfc000000 0x100>;
                                interrupts = <34 IRQ_TYPE_LEVEL_HIGH 7>;
                                dmas = <&dma0
                                        (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) |
                                         AT91_XDMAC_DT_PERID(8))>,
                                       <&dma0
                                        (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) |
                                         AT91_XDMAC_DT_PERID(9))>;
                                dma-names = "tx", "rx";
                                clocks = <&pmc PMC_TYPE_PERIPHERAL 34>;
                                clock-names = "spi_clk";
                                atmel,fifo-size = <16>;
                                #address-cells = <1>;
                                #size-cells = <0>;
                                status = "okay";
                        };
My system info :

Code: Select all

# uname -ra
Linux sama5 5.4.41-linux4sam-2020.04 #1 Sat Oct 17 09:07:47 +07 2020 armv7l GNU/Linux

Thanks in advance,
Khang
blue_z
Location: USA
Posts: 2131
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D27-SOM1-EK1 spidev not mounted

Tue Oct 20, 2020 1:50 am

linux4es wrote: I'm following the AN_3253_How-to-Use-SAMA5D2-SPI-Under-Linux-00003253a.pdf ...

What I did change was :

1. sama5d2.dtsi

1.) That application note did not tell you to make any changes to sama5d2.dtsi.
The sama5d2.dtsi file is the Device Tree file for the SoC itself, and is a minimal and generic configuration that can be used for any board.
Since you have not made any changes to the SoC silicon, you have no reason for making changes to this file.
Your board-level configuration (e.g. using a spidev pseudo-device) needs to be specified at the board level of the Device Tree, which in your case is the at91-sama5d27_som1_ek.dts file, and is the only "action" specified for the DT in that application note.

2.) That application note specifies a Linux kernel version (i.e. Linux4SAM 6.0 aka Linux kernel 4.14.x), but you choose to use a different kernel version.
Be aware that Device Tree files for Microchip devices are still considered a "work in progress" and "unstable", meaning that DT files (and constructs for properties) must match the kernel source code.
Apparently you are blindly making edits which reflect an old construction of the DT 'clocks' property which no longer applies for the kernel version you are actually using.
(It doesn't help that somebody at Microchip only partially updated the bindings documentation for the Flexcom.)
By using an example of older DT files for patching a more recent kernel/DT, you will probably end up with a disabled Flexcom/SPI device (due to no peripheral clock).

Regards
linux4es
Posts: 2
Joined: Sun Oct 18, 2020 3:03 pm

Re: SAMA5D27-SOM1-EK1 spidev not mounted

Tue Oct 20, 2020 3:01 am

Dear blue_z,

Firstly, thanks for your reply.
1.) That application note did not tell you to make any changes to sama5d2.dtsi.
The sama5d2.dtsi file is the Device Tree file for the SoC itself, and is a minimal and generic configuration that can be used for any board.
Since you have not made any changes to the SoC silicon, you have no reason for making changes to this file.
Your board-level configuration (e.g. using a spidev psuedo-device) needs to be specified at the board level of the Device Tree, which in your case is the at91-sama5d27_som1_ek.dts file, and is the only "action" specified for the DT in that application note.
--> Thanks for this confirmation, since the sama5d2.dtsi the AN_3253_How-to-Use-SAMA5D2-SPI-Under-Linux-00003253a.pdf is not exactly the same with the one of linux4sam-2020.04 branch, that the reason I made following modification of this file, especially for :

Code: Select all

flx4: flexcom@fc018000 {
...
clocks = <&flx4_clk>; // definition for uart4 clock source
..
status = "disabled"; // default disabled, and will be replaced with “okay”
};

flx4_clk: flx4_clk {
#clock-cells = <0>;
reg = <23>; // PID for FLEXCOM4 is 23, this definition of offset will be used to enable
// FLEXCOM4 clock in PMC
atmel,clk-output-range = <0 83000000>; // FLEXCOM4 input clock, max frequency is 83MHz
};
Also, there's certain misunderstanding that the status should be changed to okay because of the following comment :
status = "disabled"; // default disabled, and will be replaced with “okay”
Anyway, I tried both without and with the above modification but neither of them work. Now, I will revert the sama5d2.dtsi to the original version.

2.) That application note specifies a Linux kernel version (i.e. Linux4SAM 6.0 aka Linux kernel 4.14.x), but you choose to use a different kernel version.
Be aware that Device Tree files for Microchip devices are still considered a "work in progress" and "unstable", meaning that DT files (and constructs for properties) must match the kernel source code.
--> This is because I find no active discussion about this subject for recent kernel versions which is largely supported by other SoC manufacturers. They seem to be more active.
Apparently you are blindly making edits which reflect an old construction of the DT 'clocks' property which no longer applies for the kernel version you are actually using.
(It doesn't help that somebody at Microchip only partially updated the bindings documentation for the Flexcom.)
By using an example of older DT files for patching a more recent kernel/DT, you will probably end up with a disabled Flexcom/SPI device (due to no peripheral clock).
--> Since there's no new version of the AN_3253_How-to-Use-SAMA5D2-SPI-Under-Linux-00003253a.pdf, I did believe that it could be applied straight-forwardly for newer kernel versions supported by AT91 community.
By using an example of older DT files for patching a more recent kernel/DT, you will probably end up with a disabled Flexcom/SPI device (due to no peripheral clock).
--> Even-though we really expect to use the recent kernel version (5.x) but with your advice, I will switch back to the mentioned Linux kernel version in the AN_3253_How-to-Use-SAMA5D2-SPI-Under-Linux-00003253a.pdf (i.e. Linux4SAM 6.0 aka Linux kernel 4.14.x) for testing purpose.

Thanks and best regards,
Khang
Mokkael
Posts: 1
Joined: Fri Nov 13, 2020 11:39 pm

Re: SAMA5D27-SOM1-EK1 spidev not mounted

Fri Nov 13, 2020 11:45 pm

I am currently experiencing the exact same problem as it was described in the original post. The spidev devices are not mounted, although I am following the application note.

Did anybody find a solution to that problem?

Return to “LINUX”

Who is online

Users browsing this forum: Bing [Bot] and 13 guests