building blocks for pru broad market success...

26
Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session covers the Linux drivers to enable the PRU-ICSS sub-system. Author: Texas Instruments ® , Sitara™ ARM ® Processors October 2014

Upload: others

Post on 14-Mar-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Building Blocks for PRU Broad Market Success

Module 4 – Linux Drivers

This session covers the Linux drivers to enable the PRU-ICSS sub-system.

Author: Texas Instruments®, Sitara™ ARM® Processors

October 2014

Page 2: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

2

Page 3: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

ARM + PRU SoC Software ArchitectureProgrammable Real-Time Unit (PRU) Subsystem PRU0

I/O

ARM Subsystem

PRU0 (200MHz)

PRU1 (200MHz)

ARM Subsystem Programmable Real-Time Unit (PRU)Subsystem

Inst.RAMInst.RAM

Shared RAM

Shared RAM

DataRAMDataRAM

Inst.RAMInst.RAM

DataRAMDataRAM

PRU1 I/O

Cortex-A

L1 Instruction

C

L1 Instruction

C

L1 Data

C

L1 Data

C

(200MHz) (200MHz)

Interconnect

INTCINTC Peripherals

CacheCache CacheCache

L2 Data CacheL2 Data Cache

L3 InterconnectL3 Interconnect

Shared MemoryShared Memory Peripherals

Peripherals GP I/O

L4 Interconnect

3

Peripherals GP I/O

Page 4: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

What do we need Linux to do?

• Load the Firmware

• Manage resources (memory, CPU, etc.)

• Control execution (start, stop, etc.)

• Send/receive messages to share data

• Synchronize through events (interrupts)• Synchronize through events (interrupts)

• These services are provided through a combination of remoteproc/rpmsg + virtio transport frameworksremoteproc/rpmsg virtio transport frameworks

4

Page 5: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Linux DriversLinux Drivers

Remoteproc

5

Page 6: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

PRU remoteproc Stack

• The remoteproc framework allows different platforms/architectures to

pruss-remoteprocKernel Client drivers

specifically for PRU core

different platforms/architectures to control (power on, load firmware, power off) remote processors while abstracting any hardware

remoteproc

PRU core

remoteprocframework

g ydifferences

– Does not matter what OS (if any) the remote processor is running

DTB File passed from U-

Boot

• Kernel documentation available in /Documentation/remoteproc.txt

PRU FW

Boot

PRUResourceTable

6

Page 7: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Why Use Remoteproc?

• It already existsEasier to reuse an existing framework than to create a new one– Easier to reuse an existing framework than to create a new one

• Easy to implementRequires only a few custom low level handlers in the Linux driver for a new– Requires only a few custom low-level handlers in the Linux driver for a new platform

• Mainline-friendlyy– The core driver has been in mainline for a couple years

• Fairly simple interface for powering up and controlling a remote y p p g p gprocessor from the kernel

• Enables us to use rpmsg framework for message sharing

7

Page 8: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

How to Use Remoteproc

• Load driver manually or build into kernelUse menuconfig to build into kernel or create a module– Use menuconfig to build into kernel or create a module

• Probe() function automatically looks for firmware in /lib/firmware directory in target filesystemdirectory in target filesystem– rproc_pru0_fw or rproc_pru1_fw for core 0 and 1, respectively

• Interrupts passed between host application and PRU firmwareInterrupts passed between host application and PRU firmware– Application effectively registers to an interrupt

8

Page 9: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Creating a New Node

• A pruss node is created in the root am33xx Device Tree file

• This passes information about the subsystem on AM335x into the PRU rproc driver during probe() function– Primarily register offsets clock speed and other non-changing informationPrimarily register offsets, clock speed, and other non-changing information

• Requires little-to-no interaction on a case-by-case basis – All project-dependent settings are configured in Resource TableAll project dependent settings are configured in Resource Table

9

Page 10: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Understanding the Resource Table

• What is a Resource Table?A Linux construct used to inform the remoteproc driver about the remote– A Linux construct used to inform the remoteproc driver about the remote processor’s available resources

– Typically refers to memory, local peripheral registers, etc. – Firmware-dependent

• Why do I need one?All th d i t i i hil till ti b f– Allows the driver to remain generic while still supporting a number of different, often unique remote processors

• Is flexible enough to allow for the creation of a custom resource type– Is not strictly required as the driver can fall back on defaults

• This severely limits it as the driver may not understand how the PRU firmware wishes to map/handle interrupts

10

Page 11: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Configuring the Resource Table

• Most projects will not need to touch anything beyond the interrupt and vring configurationvring configuration

• Typically only need to modify up to three things– Event-to-channel mappingEvent-to-channel mapping– Channel-to-host mapping– Number and location of vrings

11

Page 12: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Linux DriversLinux Drivers

Rpmsg

12

Page 13: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

PRU rpmsg StackApplication

User SpaceApplication uses /dev/rpmsg-prux interface to send messages

pruss-remoteproc pru-rpmsgKernel

Client drivers specifically for PRU core

remoteproc rpmsg Linux frameworks

virtioDTB File

passed from U-Boot

PRU FW

Boot

PRU Data Memoryvring

PRU rpmsg lib

PRUResourceTable

13

Page 14: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

What Is Rpmsg?• Rpmsg is a Linux framework designed

to allow for message passing between Application

User Spaceg p gthe kernel and a remote processor

• Kernel documentation available in pru-rpmsgKernel

/Documentation/rpmsg.txt

• Virtio is a virtualized I/O framework rpmsg

– We will use it to communicate with our virtio device (vdev)

• There are several ‘standard’ vdevs, but virtio

we only use virtio_ring• Virtio_ring (vring) is the transport

implementation for virtioTh h t d PRU ill i t PRU– The host and PRU will communicate with one another via the virtio_rings(vrings) and “kicks” for synchronization

PRU vring DataMemory

14

Page 15: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Why Use Rpmsg?• It already exists

– Easier to reuse an existing framework than to create a new one

• Mainline-friendly– The core driver has been in mainline for at least a couple years

• Ties in with existing remoteproc driver framework

• Fairly simple interface for passing messages between User Space and the PRU firmware

• Allows developers to expose the virtual device (PRU) to User Space or th f kother frameworks

• Provides scalability for integrating individual PRU peripherals with the respective driver sub systemsrespective driver sub-systems.

15

Page 16: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

How to Use pru-rpmsg Generic Client DriverDriver• User Space applications use

/dev/rpmsg-prux interface to

/dev/rpmsg-pru0User Space

/dev/rpmsg-prux interface to pass messages to and from PRU pru-rpmsg

Kernel

• An example Generic Client Driver is under development rpmsg

virtio

PRUPRU vring Data

Memory

16

Page 17: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Linux DriversLinux Drivers

Custom Function Drivers

17

Page 18: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Custom rpmsg Client Drivers

• User Space applications use /dev/rpmsg-pru0 interface to

/dev/rpmsg-pru0User Space

/dev/tty06

/dev/rpmsg-pru0 interface to pass messages to and from PRU pru-rpmsg

Kernelpru-tty

• Create different rpmsg client drivers to expose the PRU as other interfaces

rpmsg

other interfaces– Firmware based UART, SPI,

etc.All t PRU fi

virtio

– Allows true PRU firmware enhanced Linux devices

PRUPRU vring Data

Memory

18

Page 19: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Custom Function Drivers

• Some users may wish to use the PRU as another Linux Device (e.g. as another UART /dev/ttyO6)another UART /dev/ttyO6)– This will require a custom Linux driver to work in tandem with rproc/rpmsg– Customer at this time will have to develop this custom driver themselves or

k ith thi d t t dwork with a third party to do so

• TI is not initially launching any support for this mechanismW h l diff t t t i i d (UART I2C I2S SPI t ) b t– We have several different targets in mind (UART, I2C, I2S, SPI, etc…), but these will not be available at release

– No target date available today, but we will start evaluating after broad k t PRU l hmarket PRU launch

19

Page 20: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Thank youThank you

20

Page 21: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Backup SlidesBackup Slides

21

Page 22: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Virtio & Vring

• Virtio is a virtualized I/O frameworkWe will use it to communicate with our virtio device (vdev)– We will use it to communicate with our virtio device (vdev)

• There are several ‘standard’ vdevs, but we only use virtio_ring– The host and PRU will communicate with one another via the virtio_rings

( i )(vrings)

22

Page 23: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Virtio & Vring• Virtio_ring (vring) is the transport implementation for virtio

A vring consists of three primary parts:• A vring consists of three primary parts:– A descriptor array – The available ring– The used ring

• In our case the vring contains our list of buffers used to pass data between the host and PRU cores via rpmsghost and PRU cores via rpmsg

23

Page 24: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Virtio & Vring• The descriptor array

– This is where the guest chains together length/address pairsg g g p– Address is the guest-physical address of the buffer– Length is the size of the buffer

There are two flags: R/W and whether or not Next is valid– There are two flags: R/W, and whether or not Next is valid– Next is used for chaining

• This is generally used for packet processing (LANs)

Address Length Flags Next

24

Page 25: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Virtio & Vring• The available ring

– This where the guest (PRU) indicates which descriptors are ready for useg ( ) p y– Consists of a free-running index, an interrupt suppression flag, and an array

of indices into the descriptor table (representing the heads of available buffers))

– Available buffers do not have to be contiguous in memory

Available Buffers

vring buffers

25

Page 26: Building Blocks for PRU Broad Market Success …software-dl.ti.com/public/hpmp/sitara/sitara_pru...Building Blocks for PRU Broad Market Success Module 4 – Linux Drivers This session

Virtio & Vring• The used ring

– This is where the host indicates which descriptors chains it has usedp– The used ring is similar to the available ring except it is written by the host

as descriptor chains are consumed– Consists of a free-running index an interrupt suppression flag and an arrayConsists of a free running index, an interrupt suppression flag, and an array

of indices into the descriptor table (representing the heads of used buffers)– Used buffers do not need to be contiguous in memory

vring buffers

Used Buffers

vring buffers

26