xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/mali400/mali/common/mali_osk_mali.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (C) 2010-2017 ARM Limited. All rights reserved.
3  *
4  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6  *
7  * A copy of the licence is included with the program, and can also be obtained from Free Software
8  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9  */
10 
11 /**
12  * @file mali_osk_mali.h
13  * Defines the OS abstraction layer which is specific for the Mali kernel device driver (OSK)
14  */
15 
16 #ifndef __MALI_OSK_MALI_H__
17 #define __MALI_OSK_MALI_H__
18 
19 #include <linux/mali/mali_utgard.h>
20 #include <mali_osk.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #ifdef CONFIG_MALI_DEVFREQ
27 struct mali_device {
28 	struct device *dev;
29 #ifdef CONFIG_HAVE_CLK
30 	struct clk *clock;
31 	struct clk_bulk_data *clks;
32 	int num_clks;
33 #endif
34 #ifdef CONFIG_REGULATOR
35 	struct regulator *regulator;
36 	struct opp_table *opp_table;
37 #endif
38 #ifdef CONFIG_PM_DEVFREQ
39 	struct devfreq_dev_profile devfreq_profile;
40 	struct devfreq *devfreq;
41 	unsigned long current_freq;
42 	unsigned long current_voltage;
43 	struct monitor_dev_info *mdev_info;
44 #ifdef CONFIG_DEVFREQ_THERMAL
45 	struct thermal_cooling_device *devfreq_cooling;
46 #endif
47 #endif
48 	struct mali_pm_metrics_data mali_metrics;
49 };
50 #endif
51 
52 /** @addtogroup _mali_osk_miscellaneous
53  * @{ */
54 
55 /** @brief Struct with device specific configuration data
56  */
57 typedef struct mali_gpu_device_data _mali_osk_device_data;
58 
59 #ifdef CONFIG_MALI_DT
60 /** @brief Initialize those device resources when we use device tree
61  *
62  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
63  */
64 _mali_osk_errcode_t _mali_osk_resource_initialize(void);
65 #endif
66 
67 /** @brief Find Mali GPU HW resource
68  *
69  * @param addr Address of Mali GPU resource to find
70  * @param res Storage for resource information if resource is found.
71  * @return _MALI_OSK_ERR_OK on success, _MALI_OSK_ERR_ITEM_NOT_FOUND if resource is not found
72  */
73 _mali_osk_errcode_t _mali_osk_resource_find(u32 addr, _mali_osk_resource_t *res);
74 
75 
76 /** @brief Find Mali GPU HW base address
77  *
78  * @return 0 if resources are found, otherwise the Mali GPU component with lowest address.
79  */
80 uintptr_t _mali_osk_resource_base_address(void);
81 
82 /** @brief Find the specific GPU resource.
83  *
84  * @return value
85  * 0x400 if Mali 400 specific GPU resource identified
86  * 0x450 if Mali 450 specific GPU resource identified
87  * 0x470 if Mali 470 specific GPU resource identified
88  *
89  */
90 u32 _mali_osk_identify_gpu_resource(void);
91 
92 /** @brief Retrieve the Mali GPU specific data
93  *
94  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
95  */
96 _mali_osk_errcode_t _mali_osk_device_data_get(_mali_osk_device_data *data);
97 
98 /** @brief Find the pmu domain config from device data.
99  *
100  * @param domain_config_array used to store pmu domain config found in device data.
101  * @param array_size is the size of array domain_config_array.
102  */
103 void _mali_osk_device_data_pmu_config_get(u16 *domain_config_array, int array_size);
104 
105 /** @brief Get Mali PMU switch delay
106  *
107  *@return pmu switch delay if it is configured
108  */
109 u32 _mali_osk_get_pmu_switch_delay(void);
110 
111 /** @brief Determines if Mali GPU has been configured with shared interrupts.
112  *
113  * @return MALI_TRUE if shared interrupts, MALI_FALSE if not.
114  */
115 mali_bool _mali_osk_shared_interrupts(void);
116 
117 /** @brief Initialize the gpu secure mode.
118  * The gpu secure mode will initially be in a disabled state.
119  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
120  */
121 _mali_osk_errcode_t _mali_osk_gpu_secure_mode_init(void);
122 
123 /** @brief Deinitialize the gpu secure mode.
124  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
125  */
126 _mali_osk_errcode_t _mali_osk_gpu_secure_mode_deinit(void);
127 
128 /** @brief Reset GPU and enable the gpu secure mode.
129  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
130  */
131 _mali_osk_errcode_t _mali_osk_gpu_reset_and_secure_mode_enable(void);
132 
133 /** @brief Reset GPU and disable the gpu secure mode.
134  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
135  */
136 _mali_osk_errcode_t _mali_osk_gpu_reset_and_secure_mode_disable(void);
137 
138 /** @brief Check if the gpu secure mode has been enabled.
139  * @return MALI_TRUE if enabled, otherwise MALI_FALSE.
140  */
141 mali_bool _mali_osk_gpu_secure_mode_is_enabled(void);
142 
143 /** @brief Check if the gpu secure mode is supported.
144  * @return MALI_TRUE if supported, otherwise MALI_FALSE.
145  */
146 mali_bool _mali_osk_gpu_secure_mode_is_supported(void);
147 
148 
149 /** @} */ /* end group _mali_osk_miscellaneous */
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 
155 #endif /* __MALI_OSK_MALI_H__ */
156