Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] drm/panel: missing prepare_prev_first = true in nt36525_probe()
- [Medium] drm/panel: vpos, vneg, and backlight in nt36525_probe()
  mismatch DT binding
- [Medium] drm/panel: inverted gpiod logical polarity for reset_gpio in
  nt36525
- [Low] drm/panel: negative return and open-coded helper in
  nt36525_get_modes()
--

commit bba87e5acae9fff577a4366212e7273dead1f8e4
Author: Adil Hüsrev Tepe <[email protected]>

drm/panel: add Novatek NT36525 panel driver

This commit adds a DRM panel driver for Novatek NT36525-based MIPI-DSI
video-mode panels used in the Samsung Galaxy XCover5.

> diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36525.c 
> b/drivers/gpu/drm/panel/panel-novatek-nt36525.c
> new file mode 100644
> index 0000000000000..246476af49b15
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-novatek-nt36525.c
[ ... ]
> +static int nt36525_prepare(struct drm_panel *panel)
> +{
> +     struct nt36525 *p = panel_to_nt36525(panel);
> +     int ret;
> +
> +     /* Power-up sequence from Samsung decon_board_nt36525 
> panel_power_enable */
> +     ret = regulator_enable(p->vdd);
> +     if (ret)
> +             return ret;
> +     usleep_range(1000, 1500);
> +     ret = regulator_enable(p->vpos);
> +     if (ret)
> +             goto disable_vdd;
> +     usleep_range(1000, 1500);
> +     ret = regulator_enable(p->vneg);
> +     if (ret)
> +             goto disable_vpos;
> +     usleep_range(1000, 1500);
> +
> +     /* Reset pulse, Samsung sequence from panel_reset */
> +     usleep_range(10000, 11000);
> +     gpiod_set_value_cansleep(p->reset_gpio, 1);
> +     usleep_range(1000, 1500);
> +     gpiod_set_value_cansleep(p->reset_gpio, 0);
> +     usleep_range(3500, 4000);
> +     gpiod_set_value_cansleep(p->reset_gpio, 1);
> +     usleep_range(10000, 11000);
> +
> +     ret = nt36525_on(p);
> +     if (ret)
> +             goto fail;
> +
> +     return 0;
> +
> +fail:
> +     gpiod_set_value_cansleep(p->reset_gpio, 0);
> +     regulator_disable(p->vneg);
> +     usleep_range(1000, 1500);
> +disable_vpos:
> +     regulator_disable(p->vpos);
> +     usleep_range(5000, 5500);
> +disable_vdd:
> +     regulator_disable(p->vdd);
> +     return ret;
> +}
> +
> +static int nt36525_unprepare(struct drm_panel *panel)
> +{
> +     struct nt36525 *p = panel_to_nt36525(panel);
> +     struct mipi_dsi_multi_context ctx = { .dsi = p->dsi };
> +
> +     mipi_dsi_dcs_set_display_off_multi(&ctx);
> +     mipi_dsi_msleep(&ctx, 20);
> +     mipi_dsi_dcs_enter_sleep_mode_multi(&ctx);
> +     mipi_dsi_msleep(&ctx, 60);
> +
> +     usleep_range(3000, 3500);
> +     regulator_disable(p->vneg);
> +     usleep_range(1000, 1500);
> +     regulator_disable(p->vpos);
> +     usleep_range(5000, 5500);
> +     regulator_disable(p->vdd);
> +     msleep(30);
> +     gpiod_set_value_cansleep(p->reset_gpio, 0);
> +     return 0;
> +}

[Severity: Medium]
Are the gpiod logical states for p->reset_gpio inverted across
nt36525_prepare(), nt36525_unprepare(), and nt36525_probe()?

As noted in the comment in nt36525_probe() ("Request RESX released (high)
rather than asserting it here"), the hardware RESX pin is active-low
(physical 0 asserts reset, physical 1 releases it).  Under the gpiod API
and panel-common.yaml, logical 1 (GPIOD_OUT_HIGH) means reset asserted and
logical 0 (GPIOD_OUT_LOW) means reset deasserted, with the physical
inversion described via GPIO_ACTIVE_LOW in Device Tree.

Passing physical levels directly means a Device Tree using standard
GPIO_ACTIVE_LOW polarity holds the panel in reset during nt36525_on() and
releases reset when powering off, or else has to misdeclare the active-low
pin as GPIO_ACTIVE_HIGH.

> +static int nt36525_get_modes(struct drm_panel *panel, struct drm_connector 
> *conn)
> +{
> +     struct drm_display_mode *m;
> +
> +     m = drm_mode_duplicate(conn->dev, &nt36525_xcover5_mode);
> +     if (!m)
> +             return -ENOMEM;
> +     drm_mode_set_name(m);
> +     drm_mode_probed_add(conn, m);
> +     conn->display_info.width_mm = m->width_mm;
> +     conn->display_info.height_mm = m->height_mm;
> +     return 1;
> +}

[Severity: Low]
Can nt36525_get_modes() use drm_connector_helper_get_modes_fixed(conn,
&nt36525_xcover5_mode) instead of open-coding mode duplication?

drm_helper_probe_get_modes() expects .get_modes() callbacks to return the
number of modes (0 on failure) and logs a drm_err() if a negative error
code such as -ENOMEM is returned.  drm_connector_helper_get_modes_fixed()
handles duplicating the mode, setting its name, updating display_info
dimensions, and returning 0 on failure.

[ ... ]
> +static int nt36525_probe(struct mipi_dsi_device *dsi)
> +{
> +     struct device *dev = &dsi->dev;
> +     struct nt36525 *p;
> +     int ret;
> +
> +     p = devm_drm_panel_alloc(dev, struct nt36525, panel, &nt36525_funcs,
> +                              DRM_MODE_CONNECTOR_DSI);
> +     if (IS_ERR(p))
> +             return PTR_ERR(p);
> +
> +     p->dsi = dsi;
> +     ret = drm_panel_of_backlight(&p->panel);
> +     if (ret)
> +             return ret;
> +
> +     p->vdd = devm_regulator_get(dev, "vdd");
> +     if (IS_ERR(p->vdd))
> +             return dev_err_probe(dev, PTR_ERR(p->vdd), "vdd supply\n");
> +
> +     p->vpos = devm_regulator_get(dev, "vpos");
> +     if (IS_ERR(p->vpos))
> +             return dev_err_probe(dev, PTR_ERR(p->vpos), "vpos supply\n");
> +
> +     p->vneg = devm_regulator_get(dev, "vneg");
> +     if (IS_ERR(p->vneg))
> +             return dev_err_probe(dev, PTR_ERR(p->vneg), "vneg supply\n");

[Severity: Medium]
Do the vpos, vneg, and backlight properties requested here match the DT
binding in Documentation/devicetree/bindings/display/panel/novatek,nt36525.yaml?

The binding schema only defines compatible, reg, reset-gpios, vdd-supply,
and port with additionalProperties: false.  A Device Tree conforming to
that schema will lack vpos-supply, vneg-supply, and backlight, causing
devm_regulator_get() to fall back to dummy regulators with a warning
(leaving the positive and negative LCD bias supplies unswitched) and
drm_panel_of_backlight() to find no backlight, while a Device Tree that
includes them will fail dtbs_check.

[ ... ]
> +     dsi->mode_flags  = MIPI_DSI_MODE_VIDEO          /* video (non-burst) */
> +                      | MIPI_DSI_MODE_VIDEO_SYNC_PULSE
> +                      | MIPI_DSI_MODE_LPM            /* force LP for all 
> transfers */
> +                      | MIPI_DSI_CLOCK_NON_CONTINUOUS;
> +
> +     drm_panel_add(&p->panel);

[Severity: High]
Should p->panel.prepare_prev_first = true be set before calling
drm_panel_add(&p->panel)?

drm_panel_add() copies panel->prepare_prev_first into
panel->bridge.pre_enable_prev_first.  Because it is left false,
drm_atomic_bridge_chain_pre_enable() calls nt36525_prepare() ->
nt36525_on() before the upstream DSI host bridge's atomic_pre_enable()
callback, and drm_atomic_bridge_chain_post_disable() disables the upstream
DSI host bridge before nt36525_unprepare() sends display-off and sleep-in
commands.  On bridge-based DSI hosts such as samsung-dsim, transfers sent
while DSIM_STATE_ENABLED is cleared are rejected by
samsung_dsim_host_transfer() with -EINVAL, causing panel bring-up and
power-down to fail.

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=2

Reply via email to