Hi Guido.

> +static int mantix_probe(struct mipi_dsi_device *dsi)
> +{
> +     struct device *dev = &dsi->dev;
> +     struct mantix *ctx;
> +     int ret;
> +
> +     ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> +     if (!ctx)
> +             return -ENOMEM;
> +
> +     ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
> +     if (IS_ERR(ctx->reset_gpio)) {
> +             DRM_DEV_ERROR(dev, "cannot get reset gpio\n");
> +             return PTR_ERR(ctx->reset_gpio);
> +     }
> +
> +     mipi_dsi_set_drvdata(dsi, ctx);
> +     ctx->dev = dev;
> +
> +     dsi->lanes = 4;
> +     dsi->format = MIPI_DSI_FMT_RGB888;
> +     dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
> +             MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
> +
> +     ctx->avdd = devm_regulator_get(dev, "avdd");
> +     if (IS_ERR(ctx->avdd)) {
> +             ret = PTR_ERR(ctx->avdd);
> +             if (ret != -EPROBE_DEFER)
> +                     DRM_DEV_ERROR(dev,
> +                                   "Failed to request avdd regulator: %d\n",
> +                                   ret);
> +             return ret;
> +     }

Consider to use the recently added dev_err_probe() here and below.
Note: Not part of drm-misc-next yet - but hopefully after -rc1
when a backmerge is done.

        Sam

> +     ctx->avee = devm_regulator_get(dev, "avee");
> +     if (IS_ERR(ctx->avee)) {
> +             ret = PTR_ERR(ctx->avee);
> +             if (ret != -EPROBE_DEFER)
> +                     DRM_DEV_ERROR(dev,
> +                                   "Failed to request avee regulator: %d\n",
> +                                   ret);
> +             return ret;
> +     }
> +     ctx->vddi = devm_regulator_get(dev, "vddi");
> +     if (IS_ERR(ctx->vddi)) {
> +             ret = PTR_ERR(ctx->vddi);
> +             if (ret != -EPROBE_DEFER)
> +                     DRM_DEV_ERROR(dev,
> +                                   "Failed to request vddi regulator: %d\n",
> +                                   ret);
> +             return ret;
> +     }
> +
> +     drm_panel_init(&ctx->panel, dev, &mantix_drm_funcs,
> +                    DRM_MODE_CONNECTOR_DSI);
> +
> +     ret = drm_panel_of_backlight(&ctx->panel);
> +     if (ret)
> +             return ret;
> +     drm_panel_add(&ctx->panel);
> +
> +     ret = mipi_dsi_attach(dsi);
> +     if (ret < 0) {
> +             DRM_DEV_ERROR(dev,
> +                           "mipi_dsi_attach failed (%d). Is host ready?\n",
> +                           ret);
> +             drm_panel_remove(&ctx->panel);
> +             return ret;
> +     }
> +
> +     DRM_DEV_INFO(dev, "%ux%u@%u %ubpp dsi %udl - ready\n",
> +                  default_mode.hdisplay, default_mode.vdisplay,
> +                  drm_mode_vrefresh(&default_mode),
> +                  mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes);
> +
> +     return 0;
> +}
> +
> +static void mantix_shutdown(struct mipi_dsi_device *dsi)
> +{
> +     struct mantix *ctx = mipi_dsi_get_drvdata(dsi);
> +     int ret;
> +
> +     ret = drm_panel_unprepare(&ctx->panel);
> +     if (ret < 0)
> +             DRM_DEV_ERROR(&dsi->dev, "Failed to unprepare panel: %d\n",
> +                           ret);
> +
> +     ret = drm_panel_disable(&ctx->panel);
> +     if (ret < 0)
> +             DRM_DEV_ERROR(&dsi->dev, "Failed to disable panel: %d\n",
> +                           ret);
> +}
> +
> +static int mantix_remove(struct mipi_dsi_device *dsi)
> +{
> +     struct mantix *ctx = mipi_dsi_get_drvdata(dsi);
> +     int ret;
> +
> +     mantix_shutdown(dsi);
> +
> +     ret = mipi_dsi_detach(dsi);
> +     if (ret < 0)
> +             DRM_DEV_ERROR(&dsi->dev, "Failed to detach from DSI host: %d\n",
> +                           ret);
> +
> +     drm_panel_remove(&ctx->panel);
> +
> +     return 0;
> +}
> +
> +static const struct of_device_id mantix_of_match[] = {
> +     { .compatible = "mantix,mlaf057we51-x" },
> +     { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mantix_of_match);
> +
> +static struct mipi_dsi_driver mantix_driver = {
> +     .probe  = mantix_probe,
> +     .remove = mantix_remove,
> +     .shutdown = mantix_shutdown,
> +     .driver = {
> +             .name = DRV_NAME,
> +             .of_match_table = mantix_of_match,
> +     },
> +};
> +module_mipi_dsi_driver(mantix_driver);
> +
> +MODULE_AUTHOR("Guido Günther <a...@sigxcpu.org>");
> +MODULE_DESCRIPTION("DRM driver for Mantix MLAF057WE51-X MIPI DSI panel");
> +MODULE_LICENSE("GPL v2");
> -- 
> 2.26.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to