Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 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 | */ |
Ben Skeggs | c85ee6c | 2015-08-20 14:54:22 +1000 | [diff] [blame] | 24 | #ifndef __GF100_GR_H__ |
| 25 | #define __GF100_GR_H__ |
Ben Skeggs | 27f3d6c | 2015-08-20 14:54:19 +1000 | [diff] [blame] | 26 | #define gf100_gr(p) container_of((p), struct gf100_gr, base) |
| 27 | #include "priv.h" |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 28 | |
Ben Skeggs | 27f3d6c | 2015-08-20 14:54:19 +1000 | [diff] [blame] | 29 | #include <core/gpuobj.h> |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 30 | #include <subdev/ltc.h> |
Ben Skeggs | 27f3d6c | 2015-08-20 14:54:19 +1000 | [diff] [blame] | 31 | #include <subdev/mmu.h> |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 32 | |
| 33 | #define GPC_MAX 32 |
| 34 | #define TPC_MAX (GPC_MAX * 8) |
| 35 | |
| 36 | #define ROP_BCAST(r) (0x408800 + (r)) |
| 37 | #define ROP_UNIT(u, r) (0x410000 + (u) * 0x400 + (r)) |
| 38 | #define GPC_BCAST(r) (0x418000 + (r)) |
| 39 | #define GPC_UNIT(t, r) (0x500000 + (t) * 0x8000 + (r)) |
| 40 | #define PPC_UNIT(t, m, r) (0x503000 + (t) * 0x8000 + (m) * 0x200 + (r)) |
| 41 | #define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r)) |
| 42 | |
| 43 | struct gf100_gr_data { |
| 44 | u32 size; |
| 45 | u32 align; |
| 46 | u32 access; |
| 47 | }; |
| 48 | |
| 49 | struct gf100_gr_mmio { |
| 50 | u32 addr; |
| 51 | u32 data; |
| 52 | u32 shift; |
| 53 | int buffer; |
| 54 | }; |
| 55 | |
| 56 | struct gf100_gr_fuc { |
| 57 | u32 *data; |
| 58 | u32 size; |
| 59 | }; |
| 60 | |
| 61 | struct gf100_gr_zbc_color { |
| 62 | u32 format; |
| 63 | u32 ds[4]; |
| 64 | u32 l2[4]; |
| 65 | }; |
| 66 | |
| 67 | struct gf100_gr_zbc_depth { |
| 68 | u32 format; |
| 69 | u32 ds; |
| 70 | u32 l2; |
| 71 | }; |
| 72 | |
Ben Skeggs | bfee3f3 | 2015-08-20 14:54:08 +1000 | [diff] [blame] | 73 | struct gf100_gr { |
Ben Skeggs | 27f3d6c | 2015-08-20 14:54:19 +1000 | [diff] [blame] | 74 | const struct gf100_gr_func *func; |
Ben Skeggs | c85ee6c | 2015-08-20 14:54:22 +1000 | [diff] [blame] | 75 | struct nvkm_gr base; |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 76 | |
| 77 | struct gf100_gr_fuc fuc409c; |
| 78 | struct gf100_gr_fuc fuc409d; |
| 79 | struct gf100_gr_fuc fuc41ac; |
| 80 | struct gf100_gr_fuc fuc41ad; |
| 81 | bool firmware; |
| 82 | |
Alexandre Courbot | c4d0f8f | 2015-06-23 15:16:02 +0900 | [diff] [blame] | 83 | /* |
| 84 | * Used if the register packs are loaded from NVIDIA fw instead of |
| 85 | * using hardcoded arrays. |
| 86 | */ |
| 87 | struct gf100_gr_pack *fuc_sw_nonctx; |
| 88 | struct gf100_gr_pack *fuc_sw_ctx; |
| 89 | struct gf100_gr_pack *fuc_bundle; |
| 90 | struct gf100_gr_pack *fuc_method; |
| 91 | |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 92 | struct gf100_gr_zbc_color zbc_color[NVKM_LTC_MAX_ZBC_CNT]; |
| 93 | struct gf100_gr_zbc_depth zbc_depth[NVKM_LTC_MAX_ZBC_CNT]; |
| 94 | |
| 95 | u8 rop_nr; |
| 96 | u8 gpc_nr; |
| 97 | u8 tpc_nr[GPC_MAX]; |
| 98 | u8 tpc_total; |
| 99 | u8 ppc_nr[GPC_MAX]; |
| 100 | u8 ppc_tpc_nr[GPC_MAX][4]; |
| 101 | |
Ben Skeggs | 227c95d | 2015-08-20 14:54:17 +1000 | [diff] [blame] | 102 | struct nvkm_memory *unk4188b4; |
| 103 | struct nvkm_memory *unk4188b8; |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 104 | |
| 105 | struct gf100_gr_data mmio_data[4]; |
| 106 | struct gf100_gr_mmio mmio_list[4096/8]; |
| 107 | u32 size; |
| 108 | u32 *data; |
| 109 | |
| 110 | u8 magic_not_rop_nr; |
| 111 | }; |
| 112 | |
Ben Skeggs | c85ee6c | 2015-08-20 14:54:22 +1000 | [diff] [blame] | 113 | int gf100_gr_ctor(const struct gf100_gr_func *, struct nvkm_device *, |
| 114 | int, struct gf100_gr *); |
| 115 | int gf100_gr_new_(const struct gf100_gr_func *, struct nvkm_device *, |
| 116 | int, struct nvkm_gr **); |
| 117 | void *gf100_gr_dtor(struct nvkm_gr *); |
| 118 | |
Ben Skeggs | 27f3d6c | 2015-08-20 14:54:19 +1000 | [diff] [blame] | 119 | struct gf100_gr_func { |
Ben Skeggs | c85ee6c | 2015-08-20 14:54:22 +1000 | [diff] [blame] | 120 | void (*dtor)(struct gf100_gr *); |
| 121 | int (*init)(struct gf100_gr *); |
| 122 | void (*init_gpc_mmu)(struct gf100_gr *); |
| 123 | void (*set_hww_esr_report_mask)(struct gf100_gr *); |
| 124 | const struct gf100_gr_pack *mmio; |
| 125 | struct { |
| 126 | struct gf100_gr_ucode *ucode; |
| 127 | } fecs; |
| 128 | struct { |
| 129 | struct gf100_gr_ucode *ucode; |
| 130 | } gpccs; |
| 131 | int ppc_nr; |
Ben Skeggs | 27f3d6c | 2015-08-20 14:54:19 +1000 | [diff] [blame] | 132 | const struct gf100_grctx_func *grctx; |
| 133 | struct nvkm_sclass sclass[]; |
| 134 | }; |
| 135 | |
Ben Skeggs | c85ee6c | 2015-08-20 14:54:22 +1000 | [diff] [blame] | 136 | int gf100_gr_init(struct gf100_gr *); |
| 137 | |
| 138 | int gk104_gr_init(struct gf100_gr *); |
| 139 | |
| 140 | int gk20a_gr_new_(const struct gf100_gr_func *, struct nvkm_device *, |
| 141 | int, struct nvkm_gr **); |
| 142 | void gk20a_gr_dtor(struct gf100_gr *); |
| 143 | int gk20a_gr_init(struct gf100_gr *); |
| 144 | |
| 145 | int gm204_gr_init(struct gf100_gr *); |
| 146 | |
Ben Skeggs | 27f3d6c | 2015-08-20 14:54:19 +1000 | [diff] [blame] | 147 | #define gf100_gr_chan(p) container_of((p), struct gf100_gr_chan, object) |
| 148 | |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 149 | struct gf100_gr_chan { |
Ben Skeggs | 27f3d6c | 2015-08-20 14:54:19 +1000 | [diff] [blame] | 150 | struct nvkm_object object; |
| 151 | struct gf100_gr *gr; |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 152 | |
Ben Skeggs | 227c95d | 2015-08-20 14:54:17 +1000 | [diff] [blame] | 153 | struct nvkm_memory *mmio; |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 154 | struct nvkm_vma mmio_vma; |
| 155 | int mmio_nr; |
Ben Skeggs | 27f3d6c | 2015-08-20 14:54:19 +1000 | [diff] [blame] | 156 | |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 157 | struct { |
Ben Skeggs | 227c95d | 2015-08-20 14:54:17 +1000 | [diff] [blame] | 158 | struct nvkm_memory *mem; |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 159 | struct nvkm_vma vma; |
| 160 | } data[4]; |
| 161 | }; |
| 162 | |
Ben Skeggs | bfee3f3 | 2015-08-20 14:54:08 +1000 | [diff] [blame] | 163 | void gf100_gr_ctxctl_debug(struct gf100_gr *); |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 164 | |
Alexandre Courbot | c4d0f8f | 2015-06-23 15:16:02 +0900 | [diff] [blame] | 165 | void gf100_gr_dtor_fw(struct gf100_gr_fuc *); |
Ben Skeggs | bfee3f3 | 2015-08-20 14:54:08 +1000 | [diff] [blame] | 166 | int gf100_gr_ctor_fw(struct gf100_gr *, const char *, |
Alexandre Courbot | c4d0f8f | 2015-06-23 15:16:02 +0900 | [diff] [blame] | 167 | struct gf100_gr_fuc *); |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 168 | u64 gf100_gr_units(struct nvkm_gr *); |
Ben Skeggs | bfee3f3 | 2015-08-20 14:54:08 +1000 | [diff] [blame] | 169 | void gf100_gr_zbc_init(struct gf100_gr *); |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 170 | |
Ben Skeggs | 27f3d6c | 2015-08-20 14:54:19 +1000 | [diff] [blame] | 171 | extern const struct nvkm_object_func gf100_fermi; |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 172 | |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 173 | struct gf100_gr_init { |
| 174 | u32 addr; |
| 175 | u8 count; |
| 176 | u8 pitch; |
| 177 | u32 data; |
| 178 | }; |
| 179 | |
| 180 | struct gf100_gr_pack { |
| 181 | const struct gf100_gr_init *init; |
| 182 | u32 type; |
| 183 | }; |
| 184 | |
| 185 | #define pack_for_each_init(init, pack, head) \ |
| 186 | for (pack = head; pack && pack->init; pack++) \ |
| 187 | for (init = pack->init; init && init->count; init++) |
| 188 | |
| 189 | struct gf100_gr_ucode { |
| 190 | struct gf100_gr_fuc code; |
| 191 | struct gf100_gr_fuc data; |
| 192 | }; |
| 193 | |
| 194 | extern struct gf100_gr_ucode gf100_gr_fecs_ucode; |
| 195 | extern struct gf100_gr_ucode gf100_gr_gpccs_ucode; |
| 196 | |
| 197 | extern struct gf100_gr_ucode gk110_gr_fecs_ucode; |
| 198 | extern struct gf100_gr_ucode gk110_gr_gpccs_ucode; |
| 199 | |
Ben Skeggs | bfee3f3 | 2015-08-20 14:54:08 +1000 | [diff] [blame] | 200 | int gf100_gr_wait_idle(struct gf100_gr *); |
| 201 | void gf100_gr_mmio(struct gf100_gr *, const struct gf100_gr_pack *); |
| 202 | void gf100_gr_icmd(struct gf100_gr *, const struct gf100_gr_pack *); |
| 203 | void gf100_gr_mthd(struct gf100_gr *, const struct gf100_gr_pack *); |
| 204 | int gf100_gr_init_ctxctl(struct gf100_gr *); |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 205 | |
| 206 | /* register init value lists */ |
| 207 | |
| 208 | extern const struct gf100_gr_init gf100_gr_init_main_0[]; |
| 209 | extern const struct gf100_gr_init gf100_gr_init_fe_0[]; |
| 210 | extern const struct gf100_gr_init gf100_gr_init_pri_0[]; |
| 211 | extern const struct gf100_gr_init gf100_gr_init_rstr2d_0[]; |
| 212 | extern const struct gf100_gr_init gf100_gr_init_pd_0[]; |
| 213 | extern const struct gf100_gr_init gf100_gr_init_ds_0[]; |
| 214 | extern const struct gf100_gr_init gf100_gr_init_scc_0[]; |
| 215 | extern const struct gf100_gr_init gf100_gr_init_prop_0[]; |
| 216 | extern const struct gf100_gr_init gf100_gr_init_gpc_unk_0[]; |
| 217 | extern const struct gf100_gr_init gf100_gr_init_setup_0[]; |
| 218 | extern const struct gf100_gr_init gf100_gr_init_crstr_0[]; |
| 219 | extern const struct gf100_gr_init gf100_gr_init_setup_1[]; |
| 220 | extern const struct gf100_gr_init gf100_gr_init_zcull_0[]; |
| 221 | extern const struct gf100_gr_init gf100_gr_init_gpm_0[]; |
| 222 | extern const struct gf100_gr_init gf100_gr_init_gpc_unk_1[]; |
| 223 | extern const struct gf100_gr_init gf100_gr_init_gcc_0[]; |
| 224 | extern const struct gf100_gr_init gf100_gr_init_tpccs_0[]; |
| 225 | extern const struct gf100_gr_init gf100_gr_init_tex_0[]; |
| 226 | extern const struct gf100_gr_init gf100_gr_init_pe_0[]; |
| 227 | extern const struct gf100_gr_init gf100_gr_init_l1c_0[]; |
| 228 | extern const struct gf100_gr_init gf100_gr_init_wwdx_0[]; |
| 229 | extern const struct gf100_gr_init gf100_gr_init_tpccs_1[]; |
| 230 | extern const struct gf100_gr_init gf100_gr_init_mpc_0[]; |
| 231 | extern const struct gf100_gr_init gf100_gr_init_be_0[]; |
| 232 | extern const struct gf100_gr_init gf100_gr_init_fe_1[]; |
| 233 | extern const struct gf100_gr_init gf100_gr_init_pe_1[]; |
| 234 | |
| 235 | extern const struct gf100_gr_init gf104_gr_init_ds_0[]; |
| 236 | extern const struct gf100_gr_init gf104_gr_init_tex_0[]; |
| 237 | extern const struct gf100_gr_init gf104_gr_init_sm_0[]; |
| 238 | |
| 239 | extern const struct gf100_gr_init gf108_gr_init_gpc_unk_0[]; |
| 240 | extern const struct gf100_gr_init gf108_gr_init_setup_1[]; |
| 241 | |
| 242 | extern const struct gf100_gr_init gf119_gr_init_pd_0[]; |
| 243 | extern const struct gf100_gr_init gf119_gr_init_ds_0[]; |
| 244 | extern const struct gf100_gr_init gf119_gr_init_prop_0[]; |
| 245 | extern const struct gf100_gr_init gf119_gr_init_gpm_0[]; |
| 246 | extern const struct gf100_gr_init gf119_gr_init_gpc_unk_1[]; |
| 247 | extern const struct gf100_gr_init gf119_gr_init_tex_0[]; |
| 248 | extern const struct gf100_gr_init gf119_gr_init_sm_0[]; |
| 249 | extern const struct gf100_gr_init gf119_gr_init_fe_1[]; |
| 250 | |
| 251 | extern const struct gf100_gr_init gf117_gr_init_pes_0[]; |
| 252 | extern const struct gf100_gr_init gf117_gr_init_wwdx_0[]; |
| 253 | extern const struct gf100_gr_init gf117_gr_init_cbm_0[]; |
| 254 | |
| 255 | extern const struct gf100_gr_init gk104_gr_init_main_0[]; |
| 256 | extern const struct gf100_gr_init gk104_gr_init_tpccs_0[]; |
| 257 | extern const struct gf100_gr_init gk104_gr_init_pe_0[]; |
| 258 | extern const struct gf100_gr_init gk104_gr_init_be_0[]; |
| 259 | extern const struct gf100_gr_pack gk104_gr_pack_mmio[]; |
| 260 | |
| 261 | extern const struct gf100_gr_init gk110_gr_init_fe_0[]; |
| 262 | extern const struct gf100_gr_init gk110_gr_init_ds_0[]; |
| 263 | extern const struct gf100_gr_init gk110_gr_init_sked_0[]; |
| 264 | extern const struct gf100_gr_init gk110_gr_init_cwd_0[]; |
| 265 | extern const struct gf100_gr_init gk110_gr_init_gpc_unk_1[]; |
| 266 | extern const struct gf100_gr_init gk110_gr_init_tex_0[]; |
| 267 | extern const struct gf100_gr_init gk110_gr_init_sm_0[]; |
| 268 | |
| 269 | extern const struct gf100_gr_init gk208_gr_init_gpc_unk_0[]; |
Ben Skeggs | 3fed3ea | 2015-03-26 09:28:34 +1000 | [diff] [blame] | 270 | |
| 271 | extern const struct gf100_gr_init gm107_gr_init_scc_0[]; |
| 272 | extern const struct gf100_gr_init gm107_gr_init_prop_0[]; |
| 273 | extern const struct gf100_gr_init gm107_gr_init_setup_1[]; |
| 274 | extern const struct gf100_gr_init gm107_gr_init_zcull_0[]; |
| 275 | extern const struct gf100_gr_init gm107_gr_init_gpc_unk_1[]; |
| 276 | extern const struct gf100_gr_init gm107_gr_init_tex_0[]; |
| 277 | extern const struct gf100_gr_init gm107_gr_init_l1c_0[]; |
| 278 | extern const struct gf100_gr_init gm107_gr_init_wwdx_0[]; |
| 279 | extern const struct gf100_gr_init gm107_gr_init_cbm_0[]; |
Ben Skeggs | bfee3f3 | 2015-08-20 14:54:08 +1000 | [diff] [blame] | 280 | void gm107_gr_init_bios(struct gf100_gr *); |
Ben Skeggs | 3fed3ea | 2015-03-26 09:28:34 +1000 | [diff] [blame] | 281 | |
Ben Skeggs | 426b20e | 2015-04-14 12:06:44 +1000 | [diff] [blame] | 282 | extern const struct gf100_gr_pack gm204_gr_pack_mmio[]; |
Ben Skeggs | e3c71eb | 2015-01-14 15:29:43 +1000 | [diff] [blame] | 283 | #endif |