1 /* 2 * Copyright 2010 Red Hat Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22 * Authors: Ben Skeggs 23 */ 24 #ifndef __NVC0_GR_H__ 25 #define __NVC0_GR_H__ 26 #include <engine/gr.h> 27 28 #include <subdev/ltc.h> 29 30 #define GPC_MAX 32 31 #define TPC_MAX (GPC_MAX * 8) 32 33 #define ROP_BCAST(r) (0x408800 + (r)) 34 #define ROP_UNIT(u, r) (0x410000 + (u) * 0x400 + (r)) 35 #define GPC_BCAST(r) (0x418000 + (r)) 36 #define GPC_UNIT(t, r) (0x500000 + (t) * 0x8000 + (r)) 37 #define PPC_UNIT(t, m, r) (0x503000 + (t) * 0x8000 + (m) * 0x200 + (r)) 38 #define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r)) 39 40 struct gf100_gr_data { 41 u32 size; 42 u32 align; 43 u32 access; 44 }; 45 46 struct gf100_gr_mmio { 47 u32 addr; 48 u32 data; 49 u32 shift; 50 int buffer; 51 }; 52 53 struct gf100_gr_fuc { 54 u32 *data; 55 u32 size; 56 }; 57 58 struct gf100_gr_zbc_color { 59 u32 format; 60 u32 ds[4]; 61 u32 l2[4]; 62 }; 63 64 struct gf100_gr_zbc_depth { 65 u32 format; 66 u32 ds; 67 u32 l2; 68 }; 69 70 struct gf100_gr { 71 struct nvkm_gr base; 72 73 struct gf100_gr_fuc fuc409c; 74 struct gf100_gr_fuc fuc409d; 75 struct gf100_gr_fuc fuc41ac; 76 struct gf100_gr_fuc fuc41ad; 77 bool firmware; 78 79 /* 80 * Used if the register packs are loaded from NVIDIA fw instead of 81 * using hardcoded arrays. 82 */ 83 struct gf100_gr_pack *fuc_sw_nonctx; 84 struct gf100_gr_pack *fuc_sw_ctx; 85 struct gf100_gr_pack *fuc_bundle; 86 struct gf100_gr_pack *fuc_method; 87 88 struct gf100_gr_zbc_color zbc_color[NVKM_LTC_MAX_ZBC_CNT]; 89 struct gf100_gr_zbc_depth zbc_depth[NVKM_LTC_MAX_ZBC_CNT]; 90 91 u8 rop_nr; 92 u8 gpc_nr; 93 u8 tpc_nr[GPC_MAX]; 94 u8 tpc_total; 95 u8 ppc_nr[GPC_MAX]; 96 u8 ppc_tpc_nr[GPC_MAX][4]; 97 98 struct nvkm_memory *unk4188b4; 99 struct nvkm_memory *unk4188b8; 100 101 struct gf100_gr_data mmio_data[4]; 102 struct gf100_gr_mmio mmio_list[4096/8]; 103 u32 size; 104 u32 *data; 105 106 u8 magic_not_rop_nr; 107 }; 108 109 struct gf100_gr_chan { 110 struct nvkm_gr_chan base; 111 112 struct nvkm_memory *mmio; 113 struct nvkm_vma mmio_vma; 114 int mmio_nr; 115 struct { 116 struct nvkm_memory *mem; 117 struct nvkm_vma vma; 118 } data[4]; 119 }; 120 121 int gf100_gr_context_ctor(struct nvkm_object *, struct nvkm_object *, 122 struct nvkm_oclass *, void *, u32, 123 struct nvkm_object **); 124 void gf100_gr_context_dtor(struct nvkm_object *); 125 126 void gf100_gr_ctxctl_debug(struct gf100_gr *); 127 128 void gf100_gr_dtor_fw(struct gf100_gr_fuc *); 129 int gf100_gr_ctor_fw(struct gf100_gr *, const char *, 130 struct gf100_gr_fuc *); 131 u64 gf100_gr_units(struct nvkm_gr *); 132 int gf100_gr_ctor(struct nvkm_object *, struct nvkm_object *, 133 struct nvkm_oclass *, void *data, u32 size, 134 struct nvkm_object **); 135 void gf100_gr_dtor(struct nvkm_object *); 136 int gf100_gr_init(struct nvkm_object *); 137 void gf100_gr_zbc_init(struct gf100_gr *); 138 139 int gk104_gr_ctor(struct nvkm_object *, struct nvkm_object *, 140 struct nvkm_oclass *, void *data, u32 size, 141 struct nvkm_object **); 142 int gk104_gr_init(struct nvkm_object *); 143 144 int gk20a_gr_ctor(struct nvkm_object *, struct nvkm_object *, 145 struct nvkm_oclass *, void *data, u32 size, 146 struct nvkm_object **); 147 void gk20a_gr_dtor(struct nvkm_object *); 148 int gk20a_gr_init(struct nvkm_object *); 149 150 int gm204_gr_init(struct nvkm_object *); 151 152 extern struct nvkm_ofuncs gf100_fermi_ofuncs; 153 154 extern struct nvkm_oclass gf100_gr_sclass[]; 155 extern struct nvkm_omthds gf100_gr_9097_omthds[]; 156 extern struct nvkm_omthds gf100_gr_90c0_omthds[]; 157 extern struct nvkm_oclass gf110_gr_sclass[]; 158 extern struct nvkm_oclass gk110_gr_sclass[]; 159 extern struct nvkm_oclass gm204_gr_sclass[]; 160 161 struct gf100_gr_init { 162 u32 addr; 163 u8 count; 164 u8 pitch; 165 u32 data; 166 }; 167 168 struct gf100_gr_pack { 169 const struct gf100_gr_init *init; 170 u32 type; 171 }; 172 173 #define pack_for_each_init(init, pack, head) \ 174 for (pack = head; pack && pack->init; pack++) \ 175 for (init = pack->init; init && init->count; init++) 176 177 struct gf100_gr_ucode { 178 struct gf100_gr_fuc code; 179 struct gf100_gr_fuc data; 180 }; 181 182 extern struct gf100_gr_ucode gf100_gr_fecs_ucode; 183 extern struct gf100_gr_ucode gf100_gr_gpccs_ucode; 184 185 extern struct gf100_gr_ucode gk110_gr_fecs_ucode; 186 extern struct gf100_gr_ucode gk110_gr_gpccs_ucode; 187 188 struct gf100_gr_oclass { 189 struct nvkm_oclass base; 190 struct nvkm_oclass **cclass; 191 struct nvkm_oclass *sclass; 192 const struct gf100_gr_pack *mmio; 193 struct { 194 struct gf100_gr_ucode *ucode; 195 } fecs; 196 struct { 197 struct gf100_gr_ucode *ucode; 198 } gpccs; 199 int ppc_nr; 200 }; 201 202 int gf100_gr_wait_idle(struct gf100_gr *); 203 void gf100_gr_mmio(struct gf100_gr *, const struct gf100_gr_pack *); 204 void gf100_gr_icmd(struct gf100_gr *, const struct gf100_gr_pack *); 205 void gf100_gr_mthd(struct gf100_gr *, const struct gf100_gr_pack *); 206 int gf100_gr_init_ctxctl(struct gf100_gr *); 207 208 /* register init value lists */ 209 210 extern const struct gf100_gr_init gf100_gr_init_main_0[]; 211 extern const struct gf100_gr_init gf100_gr_init_fe_0[]; 212 extern const struct gf100_gr_init gf100_gr_init_pri_0[]; 213 extern const struct gf100_gr_init gf100_gr_init_rstr2d_0[]; 214 extern const struct gf100_gr_init gf100_gr_init_pd_0[]; 215 extern const struct gf100_gr_init gf100_gr_init_ds_0[]; 216 extern const struct gf100_gr_init gf100_gr_init_scc_0[]; 217 extern const struct gf100_gr_init gf100_gr_init_prop_0[]; 218 extern const struct gf100_gr_init gf100_gr_init_gpc_unk_0[]; 219 extern const struct gf100_gr_init gf100_gr_init_setup_0[]; 220 extern const struct gf100_gr_init gf100_gr_init_crstr_0[]; 221 extern const struct gf100_gr_init gf100_gr_init_setup_1[]; 222 extern const struct gf100_gr_init gf100_gr_init_zcull_0[]; 223 extern const struct gf100_gr_init gf100_gr_init_gpm_0[]; 224 extern const struct gf100_gr_init gf100_gr_init_gpc_unk_1[]; 225 extern const struct gf100_gr_init gf100_gr_init_gcc_0[]; 226 extern const struct gf100_gr_init gf100_gr_init_tpccs_0[]; 227 extern const struct gf100_gr_init gf100_gr_init_tex_0[]; 228 extern const struct gf100_gr_init gf100_gr_init_pe_0[]; 229 extern const struct gf100_gr_init gf100_gr_init_l1c_0[]; 230 extern const struct gf100_gr_init gf100_gr_init_wwdx_0[]; 231 extern const struct gf100_gr_init gf100_gr_init_tpccs_1[]; 232 extern const struct gf100_gr_init gf100_gr_init_mpc_0[]; 233 extern const struct gf100_gr_init gf100_gr_init_be_0[]; 234 extern const struct gf100_gr_init gf100_gr_init_fe_1[]; 235 extern const struct gf100_gr_init gf100_gr_init_pe_1[]; 236 237 extern const struct gf100_gr_init gf104_gr_init_ds_0[]; 238 extern const struct gf100_gr_init gf104_gr_init_tex_0[]; 239 extern const struct gf100_gr_init gf104_gr_init_sm_0[]; 240 241 extern const struct gf100_gr_init gf108_gr_init_gpc_unk_0[]; 242 extern const struct gf100_gr_init gf108_gr_init_setup_1[]; 243 244 extern const struct gf100_gr_init gf119_gr_init_pd_0[]; 245 extern const struct gf100_gr_init gf119_gr_init_ds_0[]; 246 extern const struct gf100_gr_init gf119_gr_init_prop_0[]; 247 extern const struct gf100_gr_init gf119_gr_init_gpm_0[]; 248 extern const struct gf100_gr_init gf119_gr_init_gpc_unk_1[]; 249 extern const struct gf100_gr_init gf119_gr_init_tex_0[]; 250 extern const struct gf100_gr_init gf119_gr_init_sm_0[]; 251 extern const struct gf100_gr_init gf119_gr_init_fe_1[]; 252 253 extern const struct gf100_gr_init gf117_gr_init_pes_0[]; 254 extern const struct gf100_gr_init gf117_gr_init_wwdx_0[]; 255 extern const struct gf100_gr_init gf117_gr_init_cbm_0[]; 256 257 extern const struct gf100_gr_init gk104_gr_init_main_0[]; 258 extern const struct gf100_gr_init gk104_gr_init_tpccs_0[]; 259 extern const struct gf100_gr_init gk104_gr_init_pe_0[]; 260 extern const struct gf100_gr_init gk104_gr_init_be_0[]; 261 extern const struct gf100_gr_pack gk104_gr_pack_mmio[]; 262 263 extern const struct gf100_gr_init gk110_gr_init_fe_0[]; 264 extern const struct gf100_gr_init gk110_gr_init_ds_0[]; 265 extern const struct gf100_gr_init gk110_gr_init_sked_0[]; 266 extern const struct gf100_gr_init gk110_gr_init_cwd_0[]; 267 extern const struct gf100_gr_init gk110_gr_init_gpc_unk_1[]; 268 extern const struct gf100_gr_init gk110_gr_init_tex_0[]; 269 extern const struct gf100_gr_init gk110_gr_init_sm_0[]; 270 271 extern const struct gf100_gr_init gk208_gr_init_gpc_unk_0[]; 272 273 extern const struct gf100_gr_init gm107_gr_init_scc_0[]; 274 extern const struct gf100_gr_init gm107_gr_init_prop_0[]; 275 extern const struct gf100_gr_init gm107_gr_init_setup_1[]; 276 extern const struct gf100_gr_init gm107_gr_init_zcull_0[]; 277 extern const struct gf100_gr_init gm107_gr_init_gpc_unk_1[]; 278 extern const struct gf100_gr_init gm107_gr_init_tex_0[]; 279 extern const struct gf100_gr_init gm107_gr_init_l1c_0[]; 280 extern const struct gf100_gr_init gm107_gr_init_wwdx_0[]; 281 extern const struct gf100_gr_init gm107_gr_init_cbm_0[]; 282 void gm107_gr_init_bios(struct gf100_gr *); 283 284 extern const struct gf100_gr_pack gm204_gr_pack_mmio[]; 285 #endif 286