Switch from a generic platform driver to a dedicated MIPI DBI Type B
driver.

Signed-off-by: Svyatoslav Ryhel <[email protected]>
---
 .../drm/panel/panel-hitachi-tx10d07vm0baa.c   | 25 +++++++++----------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c 
b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
index 83c2af1be9755..318ece68b7806 100644
--- a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
+++ b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
@@ -14,6 +14,7 @@
 #include <video/mipi_display.h>
 
 #include <drm/drm_mipi_dbi.h>
+#include <drm/drm_mipi_dbi_bus.h>
 #include <drm/drm_modes.h>
 #include <drm/drm_of.h>
 #include <drm/drm_panel.h>
@@ -25,7 +26,7 @@ static const struct regulator_bulk_data 
hitachi_tx10d07vm0baa_supplies[] = {
 
 struct hitachi_tx10d07vm0baa {
        struct drm_panel panel;
-       struct mipi_dbi *dbi;
+       struct mipi_dbi_device *dbidev;
 
        struct regulator_bulk_data *supplies;
        struct gpio_desc *reset_gpio;
@@ -40,9 +41,10 @@ static inline struct hitachi_tx10d07vm0baa 
*to_hitachi_tx10d07vm0baa(struct drm_
 ({ \
        const u8 d[] = { seq }; \
        struct drm_panel *panel = &(priv)->panel; \
+       struct mipi_dbi_device *dbidev = (priv)->dbidev; \
        struct device *dev = panel->dev; \
        int ret; \
-       ret = mipi_dbi_command_stackbuf((priv)->dbi, cmd, d, ARRAY_SIZE(d)); \
+       ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \
        if (ret) \
                dev_err_ratelimited(dev, "error %d when sending command 
%#02x\n", ret, cmd); \
        ret; \
@@ -54,10 +56,6 @@ static int hitachi_tx10d07vm0baa_prepare(struct drm_panel 
*panel)
        struct device *dev = panel->dev;
        int ret;
 
-       priv->dbi = dev_get_drvdata(dev->parent);
-       if (!priv->dbi)
-               return -ENODEV;
-
        gpiod_set_value_cansleep(priv->reset_gpio, 1);
 
        ret = regulator_bulk_enable(ARRAY_SIZE(hitachi_tx10d07vm0baa_supplies), 
priv->supplies);
@@ -243,9 +241,9 @@ static const struct drm_panel_funcs 
hitachi_tx10d07vm0baa_panel_funcs = {
        .get_modes = hitachi_tx10d07vm0baa_get_modes,
 };
 
-static int hitachi_tx10d07vm0baa_probe(struct platform_device *pdev)
+static int hitachi_tx10d07vm0baa_probe(struct mipi_dbi_device *dbidev)
 {
-       struct device *dev = &pdev->dev;
+       struct device *dev = &dbidev->dev;
        struct hitachi_tx10d07vm0baa *priv;
        int ret;
 
@@ -264,6 +262,9 @@ static int hitachi_tx10d07vm0baa_probe(struct 
platform_device *pdev)
                return dev_err_probe(dev, PTR_ERR(priv->reset_gpio),
                                     "Failed to get reset gpio\n");
 
+       priv->dbidev = dbidev;
+       mipi_dbi_set_drvdata(dbidev, priv);
+
        ret = drm_panel_of_backlight(&priv->panel);
        if (ret)
                return dev_err_probe(dev, ret, "Failed to get backlight\n");
@@ -272,9 +273,7 @@ static int hitachi_tx10d07vm0baa_probe(struct 
platform_device *pdev)
        if (ret)
                return dev_err_probe(dev, ret, "Failed to add panel\n");
 
-       platform_set_drvdata(pdev, priv);
-
-       return 0;
+       return devm_mipi_dbi_attach(dev, dbidev);
 }
 
 static const struct of_device_id hitachi_tx10d07vm0baa_of_match[] = {
@@ -283,14 +282,14 @@ static const struct of_device_id 
hitachi_tx10d07vm0baa_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, hitachi_tx10d07vm0baa_of_match);
 
-static struct platform_driver hitachi_tx10d07vm0baa_driver = {
+static struct mipi_dbi_driver hitachi_tx10d07vm0baa_driver = {
        .driver = {
                .name = "panel-hitachi-tx10d07vm0baa",
                .of_match_table = hitachi_tx10d07vm0baa_of_match,
        },
        .probe = hitachi_tx10d07vm0baa_probe,
 };
-module_platform_driver(hitachi_tx10d07vm0baa_driver);
+module_mipi_dbi_driver(hitachi_tx10d07vm0baa_driver);
 
 MODULE_AUTHOR("Svyatoslav Ryhel <[email protected]>");
 MODULE_DESCRIPTION("HITACHI TX10D07VM0BAA MIPI DBI Type B panel driver");
-- 
2.53.0

Reply via email to