rv515.c 33 KB

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