Table of Contents

Preface

Section 1: Kernel Core Frameworks for Embedded Device Driver Development

Chapter 1: Linux Kernel Concepts for Embedded Developers

Technical requirements

The kernel locking API and shared objects

Spinlocks

Mutexes

The try-lock method

Waiting, sensing, and blocking in the Linux kernel

Work deferring mechanisms

SoftIRQs

Tasklets

Workqueues

Workqueues – a new generation

Linux kernel interrupt management

Designing an interrupt handler

Summary

Chapter 2: Leveraging the Regmap API and Simplifying the Code

Technical requirements

Introduction to regmap and its data structures – I2C, SPI, and MMIO

Accessing device registers

Quick recap on Linux kernel IRQ management

Regmap IRQ API and data structures

Summary

Chapter 3: Delving into the MFD Subsystem and Syscon API

Technical requirements

Introducing the MFD subsystem and Syscon APIs

Device tree binding for MFD devices

Understanding Syscon and simple-mfd

Introducing simple-mfd

Summary

Chapter 4: Storming the Common Clock Framework

Technical requirements

CCF data structures and interfaces

Understanding struct clk_hw and its dependencies

Registering/unregistering the clock provider

Exposing clocks to others (in detail)

Writing a clock provider driver

Providing clock ops

Putting it all together – global overview

Grabbing and releasing clocks

Preparing/unpreparing clocks

Rate functions

Parent functions

Putting it all together

Section 2: Multimedia and Power Saving in Embedded Linux Systems

Chapter 5: ALSA SoC Framework – Leveraging Codec and Platform Class Drivers

Technical requirements

Introduction to ASoC

ASoC Digital Audio Interface

ASoC sub-elements

Writing codec class drivers

Codec DAI and PCM (AKA DSP) configurations

The concept of controls

The concept of DAPM

Writing the platform class driver

The CPU DAI driver

The platform DMA driver AKA PCM DMA driver

Summary

Chapter 6: ALSA SoC Framework – Delving into the Machine Class Drivers

Technical requirements

Introduction to machine class drivers

The DAI link

Machine routing consideration

Codec pins

Board connectors

Machine routing

Clocking and formatting considerations

Sound card registration

Leveraging the simple-card machine driver

Codec-less sound cards

Summary

Chapter 7: Demystifying V4L2 and Video Capture Device Drivers

Technical requirements

Framework architecture and the main data structures

Initializing and registering a V4L2 device

Introducing video device drivers – the bridge driver

Initializing and registering the video device

Video device file operations

V4L2 ioctl handling

The videobuf2 interface and APIs

The concept of sub-devices

Sub-device initialization

Sub-device operations

Traditional sub-device (un)registration

V4L2 controls infrastructure

A word about control inheritance

Summary

Chapter 8: Integrating with V4L2 Async and Media Controller Frameworks

Technical requirements

The V4L2 async interface and the concept of graph binding

Graph binding

The V4L2 async and graph-oriented API

V4L2 async

The Linux media controller framework

The media controller abstraction model

Integrating media controller support in the driver

Media controller from user space

Summary

Chapter 9:Leveraging the V4L2 API from the User Space

Technical requirements

Introduction to V4L2 from user space

The V4L2 user space API

Video device opening and property management

Querying the device capabilities

Buffer management

Image (buffer) format

Requesting buffers

Enqueueing the buffer and enabling streaming

Dequeuing buffers

V4L2 user space tools

Using v4l2-ctl

Debugging V4L2 in user space

Summary

Chapter 10: Linux Kernel Power Management

Technical requirements

The concept of power management on Linux-based systems

Runtime power management

System power management sleep states

Adding power management capabilities to device drivers

Implementing runtime PM capability

System suspend and resume sequences

Implementing system sleep capability

Being a source of system wakeup

Wakeup source and sysfs (or debugfs)

The IRQF_NO_SUSPEND flag

Summary

Section 3: Staying Up to Date with Other Linux Kernel Subsystems

Chapter 11: Writing PCI Device Drivers

Technical requirements

Introduction to PCI buses and interfaces

Terminology

PCI bus enumeration, device configuration, and addressing

PCI address spaces

Interrupt distribution

The Linux kernel PCI subsystem and data structures

PCI data structures

Overview of the PCI driver structure

PCI and Direct Memory Access (DMA)

PCI coherent (aka consistent) mapping

Streaming DMA mapping

Summary

Chapter 12: Leveraging the NVMEM Framework

Technical requirements

Introducing NVMEM data structures and APIs

Writing the NVMEM provider driver

NVMEM device (un)registration

Implementing NVMEM read/write callbacks

Device tree bindings for NVMEM providers

NVMEM consumer driver APIs

NVMEM in user space

Summary

Chapter 13: Watchdog Device Drivers

Technical requirements

Watchdog data structures and APIs

Registering/unregistering a watchdog device

Handling pretimeouts and governors

GPIO-based watchdogs

The watchdog user space interface

Starting and stopping the watchdog

Getting watchdog capabilities and identity

Setting and getting the timeout and pretimeout

Getting the (boot/reboot) status

The watchdog sysfs interface

Summary

Chapter 14: Linux Kernel Debugging Tips and Best Practices

Technical requirements

Understanding the Linux kernel release process

Linux kernel development tips

Message printing

Linux kernel tracing and performance analysis

Using Ftrace to instrument the code

Linux kernel debugging tips

Oops and panic analysis

Using objdump to identify the faulty code line in the kernel module

Summary

Other Books You May Enjoy