]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/host1x.h
objtool, x86: Add several functions and files to the objtool whitelist
[mirror_ubuntu-artful-kernel.git] / include / linux / host1x.h
CommitLineData
6579324a 1/*
6579324a
TB
2 * Copyright (c) 2009-2013, NVIDIA Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#ifndef __LINUX_HOST1X_H
20#define __LINUX_HOST1X_H
21
776dc384 22#include <linux/device.h>
35d747a8
TR
23#include <linux/types.h>
24
6579324a 25enum host1x_class {
e1e90644
TR
26 HOST1X_CLASS_HOST1X = 0x1,
27 HOST1X_CLASS_GR2D = 0x51,
28 HOST1X_CLASS_GR2D_SB = 0x52,
0ae797a8 29 HOST1X_CLASS_VIC = 0x5D,
5f60ed0d 30 HOST1X_CLASS_GR3D = 0x60,
6579324a
TB
31};
32
53fa7f72
TR
33struct host1x_client;
34
35struct host1x_client_ops {
36 int (*init)(struct host1x_client *client);
37 int (*exit)(struct host1x_client *client);
38};
39
40struct host1x_client {
41 struct list_head list;
776dc384 42 struct device *parent;
53fa7f72
TR
43 struct device *dev;
44
45 const struct host1x_client_ops *ops;
46
47 enum host1x_class class;
48 struct host1x_channel *channel;
49
50 struct host1x_syncpt **syncpts;
51 unsigned int num_syncpts;
52};
53
35d747a8
TR
54/*
55 * host1x buffer objects
56 */
57
58struct host1x_bo;
59struct sg_table;
60
61struct host1x_bo_ops {
62 struct host1x_bo *(*get)(struct host1x_bo *bo);
63 void (*put)(struct host1x_bo *bo);
64 dma_addr_t (*pin)(struct host1x_bo *bo, struct sg_table **sgt);
65 void (*unpin)(struct host1x_bo *bo, struct sg_table *sgt);
66 void *(*mmap)(struct host1x_bo *bo);
67 void (*munmap)(struct host1x_bo *bo, void *addr);
68 void *(*kmap)(struct host1x_bo *bo, unsigned int pagenum);
69 void (*kunmap)(struct host1x_bo *bo, unsigned int pagenum, void *addr);
70};
71
72struct host1x_bo {
73 const struct host1x_bo_ops *ops;
74};
75
76static inline void host1x_bo_init(struct host1x_bo *bo,
77 const struct host1x_bo_ops *ops)
78{
79 bo->ops = ops;
80}
81
82static inline struct host1x_bo *host1x_bo_get(struct host1x_bo *bo)
83{
84 return bo->ops->get(bo);
85}
86
87static inline void host1x_bo_put(struct host1x_bo *bo)
88{
89 bo->ops->put(bo);
90}
91
92static inline dma_addr_t host1x_bo_pin(struct host1x_bo *bo,
93 struct sg_table **sgt)
94{
95 return bo->ops->pin(bo, sgt);
96}
97
98static inline void host1x_bo_unpin(struct host1x_bo *bo, struct sg_table *sgt)
99{
100 bo->ops->unpin(bo, sgt);
101}
102
103static inline void *host1x_bo_mmap(struct host1x_bo *bo)
104{
105 return bo->ops->mmap(bo);
106}
107
108static inline void host1x_bo_munmap(struct host1x_bo *bo, void *addr)
109{
110 bo->ops->munmap(bo, addr);
111}
112
113static inline void *host1x_bo_kmap(struct host1x_bo *bo, unsigned int pagenum)
114{
115 return bo->ops->kmap(bo, pagenum);
116}
117
118static inline void host1x_bo_kunmap(struct host1x_bo *bo,
119 unsigned int pagenum, void *addr)
120{
121 bo->ops->kunmap(bo, pagenum, addr);
122}
123
124/*
125 * host1x syncpoints
126 */
127
8736fe81 128#define HOST1X_SYNCPT_CLIENT_MANAGED (1 << 0)
f5a954fe 129#define HOST1X_SYNCPT_HAS_BASE (1 << 1)
8736fe81 130
f5a954fe 131struct host1x_syncpt_base;
35d747a8
TR
132struct host1x_syncpt;
133struct host1x;
134
135struct host1x_syncpt *host1x_syncpt_get(struct host1x *host, u32 id);
136u32 host1x_syncpt_id(struct host1x_syncpt *sp);
137u32 host1x_syncpt_read_min(struct host1x_syncpt *sp);
138u32 host1x_syncpt_read_max(struct host1x_syncpt *sp);
b4a20144 139u32 host1x_syncpt_read(struct host1x_syncpt *sp);
35d747a8 140int host1x_syncpt_incr(struct host1x_syncpt *sp);
64400c37 141u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs);
35d747a8
TR
142int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout,
143 u32 *value);
144struct host1x_syncpt *host1x_syncpt_request(struct device *dev,
8736fe81 145 unsigned long flags);
35d747a8
TR
146void host1x_syncpt_free(struct host1x_syncpt *sp);
147
f5a954fe
AM
148struct host1x_syncpt_base *host1x_syncpt_get_base(struct host1x_syncpt *sp);
149u32 host1x_syncpt_base_id(struct host1x_syncpt_base *base);
150
35d747a8
TR
151/*
152 * host1x channel
153 */
154
155struct host1x_channel;
156struct host1x_job;
157
158struct host1x_channel *host1x_channel_request(struct device *dev);
159void host1x_channel_free(struct host1x_channel *channel);
160struct host1x_channel *host1x_channel_get(struct host1x_channel *channel);
161void host1x_channel_put(struct host1x_channel *channel);
162int host1x_job_submit(struct host1x_job *job);
163
164/*
165 * host1x job
166 */
167
168struct host1x_reloc {
961e3bea
TR
169 struct {
170 struct host1x_bo *bo;
171 unsigned long offset;
172 } cmdbuf;
173 struct {
174 struct host1x_bo *bo;
175 unsigned long offset;
176 } target;
177 unsigned long shift;
35d747a8
TR
178};
179
180struct host1x_job {
181 /* When refcount goes to zero, job can be freed */
182 struct kref ref;
183
184 /* List entry */
185 struct list_head list;
186
187 /* Channel where job is submitted to */
188 struct host1x_channel *channel;
189
190 u32 client;
191
192 /* Gathers and their memory */
193 struct host1x_job_gather *gathers;
194 unsigned int num_gathers;
195
196 /* Wait checks to be processed at submit time */
197 struct host1x_waitchk *waitchk;
198 unsigned int num_waitchk;
199 u32 waitchk_mask;
200
201 /* Array of handles to be pinned & unpinned */
202 struct host1x_reloc *relocarray;
203 unsigned int num_relocs;
204 struct host1x_job_unpin_data *unpins;
205 unsigned int num_unpins;
206
207 dma_addr_t *addr_phys;
208 dma_addr_t *gather_addr_phys;
209 dma_addr_t *reloc_addr_phys;
210
211 /* Sync point id, number of increments and end related to the submit */
212 u32 syncpt_id;
213 u32 syncpt_incrs;
214 u32 syncpt_end;
215
216 /* Maximum time to wait for this job */
217 unsigned int timeout;
218
219 /* Index and number of slots used in the push buffer */
220 unsigned int first_get;
221 unsigned int num_slots;
222
223 /* Copy of gathers */
224 size_t gather_copy_size;
225 dma_addr_t gather_copy;
226 u8 *gather_copy_mapped;
227
228 /* Check if register is marked as an address reg */
229 int (*is_addr_reg)(struct device *dev, u32 reg, u32 class);
230
231 /* Request a SETCLASS to this class */
232 u32 class;
233
234 /* Add a channel wait for previous ops to complete */
235 bool serialize;
236};
237
238struct host1x_job *host1x_job_alloc(struct host1x_channel *ch,
239 u32 num_cmdbufs, u32 num_relocs,
240 u32 num_waitchks);
241void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *mem_id,
242 u32 words, u32 offset);
243struct host1x_job *host1x_job_get(struct host1x_job *job);
244void host1x_job_put(struct host1x_job *job);
245int host1x_job_pin(struct host1x_job *job, struct device *dev);
246void host1x_job_unpin(struct host1x_job *job);
247
776dc384
TR
248/*
249 * subdevice probe infrastructure
250 */
251
252struct host1x_device;
253
254struct host1x_driver {
f4c5cf88
TR
255 struct device_driver driver;
256
776dc384
TR
257 const struct of_device_id *subdevs;
258 struct list_head list;
776dc384
TR
259
260 int (*probe)(struct host1x_device *device);
261 int (*remove)(struct host1x_device *device);
f4c5cf88 262 void (*shutdown)(struct host1x_device *device);
776dc384
TR
263};
264
f4c5cf88
TR
265static inline struct host1x_driver *
266to_host1x_driver(struct device_driver *driver)
267{
268 return container_of(driver, struct host1x_driver, driver);
269}
270
271int host1x_driver_register_full(struct host1x_driver *driver,
272 struct module *owner);
776dc384
TR
273void host1x_driver_unregister(struct host1x_driver *driver);
274
f4c5cf88
TR
275#define host1x_driver_register(driver) \
276 host1x_driver_register_full(driver, THIS_MODULE)
277
776dc384
TR
278struct host1x_device {
279 struct host1x_driver *driver;
280 struct list_head list;
281 struct device dev;
282
283 struct mutex subdevs_lock;
284 struct list_head subdevs;
285 struct list_head active;
286
287 struct mutex clients_lock;
288 struct list_head clients;
536e1715 289
f4c5cf88 290 bool registered;
776dc384
TR
291};
292
293static inline struct host1x_device *to_host1x_device(struct device *dev)
294{
295 return container_of(dev, struct host1x_device, dev);
296}
297
298int host1x_device_init(struct host1x_device *device);
299int host1x_device_exit(struct host1x_device *device);
300
301int host1x_client_register(struct host1x_client *client);
302int host1x_client_unregister(struct host1x_client *client);
303
4de6a2d6
TR
304struct tegra_mipi_device;
305
306struct tegra_mipi_device *tegra_mipi_request(struct device *device);
307void tegra_mipi_free(struct tegra_mipi_device *device);
87904c3e
TR
308int tegra_mipi_enable(struct tegra_mipi_device *device);
309int tegra_mipi_disable(struct tegra_mipi_device *device);
4de6a2d6
TR
310int tegra_mipi_calibrate(struct tegra_mipi_device *device);
311
6579324a 312#endif