OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * arch/arm/mach-tegra/include/linux/nvmem_ioctl.h |
| 3 * |
| 4 * structure declarations for nvmem and nvmap user-space ioctls |
| 5 * |
| 6 * Copyright (c) 2009, 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 |
| 25 #if !defined(__KERNEL__) |
| 26 #define __user |
| 27 #endif |
| 28 |
| 29 #ifndef _MACH_TEGRA_NVMEM_IOCTL_H_ |
| 30 #define _MACH_TEGRA_NVMEM_IOCTL_H_ |
| 31 |
| 32 struct nvmem_create_handle { |
| 33 union { |
| 34 __u32 key; /* ClaimPreservedHandle */ |
| 35 __u32 id; /* FromId */ |
| 36 __u32 size; /* CreateHandle */ |
| 37 }; |
| 38 __u32 handle; |
| 39 }; |
| 40 |
| 41 #define NVMEM_HEAP_SYSMEM (1ul<<31) |
| 42 #define NVMEM_HEAP_IOVMM (1ul<<30) |
| 43 |
| 44 /* common carveout heaps */ |
| 45 #define NVMEM_HEAP_CARVEOUT_IRAM (1ul<<29) |
| 46 #define NVMEM_HEAP_CARVEOUT_GENERIC (1ul<<0) |
| 47 |
| 48 #define NVMEM_HEAP_CARVEOUT_MASK (NVMEM_HEAP_IOVMM - 1) |
| 49 |
| 50 #define NVMEM_HANDLE_UNCACHEABLE (0x0ul << 0) |
| 51 #define NVMEM_HANDLE_WRITE_COMBINE (0x1ul << 0) |
| 52 #define NVMEM_HANDLE_INNER_CACHEABLE (0x2ul << 0) |
| 53 #define NVMEM_HANDLE_CACHEABLE (0x3ul << 0) |
| 54 |
| 55 #define NVMEM_HANDLE_SECURE (0x1ul << 2) |
| 56 |
| 57 struct nvmem_alloc_handle { |
| 58 __u32 handle; |
| 59 __u32 heap_mask; |
| 60 __u32 flags; |
| 61 __u32 align; |
| 62 }; |
| 63 |
| 64 struct nvmem_map_caller { |
| 65 __u32 handle; /* hmem */ |
| 66 __u32 offset; /* offset into hmem; should be page-aligned */ |
| 67 __u32 length; /* number of bytes to map */ |
| 68 __u32 flags; |
| 69 unsigned long addr; /* user pointer */ |
| 70 }; |
| 71 |
| 72 struct nvmem_rw_handle { |
| 73 unsigned long addr; /* user pointer */ |
| 74 __u32 handle; /* hmem */ |
| 75 __u32 offset; /* offset into hmem */ |
| 76 __u32 elem_size; /* individual atom size */ |
| 77 __u32 hmem_stride; /* delta in bytes between atoms in hmem */ |
| 78 __u32 user_stride; /* delta in bytes between atoms in user */ |
| 79 __u32 count; /* number of atoms to copy */ |
| 80 }; |
| 81 |
| 82 struct nvmem_pin_handle { |
| 83 unsigned long handles; /* array of handles to pin/unpin */ |
| 84 unsigned long addr; /* array of addresses to return */ |
| 85 __u32 count; /* number of entries in handles */ |
| 86 }; |
| 87 |
| 88 struct nvmem_handle_param { |
| 89 __u32 handle; |
| 90 __u32 param; |
| 91 unsigned long result; |
| 92 }; |
| 93 |
| 94 enum { |
| 95 NVMEM_HANDLE_PARAM_SIZE = 1, |
| 96 NVMEM_HANDLE_PARAM_ALIGNMENT, |
| 97 NVMEM_HANDLE_PARAM_BASE, |
| 98 NVMEM_HANDLE_PARAM_HEAP, |
| 99 }; |
| 100 |
| 101 enum { |
| 102 NVMEM_CACHE_OP_WB = 0, |
| 103 NVMEM_CACHE_OP_INV, |
| 104 NVMEM_CACHE_OP_WB_INV, |
| 105 }; |
| 106 |
| 107 struct nvmem_cache_op { |
| 108 unsigned long addr; |
| 109 __u32 handle; |
| 110 __u32 len; |
| 111 __s32 op; |
| 112 }; |
| 113 |
| 114 #define NVMEM_IOC_MAGIC 'N' |
| 115 |
| 116 /* Creates a new memory handle. On input, the argument is the size of the new |
| 117 * handle; on return, the argument is the name of the new handle |
| 118 */ |
| 119 #define NVMEM_IOC_CREATE _IOWR(NVMEM_IOC_MAGIC, 0, struct nvmem_create_handle) |
| 120 #define NVMEM_IOC_CLAIM _IOWR(NVMEM_IOC_MAGIC, 1, struct nvmem_create_handle) |
| 121 #define NVMEM_IOC_FROM_ID _IOWR(NVMEM_IOC_MAGIC, 2, struct nvmem_create_handle) |
| 122 |
| 123 /* Actually allocates memory for the specified handle */ |
| 124 #define NVMEM_IOC_ALLOC _IOW (NVMEM_IOC_MAGIC, 3, struct nvmem_alloc_handle) |
| 125 |
| 126 /* Frees a memory handle, unpinning any pinned pages and unmapping any mappings |
| 127 */ |
| 128 #define NVMEM_IOC_FREE _IO (NVMEM_IOC_MAGIC, 4) |
| 129 |
| 130 /* Maps the region of the specified handle into a user-provided virtual address |
| 131 * that was previously created via an mmap syscall on this fd */ |
| 132 #define NVMEM_IOC_MMAP _IOWR(NVMEM_IOC_MAGIC, 5, struct nvmem_map_caller) |
| 133 |
| 134 /* Reads/writes data (possibly strided) from a user-provided buffer into the |
| 135 * hmem at the specified offset */ |
| 136 #define NVMEM_IOC_WRITE _IOW (NVMEM_IOC_MAGIC, 6, struct nvmem_rw_handle) |
| 137 #define NVMEM_IOC_READ _IOW (NVMEM_IOC_MAGIC, 7, struct nvmem_rw_handle) |
| 138 |
| 139 #define NVMEM_IOC_PARAM _IOWR(NVMEM_IOC_MAGIC, 8, struct nvmem_handle_param) |
| 140 |
| 141 /* Pins a list of memory handles into IO-addressable memory (either IOVMM |
| 142 * space or physical memory, depending on the allocation), and returns the |
| 143 * address. Handles may be pinned recursively. */ |
| 144 #define NVMEM_IOC_PIN_MULT _IOWR(NVMEM_IOC_MAGIC, 10, struct nvmem_pin_handle) |
| 145 #define NVMEM_IOC_UNPIN_MULT _IOW (NVMEM_IOC_MAGIC, 11, struct nvmem_pin_handle) |
| 146 |
| 147 #define NVMEM_IOC_CACHE _IOW (NVMEM_IOC_MAGIC, 12, struct nvmem_cache_op) |
| 148 |
| 149 /* Returns a global ID usable to allow a remote process to create a handle |
| 150 * reference to the same handle */ |
| 151 #define NVMEM_IOC_GET_ID _IOWR(NVMEM_IOC_MAGIC, 13, struct nvmem_create_handle) |
| 152 |
| 153 #define NVMEM_IOC_MAXNR (_IOC_NR(NVMEM_IOC_GET_ID)) |
| 154 #endif |
OLD | NEW |