| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright 2008 Advanced Micro Devices, Inc. | 
					
						
							|  |  |  |  * Copyright 2008 Red Hat Inc. | 
					
						
							|  |  |  |  * Copyright 2009 Jerome Glisse. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Permission is hereby granted, free of charge, to any person obtaining a | 
					
						
							|  |  |  |  * copy of this software and associated documentation files (the "Software"), | 
					
						
							|  |  |  |  * to deal in the Software without restriction, including without limitation | 
					
						
							|  |  |  |  * the rights to use, copy, modify, merge, publish, distribute, sublicense, | 
					
						
							|  |  |  |  * and/or sell copies of the Software, and to permit persons to whom the | 
					
						
							|  |  |  |  * Software is furnished to do so, subject to the following conditions: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The above copyright notice and this permission notice shall be included in | 
					
						
							|  |  |  |  * all copies or substantial portions of the Software. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
					
						
							|  |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
					
						
							|  |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL | 
					
						
							|  |  |  |  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | 
					
						
							|  |  |  |  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | 
					
						
							|  |  |  |  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 
					
						
							|  |  |  |  * OTHER DEALINGS IN THE SOFTWARE. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Authors: Dave Airlie | 
					
						
							|  |  |  |  *          Alex Deucher | 
					
						
							|  |  |  |  *          Jerome Glisse | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | #include <linux/firmware.h>
 | 
					
						
							|  |  |  | #include <linux/platform_device.h>
 | 
					
						
							| 
									
										
											  
											
												include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files.  percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed.  Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability.  As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
  http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
  only the necessary includes are there.  ie. if only gfp is used,
  gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
  blocks and try to put the new include such that its order conforms
  to its surrounding.  It's put in the include block which contains
  core kernel includes, in the same order that the rest are ordered -
  alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
  doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
  because the file doesn't have fitting include block), it prints out
  an error message indicating which .h file needs to be added to the
  file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
   over 4000 files, deleting around 700 includes and adding ~480 gfp.h
   and ~3000 slab.h inclusions.  The script emitted errors for ~400
   files.
2. Each error was manually checked.  Some didn't need the inclusion,
   some needed manual addition while adding it to implementation .h or
   embedding .c file was more appropriate for others.  This step added
   inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
   from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
   e.g. lib/decompress_*.c used malloc/free() wrappers around slab
   APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
   editing them as sprinkling gfp.h and slab.h inclusions around .h
   files could easily lead to inclusion dependency hell.  Most gfp.h
   inclusion directives were ignored as stuff from gfp.h was usually
   wildly available and often used in preprocessor macros.  Each
   slab.h inclusion directive was examined and added manually as
   necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
   were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
   distributed build env didn't work with gcov compiles) and a few
   more options had to be turned off depending on archs to make things
   build (like ipr on powerpc/64 which failed due to missing writeq).
   * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
   * powerpc and powerpc64 SMP allmodconfig
   * sparc and sparc64 SMP allmodconfig
   * ia64 SMP allmodconfig
   * s390 SMP allmodconfig
   * alpha SMP allmodconfig
   * um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
   a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
											
										 
											2010-03-24 17:04:11 +09:00
										 |  |  | #include <linux/slab.h>
 | 
					
						
							| 
									
										
										
										
											2012-10-02 18:01:07 +01:00
										 |  |  | #include <drm/drmP.h>
 | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | #include "radeon.h"
 | 
					
						
							| 
									
										
										
										
											2010-03-11 21:19:17 +00:00
										 |  |  | #include "radeon_asic.h"
 | 
					
						
							| 
									
										
										
										
											2012-10-02 18:01:07 +01:00
										 |  |  | #include <drm/radeon_drm.h>
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | #include "rv770d.h"
 | 
					
						
							|  |  |  | #include "atom.h"
 | 
					
						
							| 
									
										
										
										
											2009-09-28 18:34:43 +02:00
										 |  |  | #include "avivod.h"
 | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | #define R700_PFP_UCODE_SIZE 848
 | 
					
						
							|  |  |  | #define R700_PM4_UCODE_SIZE 1360
 | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | static void rv770_gpu_init(struct radeon_device *rdev); | 
					
						
							|  |  |  | void rv770_fini(struct radeon_device *rdev); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | static void rv770_pcie_gen2_enable(struct radeon_device *rdev); | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:35 +02:00
										 |  |  | int evergreen_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int rv770_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-29 11:55:02 +02:00
										 |  |  | 	unsigned fb_div = 0, vclk_div = 0, dclk_div = 0; | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:35 +02:00
										 |  |  | 	int r; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* RV740 uses evergreen uvd clk programming */ | 
					
						
							|  |  |  | 	if (rdev->family == CHIP_RV740) | 
					
						
							|  |  |  | 		return evergreen_set_uvd_clocks(rdev, vclk, dclk); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-18 15:25:58 +02:00
										 |  |  | 	/* bypass vclk and dclk with bclk */ | 
					
						
							|  |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL_2, | 
					
						
							|  |  |  | 		 VCLK_SRC_SEL(1) | DCLK_SRC_SEL(1), | 
					
						
							|  |  |  | 		 ~(VCLK_SRC_SEL_MASK | DCLK_SRC_SEL_MASK)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!vclk || !dclk) { | 
					
						
							|  |  |  | 		/* keep the Bypass mode, put PLL to sleep */ | 
					
						
							|  |  |  | 		WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_SLEEP_MASK, ~UPLL_SLEEP_MASK); | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-29 11:55:02 +02:00
										 |  |  | 	r = radeon_uvd_calc_upll_dividers(rdev, vclk, dclk, 50000, 160000, | 
					
						
							|  |  |  | 					  43663, 0x03FFFFFE, 1, 30, ~0, | 
					
						
							|  |  |  | 					  &fb_div, &vclk_div, &dclk_div); | 
					
						
							|  |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	fb_div |= 1; | 
					
						
							|  |  |  | 	vclk_div -= 1; | 
					
						
							|  |  |  | 	dclk_div -= 1; | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:35 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* set UPLL_FB_DIV to 0x50000 */ | 
					
						
							|  |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL_3, UPLL_FB_DIV(0x50000), ~UPLL_FB_DIV_MASK); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-18 15:25:58 +02:00
										 |  |  | 	/* deassert UPLL_RESET and UPLL_SLEEP */ | 
					
						
							|  |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~(UPLL_RESET_MASK | UPLL_SLEEP_MASK)); | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:35 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* assert BYPASS EN and FB_DIV[0] <- ??? why? */ | 
					
						
							|  |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_BYPASS_EN_MASK, ~UPLL_BYPASS_EN_MASK); | 
					
						
							|  |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL_3, UPLL_FB_DIV(1), ~UPLL_FB_DIV(1)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-29 11:55:02 +02:00
										 |  |  | 	r = radeon_uvd_send_upll_ctlreq(rdev, CG_UPLL_FUNC_CNTL); | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:35 +02:00
										 |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* assert PLL_RESET */ | 
					
						
							|  |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_RESET_MASK, ~UPLL_RESET_MASK); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* set the required FB_DIV, REF_DIV, Post divder values */ | 
					
						
							|  |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL, UPLL_REF_DIV(1), ~UPLL_REF_DIV_MASK); | 
					
						
							|  |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL_2, | 
					
						
							| 
									
										
										
										
											2013-04-29 11:55:02 +02:00
										 |  |  | 		 UPLL_SW_HILEN(vclk_div >> 1) | | 
					
						
							|  |  |  | 		 UPLL_SW_LOLEN((vclk_div >> 1) + (vclk_div & 1)) | | 
					
						
							|  |  |  | 		 UPLL_SW_HILEN2(dclk_div >> 1) | | 
					
						
							|  |  |  | 		 UPLL_SW_LOLEN2((dclk_div >> 1) + (dclk_div & 1)), | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:35 +02:00
										 |  |  | 		 ~UPLL_SW_MASK); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-29 11:55:02 +02:00
										 |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL_3, UPLL_FB_DIV(fb_div), | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:35 +02:00
										 |  |  | 		 ~UPLL_FB_DIV_MASK); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* give the PLL some time to settle */ | 
					
						
							|  |  |  | 	mdelay(15); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* deassert PLL_RESET */ | 
					
						
							|  |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_RESET_MASK); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mdelay(15); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* deassert BYPASS EN and FB_DIV[0] <- ??? why? */ | 
					
						
							|  |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL, 0, ~UPLL_BYPASS_EN_MASK); | 
					
						
							|  |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL_3, 0, ~UPLL_FB_DIV(1)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-29 11:55:02 +02:00
										 |  |  | 	r = radeon_uvd_send_upll_ctlreq(rdev, CG_UPLL_FUNC_CNTL); | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:35 +02:00
										 |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* switch VCLK and DCLK selection */ | 
					
						
							|  |  |  | 	WREG32_P(CG_UPLL_FUNC_CNTL_2, | 
					
						
							|  |  |  | 		 VCLK_SRC_SEL(2) | DCLK_SRC_SEL(2), | 
					
						
							|  |  |  | 		 ~(VCLK_SRC_SEL_MASK | DCLK_SRC_SEL_MASK)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mdelay(100); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-26 15:59:47 -05:00
										 |  |  | static const u32 r7xx_golden_registers[] = | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	0x8d00, 0xffffffff, 0x0e0e0074, | 
					
						
							|  |  |  | 	0x8d04, 0xffffffff, 0x013a2b34, | 
					
						
							|  |  |  | 	0x9508, 0xffffffff, 0x00000002, | 
					
						
							|  |  |  | 	0x8b20, 0xffffffff, 0, | 
					
						
							|  |  |  | 	0x88c4, 0xffffffff, 0x000000c2, | 
					
						
							|  |  |  | 	0x28350, 0xffffffff, 0, | 
					
						
							|  |  |  | 	0x9058, 0xffffffff, 0x0fffc40f, | 
					
						
							|  |  |  | 	0x240c, 0xffffffff, 0x00000380, | 
					
						
							|  |  |  | 	0x733c, 0xffffffff, 0x00000002, | 
					
						
							|  |  |  | 	0x2650, 0x00040000, 0, | 
					
						
							|  |  |  | 	0x20bc, 0x00040000, 0, | 
					
						
							|  |  |  | 	0x7300, 0xffffffff, 0x001000f0 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const u32 r7xx_golden_dyn_gpr_registers[] = | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	0x8db0, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8db4, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8db8, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8dbc, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8dc0, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8dc4, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8dc8, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8dcc, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x88c4, 0xffffffff, 0x00000082 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const u32 rv770_golden_registers[] = | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	0x562c, 0xffffffff, 0, | 
					
						
							|  |  |  | 	0x3f90, 0xffffffff, 0, | 
					
						
							|  |  |  | 	0x9148, 0xffffffff, 0, | 
					
						
							|  |  |  | 	0x3f94, 0xffffffff, 0, | 
					
						
							|  |  |  | 	0x914c, 0xffffffff, 0, | 
					
						
							|  |  |  | 	0x9698, 0x18000000, 0x18000000 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const u32 rv770ce_golden_registers[] = | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	0x562c, 0xffffffff, 0, | 
					
						
							|  |  |  | 	0x3f90, 0xffffffff, 0x00cc0000, | 
					
						
							|  |  |  | 	0x9148, 0xffffffff, 0x00cc0000, | 
					
						
							|  |  |  | 	0x3f94, 0xffffffff, 0x00cc0000, | 
					
						
							|  |  |  | 	0x914c, 0xffffffff, 0x00cc0000, | 
					
						
							|  |  |  | 	0x9b7c, 0xffffffff, 0x00fa0000, | 
					
						
							|  |  |  | 	0x3f8c, 0xffffffff, 0x00fa0000, | 
					
						
							|  |  |  | 	0x9698, 0x18000000, 0x18000000 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const u32 rv770_mgcg_init[] = | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	0x8bcc, 0xffffffff, 0x130300f9, | 
					
						
							|  |  |  | 	0x5448, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x55e4, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x160c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x5644, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xc164, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x8a18, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x897c, 0xffffffff, 0x8000100, | 
					
						
							|  |  |  | 	0x8b28, 0xffffffff, 0x3c000100, | 
					
						
							|  |  |  | 	0x9144, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x10000, | 
					
						
							|  |  |  | 	0x9a50, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x10001, | 
					
						
							|  |  |  | 	0x9a50, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x10002, | 
					
						
							|  |  |  | 	0x9a50, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x10003, | 
					
						
							|  |  |  | 	0x9a50, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x9870, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x8d58, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x1, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x2, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x3, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x4, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x5, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x6, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x7, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x8, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x9, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x8000, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x1, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x2, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x3, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x4, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x5, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x6, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x7, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x8, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x9, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x8000, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x1, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x2, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x3, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x4, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x5, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x6, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x7, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x8, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x9, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x80000000, | 
					
						
							|  |  |  | 	0x9030, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9034, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9038, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x903c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9040, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa200, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa204, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa208, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa20c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x971c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x915c, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x9160, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x916c, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x9170, 0xffffffff, 0x00080007, | 
					
						
							|  |  |  | 	0x9174, 0xffffffff, 0x000a0009, | 
					
						
							|  |  |  | 	0x9178, 0xffffffff, 0x000c000b, | 
					
						
							|  |  |  | 	0x917c, 0xffffffff, 0x000e000d, | 
					
						
							|  |  |  | 	0x9180, 0xffffffff, 0x0010000f, | 
					
						
							|  |  |  | 	0x918c, 0xffffffff, 0x00120011, | 
					
						
							|  |  |  | 	0x9190, 0xffffffff, 0x00140013, | 
					
						
							|  |  |  | 	0x9194, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x9198, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x919c, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x91a8, 0xffffffff, 0x00080007, | 
					
						
							|  |  |  | 	0x91ac, 0xffffffff, 0x000a0009, | 
					
						
							|  |  |  | 	0x91b0, 0xffffffff, 0x000c000b, | 
					
						
							|  |  |  | 	0x91b4, 0xffffffff, 0x000e000d, | 
					
						
							|  |  |  | 	0x91b8, 0xffffffff, 0x0010000f, | 
					
						
							|  |  |  | 	0x91c4, 0xffffffff, 0x00120011, | 
					
						
							|  |  |  | 	0x91c8, 0xffffffff, 0x00140013, | 
					
						
							|  |  |  | 	0x91cc, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x91d0, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x91d4, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x91e0, 0xffffffff, 0x00080007, | 
					
						
							|  |  |  | 	0x91e4, 0xffffffff, 0x000a0009, | 
					
						
							|  |  |  | 	0x91e8, 0xffffffff, 0x000c000b, | 
					
						
							|  |  |  | 	0x91ec, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x91f0, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x91f4, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x9200, 0xffffffff, 0x00080007, | 
					
						
							|  |  |  | 	0x9204, 0xffffffff, 0x000a0009, | 
					
						
							|  |  |  | 	0x9208, 0xffffffff, 0x000c000b, | 
					
						
							|  |  |  | 	0x920c, 0xffffffff, 0x000e000d, | 
					
						
							|  |  |  | 	0x9210, 0xffffffff, 0x0010000f, | 
					
						
							|  |  |  | 	0x921c, 0xffffffff, 0x00120011, | 
					
						
							|  |  |  | 	0x9220, 0xffffffff, 0x00140013, | 
					
						
							|  |  |  | 	0x9224, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x9228, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x922c, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x9238, 0xffffffff, 0x00080007, | 
					
						
							|  |  |  | 	0x923c, 0xffffffff, 0x000a0009, | 
					
						
							|  |  |  | 	0x9240, 0xffffffff, 0x000c000b, | 
					
						
							|  |  |  | 	0x9244, 0xffffffff, 0x000e000d, | 
					
						
							|  |  |  | 	0x9248, 0xffffffff, 0x0010000f, | 
					
						
							|  |  |  | 	0x9254, 0xffffffff, 0x00120011, | 
					
						
							|  |  |  | 	0x9258, 0xffffffff, 0x00140013, | 
					
						
							|  |  |  | 	0x925c, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x9260, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x9264, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x9270, 0xffffffff, 0x00080007, | 
					
						
							|  |  |  | 	0x9274, 0xffffffff, 0x000a0009, | 
					
						
							|  |  |  | 	0x9278, 0xffffffff, 0x000c000b, | 
					
						
							|  |  |  | 	0x927c, 0xffffffff, 0x000e000d, | 
					
						
							|  |  |  | 	0x9280, 0xffffffff, 0x0010000f, | 
					
						
							|  |  |  | 	0x928c, 0xffffffff, 0x00120011, | 
					
						
							|  |  |  | 	0x9290, 0xffffffff, 0x00140013, | 
					
						
							|  |  |  | 	0x9294, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x929c, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x92a0, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x92a4, 0xffffffff, 0x00080007 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const u32 rv710_golden_registers[] = | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	0x3f90, 0x00ff0000, 0x00fc0000, | 
					
						
							|  |  |  | 	0x9148, 0x00ff0000, 0x00fc0000, | 
					
						
							|  |  |  | 	0x3f94, 0x00ff0000, 0x00fc0000, | 
					
						
							|  |  |  | 	0x914c, 0x00ff0000, 0x00fc0000, | 
					
						
							|  |  |  | 	0xb4c, 0x00000020, 0x00000020, | 
					
						
							|  |  |  | 	0xa180, 0xffffffff, 0x00003f3f | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const u32 rv710_mgcg_init[] = | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	0x8bcc, 0xffffffff, 0x13030040, | 
					
						
							|  |  |  | 	0x5448, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x55e4, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x160c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x5644, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xc164, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x8a18, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x897c, 0xffffffff, 0x8000100, | 
					
						
							|  |  |  | 	0x8b28, 0xffffffff, 0x3c000100, | 
					
						
							|  |  |  | 	0x9144, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x10000, | 
					
						
							|  |  |  | 	0x9a50, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x9870, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x8d58, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x1, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x8000, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x1, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x8000, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x1, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x80000000, | 
					
						
							|  |  |  | 	0x9030, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9034, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9038, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x903c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9040, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa200, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa204, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa208, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa20c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x971c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x915c, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x9174, 0xffffffff, 0x00000003, | 
					
						
							|  |  |  | 	0x9178, 0xffffffff, 0x00050001, | 
					
						
							|  |  |  | 	0x917c, 0xffffffff, 0x00030002, | 
					
						
							|  |  |  | 	0x918c, 0xffffffff, 0x00000004, | 
					
						
							|  |  |  | 	0x9190, 0xffffffff, 0x00070006, | 
					
						
							|  |  |  | 	0x9194, 0xffffffff, 0x00050001, | 
					
						
							|  |  |  | 	0x9198, 0xffffffff, 0x00030002, | 
					
						
							|  |  |  | 	0x91a8, 0xffffffff, 0x00000004, | 
					
						
							|  |  |  | 	0x91ac, 0xffffffff, 0x00070006, | 
					
						
							|  |  |  | 	0x91e8, 0xffffffff, 0x00000001, | 
					
						
							|  |  |  | 	0x9294, 0xffffffff, 0x00000001, | 
					
						
							|  |  |  | 	0x929c, 0xffffffff, 0x00000002, | 
					
						
							|  |  |  | 	0x92a0, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x9150, 0xffffffff, 0x4d940000 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const u32 rv730_golden_registers[] = | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	0x3f90, 0x00ff0000, 0x00f00000, | 
					
						
							|  |  |  | 	0x9148, 0x00ff0000, 0x00f00000, | 
					
						
							|  |  |  | 	0x3f94, 0x00ff0000, 0x00f00000, | 
					
						
							|  |  |  | 	0x914c, 0x00ff0000, 0x00f00000, | 
					
						
							|  |  |  | 	0x900c, 0xffffffff, 0x003b033f, | 
					
						
							|  |  |  | 	0xb4c, 0x00000020, 0x00000020, | 
					
						
							|  |  |  | 	0xa180, 0xffffffff, 0x00003f3f | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const u32 rv730_mgcg_init[] = | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	0x8bcc, 0xffffffff, 0x130300f9, | 
					
						
							|  |  |  | 	0x5448, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x55e4, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x160c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x5644, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xc164, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x8a18, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x897c, 0xffffffff, 0x8000100, | 
					
						
							|  |  |  | 	0x8b28, 0xffffffff, 0x3c000100, | 
					
						
							|  |  |  | 	0x9144, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x10000, | 
					
						
							|  |  |  | 	0x9a50, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x10001, | 
					
						
							|  |  |  | 	0x9a50, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x9870, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x8d58, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x1, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x2, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x3, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x4, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x5, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x6, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x7, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x8000, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x1, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x2, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x3, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x4, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x5, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x6, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x7, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x8000, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x1, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x2, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x3, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x4, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x5, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x6, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x7, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x80000000, | 
					
						
							|  |  |  | 	0x9030, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9034, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9038, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x903c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9040, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa200, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa204, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa208, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa20c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x971c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x915c, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x916c, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x9170, 0xffffffff, 0x00000005, | 
					
						
							|  |  |  | 	0x9178, 0xffffffff, 0x00050001, | 
					
						
							|  |  |  | 	0x917c, 0xffffffff, 0x00030002, | 
					
						
							|  |  |  | 	0x918c, 0xffffffff, 0x00000004, | 
					
						
							|  |  |  | 	0x9190, 0xffffffff, 0x00070006, | 
					
						
							|  |  |  | 	0x9194, 0xffffffff, 0x00050001, | 
					
						
							|  |  |  | 	0x9198, 0xffffffff, 0x00030002, | 
					
						
							|  |  |  | 	0x91a8, 0xffffffff, 0x00000004, | 
					
						
							|  |  |  | 	0x91ac, 0xffffffff, 0x00070006, | 
					
						
							|  |  |  | 	0x91b0, 0xffffffff, 0x00050001, | 
					
						
							|  |  |  | 	0x91b4, 0xffffffff, 0x00030002, | 
					
						
							|  |  |  | 	0x91c4, 0xffffffff, 0x00000004, | 
					
						
							|  |  |  | 	0x91c8, 0xffffffff, 0x00070006, | 
					
						
							|  |  |  | 	0x91cc, 0xffffffff, 0x00050001, | 
					
						
							|  |  |  | 	0x91d0, 0xffffffff, 0x00030002, | 
					
						
							|  |  |  | 	0x91e0, 0xffffffff, 0x00000004, | 
					
						
							|  |  |  | 	0x91e4, 0xffffffff, 0x00070006, | 
					
						
							|  |  |  | 	0x91e8, 0xffffffff, 0x00000001, | 
					
						
							|  |  |  | 	0x91ec, 0xffffffff, 0x00050001, | 
					
						
							|  |  |  | 	0x91f0, 0xffffffff, 0x00030002, | 
					
						
							|  |  |  | 	0x9200, 0xffffffff, 0x00000004, | 
					
						
							|  |  |  | 	0x9204, 0xffffffff, 0x00070006, | 
					
						
							|  |  |  | 	0x9208, 0xffffffff, 0x00050001, | 
					
						
							|  |  |  | 	0x920c, 0xffffffff, 0x00030002, | 
					
						
							|  |  |  | 	0x921c, 0xffffffff, 0x00000004, | 
					
						
							|  |  |  | 	0x9220, 0xffffffff, 0x00070006, | 
					
						
							|  |  |  | 	0x9224, 0xffffffff, 0x00050001, | 
					
						
							|  |  |  | 	0x9228, 0xffffffff, 0x00030002, | 
					
						
							|  |  |  | 	0x9238, 0xffffffff, 0x00000004, | 
					
						
							|  |  |  | 	0x923c, 0xffffffff, 0x00070006, | 
					
						
							|  |  |  | 	0x9240, 0xffffffff, 0x00050001, | 
					
						
							|  |  |  | 	0x9244, 0xffffffff, 0x00030002, | 
					
						
							|  |  |  | 	0x9254, 0xffffffff, 0x00000004, | 
					
						
							|  |  |  | 	0x9258, 0xffffffff, 0x00070006, | 
					
						
							|  |  |  | 	0x9294, 0xffffffff, 0x00000001, | 
					
						
							|  |  |  | 	0x929c, 0xffffffff, 0x00000002, | 
					
						
							|  |  |  | 	0x92a0, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x92a4, 0xffffffff, 0x00000005 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const u32 rv740_golden_registers[] = | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	0x88c4, 0xffffffff, 0x00000082, | 
					
						
							|  |  |  | 	0x28a50, 0xfffffffc, 0x00000004, | 
					
						
							|  |  |  | 	0x2650, 0x00040000, 0, | 
					
						
							|  |  |  | 	0x20bc, 0x00040000, 0, | 
					
						
							|  |  |  | 	0x733c, 0xffffffff, 0x00000002, | 
					
						
							|  |  |  | 	0x7300, 0xffffffff, 0x001000f0, | 
					
						
							|  |  |  | 	0x3f90, 0x00ff0000, 0, | 
					
						
							|  |  |  | 	0x9148, 0x00ff0000, 0, | 
					
						
							|  |  |  | 	0x3f94, 0x00ff0000, 0, | 
					
						
							|  |  |  | 	0x914c, 0x00ff0000, 0, | 
					
						
							|  |  |  | 	0x240c, 0xffffffff, 0x00000380, | 
					
						
							|  |  |  | 	0x8a14, 0x00000007, 0x00000007, | 
					
						
							|  |  |  | 	0x8b24, 0xffffffff, 0x00ff0fff, | 
					
						
							|  |  |  | 	0x28a4c, 0xffffffff, 0x00004000, | 
					
						
							|  |  |  | 	0xa180, 0xffffffff, 0x00003f3f, | 
					
						
							|  |  |  | 	0x8d00, 0xffffffff, 0x0e0e003a, | 
					
						
							|  |  |  | 	0x8d04, 0xffffffff, 0x013a0e2a, | 
					
						
							|  |  |  | 	0x8c00, 0xffffffff, 0xe400000f, | 
					
						
							|  |  |  | 	0x8db0, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8db4, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8db8, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8dbc, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8dc0, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8dc4, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8dc8, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x8dcc, 0xffffffff, 0x98989898, | 
					
						
							|  |  |  | 	0x9058, 0xffffffff, 0x0fffc40f, | 
					
						
							|  |  |  | 	0x900c, 0xffffffff, 0x003b033f, | 
					
						
							|  |  |  | 	0x28350, 0xffffffff, 0, | 
					
						
							|  |  |  | 	0x8cf0, 0x1fffffff, 0x08e00420, | 
					
						
							|  |  |  | 	0x9508, 0xffffffff, 0x00000002, | 
					
						
							|  |  |  | 	0x88c4, 0xffffffff, 0x000000c2, | 
					
						
							|  |  |  | 	0x9698, 0x18000000, 0x18000000 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const u32 rv740_mgcg_init[] = | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	0x8bcc, 0xffffffff, 0x13030100, | 
					
						
							|  |  |  | 	0x5448, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x55e4, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x160c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x5644, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xc164, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x8a18, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x897c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x8b28, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9144, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x10000, | 
					
						
							|  |  |  | 	0x9a50, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x10001, | 
					
						
							|  |  |  | 	0x9a50, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x10002, | 
					
						
							|  |  |  | 	0x9a50, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x10003, | 
					
						
							|  |  |  | 	0x9a50, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9a1c, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x9870, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x8d58, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x1, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x2, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x3, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x4, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x5, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x6, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x7, | 
					
						
							|  |  |  | 	0x9510, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9500, 0xffffffff, 0x8000, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x1, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x2, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x3, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x4, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x5, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x6, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x7, | 
					
						
							|  |  |  | 	0x949c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9490, 0xffffffff, 0x8000, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x0, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x1, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x2, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x3, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x4, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x5, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x6, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x7, | 
					
						
							|  |  |  | 	0x9654, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9604, 0xffffffff, 0x80000000, | 
					
						
							|  |  |  | 	0x9030, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9034, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9038, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x903c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x9040, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa200, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa204, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa208, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0xa20c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x971c, 0xffffffff, 0x100, | 
					
						
							|  |  |  | 	0x915c, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x9160, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x916c, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x9170, 0xffffffff, 0x00080007, | 
					
						
							|  |  |  | 	0x9174, 0xffffffff, 0x000a0009, | 
					
						
							|  |  |  | 	0x9178, 0xffffffff, 0x000c000b, | 
					
						
							|  |  |  | 	0x917c, 0xffffffff, 0x000e000d, | 
					
						
							|  |  |  | 	0x9180, 0xffffffff, 0x0010000f, | 
					
						
							|  |  |  | 	0x918c, 0xffffffff, 0x00120011, | 
					
						
							|  |  |  | 	0x9190, 0xffffffff, 0x00140013, | 
					
						
							|  |  |  | 	0x9194, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x9198, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x919c, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x91a8, 0xffffffff, 0x00080007, | 
					
						
							|  |  |  | 	0x91ac, 0xffffffff, 0x000a0009, | 
					
						
							|  |  |  | 	0x91b0, 0xffffffff, 0x000c000b, | 
					
						
							|  |  |  | 	0x91b4, 0xffffffff, 0x000e000d, | 
					
						
							|  |  |  | 	0x91b8, 0xffffffff, 0x0010000f, | 
					
						
							|  |  |  | 	0x91c4, 0xffffffff, 0x00120011, | 
					
						
							|  |  |  | 	0x91c8, 0xffffffff, 0x00140013, | 
					
						
							|  |  |  | 	0x91cc, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x91d0, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x91d4, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x91e0, 0xffffffff, 0x00080007, | 
					
						
							|  |  |  | 	0x91e4, 0xffffffff, 0x000a0009, | 
					
						
							|  |  |  | 	0x91e8, 0xffffffff, 0x000c000b, | 
					
						
							|  |  |  | 	0x91ec, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x91f0, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x91f4, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x9200, 0xffffffff, 0x00080007, | 
					
						
							|  |  |  | 	0x9204, 0xffffffff, 0x000a0009, | 
					
						
							|  |  |  | 	0x9208, 0xffffffff, 0x000c000b, | 
					
						
							|  |  |  | 	0x920c, 0xffffffff, 0x000e000d, | 
					
						
							|  |  |  | 	0x9210, 0xffffffff, 0x0010000f, | 
					
						
							|  |  |  | 	0x921c, 0xffffffff, 0x00120011, | 
					
						
							|  |  |  | 	0x9220, 0xffffffff, 0x00140013, | 
					
						
							|  |  |  | 	0x9224, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x9228, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x922c, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x9238, 0xffffffff, 0x00080007, | 
					
						
							|  |  |  | 	0x923c, 0xffffffff, 0x000a0009, | 
					
						
							|  |  |  | 	0x9240, 0xffffffff, 0x000c000b, | 
					
						
							|  |  |  | 	0x9244, 0xffffffff, 0x000e000d, | 
					
						
							|  |  |  | 	0x9248, 0xffffffff, 0x0010000f, | 
					
						
							|  |  |  | 	0x9254, 0xffffffff, 0x00120011, | 
					
						
							|  |  |  | 	0x9258, 0xffffffff, 0x00140013, | 
					
						
							|  |  |  | 	0x9294, 0xffffffff, 0x00020001, | 
					
						
							|  |  |  | 	0x929c, 0xffffffff, 0x00040003, | 
					
						
							|  |  |  | 	0x92a0, 0xffffffff, 0x00060005, | 
					
						
							|  |  |  | 	0x92a4, 0xffffffff, 0x00080007 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void rv770_init_golden_registers(struct radeon_device *rdev) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	switch (rdev->family) { | 
					
						
							|  |  |  | 	case CHIP_RV770: | 
					
						
							|  |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 r7xx_golden_registers, | 
					
						
							|  |  |  | 						 (const u32)ARRAY_SIZE(r7xx_golden_registers)); | 
					
						
							|  |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 r7xx_golden_dyn_gpr_registers, | 
					
						
							|  |  |  | 						 (const u32)ARRAY_SIZE(r7xx_golden_dyn_gpr_registers)); | 
					
						
							|  |  |  | 		if (rdev->pdev->device == 0x994e) | 
					
						
							|  |  |  | 			radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 							 rv770ce_golden_registers, | 
					
						
							|  |  |  | 							 (const u32)ARRAY_SIZE(rv770ce_golden_registers)); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 							 rv770_golden_registers, | 
					
						
							|  |  |  | 							 (const u32)ARRAY_SIZE(rv770_golden_registers)); | 
					
						
							|  |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 rv770_mgcg_init, | 
					
						
							|  |  |  | 						 (const u32)ARRAY_SIZE(rv770_mgcg_init)); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case CHIP_RV730: | 
					
						
							|  |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 r7xx_golden_registers, | 
					
						
							|  |  |  | 						 (const u32)ARRAY_SIZE(r7xx_golden_registers)); | 
					
						
							|  |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 r7xx_golden_dyn_gpr_registers, | 
					
						
							|  |  |  | 						 (const u32)ARRAY_SIZE(r7xx_golden_dyn_gpr_registers)); | 
					
						
							|  |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 rv730_golden_registers, | 
					
						
							| 
									
										
										
										
											2013-08-13 15:57:32 -04:00
										 |  |  | 						 (const u32)ARRAY_SIZE(rv730_golden_registers)); | 
					
						
							| 
									
										
										
										
											2013-02-26 15:59:47 -05:00
										 |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 rv730_mgcg_init, | 
					
						
							| 
									
										
										
										
											2013-08-13 15:57:32 -04:00
										 |  |  | 						 (const u32)ARRAY_SIZE(rv730_mgcg_init)); | 
					
						
							| 
									
										
										
										
											2013-02-26 15:59:47 -05:00
										 |  |  | 		break; | 
					
						
							|  |  |  | 	case CHIP_RV710: | 
					
						
							|  |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 r7xx_golden_registers, | 
					
						
							|  |  |  | 						 (const u32)ARRAY_SIZE(r7xx_golden_registers)); | 
					
						
							|  |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 r7xx_golden_dyn_gpr_registers, | 
					
						
							|  |  |  | 						 (const u32)ARRAY_SIZE(r7xx_golden_dyn_gpr_registers)); | 
					
						
							|  |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 rv710_golden_registers, | 
					
						
							| 
									
										
										
										
											2013-08-13 15:57:32 -04:00
										 |  |  | 						 (const u32)ARRAY_SIZE(rv710_golden_registers)); | 
					
						
							| 
									
										
										
										
											2013-02-26 15:59:47 -05:00
										 |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 rv710_mgcg_init, | 
					
						
							| 
									
										
										
										
											2013-08-13 15:57:32 -04:00
										 |  |  | 						 (const u32)ARRAY_SIZE(rv710_mgcg_init)); | 
					
						
							| 
									
										
										
										
											2013-02-26 15:59:47 -05:00
										 |  |  | 		break; | 
					
						
							|  |  |  | 	case CHIP_RV740: | 
					
						
							|  |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 rv740_golden_registers, | 
					
						
							| 
									
										
										
										
											2013-08-13 15:57:32 -04:00
										 |  |  | 						 (const u32)ARRAY_SIZE(rv740_golden_registers)); | 
					
						
							| 
									
										
										
										
											2013-02-26 15:59:47 -05:00
										 |  |  | 		radeon_program_register_sequence(rdev, | 
					
						
							|  |  |  | 						 rv740_mgcg_init, | 
					
						
							| 
									
										
										
										
											2013-08-13 15:57:32 -04:00
										 |  |  | 						 (const u32)ARRAY_SIZE(rv740_mgcg_init)); | 
					
						
							| 
									
										
										
										
											2013-02-26 15:59:47 -05:00
										 |  |  | 		break; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-14 10:04:02 -05:00
										 |  |  | #define PCIE_BUS_CLK                10000
 | 
					
						
							|  |  |  | #define TCLK                        (PCIE_BUS_CLK / 10)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * rv770_get_xclk - get the xclk | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @rdev: radeon_device pointer | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Returns the reference clock used by the gfx engine | 
					
						
							|  |  |  |  * (r7xx-cayman). | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | u32 rv770_get_xclk(struct radeon_device *rdev) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u32 reference_clock = rdev->clock.spll.reference_freq; | 
					
						
							|  |  |  | 	u32 tmp = RREG32(CG_CLKPIN_CNTL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (tmp & MUX_TCLK_TO_XCLK) | 
					
						
							|  |  |  | 		return TCLK; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (tmp & XTALIN_DIVIDE) | 
					
						
							|  |  |  | 		return reference_clock / 4; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return reference_clock; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-21 10:59:01 -05:00
										 |  |  | u32 rv770_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id]; | 
					
						
							|  |  |  | 	u32 tmp = RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset); | 
					
						
							| 
									
										
										
										
											2011-11-28 14:49:26 -05:00
										 |  |  | 	int i; | 
					
						
							| 
									
										
										
										
											2010-11-21 10:59:01 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Lock the graphics update lock */ | 
					
						
							|  |  |  | 	tmp |= AVIVO_D1GRPH_UPDATE_LOCK; | 
					
						
							|  |  |  | 	WREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset, tmp); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* update the scanout addresses */ | 
					
						
							|  |  |  | 	if (radeon_crtc->crtc_id) { | 
					
						
							|  |  |  | 		WREG32(D2GRPH_SECONDARY_SURFACE_ADDRESS_HIGH, upper_32_bits(crtc_base)); | 
					
						
							|  |  |  | 		WREG32(D2GRPH_PRIMARY_SURFACE_ADDRESS_HIGH, upper_32_bits(crtc_base)); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		WREG32(D1GRPH_SECONDARY_SURFACE_ADDRESS_HIGH, upper_32_bits(crtc_base)); | 
					
						
							|  |  |  | 		WREG32(D1GRPH_PRIMARY_SURFACE_ADDRESS_HIGH, upper_32_bits(crtc_base)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	WREG32(D1GRPH_SECONDARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, | 
					
						
							|  |  |  | 	       (u32)crtc_base); | 
					
						
							|  |  |  | 	WREG32(D1GRPH_PRIMARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, | 
					
						
							|  |  |  | 	       (u32)crtc_base); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Wait for update_pending to go high. */ | 
					
						
							| 
									
										
										
										
											2011-11-28 14:49:26 -05:00
										 |  |  | 	for (i = 0; i < rdev->usec_timeout; i++) { | 
					
						
							|  |  |  | 		if (RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset) & AVIVO_D1GRPH_SURFACE_UPDATE_PENDING) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		udelay(1); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-11-21 10:59:01 -05:00
										 |  |  | 	DRM_DEBUG("Update pending now high. Unlocking vupdate_lock.\n"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Unlock the lock, so double-buffering can take place inside vblank */ | 
					
						
							|  |  |  | 	tmp &= ~AVIVO_D1GRPH_UPDATE_LOCK; | 
					
						
							|  |  |  | 	WREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset, tmp); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Return current update_pending status: */ | 
					
						
							|  |  |  | 	return RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset) & AVIVO_D1GRPH_SURFACE_UPDATE_PENDING; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-02 12:58:16 -04:00
										 |  |  | /* get temperature in millidegrees */ | 
					
						
							| 
									
										
										
										
											2011-02-01 16:12:34 -05:00
										 |  |  | int rv770_get_temp(struct radeon_device *rdev) | 
					
						
							| 
									
										
										
										
											2010-07-02 12:58:16 -04:00
										 |  |  | { | 
					
						
							|  |  |  | 	u32 temp = (RREG32(CG_MULT_THERMAL_STATUS) & ASIC_T_MASK) >> | 
					
						
							|  |  |  | 		ASIC_T_SHIFT; | 
					
						
							| 
									
										
										
										
											2011-02-01 16:12:34 -05:00
										 |  |  | 	int actual_temp; | 
					
						
							| 
									
										
										
										
											2010-07-02 12:58:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-01 16:12:34 -05:00
										 |  |  | 	if (temp & 0x400) | 
					
						
							|  |  |  | 		actual_temp = -256; | 
					
						
							|  |  |  | 	else if (temp & 0x200) | 
					
						
							|  |  |  | 		actual_temp = 255; | 
					
						
							|  |  |  | 	else if (temp & 0x100) { | 
					
						
							|  |  |  | 		actual_temp = temp & 0x1ff; | 
					
						
							|  |  |  | 		actual_temp |= ~0x1ff; | 
					
						
							|  |  |  | 	} else | 
					
						
							|  |  |  | 		actual_temp = temp & 0xff; | 
					
						
							| 
									
										
										
										
											2010-07-02 12:58:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-01 16:12:34 -05:00
										 |  |  | 	return (actual_temp * 1000) / 2; | 
					
						
							| 
									
										
										
										
											2010-07-02 12:58:16 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-23 17:57:27 -04:00
										 |  |  | void rv770_pm_misc(struct radeon_device *rdev) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-06-07 18:20:25 -04:00
										 |  |  | 	int req_ps_idx = rdev->pm.requested_power_state_index; | 
					
						
							|  |  |  | 	int req_cm_idx = rdev->pm.requested_clock_mode_index; | 
					
						
							|  |  |  | 	struct radeon_power_state *ps = &rdev->pm.power_state[req_ps_idx]; | 
					
						
							|  |  |  | 	struct radeon_voltage *voltage = &ps->clock_info[req_cm_idx].voltage; | 
					
						
							| 
									
										
										
										
											2010-06-07 18:15:18 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if ((voltage->type == VOLTAGE_SW) && voltage->voltage) { | 
					
						
							| 
									
										
										
										
											2011-06-20 13:00:31 -04:00
										 |  |  | 		/* 0xff01 is a flag rather then an actual voltage */ | 
					
						
							|  |  |  | 		if (voltage->voltage == 0xff01) | 
					
						
							|  |  |  | 			return; | 
					
						
							| 
									
										
										
										
											2010-06-07 18:15:18 -04:00
										 |  |  | 		if (voltage->voltage != rdev->pm.current_vddc) { | 
					
						
							| 
									
										
										
										
											2011-04-12 14:49:23 -04:00
										 |  |  | 			radeon_atom_set_voltage(rdev, voltage->voltage, SET_VOLTAGE_TYPE_ASIC_VDDC); | 
					
						
							| 
									
										
										
										
											2010-06-07 18:15:18 -04:00
										 |  |  | 			rdev->pm.current_vddc = voltage->voltage; | 
					
						
							| 
									
										
										
										
											2010-06-07 18:25:21 -04:00
										 |  |  | 			DRM_DEBUG("Setting: v: %d\n", voltage->voltage); | 
					
						
							| 
									
										
										
										
											2010-06-07 18:15:18 -04:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-04-23 17:57:27 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  |  * GART | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-08-31 13:43:50 -04:00
										 |  |  | static int rv770_pcie_gart_enable(struct radeon_device *rdev) | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	u32 tmp; | 
					
						
							|  |  |  | 	int r, i; | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-03 11:16:49 -04:00
										 |  |  | 	if (rdev->gart.robj == NULL) { | 
					
						
							| 
									
										
										
										
											2009-09-14 18:29:49 +02:00
										 |  |  | 		dev_err(rdev->dev, "No VRAM object for PCIE GART.\n"); | 
					
						
							|  |  |  | 		return -EINVAL; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-09-14 18:29:49 +02:00
										 |  |  | 	r = radeon_gart_table_vram_pin(rdev); | 
					
						
							|  |  |  | 	if (r) | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 		return r; | 
					
						
							| 
									
										
										
										
											2010-02-05 16:00:07 +10:00
										 |  |  | 	radeon_gart_restore(rdev); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	/* Setup L2 cache */ | 
					
						
							|  |  |  | 	WREG32(VM_L2_CNTL, ENABLE_L2_CACHE | ENABLE_L2_FRAGMENT_PROCESSING | | 
					
						
							|  |  |  | 				ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE | | 
					
						
							|  |  |  | 				EFFECTIVE_L2_QUEUE_SIZE(7)); | 
					
						
							|  |  |  | 	WREG32(VM_L2_CNTL2, 0); | 
					
						
							|  |  |  | 	WREG32(VM_L2_CNTL3, BANK_SELECT(0) | CACHE_UPDATE_MODE(2)); | 
					
						
							|  |  |  | 	/* Setup TLB control */ | 
					
						
							|  |  |  | 	tmp = ENABLE_L1_TLB | ENABLE_L1_FRAGMENT_PROCESSING | | 
					
						
							|  |  |  | 		SYSTEM_ACCESS_MODE_NOT_IN_SYS | | 
					
						
							|  |  |  | 		SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU | | 
					
						
							|  |  |  | 		EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MD_L1_TLB0_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MD_L1_TLB1_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MD_L1_TLB2_CNTL, tmp); | 
					
						
							| 
									
										
										
										
											2012-05-31 18:54:43 -04:00
										 |  |  | 	if (rdev->family == CHIP_RV740) | 
					
						
							|  |  |  | 		WREG32(MC_VM_MD_L1_TLB3_CNTL, tmp); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	WREG32(MC_VM_MB_L1_TLB0_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MB_L1_TLB3_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR, rdev->mc.gtt_start >> 12); | 
					
						
							| 
									
										
										
										
											2009-10-06 19:04:30 +02:00
										 |  |  | 	WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR, rdev->mc.gtt_end >> 12); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR, rdev->gart.table_addr >> 12); | 
					
						
							|  |  |  | 	WREG32(VM_CONTEXT0_CNTL, ENABLE_CONTEXT | PAGE_TABLE_DEPTH(0) | | 
					
						
							|  |  |  | 				RANGE_PROTECTION_FAULT_ENABLE_DEFAULT); | 
					
						
							|  |  |  | 	WREG32(VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, | 
					
						
							|  |  |  | 			(u32)(rdev->dummy_page.addr >> 12)); | 
					
						
							|  |  |  | 	for (i = 1; i < 7; i++) | 
					
						
							|  |  |  | 		WREG32(VM_CONTEXT0_CNTL + (i * 4), 0); | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	r600_pcie_gart_tlb_flush(rdev); | 
					
						
							| 
									
										
										
										
											2011-08-31 21:54:07 +00:00
										 |  |  | 	DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", | 
					
						
							|  |  |  | 		 (unsigned)(rdev->mc.gtt_size >> 20), | 
					
						
							|  |  |  | 		 (unsigned long long)rdev->gart.table_addr); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	rdev->gart.ready = true; | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-31 13:43:50 -04:00
										 |  |  | static void rv770_pcie_gart_disable(struct radeon_device *rdev) | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	u32 tmp; | 
					
						
							| 
									
										
										
										
											2011-11-03 11:16:49 -04:00
										 |  |  | 	int i; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Disable all tables */ | 
					
						
							|  |  |  | 	for (i = 0; i < 7; i++) | 
					
						
							|  |  |  | 		WREG32(VM_CONTEXT0_CNTL + (i * 4), 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Setup L2 cache */ | 
					
						
							|  |  |  | 	WREG32(VM_L2_CNTL, ENABLE_L2_FRAGMENT_PROCESSING | | 
					
						
							|  |  |  | 				EFFECTIVE_L2_QUEUE_SIZE(7)); | 
					
						
							|  |  |  | 	WREG32(VM_L2_CNTL2, 0); | 
					
						
							|  |  |  | 	WREG32(VM_L2_CNTL3, BANK_SELECT(0) | CACHE_UPDATE_MODE(2)); | 
					
						
							|  |  |  | 	/* Setup TLB control */ | 
					
						
							|  |  |  | 	tmp = EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MD_L1_TLB0_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MD_L1_TLB1_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MD_L1_TLB2_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MB_L1_TLB0_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MB_L1_TLB3_CNTL, tmp); | 
					
						
							| 
									
										
										
										
											2011-11-03 11:16:49 -04:00
										 |  |  | 	radeon_gart_table_vram_unpin(rdev); | 
					
						
							| 
									
										
										
										
											2009-09-14 18:29:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-31 13:43:50 -04:00
										 |  |  | static void rv770_pcie_gart_fini(struct radeon_device *rdev) | 
					
						
							| 
									
										
										
										
											2009-09-14 18:29:49 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-03-17 14:44:29 +00:00
										 |  |  | 	radeon_gart_fini(rdev); | 
					
						
							| 
									
										
										
										
											2009-09-14 18:29:49 +02:00
										 |  |  | 	rv770_pcie_gart_disable(rdev); | 
					
						
							|  |  |  | 	radeon_gart_table_vram_free(rdev); | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-31 13:43:50 -04:00
										 |  |  | static void rv770_agp_enable(struct radeon_device *rdev) | 
					
						
							| 
									
										
										
										
											2009-10-06 19:04:30 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	u32 tmp; | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Setup L2 cache */ | 
					
						
							|  |  |  | 	WREG32(VM_L2_CNTL, ENABLE_L2_CACHE | ENABLE_L2_FRAGMENT_PROCESSING | | 
					
						
							|  |  |  | 				ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE | | 
					
						
							|  |  |  | 				EFFECTIVE_L2_QUEUE_SIZE(7)); | 
					
						
							|  |  |  | 	WREG32(VM_L2_CNTL2, 0); | 
					
						
							|  |  |  | 	WREG32(VM_L2_CNTL3, BANK_SELECT(0) | CACHE_UPDATE_MODE(2)); | 
					
						
							|  |  |  | 	/* Setup TLB control */ | 
					
						
							|  |  |  | 	tmp = ENABLE_L1_TLB | ENABLE_L1_FRAGMENT_PROCESSING | | 
					
						
							|  |  |  | 		SYSTEM_ACCESS_MODE_NOT_IN_SYS | | 
					
						
							|  |  |  | 		SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU | | 
					
						
							|  |  |  | 		EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MD_L1_TLB0_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MD_L1_TLB1_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MD_L1_TLB2_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MB_L1_TLB0_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); | 
					
						
							|  |  |  | 	WREG32(MC_VM_MB_L1_TLB3_CNTL, tmp); | 
					
						
							|  |  |  | 	for (i = 0; i < 7; i++) | 
					
						
							|  |  |  | 		WREG32(VM_CONTEXT0_CNTL + (i * 4), 0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-01 18:02:13 +02:00
										 |  |  | static void rv770_mc_program(struct radeon_device *rdev) | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-01 18:02:13 +02:00
										 |  |  | 	struct rv515_mc_save save; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	u32 tmp; | 
					
						
							|  |  |  | 	int i, j; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Initialize HDP */ | 
					
						
							|  |  |  | 	for (i = 0, j = 0; i < 32; i++, j += 0x18) { | 
					
						
							|  |  |  | 		WREG32((0x2c14 + j), 0x00000000); | 
					
						
							|  |  |  | 		WREG32((0x2c18 + j), 0x00000000); | 
					
						
							|  |  |  | 		WREG32((0x2c1c + j), 0x00000000); | 
					
						
							|  |  |  | 		WREG32((0x2c20 + j), 0x00000000); | 
					
						
							|  |  |  | 		WREG32((0x2c24 + j), 0x00000000); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-07-26 18:51:53 -04:00
										 |  |  | 	/* r7xx hw bug.  Read from HDP_DEBUG1 rather
 | 
					
						
							|  |  |  | 	 * than writing to HDP_REG_COHERENCY_FLUSH_CNTL | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	tmp = RREG32(HDP_DEBUG1); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-01 18:02:13 +02:00
										 |  |  | 	rv515_mc_stop(rdev, &save); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	if (r600_mc_wait_for_idle(rdev)) { | 
					
						
							| 
									
										
										
										
											2009-10-01 18:02:13 +02:00
										 |  |  | 		dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	/* Lockout access through VGA aperture*/ | 
					
						
							|  |  |  | 	WREG32(VGA_HDP_CONTROL, VGA_MEMORY_DISABLE); | 
					
						
							|  |  |  | 	/* Update configuration */ | 
					
						
							| 
									
										
										
										
											2009-10-06 19:04:30 +02:00
										 |  |  | 	if (rdev->flags & RADEON_IS_AGP) { | 
					
						
							|  |  |  | 		if (rdev->mc.vram_start < rdev->mc.gtt_start) { | 
					
						
							|  |  |  | 			/* VRAM before AGP */ | 
					
						
							|  |  |  | 			WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, | 
					
						
							|  |  |  | 				rdev->mc.vram_start >> 12); | 
					
						
							|  |  |  | 			WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, | 
					
						
							|  |  |  | 				rdev->mc.gtt_end >> 12); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			/* VRAM after AGP */ | 
					
						
							|  |  |  | 			WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, | 
					
						
							|  |  |  | 				rdev->mc.gtt_start >> 12); | 
					
						
							|  |  |  | 			WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, | 
					
						
							|  |  |  | 				rdev->mc.vram_end >> 12); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, | 
					
						
							|  |  |  | 			rdev->mc.vram_start >> 12); | 
					
						
							|  |  |  | 		WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, | 
					
						
							|  |  |  | 			rdev->mc.vram_end >> 12); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-10-28 10:30:02 -04:00
										 |  |  | 	WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, rdev->vram_scratch.gpu_addr >> 12); | 
					
						
							| 
									
										
										
										
											2009-10-06 19:04:30 +02:00
										 |  |  | 	tmp = ((rdev->mc.vram_end >> 24) & 0xFFFF) << 16; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	tmp |= ((rdev->mc.vram_start >> 24) & 0xFFFF); | 
					
						
							|  |  |  | 	WREG32(MC_VM_FB_LOCATION, tmp); | 
					
						
							|  |  |  | 	WREG32(HDP_NONSURFACE_BASE, (rdev->mc.vram_start >> 8)); | 
					
						
							|  |  |  | 	WREG32(HDP_NONSURFACE_INFO, (2 << 7)); | 
					
						
							| 
									
										
										
										
											2010-06-03 19:34:48 +02:00
										 |  |  | 	WREG32(HDP_NONSURFACE_SIZE, 0x3FFFFFFF); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	if (rdev->flags & RADEON_IS_AGP) { | 
					
						
							| 
									
										
										
										
											2009-10-06 19:04:30 +02:00
										 |  |  | 		WREG32(MC_VM_AGP_TOP, rdev->mc.gtt_end >> 16); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 		WREG32(MC_VM_AGP_BOT, rdev->mc.gtt_start >> 16); | 
					
						
							|  |  |  | 		WREG32(MC_VM_AGP_BASE, rdev->mc.agp_base >> 22); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		WREG32(MC_VM_AGP_BASE, 0); | 
					
						
							|  |  |  | 		WREG32(MC_VM_AGP_TOP, 0x0FFFFFFF); | 
					
						
							|  |  |  | 		WREG32(MC_VM_AGP_BOT, 0x0FFFFFFF); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (r600_mc_wait_for_idle(rdev)) { | 
					
						
							| 
									
										
										
										
											2009-10-01 18:02:13 +02:00
										 |  |  | 		dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-10-01 18:02:13 +02:00
										 |  |  | 	rv515_mc_resume(rdev, &save); | 
					
						
							| 
									
										
										
										
											2009-09-18 14:16:38 +10:00
										 |  |  | 	/* we need to own VRAM, so turn off the VGA renderer here
 | 
					
						
							|  |  |  | 	 * to stop it overwriting our objects */ | 
					
						
							| 
									
										
										
										
											2009-09-28 18:34:43 +02:00
										 |  |  | 	rv515_vga_render_disable(rdev); | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * CP. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | void r700_cp_stop(struct radeon_device *rdev) | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-01-27 11:26:33 -05:00
										 |  |  | 	if (rdev->asic->copy.copy_ring_index == RADEON_RING_TYPE_GFX_INDEX) | 
					
						
							|  |  |  | 		radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	WREG32(CP_ME_CNTL, (CP_ME_HALT | CP_PFP_HALT)); | 
					
						
							| 
									
										
										
										
											2010-08-27 18:25:25 -04:00
										 |  |  | 	WREG32(SCRATCH_UMSK, 0); | 
					
						
							| 
									
										
										
										
											2012-09-27 15:08:35 -04:00
										 |  |  | 	rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = false; | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | static int rv770_cp_load_microcode(struct radeon_device *rdev) | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	const __be32 *fw_data; | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!rdev->me_fw || !rdev->pfp_fw) | 
					
						
							|  |  |  | 		return -EINVAL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	r700_cp_stop(rdev); | 
					
						
							| 
									
										
										
										
											2011-02-11 19:45:38 -05:00
										 |  |  | 	WREG32(CP_RB_CNTL, | 
					
						
							|  |  |  | #ifdef __BIG_ENDIAN
 | 
					
						
							|  |  |  | 	       BUF_SWAP_32BIT | | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 	       RB_NO_UPDATE | RB_BLKSZ(15) | RB_BUFSZ(3)); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Reset cp */ | 
					
						
							|  |  |  | 	WREG32(GRBM_SOFT_RESET, SOFT_RESET_CP); | 
					
						
							|  |  |  | 	RREG32(GRBM_SOFT_RESET); | 
					
						
							|  |  |  | 	mdelay(15); | 
					
						
							|  |  |  | 	WREG32(GRBM_SOFT_RESET, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	fw_data = (const __be32 *)rdev->pfp_fw->data; | 
					
						
							|  |  |  | 	WREG32(CP_PFP_UCODE_ADDR, 0); | 
					
						
							|  |  |  | 	for (i = 0; i < R700_PFP_UCODE_SIZE; i++) | 
					
						
							|  |  |  | 		WREG32(CP_PFP_UCODE_DATA, be32_to_cpup(fw_data++)); | 
					
						
							|  |  |  | 	WREG32(CP_PFP_UCODE_ADDR, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	fw_data = (const __be32 *)rdev->me_fw->data; | 
					
						
							|  |  |  | 	WREG32(CP_ME_RAM_WADDR, 0); | 
					
						
							|  |  |  | 	for (i = 0; i < R700_PM4_UCODE_SIZE; i++) | 
					
						
							|  |  |  | 		WREG32(CP_ME_RAM_DATA, be32_to_cpup(fw_data++)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(CP_PFP_UCODE_ADDR, 0); | 
					
						
							|  |  |  | 	WREG32(CP_ME_RAM_WADDR, 0); | 
					
						
							|  |  |  | 	WREG32(CP_ME_RAM_RADDR, 0); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-24 13:36:43 -04:00
										 |  |  | void r700_cp_fini(struct radeon_device *rdev) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-07-06 16:22:55 +02:00
										 |  |  | 	struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; | 
					
						
							| 
									
										
										
										
											2010-03-24 13:36:43 -04:00
										 |  |  | 	r700_cp_stop(rdev); | 
					
						
							| 
									
										
										
										
											2012-07-06 16:22:55 +02:00
										 |  |  | 	radeon_ring_fini(rdev, ring); | 
					
						
							|  |  |  | 	radeon_scratch_free(rdev, ring->rptr_save_reg); | 
					
						
							| 
									
										
										
										
											2010-03-24 13:36:43 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-01 19:01:36 -04:00
										 |  |  | void rv770_set_clk_bypass_mode(struct radeon_device *rdev) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u32 tmp, i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (rdev->flags & RADEON_IS_IGP) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tmp = RREG32(CG_SPLL_FUNC_CNTL_2); | 
					
						
							|  |  |  | 	tmp &= SCLK_MUX_SEL_MASK; | 
					
						
							|  |  |  | 	tmp |= SCLK_MUX_SEL(1) | SCLK_MUX_UPDATE; | 
					
						
							|  |  |  | 	WREG32(CG_SPLL_FUNC_CNTL_2, tmp); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (i = 0; i < rdev->usec_timeout; i++) { | 
					
						
							|  |  |  | 		if (RREG32(CG_SPLL_STATUS) & SPLL_CHG_STATUS) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		udelay(1); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tmp &= ~SCLK_MUX_UPDATE; | 
					
						
							|  |  |  | 	WREG32(CG_SPLL_FUNC_CNTL_2, tmp); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tmp = RREG32(MPLL_CNTL_MODE); | 
					
						
							|  |  |  | 	if ((rdev->family == CHIP_RV710) || (rdev->family == CHIP_RV730)) | 
					
						
							|  |  |  | 		tmp &= ~RV730_MPLL_MCLK_SEL; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		tmp &= ~MPLL_MCLK_SEL; | 
					
						
							|  |  |  | 	WREG32(MPLL_CNTL_MODE, tmp); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  |  * Core functions | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | static void rv770_gpu_init(struct radeon_device *rdev) | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	int i, j, num_qd_pipes; | 
					
						
							| 
									
										
										
										
											2010-02-19 16:22:31 -05:00
										 |  |  | 	u32 ta_aux_cntl; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	u32 sx_debug_1; | 
					
						
							|  |  |  | 	u32 smx_dc_ctl0; | 
					
						
							| 
									
										
										
										
											2010-02-19 16:22:31 -05:00
										 |  |  | 	u32 db_debug3; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	u32 num_gs_verts_per_thread; | 
					
						
							|  |  |  | 	u32 vgt_gs_per_es; | 
					
						
							|  |  |  | 	u32 gs_prim_buffer_depth = 0; | 
					
						
							|  |  |  | 	u32 sq_ms_fifo_sizes; | 
					
						
							|  |  |  | 	u32 sq_config; | 
					
						
							|  |  |  | 	u32 sq_thread_resource_mgmt; | 
					
						
							|  |  |  | 	u32 hdp_host_path_cntl; | 
					
						
							|  |  |  | 	u32 sq_dyn_gpr_size_simd_ab_0; | 
					
						
							|  |  |  | 	u32 gb_tiling_config = 0; | 
					
						
							|  |  |  | 	u32 cc_rb_backend_disable = 0; | 
					
						
							|  |  |  | 	u32 cc_gc_shader_pipe_config = 0; | 
					
						
							|  |  |  | 	u32 mc_arb_ramcfg; | 
					
						
							| 
									
										
										
										
											2012-05-31 19:00:25 -04:00
										 |  |  | 	u32 db_debug4, tmp; | 
					
						
							|  |  |  | 	u32 inactive_pipes, shader_pipe_config; | 
					
						
							|  |  |  | 	u32 disabled_rb_mask; | 
					
						
							|  |  |  | 	unsigned active_number; | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	/* setup chip specs */ | 
					
						
							| 
									
										
										
										
											2012-05-31 19:00:25 -04:00
										 |  |  | 	rdev->config.rv770.tiling_group_size = 256; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	switch (rdev->family) { | 
					
						
							|  |  |  | 	case CHIP_RV770: | 
					
						
							|  |  |  | 		rdev->config.rv770.max_pipes = 4; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_tile_pipes = 8; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_simds = 10; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_backends = 4; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_gprs = 256; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_threads = 248; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_stack_entries = 512; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_hw_contexts = 8; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_gs_threads = 16 * 2; | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_max_export_size = 128; | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_max_export_pos_size = 16; | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_max_export_smx_size = 112; | 
					
						
							|  |  |  | 		rdev->config.rv770.sq_num_cf_insts = 2; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_num_of_sets = 7; | 
					
						
							|  |  |  | 		rdev->config.rv770.sc_prim_fifo_size = 0xF9; | 
					
						
							|  |  |  | 		rdev->config.rv770.sc_hiz_tile_fifo_size = 0x30; | 
					
						
							|  |  |  | 		rdev->config.rv770.sc_earlyz_tile_fifo_fize = 0x130; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case CHIP_RV730: | 
					
						
							|  |  |  | 		rdev->config.rv770.max_pipes = 2; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_tile_pipes = 4; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_simds = 8; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_backends = 2; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_gprs = 128; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_threads = 248; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_stack_entries = 256; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_hw_contexts = 8; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_gs_threads = 16 * 2; | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_max_export_size = 256; | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_max_export_pos_size = 32; | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_max_export_smx_size = 224; | 
					
						
							|  |  |  | 		rdev->config.rv770.sq_num_cf_insts = 2; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_num_of_sets = 7; | 
					
						
							|  |  |  | 		rdev->config.rv770.sc_prim_fifo_size = 0xf9; | 
					
						
							|  |  |  | 		rdev->config.rv770.sc_hiz_tile_fifo_size = 0x30; | 
					
						
							|  |  |  | 		rdev->config.rv770.sc_earlyz_tile_fifo_fize = 0x130; | 
					
						
							|  |  |  | 		if (rdev->config.rv770.sx_max_export_pos_size > 16) { | 
					
						
							|  |  |  | 			rdev->config.rv770.sx_max_export_pos_size -= 16; | 
					
						
							|  |  |  | 			rdev->config.rv770.sx_max_export_smx_size += 16; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case CHIP_RV710: | 
					
						
							|  |  |  | 		rdev->config.rv770.max_pipes = 2; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_tile_pipes = 2; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_simds = 2; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_backends = 1; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_gprs = 256; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_threads = 192; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_stack_entries = 256; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_hw_contexts = 4; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_gs_threads = 8 * 2; | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_max_export_size = 128; | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_max_export_pos_size = 16; | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_max_export_smx_size = 112; | 
					
						
							|  |  |  | 		rdev->config.rv770.sq_num_cf_insts = 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_num_of_sets = 7; | 
					
						
							|  |  |  | 		rdev->config.rv770.sc_prim_fifo_size = 0x40; | 
					
						
							|  |  |  | 		rdev->config.rv770.sc_hiz_tile_fifo_size = 0x30; | 
					
						
							|  |  |  | 		rdev->config.rv770.sc_earlyz_tile_fifo_fize = 0x130; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case CHIP_RV740: | 
					
						
							|  |  |  | 		rdev->config.rv770.max_pipes = 4; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_tile_pipes = 4; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_simds = 8; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_backends = 4; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_gprs = 256; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_threads = 248; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_stack_entries = 512; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_hw_contexts = 8; | 
					
						
							|  |  |  | 		rdev->config.rv770.max_gs_threads = 16 * 2; | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_max_export_size = 256; | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_max_export_pos_size = 32; | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_max_export_smx_size = 224; | 
					
						
							|  |  |  | 		rdev->config.rv770.sq_num_cf_insts = 2; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		rdev->config.rv770.sx_num_of_sets = 7; | 
					
						
							|  |  |  | 		rdev->config.rv770.sc_prim_fifo_size = 0x100; | 
					
						
							|  |  |  | 		rdev->config.rv770.sc_hiz_tile_fifo_size = 0x30; | 
					
						
							|  |  |  | 		rdev->config.rv770.sc_earlyz_tile_fifo_fize = 0x130; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (rdev->config.rv770.sx_max_export_pos_size > 16) { | 
					
						
							|  |  |  | 			rdev->config.rv770.sx_max_export_pos_size -= 16; | 
					
						
							|  |  |  | 			rdev->config.rv770.sx_max_export_smx_size += 16; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Initialize HDP */ | 
					
						
							|  |  |  | 	j = 0; | 
					
						
							|  |  |  | 	for (i = 0; i < 32; i++) { | 
					
						
							|  |  |  | 		WREG32((0x2c14 + j), 0x00000000); | 
					
						
							|  |  |  | 		WREG32((0x2c18 + j), 0x00000000); | 
					
						
							|  |  |  | 		WREG32((0x2c1c + j), 0x00000000); | 
					
						
							|  |  |  | 		WREG32((0x2c20 + j), 0x00000000); | 
					
						
							|  |  |  | 		WREG32((0x2c24 + j), 0x00000000); | 
					
						
							|  |  |  | 		j += 0x18; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* setup tiling, simd, pipe config */ | 
					
						
							|  |  |  | 	mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-31 19:00:25 -04:00
										 |  |  | 	shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG); | 
					
						
							|  |  |  | 	inactive_pipes = (shader_pipe_config & INACTIVE_QD_PIPES_MASK) >> INACTIVE_QD_PIPES_SHIFT; | 
					
						
							|  |  |  | 	for (i = 0, tmp = 1, active_number = 0; i < R7XX_MAX_PIPES; i++) { | 
					
						
							|  |  |  | 		if (!(inactive_pipes & tmp)) { | 
					
						
							|  |  |  | 			active_number++; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		tmp <<= 1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (active_number == 1) { | 
					
						
							|  |  |  | 		WREG32(SPI_CONFIG_CNTL, DISABLE_INTERP_1); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		WREG32(SPI_CONFIG_CNTL, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	cc_rb_backend_disable = RREG32(CC_RB_BACKEND_DISABLE) & 0x00ff0000; | 
					
						
							|  |  |  | 	tmp = R7XX_MAX_BACKENDS - r600_count_pipe_bits(cc_rb_backend_disable >> 16); | 
					
						
							|  |  |  | 	if (tmp < rdev->config.rv770.max_backends) { | 
					
						
							|  |  |  | 		rdev->config.rv770.max_backends = tmp; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG) & 0xffffff00; | 
					
						
							|  |  |  | 	tmp = R7XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config >> 8) & R7XX_MAX_PIPES_MASK); | 
					
						
							|  |  |  | 	if (tmp < rdev->config.rv770.max_pipes) { | 
					
						
							|  |  |  | 		rdev->config.rv770.max_pipes = tmp; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	tmp = R7XX_MAX_SIMDS - r600_count_pipe_bits((cc_gc_shader_pipe_config >> 16) & R7XX_MAX_SIMDS_MASK); | 
					
						
							|  |  |  | 	if (tmp < rdev->config.rv770.max_simds) { | 
					
						
							|  |  |  | 		rdev->config.rv770.max_simds = tmp; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	switch (rdev->config.rv770.max_tile_pipes) { | 
					
						
							|  |  |  | 	case 1: | 
					
						
							| 
									
										
										
										
											2010-02-19 16:22:31 -05:00
										 |  |  | 	default: | 
					
						
							| 
									
										
										
										
											2012-05-31 19:00:25 -04:00
										 |  |  | 		gb_tiling_config = PIPE_TILING(0); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 		break; | 
					
						
							|  |  |  | 	case 2: | 
					
						
							| 
									
										
										
										
											2012-05-31 19:00:25 -04:00
										 |  |  | 		gb_tiling_config = PIPE_TILING(1); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 		break; | 
					
						
							|  |  |  | 	case 4: | 
					
						
							| 
									
										
										
										
											2012-05-31 19:00:25 -04:00
										 |  |  | 		gb_tiling_config = PIPE_TILING(2); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 		break; | 
					
						
							|  |  |  | 	case 8: | 
					
						
							| 
									
										
										
										
											2012-05-31 19:00:25 -04:00
										 |  |  | 		gb_tiling_config = PIPE_TILING(3); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-02-19 16:22:31 -05:00
										 |  |  | 	rdev->config.rv770.tiling_npipes = rdev->config.rv770.max_tile_pipes; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-31 19:00:25 -04:00
										 |  |  | 	disabled_rb_mask = (RREG32(CC_RB_BACKEND_DISABLE) >> 16) & R7XX_MAX_BACKENDS_MASK; | 
					
						
							|  |  |  | 	tmp = (gb_tiling_config & PIPE_TILING__MASK) >> PIPE_TILING__SHIFT; | 
					
						
							|  |  |  | 	tmp = r6xx_remap_render_backend(rdev, tmp, rdev->config.rv770.max_backends, | 
					
						
							|  |  |  | 					R7XX_MAX_BACKENDS, disabled_rb_mask); | 
					
						
							|  |  |  | 	gb_tiling_config |= tmp << 16; | 
					
						
							|  |  |  | 	rdev->config.rv770.backend_map = tmp; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	if (rdev->family == CHIP_RV770) | 
					
						
							|  |  |  | 		gb_tiling_config |= BANK_TILING(1); | 
					
						
							| 
									
										
										
										
											2012-05-31 18:53:36 -04:00
										 |  |  | 	else { | 
					
						
							|  |  |  | 		if ((mc_arb_ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT) | 
					
						
							|  |  |  | 			gb_tiling_config |= BANK_TILING(1); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			gb_tiling_config |= BANK_TILING(0); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-02-10 22:30:05 +00:00
										 |  |  | 	rdev->config.rv770.tiling_nbanks = 4 << ((gb_tiling_config >> 4) & 0x3); | 
					
						
							| 
									
										
										
										
											2010-10-18 23:54:56 -04:00
										 |  |  | 	gb_tiling_config |= GROUP_SIZE((mc_arb_ramcfg & BURSTLENGTH_MASK) >> BURSTLENGTH_SHIFT); | 
					
						
							| 
									
										
										
										
											2009-11-03 10:04:01 -05:00
										 |  |  | 	if (((mc_arb_ramcfg & NOOFROWS_MASK) >> NOOFROWS_SHIFT) > 3) { | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 		gb_tiling_config |= ROW_TILING(3); | 
					
						
							|  |  |  | 		gb_tiling_config |= SAMPLE_SPLIT(3); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		gb_tiling_config |= | 
					
						
							|  |  |  | 			ROW_TILING(((mc_arb_ramcfg & NOOFROWS_MASK) >> NOOFROWS_SHIFT)); | 
					
						
							|  |  |  | 		gb_tiling_config |= | 
					
						
							|  |  |  | 			SAMPLE_SPLIT(((mc_arb_ramcfg & NOOFROWS_MASK) >> NOOFROWS_SHIFT)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	gb_tiling_config |= BANK_SWAPS(1); | 
					
						
							| 
									
										
										
										
											2010-06-04 13:10:12 -04:00
										 |  |  | 	rdev->config.rv770.tile_config = gb_tiling_config; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(GB_TILING_CONFIG, gb_tiling_config); | 
					
						
							|  |  |  | 	WREG32(DCP_TILING_CONFIG, (gb_tiling_config & 0xffff)); | 
					
						
							|  |  |  | 	WREG32(HDP_TILING_CONFIG, (gb_tiling_config & 0xffff)); | 
					
						
							| 
									
										
										
										
											2012-09-27 15:08:35 -04:00
										 |  |  | 	WREG32(DMA_TILING_CONFIG, (gb_tiling_config & 0xffff)); | 
					
						
							|  |  |  | 	WREG32(DMA_TILING_CONFIG2, (gb_tiling_config & 0xffff)); | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:37 +02:00
										 |  |  | 	if (rdev->family == CHIP_RV730) { | 
					
						
							|  |  |  | 		WREG32(UVD_UDEC_DB_TILING_CONFIG, (gb_tiling_config & 0xffff)); | 
					
						
							|  |  |  | 		WREG32(UVD_UDEC_DBW_TILING_CONFIG, (gb_tiling_config & 0xffff)); | 
					
						
							|  |  |  | 		WREG32(UVD_UDEC_TILING_CONFIG, (gb_tiling_config & 0xffff)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(CGTS_SYS_TCC_DISABLE, 0); | 
					
						
							|  |  |  | 	WREG32(CGTS_TCC_DISABLE, 0); | 
					
						
							| 
									
										
										
										
											2010-03-05 14:50:37 -05:00
										 |  |  | 	WREG32(CGTS_USER_SYS_TCC_DISABLE, 0); | 
					
						
							|  |  |  | 	WREG32(CGTS_USER_TCC_DISABLE, 0); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-31 19:00:25 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	num_qd_pipes = R7XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config & INACTIVE_QD_PIPES_MASK) >> 8); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	WREG32(VGT_OUT_DEALLOC_CNTL, (num_qd_pipes * 4) & DEALLOC_DIST_MASK); | 
					
						
							|  |  |  | 	WREG32(VGT_VERTEX_REUSE_BLOCK_CNTL, ((num_qd_pipes * 4) - 2) & VTX_REUSE_DEPTH_MASK); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* set HW defaults for 3D engine */ | 
					
						
							|  |  |  | 	WREG32(CP_QUEUE_THRESHOLDS, (ROQ_IB1_START(0x16) | | 
					
						
							| 
									
										
										
										
											2009-11-03 10:04:01 -05:00
										 |  |  | 				     ROQ_IB2_START(0x2b))); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(CP_MEQ_THRESHOLDS, STQ_SPLIT(0x30)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-19 16:22:31 -05:00
										 |  |  | 	ta_aux_cntl = RREG32(TA_CNTL_AUX); | 
					
						
							|  |  |  | 	WREG32(TA_CNTL_AUX, ta_aux_cntl | DISABLE_CUBE_ANISO); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	sx_debug_1 = RREG32(SX_DEBUG_1); | 
					
						
							|  |  |  | 	sx_debug_1 |= ENABLE_NEW_SMX_ADDRESS; | 
					
						
							|  |  |  | 	WREG32(SX_DEBUG_1, sx_debug_1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	smx_dc_ctl0 = RREG32(SMX_DC_CTL0); | 
					
						
							|  |  |  | 	smx_dc_ctl0 &= ~CACHE_DEPTH(0x1ff); | 
					
						
							|  |  |  | 	smx_dc_ctl0 |= CACHE_DEPTH((rdev->config.rv770.sx_num_of_sets * 64) - 1); | 
					
						
							|  |  |  | 	WREG32(SMX_DC_CTL0, smx_dc_ctl0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-19 16:22:31 -05:00
										 |  |  | 	if (rdev->family != CHIP_RV740) | 
					
						
							|  |  |  | 		WREG32(SMX_EVENT_CTL, (ES_FLUSH_CTL(4) | | 
					
						
							|  |  |  | 				       GS_FLUSH_CTL(4) | | 
					
						
							|  |  |  | 				       ACK_FLUSH_CTL(3) | | 
					
						
							|  |  |  | 				       SYNC_FLUSH_CTL)); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-14 22:06:36 +02:00
										 |  |  | 	if (rdev->family != CHIP_RV770) | 
					
						
							|  |  |  | 		WREG32(SMX_SAR_CTL0, 0x00003f3f); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-19 16:22:31 -05:00
										 |  |  | 	db_debug3 = RREG32(DB_DEBUG3); | 
					
						
							|  |  |  | 	db_debug3 &= ~DB_CLK_OFF_DELAY(0x1f); | 
					
						
							|  |  |  | 	switch (rdev->family) { | 
					
						
							|  |  |  | 	case CHIP_RV770: | 
					
						
							|  |  |  | 	case CHIP_RV740: | 
					
						
							|  |  |  | 		db_debug3 |= DB_CLK_OFF_DELAY(0x1f); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case CHIP_RV710: | 
					
						
							|  |  |  | 	case CHIP_RV730: | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		db_debug3 |= DB_CLK_OFF_DELAY(2); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	WREG32(DB_DEBUG3, db_debug3); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (rdev->family != CHIP_RV770) { | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 		db_debug4 = RREG32(DB_DEBUG4); | 
					
						
							|  |  |  | 		db_debug4 |= DISABLE_TILE_COVERED_FOR_PS_ITER; | 
					
						
							|  |  |  | 		WREG32(DB_DEBUG4, db_debug4); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(SX_EXPORT_BUFFER_SIZES, (COLOR_BUFFER_SIZE((rdev->config.rv770.sx_max_export_size / 4) - 1) | | 
					
						
							| 
									
										
										
										
											2009-11-03 10:04:01 -05:00
										 |  |  | 					POSITION_BUFFER_SIZE((rdev->config.rv770.sx_max_export_pos_size / 4) - 1) | | 
					
						
							|  |  |  | 					SMX_BUFFER_SIZE((rdev->config.rv770.sx_max_export_smx_size / 4) - 1))); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(PA_SC_FIFO_SIZE, (SC_PRIM_FIFO_SIZE(rdev->config.rv770.sc_prim_fifo_size) | | 
					
						
							| 
									
										
										
										
											2009-11-03 10:04:01 -05:00
										 |  |  | 				 SC_HIZ_TILE_FIFO_SIZE(rdev->config.rv770.sc_hiz_tile_fifo_size) | | 
					
						
							|  |  |  | 				 SC_EARLYZ_TILE_FIFO_SIZE(rdev->config.rv770.sc_earlyz_tile_fifo_fize))); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(PA_SC_MULTI_CHIP_CNTL, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(VGT_NUM_INSTANCES, 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(SPI_CONFIG_CNTL_1, VTX_DONE_DELAY(4)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(CP_PERFMON_CNTL, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	sq_ms_fifo_sizes = (CACHE_FIFO_SIZE(16 * rdev->config.rv770.sq_num_cf_insts) | | 
					
						
							|  |  |  | 			    DONE_FIFO_HIWATER(0xe0) | | 
					
						
							|  |  |  | 			    ALU_UPDATE_FIFO_HIWATER(0x8)); | 
					
						
							|  |  |  | 	switch (rdev->family) { | 
					
						
							|  |  |  | 	case CHIP_RV770: | 
					
						
							|  |  |  | 	case CHIP_RV730: | 
					
						
							|  |  |  | 	case CHIP_RV710: | 
					
						
							| 
									
										
										
										
											2010-02-19 16:22:31 -05:00
										 |  |  | 		sq_ms_fifo_sizes |= FETCH_FIFO_HIWATER(0x1); | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	case CHIP_RV740: | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		sq_ms_fifo_sizes |= FETCH_FIFO_HIWATER(0x4); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	WREG32(SQ_MS_FIFO_SIZES, sq_ms_fifo_sizes); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* SQ_CONFIG, SQ_GPR_RESOURCE_MGMT, SQ_THREAD_RESOURCE_MGMT, SQ_STACK_RESOURCE_MGMT
 | 
					
						
							|  |  |  | 	 * should be adjusted as needed by the 2D/3D drivers.  This just sets default values | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	sq_config = RREG32(SQ_CONFIG); | 
					
						
							|  |  |  | 	sq_config &= ~(PS_PRIO(3) | | 
					
						
							|  |  |  | 		       VS_PRIO(3) | | 
					
						
							|  |  |  | 		       GS_PRIO(3) | | 
					
						
							|  |  |  | 		       ES_PRIO(3)); | 
					
						
							|  |  |  | 	sq_config |= (DX9_CONSTS | | 
					
						
							|  |  |  | 		      VC_ENABLE | | 
					
						
							|  |  |  | 		      EXPORT_SRC_C | | 
					
						
							|  |  |  | 		      PS_PRIO(0) | | 
					
						
							|  |  |  | 		      VS_PRIO(1) | | 
					
						
							|  |  |  | 		      GS_PRIO(2) | | 
					
						
							|  |  |  | 		      ES_PRIO(3)); | 
					
						
							|  |  |  | 	if (rdev->family == CHIP_RV710) | 
					
						
							|  |  |  | 		/* no vertex cache */ | 
					
						
							|  |  |  | 		sq_config &= ~VC_ENABLE; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(SQ_CONFIG, sq_config); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(SQ_GPR_RESOURCE_MGMT_1,  (NUM_PS_GPRS((rdev->config.rv770.max_gprs * 24)/64) | | 
					
						
							| 
									
										
										
										
											2009-09-21 14:06:30 +10:00
										 |  |  | 					 NUM_VS_GPRS((rdev->config.rv770.max_gprs * 24)/64) | | 
					
						
							|  |  |  | 					 NUM_CLAUSE_TEMP_GPRS(((rdev->config.rv770.max_gprs * 24)/64)/2))); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(SQ_GPR_RESOURCE_MGMT_2,  (NUM_GS_GPRS((rdev->config.rv770.max_gprs * 7)/64) | | 
					
						
							| 
									
										
										
										
											2009-09-21 14:06:30 +10:00
										 |  |  | 					 NUM_ES_GPRS((rdev->config.rv770.max_gprs * 7)/64))); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	sq_thread_resource_mgmt = (NUM_PS_THREADS((rdev->config.rv770.max_threads * 4)/8) | | 
					
						
							|  |  |  | 				   NUM_VS_THREADS((rdev->config.rv770.max_threads * 2)/8) | | 
					
						
							|  |  |  | 				   NUM_ES_THREADS((rdev->config.rv770.max_threads * 1)/8)); | 
					
						
							|  |  |  | 	if (((rdev->config.rv770.max_threads * 1) / 8) > rdev->config.rv770.max_gs_threads) | 
					
						
							|  |  |  | 		sq_thread_resource_mgmt |= NUM_GS_THREADS(rdev->config.rv770.max_gs_threads); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		sq_thread_resource_mgmt |= NUM_GS_THREADS((rdev->config.rv770.max_gs_threads * 1)/8); | 
					
						
							|  |  |  | 	WREG32(SQ_THREAD_RESOURCE_MGMT, sq_thread_resource_mgmt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(SQ_STACK_RESOURCE_MGMT_1, (NUM_PS_STACK_ENTRIES((rdev->config.rv770.max_stack_entries * 1)/4) | | 
					
						
							|  |  |  | 						     NUM_VS_STACK_ENTRIES((rdev->config.rv770.max_stack_entries * 1)/4))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(SQ_STACK_RESOURCE_MGMT_2, (NUM_GS_STACK_ENTRIES((rdev->config.rv770.max_stack_entries * 1)/4) | | 
					
						
							|  |  |  | 						     NUM_ES_STACK_ENTRIES((rdev->config.rv770.max_stack_entries * 1)/4))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	sq_dyn_gpr_size_simd_ab_0 = (SIMDA_RING0((rdev->config.rv770.max_gprs * 38)/64) | | 
					
						
							|  |  |  | 				     SIMDA_RING1((rdev->config.rv770.max_gprs * 38)/64) | | 
					
						
							|  |  |  | 				     SIMDB_RING0((rdev->config.rv770.max_gprs * 38)/64) | | 
					
						
							|  |  |  | 				     SIMDB_RING1((rdev->config.rv770.max_gprs * 38)/64)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(SQ_DYN_GPR_SIZE_SIMD_AB_0, sq_dyn_gpr_size_simd_ab_0); | 
					
						
							|  |  |  | 	WREG32(SQ_DYN_GPR_SIZE_SIMD_AB_1, sq_dyn_gpr_size_simd_ab_0); | 
					
						
							|  |  |  | 	WREG32(SQ_DYN_GPR_SIZE_SIMD_AB_2, sq_dyn_gpr_size_simd_ab_0); | 
					
						
							|  |  |  | 	WREG32(SQ_DYN_GPR_SIZE_SIMD_AB_3, sq_dyn_gpr_size_simd_ab_0); | 
					
						
							|  |  |  | 	WREG32(SQ_DYN_GPR_SIZE_SIMD_AB_4, sq_dyn_gpr_size_simd_ab_0); | 
					
						
							|  |  |  | 	WREG32(SQ_DYN_GPR_SIZE_SIMD_AB_5, sq_dyn_gpr_size_simd_ab_0); | 
					
						
							|  |  |  | 	WREG32(SQ_DYN_GPR_SIZE_SIMD_AB_6, sq_dyn_gpr_size_simd_ab_0); | 
					
						
							|  |  |  | 	WREG32(SQ_DYN_GPR_SIZE_SIMD_AB_7, sq_dyn_gpr_size_simd_ab_0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(PA_SC_FORCE_EOV_MAX_CNTS, (FORCE_EOV_MAX_CLK_CNT(4095) | | 
					
						
							| 
									
										
										
										
											2009-09-21 14:06:30 +10:00
										 |  |  | 					  FORCE_EOV_MAX_REZ_CNT(255))); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (rdev->family == CHIP_RV710) | 
					
						
							|  |  |  | 		WREG32(VGT_CACHE_INVALIDATION, (CACHE_INVALIDATION(TC_ONLY) | | 
					
						
							| 
									
										
										
										
											2009-09-21 14:06:30 +10:00
										 |  |  | 						AUTO_INVLD_EN(ES_AND_GS_AUTO))); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	else | 
					
						
							|  |  |  | 		WREG32(VGT_CACHE_INVALIDATION, (CACHE_INVALIDATION(VC_AND_TC) | | 
					
						
							| 
									
										
										
										
											2009-09-21 14:06:30 +10:00
										 |  |  | 						AUTO_INVLD_EN(ES_AND_GS_AUTO))); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	switch (rdev->family) { | 
					
						
							|  |  |  | 	case CHIP_RV770: | 
					
						
							|  |  |  | 	case CHIP_RV730: | 
					
						
							|  |  |  | 	case CHIP_RV740: | 
					
						
							|  |  |  | 		gs_prim_buffer_depth = 384; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case CHIP_RV710: | 
					
						
							|  |  |  | 		gs_prim_buffer_depth = 128; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	num_gs_verts_per_thread = rdev->config.rv770.max_pipes * 16; | 
					
						
							|  |  |  | 	vgt_gs_per_es = gs_prim_buffer_depth + num_gs_verts_per_thread; | 
					
						
							|  |  |  | 	/* Max value for this is 256 */ | 
					
						
							|  |  |  | 	if (vgt_gs_per_es > 256) | 
					
						
							|  |  |  | 		vgt_gs_per_es = 256; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(VGT_ES_PER_GS, 128); | 
					
						
							|  |  |  | 	WREG32(VGT_GS_PER_ES, vgt_gs_per_es); | 
					
						
							|  |  |  | 	WREG32(VGT_GS_PER_VS, 2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* more default values. 2D/3D driver should adjust as needed */ | 
					
						
							|  |  |  | 	WREG32(VGT_GS_VERTEX_REUSE, 16); | 
					
						
							|  |  |  | 	WREG32(PA_SC_LINE_STIPPLE_STATE, 0); | 
					
						
							|  |  |  | 	WREG32(VGT_STRMOUT_EN, 0); | 
					
						
							|  |  |  | 	WREG32(SX_MISC, 0); | 
					
						
							|  |  |  | 	WREG32(PA_SC_MODE_CNTL, 0); | 
					
						
							|  |  |  | 	WREG32(PA_SC_EDGERULE, 0xaaaaaaaa); | 
					
						
							|  |  |  | 	WREG32(PA_SC_AA_CONFIG, 0); | 
					
						
							|  |  |  | 	WREG32(PA_SC_CLIPRECT_RULE, 0xffff); | 
					
						
							|  |  |  | 	WREG32(PA_SC_LINE_STIPPLE, 0); | 
					
						
							|  |  |  | 	WREG32(SPI_INPUT_Z, 0); | 
					
						
							|  |  |  | 	WREG32(SPI_PS_IN_CONTROL_0, NUM_INTERP(2)); | 
					
						
							|  |  |  | 	WREG32(CB_COLOR7_FRAG, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* clear render buffer base addresses */ | 
					
						
							|  |  |  | 	WREG32(CB_COLOR0_BASE, 0); | 
					
						
							|  |  |  | 	WREG32(CB_COLOR1_BASE, 0); | 
					
						
							|  |  |  | 	WREG32(CB_COLOR2_BASE, 0); | 
					
						
							|  |  |  | 	WREG32(CB_COLOR3_BASE, 0); | 
					
						
							|  |  |  | 	WREG32(CB_COLOR4_BASE, 0); | 
					
						
							|  |  |  | 	WREG32(CB_COLOR5_BASE, 0); | 
					
						
							|  |  |  | 	WREG32(CB_COLOR6_BASE, 0); | 
					
						
							|  |  |  | 	WREG32(CB_COLOR7_BASE, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(TCP_CNTL, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	hdp_host_path_cntl = RREG32(HDP_HOST_PATH_CNTL); | 
					
						
							|  |  |  | 	WREG32(HDP_HOST_PATH_CNTL, hdp_host_path_cntl); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(PA_SC_MULTI_CHIP_CNTL, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WREG32(PA_CL_ENHANCE, (CLIP_VTX_REORDER_ENA | | 
					
						
							|  |  |  | 					  NUM_CLIP_SEQ(3))); | 
					
						
							| 
									
										
										
										
											2012-06-14 22:06:36 +02:00
										 |  |  | 	WREG32(VC_ENHANCE, 0); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-22 17:56:26 -05:00
										 |  |  | void r700_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u64 size_bf, size_af; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (mc->mc_vram_size > 0xE0000000) { | 
					
						
							|  |  |  | 		/* leave room for at least 512M GTT */ | 
					
						
							|  |  |  | 		dev_warn(rdev->dev, "limiting VRAM\n"); | 
					
						
							|  |  |  | 		mc->real_vram_size = 0xE0000000; | 
					
						
							|  |  |  | 		mc->mc_vram_size = 0xE0000000; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (rdev->flags & RADEON_IS_AGP) { | 
					
						
							|  |  |  | 		size_bf = mc->gtt_start; | 
					
						
							| 
									
										
										
										
											2013-04-08 11:13:01 -04:00
										 |  |  | 		size_af = mc->mc_mask - mc->gtt_end; | 
					
						
							| 
									
										
										
										
											2010-11-22 17:56:26 -05:00
										 |  |  | 		if (size_bf > size_af) { | 
					
						
							|  |  |  | 			if (mc->mc_vram_size > size_bf) { | 
					
						
							|  |  |  | 				dev_warn(rdev->dev, "limiting VRAM\n"); | 
					
						
							|  |  |  | 				mc->real_vram_size = size_bf; | 
					
						
							|  |  |  | 				mc->mc_vram_size = size_bf; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			mc->vram_start = mc->gtt_start - mc->mc_vram_size; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			if (mc->mc_vram_size > size_af) { | 
					
						
							|  |  |  | 				dev_warn(rdev->dev, "limiting VRAM\n"); | 
					
						
							|  |  |  | 				mc->real_vram_size = size_af; | 
					
						
							|  |  |  | 				mc->mc_vram_size = size_af; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-04-17 16:51:38 -04:00
										 |  |  | 			mc->vram_start = mc->gtt_end + 1; | 
					
						
							| 
									
										
										
										
											2010-11-22 17:56:26 -05:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; | 
					
						
							|  |  |  | 		dev_info(rdev->dev, "VRAM: %lluM 0x%08llX - 0x%08llX (%lluM used)\n", | 
					
						
							|  |  |  | 				mc->mc_vram_size >> 20, mc->vram_start, | 
					
						
							|  |  |  | 				mc->vram_end, mc->real_vram_size >> 20); | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2010-12-15 11:04:10 -05:00
										 |  |  | 		radeon_vram_location(rdev, &rdev->mc, 0); | 
					
						
							| 
									
										
										
										
											2010-11-22 17:56:26 -05:00
										 |  |  | 		rdev->mc.gtt_base_align = 0; | 
					
						
							|  |  |  | 		radeon_gtt_location(rdev, mc); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-31 13:43:50 -04:00
										 |  |  | static int rv770_mc_init(struct radeon_device *rdev) | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | { | 
					
						
							|  |  |  | 	u32 tmp; | 
					
						
							| 
									
										
										
										
											2009-10-19 17:23:33 -04:00
										 |  |  | 	int chansize, numchan; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Get VRAM informations */ | 
					
						
							|  |  |  | 	rdev->mc.vram_is_ddr = true; | 
					
						
							| 
									
										
										
										
											2009-10-19 17:23:33 -04:00
										 |  |  | 	tmp = RREG32(MC_ARB_RAMCFG); | 
					
						
							|  |  |  | 	if (tmp & CHANSIZE_OVERRIDE) { | 
					
						
							|  |  |  | 		chansize = 16; | 
					
						
							|  |  |  | 	} else if (tmp & CHANSIZE_MASK) { | 
					
						
							|  |  |  | 		chansize = 64; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		chansize = 32; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	tmp = RREG32(MC_SHARED_CHMAP); | 
					
						
							|  |  |  | 	switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) { | 
					
						
							|  |  |  | 	case 0: | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		numchan = 1; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case 1: | 
					
						
							|  |  |  | 		numchan = 2; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case 2: | 
					
						
							|  |  |  | 		numchan = 4; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case 3: | 
					
						
							|  |  |  | 		numchan = 8; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	rdev->mc.vram_width = numchan * chansize; | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | 	/* Could aper size report 0 ? */ | 
					
						
							| 
									
										
										
										
											2010-05-27 13:40:24 -06:00
										 |  |  | 	rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); | 
					
						
							|  |  |  | 	rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	/* Setup GPU memory space */ | 
					
						
							|  |  |  | 	rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); | 
					
						
							|  |  |  | 	rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); | 
					
						
							| 
									
										
										
										
											2010-02-19 14:33:54 +00:00
										 |  |  | 	rdev->mc.visible_vram_size = rdev->mc.aper_size; | 
					
						
							| 
									
										
										
										
											2010-11-22 17:56:26 -05:00
										 |  |  | 	r700_vram_gtt_location(rdev, &rdev->mc); | 
					
						
							| 
									
										
										
										
											2010-03-16 20:54:38 -04:00
										 |  |  | 	radeon_update_bandwidth_info(rdev); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
											
												drm/radeon/kms: simplify memory controller setup V2
Get rid of _location and use _start/_end also simplify the
computation of vram_start|end & gtt_start|end. For R1XX-R2XX
we place VRAM at the same address of PCI aperture, those GPU
shouldn't have much memory and seems to behave better when
setup that way. For R3XX and newer we place VRAM at 0. For
R6XX-R7XX AGP we place VRAM before or after AGP aperture this
might limit to limit the VRAM size but it's very unlikely.
For IGP we don't change the VRAM placement.
Tested on (compiz,quake3,suspend/resume):
PCI/PCIE:RV280,R420,RV515,RV570,RV610,RV710
AGP:RV100,RV280,R420,RV350,RV620(RPB*),RV730
IGP:RS480(RPB*),RS690,RS780(RPB*),RS880
RPB: resume previously broken
V2 correct commit message to reflect more accurately the bug
and move VRAM placement to 0 for most of the GPU to avoid
limiting VRAM.
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
											
										 
											2010-02-17 21:54:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-18 15:19:37 +10:00
										 |  |  | static int rv770_startup(struct radeon_device *rdev) | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-09-27 15:08:35 -04:00
										 |  |  | 	struct radeon_ring *ring; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	int r; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 	/* enable pcie gen2 link */ | 
					
						
							|  |  |  | 	rv770_pcie_gen2_enable(rdev); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-30 08:58:20 -04:00
										 |  |  | 	/* scratch needs to be initialized before MC */ | 
					
						
							|  |  |  | 	r = r600_vram_scratch_init(rdev); | 
					
						
							|  |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-04 12:13:17 -04:00
										 |  |  | 	rv770_mc_program(rdev); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-06 19:04:30 +02:00
										 |  |  | 	if (rdev->flags & RADEON_IS_AGP) { | 
					
						
							|  |  |  | 		rv770_agp_enable(rdev); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		r = rv770_pcie_gart_enable(rdev); | 
					
						
							|  |  |  | 		if (r) | 
					
						
							|  |  |  | 			return r; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-10-28 10:30:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	rv770_gpu_init(rdev); | 
					
						
							| 
									
										
										
										
											2010-08-06 21:36:58 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-27 18:25:25 -04:00
										 |  |  | 	/* allocate wb buffer */ | 
					
						
							|  |  |  | 	r = radeon_wb_init(rdev); | 
					
						
							|  |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-20 20:45:34 +00:00
										 |  |  | 	r = radeon_fence_driver_start_ring(rdev, RADEON_RING_TYPE_GFX_INDEX); | 
					
						
							|  |  |  | 	if (r) { | 
					
						
							|  |  |  | 		dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r); | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-27 15:08:35 -04:00
										 |  |  | 	r = radeon_fence_driver_start_ring(rdev, R600_RING_TYPE_DMA_INDEX); | 
					
						
							|  |  |  | 	if (r) { | 
					
						
							|  |  |  | 		dev_err(rdev->dev, "failed initializing DMA fences (%d).\n", r); | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-13 11:56:53 +02:00
										 |  |  | 	r = uvd_v2_2_resume(rdev); | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:29 +02:00
										 |  |  | 	if (!r) { | 
					
						
							|  |  |  | 		r = radeon_fence_driver_start_ring(rdev, | 
					
						
							|  |  |  | 						   R600_RING_TYPE_UVD_INDEX); | 
					
						
							|  |  |  | 		if (r) | 
					
						
							|  |  |  | 			dev_err(rdev->dev, "UVD fences init error (%d).\n", r); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (r) | 
					
						
							|  |  |  | 		rdev->ring[R600_RING_TYPE_UVD_INDEX].ring_size = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-01 13:43:46 -05:00
										 |  |  | 	/* Enable IRQ */ | 
					
						
							| 
									
										
											  
											
												radeon: Fix system hang issue when using KMS with older cards
The current radeon driver initialization routines, when using KMS, are written
so that the IRQ installation routine is called before initializing the WB buffer
and the CP rings. With some ASICs, though, the IRQ routine tries to access the
GFX_INDEX ring causing a call to RREG32 with the value of -1 in
radeon_fence_read. This, in turn causes the system to completely hang with some
cards, requiring a hard reset.
A call stack that can cause such a hang looks like this (using rv515 ASIC for the
example here):
 * rv515_init (rv515.c)
 * radeon_irq_kms_init (radeon_irq_kms.c)
 * drm_irq_install (drm_irq.c)
 * radeon_driver_irq_preinstall_kms (radeon_irq_kms.c)
 * rs600_irq_process (rs600.c)
 * radeon_fence_process - due to SW interrupt (radeon_fence.c)
 * radeon_fence_read (radeon_fence.c)
 * hang due to RREG32(-1)
The patch moves the IRQ installation to the card startup routine, after the ring
has been initialized, but before the IRQ has been set. This fixes the issue, but
requires a check to see if the IRQ is already installed, as is the case in the
system resume codepath.
I have tested the patch on three machines using the rv515, the rv770 and the
evergreen ASIC. They worked without issues.
This seems to be a known issue and has been reported on several bug tracking
sites by various distributions (see links below). Most of reports recommend
booting the system with KMS disabled and then enabling KMS by reloading the
radeon module. For some reason, this was indeed a usable workaround, however,
UMS is now deprecated and disabled by default.
Bug reports:
https://bugzilla.redhat.com/show_bug.cgi?id=845745
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/561789
https://bbs.archlinux.org/viewtopic.php?id=156964
Signed-off-by: Adis Hamzić <adis@hamzadis.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
											
										 
											2013-06-02 16:47:54 +02:00
										 |  |  | 	if (!rdev->irq.installed) { | 
					
						
							|  |  |  | 		r = radeon_irq_kms_init(rdev); | 
					
						
							|  |  |  | 		if (r) | 
					
						
							|  |  |  | 			return r; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-01 13:43:46 -05:00
										 |  |  | 	r = r600_irq_init(rdev); | 
					
						
							|  |  |  | 	if (r) { | 
					
						
							|  |  |  | 		DRM_ERROR("radeon: IH init failed (%d).\n", r); | 
					
						
							|  |  |  | 		radeon_irq_kms_fini(rdev); | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	r600_irq_set(rdev); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-27 15:08:35 -04:00
										 |  |  | 	ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; | 
					
						
							| 
									
										
										
										
											2011-10-23 12:56:27 +02:00
										 |  |  | 	r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP_RPTR_OFFSET, | 
					
						
							| 
									
										
										
										
											2013-08-13 11:56:52 +02:00
										 |  |  | 			     RADEON_CP_PACKET2); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							| 
									
										
										
										
											2012-09-27 15:08:35 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX]; | 
					
						
							|  |  |  | 	r = radeon_ring_init(rdev, ring, ring->ring_size, R600_WB_DMA_RPTR_OFFSET, | 
					
						
							| 
									
										
										
										
											2013-08-13 11:56:52 +02:00
										 |  |  | 			     DMA_PACKET(DMA_PACKET_NOP, 0, 0, 0)); | 
					
						
							| 
									
										
										
										
											2012-09-27 15:08:35 -04:00
										 |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	r = rv770_cp_load_microcode(rdev); | 
					
						
							|  |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 	r = r600_cp_resume(rdev); | 
					
						
							|  |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							| 
									
										
										
										
											2010-08-27 18:25:25 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-27 15:08:35 -04:00
										 |  |  | 	r = r600_dma_resume(rdev); | 
					
						
							|  |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:29 +02:00
										 |  |  | 	ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX]; | 
					
						
							|  |  |  | 	if (ring->ring_size) { | 
					
						
							| 
									
										
										
										
											2013-08-13 11:56:51 +02:00
										 |  |  | 		r = radeon_ring_init(rdev, ring, ring->ring_size, 0, | 
					
						
							| 
									
										
										
										
											2013-08-13 11:56:52 +02:00
										 |  |  | 				     RADEON_CP_PACKET2); | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:29 +02:00
										 |  |  | 		if (!r) | 
					
						
							| 
									
										
										
										
											2013-08-13 11:56:53 +02:00
										 |  |  | 			r = uvd_v1_0_init(rdev); | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (r) | 
					
						
							|  |  |  | 			DRM_ERROR("radeon: failed initializing UVD (%d).\n", r); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-05 11:55:34 +02:00
										 |  |  | 	r = radeon_ib_pool_init(rdev); | 
					
						
							|  |  |  | 	if (r) { | 
					
						
							|  |  |  | 		dev_err(rdev->dev, "IB initialization failed (%d).\n", r); | 
					
						
							| 
									
										
										
											
												drm/radeon: introduce a sub allocator and convert ib pool to it v4
Somewhat specializaed sub-allocator designed to perform sub-allocation
for command buffer not only for current cs ioctl but for future command
submission ioctl as well. Patch also convert current ib pool to use
the sub allocator. Idea is that ib poll buffer can be share with other
command buffer submission not having 64K granularity.
v2 Harmonize pool handling and add suspend/resume callback to pin/unpin
sa bo (tested on rv280, rv370, r420, rv515, rv610, rv710, redwood, cayman,
rs480, rs690, rs880)
v3 Simplify allocator
v4 Fix radeon_ib_get error path to properly free fence
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
											
										 
											2011-11-15 11:48:34 -05:00
										 |  |  | 		return r; | 
					
						
							| 
									
										
										
										
											2012-07-05 11:55:34 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
											
												drm/radeon: introduce a sub allocator and convert ib pool to it v4
Somewhat specializaed sub-allocator designed to perform sub-allocation
for command buffer not only for current cs ioctl but for future command
submission ioctl as well. Patch also convert current ib pool to use
the sub allocator. Idea is that ib poll buffer can be share with other
command buffer submission not having 64K granularity.
v2 Harmonize pool handling and add suspend/resume callback to pin/unpin
sa bo (tested on rv280, rv370, r420, rv515, rv610, rv710, redwood, cayman,
rs480, rs690, rs880)
v3 Simplify allocator
v4 Fix radeon_ib_get error path to properly free fence
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
											
										 
											2011-11-15 11:48:34 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-04 17:18:51 -04:00
										 |  |  | 	r = r600_audio_init(rdev); | 
					
						
							|  |  |  | 	if (r) { | 
					
						
							|  |  |  | 		DRM_ERROR("radeon: audio init failed\n"); | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-18 15:19:37 +10:00
										 |  |  | int rv770_resume(struct radeon_device *rdev) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int r; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-06 19:04:30 +02:00
										 |  |  | 	/* Do not reset GPU before posting, on rv770 hw unlike on r500 hw,
 | 
					
						
							|  |  |  | 	 * posting will perform necessary task to bring back GPU into good | 
					
						
							|  |  |  | 	 * shape. | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2009-09-18 15:19:37 +10:00
										 |  |  | 	/* post card */ | 
					
						
							| 
									
										
										
										
											2009-10-01 18:02:15 +02:00
										 |  |  | 	atom_asic_init(rdev->mode_info.atom_context); | 
					
						
							| 
									
										
										
										
											2009-09-18 15:19:37 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-26 15:59:47 -05:00
										 |  |  | 	/* init golden registers */ | 
					
						
							|  |  |  | 	rv770_init_golden_registers(rdev); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-25 12:01:28 -05:00
										 |  |  | 	if (rdev->pm.pm_method == PM_METHOD_DPM) | 
					
						
							|  |  |  | 		radeon_pm_resume(rdev); | 
					
						
							| 
									
										
										
										
											2013-12-18 14:07:14 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												drm/radeon: introduce a sub allocator and convert ib pool to it v4
Somewhat specializaed sub-allocator designed to perform sub-allocation
for command buffer not only for current cs ioctl but for future command
submission ioctl as well. Patch also convert current ib pool to use
the sub allocator. Idea is that ib poll buffer can be share with other
command buffer submission not having 64K granularity.
v2 Harmonize pool handling and add suspend/resume callback to pin/unpin
sa bo (tested on rv280, rv370, r420, rv515, rv610, rv710, redwood, cayman,
rs480, rs690, rs880)
v3 Simplify allocator
v4 Fix radeon_ib_get error path to properly free fence
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
											
										 
											2011-11-15 11:48:34 -05:00
										 |  |  | 	rdev->accel_working = true; | 
					
						
							| 
									
										
										
										
											2009-09-18 15:19:37 +10:00
										 |  |  | 	r = rv770_startup(rdev); | 
					
						
							|  |  |  | 	if (r) { | 
					
						
							|  |  |  | 		DRM_ERROR("r600 startup failed on resume\n"); | 
					
						
							| 
									
										
										
										
											2012-02-20 17:57:20 -05:00
										 |  |  | 		rdev->accel_working = false; | 
					
						
							| 
									
										
										
										
											2009-09-18 15:19:37 +10:00
										 |  |  | 		return r; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return r; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | int rv770_suspend(struct radeon_device *rdev) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-12-18 14:07:14 -05:00
										 |  |  | 	radeon_pm_suspend(rdev); | 
					
						
							| 
									
										
										
										
											2010-03-06 13:03:36 +00:00
										 |  |  | 	r600_audio_fini(rdev); | 
					
						
							| 
									
										
										
										
											2013-08-13 11:56:53 +02:00
										 |  |  | 	uvd_v1_0_fini(rdev); | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:29 +02:00
										 |  |  | 	radeon_uvd_suspend(rdev); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	r700_cp_stop(rdev); | 
					
						
							| 
									
										
										
										
											2012-09-27 15:08:35 -04:00
										 |  |  | 	r600_dma_stop(rdev); | 
					
						
							| 
									
										
										
										
											2010-01-15 14:44:37 +01:00
										 |  |  | 	r600_irq_suspend(rdev); | 
					
						
							| 
									
										
										
										
											2010-08-27 18:25:25 -04:00
										 |  |  | 	radeon_wb_disable(rdev); | 
					
						
							| 
									
										
										
										
											2009-09-14 18:29:49 +02:00
										 |  |  | 	rv770_pcie_gart_disable(rdev); | 
					
						
							| 
									
										
										
										
											2011-10-14 10:51:22 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Plan is to move initialization in that function and use
 | 
					
						
							|  |  |  |  * helper function so that radeon_device_init pretty much | 
					
						
							|  |  |  |  * do nothing more than calling asic specific function. This | 
					
						
							|  |  |  |  * should also allow to remove a bunch of callback function | 
					
						
							|  |  |  |  * like vram_info. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | int rv770_init(struct radeon_device *rdev) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int r; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Read BIOS */ | 
					
						
							|  |  |  | 	if (!radeon_get_bios(rdev)) { | 
					
						
							|  |  |  | 		if (ASIC_IS_AVIVO(rdev)) | 
					
						
							|  |  |  | 			return -EINVAL; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	/* Must be an ATOMBIOS */ | 
					
						
							| 
									
										
										
										
											2009-10-01 18:02:15 +02:00
										 |  |  | 	if (!rdev->is_atom_bios) { | 
					
						
							|  |  |  | 		dev_err(rdev->dev, "Expecting atombios for R600 GPU\n"); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 		return -EINVAL; | 
					
						
							| 
									
										
										
										
											2009-10-01 18:02:15 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	r = radeon_atombios_init(rdev); | 
					
						
							|  |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 	/* Post card if necessary */ | 
					
						
							| 
									
										
										
										
											2011-01-11 18:08:59 -05:00
										 |  |  | 	if (!radeon_card_posted(rdev)) { | 
					
						
							| 
									
										
										
										
											2009-12-01 14:06:31 +10:00
										 |  |  | 		if (!rdev->bios) { | 
					
						
							|  |  |  | 			dev_err(rdev->dev, "Card not posted and no BIOS - ignoring\n"); | 
					
						
							|  |  |  | 			return -EINVAL; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 		DRM_INFO("GPU not posted. posting now...\n"); | 
					
						
							|  |  |  | 		atom_asic_init(rdev->mode_info.atom_context); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-02-26 15:59:47 -05:00
										 |  |  | 	/* init golden registers */ | 
					
						
							|  |  |  | 	rv770_init_golden_registers(rdev); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	/* Initialize scratch registers */ | 
					
						
							|  |  |  | 	r600_scratch_init(rdev); | 
					
						
							|  |  |  | 	/* Initialize surface registers */ | 
					
						
							|  |  |  | 	radeon_surface_init(rdev); | 
					
						
							| 
									
										
										
										
											2009-11-03 00:53:02 +01:00
										 |  |  | 	/* Initialize clocks */ | 
					
						
							| 
									
										
										
										
											2009-09-17 09:42:28 +02:00
										 |  |  | 	radeon_get_clock_info(rdev->ddev); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	/* Fence driver */ | 
					
						
							| 
									
										
										
										
											2011-11-20 20:45:34 +00:00
										 |  |  | 	r = radeon_fence_driver_init(rdev); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							| 
									
										
										
											
												drm/radeon/kms: simplify memory controller setup V2
Get rid of _location and use _start/_end also simplify the
computation of vram_start|end & gtt_start|end. For R1XX-R2XX
we place VRAM at the same address of PCI aperture, those GPU
shouldn't have much memory and seems to behave better when
setup that way. For R3XX and newer we place VRAM at 0. For
R6XX-R7XX AGP we place VRAM before or after AGP aperture this
might limit to limit the VRAM size but it's very unlikely.
For IGP we don't change the VRAM placement.
Tested on (compiz,quake3,suspend/resume):
PCI/PCIE:RV280,R420,RV515,RV570,RV610,RV710
AGP:RV100,RV280,R420,RV350,RV620(RPB*),RV730
IGP:RS480(RPB*),RS690,RS780(RPB*),RS880
RPB: resume previously broken
V2 correct commit message to reflect more accurately the bug
and move VRAM placement to 0 for most of the GPU to avoid
limiting VRAM.
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
											
										 
											2010-02-17 21:54:29 +00:00
										 |  |  | 	/* initialize AGP */ | 
					
						
							| 
									
										
										
										
											2010-01-13 15:16:38 +01:00
										 |  |  | 	if (rdev->flags & RADEON_IS_AGP) { | 
					
						
							|  |  |  | 		r = radeon_agp_init(rdev); | 
					
						
							|  |  |  | 		if (r) | 
					
						
							|  |  |  | 			radeon_agp_disable(rdev); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	r = rv770_mc_init(rdev); | 
					
						
							| 
									
										
										
										
											2009-10-06 19:04:29 +02:00
										 |  |  | 	if (r) | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 		return r; | 
					
						
							|  |  |  | 	/* Memory manager */ | 
					
						
							| 
									
										
										
										
											2009-11-20 14:29:23 +01:00
										 |  |  | 	r = radeon_bo_init(rdev); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							| 
									
										
										
										
											2009-12-01 13:43:46 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-18 19:11:27 -05:00
										 |  |  | 	if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { | 
					
						
							|  |  |  | 		r = r600_init_microcode(rdev); | 
					
						
							|  |  |  | 		if (r) { | 
					
						
							|  |  |  | 			DRM_ERROR("Failed to load firmware!\n"); | 
					
						
							|  |  |  | 			return r; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-18 14:07:14 -05:00
										 |  |  | 	/* Initialize power management */ | 
					
						
							|  |  |  | 	radeon_pm_init(rdev); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-23 12:56:27 +02:00
										 |  |  | 	rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ring_obj = NULL; | 
					
						
							|  |  |  | 	r600_ring_init(rdev, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX], 1024 * 1024); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-27 15:08:35 -04:00
										 |  |  | 	rdev->ring[R600_RING_TYPE_DMA_INDEX].ring_obj = NULL; | 
					
						
							|  |  |  | 	r600_ring_init(rdev, &rdev->ring[R600_RING_TYPE_DMA_INDEX], 64 * 1024); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:29 +02:00
										 |  |  | 	r = radeon_uvd_init(rdev); | 
					
						
							|  |  |  | 	if (!r) { | 
					
						
							|  |  |  | 		rdev->ring[R600_RING_TYPE_UVD_INDEX].ring_obj = NULL; | 
					
						
							|  |  |  | 		r600_ring_init(rdev, &rdev->ring[R600_RING_TYPE_UVD_INDEX], | 
					
						
							|  |  |  | 			       4096); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-01 13:43:46 -05:00
										 |  |  | 	rdev->ih.ring_obj = NULL; | 
					
						
							|  |  |  | 	r600_ih_ring_init(rdev, 64 * 1024); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-14 18:29:49 +02:00
										 |  |  | 	r = r600_pcie_gart_init(rdev); | 
					
						
							|  |  |  | 	if (r) | 
					
						
							|  |  |  | 		return r; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-09 19:31:44 -05:00
										 |  |  | 	rdev->accel_working = true; | 
					
						
							| 
									
										
										
										
											2009-09-18 15:19:37 +10:00
										 |  |  | 	r = rv770_startup(rdev); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	if (r) { | 
					
						
							| 
									
										
										
										
											2010-02-02 11:51:45 +01:00
										 |  |  | 		dev_err(rdev->dev, "disabling GPU acceleration\n"); | 
					
						
							| 
									
										
										
										
											2010-03-24 13:36:43 -04:00
										 |  |  | 		r700_cp_fini(rdev); | 
					
						
							| 
									
										
										
										
											2012-09-27 15:08:35 -04:00
										 |  |  | 		r600_dma_fini(rdev); | 
					
						
							| 
									
										
										
										
											2010-02-02 11:51:45 +01:00
										 |  |  | 		r600_irq_fini(rdev); | 
					
						
							| 
									
										
										
										
											2010-08-27 18:25:25 -04:00
										 |  |  | 		radeon_wb_fini(rdev); | 
					
						
							| 
									
										
										
										
											2012-07-05 11:55:34 +02:00
										 |  |  | 		radeon_ib_pool_fini(rdev); | 
					
						
							| 
									
										
										
										
											2010-02-02 11:51:45 +01:00
										 |  |  | 		radeon_irq_kms_fini(rdev); | 
					
						
							| 
									
										
										
										
											2009-10-01 18:02:14 +02:00
										 |  |  | 		rv770_pcie_gart_fini(rdev); | 
					
						
							| 
									
										
										
										
											2009-09-16 15:24:21 +02:00
										 |  |  | 		rdev->accel_working = false; | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-03-06 13:03:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void rv770_fini(struct radeon_device *rdev) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-12-18 14:07:14 -05:00
										 |  |  | 	radeon_pm_fini(rdev); | 
					
						
							| 
									
										
										
										
											2010-03-24 13:36:43 -04:00
										 |  |  | 	r700_cp_fini(rdev); | 
					
						
							| 
									
										
										
										
											2012-09-27 15:08:35 -04:00
										 |  |  | 	r600_dma_fini(rdev); | 
					
						
							| 
									
										
										
										
											2009-12-01 13:43:46 -05:00
										 |  |  | 	r600_irq_fini(rdev); | 
					
						
							| 
									
										
										
										
											2010-08-27 18:25:25 -04:00
										 |  |  | 	radeon_wb_fini(rdev); | 
					
						
							| 
									
										
										
										
											2012-07-05 11:55:34 +02:00
										 |  |  | 	radeon_ib_pool_fini(rdev); | 
					
						
							| 
									
										
										
										
											2009-12-01 13:43:46 -05:00
										 |  |  | 	radeon_irq_kms_fini(rdev); | 
					
						
							| 
									
										
										
										
											2013-08-13 11:56:53 +02:00
										 |  |  | 	uvd_v1_0_fini(rdev); | 
					
						
							| 
									
										
										
										
											2013-04-08 12:41:29 +02:00
										 |  |  | 	radeon_uvd_fini(rdev); | 
					
						
							| 
									
										
										
										
											2014-02-26 19:22:47 -05:00
										 |  |  | 	rv770_pcie_gart_fini(rdev); | 
					
						
							| 
									
										
										
										
											2011-10-28 10:30:02 -04:00
										 |  |  | 	r600_vram_scratch_fini(rdev); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	radeon_gem_fini(rdev); | 
					
						
							|  |  |  | 	radeon_fence_driver_fini(rdev); | 
					
						
							| 
									
										
										
										
											2010-01-07 16:08:32 +01:00
										 |  |  | 	radeon_agp_fini(rdev); | 
					
						
							| 
									
										
										
										
											2009-11-20 14:29:23 +01:00
										 |  |  | 	radeon_bo_fini(rdev); | 
					
						
							| 
									
										
										
										
											2009-10-01 18:02:15 +02:00
										 |  |  | 	radeon_atombios_fini(rdev); | 
					
						
							| 
									
										
										
										
											2009-09-08 10:10:24 +10:00
										 |  |  | 	kfree(rdev->bios); | 
					
						
							|  |  |  | 	rdev->bios = NULL; | 
					
						
							| 
									
										
										
										
											2009-06-05 14:42:42 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | static void rv770_pcie_gen2_enable(struct radeon_device *rdev) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u32 link_width_cntl, lanes, speed_cntl, tmp; | 
					
						
							|  |  |  | 	u16 link_cntl2; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-12 20:05:11 -05:00
										 |  |  | 	if (radeon_pcie_gen2 == 0) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 	if (rdev->flags & RADEON_IS_IGP) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!(rdev->flags & RADEON_IS_PCIE)) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* x2 cards have a special sequence */ | 
					
						
							|  |  |  | 	if (ASIC_IS_X2(rdev)) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-03 19:43:13 -03:00
										 |  |  | 	if ((rdev->pdev->bus->max_bus_speed != PCIE_SPEED_5_0GT) && | 
					
						
							|  |  |  | 		(rdev->pdev->bus->max_bus_speed != PCIE_SPEED_8_0GT)) | 
					
						
							| 
									
										
										
										
											2012-06-27 08:35:54 +01:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 	/* advertise upconfig capability */ | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 	link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 	link_width_cntl &= ~LC_UPCONFIGURE_DIS; | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 	WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); | 
					
						
							|  |  |  | 	link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 	if (link_width_cntl & LC_RENEGOTIATION_SUPPORT) { | 
					
						
							|  |  |  | 		lanes = (link_width_cntl & LC_LINK_WIDTH_RD_MASK) >> LC_LINK_WIDTH_RD_SHIFT; | 
					
						
							|  |  |  | 		link_width_cntl &= ~(LC_LINK_WIDTH_MASK | | 
					
						
							|  |  |  | 				     LC_RECONFIG_ARC_MISSING_ESCAPE); | 
					
						
							|  |  |  | 		link_width_cntl |= lanes | LC_RECONFIG_NOW | | 
					
						
							|  |  |  | 			LC_RENEGOTIATE_EN | LC_UPCONFIGURE_SUPPORT; | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 		WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 	} else { | 
					
						
							|  |  |  | 		link_width_cntl |= LC_UPCONFIGURE_DIS; | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 		WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 	speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 	if ((speed_cntl & LC_OTHER_SIDE_EVER_SENT_GEN2) && | 
					
						
							|  |  |  | 	    (speed_cntl & LC_OTHER_SIDE_SUPPORTS_GEN2)) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		tmp = RREG32(0x541c); | 
					
						
							|  |  |  | 		WREG32(0x541c, tmp | 0x8); | 
					
						
							|  |  |  | 		WREG32(MM_CFGREGS_CNTL, MM_WR_TO_CFG_EN); | 
					
						
							|  |  |  | 		link_cntl2 = RREG16(0x4088); | 
					
						
							|  |  |  | 		link_cntl2 &= ~TARGET_LINK_SPEED_MASK; | 
					
						
							|  |  |  | 		link_cntl2 |= 0x2; | 
					
						
							|  |  |  | 		WREG16(0x4088, link_cntl2); | 
					
						
							|  |  |  | 		WREG32(MM_CFGREGS_CNTL, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 		speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 		speed_cntl &= ~LC_TARGET_LINK_SPEED_OVERRIDE_EN; | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 		WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 		speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 		speed_cntl |= LC_CLR_FAILED_SPD_CHANGE_CNT; | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 		WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 		speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 		speed_cntl &= ~LC_CLR_FAILED_SPD_CHANGE_CNT; | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 		WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 		speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 		speed_cntl |= LC_GEN2_EN_STRAP; | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 		WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 		link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 		/* XXX: only disable it if gen1 bridge vendor == 0x111d or 0x1106 */ | 
					
						
							|  |  |  | 		if (1) | 
					
						
							|  |  |  | 			link_width_cntl |= LC_UPCONFIGURE_DIS; | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			link_width_cntl &= ~LC_UPCONFIGURE_DIS; | 
					
						
							| 
									
										
										
										
											2012-10-25 16:06:59 -04:00
										 |  |  | 		WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); | 
					
						
							| 
									
										
										
										
											2011-01-06 18:49:35 -05:00
										 |  |  | 	} | 
					
						
							|  |  |  | } |