1*4882a593Smuzhiyun# 2*4882a593Smuzhiyun# (C) Copyright 2015 3*4882a593Smuzhiyun# Texas Instruments Incorporated - http://www.ti.com/ 4*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0+ 5*4882a593Smuzhiyun# 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunRemote Processor Framework 8*4882a593Smuzhiyun========================== 9*4882a593SmuzhiyunTOC: 10*4882a593Smuzhiyun1. Introduction 11*4882a593Smuzhiyun2. How does it work - The driver 12*4882a593Smuzhiyun3. Describing the device using platform data 13*4882a593Smuzhiyun4. Describing the device using device tree 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun1. Introduction 16*4882a593Smuzhiyun=============== 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunThis is an introduction to driver-model for Remote Processors found 19*4882a593Smuzhiyunon various System on Chip(SoCs). The term remote processor is used to 20*4882a593Smuzhiyunindicate that this is not the processor on which U-Boot is operating 21*4882a593Smuzhiyunon, instead is yet another processing entity that may be controlled by 22*4882a593Smuzhiyunthe processor on which we are functional. 23*4882a593Smuzhiyun 24*4882a593SmuzhiyunThe simplified model depends on a single UCLASS - UCLASS_REMOTEPROC 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunUCLASS_REMOTEPROC: 27*4882a593Smuzhiyun- drivers/remoteproc/rproc-uclass.c 28*4882a593Smuzhiyun- include/remoteproc.h 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunCommands: 31*4882a593Smuzhiyun- common/cmd_remoteproc.c 32*4882a593Smuzhiyun 33*4882a593SmuzhiyunConfiguration: 34*4882a593SmuzhiyunCONFIG_REMOTEPROC is selected by drivers as needed 35*4882a593SmuzhiyunCONFIG_CMD_REMOTEPROC for the commands if required. 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun2. How does it work - The driver 38*4882a593Smuzhiyun================================= 39*4882a593Smuzhiyun 40*4882a593SmuzhiyunOverall, the driver statemachine transitions are typically as follows: 41*4882a593Smuzhiyun (entry) 42*4882a593Smuzhiyun +-------+ 43*4882a593Smuzhiyun +---+ init | 44*4882a593Smuzhiyun | | | <---------------------+ 45*4882a593Smuzhiyun | +-------+ | 46*4882a593Smuzhiyun | | 47*4882a593Smuzhiyun | | 48*4882a593Smuzhiyun | +--------+ | 49*4882a593SmuzhiyunLoad| | reset | | 50*4882a593Smuzhiyun | | | <----------+ | 51*4882a593Smuzhiyun | +--------+ | | 52*4882a593Smuzhiyun | |Load | | 53*4882a593Smuzhiyun | | | | 54*4882a593Smuzhiyun | +----v----+ reset | | 55*4882a593Smuzhiyun +-> | | (opt) | | 56*4882a593Smuzhiyun | Loaded +-----------+ | 57*4882a593Smuzhiyun | | | 58*4882a593Smuzhiyun +----+----+ | 59*4882a593Smuzhiyun | Start | 60*4882a593Smuzhiyun +---v-----+ (opt) | 61*4882a593Smuzhiyun +->| Running | Stop | 62*4882a593SmuzhiyunPing +- | +--------------------+ 63*4882a593Smuzhiyun(opt) +---------+ 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun(is_running does not change state) 66*4882a593Smuzhiyunopt: Optional state transition implemented by driver. 67*4882a593Smuzhiyun 68*4882a593SmuzhiyunNOTE: It depends on the remote processor as to the exact behavior 69*4882a593Smuzhiyunof the statemachine, remoteproc core does not intent to implement 70*4882a593Smuzhiyunstatemachine logic. Certain processors may allow start/stop without 71*4882a593Smuzhiyunreloading the image in the middle, certain other processors may only 72*4882a593Smuzhiyunallow us to start the processor(image from a EEPROM/OTP) etc. 73*4882a593Smuzhiyun 74*4882a593SmuzhiyunIt is hence the responsibility of the driver to handle the requisite 75*4882a593Smuzhiyunstate transitions of the device as necessary. 76*4882a593Smuzhiyun 77*4882a593SmuzhiyunBasic design assumptions: 78*4882a593Smuzhiyun 79*4882a593SmuzhiyunRemote processor can operate on a certain firmware that maybe loaded 80*4882a593Smuzhiyunand released from reset. 81*4882a593Smuzhiyun 82*4882a593SmuzhiyunThe driver follows a standard UCLASS DM. 83*4882a593Smuzhiyun 84*4882a593Smuzhiyunin the bare minimum form: 85*4882a593Smuzhiyun 86*4882a593Smuzhiyunstatic const struct dm_rproc_ops sandbox_testproc_ops = { 87*4882a593Smuzhiyun .load = sandbox_testproc_load, 88*4882a593Smuzhiyun .start = sandbox_testproc_start, 89*4882a593Smuzhiyun}; 90*4882a593Smuzhiyun 91*4882a593Smuzhiyunstatic const struct udevice_id sandbox_ids[] = { 92*4882a593Smuzhiyun {.compatible = "sandbox,test-processor"}, 93*4882a593Smuzhiyun {} 94*4882a593Smuzhiyun}; 95*4882a593Smuzhiyun 96*4882a593SmuzhiyunU_BOOT_DRIVER(sandbox_testproc) = { 97*4882a593Smuzhiyun .name = "sandbox_test_proc", 98*4882a593Smuzhiyun .of_match = sandbox_ids, 99*4882a593Smuzhiyun .id = UCLASS_REMOTEPROC, 100*4882a593Smuzhiyun .ops = &sandbox_testproc_ops, 101*4882a593Smuzhiyun .probe = sandbox_testproc_probe, 102*4882a593Smuzhiyun}; 103*4882a593Smuzhiyun 104*4882a593SmuzhiyunThis allows for the device to be probed as part of the "init" command 105*4882a593Smuzhiyunor invocation of 'rproc_init()' function as the system dependencies define. 106*4882a593Smuzhiyun 107*4882a593SmuzhiyunThe driver is expected to maintain it's own statemachine which is 108*4882a593Smuzhiyunappropriate for the device it maintains. It must, at the very least 109*4882a593Smuzhiyunprovide a load and start function. We assume here that the device 110*4882a593Smuzhiyunneeds to be loaded and started, else, there is no real purpose of 111*4882a593Smuzhiyunusing the remoteproc framework. 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun3. Describing the device using platform data 114*4882a593Smuzhiyun============================================ 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun*IMPORTANT* NOTE: THIS SUPPORT IS NOT MEANT FOR USE WITH NEWER PLATFORM 117*4882a593SmuzhiyunSUPPORT. THIS IS ONLY FOR LEGACY DEVICES. THIS MODE OF INITIALIZATION 118*4882a593Smuzhiyun*WILL* BE EVENTUALLY REMOVED ONCE ALL NECESSARY PLATFORMS HAVE MOVED 119*4882a593SmuzhiyunTO DM/FDT. 120*4882a593Smuzhiyun 121*4882a593SmuzhiyunConsidering that many platforms are yet to move to device-tree model, 122*4882a593Smuzhiyuna simplified definition of a device is as follows: 123*4882a593Smuzhiyun 124*4882a593Smuzhiyunstruct dm_rproc_uclass_pdata proc_3_test = { 125*4882a593Smuzhiyun .name = "proc_3_legacy", 126*4882a593Smuzhiyun .mem_type = RPROC_INTERNAL_MEMORY_MAPPED, 127*4882a593Smuzhiyun .driver_plat_data = &mydriver_data; 128*4882a593Smuzhiyun}; 129*4882a593Smuzhiyun 130*4882a593SmuzhiyunU_BOOT_DEVICE(proc_3_demo) = { 131*4882a593Smuzhiyun .name = "sandbox_test_proc", 132*4882a593Smuzhiyun .platdata = &proc_3_test, 133*4882a593Smuzhiyun}; 134*4882a593Smuzhiyun 135*4882a593SmuzhiyunThere can be additional data that may be desired depending on the 136*4882a593Smuzhiyunremoteproc driver specific needs (for example: SoC integration 137*4882a593Smuzhiyundetails such as clock handle or something similar). See appropriate 138*4882a593Smuzhiyundocumentation for specific remoteproc driver for further details. 139*4882a593SmuzhiyunThese are passed via driver_plat_data. 140*4882a593Smuzhiyun 141*4882a593Smuzhiyun3. Describing the device using device tree 142*4882a593Smuzhiyun========================================== 143*4882a593Smuzhiyun/ { 144*4882a593Smuzhiyun ... 145*4882a593Smuzhiyun aliases { 146*4882a593Smuzhiyun ... 147*4882a593Smuzhiyun remoteproc0 = &rproc_1; 148*4882a593Smuzhiyun remoteproc1 = &rproc_2; 149*4882a593Smuzhiyun 150*4882a593Smuzhiyun }; 151*4882a593Smuzhiyun ... 152*4882a593Smuzhiyun 153*4882a593Smuzhiyun rproc_1: rproc@1 { 154*4882a593Smuzhiyun compatible = "sandbox,test-processor"; 155*4882a593Smuzhiyun remoteproc-name = "remoteproc-test-dev1"; 156*4882a593Smuzhiyun }; 157*4882a593Smuzhiyun 158*4882a593Smuzhiyun rproc_2: rproc@2 { 159*4882a593Smuzhiyun compatible = "sandbox,test-processor"; 160*4882a593Smuzhiyun internal-memory-mapped; 161*4882a593Smuzhiyun remoteproc-name = "remoteproc-test-dev2"; 162*4882a593Smuzhiyun }; 163*4882a593Smuzhiyun ... 164*4882a593Smuzhiyun}; 165*4882a593Smuzhiyun 166*4882a593Smuzhiyunaliases usage is optional, but it is usually recommended to ensure the 167*4882a593Smuzhiyunusers have a consistent usage model for a platform. 168*4882a593Smuzhiyunthe compatible string used here is specific to the remoteproc driver involved. 169