2 * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
4 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
7 * A copy of the licence is included with the program, and can also be obtained from Free Software
8 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 * @file mali_platform.c
13 * Platform specific Mali driver functions for a default platform
16 #include <linux/platform_device.h>
17 #include <linux/version.h>
18 #include <linux/delay.h>
19 #include <linux/clk.h>
21 #ifdef CONFIG_PM_RUNTIME
22 #include <linux/pm_runtime.h>
25 #include <linux/mali/mali_utgard.h>
27 #include <mach/globalregs.h>
28 #include "mali_kernel_common.h"
29 #include "mali_kernel_linux.h"
32 #define SPRD_MALI_PHYS 0xA0010000
33 #define IRQ_G3D_INT 25
35 void mali_platform_device_release(struct device *device);
36 void mali_platform_utilization(unsigned int);
38 static struct resource mali_gpu_resources[] =
40 MALI_GPU_RESOURCES_MALI300_PMU(SPRD_MALI_PHYS, IRQ_G3D_INT, IRQ_G3D_INT,
41 IRQ_G3D_INT, IRQ_G3D_INT)
44 static struct mali_gpu_device_data mali_gpu_data =
46 .shared_mem_size = ARCH_MALI_MEMORY_SIZE_DEFAULT,
47 .utilization_interval = 300,
48 .utilization_handler = mali_platform_utilization,
51 static struct platform_device mali_gpu_device =
53 .name = MALI_GPU_NAME_UTGARD,
55 .num_resources = ARRAY_SIZE(mali_gpu_resources),
56 .resource = mali_gpu_resources,
57 .dev.platform_data = &mali_gpu_data,
58 .dev.release = mali_platform_device_release,
61 static int g_gpu_clock_on = 0;
62 static int g_gpu_power_on = 0;
64 int mali_platform_device_register(void)
68 MALI_DEBUG_PRINT(4, ("mali_platform_device_register() called\n"));
73 sprd_greg_clear_bits(REG_TYPE_GLOBAL, BIT(23), GR_G3D_PWR_CTRL);
79 sprd_greg_set_bits(REG_TYPE_AHB_GLOBAL, BIT(21), AHB_CTL0);
82 err = platform_device_register(&mali_gpu_device);
85 #ifdef CONFIG_PM_RUNTIME
86 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
87 pm_runtime_set_autosuspend_delay(&(mali_gpu_device.dev), 50);
88 pm_runtime_use_autosuspend(&(mali_gpu_device.dev));
90 pm_runtime_enable(&(mali_gpu_device.dev));
96 platform_device_unregister(&mali_gpu_device);
101 sprd_greg_clear_bits(REG_TYPE_AHB_GLOBAL, BIT(21), AHB_CTL0);
106 sprd_greg_set_bits(REG_TYPE_GLOBAL, BIT(23), GR_G3D_PWR_CTRL);
112 void mali_platform_device_unregister(void)
114 MALI_DEBUG_PRINT(4, ("mali_platform_device_unregister() called\n"));
116 platform_device_unregister(&mali_gpu_device);
121 sprd_greg_clear_bits(REG_TYPE_AHB_GLOBAL, BIT(21), AHB_CTL0);
126 sprd_greg_set_bits(REG_TYPE_GLOBAL, BIT(23), GR_G3D_PWR_CTRL);
130 void mali_platform_device_release(struct device *device)
132 MALI_DEBUG_PRINT(4, ("mali_platform_device_release() called\n"));
135 void mali_platform_power_mode_change(int power_mode)
139 case 0://MALI_POWER_MODE_ON:
140 sprd_greg_set_bits(REG_TYPE_AHB_GLOBAL, BIT(21), AHB_CTL0);
142 case 1://MALI_POWER_MODE_LIGHT_SLEEP:
143 sprd_greg_clear_bits(REG_TYPE_AHB_GLOBAL, BIT(21), AHB_CTL0);
145 case 2://MALI_POWER_MODE_DEEP_SLEEP:
146 sprd_greg_clear_bits(REG_TYPE_AHB_GLOBAL, BIT(21), AHB_CTL0);
151 void mali_platform_utilization(u32 utilization)