_mali_osk_errcode_t mali_hw_core_create(struct mali_hw_core *core, const _mali_osk_resource_t *resource, u32 reg_size) { core->phys_addr = resource->base; core->description = resource->description; core->size = reg_size; if (_MALI_OSK_ERR_OK == _mali_osk_mem_reqregion(core->phys_addr, core->size, core->description)) { core->mapped_registers = _mali_osk_mem_mapioregion(core->phys_addr, core->size, core->description); if (NULL != core->mapped_registers) { return _MALI_OSK_ERR_OK; } else { MALI_PRINT_ERROR(("Failed to map memory region for core %s at phys_addr 0x%08X\n", core->description, core->phys_addr)); } _mali_osk_mem_unreqregion(core->phys_addr, core->size); } else { MALI_PRINT_ERROR(("Failed to request memory region for core %s at phys_addr 0x%08X\n", core->description, core->phys_addr)); } return _MALI_OSK_ERR_FAULT; }
_mali_osk_errcode_t mali_platform_init() { MALI_CHECK(init_mali_clock(), _MALI_OSK_ERR_FAULT); #if MALI_DVFS_ENABLED if (!clk_register_map) clk_register_map = _mali_osk_mem_mapioregion( CLK_DIV_STAT_G3D, 0x20, CLK_DESC ); if(!init_mali_dvfs_status(MALI_DVFS_DEFAULT_STEP)) MALI_DEBUG_PRINT(1, ("mali_platform_init failed\n")); #endif MALI_SUCCESS; }
_mali_osk_errcode_t mali_platform_init(struct device *dev) { MALI_CHECK(init_mali_clock(), _MALI_OSK_ERR_FAULT); #ifdef CONFIG_MALI_DVFS if (!clk_register_map) clk_register_map = _mali_osk_mem_mapioregion(CLK_DIV_STAT_G3D, 0x20, CLK_DESC); maliDvfsStatus.currentStep = MALI_DVFS_DEFAULT_STEP; #endif mali_platform_power_mode_change(dev, MALI_POWER_MODE_ON); MALI_SUCCESS; }
static mali_physical_memory_allocation_result block_allocator_allocate_page_table_block(void * ctx, mali_page_table_block * block) { block_allocator * info; mali_physical_memory_allocation_result result = MALI_MEM_ALLOC_INTERNAL_FAILURE; MALI_DEBUG_ASSERT_POINTER(ctx); MALI_DEBUG_ASSERT_POINTER(block); info = (block_allocator*)ctx; if (_MALI_OSK_ERR_OK != _mali_osk_lock_wait(info->mutex, _MALI_OSK_LOCKMODE_RW)) return MALI_MEM_ALLOC_INTERNAL_FAILURE; if (NULL != info->first_free) { void * virt; u32 phys; u32 size; block_info * alloc; alloc = info->first_free; phys = get_phys(info, alloc); /* Does not modify info or alloc */ size = MALI_BLOCK_SIZE; /* Must be multiple of MALI_MMU_PAGE_SIZE */ virt = _mali_osk_mem_mapioregion( phys, size, "Mali block allocator page tables" ); /* Failure of _mali_osk_mem_mapioregion will result in MALI_MEM_ALLOC_INTERNAL_FAILURE, * because it's unlikely another allocator will be able to map in. */ if ( NULL != virt ) { block->ctx = info; /* same as incoming ctx */ block->handle = alloc; block->phys_base = phys; block->size = size; block->release = block_allocator_release_page_table_block; block->mapping = virt; info->first_free = alloc->next; alloc->next = NULL; /* Could potentially link many blocks together instead */ result = MALI_MEM_ALLOC_FINISHED; } } else result = MALI_MEM_ALLOC_NONE; _mali_osk_lock_signal(info->mutex, _MALI_OSK_LOCKMODE_RW); return result; }
_mali_osk_errcode_t mali_pegasus_platform_init() { mali_gpu_clk = 266; mali_gpu_vol = 900000; MALI_CHECK(init_mali_pegasus_clock(), _MALI_OSK_ERR_FAULT); #ifdef CONFIG_EXYNOS_TMU_TC _mali_osk_atomic_init(&voltage_lock_status, 0); #endif #if MALI_DVFS_ENABLED if (!clk_pegasus_register_map) clk_pegasus_register_map = _mali_osk_mem_mapioregion( CLK_DIV_STAT_G3D, 0x20, CLK_DESC ); if(!init_mali_pegasus_dvfs_status(MALI_DVFS_DEFAULT_STEP)) MALI_DEBUG_PRINT(1, ("mali_platform_init failed\n")); #endif MALI_SUCCESS; }
_mali_osk_errcode_t mali_pmm_pmu_init(_mali_osk_resource_t *resource) { if( resource->type == PMU ) { if( (resource->base == 0) || (resource->description == NULL) ) { /* NOTE: We currently don't care about any other resource settings */ MALI_PRINT_ERROR(("PLATFORM mali400-pmu: Missing PMU set up information\n")); MALI_ERROR(_MALI_OSK_ERR_INVALID_ARGS); } pmu_info = (platform_pmu_t *)_mali_osk_malloc(sizeof(*pmu_info)); MALI_CHECK_NON_NULL( pmu_info, _MALI_OSK_ERR_NOMEM ); /* All values get 0 as default */ _mali_osk_memset(pmu_info, 0, sizeof(*pmu_info)); pmu_info->reg_base_addr = resource->base; pmu_info->reg_size = (u32)PMU_REGISTER_ADDRESS_SPACE_SIZE; pmu_info->name = resource->description; pmu_info->irq_num = resource->irq; if( _MALI_OSK_ERR_OK != _mali_osk_mem_reqregion(pmu_info->reg_base_addr, pmu_info->reg_size, pmu_info->name) ) { MALI_PRINT_ERROR(("PLATFORM mali400-pmu: Could not request register region (0x%08X - 0x%08X) for %s\n", pmu_info->reg_base_addr, pmu_info->reg_base_addr + pmu_info->reg_size - 1, pmu_info->name)); goto cleanup; } else { MALI_DEBUG_PRINT( 4, ("PLATFORM mali400-pmu: Success: request_mem_region: (0x%08X - 0x%08X) for %s\n", pmu_info->reg_base_addr, pmu_info->reg_base_addr + pmu_info->reg_size - 1, pmu_info->name)); } pmu_info->reg_mapped = _mali_osk_mem_mapioregion( pmu_info->reg_base_addr, pmu_info->reg_size, pmu_info->name ); if( 0 == pmu_info->reg_mapped ) { MALI_PRINT_ERROR(("PLATFORM mali400-pmu: Could not ioremap registers for %s .\n", pmu_info->name)); _mali_osk_mem_unreqregion( pmu_info->reg_base_addr, pmu_info->reg_size ); goto cleanup; } else { MALI_DEBUG_PRINT( 4, ("PLATFORM mali400-pmu: Success: ioremap_nocache: Internal ptr: (0x%08X - 0x%08X) for %s\n", (u32) pmu_info->reg_mapped, ((u32)pmu_info->reg_mapped)+ pmu_info->reg_size - 1, pmu_info->name)); } MALI_DEBUG_PRINT( 4, ("PLATFORM mali400-pmu: Success: Mapping registers to %s\n", pmu_info->name)); #if PMU_TEST pmu_test(pmu_info, (MALI_PMM_CORE_GP)); pmu_test(pmu_info, (MALI_PMM_CORE_GP|MALI_PMM_CORE_L2|MALI_PMM_CORE_PP0)); #endif MALI_DEBUG_PRINT( 4, ("PLATFORM mali400-pmu: Initialized - %s\n", pmu_info->name) ); } else { /* Didn't expect a different resource */ MALI_ERROR(_MALI_OSK_ERR_INVALID_ARGS); } MALI_SUCCESS; cleanup: _mali_osk_free(pmu_info); pmu_info = NULL; MALI_ERROR(_MALI_OSK_ERR_NOMEM); }
_mali_osk_errcode_t mali_platform_init(_mali_osk_resource_t *resource) { unsigned long rate; int clk_div; int mali_used = 0; //get mali ahb clock h_ahb_mali = clk_get(NULL, "ahb_mali"); if(!h_ahb_mali){ MALI_PRINT(("try to get ahb mali clock failed!\n")); } //get mali clk h_mali_clk = clk_get(NULL, "mali"); if(!h_mali_clk){ MALI_PRINT(("try to get mali clock failed!\n")); } h_ve_pll = clk_get(NULL, "ve_pll"); if(!h_ve_pll){ MALI_PRINT(("try to get ve pll clock failed!\n")); } //set mali parent clock if(clk_set_parent(h_mali_clk, h_ve_pll)){ MALI_PRINT(("try to set mali clock source failed!\n")); } //set mali clock rate = clk_get_rate(h_ve_pll); if(!script_parser_fetch("mali_para", "mali_used", &mali_used, 1)) { if (mali_used == 1) { if (!script_parser_fetch("mali_para", "mali_clkdiv", &clk_div, 1)) { if (clk_div > 0) { pr_info("mali: use config clk_div %d\n", clk_div); mali_clk_div = clk_div; } } } } pr_info("mali: clk_div %d\n", mali_clk_div); rate /= mali_clk_div; if(clk_set_rate(h_mali_clk, rate)){ MALI_PRINT(("try to set mali clock failed!\n")); } if(clk_reset(h_mali_clk,0)){ MALI_PRINT(("try to reset release failed!\n")); } MALI_PRINT(("mali clock set completed, clock is %d Mhz\n", rate)); #if USING_MALI_PMM if( resource == NULL ) { /* Nothing to set up for the system */ } else if( resource->type == PMU ) { if( (resource->base == 0) || (resource->description == NULL) ) { /* NOTE: We currently don't care about any other resource settings */ MALI_PRINT_ERROR(("PLATFORM mali400-pmu: Missing PMU set up information\n")); MALI_ERROR(_MALI_OSK_ERR_INVALID_ARGS); } MALI_DEBUG_ASSERT( pmu_info == NULL ); pmu_info = (platform_pmu_t *)_mali_osk_malloc(sizeof(*pmu_info)); MALI_CHECK_NON_NULL( pmu_info, _MALI_OSK_ERR_NOMEM ); /* All values get 0 as default */ _mali_osk_memset(pmu_info, 0, sizeof(*pmu_info)); pmu_info->reg_base_addr = resource->base; pmu_info->reg_size = (u32)PMU_REGISTER_ADDRESS_SPACE_SIZE; pmu_info->name = resource->description; pmu_info->irq_num = resource->irq; if( _MALI_OSK_ERR_OK != _mali_osk_mem_reqregion(pmu_info->reg_base_addr, pmu_info->reg_size, pmu_info->name) ) { MALI_PRINT_ERROR(("PLATFORM mali400-pmu: Could not request register region (0x%08X - 0x%08X) for %s\n", pmu_info->reg_base_addr, pmu_info->reg_base_addr + pmu_info->reg_size - 1, pmu_info->name)); goto cleanup; } else { MALI_DEBUG_PRINT( 4, ("PLATFORM mali400-pmu: Success: request_mem_region: (0x%08X - 0x%08X) for %s\n", pmu_info->reg_base_addr, pmu_info->reg_base_addr + pmu_info->reg_size - 1, pmu_info->name)); } pmu_info->reg_mapped = _mali_osk_mem_mapioregion( pmu_info->reg_base_addr, pmu_info->reg_size, pmu_info->name ); if( 0 == pmu_info->reg_mapped ) { MALI_PRINT_ERROR(("PLATFORM mali400-pmu: Could not ioremap registers for %s .\n", pmu_info->name)); _mali_osk_mem_unreqregion( pmu_info->reg_base_addr, pmu_info->reg_size ); goto cleanup; } else { MALI_DEBUG_PRINT( 4, ("PLATFORM mali400-pmu: Success: ioremap_nocache: Internal ptr: (0x%08X - 0x%08X) for %s\n", (u32) pmu_info->reg_mapped, ((u32)pmu_info->reg_mapped)+ pmu_info->reg_size - 1, pmu_info->name)); } MALI_DEBUG_PRINT( 4, ("PLATFORM mali400-pmu: Success: Mapping registers to %s\n", pmu_info->name)); #if PMU_TEST pmu_test(pmu_info, (MALI_PMM_CORE_GP)); pmu_test(pmu_info, (MALI_PMM_CORE_GP|MALI_PMM_CORE_L2|MALI_PMM_CORE_PP0)); #endif MALI_DEBUG_PRINT( 4, ("PLATFORM mali400-pmu: Initialized - %s\n", pmu_info->name) ); } else { /* Didn't expect a different resource */ MALI_ERROR(_MALI_OSK_ERR_INVALID_ARGS); } MALI_SUCCESS; cleanup: _mali_osk_free(pmu_info); pmu_info = NULL; MALI_ERROR(_MALI_OSK_ERR_NOMEM); #else /* Nothing to do when not using PMM - as mali already on */ MALI_SUCCESS; #endif }