1 /* fuc microcode util functions for gf100 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
96 bset $r12 31 // MMIO_CTRL_PENDING
97 nv_iowr(NV_PGRAPH_FECS_MMIO_CTRL, 0, $r12)
99 nv_iord($r12, NV_PGRAPH_FECS_MMIO_CTRL, 0)
102 mov $r10 6 // DONE_MMIO_RD
104 nv_iord($r15, NV_PGRAPH_FECS_MMIO_RDVAL, 0)
107 // nv_wr32 - write 32-bit value to nv register
109 // In : $r14 register
113 nv_iowr(NV_PGRAPH_FECS_MMIO_WRVAL, 0, $r15)
115 bset $r12 31 // MMIO_CTRL_PENDING
116 bset $r12 30 // MMIO_CTRL_WRITE
117 nv_iowr(NV_PGRAPH_FECS_MMIO_CTRL, 0, $r12)
119 nv_iord($r12, NV_PGRAPH_FECS_MMIO_CTRL, 0)
124 // wait_donez - wait on FUC_DONE bit to become clear
126 // In : $r10 bit to wait on
130 nv_iowr(NV_PGRAPH_FECS_CC_SCRATCH_VAL(6), 0, $r10)
132 nv_iord($r8, NV_PGRAPH_FECS_SIGNAL, 0)
134 bra ne #wait_donez_ne
138 // wait_doneo - wait on FUC_DONE bit to become set
140 // In : $r10 bit to wait on
144 nv_iowr(NV_PGRAPH_FECS_CC_SCRATCH_VAL(6), 0, $r10)
146 nv_iord($r8, NV_PGRAPH_FECS_SIGNAL, 0)
152 // mmctx_size - determine size of a mmio list transfer
154 // In : $r14 mmio list head
155 // $r15 mmio list tail
156 // Out: $r15 transfer size (in bytes)
168 bra ne #nv_mmctx_size_loop
172 // mmctx_xfer - execute a list of mmio transfers
175 // bit 0: direction (0 = save, 1 = load)
176 // bit 1: set if first transfer
177 // bit 2: set if last transfer
179 // $r12 mmio list head
180 // $r13 mmio list tail
188 bra e #mmctx_base_disabled
189 nv_iowr(NV_PGRAPH_FECS_MMCTX_BASE, 0, $r11)
190 bset $r9 0 // BASE_EN
193 bra e #mmctx_multi_disabled
194 nv_iowr(NV_PGRAPH_FECS_MMCTX_MULTI_STRIDE, 0, $r14)
195 nv_iowr(NV_PGRAPH_FECS_MMCTX_MULTI_MASK, 0, $r15)
196 bset $r9 1 // MULTI_EN
197 mmctx_multi_disabled:
200 shl b32 $r11 16 // DIR
201 bset $r11 12 // QLIMIT = 0x10
204 or $r11 $r14 // START_TRIGGER
205 nv_iowr(NV_PGRAPH_FECS_MMCTX_CTRL, 0, $r11)
207 // loop over the mmio list, and send requests to the hw
209 // wait for space in mmctx queue
211 nv_iord($r14, NV_PGRAPH_FECS_MMCTX_CTRL, 0)
213 bra e #mmctx_wait_free
218 nv_iowr(NV_PGRAPH_FECS_MMCTX_QUEUE, 0, $r14)
221 bra ne #mmctx_exec_loop
225 // wait for queue to empty
227 nv_iord($r11, NV_PGRAPH_FECS_MMCTX_CTRL, 0)
230 bra ne #mmctx_fini_wait
231 mov $r10 5 // DONE_MMCTX
236 shl b32 $r11 16 // DIR
237 bset $r11 12 // QLIMIT = 0x10
238 bset $r11 18 // STOP_TRIGGER
239 nv_iowr(NV_PGRAPH_FECS_MMCTX_CTRL, 0, $r11)
241 // wait for STOP_TRIGGER to clear
242 nv_iord($r11, NV_PGRAPH_FECS_MMCTX_CTRL, 0)
244 bra ne #mmctx_stop_wait
249 // Wait for DONE_STRAND
258 // unknown - call before issuing strand commands
261 mov $r9 NV_PGRAPH_FECS_STRAND_CMD_ENABLE
262 nv_iowr(NV_PGRAPH_FECS_STRAND_CMD, 0x3f, $r9)
266 // unknown - call after issuing strand commands
269 mov $r9 NV_PGRAPH_FECS_STRAND_CMD_DISABLE
270 nv_iowr(NV_PGRAPH_FECS_STRAND_CMD, 0x3f, $r9)
274 // Selects strand set?!
280 nv_iowr(NV_PGRAPH_FECS_STRAND_FILTER, 0x3f, $r12)
281 mov $r12 NV_PGRAPH_FECS_STRAND_CMD_DEACTIVATE_FILTER
282 nv_iowr(NV_PGRAPH_FECS_STRAND_CMD, 0x3f, $r12)
283 nv_iowr(NV_PGRAPH_FECS_STRAND_FILTER, 0x3f, $r14)
284 mov $r12 NV_PGRAPH_FECS_STRAND_CMD_ACTIVATE_FILTER
285 nv_iowr(NV_PGRAPH_FECS_STRAND_CMD, 0x3f, $r12)
289 // Initialise strand context data
291 // In : $r15 context base
292 // Out: $r15 context size (in bytes)
294 // Strandset(?) 3 hardcoded currently
303 nv_iowr(NV_PGRAPH_FECS_STRAND_SELECT, 0x3f, $r12)
304 mov $r12 NV_PGRAPH_FECS_STRAND_CMD_SEEK
305 nv_iowr(NV_PGRAPH_FECS_STRAND_CMD, 0x3f, $r12)
308 nv_iowr(NV_PGRAPH_FECS_STRAND_DATA, 0x3f, $r12)
309 mov $r12 NV_PGRAPH_FECS_STRAND_CMD_GET_INFO
310 nv_iowr(NV_PGRAPH_FECS_STRAND_CMD, 0x3f, $r12)
314 // read the size of each strand, poke the context offset of
315 // each into STRAND_{SAVE,LOAD}_SWBASE now, no need to worry
316 // about it later then.
317 nv_mkio($r8, NV_PGRAPH_FECS_STRAND_SAVE_SWBASE, 0x00)
318 nv_iord($r9, NV_PGRAPH_FECS_STRANDS_CNT, 0x00)
320 ctx_init_strand_loop:
321 iowr I[$r8 + 0x000] $r14 // STRAND_SAVE_SWBASE
322 iowr I[$r8 + 0x100] $r14 // STRAND_LOAD_SWBASE
323 iord $r10 I[$r8 + 0x200] // STRAND_SIZE
329 bra ne #ctx_init_strand_loop
332 sub b32 $r15 $r14 $r15