_mali_osk_errcode_t g3d_power_domain_control(int bpower_on)
{
	if (bpower_on)
	{
#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
		MALI_DEBUG_PRINT(3,("_mali_osk_pmm_dev_activate \n"));
		_mali_osk_pm_dev_activate();
#else //MALI_PMM_RUNTIME_JOB_CONTROL_ON
		void __iomem *status;
		u32 timeout;
		__raw_writel(S5P_INT_LOCAL_PWR_EN, S5P_PMU_G3D_CONF);
		status = S5P_PMU_G3D_CONF + 0x4;

		timeout = 10;
		while ((__raw_readl(status) & S5P_INT_LOCAL_PWR_EN)
				!= S5P_INT_LOCAL_PWR_EN) {
			if (timeout == 0) {
				MALI_PRINTF(("Power domain  enable failed.\n"));
				return -ETIMEDOUT;
			}
			timeout--;
			_mali_osk_time_ubusydelay(100);
		}
		MALI_PRINTF(("MALI Power domain enabled"));		
#endif //MALI_PMM_RUNTIME_JOB_CONTROL_ON
	}
	else
	{
#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
		MALI_DEBUG_PRINT( 4,("_mali_osk_pmm_dev_idle\n"));
		_mali_osk_pm_dev_idle();
#else //MALI_PMM_RUNTIME_JOB_CONTROL_ON
		void __iomem *status;
		u32 timeout;
		__raw_writel(0, S5P_PMU_G3D_CONF);

		status = S5P_PMU_G3D_CONF + 0x4;
		/* Wait max 1ms */
		timeout = 10;
		while (__raw_readl(status) & S5P_INT_LOCAL_PWR_EN)
		{
			if (timeout == 0) {
				MALI_PRINTF(("Power domain  disable failed.\n" ));
				return -ETIMEDOUT;
			}
			timeout--;
			_mali_osk_time_ubusydelay( 100);
		}
		MALI_PRINTF(("MALI Power domain disabled"));
#endif //MALI_PMM_RUNTIME_JOB_CONTROL_ON
	}

	MALI_SUCCESS;
}
_mali_osk_errcode_t mali_platform_power_mode_change(struct device *dev, mali_power_mode power_mode)
{
	switch (power_mode)
	{
	case MALI_POWER_MODE_ON:
		MALI_DEBUG_PRINT(3, ("Mali platform: Got MALI_POWER_MODE_ON event, %s\n",
					nPowermode ? "powering on" : "already on"));
		if (nPowermode == MALI_POWER_MODE_LIGHT_SLEEP || nPowermode == MALI_POWER_MODE_DEEP_SLEEP)	{
#if !defined(CONFIG_PM_RUNTIME)
			g3d_power_domain_control(1);
#endif
			MALI_DEBUG_PRINT(4, ("enable clock\n"));
			enable_mali_clocks(dev);

			if (nPowermode == MALI_POWER_MODE_DEEP_SLEEP)	{
#ifdef CONFIG_MALI_DVFS
				mali_devfreq = NULL;
				if (!mali_devfreq_add(dev))
					MALI_PRINTF(("failed to mali_devfreq_add()\n"));
#endif
			}
#if defined(CONFIG_MALI400_PROFILING)
			_mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
			MALI_PROFILING_EVENT_CHANNEL_GPU |
			MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
			mali_gpu_clk, mali_gpu_vol/1000, 0, 0, 0);
#endif
			nPowermode = power_mode;
		}
		break;
	case MALI_POWER_MODE_DEEP_SLEEP:
#ifdef CONFIG_MALI_DVFS
		mali_devfreq_remove();
#endif
	case MALI_POWER_MODE_LIGHT_SLEEP:
		MALI_DEBUG_PRINT(3, ("Mali platform: Got %s event, %s\n", power_mode == MALI_POWER_MODE_LIGHT_SLEEP ?
					"MALI_POWER_MODE_LIGHT_SLEEP" : "MALI_POWER_MODE_DEEP_SLEEP",
					nPowermode ? "already off" : "powering off"));
		if (nPowermode == MALI_POWER_MODE_ON)	{
			disable_mali_clocks();

#if defined(CONFIG_MALI400_PROFILING)
			_mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
			MALI_PROFILING_EVENT_CHANNEL_GPU |
			MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
			0, 0, 0, 0, 0);
#endif
#if !defined(CONFIG_PM_RUNTIME)
			g3d_power_domain_control(0);
#endif
			nPowermode = power_mode;
		}
		break;
	}
	MALI_SUCCESS;
}
_mali_osk_errcode_t g3d_power_domain_control(int bpower_on)
{
    MALI_SUCCESS;
    if (bpower_on)
    {
        void __iomem *status;
        u32 timeout;
        __raw_writel(EXYNOS_INT_LOCAL_PWR_EN, S5P_G3D_CONFIGURATION);
        status = S5P_G3D_STATUS;

        timeout = 10;
        while ((__raw_readl(status) & EXYNOS_INT_LOCAL_PWR_EN)
                != EXYNOS_INT_LOCAL_PWR_EN) {
            if (timeout == 0) {
                MALI_PRINTF(("Power domain  enable failed.\n"));
                return -ETIMEDOUT;
            }
            timeout--;
            _mali_osk_time_ubusydelay(100);
        }
    }
    else
    {
        void __iomem *status;
        u32 timeout;
        __raw_writel(0, S5P_G3D_CONFIGURATION);

        status = S5P_G3D_STATUS;
        /* Wait max 1ms */
        timeout = 10;
        while (__raw_readl(status) & EXYNOS_INT_LOCAL_PWR_EN)
        {
            if (timeout == 0) {
                MALI_PRINTF(("Power domain  disable failed.\n" ));
                return -ETIMEDOUT;
            }
            timeout--;
            _mali_osk_time_ubusydelay( 100);
        }
    }

    MALI_SUCCESS;
}
Example #4
0
void _mali_pm_callback(void *arg)
{
#if MALI_LICENSE_IS_GPL
    if (mali_pm_wq)
    {
        queue_work(mali_pm_wq, &mali_pm_wq_work_handle);
    }
    else
    {
        MALI_PRINTF(("mali_pm_wq is NULL !!!\n"));
        mali_bottom_half_pm(NULL);
    }
#else
    schedule_work(&mali_pm_wq_work_handle);
#endif
}
/* Can run in atomic context */
void _mali_osk_pm_dev_ref_dec(void)
{
#ifdef CONFIG_PM_RUNTIME
	MALI_DEBUG_ASSERT_POINTER(mali_platform_device);
	_mali_osk_atomic_dec(&mali_pm_ref_count);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
	pm_runtime_mark_last_busy(&(mali_platform_device->dev));
	pm_runtime_put_autosuspend(&(mali_platform_device->dev));
#else
	pm_runtime_put(&(mali_platform_device->dev));
#endif
	MALI_DEBUG_PRINT(4, ("Mali OSK PM: Power ref released (%u)\n", _mali_osk_atomic_read(&mali_pm_ref_count)));

#else /// CONFIG_PM_RUNTIME
      	
	if(_mali_osk_atomic_dec_return(&mali_pm_ref_count) == 0)
	{
	    if (NULL != pm_timer)
	    {
		    _mali_osk_timer_mod(pm_timer, _mali_osk_time_mstoticks(mali_pm_wq ? 15 : 3000));
		}
		else
		{
#if MALI_LICENSE_IS_GPL
            if (mali_pm_wq)
            {
                queue_work(mali_pm_wq, &mali_pm_wq_work_handle);
            }
            else
            {
                MALI_PRINTF(("mali_pm_wq is NULL !!!\n"));
                mali_bottom_half_pm(NULL);
            }
#else
            schedule_work(&mali_pm_wq_work_handle);
#endif
	    }
	}

	MALI_DEBUG_PRINT(4, ("Mali OSK PM: Power ref released (%u)\n", _mali_osk_atomic_read(&mali_pm_ref_count)));
#endif
}
_mali_osk_errcode_t mali_kernel_core_validate_mali_phys_range( u32 phys_base, u32 size )
{
	MALI_CHECK_GOTO( 0 == ( phys_base & (~_MALI_OSK_CPU_PAGE_MASK)), failure );
	MALI_CHECK_GOTO( 0 == ( size & (~_MALI_OSK_CPU_PAGE_MASK)), failure );

	if ( phys_base             >= mem_validator.phys_base
		 && (phys_base + size) >= mem_validator.phys_base
		 && phys_base          <= (mem_validator.phys_base + mem_validator.size)
		 && (phys_base + size) <= (mem_validator.phys_base + mem_validator.size) )
	{
		MALI_SUCCESS;
	}

 failure:
	MALI_PRINTF( ("*******************************************************************************\n") );
	MALI_PRINTF( ("MALI PHYSICAL RANGE VALIDATION ERROR!\n") );
	MALI_PRINTF( ("\n") );
	MALI_PRINTF( ("We failed to validate a Mali-Physical range that the user-side wished to map in\n") );
	MALI_PRINTF( ("\n") );
	MALI_PRINTF( ("It is likely that the user-side wished to do Direct Rendering, but a suitable\n") );
	MALI_PRINTF( ("address range validation mechanism has not been correctly setup\n") );
	MALI_PRINTF( ("\n") );
	MALI_PRINTF( ("The range supplied was: phys_base=0x%08X, size=0x%08X\n", phys_base, size) );
	MALI_PRINTF( ("\n") );
	MALI_PRINTF( ("Please refer to the ARM Mali Software Integration Guide for more information.\n") );
	MALI_PRINTF( ("\n") );
	MALI_PRINTF( ("*******************************************************************************\n") );

	MALI_ERROR( _MALI_OSK_ERR_FAULT );
}