xref: /linux/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/macros.fuc (revision e5451c8f8330e03ad3cfa16048b4daf961af434f)
1b8bf04e1SBen Skeggs/*
2b8bf04e1SBen Skeggs * Copyright 2013 Red Hat Inc.
3b8bf04e1SBen Skeggs *
4b8bf04e1SBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
5b8bf04e1SBen Skeggs * copy of this software and associated documentation files (the "Software"),
6b8bf04e1SBen Skeggs * to deal in the Software without restriction, including without limitation
7b8bf04e1SBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8b8bf04e1SBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
9b8bf04e1SBen Skeggs * Software is furnished to do so, subject to the following conditions:
10b8bf04e1SBen Skeggs *
11b8bf04e1SBen Skeggs * The above copyright notice and this permission notice shall be included in
12b8bf04e1SBen Skeggs * all copies or substantial portions of the Software.
13b8bf04e1SBen Skeggs *
14b8bf04e1SBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15b8bf04e1SBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16b8bf04e1SBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17b8bf04e1SBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18b8bf04e1SBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19b8bf04e1SBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20b8bf04e1SBen Skeggs * OTHER DEALINGS IN THE SOFTWARE.
21b8bf04e1SBen Skeggs *
22b8bf04e1SBen Skeggs * Authors: Ben Skeggs <bskeggs@redhat.com>
23b8bf04e1SBen Skeggs */
24b8bf04e1SBen Skeggs
25b8bf04e1SBen Skeggs#include "os.h"
26b8bf04e1SBen Skeggs
27b8bf04e1SBen Skeggs#define GF100 0xc0
28b8bf04e1SBen Skeggs#define GF117 0xd7
29b8bf04e1SBen Skeggs#define GK100 0xe0
30b8bf04e1SBen Skeggs#define GK110 0xf0
31b8bf04e1SBen Skeggs#define GK208 0x108
32*8fd4b7d4SBen Skeggs#define GM107 0x117
33b8bf04e1SBen Skeggs
34b8bf04e1SBen Skeggs#define NV_PGRAPH_TRAPPED_ADDR                                         0x400704
35b8bf04e1SBen Skeggs#define NV_PGRAPH_TRAPPED_DATA_LO                                      0x400708
36b8bf04e1SBen Skeggs#define NV_PGRAPH_TRAPPED_DATA_HI                                      0x40070c
37b8bf04e1SBen Skeggs
38b8bf04e1SBen Skeggs#define NV_PGRAPH_FE_OBJECT_TABLE(n)                        ((n) * 4 + 0x400700)
39b8bf04e1SBen Skeggs
40b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_ACK                                        0x409004
41b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR                                            0x409008
42b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_FWMTHD                                   0x00000400
43b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_CHSW                                     0x00000100
44b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_FIFO                                     0x00000004
45b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_MODE                                       0x40900c
46b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_MODE_FIFO                                0x00000004
47b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_MODE_FIFO_LEVEL                          0x00000004
48b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_MODE_FIFO_EDGE                           0x00000000
49b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_EN_SET                                     0x409010
50b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_EN_SET_FIFO                              0x00000004
51b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_ROUTE                                      0x40901c
52b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_ACCESS                                          0x409048
53b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_ACCESS_FIFO                                   0x00000002
54b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_FIFO_DATA                                       0x409064
55b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_FIFO_CMD                                        0x409068
56b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_FIFO_ACK                                        0x409074
57b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_CAPS                                            0x409108
58b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_SIGNAL                                          0x409400
59b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_IROUTE                                          0x409404
60b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_BAR_MASK0                                       0x40940c
61b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_BAR_MASK1                                       0x409410
62b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_BAR                                             0x409414
63b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_BAR_SET                                         0x409418
64b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_RED_SWITCH                                      0x409614
65b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_RED_SWITCH_ENABLE_ROP                         0x00000400
66b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_RED_SWITCH_ENABLE_GPC                         0x00000200
67b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_RED_SWITCH_ENABLE_MAIN                        0x00000100
68b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_RED_SWITCH_POWER_ROP                          0x00000040
69b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_RED_SWITCH_POWER_GPC                          0x00000020
70b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_RED_SWITCH_POWER_MAIN                         0x00000010
71b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_RED_SWITCH_PAUSE_GPC                          0x00000002
72b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_RED_SWITCH_PAUSE_MAIN                         0x00000001
73b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMCTX_SAVE_SWBASE                               0x409700
74b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMCTX_LOAD_SWBASE                               0x409704
75b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMCTX_LOAD_COUNT                                0x40974c
76b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMCTX_SAVE_SWBASE                               0x409700
77b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMCTX_LOAD_SWBASE                               0x409704
78b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMCTX_BASE                                      0x409710
79b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMCTX_CTRL                                      0x409714
80b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMCTX_MULTI_STRIDE                              0x409718
81b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMCTX_MULTI_MASK                                0x40971c
82b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMCTX_QUEUE                                     0x409720
832a19b3edSBen Skeggs#define NV_PGRAPH_FECS_MMIO_BASE                                       0x409724
84b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMIO_CTRL                                       0x409728
852a19b3edSBen Skeggs#define NV_PGRAPH_FECS_MMIO_CTRL_BASE_ENABLE                         0x00000001
86b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMIO_RDVAL                                      0x40972c
87b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMIO_WRVAL                                      0x409730
88b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MMCTX_LOAD_COUNT                                0x40974c
89b8bf04e1SBen Skeggs#if CHIPSET < GK110
90b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_CC_SCRATCH_VAL(n)                    ((n) * 4 + 0x409800)
91b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_CC_SCRATCH_SET(n)                    ((n) * 4 + 0x409820)
92b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_CC_SCRATCH_CLR(n)                    ((n) * 4 + 0x409840)
93b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_UNK86C                                          0x40986c
94b8bf04e1SBen Skeggs#else
95b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_CC_SCRATCH_VAL(n)                    ((n) * 4 + 0x409800)
96b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_CC_SCRATCH_CLR(n)                    ((n) * 4 + 0x409840)
97b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_UNK86C                                          0x40988c
98b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_CC_SCRATCH_SET(n)                    ((n) * 4 + 0x4098c0)
99b8bf04e1SBen Skeggs#endif
100b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRANDS_CNT                                     0x409880
101b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_SAVE_SWBASE                              0x409908
102b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_LOAD_SWBASE                              0x40990c
103b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_WORDS                                    0x409910
104b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_DATA                                     0x409918
105b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_SELECT                                   0x40991c
106b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_CMD                                      0x409928
107b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_CMD_SEEK                               0x00000001
108b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_CMD_GET_INFO                           0x00000002
109b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_CMD_SAVE                               0x00000003
110b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_CMD_LOAD                               0x00000004
111b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_CMD_ACTIVATE_FILTER                    0x0000000a
112b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_CMD_DEACTIVATE_FILTER                  0x0000000b
113b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_CMD_ENABLE                             0x0000000c
114b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_CMD_DISABLE                            0x0000000d
115b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_STRAND_FILTER                                   0x40993c
116b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MEM_BASE                                        0x409a04
117b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MEM_CHAN                                        0x409a0c
118b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MEM_CMD                                         0x409a10
119b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MEM_CMD_LOAD_CHAN                             0x00000007
120b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MEM_TARGET                                      0x409a20
121b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MEM_TARGET_UNK31                              0x80000000
122b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MEM_TARGET_AS                                 0x0000001f
123b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MEM_TARGET_AS_VM                              0x00000001
124b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_MEM_TARGET_AS_VRAM                            0x00000002
125b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_CHAN_ADDR                                       0x409b00
126b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_CHAN_NEXT                                       0x409b04
127b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_CHSW                                            0x409b0c
128b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_CHSW_ACK                                      0x00000001
129b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_UP_SET                                     0x409c1c
130b8bf04e1SBen Skeggs#define NV_PGRAPH_FECS_INTR_UP_EN                                      0x409c24
131b8bf04e1SBen Skeggs
132b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_INTR_ACK                                  0x41a004
133b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_INTR                                      0x41a008
134b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_INTR_FIFO                               0x00000004
135b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_INTR_EN_SET                               0x41a010
136b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_INTR_EN_SET_FIFO                        0x00000004
137b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_INTR_ROUTE                                0x41a01c
138b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_ACCESS                                    0x41a048
139b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_ACCESS_FIFO                             0x00000002
140b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_FIFO_DATA                                 0x41a064
141b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_FIFO_CMD                                  0x41a068
142b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_FIFO_ACK                                  0x41a074
143b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_UNITS                                     0x41a608
144b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_CAPS                                      0x41a108
145b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_RED_SWITCH                                0x41a614
146b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_RED_SWITCH_UNK11                        0x00000800
147b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_RED_SWITCH_ENABLE                       0x00000200
148b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_RED_SWITCH_POWER                        0x00000020
149b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_RED_SWITCH_PAUSE                        0x00000002
150b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_MYINDEX                                   0x41a618
151b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_MMCTX_SAVE_SWBASE                         0x41a700
152b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_MMCTX_LOAD_SWBASE                         0x41a704
1532a19b3edSBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_MMIO_BASE                                 0x41a724
1542a19b3edSBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_MMIO_CTRL                                 0x41a728
1552a19b3edSBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_MMIO_CTRL_BASE_ENABLE                   0x00000001
1562a19b3edSBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_MMIO_RDVAL                                0x41a72c
1572a19b3edSBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_MMIO_WRVAL                                0x41a730
158b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_MMCTX_LOAD_COUNT                          0x41a74c
159b8bf04e1SBen Skeggs#if CHIPSET < GK110
160b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_CC_SCRATCH_VAL(n)              ((n) * 4 + 0x41a800)
161b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_CC_SCRATCH_SET(n)              ((n) * 4 + 0x41a820)
162b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_CC_SCRATCH_CLR(n)              ((n) * 4 + 0x41a840)
163b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_UNK86C                                    0x41a86c
164b8bf04e1SBen Skeggs#else
165b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_CC_SCRATCH_VAL(n)              ((n) * 4 + 0x41a800)
166b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_CC_SCRATCH_CLR(n)              ((n) * 4 + 0x41a840)
167b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_UNK86C                                    0x41a88c
168b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_CC_SCRATCH_SET(n)              ((n) * 4 + 0x41a8c0)
169b8bf04e1SBen Skeggs#endif
170b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_STRAND_SELECT                             0x41a91c
171b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_STRAND_CMD                                0x41a928
172b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_STRAND_CMD_SAVE                         0x00000003
173b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_STRAND_CMD_LOAD                         0x00000004
174b8bf04e1SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_MEM_BASE                                  0x41aa04
175*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPCX_GPCCS_TPC_STATUS                                0x41acfc
176*8fd4b7d4SBen Skeggs
177*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPC0                                            0x504000
178*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPC0__SIZE                                      0x000800
179*8fd4b7d4SBen Skeggs
180*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPCX_STRAND_INDEX                               0x501d60
181*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPCX_STRAND_INDEX_ALL                         0x0000003f
182*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPCX_STRAND_DATA                                0x501d98
183*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPCX_STRAND_SELECT                              0x501d9c
184*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD                                 0x501da8
185*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD_SEEK                          0x00000001
186*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD_GET_INFO                      0x00000002
187*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD_SAVE                          0x00000003
188*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD_LOAD                          0x00000004
189*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD_ENABLE                        0x0000000c
190*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPCX_STRAND_CMD_DISABLE                       0x0000000d
191*8fd4b7d4SBen Skeggs#define NV_PGRAPH_GPC0_TPCX_STRAND_MEM_BASE                            0x501dc4
192*8fd4b7d4SBen Skeggs
193*8fd4b7d4SBen Skeggs#define NV_TPC_STRAND_INDEX                                               0x560
194*8fd4b7d4SBen Skeggs#define NV_TPC_STRAND_CNT                                                 0x570
195*8fd4b7d4SBen Skeggs#define NV_TPC_STRAND_SAVE_SWBASE                                         0x588
196*8fd4b7d4SBen Skeggs#define NV_TPC_STRAND_LOAD_SWBASE                                         0x58c
197*8fd4b7d4SBen Skeggs#define NV_TPC_STRAND_WORDS                                               0x590
198b8bf04e1SBen Skeggs
199b8bf04e1SBen Skeggs#define mmctx_data(r,c) .b32 (((c - 1) << 26) | r)
200b8bf04e1SBen Skeggs#define queue_init      .skip 72 // (2 * 4) + ((8 * 4) * 2)
201b8bf04e1SBen Skeggs
202b8bf04e1SBen Skeggs#define T_WAIT    0
203b8bf04e1SBen Skeggs#define T_MMCTX   1
204b8bf04e1SBen Skeggs#define T_STRWAIT 2
205b8bf04e1SBen Skeggs#define T_STRINIT 3
206b8bf04e1SBen Skeggs#define T_AUTO    4
207b8bf04e1SBen Skeggs#define T_CHAN    5
208b8bf04e1SBen Skeggs#define T_LOAD    6
209b8bf04e1SBen Skeggs#define T_SAVE    7
210b8bf04e1SBen Skeggs#define T_LCHAN   8
211b8bf04e1SBen Skeggs#define T_LCTXH   9
212*8fd4b7d4SBen Skeggs#define T_STRTPC  10
213b8bf04e1SBen Skeggs
214b8bf04e1SBen Skeggs#if CHIPSET < GK208
215b8bf04e1SBen Skeggs#define imm32(reg,val) /*
216b8bf04e1SBen Skeggs*/	movw reg  ((val) & 0x0000ffff) /*
217b8bf04e1SBen Skeggs*/	sethi reg ((val) & 0xffff0000)
218b8bf04e1SBen Skeggs#else
219b8bf04e1SBen Skeggs#define imm32(reg,val) /*
220b8bf04e1SBen Skeggs*/	mov reg (val)
221b8bf04e1SBen Skeggs#endif
222b8bf04e1SBen Skeggs
223b8bf04e1SBen Skeggs#define nv_mkio(rv,r,i) /*
224b8bf04e1SBen Skeggs*/	imm32(rv, (((r) & 0xffc) << 6) | ((i) << 2))
225b8bf04e1SBen Skeggs
226b8bf04e1SBen Skeggs#define hash #
227b8bf04e1SBen Skeggs#define fn(a) a
228b8bf04e1SBen Skeggs#if CHIPSET < GK208
229b8bf04e1SBen Skeggs#define call(a) call fn(hash)a
230b8bf04e1SBen Skeggs#else
231b8bf04e1SBen Skeggs#define call(a) lcall fn(hash)a
232b8bf04e1SBen Skeggs#endif
233b8bf04e1SBen Skeggs
234b8bf04e1SBen Skeggs#define nv_iord(rv,r,i) /*
235b8bf04e1SBen Skeggs*/	nv_mkio(rv,r,i) /*
236b8bf04e1SBen Skeggs*/	iord rv I[rv]
237b8bf04e1SBen Skeggs
238b8bf04e1SBen Skeggs#define nv_iowr(r,i,rv) /*
239b8bf04e1SBen Skeggs*/	nv_mkio($r0,r,i) /*
240b8bf04e1SBen Skeggs*/	iowr I[$r0] rv /*
241b8bf04e1SBen Skeggs*/	clear b32 $r0
242b8bf04e1SBen Skeggs
243b8bf04e1SBen Skeggs#define nv_rd32(reg,addr) /*
244b8bf04e1SBen Skeggs*/	imm32($r14, addr) /*
245b8bf04e1SBen Skeggs*/	call(nv_rd32) /*
246b8bf04e1SBen Skeggs*/	mov b32 reg $r15
247b8bf04e1SBen Skeggs
248b8bf04e1SBen Skeggs#define nv_wr32(addr,reg) /*
249b8bf04e1SBen Skeggs*/	mov b32 $r15 reg /*
250b8bf04e1SBen Skeggs*/	imm32($r14, addr) /*
251b8bf04e1SBen Skeggs*/	call(nv_wr32)
252b8bf04e1SBen Skeggs
253b8bf04e1SBen Skeggs#define trace_set(bit) /*
254b8bf04e1SBen Skeggs*/	clear b32 $r9 /*
255b8bf04e1SBen Skeggs*/	bset $r9 bit /*
256b8bf04e1SBen Skeggs*/	nv_iowr(NV_PGRAPH_FECS_CC_SCRATCH_SET(7), 0, $r9)
257b8bf04e1SBen Skeggs
258b8bf04e1SBen Skeggs#define trace_clr(bit) /*
259b8bf04e1SBen Skeggs*/	clear b32 $r9 /*
260b8bf04e1SBen Skeggs*/	bset $r9 bit /*
261b8bf04e1SBen Skeggs*/	nv_iowr(NV_PGRAPH_FECS_CC_SCRATCH_CLR(7), 0, $r9)
262