| 1 | /* $NetBSD: nouveau_engine_graph_nv108.c,v 1.1.1.1 2014/08/06 12:36:26 riastradh Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright 2013 Red Hat Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 22 | * OTHER DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: Ben Skeggs <bskeggs@redhat.com> |
| 25 | */ |
| 26 | |
| 27 | #include <sys/cdefs.h> |
| 28 | __KERNEL_RCSID(0, "$NetBSD: nouveau_engine_graph_nv108.c,v 1.1.1.1 2014/08/06 12:36:26 riastradh Exp $" ); |
| 29 | |
| 30 | #include "nvc0.h" |
| 31 | #include "ctxnvc0.h" |
| 32 | |
| 33 | /******************************************************************************* |
| 34 | * Graphics object classes |
| 35 | ******************************************************************************/ |
| 36 | |
| 37 | static struct nouveau_oclass |
| 38 | nv108_graph_sclass[] = { |
| 39 | { 0x902d, &nouveau_object_ofuncs }, |
| 40 | { 0xa140, &nouveau_object_ofuncs }, |
| 41 | { 0xa197, &nouveau_object_ofuncs }, |
| 42 | { 0xa1c0, &nouveau_object_ofuncs }, |
| 43 | {} |
| 44 | }; |
| 45 | |
| 46 | /******************************************************************************* |
| 47 | * PGRAPH register lists |
| 48 | ******************************************************************************/ |
| 49 | |
| 50 | static const struct nvc0_graph_init |
| 51 | nv108_graph_init_main_0[] = { |
| 52 | { 0x400080, 1, 0x04, 0x003083c2 }, |
| 53 | { 0x400088, 1, 0x04, 0x0001bfe7 }, |
| 54 | { 0x40008c, 1, 0x04, 0x00000000 }, |
| 55 | { 0x400090, 1, 0x04, 0x00000030 }, |
| 56 | { 0x40013c, 1, 0x04, 0x003901f7 }, |
| 57 | { 0x400140, 1, 0x04, 0x00000100 }, |
| 58 | { 0x400144, 1, 0x04, 0x00000000 }, |
| 59 | { 0x400148, 1, 0x04, 0x00000110 }, |
| 60 | { 0x400138, 1, 0x04, 0x00000000 }, |
| 61 | { 0x400130, 2, 0x04, 0x00000000 }, |
| 62 | { 0x400124, 1, 0x04, 0x00000002 }, |
| 63 | {} |
| 64 | }; |
| 65 | |
| 66 | static const struct nvc0_graph_init |
| 67 | nv108_graph_init_ds_0[] = { |
| 68 | { 0x405844, 1, 0x04, 0x00ffffff }, |
| 69 | { 0x405850, 1, 0x04, 0x00000000 }, |
| 70 | { 0x405900, 1, 0x04, 0x00000000 }, |
| 71 | { 0x405908, 1, 0x04, 0x00000000 }, |
| 72 | { 0x405928, 2, 0x04, 0x00000000 }, |
| 73 | {} |
| 74 | }; |
| 75 | |
| 76 | const struct nvc0_graph_init |
| 77 | nv108_graph_init_gpc_unk_0[] = { |
| 78 | { 0x418604, 1, 0x04, 0x00000000 }, |
| 79 | { 0x418680, 1, 0x04, 0x00000000 }, |
| 80 | { 0x418714, 1, 0x04, 0x00000000 }, |
| 81 | { 0x418384, 2, 0x04, 0x00000000 }, |
| 82 | {} |
| 83 | }; |
| 84 | |
| 85 | static const struct nvc0_graph_init |
| 86 | nv108_graph_init_setup_1[] = { |
| 87 | { 0x4188c8, 2, 0x04, 0x00000000 }, |
| 88 | { 0x4188d0, 1, 0x04, 0x00010000 }, |
| 89 | { 0x4188d4, 1, 0x04, 0x00000201 }, |
| 90 | {} |
| 91 | }; |
| 92 | |
| 93 | static const struct nvc0_graph_init |
| 94 | nv108_graph_init_tex_0[] = { |
| 95 | { 0x419ab0, 1, 0x04, 0x00000000 }, |
| 96 | { 0x419ac8, 1, 0x04, 0x00000000 }, |
| 97 | { 0x419ab8, 1, 0x04, 0x000000e7 }, |
| 98 | { 0x419abc, 2, 0x04, 0x00000000 }, |
| 99 | { 0x419ab4, 1, 0x04, 0x00000000 }, |
| 100 | { 0x419aa8, 2, 0x04, 0x00000000 }, |
| 101 | {} |
| 102 | }; |
| 103 | |
| 104 | static const struct nvc0_graph_init |
| 105 | nv108_graph_init_l1c_0[] = { |
| 106 | { 0x419c98, 1, 0x04, 0x00000000 }, |
| 107 | { 0x419ca8, 1, 0x04, 0x00000000 }, |
| 108 | { 0x419cb0, 1, 0x04, 0x01000000 }, |
| 109 | { 0x419cb4, 1, 0x04, 0x00000000 }, |
| 110 | { 0x419cb8, 1, 0x04, 0x00b08bea }, |
| 111 | { 0x419c84, 1, 0x04, 0x00010384 }, |
| 112 | { 0x419cbc, 1, 0x04, 0x281b3646 }, |
| 113 | { 0x419cc0, 2, 0x04, 0x00000000 }, |
| 114 | { 0x419c80, 1, 0x04, 0x00000230 }, |
| 115 | { 0x419ccc, 2, 0x04, 0x00000000 }, |
| 116 | {} |
| 117 | }; |
| 118 | |
| 119 | static const struct nvc0_graph_pack |
| 120 | nv108_graph_pack_mmio[] = { |
| 121 | { nv108_graph_init_main_0 }, |
| 122 | { nvf0_graph_init_fe_0 }, |
| 123 | { nvc0_graph_init_pri_0 }, |
| 124 | { nvc0_graph_init_rstr2d_0 }, |
| 125 | { nvd9_graph_init_pd_0 }, |
| 126 | { nv108_graph_init_ds_0 }, |
| 127 | { nvc0_graph_init_scc_0 }, |
| 128 | { nvf0_graph_init_sked_0 }, |
| 129 | { nvf0_graph_init_cwd_0 }, |
| 130 | { nvd9_graph_init_prop_0 }, |
| 131 | { nv108_graph_init_gpc_unk_0 }, |
| 132 | { nvc0_graph_init_setup_0 }, |
| 133 | { nvc0_graph_init_crstr_0 }, |
| 134 | { nv108_graph_init_setup_1 }, |
| 135 | { nvc0_graph_init_zcull_0 }, |
| 136 | { nvd9_graph_init_gpm_0 }, |
| 137 | { nvf0_graph_init_gpc_unk_1 }, |
| 138 | { nvc0_graph_init_gcc_0 }, |
| 139 | { nve4_graph_init_tpccs_0 }, |
| 140 | { nv108_graph_init_tex_0 }, |
| 141 | { nve4_graph_init_pe_0 }, |
| 142 | { nv108_graph_init_l1c_0 }, |
| 143 | { nvc0_graph_init_mpc_0 }, |
| 144 | { nvf0_graph_init_sm_0 }, |
| 145 | { nvd7_graph_init_pes_0 }, |
| 146 | { nvd7_graph_init_wwdx_0 }, |
| 147 | { nvd7_graph_init_cbm_0 }, |
| 148 | { nve4_graph_init_be_0 }, |
| 149 | { nvc0_graph_init_fe_1 }, |
| 150 | {} |
| 151 | }; |
| 152 | |
| 153 | /******************************************************************************* |
| 154 | * PGRAPH engine/subdev functions |
| 155 | ******************************************************************************/ |
| 156 | |
| 157 | static int |
| 158 | nv108_graph_fini(struct nouveau_object *object, bool suspend) |
| 159 | { |
| 160 | struct nvc0_graph_priv *priv = (void *)object; |
| 161 | static const struct { |
| 162 | u32 addr; |
| 163 | u32 data; |
| 164 | } magic[] = { |
| 165 | { 0x020520, 0xfffffffc }, |
| 166 | { 0x020524, 0xfffffffe }, |
| 167 | { 0x020524, 0xfffffffc }, |
| 168 | { 0x020524, 0xfffffff8 }, |
| 169 | { 0x020524, 0xffffffe0 }, |
| 170 | { 0x020530, 0xfffffffe }, |
| 171 | { 0x02052c, 0xfffffffa }, |
| 172 | { 0x02052c, 0xfffffff0 }, |
| 173 | { 0x02052c, 0xffffffc0 }, |
| 174 | { 0x02052c, 0xffffff00 }, |
| 175 | { 0x02052c, 0xfffffc00 }, |
| 176 | { 0x02052c, 0xfffcfc00 }, |
| 177 | { 0x02052c, 0xfff0fc00 }, |
| 178 | { 0x02052c, 0xff80fc00 }, |
| 179 | { 0x020528, 0xfffffffe }, |
| 180 | { 0x020528, 0xfffffffc }, |
| 181 | }; |
| 182 | int i; |
| 183 | |
| 184 | nv_mask(priv, 0x000200, 0x08001000, 0x00000000); |
| 185 | nv_mask(priv, 0x0206b4, 0x00000000, 0x00000000); |
| 186 | for (i = 0; i < ARRAY_SIZE(magic); i++) { |
| 187 | nv_wr32(priv, magic[i].addr, magic[i].data); |
| 188 | nv_wait(priv, magic[i].addr, 0x80000000, 0x00000000); |
| 189 | } |
| 190 | |
| 191 | return nouveau_graph_fini(&priv->base, suspend); |
| 192 | } |
| 193 | |
| 194 | #include "fuc/hubnv108.fuc5.h" |
| 195 | |
| 196 | static struct nvc0_graph_ucode |
| 197 | nv108_graph_fecs_ucode = { |
| 198 | .code.data = nv108_grhub_code, |
| 199 | .code.size = sizeof(nv108_grhub_code), |
| 200 | .data.data = nv108_grhub_data, |
| 201 | .data.size = sizeof(nv108_grhub_data), |
| 202 | }; |
| 203 | |
| 204 | #include "fuc/gpcnv108.fuc5.h" |
| 205 | |
| 206 | static struct nvc0_graph_ucode |
| 207 | nv108_graph_gpccs_ucode = { |
| 208 | .code.data = nv108_grgpc_code, |
| 209 | .code.size = sizeof(nv108_grgpc_code), |
| 210 | .data.data = nv108_grgpc_data, |
| 211 | .data.size = sizeof(nv108_grgpc_data), |
| 212 | }; |
| 213 | |
| 214 | struct nouveau_oclass * |
| 215 | nv108_graph_oclass = &(struct nvc0_graph_oclass) { |
| 216 | .base.handle = NV_ENGINE(GR, 0x08), |
| 217 | .base.ofuncs = &(struct nouveau_ofuncs) { |
| 218 | .ctor = nvc0_graph_ctor, |
| 219 | .dtor = nvc0_graph_dtor, |
| 220 | .init = nve4_graph_init, |
| 221 | .fini = nv108_graph_fini, |
| 222 | }, |
| 223 | .cclass = &nv108_grctx_oclass, |
| 224 | .sclass = nv108_graph_sclass, |
| 225 | .mmio = nv108_graph_pack_mmio, |
| 226 | .fecs.ucode = &nv108_graph_fecs_ucode, |
| 227 | .gpccs.ucode = &nv108_graph_gpccs_ucode, |
| 228 | }.base; |
| 229 | |