diff options
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/Makefile | 6 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/Makefile.sources | 3 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gv100/clk_gv100.c | 193 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gv100/clk_gv100.h | 63 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gv100/hal_gv100.c | 13 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/hw/gv100/hw_trim_gv100.h | 48 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/debug_clk_gv100.c | 193 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/debug_clk_gv100.h | 29 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/os_ops_gv100.c | 4 |
9 files changed, 540 insertions, 12 deletions
diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index d7944088..d704de83 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile | |||
@@ -113,7 +113,8 @@ nvgpu-$(CONFIG_DEBUG_FS) += \ | |||
113 | os/linux/debug_therm_gp106.o \ | 113 | os/linux/debug_therm_gp106.o \ |
114 | os/linux/debug_bios.o \ | 114 | os/linux/debug_bios.o \ |
115 | os/linux/debug_ltc.o \ | 115 | os/linux/debug_ltc.o \ |
116 | os/linux/debug_xve.o | 116 | os/linux/debug_xve.o \ |
117 | os/linux/debug_clk_gv100.o | ||
117 | 118 | ||
118 | ifeq ($(CONFIG_NVGPU_TRACK_MEM_USAGE),y) | 119 | ifeq ($(CONFIG_NVGPU_TRACK_MEM_USAGE),y) |
119 | nvgpu-$(CONFIG_DEBUG_FS) += \ | 120 | nvgpu-$(CONFIG_DEBUG_FS) += \ |
@@ -363,4 +364,5 @@ nvgpu-y += \ | |||
363 | therm/thrmchannel.o \ | 364 | therm/thrmchannel.o \ |
364 | therm/thrmpmu.o \ | 365 | therm/thrmpmu.o \ |
365 | lpwr/rppg.o \ | 366 | lpwr/rppg.o \ |
366 | lpwr/lpwr.o | 367 | lpwr/lpwr.o \ |
368 | gv100/clk_gv100.o | ||
diff --git a/drivers/gpu/nvgpu/Makefile.sources b/drivers/gpu/nvgpu/Makefile.sources index a5325980..cc612e07 100644 --- a/drivers/gpu/nvgpu/Makefile.sources +++ b/drivers/gpu/nvgpu/Makefile.sources | |||
@@ -217,4 +217,5 @@ srcs := os/posix/nvgpu.c \ | |||
217 | gv100/hal_gv100.c \ | 217 | gv100/hal_gv100.c \ |
218 | gv100/pmu_gv100.c \ | 218 | gv100/pmu_gv100.c \ |
219 | gv100/perf_gv100.c \ | 219 | gv100/perf_gv100.c \ |
220 | gv100/gsp_gv100.c | 220 | gv100/gsp_gv100.c \ |
221 | gv100/clk_gv100.c | ||
diff --git a/drivers/gpu/nvgpu/gv100/clk_gv100.c b/drivers/gpu/nvgpu/gv100/clk_gv100.c new file mode 100644 index 00000000..7855aa41 --- /dev/null +++ b/drivers/gpu/nvgpu/gv100/clk_gv100.c | |||
@@ -0,0 +1,193 @@ | |||
1 | /* | ||
2 | * GV100 Clocks | ||
3 | * | ||
4 | * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. | ||
5 | * | ||
6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
7 | * copy of this software and associated documentation files (the "Software"), | ||
8 | * to deal in the Software without restriction, including without limitation | ||
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
10 | * and/or sell copies of the Software, and to permit persons to whom the | ||
11 | * Software is furnished to do so, subject to the following conditions: | ||
12 | * | ||
13 | * The above copyright notice and this permission notice shall be included in | ||
14 | * all copies or substantial portions of the Software. | ||
15 | * | ||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
22 | * DEALINGS IN THE SOFTWARE. | ||
23 | */ | ||
24 | |||
25 | #ifdef CONFIG_DEBUG_FS | ||
26 | #include <linux/debugfs.h> | ||
27 | #include "os/linux/os_linux.h" | ||
28 | #endif | ||
29 | |||
30 | #include <nvgpu/kmem.h> | ||
31 | #include <nvgpu/io.h> | ||
32 | #include <nvgpu/list.h> | ||
33 | #include <nvgpu/clk_arb.h> | ||
34 | #include <nvgpu/timers.h> | ||
35 | |||
36 | #include "gk20a/gk20a.h" | ||
37 | |||
38 | #include "clk_gv100.h" | ||
39 | |||
40 | #include <nvgpu/hw/gv100/hw_trim_gv100.h> | ||
41 | |||
42 | |||
43 | u32 gv100_crystal_clk_hz(struct gk20a *g) | ||
44 | { | ||
45 | return (XTAL4X_KHZ * 1000); | ||
46 | } | ||
47 | |||
48 | unsigned long gv100_clk_measure_freq(struct gk20a *g, u32 api_domain) | ||
49 | { | ||
50 | struct clk_gk20a *clk = &g->clk; | ||
51 | u32 freq_khz; | ||
52 | u32 i; | ||
53 | struct namemap_cfg *c = NULL; | ||
54 | |||
55 | for (i = 0; i < clk->namemap_num; i++) { | ||
56 | if (api_domain == clk->namemap_xlat_table[i]) { | ||
57 | c = &clk->clk_namemap[i]; | ||
58 | break; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | if (c == NULL) { | ||
63 | return 0; | ||
64 | } | ||
65 | if (c->is_counter != 0U) { | ||
66 | freq_khz = c->scale * gv100_get_rate_cntr(g, c); | ||
67 | } else { | ||
68 | freq_khz = 0U; | ||
69 | /* TODO: PLL read */ | ||
70 | } | ||
71 | |||
72 | /* Convert to HZ */ | ||
73 | return freq_khz * 1000UL; | ||
74 | } | ||
75 | |||
76 | int gv100_init_clk_support(struct gk20a *g) | ||
77 | { | ||
78 | struct clk_gk20a *clk = &g->clk; | ||
79 | int err = 0; | ||
80 | |||
81 | nvgpu_log_fn(g, " "); | ||
82 | |||
83 | err = nvgpu_mutex_init(&clk->clk_mutex); | ||
84 | if (err != 0) { | ||
85 | return err; | ||
86 | } | ||
87 | |||
88 | clk->clk_namemap = (struct namemap_cfg *) | ||
89 | nvgpu_kzalloc(g, sizeof(struct namemap_cfg) * NUM_NAMEMAPS); | ||
90 | |||
91 | if (clk->clk_namemap == NULL) { | ||
92 | nvgpu_mutex_destroy(&clk->clk_mutex); | ||
93 | return -ENOMEM; | ||
94 | } | ||
95 | |||
96 | clk->namemap_xlat_table = nvgpu_kcalloc(g, NUM_NAMEMAPS, sizeof(u32)); | ||
97 | |||
98 | if (clk->namemap_xlat_table == NULL) { | ||
99 | nvgpu_kfree(g, clk->clk_namemap); | ||
100 | nvgpu_mutex_destroy(&clk->clk_mutex); | ||
101 | return -ENOMEM; | ||
102 | } | ||
103 | |||
104 | clk->clk_namemap[0] = (struct namemap_cfg) { | ||
105 | .namemap = CLK_NAMEMAP_INDEX_GPCCLK, | ||
106 | .is_enable = 1, | ||
107 | .is_counter = 1, | ||
108 | .g = g, | ||
109 | .cntr = { | ||
110 | .reg_ctrl_addr = trim_gpc_bcast_fr_clk_cntr_ncgpcclk_cfg_r(), | ||
111 | .reg_ctrl_idx = trim_gpc_bcast_fr_clk_cntr_ncgpcclk_cfg_source_gpcclk_f(), | ||
112 | .reg_cntr_addr[0] = trim_gpc_bcast_fr_clk_cntr_ncgpcclk_cnt0_r(), | ||
113 | .reg_cntr_addr[1] = trim_gpc_bcast_fr_clk_cntr_ncgpcclk_cnt1_r() | ||
114 | }, | ||
115 | .name = "gpcclk", | ||
116 | .scale = 1 | ||
117 | }; | ||
118 | clk->namemap_xlat_table[0] = CTRL_CLK_DOMAIN_GPCCLK; | ||
119 | |||
120 | clk->clk_namemap[1] = (struct namemap_cfg) { | ||
121 | .namemap = CLK_NAMEMAP_INDEX_SYSCLK, | ||
122 | .is_enable = 1, | ||
123 | .is_counter = 1, | ||
124 | .g = g, | ||
125 | .cntr = { | ||
126 | .reg_ctrl_addr = trim_sys_fr_clk_cntr_sysclk_cfg_r(), | ||
127 | .reg_ctrl_idx = trim_sys_fr_clk_cntr_sysclk_cfg_source_sysclk_f(), | ||
128 | .reg_cntr_addr[0] = trim_sys_fr_clk_cntr_sysclk_cntr0_r(), | ||
129 | .reg_cntr_addr[1] = trim_sys_fr_clk_cntr_sysclk_cntr1_r() | ||
130 | }, | ||
131 | .name = "sysclk", | ||
132 | .scale = 1 | ||
133 | }; | ||
134 | clk->namemap_xlat_table[1] = CTRL_CLK_DOMAIN_SYSCLK; | ||
135 | |||
136 | clk->clk_namemap[2] = (struct namemap_cfg) { | ||
137 | .namemap = CLK_NAMEMAP_INDEX_XBARCLK, | ||
138 | .is_enable = 1, | ||
139 | .is_counter = 1, | ||
140 | .g = g, | ||
141 | .cntr = { | ||
142 | .reg_ctrl_addr = trim_sys_nafll_fr_clk_cntr_xbarclk_cfg_r(), | ||
143 | .reg_ctrl_idx = trim_sys_nafll_fr_clk_cntr_xbarclk_cfg_source_xbarclk_f(), | ||
144 | .reg_cntr_addr[0] = trim_sys_nafll_fr_clk_cntr_xbarclk_cntr0_r(), | ||
145 | .reg_cntr_addr[1] = trim_sys_nafll_fr_clk_cntr_xbarclk_cntr1_r() | ||
146 | }, | ||
147 | .name = "xbarclk", | ||
148 | .scale = 1 | ||
149 | }; | ||
150 | clk->namemap_xlat_table[2] = CTRL_CLK_DOMAIN_XBARCLK; | ||
151 | |||
152 | clk->namemap_num = NUM_NAMEMAPS; | ||
153 | |||
154 | clk->g = g; | ||
155 | |||
156 | return err; | ||
157 | } | ||
158 | |||
159 | u32 gv100_get_rate_cntr(struct gk20a *g, struct namemap_cfg *c) { | ||
160 | u32 cntr = 0; | ||
161 | u64 cntr_start = 0; | ||
162 | u64 cntr_stop = 0; | ||
163 | |||
164 | struct clk_gk20a *clk = &g->clk; | ||
165 | |||
166 | if ((c == NULL) || (c->cntr.reg_ctrl_addr == 0U) || | ||
167 | (c->cntr.reg_cntr_addr[0] == 0U) || | ||
168 | (c->cntr.reg_cntr_addr[1]) == 0U) { | ||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | nvgpu_mutex_acquire(&clk->clk_mutex); | ||
173 | |||
174 | /* Read the counter values */ | ||
175 | /* Counter is 36bits , 32 bits on addr[0] and 4 lsb on addr[1] others zero*/ | ||
176 | cntr_start = (u64)gk20a_readl(g, c->cntr.reg_cntr_addr[0]); | ||
177 | cntr_start += ((u64)gk20a_readl(g, c->cntr.reg_cntr_addr[1]) << 32); | ||
178 | nvgpu_udelay(XTAL_CNTR_DELAY); | ||
179 | cntr_stop = (u64) gk20a_readl(g, c->cntr.reg_cntr_addr[0]); | ||
180 | cntr_stop += ((u64)gk20a_readl(g, c->cntr.reg_cntr_addr[1]) << 32); | ||
181 | /*Calculate the difference and convert to KHz*/ | ||
182 | cntr = (u32)((cntr_stop - cntr_start) / 10ULL); | ||
183 | nvgpu_mutex_release(&clk->clk_mutex); | ||
184 | |||
185 | return cntr; | ||
186 | |||
187 | } | ||
188 | |||
189 | int gv100_suspend_clk_support(struct gk20a *g) | ||
190 | { | ||
191 | nvgpu_mutex_destroy(&g->clk.clk_mutex); | ||
192 | return 0; | ||
193 | } | ||
diff --git a/drivers/gpu/nvgpu/gv100/clk_gv100.h b/drivers/gpu/nvgpu/gv100/clk_gv100.h new file mode 100644 index 00000000..d3356a7f --- /dev/null +++ b/drivers/gpu/nvgpu/gv100/clk_gv100.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016-2018, 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 | #ifndef CLK_GV100_H | ||
23 | #define CLK_GV100_H | ||
24 | |||
25 | #include <nvgpu/lock.h> | ||
26 | #include "gk20a/gk20a.h" | ||
27 | |||
28 | #define CLK_NAMEMAP_INDEX_GPCCLK 0x00 | ||
29 | #define CLK_NAMEMAP_INDEX_XBARCLK 0x02 | ||
30 | #define CLK_NAMEMAP_INDEX_SYSCLK 0x07 /* SYSPLL */ | ||
31 | #define CLK_NAMEMAP_INDEX_DRAMCLK 0x20 /* DRAMPLL */ | ||
32 | |||
33 | #define CLK_DEFAULT_CNTRL_SETTLE_RETRIES 10 | ||
34 | #define CLK_DEFAULT_CNTRL_SETTLE_USECS 5 | ||
35 | #define CLK_MAX_CNTRL_REGISTERS 2 | ||
36 | |||
37 | #define XTAL_CNTR_CLKS 27000 /* 1000usec at 27KHz XTAL */ | ||
38 | #define XTAL_CNTR_DELAY 10000 /* we need acuracy up to the 10ms */ | ||
39 | #define XTAL_SCALE_TO_KHZ 1 | ||
40 | #define NUM_NAMEMAPS (3U) | ||
41 | #define XTAL4X_KHZ 108000 | ||
42 | |||
43 | u32 gv100_get_rate_cntr(struct gk20a *g, struct namemap_cfg *c); | ||
44 | struct namemap_cfg { | ||
45 | u32 namemap; | ||
46 | u32 is_enable; /* Namemap enabled */ | ||
47 | u32 is_counter; /* Using cntr */ | ||
48 | struct gk20a *g; | ||
49 | struct { | ||
50 | u32 reg_ctrl_addr; | ||
51 | u32 reg_ctrl_idx; | ||
52 | u32 reg_cntr_addr[CLK_MAX_CNTRL_REGISTERS]; | ||
53 | } cntr; | ||
54 | u32 scale; | ||
55 | char name[24]; | ||
56 | }; | ||
57 | |||
58 | int gv100_init_clk_support(struct gk20a *g); | ||
59 | u32 gv100_crystal_clk_hz(struct gk20a *g); | ||
60 | unsigned long gv100_clk_measure_freq(struct gk20a *g, u32 api_domain); | ||
61 | int gv100_suspend_clk_support(struct gk20a *g); | ||
62 | |||
63 | #endif /* CLK_GV100_H */ | ||
diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c index 041422e0..7cd466c3 100644 --- a/drivers/gpu/nvgpu/gv100/hal_gv100.c +++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c | |||
@@ -66,13 +66,11 @@ | |||
66 | #include "gm20b/pmu_gm20b.h" | 66 | #include "gm20b/pmu_gm20b.h" |
67 | #include "gm20b/acr_gm20b.h" | 67 | #include "gm20b/acr_gm20b.h" |
68 | 68 | ||
69 | #include "gp106/clk_gp106.h" | ||
70 | #include "gp106/clk_arb_gp106.h" | 69 | #include "gp106/clk_arb_gp106.h" |
71 | #include "gp106/pmu_gp106.h" | 70 | #include "gp106/pmu_gp106.h" |
72 | #include "gp106/acr_gp106.h" | 71 | #include "gp106/acr_gp106.h" |
73 | #include "gp106/sec2_gp106.h" | 72 | #include "gp106/sec2_gp106.h" |
74 | #include "gp106/bios_gp106.h" | 73 | #include "gp106/bios_gp106.h" |
75 | #include "gp106/clk_gp106.h" | ||
76 | #include "gp106/flcn_gp106.h" | 74 | #include "gp106/flcn_gp106.h" |
77 | 75 | ||
78 | #include "gp10b/gr_gp10b.h" | 76 | #include "gp10b/gr_gp10b.h" |
@@ -107,6 +105,7 @@ | |||
107 | #include "gv100/nvlink_gv100.h" | 105 | #include "gv100/nvlink_gv100.h" |
108 | #include "gv100/regops_gv100.h" | 106 | #include "gv100/regops_gv100.h" |
109 | #include "gv100/perf_gv100.h" | 107 | #include "gv100/perf_gv100.h" |
108 | #include "gv100/clk_gv100.h" | ||
110 | 109 | ||
111 | #include <nvgpu/ptimer.h> | 110 | #include <nvgpu/ptimer.h> |
112 | #include <nvgpu/debug.h> | 111 | #include <nvgpu/debug.h> |
@@ -768,11 +767,11 @@ static const struct gpu_ops gv100_ops = { | |||
768 | .secured_pmu_start = gm20b_secured_pmu_start, | 767 | .secured_pmu_start = gm20b_secured_pmu_start, |
769 | }, | 768 | }, |
770 | .clk = { | 769 | .clk = { |
771 | .init_clk_support = gp106_init_clk_support, | 770 | .init_clk_support = gv100_init_clk_support, |
772 | .get_crystal_clk_hz = gp106_crystal_clk_hz, | 771 | .get_crystal_clk_hz = gv100_crystal_clk_hz, |
773 | .get_rate_cntr = gp106_get_rate_cntr, | 772 | .get_rate_cntr = gv100_get_rate_cntr, |
774 | .measure_freq = gp106_clk_measure_freq, | 773 | .measure_freq = gv100_clk_measure_freq, |
775 | .suspend_clk_support = gp106_suspend_clk_support, | 774 | .suspend_clk_support = gv100_suspend_clk_support, |
776 | .perf_pmu_vfe_load = gv100_perf_pmu_vfe_load, | 775 | .perf_pmu_vfe_load = gv100_perf_pmu_vfe_load, |
777 | }, | 776 | }, |
778 | .clk_arb = { | 777 | .clk_arb = { |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/hw/gv100/hw_trim_gv100.h b/drivers/gpu/nvgpu/include/nvgpu/hw/gv100/hw_trim_gv100.h index 9e7ceaff..f1b6da28 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/hw/gv100/hw_trim_gv100.h +++ b/drivers/gpu/nvgpu/include/nvgpu/hw/gv100/hw_trim_gv100.h | |||
@@ -196,4 +196,52 @@ static inline u32 trim_sys_nvl_common_clk_alt_switch_finalsel_onesrcclk_f(void) | |||
196 | { | 196 | { |
197 | return 0x3U; | 197 | return 0x3U; |
198 | } | 198 | } |
199 | static inline u32 trim_gpc_bcast_fr_clk_cntr_ncgpcclk_cfg_r(void) | ||
200 | { | ||
201 | return 0x00132a70U; | ||
202 | } | ||
203 | static inline u32 trim_gpc_bcast_fr_clk_cntr_ncgpcclk_cfg_source_gpcclk_f(void) | ||
204 | { | ||
205 | return 0x10000000U; | ||
206 | } | ||
207 | static inline u32 trim_gpc_bcast_fr_clk_cntr_ncgpcclk_cnt0_r(void) | ||
208 | { | ||
209 | return 0x00132a74U; | ||
210 | } | ||
211 | static inline u32 trim_gpc_bcast_fr_clk_cntr_ncgpcclk_cnt1_r(void) | ||
212 | { | ||
213 | return 0x00132a78U; | ||
214 | } | ||
215 | static inline u32 trim_sys_nafll_fr_clk_cntr_xbarclk_cfg_r(void) | ||
216 | { | ||
217 | return 0x00136470U; | ||
218 | } | ||
219 | static inline u32 trim_sys_nafll_fr_clk_cntr_xbarclk_cfg_source_xbarclk_f(void) | ||
220 | { | ||
221 | return 0x10000000U; | ||
222 | } | ||
223 | static inline u32 trim_sys_nafll_fr_clk_cntr_xbarclk_cntr0_r(void) | ||
224 | { | ||
225 | return 0x00136474U; | ||
226 | } | ||
227 | static inline u32 trim_sys_nafll_fr_clk_cntr_xbarclk_cntr1_r(void) | ||
228 | { | ||
229 | return 0x00136478U; | ||
230 | } | ||
231 | static inline u32 trim_sys_fr_clk_cntr_sysclk_cfg_r(void) | ||
232 | { | ||
233 | return 0x0013762cU; | ||
234 | } | ||
235 | static inline u32 trim_sys_fr_clk_cntr_sysclk_cfg_source_sysclk_f(void) | ||
236 | { | ||
237 | return 0x20000000U; | ||
238 | } | ||
239 | static inline u32 trim_sys_fr_clk_cntr_sysclk_cntr0_r(void) | ||
240 | { | ||
241 | return 0x00137630U; | ||
242 | } | ||
243 | static inline u32 trim_sys_fr_clk_cntr_sysclk_cntr1_r(void) | ||
244 | { | ||
245 | return 0x00137634U; | ||
246 | } | ||
199 | #endif | 247 | #endif |
diff --git a/drivers/gpu/nvgpu/os/linux/debug_clk_gv100.c b/drivers/gpu/nvgpu/os/linux/debug_clk_gv100.c new file mode 100644 index 00000000..623f2b6b --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/debug_clk_gv100.c | |||
@@ -0,0 +1,193 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018, 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 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include <linux/debugfs.h> | ||
18 | |||
19 | #include "gv100/clk_gv100.h" | ||
20 | |||
21 | #include "os_linux.h" | ||
22 | |||
23 | void nvgpu_clk_arb_pstate_change_lock(struct gk20a *g, bool lock); | ||
24 | |||
25 | static int gv100_get_rate_show(void *data , u64 *val) | ||
26 | { | ||
27 | struct namemap_cfg *c = (struct namemap_cfg *)data; | ||
28 | struct gk20a *g = c->g; | ||
29 | |||
30 | if (!g->ops.clk.get_rate_cntr) | ||
31 | return -EINVAL; | ||
32 | |||
33 | *val = c->is_counter ? (u64)c->scale * g->ops.clk.get_rate_cntr(g, c) : | ||
34 | 0 /* TODO PLL read */; | ||
35 | |||
36 | return 0; | ||
37 | } | ||
38 | DEFINE_SIMPLE_ATTRIBUTE(get_rate_fops, gv100_get_rate_show, NULL, "%llu\n"); | ||
39 | |||
40 | static int sys_cfc_read(void *data , u64 *val) | ||
41 | { | ||
42 | struct gk20a *g = (struct gk20a *)data; | ||
43 | bool bload = boardobjgrpmask_bitget( | ||
44 | &g->clk_pmu.clk_freq_controllers.freq_ctrl_load_mask.super, | ||
45 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_SYS); | ||
46 | |||
47 | /* val = 1 implies CLFC is loaded or enabled */ | ||
48 | *val = bload ? 1 : 0; | ||
49 | return 0; | ||
50 | } | ||
51 | static int sys_cfc_write(void *data , u64 val) | ||
52 | { | ||
53 | struct gk20a *g = (struct gk20a *)data; | ||
54 | int status; | ||
55 | /* val = 1 implies load or enable the CLFC */ | ||
56 | bool bload = val ? true : false; | ||
57 | |||
58 | nvgpu_clk_arb_pstate_change_lock(g, true); | ||
59 | status = clk_pmu_freq_controller_load(g, bload, | ||
60 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_SYS); | ||
61 | nvgpu_clk_arb_pstate_change_lock(g, false); | ||
62 | |||
63 | return status; | ||
64 | } | ||
65 | DEFINE_SIMPLE_ATTRIBUTE(sys_cfc_fops, sys_cfc_read, sys_cfc_write, "%llu\n"); | ||
66 | |||
67 | static int ltc_cfc_read(void *data , u64 *val) | ||
68 | { | ||
69 | struct gk20a *g = (struct gk20a *)data; | ||
70 | bool bload = boardobjgrpmask_bitget( | ||
71 | &g->clk_pmu.clk_freq_controllers.freq_ctrl_load_mask.super, | ||
72 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_LTC); | ||
73 | |||
74 | /* val = 1 implies CLFC is loaded or enabled */ | ||
75 | *val = bload ? 1 : 0; | ||
76 | return 0; | ||
77 | } | ||
78 | static int ltc_cfc_write(void *data , u64 val) | ||
79 | { | ||
80 | struct gk20a *g = (struct gk20a *)data; | ||
81 | int status; | ||
82 | /* val = 1 implies load or enable the CLFC */ | ||
83 | bool bload = val ? true : false; | ||
84 | |||
85 | nvgpu_clk_arb_pstate_change_lock(g, true); | ||
86 | status = clk_pmu_freq_controller_load(g, bload, | ||
87 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_LTC); | ||
88 | nvgpu_clk_arb_pstate_change_lock(g, false); | ||
89 | |||
90 | return status; | ||
91 | } | ||
92 | DEFINE_SIMPLE_ATTRIBUTE(ltc_cfc_fops, ltc_cfc_read, ltc_cfc_write, "%llu\n"); | ||
93 | |||
94 | static int xbar_cfc_read(void *data , u64 *val) | ||
95 | { | ||
96 | struct gk20a *g = (struct gk20a *)data; | ||
97 | bool bload = boardobjgrpmask_bitget( | ||
98 | &g->clk_pmu.clk_freq_controllers.freq_ctrl_load_mask.super, | ||
99 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_XBAR); | ||
100 | |||
101 | /* val = 1 implies CLFC is loaded or enabled */ | ||
102 | *val = bload ? 1 : 0; | ||
103 | return 0; | ||
104 | } | ||
105 | static int xbar_cfc_write(void *data , u64 val) | ||
106 | { | ||
107 | struct gk20a *g = (struct gk20a *)data; | ||
108 | int status; | ||
109 | /* val = 1 implies load or enable the CLFC */ | ||
110 | bool bload = val ? true : false; | ||
111 | |||
112 | nvgpu_clk_arb_pstate_change_lock(g, true); | ||
113 | status = clk_pmu_freq_controller_load(g, bload, | ||
114 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_XBAR); | ||
115 | nvgpu_clk_arb_pstate_change_lock(g, false); | ||
116 | |||
117 | return status; | ||
118 | } | ||
119 | DEFINE_SIMPLE_ATTRIBUTE(xbar_cfc_fops, xbar_cfc_read, | ||
120 | xbar_cfc_write, "%llu\n"); | ||
121 | |||
122 | static int gpc_cfc_read(void *data , u64 *val) | ||
123 | { | ||
124 | struct gk20a *g = (struct gk20a *)data; | ||
125 | bool bload = boardobjgrpmask_bitget( | ||
126 | &g->clk_pmu.clk_freq_controllers.freq_ctrl_load_mask.super, | ||
127 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC0); | ||
128 | |||
129 | /* val = 1 implies CLFC is loaded or enabled */ | ||
130 | *val = bload ? 1 : 0; | ||
131 | return 0; | ||
132 | } | ||
133 | static int gpc_cfc_write(void *data , u64 val) | ||
134 | { | ||
135 | struct gk20a *g = (struct gk20a *)data; | ||
136 | int status; | ||
137 | /* val = 1 implies load or enable the CLFC */ | ||
138 | bool bload = val ? true : false; | ||
139 | |||
140 | nvgpu_clk_arb_pstate_change_lock(g, true); | ||
141 | status = clk_pmu_freq_controller_load(g, bload, | ||
142 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC0); | ||
143 | nvgpu_clk_arb_pstate_change_lock(g, false); | ||
144 | |||
145 | return status; | ||
146 | } | ||
147 | DEFINE_SIMPLE_ATTRIBUTE(gpc_cfc_fops, gpc_cfc_read, gpc_cfc_write, "%llu\n"); | ||
148 | |||
149 | int gv100_clk_init_debugfs(struct gk20a *g) | ||
150 | { | ||
151 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); | ||
152 | struct dentry *gpu_root = l->debugfs; | ||
153 | struct dentry *clocks_root, *clk_freq_ctlr_root; | ||
154 | struct dentry *d; | ||
155 | unsigned int i; | ||
156 | |||
157 | if (NULL == (clocks_root = debugfs_create_dir("clocks", gpu_root))) | ||
158 | return -ENOMEM; | ||
159 | |||
160 | clk_freq_ctlr_root = debugfs_create_dir("clk_freq_ctlr", gpu_root); | ||
161 | if (clk_freq_ctlr_root == NULL) | ||
162 | return -ENOMEM; | ||
163 | |||
164 | d = debugfs_create_file("sys", S_IRUGO | S_IWUSR, clk_freq_ctlr_root, | ||
165 | g, &sys_cfc_fops); | ||
166 | d = debugfs_create_file("ltc", S_IRUGO | S_IWUSR, clk_freq_ctlr_root, | ||
167 | g, <c_cfc_fops); | ||
168 | d = debugfs_create_file("xbar", S_IRUGO | S_IWUSR, clk_freq_ctlr_root, | ||
169 | g, &xbar_cfc_fops); | ||
170 | d = debugfs_create_file("gpc", S_IRUGO | S_IWUSR, clk_freq_ctlr_root, | ||
171 | g, &gpc_cfc_fops); | ||
172 | |||
173 | nvgpu_log(g, gpu_dbg_info, "g=%p", g); | ||
174 | |||
175 | for (i = 0; i < g->clk.namemap_num; i++) { | ||
176 | if (g->clk.clk_namemap[i].is_enable) { | ||
177 | d = debugfs_create_file( | ||
178 | g->clk.clk_namemap[i].name, | ||
179 | S_IRUGO, | ||
180 | clocks_root, | ||
181 | &g->clk.clk_namemap[i], | ||
182 | &get_rate_fops); | ||
183 | if (!d) | ||
184 | goto err_out; | ||
185 | } | ||
186 | } | ||
187 | return 0; | ||
188 | |||
189 | err_out: | ||
190 | pr_err("%s: Failed to make debugfs node\n", __func__); | ||
191 | debugfs_remove_recursive(clocks_root); | ||
192 | return -ENOMEM; | ||
193 | } | ||
diff --git a/drivers/gpu/nvgpu/os/linux/debug_clk_gv100.h b/drivers/gpu/nvgpu/os/linux/debug_clk_gv100.h new file mode 100644 index 00000000..38ba61bd --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/debug_clk_gv100.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018, 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 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #ifndef __DEBUG_CLK_GV100_H | ||
18 | #define __DEBUG_CLK_GV100_H | ||
19 | |||
20 | #ifdef CONFIG_DEBUG_FS | ||
21 | int gv100_clk_init_debugfs(struct gk20a *g); | ||
22 | #else | ||
23 | inline int gv100_clk_init_debugfs(struct gk20a *g) | ||
24 | { | ||
25 | return 0; | ||
26 | } | ||
27 | #endif | ||
28 | |||
29 | #endif | ||
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c b/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c index f5c5a604..9d92bdfb 100644 --- a/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c +++ b/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c | |||
@@ -16,13 +16,13 @@ | |||
16 | 16 | ||
17 | #include "os_linux.h" | 17 | #include "os_linux.h" |
18 | 18 | ||
19 | #include "debug_clk_gp106.h" | 19 | #include "debug_clk_gv100.h" |
20 | #include "debug_therm_gp106.h" | 20 | #include "debug_therm_gp106.h" |
21 | #include "debug_fecs_trace.h" | 21 | #include "debug_fecs_trace.h" |
22 | 22 | ||
23 | static struct nvgpu_os_linux_ops gv100_os_linux_ops = { | 23 | static struct nvgpu_os_linux_ops gv100_os_linux_ops = { |
24 | .clk = { | 24 | .clk = { |
25 | .init_debugfs = gp106_clk_init_debugfs, | 25 | .init_debugfs = gv100_clk_init_debugfs, |
26 | }, | 26 | }, |
27 | .therm = { | 27 | .therm = { |
28 | .init_debugfs = gp106_therm_init_debugfs, | 28 | .init_debugfs = gp106_therm_init_debugfs, |