Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Linux Device Drivers Development

You're reading from   Linux Device Drivers Development Develop customized drivers for embedded Linux

Arrow left icon
Product type Paperback
Published in Oct 2017
Publisher Packt
ISBN-13 9781785280009
Length 586 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
John Madieu John Madieu
Author Profile Icon John Madieu
John Madieu
Arrow right icon
View More author details
Toc

Table of Contents (31) Chapters Close

Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface
1. Introduction to Kernel Development FREE CHAPTER 2. Device Driver Basis 3. Kernel Facilities and Helper Functions 4. Character Device Drivers 5. Platform Device Drivers 6. The Concept of a Device Tree 7. I2C Client Drivers 8. SPI Device Drivers 9. Regmap API - A Register Map Abstraction 10. IIO Framework 11. Kernel Memory Management 12. DMA - Direct Memory Access 13. The Linux Device Model 14. Pin Control and GPIO Subsystem 15. GPIO Controller Drivers - gpio_chip 16. Advanced IRQ Management 17. Input Devices Drivers 18. RTC Drivers 19. PWM Drivers 20. Regulator Framework 21. Framebuffer Drivers 22. Network Interface Card Drivers Index

The driver architecture


The required header for SPI stuff in the Linux kernel is <linux/spi/spi.h>. Before talking about the driver structure, let's see how SPI devices are defined in the kernel. An SPI device is represented in the kernel as an instance of spi_device. The instance of the driver that manages them is the struct spi_driver structure.

The device structure

The struct spi_device structure represents an SPI device, and is defined in include/linux/spi/spi.h:

struct spi_device { 
    struct devicedev; 
    struct spi_master*master; 
    u32 max_speed_hz; 
    u8 chip_select; 
    u8 bits_per_word; 
    u16 mode; 
    int irq; 
    [...] 
    int cs_gpio;        /* chip select gpio */ 
}; 

Some fields that are not meaningful for us have been removed.  The following are the meanings of the elements in the structure:

  • master: This represents the SPI controller (bus) on which the device is connected.
  • max_speed_hz: This is the maximum clock rate to be used with this chip (on the current...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images