gpu: update midgard r21p0 kernel driver
[GitHub/LineageOS/G12/android_hardware_amlogic_kernel-modules_mali-driver.git] / t83x / kernel / drivers / gpu / arm / midgard / mali_kbase_hwaccess_pm.h
1 /*
2 *
3 * (C) COPYRIGHT 2014-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
19 /**
20 * @file mali_kbase_hwaccess_pm.h
21 * HW access power manager common APIs
22 */
23
24 #ifndef _KBASE_HWACCESS_PM_H_
25 #define _KBASE_HWACCESS_PM_H_
26
27 #include <mali_midg_regmap.h>
28 #include <linux/atomic.h>
29
30 #include <mali_kbase_pm_defs.h>
31
32 /* Forward definition - see mali_kbase.h */
33 struct kbase_device;
34
35 /* Functions common to all HW access backends */
36
37 /**
38 * Initialize the power management framework.
39 *
40 * Must be called before any other power management function
41 *
42 * @param kbdev The kbase device structure for the device (must be a valid
43 * pointer)
44 *
45 * @return 0 if the power management framework was successfully
46 * initialized.
47 */
48 int kbase_hwaccess_pm_init(struct kbase_device *kbdev);
49
50 /**
51 * Terminate the power management framework.
52 *
53 * No power management functions may be called after this (except
54 * @ref kbase_pm_init)
55 *
56 * @param kbdev The kbase device structure for the device (must be a valid
57 * pointer)
58 */
59 void kbase_hwaccess_pm_term(struct kbase_device *kbdev);
60
61 /**
62 * kbase_hwaccess_pm_powerup - Power up the GPU.
63 * @kbdev: The kbase device structure for the device (must be a valid pointer)
64 * @flags: Flags to pass on to kbase_pm_init_hw
65 *
66 * Power up GPU after all modules have been initialized and interrupt handlers
67 * installed.
68 *
69 * Return: 0 if powerup was successful.
70 */
71 int kbase_hwaccess_pm_powerup(struct kbase_device *kbdev,
72 unsigned int flags);
73
74 /**
75 * Halt the power management framework.
76 *
77 * Should ensure that no new interrupts are generated, but allow any currently
78 * running interrupt handlers to complete successfully. The GPU is forced off by
79 * the time this function returns, regardless of whether or not the active power
80 * policy asks for the GPU to be powered off.
81 *
82 * @param kbdev The kbase device structure for the device (must be a valid
83 * pointer)
84 */
85 void kbase_hwaccess_pm_halt(struct kbase_device *kbdev);
86
87 /**
88 * Perform any backend-specific actions to suspend the GPU
89 *
90 * @param kbdev The kbase device structure for the device (must be a valid
91 * pointer)
92 */
93 void kbase_hwaccess_pm_suspend(struct kbase_device *kbdev);
94
95 /**
96 * Perform any backend-specific actions to resume the GPU from a suspend
97 *
98 * @param kbdev The kbase device structure for the device (must be a valid
99 * pointer)
100 */
101 void kbase_hwaccess_pm_resume(struct kbase_device *kbdev);
102
103 /**
104 * Perform any required actions for activating the GPU. Called when the first
105 * context goes active.
106 *
107 * @param kbdev The kbase device structure for the device (must be a valid
108 * pointer)
109 */
110 void kbase_hwaccess_pm_gpu_active(struct kbase_device *kbdev);
111
112 /**
113 * Perform any required actions for idling the GPU. Called when the last
114 * context goes idle.
115 *
116 * @param kbdev The kbase device structure for the device (must be a valid
117 * pointer)
118 */
119 void kbase_hwaccess_pm_gpu_idle(struct kbase_device *kbdev);
120
121
122 /**
123 * Set the debug core mask.
124 *
125 * This determines which cores the power manager is allowed to use.
126 *
127 * @param kbdev The kbase device structure for the device (must be a
128 * valid pointer)
129 * @param new_core_mask_js0 The core mask to use for job slot 0
130 * @param new_core_mask_js0 The core mask to use for job slot 1
131 * @param new_core_mask_js0 The core mask to use for job slot 2
132 */
133 void kbase_pm_set_debug_core_mask(struct kbase_device *kbdev,
134 u64 new_core_mask_js0, u64 new_core_mask_js1,
135 u64 new_core_mask_js2);
136
137
138 /**
139 * Get the current policy.
140 *
141 * Returns the policy that is currently active.
142 *
143 * @param kbdev The kbase device structure for the device (must be a valid
144 * pointer)
145 *
146 * @return The current policy
147 */
148 const struct kbase_pm_ca_policy
149 *kbase_pm_ca_get_policy(struct kbase_device *kbdev);
150
151 /**
152 * Change the policy to the one specified.
153 *
154 * @param kbdev The kbase device structure for the device (must be a valid
155 * pointer)
156 * @param policy The policy to change to (valid pointer returned from
157 * @ref kbase_pm_ca_list_policies)
158 */
159 void kbase_pm_ca_set_policy(struct kbase_device *kbdev,
160 const struct kbase_pm_ca_policy *policy);
161
162 /**
163 * Retrieve a static list of the available policies.
164 *
165 * @param[out] policies An array pointer to take the list of policies. This may
166 * be NULL. The contents of this array must not be
167 * modified.
168 *
169 * @return The number of policies
170 */
171 int
172 kbase_pm_ca_list_policies(const struct kbase_pm_ca_policy * const **policies);
173
174
175 /**
176 * Get the current policy.
177 *
178 * Returns the policy that is currently active.
179 *
180 * @param kbdev The kbase device structure for the device (must be a valid
181 * pointer)
182 *
183 * @return The current policy
184 */
185 const struct kbase_pm_policy *kbase_pm_get_policy(struct kbase_device *kbdev);
186 int set_policy_by_name(struct kbase_device *kbdev, const char *name);
187
188 /**
189 * Change the policy to the one specified.
190 *
191 * @param kbdev The kbase device structure for the device (must be a valid
192 * pointer)
193 * @param policy The policy to change to (valid pointer returned from
194 * @ref kbase_pm_list_policies)
195 */
196 void kbase_pm_set_policy(struct kbase_device *kbdev,
197 const struct kbase_pm_policy *policy);
198
199 /**
200 * Retrieve a static list of the available policies.
201 *
202 * @param[out] policies An array pointer to take the list of policies. This may
203 * be NULL. The contents of this array must not be
204 * modified.
205 *
206 * @return The number of policies
207 */
208 int kbase_pm_list_policies(const struct kbase_pm_policy * const **policies);
209
210 #endif /* _KBASE_HWACCESS_PM_H_ */