summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gp106/clk_arb_gp106.c
diff options
context:
space:
mode:
authorThomas Fleury <tfleury@nvidia.com>2016-09-13 17:23:45 -0400
committerDeepak Nibade <dnibade@nvidia.com>2016-12-27 04:56:51 -0500
commit3d9c33c5953e383527c7e4af594adfe0c82b5788 (patch)
tree6de4ae86667c763ed0deef3add9336b570ca15ff /drivers/gpu/nvgpu/gp106/clk_arb_gp106.c
parentc320ccfa952a2796db27d97111791bcbeff9f5c7 (diff)
gpu: nvgpu: clk arbiter skeleton
Add clock arbiter skeleton with support of clock sessions, notifications on clock changes, request numbering, and asynchronous handling of clock requests. Provides minimum behaviour to allow unit tests implementation. Actual arbitration and clock settings will be done separately. For now, dummy arbiter keeps last requested target mhz. Actual arbiter may move to a lockless implementation. Jira DNVGPU-125 Change-Id: I6a8e443fb0d15dc5f1993e7260256d71acddd106 Signed-off-by: Thomas Fleury <tfleury@nvidia.com> Reviewed-on: http://git-master/r/1223476 (cherry picked from commit cb130825d84e4124d273bd443e2b62d493377461) Reviewed-on: http://git-master/r/1243105 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gp106/clk_arb_gp106.c')
-rw-r--r--drivers/gpu/nvgpu/gp106/clk_arb_gp106.c95
1 files changed, 95 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..d1cbb32b
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/clk_arb_gp106.c
@@ -0,0 +1,95 @@
1/*
2 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 */
13
14#include "gk20a/gk20a.h"
15
16#include "clk/clk_arb.h"
17#include "clk_arb_gp106.h"
18
19static u32 gp106_get_arbiter_clk_domains(struct gk20a *g)
20{
21 (void)g;
22 return (CTRL_CLK_DOMAIN_MCLK|CTRL_CLK_DOMAIN_GPC2CLK);
23}
24
25static int gp106_get_arbiter_clk_range(struct gk20a *g, u32 api_domain,
26 u16 *min_mhz, u16 *max_mhz)
27{
28 enum nv_pmu_clk_clkwhich clkwhich;
29 struct clk_set_info *p0_info;
30 struct clk_set_info *p5_info;
31
32 switch (api_domain) {
33 case CTRL_CLK_DOMAIN_MCLK:
34 clkwhich = clkwhich_mclk;
35 break;
36
37 case CTRL_CLK_DOMAIN_GPC2CLK:
38 clkwhich = clkwhich_gpc2clk;
39 break;
40
41 default:
42 return -EINVAL;
43 }
44
45 p5_info = pstate_get_clk_set_info(g,
46 CTRL_PERF_PSTATE_P5, clkwhich);
47 if (!p5_info)
48 return -EINVAL;
49
50 p0_info = pstate_get_clk_set_info(g,
51 CTRL_PERF_PSTATE_P0, clkwhich);
52 if (!p0_info)
53 return -EINVAL;
54
55 *min_mhz = p5_info->min_mhz;
56 *max_mhz = p0_info->max_mhz;
57
58 return 0;
59}
60
61static int gp106_get_arbiter_clk_default(struct gk20a *g, u32 api_domain,
62 u16 *default_mhz)
63{
64 enum nv_pmu_clk_clkwhich clkwhich;
65 struct clk_set_info *p0_info;
66
67 switch (api_domain) {
68 case CTRL_CLK_DOMAIN_MCLK:
69 clkwhich = clkwhich_mclk;
70 break;
71
72 case CTRL_CLK_DOMAIN_GPC2CLK:
73 clkwhich = clkwhich_gpc2clk;
74 break;
75
76 default:
77 return -EINVAL;
78 }
79
80 p0_info = pstate_get_clk_set_info(g,
81 CTRL_PERF_PSTATE_P0, clkwhich);
82 if (!p0_info)
83 return -EINVAL;
84
85 *default_mhz = p0_info->max_mhz;
86
87 return 0;
88}
89
90void gp106_init_clk_arb_ops(struct gpu_ops *gops)
91{
92 gops->clk_arb.get_arbiter_clk_domains = gp106_get_arbiter_clk_domains;
93 gops->clk_arb.get_arbiter_clk_range = gp106_get_arbiter_clk_range;
94 gops->clk_arb.get_arbiter_clk_default = gp106_get_arbiter_clk_default;
95}