summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/gr_pri_gk20a.h
diff options
context:
space:
mode:
authorArto Merilainen <amerilainen@nvidia.com>2014-03-19 03:38:25 -0400
committerDan Willemsen <dwillemsen@nvidia.com>2015-03-18 15:08:53 -0400
commita9785995d5f22aaeb659285f8aeb64d8b56982e0 (patch)
treecc75f75bcf43db316a002a7a240b81f299bf6d7f /drivers/gpu/nvgpu/gk20a/gr_pri_gk20a.h
parent61efaf843c22b85424036ec98015121c08f5f16c (diff)
gpu: nvgpu: Add NVIDIA GPU Driver
This patch moves the NVIDIA GPU driver to a new location. Bug 1482562 Change-Id: I24293810b9d0f1504fd9be00135e21dad656ccb6 Signed-off-by: Arto Merilainen <amerilainen@nvidia.com> Reviewed-on: http://git-master/r/383722 Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gr_pri_gk20a.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_pri_gk20a.h179
1 files changed, 179 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gr_pri_gk20a.h b/drivers/gpu/nvgpu/gk20a/gr_pri_gk20a.h
new file mode 100644
index 00000000..a82a1ee7
--- /dev/null
+++ b/drivers/gpu/nvgpu/gk20a/gr_pri_gk20a.h
@@ -0,0 +1,179 @@
1/*
2 * GK20A Graphics Context Pri Register Addressing
3 *
4 * Copyright (c) 2013, 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 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef _NVHOST_GR_PRI_GK20A_H_
19#define _NVHOST_GR_PRI_GK20A_H_
20
21/*
22 * These convenience macros are generally for use in the management/modificaiton
23 * of the context state store for gr/compute contexts.
24 */
25
26/*
27 * GPC pri addressing
28 */
29static inline u32 pri_gpccs_addr_width(void)
30{
31 return 15; /*from where?*/
32}
33static inline u32 pri_gpccs_addr_mask(u32 addr)
34{
35 return addr & ((1 << pri_gpccs_addr_width()) - 1);
36}
37static inline u32 pri_gpc_addr(u32 addr, u32 gpc)
38{
39 return proj_gpc_base_v() + (gpc * proj_gpc_stride_v()) + addr;
40}
41static inline bool pri_is_gpc_addr_shared(u32 addr)
42{
43 return (addr >= proj_gpc_shared_base_v()) &&
44 (addr < proj_gpc_shared_base_v() + proj_gpc_stride_v());
45}
46static inline bool pri_is_gpc_addr(u32 addr)
47{
48 return ((addr >= proj_gpc_base_v()) &&
49 (addr < proj_gpc_base_v() +
50 proj_scal_litter_num_gpcs_v() * proj_gpc_stride_v())) ||
51 pri_is_gpc_addr_shared(addr);
52}
53static inline u32 pri_get_gpc_num(u32 addr)
54{
55 u32 i, start;
56 u32 num_gpcs = proj_scal_litter_num_gpcs_v();
57
58 for (i = 0; i < num_gpcs; i++) {
59 start = proj_gpc_base_v() + (i * proj_gpc_stride_v());
60 if ((addr >= start) && (addr < (start + proj_gpc_stride_v())))
61 return i;
62 }
63 return 0;
64}
65/*
66 * TPC pri addressing
67 */
68static inline u32 pri_tpccs_addr_width(void)
69{
70 return 11; /* from where? */
71}
72static inline u32 pri_tpccs_addr_mask(u32 addr)
73{
74 return addr & ((1 << pri_tpccs_addr_width()) - 1);
75}
76static inline u32 pri_tpc_addr(u32 addr, u32 gpc, u32 tpc)
77{
78 return proj_gpc_base_v() + (gpc * proj_gpc_stride_v()) +
79 proj_tpc_in_gpc_base_v() + (tpc * proj_tpc_in_gpc_stride_v()) +
80 addr;
81}
82static inline bool pri_is_tpc_addr_shared(u32 addr)
83{
84 return (addr >= proj_tpc_in_gpc_shared_base_v()) &&
85 (addr < (proj_tpc_in_gpc_shared_base_v() +
86 proj_tpc_in_gpc_stride_v()));
87}
88static inline bool pri_is_tpc_addr(u32 addr)
89{
90 return ((addr >= proj_tpc_in_gpc_base_v()) &&
91 (addr < proj_tpc_in_gpc_base_v() + (proj_scal_litter_num_tpc_per_gpc_v() *
92 proj_tpc_in_gpc_stride_v())))
93 ||
94 pri_is_tpc_addr_shared(addr);
95}
96static inline u32 pri_get_tpc_num(u32 addr)
97{
98 u32 i, start;
99 u32 num_tpcs = proj_scal_litter_num_tpc_per_gpc_v();
100
101 for (i = 0; i < num_tpcs; i++) {
102 start = proj_tpc_in_gpc_base_v() + (i * proj_tpc_in_gpc_stride_v());
103 if ((addr >= start) && (addr < (start + proj_tpc_in_gpc_stride_v())))
104 return i;
105 }
106 return 0;
107}
108
109/*
110 * BE pri addressing
111 */
112static inline u32 pri_becs_addr_width(void)
113{
114 return 10;/* from where? */
115}
116static inline u32 pri_becs_addr_mask(u32 addr)
117{
118 return addr & ((1 << pri_becs_addr_width()) - 1);
119}
120static inline bool pri_is_be_addr_shared(u32 addr)
121{
122 return (addr >= proj_rop_shared_base_v()) &&
123 (addr < proj_rop_shared_base_v() + proj_rop_stride_v());
124}
125static inline u32 pri_be_shared_addr(u32 addr)
126{
127 return proj_rop_shared_base_v() + pri_becs_addr_mask(addr);
128}
129static inline bool pri_is_be_addr(u32 addr)
130{
131 return ((addr >= proj_rop_base_v()) &&
132 (addr < proj_rop_base_v()+proj_scal_litter_num_fbps_v() * proj_rop_stride_v())) ||
133 pri_is_be_addr_shared(addr);
134}
135
136static inline u32 pri_get_be_num(u32 addr)
137{
138 u32 i, start;
139 u32 num_fbps = proj_scal_litter_num_fbps_v();
140 for (i = 0; i < num_fbps; i++) {
141 start = proj_rop_base_v() + (i * proj_rop_stride_v());
142 if ((addr >= start) && (addr < (start + proj_rop_stride_v())))
143 return i;
144 }
145 return 0;
146}
147
148/*
149 * PPC pri addressing
150 */
151static inline u32 pri_ppccs_addr_width(void)
152{
153 return 9; /* from where? */
154}
155static inline u32 pri_ppccs_addr_mask(u32 addr)
156{
157 return addr & ((1 << pri_ppccs_addr_width()) - 1);
158}
159static inline u32 pri_ppc_addr(u32 addr, u32 gpc, u32 ppc)
160{
161 return proj_gpc_base_v() + (gpc * proj_gpc_stride_v()) +
162 proj_ppc_in_gpc_base_v() + (ppc * proj_ppc_in_gpc_stride_v()) + addr;
163}
164
165enum ctxsw_addr_type {
166 CTXSW_ADDR_TYPE_SYS = 0,
167 CTXSW_ADDR_TYPE_GPC = 1,
168 CTXSW_ADDR_TYPE_TPC = 2,
169 CTXSW_ADDR_TYPE_BE = 3,
170 CTXSW_ADDR_TYPE_PPC = 4
171};
172
173#define PRI_BROADCAST_FLAGS_NONE 0
174#define PRI_BROADCAST_FLAGS_GPC BIT(0)
175#define PRI_BROADCAST_FLAGS_TPC BIT(1)
176#define PRI_BROADCAST_FLAGS_BE BIT(2)
177#define PRI_BROADCAST_FLAGS_PPC BIT(3)
178
179#endif /*_NVHOST_GR_PRI_GK20A_H_ */