diff options
Diffstat (limited to 'drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/platform/ux500/mali_platform.c')
-rw-r--r-- | drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/platform/ux500/mali_platform.c | 151 |
1 files changed, 92 insertions, 59 deletions
diff --git a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/platform/ux500/mali_platform.c b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/platform/ux500/mali_platform.c index 481e6e76c54..f9343def5d6 100644 --- a/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/platform/ux500/mali_platform.c +++ b/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/platform/ux500/mali_platform.c @@ -21,18 +21,71 @@ #include <linux/clk.h> #include <linux/io.h> #include <linux/workqueue.h> +#include <linux/wakelock.h> +#include <linux/version.h> +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) +#include <mach/prcmu.h> +#else #include <linux/mfd/dbx500-prcmu.h> +#endif #define MALI_HIGH_TO_LOW_LEVEL_UTILIZATION_LIMIT 64 #define MALI_LOW_TO_HIGH_LEVEL_UTILIZATION_LIMIT 192 -static int is_running; +static bool is_running; +static bool is_initialized; static struct regulator *regulator; static struct clk *clk_sga; static u32 last_utilization; static struct work_struct mali_utilization_work; static struct workqueue_struct *mali_utilization_workqueue; +static struct wake_lock wakelock; + +static _mali_osk_errcode_t mali_platform_powerdown() +{ + if (is_running) { + wake_unlock(&wakelock); + clk_disable(clk_sga); + if (regulator) { + int ret = regulator_disable(regulator); + if (ret < 0) { + MALI_DEBUG_PRINT(2, ("%s: Failed to disable regulator %s\n", __func__, "v-mali")); + is_running = false; + MALI_ERROR(_MALI_OSK_ERR_FAULT); + } + } + is_running = false; + } + MALI_DEBUG_PRINT(4, ("mali_platform_powerdown is_running: %u\n", is_running)); + MALI_SUCCESS; +} + +static _mali_osk_errcode_t mali_platform_powerup() +{ + if (!is_running) { + int ret = regulator_enable(regulator); + if (ret < 0) { + MALI_DEBUG_PRINT(2, ("%s: Failed to enable regulator %s\n", __func__, "v-mali")); + goto error; + } + + ret = clk_enable(clk_sga); + if (ret < 0) { + regulator_disable(regulator); + MALI_DEBUG_PRINT(2, ("%s: Failed to enable clock %s\n", __func__, "mali")); + goto error; + } + + wake_lock(&wakelock); + is_running = true; + } + MALI_DEBUG_PRINT(4, ("mali_platform_powerup is_running:%u\n", is_running)); + MALI_SUCCESS; +error: + MALI_DEBUG_PRINT(1, ("Failed to power up.\n")); + MALI_ERROR(_MALI_OSK_ERR_FAULT); +} /* Rationale behind the values for: * MALI_HIGH_LEVEL_UTILIZATION_LIMIT and MALI_LOW_LEVEL_UTILIZATION_LIMIT @@ -91,29 +144,35 @@ void mali_utilization_function(struct work_struct *ptr) MALI_DEBUG_PRINT(5, ("MALI GPU utilization: %u\n", last_utilization)); } -_mali_osk_errcode_t mali_platform_init(_mali_osk_resource_t *resource) +_mali_osk_errcode_t mali_platform_init() { - is_running = 0; + is_running = false; last_utilization = 0; - mali_utilization_workqueue = create_singlethread_workqueue("mali_utilization_workqueue"); - if (NULL == mali_utilization_workqueue) { - MALI_DEBUG_PRINT(2, ("%s: Failed to setup workqueue %s\n", __func__, "v-mali")); - goto error; - } - INIT_WORK(&mali_utilization_work, mali_utilization_function); + if(!is_initialized) { - regulator = regulator_get(NULL, "v-mali"); - if (IS_ERR(regulator)) { - MALI_DEBUG_PRINT(2, ("%s: Failed to get regulator %s\n", __func__, "v-mali")); + mali_utilization_workqueue = create_singlethread_workqueue("mali_utilization_workqueue"); + if (NULL == mali_utilization_workqueue) { + MALI_DEBUG_PRINT(2, ("%s: Failed to setup workqueue %s\n", __func__, "mali_utilization_workqueue")); goto error; - } + } + INIT_WORK(&mali_utilization_work, mali_utilization_function); - clk_sga = clk_get_sys("mali", NULL); - if (IS_ERR(clk_sga)) { - regulator_put(regulator); - MALI_DEBUG_PRINT(2, ("%s: Failed to get clock %s\n", __func__, "mali")); - goto error; + regulator = regulator_get(NULL, "v-mali"); + if (IS_ERR(regulator)) { + MALI_DEBUG_PRINT(2, ("%s: Failed to get regulator %s\n", __func__, "v-mali")); + goto error; + } + + clk_sga = clk_get_sys("mali", NULL); + if (IS_ERR(clk_sga)) { + regulator_put(regulator); + MALI_DEBUG_PRINT(2, ("%s: Failed to get clock %s\n", __func__, "mali")); + goto error; + } + + wake_lock_init(&wakelock, WAKE_LOCK_SUSPEND, "mali_wakelock"); + is_initialized = true; } MALI_SUCCESS; @@ -122,55 +181,26 @@ error: MALI_ERROR(_MALI_OSK_ERR_FAULT); } -_mali_osk_errcode_t mali_platform_deinit(_mali_osk_resource_type_t *type) +_mali_osk_errcode_t mali_platform_deinit() { destroy_workqueue(mali_utilization_workqueue); regulator_put(regulator); clk_put(clk_sga); + wake_lock_destroy(&wakelock); + is_running = false; + last_utilization = 0; + is_initialized = false; MALI_DEBUG_PRINT(2, ("SGA terminated.\n")); MALI_SUCCESS; } -_mali_osk_errcode_t mali_platform_powerdown(u32 cores) +_mali_osk_errcode_t mali_platform_power_mode_change(mali_power_mode power_mode) { - if (is_running) { - clk_disable(clk_sga); - if (regulator) { - int ret = regulator_disable(regulator); - if (ret < 0) { - MALI_DEBUG_PRINT(2, ("%s: Failed to disable regulator %s\n", __func__, "v-mali")); - is_running = 0; - MALI_ERROR(_MALI_OSK_ERR_FAULT); - } - } - is_running = 0; - } - MALI_DEBUG_PRINT(4, ("mali_platform_powerdown is_running: %u cores: %u\n", is_running, cores)); - MALI_SUCCESS; -} - -_mali_osk_errcode_t mali_platform_powerup(u32 cores) -{ - if (!is_running) { - int ret = regulator_enable(regulator); - if (ret < 0) { - MALI_DEBUG_PRINT(2, ("%s: Failed to enable regulator %s\n", __func__, "v-mali")); - goto error; - } - - ret = clk_enable(clk_sga); - if (ret < 0) { - regulator_disable(regulator); - MALI_DEBUG_PRINT(2, ("%s: Failed to enable clock %s\n", __func__, "mali")); - goto error; - } - is_running = 1; - } - MALI_DEBUG_PRINT(4, ("mali_platform_powerup is_running:%u cores: %u\n", is_running, cores)); - MALI_SUCCESS; -error: - MALI_DEBUG_PRINT(1, ("Failed to power up.\n")); - MALI_ERROR(_MALI_OSK_ERR_FAULT); + if (MALI_POWER_MODE_ON == power_mode) { + return mali_platform_powerup(); + } + /*We currently don't make any distinction between MALI_POWER_MODE_LIGHT_SLEEP and MALI_POWER_MODE_DEEP_SLEEP*/ + return mali_platform_powerdown(); } void mali_gpu_utilization_handler(u32 utilization) @@ -187,4 +217,7 @@ void mali_gpu_utilization_handler(u32 utilization) queue_work(mali_utilization_workqueue, &mali_utilization_work); } - +void set_mali_parent_power_domain(void* dev) +{ + MALI_DEBUG_PRINT(1, ("This function should not be called since we are not using run time pm\n")); +} |