summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoren HUANG <b02279@freescle.com>2013-01-14 16:53:12 +0800
committerLoren Huang <b02279@freescale.com>2013-01-25 13:09:15 +0800
commit4eb50eb4b7c4e9e6d34a1939610dea214544b324 (patch)
tree662dc1ff169adadded6e11626d90744c21cf22af
parentca2426a9529060636d40a262647093c3bf139486 (diff)
ENGR00240988-10 Add runtime pm function call in gpu driver
Cherry-pick from imx_3.5.7 branch. -Add runtime pm function. -Set bus frequency to high when gpu power is on. Signed-off-by: Loren HUANG <b02279@freescale.com> Acked-by: Lily Zhang
-rw-r--r--drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.c8
-rw-r--r--drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.h2
-rw-r--r--drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c26
-rw-r--r--drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c19
4 files changed, 48 insertions, 7 deletions
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.c
index a5eed3539a6e..b3b28ec29cfb 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.c
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.c
@@ -28,6 +28,7 @@
#include <linux/mman.h>
#include <linux/slab.h>
#include <mach/hardware.h>
+#include <linux/pm_runtime.h>
#define _GC_OBJ_ZONE gcvZONE_DEVICE
@@ -359,9 +360,14 @@ gckGALDEVICE_Construct(
gckDebugFileSystemSetCurrentNode(device->dbgnode);
}
}
+#ifdef CONFIG_PM
+ /*Init runtime pm for gpu*/
+ pm_runtime_enable(pdev);
+ device->pmdev = pdev;
+#endif
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
device->gpu_regulator =(struct regulator*)0xffffffff ;
-
#else
/*get gpu regulator*/
device->gpu_regulator = regulator_get(pdev, "cpu_vddgpu");
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.h b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.h
index 1635ff690db7..f990adf9c2fd 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.h
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.h
@@ -93,6 +93,8 @@ typedef struct _gckGALDEVICE
/*Power management.*/
struct regulator *gpu_regulator;
+ /*Run time pm*/
+ struct device *pmdev;
}
* gckGALDEVICE;
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c
index 4da49fe3c7b0..7586bca52095 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c
@@ -43,9 +43,10 @@
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
#include <mach/viv_gpu.h>
+#else
+#include <linux/pm_runtime.h>
+#include <mach/busfreq.h>
#endif
-
-
/* Zone used for header/footer. */
#define _GC_OBJ_ZONE gcvZONE_DRIVER
@@ -1164,6 +1165,24 @@ static const struct of_device_id mxs_gpu_dt_ids[] = {
{/* sentinel */}
};
MODULE_DEVICE_TABLE(of, mxs_gpu_dt_ids);
+
+#ifdef CONFIG_PM
+int gpu_runtime_suspend(struct device *dev)
+{
+ release_bus_freq(BUS_FREQ_HIGH);
+ return 0;
+}
+
+int gpu_runtime_resume(struct device *dev)
+{
+ request_bus_freq(BUS_FREQ_HIGH);
+ return 0;
+}
+
+static const struct dev_pm_ops gpu_pm_ops = {
+ SET_RUNTIME_PM_OPS(gpu_runtime_suspend, gpu_runtime_resume, NULL)
+};
+#endif
#endif
static struct platform_driver gpu_driver = {
@@ -1177,6 +1196,9 @@ static struct platform_driver gpu_driver = {
.name = DEVICE_NAME,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
.of_match_table = mxs_gpu_dt_ids,
+#if CONFIG_PM
+ .pm = &gpu_pm_ops,
+#endif
#endif
}
};
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c
index e9e4e07106a6..cb6d3ea2c16f 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c
@@ -39,6 +39,7 @@
#include <linux/math64.h>
#endif
#include <linux/delay.h>
+#include <linux/pm_runtime.h>
#define _GC_OBJ_ZONE gcvZONE_OS
@@ -6738,9 +6739,14 @@ gckOS_SetGPUPower(
}
#endif
}
- if((Power == gcvTRUE) && (oldPowerState == gcvFALSE) &&
- !IS_ERR(Os->device->gpu_regulator))
+ if((Power == gcvTRUE) && (oldPowerState == gcvFALSE))
+ {
+ if(!IS_ERR(Os->device->gpu_regulator))
regulator_enable(Os->device->gpu_regulator);
+#ifdef CONFIG_PM
+ pm_runtime_get_sync(Os->device->pmdev);
+#endif
+ }
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
if (Clock == gcvTRUE) {
@@ -6843,9 +6849,14 @@ gckOS_SetGPUPower(
}
}
#endif
- if((Power == gcvFALSE) && (oldPowerState == gcvTRUE) &&
- !IS_ERR(Os->device->gpu_regulator))
+ if((Power == gcvFALSE) && (oldPowerState == gcvTRUE))
+ {
+#ifdef CONFIG_PM
+ pm_runtime_put_sync(Os->device->pmdev);
+#endif
+ if(!IS_ERR(Os->device->gpu_regulator))
regulator_disable(Os->device->gpu_regulator);
+ }
/* TODO: Put your code here. */
gcmkFOOTER_NO();
return gcvSTATUS_OK;