FreeBSD/sys/dev/drm2/radeon/ni.c
/* 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.
 */
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.
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 cayman_init(struct radeon_device *rdev)
{
	struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
	int r;
	if (!radeon_get_bios(rdev)) {
		if (ASIC_IS_AVIVO(rdev))
			return -EINVAL;
	}
	if (!rdev->is_atom_bios) {
		dev_err(rdev->dev, "Expecting atombios for cayman GPU\n");
		return -EINVAL;
	}
	r = radeon_atombios_init(rdev);
	if (r)
		return r;
	if (!radeon_card_posted(rdev)) {
		if (!rdev->bios) {
			dev_err(rdev->dev, "Card not posted and no BIOS - ignoring\n");
			return -EINVAL;
		}
		DRM_INFO("GPU not posted. posting now...\n");
		atom_asic_init(rdev->mode_info.atom_context);
	}
	r600_scratch_init(rdev);
	radeon_surface_init(rdev);
	radeon_get_clock_info(rdev->ddev);
	r = radeon_fence_driver_init(rdev);
	if (r)
		return r;
	r = evergreen_mc_init(rdev);
	if (r)
		return r;
	r = radeon_bo_init(rdev);
	if (r)
		return r;
	r = radeon_irq_kms_init(rdev);
	if (r)
		return r;
	ring->ring_obj = NULL;
	r600_ring_init(rdev, ring, 1024 * 1024);
	ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX];
	ring->ring_obj = NULL;
	r600_ring_init(rdev, ring, 64 * 1024);
	ring = &rdev->ring[CAYMAN_RING_TYPE_DMA1_INDEX];
	ring->ring_obj = NULL;
	r600_ring_init(rdev, ring, 64 * 1024);
	rdev->ih.ring_obj = NULL;
	r600_ih_ring_init(rdev, 64 * 1024);
	r = r600_pcie_gart_init(rdev);
	if (r)
		return r;
	rdev->accel_working = true;
	r = cayman_startup(rdev);
	if (r) {
		dev_err(rdev->dev, "disabling GPU acceleration\n");
		cayman_cp_fini(rdev);
		cayman_dma_fini(rdev);
		r600_irq_fini(rdev);
		if (rdev->flags & RADEON_IS_IGP)
			si_rlc_fini(rdev);
		radeon_wb_fini(rdev);
		radeon_ib_pool_fini(rdev);
		radeon_vm_manager_fini(rdev);
		radeon_irq_kms_fini(rdev);
		cayman_pcie_gart_fini(rdev);
		rdev->accel_working = false;
	}
	if (!rdev->mc_fw && !(rdev->flags & RADEON_IS_IGP)) {
		DRM_ERROR("radeon: MC ucode required for NI+.\n");
		return -EINVAL;
	}
	return 0;
}
int cayman_init ( struct radeon_device * rdev ) { struct radeon_ring * ring = & rdev -> ring [ RADEON_RING_TYPE_GFX_INDEX ] ; int r ; if ( ! radeon_get_bios ( rdev ) ) { if ( ASIC_IS_AVIVO ( rdev ) ) return - EINVAL ; } if ( ! rdev -> is_atom_bios ) { dev_err ( rdev -> dev , " \n " ) ; return - EINVAL ; } r = radeon_atombios_init ( rdev ) ; if ( r ) return r ; if ( ! radeon_card_posted ( rdev ) ) { if ( ! rdev -> bios ) { dev_err ( rdev -> dev , " \n " ) ; return - EINVAL ; } DRM_INFO ( " \n " ) ; atom_asic_init ( rdev -> mode_info . atom_context ) ; } r600_scratch_init ( rdev ) ; radeon_surface_init ( rdev ) ; radeon_get_clock_info ( rdev -> ddev ) ; r = radeon_fence_driver_init ( rdev ) ; if ( r ) return r ; r = evergreen_mc_init ( rdev ) ; if ( r ) return r ; r = radeon_bo_init ( rdev ) ; if ( r ) return r ; r = radeon_irq_kms_init ( rdev ) ; if ( r ) return r ; ring -> ring_obj = NULL ; r600_ring_init ( rdev , ring , 1024 * 1024 ) ; ring = & rdev -> ring [ R600_RING_TYPE_DMA_INDEX ] ; ring -> ring_obj = NULL ; r600_ring_init ( rdev , ring , 64 * 1024 ) ; ring = & rdev -> ring [ CAYMAN_RING_TYPE_DMA1_INDEX ] ; ring -> ring_obj = NULL ; r600_ring_init ( rdev , ring , 64 * 1024 ) ; rdev -> ih . ring_obj = NULL ; r600_ih_ring_init ( rdev , 64 * 1024 ) ; r = r600_pcie_gart_init ( rdev ) ; if ( r ) return r ; rdev -> accel_working = true ; r = cayman_startup ( rdev ) ; if ( r ) { dev_err ( rdev -> dev , " \n " ) ; cayman_cp_fini ( rdev ) ; cayman_dma_fini ( rdev ) ; r600_irq_fini ( rdev ) ; if ( rdev -> flags & RADEON_IS_IGP ) si_rlc_fini ( rdev ) ; radeon_wb_fini ( rdev ) ; radeon_ib_pool_fini ( rdev ) ; radeon_vm_manager_fini ( rdev ) ; radeon_irq_kms_fini ( rdev ) ; cayman_pcie_gart_fini ( rdev ) ; rdev -> accel_working = false ; } if ( ! rdev -> mc_fw && ! ( rdev -> flags & RADEON_IS_IGP ) ) { DRM_ERROR ( " \n " ) ; return - EINVAL ; } 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.
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 .
/* Read BIOS */ /* Must be an ATOMBIOS */ /* Post card if necessary */ /* Initialize scratch registers */ /* Initialize surface registers */ /* Initialize clocks */ /* Fence driver */ /* initialize memory controller */ /* Memory manager */ /* Don't start up if the MC ucode is missing.
	 * The default clocks and voltages before the MC ucode
	 * is loaded are not suffient for advanced operations.
	 *
	 * We can skip this check for TN, because there is no MC
	 * ucode.
	 */