Re: spidev.c ?


Using 'make nconfig' I selected the following options:
(Keep in mind I using an Altera/Intel Arria 10 SoC which uses DesignWare hard SPI controllers. BUT the SPI controllers I'm concerned with now are soft controllers defined in the FPGA code).

                     .config - Linux/arm 5.4.74 Kernel Configuration
 ┌── SPI support ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
                             --- SPI support                                                                                         
                             [*]   Debug support for SPI drivers                                                                     
                             -*-   SPI memory extension                                                                              
                                   *** SPI Master Controller Drivers ***                                                             
                             <M>   Altera SPI Controller                                             
                             <*>   Utilities for Bitbanging SPI masters                                                              
                             < >   Cadence SPI controller                                                                            
                             < >   CLPS711X host SPI controller                                                                      
                             <*>   DesignWare SPI controller core support                                                            
                             <*>     PCI interface driver for DW SPI core                                                            
                             <*>     Memory-mapped io interface driver for DW SPI core                                               
                                   *** SPI Protocol Masters ***                                                                      
                             <M>   User mode SPI device driver support                                                               
                             <M>   spi loopback test framework support                                                               
                             < >   Infineon TLE62X0 (for power switching)                                                            
                             [*]   SPI slave protocol handlers                                                                       
                             <M>     SPI slave handler reporting boot up time                                                        │
 │                            <M>     SPI slave handler controlling system state                                                      │
This got the SPI nodes to show up in /sys/firmware/devicetree/ but there were no udev files (/dev/spidevXX). So I commented out the 'interrupts' in the DTSI file and the udev files appeared?
spi2: spi@0xc00c0800 { // hps_spi_1553_int
   address-cells = <0x1>;
   #size-cells = <0x0>;
   reg = <0xc00c0800 0x20>;
   // interrupt-parent = <&intc>;
   // interrupts = <0 24 IRQ_TYPE_EDGE_FALLING>;
   num-cs = <0x1>;
   status = "okay";

   spidev@0 {
      compatible = "rohm,dh2228fv";
      #address-cells = <0x1>;
      #size-cells = <0x0>;
      reg = <0x0>;
      spi-max-frequency = <0x1f400>;
      // enable-dma = <0x1>;
BUT I need those interrupts. Thoughts and/or suggestions?

On 2021-03-19 01:10, Zoran wrote:
Hello John,

It seems that your target is configured correctly. Since you have all
the components you should and must have as SPI framework.

Namely I was looking for /sys/bus (since you must have an SPI bus
driver), and then /sys/class (since as my best understanding is that
SPI is a master/slave device), you must have class/). Others are
assumed, you added debug directories.

When I separately build spidev.c as an .ko and try
loading it, I get: "Device or resource busy"

This is understandable, since you already have included spidev.ko as
menuconfig value Y, so it is already present in the kernel, but as a
built-in part of the kernel (my best guess).

root@arria10:~# lsmod
Module                  Size  Used by
spi_altera             16384  0
spidev                 20480  0

I see that you did change the menuconfig, and made spidev to be M.

What I also see is that there are no dependencies between spidev and
spi_altera. This is what you really wanted?

But there are NO udev files for the SPI devices
defined in the DTSI file.

Could you, please, better explain this sentence? In more details (as
much as you can)?

Thank you,

On Thu, Mar 18, 2021 at 10:07 PM jchludzinski <jchludzinski@...> wrote:

root@arria10:~# find /sys/ -name 'spi*'


On 2021-03-18 03:44, Zoran wrote:

I am guessing here.... But what do you have while executing the
following command being in /sys
 as root?

root@arm:/sys# find . -name spi*


On Wed, Mar 17, 2021 at 5:41 PM jchludzinski via
<> wrote:

In the YOCTO/Linux source tree there's drivers/spi/ which has all the source for SPI drivers. There's only 1 file, spidev.c, which has:

static int __init spidev_init(void)
        int status;

        /* Claim our 256 reserved device numbers.  Then register a class
         * that will key udev/mdev to add/remove /dev nodes.  Last, register
         * the driver which manages those device numbers.
        BUILD_BUG_ON(N_SPI_MINORS > 256);
        status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
        if (status < 0)
                return status;

        spidev_class = class_create(THIS_MODULE, "spidev");
        if (IS_ERR(spidev_class)) {
                return PTR_ERR(spidev_class);

        status = spi_register_driver(&spidev_spi_driver);
        if (status < 0) {
        return status;

... for creating device files in udev.

So when I use 'make nconfig' to specifiy that I want a loadable module for the ALTERA SPI driver, why don't I see a spidev.o file in drivers/spi/ ?

How does spi-altera.ko create device files without a call to register_chrdev(...).

How is it a loadable module without module_init(...)?

When I separately build spidev.c as an .ko and try loading it, I get: "Device or resourse busy"


Join { to automatically receive all group messages.