summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2016-03-30 17:03:35 -0400
committerDeepak Nibade <dnibade@nvidia.com>2016-12-27 04:52:11 -0500
commitfce01666d57c9c76c21d4ac31adc225a2a6c2e42 (patch)
treeebddef3f3e9ed0c04535535c793c44132ea847e7 /drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c
parentbd688d31ce7df4a2d9134a521fa4c4f5eba06c2d (diff)
gpu: nvgpu: Use device instead of platform_device
Use struct device instead of struct platform_device wherever possible. This allows adding other bus types later. Change-Id: I90623c020919ca8e2e5b31d53914c324d2dc6af9 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/1120464
Diffstat (limited to 'drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c')
-rw-r--r--drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c101
1 files changed, 47 insertions, 54 deletions
diff --git a/drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c
index 6cb89cae..7d8312fc 100644
--- a/drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c
+++ b/drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c
@@ -1,7 +1,5 @@
1/* 1/*
2 * drivers/video/tegra/host/gk20a/platform_gk20a_tegra.c 2 * GP10B Tegra Platform Interface
3 *
4 * GK20A Tegra Platform Interface
5 * 3 *
6 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
7 * 5 *
@@ -62,11 +60,9 @@ static void gr_gp10b_remove_sysfs(struct device *dev);
62 * the clock information to gp10b platform data. 60 * the clock information to gp10b platform data.
63 */ 61 */
64 62
65static int gp10b_tegra_get_clocks(struct platform_device *pdev) 63static int gp10b_tegra_get_clocks(struct device *dev)
66{ 64{
67 struct gk20a_platform *platform = platform_get_drvdata(pdev); 65 struct gk20a_platform *platform = dev_get_drvdata(dev);
68 struct gk20a *g = get_gk20a(pdev);
69 struct device *dev = dev_from_gk20a(g);
70 int i; 66 int i;
71 67
72 if (tegra_platform_is_linsim()) 68 if (tegra_platform_is_linsim())
@@ -79,7 +75,7 @@ static int gp10b_tegra_get_clocks(struct platform_device *pdev)
79 75
80 c = clk_get(dev, tegra_gp10b_clocks[i].name); 76 c = clk_get(dev, tegra_gp10b_clocks[i].name);
81 if (IS_ERR(c)) { 77 if (IS_ERR(c)) {
82 gk20a_err(&pdev->dev, "cannot get clock %s", 78 gk20a_err(dev, "cannot get clock %s",
83 tegra_gp10b_clocks[i].name); 79 tegra_gp10b_clocks[i].name);
84 } else { 80 } else {
85 clk_set_rate(c, rate); 81 clk_set_rate(c, rate);
@@ -91,9 +87,9 @@ static int gp10b_tegra_get_clocks(struct platform_device *pdev)
91 return 0; 87 return 0;
92} 88}
93 89
94static void gp10b_tegra_scale_init(struct platform_device *pdev) 90static void gp10b_tegra_scale_init(struct device *dev)
95{ 91{
96 struct gk20a_platform *platform = gk20a_get_platform(pdev); 92 struct gk20a_platform *platform = gk20a_get_platform(dev);
97 struct gk20a_scale_profile *profile = platform->g->scale_profile; 93 struct gk20a_scale_profile *profile = platform->g->scale_profile;
98 struct tegra_bwmgr_client *bwmgr_handle; 94 struct tegra_bwmgr_client *bwmgr_handle;
99 95
@@ -104,9 +100,9 @@ static void gp10b_tegra_scale_init(struct platform_device *pdev)
104 profile->private_data = (void *)bwmgr_handle; 100 profile->private_data = (void *)bwmgr_handle;
105} 101}
106 102
107static void gp10b_tegra_scale_exit(struct platform_device *pdev) 103static void gp10b_tegra_scale_exit(struct device *dev)
108{ 104{
109 struct gk20a_platform *platform = gk20a_get_platform(pdev); 105 struct gk20a_platform *platform = gk20a_get_platform(dev);
110 struct gk20a_scale_profile *profile = platform->g->scale_profile; 106 struct gk20a_scale_profile *profile = platform->g->scale_profile;
111 107
112 if (profile) 108 if (profile)
@@ -114,30 +110,29 @@ static void gp10b_tegra_scale_exit(struct platform_device *pdev)
114 (struct tegra_bwmgr_client *)profile->private_data); 110 (struct tegra_bwmgr_client *)profile->private_data);
115} 111}
116 112
117 113static int gp10b_tegra_probe(struct device *dev)
118static int gp10b_tegra_probe(struct platform_device *pdev)
119{ 114{
120 struct gk20a_platform *platform = gk20a_get_platform(pdev); 115 struct gk20a_platform *platform = dev_get_drvdata(dev);
121 struct device_node *np = pdev->dev.of_node; 116 struct device_node *np = dev->of_node;
122 struct device_node *host1x_node; 117 struct device_node *host1x_node;
123 struct platform_device *host1x_pdev; 118 struct platform_device *host1x_pdev;
124 const __be32 *host1x_ptr; 119 const __be32 *host1x_ptr;
125 120
126 host1x_ptr = of_get_property(np, "nvidia,host1x", NULL); 121 host1x_ptr = of_get_property(np, "nvidia,host1x", NULL);
127 if (!host1x_ptr) { 122 if (!host1x_ptr) {
128 gk20a_err(&pdev->dev, "host1x device not available"); 123 gk20a_err(dev, "host1x device not available");
129 return -ENOSYS; 124 return -ENOSYS;
130 } 125 }
131 126
132 host1x_node = of_find_node_by_phandle(be32_to_cpup(host1x_ptr)); 127 host1x_node = of_find_node_by_phandle(be32_to_cpup(host1x_ptr));
133 host1x_pdev = of_find_device_by_node(host1x_node); 128 host1x_pdev = of_find_device_by_node(host1x_node);
134 if (!host1x_pdev) { 129 if (!host1x_pdev) {
135 gk20a_err(&pdev->dev, "host1x device not available"); 130 gk20a_err(dev, "host1x device not available");
136 return -ENOSYS; 131 return -ENOSYS;
137 } 132 }
138 133
139 platform->g->host1x_dev = host1x_pdev; 134 platform->g->host1x_dev = host1x_pdev;
140 platform->bypass_smmu = !device_is_iommuable(&pdev->dev); 135 platform->bypass_smmu = !device_is_iommuable(dev);
141 platform->disable_bigpage = platform->bypass_smmu; 136 platform->disable_bigpage = platform->bypass_smmu;
142 137
143 platform->g->gr.t18x.ctx_vars.dump_ctxsw_stats_on_channel_close 138 platform->g->gr.t18x.ctx_vars.dump_ctxsw_stats_on_channel_close
@@ -165,39 +160,39 @@ static int gp10b_tegra_probe(struct platform_device *pdev)
165 &platform->g->gr.t18x. 160 &platform->g->gr.t18x.
166 ctx_vars.dump_ctxsw_stats_on_channel_close); 161 ctx_vars.dump_ctxsw_stats_on_channel_close);
167 162
168 gp10b_tegra_get_clocks(pdev); 163 gp10b_tegra_get_clocks(dev);
169 164
170 return 0; 165 return 0;
171} 166}
172 167
173static int gp10b_tegra_late_probe(struct platform_device *pdev) 168static int gp10b_tegra_late_probe(struct device *dev)
174{ 169{
175 /* Make gk20a power domain a subdomain of host1x */ 170 /* Make gk20a power domain a subdomain of host1x */
176 nvhost_register_client_domain(dev_to_genpd(&pdev->dev)); 171 nvhost_register_client_domain(dev_to_genpd(dev));
177 /*Create GP10B specific sysfs*/ 172 /*Create GP10B specific sysfs*/
178 gp10b_create_sysfs(pdev); 173 gp10b_create_sysfs(dev);
179 174
180 /* Initialise tegra specific scaling quirks */ 175 /* Initialise tegra specific scaling quirks */
181 gp10b_tegra_scale_init(pdev); 176 gp10b_tegra_scale_init(dev);
182 return 0; 177 return 0;
183} 178}
184 179
185static int gp10b_tegra_remove(struct platform_device *pdev) 180static int gp10b_tegra_remove(struct device *dev)
186{ 181{
187 /* remove gk20a power subdomain from host1x */ 182 /* remove gk20a power subdomain from host1x */
188 nvhost_unregister_client_domain(dev_to_genpd(&pdev->dev)); 183 nvhost_unregister_client_domain(dev_to_genpd(dev));
189 gr_gp10b_remove_sysfs(&pdev->dev); 184 gr_gp10b_remove_sysfs(dev);
190 /*Remove GP10B specific sysfs*/ 185 /*Remove GP10B specific sysfs*/
191 gp10b_remove_sysfs(&pdev->dev); 186 gp10b_remove_sysfs(dev);
192 187
193 /* deinitialise tegra specific scaling quirks */ 188 /* deinitialise tegra specific scaling quirks */
194 gp10b_tegra_scale_exit(pdev); 189 gp10b_tegra_scale_exit(dev);
195 190
196 return 0; 191 return 0;
197 192
198} 193}
199 194
200static bool gp10b_tegra_is_railgated(struct platform_device *pdev) 195static bool gp10b_tegra_is_railgated(struct device *dev)
201{ 196{
202 bool ret = false; 197 bool ret = false;
203 198
@@ -207,9 +202,9 @@ static bool gp10b_tegra_is_railgated(struct platform_device *pdev)
207 return ret; 202 return ret;
208} 203}
209 204
210static int gp10b_tegra_railgate(struct platform_device *pdev) 205static int gp10b_tegra_railgate(struct device *dev)
211{ 206{
212 struct gk20a_platform *platform = gk20a_get_platform(pdev); 207 struct gk20a_platform *platform = gk20a_get_platform(dev);
213 208
214 if (tegra_bpmp_running() && 209 if (tegra_bpmp_running() &&
215 tegra_powergate_is_powered(TEGRA_POWERGATE_GPU)) { 210 tegra_powergate_is_powered(TEGRA_POWERGATE_GPU)) {
@@ -223,10 +218,10 @@ static int gp10b_tegra_railgate(struct platform_device *pdev)
223 return 0; 218 return 0;
224} 219}
225 220
226static int gp10b_tegra_unrailgate(struct platform_device *pdev) 221static int gp10b_tegra_unrailgate(struct device *dev)
227{ 222{
228 int ret = 0; 223 int ret = 0;
229 struct gk20a_platform *platform = gk20a_get_platform(pdev); 224 struct gk20a_platform *platform = gk20a_get_platform(dev);
230 225
231 if (tegra_bpmp_running()) { 226 if (tegra_bpmp_running()) {
232 int i; 227 int i;
@@ -244,7 +239,7 @@ static int gp10b_tegra_suspend(struct device *dev)
244 return 0; 239 return 0;
245} 240}
246 241
247static int gp10b_tegra_reset_assert(struct platform_device *dev) 242static int gp10b_tegra_reset_assert(struct device *dev)
248{ 243{
249 struct gk20a_platform *platform = gk20a_get_platform(dev); 244 struct gk20a_platform *platform = gk20a_get_platform(dev);
250 int ret = 0; 245 int ret = 0;
@@ -257,7 +252,7 @@ static int gp10b_tegra_reset_assert(struct platform_device *dev)
257 return ret; 252 return ret;
258} 253}
259 254
260static int gp10b_tegra_reset_deassert(struct platform_device *dev) 255static int gp10b_tegra_reset_deassert(struct device *dev)
261{ 256{
262 struct gk20a_platform *platform = gk20a_get_platform(dev); 257 struct gk20a_platform *platform = gk20a_get_platform(dev);
263 int ret = 0; 258 int ret = 0;
@@ -270,9 +265,9 @@ static int gp10b_tegra_reset_deassert(struct platform_device *dev)
270 return ret; 265 return ret;
271} 266}
272 267
273static void gp10b_tegra_prescale(struct platform_device *pdev) 268static void gp10b_tegra_prescale(struct device *dev)
274{ 269{
275 struct gk20a *g = get_gk20a(pdev); 270 struct gk20a *g = get_gk20a(dev);
276 u32 avg = 0; 271 u32 avg = 0;
277 272
278 gk20a_dbg_fn(""); 273 gk20a_dbg_fn("");
@@ -282,7 +277,7 @@ static void gp10b_tegra_prescale(struct platform_device *pdev)
282 gk20a_dbg_fn("done"); 277 gk20a_dbg_fn("done");
283} 278}
284 279
285static void gp10b_tegra_postscale(struct platform_device *pdev, 280static void gp10b_tegra_postscale(struct device *pdev,
286 unsigned long freq) 281 unsigned long freq)
287{ 282{
288 struct gk20a_platform *platform = gk20a_get_platform(pdev); 283 struct gk20a_platform *platform = gk20a_get_platform(pdev);
@@ -304,7 +299,7 @@ static void gp10b_tegra_postscale(struct platform_device *pdev,
304 gk20a_dbg_fn("done"); 299 gk20a_dbg_fn("done");
305} 300}
306 301
307static unsigned long gp10b_get_clk_rate(struct platform_device *dev) 302static unsigned long gp10b_get_clk_rate(struct device *dev)
308{ 303{
309 struct gk20a_platform *platform = gk20a_get_platform(dev); 304 struct gk20a_platform *platform = gk20a_get_platform(dev);
310 305
@@ -312,25 +307,24 @@ static unsigned long gp10b_get_clk_rate(struct platform_device *dev)
312 307
313} 308}
314 309
315static long gp10b_round_clk_rate(struct platform_device *dev, 310static long gp10b_round_clk_rate(struct device *dev, unsigned long rate)
316 unsigned long rate)
317{ 311{
318 struct gk20a_platform *platform = gk20a_get_platform(dev); 312 struct gk20a_platform *platform = gk20a_get_platform(dev);
319 313
320 return clk_round_rate(platform->clk[0], rate); 314 return clk_round_rate(platform->clk[0], rate);
321} 315}
322 316
323static int gp10b_set_clk_rate(struct platform_device *dev, unsigned long rate) 317static int gp10b_set_clk_rate(struct device *dev, unsigned long rate)
324{ 318{
325 struct gk20a_platform *platform = gk20a_get_platform(dev); 319 struct gk20a_platform *platform = gk20a_get_platform(dev);
326 320
327 return clk_set_rate(platform->clk[0], rate); 321 return clk_set_rate(platform->clk[0], rate);
328} 322}
329 323
330static int gp10b_clk_get_freqs(struct platform_device *pdev, 324static int gp10b_clk_get_freqs(struct device *dev,
331 unsigned long **freqs, int *num_freqs) 325 unsigned long **freqs, int *num_freqs)
332{ 326{
333 struct gk20a_platform *platform = gk20a_get_platform(pdev); 327 struct gk20a_platform *platform = gk20a_get_platform(dev);
334 unsigned long min_rate, max_rate, freq_step, rate; 328 unsigned long min_rate, max_rate, freq_step, rate;
335 int i; 329 int i;
336 330
@@ -408,6 +402,8 @@ struct gk20a_platform t18x_gpu_tegra_platform = {
408 .reset_deassert = gp10b_tegra_reset_deassert, 402 .reset_deassert = gp10b_tegra_reset_deassert,
409 403
410 .force_reset_in_do_idle = false, 404 .force_reset_in_do_idle = false,
405
406 .soc_name = "tegra18x",
411}; 407};
412 408
413 409
@@ -481,7 +477,7 @@ static ssize_t ecc_stat_show(struct device *dev,
481 return snprintf(buf, PAGE_SIZE, "Error: No ECC stat found!\n"); 477 return snprintf(buf, PAGE_SIZE, "Error: No ECC stat found!\n");
482} 478}
483 479
484static int ecc_stat_create(struct platform_device *dev, 480static int ecc_stat_create(struct device *dev,
485 int is_l2, 481 int is_l2,
486 char *ecc_stat_name, 482 char *ecc_stat_name,
487 struct ecc_stat *ecc_stat, 483 struct ecc_stat *ecc_stat,
@@ -526,8 +522,7 @@ static int ecc_stat_create(struct platform_device *dev,
526 dev_attr_array[hw_unit].store = NULL; 522 dev_attr_array[hw_unit].store = NULL;
527 523
528 /* Create sysfs file */ 524 /* Create sysfs file */
529 error |= device_create_file(&dev->dev, 525 error |= device_create_file(dev, &dev_attr_array[hw_unit]);
530 &dev_attr_array[hw_unit]);
531 } 526 }
532 527
533 /* Add hash table entry */ 528 /* Add hash table entry */
@@ -544,8 +539,7 @@ static void ecc_stat_remove(struct device *dev,
544 struct ecc_stat *ecc_stat, 539 struct ecc_stat *ecc_stat,
545 struct device_attribute *dev_attr_array) 540 struct device_attribute *dev_attr_array)
546{ 541{
547 struct platform_device *ndev = to_platform_device(dev); 542 struct gk20a *g = get_gk20a(dev);
548 struct gk20a *g = get_gk20a(ndev);
549 int num_hw_units = 0; 543 int num_hw_units = 0;
550 int hw_unit = 0; 544 int hw_unit = 0;
551 545
@@ -571,7 +565,7 @@ static void ecc_stat_remove(struct device *dev,
571 kfree(dev_attr_array); 565 kfree(dev_attr_array);
572} 566}
573 567
574void gr_gp10b_create_sysfs(struct platform_device *dev) 568void gr_gp10b_create_sysfs(struct device *dev)
575{ 569{
576 int error = 0; 570 int error = 0;
577 struct gk20a *g = get_gk20a(dev); 571 struct gk20a *g = get_gk20a(dev);
@@ -663,13 +657,12 @@ void gr_gp10b_create_sysfs(struct platform_device *dev)
663 dev_attr_l2_ecc_ded_count_array); 657 dev_attr_l2_ecc_ded_count_array);
664 658
665 if (error) 659 if (error)
666 dev_err(&dev->dev, "Failed to create sysfs attributes!\n"); 660 dev_err(dev, "Failed to create sysfs attributes!\n");
667} 661}
668 662
669static void gr_gp10b_remove_sysfs(struct device *dev) 663static void gr_gp10b_remove_sysfs(struct device *dev)
670{ 664{
671 struct platform_device *ndev = to_platform_device(dev); 665 struct gk20a *g = get_gk20a(dev);
672 struct gk20a *g = get_gk20a(ndev);
673 666
674 ecc_stat_remove(dev, 667 ecc_stat_remove(dev,
675 0, 668 0,