mtd: rawnand: sunxi: Add A23/A33 DMA support
[linux/fpc-iii.git] / include / soc / tegra / bpmp.h
blob45960aa08f4aa18374f49866094325407dbae626
1 /*
2 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
14 #ifndef __SOC_TEGRA_BPMP_H
15 #define __SOC_TEGRA_BPMP_H
17 #include <linux/mailbox_client.h>
18 #include <linux/pm_domain.h>
19 #include <linux/reset-controller.h>
20 #include <linux/semaphore.h>
21 #include <linux/types.h>
23 #include <soc/tegra/bpmp-abi.h>
25 struct tegra_bpmp_clk;
26 struct tegra_bpmp_ops;
28 struct tegra_bpmp_soc {
29 struct {
30 struct {
31 unsigned int offset;
32 unsigned int count;
33 unsigned int timeout;
34 } cpu_tx, thread, cpu_rx;
35 } channels;
37 const struct tegra_bpmp_ops *ops;
38 unsigned int num_resets;
41 struct tegra_bpmp_mb_data {
42 u32 code;
43 u32 flags;
44 u8 data[MSG_DATA_MIN_SZ];
45 } __packed;
47 struct tegra_bpmp_channel {
48 struct tegra_bpmp *bpmp;
49 struct tegra_bpmp_mb_data *ib;
50 struct tegra_bpmp_mb_data *ob;
51 struct completion completion;
52 struct tegra_ivc *ivc;
53 unsigned int index;
56 typedef void (*tegra_bpmp_mrq_handler_t)(unsigned int mrq,
57 struct tegra_bpmp_channel *channel,
58 void *data);
60 struct tegra_bpmp_mrq {
61 struct list_head list;
62 unsigned int mrq;
63 tegra_bpmp_mrq_handler_t handler;
64 void *data;
67 struct tegra_bpmp {
68 const struct tegra_bpmp_soc *soc;
69 struct device *dev;
70 void *priv;
72 struct {
73 struct mbox_client client;
74 struct mbox_chan *channel;
75 } mbox;
77 spinlock_t atomic_tx_lock;
78 struct tegra_bpmp_channel *tx_channel, *rx_channel, *threaded_channels;
80 struct {
81 unsigned long *allocated;
82 unsigned long *busy;
83 unsigned int count;
84 struct semaphore lock;
85 } threaded;
87 struct list_head mrqs;
88 spinlock_t lock;
90 struct tegra_bpmp_clk **clocks;
91 unsigned int num_clocks;
93 struct reset_controller_dev rstc;
95 struct genpd_onecell_data genpd;
97 #ifdef CONFIG_DEBUG_FS
98 struct dentry *debugfs_mirror;
99 #endif
102 struct tegra_bpmp_message {
103 unsigned int mrq;
105 struct {
106 const void *data;
107 size_t size;
108 } tx;
110 struct {
111 void *data;
112 size_t size;
113 int ret;
114 } rx;
117 #if IS_ENABLED(CONFIG_TEGRA_BPMP)
118 struct tegra_bpmp *tegra_bpmp_get(struct device *dev);
119 void tegra_bpmp_put(struct tegra_bpmp *bpmp);
120 int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
121 struct tegra_bpmp_message *msg);
122 int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
123 struct tegra_bpmp_message *msg);
124 void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel, int code,
125 const void *data, size_t size);
127 int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
128 tegra_bpmp_mrq_handler_t handler, void *data);
129 void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
130 void *data);
131 bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp *bpmp, unsigned int mrq);
132 #else
133 static inline struct tegra_bpmp *tegra_bpmp_get(struct device *dev)
135 return ERR_PTR(-ENOTSUPP);
137 static inline void tegra_bpmp_put(struct tegra_bpmp *bpmp)
140 static inline int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
141 struct tegra_bpmp_message *msg)
143 return -ENOTSUPP;
145 static inline int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
146 struct tegra_bpmp_message *msg)
148 return -ENOTSUPP;
150 static inline void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel,
151 int code, const void *data,
152 size_t size)
156 static inline int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp,
157 unsigned int mrq,
158 tegra_bpmp_mrq_handler_t handler,
159 void *data)
161 return -ENOTSUPP;
163 static inline void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp,
164 unsigned int mrq, void *data)
168 static inline bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp *bpmp,
169 unsigned int mrq)
171 return false;
173 #endif
175 void tegra_bpmp_handle_rx(struct tegra_bpmp *bpmp);
177 #if IS_ENABLED(CONFIG_CLK_TEGRA_BPMP)
178 int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp);
179 #else
180 static inline int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp)
182 return 0;
184 #endif
186 #if IS_ENABLED(CONFIG_RESET_TEGRA_BPMP)
187 int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp);
188 #else
189 static inline int tegra_bpmp_init_resets(struct tegra_bpmp *bpmp)
191 return 0;
193 #endif
195 #if IS_ENABLED(CONFIG_SOC_TEGRA_POWERGATE_BPMP)
196 int tegra_bpmp_init_powergates(struct tegra_bpmp *bpmp);
197 #else
198 static inline int tegra_bpmp_init_powergates(struct tegra_bpmp *bpmp)
200 return 0;
202 #endif
204 #if IS_ENABLED(CONFIG_DEBUG_FS)
205 int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp);
206 #else
207 static inline int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
209 return 0;
211 #endif
214 #endif /* __SOC_TEGRA_BPMP_H */