|
3 | 3 | #define nvkm_gsp(p) container_of((p), struct nvkm_gsp, subdev) |
4 | 4 | #include <core/subdev.h> |
5 | 5 | #include <core/falcon.h> |
| 6 | +#include <core/firmware.h> |
| 7 | + |
| 8 | +#define GSP_PAGE_SHIFT 12 |
| 9 | +#define GSP_PAGE_SIZE BIT(GSP_PAGE_SHIFT) |
| 10 | + |
| 11 | +struct nvkm_gsp_mem { |
| 12 | + u32 size; |
| 13 | + void *data; |
| 14 | + dma_addr_t addr; |
| 15 | +}; |
| 16 | + |
| 17 | +struct nvkm_gsp_radix3 { |
| 18 | + struct nvkm_gsp_mem mem[3]; |
| 19 | +}; |
| 20 | + |
| 21 | +int nvkm_gsp_sg(struct nvkm_device *, u64 size, struct sg_table *); |
| 22 | +void nvkm_gsp_sg_free(struct nvkm_device *, struct sg_table *); |
| 23 | + |
| 24 | +typedef int (*nvkm_gsp_msg_ntfy_func)(void *priv, u32 fn, void *repv, u32 repc); |
6 | 25 |
|
7 | 26 | struct nvkm_gsp { |
8 | 27 | const struct nvkm_gsp_func *func; |
9 | 28 | struct nvkm_subdev subdev; |
10 | 29 |
|
11 | 30 | struct nvkm_falcon falcon; |
| 31 | + |
| 32 | + struct { |
| 33 | + struct { |
| 34 | + const struct firmware *load; |
| 35 | + const struct firmware *unload; |
| 36 | + } booter; |
| 37 | + const struct firmware *bl; |
| 38 | + const struct firmware *rm; |
| 39 | + } fws; |
| 40 | + |
| 41 | + struct nvkm_firmware fw; |
| 42 | + struct nvkm_gsp_mem sig; |
| 43 | + struct nvkm_gsp_radix3 radix3; |
| 44 | + |
| 45 | + struct { |
| 46 | + struct { |
| 47 | + struct { |
| 48 | + u64 addr; |
| 49 | + u64 size; |
| 50 | + } vga_workspace; |
| 51 | + u64 addr; |
| 52 | + u64 size; |
| 53 | + } bios; |
| 54 | + struct { |
| 55 | + struct { |
| 56 | + u64 addr; |
| 57 | + u64 size; |
| 58 | + } frts, boot, elf, heap; |
| 59 | + u64 addr; |
| 60 | + u64 size; |
| 61 | + } wpr2; |
| 62 | + struct { |
| 63 | + u64 addr; |
| 64 | + u64 size; |
| 65 | + } heap; |
| 66 | + u64 addr; |
| 67 | + u64 size; |
| 68 | + } fb; |
| 69 | + |
| 70 | + struct { |
| 71 | + struct nvkm_falcon_fw load; |
| 72 | + struct nvkm_falcon_fw unload; |
| 73 | + } booter; |
| 74 | + |
| 75 | + struct { |
| 76 | + struct nvkm_gsp_mem fw; |
| 77 | + u32 code_offset; |
| 78 | + u32 data_offset; |
| 79 | + u32 manifest_offset; |
| 80 | + u32 app_version; |
| 81 | + } boot; |
| 82 | + |
| 83 | + struct nvkm_gsp_mem libos; |
| 84 | + struct nvkm_gsp_mem loginit; |
| 85 | + struct nvkm_gsp_mem logintr; |
| 86 | + struct nvkm_gsp_mem logrm; |
| 87 | + struct nvkm_gsp_mem rmargs; |
| 88 | + |
| 89 | + struct nvkm_gsp_mem wpr_meta; |
| 90 | + |
| 91 | + struct { |
| 92 | + struct sg_table sgt; |
| 93 | + struct nvkm_gsp_radix3 radix3; |
| 94 | + struct nvkm_gsp_mem meta; |
| 95 | + } sr; |
| 96 | + |
| 97 | + struct { |
| 98 | + struct nvkm_gsp_mem mem; |
| 99 | + |
| 100 | + struct { |
| 101 | + int nr; |
| 102 | + u32 size; |
| 103 | + u64 *ptr; |
| 104 | + } ptes; |
| 105 | + |
| 106 | + struct { |
| 107 | + u32 size; |
| 108 | + void *ptr; |
| 109 | + } cmdq, msgq; |
| 110 | + } shm; |
| 111 | + |
| 112 | + struct nvkm_gsp_cmdq { |
| 113 | + struct mutex mutex; |
| 114 | + u32 cnt; |
| 115 | + u32 seq; |
| 116 | + u32 *wptr; |
| 117 | + u32 *rptr; |
| 118 | + } cmdq; |
| 119 | + |
| 120 | + struct nvkm_gsp_msgq { |
| 121 | + struct mutex mutex; |
| 122 | + u32 cnt; |
| 123 | + u32 *wptr; |
| 124 | + u32 *rptr; |
| 125 | + struct nvkm_gsp_msgq_ntfy { |
| 126 | + u32 fn; |
| 127 | + nvkm_gsp_msg_ntfy_func func; |
| 128 | + void *priv; |
| 129 | + } ntfy[16]; |
| 130 | + int ntfy_nr; |
| 131 | + } msgq; |
| 132 | + |
| 133 | + bool running; |
| 134 | + |
| 135 | + const struct nvkm_gsp_rm { |
| 136 | + void *(*rpc_get)(struct nvkm_gsp *, u32 fn, u32 argc); |
| 137 | + void *(*rpc_push)(struct nvkm_gsp *, void *argv, bool wait, u32 repc); |
| 138 | + void (*rpc_done)(struct nvkm_gsp *gsp, void *repv); |
| 139 | + } *rm; |
12 | 140 | }; |
13 | 141 |
|
14 | 142 | static inline bool |
15 | 143 | nvkm_gsp_rm(struct nvkm_gsp *gsp) |
16 | 144 | { |
17 | | - return false; |
| 145 | + return gsp && (gsp->fws.rm || gsp->fw.img); |
| 146 | +} |
| 147 | + |
| 148 | +static inline void * |
| 149 | +nvkm_gsp_rpc_get(struct nvkm_gsp *gsp, u32 fn, u32 argc) |
| 150 | +{ |
| 151 | + return gsp->rm->rpc_get(gsp, fn, argc); |
| 152 | +} |
| 153 | + |
| 154 | +static inline void * |
| 155 | +nvkm_gsp_rpc_push(struct nvkm_gsp *gsp, void *argv, bool wait, u32 repc) |
| 156 | +{ |
| 157 | + return gsp->rm->rpc_push(gsp, argv, wait, repc); |
| 158 | +} |
| 159 | + |
| 160 | +static inline void * |
| 161 | +nvkm_gsp_rpc_rd(struct nvkm_gsp *gsp, u32 fn, u32 argc) |
| 162 | +{ |
| 163 | + void *argv = nvkm_gsp_rpc_get(gsp, fn, argc); |
| 164 | + |
| 165 | + if (IS_ERR_OR_NULL(argv)) |
| 166 | + return argv; |
| 167 | + |
| 168 | + return nvkm_gsp_rpc_push(gsp, argv, true, argc); |
| 169 | +} |
| 170 | + |
| 171 | +static inline int |
| 172 | +nvkm_gsp_rpc_wr(struct nvkm_gsp *gsp, void *argv, bool wait) |
| 173 | +{ |
| 174 | + void *repv = nvkm_gsp_rpc_push(gsp, argv, wait, 0); |
| 175 | + |
| 176 | + if (IS_ERR(repv)) |
| 177 | + return PTR_ERR(repv); |
| 178 | + |
| 179 | + return 0; |
| 180 | +} |
| 181 | + |
| 182 | +static inline void |
| 183 | +nvkm_gsp_rpc_done(struct nvkm_gsp *gsp, void *repv) |
| 184 | +{ |
| 185 | + gsp->rm->rpc_done(gsp, repv); |
18 | 186 | } |
19 | 187 |
|
20 | 188 | int gv100_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **); |
21 | 189 | int tu102_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **); |
22 | 190 | int tu116_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **); |
23 | 191 | int ga100_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **); |
24 | 192 | int ga102_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **); |
| 193 | +int ad102_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **); |
25 | 194 | #endif |
0 commit comments