nv40_graph.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /*
  2. * Copyright (C) 2007 Ben Skeggs.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the
  14. * next paragraph) shall be included in all copies or substantial
  15. * portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
  21. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. */
  26. #include <linux/firmware.h>
  27. #include "drmP.h"
  28. #include "drm.h"
  29. #include "nouveau_drv.h"
  30. MODULE_FIRMWARE("nouveau/nv40.ctxprog");
  31. MODULE_FIRMWARE("nouveau/nv40.ctxvals");
  32. MODULE_FIRMWARE("nouveau/nv41.ctxprog");
  33. MODULE_FIRMWARE("nouveau/nv41.ctxvals");
  34. MODULE_FIRMWARE("nouveau/nv42.ctxprog");
  35. MODULE_FIRMWARE("nouveau/nv42.ctxvals");
  36. MODULE_FIRMWARE("nouveau/nv43.ctxprog");
  37. MODULE_FIRMWARE("nouveau/nv43.ctxvals");
  38. MODULE_FIRMWARE("nouveau/nv44.ctxprog");
  39. MODULE_FIRMWARE("nouveau/nv44.ctxvals");
  40. MODULE_FIRMWARE("nouveau/nv46.ctxprog");
  41. MODULE_FIRMWARE("nouveau/nv46.ctxvals");
  42. MODULE_FIRMWARE("nouveau/nv47.ctxprog");
  43. MODULE_FIRMWARE("nouveau/nv47.ctxvals");
  44. MODULE_FIRMWARE("nouveau/nv49.ctxprog");
  45. MODULE_FIRMWARE("nouveau/nv49.ctxvals");
  46. MODULE_FIRMWARE("nouveau/nv4a.ctxprog");
  47. MODULE_FIRMWARE("nouveau/nv4a.ctxvals");
  48. MODULE_FIRMWARE("nouveau/nv4b.ctxprog");
  49. MODULE_FIRMWARE("nouveau/nv4b.ctxvals");
  50. MODULE_FIRMWARE("nouveau/nv4c.ctxprog");
  51. MODULE_FIRMWARE("nouveau/nv4c.ctxvals");
  52. MODULE_FIRMWARE("nouveau/nv4e.ctxprog");
  53. MODULE_FIRMWARE("nouveau/nv4e.ctxvals");
  54. struct nouveau_channel *
  55. nv40_graph_channel(struct drm_device *dev)
  56. {
  57. struct drm_nouveau_private *dev_priv = dev->dev_private;
  58. uint32_t inst;
  59. int i;
  60. inst = nv_rd32(dev, NV40_PGRAPH_CTXCTL_CUR);
  61. if (!(inst & NV40_PGRAPH_CTXCTL_CUR_LOADED))
  62. return NULL;
  63. inst = (inst & NV40_PGRAPH_CTXCTL_CUR_INSTANCE) << 4;
  64. for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
  65. struct nouveau_channel *chan = dev_priv->fifos[i];
  66. if (chan && chan->ramin_grctx &&
  67. chan->ramin_grctx->instance == inst)
  68. return chan;
  69. }
  70. return NULL;
  71. }
  72. int
  73. nv40_graph_create_context(struct nouveau_channel *chan)
  74. {
  75. struct drm_device *dev = chan->dev;
  76. struct drm_nouveau_private *dev_priv = dev->dev_private;
  77. struct nouveau_gpuobj *ctx;
  78. int ret;
  79. /* Allocate a 175KiB block of PRAMIN to store the context. This
  80. * is massive overkill for a lot of chipsets, but it should be safe
  81. * until we're able to implement this properly (will happen at more
  82. * or less the same time we're able to write our own context programs.
  83. */
  84. ret = nouveau_gpuobj_new_ref(dev, chan, NULL, 0, 175*1024, 16,
  85. NVOBJ_FLAG_ZERO_ALLOC,
  86. &chan->ramin_grctx);
  87. if (ret)
  88. return ret;
  89. ctx = chan->ramin_grctx->gpuobj;
  90. /* Initialise default context values */
  91. dev_priv->engine.instmem.prepare_access(dev, true);
  92. nv40_grctx_vals_load(dev, ctx);
  93. nv_wo32(dev, ctx, 0, ctx->im_pramin->start);
  94. dev_priv->engine.instmem.finish_access(dev);
  95. return 0;
  96. }
  97. void
  98. nv40_graph_destroy_context(struct nouveau_channel *chan)
  99. {
  100. nouveau_gpuobj_ref_del(chan->dev, &chan->ramin_grctx);
  101. }
  102. static int
  103. nv40_graph_transfer_context(struct drm_device *dev, uint32_t inst, int save)
  104. {
  105. uint32_t old_cp, tv = 1000, tmp;
  106. int i;
  107. old_cp = nv_rd32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER);
  108. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER, inst);
  109. tmp = nv_rd32(dev, NV40_PGRAPH_CTXCTL_0310);
  110. tmp |= save ? NV40_PGRAPH_CTXCTL_0310_XFER_SAVE :
  111. NV40_PGRAPH_CTXCTL_0310_XFER_LOAD;
  112. nv_wr32(dev, NV40_PGRAPH_CTXCTL_0310, tmp);
  113. tmp = nv_rd32(dev, NV40_PGRAPH_CTXCTL_0304);
  114. tmp |= NV40_PGRAPH_CTXCTL_0304_XFER_CTX;
  115. nv_wr32(dev, NV40_PGRAPH_CTXCTL_0304, tmp);
  116. nouveau_wait_for_idle(dev);
  117. for (i = 0; i < tv; i++) {
  118. if (nv_rd32(dev, NV40_PGRAPH_CTXCTL_030C) == 0)
  119. break;
  120. }
  121. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER, old_cp);
  122. if (i == tv) {
  123. uint32_t ucstat = nv_rd32(dev, NV40_PGRAPH_CTXCTL_UCODE_STAT);
  124. NV_ERROR(dev, "Failed: Instance=0x%08x Save=%d\n", inst, save);
  125. NV_ERROR(dev, "IP: 0x%02x, Opcode: 0x%08x\n",
  126. ucstat >> NV40_PGRAPH_CTXCTL_UCODE_STAT_IP_SHIFT,
  127. ucstat & NV40_PGRAPH_CTXCTL_UCODE_STAT_OP_MASK);
  128. NV_ERROR(dev, "0x40030C = 0x%08x\n",
  129. nv_rd32(dev, NV40_PGRAPH_CTXCTL_030C));
  130. return -EBUSY;
  131. }
  132. return 0;
  133. }
  134. /* Restore the context for a specific channel into PGRAPH */
  135. int
  136. nv40_graph_load_context(struct nouveau_channel *chan)
  137. {
  138. struct drm_device *dev = chan->dev;
  139. uint32_t inst;
  140. int ret;
  141. if (!chan->ramin_grctx)
  142. return -EINVAL;
  143. inst = chan->ramin_grctx->instance >> 4;
  144. ret = nv40_graph_transfer_context(dev, inst, 0);
  145. if (ret)
  146. return ret;
  147. /* 0x40032C, no idea of it's exact function. Could simply be a
  148. * record of the currently active PGRAPH context. It's currently
  149. * unknown as to what bit 24 does. The nv ddx has it set, so we will
  150. * set it here too.
  151. */
  152. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER, inst);
  153. nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR,
  154. (inst & NV40_PGRAPH_CTXCTL_CUR_INSTANCE) |
  155. NV40_PGRAPH_CTXCTL_CUR_LOADED);
  156. /* 0x32E0 records the instance address of the active FIFO's PGRAPH
  157. * context. If at any time this doesn't match 0x40032C, you will
  158. * recieve PGRAPH_INTR_CONTEXT_SWITCH
  159. */
  160. nv_wr32(dev, NV40_PFIFO_GRCTX_INSTANCE, inst);
  161. return 0;
  162. }
  163. int
  164. nv40_graph_unload_context(struct drm_device *dev)
  165. {
  166. uint32_t inst;
  167. int ret;
  168. inst = nv_rd32(dev, NV40_PGRAPH_CTXCTL_CUR);
  169. if (!(inst & NV40_PGRAPH_CTXCTL_CUR_LOADED))
  170. return 0;
  171. inst &= NV40_PGRAPH_CTXCTL_CUR_INSTANCE;
  172. ret = nv40_graph_transfer_context(dev, inst, 1);
  173. nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, inst);
  174. return ret;
  175. }
  176. struct nouveau_ctxprog {
  177. uint32_t signature;
  178. uint8_t version;
  179. uint16_t length;
  180. uint32_t data[];
  181. } __attribute__ ((packed));
  182. struct nouveau_ctxvals {
  183. uint32_t signature;
  184. uint8_t version;
  185. uint32_t length;
  186. struct {
  187. uint32_t offset;
  188. uint32_t value;
  189. } data[];
  190. } __attribute__ ((packed));
  191. int
  192. nv40_grctx_init(struct drm_device *dev)
  193. {
  194. struct drm_nouveau_private *dev_priv = dev->dev_private;
  195. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  196. const int chipset = dev_priv->chipset;
  197. const struct firmware *fw;
  198. const struct nouveau_ctxprog *cp;
  199. const struct nouveau_ctxvals *cv;
  200. char name[32];
  201. int ret, i;
  202. pgraph->accel_blocked = true;
  203. if (!pgraph->ctxprog) {
  204. sprintf(name, "nouveau/nv%02x.ctxprog", chipset);
  205. ret = request_firmware(&fw, name, &dev->pdev->dev);
  206. if (ret) {
  207. NV_ERROR(dev, "No ctxprog for NV%02x\n", chipset);
  208. return ret;
  209. }
  210. pgraph->ctxprog = kmalloc(fw->size, GFP_KERNEL);
  211. if (!pgraph->ctxprog) {
  212. NV_ERROR(dev, "OOM copying ctxprog\n");
  213. release_firmware(fw);
  214. return -ENOMEM;
  215. }
  216. memcpy(pgraph->ctxprog, fw->data, fw->size);
  217. cp = pgraph->ctxprog;
  218. if (cp->signature != 0x5043564e || cp->version != 0 ||
  219. cp->length != ((fw->size - 7) / 4)) {
  220. NV_ERROR(dev, "ctxprog invalid\n");
  221. release_firmware(fw);
  222. nv40_grctx_fini(dev);
  223. return -EINVAL;
  224. }
  225. release_firmware(fw);
  226. }
  227. if (!pgraph->ctxvals) {
  228. sprintf(name, "nouveau/nv%02x.ctxvals", chipset);
  229. ret = request_firmware(&fw, name, &dev->pdev->dev);
  230. if (ret) {
  231. NV_ERROR(dev, "No ctxvals for NV%02x\n", chipset);
  232. nv40_grctx_fini(dev);
  233. return ret;
  234. }
  235. pgraph->ctxvals = kmalloc(fw->size, GFP_KERNEL);
  236. if (!pgraph->ctxprog) {
  237. NV_ERROR(dev, "OOM copying ctxprog\n");
  238. release_firmware(fw);
  239. nv40_grctx_fini(dev);
  240. return -ENOMEM;
  241. }
  242. memcpy(pgraph->ctxvals, fw->data, fw->size);
  243. cv = (void *)pgraph->ctxvals;
  244. if (cv->signature != 0x5643564e || cv->version != 0 ||
  245. cv->length != ((fw->size - 9) / 8)) {
  246. NV_ERROR(dev, "ctxvals invalid\n");
  247. release_firmware(fw);
  248. nv40_grctx_fini(dev);
  249. return -EINVAL;
  250. }
  251. release_firmware(fw);
  252. }
  253. cp = pgraph->ctxprog;
  254. nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
  255. for (i = 0; i < cp->length; i++)
  256. nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, cp->data[i]);
  257. pgraph->accel_blocked = false;
  258. return 0;
  259. }
  260. void
  261. nv40_grctx_fini(struct drm_device *dev)
  262. {
  263. struct drm_nouveau_private *dev_priv = dev->dev_private;
  264. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  265. if (pgraph->ctxprog) {
  266. kfree(pgraph->ctxprog);
  267. pgraph->ctxprog = NULL;
  268. }
  269. if (pgraph->ctxvals) {
  270. kfree(pgraph->ctxprog);
  271. pgraph->ctxvals = NULL;
  272. }
  273. }
  274. void
  275. nv40_grctx_vals_load(struct drm_device *dev, struct nouveau_gpuobj *ctx)
  276. {
  277. struct drm_nouveau_private *dev_priv = dev->dev_private;
  278. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  279. struct nouveau_ctxvals *cv = pgraph->ctxvals;
  280. int i;
  281. if (!cv)
  282. return;
  283. for (i = 0; i < cv->length; i++)
  284. nv_wo32(dev, ctx, cv->data[i].offset, cv->data[i].value);
  285. }
  286. /*
  287. * G70 0x47
  288. * G71 0x49
  289. * NV45 0x48
  290. * G72[M] 0x46
  291. * G73 0x4b
  292. * C51_G7X 0x4c
  293. * C51 0x4e
  294. */
  295. int
  296. nv40_graph_init(struct drm_device *dev)
  297. {
  298. struct drm_nouveau_private *dev_priv =
  299. (struct drm_nouveau_private *)dev->dev_private;
  300. uint32_t vramsz, tmp;
  301. int i, j;
  302. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) &
  303. ~NV_PMC_ENABLE_PGRAPH);
  304. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) |
  305. NV_PMC_ENABLE_PGRAPH);
  306. nv40_grctx_init(dev);
  307. /* No context present currently */
  308. nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0x00000000);
  309. nv_wr32(dev, NV03_PGRAPH_INTR , 0xFFFFFFFF);
  310. nv_wr32(dev, NV40_PGRAPH_INTR_EN, 0xFFFFFFFF);
  311. nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0xFFFFFFFF);
  312. nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x00000000);
  313. nv_wr32(dev, NV04_PGRAPH_DEBUG_1, 0x401287c0);
  314. nv_wr32(dev, NV04_PGRAPH_DEBUG_3, 0xe0de8055);
  315. nv_wr32(dev, NV10_PGRAPH_DEBUG_4, 0x00008000);
  316. nv_wr32(dev, NV04_PGRAPH_LIMIT_VIOL_PIX, 0x00be3c5f);
  317. nv_wr32(dev, NV10_PGRAPH_CTX_CONTROL, 0x10010100);
  318. nv_wr32(dev, NV10_PGRAPH_STATE , 0xFFFFFFFF);
  319. j = nv_rd32(dev, 0x1540) & 0xff;
  320. if (j) {
  321. for (i = 0; !(j & 1); j >>= 1, i++)
  322. ;
  323. nv_wr32(dev, 0x405000, i);
  324. }
  325. if (dev_priv->chipset == 0x40) {
  326. nv_wr32(dev, 0x4009b0, 0x83280fff);
  327. nv_wr32(dev, 0x4009b4, 0x000000a0);
  328. } else {
  329. nv_wr32(dev, 0x400820, 0x83280eff);
  330. nv_wr32(dev, 0x400824, 0x000000a0);
  331. }
  332. switch (dev_priv->chipset) {
  333. case 0x40:
  334. case 0x45:
  335. nv_wr32(dev, 0x4009b8, 0x0078e366);
  336. nv_wr32(dev, 0x4009bc, 0x0000014c);
  337. break;
  338. case 0x41:
  339. case 0x42: /* pciid also 0x00Cx */
  340. /* case 0x0120: XXX (pciid) */
  341. nv_wr32(dev, 0x400828, 0x007596ff);
  342. nv_wr32(dev, 0x40082c, 0x00000108);
  343. break;
  344. case 0x43:
  345. nv_wr32(dev, 0x400828, 0x0072cb77);
  346. nv_wr32(dev, 0x40082c, 0x00000108);
  347. break;
  348. case 0x44:
  349. case 0x46: /* G72 */
  350. case 0x4a:
  351. case 0x4c: /* G7x-based C51 */
  352. case 0x4e:
  353. nv_wr32(dev, 0x400860, 0);
  354. nv_wr32(dev, 0x400864, 0);
  355. break;
  356. case 0x47: /* G70 */
  357. case 0x49: /* G71 */
  358. case 0x4b: /* G73 */
  359. nv_wr32(dev, 0x400828, 0x07830610);
  360. nv_wr32(dev, 0x40082c, 0x0000016A);
  361. break;
  362. default:
  363. break;
  364. }
  365. nv_wr32(dev, 0x400b38, 0x2ffff800);
  366. nv_wr32(dev, 0x400b3c, 0x00006000);
  367. /* copy tile info from PFB */
  368. switch (dev_priv->chipset) {
  369. case 0x40: /* vanilla NV40 */
  370. for (i = 0; i < NV10_PFB_TILE__SIZE; i++) {
  371. tmp = nv_rd32(dev, NV10_PFB_TILE(i));
  372. nv_wr32(dev, NV40_PGRAPH_TILE0(i), tmp);
  373. nv_wr32(dev, NV40_PGRAPH_TILE1(i), tmp);
  374. tmp = nv_rd32(dev, NV10_PFB_TLIMIT(i));
  375. nv_wr32(dev, NV40_PGRAPH_TLIMIT0(i), tmp);
  376. nv_wr32(dev, NV40_PGRAPH_TLIMIT1(i), tmp);
  377. tmp = nv_rd32(dev, NV10_PFB_TSIZE(i));
  378. nv_wr32(dev, NV40_PGRAPH_TSIZE0(i), tmp);
  379. nv_wr32(dev, NV40_PGRAPH_TSIZE1(i), tmp);
  380. tmp = nv_rd32(dev, NV10_PFB_TSTATUS(i));
  381. nv_wr32(dev, NV40_PGRAPH_TSTATUS0(i), tmp);
  382. nv_wr32(dev, NV40_PGRAPH_TSTATUS1(i), tmp);
  383. }
  384. break;
  385. case 0x44:
  386. case 0x4a:
  387. case 0x4e: /* NV44-based cores don't have 0x406900? */
  388. for (i = 0; i < NV40_PFB_TILE__SIZE_0; i++) {
  389. tmp = nv_rd32(dev, NV40_PFB_TILE(i));
  390. nv_wr32(dev, NV40_PGRAPH_TILE0(i), tmp);
  391. tmp = nv_rd32(dev, NV40_PFB_TLIMIT(i));
  392. nv_wr32(dev, NV40_PGRAPH_TLIMIT0(i), tmp);
  393. tmp = nv_rd32(dev, NV40_PFB_TSIZE(i));
  394. nv_wr32(dev, NV40_PGRAPH_TSIZE0(i), tmp);
  395. tmp = nv_rd32(dev, NV40_PFB_TSTATUS(i));
  396. nv_wr32(dev, NV40_PGRAPH_TSTATUS0(i), tmp);
  397. }
  398. break;
  399. case 0x46:
  400. case 0x47:
  401. case 0x49:
  402. case 0x4b: /* G7X-based cores */
  403. for (i = 0; i < NV40_PFB_TILE__SIZE_1; i++) {
  404. tmp = nv_rd32(dev, NV40_PFB_TILE(i));
  405. nv_wr32(dev, NV47_PGRAPH_TILE0(i), tmp);
  406. nv_wr32(dev, NV40_PGRAPH_TILE1(i), tmp);
  407. tmp = nv_rd32(dev, NV40_PFB_TLIMIT(i));
  408. nv_wr32(dev, NV47_PGRAPH_TLIMIT0(i), tmp);
  409. nv_wr32(dev, NV40_PGRAPH_TLIMIT1(i), tmp);
  410. tmp = nv_rd32(dev, NV40_PFB_TSIZE(i));
  411. nv_wr32(dev, NV47_PGRAPH_TSIZE0(i), tmp);
  412. nv_wr32(dev, NV40_PGRAPH_TSIZE1(i), tmp);
  413. tmp = nv_rd32(dev, NV40_PFB_TSTATUS(i));
  414. nv_wr32(dev, NV47_PGRAPH_TSTATUS0(i), tmp);
  415. nv_wr32(dev, NV40_PGRAPH_TSTATUS1(i), tmp);
  416. }
  417. break;
  418. default: /* everything else */
  419. for (i = 0; i < NV40_PFB_TILE__SIZE_0; i++) {
  420. tmp = nv_rd32(dev, NV40_PFB_TILE(i));
  421. nv_wr32(dev, NV40_PGRAPH_TILE0(i), tmp);
  422. nv_wr32(dev, NV40_PGRAPH_TILE1(i), tmp);
  423. tmp = nv_rd32(dev, NV40_PFB_TLIMIT(i));
  424. nv_wr32(dev, NV40_PGRAPH_TLIMIT0(i), tmp);
  425. nv_wr32(dev, NV40_PGRAPH_TLIMIT1(i), tmp);
  426. tmp = nv_rd32(dev, NV40_PFB_TSIZE(i));
  427. nv_wr32(dev, NV40_PGRAPH_TSIZE0(i), tmp);
  428. nv_wr32(dev, NV40_PGRAPH_TSIZE1(i), tmp);
  429. tmp = nv_rd32(dev, NV40_PFB_TSTATUS(i));
  430. nv_wr32(dev, NV40_PGRAPH_TSTATUS0(i), tmp);
  431. nv_wr32(dev, NV40_PGRAPH_TSTATUS1(i), tmp);
  432. }
  433. break;
  434. }
  435. /* begin RAM config */
  436. vramsz = drm_get_resource_len(dev, 0) - 1;
  437. switch (dev_priv->chipset) {
  438. case 0x40:
  439. nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
  440. nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
  441. nv_wr32(dev, 0x4069A4, nv_rd32(dev, NV04_PFB_CFG0));
  442. nv_wr32(dev, 0x4069A8, nv_rd32(dev, NV04_PFB_CFG1));
  443. nv_wr32(dev, 0x400820, 0);
  444. nv_wr32(dev, 0x400824, 0);
  445. nv_wr32(dev, 0x400864, vramsz);
  446. nv_wr32(dev, 0x400868, vramsz);
  447. break;
  448. default:
  449. switch (dev_priv->chipset) {
  450. case 0x46:
  451. case 0x47:
  452. case 0x49:
  453. case 0x4b:
  454. nv_wr32(dev, 0x400DF0, nv_rd32(dev, NV04_PFB_CFG0));
  455. nv_wr32(dev, 0x400DF4, nv_rd32(dev, NV04_PFB_CFG1));
  456. break;
  457. default:
  458. nv_wr32(dev, 0x4009F0, nv_rd32(dev, NV04_PFB_CFG0));
  459. nv_wr32(dev, 0x4009F4, nv_rd32(dev, NV04_PFB_CFG1));
  460. break;
  461. }
  462. nv_wr32(dev, 0x4069F0, nv_rd32(dev, NV04_PFB_CFG0));
  463. nv_wr32(dev, 0x4069F4, nv_rd32(dev, NV04_PFB_CFG1));
  464. nv_wr32(dev, 0x400840, 0);
  465. nv_wr32(dev, 0x400844, 0);
  466. nv_wr32(dev, 0x4008A0, vramsz);
  467. nv_wr32(dev, 0x4008A4, vramsz);
  468. break;
  469. }
  470. return 0;
  471. }
  472. void nv40_graph_takedown(struct drm_device *dev)
  473. {
  474. }
  475. struct nouveau_pgraph_object_class nv40_graph_grclass[] = {
  476. { 0x0030, false, NULL }, /* null */
  477. { 0x0039, false, NULL }, /* m2mf */
  478. { 0x004a, false, NULL }, /* gdirect */
  479. { 0x009f, false, NULL }, /* imageblit (nv12) */
  480. { 0x008a, false, NULL }, /* ifc */
  481. { 0x0089, false, NULL }, /* sifm */
  482. { 0x3089, false, NULL }, /* sifm (nv40) */
  483. { 0x0062, false, NULL }, /* surf2d */
  484. { 0x3062, false, NULL }, /* surf2d (nv40) */
  485. { 0x0043, false, NULL }, /* rop */
  486. { 0x0012, false, NULL }, /* beta1 */
  487. { 0x0072, false, NULL }, /* beta4 */
  488. { 0x0019, false, NULL }, /* cliprect */
  489. { 0x0044, false, NULL }, /* pattern */
  490. { 0x309e, false, NULL }, /* swzsurf */
  491. { 0x4097, false, NULL }, /* curie (nv40) */
  492. { 0x4497, false, NULL }, /* curie (nv44) */
  493. {}
  494. };