xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/bifrost/mali_kbase_gpuprops.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2011-2015, 2017, 2019-2022 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: Base kernel property query APIs
24  */
25 
26 #ifndef _KBASE_GPUPROPS_H_
27 #define _KBASE_GPUPROPS_H_
28 
29 #include "mali_kbase_gpuprops_types.h"
30 
31 /* Forward definition - see mali_kbase.h */
32 struct kbase_device;
33 
34 /**
35  * KBASE_UBFX32 - Extracts bits from a 32-bit bitfield.
36  * @value:  The value from which to extract bits.
37  * @offset: The first bit to extract (0 being the LSB).
38  * @size:   The number of bits to extract.
39  *
40  * Context: @offset + @size <= 32.
41  *
42  * Return: Bits [@offset, @offset + @size) from @value.
43  */
44 /* from mali_cdsb.h */
45 #define KBASE_UBFX32(value, offset, size) \
46 	(((u32)(value) >> (u32)(offset)) & (u32)((1ULL << (u32)(size)) - 1))
47 
48 /**
49  * kbase_gpuprops_set - Set up Kbase GPU properties.
50  * @kbdev: The struct kbase_device structure for the device
51  *
52  * Set up Kbase GPU properties with information from the GPU registers
53  */
54 void kbase_gpuprops_set(struct kbase_device *kbdev);
55 
56 /**
57  * kbase_gpuprops_set_features - Set up Kbase GPU properties
58  * @kbdev:   Device pointer
59  *
60  * This function sets up GPU properties that are dependent on the hardware
61  * features bitmask. This function must be preceeded by a call to
62  * kbase_hw_set_features_mask().
63  *
64  * Return: Zero on success, Linux error code on failure
65  */
66 int kbase_gpuprops_set_features(struct kbase_device *kbdev);
67 
68 /**
69  * kbase_gpuprops_update_l2_features - Update GPU property of L2_FEATURES
70  * @kbdev:   Device pointer
71  *
72  * This function updates l2_features and the log2 cache size.
73  * The function expects GPU to be powered up and value of pm.active_count
74  * to be 1.
75  *
76  * Return: Zero on success, Linux error code for failure
77  */
78 int kbase_gpuprops_update_l2_features(struct kbase_device *kbdev);
79 
80 /**
81  * kbase_gpuprops_populate_user_buffer - Populate the GPU properties buffer
82  * @kbdev: The kbase device
83  *
84  * Fills prop_buffer with the GPU properties for user space to read.
85  *
86  * Return: MALI_ERROR_NONE on success. Any other value indicates failure.
87  */
88 int kbase_gpuprops_populate_user_buffer(struct kbase_device *kbdev);
89 
90 /**
91  * kbase_gpuprops_free_user_buffer - Free the GPU properties buffer.
92  * @kbdev: kbase device pointer
93  *
94  * Free the GPU properties buffer allocated from
95  * kbase_gpuprops_populate_user_buffer.
96  */
97 void kbase_gpuprops_free_user_buffer(struct kbase_device *kbdev);
98 
99 /**
100  * kbase_device_populate_max_freq - Populate max gpu frequency.
101  * @kbdev: kbase device pointer
102  *
103  * Populate the maximum gpu frequency to be used when devfreq is disabled.
104  *
105  * Return: 0 on success and non-zero value on failure.
106  */
107 int kbase_device_populate_max_freq(struct kbase_device *kbdev);
108 
109 /**
110  * kbase_gpuprops_update_core_props_gpu_id - break down gpu id value
111  * @gpu_props: the &base_gpu_props structure
112  *
113  * Break down gpu_id value stored in base_gpu_props::raw_props.gpu_id into
114  * separate fields (version_status, minor_revision, major_revision, product_id)
115  * stored in base_gpu_props::core_props.
116  */
117 void kbase_gpuprops_update_core_props_gpu_id(
118 	struct base_gpu_props * const gpu_props);
119 
120 /**
121  * kbase_gpuprops_set_max_config - Set the max config information
122  * @kbdev:       Device pointer
123  * @max_config:  Maximum configuration data to be updated
124  *
125  * This function sets max_config in the kbase_gpu_props.
126  */
127 void kbase_gpuprops_set_max_config(struct kbase_device *kbdev,
128 	const struct max_config_props *max_config);
129 
130 /**
131  * kbase_gpuprops_get_curr_config_props - Get the current allocated resources
132  * @kbdev: The &struct kbase_device structure for the device
133  * @curr_config: The &struct curr_config_props structure to receive the result
134  *
135  * Fill the &struct curr_config_props structure with values from the GPU
136  * configuration registers.
137  *
138  * Return: Zero on success, Linux error code on failure
139  */
140 int kbase_gpuprops_get_curr_config_props(struct kbase_device *kbdev,
141 	struct curr_config_props * const curr_config);
142 
143 /**
144  * kbase_gpuprops_req_curr_config_update - Request Current Config Update
145  * @kbdev: The &struct kbase_device structure for the device
146  *
147  * Requests the current configuration to be updated next time the
148  * kbase_gpuprops_get_curr_config_props() is called.
149  *
150  * Return: Zero on success, Linux error code on failure
151  */
152 int kbase_gpuprops_req_curr_config_update(struct kbase_device *kbdev);
153 
154 #endif				/* _KBASE_GPUPROPS_H_ */
155