From: Andrej Picej <andrej.picej@norik.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, upstream@lists.phytec.de,
andrzej.hajda@intel.com, neil.armstrong@linaro.org,
rfoss@kernel.org, Laurent.pinchart@ideasonboard.com,
jonas@kwiboo.se, jernej.skrabec@gmail.com, airlied@gmail.com,
simona@ffwll.ch, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, tzimmermann@suse.de, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com, marex@denx.de
Subject: Re: [PATCH v6 2/3] drm/bridge: ti-sn65dsi83: Add ti,lvds-vod-swing optional properties
Date: Fri, 13 Dec 2024 07:57:30 +0100 [thread overview]
Message-ID: <cdf8cff7-543c-4a28-bf2e-bc7f331d0db5@norik.com> (raw)
In-Reply-To: <45f90007-3136-4b59-a3fc-6fc0147b8ad8@wanadoo.fr>
Hi Christophe,
On 12. 12. 24 13:33, Christophe JAILLET wrote:
> Le 12/12/2024 à 13:17, Andrej Picej a écrit :
>> Add a optional properties to change LVDS output voltage. This should not
>> be static as this depends mainly on the connected display voltage
>> requirement. We have three properties:
>> - "ti,lvds-termination-ohms", which sets near end termination,
>> - "ti,lvds-vod-swing-data-microvolt" and
>> - "ti,lvds-vod-swing-clock-microvolt" which both set LVDS differential
>> output voltage for data and clock lanes. They are defined as an array
>> with min and max values. The appropriate bitfield will be set if
>> selected constraints can be met.
>>
>> If "ti,lvds-termination-ohms" is not defined the default of 200 Ohm near
>> end termination will be used. Selecting only one:
>> "ti,lvds-vod-swing-data-microvolt" or
>> "ti,lvds-vod-swing-clock-microvolt" can be done, but the output voltage
>> constraint for only data/clock lanes will be met. Setting both is
>> recommended.
>
> ...
>
>> +static int sn65dsi83_select_lvds_vod_swing(struct device *dev,
>> + u32 lvds_vod_swing_data[2], u32 lvds_vod_swing_clk[2], u8 lvds_term)
>> +{
>> + int i;
>> +
>> + for (i = 0; i <= 3; i++) {
>> + if (lvds_vod_swing_data_table[lvds_term][i][0] >=
>> lvds_vod_swing_data[0] &&
>> + lvds_vod_swing_data_table[lvds_term][i][1] <=
>> lvds_vod_swing_data[1] &&
>> + lvds_vod_swing_clock_table[lvds_term][i][0] >=
>> lvds_vod_swing_clk[0] &&
>> + lvds_vod_swing_clock_table[lvds_term][i][1] <=
>> lvds_vod_swing_clk[1])
>
> Adding a few spaces to align things would help reading.
Ok, that makes sense, will fix.
>
>> + return i;
>> + }
>> +
>> + dev_err(dev, "failed to find appropriate LVDS_VOD_SWING
>> configuration\n");
>> + return -EINVAL;
>> +}
>> +
>> +static int sn65dsi83_parse_lvds_endpoint(struct sn65dsi83 *ctx, int
>> channel)
>> +{
>> + struct device *dev = ctx->dev;
>> + struct device_node *endpoint;
>> + int endpoint_reg;
>> + /* Set so the property can be freely selected if not defined */
>> + u32 lvds_vod_swing_data[2] = { 0, 1000000 };
>> + u32 lvds_vod_swing_clk[2] = { 0, 1000000 };
>> + /* Set default near end terminataion to 200 Ohm */
>> + u32 lvds_term = 200;
>> + int lvds_vod_swing_conf;
>> + int ret = 0;
>> + int ret_data;
>> + int ret_clock;
>> +
>> + if (channel == CHANNEL_A)
>> + endpoint_reg = 2;
>> + else
>> + endpoint_reg = 3;
>> +
>> + endpoint = of_graph_get_endpoint_by_regs(dev->of_node,
>> endpoint_reg, -1);
>> +
>> + of_property_read_u32(endpoint, "ti,lvds-termination-ohms",
>> &lvds_term);
>> + if (lvds_term == 100)
>> + ctx->lvds_term_conf[channel] = OHM_100;
>> + else if (lvds_term == 200)
>> + ctx->lvds_term_conf[channel] = OHM_200;
>> + else
>> + return -EINVAL;
>
> Should it be:
> else {
> ret = -EINVAL;
> goto exit;
> }
> ?
Of course, good catch. Thanks.
Best regards,
Andrej.
>
>> +
>> + ret_data = of_property_read_u32_array(endpoint,
>> "ti,lvds-vod-swing-data-microvolt",
>> + lvds_vod_swing_data,
>> ARRAY_SIZE(lvds_vod_swing_data));
>> + if (ret_data != 0 && ret_data != -EINVAL) {
>> + ret = ret_data;
>> + goto exit;
>> + }
>> +
>> + ret_clock = of_property_read_u32_array(endpoint,
>> "ti,lvds-vod-swing-clock-microvolt",
>> + lvds_vod_swing_clk, ARRAY_SIZE(lvds_vod_swing_clk));
>> + if (ret_clock != 0 && ret_clock != -EINVAL) {
>> + ret = ret_clock;
>> + goto exit;
>> + }
>> +
>> + /* Use default value if both properties are NOT defined. */
>> + if (ret_data == -EINVAL && ret_clock == -EINVAL)
>> + lvds_vod_swing_conf = 0x1;
>> +
>> + /* Use lookup table if any of the two properties is defined. */
>> + if (!ret_data || !ret_clock) {
>> + lvds_vod_swing_conf = sn65dsi83_select_lvds_vod_swing(dev,
>> lvds_vod_swing_data,
>> + lvds_vod_swing_clk,
>> ctx->lvds_term_conf[channel]);
>> + if (lvds_vod_swing_conf < 0) {
>> + ret = lvds_vod_swing_conf;
>> + goto exit;
>> + }
>> + }
>> +
>> + ctx->lvds_vod_swing_conf[channel] = lvds_vod_swing_conf;
>> + ret = 0;
>> +exit:
>> + of_node_put(endpoint);
>> + return ret;
>> +}
>
> ...
>
> CJ
next prev parent reply other threads:[~2024-12-13 6:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 12:17 [PATCH v6 0/3] SN65DSI83/4 lvds_vod_swing properties Andrej Picej
2024-12-12 12:17 ` [PATCH v6 1/3] dt-bindings: drm/bridge: ti-sn65dsi83: Add properties for ti,lvds-vod-swing Andrej Picej
2024-12-12 12:17 ` [PATCH v6 2/3] drm/bridge: ti-sn65dsi83: Add ti,lvds-vod-swing optional properties Andrej Picej
2024-12-12 12:33 ` Christophe JAILLET
2024-12-13 6:57 ` Andrej Picej [this message]
2024-12-12 12:17 ` [PATCH v6 3/3] arm64: dts: imx8mm-phyboard-polis-peb-av-10: Set lvds-vod-swing Andrej Picej
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=cdf8cff7-543c-4a28-bf2e-bc7f331d0db5@norik.com \
--to=andrej.picej@norik.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=marex@denx.de \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=upstream@lists.phytec.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox