aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/samsung/mali/linux/mali_kernel_pm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/samsung/mali/linux/mali_kernel_pm.c')
-rw-r--r--drivers/media/video/samsung/mali/linux/mali_kernel_pm.c681
1 files changed, 120 insertions, 561 deletions
diff --git a/drivers/media/video/samsung/mali/linux/mali_kernel_pm.c b/drivers/media/video/samsung/mali/linux/mali_kernel_pm.c
index f06ea4b..1d861f5 100644
--- a/drivers/media/video/samsung/mali/linux/mali_kernel_pm.c
+++ b/drivers/media/video/samsung/mali/linux/mali_kernel_pm.c
@@ -1,5 +1,5 @@
-/*
- * Copyright (C) 2010 ARM Limited. All rights reserved.
+/**
+ * Copyright (C) 2010-2012 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
@@ -10,615 +10,211 @@
/**
* @file mali_kernel_pm.c
- * Implementation of the Linux Power Management for Mali GPU kernel driver
+ * Linux Power Management integration
*/
-#if USING_MALI_PMM
#include <linux/sched.h>
-
-#ifdef CONFIG_PM_RUNTIME
-#include <linux/pm_runtime.h>
-#endif /* CONFIG_PM_RUNTIME */
-
#include <linux/platform_device.h>
#include <linux/version.h>
#include <asm/current.h>
#include <linux/suspend.h>
-
-#include <plat/cpu.h>
-#include <plat/pd.h>
-#include <plat/devs.h>
-
-#include "mali_platform.h"
+#include <linux/module.h>
+#ifdef CONFIG_PM_RUNTIME
+#include <linux/pm_runtime.h>
+#endif
#include "mali_osk.h"
#include "mali_uk_types.h"
-#include "mali_pmm.h"
-#include "mali_ukk.h"
#include "mali_kernel_common.h"
#include "mali_kernel_license.h"
-#include "mali_kernel_pm.h"
-#include "mali_device_pause_resume.h"
#include "mali_linux_pm.h"
+#include "mali_pm.h"
+#include "mali_platform.h"
-#ifdef MALI_REBOOTNOTIFIER
-_mali_osk_atomic_t mali_shutdown_state;
-#include <linux/reboot.h>
+#if ! MALI_LICENSE_IS_GPL
+#undef CONFIG_PM_RUNTIME
#endif
-#if MALI_GPU_UTILIZATION
-#include "mali_kernel_utilization.h"
-#endif /* MALI_GPU_UTILIZATION */
-
-#if MALI_POWER_MGMT_TEST_SUITE
-#ifdef CONFIG_PM
-#include "mali_linux_pm_testsuite.h"
-#include "mali_platform_pmu_internal_testing.h"
-unsigned int pwr_mgmt_status_reg = 0;
-#endif /* CONFIG_PM */
-#endif /* MALI_POWER_MGMT_TEST_SUITE */
-
-static int is_os_pmm_thread_waiting = 0;
-
-/* kernel should be configured with power management support */
-#ifdef CONFIG_PM
-
-/* License should be GPL */
-#if MALI_LICENSE_IS_GPL
-
-/* Linux kernel major version */
-#define LINUX_KERNEL_MAJOR_VERSION 2
-
-/* Linux kernel minor version */
-#define LINUX_KERNEL_MINOR_VERSION 6
-
-/* Linux kernel development version */
-#define LINUX_KERNEL_DEVELOPMENT_VERSION 29
-
-#ifdef CONFIG_PM_DEBUG
-static const char* const mali_states[_MALI_MAX_DEBUG_OPERATIONS] = {
- [_MALI_DEVICE_SUSPEND] = "suspend",
- [_MALI_DEVICE_RESUME] = "resume",
- [_MALI_DVFS_PAUSE_EVENT] = "dvfs_pause",
- [_MALI_DVFS_RESUME_EVENT] = "dvfs_resume",
-};
-
-#endif /* CONFIG_PM_DEBUG */
-
#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
extern void set_mali_parent_power_domain(struct platform_device* dev);
#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
+static int mali_probe(struct platform_device *pdev);
+static int mali_remove(struct platform_device *pdev);
#ifdef CONFIG_PM_RUNTIME
-#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
-static int mali_pwr_suspend_notifier(struct notifier_block *nb,unsigned long event,void* dummy);
-
-static struct notifier_block mali_pwr_notif_block = {
- .notifier_call = mali_pwr_suspend_notifier
-};
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-#endif /* CONFIG_PM_RUNTIME */
-
-/* Power management thread pointer */
-struct task_struct *pm_thread;
-
-/* dvfs power management thread */
-struct task_struct *dvfs_pm_thread;
-
-/* is wake up needed */
-short is_wake_up_needed = 0;
-int timeout_fired = 2;
-unsigned int is_mali_pmm_testsuite_enabled = 0;
-
-_mali_device_power_states mali_device_state = _MALI_DEVICE_RESUME;
-_mali_device_power_states mali_dvfs_device_state = _MALI_DEVICE_RESUME;
-_mali_osk_lock_t *lock;
-
-#if MALI_POWER_MGMT_TEST_SUITE
-
-const char* const mali_pmm_recording_events[_MALI_DEVICE_MAX_PMM_EVENTS] = {
- [_MALI_DEVICE_PMM_TIMEOUT_EVENT] = "timeout",
- [_MALI_DEVICE_PMM_JOB_SCHEDULING_EVENTS] = "job_scheduling",
- [_MALI_DEVICE_PMM_REGISTERED_CORES] = "cores",
-
-};
-
-unsigned int mali_timeout_event_recording_on = 0;
-unsigned int mali_job_scheduling_events_recording_on = 0;
-unsigned int is_mali_pmu_present = 0;
-#endif /* MALI_POWER_MGMT_TEST_SUITE */
-
-/* Function prototypes */
-static int mali_pm_probe(struct platform_device *pdev);
-static int mali_pm_remove(struct platform_device *pdev);
-static void mali_pm_shutdown(struct platform_device *pdev);
-
-/* Mali device suspend function */
-static int mali_pm_suspend(struct device *dev);
-
-/* Mali device resume function */
-static int mali_pm_resume(struct device *dev);
-
-/* Run time suspend and resume functions */
-#ifdef CONFIG_PM_RUNTIME
-#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
-static int mali_device_runtime_suspend(struct device *dev);
-static int mali_device_runtime_resume(struct device *dev);
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-#endif /* CONFIG_PM_RUNTIME */
-
-/* OS suspend and resume callbacks */
-#if !MALI_PMM_RUNTIME_JOB_CONTROL_ON
-#ifndef CONFIG_PM_RUNTIME
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(LINUX_KERNEL_MAJOR_VERSION,LINUX_KERNEL_MINOR_VERSION,LINUX_KERNEL_DEVELOPMENT_VERSION))
-static int mali_pm_os_suspend(struct platform_device *pdev, pm_message_t state);
-#else
-static int mali_pm_os_suspend(struct device *dev);
+static int mali_runtime_suspend(struct device *dev);
+static int mali_runtime_resume(struct device *dev);
#endif
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(LINUX_KERNEL_MAJOR_VERSION,LINUX_KERNEL_MINOR_VERSION,LINUX_KERNEL_DEVELOPMENT_VERSION))
-static int mali_pm_os_resume(struct platform_device *pdev);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
+static int mali_os_suspend(struct platform_device *pdev, pm_message_t state);
+static int mali_os_resume(struct platform_device *pdev);
#else
-static int mali_pm_os_resume(struct device *dev);
+static int mali_os_suspend(struct device *dev);
+static int mali_os_resume(struct device *dev);
#endif
-#endif /* CONFIG_PM_RUNTIME */
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-
-/* OS Hibernation suspend callback */
-static int mali_pm_os_suspend_on_hibernation(struct device *dev);
-
-/* OS Hibernation resume callback */
-static int mali_pm_os_resume_on_hibernation(struct device *dev);
-
-static void _mali_release_pm(struct device* device);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(LINUX_KERNEL_MAJOR_VERSION,LINUX_KERNEL_MINOR_VERSION,LINUX_KERNEL_DEVELOPMENT_VERSION))
-static const struct dev_pm_ops mali_dev_pm_ops = {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
+static const struct dev_pm_ops mali_dev_pm_ops =
+{
#ifdef CONFIG_PM_RUNTIME
-#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
- .runtime_suspend = mali_device_runtime_suspend,
- .runtime_resume = mali_device_runtime_resume,
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-#endif /* CONFIG_PM_RUNTIME */
-
-#ifndef CONFIG_PM_RUNTIME
-#if !MALI_PMM_RUNTIME_JOB_CONTROL_ON
- .suspend = mali_pm_os_suspend,
- .resume = mali_pm_os_resume,
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-#endif /* CONFIG_PM_RUNTIME */
- .freeze = mali_pm_os_suspend_on_hibernation,
- .poweroff = mali_pm_os_suspend_on_hibernation,
- .thaw = mali_pm_os_resume_on_hibernation,
- .restore = mali_pm_os_resume_on_hibernation,
-};
+ .runtime_suspend = mali_runtime_suspend,
+ .runtime_resume = mali_runtime_resume,
+ .runtime_idle = NULL,
+#else
+ .suspend = mali_os_suspend,
+ .resume = mali_os_resume,
#endif
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(LINUX_KERNEL_MAJOR_VERSION,LINUX_KERNEL_MINOR_VERSION,LINUX_KERNEL_DEVELOPMENT_VERSION))
-struct pm_ext_ops mali_pm_operations = {
- .base = {
- .freeze = mali_pm_os_suspend_on_hibernation,
- .thaw = mali_pm_os_resume_on_hibernation,
- .poweroff = mali_pm_os_resume_on_hibernation,
- .restore = mali_pm_os_resume_on_hibernation,
+ .freeze = mali_os_suspend,
+ .poweroff = mali_os_suspend,
+ .thaw = mali_os_resume,
+ .restore = mali_os_resume,
+};
+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
+struct pm_ext_ops mali_ext_pm_operations =
+{
+ .base =
+ {
+ .freeze = mali_os_suspend,
+ .thaw = mali_os_resume,
+ .poweroff = mali_os_suspend,
+ .restore = mali_os_resume,
},
};
#endif
-static struct platform_driver mali_plat_driver = {
- .probe = mali_pm_probe,
- .remove = mali_pm_remove,
- .shutdown = mali_pm_shutdown,
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(LINUX_KERNEL_MAJOR_VERSION,LINUX_KERNEL_MINOR_VERSION,LINUX_KERNEL_DEVELOPMENT_VERSION))
-#ifndef CONFIG_PM_RUNTIME
-#if !MALI_PMM_RUNTIME_JOB_CONTROL_ON
- .suspend = mali_pm_os_suspend,
- .resume = mali_pm_os_resume,
-#endif /* CONFIG_PM_RUNTIME */
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
- .pm = &mali_pm_operations,
+
+static struct platform_driver mali_plat_driver =
+{
+ .probe = mali_probe,
+ .remove = mali_remove,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
+ .suspend = mali_os_suspend,
+ .resume = mali_os_resume,
+ .pm = &mali_ext_pm_operations,
#endif
- .driver = {
+ .driver =
+ {
.name = "mali_dev",
.owner = THIS_MODULE,
+#if MALI_LICENSE_IS_GPL
.bus = &platform_bus_type,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(LINUX_KERNEL_MAJOR_VERSION,LINUX_KERNEL_MINOR_VERSION,LINUX_KERNEL_DEVELOPMENT_VERSION))
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
.pm = &mali_dev_pm_ops,
#endif
- },
+ },
};
-/* Mali GPU platform device */
-struct platform_device mali_gpu_device = {
- .name = "mali_dev",
- .id = 0,
- .dev.release = _mali_release_pm
+#ifdef CONFIG_PM_RUNTIME
+static int mali_pwr_suspend_notifier(struct notifier_block *nb,unsigned long event,void* dummy);
+
+static struct notifier_block mali_pwr_notif_block =
+{
+ .notifier_call = mali_pwr_suspend_notifier
};
+#endif
/** This function is called when platform device is unregistered. This function
* is necessary when the platform device is unregistered.
*/
static void _mali_release_pm(struct device *device)
{
- MALI_DEBUG_PRINT(4, ("OSPMM: MALI Platform device removed\n" ));
}
-
-#if MALI_POWER_MGMT_TEST_SUITE
-void mali_is_pmu_present(void)
+struct platform_device mali_gpu_device =
{
- int temp = 0;
- temp = pmu_get_power_up_down_info();
- if (4095 == temp)
- {
- is_mali_pmu_present = 0;
- }
- else
- {
- is_mali_pmu_present = 1;
- }
-}
-#endif /* MALI_POWER_MGMT_TEST_SUITE */
-#endif /* MALI_LICENSE_IS_GPL */
-
-#if MALI_LICENSE_IS_GPL
-
-static int mali_wait_for_power_management_policy_event(void)
-{
- int err = 0;
- for (; ;)
- {
- set_current_state(TASK_INTERRUPTIBLE);
- if (signal_pending(current))
- {
- err = -EINTR;
- break;
- }
- if (is_wake_up_needed == 1)
- {
- break;
- }
- schedule();
- }
- __set_current_state(TASK_RUNNING);
- is_wake_up_needed =0;
- return err;
-}
+ .name = "mali_dev",
+ .id = 0,
+ .dev.release = _mali_release_pm
+};
-/** This function is invoked when mali device is suspended
- */
-int mali_device_suspend(unsigned int event_id, struct task_struct **pwr_mgmt_thread)
+/** This function is called when the device is probed */
+static int mali_probe(struct platform_device *pdev)
{
- int err = 0;
- _mali_uk_pmm_message_s event = {
- NULL,
- event_id,
- timeout_fired};
- *pwr_mgmt_thread = current;
- MALI_DEBUG_PRINT(4, ("OSPMM: MALI device is being suspended\n" ));
- _mali_ukk_pmm_event_message(&event);
- is_os_pmm_thread_waiting = 1;
- err = mali_wait_for_power_management_policy_event();
- is_os_pmm_thread_waiting = 0;
- return err;
+ return 0;
}
-/** This function is called when Operating system wants to power down
- * the mali GPU device.
- */
-static int mali_pm_suspend(struct device *dev)
+static int mali_remove(struct platform_device *pdev)
{
- int err = 0;
- _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
- if ((mali_device_state == _MALI_DEVICE_SUSPEND))
- {
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return err;
- }
-#if MALI_DVFS_ENABLED
- mali_utilization_suspend();
-#endif
- err = mali_device_suspend(MALI_PMM_EVENT_OS_POWER_DOWN, &pm_thread);
- mali_device_state = _MALI_DEVICE_SUSPEND;
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return err;
-}
-
-#ifndef CONFIG_PM_RUNTIME
-#if !MALI_PMM_RUNTIME_JOB_CONTROL_ON
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(LINUX_KERNEL_MAJOR_VERSION,LINUX_KERNEL_MINOR_VERSION,LINUX_KERNEL_DEVELOPMENT_VERSION))
-static int mali_pm_os_suspend(struct platform_device *pdev, pm_message_t state)
-#else
-static int mali_pm_os_suspend(struct device *dev)
+#ifdef CONFIG_PM_RUNTIME
+ pm_runtime_disable(&pdev->dev);
#endif
-{
- int err = 0;
- err = mali_pm_suspend(NULL);
- return err;
+ return 0;
}
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-#endif /* CONFIG_PM_RUNTIME */
#ifdef CONFIG_PM_RUNTIME
-#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
static int mali_pwr_suspend_notifier(struct notifier_block *nb,unsigned long event,void* dummy)
{
- int err = 0;
switch (event)
{
case PM_SUSPEND_PREPARE:
- err = mali_pm_suspend(NULL);
- break;
-
+ MALI_DEBUG_PRINT(2, ("mali_pwr_suspend_notifier(PM_SUSPEND_PREPARE) called\n"));
+ mali_pm_os_suspend();
+ break;
case PM_POST_SUSPEND:
- err = mali_pm_resume(NULL);
- break;
+ MALI_DEBUG_PRINT(2, ("mali_pwr_suspend_notifier(PM_SUSPEND_PREPARE) called\n"));
+ mali_pm_os_resume();
+ break;
default:
- break;
+ break;
}
return 0;
}
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-#endif /* CONFIG_PM_RUNTIME */
-
-/** This function is called when mali GPU device is to be resumed.
- */
-int mali_device_resume(unsigned int event_id, struct task_struct **pwr_mgmt_thread)
-{
- int err = 0;
- _mali_uk_pmm_message_s event = {
- NULL,
- event_id,
- timeout_fired};
- *pwr_mgmt_thread = current;
- MALI_DEBUG_PRINT(4, ("OSPMM: MALI device is being resumed\n" ));
- _mali_ukk_pmm_event_message(&event);
- MALI_DEBUG_PRINT(4, ("OSPMM: MALI Power up event is scheduled\n" ));
- is_os_pmm_thread_waiting = 1;
- err = mali_wait_for_power_management_policy_event();
- is_os_pmm_thread_waiting = 0;
- return err;
-}
-
-/** This function is called when mali GPU device is to be resumed
- */
-static int mali_pm_resume(struct device *dev)
-{
- int err = 0;
-
- _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW);
-
-#ifdef CONFIG_REGULATOR
- mali_regulator_enable();
-#endif
-
- if (mali_device_state == _MALI_DEVICE_RESUME)
- {
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return err;
- }
- err = mali_device_resume(MALI_PMM_EVENT_OS_POWER_UP, &pm_thread);
- mali_device_state = _MALI_DEVICE_RESUME;
- mali_dvfs_device_state = _MALI_DEVICE_RESUME;
- _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW);
- return err;
-}
-
-#ifndef CONFIG_PM_RUNTIME
-#if !MALI_PMM_RUNTIME_JOB_CONTROL_ON
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(LINUX_KERNEL_MAJOR_VERSION,LINUX_KERNEL_MINOR_VERSION,LINUX_KERNEL_DEVELOPMENT_VERSION))
-static int mali_pm_os_resume(struct platform_device *pdev)
-#else
-static int mali_pm_os_resume(struct device *dev)
#endif
-{
- int err = 0;
- err = mali_pm_resume(NULL);
- return err;
-}
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-#endif /* CONFIG_PM_RUNTIME */
-
-static int mali_pm_os_suspend_on_hibernation(struct device *dev)
-{
- int err = 0;
- err = mali_pm_suspend(NULL);
- return err;
-}
-static int mali_pm_os_resume_on_hibernation(struct device *dev)
-{
- int err = 0;
- err = mali_pm_resume(NULL);
- return err;
-}
#ifdef CONFIG_PM_RUNTIME
-#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
-/** This function is called when runtime suspend of mali device is required.
- */
-static int mali_device_runtime_suspend(struct device *dev)
-{
- MALI_DEBUG_PRINT(4, ("PMMDEBUG: Mali device Run time suspended \n" ));
- return 0;
-}
-/** This function is called when runtime resume of mali device is required.
- */
-static int mali_device_runtime_resume(struct device *dev)
+static int mali_runtime_suspend(struct device *dev)
{
- MALI_DEBUG_PRINT(4, ("PMMDEBUG: Mali device Run time Resumed \n" ));
- return 0;
+ MALI_DEBUG_PRINT(3, ("mali_runtime_suspend() called\n"));
+ mali_pm_runtime_suspend();
+ return 0; /* all ok */
}
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-#endif /* CONFIG_PM_RUNTIME */
-#ifdef CONFIG_PM_DEBUG
-
-/** This function is used for debugging purposes when the user want to see
- * which power management operations are supported for
- * mali device.
- */
-static ssize_t show_file(struct device *dev, struct device_attribute *attr, char *buf)
+static int mali_runtime_resume(struct device *dev)
{
- char *str = buf;
-#if !MALI_POWER_MGMT_TEST_SUITE
- int pm_counter = 0;
- for (pm_counter = 0; pm_counter<_MALI_MAX_DEBUG_OPERATIONS; pm_counter++)
- {
- str += sprintf(str, "%s ", mali_states[pm_counter]);
- }
-#else
- str += sprintf(str, "%d ",pwr_mgmt_status_reg);
-#endif
- if (str != buf)
- {
- *(str-1) = '\n';
- }
- return (str-buf);
+ MALI_DEBUG_PRINT(3, ("mali_runtime_resume() called\n"));
+ mali_pm_runtime_resume();
+ return 0; /* all ok */
}
-/** This function is called when user wants to suspend the mali GPU device in order
- * to simulate the power up and power down events.
- */
-static ssize_t store_file(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
-{
- int err = 0;
-
-#if MALI_POWER_MGMT_TEST_SUITE
- int test_flag_dvfs = 0;
- pwr_mgmt_status_reg = 0;
- mali_is_pmu_present();
-
#endif
- if (!strncmp(buf,mali_states[_MALI_DEVICE_SUSPEND],strlen(mali_states[_MALI_DEVICE_SUSPEND])))
- {
- MALI_DEBUG_PRINT(4, ("PMMDEBUG: MALI suspend Power operation is scheduled\n" ));
- err = mali_pm_suspend(NULL);
- }
-#if MALI_POWER_MGMT_TEST_SUITE
- else if (!strncmp(buf,mali_pmm_recording_events[_MALI_DEVICE_PMM_REGISTERED_CORES],strlen(mali_pmm_recording_events[_MALI_DEVICE_PMM_REGISTERED_CORES])))
- {
- MALI_DEBUG_PRINT(4, ("PMMDEBUG: MALI Device get number of registerd cores\n" ));
- pwr_mgmt_status_reg = _mali_pmm_cores_list();
- return count;
- }
- else if (!strncmp(buf,mali_pmm_recording_events[_MALI_DEVICE_PMM_TIMEOUT_EVENT],strlen(mali_pmm_recording_events[_MALI_DEVICE_PMM_TIMEOUT_EVENT])))
- {
- MALI_DEBUG_PRINT(4, ("PMMDEBUG: MALI timeout event recording is enabled\n" ));
- mali_timeout_event_recording_on = 1;
- }
- else if (!strncmp(buf,mali_pmm_recording_events[_MALI_DEVICE_PMM_JOB_SCHEDULING_EVENTS],strlen(mali_pmm_recording_events[_MALI_DEVICE_PMM_JOB_SCHEDULING_EVENTS])))
- {
- MALI_DEBUG_PRINT(4, ("PMMDEBUG: MALI Job scheduling events recording is enabled\n" ));
- mali_job_scheduling_events_recording_on = 1;
- }
-#endif /* MALI_POWER_MGMT_TEST_SUITE */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
- else if (!strncmp(buf,mali_states[_MALI_DEVICE_RESUME],strlen(mali_states[_MALI_DEVICE_RESUME])))
- {
- MALI_DEBUG_PRINT(4, ("PMMDEBUG: MALI Resume Power operation is scheduled\n" ));
- err = mali_pm_resume(NULL);
- }
- else if (!strncmp(buf,mali_states[_MALI_DVFS_PAUSE_EVENT],strlen(mali_states[_MALI_DVFS_PAUSE_EVENT])))
- {
- MALI_DEBUG_PRINT(4, ("PMMDEBUG: MALI DVFS Pause Power operation is scheduled\n" ));
- err = mali_dev_pause();
-#if MALI_POWER_MGMT_TEST_SUITE
- test_flag_dvfs = 1;
-#endif /* MALI_POWER_MGMT_TEST_SUITE */
- }
- else if (!strncmp(buf,mali_states[_MALI_DVFS_RESUME_EVENT],strlen(mali_states[_MALI_DVFS_RESUME_EVENT])))
- {
- MALI_DEBUG_PRINT(4, ("PMMDEBUG: MALI DVFS Resume Power operation is scheduled\n" ));
- err = mali_dev_resume();
-#if MALI_POWER_MGMT_TEST_SUITE
- test_flag_dvfs = 1;
-#endif /* MALI_POWER_MGMT_TEST_SUITE */
- }
- else
- {
- MALI_DEBUG_PRINT(4, ("PMMDEBUG: Invalid Power Mode Operation selected\n" ));
- }
-#if MALI_POWER_MGMT_TEST_SUITE
- if (test_flag_dvfs == 1)
- {
- if (err)
- {
- pwr_mgmt_status_reg = 2;
- }
- else
- {
- pwr_mgmt_status_reg = 1;
- }
- }
- else
- {
- if (1 == is_mali_pmu_present)
- {
- pwr_mgmt_status_reg = pmu_get_power_up_down_info();
- }
- }
-#endif /* MALI_POWER_MGMT_TEST_SUITE */
- return count;
-}
-
-/* Device attribute file */
-static DEVICE_ATTR(file, 0644, show_file, store_file);
-#endif /* CONFIG_PM_DEBUG */
-
-static int mali_pm_remove(struct platform_device *pdev)
+static int mali_os_suspend(struct platform_device *pdev, pm_message_t state)
{
-#ifdef CONFIG_PM_DEBUG
- device_remove_file(&mali_gpu_device.dev, &dev_attr_file);
-#endif /* CONFIG_PM_DEBUG */
-#ifdef CONFIG_PM_RUNTIME
-#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
- pm_runtime_disable(&pdev->dev);
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-#endif /* CONFIG_PM_RUNTIME */
- return 0;
+ MALI_DEBUG_PRINT(3, ("mali_os_suspend(old) called\n"));
+ mali_pm_os_suspend();
+ return 0; /* all ok */
}
-int mali_pd_enable(void)
+static int mali_os_resume(struct platform_device *pdev)
{
- return exynos_pd_enable(&exynos4_device_pd[PD_G3D].dev);
+ MALI_DEBUG_PRINT(3, ("mali_os_resume(old) called\n"));
+ mali_pm_os_resume();
+ return 0; /* all ok */
}
-static void mali_pm_shutdown(struct platform_device *pdev)
-{
- MALI_PRINT(("Mali shutdown!!\n"));
- mali_dvfs_device_state =_MALI_DEVICE_SHUTDOWN;
- exynos_pd_enable(&exynos4_device_pd[PD_G3D].dev);
- return;
-}
+#else
-/** This function is called when the device is probed */
-static int mali_pm_probe(struct platform_device *pdev)
+static int mali_os_suspend(struct device *dev)
{
-#ifdef CONFIG_PM_DEBUG
- int err;
- err = device_create_file(&mali_gpu_device.dev, &dev_attr_file);
- if (err)
- {
- MALI_DEBUG_PRINT(4, ("PMMDEBUG: Error in creating device file\n" ));
- }
-#endif /* CONFIG_PM_DEBUG */
- return 0;
+ MALI_DEBUG_PRINT(3, ("mali_os_suspend(new) called\n"));
+ mali_pm_os_suspend();
+ return 0; /* all ok */
}
-#ifdef MALI_REBOOTNOTIFIER
-static int mali_reboot_notify(struct notifier_block *this,
- unsigned long code, void *unused)
+
+static int mali_os_resume(struct device *dev)
{
- _mali_osk_atomic_inc_return(&mali_shutdown_state);
- mali_dvfs_device_state = _MALI_DEVICE_SHUTDOWN;
- MALI_PRINT(("REBOOT Notifier for mali\n"));
- return NOTIFY_DONE;
+ MALI_DEBUG_PRINT(3, ("mali_os_resume(new) called\n"));
+ mali_pm_os_resume();
+ return 0; /* all ok */
}
-static struct notifier_block mali_reboot_notifier = {
- .notifier_call = mali_reboot_notify,
-};
+
#endif
/** This function is called when Mali GPU device is initialized
@@ -626,50 +222,34 @@ static struct notifier_block mali_reboot_notifier = {
int _mali_dev_platform_register(void)
{
int err;
-#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
+
+#ifdef CONFIG_PM_RUNTIME
set_mali_parent_power_domain((void *)&mali_gpu_device);
#endif
#ifdef CONFIG_PM_RUNTIME
-#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
err = register_pm_notifier(&mali_pwr_notif_block);
if (err)
{
return err;
}
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-#endif /* CONFIG_PM_RUNTIME */
-
-#ifdef MALI_REBOOTNOTIFIER
- _mali_osk_atomic_init(&mali_shutdown_state, 0);
- err = register_reboot_notifier(&mali_reboot_notifier);
- if (err) {
- MALI_PRINT(("Failed to setup reboot notifier\n"));
- return err;
- }
#endif
+#if MALI_LICENSE_IS_GPL
err = platform_device_register(&mali_gpu_device);
- lock = _mali_osk_lock_init((_mali_osk_lock_flags_t)( _MALI_OSK_LOCKFLAG_READERWRITER | _MALI_OSK_LOCKFLAG_ORDERED), 0, 0);
if (!err)
{
err = platform_driver_register(&mali_plat_driver);
if (err)
{
- _mali_osk_lock_term(lock);
#ifdef CONFIG_PM_RUNTIME
-#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
unregister_pm_notifier(&mali_pwr_notif_block);
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-#endif /* CONFIG_PM_RUNTIME */
-
-#ifdef MALI_REBOOTNOTIFIER
- unregister_reboot_notifier(&mali_reboot_notifier);
#endif
-
platform_device_unregister(&mali_gpu_device);
}
}
+#endif
+
return err;
}
@@ -677,33 +257,12 @@ int _mali_dev_platform_register(void)
*/
void _mali_dev_platform_unregister(void)
{
- _mali_osk_lock_term(lock);
-
#ifdef CONFIG_PM_RUNTIME
-#if MALI_PMM_RUNTIME_JOB_CONTROL_ON
unregister_pm_notifier(&mali_pwr_notif_block);
-#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */
-#endif /* CONFIG_PM_RUNTIME */
-
-#ifdef MALI_REBOOTNOTIFIER
- unregister_reboot_notifier(&mali_reboot_notifier);
#endif
+
+#if MALI_LICENSE_IS_GPL
platform_driver_unregister(&mali_plat_driver);
platform_device_unregister(&mali_gpu_device);
+#endif
}
-
-int mali_get_ospmm_thread_state(void)
-{
- return is_os_pmm_thread_waiting;
-}
-
-#endif /* MALI_LICENSE_IS_GPL */
-#endif /* CONFIG_PM */
-
-#if MALI_STATE_TRACKING
-u32 mali_pmm_dump_os_thread_state( char *buf, u32 size )
-{
- return snprintf(buf, size, "OSPMM: OS PMM thread is waiting: %s\n", is_os_pmm_thread_waiting ? "true" : "false");
-}
-#endif /* MALI_STATE_TRACKING */
-#endif /* USING_MALI_PMM */