Re: [PATCH v8 2/8] drm/panel: support for BOE tv101wum-nl6 wuxga dsi video mode panel
From: Sam Ravnborg
Date: Wed Jan 15 2020 - 16:14:13 EST
Hi Jitao.
> +
> +static int boe_panel_add(struct boe_panel *boe)
> +{
> + struct device *dev = &boe->dsi->dev;
> + int err;
> +
> + boe->avdd = devm_regulator_get(dev, "avdd");
> + if (IS_ERR(boe->avdd))
> + return PTR_ERR(boe->avdd);
> +
> + boe->avee = devm_regulator_get(dev, "avee");
> + if (IS_ERR(boe->avee))
> + return PTR_ERR(boe->avee);
> +
> + boe->pp1800 = devm_regulator_get(dev, "pp1800");
> + if (IS_ERR(boe->pp1800))
> + return PTR_ERR(boe->pp1800);
> +
> + boe->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
> + if (IS_ERR(boe->enable_gpio)) {
> + dev_err(dev, "cannot get reset-gpios %ld\n",
> + PTR_ERR(boe->enable_gpio));
> + return PTR_ERR(boe->enable_gpio);
> + }
> +
> + gpiod_set_value(boe->enable_gpio, 0);
> +
> + err = drm_panel_of_backlight(&boe->base);
> + if (err)
> + return err;
>From the descrition of drm_panel_of_backlight():
""
drm_panel_of_backlight() must be called after the call to drm_panel_init().
""
Please do as documented.
Sam
> +
> + drm_panel_init(&boe->base, dev, &boe_panel_funcs,
> + DRM_MODE_CONNECTOR_DSI);
> +
> + boe->base.funcs = &boe_panel_funcs;
> + boe->base.dev = &boe->dsi->dev;
> +
> + return drm_panel_add(&boe->base);
> +}
> +
> +static int boe_panel_probe(struct mipi_dsi_device *dsi)
> +{
> + struct boe_panel *boe;
> + int ret;
> + const struct panel_desc *desc;
> +
> + boe = devm_kzalloc(&dsi->dev, sizeof(*boe), GFP_KERNEL);
> + if (!boe)
> + return -ENOMEM;
> +
> + desc = of_device_get_match_data(&dsi->dev);
> + dsi->lanes = desc->lanes;
> + dsi->format = desc->format;
> + dsi->mode_flags = desc->mode_flags;
> + boe->desc = desc;
> + boe->dsi = dsi;
> + ret = boe_panel_add(boe);
> + if (ret < 0)
> + return ret;
> +
> + mipi_dsi_set_drvdata(dsi, boe);
> +
> + ret = mipi_dsi_attach(dsi);
> + if (ret)
> + drm_panel_remove(&boe->base);
> +
> + return ret;
> +}
> +
> +static void boe_panel_shutdown(struct mipi_dsi_device *dsi)
> +{
> + struct boe_panel *boe = mipi_dsi_get_drvdata(dsi);
> +
> + drm_panel_disable(&boe->base);
> + drm_panel_unprepare(&boe->base);
> +}
> +
> +static int boe_panel_remove(struct mipi_dsi_device *dsi)
> +{
> + struct boe_panel *boe = mipi_dsi_get_drvdata(dsi);
> + int ret;
> +
> + boe_panel_shutdown(dsi);
> +
> + ret = mipi_dsi_detach(dsi);
> + if (ret < 0)
> + dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", ret);
> +
> + if (boe->base.dev)
> + drm_panel_remove(&boe->base);
> +
> + return 0;
> +}
> +
> +static const struct of_device_id boe_of_match[] = {
> + { .compatible = "boe,tv101wum-nl6",
> + .data = &boe_tv101wum_nl6_desc
> + },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, boe_of_match);
> +
> +static struct mipi_dsi_driver boe_panel_driver = {
> + .driver = {
> + .name = "panel-boe-tv101wum-nl6",
> + .of_match_table = boe_of_match,
> + },
> + .probe = boe_panel_probe,
> + .remove = boe_panel_remove,
> + .shutdown = boe_panel_shutdown,
> +};
> +module_mipi_dsi_driver(boe_panel_driver);
> +
> +MODULE_AUTHOR("Jitao Shi <jitao.shi@xxxxxxxxxxxx>");
> +MODULE_DESCRIPTION("BOE tv101wum-nl6 1200x1920 video mode panel driver");
> +MODULE_LICENSE("GPL v2");
> --
> 2.21.0