30 #include <linux/slab.h>
39 #define R700_PFP_UCODE_SIZE 848
40 #define R700_PM4_UCODE_SIZE 1360
75 DRM_DEBUG(
"Update pending now high. Unlocking vupdate_lock.\n");
94 else if (temp & 0x200)
96 else if (temp & 0x100) {
97 actual_temp = temp & 0x1ff;
98 actual_temp |= ~0x1ff;
100 actual_temp = temp & 0xff;
102 return (actual_temp * 1000) / 2;
107 int req_ps_idx = rdev->
pm.requested_power_state_index;
108 int req_cm_idx = rdev->
pm.requested_clock_mode_index;
114 if (voltage->
voltage == 0xff01)
116 if (voltage->
voltage != rdev->
pm.current_vddc) {
118 rdev->
pm.current_vddc = voltage->
voltage;
119 DRM_DEBUG(
"Setting: v: %d\n", voltage->
voltage);
133 dev_err(rdev->
dev,
"No VRAM object for PCIE GART.\n");
167 for (i = 1; i < 7; i++)
171 DRM_INFO(
"PCIE GART of %uM enabled (table at 0x%016llX).\n",
172 (
unsigned)(rdev->
mc.gtt_size >> 20),
173 (
unsigned long long)rdev->
gart.table_addr);
174 rdev->
gart.ready =
true;
178 static void rv770_pcie_gart_disable(
struct radeon_device *rdev)
184 for (i = 0; i < 7; i++)
207 rv770_pcie_gart_disable(rdev);
235 for (i = 0; i < 7; i++)
246 for (i = 0, j = 0; i < 32; i++, j += 0x18) {
247 WREG32((0x2c14 + j), 0x00000000);
248 WREG32((0x2c18 + j), 0x00000000);
249 WREG32((0x2c1c + j), 0x00000000);
250 WREG32((0x2c20 + j), 0x00000000);
251 WREG32((0x2c24 + j), 0x00000000);
260 dev_warn(rdev->
dev,
"Wait for MC idle timedout !\n");
266 if (rdev->
mc.vram_start < rdev->
mc.gtt_start) {
269 rdev->
mc.vram_start >> 12);
271 rdev->
mc.gtt_end >> 12);
275 rdev->
mc.gtt_start >> 12);
277 rdev->
mc.vram_end >> 12);
281 rdev->
mc.vram_start >> 12);
283 rdev->
mc.vram_end >> 12);
286 tmp = ((rdev->
mc.vram_end >> 24) & 0xFFFF) << 16;
287 tmp |= ((rdev->
mc.vram_start >> 24) & 0xFFFF);
302 dev_warn(rdev->
dev,
"Wait for MC idle timedout !\n");
321 static int rv770_cp_load_microcode(
struct radeon_device *rdev)
372 int i,
j, num_qd_pipes;
377 u32 num_gs_verts_per_thread;
379 u32 gs_prim_buffer_depth = 0;
380 u32 sq_ms_fifo_sizes;
382 u32 sq_thread_resource_mgmt;
383 u32 hdp_host_path_cntl;
384 u32 sq_dyn_gpr_size_simd_ab_0;
385 u32 gb_tiling_config = 0;
386 u32 cc_rb_backend_disable = 0;
387 u32 cc_gc_shader_pipe_config = 0;
390 u32 inactive_pipes, shader_pipe_config;
391 u32 disabled_rb_mask;
392 unsigned active_number;
415 rdev->
config.
rv770.sc_earlyz_tile_fifo_fize = 0x130;
435 rdev->
config.
rv770.sc_earlyz_tile_fifo_fize = 0x130;
436 if (rdev->
config.
rv770.sx_max_export_pos_size > 16) {
459 rdev->
config.
rv770.sc_earlyz_tile_fifo_fize = 0x130;
479 rdev->
config.
rv770.sc_earlyz_tile_fifo_fize = 0x130;
481 if (rdev->
config.
rv770.sx_max_export_pos_size > 16) {
492 for (i = 0; i < 32; i++) {
493 WREG32((0x2c14 + j), 0x00000000);
494 WREG32((0x2c18 + j), 0x00000000);
495 WREG32((0x2c1c + j), 0x00000000);
496 WREG32((0x2c20 + j), 0x00000000);
497 WREG32((0x2c24 + j), 0x00000000);
508 for (i = 0, tmp = 1, active_number = 0; i <
R7XX_MAX_PIPES; i++) {
509 if (!(inactive_pipes & tmp)) {
514 if (active_number == 1) {
522 if (tmp < rdev->
config.rv770.max_backends) {
528 if (tmp < rdev->
config.rv770.max_pipes) {
532 if (tmp < rdev->
config.rv770.max_simds) {
557 gb_tiling_config |= tmp << 16;
568 rdev->
config.
rv770.tiling_nbanks = 4 << ((gb_tiling_config >> 4) & 0x3);
748 gs_prim_buffer_depth = 384;
751 gs_prim_buffer_depth = 128;
757 num_gs_verts_per_thread = rdev->
config.
rv770.max_pipes * 16;
758 vgt_gs_per_es = gs_prim_buffer_depth + num_gs_verts_per_thread;
760 if (vgt_gs_per_es > 256)
805 u64 size_bf, size_af;
815 size_af = 0xFFFFFFFF - mc->
gtt_end;
816 if (size_bf > size_af) {
832 dev_info(rdev->
dev,
"VRAM: %lluM 0x%08llX - 0x%08llX (%lluM used)\n",
837 rdev->
mc.gtt_base_align = 0;
845 int chansize, numchan;
848 rdev->
mc.vram_is_ddr =
true;
873 rdev->
mc.vram_width = numchan * chansize;
880 rdev->
mc.visible_vram_size = rdev->
mc.aper_size;
893 rv770_pcie_gen2_enable(rdev);
898 DRM_ERROR(
"Failed to load firmware!\n");
907 rv770_mc_program(rdev);
909 rv770_agp_enable(rdev);
911 r = rv770_pcie_gart_enable(rdev);
916 rv770_gpu_init(rdev);
921 dev_warn(rdev->
dev,
"failed blitter (%d) falling back to memcpy\n", r);
931 dev_err(rdev->
dev,
"failed initializing CP fences (%d).\n", r);
938 DRM_ERROR(
"radeon: IH init failed (%d).\n", r);
949 r = rv770_cp_load_microcode(rdev);
958 dev_err(rdev->
dev,
"IB initialization failed (%d).\n", r);
964 DRM_ERROR(
"radeon: audio init failed\n");
983 r = rv770_startup(rdev);
985 DRM_ERROR(
"r600 startup failed on resume\n");
1001 rv770_pcie_gart_disable(rdev);
1023 dev_err(rdev->
dev,
"Expecting atombios for R600 GPU\n");
1032 dev_err(rdev->
dev,
"Card not posted and no BIOS - ignoring\n");
1035 DRM_INFO(
"GPU not posted. posting now...\n");
1054 r = rv770_mc_init(rdev);
1069 rdev->
ih.ring_obj =
NULL;
1077 r = rv770_startup(rdev);
1079 dev_err(rdev->
dev,
"disabling GPU acceleration\n");
1085 rv770_pcie_gart_fini(rdev);
1100 rv770_pcie_gart_fini(rdev);
1111 static void rv770_pcie_gen2_enable(
struct radeon_device *rdev)
1135 if (!(mask & DRM_PCIE_SPEED_50))
1138 DRM_INFO(
"enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n");
1162 WREG32(0x541c, tmp | 0x8);
1164 link_cntl2 =
RREG16(0x4088);
1167 WREG16(0x4088, link_cntl2);