nv30.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. #include "nv20.h"
  2. #include "regs.h"
  3. #include <core/gpuobj.h>
  4. #include <engine/fifo.h>
  5. #include <engine/fifo/chan.h>
  6. #include <subdev/fb.h>
  7. /*******************************************************************************
  8. * PGRAPH context
  9. ******************************************************************************/
  10. static const struct nvkm_object_func
  11. nv30_gr_chan = {
  12. .dtor = nv20_gr_chan_dtor,
  13. .init = nv20_gr_chan_init,
  14. .fini = nv20_gr_chan_fini,
  15. };
  16. static int
  17. nv30_gr_chan_new(struct nvkm_gr *base, struct nvkm_fifo_chan *fifoch,
  18. const struct nvkm_oclass *oclass, struct nvkm_object **pobject)
  19. {
  20. struct nv20_gr *gr = nv20_gr(base);
  21. struct nv20_gr_chan *chan;
  22. int ret, i;
  23. if (!(chan = kzalloc(sizeof(*chan), GFP_KERNEL)))
  24. return -ENOMEM;
  25. nvkm_object_ctor(&nv30_gr_chan, oclass, &chan->object);
  26. chan->gr = gr;
  27. chan->chid = fifoch->chid;
  28. *pobject = &chan->object;
  29. ret = nvkm_memory_new(gr->base.engine.subdev.device,
  30. NVKM_MEM_TARGET_INST, 0x5f48, 16, true,
  31. &chan->inst);
  32. if (ret)
  33. return ret;
  34. nvkm_kmap(chan->inst);
  35. nvkm_wo32(chan->inst, 0x0028, 0x00000001 | (chan->chid << 24));
  36. nvkm_wo32(chan->inst, 0x0410, 0x00000101);
  37. nvkm_wo32(chan->inst, 0x0424, 0x00000111);
  38. nvkm_wo32(chan->inst, 0x0428, 0x00000060);
  39. nvkm_wo32(chan->inst, 0x0444, 0x00000080);
  40. nvkm_wo32(chan->inst, 0x0448, 0xffff0000);
  41. nvkm_wo32(chan->inst, 0x044c, 0x00000001);
  42. nvkm_wo32(chan->inst, 0x0460, 0x44400000);
  43. nvkm_wo32(chan->inst, 0x048c, 0xffff0000);
  44. for (i = 0x04e0; i < 0x04e8; i += 4)
  45. nvkm_wo32(chan->inst, i, 0x0fff0000);
  46. nvkm_wo32(chan->inst, 0x04ec, 0x00011100);
  47. for (i = 0x0508; i < 0x0548; i += 4)
  48. nvkm_wo32(chan->inst, i, 0x07ff0000);
  49. nvkm_wo32(chan->inst, 0x0550, 0x4b7fffff);
  50. nvkm_wo32(chan->inst, 0x058c, 0x00000080);
  51. nvkm_wo32(chan->inst, 0x0590, 0x30201000);
  52. nvkm_wo32(chan->inst, 0x0594, 0x70605040);
  53. nvkm_wo32(chan->inst, 0x0598, 0xb8a89888);
  54. nvkm_wo32(chan->inst, 0x059c, 0xf8e8d8c8);
  55. nvkm_wo32(chan->inst, 0x05b0, 0xb0000000);
  56. for (i = 0x0600; i < 0x0640; i += 4)
  57. nvkm_wo32(chan->inst, i, 0x00010588);
  58. for (i = 0x0640; i < 0x0680; i += 4)
  59. nvkm_wo32(chan->inst, i, 0x00030303);
  60. for (i = 0x06c0; i < 0x0700; i += 4)
  61. nvkm_wo32(chan->inst, i, 0x0008aae4);
  62. for (i = 0x0700; i < 0x0740; i += 4)
  63. nvkm_wo32(chan->inst, i, 0x01012000);
  64. for (i = 0x0740; i < 0x0780; i += 4)
  65. nvkm_wo32(chan->inst, i, 0x00080008);
  66. nvkm_wo32(chan->inst, 0x085c, 0x00040000);
  67. nvkm_wo32(chan->inst, 0x0860, 0x00010000);
  68. for (i = 0x0864; i < 0x0874; i += 4)
  69. nvkm_wo32(chan->inst, i, 0x00040004);
  70. for (i = 0x1f18; i <= 0x3088 ; i += 16) {
  71. nvkm_wo32(chan->inst, i + 0, 0x10700ff9);
  72. nvkm_wo32(chan->inst, i + 4, 0x0436086c);
  73. nvkm_wo32(chan->inst, i + 8, 0x000c001b);
  74. }
  75. for (i = 0x30b8; i < 0x30c8; i += 4)
  76. nvkm_wo32(chan->inst, i, 0x0000ffff);
  77. nvkm_wo32(chan->inst, 0x344c, 0x3f800000);
  78. nvkm_wo32(chan->inst, 0x3808, 0x3f800000);
  79. nvkm_wo32(chan->inst, 0x381c, 0x3f800000);
  80. nvkm_wo32(chan->inst, 0x3848, 0x40000000);
  81. nvkm_wo32(chan->inst, 0x384c, 0x3f800000);
  82. nvkm_wo32(chan->inst, 0x3850, 0x3f000000);
  83. nvkm_wo32(chan->inst, 0x3858, 0x40000000);
  84. nvkm_wo32(chan->inst, 0x385c, 0x3f800000);
  85. nvkm_wo32(chan->inst, 0x3864, 0xbf800000);
  86. nvkm_wo32(chan->inst, 0x386c, 0xbf800000);
  87. nvkm_done(chan->inst);
  88. return 0;
  89. }
  90. /*******************************************************************************
  91. * PGRAPH engine/subdev functions
  92. ******************************************************************************/
  93. int
  94. nv30_gr_init(struct nvkm_gr *base)
  95. {
  96. struct nv20_gr *gr = nv20_gr(base);
  97. struct nvkm_device *device = gr->base.engine.subdev.device;
  98. nvkm_wr32(device, NV20_PGRAPH_CHANNEL_CTX_TABLE,
  99. nvkm_memory_addr(gr->ctxtab) >> 4);
  100. nvkm_wr32(device, NV03_PGRAPH_INTR , 0xFFFFFFFF);
  101. nvkm_wr32(device, NV03_PGRAPH_INTR_EN, 0xFFFFFFFF);
  102. nvkm_wr32(device, NV04_PGRAPH_DEBUG_0, 0xFFFFFFFF);
  103. nvkm_wr32(device, NV04_PGRAPH_DEBUG_0, 0x00000000);
  104. nvkm_wr32(device, NV04_PGRAPH_DEBUG_1, 0x401287c0);
  105. nvkm_wr32(device, 0x400890, 0x01b463ff);
  106. nvkm_wr32(device, NV04_PGRAPH_DEBUG_3, 0xf2de0475);
  107. nvkm_wr32(device, NV10_PGRAPH_DEBUG_4, 0x00008000);
  108. nvkm_wr32(device, NV04_PGRAPH_LIMIT_VIOL_PIX, 0xf04bdff6);
  109. nvkm_wr32(device, 0x400B80, 0x1003d888);
  110. nvkm_wr32(device, 0x400B84, 0x0c000000);
  111. nvkm_wr32(device, 0x400098, 0x00000000);
  112. nvkm_wr32(device, 0x40009C, 0x0005ad00);
  113. nvkm_wr32(device, 0x400B88, 0x62ff00ff); /* suspiciously like PGRAPH_DEBUG_2 */
  114. nvkm_wr32(device, 0x4000a0, 0x00000000);
  115. nvkm_wr32(device, 0x4000a4, 0x00000008);
  116. nvkm_wr32(device, 0x4008a8, 0xb784a400);
  117. nvkm_wr32(device, 0x400ba0, 0x002f8685);
  118. nvkm_wr32(device, 0x400ba4, 0x00231f3f);
  119. nvkm_wr32(device, 0x4008a4, 0x40000020);
  120. if (device->chipset == 0x34) {
  121. nvkm_wr32(device, NV10_PGRAPH_RDI_INDEX, 0x00EA0004);
  122. nvkm_wr32(device, NV10_PGRAPH_RDI_DATA , 0x00200201);
  123. nvkm_wr32(device, NV10_PGRAPH_RDI_INDEX, 0x00EA0008);
  124. nvkm_wr32(device, NV10_PGRAPH_RDI_DATA , 0x00000008);
  125. nvkm_wr32(device, NV10_PGRAPH_RDI_INDEX, 0x00EA0000);
  126. nvkm_wr32(device, NV10_PGRAPH_RDI_DATA , 0x00000032);
  127. nvkm_wr32(device, NV10_PGRAPH_RDI_INDEX, 0x00E00004);
  128. nvkm_wr32(device, NV10_PGRAPH_RDI_DATA , 0x00000002);
  129. }
  130. nvkm_wr32(device, 0x4000c0, 0x00000016);
  131. nvkm_wr32(device, NV10_PGRAPH_CTX_CONTROL, 0x10000100);
  132. nvkm_wr32(device, NV10_PGRAPH_STATE , 0xFFFFFFFF);
  133. nvkm_wr32(device, 0x0040075c , 0x00000001);
  134. /* begin RAM config */
  135. /* vramsz = pci_resource_len(gr->dev->pdev, 1) - 1; */
  136. nvkm_wr32(device, 0x4009A4, nvkm_rd32(device, 0x100200));
  137. nvkm_wr32(device, 0x4009A8, nvkm_rd32(device, 0x100204));
  138. if (device->chipset != 0x34) {
  139. nvkm_wr32(device, 0x400750, 0x00EA0000);
  140. nvkm_wr32(device, 0x400754, nvkm_rd32(device, 0x100200));
  141. nvkm_wr32(device, 0x400750, 0x00EA0004);
  142. nvkm_wr32(device, 0x400754, nvkm_rd32(device, 0x100204));
  143. }
  144. return 0;
  145. }
  146. static const struct nvkm_gr_func
  147. nv30_gr = {
  148. .dtor = nv20_gr_dtor,
  149. .oneinit = nv20_gr_oneinit,
  150. .init = nv30_gr_init,
  151. .intr = nv20_gr_intr,
  152. .tile = nv20_gr_tile,
  153. .chan_new = nv30_gr_chan_new,
  154. .sclass = {
  155. { -1, -1, 0x0012, &nv04_gr_object }, /* beta1 */
  156. { -1, -1, 0x0019, &nv04_gr_object }, /* clip */
  157. { -1, -1, 0x0030, &nv04_gr_object }, /* null */
  158. { -1, -1, 0x0039, &nv04_gr_object }, /* m2mf */
  159. { -1, -1, 0x0043, &nv04_gr_object }, /* rop */
  160. { -1, -1, 0x0044, &nv04_gr_object }, /* patt */
  161. { -1, -1, 0x004a, &nv04_gr_object }, /* gdi */
  162. { -1, -1, 0x0062, &nv04_gr_object }, /* surf2d */
  163. { -1, -1, 0x0072, &nv04_gr_object }, /* beta4 */
  164. { -1, -1, 0x0089, &nv04_gr_object }, /* sifm */
  165. { -1, -1, 0x008a, &nv04_gr_object }, /* ifc */
  166. { -1, -1, 0x009f, &nv04_gr_object }, /* imageblit */
  167. { -1, -1, 0x0362, &nv04_gr_object }, /* surf2d (nv30) */
  168. { -1, -1, 0x0389, &nv04_gr_object }, /* sifm (nv30) */
  169. { -1, -1, 0x038a, &nv04_gr_object }, /* ifc (nv30) */
  170. { -1, -1, 0x039e, &nv04_gr_object }, /* swzsurf (nv30) */
  171. { -1, -1, 0x0397, &nv04_gr_object }, /* rankine */
  172. { -1, -1, 0x0597, &nv04_gr_object }, /* kelvin */
  173. {}
  174. }
  175. };
  176. int
  177. nv30_gr_new(struct nvkm_device *device, int index, struct nvkm_gr **pgr)
  178. {
  179. return nv20_gr_new_(&nv30_gr, device, index, pgr);
  180. }