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

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
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
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
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!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
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
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

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