1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * (C) COPYRIGHT 2011-2015, 2017, 2019-2022 ARM Limited. All rights reserved. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * This program is free software and is provided to you under the terms of the 7*4882a593Smuzhiyun * GNU General Public License version 2 as published by the Free Software 8*4882a593Smuzhiyun * Foundation, and any use by you of this program is subject to the terms 9*4882a593Smuzhiyun * of such GNU license. 10*4882a593Smuzhiyun * 11*4882a593Smuzhiyun * This program is distributed in the hope that it will be useful, 12*4882a593Smuzhiyun * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*4882a593Smuzhiyun * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*4882a593Smuzhiyun * GNU General Public License for more details. 15*4882a593Smuzhiyun * 16*4882a593Smuzhiyun * You should have received a copy of the GNU General Public License 17*4882a593Smuzhiyun * along with this program; if not, you can access it online at 18*4882a593Smuzhiyun * http://www.gnu.org/licenses/gpl-2.0.html. 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun */ 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun /** 23*4882a593Smuzhiyun * DOC: Base kernel property query APIs 24*4882a593Smuzhiyun */ 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun #ifndef _KBASE_GPUPROPS_H_ 27*4882a593Smuzhiyun #define _KBASE_GPUPROPS_H_ 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun #include "mali_kbase_gpuprops_types.h" 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun /* Forward definition - see mali_kbase.h */ 32*4882a593Smuzhiyun struct kbase_device; 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun /** 35*4882a593Smuzhiyun * KBASE_UBFX32 - Extracts bits from a 32-bit bitfield. 36*4882a593Smuzhiyun * @value: The value from which to extract bits. 37*4882a593Smuzhiyun * @offset: The first bit to extract (0 being the LSB). 38*4882a593Smuzhiyun * @size: The number of bits to extract. 39*4882a593Smuzhiyun * 40*4882a593Smuzhiyun * Context: @offset + @size <= 32. 41*4882a593Smuzhiyun * 42*4882a593Smuzhiyun * Return: Bits [@offset, @offset + @size) from @value. 43*4882a593Smuzhiyun */ 44*4882a593Smuzhiyun /* from mali_cdsb.h */ 45*4882a593Smuzhiyun #define KBASE_UBFX32(value, offset, size) \ 46*4882a593Smuzhiyun (((u32)(value) >> (u32)(offset)) & (u32)((1ULL << (u32)(size)) - 1)) 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun /** 49*4882a593Smuzhiyun * kbase_gpuprops_set - Set up Kbase GPU properties. 50*4882a593Smuzhiyun * @kbdev: The struct kbase_device structure for the device 51*4882a593Smuzhiyun * 52*4882a593Smuzhiyun * Set up Kbase GPU properties with information from the GPU registers 53*4882a593Smuzhiyun */ 54*4882a593Smuzhiyun void kbase_gpuprops_set(struct kbase_device *kbdev); 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun /** 57*4882a593Smuzhiyun * kbase_gpuprops_set_features - Set up Kbase GPU properties 58*4882a593Smuzhiyun * @kbdev: Device pointer 59*4882a593Smuzhiyun * 60*4882a593Smuzhiyun * This function sets up GPU properties that are dependent on the hardware 61*4882a593Smuzhiyun * features bitmask. This function must be preceeded by a call to 62*4882a593Smuzhiyun * kbase_hw_set_features_mask(). 63*4882a593Smuzhiyun * 64*4882a593Smuzhiyun * Return: Zero on success, Linux error code on failure 65*4882a593Smuzhiyun */ 66*4882a593Smuzhiyun int kbase_gpuprops_set_features(struct kbase_device *kbdev); 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun /** 69*4882a593Smuzhiyun * kbase_gpuprops_update_l2_features - Update GPU property of L2_FEATURES 70*4882a593Smuzhiyun * @kbdev: Device pointer 71*4882a593Smuzhiyun * 72*4882a593Smuzhiyun * This function updates l2_features and the log2 cache size. 73*4882a593Smuzhiyun * The function expects GPU to be powered up and value of pm.active_count 74*4882a593Smuzhiyun * to be 1. 75*4882a593Smuzhiyun * 76*4882a593Smuzhiyun * Return: Zero on success, Linux error code for failure 77*4882a593Smuzhiyun */ 78*4882a593Smuzhiyun int kbase_gpuprops_update_l2_features(struct kbase_device *kbdev); 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun /** 81*4882a593Smuzhiyun * kbase_gpuprops_populate_user_buffer - Populate the GPU properties buffer 82*4882a593Smuzhiyun * @kbdev: The kbase device 83*4882a593Smuzhiyun * 84*4882a593Smuzhiyun * Fills prop_buffer with the GPU properties for user space to read. 85*4882a593Smuzhiyun * 86*4882a593Smuzhiyun * Return: MALI_ERROR_NONE on success. Any other value indicates failure. 87*4882a593Smuzhiyun */ 88*4882a593Smuzhiyun int kbase_gpuprops_populate_user_buffer(struct kbase_device *kbdev); 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun /** 91*4882a593Smuzhiyun * kbase_gpuprops_free_user_buffer - Free the GPU properties buffer. 92*4882a593Smuzhiyun * @kbdev: kbase device pointer 93*4882a593Smuzhiyun * 94*4882a593Smuzhiyun * Free the GPU properties buffer allocated from 95*4882a593Smuzhiyun * kbase_gpuprops_populate_user_buffer. 96*4882a593Smuzhiyun */ 97*4882a593Smuzhiyun void kbase_gpuprops_free_user_buffer(struct kbase_device *kbdev); 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun /** 100*4882a593Smuzhiyun * kbase_device_populate_max_freq - Populate max gpu frequency. 101*4882a593Smuzhiyun * @kbdev: kbase device pointer 102*4882a593Smuzhiyun * 103*4882a593Smuzhiyun * Populate the maximum gpu frequency to be used when devfreq is disabled. 104*4882a593Smuzhiyun * 105*4882a593Smuzhiyun * Return: 0 on success and non-zero value on failure. 106*4882a593Smuzhiyun */ 107*4882a593Smuzhiyun int kbase_device_populate_max_freq(struct kbase_device *kbdev); 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun /** 110*4882a593Smuzhiyun * kbase_gpuprops_update_core_props_gpu_id - break down gpu id value 111*4882a593Smuzhiyun * @gpu_props: the &base_gpu_props structure 112*4882a593Smuzhiyun * 113*4882a593Smuzhiyun * Break down gpu_id value stored in base_gpu_props::raw_props.gpu_id into 114*4882a593Smuzhiyun * separate fields (version_status, minor_revision, major_revision, product_id) 115*4882a593Smuzhiyun * stored in base_gpu_props::core_props. 116*4882a593Smuzhiyun */ 117*4882a593Smuzhiyun void kbase_gpuprops_update_core_props_gpu_id( 118*4882a593Smuzhiyun struct base_gpu_props * const gpu_props); 119*4882a593Smuzhiyun 120*4882a593Smuzhiyun /** 121*4882a593Smuzhiyun * kbase_gpuprops_set_max_config - Set the max config information 122*4882a593Smuzhiyun * @kbdev: Device pointer 123*4882a593Smuzhiyun * @max_config: Maximum configuration data to be updated 124*4882a593Smuzhiyun * 125*4882a593Smuzhiyun * This function sets max_config in the kbase_gpu_props. 126*4882a593Smuzhiyun */ 127*4882a593Smuzhiyun void kbase_gpuprops_set_max_config(struct kbase_device *kbdev, 128*4882a593Smuzhiyun const struct max_config_props *max_config); 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun /** 131*4882a593Smuzhiyun * kbase_gpuprops_get_curr_config_props - Get the current allocated resources 132*4882a593Smuzhiyun * @kbdev: The &struct kbase_device structure for the device 133*4882a593Smuzhiyun * @curr_config: The &struct curr_config_props structure to receive the result 134*4882a593Smuzhiyun * 135*4882a593Smuzhiyun * Fill the &struct curr_config_props structure with values from the GPU 136*4882a593Smuzhiyun * configuration registers. 137*4882a593Smuzhiyun * 138*4882a593Smuzhiyun * Return: Zero on success, Linux error code on failure 139*4882a593Smuzhiyun */ 140*4882a593Smuzhiyun int kbase_gpuprops_get_curr_config_props(struct kbase_device *kbdev, 141*4882a593Smuzhiyun struct curr_config_props * const curr_config); 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun /** 144*4882a593Smuzhiyun * kbase_gpuprops_req_curr_config_update - Request Current Config Update 145*4882a593Smuzhiyun * @kbdev: The &struct kbase_device structure for the device 146*4882a593Smuzhiyun * 147*4882a593Smuzhiyun * Requests the current configuration to be updated next time the 148*4882a593Smuzhiyun * kbase_gpuprops_get_curr_config_props() is called. 149*4882a593Smuzhiyun * 150*4882a593Smuzhiyun * Return: Zero on success, Linux error code on failure 151*4882a593Smuzhiyun */ 152*4882a593Smuzhiyun int kbase_gpuprops_req_curr_config_update(struct kbase_device *kbdev); 153*4882a593Smuzhiyun 154*4882a593Smuzhiyun #endif /* _KBASE_GPUPROPS_H_ */ 155