/drivers/gpu/drm/radeon/cik.c

https://gitlab.com/tbwtiot/kernel_source · C · 8400 lines · 6537 code · 769 blank · 1094 comment · 818 complexity · 9ad068766f95edf74243255a2fb6ef15 MD5 · raw file

Large files are truncated click here to view the full file

  1. /*
  2. * Copyright 2012 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: Alex Deucher
  23. */
  24. #include <linux/firmware.h>
  25. #include <linux/slab.h>
  26. #include <linux/module.h>
  27. #include "drmP.h"
  28. #include "radeon.h"
  29. #include "radeon_asic.h"
  30. #include "cikd.h"
  31. #include "atom.h"
  32. #include "cik_blit_shaders.h"
  33. #include "radeon_ucode.h"
  34. #include "clearstate_ci.h"
  35. MODULE_FIRMWARE("radeon/BONAIRE_pfp.bin");
  36. MODULE_FIRMWARE("radeon/BONAIRE_me.bin");
  37. MODULE_FIRMWARE("radeon/BONAIRE_ce.bin");
  38. MODULE_FIRMWARE("radeon/BONAIRE_mec.bin");
  39. MODULE_FIRMWARE("radeon/BONAIRE_mc.bin");
  40. MODULE_FIRMWARE("radeon/BONAIRE_rlc.bin");
  41. MODULE_FIRMWARE("radeon/BONAIRE_sdma.bin");
  42. MODULE_FIRMWARE("radeon/BONAIRE_smc.bin");
  43. MODULE_FIRMWARE("radeon/KAVERI_pfp.bin");
  44. MODULE_FIRMWARE("radeon/KAVERI_me.bin");
  45. MODULE_FIRMWARE("radeon/KAVERI_ce.bin");
  46. MODULE_FIRMWARE("radeon/KAVERI_mec.bin");
  47. MODULE_FIRMWARE("radeon/KAVERI_rlc.bin");
  48. MODULE_FIRMWARE("radeon/KAVERI_sdma.bin");
  49. MODULE_FIRMWARE("radeon/KABINI_pfp.bin");
  50. MODULE_FIRMWARE("radeon/KABINI_me.bin");
  51. MODULE_FIRMWARE("radeon/KABINI_ce.bin");
  52. MODULE_FIRMWARE("radeon/KABINI_mec.bin");
  53. MODULE_FIRMWARE("radeon/KABINI_rlc.bin");
  54. MODULE_FIRMWARE("radeon/KABINI_sdma.bin");
  55. extern int r600_ih_ring_alloc(struct radeon_device *rdev);
  56. extern void r600_ih_ring_fini(struct radeon_device *rdev);
  57. extern void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *save);
  58. extern void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *save);
  59. extern bool evergreen_is_display_hung(struct radeon_device *rdev);
  60. extern void sumo_rlc_fini(struct radeon_device *rdev);
  61. extern int sumo_rlc_init(struct radeon_device *rdev);
  62. extern void si_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc);
  63. extern void si_rlc_reset(struct radeon_device *rdev);
  64. extern void si_init_uvd_internal_cg(struct radeon_device *rdev);
  65. extern int cik_sdma_resume(struct radeon_device *rdev);
  66. extern void cik_sdma_enable(struct radeon_device *rdev, bool enable);
  67. extern void cik_sdma_fini(struct radeon_device *rdev);
  68. extern void cik_sdma_vm_set_page(struct radeon_device *rdev,
  69. struct radeon_ib *ib,
  70. uint64_t pe,
  71. uint64_t addr, unsigned count,
  72. uint32_t incr, uint32_t flags);
  73. static void cik_rlc_stop(struct radeon_device *rdev);
  74. static void cik_pcie_gen3_enable(struct radeon_device *rdev);
  75. static void cik_program_aspm(struct radeon_device *rdev);
  76. static void cik_init_pg(struct radeon_device *rdev);
  77. static void cik_init_cg(struct radeon_device *rdev);
  78. static void cik_fini_pg(struct radeon_device *rdev);
  79. static void cik_fini_cg(struct radeon_device *rdev);
  80. static void cik_enable_gui_idle_interrupt(struct radeon_device *rdev,
  81. bool enable);
  82. /* get temperature in millidegrees */
  83. int ci_get_temp(struct radeon_device *rdev)
  84. {
  85. u32 temp;
  86. int actual_temp = 0;
  87. temp = (RREG32_SMC(CG_MULT_THERMAL_STATUS) & CTF_TEMP_MASK) >>
  88. CTF_TEMP_SHIFT;
  89. if (temp & 0x200)
  90. actual_temp = 255;
  91. else
  92. actual_temp = temp & 0x1ff;
  93. actual_temp = actual_temp * 1000;
  94. return actual_temp;
  95. }
  96. /* get temperature in millidegrees */
  97. int kv_get_temp(struct radeon_device *rdev)
  98. {
  99. u32 temp;
  100. int actual_temp = 0;
  101. temp = RREG32_SMC(0xC0300E0C);
  102. if (temp)
  103. actual_temp = (temp / 8) - 49;
  104. else
  105. actual_temp = 0;
  106. actual_temp = actual_temp * 1000;
  107. return actual_temp;
  108. }
  109. /*
  110. * Indirect registers accessor
  111. */
  112. u32 cik_pciep_rreg(struct radeon_device *rdev, u32 reg)
  113. {
  114. unsigned long flags;
  115. u32 r;
  116. spin_lock_irqsave(&rdev->pciep_idx_lock, flags);
  117. WREG32(PCIE_INDEX, reg);
  118. (void)RREG32(PCIE_INDEX);
  119. r = RREG32(PCIE_DATA);
  120. spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags);
  121. return r;
  122. }
  123. void cik_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v)
  124. {
  125. unsigned long flags;
  126. spin_lock_irqsave(&rdev->pciep_idx_lock, flags);
  127. WREG32(PCIE_INDEX, reg);
  128. (void)RREG32(PCIE_INDEX);
  129. WREG32(PCIE_DATA, v);
  130. (void)RREG32(PCIE_DATA);
  131. spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags);
  132. }
  133. static const u32 spectre_rlc_save_restore_register_list[] =
  134. {
  135. (0x0e00 << 16) | (0xc12c >> 2),
  136. 0x00000000,
  137. (0x0e00 << 16) | (0xc140 >> 2),
  138. 0x00000000,
  139. (0x0e00 << 16) | (0xc150 >> 2),
  140. 0x00000000,
  141. (0x0e00 << 16) | (0xc15c >> 2),
  142. 0x00000000,
  143. (0x0e00 << 16) | (0xc168 >> 2),
  144. 0x00000000,
  145. (0x0e00 << 16) | (0xc170 >> 2),
  146. 0x00000000,
  147. (0x0e00 << 16) | (0xc178 >> 2),
  148. 0x00000000,
  149. (0x0e00 << 16) | (0xc204 >> 2),
  150. 0x00000000,
  151. (0x0e00 << 16) | (0xc2b4 >> 2),
  152. 0x00000000,
  153. (0x0e00 << 16) | (0xc2b8 >> 2),
  154. 0x00000000,
  155. (0x0e00 << 16) | (0xc2bc >> 2),
  156. 0x00000000,
  157. (0x0e00 << 16) | (0xc2c0 >> 2),
  158. 0x00000000,
  159. (0x0e00 << 16) | (0x8228 >> 2),
  160. 0x00000000,
  161. (0x0e00 << 16) | (0x829c >> 2),
  162. 0x00000000,
  163. (0x0e00 << 16) | (0x869c >> 2),
  164. 0x00000000,
  165. (0x0600 << 16) | (0x98f4 >> 2),
  166. 0x00000000,
  167. (0x0e00 << 16) | (0x98f8 >> 2),
  168. 0x00000000,
  169. (0x0e00 << 16) | (0x9900 >> 2),
  170. 0x00000000,
  171. (0x0e00 << 16) | (0xc260 >> 2),
  172. 0x00000000,
  173. (0x0e00 << 16) | (0x90e8 >> 2),
  174. 0x00000000,
  175. (0x0e00 << 16) | (0x3c000 >> 2),
  176. 0x00000000,
  177. (0x0e00 << 16) | (0x3c00c >> 2),
  178. 0x00000000,
  179. (0x0e00 << 16) | (0x8c1c >> 2),
  180. 0x00000000,
  181. (0x0e00 << 16) | (0x9700 >> 2),
  182. 0x00000000,
  183. (0x0e00 << 16) | (0xcd20 >> 2),
  184. 0x00000000,
  185. (0x4e00 << 16) | (0xcd20 >> 2),
  186. 0x00000000,
  187. (0x5e00 << 16) | (0xcd20 >> 2),
  188. 0x00000000,
  189. (0x6e00 << 16) | (0xcd20 >> 2),
  190. 0x00000000,
  191. (0x7e00 << 16) | (0xcd20 >> 2),
  192. 0x00000000,
  193. (0x8e00 << 16) | (0xcd20 >> 2),
  194. 0x00000000,
  195. (0x9e00 << 16) | (0xcd20 >> 2),
  196. 0x00000000,
  197. (0xae00 << 16) | (0xcd20 >> 2),
  198. 0x00000000,
  199. (0xbe00 << 16) | (0xcd20 >> 2),
  200. 0x00000000,
  201. (0x0e00 << 16) | (0x89bc >> 2),
  202. 0x00000000,
  203. (0x0e00 << 16) | (0x8900 >> 2),
  204. 0x00000000,
  205. 0x3,
  206. (0x0e00 << 16) | (0xc130 >> 2),
  207. 0x00000000,
  208. (0x0e00 << 16) | (0xc134 >> 2),
  209. 0x00000000,
  210. (0x0e00 << 16) | (0xc1fc >> 2),
  211. 0x00000000,
  212. (0x0e00 << 16) | (0xc208 >> 2),
  213. 0x00000000,
  214. (0x0e00 << 16) | (0xc264 >> 2),
  215. 0x00000000,
  216. (0x0e00 << 16) | (0xc268 >> 2),
  217. 0x00000000,
  218. (0x0e00 << 16) | (0xc26c >> 2),
  219. 0x00000000,
  220. (0x0e00 << 16) | (0xc270 >> 2),
  221. 0x00000000,
  222. (0x0e00 << 16) | (0xc274 >> 2),
  223. 0x00000000,
  224. (0x0e00 << 16) | (0xc278 >> 2),
  225. 0x00000000,
  226. (0x0e00 << 16) | (0xc27c >> 2),
  227. 0x00000000,
  228. (0x0e00 << 16) | (0xc280 >> 2),
  229. 0x00000000,
  230. (0x0e00 << 16) | (0xc284 >> 2),
  231. 0x00000000,
  232. (0x0e00 << 16) | (0xc288 >> 2),
  233. 0x00000000,
  234. (0x0e00 << 16) | (0xc28c >> 2),
  235. 0x00000000,
  236. (0x0e00 << 16) | (0xc290 >> 2),
  237. 0x00000000,
  238. (0x0e00 << 16) | (0xc294 >> 2),
  239. 0x00000000,
  240. (0x0e00 << 16) | (0xc298 >> 2),
  241. 0x00000000,
  242. (0x0e00 << 16) | (0xc29c >> 2),
  243. 0x00000000,
  244. (0x0e00 << 16) | (0xc2a0 >> 2),
  245. 0x00000000,
  246. (0x0e00 << 16) | (0xc2a4 >> 2),
  247. 0x00000000,
  248. (0x0e00 << 16) | (0xc2a8 >> 2),
  249. 0x00000000,
  250. (0x0e00 << 16) | (0xc2ac >> 2),
  251. 0x00000000,
  252. (0x0e00 << 16) | (0xc2b0 >> 2),
  253. 0x00000000,
  254. (0x0e00 << 16) | (0x301d0 >> 2),
  255. 0x00000000,
  256. (0x0e00 << 16) | (0x30238 >> 2),
  257. 0x00000000,
  258. (0x0e00 << 16) | (0x30250 >> 2),
  259. 0x00000000,
  260. (0x0e00 << 16) | (0x30254 >> 2),
  261. 0x00000000,
  262. (0x0e00 << 16) | (0x30258 >> 2),
  263. 0x00000000,
  264. (0x0e00 << 16) | (0x3025c >> 2),
  265. 0x00000000,
  266. (0x4e00 << 16) | (0xc900 >> 2),
  267. 0x00000000,
  268. (0x5e00 << 16) | (0xc900 >> 2),
  269. 0x00000000,
  270. (0x6e00 << 16) | (0xc900 >> 2),
  271. 0x00000000,
  272. (0x7e00 << 16) | (0xc900 >> 2),
  273. 0x00000000,
  274. (0x8e00 << 16) | (0xc900 >> 2),
  275. 0x00000000,
  276. (0x9e00 << 16) | (0xc900 >> 2),
  277. 0x00000000,
  278. (0xae00 << 16) | (0xc900 >> 2),
  279. 0x00000000,
  280. (0xbe00 << 16) | (0xc900 >> 2),
  281. 0x00000000,
  282. (0x4e00 << 16) | (0xc904 >> 2),
  283. 0x00000000,
  284. (0x5e00 << 16) | (0xc904 >> 2),
  285. 0x00000000,
  286. (0x6e00 << 16) | (0xc904 >> 2),
  287. 0x00000000,
  288. (0x7e00 << 16) | (0xc904 >> 2),
  289. 0x00000000,
  290. (0x8e00 << 16) | (0xc904 >> 2),
  291. 0x00000000,
  292. (0x9e00 << 16) | (0xc904 >> 2),
  293. 0x00000000,
  294. (0xae00 << 16) | (0xc904 >> 2),
  295. 0x00000000,
  296. (0xbe00 << 16) | (0xc904 >> 2),
  297. 0x00000000,
  298. (0x4e00 << 16) | (0xc908 >> 2),
  299. 0x00000000,
  300. (0x5e00 << 16) | (0xc908 >> 2),
  301. 0x00000000,
  302. (0x6e00 << 16) | (0xc908 >> 2),
  303. 0x00000000,
  304. (0x7e00 << 16) | (0xc908 >> 2),
  305. 0x00000000,
  306. (0x8e00 << 16) | (0xc908 >> 2),
  307. 0x00000000,
  308. (0x9e00 << 16) | (0xc908 >> 2),
  309. 0x00000000,
  310. (0xae00 << 16) | (0xc908 >> 2),
  311. 0x00000000,
  312. (0xbe00 << 16) | (0xc908 >> 2),
  313. 0x00000000,
  314. (0x4e00 << 16) | (0xc90c >> 2),
  315. 0x00000000,
  316. (0x5e00 << 16) | (0xc90c >> 2),
  317. 0x00000000,
  318. (0x6e00 << 16) | (0xc90c >> 2),
  319. 0x00000000,
  320. (0x7e00 << 16) | (0xc90c >> 2),
  321. 0x00000000,
  322. (0x8e00 << 16) | (0xc90c >> 2),
  323. 0x00000000,
  324. (0x9e00 << 16) | (0xc90c >> 2),
  325. 0x00000000,
  326. (0xae00 << 16) | (0xc90c >> 2),
  327. 0x00000000,
  328. (0xbe00 << 16) | (0xc90c >> 2),
  329. 0x00000000,
  330. (0x4e00 << 16) | (0xc910 >> 2),
  331. 0x00000000,
  332. (0x5e00 << 16) | (0xc910 >> 2),
  333. 0x00000000,
  334. (0x6e00 << 16) | (0xc910 >> 2),
  335. 0x00000000,
  336. (0x7e00 << 16) | (0xc910 >> 2),
  337. 0x00000000,
  338. (0x8e00 << 16) | (0xc910 >> 2),
  339. 0x00000000,
  340. (0x9e00 << 16) | (0xc910 >> 2),
  341. 0x00000000,
  342. (0xae00 << 16) | (0xc910 >> 2),
  343. 0x00000000,
  344. (0xbe00 << 16) | (0xc910 >> 2),
  345. 0x00000000,
  346. (0x0e00 << 16) | (0xc99c >> 2),
  347. 0x00000000,
  348. (0x0e00 << 16) | (0x9834 >> 2),
  349. 0x00000000,
  350. (0x0000 << 16) | (0x30f00 >> 2),
  351. 0x00000000,
  352. (0x0001 << 16) | (0x30f00 >> 2),
  353. 0x00000000,
  354. (0x0000 << 16) | (0x30f04 >> 2),
  355. 0x00000000,
  356. (0x0001 << 16) | (0x30f04 >> 2),
  357. 0x00000000,
  358. (0x0000 << 16) | (0x30f08 >> 2),
  359. 0x00000000,
  360. (0x0001 << 16) | (0x30f08 >> 2),
  361. 0x00000000,
  362. (0x0000 << 16) | (0x30f0c >> 2),
  363. 0x00000000,
  364. (0x0001 << 16) | (0x30f0c >> 2),
  365. 0x00000000,
  366. (0x0600 << 16) | (0x9b7c >> 2),
  367. 0x00000000,
  368. (0x0e00 << 16) | (0x8a14 >> 2),
  369. 0x00000000,
  370. (0x0e00 << 16) | (0x8a18 >> 2),
  371. 0x00000000,
  372. (0x0600 << 16) | (0x30a00 >> 2),
  373. 0x00000000,
  374. (0x0e00 << 16) | (0x8bf0 >> 2),
  375. 0x00000000,
  376. (0x0e00 << 16) | (0x8bcc >> 2),
  377. 0x00000000,
  378. (0x0e00 << 16) | (0x8b24 >> 2),
  379. 0x00000000,
  380. (0x0e00 << 16) | (0x30a04 >> 2),
  381. 0x00000000,
  382. (0x0600 << 16) | (0x30a10 >> 2),
  383. 0x00000000,
  384. (0x0600 << 16) | (0x30a14 >> 2),
  385. 0x00000000,
  386. (0x0600 << 16) | (0x30a18 >> 2),
  387. 0x00000000,
  388. (0x0600 << 16) | (0x30a2c >> 2),
  389. 0x00000000,
  390. (0x0e00 << 16) | (0xc700 >> 2),
  391. 0x00000000,
  392. (0x0e00 << 16) | (0xc704 >> 2),
  393. 0x00000000,
  394. (0x0e00 << 16) | (0xc708 >> 2),
  395. 0x00000000,
  396. (0x0e00 << 16) | (0xc768 >> 2),
  397. 0x00000000,
  398. (0x0400 << 16) | (0xc770 >> 2),
  399. 0x00000000,
  400. (0x0400 << 16) | (0xc774 >> 2),
  401. 0x00000000,
  402. (0x0400 << 16) | (0xc778 >> 2),
  403. 0x00000000,
  404. (0x0400 << 16) | (0xc77c >> 2),
  405. 0x00000000,
  406. (0x0400 << 16) | (0xc780 >> 2),
  407. 0x00000000,
  408. (0x0400 << 16) | (0xc784 >> 2),
  409. 0x00000000,
  410. (0x0400 << 16) | (0xc788 >> 2),
  411. 0x00000000,
  412. (0x0400 << 16) | (0xc78c >> 2),
  413. 0x00000000,
  414. (0x0400 << 16) | (0xc798 >> 2),
  415. 0x00000000,
  416. (0x0400 << 16) | (0xc79c >> 2),
  417. 0x00000000,
  418. (0x0400 << 16) | (0xc7a0 >> 2),
  419. 0x00000000,
  420. (0x0400 << 16) | (0xc7a4 >> 2),
  421. 0x00000000,
  422. (0x0400 << 16) | (0xc7a8 >> 2),
  423. 0x00000000,
  424. (0x0400 << 16) | (0xc7ac >> 2),
  425. 0x00000000,
  426. (0x0400 << 16) | (0xc7b0 >> 2),
  427. 0x00000000,
  428. (0x0400 << 16) | (0xc7b4 >> 2),
  429. 0x00000000,
  430. (0x0e00 << 16) | (0x9100 >> 2),
  431. 0x00000000,
  432. (0x0e00 << 16) | (0x3c010 >> 2),
  433. 0x00000000,
  434. (0x0e00 << 16) | (0x92a8 >> 2),
  435. 0x00000000,
  436. (0x0e00 << 16) | (0x92ac >> 2),
  437. 0x00000000,
  438. (0x0e00 << 16) | (0x92b4 >> 2),
  439. 0x00000000,
  440. (0x0e00 << 16) | (0x92b8 >> 2),
  441. 0x00000000,
  442. (0x0e00 << 16) | (0x92bc >> 2),
  443. 0x00000000,
  444. (0x0e00 << 16) | (0x92c0 >> 2),
  445. 0x00000000,
  446. (0x0e00 << 16) | (0x92c4 >> 2),
  447. 0x00000000,
  448. (0x0e00 << 16) | (0x92c8 >> 2),
  449. 0x00000000,
  450. (0x0e00 << 16) | (0x92cc >> 2),
  451. 0x00000000,
  452. (0x0e00 << 16) | (0x92d0 >> 2),
  453. 0x00000000,
  454. (0x0e00 << 16) | (0x8c00 >> 2),
  455. 0x00000000,
  456. (0x0e00 << 16) | (0x8c04 >> 2),
  457. 0x00000000,
  458. (0x0e00 << 16) | (0x8c20 >> 2),
  459. 0x00000000,
  460. (0x0e00 << 16) | (0x8c38 >> 2),
  461. 0x00000000,
  462. (0x0e00 << 16) | (0x8c3c >> 2),
  463. 0x00000000,
  464. (0x0e00 << 16) | (0xae00 >> 2),
  465. 0x00000000,
  466. (0x0e00 << 16) | (0x9604 >> 2),
  467. 0x00000000,
  468. (0x0e00 << 16) | (0xac08 >> 2),
  469. 0x00000000,
  470. (0x0e00 << 16) | (0xac0c >> 2),
  471. 0x00000000,
  472. (0x0e00 << 16) | (0xac10 >> 2),
  473. 0x00000000,
  474. (0x0e00 << 16) | (0xac14 >> 2),
  475. 0x00000000,
  476. (0x0e00 << 16) | (0xac58 >> 2),
  477. 0x00000000,
  478. (0x0e00 << 16) | (0xac68 >> 2),
  479. 0x00000000,
  480. (0x0e00 << 16) | (0xac6c >> 2),
  481. 0x00000000,
  482. (0x0e00 << 16) | (0xac70 >> 2),
  483. 0x00000000,
  484. (0x0e00 << 16) | (0xac74 >> 2),
  485. 0x00000000,
  486. (0x0e00 << 16) | (0xac78 >> 2),
  487. 0x00000000,
  488. (0x0e00 << 16) | (0xac7c >> 2),
  489. 0x00000000,
  490. (0x0e00 << 16) | (0xac80 >> 2),
  491. 0x00000000,
  492. (0x0e00 << 16) | (0xac84 >> 2),
  493. 0x00000000,
  494. (0x0e00 << 16) | (0xac88 >> 2),
  495. 0x00000000,
  496. (0x0e00 << 16) | (0xac8c >> 2),
  497. 0x00000000,
  498. (0x0e00 << 16) | (0x970c >> 2),
  499. 0x00000000,
  500. (0x0e00 << 16) | (0x9714 >> 2),
  501. 0x00000000,
  502. (0x0e00 << 16) | (0x9718 >> 2),
  503. 0x00000000,
  504. (0x0e00 << 16) | (0x971c >> 2),
  505. 0x00000000,
  506. (0x0e00 << 16) | (0x31068 >> 2),
  507. 0x00000000,
  508. (0x4e00 << 16) | (0x31068 >> 2),
  509. 0x00000000,
  510. (0x5e00 << 16) | (0x31068 >> 2),
  511. 0x00000000,
  512. (0x6e00 << 16) | (0x31068 >> 2),
  513. 0x00000000,
  514. (0x7e00 << 16) | (0x31068 >> 2),
  515. 0x00000000,
  516. (0x8e00 << 16) | (0x31068 >> 2),
  517. 0x00000000,
  518. (0x9e00 << 16) | (0x31068 >> 2),
  519. 0x00000000,
  520. (0xae00 << 16) | (0x31068 >> 2),
  521. 0x00000000,
  522. (0xbe00 << 16) | (0x31068 >> 2),
  523. 0x00000000,
  524. (0x0e00 << 16) | (0xcd10 >> 2),
  525. 0x00000000,
  526. (0x0e00 << 16) | (0xcd14 >> 2),
  527. 0x00000000,
  528. (0x0e00 << 16) | (0x88b0 >> 2),
  529. 0x00000000,
  530. (0x0e00 << 16) | (0x88b4 >> 2),
  531. 0x00000000,
  532. (0x0e00 << 16) | (0x88b8 >> 2),
  533. 0x00000000,
  534. (0x0e00 << 16) | (0x88bc >> 2),
  535. 0x00000000,
  536. (0x0400 << 16) | (0x89c0 >> 2),
  537. 0x00000000,
  538. (0x0e00 << 16) | (0x88c4 >> 2),
  539. 0x00000000,
  540. (0x0e00 << 16) | (0x88c8 >> 2),
  541. 0x00000000,
  542. (0x0e00 << 16) | (0x88d0 >> 2),
  543. 0x00000000,
  544. (0x0e00 << 16) | (0x88d4 >> 2),
  545. 0x00000000,
  546. (0x0e00 << 16) | (0x88d8 >> 2),
  547. 0x00000000,
  548. (0x0e00 << 16) | (0x8980 >> 2),
  549. 0x00000000,
  550. (0x0e00 << 16) | (0x30938 >> 2),
  551. 0x00000000,
  552. (0x0e00 << 16) | (0x3093c >> 2),
  553. 0x00000000,
  554. (0x0e00 << 16) | (0x30940 >> 2),
  555. 0x00000000,
  556. (0x0e00 << 16) | (0x89a0 >> 2),
  557. 0x00000000,
  558. (0x0e00 << 16) | (0x30900 >> 2),
  559. 0x00000000,
  560. (0x0e00 << 16) | (0x30904 >> 2),
  561. 0x00000000,
  562. (0x0e00 << 16) | (0x89b4 >> 2),
  563. 0x00000000,
  564. (0x0e00 << 16) | (0x3c210 >> 2),
  565. 0x00000000,
  566. (0x0e00 << 16) | (0x3c214 >> 2),
  567. 0x00000000,
  568. (0x0e00 << 16) | (0x3c218 >> 2),
  569. 0x00000000,
  570. (0x0e00 << 16) | (0x8904 >> 2),
  571. 0x00000000,
  572. 0x5,
  573. (0x0e00 << 16) | (0x8c28 >> 2),
  574. (0x0e00 << 16) | (0x8c2c >> 2),
  575. (0x0e00 << 16) | (0x8c30 >> 2),
  576. (0x0e00 << 16) | (0x8c34 >> 2),
  577. (0x0e00 << 16) | (0x9600 >> 2),
  578. };
  579. static const u32 kalindi_rlc_save_restore_register_list[] =
  580. {
  581. (0x0e00 << 16) | (0xc12c >> 2),
  582. 0x00000000,
  583. (0x0e00 << 16) | (0xc140 >> 2),
  584. 0x00000000,
  585. (0x0e00 << 16) | (0xc150 >> 2),
  586. 0x00000000,
  587. (0x0e00 << 16) | (0xc15c >> 2),
  588. 0x00000000,
  589. (0x0e00 << 16) | (0xc168 >> 2),
  590. 0x00000000,
  591. (0x0e00 << 16) | (0xc170 >> 2),
  592. 0x00000000,
  593. (0x0e00 << 16) | (0xc204 >> 2),
  594. 0x00000000,
  595. (0x0e00 << 16) | (0xc2b4 >> 2),
  596. 0x00000000,
  597. (0x0e00 << 16) | (0xc2b8 >> 2),
  598. 0x00000000,
  599. (0x0e00 << 16) | (0xc2bc >> 2),
  600. 0x00000000,
  601. (0x0e00 << 16) | (0xc2c0 >> 2),
  602. 0x00000000,
  603. (0x0e00 << 16) | (0x8228 >> 2),
  604. 0x00000000,
  605. (0x0e00 << 16) | (0x829c >> 2),
  606. 0x00000000,
  607. (0x0e00 << 16) | (0x869c >> 2),
  608. 0x00000000,
  609. (0x0600 << 16) | (0x98f4 >> 2),
  610. 0x00000000,
  611. (0x0e00 << 16) | (0x98f8 >> 2),
  612. 0x00000000,
  613. (0x0e00 << 16) | (0x9900 >> 2),
  614. 0x00000000,
  615. (0x0e00 << 16) | (0xc260 >> 2),
  616. 0x00000000,
  617. (0x0e00 << 16) | (0x90e8 >> 2),
  618. 0x00000000,
  619. (0x0e00 << 16) | (0x3c000 >> 2),
  620. 0x00000000,
  621. (0x0e00 << 16) | (0x3c00c >> 2),
  622. 0x00000000,
  623. (0x0e00 << 16) | (0x8c1c >> 2),
  624. 0x00000000,
  625. (0x0e00 << 16) | (0x9700 >> 2),
  626. 0x00000000,
  627. (0x0e00 << 16) | (0xcd20 >> 2),
  628. 0x00000000,
  629. (0x4e00 << 16) | (0xcd20 >> 2),
  630. 0x00000000,
  631. (0x5e00 << 16) | (0xcd20 >> 2),
  632. 0x00000000,
  633. (0x6e00 << 16) | (0xcd20 >> 2),
  634. 0x00000000,
  635. (0x7e00 << 16) | (0xcd20 >> 2),
  636. 0x00000000,
  637. (0x0e00 << 16) | (0x89bc >> 2),
  638. 0x00000000,
  639. (0x0e00 << 16) | (0x8900 >> 2),
  640. 0x00000000,
  641. 0x3,
  642. (0x0e00 << 16) | (0xc130 >> 2),
  643. 0x00000000,
  644. (0x0e00 << 16) | (0xc134 >> 2),
  645. 0x00000000,
  646. (0x0e00 << 16) | (0xc1fc >> 2),
  647. 0x00000000,
  648. (0x0e00 << 16) | (0xc208 >> 2),
  649. 0x00000000,
  650. (0x0e00 << 16) | (0xc264 >> 2),
  651. 0x00000000,
  652. (0x0e00 << 16) | (0xc268 >> 2),
  653. 0x00000000,
  654. (0x0e00 << 16) | (0xc26c >> 2),
  655. 0x00000000,
  656. (0x0e00 << 16) | (0xc270 >> 2),
  657. 0x00000000,
  658. (0x0e00 << 16) | (0xc274 >> 2),
  659. 0x00000000,
  660. (0x0e00 << 16) | (0xc28c >> 2),
  661. 0x00000000,
  662. (0x0e00 << 16) | (0xc290 >> 2),
  663. 0x00000000,
  664. (0x0e00 << 16) | (0xc294 >> 2),
  665. 0x00000000,
  666. (0x0e00 << 16) | (0xc298 >> 2),
  667. 0x00000000,
  668. (0x0e00 << 16) | (0xc2a0 >> 2),
  669. 0x00000000,
  670. (0x0e00 << 16) | (0xc2a4 >> 2),
  671. 0x00000000,
  672. (0x0e00 << 16) | (0xc2a8 >> 2),
  673. 0x00000000,
  674. (0x0e00 << 16) | (0xc2ac >> 2),
  675. 0x00000000,
  676. (0x0e00 << 16) | (0x301d0 >> 2),
  677. 0x00000000,
  678. (0x0e00 << 16) | (0x30238 >> 2),
  679. 0x00000000,
  680. (0x0e00 << 16) | (0x30250 >> 2),
  681. 0x00000000,
  682. (0x0e00 << 16) | (0x30254 >> 2),
  683. 0x00000000,
  684. (0x0e00 << 16) | (0x30258 >> 2),
  685. 0x00000000,
  686. (0x0e00 << 16) | (0x3025c >> 2),
  687. 0x00000000,
  688. (0x4e00 << 16) | (0xc900 >> 2),
  689. 0x00000000,
  690. (0x5e00 << 16) | (0xc900 >> 2),
  691. 0x00000000,
  692. (0x6e00 << 16) | (0xc900 >> 2),
  693. 0x00000000,
  694. (0x7e00 << 16) | (0xc900 >> 2),
  695. 0x00000000,
  696. (0x4e00 << 16) | (0xc904 >> 2),
  697. 0x00000000,
  698. (0x5e00 << 16) | (0xc904 >> 2),
  699. 0x00000000,
  700. (0x6e00 << 16) | (0xc904 >> 2),
  701. 0x00000000,
  702. (0x7e00 << 16) | (0xc904 >> 2),
  703. 0x00000000,
  704. (0x4e00 << 16) | (0xc908 >> 2),
  705. 0x00000000,
  706. (0x5e00 << 16) | (0xc908 >> 2),
  707. 0x00000000,
  708. (0x6e00 << 16) | (0xc908 >> 2),
  709. 0x00000000,
  710. (0x7e00 << 16) | (0xc908 >> 2),
  711. 0x00000000,
  712. (0x4e00 << 16) | (0xc90c >> 2),
  713. 0x00000000,
  714. (0x5e00 << 16) | (0xc90c >> 2),
  715. 0x00000000,
  716. (0x6e00 << 16) | (0xc90c >> 2),
  717. 0x00000000,
  718. (0x7e00 << 16) | (0xc90c >> 2),
  719. 0x00000000,
  720. (0x4e00 << 16) | (0xc910 >> 2),
  721. 0x00000000,
  722. (0x5e00 << 16) | (0xc910 >> 2),
  723. 0x00000000,
  724. (0x6e00 << 16) | (0xc910 >> 2),
  725. 0x00000000,
  726. (0x7e00 << 16) | (0xc910 >> 2),
  727. 0x00000000,
  728. (0x0e00 << 16) | (0xc99c >> 2),
  729. 0x00000000,
  730. (0x0e00 << 16) | (0x9834 >> 2),
  731. 0x00000000,
  732. (0x0000 << 16) | (0x30f00 >> 2),
  733. 0x00000000,
  734. (0x0000 << 16) | (0x30f04 >> 2),
  735. 0x00000000,
  736. (0x0000 << 16) | (0x30f08 >> 2),
  737. 0x00000000,
  738. (0x0000 << 16) | (0x30f0c >> 2),
  739. 0x00000000,
  740. (0x0600 << 16) | (0x9b7c >> 2),
  741. 0x00000000,
  742. (0x0e00 << 16) | (0x8a14 >> 2),
  743. 0x00000000,
  744. (0x0e00 << 16) | (0x8a18 >> 2),
  745. 0x00000000,
  746. (0x0600 << 16) | (0x30a00 >> 2),
  747. 0x00000000,
  748. (0x0e00 << 16) | (0x8bf0 >> 2),
  749. 0x00000000,
  750. (0x0e00 << 16) | (0x8bcc >> 2),
  751. 0x00000000,
  752. (0x0e00 << 16) | (0x8b24 >> 2),
  753. 0x00000000,
  754. (0x0e00 << 16) | (0x30a04 >> 2),
  755. 0x00000000,
  756. (0x0600 << 16) | (0x30a10 >> 2),
  757. 0x00000000,
  758. (0x0600 << 16) | (0x30a14 >> 2),
  759. 0x00000000,
  760. (0x0600 << 16) | (0x30a18 >> 2),
  761. 0x00000000,
  762. (0x0600 << 16) | (0x30a2c >> 2),
  763. 0x00000000,
  764. (0x0e00 << 16) | (0xc700 >> 2),
  765. 0x00000000,
  766. (0x0e00 << 16) | (0xc704 >> 2),
  767. 0x00000000,
  768. (0x0e00 << 16) | (0xc708 >> 2),
  769. 0x00000000,
  770. (0x0e00 << 16) | (0xc768 >> 2),
  771. 0x00000000,
  772. (0x0400 << 16) | (0xc770 >> 2),
  773. 0x00000000,
  774. (0x0400 << 16) | (0xc774 >> 2),
  775. 0x00000000,
  776. (0x0400 << 16) | (0xc798 >> 2),
  777. 0x00000000,
  778. (0x0400 << 16) | (0xc79c >> 2),
  779. 0x00000000,
  780. (0x0e00 << 16) | (0x9100 >> 2),
  781. 0x00000000,
  782. (0x0e00 << 16) | (0x3c010 >> 2),
  783. 0x00000000,
  784. (0x0e00 << 16) | (0x8c00 >> 2),
  785. 0x00000000,
  786. (0x0e00 << 16) | (0x8c04 >> 2),
  787. 0x00000000,
  788. (0x0e00 << 16) | (0x8c20 >> 2),
  789. 0x00000000,
  790. (0x0e00 << 16) | (0x8c38 >> 2),
  791. 0x00000000,
  792. (0x0e00 << 16) | (0x8c3c >> 2),
  793. 0x00000000,
  794. (0x0e00 << 16) | (0xae00 >> 2),
  795. 0x00000000,
  796. (0x0e00 << 16) | (0x9604 >> 2),
  797. 0x00000000,
  798. (0x0e00 << 16) | (0xac08 >> 2),
  799. 0x00000000,
  800. (0x0e00 << 16) | (0xac0c >> 2),
  801. 0x00000000,
  802. (0x0e00 << 16) | (0xac10 >> 2),
  803. 0x00000000,
  804. (0x0e00 << 16) | (0xac14 >> 2),
  805. 0x00000000,
  806. (0x0e00 << 16) | (0xac58 >> 2),
  807. 0x00000000,
  808. (0x0e00 << 16) | (0xac68 >> 2),
  809. 0x00000000,
  810. (0x0e00 << 16) | (0xac6c >> 2),
  811. 0x00000000,
  812. (0x0e00 << 16) | (0xac70 >> 2),
  813. 0x00000000,
  814. (0x0e00 << 16) | (0xac74 >> 2),
  815. 0x00000000,
  816. (0x0e00 << 16) | (0xac78 >> 2),
  817. 0x00000000,
  818. (0x0e00 << 16) | (0xac7c >> 2),
  819. 0x00000000,
  820. (0x0e00 << 16) | (0xac80 >> 2),
  821. 0x00000000,
  822. (0x0e00 << 16) | (0xac84 >> 2),
  823. 0x00000000,
  824. (0x0e00 << 16) | (0xac88 >> 2),
  825. 0x00000000,
  826. (0x0e00 << 16) | (0xac8c >> 2),
  827. 0x00000000,
  828. (0x0e00 << 16) | (0x970c >> 2),
  829. 0x00000000,
  830. (0x0e00 << 16) | (0x9714 >> 2),
  831. 0x00000000,
  832. (0x0e00 << 16) | (0x9718 >> 2),
  833. 0x00000000,
  834. (0x0e00 << 16) | (0x971c >> 2),
  835. 0x00000000,
  836. (0x0e00 << 16) | (0x31068 >> 2),
  837. 0x00000000,
  838. (0x4e00 << 16) | (0x31068 >> 2),
  839. 0x00000000,
  840. (0x5e00 << 16) | (0x31068 >> 2),
  841. 0x00000000,
  842. (0x6e00 << 16) | (0x31068 >> 2),
  843. 0x00000000,
  844. (0x7e00 << 16) | (0x31068 >> 2),
  845. 0x00000000,
  846. (0x0e00 << 16) | (0xcd10 >> 2),
  847. 0x00000000,
  848. (0x0e00 << 16) | (0xcd14 >> 2),
  849. 0x00000000,
  850. (0x0e00 << 16) | (0x88b0 >> 2),
  851. 0x00000000,
  852. (0x0e00 << 16) | (0x88b4 >> 2),
  853. 0x00000000,
  854. (0x0e00 << 16) | (0x88b8 >> 2),
  855. 0x00000000,
  856. (0x0e00 << 16) | (0x88bc >> 2),
  857. 0x00000000,
  858. (0x0400 << 16) | (0x89c0 >> 2),
  859. 0x00000000,
  860. (0x0e00 << 16) | (0x88c4 >> 2),
  861. 0x00000000,
  862. (0x0e00 << 16) | (0x88c8 >> 2),
  863. 0x00000000,
  864. (0x0e00 << 16) | (0x88d0 >> 2),
  865. 0x00000000,
  866. (0x0e00 << 16) | (0x88d4 >> 2),
  867. 0x00000000,
  868. (0x0e00 << 16) | (0x88d8 >> 2),
  869. 0x00000000,
  870. (0x0e00 << 16) | (0x8980 >> 2),
  871. 0x00000000,
  872. (0x0e00 << 16) | (0x30938 >> 2),
  873. 0x00000000,
  874. (0x0e00 << 16) | (0x3093c >> 2),
  875. 0x00000000,
  876. (0x0e00 << 16) | (0x30940 >> 2),
  877. 0x00000000,
  878. (0x0e00 << 16) | (0x89a0 >> 2),
  879. 0x00000000,
  880. (0x0e00 << 16) | (0x30900 >> 2),
  881. 0x00000000,
  882. (0x0e00 << 16) | (0x30904 >> 2),
  883. 0x00000000,
  884. (0x0e00 << 16) | (0x89b4 >> 2),
  885. 0x00000000,
  886. (0x0e00 << 16) | (0x3e1fc >> 2),
  887. 0x00000000,
  888. (0x0e00 << 16) | (0x3c210 >> 2),
  889. 0x00000000,
  890. (0x0e00 << 16) | (0x3c214 >> 2),
  891. 0x00000000,
  892. (0x0e00 << 16) | (0x3c218 >> 2),
  893. 0x00000000,
  894. (0x0e00 << 16) | (0x8904 >> 2),
  895. 0x00000000,
  896. 0x5,
  897. (0x0e00 << 16) | (0x8c28 >> 2),
  898. (0x0e00 << 16) | (0x8c2c >> 2),
  899. (0x0e00 << 16) | (0x8c30 >> 2),
  900. (0x0e00 << 16) | (0x8c34 >> 2),
  901. (0x0e00 << 16) | (0x9600 >> 2),
  902. };
  903. static const u32 bonaire_golden_spm_registers[] =
  904. {
  905. 0x30800, 0xe0ffffff, 0xe0000000
  906. };
  907. static const u32 bonaire_golden_common_registers[] =
  908. {
  909. 0xc770, 0xffffffff, 0x00000800,
  910. 0xc774, 0xffffffff, 0x00000800,
  911. 0xc798, 0xffffffff, 0x00007fbf,
  912. 0xc79c, 0xffffffff, 0x00007faf
  913. };
  914. static const u32 bonaire_golden_registers[] =
  915. {
  916. 0x3354, 0x00000333, 0x00000333,
  917. 0x3350, 0x000c0fc0, 0x00040200,
  918. 0x9a10, 0x00010000, 0x00058208,
  919. 0x3c000, 0xffff1fff, 0x00140000,
  920. 0x3c200, 0xfdfc0fff, 0x00000100,
  921. 0x3c234, 0x40000000, 0x40000200,
  922. 0x9830, 0xffffffff, 0x00000000,
  923. 0x9834, 0xf00fffff, 0x00000400,
  924. 0x9838, 0x0002021c, 0x00020200,
  925. 0xc78, 0x00000080, 0x00000000,
  926. 0x5bb0, 0x000000f0, 0x00000070,
  927. 0x5bc0, 0xf0311fff, 0x80300000,
  928. 0x98f8, 0x73773777, 0x12010001,
  929. 0x350c, 0x00810000, 0x408af000,
  930. 0x7030, 0x31000111, 0x00000011,
  931. 0x2f48, 0x73773777, 0x12010001,
  932. 0x220c, 0x00007fb6, 0x0021a1b1,
  933. 0x2210, 0x00007fb6, 0x002021b1,
  934. 0x2180, 0x00007fb6, 0x00002191,
  935. 0x2218, 0x00007fb6, 0x002121b1,
  936. 0x221c, 0x00007fb6, 0x002021b1,
  937. 0x21dc, 0x00007fb6, 0x00002191,
  938. 0x21e0, 0x00007fb6, 0x00002191,
  939. 0x3628, 0x0000003f, 0x0000000a,
  940. 0x362c, 0x0000003f, 0x0000000a,
  941. 0x2ae4, 0x00073ffe, 0x000022a2,
  942. 0x240c, 0x000007ff, 0x00000000,
  943. 0x8a14, 0xf000003f, 0x00000007,
  944. 0x8bf0, 0x00002001, 0x00000001,
  945. 0x8b24, 0xffffffff, 0x00ffffff,
  946. 0x30a04, 0x0000ff0f, 0x00000000,
  947. 0x28a4c, 0x07ffffff, 0x06000000,
  948. 0x4d8, 0x00000fff, 0x00000100,
  949. 0x3e78, 0x00000001, 0x00000002,
  950. 0x9100, 0x03000000, 0x0362c688,
  951. 0x8c00, 0x000000ff, 0x00000001,
  952. 0xe40, 0x00001fff, 0x00001fff,
  953. 0x9060, 0x0000007f, 0x00000020,
  954. 0x9508, 0x00010000, 0x00010000,
  955. 0xac14, 0x000003ff, 0x000000f3,
  956. 0xac0c, 0xffffffff, 0x00001032
  957. };
  958. static const u32 bonaire_mgcg_cgcg_init[] =
  959. {
  960. 0xc420, 0xffffffff, 0xfffffffc,
  961. 0x30800, 0xffffffff, 0xe0000000,
  962. 0x3c2a0, 0xffffffff, 0x00000100,
  963. 0x3c208, 0xffffffff, 0x00000100,
  964. 0x3c2c0, 0xffffffff, 0xc0000100,
  965. 0x3c2c8, 0xffffffff, 0xc0000100,
  966. 0x3c2c4, 0xffffffff, 0xc0000100,
  967. 0x55e4, 0xffffffff, 0x00600100,
  968. 0x3c280, 0xffffffff, 0x00000100,
  969. 0x3c214, 0xffffffff, 0x06000100,
  970. 0x3c220, 0xffffffff, 0x00000100,
  971. 0x3c218, 0xffffffff, 0x06000100,
  972. 0x3c204, 0xffffffff, 0x00000100,
  973. 0x3c2e0, 0xffffffff, 0x00000100,
  974. 0x3c224, 0xffffffff, 0x00000100,
  975. 0x3c200, 0xffffffff, 0x00000100,
  976. 0x3c230, 0xffffffff, 0x00000100,
  977. 0x3c234, 0xffffffff, 0x00000100,
  978. 0x3c250, 0xffffffff, 0x00000100,
  979. 0x3c254, 0xffffffff, 0x00000100,
  980. 0x3c258, 0xffffffff, 0x00000100,
  981. 0x3c25c, 0xffffffff, 0x00000100,
  982. 0x3c260, 0xffffffff, 0x00000100,
  983. 0x3c27c, 0xffffffff, 0x00000100,
  984. 0x3c278, 0xffffffff, 0x00000100,
  985. 0x3c210, 0xffffffff, 0x06000100,
  986. 0x3c290, 0xffffffff, 0x00000100,
  987. 0x3c274, 0xffffffff, 0x00000100,
  988. 0x3c2b4, 0xffffffff, 0x00000100,
  989. 0x3c2b0, 0xffffffff, 0x00000100,
  990. 0x3c270, 0xffffffff, 0x00000100,
  991. 0x30800, 0xffffffff, 0xe0000000,
  992. 0x3c020, 0xffffffff, 0x00010000,
  993. 0x3c024, 0xffffffff, 0x00030002,
  994. 0x3c028, 0xffffffff, 0x00040007,
  995. 0x3c02c, 0xffffffff, 0x00060005,
  996. 0x3c030, 0xffffffff, 0x00090008,
  997. 0x3c034, 0xffffffff, 0x00010000,
  998. 0x3c038, 0xffffffff, 0x00030002,
  999. 0x3c03c, 0xffffffff, 0x00040007,
  1000. 0x3c040, 0xffffffff, 0x00060005,
  1001. 0x3c044, 0xffffffff, 0x00090008,
  1002. 0x3c048, 0xffffffff, 0x00010000,
  1003. 0x3c04c, 0xffffffff, 0x00030002,
  1004. 0x3c050, 0xffffffff, 0x00040007,
  1005. 0x3c054, 0xffffffff, 0x00060005,
  1006. 0x3c058, 0xffffffff, 0x00090008,
  1007. 0x3c05c, 0xffffffff, 0x00010000,
  1008. 0x3c060, 0xffffffff, 0x00030002,
  1009. 0x3c064, 0xffffffff, 0x00040007,
  1010. 0x3c068, 0xffffffff, 0x00060005,
  1011. 0x3c06c, 0xffffffff, 0x00090008,
  1012. 0x3c070, 0xffffffff, 0x00010000,
  1013. 0x3c074, 0xffffffff, 0x00030002,
  1014. 0x3c078, 0xffffffff, 0x00040007,
  1015. 0x3c07c, 0xffffffff, 0x00060005,
  1016. 0x3c080, 0xffffffff, 0x00090008,
  1017. 0x3c084, 0xffffffff, 0x00010000,
  1018. 0x3c088, 0xffffffff, 0x00030002,
  1019. 0x3c08c, 0xffffffff, 0x00040007,
  1020. 0x3c090, 0xffffffff, 0x00060005,
  1021. 0x3c094, 0xffffffff, 0x00090008,
  1022. 0x3c098, 0xffffffff, 0x00010000,
  1023. 0x3c09c, 0xffffffff, 0x00030002,
  1024. 0x3c0a0, 0xffffffff, 0x00040007,
  1025. 0x3c0a4, 0xffffffff, 0x00060005,
  1026. 0x3c0a8, 0xffffffff, 0x00090008,
  1027. 0x3c000, 0xffffffff, 0x96e00200,
  1028. 0x8708, 0xffffffff, 0x00900100,
  1029. 0xc424, 0xffffffff, 0x0020003f,
  1030. 0x38, 0xffffffff, 0x0140001c,
  1031. 0x3c, 0x000f0000, 0x000f0000,
  1032. 0x220, 0xffffffff, 0xC060000C,
  1033. 0x224, 0xc0000fff, 0x00000100,
  1034. 0xf90, 0xffffffff, 0x00000100,
  1035. 0xf98, 0x00000101, 0x00000000,
  1036. 0x20a8, 0xffffffff, 0x00000104,
  1037. 0x55e4, 0xff000fff, 0x00000100,
  1038. 0x30cc, 0xc0000fff, 0x00000104,
  1039. 0xc1e4, 0x00000001, 0x00000001,
  1040. 0xd00c, 0xff000ff0, 0x00000100,
  1041. 0xd80c, 0xff000ff0, 0x00000100
  1042. };
  1043. static const u32 spectre_golden_spm_registers[] =
  1044. {
  1045. 0x30800, 0xe0ffffff, 0xe0000000
  1046. };
  1047. static const u32 spectre_golden_common_registers[] =
  1048. {
  1049. 0xc770, 0xffffffff, 0x00000800,
  1050. 0xc774, 0xffffffff, 0x00000800,
  1051. 0xc798, 0xffffffff, 0x00007fbf,
  1052. 0xc79c, 0xffffffff, 0x00007faf
  1053. };
  1054. static const u32 spectre_golden_registers[] =
  1055. {
  1056. 0x3c000, 0xffff1fff, 0x96940200,
  1057. 0x3c00c, 0xffff0001, 0xff000000,
  1058. 0x3c200, 0xfffc0fff, 0x00000100,
  1059. 0x6ed8, 0x00010101, 0x00010000,
  1060. 0x9834, 0xf00fffff, 0x00000400,
  1061. 0x9838, 0xfffffffc, 0x00020200,
  1062. 0x5bb0, 0x000000f0, 0x00000070,
  1063. 0x5bc0, 0xf0311fff, 0x80300000,
  1064. 0x98f8, 0x73773777, 0x12010001,
  1065. 0x9b7c, 0x00ff0000, 0x00fc0000,
  1066. 0x2f48, 0x73773777, 0x12010001,
  1067. 0x8a14, 0xf000003f, 0x00000007,
  1068. 0x8b24, 0xffffffff, 0x00ffffff,
  1069. 0x28350, 0x3f3f3fff, 0x00000082,
  1070. 0x28355, 0x0000003f, 0x00000000,
  1071. 0x3e78, 0x00000001, 0x00000002,
  1072. 0x913c, 0xffff03df, 0x00000004,
  1073. 0xc768, 0x00000008, 0x00000008,
  1074. 0x8c00, 0x000008ff, 0x00000800,
  1075. 0x9508, 0x00010000, 0x00010000,
  1076. 0xac0c, 0xffffffff, 0x54763210,
  1077. 0x214f8, 0x01ff01ff, 0x00000002,
  1078. 0x21498, 0x007ff800, 0x00200000,
  1079. 0x2015c, 0xffffffff, 0x00000f40,
  1080. 0x30934, 0xffffffff, 0x00000001
  1081. };
  1082. static const u32 spectre_mgcg_cgcg_init[] =
  1083. {
  1084. 0xc420, 0xffffffff, 0xfffffffc,
  1085. 0x30800, 0xffffffff, 0xe0000000,
  1086. 0x3c2a0, 0xffffffff, 0x00000100,
  1087. 0x3c208, 0xffffffff, 0x00000100,
  1088. 0x3c2c0, 0xffffffff, 0x00000100,
  1089. 0x3c2c8, 0xffffffff, 0x00000100,
  1090. 0x3c2c4, 0xffffffff, 0x00000100,
  1091. 0x55e4, 0xffffffff, 0x00600100,
  1092. 0x3c280, 0xffffffff, 0x00000100,
  1093. 0x3c214, 0xffffffff, 0x06000100,
  1094. 0x3c220, 0xffffffff, 0x00000100,
  1095. 0x3c218, 0xffffffff, 0x06000100,
  1096. 0x3c204, 0xffffffff, 0x00000100,
  1097. 0x3c2e0, 0xffffffff, 0x00000100,
  1098. 0x3c224, 0xffffffff, 0x00000100,
  1099. 0x3c200, 0xffffffff, 0x00000100,
  1100. 0x3c230, 0xffffffff, 0x00000100,
  1101. 0x3c234, 0xffffffff, 0x00000100,
  1102. 0x3c250, 0xffffffff, 0x00000100,
  1103. 0x3c254, 0xffffffff, 0x00000100,
  1104. 0x3c258, 0xffffffff, 0x00000100,
  1105. 0x3c25c, 0xffffffff, 0x00000100,
  1106. 0x3c260, 0xffffffff, 0x00000100,
  1107. 0x3c27c, 0xffffffff, 0x00000100,
  1108. 0x3c278, 0xffffffff, 0x00000100,
  1109. 0x3c210, 0xffffffff, 0x06000100,
  1110. 0x3c290, 0xffffffff, 0x00000100,
  1111. 0x3c274, 0xffffffff, 0x00000100,
  1112. 0x3c2b4, 0xffffffff, 0x00000100,
  1113. 0x3c2b0, 0xffffffff, 0x00000100,
  1114. 0x3c270, 0xffffffff, 0x00000100,
  1115. 0x30800, 0xffffffff, 0xe0000000,
  1116. 0x3c020, 0xffffffff, 0x00010000,
  1117. 0x3c024, 0xffffffff, 0x00030002,
  1118. 0x3c028, 0xffffffff, 0x00040007,
  1119. 0x3c02c, 0xffffffff, 0x00060005,
  1120. 0x3c030, 0xffffffff, 0x00090008,
  1121. 0x3c034, 0xffffffff, 0x00010000,
  1122. 0x3c038, 0xffffffff, 0x00030002,
  1123. 0x3c03c, 0xffffffff, 0x00040007,
  1124. 0x3c040, 0xffffffff, 0x00060005,
  1125. 0x3c044, 0xffffffff, 0x00090008,
  1126. 0x3c048, 0xffffffff, 0x00010000,
  1127. 0x3c04c, 0xffffffff, 0x00030002,
  1128. 0x3c050, 0xffffffff, 0x00040007,
  1129. 0x3c054, 0xffffffff, 0x00060005,
  1130. 0x3c058, 0xffffffff, 0x00090008,
  1131. 0x3c05c, 0xffffffff, 0x00010000,
  1132. 0x3c060, 0xffffffff, 0x00030002,
  1133. 0x3c064, 0xffffffff, 0x00040007,
  1134. 0x3c068, 0xffffffff, 0x00060005,
  1135. 0x3c06c, 0xffffffff, 0x00090008,
  1136. 0x3c070, 0xffffffff, 0x00010000,
  1137. 0x3c074, 0xffffffff, 0x00030002,
  1138. 0x3c078, 0xffffffff, 0x00040007,
  1139. 0x3c07c, 0xffffffff, 0x00060005,
  1140. 0x3c080, 0xffffffff, 0x00090008,
  1141. 0x3c084, 0xffffffff, 0x00010000,
  1142. 0x3c088, 0xffffffff, 0x00030002,
  1143. 0x3c08c, 0xffffffff, 0x00040007,
  1144. 0x3c090, 0xffffffff, 0x00060005,
  1145. 0x3c094, 0xffffffff, 0x00090008,
  1146. 0x3c098, 0xffffffff, 0x00010000,
  1147. 0x3c09c, 0xffffffff, 0x00030002,
  1148. 0x3c0a0, 0xffffffff, 0x00040007,
  1149. 0x3c0a4, 0xffffffff, 0x00060005,
  1150. 0x3c0a8, 0xffffffff, 0x00090008,
  1151. 0x3c0ac, 0xffffffff, 0x00010000,
  1152. 0x3c0b0, 0xffffffff, 0x00030002,
  1153. 0x3c0b4, 0xffffffff, 0x00040007,
  1154. 0x3c0b8, 0xffffffff, 0x00060005,
  1155. 0x3c0bc, 0xffffffff, 0x00090008,
  1156. 0x3c000, 0xffffffff, 0x96e00200,
  1157. 0x8708, 0xffffffff, 0x00900100,
  1158. 0xc424, 0xffffffff, 0x0020003f,
  1159. 0x38, 0xffffffff, 0x0140001c,
  1160. 0x3c, 0x000f0000, 0x000f0000,
  1161. 0x220, 0xffffffff, 0xC060000C,
  1162. 0x224, 0xc0000fff, 0x00000100,
  1163. 0xf90, 0xffffffff, 0x00000100,
  1164. 0xf98, 0x00000101, 0x00000000,
  1165. 0x20a8, 0xffffffff, 0x00000104,
  1166. 0x55e4, 0xff000fff, 0x00000100,
  1167. 0x30cc, 0xc0000fff, 0x00000104,
  1168. 0xc1e4, 0x00000001, 0x00000001,
  1169. 0xd00c, 0xff000ff0, 0x00000100,
  1170. 0xd80c, 0xff000ff0, 0x00000100
  1171. };
  1172. static const u32 kalindi_golden_spm_registers[] =
  1173. {
  1174. 0x30800, 0xe0ffffff, 0xe0000000
  1175. };
  1176. static const u32 kalindi_golden_common_registers[] =
  1177. {
  1178. 0xc770, 0xffffffff, 0x00000800,
  1179. 0xc774, 0xffffffff, 0x00000800,
  1180. 0xc798, 0xffffffff, 0x00007fbf,
  1181. 0xc79c, 0xffffffff, 0x00007faf
  1182. };
  1183. static const u32 kalindi_golden_registers[] =
  1184. {
  1185. 0x3c000, 0xffffdfff, 0x6e944040,
  1186. 0x55e4, 0xff607fff, 0xfc000100,
  1187. 0x3c220, 0xff000fff, 0x00000100,
  1188. 0x3c224, 0xff000fff, 0x00000100,
  1189. 0x3c200, 0xfffc0fff, 0x00000100,
  1190. 0x6ed8, 0x00010101, 0x00010000,
  1191. 0x9830, 0xffffffff, 0x00000000,
  1192. 0x9834, 0xf00fffff, 0x00000400,
  1193. 0x5bb0, 0x000000f0, 0x00000070,
  1194. 0x5bc0, 0xf0311fff, 0x80300000,
  1195. 0x98f8, 0x73773777, 0x12010001,
  1196. 0x98fc, 0xffffffff, 0x00000010,
  1197. 0x9b7c, 0x00ff0000, 0x00fc0000,
  1198. 0x8030, 0x00001f0f, 0x0000100a,
  1199. 0x2f48, 0x73773777, 0x12010001,
  1200. 0x2408, 0x000fffff, 0x000c007f,
  1201. 0x8a14, 0xf000003f, 0x00000007,
  1202. 0x8b24, 0x3fff3fff, 0x00ffcfff,
  1203. 0x30a04, 0x0000ff0f, 0x00000000,
  1204. 0x28a4c, 0x07ffffff, 0x06000000,
  1205. 0x4d8, 0x00000fff, 0x00000100,
  1206. 0x3e78, 0x00000001, 0x00000002,
  1207. 0xc768, 0x00000008, 0x00000008,
  1208. 0x8c00, 0x000000ff, 0x00000003,
  1209. 0x214f8, 0x01ff01ff, 0x00000002,
  1210. 0x21498, 0x007ff800, 0x00200000,
  1211. 0x2015c, 0xffffffff, 0x00000f40,
  1212. 0x88c4, 0x001f3ae3, 0x00000082,
  1213. 0x88d4, 0x0000001f, 0x00000010,
  1214. 0x30934, 0xffffffff, 0x00000000
  1215. };
  1216. static const u32 kalindi_mgcg_cgcg_init[] =
  1217. {
  1218. 0xc420, 0xffffffff, 0xfffffffc,
  1219. 0x30800, 0xffffffff, 0xe0000000,
  1220. 0x3c2a0, 0xffffffff, 0x00000100,
  1221. 0x3c208, 0xffffffff, 0x00000100,
  1222. 0x3c2c0, 0xffffffff, 0x00000100,
  1223. 0x3c2c8, 0xffffffff, 0x00000100,
  1224. 0x3c2c4, 0xffffffff, 0x00000100,
  1225. 0x55e4, 0xffffffff, 0x00600100,
  1226. 0x3c280, 0xffffffff, 0x00000100,
  1227. 0x3c214, 0xffffffff, 0x06000100,
  1228. 0x3c220, 0xffffffff, 0x00000100,
  1229. 0x3c218, 0xffffffff, 0x06000100,
  1230. 0x3c204, 0xffffffff, 0x00000100,
  1231. 0x3c2e0, 0xffffffff, 0x00000100,
  1232. 0x3c224, 0xffffffff, 0x00000100,
  1233. 0x3c200, 0xffffffff, 0x00000100,
  1234. 0x3c230, 0xffffffff, 0x00000100,
  1235. 0x3c234, 0xffffffff, 0x00000100,
  1236. 0x3c250, 0xffffffff, 0x00000100,
  1237. 0x3c254, 0xffffffff, 0x00000100,
  1238. 0x3c258, 0xffffffff, 0x00000100,
  1239. 0x3c25c, 0xffffffff, 0x00000100,
  1240. 0x3c260, 0xffffffff, 0x00000100,
  1241. 0x3c27c, 0xffffffff, 0x00000100,
  1242. 0x3c278, 0xffffffff, 0x00000100,
  1243. 0x3c210, 0xffffffff, 0x06000100,
  1244. 0x3c290, 0xffffffff, 0x00000100,
  1245. 0x3c274, 0xffffffff, 0x00000100,
  1246. 0x3c2b4, 0xffffffff, 0x00000100,
  1247. 0x3c2b0, 0xffffffff, 0x00000100,
  1248. 0x3c270, 0xffffffff, 0x00000100,
  1249. 0x30800, 0xffffffff, 0xe0000000,
  1250. 0x3c020, 0xffffffff, 0x00010000,
  1251. 0x3c024, 0xffffffff, 0x00030002,
  1252. 0x3c028, 0xffffffff, 0x00040007,
  1253. 0x3c02c, 0xffffffff, 0x00060005,
  1254. 0x3c030, 0xffffffff, 0x00090008,
  1255. 0x3c034, 0xffffffff, 0x00010000,
  1256. 0x3c038, 0xffffffff, 0x00030002,
  1257. 0x3c03c, 0xffffffff, 0x00040007,
  1258. 0x3c040, 0xffffffff, 0x00060005,
  1259. 0x3c044, 0xffffffff, 0x00090008,
  1260. 0x3c000, 0xffffffff, 0x96e00200,
  1261. 0x8708, 0xffffffff, 0x00900100,
  1262. 0xc424, 0xffffffff, 0x0020003f,
  1263. 0x38, 0xffffffff, 0x0140001c,
  1264. 0x3c, 0x000f0000, 0x000f0000,
  1265. 0x220, 0xffffffff, 0xC060000C,
  1266. 0x224, 0xc0000fff, 0x00000100,
  1267. 0x20a8, 0xffffffff, 0x00000104,
  1268. 0x55e4, 0xff000fff, 0x00000100,
  1269. 0x30cc, 0xc0000fff, 0x00000104,
  1270. 0xc1e4, 0x00000001, 0x00000001,
  1271. 0xd00c, 0xff000ff0, 0x00000100,
  1272. 0xd80c, 0xff000ff0, 0x00000100
  1273. };
  1274. static void cik_init_golden_registers(struct radeon_device *rdev)
  1275. {
  1276. switch (rdev->family) {
  1277. case CHIP_BONAIRE:
  1278. radeon_program_register_sequence(rdev,
  1279. bonaire_mgcg_cgcg_init,
  1280. (const u32)ARRAY_SIZE(bonaire_mgcg_cgcg_init));
  1281. radeon_program_register_sequence(rdev,
  1282. bonaire_golden_registers,
  1283. (const u32)ARRAY_SIZE(bonaire_golden_registers));
  1284. radeon_program_register_sequence(rdev,
  1285. bonaire_golden_common_registers,
  1286. (const u32)ARRAY_SIZE(bonaire_golden_common_registers));
  1287. radeon_program_register_sequence(rdev,
  1288. bonaire_golden_spm_registers,
  1289. (const u32)ARRAY_SIZE(bonaire_golden_spm_registers));
  1290. break;
  1291. case CHIP_KABINI:
  1292. radeon_program_register_sequence(rdev,
  1293. kalindi_mgcg_cgcg_init,
  1294. (const u32)ARRAY_SIZE(kalindi_mgcg_cgcg_init));
  1295. radeon_program_register_sequence(rdev,
  1296. kalindi_golden_registers,
  1297. (const u32)ARRAY_SIZE(kalindi_golden_registers));
  1298. radeon_program_register_sequence(rdev,
  1299. kalindi_golden_common_registers,
  1300. (const u32)ARRAY_SIZE(kalindi_golden_common_registers));
  1301. radeon_program_register_sequence(rdev,
  1302. kalindi_golden_spm_registers,
  1303. (const u32)ARRAY_SIZE(kalindi_golden_spm_registers));
  1304. break;
  1305. case CHIP_KAVERI:
  1306. radeon_program_register_sequence(rdev,
  1307. spectre_mgcg_cgcg_init,
  1308. (const u32)ARRAY_SIZE(spectre_mgcg_cgcg_init));
  1309. radeon_program_register_sequence(rdev,
  1310. spectre_golden_registers,
  1311. (const u32)ARRAY_SIZE(spectre_golden_registers));
  1312. radeon_program_register_sequence(rdev,
  1313. spectre_golden_common_registers,
  1314. (const u32)ARRAY_SIZE(spectre_golden_common_registers));
  1315. radeon_program_register_sequence(rdev,
  1316. spectre_golden_spm_registers,
  1317. (const u32)ARRAY_SIZE(spectre_golden_spm_registers));
  1318. break;
  1319. default:
  1320. break;
  1321. }
  1322. }
  1323. /**
  1324. * cik_get_xclk - get the xclk
  1325. *
  1326. * @rdev: radeon_device pointer
  1327. *
  1328. * Returns the reference clock used by the gfx engine
  1329. * (CIK).
  1330. */
  1331. u32 cik_get_xclk(struct radeon_device *rdev)
  1332. {
  1333. u32 reference_clock = rdev->clock.spll.reference_freq;
  1334. if (rdev->flags & RADEON_IS_IGP) {
  1335. if (RREG32_SMC(GENERAL_PWRMGT) & GPU_COUNTER_CLK)
  1336. return reference_clock / 2;
  1337. } else {
  1338. if (RREG32_SMC(CG_CLKPIN_CNTL) & XTALIN_DIVIDE)
  1339. return reference_clock / 4;
  1340. }
  1341. return reference_clock;
  1342. }
  1343. /**
  1344. * cik_mm_rdoorbell - read a doorbell dword
  1345. *
  1346. * @rdev: radeon_device pointer
  1347. * @offset: byte offset into the aperture
  1348. *
  1349. * Returns the value in the doorbell aperture at the
  1350. * requested offset (CIK).
  1351. */
  1352. u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 offset)
  1353. {
  1354. if (offset < rdev->doorbell.size) {
  1355. return readl(((void __iomem *)rdev->doorbell.ptr) + offset);
  1356. } else {
  1357. DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", offset);
  1358. return 0;
  1359. }
  1360. }
  1361. /**
  1362. * cik_mm_wdoorbell - write a doorbell dword
  1363. *
  1364. * @rdev: radeon_device pointer
  1365. * @offset: byte offset into the aperture
  1366. * @v: value to write
  1367. *
  1368. * Writes @v to the doorbell aperture at the
  1369. * requested offset (CIK).
  1370. */
  1371. void cik_mm_wdoorbell(struct radeon_device *rdev, u32 offset, u32 v)
  1372. {
  1373. if (offset < rdev->doorbell.size) {
  1374. writel(v, ((void __iomem *)rdev->doorbell.ptr) + offset);
  1375. } else {
  1376. DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", offset);
  1377. }
  1378. }
  1379. #define BONAIRE_IO_MC_REGS_SIZE 36
  1380. static const u32 bonaire_io_mc_regs[BONAIRE_IO_MC_REGS_SIZE][2] =
  1381. {
  1382. {0x00000070, 0x04400000},
  1383. {0x00000071, 0x80c01803},
  1384. {0x00000072, 0x00004004},
  1385. {0x00000073, 0x00000100},
  1386. {0x00000074, 0x00ff0000},
  1387. {0x00000075, 0x34000000},
  1388. {0x00000076, 0x08000014},
  1389. {0x00000077, 0x00cc08ec},
  1390. {0x00000078, 0x00000400},
  1391. {0x00000079, 0x00000000},
  1392. {0x0000007a, 0x04090000},
  1393. {0x0000007c, 0x00000000},
  1394. {0x0000007e, 0x4408a8e8},
  1395. {0x0000007f, 0x00000304},
  1396. {0x00000080, 0x00000000},
  1397. {0x00000082, 0x00000001},
  1398. {0x00000083, 0x00000002},
  1399. {0x00000084, 0xf3e4f400},
  1400. {0x00000085, 0x052024e3},
  1401. {0x00000087, 0x00000000},
  1402. {0x00000088, 0x01000000},
  1403. {0x0000008a, 0x1c0a0000},
  1404. {0x0000008b, 0xff010000},
  1405. {0x0000008d, 0xffffefff},
  1406. {0x0000008e, 0xfff3efff},
  1407. {0x0000008f, 0xfff3efbf},
  1408. {0x00000092, 0xf7ffffff},
  1409. {0x00000093, 0xffffff7f},
  1410. {0x00000095, 0x00101101},
  1411. {0x00000096, 0x00000fff},
  1412. {0x00000097, 0x00116fff},
  1413. {0x00000098, 0x60010000},
  1414. {0x00000099, 0x10010000},
  1415. {0x0000009a, 0x00006000},
  1416. {0x0000009b, 0x00001000},
  1417. {0x0000009f, 0x00b48000}
  1418. };
  1419. /**
  1420. * cik_srbm_select - select specific register instances
  1421. *
  1422. * @rdev: radeon_device pointer
  1423. * @me: selected ME (micro engine)
  1424. * @pipe: pipe
  1425. * @queue: queue
  1426. * @vmid: VMID
  1427. *
  1428. * Switches the currently active registers instances. Some
  1429. * registers are instanced per VMID, others are instanced per
  1430. * me/pipe/queue combination.
  1431. */
  1432. static void cik_srbm_select(struct radeon_device *rdev,
  1433. u32 me, u32 pipe, u32 queue, u32 vmid)
  1434. {
  1435. u32 srbm_gfx_cntl = (PIPEID(pipe & 0x3) |
  1436. MEID(me & 0x3) |
  1437. VMID(vmid & 0xf) |
  1438. QUEUEID(queue & 0x7));
  1439. WREG32(SRBM_GFX_CNTL, srbm_gfx_cntl);
  1440. }
  1441. /* ucode loading */
  1442. /**
  1443. * ci_mc_load_microcode - load MC ucode into the hw
  1444. *
  1445. * @rdev: radeon_device pointer
  1446. *
  1447. * Load the GDDR MC ucode into the hw (CIK).
  1448. * Returns 0 on success, error on failure.
  1449. */
  1450. static int ci_mc_load_microcode(struct radeon_device *rdev)
  1451. {
  1452. const __be32 *fw_data;
  1453. u32 running, blackout = 0;
  1454. u32 *io_mc_regs;
  1455. int i, ucode_size, regs_size;
  1456. if (!rdev->mc_fw)
  1457. return -EINVAL;
  1458. switch (rdev->family) {
  1459. case CHIP_BONAIRE:
  1460. default:
  1461. io_mc_regs = (u32 *)&bonaire_io_mc_regs;
  1462. ucode_size = CIK_MC_UCODE_SIZE;
  1463. regs_size = BONAIRE_IO_MC_REGS_SIZE;
  1464. break;
  1465. }
  1466. running = RREG32(MC_SEQ_SUP_CNTL) & RUN_MASK;
  1467. if (running == 0) {
  1468. if (running) {
  1469. blackout = RREG32(MC_SHARED_BLACKOUT_CNTL);
  1470. WREG32(MC_SHARED_BLACKOUT_CNTL, blackout | 1);
  1471. }
  1472. /* reset the engine and set to writable */
  1473. WREG32(MC_SEQ_SUP_CNTL, 0x00000008);
  1474. WREG32(MC_SEQ_SUP_CNTL, 0x00000010);
  1475. /* load mc io regs */
  1476. for (i = 0; i < regs_size; i++) {
  1477. WREG32(MC_SEQ_IO_DEBUG_INDEX, io_mc_regs[(i << 1)]);
  1478. WREG32(MC_SEQ_IO_DEBUG_DATA, io_mc_regs[(i << 1) + 1]);
  1479. }
  1480. /* load the MC ucode */
  1481. fw_data = (const __be32 *)rdev->mc_fw->data;
  1482. for (i = 0; i < ucode_size; i++)
  1483. WREG32(MC_SEQ_SUP_PGM, be32_to_cpup(fw_data++));
  1484. /* put the engine back into the active state */
  1485. WREG32(MC_SEQ_SUP_CNTL, 0x00000008);
  1486. WREG32(MC_SEQ_SUP_CNTL, 0x00000004);
  1487. WREG32(MC_SEQ_SUP_CNTL, 0x00000001);
  1488. /* wait for training to complete */
  1489. for (i = 0; i < rdev->usec_timeout; i++) {
  1490. if (RREG32(MC_SEQ_TRAIN_WAKEUP_CNTL) & TRAIN_DONE_D0)
  1491. break;
  1492. udelay(1);
  1493. }
  1494. for (i = 0; i < rdev->usec_timeout; i++) {
  1495. if (RREG32(MC_SEQ_TRAIN_WAKEUP_CNTL) & TRAIN_DONE_D1)
  1496. break;
  1497. udelay(1);
  1498. }
  1499. if (running)
  1500. WREG32(MC_SHARED_BLACKOUT_CNTL, blackout);
  1501. }
  1502. return 0;
  1503. }
  1504. /**
  1505. * cik_init_microcode - load ucode images from disk
  1506. *
  1507. * @rdev: radeon_device pointer
  1508. *
  1509. * Use the firmware interface to load the ucode images into
  1510. * the driver (not loaded into hw).
  1511. * Returns 0 on success, error on failure.
  1512. */
  1513. static int cik_init_microcode(struct radeon_device *rdev)
  1514. {
  1515. const char *chip_name;
  1516. size_t pfp_req_size, me_req_size, ce_req_size,
  1517. mec_req_size, rlc_req_size, mc_req_size,
  1518. sdma_req_size, smc_req_size;
  1519. char fw_name[30];
  1520. int err;
  1521. DRM_DEBUG("\n");
  1522. switch (rdev->family) {
  1523. case CHIP_BONAIRE:
  1524. chip_name = "BONAIRE";
  1525. pfp_req_size = CIK_PFP_UCODE_SIZE * 4;
  1526. me_req_size = CIK_ME_UCODE_SIZE * 4;
  1527. ce_req_size = CIK_CE_UCODE_SIZE * 4;
  1528. mec_req_size = CIK_MEC_UCODE_SIZE * 4;
  1529. rlc_req_size = BONAIRE_RLC_UCODE_SIZE * 4;
  1530. mc_req_size = CIK_MC_UCODE_SIZE * 4;
  1531. sdma_req_size = CIK_SDMA_UCODE_SIZE * 4;
  1532. smc_req_size = ALIGN(BONAIRE_SMC_UCODE_SIZE, 4);
  1533. break;
  1534. case CHIP_KAVERI:
  1535. chip_name = "KAVERI";
  1536. pfp_req_size = CIK_PFP_UCODE_SIZE * 4;
  1537. me_req_size = CIK_ME_UCODE_SIZE * 4;
  1538. ce_req_size = CIK_CE_UCODE_SIZE * 4;
  1539. mec_req_size = CIK_MEC_UCODE_SIZE * 4;
  1540. rlc_req_size = KV_RLC_UCODE_SIZE * 4;
  1541. sdma_req_size = CIK_SDMA_UCODE_SIZE * 4;
  1542. break;
  1543. case CHIP_KABINI:
  1544. chip_name = "KABINI";
  1545. pfp_req_size = CIK_PFP_UCODE_SIZE * 4;
  1546. me_req_size = CIK_ME_UCODE_SIZE * 4;
  1547. ce_req_size = CIK_CE_UCODE_SIZE * 4;
  1548. mec_req_size = CIK_MEC_UCODE_SIZE * 4;
  1549. rlc_req_size = KB_RLC_UCODE_SIZE * 4;
  1550. sdma_req_size = CIK_SDMA_UCODE_SIZE * 4;
  1551. break;
  1552. default: BUG();
  1553. }
  1554. DRM_INFO("Loading %s Microcode\n", chip_name);
  1555. snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
  1556. err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
  1557. if (err)
  1558. goto out;
  1559. if (rdev->pfp_fw->size != pfp_req_size) {
  1560. printk(KERN_ERR
  1561. "cik_cp: Bogus length %zu in firmware \"%s\"\n",
  1562. rdev->pfp_fw->size, fw_name);
  1563. err = -EINVAL;
  1564. goto out;
  1565. }
  1566. snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
  1567. err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
  1568. if (err)
  1569. goto out;
  1570. if (rdev->me_fw->size != me_req_size) {
  1571. printk(KERN_ERR
  1572. "cik_cp: Bogus length %zu in firmware \"%s\"\n",
  1573. rdev->me_fw->size, fw_name);
  1574. err = -EINVAL;
  1575. }
  1576. snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name);
  1577. err = request_firmware(&rdev->ce_fw, fw_name, rdev->dev);
  1578. if (err)
  1579. goto out;
  1580. if (rdev->ce_fw->size != ce_req_size) {
  1581. printk(KERN_ERR
  1582. "cik_cp: Bogus length %zu in firmware \"%s\"\n",
  1583. rdev->ce_fw->size, fw_name);
  1584. err = -EINVAL;
  1585. }
  1586. snprintf(fw_name, sizeof(fw_name), "radeon/%s_mec.bin", chip_name);
  1587. err = request_firmware(&rdev->mec_fw, fw_name, rdev->dev);
  1588. if (err)
  1589. goto out;
  1590. if (rdev->mec_fw->size != mec_req_size) {
  1591. printk(KERN_ERR
  1592. "cik_cp: Bogus length %zu in firmware \"%s\"\n",
  1593. rdev->mec_fw->size, fw_name);
  1594. err = -EINVAL;
  1595. }
  1596. snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", chip_name);
  1597. err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
  1598. if (err)
  1599. goto out;
  1600. if (rdev->rlc_fw->size != rlc_req_size) {
  1601. printk(KERN_ERR
  1602. "cik_rlc: Bogus length %zu in firmware \"%s\"\n",
  1603. rdev->rlc_fw->size, fw_name);
  1604. err = -EINVAL;
  1605. }
  1606. snprintf(fw_name, sizeof(fw_name), "radeon/%s_sdma.bin", chip_name);
  1607. err = request_firmware(&rdev->sdma_fw, fw_name, rdev->dev);
  1608. if (err)
  1609. goto out;
  1610. if (rdev->sdma_fw->size != sdma_req_size) {
  1611. printk(KERN_ERR
  1612. "cik_sdma: Bogus length %zu in firmware \"%s\"\n",
  1613. rdev->sdma_fw->size, fw_name);
  1614. err = -EINVAL;
  1615. }
  1616. /* No SMC, MC ucode on APUs */
  1617. if (!(rdev->flags & RADEON_IS_IGP)) {
  1618. snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name);
  1619. err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev);
  1620. if (err)
  1621. goto out;
  1622. if (rdev->mc_fw->size != mc_req_size) {
  1623. printk(KERN_ERR
  1624. "cik_mc: Bogus length %zu in firmware \"%s\"\n",
  1625. rdev->mc_fw->size, fw_name);
  1626. err = -EINVAL;
  1627. }
  1628. snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
  1629. err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
  1630. if (err) {
  1631. printk(KERN_ERR
  1632. "smc: error loading firmware \"%s\"\n",
  1633. fw_name);
  1634. release_firmware(rdev->smc_fw);
  1635. rdev->smc_fw = NULL;
  1636. err = 0;
  1637. } else if (rdev->smc_fw->size != smc_req_size) {
  1638. printk(KERN_ERR
  1639. "cik_smc: Bogus length %zu in firmware \"%s\"\n",
  1640. rdev->smc_fw->size, fw_name);
  1641. err = -EINVAL;
  1642. }
  1643. }
  1644. out:
  1645. if (err) {
  1646. if (err != -EINVAL)
  1647. printk(KERN_ERR
  1648. "cik_cp: Failed to load firmware \"%s\"\n",
  1649. fw_name);
  1650. release_firmware(rdev->pfp_fw);
  1651. rdev->pfp_fw = NULL;
  1652. release_firmware(rdev->me_fw);
  1653. rdev->me_fw = NULL;
  1654. release_firmware(rdev->ce_fw);
  1655. rdev->ce_fw = NULL;
  1656. release_firmware(rdev->rlc_fw);
  1657. rdev->rlc_fw = NULL;
  1658. release_firmware(rdev->mc_fw);
  1659. rdev->mc_fw = NULL;
  1660. release_firmware(rdev->smc_fw);
  1661. rdev->smc_fw = NULL;
  1662. }
  1663. return err;
  1664. }
  1665. /*
  1666. * Core functions
  1667. */
  1668. /**
  1669. * cik_tiling_mode_table_init - init the hw tiling table
  1670. *
  1671. * @rdev: radeon_device pointer
  1672. *
  1673. * Starting with SI, the tiling setup is done globally in a
  1674. * set of 32 tiling modes. Rather than selecting each set of
  1675. * parameters per surface as on older asics, we just select
  1676. * which index in the tiling table we want to use, and the
  1677. * surface uses those parameters (CIK).
  1678. */
  1679. static void cik_tiling_mode_table_init(struct radeon_device *rdev)
  1680. {
  1681. const u32 num_tile_mode_states = 32;
  1682. const u32 num_secondary_tile_mode_states = 16;
  1683. u32 reg_offset, gb_tile_moden, split_equal_to_row_size;
  1684. u32 num_pipe_configs;
  1685. u32 num_rbs = rdev->config.cik.max_backends_per_se *
  1686. rdev->config.cik.max_shader_engines;
  1687. switch (rdev->config.cik.mem_row_size_in_kb) {
  1688. case 1:
  1689. split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_1KB;
  1690. break;
  1691. case 2:
  1692. default:
  1693. split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_2KB;
  1694. break;
  1695. case 4:
  1696. split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_4KB;
  1697. break;
  1698. }
  1699. num_pipe_configs = rdev->config.cik.max_tile_pipes;
  1700. if (num_pipe_configs > 8)
  1701. num_pipe_configs = 8; /* ??? */
  1702. if (num_pipe_configs == 8) {
  1703. for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) {
  1704. switch (reg_offset) {
  1705. case 0:
  1706. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1707. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) |
  1708. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1709. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B));
  1710. break;
  1711. case 1:
  1712. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1713. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) |
  1714. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1715. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B));
  1716. break;
  1717. case 2:
  1718. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1719. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) |
  1720. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1721. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B));
  1722. break;
  1723. case 3:
  1724. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1725. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) |
  1726. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1727. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B));
  1728. break;
  1729. case 4:
  1730. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1731. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) |
  1732. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1733. TILE_SPLIT(split_equal_to_row_size));
  1734. break;
  1735. case 5:
  1736. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1737. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1738. break;
  1739. case 6:
  1740. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) |
  1741. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) |
  1742. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1743. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B));
  1744. break;
  1745. case 7:
  1746. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) |
  1747. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) |
  1748. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1749. TILE_SPLIT(split_equal_to_row_size));
  1750. break;
  1751. case 8:
  1752. gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) |
  1753. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16));
  1754. break;
  1755. case 9:
  1756. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1757. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING));
  1758. break;
  1759. case 10:
  1760. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1761. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1762. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1763. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1764. break;
  1765. case 11:
  1766. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |