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