xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/bifrost/arbiter/mali_kbase_arbif.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2019-2021 ARM Limited. All rights reserved.
5  *
6  * This program is free software and is provided to you under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation, and any use by you of this program is subject to the terms
9  * of such GNU license.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you can access it online at
18  * http://www.gnu.org/licenses/gpl-2.0.html.
19  *
20  */
21 
22 /**
23  * DOC: Mali arbiter interface APIs to share GPU between Virtual Machines
24  */
25 
26 #ifndef _MALI_KBASE_ARBIF_H_
27 #define _MALI_KBASE_ARBIF_H_
28 
29 /**
30  * enum kbase_arbif_evt - Internal Arbiter event.
31  *
32  * @KBASE_VM_GPU_INITIALIZED_EVT: KBase has finished initializing
33  *                                and can be stopped
34  * @KBASE_VM_GPU_STOP_EVT: Stop message received from Arbiter
35  * @KBASE_VM_GPU_GRANTED_EVT: Grant message received from Arbiter
36  * @KBASE_VM_GPU_LOST_EVT: Lost message received from Arbiter
37  * @KBASE_VM_GPU_IDLE_EVENT: KBase has transitioned into an inactive state.
38  * @KBASE_VM_REF_EVENT: KBase has transitioned into an active state.
39  * @KBASE_VM_OS_SUSPEND_EVENT: KBase is suspending
40  * @KBASE_VM_OS_RESUME_EVENT: Kbase is resuming
41  */
42 enum kbase_arbif_evt {
43 	KBASE_VM_GPU_INITIALIZED_EVT = 1,
44 	KBASE_VM_GPU_STOP_EVT,
45 	KBASE_VM_GPU_GRANTED_EVT,
46 	KBASE_VM_GPU_LOST_EVT,
47 	KBASE_VM_GPU_IDLE_EVENT,
48 	KBASE_VM_REF_EVENT,
49 	KBASE_VM_OS_SUSPEND_EVENT,
50 	KBASE_VM_OS_RESUME_EVENT,
51 };
52 
53 /**
54  * kbase_arbif_init() - Initialize the arbiter interface functionality.
55  * @kbdev: The kbase device structure for the device (must be a valid pointer)
56  *
57  * Initialize the arbiter interface and also determines
58  * if Arbiter functionality is required.
59  *
60  * Return:
61  * * 0			- the interface was initialized or was not specified
62  * *			in the device tree.
63  * * -EFAULT		- the interface was specified but failed to initialize.
64  * * -EPROBE_DEFER	- module dependencies are not yet available.
65  */
66 int kbase_arbif_init(struct kbase_device *kbdev);
67 
68 /**
69  * kbase_arbif_destroy() - Cleanups the arbiter interface functionality.
70  * @kbdev: The kbase device structure for the device (must be a valid pointer)
71  *
72  * Cleans up the arbiter interface functionality and resets the reference count
73  * of the arbif module used
74  */
75 void kbase_arbif_destroy(struct kbase_device *kbdev);
76 
77 /**
78  * kbase_arbif_get_max_config() - Request max config info
79  * @kbdev: The kbase device structure for the device (must be a valid pointer)
80  *
81  * call back function from arb interface to arbiter requesting max config info
82  */
83 void kbase_arbif_get_max_config(struct kbase_device *kbdev);
84 
85 /**
86  * kbase_arbif_gpu_request() - Send GPU request message to the arbiter
87  * @kbdev: The kbase device structure for the device (must be a valid pointer)
88  *
89  * Sends a message to Arbiter to request GPU access.
90  */
91 void kbase_arbif_gpu_request(struct kbase_device *kbdev);
92 
93 /**
94  * kbase_arbif_gpu_stopped() - Send GPU stopped message to the arbiter
95  * @kbdev: The kbase device structure for the device (must be a valid pointer)
96  * @gpu_required: true if GPU access is still required
97  *                (Arbiter will automatically send another grant message)
98  *
99  * Sends a message to Arbiter to notify that the GPU has stopped.
100  * @note Once this call has been made, KBase must not attempt to access the GPU
101  *       until the #KBASE_VM_GPU_GRANTED_EVT event has been received.
102  */
103 void kbase_arbif_gpu_stopped(struct kbase_device *kbdev, u8 gpu_required);
104 
105 /**
106  * kbase_arbif_gpu_active() - Send a GPU active message to the arbiter
107  * @kbdev: The kbase device structure for the device (must be a valid pointer)
108  *
109  * Sends a message to Arbiter to report that KBase has gone active.
110  */
111 void kbase_arbif_gpu_active(struct kbase_device *kbdev);
112 
113 /**
114  * kbase_arbif_gpu_idle() - Send a GPU idle message to the arbiter
115  * @kbdev: The kbase device structure for the device (must be a valid pointer)
116  *
117  * Sends a message to Arbiter to report that KBase has gone idle.
118  */
119 void kbase_arbif_gpu_idle(struct kbase_device *kbdev);
120 
121 #endif /* _MALI_KBASE_ARBIF_H_ */
122