drm/panfrost: Remove set but not used variable 'bo'
[linux/fpc-iii.git] / include / soc / tegra / bpmp.h
blobf2604e99af0911d00d0c747cee5b5b73d0600fbe
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
4 */
6 #ifndef __SOC_TEGRA_BPMP_H
7 #define __SOC_TEGRA_BPMP_H
9 #include <linux/mailbox_client.h>
10 #include <linux/pm_domain.h>
11 #include <linux/reset-controller.h>
12 #include <linux/semaphore.h>
13 #include <linux/types.h>
15 #include <soc/tegra/bpmp-abi.h>
17 struct tegra_bpmp_clk;
18 struct tegra_bpmp_ops;
20 struct tegra_bpmp_soc {
21 struct {
22 struct {
23 unsigned int offset;
24 unsigned int count;
25 unsigned int timeout;
26 } cpu_tx, thread, cpu_rx;
27 } channels;
29 const struct tegra_bpmp_ops *ops;
30 unsigned int num_resets;
33 struct tegra_bpmp_mb_data {
34 u32 code;
35 u32 flags;
36 u8 data[MSG_DATA_MIN_SZ];
37 } __packed;
39 struct tegra_bpmp_channel {
40 struct tegra_bpmp *bpmp;
41 struct tegra_bpmp_mb_data *ib;
42 struct tegra_bpmp_mb_data *ob;
43 struct completion completion;
44 struct tegra_ivc *ivc;
45 unsigned int index;
48 typedef void (*tegra_bpmp_mrq_handler_t)(unsigned int mrq,
49 struct tegra_bpmp_channel *channel,
50 void *data);
52 struct tegra_bpmp_mrq {
53 struct list_head list;
54 unsigned int mrq;
55 tegra_bpmp_mrq_handler_t handler;
56 void *data;
59 struct tegra_bpmp {
60 const struct tegra_bpmp_soc *soc;
61 struct device *dev;
62 void *priv;
64 struct {
65 struct mbox_client client;
66 struct mbox_chan *channel;
67 } mbox;
69 spinlock_t atomic_tx_lock;
70 struct tegra_bpmp_channel *tx_channel, *rx_channel, *threaded_channels;
72 struct {
73 unsigned long *allocated;
74 unsigned long *busy;
75 unsigned int count;
76 struct semaphore lock;
77 } threaded;
79 struct list_head mrqs;
80 spinlock_t lock;
82 struct tegra_bpmp_clk **clocks;
83 unsigned int num_clocks;
85 struct reset_controller_dev rstc;
87 struct genpd_onecell_data genpd;
89 #ifdef CONFIG_DEBUG_FS
90 struct dentry *debugfs_mirror;
91 #endif
94 struct tegra_bpmp_message {
95 unsigned int mrq;
97 struct {
98 const void *data;
99 size_t size;
100 } tx;
102 struct {
103 void *data;
104 size_t size;
105 int ret;
106 } rx;
109 #if IS_ENABLED(CONFIG_TEGRA_BPMP)
110 struct tegra_bpmp *tegra_bpmp_get(struct device *dev);
111 void tegra_bpmp_put(struct tegra_bpmp *bpmp);
112 int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
113 struct tegra_bpmp_message *msg);
114 int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
115 struct tegra_bpmp_message *msg);
116 void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel, int code,
117 const void *data, size_t size);
119 int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
120 tegra_bpmp_mrq_handler_t handler, void *data);
121 void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
122 void *data);
123 bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp *bpmp, unsigned int mrq);
124 #else
125 static inline struct tegra_bpmp *tegra_bpmp_get(struct device *dev)
127 return ERR_PTR(-ENOTSUPP);
129 static inline void tegra_bpmp_put(struct tegra_bpmp *bpmp)
132 static inline int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
133 struct tegra_bpmp_message *msg)
135 return -ENOTSUPP;
137 static inline int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
138 struct tegra_bpmp_message *msg)
140 return -ENOTSUPP;
142 static inline void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel,
143 int code, const void *data,
144 size_t size)
148 static inline int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp,
149 unsigned int mrq,
150 tegra_bpmp_mrq_handler_t handler,
151 void *data)
153 return -ENOTSUPP;
155 static inline void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp,
156 unsigned int mrq, void *data)
160 static inline bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp *bpmp,
161 unsigned int mrq)
163 return false;
165 #endif
167 void tegra_bpmp_handle_rx(struct tegra_bpmp *bpmp);
169 #if IS_ENABLED(CONFIG_CLK_TEGRA_BPMP)
170 int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp);
171 #else
172 static inline int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp)
174 return 0;
176 #endif
178 #if IS_ENABLED(CONFIG_RESET_TEGRA_BPMP)
179 int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp);
180 #else
181 static inline int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp)
183 return 0;
185 #endif
187 #if IS_ENABLED(CONFIG_SOC_TEGRA_POWERGATE_BPMP)
188 int tegra_bpmp_init_powergates(struct tegra_bpmp *bpmp);
189 #else
190 static inline int tegra_bpmp_init_powergates(struct tegra_bpmp *bpmp)
192 return 0;
194 #endif
196 #if IS_ENABLED(CONFIG_DEBUG_FS)
197 int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp);
198 #else
199 static inline int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
201 return 0;
203 #endif
206 #endif /* __SOC_TEGRA_BPMP_H */