diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/platform_gk20a.h')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/platform_gk20a.h | 293 |
1 files changed, 293 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/platform_gk20a.h b/drivers/gpu/nvgpu/common/linux/platform_gk20a.h new file mode 100644 index 00000000..47ada890 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/platform_gk20a.h | |||
@@ -0,0 +1,293 @@ | |||
1 | /* | ||
2 | * GK20A Platform (SoC) Interface | ||
3 | * | ||
4 | * Copyright (c) 2014-2017, 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 | #ifndef _GK20A_PLATFORM_H_ | ||
17 | #define _GK20A_PLATFORM_H_ | ||
18 | |||
19 | #include <linux/device.h> | ||
20 | |||
21 | #include <nvgpu/lock.h> | ||
22 | |||
23 | #include "gk20a/gk20a.h" | ||
24 | |||
25 | #define GK20A_CLKS_MAX 4 | ||
26 | |||
27 | struct gk20a; | ||
28 | struct channel_gk20a; | ||
29 | struct gr_ctx_buffer_desc; | ||
30 | struct gk20a_scale_profile; | ||
31 | |||
32 | struct secure_page_buffer { | ||
33 | void (*destroy)(struct gk20a *, struct secure_page_buffer *); | ||
34 | size_t size; | ||
35 | u64 iova; | ||
36 | }; | ||
37 | |||
38 | struct gk20a_platform { | ||
39 | /* Populated by the gk20a driver before probing the platform. */ | ||
40 | struct gk20a *g; | ||
41 | |||
42 | /* Should be populated at probe. */ | ||
43 | bool can_railgate_init; | ||
44 | |||
45 | /* Should be populated at probe. */ | ||
46 | bool can_elpg_init; | ||
47 | |||
48 | /* Should be populated at probe. */ | ||
49 | bool has_syncpoints; | ||
50 | |||
51 | /* channel limit after which to start aggressive sync destroy */ | ||
52 | unsigned int aggressive_sync_destroy_thresh; | ||
53 | |||
54 | /* flag to set sync destroy aggressiveness */ | ||
55 | bool aggressive_sync_destroy; | ||
56 | |||
57 | /* set if ASPM should be disabled on boot; only makes sense for PCI */ | ||
58 | bool disable_aspm; | ||
59 | |||
60 | /* Set if the platform can unify the small/large address spaces. */ | ||
61 | bool unify_address_spaces; | ||
62 | |||
63 | /* Clock configuration is stored here. Platform probe is responsible | ||
64 | * for filling this data. */ | ||
65 | struct clk *clk[GK20A_CLKS_MAX]; | ||
66 | int num_clks; | ||
67 | |||
68 | #ifdef CONFIG_RESET_CONTROLLER | ||
69 | /* Reset control for device */ | ||
70 | struct reset_control *reset_control; | ||
71 | #endif | ||
72 | |||
73 | /* Delay before rail gated */ | ||
74 | int railgate_delay_init; | ||
75 | |||
76 | /* Second Level Clock Gating: true = enable false = disable */ | ||
77 | bool enable_slcg; | ||
78 | |||
79 | /* Block Level Clock Gating: true = enable flase = disable */ | ||
80 | bool enable_blcg; | ||
81 | |||
82 | /* Engine Level Clock Gating: true = enable flase = disable */ | ||
83 | bool enable_elcg; | ||
84 | |||
85 | /* Should be populated at probe. */ | ||
86 | bool can_slcg; | ||
87 | |||
88 | /* Should be populated at probe. */ | ||
89 | bool can_blcg; | ||
90 | |||
91 | /* Should be populated at probe. */ | ||
92 | bool can_elcg; | ||
93 | |||
94 | /* Engine Level Power Gating: true = enable flase = disable */ | ||
95 | bool enable_elpg; | ||
96 | |||
97 | /* Adaptative ELPG: true = enable flase = disable */ | ||
98 | bool enable_aelpg; | ||
99 | |||
100 | /* PMU Perfmon: true = enable false = disable */ | ||
101 | bool enable_perfmon; | ||
102 | |||
103 | /* Memory System Clock Gating: true = enable flase = disable*/ | ||
104 | bool enable_mscg; | ||
105 | |||
106 | /* Timeout for per-channel watchdog (in mS) */ | ||
107 | u32 ch_wdt_timeout_ms; | ||
108 | |||
109 | /* Enable SMMU bypass by default */ | ||
110 | bool bypass_smmu; | ||
111 | |||
112 | /* Disable big page support */ | ||
113 | bool disable_bigpage; | ||
114 | |||
115 | /* | ||
116 | * gk20a_do_idle() API can take GPU either into rail gate or CAR reset | ||
117 | * This flag can be used to force CAR reset case instead of rail gate | ||
118 | */ | ||
119 | bool force_reset_in_do_idle; | ||
120 | |||
121 | /* default pri timeout, on PCIe it should be lower than timeout | ||
122 | * detection | ||
123 | */ | ||
124 | u32 default_pri_timeout; | ||
125 | |||
126 | /* Initialize the platform interface of the gk20a driver. | ||
127 | * | ||
128 | * The platform implementation of this function must | ||
129 | * - set the power and clocks of the gk20a device to a known | ||
130 | * state, and | ||
131 | * - populate the gk20a_platform structure (a pointer to the | ||
132 | * structure can be obtained by calling gk20a_get_platform). | ||
133 | * | ||
134 | * After this function is finished, the driver will initialise | ||
135 | * pm runtime and genpd based on the platform configuration. | ||
136 | */ | ||
137 | int (*probe)(struct device *dev); | ||
138 | |||
139 | /* Second stage initialisation - called once all power management | ||
140 | * initialisations are done. | ||
141 | */ | ||
142 | int (*late_probe)(struct device *dev); | ||
143 | |||
144 | /* Remove device after power management has been done | ||
145 | */ | ||
146 | int (*remove)(struct device *dev); | ||
147 | |||
148 | /* Poweron platform dependencies */ | ||
149 | int (*busy)(struct device *dev); | ||
150 | |||
151 | /* Powerdown platform dependencies */ | ||
152 | void (*idle)(struct device *dev); | ||
153 | |||
154 | struct secure_page_buffer secure_buffer; | ||
155 | |||
156 | /* Device is going to be suspended */ | ||
157 | int (*suspend)(struct device *); | ||
158 | |||
159 | /* Called to turn off the device */ | ||
160 | int (*railgate)(struct device *dev); | ||
161 | |||
162 | /* Called to turn on the device */ | ||
163 | int (*unrailgate)(struct device *dev); | ||
164 | struct nvgpu_mutex railgate_lock; | ||
165 | |||
166 | /* Called to check state of device */ | ||
167 | bool (*is_railgated)(struct device *dev); | ||
168 | |||
169 | /* get supported frequency list */ | ||
170 | int (*get_clk_freqs)(struct device *pdev, | ||
171 | unsigned long **freqs, int *num_freqs); | ||
172 | |||
173 | /* clk related supported functions */ | ||
174 | long (*clk_round_rate)(struct device *dev, | ||
175 | unsigned long rate); | ||
176 | |||
177 | /* Called to register GPCPLL with common clk framework */ | ||
178 | int (*clk_register)(struct gk20a *g); | ||
179 | |||
180 | /* Postscale callback is called after frequency change */ | ||
181 | void (*postscale)(struct device *dev, | ||
182 | unsigned long freq); | ||
183 | |||
184 | /* Pre callback is called before frequency change */ | ||
185 | void (*prescale)(struct device *dev); | ||
186 | |||
187 | /* Devfreq governor name. If scaling is enabled, we request | ||
188 | * this governor to be used in scaling */ | ||
189 | const char *devfreq_governor; | ||
190 | |||
191 | /* Quality of service notifier callback. If this is set, the scaling | ||
192 | * routines will register a callback to Qos. Each time we receive | ||
193 | * a new value, this callback gets called. */ | ||
194 | int (*qos_notify)(struct notifier_block *nb, | ||
195 | unsigned long n, void *p); | ||
196 | |||
197 | /* Called as part of debug dump. If the gpu gets hung, this function | ||
198 | * is responsible for delivering all necessary debug data of other | ||
199 | * hw units which may interact with the gpu without direct supervision | ||
200 | * of the CPU. | ||
201 | */ | ||
202 | void (*dump_platform_dependencies)(struct device *dev); | ||
203 | |||
204 | /* Callbacks to assert/deassert GPU reset */ | ||
205 | int (*reset_assert)(struct device *dev); | ||
206 | int (*reset_deassert)(struct device *dev); | ||
207 | struct clk *clk_reset; | ||
208 | struct dvfs_rail *gpu_rail; | ||
209 | |||
210 | bool virtual_dev; | ||
211 | #ifdef CONFIG_TEGRA_GR_VIRTUALIZATION | ||
212 | void *vgpu_priv; | ||
213 | #endif | ||
214 | /* source frequency for ptimer in hz */ | ||
215 | u32 ptimer_src_freq; | ||
216 | |||
217 | bool has_cde; | ||
218 | |||
219 | /* soc name for finding firmware files */ | ||
220 | const char *soc_name; | ||
221 | |||
222 | /* false if vidmem aperture actually points to sysmem */ | ||
223 | bool honors_aperture; | ||
224 | /* unified or split memory with separate vidmem? */ | ||
225 | bool unified_memory; | ||
226 | |||
227 | /* true if all channels must be in TSG */ | ||
228 | bool tsg_required; | ||
229 | |||
230 | /* minimum supported VBIOS version */ | ||
231 | u32 vbios_min_version; | ||
232 | |||
233 | /* true if we run preos microcode on this board */ | ||
234 | bool run_preos; | ||
235 | |||
236 | /* true if we need to program sw threshold for | ||
237 | * power limits | ||
238 | */ | ||
239 | bool hardcode_sw_threshold; | ||
240 | |||
241 | /* i2c device index, port and address for INA3221 */ | ||
242 | u32 ina3221_dcb_index; | ||
243 | u32 ina3221_i2c_address; | ||
244 | u32 ina3221_i2c_port; | ||
245 | }; | ||
246 | |||
247 | static inline struct gk20a_platform *gk20a_get_platform( | ||
248 | struct device *dev) | ||
249 | { | ||
250 | return (struct gk20a_platform *)dev_get_drvdata(dev); | ||
251 | } | ||
252 | |||
253 | #ifdef CONFIG_TEGRA_GK20A | ||
254 | extern struct gk20a_platform gm20b_tegra_platform; | ||
255 | extern struct gk20a_platform gp10b_tegra_platform; | ||
256 | #ifdef CONFIG_TEGRA_GR_VIRTUALIZATION | ||
257 | extern struct gk20a_platform vgpu_tegra_platform; | ||
258 | #endif | ||
259 | #endif | ||
260 | |||
261 | int gk20a_tegra_busy(struct device *dev); | ||
262 | void gk20a_tegra_idle(struct device *dev); | ||
263 | void gk20a_tegra_debug_dump(struct device *pdev); | ||
264 | |||
265 | static inline struct gk20a *get_gk20a(struct device *dev) | ||
266 | { | ||
267 | return gk20a_get_platform(dev)->g; | ||
268 | } | ||
269 | static inline struct gk20a *gk20a_from_dev(struct device *dev) | ||
270 | { | ||
271 | if (!dev) | ||
272 | return NULL; | ||
273 | |||
274 | return ((struct gk20a_platform *)dev_get_drvdata(dev))->g; | ||
275 | } | ||
276 | static inline bool gk20a_gpu_is_virtual(struct device *dev) | ||
277 | { | ||
278 | struct gk20a_platform *platform = dev_get_drvdata(dev); | ||
279 | |||
280 | return platform->virtual_dev; | ||
281 | } | ||
282 | |||
283 | static inline int support_gk20a_pmu(struct device *dev) | ||
284 | { | ||
285 | if (IS_ENABLED(CONFIG_GK20A_PMU)) { | ||
286 | /* gPMU is not supported for vgpu */ | ||
287 | return !gk20a_gpu_is_virtual(dev); | ||
288 | } | ||
289 | |||
290 | return 0; | ||
291 | } | ||
292 | |||
293 | #endif | ||