PageRenderTime 28ms CodeModel.GetById 19ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/video/tegra/host/chip_support.h

https://bitbucket.org/cyanogenmod/android_kernel_asus_tf300t
C Header | 180 lines | 144 code | 17 blank | 19 comment | 0 complexity | bcf399afeb8883b774eb64e0ac72f0ba MD5 | raw file
Possible License(s): LGPL-2.0, AGPL-1.0, GPL-2.0
  1/*
  2 * drivers/video/tegra/host/chip_support.h
  3 *
  4 * Tegra Graphics Host Chip Support
  5 *
  6 * Copyright (c) 2011-2012, NVIDIA Corporation.
  7 *
  8 * This program is free software; you can redistribute it and/or modify it
  9 * under the terms and conditions of the GNU General Public License,
 10 * version 2, as published by the Free Software Foundation.
 11 *
 12 * This program is distributed in the hope it will be useful, but WITHOUT
 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 14 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 15 * more details.
 16 *
 17 * You should have received a copy of the GNU General Public License
 18 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 19 */
 20#ifndef _NVHOST_CHIP_SUPPORT_H_
 21#define _NVHOST_CHIP_SUPPORT_H_
 22
 23#include <linux/types.h>
 24#include "bus.h"
 25
 26struct output;
 27
 28struct nvhost_master;
 29struct nvhost_intr;
 30struct nvhost_syncpt;
 31struct nvhost_userctx_timeout;
 32struct nvhost_channel;
 33struct nvhost_hwctx;
 34struct nvhost_cdma;
 35struct nvhost_job;
 36struct push_buffer;
 37struct nvhost_syncpt;
 38struct dentry;
 39struct nvhost_job;
 40struct nvhost_intr_syncpt;
 41struct mem_handle;
 42struct mem_mgr;
 43struct nvhost_device;
 44
 45struct nvhost_channel_ops {
 46	int (*init)(struct nvhost_channel *,
 47		    struct nvhost_master *,
 48		    int chid);
 49	int (*submit)(struct nvhost_job *job);
 50	int (*read3dreg)(struct nvhost_channel *channel,
 51			struct nvhost_hwctx *hwctx,
 52			u32 offset,
 53			u32 *value);
 54	int (*save_context)(struct nvhost_channel *channel);
 55	int (*drain_read_fifo)(struct nvhost_channel *ch,
 56		u32 *ptr, unsigned int count, unsigned int *pending);
 57};
 58
 59struct nvhost_cdma_ops {
 60	void (*start)(struct nvhost_cdma *);
 61	void (*stop)(struct nvhost_cdma *);
 62	void (*kick)(struct  nvhost_cdma *);
 63	int (*timeout_init)(struct nvhost_cdma *,
 64			    u32 syncpt_id);
 65	void (*timeout_destroy)(struct nvhost_cdma *);
 66	void (*timeout_teardown_begin)(struct nvhost_cdma *);
 67	void (*timeout_teardown_end)(struct nvhost_cdma *,
 68				     u32 getptr);
 69	void (*timeout_cpu_incr)(struct nvhost_cdma *,
 70				 u32 getptr,
 71				 u32 syncpt_incrs,
 72				 u32 syncval,
 73				 u32 nr_slots,
 74				 u32 waitbases);
 75};
 76
 77struct nvhost_pushbuffer_ops {
 78	void (*reset)(struct push_buffer *);
 79	int (*init)(struct push_buffer *);
 80	void (*destroy)(struct push_buffer *);
 81	void (*push_to)(struct push_buffer *,
 82			struct mem_mgr *, struct mem_handle *,
 83			u32 op1, u32 op2);
 84	void (*pop_from)(struct push_buffer *,
 85			 unsigned int slots);
 86	u32 (*space)(struct push_buffer *);
 87	u32 (*putptr)(struct push_buffer *);
 88};
 89
 90struct nvhost_debug_ops {
 91	void (*debug_init)(struct dentry *de);
 92	void (*show_channel_cdma)(struct nvhost_master *,
 93				  struct nvhost_channel *,
 94				  struct output *,
 95				  int chid);
 96	void (*show_channel_fifo)(struct nvhost_master *,
 97				  struct nvhost_channel *,
 98				  struct output *,
 99				  int chid);
100	void (*show_mlocks)(struct nvhost_master *m,
101			    struct output *o);
102
103};
104
105struct nvhost_syncpt_ops {
106	void (*reset)(struct nvhost_syncpt *, u32 id);
107	void (*reset_wait_base)(struct nvhost_syncpt *, u32 id);
108	void (*read_wait_base)(struct nvhost_syncpt *, u32 id);
109	u32 (*update_min)(struct nvhost_syncpt *, u32 id);
110	void (*cpu_incr)(struct nvhost_syncpt *, u32 id);
111	int (*patch_wait)(struct nvhost_syncpt *sp,
112			void *patch_addr);
113	void (*debug)(struct nvhost_syncpt *);
114	const char * (*name)(struct nvhost_syncpt *, u32 id);
115	int (*mutex_try_lock)(struct nvhost_syncpt *,
116			      unsigned int idx);
117	void (*mutex_unlock)(struct nvhost_syncpt *,
118			     unsigned int idx);
119};
120
121struct nvhost_intr_ops {
122	void (*init_host_sync)(struct nvhost_intr *);
123	void (*set_host_clocks_per_usec)(
124		struct nvhost_intr *, u32 clocks);
125	void (*set_syncpt_threshold)(
126		struct nvhost_intr *, u32 id, u32 thresh);
127	void (*enable_syncpt_intr)(struct nvhost_intr *, u32 id);
128	void (*disable_all_syncpt_intrs)(struct nvhost_intr *);
129	int  (*request_host_general_irq)(struct nvhost_intr *);
130	void (*free_host_general_irq)(struct nvhost_intr *);
131	int (*request_syncpt_irq)(struct nvhost_intr_syncpt *syncpt);
132};
133
134struct nvhost_dev_ops {
135	struct nvhost_channel *(*alloc_nvhost_channel)(
136			struct nvhost_device *dev);
137	void (*free_nvhost_channel)(struct nvhost_channel *ch);
138};
139
140struct nvhost_mem_ops {
141	struct mem_mgr *(*alloc_mgr)(void);
142	void (*put_mgr)(struct mem_mgr *);
143	struct mem_mgr *(*get_mgr)(struct mem_mgr *);
144	struct mem_mgr *(*get_mgr_file)(int fd);
145	struct mem_handle *(*alloc)(struct mem_mgr *,
146			size_t size, size_t align,
147			int flags);
148	struct mem_handle *(*get)(struct mem_mgr *, u32 id);
149	void (*put)(struct mem_mgr *, struct mem_handle *);
150	phys_addr_t (*pin)(struct mem_mgr *, struct mem_handle *);
151	void (*unpin)(struct mem_mgr *, struct mem_handle *);
152	void *(*mmap)(struct mem_handle *);
153	void (*munmap)(struct mem_handle *, void *);
154};
155
156struct nvhost_chip_support {
157	struct nvhost_channel_ops channel;
158	struct nvhost_cdma_ops cdma;
159	struct nvhost_pushbuffer_ops push_buffer;
160	struct nvhost_debug_ops debug;
161	struct nvhost_syncpt_ops syncpt;
162	struct nvhost_intr_ops intr;
163	struct nvhost_dev_ops nvhost_dev;
164	struct nvhost_mem_ops mem;
165};
166
167struct nvhost_chip_support *nvhost_get_chip_ops(void);
168
169#define host_device_op()	nvhost_get_chip_ops()->nvhost_dev
170#define channel_cdma_op()	nvhost_get_chip_ops()->cdma
171#define channel_op()		nvhost_get_chip_ops()->channel
172#define syncpt_op()		nvhost_get_chip_ops()->syncpt
173#define intr_op()		nvhost_get_chip_ops()->intr
174#define cdma_op()		nvhost_get_chip_ops()->cdma
175#define cdma_pb_op()		nvhost_get_chip_ops()->push_buffer
176#define mem_op()		(nvhost_get_chip_ops()->mem)
177
178int nvhost_init_chip_support(struct nvhost_master *);
179
180#endif /* _NVHOST_CHIP_SUPPORT_H_ */