GNU Linux-libre 6.9.2-gnu
[releases.git] / include / linux / remoteproc / pruss.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * PRU-ICSS Subsystem user interfaces
4  *
5  * Copyright (C) 2015-2022 Texas Instruments Incorporated - http://www.ti.com
6  *      Suman Anna <s-anna@ti.com>
7  */
8
9 #ifndef __LINUX_PRUSS_H
10 #define __LINUX_PRUSS_H
11
12 #include <linux/device.h>
13 #include <linux/types.h>
14
15 #define PRU_RPROC_DRVNAME "pru-rproc"
16
17 /**
18  * enum pruss_pru_id - PRU core identifiers
19  * @PRUSS_PRU0: PRU Core 0.
20  * @PRUSS_PRU1: PRU Core 1.
21  * @PRUSS_NUM_PRUS: Total number of PRU Cores available.
22  *
23  */
24
25 enum pruss_pru_id {
26         PRUSS_PRU0 = 0,
27         PRUSS_PRU1,
28         PRUSS_NUM_PRUS,
29 };
30
31 /*
32  * enum pru_ctable_idx - Configurable Constant table index identifiers
33  */
34 enum pru_ctable_idx {
35         PRU_C24 = 0,
36         PRU_C25,
37         PRU_C26,
38         PRU_C27,
39         PRU_C28,
40         PRU_C29,
41         PRU_C30,
42         PRU_C31,
43 };
44
45 struct device_node;
46 struct rproc;
47
48 #if IS_ENABLED(CONFIG_PRU_REMOTEPROC)
49
50 struct rproc *pru_rproc_get(struct device_node *np, int index,
51                             enum pruss_pru_id *pru_id);
52 void pru_rproc_put(struct rproc *rproc);
53 int pru_rproc_set_ctable(struct rproc *rproc, enum pru_ctable_idx c, u32 addr);
54
55 #else
56
57 static inline struct rproc *
58 pru_rproc_get(struct device_node *np, int index, enum pruss_pru_id *pru_id)
59 {
60         return ERR_PTR(-EOPNOTSUPP);
61 }
62
63 static inline void pru_rproc_put(struct rproc *rproc) { }
64
65 static inline int pru_rproc_set_ctable(struct rproc *rproc,
66                                        enum pru_ctable_idx c, u32 addr)
67 {
68         return -EOPNOTSUPP;
69 }
70
71 #endif /* CONFIG_PRU_REMOTEPROC */
72
73 static inline bool is_pru_rproc(struct device *dev)
74 {
75         const char *drv_name = dev_driver_string(dev);
76
77         if (strncmp(drv_name, PRU_RPROC_DRVNAME, sizeof(PRU_RPROC_DRVNAME)))
78                 return false;
79
80         return true;
81 }
82
83 #endif /* __LINUX_PRUSS_H */