PageRenderTime 143ms CodeModel.GetById 40ms app.highlight 84ms RepoModel.GetById 1ms app.codeStats 2ms

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

Large files files are truncated, but you can click here to view the full file