On 11/30/26 12:41, Svyatoslav Ryhel wrote:
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   | 32 ++++++++-----------
  1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c 
b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
index 83c2af1be9755..8c17132728807 100644
--- a/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
+++ b/drivers/gpu/drm/panel/panel-hitachi-tx10d07vm0baa.c
@@ -6,16 +6,14 @@
  #include <linux/gpio/consumer.h>
  #include <linux/media-bus-format.h>
  #include <linux/module.h>
-#include <linux/of_platform.h>
-#include <linux/platform_device.h>
-#include <linux/property.h>
+#include <linux/of.h>
  #include <linux/regulator/consumer.h>
#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>
  #include <drm/drm_probe_helper.h>
@@ -25,7 +23,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 +38,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 +53,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);
@@ -73,7 +68,7 @@ static int hitachi_tx10d07vm0baa_prepare(struct drm_panel 
*panel)
        usleep_range(10000, 11000);
return 0;
-};
+}
static int hitachi_tx10d07vm0baa_enable(struct drm_panel *panel)
  {
@@ -243,9 +238,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 +259,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 +270,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 +279,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");

Reviewed-by: Neil Armstrong <[email protected]>

Thanks,
Neil

Reply via email to