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 Menon #ifndef _RPROC_H_
8*ddf56bc7SNishanth Menon #define _RPROC_H_
9*ddf56bc7SNishanth Menon
10*ddf56bc7SNishanth Menon /*
11*ddf56bc7SNishanth Menon * Note: The platform data support is not meant for use with newer
12*ddf56bc7SNishanth Menon * platforms. This is meant only for legacy devices. This mode of
13*ddf56bc7SNishanth Menon * initialization *will* be eventually removed once all necessary
14*ddf56bc7SNishanth Menon * platforms have moved to dm/fdt.
15*ddf56bc7SNishanth Menon */
16*ddf56bc7SNishanth Menon #include <dm/platdata.h> /* For platform data support - non dt world */
17*ddf56bc7SNishanth Menon
18*ddf56bc7SNishanth Menon /**
19*ddf56bc7SNishanth Menon * enum rproc_mem_type - What type of memory model does the rproc use
20*ddf56bc7SNishanth Menon * @RPROC_INTERNAL_MEMORY_MAPPED: Remote processor uses own memory and is memory
21*ddf56bc7SNishanth Menon * mapped to the host processor over an address range.
22*ddf56bc7SNishanth Menon *
23*ddf56bc7SNishanth Menon * Please note that this is an enumeration of memory model of different types
24*ddf56bc7SNishanth Menon * of remote processors. Few of the remote processors do have own internal
25*ddf56bc7SNishanth Menon * memories, while others use external memory for instruction and data.
26*ddf56bc7SNishanth Menon */
27*ddf56bc7SNishanth Menon enum rproc_mem_type {
28*ddf56bc7SNishanth Menon RPROC_INTERNAL_MEMORY_MAPPED = 0,
29*ddf56bc7SNishanth Menon };
30*ddf56bc7SNishanth Menon
31*ddf56bc7SNishanth Menon /**
32*ddf56bc7SNishanth Menon * struct dm_rproc_uclass_pdata - platform data for a CPU
33*ddf56bc7SNishanth Menon * @name: Platform-specific way of naming the Remote proc
34*ddf56bc7SNishanth Menon * @mem_type: one of 'enum rproc_mem_type'
35*ddf56bc7SNishanth Menon * @driver_plat_data: driver specific platform data that may be needed.
36*ddf56bc7SNishanth Menon *
37*ddf56bc7SNishanth Menon * This can be accessed with dev_get_uclass_platdata() for any UCLASS_REMOTEPROC
38*ddf56bc7SNishanth Menon * device.
39*ddf56bc7SNishanth Menon *
40*ddf56bc7SNishanth Menon */
41*ddf56bc7SNishanth Menon struct dm_rproc_uclass_pdata {
42*ddf56bc7SNishanth Menon const char *name;
43*ddf56bc7SNishanth Menon enum rproc_mem_type mem_type;
44*ddf56bc7SNishanth Menon void *driver_plat_data;
45*ddf56bc7SNishanth Menon };
46*ddf56bc7SNishanth Menon
47*ddf56bc7SNishanth Menon /**
48*ddf56bc7SNishanth Menon * struct dm_rproc_ops - Operations that are provided by remote proc driver
49*ddf56bc7SNishanth Menon * @init: Initialize the remoteproc device invoked after probe (optional)
50*ddf56bc7SNishanth Menon * Return 0 on success, -ve error on fail
51*ddf56bc7SNishanth Menon * @load: Load the remoteproc device using data provided(mandatory)
52*ddf56bc7SNishanth Menon * This takes the following additional arguments.
53*ddf56bc7SNishanth Menon * addr- Address of the binary image to be loaded
54*ddf56bc7SNishanth Menon * size- Size of the binary image to be loaded
55*ddf56bc7SNishanth Menon * Return 0 on success, -ve error on fail
56*ddf56bc7SNishanth Menon * @start: Start the remoteproc device (mandatory)
57*ddf56bc7SNishanth Menon * Return 0 on success, -ve error on fail
58*ddf56bc7SNishanth Menon * @stop: Stop the remoteproc device (optional)
59*ddf56bc7SNishanth Menon * Return 0 on success, -ve error on fail
60*ddf56bc7SNishanth Menon * @reset: Reset the remote proc device (optional)
61*ddf56bc7SNishanth Menon * Return 0 on success, -ve error on fail
62*ddf56bc7SNishanth Menon * @is_running: Check if the remote processor is running(optional)
63*ddf56bc7SNishanth Menon * Return 0 on success, 1 if not running, -ve on others errors
64*ddf56bc7SNishanth Menon * @ping: Ping the remote device for basic communication check(optional)
65*ddf56bc7SNishanth Menon * Return 0 on success, 1 if not responding, -ve on other errors
66*ddf56bc7SNishanth Menon */
67*ddf56bc7SNishanth Menon struct dm_rproc_ops {
68*ddf56bc7SNishanth Menon int (*init)(struct udevice *dev);
69*ddf56bc7SNishanth Menon int (*load)(struct udevice *dev, ulong addr, ulong size);
70*ddf56bc7SNishanth Menon int (*start)(struct udevice *dev);
71*ddf56bc7SNishanth Menon int (*stop)(struct udevice *dev);
72*ddf56bc7SNishanth Menon int (*reset)(struct udevice *dev);
73*ddf56bc7SNishanth Menon int (*is_running)(struct udevice *dev);
74*ddf56bc7SNishanth Menon int (*ping)(struct udevice *dev);
75*ddf56bc7SNishanth Menon };
76*ddf56bc7SNishanth Menon
77*ddf56bc7SNishanth Menon /* Accessor */
78*ddf56bc7SNishanth Menon #define rproc_get_ops(dev) ((struct dm_rproc_ops *)(dev)->driver->ops)
79*ddf56bc7SNishanth Menon
80*ddf56bc7SNishanth Menon #ifdef CONFIG_REMOTEPROC
81*ddf56bc7SNishanth Menon /**
82*ddf56bc7SNishanth Menon * rproc_init() - Initialize all bound remote proc devices
83*ddf56bc7SNishanth Menon *
84*ddf56bc7SNishanth Menon * Return: 0 if all ok, else appropriate error value.
85*ddf56bc7SNishanth Menon */
86*ddf56bc7SNishanth Menon int rproc_init(void);
87*ddf56bc7SNishanth Menon
88*ddf56bc7SNishanth Menon /**
89*ddf56bc7SNishanth Menon * rproc_is_initialized() - check to see if remoteproc devices are initialized
90*ddf56bc7SNishanth Menon *
91*ddf56bc7SNishanth Menon * Return: 0 if all devices are initialized, else appropriate error value.
92*ddf56bc7SNishanth Menon */
93*ddf56bc7SNishanth Menon bool rproc_is_initialized(void);
94*ddf56bc7SNishanth Menon
95*ddf56bc7SNishanth Menon /**
96*ddf56bc7SNishanth Menon * rproc_load() - load binary to a remote processor
97*ddf56bc7SNishanth Menon * @id: id of the remote processor
98*ddf56bc7SNishanth Menon * @addr: address in memory where the binary image is located
99*ddf56bc7SNishanth Menon * @size: size of the binary image
100*ddf56bc7SNishanth Menon *
101*ddf56bc7SNishanth Menon * Return: 0 if all ok, else appropriate error value.
102*ddf56bc7SNishanth Menon */
103*ddf56bc7SNishanth Menon int rproc_load(int id, ulong addr, ulong size);
104*ddf56bc7SNishanth Menon
105*ddf56bc7SNishanth Menon /**
106*ddf56bc7SNishanth Menon * rproc_start() - Start a remote processor
107*ddf56bc7SNishanth Menon * @id: id of the remote processor
108*ddf56bc7SNishanth Menon *
109*ddf56bc7SNishanth Menon * Return: 0 if all ok, else appropriate error value.
110*ddf56bc7SNishanth Menon */
111*ddf56bc7SNishanth Menon int rproc_start(int id);
112*ddf56bc7SNishanth Menon
113*ddf56bc7SNishanth Menon /**
114*ddf56bc7SNishanth Menon * rproc_stop() - Stop a remote processor
115*ddf56bc7SNishanth Menon * @id: id of the remote processor
116*ddf56bc7SNishanth Menon *
117*ddf56bc7SNishanth Menon * Return: 0 if all ok, else appropriate error value.
118*ddf56bc7SNishanth Menon */
119*ddf56bc7SNishanth Menon int rproc_stop(int id);
120*ddf56bc7SNishanth Menon
121*ddf56bc7SNishanth Menon /**
122*ddf56bc7SNishanth Menon * rproc_reset() - reset a remote processor
123*ddf56bc7SNishanth Menon * @id: id of the remote processor
124*ddf56bc7SNishanth Menon *
125*ddf56bc7SNishanth Menon * Return: 0 if all ok, else appropriate error value.
126*ddf56bc7SNishanth Menon */
127*ddf56bc7SNishanth Menon int rproc_reset(int id);
128*ddf56bc7SNishanth Menon
129*ddf56bc7SNishanth Menon /**
130*ddf56bc7SNishanth Menon * rproc_ping() - ping a remote processor to check if it can communicate
131*ddf56bc7SNishanth Menon * @id: id of the remote processor
132*ddf56bc7SNishanth Menon *
133*ddf56bc7SNishanth Menon * NOTE: this might need communication path available, which is not implemented
134*ddf56bc7SNishanth Menon * as part of remoteproc framework - hook on to appropriate bus architecture to
135*ddf56bc7SNishanth Menon * do the same
136*ddf56bc7SNishanth Menon *
137*ddf56bc7SNishanth Menon * Return: 0 if all ok, else appropriate error value.
138*ddf56bc7SNishanth Menon */
139*ddf56bc7SNishanth Menon int rproc_ping(int id);
140*ddf56bc7SNishanth Menon
141*ddf56bc7SNishanth Menon /**
142*ddf56bc7SNishanth Menon * rproc_is_running() - check to see if remote processor is running
143*ddf56bc7SNishanth Menon * @id: id of the remote processor
144*ddf56bc7SNishanth Menon *
145*ddf56bc7SNishanth Menon * NOTE: this may not involve actual communication capability of the remote
146*ddf56bc7SNishanth Menon * processor, but just ensures that it is out of reset and executing code.
147*ddf56bc7SNishanth Menon *
148*ddf56bc7SNishanth Menon * Return: 0 if all ok, else appropriate error value.
149*ddf56bc7SNishanth Menon */
150*ddf56bc7SNishanth Menon int rproc_is_running(int id);
151*ddf56bc7SNishanth Menon #else
rproc_init(void)152*ddf56bc7SNishanth Menon static inline int rproc_init(void) { return -ENOSYS; }
rproc_is_initialized(void)153*ddf56bc7SNishanth Menon static inline bool rproc_is_initialized(void) { return false; }
rproc_load(int id,ulong addr,ulong size)154*ddf56bc7SNishanth Menon static inline int rproc_load(int id, ulong addr, ulong size) { return -ENOSYS; }
rproc_start(int id)155*ddf56bc7SNishanth Menon static inline int rproc_start(int id) { return -ENOSYS; }
rproc_stop(int id)156*ddf56bc7SNishanth Menon static inline int rproc_stop(int id) { return -ENOSYS; }
rproc_reset(int id)157*ddf56bc7SNishanth Menon static inline int rproc_reset(int id) { return -ENOSYS; }
rproc_ping(int id)158*ddf56bc7SNishanth Menon static inline int rproc_ping(int id) { return -ENOSYS; }
rproc_is_running(int id)159*ddf56bc7SNishanth Menon static inline int rproc_is_running(int id) { return -ENOSYS; }
160*ddf56bc7SNishanth Menon #endif
161*ddf56bc7SNishanth Menon
162*ddf56bc7SNishanth Menon #endif /* _RPROC_H_ */
163