diff options
Diffstat (limited to 'arch/arm/mach-tegra/include/mach/nvmap.h')
-rw-r--r-- | arch/arm/mach-tegra/include/mach/nvmap.h | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/include/mach/nvmap.h b/arch/arm/mach-tegra/include/mach/nvmap.h new file mode 100644 index 00000000000..88f913fc29d --- /dev/null +++ b/arch/arm/mach-tegra/include/mach/nvmap.h | |||
@@ -0,0 +1,158 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-tegra/include/mach/nvmap.h | ||
3 | * | ||
4 | * structure declarations for nvmem and nvmap user-space ioctls | ||
5 | * | ||
6 | * Copyright (c) 2009-2011, NVIDIA Corporation. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
16 | * more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License along | ||
19 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/ioctl.h> | ||
24 | #include <linux/file.h> | ||
25 | #include <linux/rbtree.h> | ||
26 | |||
27 | #if !defined(__KERNEL__) | ||
28 | #define __user | ||
29 | #endif | ||
30 | |||
31 | #ifndef __NVMAP_H | ||
32 | #define __NVMAP_H | ||
33 | |||
34 | #define NVMAP_HEAP_SYSMEM (1ul<<31) | ||
35 | #define NVMAP_HEAP_IOVMM (1ul<<30) | ||
36 | |||
37 | /* common carveout heaps */ | ||
38 | #define NVMAP_HEAP_CARVEOUT_IRAM (1ul<<29) | ||
39 | #define NVMAP_HEAP_CARVEOUT_VPR (1ul<<28) | ||
40 | #define NVMAP_HEAP_CARVEOUT_GENERIC (1ul<<0) | ||
41 | |||
42 | #define NVMAP_HEAP_CARVEOUT_MASK (NVMAP_HEAP_IOVMM - 1) | ||
43 | |||
44 | /* allocation flags */ | ||
45 | #define NVMAP_HANDLE_UNCACHEABLE (0x0ul << 0) | ||
46 | #define NVMAP_HANDLE_WRITE_COMBINE (0x1ul << 0) | ||
47 | #define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0) | ||
48 | #define NVMAP_HANDLE_CACHEABLE (0x3ul << 0) | ||
49 | #define NVMAP_HANDLE_CACHE_FLAG (0x3ul << 0) | ||
50 | |||
51 | #define NVMAP_HANDLE_SECURE (0x1ul << 2) | ||
52 | |||
53 | |||
54 | #if defined(__KERNEL__) | ||
55 | |||
56 | #if defined(CONFIG_TEGRA_NVMAP) | ||
57 | struct nvmap_handle; | ||
58 | struct nvmap_client; | ||
59 | struct nvmap_device; | ||
60 | #define nvmap_ref_to_handle(_ref) (*(struct nvmap_handle **)(_ref)) | ||
61 | /* Convert User space handle to Kernel. */ | ||
62 | #define nvmap_convert_handle_u2k(h) (h) | ||
63 | #elif defined(CONFIG_ION_TEGRA) | ||
64 | /* For Ion Mem Manager support through nvmap_* API's. */ | ||
65 | #include "../../../../../drivers/gpu/ion/ion_priv.h" | ||
66 | |||
67 | #define nvmap_client ion_client | ||
68 | #define nvmap_device ion_device | ||
69 | #define nvmap_handle ion_handle | ||
70 | #define nvmap_handle_ref ion_handle | ||
71 | #define nvmap_ref_to_handle(_ref) (struct ion_handle *)_ref | ||
72 | /* Convert User space handle to Kernel. */ | ||
73 | #define nvmap_convert_handle_u2k(h) ({ \ | ||
74 | if ((u32)h >= TASK_SIZE) { \ | ||
75 | pr_err("Invalid user space handle."); \ | ||
76 | BUG(); \ | ||
77 | } \ | ||
78 | (*((u32 *)h)); }) | ||
79 | #endif | ||
80 | |||
81 | #define nvmap_id_to_handle(_id) ((struct nvmap_handle *)(_id)) | ||
82 | |||
83 | |||
84 | struct nvmap_pinarray_elem { | ||
85 | __u32 patch_mem; | ||
86 | __u32 patch_offset; | ||
87 | __u32 pin_mem; | ||
88 | __u32 pin_offset; | ||
89 | __u32 reloc_shift; | ||
90 | }; | ||
91 | |||
92 | #if defined(CONFIG_TEGRA_NVMAP) | ||
93 | /* handle_ref objects are client-local references to an nvmap_handle; | ||
94 | * they are distinct objects so that handles can be unpinned and | ||
95 | * unreferenced the correct number of times when a client abnormally | ||
96 | * terminates */ | ||
97 | struct nvmap_handle_ref { | ||
98 | struct nvmap_handle *handle; | ||
99 | struct rb_node node; | ||
100 | atomic_t dupes; /* number of times to free on file close */ | ||
101 | atomic_t pin; /* number of times to unpin on free */ | ||
102 | }; | ||
103 | #endif | ||
104 | |||
105 | struct nvmap_client *nvmap_create_client(struct nvmap_device *dev, | ||
106 | const char *name); | ||
107 | |||
108 | struct nvmap_handle_ref *nvmap_alloc(struct nvmap_client *client, size_t size, | ||
109 | size_t align, unsigned int flags, | ||
110 | unsigned int heap_mask); | ||
111 | |||
112 | void nvmap_free(struct nvmap_client *client, struct nvmap_handle_ref *r); | ||
113 | |||
114 | void *nvmap_mmap(struct nvmap_handle_ref *r); | ||
115 | |||
116 | void nvmap_munmap(struct nvmap_handle_ref *r, void *addr); | ||
117 | |||
118 | struct nvmap_client *nvmap_client_get_file(int fd); | ||
119 | |||
120 | struct nvmap_client *nvmap_client_get(struct nvmap_client *client); | ||
121 | |||
122 | void nvmap_client_put(struct nvmap_client *c); | ||
123 | |||
124 | phys_addr_t nvmap_pin(struct nvmap_client *c, struct nvmap_handle_ref *r); | ||
125 | |||
126 | phys_addr_t nvmap_handle_address(struct nvmap_client *c, unsigned long id); | ||
127 | |||
128 | void nvmap_unpin(struct nvmap_client *client, struct nvmap_handle_ref *r); | ||
129 | |||
130 | int nvmap_pin_array(struct nvmap_client *client, struct nvmap_handle *gather, | ||
131 | const struct nvmap_pinarray_elem *arr, int nr, | ||
132 | struct nvmap_handle **unique); | ||
133 | |||
134 | void nvmap_unpin_handles(struct nvmap_client *client, | ||
135 | struct nvmap_handle **h, int nr); | ||
136 | |||
137 | int nvmap_patch_word(struct nvmap_client *client, | ||
138 | struct nvmap_handle *patch, | ||
139 | u32 patch_offset, u32 patch_value); | ||
140 | |||
141 | struct nvmap_platform_carveout { | ||
142 | const char *name; | ||
143 | unsigned int usage_mask; | ||
144 | phys_addr_t base; | ||
145 | size_t size; | ||
146 | size_t buddy_size; | ||
147 | }; | ||
148 | |||
149 | struct nvmap_platform_data { | ||
150 | const struct nvmap_platform_carveout *carveouts; | ||
151 | unsigned int nr_carveouts; | ||
152 | }; | ||
153 | |||
154 | extern struct nvmap_device *nvmap_dev; | ||
155 | |||
156 | #endif | ||
157 | |||
158 | #endif | ||