All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Looijmans <mike.looijmans@topic.nl>
To: Marek Vasut <marex@denx.de>, dri-devel@lists.freedesktop.org
Cc: Loic Poulain <loic.poulain@linaro.org>,
	ch@denx.de, Douglas Anderson <dianders@chromium.org>,
	Stephen Boyd <swboyd@chromium.org>,
	Philippe Schenker <philippe.schenker@toradex.com>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Valentin Raevsky <valentin@compulab.co.il>,
	Sam Ravnborg <sam@ravnborg.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: Re: [V3, 2/2] drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 driver
Date: Tue, 25 May 2021 14:08:42 +0200	[thread overview]
Message-ID: <27f1e433-3290-c5ea-d338-83906ef10b3f@topic.nl> (raw)
In-Reply-To: <61fe258a-c89b-ffa8-2773-0e7eef35b612@denx.de>

See below...


Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert


TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands

T: +31 (0) 499 33 69 69
E: mike.looijmans@topicproducts.com
W: www.topic.nl

Please consider the environment before printing this e-mail
On 25-05-2021 12:53, Marek Vasut wrote:
> On 5/17/21 3:23 PM, Mike Looijmans wrote:
>
> Which system/soc are you testing this on ?

On a raspberry-pi 4 at the moment.

>
> [...]
>
>>> +static void sn65dsi83_pre_enable(struct drm_bridge *bridge)
>>> +{
>>> +    struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge);
>>> +
>>> +    /*
>>> +     * Reset the chip, pull EN line low for t_reset=10ms,
>>> +     * then high for t_en=1ms.
>>> +     */
>>> +    regcache_mark_dirty(ctx->regmap);
>>> +    gpiod_set_value(ctx->enable_gpio, 0);
>>> +    usleep_range(10000, 11000);
>>> +    gpiod_set_value(ctx->enable_gpio, 1);
>>> +    usleep_range(1000, 1100);
>> Taking the chip out of reset here is not needed and may even disrupt 
>> things, as the DSI hasn't set up anything yet so the clock may not be 
>> running. I'd move this all into enable and get rid of the pre_enable 
>> call. Similar for post_disable.
>
> I am still waiting for someone to confirm the behavior of the DSI 
> clock and data lanes in pre_enable/enable() . The datasheet says the 
> HS clock have to be running and data lanes must be in LP state during 
> init, but I don't think that is guaranteed currently in either 
> pre_enable or enable.

Neither is suited. pre-enable may have nothing, while enable has the 
data lanes sending video according to the docs. So on many systems 
either this driver or the DSI driver will need changes to make it work 
properly.

On the raspberrypi, the DSI has the clock running in pre-enable, hence 
putting everything in pre-enable instead of in enable makes the chip work.

Alternatively, one can modify the RPi DSI code to start sending data 
after the enable calls. That also works on my setup, with everything in 
enable.

The major point here is that you should pick one and only one callback: 
pre-enable or enable. The GPIO reset code as well as writing the 
registers should be done in that one method.

Same for (post)disable for symmetry. There's no point keeping the chip 
awake after a disable.


It's pretty likely for a DSI driver to have the clock active in order to 
allow the panel driver to send MIPI commands and things like that. So 
everything in pre_enable makes sense.

I don't know how the platform you're testing on is behaving in this respect?


>
> [...]
>
>>> +static void sn65dsi83_enable(struct drm_bridge *bridge)
>>> +{
>>> +    struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge);
>>> +    unsigned int pval;
>>> +    u16 val;
>>> +    int ret;
>>> +
>>> +    /* Clear reset, disable PLL */
>>> +    regmap_write(ctx->regmap, REG_RC_RESET, 0x00);
>> Writing 0 to the RESET register is a no-op. Has no effect whatsoever, 
>> just wasting time and code.
>
> I would rather keep it to make sure the register is initialized.

Why? It's marked "volatile" so the regmap cache will not touch it. On 
the I2C level, there's absolutely no reason to do this.

>
>>> +    regmap_write(ctx->regmap, REG_RC_PLL_EN, 0x00);
>>> +
>>> +    /* Reference clock derived from DSI link clock. */
>>> +    regmap_write(ctx->regmap, REG_RC_LVDS_PLL,
>>> + REG_RC_LVDS_PLL_LVDS_CLK_RANGE(sn65dsi83_get_lvds_range(ctx)) |
>>> +        REG_RC_LVDS_PLL_HS_CLK_SRC_DPHY);
>>> +    regmap_write(ctx->regmap, REG_DSI_CLK,
>>> + REG_DSI_CLK_CHA_DSI_CLK_RANGE(sn65dsi83_get_dsi_range(ctx)));
>>> +    regmap_write(ctx->regmap, REG_RC_DSI_CLK,
>>> + REG_RC_DSI_CLK_DSI_CLK_DIVIDER(sn65dsi83_get_dsi_div(ctx)));
>>> +
>>> +    /* Set number of DSI lanes and LVDS link config. */
>>> +    regmap_write(ctx->regmap, REG_DSI_LANE,
>>> +        REG_DSI_LANE_LVDS_LINK_CFG_DUAL |
>>> +        REG_DSI_LANE_CHA_DSI_LANES(~(ctx->dsi_lanes - 1)) |
>>> +        /* CHB is DSI85-only, set to default on DSI83/DSI84 */
>>> +        REG_DSI_LANE_CHB_DSI_LANES(3));
>>> +    /* No equalization. */
>>> +    regmap_write(ctx->regmap, REG_DSI_EQ, 0x00);
>>> +
>>> +    /* RGB888 is the only format supported so far. */
>>> +    val = (ctx->mode.flags & DRM_MODE_FLAG_NHSYNC ?
>>> +           REG_LVDS_FMT_HS_NEG_POLARITY : 0) |
>>> +          (ctx->mode.flags & DRM_MODE_FLAG_NVSYNC ?
>>> +           REG_LVDS_FMT_VS_NEG_POLARITY : 0) |
>>> +          REG_LVDS_FMT_CHA_24BPP_MODE;
>>> +    if (ctx->lvds_dual_link)
>>> +        val |= REG_LVDS_FMT_CHB_24BPP_MODE;
>>> +    else
>>> +        val |= REG_LVDS_FMT_LVDS_LINK_CFG;
>>> +
>>> +    regmap_write(ctx->regmap, REG_LVDS_FMT, val);
>>> +    regmap_write(ctx->regmap, REG_LVDS_VCOM, 0x05);
>>> +    regmap_write(ctx->regmap, REG_LVDS_LANE,
>>> +        (ctx->lvds_dual_link_even_odd_swap ?
>>> +         REG_LVDS_LANE_EVEN_ODD_SWAP : 0) |
>>> +        REG_LVDS_LANE_CHA_LVDS_TERM |
>>> +        REG_LVDS_LANE_CHB_LVDS_TERM);
>>> +    regmap_write(ctx->regmap, REG_LVDS_CM, 0x00);
>>> +
>>> +    regmap_bulk_write(ctx->regmap, REG_VID_CHA_ACTIVE_LINE_LENGTH_LOW,
>>> +              &ctx->mode.hdisplay, 2);
>>
>> I think this ignores the endian format of the data. So this would 
>> only work on little-endian systems, right?
>
> Likely, can you double-check that ?
> Some cpu_to_le16() could help here then.

I'd add a small helper function that does the endian conversion and 
register write, e.g.

static int sn65dsi83_write16bit(struct sn65dsi83 *ctx, unsigned int reg, 
u16 value)


>>> +    regmap_bulk_write(ctx->regmap, 
>>> REG_VID_CHA_VERTICAL_DISPLAY_SIZE_LOW,
>>> +              &ctx->mode.vdisplay, 2);
>>> +    val = 32 + 1;    /* 32 + 1 pixel clock to ensure proper 
>>> operation */
>>> +    regmap_bulk_write(ctx->regmap, REG_VID_CHA_SYNC_DELAY_LOW, 
>>> &val, 2);
>>> +    val = ctx->mode.hsync_end - ctx->mode.hsync_start;
>
> [...]


-- 
Mike Looijmans


  reply	other threads:[~2021-05-25 12:09 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 10:02 [PATCH V3 1/2] dt-bindings: drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 bindings Marek Vasut
2021-05-05 10:02 ` Marek Vasut
2021-05-05 10:02 ` [PATCH V3 2/2] drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 driver Marek Vasut
2021-05-05 12:42   ` Linus Walleij
2021-05-06  9:45   ` Dave Stevenson
2021-05-06 12:48     ` Marek Vasut
2021-05-06 13:03       ` Laurent Pinchart
2021-05-06 14:57         ` Marek Vasut
2021-05-06 17:03       ` Dave Stevenson
2021-05-06 20:49         ` Marek Vasut
2021-05-07  8:55           ` Dave Stevenson
2021-05-06 15:38   ` Frieder Schrempf
2021-05-06 15:46     ` Marek Vasut
2021-05-06 16:03       ` Frieder Schrempf
2021-05-06 20:51         ` Marek Vasut
2021-05-07  9:17           ` Dave Stevenson
2021-05-08 20:10             ` Marek Vasut
2021-05-07 12:48   ` Dave Stevenson
2021-05-08 20:16     ` Marek Vasut
2021-05-10  9:58       ` Dave Stevenson
2021-05-10 11:16         ` Marek Vasut
2021-05-10 18:04           ` Dave Stevenson
2021-05-10 19:29             ` Marek Vasut
     [not found]   ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.d251689f-a6ba-486d-bfa1-070ac0c167d5@emailsignatures365.codetwo.com>
     [not found]     ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.0d2bd5fa-15cc-4b27-b94e-83614f9e5b38.81349e00-3f39-4654-ab28-8c85568d0c51@emailsignatures365.codetwo.com>
2021-05-17 13:23       ` [V3, " Mike Looijmans
2021-05-25 10:53         ` Marek Vasut
2021-05-25 12:08           ` Mike Looijmans [this message]
2021-05-25 13:00             ` Marek Vasut
2021-05-25 14:23               ` Mike Looijmans
2021-05-25 14:42                 ` Marek Vasut
2021-05-25 15:16                   ` Mike Looijmans
2021-05-05 12:38 ` [PATCH V3 1/2] dt-bindings: drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 bindings Linus Walleij
2021-05-05 12:38   ` Linus Walleij
2021-05-07  1:00 ` Rob Herring
2021-05-07  1:00   ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=27f1e433-3290-c5ea-d338-83906ef10b3f@topic.nl \
    --to=mike.looijmans@topic.nl \
    --cc=ch@denx.de \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jagan@amarulasolutions.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=loic.poulain@linaro.org \
    --cc=marex@denx.de \
    --cc=philippe.schenker@toradex.com \
    --cc=sam@ravnborg.org \
    --cc=swboyd@chromium.org \
    --cc=valentin@compulab.co.il \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.