diff options
author | Nitin Kumbhar <nkumbhar@nvidia.com> | 2018-08-12 02:09:24 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-09-05 07:51:36 -0400 |
commit | f16cc93d0a7c818327f08ece1d7fcbefcdbb055b (patch) | |
tree | 592a06f7c031d16b45e716758890b95f73ee8509 /drivers/gpu/nvgpu/gp106/clk_gp106.c | |
parent | 43851d41b187c92f5ea9c2f503a882277f661d7e (diff) |
gpu: nvgpu: move gp106 clk debugfs to linux
Move linux dependencies and CONFIG_DEBUG_FS to linux specific
code from common driver for gp106 clk debugfs. There is no
code change in functions moved from gp106/clk_gp106.c.
It uses nvgpu_os_linux_ops to add gp106 specific clk debugfs
ops. The linux specific part of nvgpu driver uses this op
to initialize gp106 clk debugfs.
As gv100 also uses gp106 clk debugfs ops, set up os ops for
gv100.
JIRA NVGPU-603
Change-Id: Ib55ef051b13366e5907e1d05376bb18bf42c8653
Signed-off-by: Nitin Kumbhar <nkumbhar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1797904
Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com>
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gp106/clk_gp106.c')
-rw-r--r-- | drivers/gpu/nvgpu/gp106/clk_gp106.c | 188 |
1 files changed, 2 insertions, 186 deletions
diff --git a/drivers/gpu/nvgpu/gp106/clk_gp106.c b/drivers/gpu/nvgpu/gp106/clk_gp106.c index dd7a2dd6..13a401f0 100644 --- a/drivers/gpu/nvgpu/gp106/clk_gp106.c +++ b/drivers/gpu/nvgpu/gp106/clk_gp106.c | |||
@@ -22,11 +22,6 @@ | |||
22 | * DEALINGS IN THE SOFTWARE. | 22 | * DEALINGS IN THE SOFTWARE. |
23 | */ | 23 | */ |
24 | 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> | 25 | #include <nvgpu/kmem.h> |
31 | #include <nvgpu/io.h> | 26 | #include <nvgpu/io.h> |
32 | #include <nvgpu/list.h> | 27 | #include <nvgpu/list.h> |
@@ -42,15 +37,9 @@ | |||
42 | 37 | ||
43 | #include <nvgpu/hw/gp106/hw_trim_gp106.h> | 38 | #include <nvgpu/hw/gp106/hw_trim_gp106.h> |
44 | 39 | ||
45 | #ifdef CONFIG_DEBUG_FS | ||
46 | static int clk_gp106_debugfs_init(struct gk20a *g); | ||
47 | #endif | ||
48 | |||
49 | #define NUM_NAMEMAPS 4 | 40 | #define NUM_NAMEMAPS 4 |
50 | #define XTAL4X_KHZ 108000 | 41 | #define XTAL4X_KHZ 108000 |
51 | 42 | ||
52 | |||
53 | static u32 gp106_get_rate_cntr(struct gk20a *g, struct namemap_cfg *); | ||
54 | u32 gp106_crystal_clk_hz(struct gk20a *g) | 43 | u32 gp106_crystal_clk_hz(struct gk20a *g) |
55 | { | 44 | { |
56 | return (XTAL4X_KHZ * 1000); | 45 | return (XTAL4X_KHZ * 1000); |
@@ -173,16 +162,11 @@ int gp106_init_clk_support(struct gk20a *g) | |||
173 | 162 | ||
174 | clk->g = g; | 163 | clk->g = g; |
175 | 164 | ||
176 | #ifdef CONFIG_DEBUG_FS | ||
177 | if (!clk->debugfs_set) { | ||
178 | if (!clk_gp106_debugfs_init(g)) | ||
179 | clk->debugfs_set = true; | ||
180 | } | ||
181 | #endif | ||
182 | return err; | 165 | return err; |
183 | } | 166 | } |
184 | 167 | ||
185 | static u32 gp106_get_rate_cntr(struct gk20a *g, struct namemap_cfg *c) { | 168 | u32 gp106_get_rate_cntr(struct gk20a *g, struct namemap_cfg *c) |
169 | { | ||
186 | u32 save_reg; | 170 | u32 save_reg; |
187 | u32 retries; | 171 | u32 retries; |
188 | u32 cntr = 0; | 172 | u32 cntr = 0; |
@@ -275,174 +259,6 @@ int gp106_clk_domain_get_f_points( | |||
275 | return status; | 259 | return status; |
276 | } | 260 | } |
277 | 261 | ||
278 | |||
279 | #ifdef CONFIG_DEBUG_FS | ||
280 | static int gp106_get_rate_show(void *data , u64 *val) { | ||
281 | struct namemap_cfg *c = (struct namemap_cfg *) data; | ||
282 | struct gk20a *g = c->g; | ||
283 | |||
284 | *val = c->is_counter ? (u64)c->scale * gp106_get_rate_cntr(g, c) : | ||
285 | 0 /* TODO PLL read */; | ||
286 | return 0; | ||
287 | } | ||
288 | DEFINE_SIMPLE_ATTRIBUTE(get_rate_fops, gp106_get_rate_show, NULL, "%llu\n"); | ||
289 | |||
290 | static int sys_cfc_read(void *data , u64 *val) | ||
291 | { | ||
292 | struct gk20a *g = (struct gk20a *)data; | ||
293 | bool bload = boardobjgrpmask_bitget( | ||
294 | &g->clk_pmu.clk_freq_controllers.freq_ctrl_load_mask.super, | ||
295 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_SYS); | ||
296 | |||
297 | /* val = 1 implies CLFC is loaded or enabled */ | ||
298 | *val = bload ? 1 : 0; | ||
299 | return 0; | ||
300 | } | ||
301 | static int sys_cfc_write(void *data , u64 val) | ||
302 | { | ||
303 | struct gk20a *g = (struct gk20a *)data; | ||
304 | int status; | ||
305 | /* val = 1 implies load or enable the CLFC */ | ||
306 | bool bload = val ? true : false; | ||
307 | |||
308 | nvgpu_clk_arb_pstate_change_lock(g, true); | ||
309 | status = clk_pmu_freq_controller_load(g, bload, | ||
310 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_SYS); | ||
311 | nvgpu_clk_arb_pstate_change_lock(g, false); | ||
312 | |||
313 | return status; | ||
314 | } | ||
315 | DEFINE_SIMPLE_ATTRIBUTE(sys_cfc_fops, sys_cfc_read, sys_cfc_write, "%llu\n"); | ||
316 | |||
317 | static int ltc_cfc_read(void *data , u64 *val) | ||
318 | { | ||
319 | struct gk20a *g = (struct gk20a *)data; | ||
320 | bool bload = boardobjgrpmask_bitget( | ||
321 | &g->clk_pmu.clk_freq_controllers.freq_ctrl_load_mask.super, | ||
322 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_LTC); | ||
323 | |||
324 | /* val = 1 implies CLFC is loaded or enabled */ | ||
325 | *val = bload ? 1 : 0; | ||
326 | return 0; | ||
327 | } | ||
328 | static int ltc_cfc_write(void *data , u64 val) | ||
329 | { | ||
330 | struct gk20a *g = (struct gk20a *)data; | ||
331 | int status; | ||
332 | /* val = 1 implies load or enable the CLFC */ | ||
333 | bool bload = val ? true : false; | ||
334 | |||
335 | nvgpu_clk_arb_pstate_change_lock(g, true); | ||
336 | status = clk_pmu_freq_controller_load(g, bload, | ||
337 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_LTC); | ||
338 | nvgpu_clk_arb_pstate_change_lock(g, false); | ||
339 | |||
340 | return status; | ||
341 | } | ||
342 | DEFINE_SIMPLE_ATTRIBUTE(ltc_cfc_fops, ltc_cfc_read, ltc_cfc_write, "%llu\n"); | ||
343 | |||
344 | static int xbar_cfc_read(void *data , u64 *val) | ||
345 | { | ||
346 | struct gk20a *g = (struct gk20a *)data; | ||
347 | bool bload = boardobjgrpmask_bitget( | ||
348 | &g->clk_pmu.clk_freq_controllers.freq_ctrl_load_mask.super, | ||
349 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_XBAR); | ||
350 | |||
351 | /* val = 1 implies CLFC is loaded or enabled */ | ||
352 | *val = bload ? 1 : 0; | ||
353 | return 0; | ||
354 | } | ||
355 | static int xbar_cfc_write(void *data , u64 val) | ||
356 | { | ||
357 | struct gk20a *g = (struct gk20a *)data; | ||
358 | int status; | ||
359 | /* val = 1 implies load or enable the CLFC */ | ||
360 | bool bload = val ? true : false; | ||
361 | |||
362 | nvgpu_clk_arb_pstate_change_lock(g, true); | ||
363 | status = clk_pmu_freq_controller_load(g, bload, | ||
364 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_XBAR); | ||
365 | nvgpu_clk_arb_pstate_change_lock(g, false); | ||
366 | |||
367 | return status; | ||
368 | } | ||
369 | DEFINE_SIMPLE_ATTRIBUTE(xbar_cfc_fops, xbar_cfc_read, | ||
370 | xbar_cfc_write, "%llu\n"); | ||
371 | |||
372 | static int gpc_cfc_read(void *data , u64 *val) | ||
373 | { | ||
374 | struct gk20a *g = (struct gk20a *)data; | ||
375 | bool bload = boardobjgrpmask_bitget( | ||
376 | &g->clk_pmu.clk_freq_controllers.freq_ctrl_load_mask.super, | ||
377 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC0); | ||
378 | |||
379 | /* val = 1 implies CLFC is loaded or enabled */ | ||
380 | *val = bload ? 1 : 0; | ||
381 | return 0; | ||
382 | } | ||
383 | static int gpc_cfc_write(void *data , u64 val) | ||
384 | { | ||
385 | struct gk20a *g = (struct gk20a *)data; | ||
386 | int status; | ||
387 | /* val = 1 implies load or enable the CLFC */ | ||
388 | bool bload = val ? true : false; | ||
389 | |||
390 | nvgpu_clk_arb_pstate_change_lock(g, true); | ||
391 | status = clk_pmu_freq_controller_load(g, bload, | ||
392 | CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC0); | ||
393 | nvgpu_clk_arb_pstate_change_lock(g, false); | ||
394 | |||
395 | return status; | ||
396 | } | ||
397 | DEFINE_SIMPLE_ATTRIBUTE(gpc_cfc_fops, gpc_cfc_read, gpc_cfc_write, "%llu\n"); | ||
398 | |||
399 | static int clk_gp106_debugfs_init(struct gk20a *g) | ||
400 | { | ||
401 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); | ||
402 | struct dentry *gpu_root = l->debugfs; | ||
403 | struct dentry *clocks_root, *clk_freq_ctlr_root; | ||
404 | struct dentry *d; | ||
405 | unsigned int i; | ||
406 | |||
407 | if (NULL == (clocks_root = debugfs_create_dir("clocks", gpu_root))) | ||
408 | return -ENOMEM; | ||
409 | |||
410 | clk_freq_ctlr_root = debugfs_create_dir("clk_freq_ctlr", gpu_root); | ||
411 | if (clk_freq_ctlr_root == NULL) | ||
412 | return -ENOMEM; | ||
413 | |||
414 | d = debugfs_create_file("sys", S_IRUGO | S_IWUSR, clk_freq_ctlr_root, | ||
415 | g, &sys_cfc_fops); | ||
416 | d = debugfs_create_file("ltc", S_IRUGO | S_IWUSR, clk_freq_ctlr_root, | ||
417 | g, <c_cfc_fops); | ||
418 | d = debugfs_create_file("xbar", S_IRUGO | S_IWUSR, clk_freq_ctlr_root, | ||
419 | g, &xbar_cfc_fops); | ||
420 | d = debugfs_create_file("gpc", S_IRUGO | S_IWUSR, clk_freq_ctlr_root, | ||
421 | g, &gpc_cfc_fops); | ||
422 | |||
423 | nvgpu_log(g, gpu_dbg_info, "g=%p", g); | ||
424 | |||
425 | for (i = 0; i < g->clk.namemap_num; i++) { | ||
426 | if (g->clk.clk_namemap[i].is_enable) { | ||
427 | d = debugfs_create_file( | ||
428 | g->clk.clk_namemap[i].name, | ||
429 | S_IRUGO, | ||
430 | clocks_root, | ||
431 | &g->clk.clk_namemap[i], | ||
432 | &get_rate_fops); | ||
433 | if (!d) | ||
434 | goto err_out; | ||
435 | } | ||
436 | } | ||
437 | return 0; | ||
438 | |||
439 | err_out: | ||
440 | pr_err("%s: Failed to make debugfs node\n", __func__); | ||
441 | debugfs_remove_recursive(clocks_root); | ||
442 | return -ENOMEM; | ||
443 | } | ||
444 | #endif /* CONFIG_DEBUG_FS */ | ||
445 | |||
446 | int gp106_suspend_clk_support(struct gk20a *g) | 262 | int gp106_suspend_clk_support(struct gk20a *g) |
447 | { | 263 | { |
448 | nvgpu_mutex_destroy(&g->clk.clk_mutex); | 264 | nvgpu_mutex_destroy(&g->clk.clk_mutex); |