3 * (C) COPYRIGHT ARM Limited. All rights reserved.
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
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.
21 * @file mali_kbase_config.h
22 * Configuration API and Attributes for KBase
25 #ifndef _KBASE_CONFIG_H_
26 #define _KBASE_CONFIG_H_
28 #include <malisw/mali_stdtypes.h>
31 * @addtogroup base_api
36 * @addtogroup base_kbase_api
41 * @addtogroup kbase_config Configuration API and Attributes
45 #if MALI_CUSTOMER_RELEASE == 0
46 /* This flag is set for internal builds so we can run tests without credentials. */
47 #define KBASE_HWCNT_DUMP_BYPASS_ROOT 1
49 #define KBASE_HWCNT_DUMP_BYPASS_ROOT 0
52 #include <linux/rbtree.h>
55 * Device wide configuration
59 * Invalid attribute ID (reserve 0).
61 * Attached value: Ignored
64 KBASE_CONFIG_ATTR_INVALID,
67 * Maximum frequency GPU will be clocked at. Given in kHz.
68 * This must be specified as there is no default value.
70 * Attached value: number in kHz
73 KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MAX,
76 * Minimum frequency GPU will be clocked at. Given in kHz.
77 * This must be specified as there is no default value.
79 * Attached value: number in kHz
82 KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MIN,
85 * Irq throttle. It is the minimum desired time in between two
86 * consecutive gpu interrupts (given in 'us'). The irq throttle
87 * gpu register will be configured after this, taking into
88 * account the configured max frequency.
90 * Attached value: number in micro seconds
91 * Default value: see DEFAULT_IRQ_THROTTLE_TIME_US
93 KBASE_CONFIG_ATTR_GPU_IRQ_THROTTLE_TIME_US,
95 /*** Begin Job Scheduling Configs ***/
97 * Job Scheduler scheduling tick granuality. This is in nanoseconds to
98 * allow HR timer support.
100 * On each scheduling tick, the scheduler may decide to:
101 * -# soft stop a job (the job will be re-run later, and other jobs will
102 * be able to run on the GPU now). This effectively controls the
103 * 'timeslice' given to a job.
104 * -# hard stop a job (to kill a job if it has spent too long on the GPU
105 * and didn't soft-stop).
107 * The numbers of ticks for these events are controlled by:
108 * - @ref KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS
109 * - @ref KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_SS
110 * - @ref KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_NSS
112 * A soft-stopped job will later be resumed, allowing it to use more GPU
113 * time <em>in total</em> than that defined by any of the above. However,
114 * the scheduling policy attempts to limit the amount of \em uninterrupted
115 * time spent on the GPU using the above values (that is, the 'timeslice'
118 * This value is supported by the following scheduling policies:
119 * - The Completely Fair Share (CFS) policy
121 * Attached value: unsigned 32-bit kbasep_js_device_data::scheduling_tick_ns.
122 * The value might be rounded down to lower precision. Must be non-zero
123 * after rounding.<br>
124 * Default value: @ref DEFAULT_JS_SCHEDULING_TICK_NS
126 * @note this value is allowed to be greater than
127 * @ref KBASE_CONFIG_ATTR_JS_CTX_TIMESLICE_NS. This allows jobs to run on (much)
128 * longer than the job-timeslice, but once this happens, the context gets
129 * scheduled in (much) less frequently than others that stay within the
132 KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS,
135 * Job Scheduler minimum number of scheduling ticks before non-CL jobs
138 * This defines the amount of time a job is allowed to stay on the GPU,
139 * before it is soft-stopped to allow other jobs to run.
141 * That is, this defines the 'timeslice' of the job. It is separate from the
142 * timeslice of the context that contains the job (see
143 * @ref KBASE_CONFIG_ATTR_JS_CTX_TIMESLICE_NS).
145 * This value is supported by the following scheduling policies:
146 * - The Completely Fair Share (CFS) policy
148 * Attached value: unsigned 32-bit kbasep_js_device_data::soft_stop_ticks<br>
149 * Default value: @ref DEFAULT_JS_SOFT_STOP_TICKS
151 * @note a value of zero means "the quickest time to soft-stop a job",
152 * which is somewhere between instant and one tick later.
154 * @note this value is allowed to be greater than
155 * @ref KBASE_CONFIG_ATTR_JS_RESET_TICKS_SS or
156 * @ref KBASE_CONFIG_ATTR_JS_RESET_TICKS_NSS. This effectively disables
157 * soft-stop, and just uses hard-stop instead. In this case, this value
158 * should be much greater than any of the hard stop values (to avoid
159 * soft-stop-after-hard-stop)
161 * @see KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS
163 KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS,
166 * Job Scheduler minimum number of scheduling ticks before CL jobs
169 * This defines the amount of time a job is allowed to stay on the GPU,
170 * before it is soft-stopped to allow other jobs to run.
172 * That is, this defines the 'timeslice' of the job. It is separate
173 * from the timeslice of the context that contains the job (see
174 * @ref KBASE_CONFIG_ATTR_JS_CTX_TIMESLICE_NS).
176 * This value is supported by the following scheduling policies:
177 * - The Completely Fair Share (CFS) policy
179 * Attached value: unsigned 32-bit
180 * kbasep_js_device_data::soft_stop_ticks_cl<br>
181 * Default value: @ref DEFAULT_JS_SOFT_STOP_TICKS_CL
183 * @note a value of zero means "the quickest time to soft-stop a job",
184 * which is somewhere between instant and one tick later.
186 * @note this value is allowed to be greater than
187 * @ref KBASE_CONFIG_ATTR_JS_RESET_TICKS_CL. This effectively
188 * disables soft-stop, and just uses hard-stop instead. In this case,
189 * this value should be much greater than any of the hard stop values
190 * (to avoid soft-stop-after-hard-stop)
192 * @see KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS
194 KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS_CL,
197 * Job Scheduler minimum number of scheduling ticks before non-CL jobs
200 * This defines the amount of time a job is allowed to spend on the GPU before it
201 * is killed. Such jobs won't be resumed if killed.
203 * This value is supported by the following scheduling policies:
204 * - The Completely Fair Share (CFS) policy
206 * Attached value: unsigned 32-bit kbasep_js_device_data::hard_stop_ticks_ss<br>
207 * Default value: @ref DEFAULT_JS_HARD_STOP_TICKS_SS
209 * @note a value of zero means "the quickest time to hard-stop a job",
210 * which is somewhere between instant and one tick later.
212 * @see KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS
214 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_SS,
217 * Job Scheduler minimum number of scheduling ticks before CL jobs are hard-stopped.
219 * This defines the amount of time a job is allowed to spend on the GPU before it
220 * is killed. Such jobs won't be resumed if killed.
222 * This value is supported by the following scheduling policies:
223 * - The Completely Fair Share (CFS) policy
225 * Attached value: unsigned 32-bit kbasep_js_device_data::hard_stop_ticks_cl<br>
226 * Default value: @ref DEFAULT_JS_HARD_STOP_TICKS_CL
228 * @note a value of zero means "the quickest time to hard-stop a job",
229 * which is somewhere between instant and one tick later.
231 * @see KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS
233 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_CL,
236 * Job Scheduler minimum number of scheduling ticks before jobs are hard-stopped
239 * This defines the amount of time a job is allowed to spend on the GPU before it
240 * is killed. Such jobs won't be resumed if killed.
242 * This value is supported by the following scheduling policies:
243 * - The Completely Fair Share (CFS) policy
245 * Attached value: unsigned 32-bit kbasep_js_device_data::hard_stop_ticks_nss<br>
246 * Default value: @ref DEFAULT_JS_HARD_STOP_TICKS_NSS
248 * @note a value of zero means "the quickest time to hard-stop a job",
249 * which is somewhere between instant and one tick later.
251 * @see KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS
253 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_NSS,
256 * Job Scheduler timeslice that a context is scheduled in for, in nanoseconds.
258 * When a context has used up this amount of time across its jobs, it is
259 * scheduled out to let another run.
261 * @note the resolution is nanoseconds (ns) here, because that's the format
262 * often used by the OS.
264 * This value controls affects the actual time defined by the following
266 * - @ref KBASE_CONFIG_ATTR_JS_CFS_CTX_RUNTIME_INIT_SLICES
267 * - @ref KBASE_CONFIG_ATTR_JS_CFS_CTX_RUNTIME_MIN_SLICES
269 * This value is supported by the following scheduling policies:
270 * - The Completely Fair Share (CFS) policy
272 * Attached value: unsigned 32-bit kbasep_js_device_data::ctx_timeslice_ns.
273 * The value might be rounded down to lower precision.<br>
274 * Default value: @ref DEFAULT_JS_CTX_TIMESLICE_NS
276 * @note a value of zero models a "Round Robin" scheduling policy, and
277 * disables @ref KBASE_CONFIG_ATTR_JS_CFS_CTX_RUNTIME_INIT_SLICES
278 * (initially causing LIFO scheduling) and
279 * @ref KBASE_CONFIG_ATTR_JS_CFS_CTX_RUNTIME_MIN_SLICES (allowing
280 * not-run-often contexts to get scheduled in quickly, but to only use
281 * a single timeslice when they get scheduled in).
283 KBASE_CONFIG_ATTR_JS_CTX_TIMESLICE_NS,
286 * Job Scheduler initial runtime of a context for the CFS Policy, in time-slices.
288 * This value is relative to that of the least-run context, and defines
289 * where in the CFS queue a new context is added. A value of 1 means 'after
290 * the least-run context has used its timeslice'. Therefore, when all
291 * contexts consistently use the same amount of time, a value of 1 models a
292 * FIFO. A value of 0 would model a LIFO.
294 * The value is represented in "numbers of time slices". Multiply this
295 * value by that defined in @ref KBASE_CONFIG_ATTR_JS_CTX_TIMESLICE_NS to get
296 * the time value for this in nanoseconds.
298 * Attached value: unsigned 32-bit kbasep_js_device_data::cfs_ctx_runtime_init_slices<br>
299 * Default value: @ref DEFAULT_JS_CFS_CTX_RUNTIME_INIT_SLICES
301 KBASE_CONFIG_ATTR_JS_CFS_CTX_RUNTIME_INIT_SLICES,
304 * Job Scheduler minimum runtime value of a context for CFS, in time_slices
305 * relative to that of the least-run context.
307 * This is a measure of how much preferrential treatment is given to a
308 * context that is not run very often.
310 * Specficially, this value defines how many timeslices such a context is
311 * (initially) allowed to use at once. Such contexts (e.g. 'interactive'
312 * processes) will appear near the front of the CFS queue, and can initially
313 * use more time than contexts that run continuously (e.g. 'batch'
316 * This limit \b prevents a "stored-up timeslices" DoS attack, where a ctx
317 * not run for a long time attacks the system by using a very large initial
318 * number of timeslices when it finally does run.
320 * Attached value: unsigned 32-bit kbasep_js_device_data::cfs_ctx_runtime_min_slices<br>
321 * Default value: @ref DEFAULT_JS_CFS_CTX_RUNTIME_MIN_SLICES
323 * @note A value of zero allows not-run-often contexts to get scheduled in
324 * quickly, but to only use a single timeslice when they get scheduled in.
326 KBASE_CONFIG_ATTR_JS_CFS_CTX_RUNTIME_MIN_SLICES,
329 * Job Scheduler minimum number of scheduling ticks before non-CL jobs
330 * cause the GPU to be reset.
332 * This defines the amount of time a job is allowed to spend on the GPU before it
333 * is assumed that the GPU has hung and needs to be reset. The assumes that the job
334 * has been hard-stopped already and so the presence of a job that has remained on
335 * the GPU for so long indicates that the GPU has in some way hung.
337 * This value is supported by the following scheduling policies:
338 * - The Completely Fair Share (CFS) policy
340 * Attached value: unsigned 32-bit kbasep_js_device_data::gpu_reset_ticks_nss<br>
341 * Default value: @ref DEFAULT_JS_RESET_TICKS_SS
343 * @see KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS
345 KBASE_CONFIG_ATTR_JS_RESET_TICKS_SS,
348 * Job Scheduler minimum number of scheduling ticks before CL jobs
349 * cause the GPU to be reset.
351 * This defines the amount of time a job is allowed to spend on the GPU before it
352 * is assumed that the GPU has hung and needs to be reset. The assumes that the job
353 * has been hard-stopped already and so the presence of a job that has remained on
354 * the GPU for so long indicates that the GPU has in some way hung.
356 * This value is supported by the following scheduling policies:
357 * - The Completely Fair Share (CFS) policy
359 * Attached value: unsigned 32-bit kbasep_js_device_data::gpu_reset_ticks_cl<br>
360 * Default value: @ref DEFAULT_JS_RESET_TICKS_CL
362 * @see KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS
364 KBASE_CONFIG_ATTR_JS_RESET_TICKS_CL,
367 * Job Scheduler minimum number of scheduling ticks before jobs cause the GPU to be
368 * reset when dumping.
370 * This defines the amount of time a job is allowed to spend on the GPU before it
371 * is assumed that the GPU has hung and needs to be reset. The assumes that the job
372 * has been hard-stopped already and so the presence of a job that has remained on
373 * the GPU for so long indicates that the GPU has in some way hung.
375 * This value is supported by the following scheduling policies:
376 * - The Completely Fair Share (CFS) policy
378 * Attached value: unsigned 32-bit kbasep_js_device_data::gpu_reset_ticks_nss<br>
379 * Default value: @ref DEFAULT_JS_RESET_TICKS_NSS
381 * @see KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS
383 KBASE_CONFIG_ATTR_JS_RESET_TICKS_NSS,
386 * Number of milliseconds given for other jobs on the GPU to be
387 * soft-stopped when the GPU needs to be reset.
389 * Attached value: number in milliseconds
390 * Default value: @ref DEFAULT_JS_RESET_TIMEOUT_MS
392 KBASE_CONFIG_ATTR_JS_RESET_TIMEOUT_MS,
393 /*** End Job Scheduling Configs ***/
395 /** Power management configuration
397 * Attached value: pointer to @ref kbase_pm_callback_conf
398 * Default value: See @ref kbase_pm_callback_conf
400 KBASE_CONFIG_ATTR_POWER_MANAGEMENT_CALLBACKS,
403 * Boolean indicating whether the driver is configured to be secure at
404 * a potential loss of performance.
406 * This currently affects only r0p0-15dev0 HW and earlier.
408 * On r0p0-15dev0 HW and earlier, there are tradeoffs between security and
411 * - When this is set to MALI_TRUE, the driver remains fully secure,
412 * but potentially loses performance compared with setting this to
414 * - When set to MALI_FALSE, the driver is open to certain security
417 * From r0p0-00rel0 and onwards, there is no security loss by setting
418 * this to MALI_FALSE, and no performance loss by setting it to
421 * Attached value: mali_bool value
422 * Default value: @ref DEFAULT_SECURE_BUT_LOSS_OF_PERFORMANCE
424 KBASE_CONFIG_ATTR_SECURE_BUT_LOSS_OF_PERFORMANCE,
427 * A pointer to a function that calculates the CPU clock
428 * speed of the platform in MHz - see
429 * @ref kbase_cpuprops_clock_speed_function for the function
432 * Attached value: A @ref kbase_cpuprops_clock_speed_function.
433 * Default Value: Pointer to @ref DEFAULT_CPU_SPEED_FUNC -
434 * returns a clock speed of 100 MHz.
436 KBASE_CONFIG_ATTR_CPU_SPEED_FUNC,
439 * A pointer to a function that calculates the GPU clock
440 * speed of the platform in MHz - see
441 * @ref kbase_gpuprops_clock_speed_function for the function
444 * Attached value: A @ref kbase_gpuprops_clock_speed_function.
445 * Default Value: NULL (in which case the driver assumes a current
446 * GPU frequency specified by KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MAX)
448 KBASE_CONFIG_ATTR_GPU_SPEED_FUNC,
451 * Platform specific configuration functions
453 * Attached value: pointer to @ref kbase_platform_funcs_conf
454 * Default value: See @ref kbase_platform_funcs_conf
456 KBASE_CONFIG_ATTR_PLATFORM_FUNCS,
459 * Limit ARID width on the AXI bus.
461 * Attached value: u32 register value
462 * KBASE_AID_32 - use the full 32 IDs (5 ID bits)
463 * KBASE_AID_16 - use 16 IDs (4 ID bits)
464 * KBASE_AID_8 - use 8 IDs (3 ID bits)
465 * KBASE_AID_4 - use 4 IDs (2 ID bits)
466 * Default value: KBASE_AID_32 (no limit). Note hardware implementation
467 * may limit to a lower value.
469 KBASE_CONFIG_ATTR_ARID_LIMIT,
472 * Limit AWID width on the AXI bus.
474 * Attached value: u32 register value
475 * KBASE_AID_32 - use the full 32 IDs (5 ID bits)
476 * KBASE_AID_16 - use 16 IDs (4 ID bits)
477 * KBASE_AID_8 - use 8 IDs (3 ID bits)
478 * KBASE_AID_4 - use 4 IDs (2 ID bits)
479 * Default value: KBASE_AID_32 (no limit). Note hardware implementation
480 * may limit to a lower value.
482 KBASE_CONFIG_ATTR_AWID_LIMIT,
485 * Rate at which dvfs data should be collected.
487 * Attached value: u32 value
488 * Default value: 500 Milliseconds
490 KBASE_CONFIG_ATTR_POWER_MANAGEMENT_DVFS_FREQ,
493 * Power Management poweroff tick granuality. This is in nanoseconds to
494 * allow HR timer support.
496 * On each scheduling tick, the power manager core may decide to:
497 * -# Power off one or more shader cores
498 * -# Power off the entire GPU
500 * Attached value: number in nanoseconds
501 * Default value: @ref DEFAULT_PM_GPU_POWEROFF_TICK_NS,
503 KBASE_CONFIG_ATTR_PM_GPU_POWEROFF_TICK_NS,
506 * Power Manager number of ticks before shader cores are powered off
508 * Attached value: unsigned 32-bit kbasep_pm_device_data::poweroff_shader_ticks<br>
509 * Default value: @ref DEFAULT_PM_POWEROFF_TICK_SHADER
511 * @see KBASE_CONFIG_ATTR_PM_GPU_POWEROFF_TICK_NS
513 KBASE_CONFIG_ATTR_PM_POWEROFF_TICK_SHADER,
516 * Power Manager number of ticks before GPU is powered off
518 * Attached value: unsigned 32-bit kbasep_pm_device_data::poweroff_gpu_ticks<br>
519 * Default value: @ref DEFAULT_PM_POWEROFF_TICK_GPU
521 * @see KBASE_CONFIG_ATTR_PM_GPU_POWEROFF_TICK_NS
523 KBASE_CONFIG_ATTR_PM_POWEROFF_TICK_GPU,
526 * End of attribute list indicator.
527 * The configuration loader will stop processing any more elements
528 * when it encounters this attribute.
532 KBASE_CONFIG_ATTR_END = 0x1FFFUL
537 * Use unrestricted Address ID width on the AXI bus.
542 * Restrict GPU to a half of maximum Address ID count.
543 * This will reduce performance, but reduce bus load due to GPU.
548 * Restrict GPU to a quarter of maximum Address ID count.
549 * This will reduce performance, but reduce bus load due to GPU.
554 * Restrict GPU to an eighth of maximum Address ID count.
555 * This will reduce performance, but reduce bus load due to GPU.
561 * @brief specifies a single attribute
563 * Attribute is identified by attr field. Data is either integer or a pointer to attribute-specific structure.
565 typedef struct kbase_attribute {
570 /* Forward declaration of kbase_device */
574 * @brief Specifies the functions for platform specific initialization and termination
576 * By default no functions are required. No additional platform specific control is necessary.
578 typedef struct kbase_platform_funcs_conf {
580 * Function pointer for platform specific initialization or NULL if no initialization function is required.
581 * This function will be called \em before any other callbacks listed in the kbase_attribute struct (such as
582 * Power Management callbacks).
583 * The platform specific private pointer kbase_device::platform_context can be accessed (and possibly initialized) in here.
585 mali_bool(*platform_init_func) (struct kbase_device *kbdev);
587 * Function pointer for platform specific termination or NULL if no termination function is required.
588 * This function will be called \em after any other callbacks listed in the kbase_attribute struct (such as
589 * Power Management callbacks).
590 * The platform specific private pointer kbase_device::platform_context can be accessed (and possibly terminated) in here.
592 void (*platform_term_func) (struct kbase_device *kbdev);
594 } kbase_platform_funcs_conf;
597 * @brief Specifies the callbacks for power management
599 * By default no callbacks will be made and the GPU must not be powered off.
601 typedef struct kbase_pm_callback_conf {
602 /** Callback for when the GPU is idle and the power to it can be switched off.
604 * The system integrator can decide whether to either do nothing, just switch off
605 * the clocks to the GPU, or to completely power down the GPU.
606 * The platform specific private pointer kbase_device::platform_context can be accessed and modified in here. It is the
607 * platform \em callbacks responsiblity to initialize and terminate this pointer if used (see @ref kbase_platform_funcs_conf).
609 void (*power_off_callback) (struct kbase_device *kbdev);
611 /** Callback for when the GPU is about to become active and power must be supplied.
613 * This function must not return until the GPU is powered and clocked sufficiently for register access to
614 * succeed. The return value specifies whether the GPU was powered down since the call to power_off_callback.
615 * If the GPU state has been lost then this function must return 1, otherwise it should return 0.
616 * The platform specific private pointer kbase_device::platform_context can be accessed and modified in here. It is the
617 * platform \em callbacks responsiblity to initialize and terminate this pointer if used (see @ref kbase_platform_funcs_conf).
619 * The return value of the first call to this function is ignored.
621 * @return 1 if the GPU state may have been lost, 0 otherwise.
623 int (*power_on_callback) (struct kbase_device *kbdev);
625 /** Callback for when the system is requesting a suspend and GPU power
626 * must be switched off.
628 * Note that if this callback is present, then this may be called
629 * without a preceding call to power_off_callback. Therefore this
630 * callback must be able to take any action that might otherwise happen
631 * in power_off_callback.
633 * The platform specific private pointer kbase_device::platform_context
634 * can be accessed and modified in here. It is the platform \em
635 * callbacks responsibility to initialize and terminate this pointer if
636 * used (see @ref kbase_platform_funcs_conf).
638 void (*power_suspend_callback) (struct kbase_device *kbdev);
640 /** Callback for when the system is resuming from a suspend and GPU
641 * power must be switched on.
643 * Note that if this callback is present, then this may be called
644 * without a following call to power_on_callback. Therefore this
645 * callback must be able to take any action that might otherwise happen
646 * in power_on_callback.
648 * The platform specific private pointer kbase_device::platform_context
649 * can be accessed and modified in here. It is the platform \em
650 * callbacks responsibility to initialize and terminate this pointer if
651 * used (see @ref kbase_platform_funcs_conf).
653 void (*power_resume_callback) (struct kbase_device *kbdev);
655 /** Callback for handling runtime power management initialization.
657 * The runtime power management callbacks @ref power_runtime_off_callback and @ref power_runtime_on_callback
658 * will become active from calls made to the OS from within this function.
659 * The runtime calls can be triggered by calls from @ref power_off_callback and @ref power_on_callback.
660 * Note: for linux the kernel must have CONFIG_PM_RUNTIME enabled to use this feature.
662 * @return MALI_ERROR_NONE on success, else mali_error erro code.
664 mali_error(*power_runtime_init_callback) (struct kbase_device *kbdev);
666 /** Callback for handling runtime power management termination.
668 * The runtime power management callbacks @ref power_runtime_off_callback and @ref power_runtime_on_callback
669 * should no longer be called by the OS on completion of this function.
670 * Note: for linux the kernel must have CONFIG_PM_RUNTIME enabled to use this feature.
672 void (*power_runtime_term_callback) (struct kbase_device *kbdev);
674 /** Callback for runtime power-off power management callback
676 * For linux this callback will be called by the kernel runtime_suspend callback.
677 * Note: for linux the kernel must have CONFIG_PM_RUNTIME enabled to use this feature.
679 * @return 0 on success, else OS error code.
681 void (*power_runtime_off_callback) (struct kbase_device *kbdev);
683 /** Callback for runtime power-on power management callback
685 * For linux this callback will be called by the kernel runtime_resume callback.
686 * Note: for linux the kernel must have CONFIG_PM_RUNTIME enabled to use this feature.
688 int (*power_runtime_on_callback) (struct kbase_device *kbdev);
690 } kbase_pm_callback_conf;
693 * Type of the function pointer for KBASE_CONFIG_ATTR_CPU_SPEED_FUNC.
695 * @param clock_speed [out] Once called this will contain the current CPU clock speed in MHz.
696 * This is mainly used to implement OpenCL's clGetDeviceInfo().
698 * @return 0 on success, 1 on error.
700 typedef int (*kbase_cpuprops_clock_speed_function) (u32 *clock_speed);
703 * Type of the function pointer for KBASE_CONFIG_ATTR_GPU_SPEED_FUNC.
705 * @param clock_speed [out] Once called this will contain the current GPU clock speed in MHz.
706 * If the system timer is not available then this function is required
707 * for the OpenCL queue profiling to return correct timing information.
709 * @return 0 on success, 1 on error. When an error is returned the caller assumes a current
710 * GPU speed as specified by KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MAX.
712 typedef int (*kbase_gpuprops_clock_speed_function) (u32 *clock_speed);
715 typedef struct kbase_platform_config {
716 const kbase_attribute *attributes;
718 } kbase_platform_config;
722 * @brief Specifies start and end of I/O memory region.
724 typedef struct kbase_io_memory_region {
727 } kbase_io_memory_region;
730 * @brief Specifies I/O related resources like IRQs and memory region for I/O operations.
732 typedef struct kbase_io_resources {
736 kbase_io_memory_region io_memory_region;
737 } kbase_io_resources;
739 typedef struct kbase_platform_config {
740 const kbase_attribute *attributes;
741 const kbase_io_resources *io_resources;
743 } kbase_platform_config;
745 #endif /* CONFIG_OF */
748 * @brief Return character string associated with the given midgard type.
750 * @param[in] midgard_type - ID of midgard type
752 * @return Pointer to NULL-terminated character array associated with the given midgard type
754 const char *kbasep_midgard_type_to_string(u32 midgard_type);
757 * @brief Gets the next config attribute with the specified ID from the array of attributes.
759 * Function gets the next attribute with specified attribute id within specified array. If no such attribute is found,
762 * @param[in] attributes Array of attributes in which lookup is performed
763 * @param[in] attribute_id ID of attribute
765 * @return Pointer to the first attribute matching id or NULL if none is found.
767 const kbase_attribute *kbasep_get_next_attribute(const kbase_attribute *attributes, int attribute_id);
770 * @brief Gets the value of a single config attribute.
772 * Function gets the value of attribute specified as parameter. If no such attribute is found in the array of
773 * attributes, default value is used.
775 * @param[in] kbdev Kbase device pointer
776 * @param[in] attributes Array of attributes in which lookup is performed
777 * @param[in] attribute_id ID of attribute
779 * @return Value of attribute with the given id
781 uintptr_t kbasep_get_config_value(struct kbase_device *kbdev, const kbase_attribute *attributes, int attribute_id);
784 * @brief Validates configuration attributes
786 * Function checks validity of given configuration attributes. It will fail on any attribute with unknown id, attribute
787 * with invalid value or attribute list that is not correctly terminated. It will also fail if
788 * KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MIN or KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MAX are not specified.
790 * @param[in] kbdev Kbase device pointer
791 * @param[in] attributes Array of attributes to validate
793 * @return MALI_TRUE if no errors have been found in the config. MALI_FALSE otherwise.
795 mali_bool kbasep_validate_configuration_attributes(struct kbase_device *kbdev, const kbase_attribute *attributes);
798 * @brief Gets the pointer to platform config.
800 * @return Pointer to the platform config
802 kbase_platform_config *kbase_get_platform_config(void);
805 * @brief Gets the count of attributes in array
807 * Function gets the count of attributes in array. Note that end of list indicator is also included.
809 * @param[in] attributes Array of attributes
811 * @return Number of attributes in the array including end of list indicator.
813 int kbasep_get_config_attribute_count(const kbase_attribute *attributes);
816 * @brief Platform specific call to initialize hardware
818 * Function calls a platform defined routine if specified in the configuration attributes.
819 * The routine can initialize any hardware and context state that is required for the GPU block to function.
821 * @param[in] kbdev Kbase device pointer
823 * @return MALI_TRUE if no errors have been found in the config. MALI_FALSE otherwise.
825 mali_bool kbasep_platform_device_init(struct kbase_device *kbdev);
828 * @brief Platform specific call to terminate hardware
830 * Function calls a platform defined routine if specified in the configuration attributes.
831 * The routine can destroy any platform specific context state and shut down any hardware functionality that are
832 * outside of the Power Management callbacks.
834 * @param[in] kbdev Kbase device pointer
837 void kbasep_platform_device_term(struct kbase_device *kbdev);
839 /** @} *//* end group kbase_config */
840 /** @} *//* end group base_kbase_api */
841 /** @} *//* end group base_api */
843 #endif /* _KBASE_CONFIG_H_ */