summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSeshendra Gadagottu <sgadagottu@nvidia.com>2015-10-23 15:02:55 -0400
committerTerje Bergstrom <tbergstrom@nvidia.com>2015-10-27 18:42:08 -0400
commit004a1880ed80f3b384cf3d0d37e0a58eff29fcaf (patch)
treeb1f55beabeeb3b9a411ff609b7c6c4984aae40c6 /drivers
parent057c6334f7f72071bc87a1793b688b34add7c681 (diff)
gpu: nvgpu: update thermal programming
Add required fileds and values for thermal slow-down settings in thermal header file and implemented chip specific thermal register programming Reviewed-on: http://git-master/r/822199 (cherry picked from commit 9e8a745b8295af002b9780c83caa8dc7b22cc737) Change-Id: I016b18ed230fa6c104eada2e166ccd1a5f2ace36 Signed-off-by: Seshendra Gadagottu <sgadagottu@nvidia.com> Reviewed-on: http://git-master/r/823012 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/Makefile3
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h3
-rw-r--r--drivers/gpu/nvgpu/gk20a/hal_gk20a.c2
-rw-r--r--drivers/gpu/nvgpu/gk20a/hw_therm_gk20a.h48
-rw-r--r--drivers/gpu/nvgpu/gk20a/therm_gk20a.c25
-rw-r--r--drivers/gpu/nvgpu/gk20a/therm_gk20a.h11
-rw-r--r--drivers/gpu/nvgpu/gm20b/hal_gm20b.c2
-rw-r--r--drivers/gpu/nvgpu/gm20b/hw_therm_gm20b.h36
-rw-r--r--drivers/gpu/nvgpu/gm20b/therm_gm20b.c72
-rw-r--r--drivers/gpu/nvgpu/gm20b/therm_gm20b.h21
10 files changed, 208 insertions, 15 deletions
diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile
index ee2117b9..966c5eea 100644
--- a/drivers/gpu/nvgpu/Makefile
+++ b/drivers/gpu/nvgpu/Makefile
@@ -62,7 +62,8 @@ nvgpu-y := \
62 gm20b/regops_gm20b.o \ 62 gm20b/regops_gm20b.o \
63 gm20b/mc_gm20b.o \ 63 gm20b/mc_gm20b.o \
64 gm20b/debug_gm20b.o \ 64 gm20b/debug_gm20b.o \
65 gm20b/cde_gm20b.o 65 gm20b/cde_gm20b.o \
66 gm20b/therm_gm20b.o
66 67
67nvgpu-$(CONFIG_TEGRA_GK20A) += gk20a/platform_gk20a_tegra.o 68nvgpu-$(CONFIG_TEGRA_GK20A) += gk20a/platform_gk20a_tegra.o
68nvgpu-$(CONFIG_SYNC) += gk20a/sync_gk20a.o 69nvgpu-$(CONFIG_SYNC) += gk20a/sync_gk20a.o
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 1cf90fbf..328bb73b 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -388,6 +388,9 @@ struct gpu_ops {
388 u32 flags); 388 u32 flags);
389 } mm; 389 } mm;
390 struct { 390 struct {
391 int (*init_therm_setup_hw)(struct gk20a *g);
392 } therm;
393 struct {
391 int (*prepare_ucode)(struct gk20a *g); 394 int (*prepare_ucode)(struct gk20a *g);
392 int (*pmu_setup_hw_and_bootstrap)(struct gk20a *g); 395 int (*pmu_setup_hw_and_bootstrap)(struct gk20a *g);
393 int (*pmu_nsbootstrap)(struct pmu_gk20a *pmu); 396 int (*pmu_nsbootstrap)(struct pmu_gk20a *pmu);
diff --git a/drivers/gpu/nvgpu/gk20a/hal_gk20a.c b/drivers/gpu/nvgpu/gk20a/hal_gk20a.c
index b8268e1f..a9ad970a 100644
--- a/drivers/gpu/nvgpu/gk20a/hal_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/hal_gk20a.c
@@ -27,6 +27,7 @@
27#include "pmu_gk20a.h" 27#include "pmu_gk20a.h"
28#include "clk_gk20a.h" 28#include "clk_gk20a.h"
29#include "regops_gk20a.h" 29#include "regops_gk20a.h"
30#include "therm_gk20a.h"
30 31
31static struct gpu_ops gk20a_ops = { 32static struct gpu_ops gk20a_ops = {
32 .clock_gating = { 33 .clock_gating = {
@@ -65,6 +66,7 @@ int gk20a_init_hal(struct gk20a *g)
65 gk20a_init_clk_ops(gops); 66 gk20a_init_clk_ops(gops);
66 gk20a_init_regops(gops); 67 gk20a_init_regops(gops);
67 gk20a_init_debug_ops(gops); 68 gk20a_init_debug_ops(gops);
69 gk20a_init_therm_ops(gops);
68 gops->name = "gk20a"; 70 gops->name = "gk20a";
69 71
70 c->twod_class = FERMI_TWOD_A; 72 c->twod_class = FERMI_TWOD_A;
diff --git a/drivers/gpu/nvgpu/gk20a/hw_therm_gk20a.h b/drivers/gpu/nvgpu/gk20a/hw_therm_gk20a.h
index 67f1bbc2..d4c04116 100644
--- a/drivers/gpu/nvgpu/gk20a/hw_therm_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/hw_therm_gk20a.h
@@ -54,18 +54,66 @@ static inline u32 therm_use_a_r(void)
54{ 54{
55 return 0x00020798; 55 return 0x00020798;
56} 56}
57static inline u32 therm_use_a_ext_therm_0_enable_f(void)
58{
59 return 0x1;
60}
61static inline u32 therm_use_a_ext_therm_1_enable_f(void)
62{
63 return 0x2;
64}
65static inline u32 therm_use_a_ext_therm_2_enable_f(void)
66{
67 return 0x4;
68}
57static inline u32 therm_evt_ext_therm_0_r(void) 69static inline u32 therm_evt_ext_therm_0_r(void)
58{ 70{
59 return 0x00020700; 71 return 0x00020700;
60} 72}
73static inline u32 therm_evt_ext_therm_0_slow_factor_f(u32 v)
74{
75 return (v & 0x3f) << 8;
76}
77static inline u32 therm_evt_ext_therm_0_slow_factor_init_v(void)
78{
79 return 0x00000000;
80}
81static inline u32 therm_evt_ext_therm_0_priority_f(u32 v)
82{
83 return (v & 0x1f) << 24;
84}
61static inline u32 therm_evt_ext_therm_1_r(void) 85static inline u32 therm_evt_ext_therm_1_r(void)
62{ 86{
63 return 0x00020704; 87 return 0x00020704;
64} 88}
89static inline u32 therm_evt_ext_therm_1_slow_factor_f(u32 v)
90{
91 return (v & 0x3f) << 8;
92}
93static inline u32 therm_evt_ext_therm_1_slow_factor_init_v(void)
94{
95 return 0x00000000;
96}
97static inline u32 therm_evt_ext_therm_1_priority_f(u32 v)
98{
99 return (v & 0x1f) << 24;
100}
65static inline u32 therm_evt_ext_therm_2_r(void) 101static inline u32 therm_evt_ext_therm_2_r(void)
66{ 102{
67 return 0x00020708; 103 return 0x00020708;
68} 104}
105static inline u32 therm_evt_ext_therm_2_slow_factor_f(u32 v)
106{
107 return (v & 0x3f) << 8;
108}
109static inline u32 therm_evt_ext_therm_2_slow_factor_init_v(void)
110{
111 return 0x00000000;
112}
113static inline u32 therm_evt_ext_therm_2_priority_f(u32 v)
114{
115 return (v & 0x1f) << 24;
116}
69static inline u32 therm_weight_1_r(void) 117static inline u32 therm_weight_1_r(void)
70{ 118{
71 return 0x00020024; 119 return 0x00020024;
diff --git a/drivers/gpu/nvgpu/gk20a/therm_gk20a.c b/drivers/gpu/nvgpu/gk20a/therm_gk20a.c
index fd4149ae..1c1b8419 100644
--- a/drivers/gpu/nvgpu/gk20a/therm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/therm_gk20a.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * GK20A Therm 4 * GK20A Therm
5 * 5 *
6 * Copyright (c) 2011-2014, NVIDIA CORPORATION. All rights reserved. 6 * Copyright (c) 2011-2015, NVIDIA CORPORATION. All rights reserved.
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License, 9 * under the terms and conditions of the GNU General Public License,
@@ -38,13 +38,20 @@ static int gk20a_init_therm_setup_hw(struct gk20a *g)
38 u32 v; 38 u32 v;
39 39
40 /* program NV_THERM registers */ 40 /* program NV_THERM registers */
41 gk20a_writel(g, therm_use_a_r(), NV_THERM_USE_A_INIT); 41 gk20a_writel(g, therm_use_a_r(), therm_use_a_ext_therm_0_enable_f() |
42 therm_use_a_ext_therm_1_enable_f() |
43 therm_use_a_ext_therm_2_enable_f());
44 /* priority for EXT_THERM_0 event set to highest */
42 gk20a_writel(g, therm_evt_ext_therm_0_r(), 45 gk20a_writel(g, therm_evt_ext_therm_0_r(),
43 NV_THERM_EVT_EXT_THERM_0_INIT); 46 therm_evt_ext_therm_0_slow_factor_f(1) |
47 therm_evt_ext_therm_0_priority_f(3));
44 gk20a_writel(g, therm_evt_ext_therm_1_r(), 48 gk20a_writel(g, therm_evt_ext_therm_1_r(),
45 NV_THERM_EVT_EXT_THERM_1_INIT); 49 therm_evt_ext_therm_1_slow_factor_f(2) |
50 therm_evt_ext_therm_1_priority_f(2));
46 gk20a_writel(g, therm_evt_ext_therm_2_r(), 51 gk20a_writel(g, therm_evt_ext_therm_2_r(),
47 NV_THERM_EVT_EXT_THERM_2_INIT); 52 therm_evt_ext_therm_2_slow_factor_f(3) |
53 therm_evt_ext_therm_2_priority_f(1));
54
48 55
49 gk20a_writel(g, therm_grad_stepping_table_r(0), 56 gk20a_writel(g, therm_grad_stepping_table_r(0),
50 therm_grad_stepping_table_slowdown_factor0_f(therm_grad_stepping_table_slowdown_factor0_fpdiv_by1p5_f()) | 57 therm_grad_stepping_table_slowdown_factor0_f(therm_grad_stepping_table_slowdown_factor0_fpdiv_by1p5_f()) |
@@ -92,9 +99,15 @@ int gk20a_init_therm_support(struct gk20a *g)
92 if (err) 99 if (err)
93 return err; 100 return err;
94 101
95 err = gk20a_init_therm_setup_hw(g); 102 if (g->ops.therm.init_therm_setup_hw)
103 err = g->ops.therm.init_therm_setup_hw(g);
96 if (err) 104 if (err)
97 return err; 105 return err;
98 106
99 return err; 107 return err;
100} 108}
109
110void gk20a_init_therm_ops(struct gpu_ops *gops)
111{
112 gops->therm.init_therm_setup_hw = gk20a_init_therm_setup_hw;
113}
diff --git a/drivers/gpu/nvgpu/gk20a/therm_gk20a.h b/drivers/gpu/nvgpu/gk20a/therm_gk20a.h
index e670ec0e..80671d68 100644
--- a/drivers/gpu/nvgpu/gk20a/therm_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/therm_gk20a.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2011 - 2014, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2011 - 2015, NVIDIA CORPORATION. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 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, 5 * under the terms and conditions of the GNU General Public License,
@@ -16,13 +16,8 @@
16#ifndef THERM_GK20A_H 16#ifndef THERM_GK20A_H
17#define THERM_GK20A_H 17#define THERM_GK20A_H
18 18
19/* priority for EXT_THERM_0 event set to highest */ 19struct gpu_ops;
20#define NV_THERM_EVT_EXT_THERM_0_INIT 0x3000100 20void gk20a_init_therm_ops(struct gpu_ops *gops);
21#define NV_THERM_EVT_EXT_THERM_1_INIT 0x2000200
22#define NV_THERM_EVT_EXT_THERM_2_INIT 0x1000300
23/* configures the thermal events that may cause clock slowdown */
24#define NV_THERM_USE_A_INIT 0x7
25 21
26int gk20a_init_therm_support(struct gk20a *g); 22int gk20a_init_therm_support(struct gk20a *g);
27
28#endif /* THERM_GK20A_H */ 23#endif /* THERM_GK20A_H */
diff --git a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c
index e57ef7ec..5fe01833 100644
--- a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c
@@ -33,6 +33,7 @@
33#include "regops_gm20b.h" 33#include "regops_gm20b.h"
34#include "debug_gm20b.h" 34#include "debug_gm20b.h"
35#include "cde_gm20b.h" 35#include "cde_gm20b.h"
36#include "therm_gm20b.h"
36 37
37#define FUSE_OPT_PRIV_SEC_DIS_0 0x264 38#define FUSE_OPT_PRIV_SEC_DIS_0 0x264
38#define PRIV_SECURITY_DISABLE 0x01 39#define PRIV_SECURITY_DISABLE 0x01
@@ -136,6 +137,7 @@ int gm20b_init_hal(struct gk20a *g)
136 gm20b_init_regops(gops); 137 gm20b_init_regops(gops);
137 gm20b_init_debug_ops(gops); 138 gm20b_init_debug_ops(gops);
138 gm20b_init_cde_ops(gops); 139 gm20b_init_cde_ops(gops);
140 gm20b_init_therm_ops(gops);
139 gops->name = "gm20b"; 141 gops->name = "gm20b";
140 142
141 c->twod_class = FERMI_TWOD_A; 143 c->twod_class = FERMI_TWOD_A;
diff --git a/drivers/gpu/nvgpu/gm20b/hw_therm_gm20b.h b/drivers/gpu/nvgpu/gm20b/hw_therm_gm20b.h
index 9943cf31..5a696409 100644
--- a/drivers/gpu/nvgpu/gm20b/hw_therm_gm20b.h
+++ b/drivers/gpu/nvgpu/gm20b/hw_therm_gm20b.h
@@ -54,18 +54,54 @@ static inline u32 therm_use_a_r(void)
54{ 54{
55 return 0x00020798; 55 return 0x00020798;
56} 56}
57static inline u32 therm_use_a_ext_therm_0_enable_f(void)
58{
59 return 0x1;
60}
61static inline u32 therm_use_a_ext_therm_1_enable_f(void)
62{
63 return 0x2;
64}
65static inline u32 therm_use_a_ext_therm_2_enable_f(void)
66{
67 return 0x4;
68}
57static inline u32 therm_evt_ext_therm_0_r(void) 69static inline u32 therm_evt_ext_therm_0_r(void)
58{ 70{
59 return 0x00020700; 71 return 0x00020700;
60} 72}
73static inline u32 therm_evt_ext_therm_0_slow_factor_f(u32 v)
74{
75 return (v & 0x3f) << 8;
76}
77static inline u32 therm_evt_ext_therm_0_slow_factor_init_v(void)
78{
79 return 0x00000000;
80}
61static inline u32 therm_evt_ext_therm_1_r(void) 81static inline u32 therm_evt_ext_therm_1_r(void)
62{ 82{
63 return 0x00020704; 83 return 0x00020704;
64} 84}
85static inline u32 therm_evt_ext_therm_1_slow_factor_f(u32 v)
86{
87 return (v & 0x3f) << 8;
88}
89static inline u32 therm_evt_ext_therm_1_slow_factor_init_v(void)
90{
91 return 0x00000000;
92}
65static inline u32 therm_evt_ext_therm_2_r(void) 93static inline u32 therm_evt_ext_therm_2_r(void)
66{ 94{
67 return 0x00020708; 95 return 0x00020708;
68} 96}
97static inline u32 therm_evt_ext_therm_2_slow_factor_f(u32 v)
98{
99 return (v & 0x3f) << 8;
100}
101static inline u32 therm_evt_ext_therm_2_slow_factor_init_v(void)
102{
103 return 0x00000000;
104}
69static inline u32 therm_weight_1_r(void) 105static inline u32 therm_weight_1_r(void)
70{ 106{
71 return 0x00020024; 107 return 0x00020024;
diff --git a/drivers/gpu/nvgpu/gm20b/therm_gm20b.c b/drivers/gpu/nvgpu/gm20b/therm_gm20b.c
new file mode 100644
index 00000000..ed1e0f49
--- /dev/null
+++ b/drivers/gpu/nvgpu/gm20b/therm_gm20b.c
@@ -0,0 +1,72 @@
1/*
2 * GM20B THERMAL
3 *
4 * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include "gk20a/gk20a.h"
17#include "hw_therm_gm20b.h"
18
19static int gm20b_init_therm_setup_hw(struct gk20a *g)
20{
21 u32 v;
22
23 gk20a_dbg_fn("");
24
25 /* program NV_THERM registers */
26 gk20a_writel(g, therm_use_a_r(), therm_use_a_ext_therm_0_enable_f() |
27 therm_use_a_ext_therm_1_enable_f() |
28 therm_use_a_ext_therm_2_enable_f());
29 gk20a_writel(g, therm_evt_ext_therm_0_r(),
30 therm_evt_ext_therm_0_slow_factor_f(1));
31 gk20a_writel(g, therm_evt_ext_therm_1_r(),
32 therm_evt_ext_therm_1_slow_factor_f(2));
33 gk20a_writel(g, therm_evt_ext_therm_2_r(),
34 therm_evt_ext_therm_2_slow_factor_f(3));
35
36 gk20a_writel(g, therm_grad_stepping_table_r(0),
37 therm_grad_stepping_table_slowdown_factor0_f(therm_grad_stepping_table_slowdown_factor0_fpdiv_by1p5_f()) |
38 therm_grad_stepping_table_slowdown_factor1_f(therm_grad_stepping_table_slowdown_factor0_fpdiv_by2_f()) |
39 therm_grad_stepping_table_slowdown_factor2_f(therm_grad_stepping_table_slowdown_factor0_fpdiv_by4_f()) |
40 therm_grad_stepping_table_slowdown_factor3_f(therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()) |
41 therm_grad_stepping_table_slowdown_factor4_f(therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()));
42 gk20a_writel(g, therm_grad_stepping_table_r(1),
43 therm_grad_stepping_table_slowdown_factor0_f(therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()) |
44 therm_grad_stepping_table_slowdown_factor1_f(therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()) |
45 therm_grad_stepping_table_slowdown_factor2_f(therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()) |
46 therm_grad_stepping_table_slowdown_factor3_f(therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()) |
47 therm_grad_stepping_table_slowdown_factor4_f(therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()));
48
49 v = gk20a_readl(g, therm_clk_timing_r(0));
50 v |= therm_clk_timing_grad_slowdown_enabled_f();
51 gk20a_writel(g, therm_clk_timing_r(0), v);
52
53 v = gk20a_readl(g, therm_config2_r());
54 v |= therm_config2_grad_enable_f(1);
55 v |= therm_config2_slowdown_factor_extended_f(1);
56 gk20a_writel(g, therm_config2_r(), v);
57
58 gk20a_writel(g, therm_grad_stepping1_r(),
59 therm_grad_stepping1_pdiv_duration_f(32));
60
61 v = gk20a_readl(g, therm_grad_stepping0_r());
62 v |= therm_grad_stepping0_feature_enable_f();
63 gk20a_writel(g, therm_grad_stepping0_r(), v);
64
65 return 0;
66}
67
68void gm20b_init_therm_ops(struct gpu_ops *gops)
69{
70 gops->therm.init_therm_setup_hw = gm20b_init_therm_setup_hw;
71
72}
diff --git a/drivers/gpu/nvgpu/gm20b/therm_gm20b.h b/drivers/gpu/nvgpu/gm20b/therm_gm20b.h
new file mode 100644
index 00000000..c346c4f2
--- /dev/null
+++ b/drivers/gpu/nvgpu/gm20b/therm_gm20b.h
@@ -0,0 +1,21 @@
1/*
2 * GM20B THERMAL
3 *
4 * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef THERM_GM20B_H
16#define THERM_GM20B_H
17
18struct gpu_ops;
19void gm20b_init_therm_ops(struct gpu_ops *gops);
20
21#endif /* THERM_GM20B_H */