1 /* drivers/gpu/mali400/mali/platform/pegasus-m400/exynos4.c
3 * Copyright 2011 by S.LSI. Samsung Electronics Inc.
4 * San#24, Nongseo-Dong, Giheung-Gu, Yongin, Korea
6 * Samsung SoC Mali400 DVFS driver
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software FoundatIon.
15 * Platform specific Mali driver functions for the exynos 4XXX based platforms
17 #include <linux/platform_device.h>
18 #include <linux/version.h>
20 #ifdef CONFIG_PM_RUNTIME
21 #include <linux/pm_runtime.h>
23 #include <linux/mali/mali_utgard.h>
24 #include "mali_kernel_common.h"
26 #include <linux/irq.h>
27 #include <plat/devs.h>
29 #include "exynos4_pmm.h"
31 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0) && LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
32 extern struct platform_device exynos4_device_pd[];
34 extern struct platform_device s5pv310_device_pd[];
35 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0) */
37 static void mali_platform_device_release(struct device *device);
38 static int mali_os_suspend(struct device *device);
39 static int mali_os_resume(struct device *device);
40 static int mali_os_freeze(struct device *device);
41 static int mali_os_thaw(struct device *device);
42 #ifdef CONFIG_PM_RUNTIME
43 static int mali_runtime_suspend(struct device *device);
44 static int mali_runtime_resume(struct device *device);
45 static int mali_runtime_idle(struct device *device);
48 #define MALI_GP_IRQ EXYNOS4_IRQ_GP_3D
49 #define MALI_PP0_IRQ EXYNOS4_IRQ_PP0_3D
50 #define MALI_PP1_IRQ EXYNOS4_IRQ_PP1_3D
51 #define MALI_PP2_IRQ EXYNOS4_IRQ_PP2_3D
52 #define MALI_PP3_IRQ EXYNOS4_IRQ_PP3_3D
53 #define MALI_GP_MMU_IRQ EXYNOS4_IRQ_GPMMU_3D
54 #define MALI_PP0_MMU_IRQ EXYNOS4_IRQ_PPMMU0_3D
55 #define MALI_PP1_MMU_IRQ EXYNOS4_IRQ_PPMMU1_3D
56 #define MALI_PP2_MMU_IRQ EXYNOS4_IRQ_PPMMU2_3D
57 #define MALI_PP3_MMU_IRQ EXYNOS4_IRQ_PPMMU3_3D
59 static struct resource mali_gpu_resources[] =
61 MALI_GPU_RESOURCES_MALI400_MP4(0x13000000,
62 MALI_GP_IRQ, MALI_GP_MMU_IRQ,
63 MALI_PP0_IRQ, MALI_PP0_MMU_IRQ,
64 MALI_PP1_IRQ, MALI_PP1_MMU_IRQ,
65 MALI_PP2_IRQ, MALI_PP2_MMU_IRQ,
66 MALI_PP3_IRQ, MALI_PP3_MMU_IRQ)
69 static struct dev_pm_ops mali_gpu_device_type_pm_ops =
71 .suspend = mali_os_suspend,
72 .resume = mali_os_resume,
73 .freeze = mali_os_freeze,
75 #ifdef CONFIG_PM_RUNTIME
76 .runtime_suspend = mali_runtime_suspend,
77 .runtime_resume = mali_runtime_resume,
78 .runtime_idle = mali_runtime_idle,
82 static struct device_type mali_gpu_device_device_type =
84 .pm = &mali_gpu_device_type_pm_ops,
88 static struct platform_device *mali_gpu_device;
90 static struct mali_gpu_device_data mali_gpu_data =
92 .shared_mem_size = 256 * 1024 * 1024, /* 256MB */
93 .fb_start = 0x40000000,
94 .fb_size = 0xb1000000,
95 /* .utilization_interval = 1000, *//* 1000ms */
96 .utilization_interval = 100, /* 100ms in Tizen */
97 .utilization_handler = mali_gpu_utilization_handler,
100 int mali_platform_device_register(void)
104 MALI_DEBUG_PRINT(4, ("mali_platform_device_register() called\n"));
106 /* Connect resources to the device */
107 err = platform_device_add_resources(&exynos4_device_g3d, mali_gpu_resources, sizeof(mali_gpu_resources) / sizeof(mali_gpu_resources[0]));
110 err = platform_device_add_data(&exynos4_device_g3d, &mali_gpu_data, sizeof(mali_gpu_data));
113 mali_platform_init();
115 #ifdef CONFIG_PM_RUNTIME
116 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
117 pm_runtime_set_autosuspend_delay(&(exynos4_device_g3d.dev), 300);
118 pm_runtime_use_autosuspend(&(exynos4_device_g3d.dev));
120 pm_runtime_enable(&(exynos4_device_g3d.dev));
129 void mali_platform_device_unregister(void)
131 MALI_DEBUG_PRINT(4, ("mali_platform_device_unregister() called\n"));
133 mali_platform_deinit();
136 static void mali_platform_device_release(struct device *device)
138 MALI_DEBUG_PRINT(4, ("mali_platform_device_release() called\n"));
141 static int mali_os_suspend(struct device *device)
145 MALI_DEBUG_PRINT(4, ("mali_os_suspend() called\n"));
147 if (NULL != device->driver &&
148 NULL != device->driver->pm &&
149 NULL != device->driver->pm->suspend)
151 /* Need to notify Mali driver about this event */
152 ret = device->driver->pm->suspend(device);
155 mali_platform_power_mode_change(MALI_POWER_MODE_DEEP_SLEEP);
160 static int mali_os_resume(struct device *device)
164 MALI_DEBUG_PRINT(4, ("mali_os_resume() called\n"));
166 mali_platform_power_mode_change(MALI_POWER_MODE_ON);
168 if (NULL != device->driver &&
169 NULL != device->driver->pm &&
170 NULL != device->driver->pm->resume)
172 /* Need to notify Mali driver about this event */
173 ret = device->driver->pm->resume(device);
179 static int mali_os_freeze(struct device *device)
183 MALI_DEBUG_PRINT(4, ("mali_os_freeze() called\n"));
185 if (NULL != device->driver &&
186 NULL != device->driver->pm &&
187 NULL != device->driver->pm->freeze)
189 /* Need to notify Mali driver about this event */
190 ret = device->driver->pm->freeze(device);
196 static int mali_os_thaw(struct device *device)
200 MALI_DEBUG_PRINT(4, ("mali_os_thaw() called\n"));
202 if (NULL != device->driver &&
203 NULL != device->driver->pm &&
204 NULL != device->driver->pm->thaw)
206 /* Need to notify Mali driver about this event */
207 ret = device->driver->pm->thaw(device);
213 #ifdef CONFIG_PM_RUNTIME
214 static int mali_runtime_suspend(struct device *device)
218 MALI_DEBUG_PRINT(4, ("mali_runtime_suspend() called\n"));
220 if (NULL != device->driver &&
221 NULL != device->driver->pm &&
222 NULL != device->driver->pm->runtime_suspend)
224 /* Need to notify Mali driver about this event */
225 ret = device->driver->pm->runtime_suspend(device);
228 mali_platform_power_mode_change(MALI_POWER_MODE_LIGHT_SLEEP);
233 static int mali_runtime_resume(struct device *device)
237 MALI_DEBUG_PRINT(4, ("mali_runtime_resume() called\n"));
239 mali_platform_power_mode_change(MALI_POWER_MODE_ON);
241 if (NULL != device->driver &&
242 NULL != device->driver->pm &&
243 NULL != device->driver->pm->runtime_resume)
245 /* Need to notify Mali driver about this event */
246 ret = device->driver->pm->runtime_resume(device);
252 static int mali_runtime_idle(struct device *device)
254 MALI_DEBUG_PRINT(4, ("mali_runtime_idle() called\n"));
256 if (NULL != device->driver &&
257 NULL != device->driver->pm &&
258 NULL != device->driver->pm->runtime_idle)
260 /* Need to notify Mali driver about this event */
261 int ret = device->driver->pm->runtime_idle(device);
268 pm_runtime_suspend(device);