The Serial Device Bus

Similar documents
SPMI: System Power Management Interface

Introduction to Linux kernel driver programming + i2c drivers

Embedded Linux kernel and driver development training 5-day session

Bridging of Control Interfaces over Multimedia Serial Links

Contents. Foreword...xxi Preface...xxiii Acknowledgments...xxix About the Author...xxx

So you want to write a Linux driver subsystem? Michael Turquette

Implementing ACPI 5 Features

Using kgdb and the kgdb Internals

CS5460/6460: Operating Systems. Lecture 24: Device drivers. Anton Burtsev April, 2014

Storage Systems. NPTEL Course Jan K. Gopinath Indian Institute of Science

Groking the Linux SPI Subsystem FOSDEM Matt Porter

sllin TTY discipline for UART-LIN device implementation P. Píša, R. Lisový, M. Sojka Czech Technical University in Prague DRAFT

FPGA Manager. State of the Union. Moritz Fischer, National Instruments

regmap The power of subsystems and abstractions 2012 Wolfson Microelectronics plc

PIN CONTROL OVERVIEW Linus Walleij

Table of Contents. Preface... xi

Introduction PCI Interface Booting PCI driver registration Other buses. Linux Device Drivers PCI Drivers

Porting Linux to a new SoC

HiKey970. I2C Development Guide. Issue 01. Date

ARM Device Tree status report

Comp 204: Computer Systems and Their Implementation. Lecture 18: Devices

Vinod Koul, Sanyog Kale Intel Corp. MIPI SoundWire Linux Subsystem: An introduction to Protocol and Linux Subsystem

- Knowledge of basic computer architecture and organization, ECE 445

Devices. Today. Comp 104: Operating Systems Concepts. Operating System An Abstract View 05/01/2017. Devices. Devices

Ubuntu Core Certified Hardware Coverage for Ubuntu Core 18

DRM(Direct Rendering Manager) of Tizen Kernel Joonyoung Shim

ARM support in the Linux kernel

Embedded Systems Programming

Enabling IoT OSs for Intel Quark MCU Platforms: the fast way. OpenIoT Summit Europe Andre Guedes

I + I2C = I3C, what s hiding in this additional I

How Not to Write an x86 Platform Driver

OpenBSD s New Suspend and Resume Framework

GPIO for Engineers and Makers. Linus Walleij, Linaro

Linux DRM Developer s Guide

LCA14-107: ACPI upstreaming. Wed-5-Mar, 11:15am, Al Stone, G Gregory, Hanjun Guo

Industrial I/O and You: Nonsense Hacks! Matt Ranostay Konsulko Group

ECE 598 Advanced Operating Systems Lecture 6

Mainline on form-factor devices / Improving AOSP

VGA Assignment Using VFIO. Alex Williamson October 21 st, 2013

U-Boot bootloader port done right 2017 edition

Ethernet switch support in the Linux kernel

json-schema for Devicetree Rob Herring

Linux Power Management Experiences on Moorestown

Future Technology Devices International Ltd. Application Note AN_172. Vinculum-II. Using the USB Slave Driver

I/O. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter 6.5-6

Fault Injection in System Calls

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

The Note/1 Driver Design

What tools exist to support device tree development and debugging? What new tools have been proposed or requested?

Marek Szyprowski Samsung R&D Institute Poland

Bharat Bhushan, Stuart Yoder

Porting U-Boot and Linux on new ARM boards: a step-by-step guide

A Linux multimedia platform for SH-Mobile processors

Runtime Power Management Framework

OpenAMP Discussion - Linaro2018HK. Copyright 2018 Xilinx

Typical modules include interfaces to ARINC-429, ARINC-561, ARINC-629 and RS-422. Each module supports up to 8 Rx or 8Tx channels.

Resource Power Manager

ECE 598 Advanced Operating Systems Lecture 6

Identifying and Supporting"Xcompatible"

Runtime Power Management on SuperH Mobile

PXA270 EPIC Computer with Power Over Ethernet & Six Serial Protocols SBC4670

Embedded Linux. Session 4: Introduction to the GPIO Kernel API. Martin Aebersold BFH-TI Dipl. El.-Ing. FH.

Groking the Linux SPI Subsystem Embedded Linux Conference Matt Porter

ARM support in the Linux kernel

Chapter 13: I/O Systems

Hello, and welcome to this presentation of the STM32 Reset and Clock Controller.

New GPIO interface for linux user space. Linux Piter 2018 Bartosz Golaszewski

AN434: CP2110/4 Interface Specification

ACRN: A Big Little Hypervisor for IoT Development

UART HCI Bluetooth Module for Linux BT860

Power Management Integrated Circuits: Keep the power in your hands

SFO15-200: TEE kernel driver

Fujitsu System Applications Support. Fujitsu Microelectronics America, Inc. 02/02

Power Management Integrated Circuits: Keep the power in your hands

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

CSE 451: Operating Systems Winter I/O System. Gary Kimura

ACPI 6 and Linux* Rafael J. Wysocki. Intel Open Source Technology Center. August 19, 2015

Hello, and welcome to this presentation of the STM32L4 power controller. The STM32L4 s power management functions and all power modes will also be

Operating Systems 2010/2011

... Application Note AN-531. PCI Express System Interconnect Software Architecture. Notes Introduction. System Architecture.

SFO15-100: 96Boards & the course upstream

CSE380 - Operating Systems. Communicating with Devices

Building Real-Time Embedded Applications on QduinoMC

Embedded Linux Conference San Diego 2016

python-periphery Documentation

Communication. Serial port programming

RAS Enhancement Activities for Mission-Critical Linux Systems

Internet of Things: Using MRAA to Abstract Platform I/O Capabilities

Getting Started using Linux on a New Embedded System

I/O Management Intro. Chapter 5

IC221: Systems Programming 12-Week Written Exam [SOLUTIONS]

Radix Tree, IDR APIs and their test suite. Rehas Sachdeva & Sandhya Bankar

Device: MOD This document Version: 1.0. Matches module version: v3 [29 June 2016] Date: 23 October 2017

CS 378 (Spring 2003)

Applying User-level Drivers on

Read section 8 of this document for detailed instructions on how to use this interface spec with LibUSB For OSX

A Sockets API For LoRa. Andreas Färber, SUSE Labs

i.mx 7 - Hetereogenous Multiprocessing Architecture

Projects on the Intel Single-chip Cloud Computer (SCC)

Transcription:

The Serial Device Bus Johan Hovold Hovold Consulting AB Embedded Linux Conference Europe October 23, 2017

Introduction UARTs and RS-232 have been around since 1960s Common interface for Bluetooth, NFC, FM Radio and GPS devices TTY layer abstracts serial connection Character-device interface (e.g. /dev/ttys1) But no (good) way to model associated resources (e.g. for PM) GPIOs and interrupts Regulators Clocks Audio interface Kernel support limited to line-discipline drivers Requires user space to configure and initialise

Outline TTY Layer Problems with line-discipline drivers Serdev implementation Serdev interfaces Serdev limitations Future work

TTY Layer Character device Line disciplines I/O processing Canonical mode Echoing Errors Signals on input TTY ports Input buffering Abstraction layer (e.g. open()) TTY drivers

User-Space Drivers Description In user space Port Associated resources GPIOs and interrupts (accessible) Regulators Clocks Power management Firmware loading

Line-Discipline Drivers Interaction with other subsystems (e.g. bluetooth, input, nfc, ppp) Registers further devices (e.g. hci0) User-space daemons to initialise port and switch line discipline ldattach inputattach hciattach (btattach) Registered while port (ldisc) is open Firmware infrastructure available But still issues with other resources and PM

Bluetooth Example int ldisc = N_ HCI ; int proto = HCI_UART_BCM ; fd = open ("/ dev / ttyo1 ",...) ; /* configure line settings */ ioctl (fd, TIOCSETD, & ldisc ); ioctl ( fd, HCIUARTSETPROTO, proto );

Bluetooth Example

Bluetooth Example

Problems with Line-Discipline Drivers Description (what, where, how?) and discovery Encoded in user space rather than firmware (DT, ACPI) User-space daemons Description and lookup of associated resources GPIOs and interrupts (e.g. reset, wakeup) Pinctrl Regulators Clocks Power management GPIOs, regulators, clocks... Open port may prevent underlying device from runtime suspending Firmware loading GPIO (e.g. reset) interaction

The Serial Device Bus The Serial Device Bus (Serdev) By Rob Herring (Linaro) Bus for UART-attached devices Replace ti-st driver and UIM daemon Earlier efforts (power management) Merged in 4.11 Enabled for serial core only in 4.12 (due to lifetime issues)

Serdev Overview New bus type: serial Serdev controllers Serdev devices (a.k.a. clients or slaves) Serdev TTY-port controller Only controller implementation Registered by TTY driver when clients defined Controller replaces TTY character device Clients described by firmware (Device Tree or soon ACPI)

Serdev Drivers

Serdev Drivers

TTY-Port Controller Implementation struct device * tty_port_register_device_serdev (...) ; struct tty_port_client_operations { int (* receive_buf ) (...) ; void (* write_wakeup ) (...) ; }; struct tty_port {... struct tty_port_client_operations * client_ops ; void * client_data ; }; Registers controller and slaves instead of TTY class device Replaces default TTY-port client operations Controller interface implemented using TTY layer and TTY-driver ops

Device Tree Bindings Child of serial-port node compatible property max-speed property (optional) Additional resources & uart1 { bluetooth { compatible = "ti, wl1835 -st"; enable - gpios = <& gpio1 7 0 >; clocks = <& clk32k_ wl18xx >; clock - names = " ext_clock "; }; };

Sysfs Example / sys / bus / platform / devices / -- 44 e09000. serial -- driver ->.../ omap_uart -- tty -- ttyo0 -- 48022000. serial -- driver ->.../ omap_uart -- serial0 -- serial0-0 -- bluetooth -- hci0 -- driver ->.../ hci -ti -- subsystem ->.../ bus / serial

Driver Interface Resembles line-discipline operations Open and close Terminal settings Write Modem control Read (callback) Write wakeup (callback) A few additional helpers

Driver Interface Functions int se rd ev_de vi ce_o pe n ( struct serdev_device *); void serdev_device_close (...) ; unsigned serdev_device_set_baudrate (...) ; void serdev_device_set_flow_control (...) ; int serdev_device_write_buf (...) ; void serdev_device_wait_until_sent (...) ; void serdev_device_write_flush (...) ; int serdev_device_write_room (...) ; int serdev_device_get_tiocm (...) ; int serdev_device_set_tiocm (...) ; No write serialisation (should not be a problem) No operation ordering enforced (except for write buf) All but write buf() and write room() may sleep

Driver Interface Callbacks struct se rdev_d evice_ ops { int (* receive_buf )( struct serdev_device *, const unsigned char *, size_ t ); void (* write_wakeup )( struct serdev_device *); }; receive buf() Workqueue context Returns number of bytes processed write wakeup() Typically atomic context Must not sleep

Example Driver static struct serdev_device_driver slave_driver = {. driver = {. name = " serdev - slave ",. of_match_table = of_match_ptr ( slave_of_match ),.pm = & slave_pm_ops, },. probe = slave_ probe,. remove = slave_ remove, }; module_serdev_device_driver ( slave_driver );

Example Driver Probe static struct se rdev_d evice_ ops slave_ops {. receive_buf = slave_receive_buf,. write_wakeup = slave_write_wake_up, }; static int slave_probe ( struct serdev_device * serdev ) {... priv -> serdev = serdev ; serdev_device_set_drvdata ( serdev, priv ); serdev_device_set_client_ops ( serdev, & slave_ops ); } serdev_device_open ( serdev ); serdev_device_set_baudrate ( serdev, 115200) ; device_add (& priv -> dev ); return 0;

Limitations Serial-core only (for now) No hotplug support Single slave No input flow control No push back Data silently dropped if client can t keep up No input processing (cf. raw terminal mode) No software flow control (XON/XOFF) No parity, framing, or overrun errors No break signalling

Serial Port Hotplugging Implemented using TTY hangups and file operations But Serdev does not use file abstraction Requires changes to TTY layer Partial reason for initial revert PCI hotplug... Description of dynamic buses Only USB has rudimentary support for Device Tree Device Tree Overlays? No in-kernel user-space interface for overlays Pass overlays (compatible strings) from TTY drivers? Example Pulse Eight HDMI CEC USB device (ACM, serio driver)

Quirks Line-discipline allocated (and used) Controller always registered No character device (feature) No bus PM (power.ignore children?) No operation ordering Code duplication and backwards compatibility Some naming inconsistencies serial bus (not serdev) serdev device/client/slave

Kconfig Notice Device drivers ---> Character devices ---> <* > Serial device bus ---> <* > Serial device TTY port controller SERIAL DEV BUS [=y] Tristate Driver dependency SERIAL DEV CTRL TTYPORT [=y] Boolean Only controller implementation Should default to y (patch posted) Depends on TTY and SERIAL DEV BUS!= m

Merged Drivers Bluetooth hci serdev (library based on hci ldisc.c) hci bcm (4.14) hci ll (4.12) hci nokia (4.12) Ethernet qca uart (4.13)

A Word on hci bcm Precursor to Serdev Hack for additional resources and PM Platform companion device Described by ACPI or platform code Child of serial device Manages GPIOs and clocks Registered in driver list at probe Looked up in list from HCI callbacks Matches on parent device Serdev ACPI and PM support merged for 4.15 Regression risk Similar problems with hci intel

In the Works ACPI support [PATCH v3 0/2] ACPI serdev support (October 11) Potential hci bcm and hci intel breakage

In the Works ACPI support [PATCH v3 0/2] ACPI serdev support (October 11) Potential hci bcm and hci intel breakage Mux support? [PATCH 0/6] serdev multiplexing support (August 16) Utilising new mux subsystem Adds reg property (mux index) Has issues (no flushing, and no locking?!) max9260 I2C-controller slave driver Basic parity support (no error handling)

In the Works ACPI support [PATCH v3 0/2] ACPI serdev support (October 11) Potential hci bcm and hci intel breakage Mux support? [PATCH 0/6] serdev multiplexing support (August 16) Utilising new mux subsystem Adds reg property (mux index) Has issues (no flushing, and no locking?!) max9260 I2C-controller slave driver Basic parity support (no error handling) RAVE slave driver [PATCH v8 0/5] ZII RAVE platform driver (October 19) MFD driver for supervisory processor (watchdog, backlight, LED, etc.)

In the Works ACPI support [PATCH v3 0/2] ACPI serdev support (October 11) Potential hci bcm and hci intel breakage Mux support? [PATCH 0/6] serdev multiplexing support (August 16) Utilising new mux subsystem Adds reg property (mux index) Has issues (no flushing, and no locking?!) max9260 I2C-controller slave driver Basic parity support (no error handling) RAVE slave driver [PATCH v8 0/5] ZII RAVE platform driver (October 19) MFD driver for supervisory processor (watchdog, backlight, LED, etc.) w2sg and w2cbw GPS and WiFi/BT slave drivers [RFC 0/3] misc: new serdev based drivers for w2sg00x4 GPS module and w2cbw003 wifi/bluetooth (May 21)

Future Work Address quirks and limitations, including Hotplug Enable for more TTY drivers (USB serial) Mux and RS-485? Bus PM? Further Bluetooth protocol drivers (e.g. hci intel) Convert line-discipline drivers NFC CAN ti-st driver Some serio drivers (e.g. pulse8-cec)?

Further Reading include/linux/serdev.h drivers/tty/serdev/ core.c serdev-ttyport.c Documentation/devicetree/bindings/ serial/slave-device.txt net/broadcom-bluetooth.txt net/nokia-bluetooth.txt net/qca,qca7000.txt net/ti,wilink-st.txt The need for TTY slave devices by Neil Brown https://lwn.net/articles/700489/

Thanks! johan@hovoldconsulting.com johan@kernel.org