RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / rk3368 / rk_init_v2.h
1 /*************************************************************************/ /*!
2 @Title          System Configuration
3 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @License        Dual MIT/GPLv2
5
6 The contents of this file are subject to the MIT license as set out below.
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 Alternatively, the contents of this file may be used under the terms of
19 the GNU General Public License Version 2 ("GPL") in which case the provisions
20 of GPL are applicable instead of those above.
21
22 If you wish to allow use of your version of this file only under the terms of
23 GPL, and not to allow others to use your version of this file under the terms
24 of the MIT license, indicate your decision by deleting the provisions above
25 and replace them with the notice and other provisions required by GPL as set
26 out in the file called "GPL-COPYING" included in this distribution. If you do
27 not delete the provisions above, a recipient may use your version of this file
28 under the terms of either the MIT license or GPL.
29
30 This License is also included in this distribution in the file called
31 "MIT-COPYING".
32
33 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 @Description    System Configuration functions
41 */ /**************************************************************************/
42
43 #if !defined(__SUNXI_INIT__)
44 #define __SUNXI_INIT__
45
46 #include "img_types.h"
47 #include "pvrsrv_error.h"
48 #include "pvrsrv_device.h"
49 #include "servicesext.h"
50 #include <linux/version.h>
51
52 #define OPEN_GPU_PD                             1
53 #define RK33_DEFAULT_CLOCK                      400
54 #define ONE_KHZ                                 1000
55 #define ONE_MHZ                                 1000000
56 #define HZ_TO_MHZ(m)                            ((m) / ONE_MHZ)
57
58 struct rk_context {
59         PVRSRV_DEVICE_CONFIG    *dev_config;
60 #if OPEN_GPU_PD
61         IMG_BOOL                        bEnablePd;
62         struct clk                      *pd_gpu_0;
63         struct clk                      *pd_gpu_1;
64 #endif
65         struct clk                      *aclk_gpu_mem;
66         struct clk                      *aclk_gpu_cfg;
67 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0))
68         struct clk                          *clk_gpu;
69         struct dvfs_node                    *gpu_clk_node;
70 #else
71         struct clk                      *sclk_gpu_core;
72         struct regulator                *gpu_reg;
73 #endif
74
75         /*To calculate utilization for x sec */
76         IMG_BOOL                        gpu_active;
77 };
78
79 #if defined(CONFIG_DEVFREQ_THERMAL) && defined(PVR_DVFS)
80 int rk_power_model_simple_init(struct device *dev);
81 #endif
82
83 long int GetConfigFreq(void);
84 IMG_UINT32 AwClockFreqGet(IMG_HANDLE hSysData);
85 struct rk_context * RgxRkInit(PVRSRV_DEVICE_CONFIG* psDevConfig);
86 void RgxRkUnInit(struct rk_context *platform);
87 void RgxResume(struct rk_context *platform);
88 void RgxSuspend(struct rk_context *platform);
89 PVRSRV_ERROR RkPrePowerState(IMG_HANDLE hSysData,
90                                                          PVRSRV_DEV_POWER_STATE eNewPowerState,
91                                                          PVRSRV_DEV_POWER_STATE eCurrentPowerState,
92                                                          IMG_BOOL bForced);
93 PVRSRV_ERROR RkPostPowerState(IMG_HANDLE hSysData,
94                                                           PVRSRV_DEV_POWER_STATE eNewPowerState,
95                                                           PVRSRV_DEV_POWER_STATE eCurrentPowerState,
96                                                           IMG_BOOL bForced);
97 void rkSetFrequency(IMG_UINT32 ui32Frequency);
98 void rkSetVoltage(IMG_UINT32 ui32Voltage);
99 #endif  /* __SUNXI_INIT__ */