diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gp106/clk_arb_gp106.c')
-rw-r--r-- | drivers/gpu/nvgpu/gp106/clk_arb_gp106.c | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gp106/clk_arb_gp106.c b/drivers/gpu/nvgpu/gp106/clk_arb_gp106.c new file mode 100644 index 00000000..ae6cd327 --- /dev/null +++ b/drivers/gpu/nvgpu/gp106/clk_arb_gp106.c | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #include "gk20a/gk20a.h" | ||
24 | |||
25 | #include "clk_arb_gp106.h" | ||
26 | |||
27 | u32 gp106_get_arbiter_clk_domains(struct gk20a *g) | ||
28 | { | ||
29 | (void)g; | ||
30 | return (CTRL_CLK_DOMAIN_MCLK|CTRL_CLK_DOMAIN_GPC2CLK); | ||
31 | } | ||
32 | |||
33 | int gp106_get_arbiter_clk_range(struct gk20a *g, u32 api_domain, | ||
34 | u16 *min_mhz, u16 *max_mhz) | ||
35 | { | ||
36 | enum nv_pmu_clk_clkwhich clkwhich; | ||
37 | struct clk_set_info *p0_info; | ||
38 | struct clk_set_info *p5_info; | ||
39 | struct avfsfllobjs *pfllobjs = &(g->clk_pmu.avfs_fllobjs); | ||
40 | |||
41 | u16 limit_min_mhz; | ||
42 | |||
43 | switch (api_domain) { | ||
44 | case CTRL_CLK_DOMAIN_MCLK: | ||
45 | clkwhich = clkwhich_mclk; | ||
46 | break; | ||
47 | |||
48 | case CTRL_CLK_DOMAIN_GPC2CLK: | ||
49 | clkwhich = clkwhich_gpc2clk; | ||
50 | break; | ||
51 | |||
52 | default: | ||
53 | return -EINVAL; | ||
54 | } | ||
55 | |||
56 | p5_info = pstate_get_clk_set_info(g, | ||
57 | CTRL_PERF_PSTATE_P5, clkwhich); | ||
58 | if (!p5_info) | ||
59 | return -EINVAL; | ||
60 | |||
61 | p0_info = pstate_get_clk_set_info(g, | ||
62 | CTRL_PERF_PSTATE_P0, clkwhich); | ||
63 | if (!p0_info) | ||
64 | return -EINVAL; | ||
65 | |||
66 | limit_min_mhz = p5_info->min_mhz; | ||
67 | /* WAR for DVCO min */ | ||
68 | if (api_domain == CTRL_CLK_DOMAIN_GPC2CLK) | ||
69 | if ((pfllobjs->max_min_freq_mhz) && | ||
70 | (pfllobjs->max_min_freq_mhz > limit_min_mhz)) | ||
71 | limit_min_mhz = pfllobjs->max_min_freq_mhz; | ||
72 | |||
73 | *min_mhz = limit_min_mhz; | ||
74 | *max_mhz = p0_info->max_mhz; | ||
75 | |||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | int gp106_get_arbiter_clk_default(struct gk20a *g, u32 api_domain, | ||
80 | u16 *default_mhz) | ||
81 | { | ||
82 | enum nv_pmu_clk_clkwhich clkwhich; | ||
83 | struct clk_set_info *p0_info; | ||
84 | |||
85 | switch (api_domain) { | ||
86 | case CTRL_CLK_DOMAIN_MCLK: | ||
87 | clkwhich = clkwhich_mclk; | ||
88 | break; | ||
89 | |||
90 | case CTRL_CLK_DOMAIN_GPC2CLK: | ||
91 | clkwhich = clkwhich_gpc2clk; | ||
92 | break; | ||
93 | |||
94 | default: | ||
95 | return -EINVAL; | ||
96 | } | ||
97 | |||
98 | p0_info = pstate_get_clk_set_info(g, | ||
99 | CTRL_PERF_PSTATE_P0, clkwhich); | ||
100 | if (!p0_info) | ||
101 | return -EINVAL; | ||
102 | |||
103 | *default_mhz = p0_info->max_mhz; | ||
104 | |||
105 | return 0; | ||
106 | } | ||