linux/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
<<
>>
Prefs
   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 __GF100_GR_H__
  25#define __GF100_GR_H__
  26#define gf100_gr(p) container_of((p), struct gf100_gr, base)
  27#include "priv.h"
  28
  29#include <core/gpuobj.h>
  30#include <subdev/ltc.h>
  31#include <subdev/mmu.h>
  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
  43struct gf100_gr_data {
  44        u32 size;
  45        u32 align;
  46        u32 access;
  47};
  48
  49struct gf100_gr_mmio {
  50        u32 addr;
  51        u32 data;
  52        u32 shift;
  53        int buffer;
  54};
  55
  56struct gf100_gr_fuc {
  57        u32 *data;
  58        u32  size;
  59};
  60
  61struct gf100_gr_zbc_color {
  62        u32 format;
  63        u32 ds[4];
  64        u32 l2[4];
  65};
  66
  67struct gf100_gr_zbc_depth {
  68        u32 format;
  69        u32 ds;
  70        u32 l2;
  71};
  72
  73struct gf100_gr {
  74        const struct gf100_gr_func *func;
  75        struct nvkm_gr base;
  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
  83        /*
  84         * Used if the register packs are loaded from NVIDIA fw instead of
  85         * using hardcoded arrays. To be allocated with vzalloc().
  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
  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_mask[GPC_MAX];
 101        u8 ppc_tpc_nr[GPC_MAX][4];
 102
 103        struct nvkm_memory *unk4188b4;
 104        struct nvkm_memory *unk4188b8;
 105
 106        struct gf100_gr_data mmio_data[4];
 107        struct gf100_gr_mmio mmio_list[4096/8];
 108        u32  size;
 109        u32 *data;
 110
 111        u8 magic_not_rop_nr;
 112};
 113
 114int gf100_gr_ctor(const struct gf100_gr_func *, struct nvkm_device *,
 115                  int, struct gf100_gr *);
 116int gf100_gr_new_(const struct gf100_gr_func *, struct nvkm_device *,
 117                  int, struct nvkm_gr **);
 118void *gf100_gr_dtor(struct nvkm_gr *);
 119
 120struct gf100_gr_func {
 121        void (*dtor)(struct gf100_gr *);
 122        int (*init)(struct gf100_gr *);
 123        void (*init_gpc_mmu)(struct gf100_gr *);
 124        void (*set_hww_esr_report_mask)(struct gf100_gr *);
 125        const struct gf100_gr_pack *mmio;
 126        struct {
 127                struct gf100_gr_ucode *ucode;
 128        } fecs;
 129        struct {
 130                struct gf100_gr_ucode *ucode;
 131        } gpccs;
 132        int ppc_nr;
 133        const struct gf100_grctx_func *grctx;
 134        struct nvkm_sclass sclass[];
 135};
 136
 137int gf100_gr_init(struct gf100_gr *);
 138
 139int gk104_gr_init(struct gf100_gr *);
 140
 141int gk20a_gr_init(struct gf100_gr *);
 142
 143int gm200_gr_init(struct gf100_gr *);
 144
 145#define gf100_gr_chan(p) container_of((p), struct gf100_gr_chan, object)
 146
 147struct gf100_gr_chan {
 148        struct nvkm_object object;
 149        struct gf100_gr *gr;
 150
 151        struct nvkm_memory *mmio;
 152        struct nvkm_vma mmio_vma;
 153        int mmio_nr;
 154
 155        struct {
 156                struct nvkm_memory *mem;
 157                struct nvkm_vma vma;
 158        } data[4];
 159};
 160
 161void gf100_gr_ctxctl_debug(struct gf100_gr *);
 162
 163void gf100_gr_dtor_fw(struct gf100_gr_fuc *);
 164int  gf100_gr_ctor_fw(struct gf100_gr *, const char *,
 165                      struct gf100_gr_fuc *);
 166u64  gf100_gr_units(struct nvkm_gr *);
 167void gf100_gr_zbc_init(struct gf100_gr *);
 168
 169extern const struct nvkm_object_func gf100_fermi;
 170
 171struct gf100_gr_init {
 172        u32 addr;
 173        u8  count;
 174        u8  pitch;
 175        u32 data;
 176};
 177
 178struct gf100_gr_pack {
 179        const struct gf100_gr_init *init;
 180        u32 type;
 181};
 182
 183#define pack_for_each_init(init, pack, head)                                   \
 184        for (pack = head; pack && pack->init; pack++)                          \
 185                  for (init = pack->init; init && init->count; init++)
 186
 187struct gf100_gr_ucode {
 188        struct gf100_gr_fuc code;
 189        struct gf100_gr_fuc data;
 190};
 191
 192extern struct gf100_gr_ucode gf100_gr_fecs_ucode;
 193extern struct gf100_gr_ucode gf100_gr_gpccs_ucode;
 194
 195extern struct gf100_gr_ucode gk110_gr_fecs_ucode;
 196extern struct gf100_gr_ucode gk110_gr_gpccs_ucode;
 197
 198int  gf100_gr_wait_idle(struct gf100_gr *);
 199void gf100_gr_mmio(struct gf100_gr *, const struct gf100_gr_pack *);
 200void gf100_gr_icmd(struct gf100_gr *, const struct gf100_gr_pack *);
 201void gf100_gr_mthd(struct gf100_gr *, const struct gf100_gr_pack *);
 202int  gf100_gr_init_ctxctl(struct gf100_gr *);
 203
 204/* external bundles loading functions */
 205int gk20a_gr_av_to_init(struct gf100_gr *, const char *,
 206                        struct gf100_gr_pack **);
 207int gk20a_gr_aiv_to_init(struct gf100_gr *, const char *,
 208                         struct gf100_gr_pack **);
 209int gk20a_gr_av_to_method(struct gf100_gr *, const char *,
 210                          struct gf100_gr_pack **);
 211
 212int gm200_gr_new_(const struct gf100_gr_func *, struct nvkm_device *, int,
 213                  struct nvkm_gr **);
 214
 215/* register init value lists */
 216
 217extern const struct gf100_gr_init gf100_gr_init_main_0[];
 218extern const struct gf100_gr_init gf100_gr_init_fe_0[];
 219extern const struct gf100_gr_init gf100_gr_init_pri_0[];
 220extern const struct gf100_gr_init gf100_gr_init_rstr2d_0[];
 221extern const struct gf100_gr_init gf100_gr_init_pd_0[];
 222extern const struct gf100_gr_init gf100_gr_init_ds_0[];
 223extern const struct gf100_gr_init gf100_gr_init_scc_0[];
 224extern const struct gf100_gr_init gf100_gr_init_prop_0[];
 225extern const struct gf100_gr_init gf100_gr_init_gpc_unk_0[];
 226extern const struct gf100_gr_init gf100_gr_init_setup_0[];
 227extern const struct gf100_gr_init gf100_gr_init_crstr_0[];
 228extern const struct gf100_gr_init gf100_gr_init_setup_1[];
 229extern const struct gf100_gr_init gf100_gr_init_zcull_0[];
 230extern const struct gf100_gr_init gf100_gr_init_gpm_0[];
 231extern const struct gf100_gr_init gf100_gr_init_gpc_unk_1[];
 232extern const struct gf100_gr_init gf100_gr_init_gcc_0[];
 233extern const struct gf100_gr_init gf100_gr_init_tpccs_0[];
 234extern const struct gf100_gr_init gf100_gr_init_tex_0[];
 235extern const struct gf100_gr_init gf100_gr_init_pe_0[];
 236extern const struct gf100_gr_init gf100_gr_init_l1c_0[];
 237extern const struct gf100_gr_init gf100_gr_init_wwdx_0[];
 238extern const struct gf100_gr_init gf100_gr_init_tpccs_1[];
 239extern const struct gf100_gr_init gf100_gr_init_mpc_0[];
 240extern const struct gf100_gr_init gf100_gr_init_be_0[];
 241extern const struct gf100_gr_init gf100_gr_init_fe_1[];
 242extern const struct gf100_gr_init gf100_gr_init_pe_1[];
 243
 244extern const struct gf100_gr_init gf104_gr_init_ds_0[];
 245extern const struct gf100_gr_init gf104_gr_init_tex_0[];
 246extern const struct gf100_gr_init gf104_gr_init_sm_0[];
 247
 248extern const struct gf100_gr_init gf108_gr_init_gpc_unk_0[];
 249extern const struct gf100_gr_init gf108_gr_init_setup_1[];
 250
 251extern const struct gf100_gr_init gf119_gr_init_pd_0[];
 252extern const struct gf100_gr_init gf119_gr_init_ds_0[];
 253extern const struct gf100_gr_init gf119_gr_init_prop_0[];
 254extern const struct gf100_gr_init gf119_gr_init_gpm_0[];
 255extern const struct gf100_gr_init gf119_gr_init_gpc_unk_1[];
 256extern const struct gf100_gr_init gf119_gr_init_tex_0[];
 257extern const struct gf100_gr_init gf119_gr_init_sm_0[];
 258extern const struct gf100_gr_init gf119_gr_init_fe_1[];
 259
 260extern const struct gf100_gr_init gf117_gr_init_pes_0[];
 261extern const struct gf100_gr_init gf117_gr_init_wwdx_0[];
 262extern const struct gf100_gr_init gf117_gr_init_cbm_0[];
 263
 264extern const struct gf100_gr_init gk104_gr_init_main_0[];
 265extern const struct gf100_gr_init gk104_gr_init_tpccs_0[];
 266extern const struct gf100_gr_init gk104_gr_init_pe_0[];
 267extern const struct gf100_gr_init gk104_gr_init_be_0[];
 268extern const struct gf100_gr_pack gk104_gr_pack_mmio[];
 269
 270extern const struct gf100_gr_init gk110_gr_init_fe_0[];
 271extern const struct gf100_gr_init gk110_gr_init_ds_0[];
 272extern const struct gf100_gr_init gk110_gr_init_sked_0[];
 273extern const struct gf100_gr_init gk110_gr_init_cwd_0[];
 274extern const struct gf100_gr_init gk110_gr_init_gpc_unk_1[];
 275extern const struct gf100_gr_init gk110_gr_init_tex_0[];
 276extern const struct gf100_gr_init gk110_gr_init_sm_0[];
 277
 278extern const struct gf100_gr_init gk208_gr_init_gpc_unk_0[];
 279
 280extern const struct gf100_gr_init gm107_gr_init_scc_0[];
 281extern const struct gf100_gr_init gm107_gr_init_prop_0[];
 282extern const struct gf100_gr_init gm107_gr_init_setup_1[];
 283extern const struct gf100_gr_init gm107_gr_init_zcull_0[];
 284extern const struct gf100_gr_init gm107_gr_init_gpc_unk_1[];
 285extern const struct gf100_gr_init gm107_gr_init_tex_0[];
 286extern const struct gf100_gr_init gm107_gr_init_l1c_0[];
 287extern const struct gf100_gr_init gm107_gr_init_wwdx_0[];
 288extern const struct gf100_gr_init gm107_gr_init_cbm_0[];
 289void gm107_gr_init_bios(struct gf100_gr *);
 290#endif
 291