Removing either one deletes the SPI devices from /dev/

What's the difference between the two modules and how do they relate?

  • 2
    I thought BCM2835 refers to the CPU - did you mean spi-bcm2835 module? Apr 1 '21 at 23:59

This may simplistic, but spidev is a generic user space interface for all Linux systems.

The spi-bcm2835 module contains the knowledge of what the BCM2835's SPI hardware looks like and how it is controlled. So on a Raspberry Pi the spidev driver will call functions in spi-bcm2835 to implement the hardware access.

Likewise for a Linux system that uses the Marvel Armada 3700 SPI controller the spidev driver would instead make functions calls into the module compiled from spi-armada-3700.c.

Both modules contain exported functions with the same parameters and purpose so spidev does not need to know which module is being used. Which module the calls are made to is selected by the device tree and the linker.

As an example spidev_sync() calls spi_sync(), which calls _spi_sync(), which calls __spi_pump_messages(), and that calls bcm2835_spi_prepare_message(). If you turn on trace you can follow the calls.

             __spi_sync() {    
3.386 us      __spi_validate();    
2.291 us      _raw_spin_lock_irqsave();    
1.406 us      _raw_spin_unlock_irqrestore();    
2.136 us      _raw_spin_lock_irqsave();    
1.407 us      _raw_spin_unlock_irqrestore();    
2.135 us      _raw_spin_lock_irqsave();    
              __spi_queued_transfer() {    
1.146 us        _raw_spin_lock_irqsave();    
1.042 us        _raw_spin_unlock_irqrestore();    
5.417 us      }  //__spi_queued_transfer    
1.458 us      _raw_spin_unlock_irqrestore();    
2.239 us      _raw_spin_lock_irqsave();    
1.510 us      _raw_spin_unlock_irqrestore();    
2.187 us      _raw_spin_lock_irqsave();    
1.354 us      _raw_spin_unlock_irqrestore();    
              __spi_pump_messages() {    
2.188 us        _raw_spin_lock_irqsave();    
1.562 us        _raw_spin_unlock_irqrestore();    
                mutex_lock() {    
                  _cond_resched() {    
1.718 us            rcu_all_qs();    
5.156 us          }    
8.646 us        }    
                bcm2835_spi_prepare_message [spi_bcm2835]() {    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.