• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2011-2015, 2017, 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: 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 int kbase_gpuprops_populate_user_buffer(struct kbase_device *kbdev);
87 
88 /**
89  * kbase_gpuprops_free_user_buffer - Free the GPU properties buffer.
90  * @kbdev: kbase device pointer
91  *
92  * Free the GPU properties buffer allocated from
93  * kbase_gpuprops_populate_user_buffer.
94  */
95 void kbase_gpuprops_free_user_buffer(struct kbase_device *kbdev);
96 
97 /**
98  * kbase_device_populate_max_freq - Populate max gpu frequency.
99  * @kbdev: kbase device pointer
100  *
101  * Populate the maximum gpu frequency to be used when devfreq is disabled.
102  *
103  * Return: 0 on success and non-zero value on failure.
104  */
105 int kbase_device_populate_max_freq(struct kbase_device *kbdev);
106 
107 /**
108  * kbase_gpuprops_update_core_props_gpu_id - break down gpu id value
109  * @gpu_props: the &base_gpu_props structure
110  *
111  * Break down gpu_id value stored in base_gpu_props::raw_props.gpu_id into
112  * separate fields (version_status, minor_revision, major_revision, product_id)
113  * stored in base_gpu_props::core_props.
114  */
115 void kbase_gpuprops_update_core_props_gpu_id(
116 	struct base_gpu_props * const gpu_props);
117 
118 /**
119  * kbase_gpuprops_set_max_config - Set the max config information
120  * @kbdev:       Device pointer
121  * @max_config:  Maximum configuration data to be updated
122  *
123  * This function sets max_config in the kbase_gpu_props.
124  */
125 void kbase_gpuprops_set_max_config(struct kbase_device *kbdev,
126 	const struct max_config_props *max_config);
127 
128 /**
129  * kbase_gpuprops_get_curr_config_props - Get the current allocated resources
130  * @kbdev: The &struct kbase_device structure for the device
131  * @curr_config: The &struct curr_config_props structure to receive the result
132  *
133  * Fill the &struct curr_config_props structure with values from the GPU
134  * configuration registers.
135  *
136  * Return: Zero on success, Linux error code on failure
137  */
138 int kbase_gpuprops_get_curr_config_props(struct kbase_device *kbdev,
139 	struct curr_config_props * const curr_config);
140 
141 /**
142  * kbase_gpuprops_req_curr_config_update - Request Current Config Update
143  * @kbdev: The &struct kbase_device structure for the device
144  *
145  * Requests the current configuration to be updated next time the
146  * kbase_gpuprops_get_curr_config_props() is called.
147  *
148  * Return: Zero on success, Linux error code on failure
149  */
150 int kbase_gpuprops_req_curr_config_update(struct kbase_device *kbdev);
151 
152 #endif				/* _KBASE_GPUPROPS_H_ */
153