summaryrefslogtreecommitdiff
path: root/mali_kbase/mali_kbase_config.h
blob: 549c17031556802c949f09d91a63c89a2e4575cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
 *
 * (C) COPYRIGHT 2010-2023 ARM Limited. All rights reserved.
 *
 * This program is free software and is provided to you under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation, and any use by you of this program is subject to the terms
 * of such GNU license.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you can access it online at
 * http://www.gnu.org/licenses/gpl-2.0.html.
 *
 */

/**
 * DOC: Configuration API and Attributes for KBase
 */

#ifndef _KBASE_CONFIG_H_
#define _KBASE_CONFIG_H_

#include <mali_malisw.h>

#include <linux/mm.h>

/* Forward declaration of struct kbase_device */
struct kbase_device;

/* Forward declaration of struct kbase_context */
struct kbase_context;

/**
 * struct kbase_platform_funcs_conf - Specifies platform integration function
 * pointers for DDK events such as device init and term.
 *
 * Specifies the functions pointers for platform specific initialization and
 * termination as well as other events. By default no functions are required.
 * No additional platform specific control is necessary.
 */
struct kbase_platform_funcs_conf {
	/**
	 * @platform_init_func: platform specific init function pointer
	 * @kbdev - kbase_device pointer
	 *
	 * Returns 0 on success, negative error code otherwise.
	 *
	 * Function pointer for platform specific initialization or NULL if no
	 * initialization function is required. At the point this the GPU is
	 * not active and its power and clocks are in unknown (platform specific
	 * state) as kbase doesn't yet have control of power and clocks.
	 *
	 * The platform specific private pointer kbase_device::platform_context
	 * can be accessed (and possibly initialized) in here.
	 */
	int (*platform_init_func)(struct kbase_device *kbdev);
	/**
	 * @platform_term_func: platform specific termination function pointer
	 * @kbdev - kbase_device pointer
	 *
	 * Function pointer for platform specific termination or NULL if no
	 * termination function is required. At the point this the GPU will be
	 * idle but still powered and clocked.
	 *
	 * The platform specific private pointer kbase_device::platform_context
	 * can be accessed (and possibly terminated) in here.
	 */
	void (*platform_term_func)(struct kbase_device *kbdev);

	/**
	 * @platform_late_init_func: platform specific late init function pointer
	 * @kbdev - kbase_device pointer
	 *
	 * Function pointer to inform that the kbase driver initialization completed
	 * or NULL if no such function is required. At this point the GPU driver will be
	 * fully initialized.
	 *
	 * The platform specific private pointer kbase_device::platform_context
	 * can be accessed (and possibly terminated) in here.
	 */
	int (*platform_late_init_func)(struct kbase_device *kbdev);

	/**
	 * @platform_late_term_func: platform specific late termination function pointer
	 * @kbdev - kbase_device pointer
	 *
	 * Function pointer for platform specific termination or NULL if no
	 * termination function is required. At this point the GPU driver will complete
	 * termination process
	 *
	 * The platform specific private pointer kbase_device::platform_context
	 * can be accessed (and possibly terminated) in here.
	 */
	void (*platform_late_term_func)(struct kbase_device *kbdev);
	/**
	 * @platform_handler_context_init_func: platform specific handler for
	 * when a new kbase_context is created.
	 * @kctx - kbase_context pointer
	 *
	 * Returns 0 on success, negative error code otherwise.
	 *
	 * Function pointer for platform specific initialization of a kernel
	 * context or NULL if not required. Called at the last stage of kernel
	 * context initialization.
	 */
	int (*platform_handler_context_init_func)(struct kbase_context *kctx);
	/**
	 * @platform_handler_context_term_func: platform specific handler for
	 * when a kbase_context is terminated.
	 * @kctx - kbase_context pointer
	 *
	 * Function pointer for platform specific termination of a kernel
	 * context or NULL if not required. Called at the first stage of kernel
	 * context termination.
	 */
	void (*platform_handler_context_term_func)(struct kbase_context *kctx);
	/**
	 * platform_handler_context_active - Platform specific handler, called when a context is
	 *                                   (re)activated.
	 *
	 * @kctx:  kbase_context pointer
	 *
	 * Context: Atomic context
	 */
	void (*platform_handler_context_active)(struct kbase_context *kctx);
	/**
	 * platform_handler_context_idle - Platform specific handler, called when a context is idled.
	 *
	 * @kctx:  kbase_context pointer
	 *
	 * Context: Atomic context
	 */
	void (*platform_handler_context_idle)(struct kbase_context *kctx);
	/**
	 * platform_handler_tick_tock - Platform specific callback when a scheduler tick/tock occurs.
	 *
	 * @kbdev: kbase_device pointer
	 *
	 * Context: Process context
	 */
	void (*platform_handler_tick_tock)(struct kbase_device *kbdev);
	/**
	 * platform_handler_work_begin_func - Platform specific handler whose
	 *                                    function changes depending on the
	 *                                    backend used.
	 * @param
	 *  - If job manager GPU: Param is a pointer of type struct kbase_jd_atom*,
	 *    to the atom that just started executing.
	 *  - If CSF GPU: Param is a pointer of type struct kbase_queue_group*, to
	 *    the group resident in a CSG slot which just started executing.
	 *
	 * Function pointer for platform specific handling at the point when a unit
	 * of work starts running on the GPU or set to NULL if not required. The
	 * function cannot assume that it is running in a process context.
	 *
	 * Context:
	 *  - If job manager: Function must be runnable in an interrupt context.
	 */
	void (*platform_handler_work_begin_func)(void* param);
	/**
	 * platform_handler_work_end_func - Platform specific handler whose function
	 *                                  changes depending on the backend used.
	 * @param
	 *  - If job manager GPU: Param is a pointer of type struct kbase_jd_atom*,
	 *    to the atom that just completed.
	 *  - If CSF GPU: Param is a pointer of type struct kbase_queue_group*, to
	 *    the group resident in a CSG slot which just completed or suspended
	 *    execution.
	 *
	 * Function pointer for platform specific handling at the point when a unit
	 * of work stops running on the GPU or set to NULL if not required. The
	 * function cannot assume that it is running in a process context.
	 *
	 * Context:
	 *  - If job manager: Function must be runnable in an interrupt context.
	 */
	void (*platform_handler_work_end_func)(void* param);
	/**
	 * platform_fw_cfg_init_func - Platform specific callback for FW configuration
	 *
	 * @kbdev: kbase_device pointer
	 *
	 * Function pointer for platform specific FW configuration
	 *
	 * Context: Process context
	 */
	int (*platform_fw_cfg_init_func)(struct kbase_device *kbdev);
	/**
	 * platform_handler_core_dump_func - Platform specific handler for triggering a core dump.
	 *
	 * @kbdev: kbase_device pointer
	 * @reason: A null terminated string containing a dump reason
	 *
	 * Function pointer for platform specific handling at the point an internal error
	 * has occurred, to dump debug info about the error. Or set to NULL if not required.
	 *
	 * Context: The caller must hold the hwaccess lock
	 */
	void (*platform_handler_core_dump_func)(struct kbase_device *kbdev, const char* reason);
};

/*
 * @brief Specifies the callbacks for power management
 *
 * By default no callbacks will be made and the GPU must not be powered off.
 */
struct kbase_pm_callback_conf {
	/** Callback for when the GPU is idle and the power to it can be switched off.
	 *
	 * The system integrator can decide whether to either do nothing, just switch off
	 * the clocks to the GPU, or to completely power down the GPU.
	 * The platform specific private pointer kbase_device::platform_context can be accessed and modified in here. It is the
	 * platform \em callbacks responsibility to initialize and terminate this pointer if used (see @ref kbase_platform_funcs_conf).
	 *
	 * If runtime PM is enabled and @power_runtime_gpu_idle_callback is used
	 * then this callback should power off the GPU (or switch off the clocks
	 * to GPU) immediately. If @power_runtime_gpu_idle_callback is not used,
	 * then this callback can set the autosuspend timeout (if desired) and
	 * let the GPU be powered down later.
	 */
	void (*power_off_callback)(struct kbase_device *kbdev);

	/** Callback for when the GPU is about to become active and power must be supplied.
	 *
	 * This function must not return until the GPU is powered and clocked sufficiently for register access to
	 * succeed.  The return value specifies whether the GPU was powered down since the call to power_off_callback.
	 * If the GPU state has been lost then this function must return 1, otherwise it should return 0.
	 * The platform specific private pointer kbase_device::platform_context can be accessed and modified in here. It is the
	 * platform \em callbacks responsibility to initialize and terminate this pointer if used (see @ref kbase_platform_funcs_conf).
	 *
	 * The return value of the first call to this function is ignored.
	 *
	 * @return 1 if the GPU state may have been lost, 0 otherwise.
	 */
	int (*power_on_callback)(struct kbase_device *kbdev);

	/** Callback for when the system is requesting a suspend and GPU power
	 * must be switched off.
	 *
	 * Note that if this callback is present, then this may be called
	 * without a preceding call to power_off_callback. Therefore this
	 * callback must be able to take any action that might otherwise happen
	 * in power_off_callback.
	 *
	 * The platform specific private pointer kbase_device::platform_context
	 * can be accessed and modified in here. It is the platform \em
	 * callbacks responsibility to initialize and terminate this pointer if
	 * used (see @ref kbase_platform_funcs_conf).
	 */
	void (*power_suspend_callback)(struct kbase_device *kbdev);

	/** Callback for when the system is resuming from a suspend and GPU
	 * power must be switched on.
	 *
	 * Note that if this callback is present, then this may be called
	 * without a following call to power_on_callback. Therefore this
	 * callback must be able to take any action that might otherwise happen
	 * in power_on_callback.
	 *
	 * The platform specific private pointer kbase_device::platform_context
	 * can be accessed and modified in here. It is the platform \em
	 * callbacks responsibility to initialize and terminate this pointer if
	 * used (see @ref kbase_platform_funcs_conf).
	 */
	void (*power_resume_callback)(struct kbase_device *kbdev);

	/** Callback for handling runtime power management initialization.
	 *
	 * The runtime power management callbacks @ref power_runtime_off_callback and @ref power_runtime_on_callback
	 * will become active from calls made to the OS from within this function.
	 * The runtime calls can be triggered by calls from @ref power_off_callback and @ref power_on_callback.
	 * Note: for linux the kernel must have CONFIG_PM_RUNTIME enabled to use this feature.
	 *
	 * @return 0 on success, else int error code.
	 */
	int (*power_runtime_init_callback)(struct kbase_device *kbdev);

	/** Callback for handling runtime power management termination.
	 *
	 * The runtime power management callbacks @ref power_runtime_off_callback and @ref power_runtime_on_callback
	 * should no longer be called by the OS on completion of this function.
	 * Note: for linux the kernel must have CONFIG_PM_RUNTIME enabled to use this feature.
	 */
	void (*power_runtime_term_callback)(struct kbase_device *kbdev);

	/** Callback for runtime power-off power management callback
	 *
	 * For linux this callback will be called by the kernel runtime_suspend callback.
	 * Note: for linux the kernel must have CONFIG_PM_RUNTIME enabled to use this feature.
	 */
	void (*power_runtime_off_callback)(struct kbase_device *kbdev);

	/** Callback for runtime power-on power management callback
	 *
	 * For linux this callback will be called by the kernel runtime_resume callback.
	 * Note: for linux the kernel must have CONFIG_PM_RUNTIME enabled to use this feature.
	 *
	 * @return 0 on success, else OS error code.
	 */
	int (*power_runtime_on_callback)(struct kbase_device *kbdev);

	/*
	 * Optional callback for checking if GPU can be suspended when idle
	 *
	 * This callback will be called by the runtime power management core
	 * when the reference count goes to 0 to provide notification that the
	 * GPU now seems idle.
	 *
	 * If this callback finds that the GPU can't be powered off, or handles
	 * suspend by powering off directly or queueing up a power off, a
	 * non-zero value must be returned to prevent the runtime PM core from
	 * also triggering a suspend.
	 *
	 * Returning 0 will cause the runtime PM core to conduct a regular
	 * autosuspend.
	 *
	 * This callback is optional and if not provided regular autosuspend
	 * will be triggered.
	 *
	 * Note: The Linux kernel must have CONFIG_PM_RUNTIME enabled to use
	 * this feature.
	 *
	 * Return 0 if GPU can be suspended, positive value if it can not be
	 * suspeneded by runtime PM, else OS error code
	 */
	int (*power_runtime_idle_callback)(struct kbase_device *kbdev);

	/*
	 * Optional callback for software reset
	 *
	 * This callback will be called by the power management core to trigger
	 * a GPU soft reset.
	 *
	 * Return 0 if the soft reset was successful and the RESET_COMPLETED
	 * interrupt will be raised, or a positive value if the interrupt won't
	 * be raised. On error, return the corresponding OS error code.
	 */
	int (*soft_reset_callback)(struct kbase_device *kbdev);

	/*
	 * Optional callback for full hardware reset of the GPU
	 *
	 * This callback will be called by the power management core to trigger
	 * a GPU hardware reset.
	 */
	void (*hardware_reset_callback)(struct kbase_device *kbdev);

	/*
	 * Optional callback invoked after GPU becomes idle, not supported on
	 * JM GPUs.
	 *
	 * This callback will be invoked by the Kbase when GPU becomes idle.
	 * For JM GPUs or when runtime PM is disabled, Kbase will not invoke
	 * this callback and @power_off_callback will be invoked directly.
	 *
	 * This callback is supposed to decrement the runtime PM core reference
	 * count to zero and trigger the auto-suspend timer, which implies that
	 * @power_off_callback shouldn't initiate the runtime suspend.
	 *
	 * GPU registers still remain accessible until @power_off_callback gets
	 * invoked later on the expiry of auto-suspend timer.
	 *
	 * Note: The Linux kernel must have CONFIG_PM_RUNTIME enabled to use
	 * this feature.
	 */
	void (*power_runtime_gpu_idle_callback)(struct kbase_device *kbdev);

	/*
	 * Optional callback invoked to change the runtime PM core state to
	 * active.
	 *
	 * This callback will be invoked by Kbase when GPU needs to be
	 * reactivated, but only if @power_runtime_gpu_idle_callback was invoked
	 * previously. So both @power_runtime_gpu_idle_callback and this
	 * callback needs to be implemented at the same time.
	 *
	 * Kbase will invoke @power_on_callback first before invoking this
	 * callback if the GPU was powered down previously, otherwise directly.
	 *
	 * This callback is supposed to increment the runtime PM core reference
	 * count to 1, which implies that @power_on_callback shouldn't initiate
	 * the runtime resume. The runtime resume may not happen synchronously
	 * to avoid a potential deadlock due to the runtime suspend happening
	 * simultaneously from some other thread.
	 *
	 * Note: The Linux kernel must have CONFIG_PM_RUNTIME enabled to use
	 * this feature.
	 */
	void (*power_runtime_gpu_active_callback)(struct kbase_device *kbdev);
};

/* struct kbase_gpu_clk_notifier_data - Data for clock rate change notifier.
 *
 * Pointer to this structure is supposed to be passed to the gpu clock rate
 * change notifier function. This structure is deliberately aligned with the
 * common clock framework notification structure 'struct clk_notifier_data'
 * and such alignment should be maintained.
 *
 * @gpu_clk_handle: Handle of the GPU clock for which notifier was registered.
 * @old_rate:       Previous rate of this GPU clock in Hz.
 * @new_rate:       New rate of this GPU clock in Hz.
 */
struct kbase_gpu_clk_notifier_data {
	void *gpu_clk_handle;
	unsigned long old_rate;
	unsigned long new_rate;
};

/**
 * struct kbase_clk_rate_trace_op_conf - Specifies GPU clock rate trace
 * operations.
 *
 * Specifies the functions pointers for platform specific GPU clock rate trace
 * operations. By default no functions are required.
 */
struct kbase_clk_rate_trace_op_conf {
	/**
	 * @enumerate_gpu_clk: Enumerate a GPU clock on the given index
	 * @kbdev - kbase_device pointer
	 * @index - GPU clock index
	 *
	 * Returns a handle unique to the given GPU clock, or NULL if the clock
	 * array has been exhausted at the given index value.
	 *
	 * Kbase will use this function pointer to enumerate the existence of a
	 * GPU clock on the given index.
	 */
	void *(*enumerate_gpu_clk)(struct kbase_device *kbdev, unsigned int index);

	/**
	 * @get_gpu_clk_rate: Get the current rate for an enumerated clock.
	 * @kbdev          - kbase_device pointer
	 * @gpu_clk_handle - Handle unique to the enumerated GPU clock
	 *
	 * Returns current rate of the GPU clock in unit of Hz.
	 */
	unsigned long (*get_gpu_clk_rate)(struct kbase_device *kbdev, void *gpu_clk_handle);

	/**
	 * @gpu_clk_notifier_register: Register a clock rate change notifier.
	 * @kbdev          - kbase_device pointer
	 * @gpu_clk_handle - Handle unique to the enumerated GPU clock
	 * @nb             - notifier block containing the callback function
	 *                   pointer
	 *
	 * Returns 0 on success, negative error code otherwise.
	 *
	 * This function pointer is used to register a callback function that
	 * is supposed to be invoked whenever the rate of clock corresponding
	 * to @gpu_clk_handle changes.
	 * @nb contains the pointer to callback function.
	 * The callback function expects the pointer of type
	 * 'struct kbase_gpu_clk_notifier_data' as the third argument.
	 */
	int (*gpu_clk_notifier_register)(struct kbase_device *kbdev, void *gpu_clk_handle,
					 struct notifier_block *nb);

	/**
	 * @gpu_clk_notifier_unregister: Unregister clock rate change notifier
	 * @kbdev          - kbase_device pointer
	 * @gpu_clk_handle - Handle unique to the enumerated GPU clock
	 * @nb             - notifier block containing the callback function
	 *                   pointer
	 *
	 * This function pointer is used to unregister a callback function that
	 * was previously registered to get notified of the change in rate
	 * of clock corresponding to @gpu_clk_handle.
	 */
	void (*gpu_clk_notifier_unregister)(struct kbase_device *kbdev, void *gpu_clk_handle,
					    struct notifier_block *nb);
};

#if IS_ENABLED(CONFIG_OF)
struct kbase_platform_config {
};
#else

/*
 * @brief Specifies start and end of I/O memory region.
 */
struct kbase_io_memory_region {
	u64 start;
	u64 end;
};

/*
 * @brief Specifies I/O related resources like IRQs and memory region for I/O operations.
 */
struct kbase_io_resources {
	u32 job_irq_number;
	u32 mmu_irq_number;
	u32 gpu_irq_number;
	struct kbase_io_memory_region io_memory_region;
};

struct kbase_platform_config {
	const struct kbase_io_resources *io_resources;
};

#endif /* CONFIG_OF */

/**
 * kbase_get_platform_config - Gets the pointer to platform config.
 *
 * Return: Pointer to the platform config
 */
struct kbase_platform_config *kbase_get_platform_config(void);

/**
 * kbasep_platform_device_init: - Platform specific call to initialize hardware
 * @kbdev: kbase device pointer
 *
 * Function calls a platform defined routine if specified in the configuration
 * attributes.  The routine can initialize any hardware and context state that
 * is required for the GPU block to function.
 *
 * Return: 0 if no errors have been found in the config.
 *         Negative error code otherwise.
 */
int kbasep_platform_device_init(struct kbase_device *kbdev);

/**
 * kbasep_platform_device_term - Platform specific call to terminate hardware
 * @kbdev: Kbase device pointer
 *
 * Function calls a platform defined routine if specified in the configuration
 * attributes. The routine can destroy any platform specific context state and
 * shut down any hardware functionality that are outside of the Power Management
 * callbacks.
 *
 */
void kbasep_platform_device_term(struct kbase_device *kbdev);

/**
 * kbasep_platform_device_late_init: - Platform specific call to finish hardware
 *                                     initialization
 * @kbdev: kbase device pointer
 *
 * Function calls a platform defined routine if specified in the configuration
 * attributes.  The routine can initialize any hardware and context state that
 * is required for the GPU block to function.
 *
 * Return: 0 if no errors have been found in the config.
 *         Negative error code otherwise.
 */
int kbasep_platform_device_late_init(struct kbase_device *kbdev);

/**
 * kbasep_platform_device_late_term - Platform specific call to finish hardware
 *                                    termination
 * @kbdev: Kbase device pointer
 *
 * Function calls a platform defined routine if specified in the configuration
 * attributes. The routine can destroy any platform specific context state and
 * shut down any hardware functionality that are outside of the Power Management
 * callbacks.
 *
 */
void kbasep_platform_device_late_term(struct kbase_device *kbdev);

/**
 * kbasep_platform_context_init - Platform specific callback when a kernel
 *                                context is created
 * @kctx: kbase_context pointer
 *
 * Function calls a platform defined routine if specified in the configuration
 * attributes.  The routine can initialize any per kernel context structures
 * that are required for the GPU block to function.
 *
 * Return: 0 if no errors were encountered. Negative error code otherwise.
 */
int kbasep_platform_context_init(struct kbase_context *kctx);

/**
 * kbasep_platform_context_term - Platform specific callback when a kernel
 *                                context is terminated
 * @kctx: kbase_context pointer
 *
 * Function calls a platform defined routine if specified in the configuration
 * attributes.  The routine should terminate any per kernel context structures
 * created as part of &kbasep_platform_context_init.
 *
 */
void kbasep_platform_context_term(struct kbase_context *kctx);

/**
 * kbasep_platform_context_active - Platform specific callback, called when a context is
 *                                 (re)activated.
 *
 * @kctx:  kbase_context pointer
 *
 * Function calls a platform defined routine if specified in the configuration attributes.
 */
void kbasep_platform_context_active(struct kbase_context *kctx);

/**
 * kbasep_platform_context_idle - Platform specific callback, called when a context is idled.
 *
 * @kctx:  kbase_context pointer
 *
 * Function calls a platform defined routine if specified in the configuration attributes.
 */
void kbasep_platform_context_idle(struct kbase_context *kctx);

/**
 * kbasep_platform_event_work_begin - Platform specific callback whose function
 *                                    changes depending on the backend used.
 *                                    Signals that a unit of work has started
 *                                    running on the GPU.
 * @param
 *  - If job manager GPU: Param is a pointer of type struct kbase_jd_atom*,
 *    to the atom that just started executing.
 *  - If CSF GPU: Param is a pointer of type struct kbase_queue_group*, to
 *    the group resident in a CSG slot which just started executing.
 *
 * Function calls a platform defined routine if specified in the configuration
 * attributes. The routine should not assume that it is in a process context.
 *
 */
void kbasep_platform_event_work_begin(void *param);

/**
 * kbasep_platform_event_work_end - Platform specific callback whose function
 *                                  changes depending on the backend used.
 *                                  Signals that a unit of work has completed.
 * @param
 *  - If job manager GPU: Param is a pointer of type struct kbase_jd_atom*,
 *    to the atom that just completed.
 *  - If CSF GPU: Param is a pointer of type struct kbase_queue_group*, to
 *    the group resident in a CSG slot which just completed or suspended execution.
 *
 * Function calls a platform defined routine if specified in the configuration
 * attributes. The routine should not assume that it is in a process context.
 *
 */
void kbasep_platform_event_work_end(void *param);

/**
 * kbasep_platform_tick_tock - Platform specific callback when a scheduler tick/tock occurs.
 *
 * @kbdev: kbase_device pointer
 *
 * Function calls a platform defined routine if specified in the configuration attributes.
 *
 */
void kbasep_platform_event_tick_tock(struct kbase_device *kbdev);

/**
 * kbasep_platform_fw_config_init - Platform specific callback to configure FW
 *
 * @kbdev - kbase_device pointer
 *
 * Function calls a platform defined routine if specified in the configuration attributes.
 *
 */
int kbasep_platform_fw_config_init(struct kbase_device *kbdev);

/**
 * kbasep_platform_event_core_dump - Platform specific callback to act on a firmware error.
 *
 * @kbdev - kbase_device pointer
 * @reason: A null terminated string containing a dump reason
 *
 * Function calls a platform defined routine if specified in the configuration attributes.
 *
 */
void kbasep_platform_event_core_dump(struct kbase_device *kbdev, const char* reason);

#ifndef CONFIG_OF
/**
 * kbase_platform_register - Register a platform device for the GPU
 * This can be used to register a platform device on systems where device tree
 * is not enabled and the platform initialisation code in the kernel doesn't
 * create the GPU device. Where possible device tree should be used instead.
 *
 * Return: 0 for success, any other fail causes module initialisation to fail
 */
int kbase_platform_register(void);

/**
 * kbase_platform_unregister - Unregister a fake platform device
 *
 * Unregister the platform device created with kbase_platform_register()
 */
void kbase_platform_unregister(void);
#endif

#endif /* _KBASE_CONFIG_H_ */