1 /* fuc microcode util functions for nvc0 PGRAPH
3 * Copyright 2011 Red Hat Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
27 // queue_put - add request to queue
29 // In : $r13 queue pointer
34 // make sure we have space..
35 ld b32 $r8 D[$r13 + 0x0] // GET
36 ld b32 $r9 D[$r13 + 0x4] // PUT
39 bra ne #queue_put_next
40 mov $r15 E_CMD_OVERFLOW
44 // store cmd/data on queue
50 st b32 D[$r8 + 0x0] $r14
51 st b32 D[$r8 + 0x4] $r15
56 st b32 D[$r13 + 0x4] $r9
59 // queue_get - fetch request from queue
61 // In : $r13 queue pointer
63 // Out: $p1 clear on success (data available)
69 ld b32 $r8 D[$r13 + 0x0] // GET
70 ld b32 $r9 D[$r13 + 0x4] // PUT
73 // fetch first cmd/data pair
78 ld b32 $r14 D[$r9 + 0x0]
79 ld b32 $r15 D[$r9 + 0x4]
84 st b32 D[$r13 + 0x0] $r8
89 // nv_rd32 - read 32-bit value from nv register
98 bset $r12 31 // MMIO_CTRL_PENDING
99 iowr I[$r11 + 0x000] $r12 // MMIO_CTRL
101 iord $r12 I[$r11 + 0x000]
104 mov $r10 6 // DONE_MMIO_RD
106 iord $r15 I[$r11 + 0x100] // MMIO_RDVAL
109 // nv_wr32 - write 32-bit value to nv register
111 // In : $r14 register
117 iowr I[$r11 + 0x200] $r15 // MMIO_WRVAL
119 bset $r12 31 // MMIO_CTRL_PENDING
120 bset $r12 30 // MMIO_CTRL_WRITE
121 iowr I[$r11 + 0x000] $r12 // MMIO_CTRL
123 iord $r12 I[$r11 + 0x000]
128 // (re)set watchdog timer
136 iowr I[$r8 + 0x000] $r15
139 // clear watchdog timer
143 iowr I[$r8 + 0x000] $r0
146 // wait_donez - wait on FUC_DONE bit to become clear
148 // In : $r10 bit to wait on
152 nv_iowr(NV_PGRAPH_FECS_CC_SCRATCH_VAL(6), 0, $r10)
154 nv_iord($r8, NV_PGRAPH_FECS_SIGNAL, 0)
156 bra ne #wait_donez_ne
160 // wait_doneo - wait on FUC_DONE bit to become set
162 // In : $r10 bit to wait on
168 iowr I[$r8 + 0x000] $r10
172 iord $r8 I[$r8 + 0x000]
178 // mmctx_size - determine size of a mmio list transfer
180 // In : $r14 mmio list head
181 // $r15 mmio list tail
182 // Out: $r15 transfer size (in bytes)
194 bra ne #nv_mmctx_size_loop
198 // mmctx_xfer - execute a list of mmio transfers
201 // bit 0: direction (0 = save, 1 = load)
202 // bit 1: set if first transfer
203 // bit 2: set if last transfer
205 // $r12 mmio list head
206 // $r13 mmio list tail
216 bra e #mmctx_base_disabled
217 iowr I[$r8 + 0x000] $r11 // MMCTX_BASE
218 bset $r9 0 // BASE_EN
221 bra e #mmctx_multi_disabled
222 iowr I[$r8 + 0x200] $r14 // MMCTX_MULTI_STRIDE
223 iowr I[$r8 + 0x300] $r15 // MMCTX_MULTI_MASK
224 bset $r9 1 // MULTI_EN
225 mmctx_multi_disabled:
229 shl b32 $r11 16 // DIR
230 bset $r11 12 // QLIMIT = 0x10
233 or $r11 $r14 // START_TRIGGER
234 iowr I[$r8 + 0x000] $r11 // MMCTX_CTRL
236 // loop over the mmio list, and send requests to the hw
238 // wait for space in mmctx queue
240 iord $r14 I[$r8 + 0x000] // MMCTX_CTRL
242 bra e #mmctx_wait_free
247 iowr I[$r8 + 0x300] $r14
250 bra ne #mmctx_exec_loop
254 // wait for queue to empty
256 iord $r11 I[$r8 + 0x000] // MMCTX_CTRL
259 bra ne #mmctx_fini_wait
260 mov $r10 2 // DONE_MMCTX
265 shl b32 $r11 16 // DIR
266 bset $r11 12 // QLIMIT = 0x10
267 bset $r11 18 // STOP_TRIGGER
268 iowr I[$r8 + 0x000] $r11 // MMCTX_CTRL
270 // wait for STOP_TRIGGER to clear
271 iord $r11 I[$r8 + 0x000] // MMCTX_CTRL
273 bra ne #mmctx_stop_wait
278 // Wait for DONE_STRAND
287 // unknown - call before issuing strand commands
297 // unknown - call after issuing strand commands
307 // Selects strand set?!
314 sub b32 $r11 $r10 0x500
316 iowr I[$r10 + 0x000] $r12 // 0x93c = 0xf
318 iowr I[$r11 + 0x000] $r12 // 0x928 = 0xb
320 iowr I[$r10 + 0x000] $r14 // 0x93c = <id>
322 iowr I[$r11 + 0x000] $r12 // 0x928 = 0xa
326 // Initialise strand context data
328 // In : $r15 context base
329 // Out: $r15 context size (in bytes)
331 // Strandset(?) 3 hardcoded currently
340 add b32 $r11 $r10 0x400
341 iowr I[$r10 + 0x100] $r0 // STRAND_FIRST_GENE = 0
343 iowr I[$r11 + 0x000] $r12 // STRAND_CMD = LATCH_FIRST_GENE
346 iowr I[$r10 + 0x000] $r12 // STRAND_GENE_CNT = 0xffffffff
348 iowr I[$r11 + 0x000] $r12 // STRAND_CMD = LATCH_GENE_CNT
352 // read the size of each strand, poke the context offset of
353 // each into STRAND_{SAVE,LOAD}_SWBASE now, no need to worry
354 // about it later then.
357 iord $r9 I[$r8 + 0x000] // STRANDS
360 ctx_init_strand_loop:
361 iowr I[$r8 + 0x000] $r14 // STRAND_SAVE_SWBASE
362 iowr I[$r8 + 0x100] $r14 // STRAND_LOAD_SWBASE
363 iord $r10 I[$r8 + 0x200] // STRAND_SIZE
369 bra ne #ctx_init_strand_loop
372 sub b32 $r15 $r14 $r15