| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * 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 | 4 | */ |
|---|
| 18 | 5 | |
|---|
| 19 | 6 | #ifndef __LINUX_HOST1X_H |
|---|
| .. | .. |
|---|
| 30 | 17 | HOST1X_CLASS_GR3D = 0x60, |
|---|
| 31 | 18 | }; |
|---|
| 32 | 19 | |
|---|
| 20 | +struct host1x; |
|---|
| 33 | 21 | struct host1x_client; |
|---|
| 22 | +struct iommu_group; |
|---|
| 23 | + |
|---|
| 24 | +u64 host1x_get_dma_mask(struct host1x *host1x); |
|---|
| 34 | 25 | |
|---|
| 35 | 26 | /** |
|---|
| 36 | 27 | * struct host1x_client_ops - host1x client operations |
|---|
| 37 | 28 | * @init: host1x client initialization code |
|---|
| 38 | 29 | * @exit: host1x client tear down code |
|---|
| 30 | + * @suspend: host1x client suspend code |
|---|
| 31 | + * @resume: host1x client resume code |
|---|
| 39 | 32 | */ |
|---|
| 40 | 33 | struct host1x_client_ops { |
|---|
| 41 | 34 | int (*init)(struct host1x_client *client); |
|---|
| 42 | 35 | int (*exit)(struct host1x_client *client); |
|---|
| 36 | + int (*suspend)(struct host1x_client *client); |
|---|
| 37 | + int (*resume)(struct host1x_client *client); |
|---|
| 43 | 38 | }; |
|---|
| 44 | 39 | |
|---|
| 45 | 40 | /** |
|---|
| 46 | 41 | * struct host1x_client - host1x client structure |
|---|
| 47 | 42 | * @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 |
|---|
| 49 | 44 | * @dev: pointer to struct device backing this host1x client |
|---|
| 45 | + * @group: IOMMU group that this client is a member of |
|---|
| 50 | 46 | * @ops: host1x client operations |
|---|
| 51 | 47 | * @class: host1x class represented by this client |
|---|
| 52 | 48 | * @channel: host1x channel associated with this client |
|---|
| 53 | 49 | * @syncpts: array of syncpoints requested for this client |
|---|
| 54 | 50 | * @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 |
|---|
| 55 | 54 | */ |
|---|
| 56 | 55 | struct host1x_client { |
|---|
| 57 | 56 | struct list_head list; |
|---|
| 58 | | - struct device *parent; |
|---|
| 57 | + struct device *host; |
|---|
| 59 | 58 | struct device *dev; |
|---|
| 59 | + struct iommu_group *group; |
|---|
| 60 | 60 | |
|---|
| 61 | 61 | const struct host1x_client_ops *ops; |
|---|
| 62 | 62 | |
|---|
| .. | .. |
|---|
| 65 | 65 | |
|---|
| 66 | 66 | struct host1x_syncpt **syncpts; |
|---|
| 67 | 67 | unsigned int num_syncpts; |
|---|
| 68 | + |
|---|
| 69 | + struct host1x_client *parent; |
|---|
| 70 | + unsigned int usecount; |
|---|
| 71 | + struct mutex lock; |
|---|
| 68 | 72 | }; |
|---|
| 69 | 73 | |
|---|
| 70 | 74 | /* |
|---|
| .. | .. |
|---|
| 77 | 81 | struct host1x_bo_ops { |
|---|
| 78 | 82 | struct host1x_bo *(*get)(struct host1x_bo *bo); |
|---|
| 79 | 83 | 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); |
|---|
| 82 | 87 | void *(*mmap)(struct host1x_bo *bo); |
|---|
| 83 | 88 | 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); |
|---|
| 86 | 89 | }; |
|---|
| 87 | 90 | |
|---|
| 88 | 91 | struct host1x_bo { |
|---|
| .. | .. |
|---|
| 105 | 108 | bo->ops->put(bo); |
|---|
| 106 | 109 | } |
|---|
| 107 | 110 | |
|---|
| 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) |
|---|
| 110 | 114 | { |
|---|
| 111 | | - return bo->ops->pin(bo, sgt); |
|---|
| 115 | + return bo->ops->pin(dev, bo, phys); |
|---|
| 112 | 116 | } |
|---|
| 113 | 117 | |
|---|
| 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) |
|---|
| 115 | 120 | { |
|---|
| 116 | | - bo->ops->unpin(bo, sgt); |
|---|
| 121 | + bo->ops->unpin(dev, sgt); |
|---|
| 117 | 122 | } |
|---|
| 118 | 123 | |
|---|
| 119 | 124 | static inline void *host1x_bo_mmap(struct host1x_bo *bo) |
|---|
| .. | .. |
|---|
| 124 | 129 | static inline void host1x_bo_munmap(struct host1x_bo *bo, void *addr) |
|---|
| 125 | 130 | { |
|---|
| 126 | 131 | 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); |
|---|
| 138 | 132 | } |
|---|
| 139 | 133 | |
|---|
| 140 | 134 | /* |
|---|
| .. | .. |
|---|
| 171 | 165 | struct host1x_channel; |
|---|
| 172 | 166 | struct host1x_job; |
|---|
| 173 | 167 | |
|---|
| 174 | | -struct host1x_channel *host1x_channel_request(struct device *dev); |
|---|
| 168 | +struct host1x_channel *host1x_channel_request(struct host1x_client *client); |
|---|
| 175 | 169 | struct host1x_channel *host1x_channel_get(struct host1x_channel *channel); |
|---|
| 176 | 170 | void host1x_channel_put(struct host1x_channel *channel); |
|---|
| 177 | 171 | int host1x_job_submit(struct host1x_job *job); |
|---|
| .. | .. |
|---|
| 179 | 173 | /* |
|---|
| 180 | 174 | * host1x job |
|---|
| 181 | 175 | */ |
|---|
| 176 | + |
|---|
| 177 | +#define HOST1X_RELOC_READ (1 << 0) |
|---|
| 178 | +#define HOST1X_RELOC_WRITE (1 << 1) |
|---|
| 182 | 179 | |
|---|
| 183 | 180 | struct host1x_reloc { |
|---|
| 184 | 181 | struct { |
|---|
| .. | .. |
|---|
| 190 | 187 | unsigned long offset; |
|---|
| 191 | 188 | } target; |
|---|
| 192 | 189 | unsigned long shift; |
|---|
| 190 | + unsigned long flags; |
|---|
| 193 | 191 | }; |
|---|
| 194 | 192 | |
|---|
| 195 | 193 | struct host1x_job { |
|---|
| .. | .. |
|---|
| 322 | 320 | int host1x_device_init(struct host1x_device *device); |
|---|
| 323 | 321 | int host1x_device_exit(struct host1x_device *device); |
|---|
| 324 | 322 | |
|---|
| 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 | + |
|---|
| 326 | 349 | 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); |
|---|
| 327 | 353 | |
|---|
| 328 | 354 | struct tegra_mipi_device; |
|---|
| 329 | 355 | |
|---|
| 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); |
|---|
| 331 | 358 | void tegra_mipi_free(struct tegra_mipi_device *device); |
|---|
| 332 | 359 | int tegra_mipi_enable(struct tegra_mipi_device *device); |
|---|
| 333 | 360 | 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); |
|---|
| 335 | 363 | |
|---|
| 336 | 364 | #endif |
|---|