xref: /linux/Documentation/staging/remoteproc.rst (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
18e2a46a4SMauro Carvalho Chehab==========================
28e2a46a4SMauro Carvalho ChehabRemote Processor Framework
38e2a46a4SMauro Carvalho Chehab==========================
48e2a46a4SMauro Carvalho Chehab
58e2a46a4SMauro Carvalho ChehabIntroduction
68e2a46a4SMauro Carvalho Chehab============
78e2a46a4SMauro Carvalho Chehab
88e2a46a4SMauro Carvalho ChehabModern SoCs typically have heterogeneous remote processor devices in asymmetric
98e2a46a4SMauro Carvalho Chehabmultiprocessing (AMP) configurations, which may be running different instances
108e2a46a4SMauro Carvalho Chehabof operating system, whether it's Linux or any other flavor of real-time OS.
118e2a46a4SMauro Carvalho Chehab
128e2a46a4SMauro Carvalho ChehabOMAP4, for example, has dual Cortex-A9, dual Cortex-M3 and a C64x+ DSP.
138e2a46a4SMauro Carvalho ChehabIn a typical configuration, the dual cortex-A9 is running Linux in a SMP
148e2a46a4SMauro Carvalho Chehabconfiguration, and each of the other three cores (two M3 cores and a DSP)
158e2a46a4SMauro Carvalho Chehabis running its own instance of RTOS in an AMP configuration.
168e2a46a4SMauro Carvalho Chehab
178e2a46a4SMauro Carvalho ChehabThe remoteproc framework allows different platforms/architectures to
188e2a46a4SMauro Carvalho Chehabcontrol (power on, load firmware, power off) those remote processors while
198e2a46a4SMauro Carvalho Chehababstracting the hardware differences, so the entire driver doesn't need to be
208e2a46a4SMauro Carvalho Chehabduplicated. In addition, this framework also adds rpmsg virtio devices
218e2a46a4SMauro Carvalho Chehabfor remote processors that supports this kind of communication. This way,
228e2a46a4SMauro Carvalho Chehabplatform-specific remoteproc drivers only need to provide a few low-level
238e2a46a4SMauro Carvalho Chehabhandlers, and then all rpmsg drivers will then just work
248e2a46a4SMauro Carvalho Chehab(for more information about the virtio-based rpmsg bus and its drivers,
258e2a46a4SMauro Carvalho Chehabplease read Documentation/staging/rpmsg.rst).
268e2a46a4SMauro Carvalho ChehabRegistration of other types of virtio devices is now also possible. Firmwares
278e2a46a4SMauro Carvalho Chehabjust need to publish what kind of virtio devices do they support, and then
288e2a46a4SMauro Carvalho Chehabremoteproc will add those devices. This makes it possible to reuse the
298e2a46a4SMauro Carvalho Chehabexisting virtio drivers with remote processor backends at a minimal development
308e2a46a4SMauro Carvalho Chehabcost.
318e2a46a4SMauro Carvalho Chehab
328e2a46a4SMauro Carvalho ChehabUser API
338e2a46a4SMauro Carvalho Chehab========
348e2a46a4SMauro Carvalho Chehab
358e2a46a4SMauro Carvalho Chehab::
368e2a46a4SMauro Carvalho Chehab
378e2a46a4SMauro Carvalho Chehab  int rproc_boot(struct rproc *rproc)
388e2a46a4SMauro Carvalho Chehab
398e2a46a4SMauro Carvalho ChehabBoot a remote processor (i.e. load its firmware, power it on, ...).
408e2a46a4SMauro Carvalho Chehab
418e2a46a4SMauro Carvalho ChehabIf the remote processor is already powered on, this function immediately
428e2a46a4SMauro Carvalho Chehabreturns (successfully).
438e2a46a4SMauro Carvalho Chehab
448e2a46a4SMauro Carvalho ChehabReturns 0 on success, and an appropriate error value otherwise.
458e2a46a4SMauro Carvalho ChehabNote: to use this function you should already have a valid rproc
468e2a46a4SMauro Carvalho Chehabhandle. There are several ways to achieve that cleanly (devres, pdata,
478e2a46a4SMauro Carvalho Chehabthe way remoteproc_rpmsg.c does this, or, if this becomes prevalent, we
488e2a46a4SMauro Carvalho Chehabmight also consider using dev_archdata for this).
498e2a46a4SMauro Carvalho Chehab
508e2a46a4SMauro Carvalho Chehab::
518e2a46a4SMauro Carvalho Chehab
52*c13b780cSSuman Anna  int rproc_shutdown(struct rproc *rproc)
538e2a46a4SMauro Carvalho Chehab
548e2a46a4SMauro Carvalho ChehabPower off a remote processor (previously booted with rproc_boot()).
558e2a46a4SMauro Carvalho ChehabIn case @rproc is still being used by an additional user(s), then
568e2a46a4SMauro Carvalho Chehabthis function will just decrement the power refcount and exit,
578e2a46a4SMauro Carvalho Chehabwithout really powering off the device.
588e2a46a4SMauro Carvalho Chehab
59*c13b780cSSuman AnnaReturns 0 on success, and an appropriate error value otherwise.
608e2a46a4SMauro Carvalho ChehabEvery call to rproc_boot() must (eventually) be accompanied by a call
618e2a46a4SMauro Carvalho Chehabto rproc_shutdown(). Calling rproc_shutdown() redundantly is a bug.
628e2a46a4SMauro Carvalho Chehab
638e2a46a4SMauro Carvalho Chehab.. note::
648e2a46a4SMauro Carvalho Chehab
658e2a46a4SMauro Carvalho Chehab  we're not decrementing the rproc's refcount, only the power refcount.
668e2a46a4SMauro Carvalho Chehab  which means that the @rproc handle stays valid even after
678e2a46a4SMauro Carvalho Chehab  rproc_shutdown() returns, and users can still use it with a subsequent
688e2a46a4SMauro Carvalho Chehab  rproc_boot(), if needed.
698e2a46a4SMauro Carvalho Chehab
708e2a46a4SMauro Carvalho Chehab::
718e2a46a4SMauro Carvalho Chehab
728e2a46a4SMauro Carvalho Chehab  struct rproc *rproc_get_by_phandle(phandle phandle)
738e2a46a4SMauro Carvalho Chehab
748e2a46a4SMauro Carvalho ChehabFind an rproc handle using a device tree phandle. Returns the rproc
758e2a46a4SMauro Carvalho Chehabhandle on success, and NULL on failure. This function increments
768e2a46a4SMauro Carvalho Chehabthe remote processor's refcount, so always use rproc_put() to
778e2a46a4SMauro Carvalho Chehabdecrement it back once rproc isn't needed anymore.
788e2a46a4SMauro Carvalho Chehab
798e2a46a4SMauro Carvalho ChehabTypical usage
808e2a46a4SMauro Carvalho Chehab=============
818e2a46a4SMauro Carvalho Chehab
828e2a46a4SMauro Carvalho Chehab::
838e2a46a4SMauro Carvalho Chehab
848e2a46a4SMauro Carvalho Chehab  #include <linux/remoteproc.h>
858e2a46a4SMauro Carvalho Chehab
868e2a46a4SMauro Carvalho Chehab  /* in case we were given a valid 'rproc' handle */
878e2a46a4SMauro Carvalho Chehab  int dummy_rproc_example(struct rproc *my_rproc)
888e2a46a4SMauro Carvalho Chehab  {
898e2a46a4SMauro Carvalho Chehab	int ret;
908e2a46a4SMauro Carvalho Chehab
918e2a46a4SMauro Carvalho Chehab	/* let's power on and boot our remote processor */
928e2a46a4SMauro Carvalho Chehab	ret = rproc_boot(my_rproc);
938e2a46a4SMauro Carvalho Chehab	if (ret) {
948e2a46a4SMauro Carvalho Chehab		/*
958e2a46a4SMauro Carvalho Chehab		 * something went wrong. handle it and leave.
968e2a46a4SMauro Carvalho Chehab		 */
978e2a46a4SMauro Carvalho Chehab	}
988e2a46a4SMauro Carvalho Chehab
998e2a46a4SMauro Carvalho Chehab	/*
1008e2a46a4SMauro Carvalho Chehab	 * our remote processor is now powered on... give it some work
1018e2a46a4SMauro Carvalho Chehab	 */
1028e2a46a4SMauro Carvalho Chehab
1038e2a46a4SMauro Carvalho Chehab	/* let's shut it down now */
1048e2a46a4SMauro Carvalho Chehab	rproc_shutdown(my_rproc);
1058e2a46a4SMauro Carvalho Chehab  }
1068e2a46a4SMauro Carvalho Chehab
1078e2a46a4SMauro Carvalho ChehabAPI for implementors
1088e2a46a4SMauro Carvalho Chehab====================
1098e2a46a4SMauro Carvalho Chehab
1108e2a46a4SMauro Carvalho Chehab::
1118e2a46a4SMauro Carvalho Chehab
1128e2a46a4SMauro Carvalho Chehab  struct rproc *rproc_alloc(struct device *dev, const char *name,
1138e2a46a4SMauro Carvalho Chehab				const struct rproc_ops *ops,
1148e2a46a4SMauro Carvalho Chehab				const char *firmware, int len)
1158e2a46a4SMauro Carvalho Chehab
1168e2a46a4SMauro Carvalho ChehabAllocate a new remote processor handle, but don't register
1178e2a46a4SMauro Carvalho Chehabit yet. Required parameters are the underlying device, the
1188e2a46a4SMauro Carvalho Chehabname of this remote processor, platform-specific ops handlers,
1198e2a46a4SMauro Carvalho Chehabthe name of the firmware to boot this rproc with, and the
1208e2a46a4SMauro Carvalho Chehablength of private data needed by the allocating rproc driver (in bytes).
1218e2a46a4SMauro Carvalho Chehab
1228e2a46a4SMauro Carvalho ChehabThis function should be used by rproc implementations during
1238e2a46a4SMauro Carvalho Chehabinitialization of the remote processor.
1248e2a46a4SMauro Carvalho Chehab
1258e2a46a4SMauro Carvalho ChehabAfter creating an rproc handle using this function, and when ready,
1268e2a46a4SMauro Carvalho Chehabimplementations should then call rproc_add() to complete
1278e2a46a4SMauro Carvalho Chehabthe registration of the remote processor.
1288e2a46a4SMauro Carvalho Chehab
1298e2a46a4SMauro Carvalho ChehabOn success, the new rproc is returned, and on failure, NULL.
1308e2a46a4SMauro Carvalho Chehab
1318e2a46a4SMauro Carvalho Chehab.. note::
1328e2a46a4SMauro Carvalho Chehab
1338e2a46a4SMauro Carvalho Chehab  **never** directly deallocate @rproc, even if it was not registered
1348e2a46a4SMauro Carvalho Chehab  yet. Instead, when you need to unroll rproc_alloc(), use rproc_free().
1358e2a46a4SMauro Carvalho Chehab
1368e2a46a4SMauro Carvalho Chehab::
1378e2a46a4SMauro Carvalho Chehab
1388e2a46a4SMauro Carvalho Chehab  void rproc_free(struct rproc *rproc)
1398e2a46a4SMauro Carvalho Chehab
1408e2a46a4SMauro Carvalho ChehabFree an rproc handle that was allocated by rproc_alloc.
1418e2a46a4SMauro Carvalho Chehab
1428e2a46a4SMauro Carvalho ChehabThis function essentially unrolls rproc_alloc(), by decrementing the
1438e2a46a4SMauro Carvalho Chehabrproc's refcount. It doesn't directly free rproc; that would happen
1448e2a46a4SMauro Carvalho Chehabonly if there are no other references to rproc and its refcount now
1458e2a46a4SMauro Carvalho Chehabdropped to zero.
1468e2a46a4SMauro Carvalho Chehab
1478e2a46a4SMauro Carvalho Chehab::
1488e2a46a4SMauro Carvalho Chehab
1498e2a46a4SMauro Carvalho Chehab  int rproc_add(struct rproc *rproc)
1508e2a46a4SMauro Carvalho Chehab
1518e2a46a4SMauro Carvalho ChehabRegister @rproc with the remoteproc framework, after it has been
1528e2a46a4SMauro Carvalho Chehaballocated with rproc_alloc().
1538e2a46a4SMauro Carvalho Chehab
1548e2a46a4SMauro Carvalho ChehabThis is called by the platform-specific rproc implementation, whenever
1558e2a46a4SMauro Carvalho Chehaba new remote processor device is probed.
1568e2a46a4SMauro Carvalho Chehab
1578e2a46a4SMauro Carvalho ChehabReturns 0 on success and an appropriate error code otherwise.
1588e2a46a4SMauro Carvalho ChehabNote: this function initiates an asynchronous firmware loading
1598e2a46a4SMauro Carvalho Chehabcontext, which will look for virtio devices supported by the rproc's
1608e2a46a4SMauro Carvalho Chehabfirmware.
1618e2a46a4SMauro Carvalho Chehab
1628e2a46a4SMauro Carvalho ChehabIf found, those virtio devices will be created and added, so as a result
1638e2a46a4SMauro Carvalho Chehabof registering this remote processor, additional virtio drivers might get
1648e2a46a4SMauro Carvalho Chehabprobed.
1658e2a46a4SMauro Carvalho Chehab
1668e2a46a4SMauro Carvalho Chehab::
1678e2a46a4SMauro Carvalho Chehab
1688e2a46a4SMauro Carvalho Chehab  int rproc_del(struct rproc *rproc)
1698e2a46a4SMauro Carvalho Chehab
1708e2a46a4SMauro Carvalho ChehabUnroll rproc_add().
1718e2a46a4SMauro Carvalho Chehab
1728e2a46a4SMauro Carvalho ChehabThis function should be called when the platform specific rproc
1738e2a46a4SMauro Carvalho Chehabimplementation decides to remove the rproc device. it should
1748e2a46a4SMauro Carvalho Chehab_only_ be called if a previous invocation of rproc_add()
1758e2a46a4SMauro Carvalho Chehabhas completed successfully.
1768e2a46a4SMauro Carvalho Chehab
1778e2a46a4SMauro Carvalho ChehabAfter rproc_del() returns, @rproc is still valid, and its
1788e2a46a4SMauro Carvalho Chehablast refcount should be decremented by calling rproc_free().
1798e2a46a4SMauro Carvalho Chehab
1808e2a46a4SMauro Carvalho ChehabReturns 0 on success and -EINVAL if @rproc isn't valid.
1818e2a46a4SMauro Carvalho Chehab
1828e2a46a4SMauro Carvalho Chehab::
1838e2a46a4SMauro Carvalho Chehab
1848e2a46a4SMauro Carvalho Chehab  void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type)
1858e2a46a4SMauro Carvalho Chehab
1868e2a46a4SMauro Carvalho ChehabReport a crash in a remoteproc
1878e2a46a4SMauro Carvalho Chehab
1888e2a46a4SMauro Carvalho ChehabThis function must be called every time a crash is detected by the
1898e2a46a4SMauro Carvalho Chehabplatform specific rproc implementation. This should not be called from a
1908e2a46a4SMauro Carvalho Chehabnon-remoteproc driver. This function can be called from atomic/interrupt
1918e2a46a4SMauro Carvalho Chehabcontext.
1928e2a46a4SMauro Carvalho Chehab
1938e2a46a4SMauro Carvalho ChehabImplementation callbacks
1948e2a46a4SMauro Carvalho Chehab========================
1958e2a46a4SMauro Carvalho Chehab
1968e2a46a4SMauro Carvalho ChehabThese callbacks should be provided by platform-specific remoteproc
1978e2a46a4SMauro Carvalho Chehabdrivers::
1988e2a46a4SMauro Carvalho Chehab
1998e2a46a4SMauro Carvalho Chehab  /**
2008e2a46a4SMauro Carvalho Chehab   * struct rproc_ops - platform-specific device handlers
2018e2a46a4SMauro Carvalho Chehab   * @start:	power on the device and boot it
2028e2a46a4SMauro Carvalho Chehab   * @stop:	power off the device
2038e2a46a4SMauro Carvalho Chehab   * @kick:	kick a virtqueue (virtqueue id given as a parameter)
2048e2a46a4SMauro Carvalho Chehab   */
2058e2a46a4SMauro Carvalho Chehab  struct rproc_ops {
2068e2a46a4SMauro Carvalho Chehab	int (*start)(struct rproc *rproc);
2078e2a46a4SMauro Carvalho Chehab	int (*stop)(struct rproc *rproc);
2088e2a46a4SMauro Carvalho Chehab	void (*kick)(struct rproc *rproc, int vqid);
2098e2a46a4SMauro Carvalho Chehab  };
2108e2a46a4SMauro Carvalho Chehab
2118e2a46a4SMauro Carvalho ChehabEvery remoteproc implementation should at least provide the ->start and ->stop
2128e2a46a4SMauro Carvalho Chehabhandlers. If rpmsg/virtio functionality is also desired, then the ->kick handler
2138e2a46a4SMauro Carvalho Chehabshould be provided as well.
2148e2a46a4SMauro Carvalho Chehab
2158e2a46a4SMauro Carvalho ChehabThe ->start() handler takes an rproc handle and should then power on the
2168e2a46a4SMauro Carvalho Chehabdevice and boot it (use rproc->priv to access platform-specific private data).
2178e2a46a4SMauro Carvalho ChehabThe boot address, in case needed, can be found in rproc->bootaddr (remoteproc
2188e2a46a4SMauro Carvalho Chehabcore puts there the ELF entry point).
2198e2a46a4SMauro Carvalho ChehabOn success, 0 should be returned, and on failure, an appropriate error code.
2208e2a46a4SMauro Carvalho Chehab
2218e2a46a4SMauro Carvalho ChehabThe ->stop() handler takes an rproc handle and powers the device down.
2228e2a46a4SMauro Carvalho ChehabOn success, 0 is returned, and on failure, an appropriate error code.
2238e2a46a4SMauro Carvalho Chehab
2248e2a46a4SMauro Carvalho ChehabThe ->kick() handler takes an rproc handle, and an index of a virtqueue
2258e2a46a4SMauro Carvalho Chehabwhere new message was placed in. Implementations should interrupt the remote
2268e2a46a4SMauro Carvalho Chehabprocessor and let it know it has pending messages. Notifying remote processors
2278e2a46a4SMauro Carvalho Chehabthe exact virtqueue index to look in is optional: it is easy (and not
2288e2a46a4SMauro Carvalho Chehabtoo expensive) to go through the existing virtqueues and look for new buffers
2298e2a46a4SMauro Carvalho Chehabin the used rings.
2308e2a46a4SMauro Carvalho Chehab
2318e2a46a4SMauro Carvalho ChehabBinary Firmware Structure
2328e2a46a4SMauro Carvalho Chehab=========================
2338e2a46a4SMauro Carvalho Chehab
2348e2a46a4SMauro Carvalho ChehabAt this point remoteproc supports ELF32 and ELF64 firmware binaries. However,
2358e2a46a4SMauro Carvalho Chehabit is quite expected that other platforms/devices which we'd want to
2368e2a46a4SMauro Carvalho Chehabsupport with this framework will be based on different binary formats.
2378e2a46a4SMauro Carvalho Chehab
2388e2a46a4SMauro Carvalho ChehabWhen those use cases show up, we will have to decouple the binary format
2398e2a46a4SMauro Carvalho Chehabfrom the framework core, so we can support several binary formats without
2408e2a46a4SMauro Carvalho Chehabduplicating common code.
2418e2a46a4SMauro Carvalho Chehab
2428e2a46a4SMauro Carvalho ChehabWhen the firmware is parsed, its various segments are loaded to memory
2438e2a46a4SMauro Carvalho Chehabaccording to the specified device address (might be a physical address
2448e2a46a4SMauro Carvalho Chehabif the remote processor is accessing memory directly).
2458e2a46a4SMauro Carvalho Chehab
2468e2a46a4SMauro Carvalho ChehabIn addition to the standard ELF segments, most remote processors would
2478e2a46a4SMauro Carvalho Chehabalso include a special section which we call "the resource table".
2488e2a46a4SMauro Carvalho Chehab
2498e2a46a4SMauro Carvalho ChehabThe resource table contains system resources that the remote processor
2508e2a46a4SMauro Carvalho Chehabrequires before it should be powered on, such as allocation of physically
2518e2a46a4SMauro Carvalho Chehabcontiguous memory, or iommu mapping of certain on-chip peripherals.
2528e2a46a4SMauro Carvalho ChehabRemotecore will only power up the device after all the resource table's
2538e2a46a4SMauro Carvalho Chehabrequirement are met.
2548e2a46a4SMauro Carvalho Chehab
2558e2a46a4SMauro Carvalho ChehabIn addition to system resources, the resource table may also contain
2568e2a46a4SMauro Carvalho Chehabresource entries that publish the existence of supported features
2578e2a46a4SMauro Carvalho Chehabor configurations by the remote processor, such as trace buffers and
2588e2a46a4SMauro Carvalho Chehabsupported virtio devices (and their configurations).
2598e2a46a4SMauro Carvalho Chehab
2608e2a46a4SMauro Carvalho ChehabThe resource table begins with this header::
2618e2a46a4SMauro Carvalho Chehab
2628e2a46a4SMauro Carvalho Chehab  /**
2638e2a46a4SMauro Carvalho Chehab   * struct resource_table - firmware resource table header
2648e2a46a4SMauro Carvalho Chehab   * @ver: version number
2658e2a46a4SMauro Carvalho Chehab   * @num: number of resource entries
2668e2a46a4SMauro Carvalho Chehab   * @reserved: reserved (must be zero)
2678e2a46a4SMauro Carvalho Chehab   * @offset: array of offsets pointing at the various resource entries
2688e2a46a4SMauro Carvalho Chehab   *
2698e2a46a4SMauro Carvalho Chehab   * The header of the resource table, as expressed by this structure,
2708e2a46a4SMauro Carvalho Chehab   * contains a version number (should we need to change this format in the
2718e2a46a4SMauro Carvalho Chehab   * future), the number of available resource entries, and their offsets
2728e2a46a4SMauro Carvalho Chehab   * in the table.
2738e2a46a4SMauro Carvalho Chehab   */
2748e2a46a4SMauro Carvalho Chehab  struct resource_table {
2758e2a46a4SMauro Carvalho Chehab	u32 ver;
2768e2a46a4SMauro Carvalho Chehab	u32 num;
2778e2a46a4SMauro Carvalho Chehab	u32 reserved[2];
2788e2a46a4SMauro Carvalho Chehab	u32 offset[0];
2798e2a46a4SMauro Carvalho Chehab  } __packed;
2808e2a46a4SMauro Carvalho Chehab
2818e2a46a4SMauro Carvalho ChehabImmediately following this header are the resource entries themselves,
2828e2a46a4SMauro Carvalho Chehabeach of which begins with the following resource entry header::
2838e2a46a4SMauro Carvalho Chehab
2848e2a46a4SMauro Carvalho Chehab  /**
2858e2a46a4SMauro Carvalho Chehab   * struct fw_rsc_hdr - firmware resource entry header
2868e2a46a4SMauro Carvalho Chehab   * @type: resource type
2878e2a46a4SMauro Carvalho Chehab   * @data: resource data
2888e2a46a4SMauro Carvalho Chehab   *
2898e2a46a4SMauro Carvalho Chehab   * Every resource entry begins with a 'struct fw_rsc_hdr' header providing
2908e2a46a4SMauro Carvalho Chehab   * its @type. The content of the entry itself will immediately follow
2918e2a46a4SMauro Carvalho Chehab   * this header, and it should be parsed according to the resource type.
2928e2a46a4SMauro Carvalho Chehab   */
2938e2a46a4SMauro Carvalho Chehab  struct fw_rsc_hdr {
2948e2a46a4SMauro Carvalho Chehab	u32 type;
2958e2a46a4SMauro Carvalho Chehab	u8 data[0];
2968e2a46a4SMauro Carvalho Chehab  } __packed;
2978e2a46a4SMauro Carvalho Chehab
2988e2a46a4SMauro Carvalho ChehabSome resources entries are mere announcements, where the host is informed
2998e2a46a4SMauro Carvalho Chehabof specific remoteproc configuration. Other entries require the host to
3008e2a46a4SMauro Carvalho Chehabdo something (e.g. allocate a system resource). Sometimes a negotiation
3018e2a46a4SMauro Carvalho Chehabis expected, where the firmware requests a resource, and once allocated,
3028e2a46a4SMauro Carvalho Chehabthe host should provide back its details (e.g. address of an allocated
3038e2a46a4SMauro Carvalho Chehabmemory region).
3048e2a46a4SMauro Carvalho Chehab
3058e2a46a4SMauro Carvalho ChehabHere are the various resource types that are currently supported::
3068e2a46a4SMauro Carvalho Chehab
3078e2a46a4SMauro Carvalho Chehab  /**
3088e2a46a4SMauro Carvalho Chehab   * enum fw_resource_type - types of resource entries
3098e2a46a4SMauro Carvalho Chehab   *
3108e2a46a4SMauro Carvalho Chehab   * @RSC_CARVEOUT:   request for allocation of a physically contiguous
3118e2a46a4SMauro Carvalho Chehab   *		    memory region.
3128e2a46a4SMauro Carvalho Chehab   * @RSC_DEVMEM:     request to iommu_map a memory-based peripheral.
3138e2a46a4SMauro Carvalho Chehab   * @RSC_TRACE:	    announces the availability of a trace buffer into which
3148e2a46a4SMauro Carvalho Chehab   *		    the remote processor will be writing logs.
3158e2a46a4SMauro Carvalho Chehab   * @RSC_VDEV:       declare support for a virtio device, and serve as its
3168e2a46a4SMauro Carvalho Chehab   *		    virtio header.
3178e2a46a4SMauro Carvalho Chehab   * @RSC_LAST:       just keep this one at the end
3188e2a46a4SMauro Carvalho Chehab   * @RSC_VENDOR_START:	start of the vendor specific resource types range
3198e2a46a4SMauro Carvalho Chehab   * @RSC_VENDOR_END:	end of the vendor specific resource types range
3208e2a46a4SMauro Carvalho Chehab   *
3218e2a46a4SMauro Carvalho Chehab   * Please note that these values are used as indices to the rproc_handle_rsc
3228e2a46a4SMauro Carvalho Chehab   * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to
3238e2a46a4SMauro Carvalho Chehab   * check the validity of an index before the lookup table is accessed, so
3248e2a46a4SMauro Carvalho Chehab   * please update it as needed.
3258e2a46a4SMauro Carvalho Chehab   */
3268e2a46a4SMauro Carvalho Chehab  enum fw_resource_type {
3278e2a46a4SMauro Carvalho Chehab	RSC_CARVEOUT		= 0,
3288e2a46a4SMauro Carvalho Chehab	RSC_DEVMEM		= 1,
3298e2a46a4SMauro Carvalho Chehab	RSC_TRACE		= 2,
3308e2a46a4SMauro Carvalho Chehab	RSC_VDEV		= 3,
3318e2a46a4SMauro Carvalho Chehab	RSC_LAST		= 4,
3328e2a46a4SMauro Carvalho Chehab	RSC_VENDOR_START	= 128,
3338e2a46a4SMauro Carvalho Chehab	RSC_VENDOR_END		= 512,
3348e2a46a4SMauro Carvalho Chehab  };
3358e2a46a4SMauro Carvalho Chehab
3368e2a46a4SMauro Carvalho ChehabFor more details regarding a specific resource type, please see its
3378e2a46a4SMauro Carvalho Chehabdedicated structure in include/linux/remoteproc.h.
3388e2a46a4SMauro Carvalho Chehab
3398e2a46a4SMauro Carvalho ChehabWe also expect that platform-specific resource entries will show up
3408e2a46a4SMauro Carvalho Chehabat some point. When that happens, we could easily add a new RSC_PLATFORM
3418e2a46a4SMauro Carvalho Chehabtype, and hand those resources to the platform-specific rproc driver to handle.
3428e2a46a4SMauro Carvalho Chehab
3438e2a46a4SMauro Carvalho ChehabVirtio and remoteproc
3448e2a46a4SMauro Carvalho Chehab=====================
3458e2a46a4SMauro Carvalho Chehab
3468e2a46a4SMauro Carvalho ChehabThe firmware should provide remoteproc information about virtio devices
3478e2a46a4SMauro Carvalho Chehabthat it supports, and their configurations: a RSC_VDEV resource entry
3488e2a46a4SMauro Carvalho Chehabshould specify the virtio device id (as in virtio_ids.h), virtio features,
3498e2a46a4SMauro Carvalho Chehabvirtio config space, vrings information, etc.
3508e2a46a4SMauro Carvalho Chehab
3518e2a46a4SMauro Carvalho ChehabWhen a new remote processor is registered, the remoteproc framework
3528e2a46a4SMauro Carvalho Chehabwill look for its resource table and will register the virtio devices
3538e2a46a4SMauro Carvalho Chehabit supports. A firmware may support any number of virtio devices, and
3548e2a46a4SMauro Carvalho Chehabof any type (a single remote processor can also easily support several
3558e2a46a4SMauro Carvalho Chehabrpmsg virtio devices this way, if desired).
3568e2a46a4SMauro Carvalho Chehab
3578e2a46a4SMauro Carvalho ChehabOf course, RSC_VDEV resource entries are only good enough for static
3588e2a46a4SMauro Carvalho Chehaballocation of virtio devices. Dynamic allocations will also be made possible
3598e2a46a4SMauro Carvalho Chehabusing the rpmsg bus (similar to how we already do dynamic allocations of
3608e2a46a4SMauro Carvalho Chehabrpmsg channels; read more about it in rpmsg.txt).
361