ctxgp102.c 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright 2016 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 <bskeggs@redhat.com>
  23. */
  24. #include "ctxgf100.h"
  25. #include <subdev/fb.h>
  26. /*******************************************************************************
  27. * PGRAPH context implementation
  28. ******************************************************************************/
  29. void
  30. gp102_grctx_generate_attrib(struct gf100_grctx *info)
  31. {
  32. struct gf100_gr *gr = info->gr;
  33. const struct gf100_grctx_func *grctx = gr->func->grctx;
  34. const u32 alpha = grctx->alpha_nr;
  35. const u32 attrib = grctx->attrib_nr;
  36. const u32 pertpc = 0x20 * (grctx->attrib_nr_max + grctx->alpha_nr_max);
  37. const u32 size = roundup(gr->tpc_total * pertpc, 0x80);
  38. const u32 access = NV_MEM_ACCESS_RW;
  39. const int s = 12;
  40. const int b = mmio_vram(info, size, (1 << s), access);
  41. const int max_batches = 0xffff;
  42. u32 ao = 0;
  43. u32 bo = ao + grctx->alpha_nr_max * gr->tpc_total;
  44. int gpc, ppc, n = 0;
  45. mmio_refn(info, 0x418810, 0x80000000, s, b);
  46. mmio_refn(info, 0x419848, 0x10000000, s, b);
  47. mmio_refn(info, 0x419c2c, 0x10000000, s, b);
  48. mmio_refn(info, 0x419b00, 0x00000000, s, b);
  49. mmio_wr32(info, 0x419b04, 0x80000000 | size >> 7);
  50. mmio_wr32(info, 0x405830, attrib);
  51. mmio_wr32(info, 0x40585c, alpha);
  52. mmio_wr32(info, 0x4064c4, ((alpha / 4) << 16) | max_batches);
  53. for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
  54. for (ppc = 0; ppc < gr->ppc_nr[gpc]; ppc++, n++) {
  55. const u32 as = alpha * gr->ppc_tpc_nr[gpc][ppc];
  56. const u32 bs = attrib * gr->ppc_tpc_nr[gpc][ppc];
  57. const u32 u = 0x418ea0 + (n * 0x04);
  58. const u32 o = PPC_UNIT(gpc, ppc, 0);
  59. const u32 p = GPC_UNIT(gpc, 0xc44 + (ppc * 4));
  60. if (!(gr->ppc_mask[gpc] & (1 << ppc)))
  61. continue;
  62. mmio_wr32(info, o + 0xc0, bs);
  63. mmio_wr32(info, p, bs);
  64. mmio_wr32(info, o + 0xf4, bo);
  65. mmio_wr32(info, o + 0xf0, bs);
  66. bo += grctx->attrib_nr_max * gr->ppc_tpc_nr[gpc][ppc];
  67. mmio_wr32(info, o + 0xe4, as);
  68. mmio_wr32(info, o + 0xf8, ao);
  69. ao += grctx->alpha_nr_max * gr->ppc_tpc_nr[gpc][ppc];
  70. mmio_wr32(info, u, bs);
  71. }
  72. }
  73. mmio_wr32(info, 0x4181e4, 0x00000100);
  74. mmio_wr32(info, 0x41befc, 0x00000100);
  75. }
  76. const struct gf100_grctx_func
  77. gp102_grctx = {
  78. .main = gp100_grctx_generate_main,
  79. .unkn = gk104_grctx_generate_unkn,
  80. .bundle = gm107_grctx_generate_bundle,
  81. .bundle_size = 0x3000,
  82. .bundle_min_gpm_fifo_depth = 0x180,
  83. .bundle_token_limit = 0x900,
  84. .pagepool = gp100_grctx_generate_pagepool,
  85. .pagepool_size = 0x20000,
  86. .attrib = gp102_grctx_generate_attrib,
  87. .attrib_nr_max = 0x5d4,
  88. .attrib_nr = 0x320,
  89. .alpha_nr_max = 0xc00,
  90. .alpha_nr = 0x800,
  91. };