| .. | .. |
|---|
| 25 | 25 | #include <core/memory.h> |
|---|
| 26 | 26 | #include <subdev/timer.h> |
|---|
| 27 | 27 | |
|---|
| 28 | | -static void |
|---|
| 28 | +void |
|---|
| 29 | 29 | nvkm_falcon_v1_load_imem(struct nvkm_falcon *falcon, void *data, u32 start, |
|---|
| 30 | 30 | u32 size, u16 tag, u8 port, bool secure) |
|---|
| 31 | 31 | { |
|---|
| .. | .. |
|---|
| 89 | 89 | } |
|---|
| 90 | 90 | } |
|---|
| 91 | 91 | |
|---|
| 92 | | -static const u32 EMEM_START_ADDR = 0x1000000; |
|---|
| 93 | | - |
|---|
| 94 | | -static void |
|---|
| 92 | +void |
|---|
| 95 | 93 | nvkm_falcon_v1_load_dmem(struct nvkm_falcon *falcon, void *data, u32 start, |
|---|
| 96 | | - u32 size, u8 port) |
|---|
| 94 | + u32 size, u8 port) |
|---|
| 97 | 95 | { |
|---|
| 96 | + const struct nvkm_falcon_func *func = falcon->func; |
|---|
| 98 | 97 | u8 rem = size % 4; |
|---|
| 99 | 98 | int i; |
|---|
| 100 | 99 | |
|---|
| 101 | | - if (start >= EMEM_START_ADDR && falcon->has_emem) |
|---|
| 100 | + if (func->emem_addr && start >= func->emem_addr) |
|---|
| 102 | 101 | return nvkm_falcon_v1_load_emem(falcon, data, |
|---|
| 103 | | - start - EMEM_START_ADDR, size, |
|---|
| 102 | + start - func->emem_addr, size, |
|---|
| 104 | 103 | port); |
|---|
| 105 | 104 | |
|---|
| 106 | 105 | size -= rem; |
|---|
| .. | .. |
|---|
| 148 | 147 | } |
|---|
| 149 | 148 | } |
|---|
| 150 | 149 | |
|---|
| 151 | | -static void |
|---|
| 150 | +void |
|---|
| 152 | 151 | nvkm_falcon_v1_read_dmem(struct nvkm_falcon *falcon, u32 start, u32 size, |
|---|
| 153 | 152 | u8 port, void *data) |
|---|
| 154 | 153 | { |
|---|
| 154 | + const struct nvkm_falcon_func *func = falcon->func; |
|---|
| 155 | 155 | u8 rem = size % 4; |
|---|
| 156 | 156 | int i; |
|---|
| 157 | 157 | |
|---|
| 158 | | - if (start >= EMEM_START_ADDR && falcon->has_emem) |
|---|
| 159 | | - return nvkm_falcon_v1_read_emem(falcon, start - EMEM_START_ADDR, |
|---|
| 158 | + if (func->emem_addr && start >= func->emem_addr) |
|---|
| 159 | + return nvkm_falcon_v1_read_emem(falcon, start - func->emem_addr, |
|---|
| 160 | 160 | size, port, data); |
|---|
| 161 | 161 | |
|---|
| 162 | 162 | size -= rem; |
|---|
| .. | .. |
|---|
| 179 | 179 | } |
|---|
| 180 | 180 | } |
|---|
| 181 | 181 | |
|---|
| 182 | | -static void |
|---|
| 182 | +void |
|---|
| 183 | 183 | nvkm_falcon_v1_bind_context(struct nvkm_falcon *falcon, struct nvkm_memory *ctx) |
|---|
| 184 | 184 | { |
|---|
| 185 | + const u32 fbif = falcon->func->fbif; |
|---|
| 185 | 186 | u32 inst_loc; |
|---|
| 186 | | - u32 fbif; |
|---|
| 187 | 187 | |
|---|
| 188 | 188 | /* disable instance block binding */ |
|---|
| 189 | 189 | if (ctx == NULL) { |
|---|
| 190 | 190 | nvkm_falcon_wr32(falcon, 0x10c, 0x0); |
|---|
| 191 | 191 | return; |
|---|
| 192 | | - } |
|---|
| 193 | | - |
|---|
| 194 | | - switch (falcon->owner->index) { |
|---|
| 195 | | - case NVKM_ENGINE_NVENC0: |
|---|
| 196 | | - case NVKM_ENGINE_NVENC1: |
|---|
| 197 | | - case NVKM_ENGINE_NVENC2: |
|---|
| 198 | | - fbif = 0x800; |
|---|
| 199 | | - break; |
|---|
| 200 | | - case NVKM_SUBDEV_PMU: |
|---|
| 201 | | - fbif = 0xe00; |
|---|
| 202 | | - break; |
|---|
| 203 | | - default: |
|---|
| 204 | | - fbif = 0x600; |
|---|
| 205 | | - break; |
|---|
| 206 | 192 | } |
|---|
| 207 | 193 | |
|---|
| 208 | 194 | nvkm_falcon_wr32(falcon, 0x10c, 0x1); |
|---|
| .. | .. |
|---|
| 235 | 221 | nvkm_falcon_mask(falcon, 0x0a4, 0x8, 0x8); |
|---|
| 236 | 222 | } |
|---|
| 237 | 223 | |
|---|
| 238 | | -static void |
|---|
| 224 | +void |
|---|
| 239 | 225 | nvkm_falcon_v1_set_start_addr(struct nvkm_falcon *falcon, u32 start_addr) |
|---|
| 240 | 226 | { |
|---|
| 241 | 227 | nvkm_falcon_wr32(falcon, 0x104, start_addr); |
|---|
| 242 | 228 | } |
|---|
| 243 | 229 | |
|---|
| 244 | | -static void |
|---|
| 230 | +void |
|---|
| 245 | 231 | nvkm_falcon_v1_start(struct nvkm_falcon *falcon) |
|---|
| 246 | 232 | { |
|---|
| 247 | 233 | u32 reg = nvkm_falcon_rd32(falcon, 0x100); |
|---|
| .. | .. |
|---|
| 252 | 238 | nvkm_falcon_wr32(falcon, 0x100, 0x2); |
|---|
| 253 | 239 | } |
|---|
| 254 | 240 | |
|---|
| 255 | | -static int |
|---|
| 241 | +int |
|---|
| 256 | 242 | nvkm_falcon_v1_wait_for_halt(struct nvkm_falcon *falcon, u32 ms) |
|---|
| 257 | 243 | { |
|---|
| 258 | 244 | struct nvkm_device *device = falcon->owner->device; |
|---|
| .. | .. |
|---|
| 265 | 251 | return 0; |
|---|
| 266 | 252 | } |
|---|
| 267 | 253 | |
|---|
| 268 | | -static int |
|---|
| 254 | +int |
|---|
| 269 | 255 | nvkm_falcon_v1_clear_interrupt(struct nvkm_falcon *falcon, u32 mask) |
|---|
| 270 | 256 | { |
|---|
| 271 | 257 | struct nvkm_device *device = falcon->owner->device; |
|---|
| .. | .. |
|---|
| 294 | 280 | return 0; |
|---|
| 295 | 281 | } |
|---|
| 296 | 282 | |
|---|
| 297 | | -static int |
|---|
| 283 | +int |
|---|
| 298 | 284 | nvkm_falcon_v1_enable(struct nvkm_falcon *falcon) |
|---|
| 299 | 285 | { |
|---|
| 300 | 286 | struct nvkm_device *device = falcon->owner->device; |
|---|
| .. | .. |
|---|
| 316 | 302 | return 0; |
|---|
| 317 | 303 | } |
|---|
| 318 | 304 | |
|---|
| 319 | | -static void |
|---|
| 305 | +void |
|---|
| 320 | 306 | nvkm_falcon_v1_disable(struct nvkm_falcon *falcon) |
|---|
| 321 | 307 | { |
|---|
| 322 | 308 | /* disable IRQs and wait for any previous code to complete */ |
|---|