rv515.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  1. /*
  2. * Copyright 2008 Advanced Micro Devices, Inc.
  3. * Copyright 2008 Red Hat Inc.
  4. * Copyright 2009 Jerome Glisse.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors: Dave Airlie
  25. * Alex Deucher
  26. * Jerome Glisse
  27. */
  28. #include <linux/seq_file.h>
  29. #include "drmP.h"
  30. #include "rv515d.h"
  31. #include "radeon.h"
  32. #include "rv515_reg_safe.h"
  33. /* rv515 depends on : */
  34. void r100_hdp_reset(struct radeon_device *rdev);
  35. int r100_cp_reset(struct radeon_device *rdev);
  36. int r100_rb2d_reset(struct radeon_device *rdev);
  37. int r100_gui_wait_for_idle(struct radeon_device *rdev);
  38. int r100_cp_init(struct radeon_device *rdev, unsigned ring_size);
  39. void r420_pipes_init(struct radeon_device *rdev);
  40. void rs600_mc_disable_clients(struct radeon_device *rdev);
  41. void rs600_disable_vga(struct radeon_device *rdev);
  42. /* This files gather functions specifics to:
  43. * rv515
  44. *
  45. * Some of these functions might be used by newer ASICs.
  46. */
  47. int rv515_debugfs_pipes_info_init(struct radeon_device *rdev);
  48. int rv515_debugfs_ga_info_init(struct radeon_device *rdev);
  49. void rv515_gpu_init(struct radeon_device *rdev);
  50. int rv515_mc_wait_for_idle(struct radeon_device *rdev);
  51. /*
  52. * MC
  53. */
  54. int rv515_mc_init(struct radeon_device *rdev)
  55. {
  56. uint32_t tmp;
  57. int r;
  58. if (r100_debugfs_rbbm_init(rdev)) {
  59. DRM_ERROR("Failed to register debugfs file for RBBM !\n");
  60. }
  61. if (rv515_debugfs_pipes_info_init(rdev)) {
  62. DRM_ERROR("Failed to register debugfs file for pipes !\n");
  63. }
  64. if (rv515_debugfs_ga_info_init(rdev)) {
  65. DRM_ERROR("Failed to register debugfs file for pipes !\n");
  66. }
  67. rv515_gpu_init(rdev);
  68. rv370_pcie_gart_disable(rdev);
  69. /* Setup GPU memory space */
  70. rdev->mc.vram_location = 0xFFFFFFFFUL;
  71. rdev->mc.gtt_location = 0xFFFFFFFFUL;
  72. if (rdev->flags & RADEON_IS_AGP) {
  73. r = radeon_agp_init(rdev);
  74. if (r) {
  75. printk(KERN_WARNING "[drm] Disabling AGP\n");
  76. rdev->flags &= ~RADEON_IS_AGP;
  77. rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
  78. } else {
  79. rdev->mc.gtt_location = rdev->mc.agp_base;
  80. }
  81. }
  82. r = radeon_mc_setup(rdev);
  83. if (r) {
  84. return r;
  85. }
  86. /* Program GPU memory space */
  87. rs600_mc_disable_clients(rdev);
  88. if (rv515_mc_wait_for_idle(rdev)) {
  89. printk(KERN_WARNING "Failed to wait MC idle while "
  90. "programming pipes. Bad things might happen.\n");
  91. }
  92. /* Write VRAM size in case we are limiting it */
  93. WREG32(RADEON_CONFIG_MEMSIZE, rdev->mc.real_vram_size);
  94. tmp = REG_SET(MC_FB_START, rdev->mc.vram_location >> 16);
  95. WREG32(0x134, tmp);
  96. tmp = rdev->mc.vram_location + rdev->mc.mc_vram_size - 1;
  97. tmp = REG_SET(MC_FB_TOP, tmp >> 16);
  98. tmp |= REG_SET(MC_FB_START, rdev->mc.vram_location >> 16);
  99. WREG32_MC(MC_FB_LOCATION, tmp);
  100. WREG32(HDP_FB_LOCATION, rdev->mc.vram_location >> 16);
  101. WREG32(0x310, rdev->mc.vram_location);
  102. if (rdev->flags & RADEON_IS_AGP) {
  103. tmp = rdev->mc.gtt_location + rdev->mc.gtt_size - 1;
  104. tmp = REG_SET(MC_AGP_TOP, tmp >> 16);
  105. tmp |= REG_SET(MC_AGP_START, rdev->mc.gtt_location >> 16);
  106. WREG32_MC(MC_AGP_LOCATION, tmp);
  107. WREG32_MC(MC_AGP_BASE, rdev->mc.agp_base);
  108. WREG32_MC(MC_AGP_BASE_2, 0);
  109. } else {
  110. WREG32_MC(MC_AGP_LOCATION, 0x0FFFFFFF);
  111. WREG32_MC(MC_AGP_BASE, 0);
  112. WREG32_MC(MC_AGP_BASE_2, 0);
  113. }
  114. return 0;
  115. }
  116. void rv515_mc_fini(struct radeon_device *rdev)
  117. {
  118. }
  119. /*
  120. * Global GPU functions
  121. */
  122. void rv515_ring_start(struct radeon_device *rdev)
  123. {
  124. int r;
  125. r = radeon_ring_lock(rdev, 64);
  126. if (r) {
  127. return;
  128. }
  129. radeon_ring_write(rdev, PACKET0(ISYNC_CNTL, 0));
  130. radeon_ring_write(rdev,
  131. ISYNC_ANY2D_IDLE3D |
  132. ISYNC_ANY3D_IDLE2D |
  133. ISYNC_WAIT_IDLEGUI |
  134. ISYNC_CPSCRATCH_IDLEGUI);
  135. radeon_ring_write(rdev, PACKET0(WAIT_UNTIL, 0));
  136. radeon_ring_write(rdev, WAIT_2D_IDLECLEAN | WAIT_3D_IDLECLEAN);
  137. radeon_ring_write(rdev, PACKET0(0x170C, 0));
  138. radeon_ring_write(rdev, 1 << 31);
  139. radeon_ring_write(rdev, PACKET0(GB_SELECT, 0));
  140. radeon_ring_write(rdev, 0);
  141. radeon_ring_write(rdev, PACKET0(GB_ENABLE, 0));
  142. radeon_ring_write(rdev, 0);
  143. radeon_ring_write(rdev, PACKET0(0x42C8, 0));
  144. radeon_ring_write(rdev, (1 << rdev->num_gb_pipes) - 1);
  145. radeon_ring_write(rdev, PACKET0(VAP_INDEX_OFFSET, 0));
  146. radeon_ring_write(rdev, 0);
  147. radeon_ring_write(rdev, PACKET0(RB3D_DSTCACHE_CTLSTAT, 0));
  148. radeon_ring_write(rdev, RB3D_DC_FLUSH | RB3D_DC_FREE);
  149. radeon_ring_write(rdev, PACKET0(ZB_ZCACHE_CTLSTAT, 0));
  150. radeon_ring_write(rdev, ZC_FLUSH | ZC_FREE);
  151. radeon_ring_write(rdev, PACKET0(WAIT_UNTIL, 0));
  152. radeon_ring_write(rdev, WAIT_2D_IDLECLEAN | WAIT_3D_IDLECLEAN);
  153. radeon_ring_write(rdev, PACKET0(GB_AA_CONFIG, 0));
  154. radeon_ring_write(rdev, 0);
  155. radeon_ring_write(rdev, PACKET0(RB3D_DSTCACHE_CTLSTAT, 0));
  156. radeon_ring_write(rdev, RB3D_DC_FLUSH | RB3D_DC_FREE);
  157. radeon_ring_write(rdev, PACKET0(ZB_ZCACHE_CTLSTAT, 0));
  158. radeon_ring_write(rdev, ZC_FLUSH | ZC_FREE);
  159. radeon_ring_write(rdev, PACKET0(GB_MSPOS0, 0));
  160. radeon_ring_write(rdev,
  161. ((6 << MS_X0_SHIFT) |
  162. (6 << MS_Y0_SHIFT) |
  163. (6 << MS_X1_SHIFT) |
  164. (6 << MS_Y1_SHIFT) |
  165. (6 << MS_X2_SHIFT) |
  166. (6 << MS_Y2_SHIFT) |
  167. (6 << MSBD0_Y_SHIFT) |
  168. (6 << MSBD0_X_SHIFT)));
  169. radeon_ring_write(rdev, PACKET0(GB_MSPOS1, 0));
  170. radeon_ring_write(rdev,
  171. ((6 << MS_X3_SHIFT) |
  172. (6 << MS_Y3_SHIFT) |
  173. (6 << MS_X4_SHIFT) |
  174. (6 << MS_Y4_SHIFT) |
  175. (6 << MS_X5_SHIFT) |
  176. (6 << MS_Y5_SHIFT) |
  177. (6 << MSBD1_SHIFT)));
  178. radeon_ring_write(rdev, PACKET0(GA_ENHANCE, 0));
  179. radeon_ring_write(rdev, GA_DEADLOCK_CNTL | GA_FASTSYNC_CNTL);
  180. radeon_ring_write(rdev, PACKET0(GA_POLY_MODE, 0));
  181. radeon_ring_write(rdev, FRONT_PTYPE_TRIANGE | BACK_PTYPE_TRIANGE);
  182. radeon_ring_write(rdev, PACKET0(GA_ROUND_MODE, 0));
  183. radeon_ring_write(rdev, GEOMETRY_ROUND_NEAREST | COLOR_ROUND_NEAREST);
  184. radeon_ring_write(rdev, PACKET0(0x20C8, 0));
  185. radeon_ring_write(rdev, 0);
  186. radeon_ring_unlock_commit(rdev);
  187. }
  188. void rv515_errata(struct radeon_device *rdev)
  189. {
  190. rdev->pll_errata = 0;
  191. }
  192. int rv515_mc_wait_for_idle(struct radeon_device *rdev)
  193. {
  194. unsigned i;
  195. uint32_t tmp;
  196. for (i = 0; i < rdev->usec_timeout; i++) {
  197. /* read MC_STATUS */
  198. tmp = RREG32_MC(MC_STATUS);
  199. if (tmp & MC_STATUS_IDLE) {
  200. return 0;
  201. }
  202. DRM_UDELAY(1);
  203. }
  204. return -1;
  205. }
  206. void rv515_gpu_init(struct radeon_device *rdev)
  207. {
  208. unsigned pipe_select_current, gb_pipe_select, tmp;
  209. r100_hdp_reset(rdev);
  210. r100_rb2d_reset(rdev);
  211. if (r100_gui_wait_for_idle(rdev)) {
  212. printk(KERN_WARNING "Failed to wait GUI idle while "
  213. "reseting GPU. Bad things might happen.\n");
  214. }
  215. rs600_disable_vga(rdev);
  216. r420_pipes_init(rdev);
  217. gb_pipe_select = RREG32(0x402C);
  218. tmp = RREG32(0x170C);
  219. pipe_select_current = (tmp >> 2) & 3;
  220. tmp = (1 << pipe_select_current) |
  221. (((gb_pipe_select >> 8) & 0xF) << 4);
  222. WREG32_PLL(0x000D, tmp);
  223. if (r100_gui_wait_for_idle(rdev)) {
  224. printk(KERN_WARNING "Failed to wait GUI idle while "
  225. "reseting GPU. Bad things might happen.\n");
  226. }
  227. if (rv515_mc_wait_for_idle(rdev)) {
  228. printk(KERN_WARNING "Failed to wait MC idle while "
  229. "programming pipes. Bad things might happen.\n");
  230. }
  231. }
  232. int rv515_ga_reset(struct radeon_device *rdev)
  233. {
  234. uint32_t tmp;
  235. bool reinit_cp;
  236. int i;
  237. reinit_cp = rdev->cp.ready;
  238. rdev->cp.ready = false;
  239. for (i = 0; i < rdev->usec_timeout; i++) {
  240. WREG32(CP_CSQ_MODE, 0);
  241. WREG32(CP_CSQ_CNTL, 0);
  242. WREG32(RBBM_SOFT_RESET, 0x32005);
  243. (void)RREG32(RBBM_SOFT_RESET);
  244. udelay(200);
  245. WREG32(RBBM_SOFT_RESET, 0);
  246. /* Wait to prevent race in RBBM_STATUS */
  247. mdelay(1);
  248. tmp = RREG32(RBBM_STATUS);
  249. if (tmp & ((1 << 20) | (1 << 26))) {
  250. DRM_ERROR("VAP & CP still busy (RBBM_STATUS=0x%08X)\n", tmp);
  251. /* GA still busy soft reset it */
  252. WREG32(0x429C, 0x200);
  253. WREG32(VAP_PVS_STATE_FLUSH_REG, 0);
  254. WREG32(0x43E0, 0);
  255. WREG32(0x43E4, 0);
  256. WREG32(0x24AC, 0);
  257. }
  258. /* Wait to prevent race in RBBM_STATUS */
  259. mdelay(1);
  260. tmp = RREG32(RBBM_STATUS);
  261. if (!(tmp & ((1 << 20) | (1 << 26)))) {
  262. break;
  263. }
  264. }
  265. for (i = 0; i < rdev->usec_timeout; i++) {
  266. tmp = RREG32(RBBM_STATUS);
  267. if (!(tmp & ((1 << 20) | (1 << 26)))) {
  268. DRM_INFO("GA reset succeed (RBBM_STATUS=0x%08X)\n",
  269. tmp);
  270. DRM_INFO("GA_IDLE=0x%08X\n", RREG32(0x425C));
  271. DRM_INFO("RB3D_RESET_STATUS=0x%08X\n", RREG32(0x46f0));
  272. DRM_INFO("ISYNC_CNTL=0x%08X\n", RREG32(0x1724));
  273. if (reinit_cp) {
  274. return r100_cp_init(rdev, rdev->cp.ring_size);
  275. }
  276. return 0;
  277. }
  278. DRM_UDELAY(1);
  279. }
  280. tmp = RREG32(RBBM_STATUS);
  281. DRM_ERROR("Failed to reset GA ! (RBBM_STATUS=0x%08X)\n", tmp);
  282. return -1;
  283. }
  284. int rv515_gpu_reset(struct radeon_device *rdev)
  285. {
  286. uint32_t status;
  287. /* reset order likely matter */
  288. status = RREG32(RBBM_STATUS);
  289. /* reset HDP */
  290. r100_hdp_reset(rdev);
  291. /* reset rb2d */
  292. if (status & ((1 << 17) | (1 << 18) | (1 << 27))) {
  293. r100_rb2d_reset(rdev);
  294. }
  295. /* reset GA */
  296. if (status & ((1 << 20) | (1 << 26))) {
  297. rv515_ga_reset(rdev);
  298. }
  299. /* reset CP */
  300. status = RREG32(RBBM_STATUS);
  301. if (status & (1 << 16)) {
  302. r100_cp_reset(rdev);
  303. }
  304. /* Check if GPU is idle */
  305. status = RREG32(RBBM_STATUS);
  306. if (status & (1 << 31)) {
  307. DRM_ERROR("Failed to reset GPU (RBBM_STATUS=0x%08X)\n", status);
  308. return -1;
  309. }
  310. DRM_INFO("GPU reset succeed (RBBM_STATUS=0x%08X)\n", status);
  311. return 0;
  312. }
  313. /*
  314. * VRAM info
  315. */
  316. static void rv515_vram_get_type(struct radeon_device *rdev)
  317. {
  318. uint32_t tmp;
  319. rdev->mc.vram_width = 128;
  320. rdev->mc.vram_is_ddr = true;
  321. tmp = RREG32_MC(RV515_MC_CNTL) & MEM_NUM_CHANNELS_MASK;
  322. switch (tmp) {
  323. case 0:
  324. rdev->mc.vram_width = 64;
  325. break;
  326. case 1:
  327. rdev->mc.vram_width = 128;
  328. break;
  329. default:
  330. rdev->mc.vram_width = 128;
  331. break;
  332. }
  333. }
  334. void rv515_vram_info(struct radeon_device *rdev)
  335. {
  336. fixed20_12 a;
  337. rv515_vram_get_type(rdev);
  338. r100_vram_init_sizes(rdev);
  339. /* FIXME: we should enforce default clock in case GPU is not in
  340. * default setup
  341. */
  342. a.full = rfixed_const(100);
  343. rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
  344. rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
  345. }
  346. /*
  347. * Indirect registers accessor
  348. */
  349. uint32_t rv515_mc_rreg(struct radeon_device *rdev, uint32_t reg)
  350. {
  351. uint32_t r;
  352. WREG32(MC_IND_INDEX, 0x7f0000 | (reg & 0xffff));
  353. r = RREG32(MC_IND_DATA);
  354. WREG32(MC_IND_INDEX, 0);
  355. return r;
  356. }
  357. void rv515_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
  358. {
  359. WREG32(MC_IND_INDEX, 0xff0000 | ((reg) & 0xffff));
  360. WREG32(MC_IND_DATA, (v));
  361. WREG32(MC_IND_INDEX, 0);
  362. }
  363. /*
  364. * Debugfs info
  365. */
  366. #if defined(CONFIG_DEBUG_FS)
  367. static int rv515_debugfs_pipes_info(struct seq_file *m, void *data)
  368. {
  369. struct drm_info_node *node = (struct drm_info_node *) m->private;
  370. struct drm_device *dev = node->minor->dev;
  371. struct radeon_device *rdev = dev->dev_private;
  372. uint32_t tmp;
  373. tmp = RREG32(GB_PIPE_SELECT);
  374. seq_printf(m, "GB_PIPE_SELECT 0x%08x\n", tmp);
  375. tmp = RREG32(SU_REG_DEST);
  376. seq_printf(m, "SU_REG_DEST 0x%08x\n", tmp);
  377. tmp = RREG32(GB_TILE_CONFIG);
  378. seq_printf(m, "GB_TILE_CONFIG 0x%08x\n", tmp);
  379. tmp = RREG32(DST_PIPE_CONFIG);
  380. seq_printf(m, "DST_PIPE_CONFIG 0x%08x\n", tmp);
  381. return 0;
  382. }
  383. static int rv515_debugfs_ga_info(struct seq_file *m, void *data)
  384. {
  385. struct drm_info_node *node = (struct drm_info_node *) m->private;
  386. struct drm_device *dev = node->minor->dev;
  387. struct radeon_device *rdev = dev->dev_private;
  388. uint32_t tmp;
  389. tmp = RREG32(0x2140);
  390. seq_printf(m, "VAP_CNTL_STATUS 0x%08x\n", tmp);
  391. radeon_gpu_reset(rdev);
  392. tmp = RREG32(0x425C);
  393. seq_printf(m, "GA_IDLE 0x%08x\n", tmp);
  394. return 0;
  395. }
  396. static struct drm_info_list rv515_pipes_info_list[] = {
  397. {"rv515_pipes_info", rv515_debugfs_pipes_info, 0, NULL},
  398. };
  399. static struct drm_info_list rv515_ga_info_list[] = {
  400. {"rv515_ga_info", rv515_debugfs_ga_info, 0, NULL},
  401. };
  402. #endif
  403. int rv515_debugfs_pipes_info_init(struct radeon_device *rdev)
  404. {
  405. #if defined(CONFIG_DEBUG_FS)
  406. return radeon_debugfs_add_files(rdev, rv515_pipes_info_list, 1);
  407. #else
  408. return 0;
  409. #endif
  410. }
  411. int rv515_debugfs_ga_info_init(struct radeon_device *rdev)
  412. {
  413. #if defined(CONFIG_DEBUG_FS)
  414. return radeon_debugfs_add_files(rdev, rv515_ga_info_list, 1);
  415. #else
  416. return 0;
  417. #endif
  418. }
  419. /*
  420. * Asic initialization
  421. */
  422. int rv515_init(struct radeon_device *rdev)
  423. {
  424. rdev->config.r300.reg_safe_bm = rv515_reg_safe_bm;
  425. rdev->config.r300.reg_safe_bm_size = ARRAY_SIZE(rv515_reg_safe_bm);
  426. return 0;
  427. }
  428. void atom_rv515_force_tv_scaler(struct radeon_device *rdev, struct radeon_crtc *crtc)
  429. {
  430. int index_reg = 0x6578 + crtc->crtc_offset;
  431. int data_reg = 0x657c + crtc->crtc_offset;
  432. WREG32(0x659C + crtc->crtc_offset, 0x0);
  433. WREG32(0x6594 + crtc->crtc_offset, 0x705);
  434. WREG32(0x65A4 + crtc->crtc_offset, 0x10001);
  435. WREG32(0x65D8 + crtc->crtc_offset, 0x0);
  436. WREG32(0x65B0 + crtc->crtc_offset, 0x0);
  437. WREG32(0x65C0 + crtc->crtc_offset, 0x0);
  438. WREG32(0x65D4 + crtc->crtc_offset, 0x0);
  439. WREG32(index_reg, 0x0);
  440. WREG32(data_reg, 0x841880A8);
  441. WREG32(index_reg, 0x1);
  442. WREG32(data_reg, 0x84208680);
  443. WREG32(index_reg, 0x2);
  444. WREG32(data_reg, 0xBFF880B0);
  445. WREG32(index_reg, 0x100);
  446. WREG32(data_reg, 0x83D88088);
  447. WREG32(index_reg, 0x101);
  448. WREG32(data_reg, 0x84608680);
  449. WREG32(index_reg, 0x102);
  450. WREG32(data_reg, 0xBFF080D0);
  451. WREG32(index_reg, 0x200);
  452. WREG32(data_reg, 0x83988068);
  453. WREG32(index_reg, 0x201);
  454. WREG32(data_reg, 0x84A08680);
  455. WREG32(index_reg, 0x202);
  456. WREG32(data_reg, 0xBFF080F8);
  457. WREG32(index_reg, 0x300);
  458. WREG32(data_reg, 0x83588058);
  459. WREG32(index_reg, 0x301);
  460. WREG32(data_reg, 0x84E08660);
  461. WREG32(index_reg, 0x302);
  462. WREG32(data_reg, 0xBFF88120);
  463. WREG32(index_reg, 0x400);
  464. WREG32(data_reg, 0x83188040);
  465. WREG32(index_reg, 0x401);
  466. WREG32(data_reg, 0x85008660);
  467. WREG32(index_reg, 0x402);
  468. WREG32(data_reg, 0xBFF88150);
  469. WREG32(index_reg, 0x500);
  470. WREG32(data_reg, 0x82D88030);
  471. WREG32(index_reg, 0x501);
  472. WREG32(data_reg, 0x85408640);
  473. WREG32(index_reg, 0x502);
  474. WREG32(data_reg, 0xBFF88180);
  475. WREG32(index_reg, 0x600);
  476. WREG32(data_reg, 0x82A08018);
  477. WREG32(index_reg, 0x601);
  478. WREG32(data_reg, 0x85808620);
  479. WREG32(index_reg, 0x602);
  480. WREG32(data_reg, 0xBFF081B8);
  481. WREG32(index_reg, 0x700);
  482. WREG32(data_reg, 0x82608010);
  483. WREG32(index_reg, 0x701);
  484. WREG32(data_reg, 0x85A08600);
  485. WREG32(index_reg, 0x702);
  486. WREG32(data_reg, 0x800081F0);
  487. WREG32(index_reg, 0x800);
  488. WREG32(data_reg, 0x8228BFF8);
  489. WREG32(index_reg, 0x801);
  490. WREG32(data_reg, 0x85E085E0);
  491. WREG32(index_reg, 0x802);
  492. WREG32(data_reg, 0xBFF88228);
  493. WREG32(index_reg, 0x10000);
  494. WREG32(data_reg, 0x82A8BF00);
  495. WREG32(index_reg, 0x10001);
  496. WREG32(data_reg, 0x82A08CC0);
  497. WREG32(index_reg, 0x10002);
  498. WREG32(data_reg, 0x8008BEF8);
  499. WREG32(index_reg, 0x10100);
  500. WREG32(data_reg, 0x81F0BF28);
  501. WREG32(index_reg, 0x10101);
  502. WREG32(data_reg, 0x83608CA0);
  503. WREG32(index_reg, 0x10102);
  504. WREG32(data_reg, 0x8018BED0);
  505. WREG32(index_reg, 0x10200);
  506. WREG32(data_reg, 0x8148BF38);
  507. WREG32(index_reg, 0x10201);
  508. WREG32(data_reg, 0x84408C80);
  509. WREG32(index_reg, 0x10202);
  510. WREG32(data_reg, 0x8008BEB8);
  511. WREG32(index_reg, 0x10300);
  512. WREG32(data_reg, 0x80B0BF78);
  513. WREG32(index_reg, 0x10301);
  514. WREG32(data_reg, 0x85008C20);
  515. WREG32(index_reg, 0x10302);
  516. WREG32(data_reg, 0x8020BEA0);
  517. WREG32(index_reg, 0x10400);
  518. WREG32(data_reg, 0x8028BF90);
  519. WREG32(index_reg, 0x10401);
  520. WREG32(data_reg, 0x85E08BC0);
  521. WREG32(index_reg, 0x10402);
  522. WREG32(data_reg, 0x8018BE90);
  523. WREG32(index_reg, 0x10500);
  524. WREG32(data_reg, 0xBFB8BFB0);
  525. WREG32(index_reg, 0x10501);
  526. WREG32(data_reg, 0x86C08B40);
  527. WREG32(index_reg, 0x10502);
  528. WREG32(data_reg, 0x8010BE90);
  529. WREG32(index_reg, 0x10600);
  530. WREG32(data_reg, 0xBF58BFC8);
  531. WREG32(index_reg, 0x10601);
  532. WREG32(data_reg, 0x87A08AA0);
  533. WREG32(index_reg, 0x10602);
  534. WREG32(data_reg, 0x8010BE98);
  535. WREG32(index_reg, 0x10700);
  536. WREG32(data_reg, 0xBF10BFF0);
  537. WREG32(index_reg, 0x10701);
  538. WREG32(data_reg, 0x886089E0);
  539. WREG32(index_reg, 0x10702);
  540. WREG32(data_reg, 0x8018BEB0);
  541. WREG32(index_reg, 0x10800);
  542. WREG32(data_reg, 0xBED8BFE8);
  543. WREG32(index_reg, 0x10801);
  544. WREG32(data_reg, 0x89408940);
  545. WREG32(index_reg, 0x10802);
  546. WREG32(data_reg, 0xBFE8BED8);
  547. WREG32(index_reg, 0x20000);
  548. WREG32(data_reg, 0x80008000);
  549. WREG32(index_reg, 0x20001);
  550. WREG32(data_reg, 0x90008000);
  551. WREG32(index_reg, 0x20002);
  552. WREG32(data_reg, 0x80008000);
  553. WREG32(index_reg, 0x20003);
  554. WREG32(data_reg, 0x80008000);
  555. WREG32(index_reg, 0x20100);
  556. WREG32(data_reg, 0x80108000);
  557. WREG32(index_reg, 0x20101);
  558. WREG32(data_reg, 0x8FE0BF70);
  559. WREG32(index_reg, 0x20102);
  560. WREG32(data_reg, 0xBFE880C0);
  561. WREG32(index_reg, 0x20103);
  562. WREG32(data_reg, 0x80008000);
  563. WREG32(index_reg, 0x20200);
  564. WREG32(data_reg, 0x8018BFF8);
  565. WREG32(index_reg, 0x20201);
  566. WREG32(data_reg, 0x8F80BF08);
  567. WREG32(index_reg, 0x20202);
  568. WREG32(data_reg, 0xBFD081A0);
  569. WREG32(index_reg, 0x20203);
  570. WREG32(data_reg, 0xBFF88000);
  571. WREG32(index_reg, 0x20300);
  572. WREG32(data_reg, 0x80188000);
  573. WREG32(index_reg, 0x20301);
  574. WREG32(data_reg, 0x8EE0BEC0);
  575. WREG32(index_reg, 0x20302);
  576. WREG32(data_reg, 0xBFB082A0);
  577. WREG32(index_reg, 0x20303);
  578. WREG32(data_reg, 0x80008000);
  579. WREG32(index_reg, 0x20400);
  580. WREG32(data_reg, 0x80188000);
  581. WREG32(index_reg, 0x20401);
  582. WREG32(data_reg, 0x8E00BEA0);
  583. WREG32(index_reg, 0x20402);
  584. WREG32(data_reg, 0xBF8883C0);
  585. WREG32(index_reg, 0x20403);
  586. WREG32(data_reg, 0x80008000);
  587. WREG32(index_reg, 0x20500);
  588. WREG32(data_reg, 0x80188000);
  589. WREG32(index_reg, 0x20501);
  590. WREG32(data_reg, 0x8D00BE90);
  591. WREG32(index_reg, 0x20502);
  592. WREG32(data_reg, 0xBF588500);
  593. WREG32(index_reg, 0x20503);
  594. WREG32(data_reg, 0x80008008);
  595. WREG32(index_reg, 0x20600);
  596. WREG32(data_reg, 0x80188000);
  597. WREG32(index_reg, 0x20601);
  598. WREG32(data_reg, 0x8BC0BE98);
  599. WREG32(index_reg, 0x20602);
  600. WREG32(data_reg, 0xBF308660);
  601. WREG32(index_reg, 0x20603);
  602. WREG32(data_reg, 0x80008008);
  603. WREG32(index_reg, 0x20700);
  604. WREG32(data_reg, 0x80108000);
  605. WREG32(index_reg, 0x20701);
  606. WREG32(data_reg, 0x8A80BEB0);
  607. WREG32(index_reg, 0x20702);
  608. WREG32(data_reg, 0xBF0087C0);
  609. WREG32(index_reg, 0x20703);
  610. WREG32(data_reg, 0x80008008);
  611. WREG32(index_reg, 0x20800);
  612. WREG32(data_reg, 0x80108000);
  613. WREG32(index_reg, 0x20801);
  614. WREG32(data_reg, 0x8920BED0);
  615. WREG32(index_reg, 0x20802);
  616. WREG32(data_reg, 0xBED08920);
  617. WREG32(index_reg, 0x20803);
  618. WREG32(data_reg, 0x80008010);
  619. WREG32(index_reg, 0x30000);
  620. WREG32(data_reg, 0x90008000);
  621. WREG32(index_reg, 0x30001);
  622. WREG32(data_reg, 0x80008000);
  623. WREG32(index_reg, 0x30100);
  624. WREG32(data_reg, 0x8FE0BF90);
  625. WREG32(index_reg, 0x30101);
  626. WREG32(data_reg, 0xBFF880A0);
  627. WREG32(index_reg, 0x30200);
  628. WREG32(data_reg, 0x8F60BF40);
  629. WREG32(index_reg, 0x30201);
  630. WREG32(data_reg, 0xBFE88180);
  631. WREG32(index_reg, 0x30300);
  632. WREG32(data_reg, 0x8EC0BF00);
  633. WREG32(index_reg, 0x30301);
  634. WREG32(data_reg, 0xBFC88280);
  635. WREG32(index_reg, 0x30400);
  636. WREG32(data_reg, 0x8DE0BEE0);
  637. WREG32(index_reg, 0x30401);
  638. WREG32(data_reg, 0xBFA083A0);
  639. WREG32(index_reg, 0x30500);
  640. WREG32(data_reg, 0x8CE0BED0);
  641. WREG32(index_reg, 0x30501);
  642. WREG32(data_reg, 0xBF7884E0);
  643. WREG32(index_reg, 0x30600);
  644. WREG32(data_reg, 0x8BA0BED8);
  645. WREG32(index_reg, 0x30601);
  646. WREG32(data_reg, 0xBF508640);
  647. WREG32(index_reg, 0x30700);
  648. WREG32(data_reg, 0x8A60BEE8);
  649. WREG32(index_reg, 0x30701);
  650. WREG32(data_reg, 0xBF2087A0);
  651. WREG32(index_reg, 0x30800);
  652. WREG32(data_reg, 0x8900BF00);
  653. WREG32(index_reg, 0x30801);
  654. WREG32(data_reg, 0xBF008900);
  655. }
  656. struct rv515_watermark {
  657. u32 lb_request_fifo_depth;
  658. fixed20_12 num_line_pair;
  659. fixed20_12 estimated_width;
  660. fixed20_12 worst_case_latency;
  661. fixed20_12 consumption_rate;
  662. fixed20_12 active_time;
  663. fixed20_12 dbpp;
  664. fixed20_12 priority_mark_max;
  665. fixed20_12 priority_mark;
  666. fixed20_12 sclk;
  667. };
  668. void rv515_crtc_bandwidth_compute(struct radeon_device *rdev,
  669. struct radeon_crtc *crtc,
  670. struct rv515_watermark *wm)
  671. {
  672. struct drm_display_mode *mode = &crtc->base.mode;
  673. fixed20_12 a, b, c;
  674. fixed20_12 pclk, request_fifo_depth, tolerable_latency, estimated_width;
  675. fixed20_12 consumption_time, line_time, chunk_time, read_delay_latency;
  676. if (!crtc->base.enabled) {
  677. /* FIXME: wouldn't it better to set priority mark to maximum */
  678. wm->lb_request_fifo_depth = 4;
  679. return;
  680. }
  681. if (crtc->vsc.full > rfixed_const(2))
  682. wm->num_line_pair.full = rfixed_const(2);
  683. else
  684. wm->num_line_pair.full = rfixed_const(1);
  685. b.full = rfixed_const(mode->crtc_hdisplay);
  686. c.full = rfixed_const(256);
  687. a.full = rfixed_mul(wm->num_line_pair, b);
  688. request_fifo_depth.full = rfixed_div(a, c);
  689. if (a.full < rfixed_const(4)) {
  690. wm->lb_request_fifo_depth = 4;
  691. } else {
  692. wm->lb_request_fifo_depth = rfixed_trunc(request_fifo_depth);
  693. }
  694. /* Determine consumption rate
  695. * pclk = pixel clock period(ns) = 1000 / (mode.clock / 1000)
  696. * vtaps = number of vertical taps,
  697. * vsc = vertical scaling ratio, defined as source/destination
  698. * hsc = horizontal scaling ration, defined as source/destination
  699. */
  700. a.full = rfixed_const(mode->clock);
  701. b.full = rfixed_const(1000);
  702. a.full = rfixed_div(a, b);
  703. pclk.full = rfixed_div(b, a);
  704. if (crtc->rmx_type != RMX_OFF) {
  705. b.full = rfixed_const(2);
  706. if (crtc->vsc.full > b.full)
  707. b.full = crtc->vsc.full;
  708. b.full = rfixed_mul(b, crtc->hsc);
  709. c.full = rfixed_const(2);
  710. b.full = rfixed_div(b, c);
  711. consumption_time.full = rfixed_div(pclk, b);
  712. } else {
  713. consumption_time.full = pclk.full;
  714. }
  715. a.full = rfixed_const(1);
  716. wm->consumption_rate.full = rfixed_div(a, consumption_time);
  717. /* Determine line time
  718. * LineTime = total time for one line of displayhtotal
  719. * LineTime = total number of horizontal pixels
  720. * pclk = pixel clock period(ns)
  721. */
  722. a.full = rfixed_const(crtc->base.mode.crtc_htotal);
  723. line_time.full = rfixed_mul(a, pclk);
  724. /* Determine active time
  725. * ActiveTime = time of active region of display within one line,
  726. * hactive = total number of horizontal active pixels
  727. * htotal = total number of horizontal pixels
  728. */
  729. a.full = rfixed_const(crtc->base.mode.crtc_htotal);
  730. b.full = rfixed_const(crtc->base.mode.crtc_hdisplay);
  731. wm->active_time.full = rfixed_mul(line_time, b);
  732. wm->active_time.full = rfixed_div(wm->active_time, a);
  733. /* Determine chunk time
  734. * ChunkTime = the time it takes the DCP to send one chunk of data
  735. * to the LB which consists of pipeline delay and inter chunk gap
  736. * sclk = system clock(Mhz)
  737. */
  738. a.full = rfixed_const(600 * 1000);
  739. chunk_time.full = rfixed_div(a, rdev->pm.sclk);
  740. read_delay_latency.full = rfixed_const(1000);
  741. /* Determine the worst case latency
  742. * NumLinePair = Number of line pairs to request(1=2 lines, 2=4 lines)
  743. * WorstCaseLatency = worst case time from urgent to when the MC starts
  744. * to return data
  745. * READ_DELAY_IDLE_MAX = constant of 1us
  746. * ChunkTime = time it takes the DCP to send one chunk of data to the LB
  747. * which consists of pipeline delay and inter chunk gap
  748. */
  749. if (rfixed_trunc(wm->num_line_pair) > 1) {
  750. a.full = rfixed_const(3);
  751. wm->worst_case_latency.full = rfixed_mul(a, chunk_time);
  752. wm->worst_case_latency.full += read_delay_latency.full;
  753. } else {
  754. wm->worst_case_latency.full = chunk_time.full + read_delay_latency.full;
  755. }
  756. /* Determine the tolerable latency
  757. * TolerableLatency = Any given request has only 1 line time
  758. * for the data to be returned
  759. * LBRequestFifoDepth = Number of chunk requests the LB can
  760. * put into the request FIFO for a display
  761. * LineTime = total time for one line of display
  762. * ChunkTime = the time it takes the DCP to send one chunk
  763. * of data to the LB which consists of
  764. * pipeline delay and inter chunk gap
  765. */
  766. if ((2+wm->lb_request_fifo_depth) >= rfixed_trunc(request_fifo_depth)) {
  767. tolerable_latency.full = line_time.full;
  768. } else {
  769. tolerable_latency.full = rfixed_const(wm->lb_request_fifo_depth - 2);
  770. tolerable_latency.full = request_fifo_depth.full - tolerable_latency.full;
  771. tolerable_latency.full = rfixed_mul(tolerable_latency, chunk_time);
  772. tolerable_latency.full = line_time.full - tolerable_latency.full;
  773. }
  774. /* We assume worst case 32bits (4 bytes) */
  775. wm->dbpp.full = rfixed_const(2 * 16);
  776. /* Determine the maximum priority mark
  777. * width = viewport width in pixels
  778. */
  779. a.full = rfixed_const(16);
  780. wm->priority_mark_max.full = rfixed_const(crtc->base.mode.crtc_hdisplay);
  781. wm->priority_mark_max.full = rfixed_div(wm->priority_mark_max, a);
  782. /* Determine estimated width */
  783. estimated_width.full = tolerable_latency.full - wm->worst_case_latency.full;
  784. estimated_width.full = rfixed_div(estimated_width, consumption_time);
  785. if (rfixed_trunc(estimated_width) > crtc->base.mode.crtc_hdisplay) {
  786. wm->priority_mark.full = rfixed_const(10);
  787. } else {
  788. a.full = rfixed_const(16);
  789. wm->priority_mark.full = rfixed_div(estimated_width, a);
  790. wm->priority_mark.full = wm->priority_mark_max.full - wm->priority_mark.full;
  791. }
  792. }
  793. void rv515_bandwidth_avivo_update(struct radeon_device *rdev)
  794. {
  795. struct drm_display_mode *mode0 = NULL;
  796. struct drm_display_mode *mode1 = NULL;
  797. struct rv515_watermark wm0;
  798. struct rv515_watermark wm1;
  799. u32 tmp;
  800. fixed20_12 priority_mark02, priority_mark12, fill_rate;
  801. fixed20_12 a, b;
  802. if (rdev->mode_info.crtcs[0]->base.enabled)
  803. mode0 = &rdev->mode_info.crtcs[0]->base.mode;
  804. if (rdev->mode_info.crtcs[1]->base.enabled)
  805. mode1 = &rdev->mode_info.crtcs[1]->base.mode;
  806. rs690_line_buffer_adjust(rdev, mode0, mode1);
  807. rv515_crtc_bandwidth_compute(rdev, rdev->mode_info.crtcs[0], &wm0);
  808. rv515_crtc_bandwidth_compute(rdev, rdev->mode_info.crtcs[1], &wm1);
  809. tmp = wm0.lb_request_fifo_depth;
  810. tmp |= wm1.lb_request_fifo_depth << 16;
  811. WREG32(LB_MAX_REQ_OUTSTANDING, tmp);
  812. if (mode0 && mode1) {
  813. if (rfixed_trunc(wm0.dbpp) > 64)
  814. a.full = rfixed_div(wm0.dbpp, wm0.num_line_pair);
  815. else
  816. a.full = wm0.num_line_pair.full;
  817. if (rfixed_trunc(wm1.dbpp) > 64)
  818. b.full = rfixed_div(wm1.dbpp, wm1.num_line_pair);
  819. else
  820. b.full = wm1.num_line_pair.full;
  821. a.full += b.full;
  822. fill_rate.full = rfixed_div(wm0.sclk, a);
  823. if (wm0.consumption_rate.full > fill_rate.full) {
  824. b.full = wm0.consumption_rate.full - fill_rate.full;
  825. b.full = rfixed_mul(b, wm0.active_time);
  826. a.full = rfixed_const(16);
  827. b.full = rfixed_div(b, a);
  828. a.full = rfixed_mul(wm0.worst_case_latency,
  829. wm0.consumption_rate);
  830. priority_mark02.full = a.full + b.full;
  831. } else {
  832. a.full = rfixed_mul(wm0.worst_case_latency,
  833. wm0.consumption_rate);
  834. b.full = rfixed_const(16 * 1000);
  835. priority_mark02.full = rfixed_div(a, b);
  836. }
  837. if (wm1.consumption_rate.full > fill_rate.full) {
  838. b.full = wm1.consumption_rate.full - fill_rate.full;
  839. b.full = rfixed_mul(b, wm1.active_time);
  840. a.full = rfixed_const(16);
  841. b.full = rfixed_div(b, a);
  842. a.full = rfixed_mul(wm1.worst_case_latency,
  843. wm1.consumption_rate);
  844. priority_mark12.full = a.full + b.full;
  845. } else {
  846. a.full = rfixed_mul(wm1.worst_case_latency,
  847. wm1.consumption_rate);
  848. b.full = rfixed_const(16 * 1000);
  849. priority_mark12.full = rfixed_div(a, b);
  850. }
  851. if (wm0.priority_mark.full > priority_mark02.full)
  852. priority_mark02.full = wm0.priority_mark.full;
  853. if (rfixed_trunc(priority_mark02) < 0)
  854. priority_mark02.full = 0;
  855. if (wm0.priority_mark_max.full > priority_mark02.full)
  856. priority_mark02.full = wm0.priority_mark_max.full;
  857. if (wm1.priority_mark.full > priority_mark12.full)
  858. priority_mark12.full = wm1.priority_mark.full;
  859. if (rfixed_trunc(priority_mark12) < 0)
  860. priority_mark12.full = 0;
  861. if (wm1.priority_mark_max.full > priority_mark12.full)
  862. priority_mark12.full = wm1.priority_mark_max.full;
  863. WREG32(D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02));
  864. WREG32(D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02));
  865. WREG32(D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12));
  866. WREG32(D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12));
  867. } else if (mode0) {
  868. if (rfixed_trunc(wm0.dbpp) > 64)
  869. a.full = rfixed_div(wm0.dbpp, wm0.num_line_pair);
  870. else
  871. a.full = wm0.num_line_pair.full;
  872. fill_rate.full = rfixed_div(wm0.sclk, a);
  873. if (wm0.consumption_rate.full > fill_rate.full) {
  874. b.full = wm0.consumption_rate.full - fill_rate.full;
  875. b.full = rfixed_mul(b, wm0.active_time);
  876. a.full = rfixed_const(16);
  877. b.full = rfixed_div(b, a);
  878. a.full = rfixed_mul(wm0.worst_case_latency,
  879. wm0.consumption_rate);
  880. priority_mark02.full = a.full + b.full;
  881. } else {
  882. a.full = rfixed_mul(wm0.worst_case_latency,
  883. wm0.consumption_rate);
  884. b.full = rfixed_const(16);
  885. priority_mark02.full = rfixed_div(a, b);
  886. }
  887. if (wm0.priority_mark.full > priority_mark02.full)
  888. priority_mark02.full = wm0.priority_mark.full;
  889. if (rfixed_trunc(priority_mark02) < 0)
  890. priority_mark02.full = 0;
  891. if (wm0.priority_mark_max.full > priority_mark02.full)
  892. priority_mark02.full = wm0.priority_mark_max.full;
  893. WREG32(D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02));
  894. WREG32(D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02));
  895. WREG32(D2MODE_PRIORITY_A_CNT, MODE_PRIORITY_OFF);
  896. WREG32(D2MODE_PRIORITY_B_CNT, MODE_PRIORITY_OFF);
  897. } else {
  898. if (rfixed_trunc(wm1.dbpp) > 64)
  899. a.full = rfixed_div(wm1.dbpp, wm1.num_line_pair);
  900. else
  901. a.full = wm1.num_line_pair.full;
  902. fill_rate.full = rfixed_div(wm1.sclk, a);
  903. if (wm1.consumption_rate.full > fill_rate.full) {
  904. b.full = wm1.consumption_rate.full - fill_rate.full;
  905. b.full = rfixed_mul(b, wm1.active_time);
  906. a.full = rfixed_const(16);
  907. b.full = rfixed_div(b, a);
  908. a.full = rfixed_mul(wm1.worst_case_latency,
  909. wm1.consumption_rate);
  910. priority_mark12.full = a.full + b.full;
  911. } else {
  912. a.full = rfixed_mul(wm1.worst_case_latency,
  913. wm1.consumption_rate);
  914. b.full = rfixed_const(16 * 1000);
  915. priority_mark12.full = rfixed_div(a, b);
  916. }
  917. if (wm1.priority_mark.full > priority_mark12.full)
  918. priority_mark12.full = wm1.priority_mark.full;
  919. if (rfixed_trunc(priority_mark12) < 0)
  920. priority_mark12.full = 0;
  921. if (wm1.priority_mark_max.full > priority_mark12.full)
  922. priority_mark12.full = wm1.priority_mark_max.full;
  923. WREG32(D1MODE_PRIORITY_A_CNT, MODE_PRIORITY_OFF);
  924. WREG32(D1MODE_PRIORITY_B_CNT, MODE_PRIORITY_OFF);
  925. WREG32(D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12));
  926. WREG32(D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12));
  927. }
  928. }
  929. void rv515_bandwidth_update(struct radeon_device *rdev)
  930. {
  931. uint32_t tmp;
  932. struct drm_display_mode *mode0 = NULL;
  933. struct drm_display_mode *mode1 = NULL;
  934. if (rdev->mode_info.crtcs[0]->base.enabled)
  935. mode0 = &rdev->mode_info.crtcs[0]->base.mode;
  936. if (rdev->mode_info.crtcs[1]->base.enabled)
  937. mode1 = &rdev->mode_info.crtcs[1]->base.mode;
  938. /*
  939. * Set display0/1 priority up in the memory controller for
  940. * modes if the user specifies HIGH for displaypriority
  941. * option.
  942. */
  943. if (rdev->disp_priority == 2) {
  944. tmp = RREG32_MC(MC_MISC_LAT_TIMER);
  945. tmp &= ~MC_DISP1R_INIT_LAT_MASK;
  946. tmp &= ~MC_DISP0R_INIT_LAT_MASK;
  947. if (mode1)
  948. tmp |= (1 << MC_DISP1R_INIT_LAT_SHIFT);
  949. if (mode0)
  950. tmp |= (1 << MC_DISP0R_INIT_LAT_SHIFT);
  951. WREG32_MC(MC_MISC_LAT_TIMER, tmp);
  952. }
  953. rv515_bandwidth_avivo_update(rdev);
  954. }