Re: [EXT] Re: [PATCH v2 2/2] drm/panel: Add support for Raydium RM67191 panel driver

From: Robert Chiras
Date: Thu Jun 20 2019 - 04:37:37 EST


Hi Sam,

On Mi, 2019-06-19 at 15:25 +0200, Sam Ravnborg wrote:
> On Tue, Jun 18, 2019 at 04:30:46PM +0300, Robert Chiras wrote:
> >
> > This patch adds Raydium RM67191 TFT LCD panel driver (MIPI-DSI
> > protocol).
> >
> > Signed-off-by: Robert Chiras <robert.chiras@xxxxxxx>
> Please include in the changelog a list of what was updated - like
> this:
>
> v2:
> - added kconif symbol sorted (sam)
> - another nitpick (foo)
> - etc
>
> In general try to namme who gave feedback to give them some credit.
Thanks. I will keep this in mind, next time
>
> Who is maintainer for this onwards?
I can offer myself to maintain this.
>
> >
> > ---
> > Âdrivers/gpu/drm/panel/KconfigÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ9 +
> > Âdrivers/gpu/drm/panel/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ1 +
> > Âdrivers/gpu/drm/panel/panel-raydium-rm67191.c | 709
> > ++++++++++++++++++++++++++
> > Â3 files changed, 719 insertions(+)
> > Âcreate mode 100644 drivers/gpu/drm/panel/panel-raydium-rm67191.c
> >
> > +static int rad_panel_prepare(struct drm_panel *panel)
> > +{
> > +ÂÂÂÂÂstruct rad_panel *rad = to_rad_panel(panel);
> > +
> > +ÂÂÂÂÂif (rad->prepared)
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂreturn 0;
> > +
> > +ÂÂÂÂÂif (rad->reset) {
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂgpiod_set_value_cansleep(rad->reset, 1);
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂusleep_range(3000, 5000);
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂgpiod_set_value_cansleep(rad->reset, 0);
> So writing a 0 will release reset.
> >
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂusleep_range(18000, 20000);
> > +ÂÂÂÂÂ}
> > +
> > +ÂÂÂÂÂrad->prepared = true;
> > +
> > +ÂÂÂÂÂreturn 0;
> > +}
> > +
> > +static int rad_panel_unprepare(struct drm_panel *panel)
> > +{
> > +ÂÂÂÂÂstruct rad_panel *rad = to_rad_panel(panel);
> > +
> > +ÂÂÂÂÂif (!rad->prepared)
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂreturn 0;
> > +
> > +ÂÂÂÂÂif (rad->reset) {
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂgpiod_set_value_cansleep(rad->reset, 1);
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂusleep_range(15000, 17000);
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂgpiod_set_value_cansleep(rad->reset, 0);
> Looks strange that reset is released in unprepare.
> I would expect it to stay reset to minimize power etc.
Yes, it looks strange indeed. The reason here is coming from the fact
that this panel also has touch-screen that shares this reset pin with
the OLED display. While the display may be turned off, the touch driver
may need to keep the connection active with the touch controller from
this panel. This is the reason for releasing the reset pin in
unprepare. I will add this in a comment in the code, to eliminate the
confusion.
>
> >
> > +
> > +ÂÂÂÂÂret = drm_display_info_set_bus_formats(&connector-
> > >display_info,
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂrad_bus_formats,
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂARRAY_SIZE(rad_bus_for
> > mats));
> Other drivers has this as the last stement in their enable function.
> I did not check why, but maybe something to invest a few minutes
> into.
> Be different only if there is a reason to do so.
Ok, I will move this as the last statement. I also noticed that the
other panel drivers do not check the return of this call, like I do
here, so I will also remove this too.
>
> >
> > +ÂÂÂÂÂif (ret)
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂreturn ret;
> > +
> > +ÂÂÂÂÂdrm_mode_probed_add(panel->connector, mode);
> > +
> > +ÂÂÂÂÂreturn 1;
> > +}
> > +
> > +
> > +#ifdef CONFIG_PM
> > +static int rad_panel_suspend(struct device *dev)
> > +{
> > +ÂÂÂÂÂstruct rad_panel *rad = dev_get_drvdata(dev);
> > +
> > +ÂÂÂÂÂif (!rad->reset)
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂreturn 0;
> > +
> > +ÂÂÂÂÂdevm_gpiod_put(dev, rad->reset);
> > +ÂÂÂÂÂrad->reset = NULL;
> > +
> > +ÂÂÂÂÂreturn 0;
> > +}
> > +
> > +static int rad_panel_resume(struct device *dev)
> > +{
> > +ÂÂÂÂÂstruct rad_panel *rad = dev_get_drvdata(dev);
> > +
> > +ÂÂÂÂÂif (rad->reset)
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂreturn 0;
> > +
> > +ÂÂÂÂÂrad->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
> > +ÂÂÂÂÂif (IS_ERR(rad->reset))
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂrad->reset = NULL;
> > +
> > +ÂÂÂÂÂreturn PTR_ERR_OR_ZERO(rad->reset);
> > +}
> > +
> > +#endif
> Use __maybe_unused for the tw functions above.
> And loose the ifdef...
Thanks. Will apply.
>
> >
> > +
> > +static const struct dev_pm_ops rad_pm_ops = {
> > +ÂÂÂÂÂSET_RUNTIME_PM_OPS(rad_panel_suspend, rad_panel_resume, NULL)
> > +ÂÂÂÂÂSET_SYSTEM_SLEEP_PM_OPS(rad_panel_suspend, rad_panel_resume)
> > +};
> > +
> > +static const struct of_device_id rad_of_match[] = {
> > +ÂÂÂÂÂ{ .compatible = "raydium,rm67191", },
> > +ÂÂÂÂÂ{ }
> We often, but not always, write this as { /* sentinal */ },
Thanks. Will apply.
>
> >
> > +};
> > +MODULE_DEVICE_TABLE(of, rad_of_match);
> > +
> > +static struct mipi_dsi_driver rad_panel_driver = {
> > +ÂÂÂÂÂ.driver = {
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂ.name = "panel-raydium-rm67191",
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂ.of_match_table = rad_of_match,
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂ.pmÂÂÂÂÂ= &rad_pm_ops,
> > +ÂÂÂÂÂ},
> > +ÂÂÂÂÂ.probe = rad_panel_probe,
> > +ÂÂÂÂÂ.remove = rad_panel_remove,
> > +ÂÂÂÂÂ.shutdown = rad_panel_shutdown,
> > +};
> > +module_mipi_dsi_driver(rad_panel_driver);
> > +
> > +MODULE_AUTHOR("Robert Chiras <robert.chiras@xxxxxxx>");
> > +MODULE_DESCRIPTION("DRM Driver for Raydium RM67191 MIPI DSI
> > panel");
> > +MODULE_LICENSE("GPL v2");
> With the above trivialities considered/fixed:
> Reviewed-by: Sam Ravnborg <sam@xxxxxxxxxxxx>
>
> ÂÂÂÂÂÂÂÂSam