MALI: rockchip: upgrade DDK to r8p0-02rel0.
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard / platform / juno_soc / mali_kbase_config_juno_soc.c
1 /*
2  *
3  * (C) COPYRIGHT 2011-2015 ARM Limited. All rights reserved.
4  *
5  * This program is free software and is provided to you under the terms of the
6  * GNU General Public License version 2 as published by the Free Software
7  * Foundation, and any use by you of this program is subject to the terms
8  * of such GNU licence.
9  *
10  * A copy of the licence is included with the program, and can also be obtained
11  * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12  * Boston, MA  02110-1301, USA.
13  *
14  */
15
16
17
18 #include <linux/ioport.h>
19 #include <linux/thermal.h>
20 #include <mali_kbase.h>
21 #include <mali_kbase_defs.h>
22 #include <mali_kbase_config.h>
23 #include <mali_kbase_smc.h>
24
25 /* Versatile Express (VE) Juno Development Platform */
26
27 #define HARD_RESET_AT_POWER_OFF 0
28
29 #ifndef CONFIG_OF
30 static struct kbase_io_resources io_resources = {
31         .job_irq_number = 65,
32         .mmu_irq_number = 66,
33         .gpu_irq_number = 64,
34         .io_memory_region = {
35                              .start = 0x2D000000,
36                              .end = 0x2D000000 + (4096 * 4) - 1}
37 };
38 #endif
39
40 static int pm_callback_power_on(struct kbase_device *kbdev)
41 {
42         /* Nothing is needed on VExpress, but we may have destroyed GPU state (if the below HARD_RESET code is active) */
43         return 1;
44 }
45
46 static void pm_callback_power_off(struct kbase_device *kbdev)
47 {
48 #if HARD_RESET_AT_POWER_OFF
49         /* Cause a GPU hard reset to test whether we have actually idled the GPU
50          * and that we properly reconfigure the GPU on power up.
51          * Usually this would be dangerous, but if the GPU is working correctly it should
52          * be completely safe as the GPU should not be active at this point.
53          * However this is disabled normally because it will most likely interfere with
54          * bus logging etc.
55          */
56         KBASE_TRACE_ADD(kbdev, CORE_GPU_HARD_RESET, NULL, NULL, 0u, 0);
57         kbase_os_reg_write(kbdev, GPU_CONTROL_REG(GPU_COMMAND), GPU_COMMAND_HARD_RESET);
58 #endif
59 }
60
61 struct kbase_pm_callback_conf pm_callbacks = {
62         .power_on_callback = pm_callback_power_on,
63         .power_off_callback = pm_callback_power_off,
64         .power_suspend_callback  = NULL,
65         .power_resume_callback = NULL
66 };
67
68 /*
69  * Juno Secure Mode integration
70  */
71
72 /* SMC Function Numbers */
73 #define JUNO_SMC_SECURE_ENABLE_FUNC  0xff06
74 #define JUNO_SMC_SECURE_DISABLE_FUNC 0xff07
75
76 static int juno_secure_mode_enable(struct kbase_device *kbdev)
77 {
78         u32 gpu_id = kbdev->gpu_props.props.raw_props.gpu_id;
79
80         if (gpu_id == GPU_ID_MAKE(GPU_ID_PI_T62X, 0, 1, 0) &&
81                         kbdev->reg_start == 0x2d000000) {
82                 /* T62X in SoC detected */
83                 u64 ret = kbase_invoke_smc(SMC_OEN_SIP,
84                         JUNO_SMC_SECURE_ENABLE_FUNC, false,
85                         0, 0, 0);
86                 return ret;
87         }
88
89         return -EINVAL; /* Not supported */
90 }
91
92 static int juno_secure_mode_disable(struct kbase_device *kbdev)
93 {
94         u32 gpu_id = kbdev->gpu_props.props.raw_props.gpu_id;
95
96         if (gpu_id == GPU_ID_MAKE(GPU_ID_PI_T62X, 0, 1, 0) &&
97                         kbdev->reg_start == 0x2d000000) {
98                 /* T62X in SoC detected */
99                 u64 ret = kbase_invoke_smc(SMC_OEN_SIP,
100                         JUNO_SMC_SECURE_DISABLE_FUNC, false,
101                         0, 0, 0);
102                 return ret;
103         }
104
105         return -EINVAL; /* Not supported */
106 }
107
108 struct kbase_secure_ops juno_secure_ops = {
109         .secure_mode_enable = juno_secure_mode_enable,
110         .secure_mode_disable = juno_secure_mode_disable,
111 };
112
113 static struct kbase_platform_config versatile_platform_config = {
114 #ifndef CONFIG_OF
115         .io_resources = &io_resources
116 #endif
117 };
118
119 struct kbase_platform_config *kbase_get_platform_config(void)
120 {
121         return &versatile_platform_config;
122 }
123
124 int kbase_platform_early_init(void)
125 {
126         /* Nothing needed at this stage */
127         return 0;
128 }