static void extmem_init(void) {
    if (extmem_mspace == NULL) {
        if (extmem_mspace_size == 0) {
        	size_t extmem_vmalloc_limit = (VMALLOC_TOTAL/3)& ~(0x02000000-1);
        	
        	if (get_max_DRAM_size() < (CONFIG_MAX_DRAM_SIZE_SUPPORT + 0x02000000)) {
        		printk(KERN_ERR "[EXT_MEM] no extmem, get_max_DRAM_size:%p, CONFIG_MAX_DRAM_SIZE_SUPPORT:0x%x, get_max_phys_addr:%p\n", 
                                 (void *)get_max_DRAM_size(), CONFIG_MAX_DRAM_SIZE_SUPPORT, (void *)get_max_phys_addr());
            	BUG();
            }
            
            extmem_mspace_size = get_max_DRAM_size() - CONFIG_MAX_DRAM_SIZE_SUPPORT - 0x02000000;
            if (extmem_mspace_size > extmem_vmalloc_limit) {
				printk(KERN_WARNING "[EXT_MEM] extmem_mspace_size: 0x%zx over limit: 0x%zx\n", 
				     	extmem_mspace_size, extmem_vmalloc_limit);
				extmem_mspace_size = extmem_vmalloc_limit;
			}
		}
		
        //extmem_mspace_base = (void*) ioremap(get_max_phys_addr(), extmem_mspace_size);
        extmem_mspace_base = (void*) ioremap_cached(get_max_phys_addr(), extmem_mspace_size);
        extmem_mspace = create_mspace_with_base(extmem_mspace_base, extmem_mspace_size, 1);
		extmem_printk("[EXT_MEM] get_max_DRAM_size:0x%x, CONFIG_MAX_DRAM_SIZE_SUPPORT:0x%x, get_max_phys_addr:%p, extmem_mspace:%p\n", 
                                 get_max_DRAM_size(), CONFIG_MAX_DRAM_SIZE_SUPPORT, (void *)get_max_phys_addr(), extmem_mspace);
    }
}
int mali_platform_device_register(void)
{
    int err = -1;
    int value;

#ifdef CONFIG_OF
	struct device_node *np_efuse;

	np_efuse = of_find_compatible_node(NULL, NULL, efuse_of_match[0].compatible);
	
	if(!efuse_base)
	{	
		efuse_base = of_iomap(np_efuse, 0);
	}
#endif

    MALI_DEBUG_PRINT(1, ("%s\n", __FUNCTION__));
    
    mali_gpu_data.shared_mem_size = get_max_DRAM_size();

    if (efuse_base)
    {
        value = mali_pmm_reg_read(efuse_base + 0x040);
        if (value & 0x00020000)
        {
            MALI_DEBUG_ASSERT(0);
            return err;
        }
        else if (value & 0x00040000)
        {
            err = platform_device_register(&mali_gpu_device_mp1);
            core_count = 1;
        }
        else
        {
            err = platform_device_register(&mali_gpu_device_mp2);
            core_count = 2;
        }
    }
    else
    {
        err = platform_device_register(&mali_gpu_device_mp2);
        core_count = 2;
    }
	
    mali_platform_power_mode_change(MALI_POWER_MODE_ON);
	
    if (0 == err) 
    {         
        mali_pmm_init();
        
#ifdef CONFIG_PM_RUNTIME
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
        if (coue_count == 2)
        {
            pm_runtime_set_autosuspend_delay(&(mali_gpu_device_mp2.dev), 1000);
            pm_runtime_use_autosuspend(&(mali_gpu_device_mp2.dev));
        }
        else
        {
            pm_runtime_set_autosuspend_delay(&(mali_gpu_device_mp1.dev), 1000);
            pm_runtime_use_autosuspend(&(mali_gpu_device_mp1.dev));
        }
#endif
        if (coue_count == 2)
        {
            pm_runtime_enable(&(mali_gpu_device_mp2.dev));
        }
        else
        {
            pm_runtime_enable(&(mali_gpu_device_mp1.dev));
        }
#endif
        
        return 0;
    }

    MALI_DEBUG_PRINT(1, ("%s err=%d\n",__FUNCTION__, err));

    if (2 == core_count)
    {
        platform_device_unregister(&mali_gpu_device_mp2);
    }
    else
    {
        platform_device_unregister(&mali_gpu_device_mp1);
    }

    return err;
}