hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/host1x.h
....@@ -1,19 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * 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.
174 */
185
196 #ifndef __LINUX_HOST1X_H
....@@ -30,33 +17,46 @@
3017 HOST1X_CLASS_GR3D = 0x60,
3118 };
3219
20
+struct host1x;
3321 struct host1x_client;
22
+struct iommu_group;
23
+
24
+u64 host1x_get_dma_mask(struct host1x *host1x);
3425
3526 /**
3627 * struct host1x_client_ops - host1x client operations
3728 * @init: host1x client initialization code
3829 * @exit: host1x client tear down code
30
+ * @suspend: host1x client suspend code
31
+ * @resume: host1x client resume code
3932 */
4033 struct host1x_client_ops {
4134 int (*init)(struct host1x_client *client);
4235 int (*exit)(struct host1x_client *client);
36
+ int (*suspend)(struct host1x_client *client);
37
+ int (*resume)(struct host1x_client *client);
4338 };
4439
4540 /**
4641 * struct host1x_client - host1x client structure
4742 * @list: list node for the host1x client
48
- * @parent: pointer to struct device representing the host1x controller
43
+ * @host: pointer to struct device representing the host1x controller
4944 * @dev: pointer to struct device backing this host1x client
45
+ * @group: IOMMU group that this client is a member of
5046 * @ops: host1x client operations
5147 * @class: host1x class represented by this client
5248 * @channel: host1x channel associated with this client
5349 * @syncpts: array of syncpoints requested for this client
5450 * @num_syncpts: number of syncpoints requested for this client
51
+ * @parent: pointer to parent structure
52
+ * @usecount: reference count for this structure
53
+ * @lock: mutex for mutually exclusive concurrency
5554 */
5655 struct host1x_client {
5756 struct list_head list;
58
- struct device *parent;
57
+ struct device *host;
5958 struct device *dev;
59
+ struct iommu_group *group;
6060
6161 const struct host1x_client_ops *ops;
6262
....@@ -65,6 +65,10 @@
6565
6666 struct host1x_syncpt **syncpts;
6767 unsigned int num_syncpts;
68
+
69
+ struct host1x_client *parent;
70
+ unsigned int usecount;
71
+ struct mutex lock;
6872 };
6973
7074 /*
....@@ -77,12 +81,11 @@
7781 struct host1x_bo_ops {
7882 struct host1x_bo *(*get)(struct host1x_bo *bo);
7983 void (*put)(struct host1x_bo *bo);
80
- dma_addr_t (*pin)(struct host1x_bo *bo, struct sg_table **sgt);
81
- void (*unpin)(struct host1x_bo *bo, struct sg_table *sgt);
84
+ struct sg_table *(*pin)(struct device *dev, struct host1x_bo *bo,
85
+ dma_addr_t *phys);
86
+ void (*unpin)(struct device *dev, struct sg_table *sgt);
8287 void *(*mmap)(struct host1x_bo *bo);
8388 void (*munmap)(struct host1x_bo *bo, void *addr);
84
- void *(*kmap)(struct host1x_bo *bo, unsigned int pagenum);
85
- void (*kunmap)(struct host1x_bo *bo, unsigned int pagenum, void *addr);
8689 };
8790
8891 struct host1x_bo {
....@@ -105,15 +108,17 @@
105108 bo->ops->put(bo);
106109 }
107110
108
-static inline dma_addr_t host1x_bo_pin(struct host1x_bo *bo,
109
- struct sg_table **sgt)
111
+static inline struct sg_table *host1x_bo_pin(struct device *dev,
112
+ struct host1x_bo *bo,
113
+ dma_addr_t *phys)
110114 {
111
- return bo->ops->pin(bo, sgt);
115
+ return bo->ops->pin(dev, bo, phys);
112116 }
113117
114
-static inline void host1x_bo_unpin(struct host1x_bo *bo, struct sg_table *sgt)
118
+static inline void host1x_bo_unpin(struct device *dev, struct host1x_bo *bo,
119
+ struct sg_table *sgt)
115120 {
116
- bo->ops->unpin(bo, sgt);
121
+ bo->ops->unpin(dev, sgt);
117122 }
118123
119124 static inline void *host1x_bo_mmap(struct host1x_bo *bo)
....@@ -124,17 +129,6 @@
124129 static inline void host1x_bo_munmap(struct host1x_bo *bo, void *addr)
125130 {
126131 bo->ops->munmap(bo, addr);
127
-}
128
-
129
-static inline void *host1x_bo_kmap(struct host1x_bo *bo, unsigned int pagenum)
130
-{
131
- return bo->ops->kmap(bo, pagenum);
132
-}
133
-
134
-static inline void host1x_bo_kunmap(struct host1x_bo *bo,
135
- unsigned int pagenum, void *addr)
136
-{
137
- bo->ops->kunmap(bo, pagenum, addr);
138132 }
139133
140134 /*
....@@ -171,7 +165,7 @@
171165 struct host1x_channel;
172166 struct host1x_job;
173167
174
-struct host1x_channel *host1x_channel_request(struct device *dev);
168
+struct host1x_channel *host1x_channel_request(struct host1x_client *client);
175169 struct host1x_channel *host1x_channel_get(struct host1x_channel *channel);
176170 void host1x_channel_put(struct host1x_channel *channel);
177171 int host1x_job_submit(struct host1x_job *job);
....@@ -179,6 +173,9 @@
179173 /*
180174 * host1x job
181175 */
176
+
177
+#define HOST1X_RELOC_READ (1 << 0)
178
+#define HOST1X_RELOC_WRITE (1 << 1)
182179
183180 struct host1x_reloc {
184181 struct {
....@@ -190,6 +187,7 @@
190187 unsigned long offset;
191188 } target;
192189 unsigned long shift;
190
+ unsigned long flags;
193191 };
194192
195193 struct host1x_job {
....@@ -322,15 +320,45 @@
322320 int host1x_device_init(struct host1x_device *device);
323321 int host1x_device_exit(struct host1x_device *device);
324322
325
-int host1x_client_register(struct host1x_client *client);
323
+void __host1x_client_init(struct host1x_client *client, struct lock_class_key *key);
324
+void host1x_client_exit(struct host1x_client *client);
325
+
326
+#define host1x_client_init(client) \
327
+ ({ \
328
+ static struct lock_class_key __key; \
329
+ __host1x_client_init(client, &__key); \
330
+ })
331
+
332
+int __host1x_client_register(struct host1x_client *client);
333
+
334
+/*
335
+ * Note that this wrapper calls __host1x_client_init() for compatibility
336
+ * with existing callers. Callers that want to separately initialize and
337
+ * register a host1x client must first initialize using either of the
338
+ * __host1x_client_init() or host1x_client_init() functions and then use
339
+ * the low-level __host1x_client_register() function to avoid the client
340
+ * getting reinitialized.
341
+ */
342
+#define host1x_client_register(client) \
343
+ ({ \
344
+ static struct lock_class_key __key; \
345
+ __host1x_client_init(client, &__key); \
346
+ __host1x_client_register(client); \
347
+ })
348
+
326349 int host1x_client_unregister(struct host1x_client *client);
350
+
351
+int host1x_client_suspend(struct host1x_client *client);
352
+int host1x_client_resume(struct host1x_client *client);
327353
328354 struct tegra_mipi_device;
329355
330
-struct tegra_mipi_device *tegra_mipi_request(struct device *device);
356
+struct tegra_mipi_device *tegra_mipi_request(struct device *device,
357
+ struct device_node *np);
331358 void tegra_mipi_free(struct tegra_mipi_device *device);
332359 int tegra_mipi_enable(struct tegra_mipi_device *device);
333360 int tegra_mipi_disable(struct tegra_mipi_device *device);
334
-int tegra_mipi_calibrate(struct tegra_mipi_device *device);
361
+int tegra_mipi_start_calibration(struct tegra_mipi_device *device);
362
+int tegra_mipi_finish_calibration(struct tegra_mipi_device *device);
335363
336364 #endif