Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
remoteproc.h
Go to the documentation of this file.
1 /*
2  * Remote Processor Framework
3  *
4  * Copyright(c) 2011 Texas Instruments, Inc.
5  * Copyright(c) 2011 Google, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in
16  * the documentation and/or other materials provided with the
17  * distribution.
18  * * Neither the name Texas Instruments nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef REMOTEPROC_H
36 #define REMOTEPROC_H
37 
38 #include <linux/types.h>
39 #include <linux/klist.h>
40 #include <linux/mutex.h>
41 #include <linux/virtio.h>
42 #include <linux/completion.h>
43 #include <linux/idr.h>
44 
76  u32 offset[0];
77 } __packed;
78 
88 struct fw_rsc_hdr {
90  u8 data[0];
91 } __packed;
92 
117  RSC_VDEV = 3,
118  RSC_LAST = 4,
119 };
120 
121 #define FW_RSC_ADDR_ANY (0xFFFFFFFFFFFFFFFF)
122 
172  u8 name[32];
173 } __packed;
174 
210  u8 name[32];
211 } __packed;
212 
229 struct fw_rsc_trace {
233  u8 name[32];
234 } __packed;
235 
259 } __packed;
260 
296 struct fw_rsc_vdev {
306 } __packed;
307 
318  void *va;
320  int len;
322  void *priv;
323  struct list_head node;
324 };
325 
326 struct rproc;
327 
334 struct rproc_ops {
335  int (*start)(struct rproc *rproc);
336  int (*stop)(struct rproc *rproc);
337  void (*kick)(struct rproc *rproc, int vqid);
338 };
339 
361 };
362 
374 };
375 
405 struct rproc {
406  struct klist_node node;
408  const char *name;
409  const char *firmware;
410  void *priv;
411  const struct rproc_ops *ops;
412  struct device dev;
413  const struct rproc_fw_ops *fw_ops;
415  unsigned int state;
416  struct mutex lock;
417  struct dentry *dbg_dir;
425  struct idr notifyids;
426  int index;
428  unsigned crash_cnt;
432 };
433 
434 /* we currently support only two vrings per rvdev */
435 #define RVDEV_NUM_VRINGS 2
436 
448 struct rproc_vring {
449  void *va;
451  int len;
454  int notifyid;
455  struct rproc_vdev *rvdev;
456  struct virtqueue *vq;
457 };
458 
468 struct rproc_vdev {
469  struct list_head node;
470  struct rproc *rproc;
473  unsigned long dfeatures;
474  unsigned long gfeatures;
475 };
476 
477 struct rproc *rproc_alloc(struct device *dev, const char *name,
478  const struct rproc_ops *ops,
479  const char *firmware, int len);
480 void rproc_put(struct rproc *rproc);
481 int rproc_add(struct rproc *rproc);
482 int rproc_del(struct rproc *rproc);
483 
484 int rproc_boot(struct rproc *rproc);
485 void rproc_shutdown(struct rproc *rproc);
487 
488 static inline struct rproc_vdev *vdev_to_rvdev(struct virtio_device *vdev)
489 {
490  return container_of(vdev, struct rproc_vdev, vdev);
491 }
492 
493 static inline struct rproc *vdev_to_rproc(struct virtio_device *vdev)
494 {
495  struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
496 
497  return rvdev->rproc;
498 }
499 
500 #endif /* REMOTEPROC_H */