tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / r4p0_rel0 / platform / exynos4415 / exynos4.c
1 /* drivers/gpu/mali400/mali/platform/exynos4415/exynos4.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 exynos4.c
15  * Platform specific Mali driver functions for the exynos 4XXX based platforms
16  */
17
18 #ifdef CONFIG_PM_RUNTIME
19 #include <linux/pm_runtime.h>
20 #endif
21
22 #include <plat/devs.h>
23 #include "mali_kernel_common.h"
24 #include "exynos4_pmm.h"
25
26 #define MALI_GP_IRQ       EXYNOS4_IRQ_GP_3D
27 #define MALI_PP0_IRQ      EXYNOS4_IRQ_PP0_3D
28 #define MALI_PP1_IRQ      EXYNOS4_IRQ_PP1_3D
29 #define MALI_PP2_IRQ      EXYNOS4_IRQ_PP2_3D
30 #define MALI_PP3_IRQ      EXYNOS4_IRQ_PP3_3D
31 #define MALI_GP_MMU_IRQ   EXYNOS4_IRQ_GPMMU_3D
32 #define MALI_PP0_MMU_IRQ  EXYNOS4_IRQ_PPMMU0_3D
33 #define MALI_PP1_MMU_IRQ  EXYNOS4_IRQ_PPMMU1_3D
34 #define MALI_PP2_MMU_IRQ  EXYNOS4_IRQ_PPMMU2_3D
35 #define MALI_PP3_MMU_IRQ  EXYNOS4_IRQ_PPMMU3_3D
36
37 static struct resource mali_gpu_resources[] =
38 {
39         MALI_GPU_RESOURCES_MALI400_MP4(0x13000000,
40                                        MALI_GP_IRQ, MALI_GP_MMU_IRQ,
41                                        MALI_PP0_IRQ, MALI_PP0_MMU_IRQ,
42                                        MALI_PP1_IRQ, MALI_PP1_MMU_IRQ,
43                                        MALI_PP2_IRQ, MALI_PP2_MMU_IRQ,
44                                        MALI_PP3_IRQ, MALI_PP3_MMU_IRQ)
45 };
46
47 static struct mali_gpu_device_data mali_gpu_data =
48 {
49         .shared_mem_size = 256 * 1024 * 1024, /* 256MB */
50         .fb_start = 0x40000000,
51         .fb_size = 0xb1000000,
52         .utilization_interval = 100, /* 100ms */
53         .utilization_callback = mali_gpu_utilization_handler,
54 };
55
56 int mali_platform_device_register(void)
57 {
58         int err;
59
60         MALI_DEBUG_PRINT(4, ("mali_platform_device_register() called\n"));
61
62         /* Connect resources to the device */
63         err = platform_device_add_resources(&exynos4_device_g3d, mali_gpu_resources, sizeof(mali_gpu_resources) / sizeof(mali_gpu_resources[0]));
64         if (0 == err)
65         {
66                 err = platform_device_add_data(&exynos4_device_g3d, &mali_gpu_data, sizeof(mali_gpu_data));
67                 if (0 == err)
68                 {
69                         mali_platform_init(&(exynos4_device_g3d.dev));
70 #ifdef CONFIG_PM_RUNTIME
71                         pm_runtime_set_autosuspend_delay(&(exynos4_device_g3d.dev), 1000);
72                         pm_runtime_use_autosuspend(&(exynos4_device_g3d.dev));
73                         pm_runtime_enable(&(exynos4_device_g3d.dev));
74 #endif
75                         return 0;
76                 }
77
78         }
79         return err;
80 }
81
82 void mali_platform_device_unregister(void)
83 {
84         MALI_DEBUG_PRINT(4, ("mali_platform_device_unregister() called\n"));
85         mali_platform_deinit(&(exynos4_device_g3d.dev));
86 }