SlideShare a Scribd company logo
1 of 28
Download to read offline
ELC, May 2014
What’s going on with SPI?
• Hardware overview
• Framework overview
• Recent enhancements
• Future plans
Overview
Simple bidirectional serial bus with four signals:
• Master Out Slave In (MOSI)
• Master In Slave Out (MISO)
• Clock
• Chip select
• Little endian byte ordering for words
What is SPI?
Comparable with I2C:
• Four wires instead of two
• Typically 1-2 orders of magnitude faster
• Full duplex
• Very simple implementation
Applications
• Flash
• Mixed signal ICs
• DSPs
What is SPI?
• No support at all, using GPIOs
• Very slow and inefficient
• Commonly used for chip select
Controller hardware
• PIO based FIFOs
• Less slow
• Requires CPU access every word
• DMA based FIFOs
• Less work for CPU
• Higher setup overhead
• Faster for large blocks of data
• Dual and quad mode
• Extra data lines, mainly used with flash (v3.12)
● Specialised flash controllers
• No support at all, using GPIOs
• Very slow and inefficient
• Commonly used for chip select
• PIO based FIFOs
• Less slow
• Requires CPU access every word
• DMA based FIFOs
• Less work for CPU
• Higher setup overhead
• Faster for large blocks of data
• Dual and quad mode
• Extra data lines, mainly used with flash (v3.12)
• Specialised flash controllers
Controller hardware
Originally contributed by David Brownell
• Merged in 2.6.16 (released March 2006)
• Largely unchanged until recently
Standard device model bus:
• Controllers and devices
• Device registration via machine driver/firmware
Basic software stack
Simple message based interface for devices
• List of transfers, for scatter/gather and mixed read/write
• Some settings can change per transfer/message
• Optionally asynchronous
Device interface
struct spi_transfer {
const void*tx_buf;
void *rx_buf;
unsigned len;
};
void spi_message_init(struct spi_message *m);
void spi_message_add_tail(struct spi_transfer *t,
struct spi_message *m);
int spi_async(struct spi_device *spi, struct
spi_message *message);
int spi_sync(struct spi_device *spi,
struct spi_message *message);
Device interface
Very basic:
int (*transfer)(struct spi_device *spi,
struct spi_message *mesg);
Basic driver interface
Executes in atomic context!
Not just for bitbanging:
int (*setup_transfer)(struct spi_device *spi,
struct spi_transfer *t);
void (*chipselect)(struct spi_device *spi, int is_on);
int (*txrx_bufs)(struct spi_device *spi,
struct spi_transfer *t);
• Factors out logic to do with transfer list
• Can even support DMA
“Bitbang” driver framework
• No code reuse outside of bitbang
• Lots of wheels of varying shapes
• Good ideas need to be copied
What’s missing?
Many ways of specifying/validation same information
• Selecting a transfer speed
• Bits per word settings
• Overriding these per transfer
• Validating buffer sizes
Standard parameter checking and handling
int (*prepare_transfer_hardware)(struct spi_master *m);
int (*transfer_one_message)(struct spi_master *m,
struct spi_message *m);
int (*unprepare_transfer_hardware)(struct spi_master *m);
• Factors out code
• Standard synchronisation with suspend
• Standard runtime PM implementation
• Standard support for managing priority of pump
Contributed by Linus Walleij, merged in v3.4 (May 2012)
Message queue
Moves more logic from spi_bitbang into core:
int (*prepare_message)(struct spi_master *master,
struct spi_message *message);
int (*unprepare_message)(struct spi_master *master,
struct spi_message *message);
void (*set_cs)(struct spi_device *spi, bool enable);
int (*transfer_one)(struct spi_master *master,
struct spi_device *spi,
struct spi_transfer *transfer);
Merged in v3.13
Standard message parsing
Most drivers only handled some cases:
• Buffers need to be mapped before DMA
• Buffers may not be physically contiguous
• vmalloc()ed addresses need different mapping
Drivers provide a callback to check for DMA:
bool (*can_dma)(struct spi_master *master,
struct spi_device *spi,
struct spi_transfer *xfer);
If true passed sg_lists instead of buffers
Standard DMA mapping
• Extra data lines for higher speed
• Capability set when registering device
• Enabled per-transfer by device drivers
Contributed by Wang Yuhang, merged in v3.12
Dual and quad modes
What’s next?
• Handling controller chip select
• Standard way to set in DT
Standard GPIO chip select
Latency - spi_sync()
Device driver SPI thread Hardware/IRQ
Queue transfer
Start transfer
Wait...
Wait...
Start transfer
Wait...
Wake SPI
Schedule
Wake driver
Schedule
Return
Schedule
Latency - spi_async()
Device driver SPI thread Hardware/IRQ
Queue transfer
Start transfer
Wait...
Wait...
Start transfer
Wait...
Wake SPI
Schedule
Wake driver
Schedule
Return
Schedule
Start transfer Start transfer
Latency - complete in IRQ
Device driver SPI thread Hardware/IRQ
Queue transfer
Start transfer
Wait...
Wait...
Start transfer
Wait...
Wake driver
Schedule
Return
Schedule
Schedule
Latency - start immediately
Device driver SPI thread Hardware/IRQ
Queue transfer
Wait...
Start transfer
Wait...
Wake SPI
Wake driver
Schedule
Return
Start transfer
• Do DMA mapping while prior transfer runs
• Coalesce transfers and use hardware scatter/gather
Latency
• Messages validated once and used several times
• Saves iterating and checking
• Allows drivers to keep buffers DMA mapped
• Mainly for very high bandwidth applications
Work being done by Martin Sperl
Pre-validated messages
• Use DMA transfers to set chip select and parameters
• Requires dmaengine and gpiolib enhancements
• Extremely low CPU overhead, runs from interrupt
Work being done by Martin Sperl
Fully DMA driven queues
• Simple bus, not so simple software
• Much more active development recently
• New hardware
• More demanding performance requirements
Summary
More about Linaro: http://www.linaro.org/about/
More about Linaro engineering: http://www.linaro.org/engineering/
How to join: http://www.linaro.org/about/how-to-join
Linaro members: www.linaro.org/members

More Related Content

What's hot

MIPI DevCon 2016: Accelerating UFS and MIPI UniPro Interoperability Testing
MIPI DevCon 2016: Accelerating UFS and MIPI UniPro Interoperability TestingMIPI DevCon 2016: Accelerating UFS and MIPI UniPro Interoperability Testing
MIPI DevCon 2016: Accelerating UFS and MIPI UniPro Interoperability TestingMIPI Alliance
 
Serial connectors, Protocols , USB (universal serial bus)
Serial connectors, Protocols , USB (universal serial bus)Serial connectors, Protocols , USB (universal serial bus)
Serial connectors, Protocols , USB (universal serial bus)A. Shamel
 
Block ciphers & public key cryptography
Block ciphers & public key cryptographyBlock ciphers & public key cryptography
Block ciphers & public key cryptographyRAMPRAKASHT1
 
Kernel Recipes 2015: Greybus
Kernel Recipes 2015: GreybusKernel Recipes 2015: Greybus
Kernel Recipes 2015: GreybusAnne Nicolas
 
LAS16-TR06: Remoteproc & rpmsg development
LAS16-TR06: Remoteproc & rpmsg developmentLAS16-TR06: Remoteproc & rpmsg development
LAS16-TR06: Remoteproc & rpmsg developmentLinaro
 
LAS16-400: Mini Conference 3 AOSP (Session 1)
LAS16-400: Mini Conference 3 AOSP (Session 1)LAS16-400: Mini Conference 3 AOSP (Session 1)
LAS16-400: Mini Conference 3 AOSP (Session 1)Linaro
 
Embedded c & working with avr studio
Embedded c & working with avr studioEmbedded c & working with avr studio
Embedded c & working with avr studioNitesh Singh
 
NXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded LinuxNXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded LinuxNEEVEE Technologies
 
Lecture 04 branch call and time delay
Lecture 04  branch call and time delayLecture 04  branch call and time delay
Lecture 04 branch call and time delayVajira Thambawita
 
TMS20DM8148 Embedded Linux Session II
TMS20DM8148 Embedded Linux Session IITMS20DM8148 Embedded Linux Session II
TMS20DM8148 Embedded Linux Session IINEEVEE Technologies
 
Linux on ARM 64-bit Architecture
Linux on ARM 64-bit ArchitectureLinux on ARM 64-bit Architecture
Linux on ARM 64-bit ArchitectureRyo Jin
 

What's hot (20)

MIPI DevCon 2016: Accelerating UFS and MIPI UniPro Interoperability Testing
MIPI DevCon 2016: Accelerating UFS and MIPI UniPro Interoperability TestingMIPI DevCon 2016: Accelerating UFS and MIPI UniPro Interoperability Testing
MIPI DevCon 2016: Accelerating UFS and MIPI UniPro Interoperability Testing
 
Serial connectors, Protocols , USB (universal serial bus)
Serial connectors, Protocols , USB (universal serial bus)Serial connectors, Protocols , USB (universal serial bus)
Serial connectors, Protocols , USB (universal serial bus)
 
PX4 Seminar 01
PX4 Seminar 01PX4 Seminar 01
PX4 Seminar 01
 
Block ciphers & public key cryptography
Block ciphers & public key cryptographyBlock ciphers & public key cryptography
Block ciphers & public key cryptography
 
Kernel Recipes 2015: Greybus
Kernel Recipes 2015: GreybusKernel Recipes 2015: Greybus
Kernel Recipes 2015: Greybus
 
LAS16-TR06: Remoteproc & rpmsg development
LAS16-TR06: Remoteproc & rpmsg developmentLAS16-TR06: Remoteproc & rpmsg development
LAS16-TR06: Remoteproc & rpmsg development
 
07 input output
07 input output07 input output
07 input output
 
LAS16-400: Mini Conference 3 AOSP (Session 1)
LAS16-400: Mini Conference 3 AOSP (Session 1)LAS16-400: Mini Conference 3 AOSP (Session 1)
LAS16-400: Mini Conference 3 AOSP (Session 1)
 
Communication Protocols (UART, SPI,I2C)
Communication Protocols (UART, SPI,I2C)Communication Protocols (UART, SPI,I2C)
Communication Protocols (UART, SPI,I2C)
 
Embedded c & working with avr studio
Embedded c & working with avr studioEmbedded c & working with avr studio
Embedded c & working with avr studio
 
TMS320DM8148 Embedded Linux
TMS320DM8148 Embedded LinuxTMS320DM8148 Embedded Linux
TMS320DM8148 Embedded Linux
 
NXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded LinuxNXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded Linux
 
17 registers
17 registers17 registers
17 registers
 
Computer arch
Computer archComputer arch
Computer arch
 
Lecture 04 branch call and time delay
Lecture 04  branch call and time delayLecture 04  branch call and time delay
Lecture 04 branch call and time delay
 
CPUs
CPUsCPUs
CPUs
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
TMS20DM8148 Embedded Linux Session II
TMS20DM8148 Embedded Linux Session IITMS20DM8148 Embedded Linux Session II
TMS20DM8148 Embedded Linux Session II
 
Linux on ARM 64-bit Architecture
Linux on ARM 64-bit ArchitectureLinux on ARM 64-bit Architecture
Linux on ARM 64-bit Architecture
 
Ccna routing
Ccna routingCcna routing
Ccna routing
 

Similar to What's going on with SPI

Cisco router basic
Cisco router basicCisco router basic
Cisco router basicTapan Khilar
 
Sept 2017 boot process
Sept 2017   boot processSept 2017   boot process
Sept 2017 boot processshahin raj
 
SOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC ToolsSOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC ToolsA B Shinde
 
Rina p4 rina workshop
Rina p4   rina workshopRina p4   rina workshop
Rina p4 rina workshopEduard Grasa
 
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLDesigning of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLJay Baxi
 
SMP implementation for OpenBSD/sgi
SMP implementation for OpenBSD/sgiSMP implementation for OpenBSD/sgi
SMP implementation for OpenBSD/sgiTakuya ASADA
 
Advanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONAdvanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONLyon Yang
 
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...DefconRussia
 
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...CanSecWest
 
BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!Linaro
 
Linkmeup v076(2019-06).2
Linkmeup v076(2019-06).2Linkmeup v076(2019-06).2
Linkmeup v076(2019-06).2eucariot
 
Nios2 and ip core
Nios2 and ip coreNios2 and ip core
Nios2 and ip coreanishgoel
 
Final Presentation on the Network layer
Final Presentation on the Network layerFinal Presentation on the Network layer
Final Presentation on the Network layerZee Haak
 
PLNOG 18 - Paweł Małachowski - Spy hard czyli regexpem po pakietach
PLNOG 18 - Paweł Małachowski - Spy hard czyli regexpem po pakietachPLNOG 18 - Paweł Małachowski - Spy hard czyli regexpem po pakietach
PLNOG 18 - Paweł Małachowski - Spy hard czyli regexpem po pakietachPROIDEA
 
NIOS II Processor.ppt
NIOS II Processor.pptNIOS II Processor.ppt
NIOS II Processor.pptAtef46
 

Similar to What's going on with SPI (20)

Cisco router basic
Cisco router basicCisco router basic
Cisco router basic
 
Sept 2017 boot process
Sept 2017   boot processSept 2017   boot process
Sept 2017 boot process
 
SOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC ToolsSOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC Tools
 
Rina p4 rina workshop
Rina p4   rina workshopRina p4   rina workshop
Rina p4 rina workshop
 
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLDesigning of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDL
 
Hardware hacking
Hardware hackingHardware hacking
Hardware hacking
 
SMP implementation for OpenBSD/sgi
SMP implementation for OpenBSD/sgiSMP implementation for OpenBSD/sgi
SMP implementation for OpenBSD/sgi
 
Advanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONAdvanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCON
 
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
Nikita Abdullin - Reverse-engineering of embedded MIPS devices. Case Study - ...
 
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
 
BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!
 
Linkmeup v076(2019-06).2
Linkmeup v076(2019-06).2Linkmeup v076(2019-06).2
Linkmeup v076(2019-06).2
 
Router configuration
Router configurationRouter configuration
Router configuration
 
Smart logic
Smart logicSmart logic
Smart logic
 
Lecture 03 basics of pic
Lecture 03 basics of picLecture 03 basics of pic
Lecture 03 basics of pic
 
Nios2 and ip core
Nios2 and ip coreNios2 and ip core
Nios2 and ip core
 
Final Presentation on the Network layer
Final Presentation on the Network layerFinal Presentation on the Network layer
Final Presentation on the Network layer
 
PLNOG 18 - Paweł Małachowski - Spy hard czyli regexpem po pakietach
PLNOG 18 - Paweł Małachowski - Spy hard czyli regexpem po pakietachPLNOG 18 - Paweł Małachowski - Spy hard czyli regexpem po pakietach
PLNOG 18 - Paweł Małachowski - Spy hard czyli regexpem po pakietach
 
NIOS II Processor.ppt
NIOS II Processor.pptNIOS II Processor.ppt
NIOS II Processor.ppt
 
pps Matters
pps Matterspps Matters
pps Matters
 

More from Mark Brown

Kernelci.org needs you!
Kernelci.org needs you!Kernelci.org needs you!
Kernelci.org needs you!Mark Brown
 
Regulators learning to play with others
Regulators  learning to play with othersRegulators  learning to play with others
Regulators learning to play with othersMark Brown
 
LCU13: Linaro Stable Kernel
LCU13: Linaro Stable KernelLCU13: Linaro Stable Kernel
LCU13: Linaro Stable KernelMark Brown
 
Linux audio for smartphones
Linux audio for smartphonesLinux audio for smartphones
Linux audio for smartphonesMark Brown
 
regmap: The power of subsystems and abstractions
regmap: The power of subsystems and abstractionsregmap: The power of subsystems and abstractions
regmap: The power of subsystems and abstractionsMark Brown
 

More from Mark Brown (6)

Kernelci.org needs you!
Kernelci.org needs you!Kernelci.org needs you!
Kernelci.org needs you!
 
Regulators learning to play with others
Regulators  learning to play with othersRegulators  learning to play with others
Regulators learning to play with others
 
LCU13: Linaro Stable Kernel
LCU13: Linaro Stable KernelLCU13: Linaro Stable Kernel
LCU13: Linaro Stable Kernel
 
LSK 13.07
LSK 13.07LSK 13.07
LSK 13.07
 
Linux audio for smartphones
Linux audio for smartphonesLinux audio for smartphones
Linux audio for smartphones
 
regmap: The power of subsystems and abstractions
regmap: The power of subsystems and abstractionsregmap: The power of subsystems and abstractions
regmap: The power of subsystems and abstractions
 

Recently uploaded

Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

What's going on with SPI

  • 1. ELC, May 2014 What’s going on with SPI?
  • 2. • Hardware overview • Framework overview • Recent enhancements • Future plans Overview
  • 3. Simple bidirectional serial bus with four signals: • Master Out Slave In (MOSI) • Master In Slave Out (MISO) • Clock • Chip select • Little endian byte ordering for words What is SPI?
  • 4. Comparable with I2C: • Four wires instead of two • Typically 1-2 orders of magnitude faster • Full duplex • Very simple implementation Applications • Flash • Mixed signal ICs • DSPs What is SPI?
  • 5. • No support at all, using GPIOs • Very slow and inefficient • Commonly used for chip select Controller hardware • PIO based FIFOs • Less slow • Requires CPU access every word • DMA based FIFOs • Less work for CPU • Higher setup overhead • Faster for large blocks of data • Dual and quad mode • Extra data lines, mainly used with flash (v3.12) ● Specialised flash controllers
  • 6. • No support at all, using GPIOs • Very slow and inefficient • Commonly used for chip select • PIO based FIFOs • Less slow • Requires CPU access every word • DMA based FIFOs • Less work for CPU • Higher setup overhead • Faster for large blocks of data • Dual and quad mode • Extra data lines, mainly used with flash (v3.12) • Specialised flash controllers Controller hardware
  • 7. Originally contributed by David Brownell • Merged in 2.6.16 (released March 2006) • Largely unchanged until recently Standard device model bus: • Controllers and devices • Device registration via machine driver/firmware Basic software stack
  • 8. Simple message based interface for devices • List of transfers, for scatter/gather and mixed read/write • Some settings can change per transfer/message • Optionally asynchronous Device interface
  • 9. struct spi_transfer { const void*tx_buf; void *rx_buf; unsigned len; }; void spi_message_init(struct spi_message *m); void spi_message_add_tail(struct spi_transfer *t, struct spi_message *m); int spi_async(struct spi_device *spi, struct spi_message *message); int spi_sync(struct spi_device *spi, struct spi_message *message); Device interface
  • 10. Very basic: int (*transfer)(struct spi_device *spi, struct spi_message *mesg); Basic driver interface Executes in atomic context!
  • 11. Not just for bitbanging: int (*setup_transfer)(struct spi_device *spi, struct spi_transfer *t); void (*chipselect)(struct spi_device *spi, int is_on); int (*txrx_bufs)(struct spi_device *spi, struct spi_transfer *t); • Factors out logic to do with transfer list • Can even support DMA “Bitbang” driver framework
  • 12. • No code reuse outside of bitbang • Lots of wheels of varying shapes • Good ideas need to be copied What’s missing?
  • 13. Many ways of specifying/validation same information • Selecting a transfer speed • Bits per word settings • Overriding these per transfer • Validating buffer sizes Standard parameter checking and handling
  • 14. int (*prepare_transfer_hardware)(struct spi_master *m); int (*transfer_one_message)(struct spi_master *m, struct spi_message *m); int (*unprepare_transfer_hardware)(struct spi_master *m); • Factors out code • Standard synchronisation with suspend • Standard runtime PM implementation • Standard support for managing priority of pump Contributed by Linus Walleij, merged in v3.4 (May 2012) Message queue
  • 15. Moves more logic from spi_bitbang into core: int (*prepare_message)(struct spi_master *master, struct spi_message *message); int (*unprepare_message)(struct spi_master *master, struct spi_message *message); void (*set_cs)(struct spi_device *spi, bool enable); int (*transfer_one)(struct spi_master *master, struct spi_device *spi, struct spi_transfer *transfer); Merged in v3.13 Standard message parsing
  • 16. Most drivers only handled some cases: • Buffers need to be mapped before DMA • Buffers may not be physically contiguous • vmalloc()ed addresses need different mapping Drivers provide a callback to check for DMA: bool (*can_dma)(struct spi_master *master, struct spi_device *spi, struct spi_transfer *xfer); If true passed sg_lists instead of buffers Standard DMA mapping
  • 17. • Extra data lines for higher speed • Capability set when registering device • Enabled per-transfer by device drivers Contributed by Wang Yuhang, merged in v3.12 Dual and quad modes
  • 19. • Handling controller chip select • Standard way to set in DT Standard GPIO chip select
  • 20. Latency - spi_sync() Device driver SPI thread Hardware/IRQ Queue transfer Start transfer Wait... Wait... Start transfer Wait... Wake SPI Schedule Wake driver Schedule Return Schedule
  • 21. Latency - spi_async() Device driver SPI thread Hardware/IRQ Queue transfer Start transfer Wait... Wait... Start transfer Wait... Wake SPI Schedule Wake driver Schedule Return Schedule Start transfer Start transfer
  • 22. Latency - complete in IRQ Device driver SPI thread Hardware/IRQ Queue transfer Start transfer Wait... Wait... Start transfer Wait... Wake driver Schedule Return Schedule Schedule
  • 23. Latency - start immediately Device driver SPI thread Hardware/IRQ Queue transfer Wait... Start transfer Wait... Wake SPI Wake driver Schedule Return Start transfer
  • 24. • Do DMA mapping while prior transfer runs • Coalesce transfers and use hardware scatter/gather Latency
  • 25. • Messages validated once and used several times • Saves iterating and checking • Allows drivers to keep buffers DMA mapped • Mainly for very high bandwidth applications Work being done by Martin Sperl Pre-validated messages
  • 26. • Use DMA transfers to set chip select and parameters • Requires dmaengine and gpiolib enhancements • Extremely low CPU overhead, runs from interrupt Work being done by Martin Sperl Fully DMA driven queues
  • 27. • Simple bus, not so simple software • Much more active development recently • New hardware • More demanding performance requirements Summary
  • 28. More about Linaro: http://www.linaro.org/about/ More about Linaro engineering: http://www.linaro.org/engineering/ How to join: http://www.linaro.org/about/how-to-join Linaro members: www.linaro.org/members