Subversion Repositories Kolibri OS

Rev

Rev 1430 | Rev 1986 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1430 Rev 1963
Line 26... Line 26...
26
 *          Jerome Glisse
26
 *          Jerome Glisse
27
 */
27
 */
28
#include 
28
#include 
29
#include 
29
#include 
30
#include "radeon.h"
30
#include "radeon.h"
-
 
31
#include "radeon_asic.h"
31
#include "rs400d.h"
32
#include "rs400d.h"
Line 32... Line 33...
32
 
33
 
33
/* This files gather functions specifics to : rs400,rs480 */
34
/* This files gather functions specifics to : rs400,rs480 */
Line 51... Line 52...
51
		DRM_ERROR("Valid GART size for IGP are 32M,64M,128M,256M,512M,1G,2G\n");
52
		DRM_ERROR("Valid GART size for IGP are 32M,64M,128M,256M,512M,1G,2G\n");
52
		DRM_ERROR("Forcing to 32M GART size\n");
53
		DRM_ERROR("Forcing to 32M GART size\n");
53
		rdev->mc.gtt_size = 32 * 1024 * 1024;
54
		rdev->mc.gtt_size = 32 * 1024 * 1024;
54
		return;
55
		return;
55
	}
56
	}
56
	if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) {
-
 
57
		/* FIXME: RS400 & RS480 seems to have issue with GART size
-
 
58
		 * if 4G of system memory (needs more testing) */
-
 
59
		rdev->mc.gtt_size = 32 * 1024 * 1024;
-
 
60
		DRM_ERROR("Forcing to 32M GART size (because of ASIC bug ?)\n");
-
 
61
	}
-
 
62
}
57
}
Line 63... Line 58...
63
 
58
 
64
void rs400_gart_tlb_flush(struct radeon_device *rdev)
59
void rs400_gart_tlb_flush(struct radeon_device *rdev)
65
{
60
{
Line 80... Line 75...
80
int rs400_gart_init(struct radeon_device *rdev)
75
int rs400_gart_init(struct radeon_device *rdev)
81
{
76
{
82
	int r;
77
	int r;
Line 83... Line 78...
83
 
78
 
84
	if (rdev->gart.table.ram.ptr) {
79
	if (rdev->gart.table.ram.ptr) {
85
		WARN(1, "RS400 GART already initialized.\n");
80
		WARN(1, "RS400 GART already initialized\n");
86
		return 0;
81
		return 0;
87
	}
82
	}
88
	/* Check gart size */
83
	/* Check gart size */
89
	switch(rdev->mc.gtt_size / (1024 * 1024)) {
84
	switch(rdev->mc.gtt_size / (1024 * 1024)) {
Line 200... Line 195...
200
	WREG32_MC(RS480_AGP_ADDRESS_SPACE_SIZE, 0);
195
	WREG32_MC(RS480_AGP_ADDRESS_SPACE_SIZE, 0);
201
}
196
}
Line 202... Line 197...
202
 
197
 
203
void rs400_gart_fini(struct radeon_device *rdev)
198
void rs400_gart_fini(struct radeon_device *rdev)
-
 
199
{
204
{
200
	radeon_gart_fini(rdev);
205
	rs400_gart_disable(rdev);
201
	rs400_gart_disable(rdev);
206
	radeon_gart_table_ram_free(rdev);
-
 
207
	radeon_gart_fini(rdev);
202
	radeon_gart_table_ram_free(rdev);
Line -... Line 203...
-
 
203
}
-
 
204
 
-
 
205
#define RS400_PTE_WRITEABLE (1 << 2)
208
}
206
#define RS400_PTE_READABLE  (1 << 3)
209
 
207
 
210
int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
208
int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
Line 211... Line 209...
211
{
209
{
212
	uint32_t entry;
210
	uint32_t entry;
213
 
211
 
Line 214... Line 212...
214
	if (i < 0 || i > rdev->gart.num_gpu_pages) {
212
	if (i < 0 || i > rdev->gart.num_gpu_pages) {
215
		return -EINVAL;
213
		return -EINVAL;
216
	}
214
	}
217
 
215
 
218
	entry = (lower_32_bits(addr) & PAGE_MASK) |
216
	entry = (lower_32_bits(addr) & PAGE_MASK) |
219
		((upper_32_bits(addr) & 0xff) << 4) |
217
		((upper_32_bits(addr) & 0xff) << 4) |
220
		0xc;
218
		RS400_PTE_WRITEABLE | RS400_PTE_READABLE;
Line 228... Line 226...
228
	unsigned i;
226
	unsigned i;
229
	uint32_t tmp;
227
	uint32_t tmp;
Line 230... Line 228...
230
 
228
 
231
	for (i = 0; i < rdev->usec_timeout; i++) {
229
	for (i = 0; i < rdev->usec_timeout; i++) {
232
		/* read MC_STATUS */
230
		/* read MC_STATUS */
233
		tmp = RREG32(0x0150);
231
		tmp = RREG32(RADEON_MC_STATUS);
234
		if (tmp & (1 << 2)) {
232
		if (tmp & RADEON_MC_IDLE) {
235
			return 0;
233
			return 0;
236
		}
234
		}
237
		DRM_UDELAY(1);
235
		DRM_UDELAY(1);
238
	}
236
	}
239
	return -1;
237
	return -1;
Line 240... Line 238...
240
}
238
}
241
 
239
 
242
void rs400_gpu_init(struct radeon_device *rdev)
-
 
243
{
-
 
244
	/* FIXME: HDP same place on rs400 ? */
240
void rs400_gpu_init(struct radeon_device *rdev)
245
	r100_hdp_reset(rdev);
241
{
246
	/* FIXME: is this correct ? */
242
	/* FIXME: is this correct ? */
247
	r420_pipes_init(rdev);
243
	r420_pipes_init(rdev);
248
	if (rs400_mc_wait_for_idle(rdev)) {
244
	if (rs400_mc_wait_for_idle(rdev)) {
249
		printk(KERN_WARNING "rs400: Failed to wait MC idle while "
245
		printk(KERN_WARNING "rs400: Failed to wait MC idle while "
250
		       "programming pipes. Bad things might happen. %08x\n", RREG32(0x150));
246
		       "programming pipes. Bad things might happen. %08x\n", RREG32(RADEON_MC_STATUS));
Line 251... Line 247...
251
	}
247
	}
252
}
248
}
Line 261... Line 257...
261
	rdev->mc.vram_is_ddr = true;
257
	rdev->mc.vram_is_ddr = true;
262
	rdev->mc.vram_width = 128;
258
	rdev->mc.vram_width = 128;
263
	r100_vram_init_sizes(rdev);
259
	r100_vram_init_sizes(rdev);
264
	base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16;
260
	base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16;
265
	radeon_vram_location(rdev, &rdev->mc, base);
261
	radeon_vram_location(rdev, &rdev->mc, base);
-
 
262
	rdev->mc.gtt_base_align = rdev->mc.gtt_size - 1;
266
	radeon_gtt_location(rdev, &rdev->mc);
263
	radeon_gtt_location(rdev, &rdev->mc);
-
 
264
	radeon_update_bandwidth_info(rdev);
267
}
265
}
Line 268... Line 266...
268
 
266
 
269
uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg)
267
uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg)
270
{
268
{
Line 302... Line 300...
302
		seq_printf(m, "MCCFG_AGP_BASE 0x%08x\n", tmp);
300
		seq_printf(m, "MCCFG_AGP_BASE 0x%08x\n", tmp);
303
		tmp = RREG32_MC(RS690_MCCFG_AGP_BASE_2);
301
		tmp = RREG32_MC(RS690_MCCFG_AGP_BASE_2);
304
		seq_printf(m, "MCCFG_AGP_BASE_2 0x%08x\n", tmp);
302
		seq_printf(m, "MCCFG_AGP_BASE_2 0x%08x\n", tmp);
305
		tmp = RREG32_MC(RS690_MCCFG_AGP_LOCATION);
303
		tmp = RREG32_MC(RS690_MCCFG_AGP_LOCATION);
306
		seq_printf(m, "MCCFG_AGP_LOCATION 0x%08x\n", tmp);
304
		seq_printf(m, "MCCFG_AGP_LOCATION 0x%08x\n", tmp);
307
		tmp = RREG32_MC(0x100);
305
		tmp = RREG32_MC(RS690_MCCFG_FB_LOCATION);
308
		seq_printf(m, "MCCFG_FB_LOCATION 0x%08x\n", tmp);
306
		seq_printf(m, "MCCFG_FB_LOCATION 0x%08x\n", tmp);
309
		tmp = RREG32(0x134);
307
		tmp = RREG32(RS690_HDP_FB_LOCATION);
310
		seq_printf(m, "HDP_FB_LOCATION 0x%08x\n", tmp);
308
		seq_printf(m, "HDP_FB_LOCATION 0x%08x\n", tmp);
311
	} else {
309
	} else {
312
		tmp = RREG32(RADEON_AGP_BASE);
310
		tmp = RREG32(RADEON_AGP_BASE);
313
		seq_printf(m, "AGP_BASE 0x%08x\n", tmp);
311
		seq_printf(m, "AGP_BASE 0x%08x\n", tmp);
314
		tmp = RREG32(RS480_AGP_BASE_2);
312
		tmp = RREG32(RS480_AGP_BASE_2);
Line 386... Line 384...
386
 
384
 
387
static int rs400_startup(struct radeon_device *rdev)
385
static int rs400_startup(struct radeon_device *rdev)
388
{
386
{
Line -... Line 387...
-
 
387
	int r;
-
 
388
 
389
	int r;
389
	r100_set_common_regs(rdev);
390
 
390
 
391
	rs400_mc_program(rdev);
391
	rs400_mc_program(rdev);
392
	/* Resume clock */
392
	/* Resume clock */
393
	r300_clock_startup(rdev);
393
	r300_clock_startup(rdev);
Line 403... Line 403...
403
//	r100_irq_set(rdev);
403
//	r100_irq_set(rdev);
404
	rdev->config.r300.hdp_cntl = RREG32(RADEON_HOST_PATH_CNTL);
404
	rdev->config.r300.hdp_cntl = RREG32(RADEON_HOST_PATH_CNTL);
405
	/* 1M ring buffer */
405
	/* 1M ring buffer */
406
   r = r100_cp_init(rdev, 1024 * 1024);
406
   r = r100_cp_init(rdev, 1024 * 1024);
407
   if (r) {
407
   if (r) {
408
       dev_err(rdev->dev, "failled initializing CP (%d).\n", r);
408
		dev_err(rdev->dev, "failed initializing CP (%d).\n", r);
409
       return r;
409
       return r;
410
   }
410
   }
411
//	r = r100_wb_init(rdev);
-
 
412
//	if (r)
-
 
413
//		dev_err(rdev->dev, "failled initializing WB (%d).\n", r);
-
 
414
//	r = r100_ib_init(rdev);
411
//	r = r100_ib_init(rdev);
415
//	if (r) {
412
//	if (r) {
416
//		dev_err(rdev->dev, "failled initializing IB (%d).\n", r);
413
//		dev_err(rdev->dev, "failled initializing IB (%d).\n", r);
417
//		return r;
414
//		return r;
418
//	}
415
//	}
Line 431... Line 428...
431
	/* Initialize scratch registers */
428
	/* Initialize scratch registers */
432
	radeon_scratch_init(rdev);
429
	radeon_scratch_init(rdev);
433
	/* Initialize surface registers */
430
	/* Initialize surface registers */
434
	radeon_surface_init(rdev);
431
	radeon_surface_init(rdev);
435
	/* TODO: disable VGA need to use VGA request */
432
	/* TODO: disable VGA need to use VGA request */
-
 
433
	/* restore some register to sane defaults */
-
 
434
	r100_restore_sanity(rdev);
436
	/* BIOS*/
435
	/* BIOS*/
437
	if (!radeon_get_bios(rdev)) {
436
	if (!radeon_get_bios(rdev)) {
438
		if (ASIC_IS_AVIVO(rdev))
437
		if (ASIC_IS_AVIVO(rdev))
439
			return -EINVAL;
438
			return -EINVAL;
440
	}
439
	}
Line 445... Line 444...
445
		r = radeon_combios_init(rdev);
444
		r = radeon_combios_init(rdev);
446
		if (r)
445
		if (r)
447
			return r;
446
			return r;
448
	}
447
	}
449
	/* Reset gpu before posting otherwise ATOM will enter infinite loop */
448
	/* Reset gpu before posting otherwise ATOM will enter infinite loop */
450
	if (radeon_gpu_reset(rdev)) {
449
	if (radeon_asic_reset(rdev)) {
451
		dev_warn(rdev->dev,
450
		dev_warn(rdev->dev,
452
			"GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n",
451
			"GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n",
453
			RREG32(R_000E40_RBBM_STATUS),
452
			RREG32(R_000E40_RBBM_STATUS),
454
			RREG32(R_0007C0_CP_STAT));
453
			RREG32(R_0007C0_CP_STAT));
455
	}
454
	}
Line 457... Line 456...
457
	if (radeon_boot_test_post_card(rdev) == false)
456
	if (radeon_boot_test_post_card(rdev) == false)
458
		return -EINVAL;
457
		return -EINVAL;
Line 459... Line 458...
459
 
458
 
460
	/* Initialize clocks */
459
	/* Initialize clocks */
461
	radeon_get_clock_info(rdev->ddev);
-
 
462
	/* Initialize power management */
-
 
463
	radeon_pm_init(rdev);
460
	radeon_get_clock_info(rdev->ddev);
464
	/* initialize memory controller */
461
	/* initialize memory controller */
465
	rs400_mc_init(rdev);
462
	rs400_mc_init(rdev);
466
	/* Fence driver */
463
	/* Fence driver */
467
//	r = radeon_fence_driver_init(rdev);
464
//	r = radeon_fence_driver_init(rdev);