tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / r4p0_rel0 / platform / exynos3250 / exynos3.c
1 /* drivers/gpu/mali400/mali/platform/exynos3250/exynos3.c
2  *
3  * Copyright 2011 by S.LSI. Samsung Electronics Inc.
4  * San#24, Nongseo-Dong, Giheung-Gu, Yongin, Korea
5  *
6  * Samsung SoC Mali400 DVFS driver
7  *
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.
11  */
12
13 /**
14  * @file exynos3.c
15  * Platform specific Mali driver functions for the exynos 3XXX based platforms
16  */
17 #include <linux/platform_device.h>
18 #include <linux/version.h>
19 #include <linux/pm.h>
20 #include <linux/pm_runtime.h>
21 #include <linux/mali/mali_utgard.h>
22 #include "mali_kernel_common.h"
23
24 #include <linux/irq.h>
25 #include <plat/devs.h>
26
27 #include "exynos3_pmm.h"
28
29 #define MALI_GP_IRQ             EXYNOS3_IRQ_GP_3D
30 #define MALI_PP0_IRQ            EXYNOS3_IRQ_PP0_3D
31 #define MALI_PP1_IRQ            EXYNOS3_IRQ_PP1_3D
32 #define MALI_GP_MMU_IRQ         EXYNOS3_IRQ_GPMMU_3D
33 #define MALI_PP0_MMU_IRQ        EXYNOS3_IRQ_PPMMU0_3D
34 #define MALI_PP1_MMU_IRQ        EXYNOS3_IRQ_PPMMU1_3D
35
36 static struct resource mali_gpu_resources[] = {
37         MALI_GPU_RESOURCES_MALI400_MP2(0x13000000,
38                                                 MALI_GP_IRQ, MALI_GP_MMU_IRQ,
39                                                 MALI_PP0_IRQ, MALI_PP0_MMU_IRQ,
40                                                 MALI_PP1_IRQ, MALI_PP1_MMU_IRQ)
41 };
42
43 static struct mali_gpu_device_data mali_gpu_data = {
44         .shared_mem_size = 256 * 1024 * 1024, /* 256MB */
45         .fb_start = 0x40000000,
46         .fb_size = 0xb1000000,
47         .utilization_interval = 100, /* 100ms */
48         .utilization_callback = mali_exynos_update_dvfs,
49 };
50
51 int mali_platform_device_register(void)
52 {
53         int err;
54
55         MALI_DEBUG_PRINT(4, ("mali_platform_device_register() called\n"));
56
57         /* Connect resources to the device */
58         err = platform_device_add_resources(&exynos4_device_g3d,
59                                                 mali_gpu_resources,
60                                                 sizeof(mali_gpu_resources) /
61                                                 sizeof(mali_gpu_resources[0]));
62         if (0 == err) {
63                 err = platform_device_add_data(&exynos4_device_g3d,
64                                                 &mali_gpu_data,
65                                                 sizeof(mali_gpu_data));
66                 if (0 == err) {
67                         mali_platform_init(&(exynos4_device_g3d.dev));
68
69 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
70                         pm_runtime_set_autosuspend_delay(&(exynos4_device_g3d.dev), 50);
71                         pm_runtime_use_autosuspend(&(exynos4_device_g3d.dev));
72 #endif
73                         pm_runtime_enable(&(exynos4_device_g3d.dev));
74                         return 0;
75                 }
76
77         }
78         return err;
79 }
80
81 void mali_platform_device_unregister(void)
82 {
83         MALI_DEBUG_PRINT(4, ("mali_platform_device_unregister() called\n"));
84
85         mali_platform_deinit(&(exynos4_device_g3d.dev));
86 }