diff options
-rw-r--r-- | drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c index 1a930b77ec53..ea7711832959 100644 --- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c +++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | |||
@@ -80,6 +80,7 @@ struct dsi_hw_ctx { | |||
80 | 80 | ||
81 | struct dw_dsi { | 81 | struct dw_dsi { |
82 | struct drm_encoder encoder; | 82 | struct drm_encoder encoder; |
83 | struct mipi_dsi_host host; | ||
83 | struct drm_display_mode cur_mode; | 84 | struct drm_display_mode cur_mode; |
84 | struct dsi_hw_ctx *ctx; | 85 | struct dsi_hw_ctx *ctx; |
85 | struct mipi_phy_params phy; | 86 | struct mipi_phy_params phy; |
@@ -654,6 +655,51 @@ static int dw_drm_encoder_init(struct device *dev, | |||
654 | return 0; | 655 | return 0; |
655 | } | 656 | } |
656 | 657 | ||
658 | static int dsi_host_attach(struct mipi_dsi_host *host, | ||
659 | struct mipi_dsi_device *mdsi) | ||
660 | { | ||
661 | struct dw_dsi *dsi = host_to_dsi(host); | ||
662 | |||
663 | if (mdsi->lanes < 1 || mdsi->lanes > 4) { | ||
664 | DRM_ERROR("dsi device params invalid\n"); | ||
665 | return -EINVAL; | ||
666 | } | ||
667 | |||
668 | dsi->lanes = mdsi->lanes; | ||
669 | dsi->format = mdsi->format; | ||
670 | dsi->mode_flags = mdsi->mode_flags; | ||
671 | |||
672 | return 0; | ||
673 | } | ||
674 | |||
675 | static int dsi_host_detach(struct mipi_dsi_host *host, | ||
676 | struct mipi_dsi_device *mdsi) | ||
677 | { | ||
678 | /* do nothing */ | ||
679 | return 0; | ||
680 | } | ||
681 | |||
682 | static const struct mipi_dsi_host_ops dsi_host_ops = { | ||
683 | .attach = dsi_host_attach, | ||
684 | .detach = dsi_host_detach, | ||
685 | }; | ||
686 | |||
687 | static int dsi_host_init(struct device *dev, struct dw_dsi *dsi) | ||
688 | { | ||
689 | struct mipi_dsi_host *host = &dsi->host; | ||
690 | int ret; | ||
691 | |||
692 | host->dev = dev; | ||
693 | host->ops = &dsi_host_ops; | ||
694 | ret = mipi_dsi_host_register(host); | ||
695 | if (ret) { | ||
696 | DRM_ERROR("failed to register dsi host\n"); | ||
697 | return ret; | ||
698 | } | ||
699 | |||
700 | return 0; | ||
701 | } | ||
702 | |||
657 | static int dsi_bind(struct device *dev, struct device *master, void *data) | 703 | static int dsi_bind(struct device *dev, struct device *master, void *data) |
658 | { | 704 | { |
659 | struct dsi_data *ddata = dev_get_drvdata(dev); | 705 | struct dsi_data *ddata = dev_get_drvdata(dev); |
@@ -665,6 +711,10 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) | |||
665 | if (ret) | 711 | if (ret) |
666 | return ret; | 712 | return ret; |
667 | 713 | ||
714 | ret = dsi_host_init(dev, dsi); | ||
715 | if (ret) | ||
716 | return ret; | ||
717 | |||
668 | return 0; | 718 | return 0; |
669 | } | 719 | } |
670 | 720 | ||