aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/omapdrm/omap_drv.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-02-13 07:00:19 -0500
committerTomi Valkeinen <tomi.valkeinen@ti.com>2018-03-01 02:18:18 -0500
commita82f034765fa3e9db73b8ca99e8830f3bb31ac90 (patch)
treef36335720514a0e1d2a3f2f1050bbe79b0bf9c82 /drivers/gpu/drm/omapdrm/omap_drv.c
parentbafa89fcac4fa4950ffde0b4f565482290176450 (diff)
drm: omapdrm: Split init and cleanup from probe and remove functions
When merging the omapdrm and omapdss drivers there will be not omapdrm platform device anymore, and thus no associated probe and remove functions. To prepare for that, split all the initialization code from the probe function to make it usable without a platform device. Similarly, split the cleanup code from the remove function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Diffstat (limited to 'drivers/gpu/drm/omapdrm/omap_drv.c')
-rw-r--r--drivers/gpu/drm/omapdrm/omap_drv.c83
1 files changed, 51 insertions, 32 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index dd68b2556f5b..b571cc04e08d 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -510,24 +510,16 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = {
510 { /* sentinel */ } 510 { /* sentinel */ }
511}; 511};
512 512
513static int pdev_probe(struct platform_device *pdev) 513static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
514{ 514{
515 const struct soc_device_attribute *soc; 515 const struct soc_device_attribute *soc;
516 struct omap_drm_private *priv;
517 struct drm_device *ddev; 516 struct drm_device *ddev;
518 unsigned int i; 517 unsigned int i;
519 int ret; 518 int ret;
520 519
521 DBG("%s", pdev->name); 520 DBG("%s", dev_name(dev));
522
523 if (omapdss_is_initialized() == false)
524 return -EPROBE_DEFER;
525 521
526 ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); 522 priv->dev = dev;
527 if (ret) {
528 dev_err(&pdev->dev, "Failed to set the DMA mask\n");
529 return ret;
530 }
531 523
532 omap_crtc_pre_init(); 524 omap_crtc_pre_init();
533 525
@@ -535,13 +527,6 @@ static int pdev_probe(struct platform_device *pdev)
535 if (ret) 527 if (ret)
536 goto err_crtc_uninit; 528 goto err_crtc_uninit;
537 529
538 /* Allocate and initialize the driver private structure. */
539 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
540 if (!priv) {
541 ret = -ENOMEM;
542 goto err_disconnect_dssdevs;
543 }
544
545 priv->dispc_ops = dispc_get_ops(); 530 priv->dispc_ops = dispc_get_ops();
546 531
547 soc = soc_device_match(omapdrm_soc_devices); 532 soc = soc_device_match(omapdrm_soc_devices);
@@ -552,14 +537,14 @@ static int pdev_probe(struct platform_device *pdev)
552 INIT_LIST_HEAD(&priv->obj_list); 537 INIT_LIST_HEAD(&priv->obj_list);
553 538
554 /* Allocate and initialize the DRM device. */ 539 /* Allocate and initialize the DRM device. */
555 ddev = drm_dev_alloc(&omap_drm_driver, &pdev->dev); 540 ddev = drm_dev_alloc(&omap_drm_driver, priv->dev);
556 if (IS_ERR(ddev)) { 541 if (IS_ERR(ddev)) {
557 ret = PTR_ERR(ddev); 542 ret = PTR_ERR(ddev);
558 goto err_free_priv; 543 goto err_destroy_wq;
559 } 544 }
560 545
546 priv->ddev = ddev;
561 ddev->dev_private = priv; 547 ddev->dev_private = priv;
562 platform_set_drvdata(pdev, ddev);
563 548
564 /* Get memory bandwidth limits */ 549 /* Get memory bandwidth limits */
565 if (priv->dispc_ops->get_memory_bandwidth_limit) 550 if (priv->dispc_ops->get_memory_bandwidth_limit)
@@ -570,14 +555,14 @@ static int pdev_probe(struct platform_device *pdev)
570 555
571 ret = omap_modeset_init(ddev); 556 ret = omap_modeset_init(ddev);
572 if (ret) { 557 if (ret) {
573 dev_err(&pdev->dev, "omap_modeset_init failed: ret=%d\n", ret); 558 dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret);
574 goto err_free_drm_dev; 559 goto err_free_drm_dev;
575 } 560 }
576 561
577 /* Initialize vblank handling, start with all CRTCs disabled. */ 562 /* Initialize vblank handling, start with all CRTCs disabled. */
578 ret = drm_vblank_init(ddev, priv->num_crtcs); 563 ret = drm_vblank_init(ddev, priv->num_crtcs);
579 if (ret) { 564 if (ret) {
580 dev_err(&pdev->dev, "could not init vblank\n"); 565 dev_err(priv->dev, "could not init vblank\n");
581 goto err_cleanup_modeset; 566 goto err_cleanup_modeset;
582 } 567 }
583 568
@@ -610,20 +595,17 @@ err_cleanup_modeset:
610err_free_drm_dev: 595err_free_drm_dev:
611 omap_gem_deinit(ddev); 596 omap_gem_deinit(ddev);
612 drm_dev_unref(ddev); 597 drm_dev_unref(ddev);
613err_free_priv: 598err_destroy_wq:
614 destroy_workqueue(priv->wq); 599 destroy_workqueue(priv->wq);
615 kfree(priv);
616err_disconnect_dssdevs:
617 omap_disconnect_dssdevs(); 600 omap_disconnect_dssdevs();
618err_crtc_uninit: 601err_crtc_uninit:
619 omap_crtc_pre_uninit(); 602 omap_crtc_pre_uninit();
620 return ret; 603 return ret;
621} 604}
622 605
623static int pdev_remove(struct platform_device *pdev) 606static void omapdrm_cleanup(struct omap_drm_private *priv)
624{ 607{
625 struct drm_device *ddev = platform_get_drvdata(pdev); 608 struct drm_device *ddev = priv->ddev;
626 struct omap_drm_private *priv = ddev->dev_private;
627 609
628 DBG(""); 610 DBG("");
629 611
@@ -645,10 +627,45 @@ static int pdev_remove(struct platform_device *pdev)
645 drm_dev_unref(ddev); 627 drm_dev_unref(ddev);
646 628
647 destroy_workqueue(priv->wq); 629 destroy_workqueue(priv->wq);
648 kfree(priv);
649 630
650 omap_disconnect_dssdevs(); 631 omap_disconnect_dssdevs();
651 omap_crtc_pre_uninit(); 632 omap_crtc_pre_uninit();
633}
634
635static int pdev_probe(struct platform_device *pdev)
636{
637 struct omap_drm_private *priv;
638 int ret;
639
640 if (omapdss_is_initialized() == false)
641 return -EPROBE_DEFER;
642
643 ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
644 if (ret) {
645 dev_err(&pdev->dev, "Failed to set the DMA mask\n");
646 return ret;
647 }
648
649 /* Allocate and initialize the driver private structure. */
650 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
651 if (!priv)
652 return -ENOMEM;
653
654 platform_set_drvdata(pdev, priv);
655
656 ret = omapdrm_init(priv, &pdev->dev);
657 if (ret < 0)
658 kfree(priv);
659
660 return ret;
661}
662
663static int pdev_remove(struct platform_device *pdev)
664{
665 struct omap_drm_private *priv = platform_get_drvdata(pdev);
666
667 omapdrm_cleanup(priv);
668 kfree(priv);
652 669
653 return 0; 670 return 0;
654} 671}
@@ -692,7 +709,8 @@ static int omap_drm_resume_all_displays(void)
692 709
693static int omap_drm_suspend(struct device *dev) 710static int omap_drm_suspend(struct device *dev)
694{ 711{
695 struct drm_device *drm_dev = dev_get_drvdata(dev); 712 struct omap_drm_private *priv = dev_get_drvdata(dev);
713 struct drm_device *drm_dev = priv->ddev;
696 714
697 drm_kms_helper_poll_disable(drm_dev); 715 drm_kms_helper_poll_disable(drm_dev);
698 716
@@ -705,7 +723,8 @@ static int omap_drm_suspend(struct device *dev)
705 723
706static int omap_drm_resume(struct device *dev) 724static int omap_drm_resume(struct device *dev)
707{ 725{
708 struct drm_device *drm_dev = dev_get_drvdata(dev); 726 struct omap_drm_private *priv = dev_get_drvdata(dev);
727 struct drm_device *drm_dev = priv->ddev;
709 728
710 drm_modeset_lock_all(drm_dev); 729 drm_modeset_lock_all(drm_dev);
711 omap_drm_resume_all_displays(); 730 omap_drm_resume_all_displays();