summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/vgpu/vgpu.c
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2016-03-29 19:02:34 -0400
committerTerje Bergstrom <tbergstrom@nvidia.com>2016-04-08 12:42:41 -0400
commite8bac374c0ed24f05bf389e1e8b5aca47f61bd3a (patch)
tree36b6e111f8706c0560ee552bc9d6e15b87fc9621 /drivers/gpu/nvgpu/vgpu/vgpu.c
parent2382a8433fddaee3baecff6ae941944850787ab7 (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: I1657287a68d85a542cdbdd8a00d1902c3d6e00ed Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/1120466
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu/vgpu.c')
-rw-r--r--drivers/gpu/nvgpu/vgpu/vgpu.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c
index ab063c9b..b67f4d95 100644
--- a/drivers/gpu/nvgpu/vgpu/vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/vgpu.c
@@ -140,7 +140,7 @@ static int vgpu_intr_thread(void *dev_id)
140 return 0; 140 return 0;
141} 141}
142 142
143static void vgpu_remove_support(struct platform_device *dev) 143static void vgpu_remove_support(struct device *dev)
144{ 144{
145 struct gk20a *g = get_gk20a(dev); 145 struct gk20a *g = get_gk20a(dev);
146 struct gk20a_platform *platform = gk20a_get_platform(dev); 146 struct gk20a_platform *platform = gk20a_get_platform(dev);
@@ -174,10 +174,10 @@ static void vgpu_remove_support(struct platform_device *dev)
174 } 174 }
175} 175}
176 176
177static int vgpu_init_support(struct platform_device *dev) 177static int vgpu_init_support(struct platform_device *pdev)
178{ 178{
179 struct resource *r = platform_get_resource(dev, IORESOURCE_MEM, 0); 179 struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
180 struct gk20a *g = get_gk20a(dev); 180 struct gk20a *g = get_gk20a(&pdev->dev);
181 int err = 0; 181 int err = 0;
182 182
183 if (!r) { 183 if (!r) {
@@ -186,7 +186,7 @@ static int vgpu_init_support(struct platform_device *dev)
186 goto fail; 186 goto fail;
187 } 187 }
188 188
189 g->bar1 = devm_ioremap_resource(&dev->dev, r); 189 g->bar1 = devm_ioremap_resource(&pdev->dev, r);
190 if (IS_ERR(g->bar1)) { 190 if (IS_ERR(g->bar1)) {
191 dev_err(dev_from_gk20a(g), "failed to remap gk20a bar1\n"); 191 dev_err(dev_from_gk20a(g), "failed to remap gk20a bar1\n");
192 err = PTR_ERR(g->bar1); 192 err = PTR_ERR(g->bar1);
@@ -200,14 +200,13 @@ static int vgpu_init_support(struct platform_device *dev)
200 return 0; 200 return 0;
201 201
202 fail: 202 fail:
203 vgpu_remove_support(dev); 203 vgpu_remove_support(&pdev->dev);
204 return err; 204 return err;
205} 205}
206 206
207int vgpu_pm_prepare_poweroff(struct device *dev) 207int vgpu_pm_prepare_poweroff(struct device *dev)
208{ 208{
209 struct platform_device *pdev = to_platform_device(dev); 209 struct gk20a *g = get_gk20a(dev);
210 struct gk20a *g = get_gk20a(pdev);
211 int ret = 0; 210 int ret = 0;
212 211
213 gk20a_dbg_fn(""); 212 gk20a_dbg_fn("");
@@ -284,7 +283,7 @@ static int vgpu_init_hal(struct gk20a *g)
284 break; 283 break;
285#endif 284#endif
286 default: 285 default:
287 gk20a_err(&g->dev->dev, "no support for %x", ver); 286 gk20a_err(g->dev, "no support for %x", ver);
288 err = -ENODEV; 287 err = -ENODEV;
289 break; 288 break;
290 } 289 }
@@ -294,8 +293,7 @@ static int vgpu_init_hal(struct gk20a *g)
294 293
295int vgpu_pm_finalize_poweron(struct device *dev) 294int vgpu_pm_finalize_poweron(struct device *dev)
296{ 295{
297 struct platform_device *pdev = to_platform_device(dev); 296 struct gk20a *g = get_gk20a(dev);
298 struct gk20a *g = get_gk20a(pdev);
299 int err; 297 int err;
300 298
301 gk20a_dbg_fn(""); 299 gk20a_dbg_fn("");
@@ -342,9 +340,9 @@ done:
342 return err; 340 return err;
343} 341}
344 342
345static int vgpu_pm_initialise_domain(struct platform_device *pdev) 343static int vgpu_pm_initialise_domain(struct device *dev)
346{ 344{
347 struct gk20a_platform *platform = platform_get_drvdata(pdev); 345 struct gk20a_platform *platform = dev_get_drvdata(dev);
348 struct dev_power_governor *pm_domain_gov = NULL; 346 struct dev_power_governor *pm_domain_gov = NULL;
349 struct gk20a_domain_data *vgpu_pd_data; 347 struct gk20a_domain_data *vgpu_pd_data;
350 struct generic_pm_domain *domain; 348 struct generic_pm_domain *domain;
@@ -369,17 +367,17 @@ static int vgpu_pm_initialise_domain(struct platform_device *pdev)
369 domain->dev_ops.save_state = vgpu_pm_prepare_poweroff; 367 domain->dev_ops.save_state = vgpu_pm_prepare_poweroff;
370 domain->dev_ops.restore_state = vgpu_pm_finalize_poweron; 368 domain->dev_ops.restore_state = vgpu_pm_finalize_poweron;
371 369
372 device_set_wakeup_capable(&pdev->dev, 0); 370 device_set_wakeup_capable(dev, 0);
373 return pm_genpd_add_device(domain, &pdev->dev); 371 return pm_genpd_add_device(domain, dev);
374} 372}
375 373
376static int vgpu_pm_init(struct platform_device *dev) 374static int vgpu_pm_init(struct device *dev)
377{ 375{
378 int err = 0; 376 int err = 0;
379 377
380 gk20a_dbg_fn(""); 378 gk20a_dbg_fn("");
381 379
382 pm_runtime_enable(&dev->dev); 380 pm_runtime_enable(dev);
383 381
384 /* genpd will take care of runtime power management if it is enabled */ 382 /* genpd will take care of runtime power management if it is enabled */
385 if (IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS)) 383 if (IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS))
@@ -388,14 +386,15 @@ static int vgpu_pm_init(struct platform_device *dev)
388 return err; 386 return err;
389} 387}
390 388
391int vgpu_probe(struct platform_device *dev) 389int vgpu_probe(struct platform_device *pdev)
392{ 390{
393 struct gk20a *gk20a; 391 struct gk20a *gk20a;
394 int err; 392 int err;
393 struct device *dev = &pdev->dev;
395 struct gk20a_platform *platform = gk20a_get_platform(dev); 394 struct gk20a_platform *platform = gk20a_get_platform(dev);
396 395
397 if (!platform) { 396 if (!platform) {
398 dev_err(&dev->dev, "no platform data\n"); 397 dev_err(dev, "no platform data\n");
399 return -ENODATA; 398 return -ENODATA;
400 } 399 }
401 400
@@ -403,18 +402,18 @@ int vgpu_probe(struct platform_device *dev)
403 402
404 gk20a = kzalloc(sizeof(struct gk20a), GFP_KERNEL); 403 gk20a = kzalloc(sizeof(struct gk20a), GFP_KERNEL);
405 if (!gk20a) { 404 if (!gk20a) {
406 dev_err(&dev->dev, "couldn't allocate gk20a support"); 405 dev_err(dev, "couldn't allocate gk20a support");
407 return -ENOMEM; 406 return -ENOMEM;
408 } 407 }
409 408
410 platform->g = gk20a; 409 platform->g = gk20a;
411 gk20a->dev = dev; 410 gk20a->dev = dev;
412 411
413 err = gk20a_user_init(dev); 412 err = gk20a_user_init(dev, INTERFACE_NAME);
414 if (err) 413 if (err)
415 return err; 414 return err;
416 415
417 vgpu_init_support(dev); 416 vgpu_init_support(pdev);
418 vgpu_dbg_init(); 417 vgpu_dbg_init();
419 418
420 init_rwsem(&gk20a->busy_lock); 419 init_rwsem(&gk20a->busy_lock);
@@ -424,33 +423,33 @@ int vgpu_probe(struct platform_device *dev)
424 /* Initialize the platform interface. */ 423 /* Initialize the platform interface. */
425 err = platform->probe(dev); 424 err = platform->probe(dev);
426 if (err) { 425 if (err) {
427 dev_err(&dev->dev, "platform probe failed"); 426 dev_err(dev, "platform probe failed");
428 return err; 427 return err;
429 } 428 }
430 429
431 err = vgpu_pm_init(dev); 430 err = vgpu_pm_init(dev);
432 if (err) { 431 if (err) {
433 dev_err(&dev->dev, "pm init failed"); 432 dev_err(dev, "pm init failed");
434 return err; 433 return err;
435 } 434 }
436 435
437 if (platform->late_probe) { 436 if (platform->late_probe) {
438 err = platform->late_probe(dev); 437 err = platform->late_probe(dev);
439 if (err) { 438 if (err) {
440 dev_err(&dev->dev, "late probe failed"); 439 dev_err(dev, "late probe failed");
441 return err; 440 return err;
442 } 441 }
443 } 442 }
444 443
445 err = vgpu_comm_init(dev); 444 err = vgpu_comm_init(pdev);
446 if (err) { 445 if (err) {
447 dev_err(&dev->dev, "failed to init comm interface\n"); 446 dev_err(dev, "failed to init comm interface\n");
448 return -ENOSYS; 447 return -ENOSYS;
449 } 448 }
450 449
451 platform->virt_handle = vgpu_connect(); 450 platform->virt_handle = vgpu_connect();
452 if (!platform->virt_handle) { 451 if (!platform->virt_handle) {
453 dev_err(&dev->dev, "failed to connect to server node\n"); 452 dev_err(dev, "failed to connect to server node\n");
454 vgpu_comm_deinit(); 453 vgpu_comm_deinit();
455 return -ENOSYS; 454 return -ENOSYS;
456 } 455 }
@@ -462,8 +461,8 @@ int vgpu_probe(struct platform_device *dev)
462 gk20a_debug_init(dev); 461 gk20a_debug_init(dev);
463 462
464 /* Set DMA parameters to allow larger sgt lists */ 463 /* Set DMA parameters to allow larger sgt lists */
465 dev->dev.dma_parms = &gk20a->dma_parms; 464 dev->dma_parms = &gk20a->dma_parms;
466 dma_set_max_seg_size(&dev->dev, UINT_MAX); 465 dma_set_max_seg_size(dev, UINT_MAX);
467 466
468 gk20a->gr_idle_timeout_default = 467 gk20a->gr_idle_timeout_default =
469 CONFIG_GK20A_DEFAULT_TIMEOUT; 468 CONFIG_GK20A_DEFAULT_TIMEOUT;
@@ -475,8 +474,9 @@ int vgpu_probe(struct platform_device *dev)
475 return 0; 474 return 0;
476} 475}
477 476
478int vgpu_remove(struct platform_device *dev) 477int vgpu_remove(struct platform_device *pdev)
479{ 478{
479 struct device *dev = &pdev->dev;
480 struct gk20a *g = get_gk20a(dev); 480 struct gk20a *g = get_gk20a(dev);
481 struct gk20a_domain_data *vgpu_gpd; 481 struct gk20a_domain_data *vgpu_gpd;
482 gk20a_dbg_fn(""); 482 gk20a_dbg_fn("");