All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>,
	dri-devel@lists.freedesktop.org,
	linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <robert.foss@linaro.org>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>
Subject: Re: [PATCH v2 7/7] drm: rcar-du: dsi: Add r8a779g0 support
Date: Tue, 29 Nov 2022 14:59:19 +0200	[thread overview]
Message-ID: <d710ac65-655a-6a5a-ce6e-6dee4fd1760b@ideasonboard.com> (raw)
In-Reply-To: <Y4VlHIpS9UnvWwt/@pendragon.ideasonboard.com>

On 29/11/2022 03:49, Laurent Pinchart wrote:

>> @@ -198,70 +436,53 @@ static void rcar_mipi_dsi_parameters_calc(struct rcar_mipi_dsi *dsi,
>>   	 */
>>   	fout_target = target * mipi_dsi_pixel_format_to_bpp(dsi->format)
>>   		    / (2 * dsi->lanes);
>> -	if (fout_target < 40000000 || fout_target > 1250000000)
>> +	if (fout_target < MHZ(40) || fout_target > MHZ(1250))
>>   		return;
>>   
>>   	/* Find vco_cntrl */
>> -	for (vco_cntrl = vco_cntrl_table; vco_cntrl->min_freq != 0; vco_cntrl++) {
>> -		if (fout_target > vco_cntrl->min_freq &&
>> -		    fout_target <= vco_cntrl->max_freq) {
>> -			setup_info->vco_cntrl = vco_cntrl->value;
>> -			if (fout_target >= 1150000000)
>> -				setup_info->prop_cntrl = 0x0c;
>> -			else
>> -				setup_info->prop_cntrl = 0x0b;
>> +	for (clkset = dsi->info->clk_cfg; clkset->min_freq != 0; clkset++) {
>> +		if (fout_target > clkset->min_freq &&
>> +		    fout_target <= clkset->max_freq) {
>> +			setup_info->clkset = clkset;
>>   			break;
>>   		}
>>   	}
>>   
>> -	/* Add divider */
>> -	setup_info->div = (setup_info->vco_cntrl & 0x30) >> 4;
>> +	switch (dsi->info->model) {
>> +	case RCAR_DSI_R8A779A0:
>> +		setup_info->vclk_divider = 1 << ((clkset->vco_cntrl >> 4) & 0x3);
> 
> If you stored (clkset->vco_cntrl >> 4) & 0x3 in setup_info->vclk_divider
> you wouldn't have to use __ffs() in rcar_mipi_dsi_startup(). You could
> also drop the - 1 there, which would allow dropping one of the
> switch(dsi->info->model). You can store the real divider value in
> setup_info separately for rcar_mipi_dsi_pll_calc_r8a779a0(), or pass it
> to the function.

That's true. The reason I chose this approach was to keep dsi_setup_info 
"neutral", containing only the logical values, and the register specific 
tinkering is done only where the register is written. Mixing the logical 
and the register values in the old dsi_setup_info was confusing, and 
implementing your suggestion would again go that direction. But as you 
noticed, this is uglified a bit by the need to get the divider from the 
vco_cntrl.

We could store the logical divider in the dsi_clk_config table, though, 
which would remove the need for the above code.

  Tomi


WARNING: multiple messages have this Message-ID (diff)
From: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: devicetree@vger.kernel.org,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Jonas Karlman <jonas@kwiboo.se>,
	Magnus Damm <magnus.damm@gmail.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-renesas-soc@vger.kernel.org,
	Rob Herring <robh+dt@kernel.org>,
	Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
	Robert Foss <robert.foss@linaro.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
Subject: Re: [PATCH v2 7/7] drm: rcar-du: dsi: Add r8a779g0 support
Date: Tue, 29 Nov 2022 14:59:19 +0200	[thread overview]
Message-ID: <d710ac65-655a-6a5a-ce6e-6dee4fd1760b@ideasonboard.com> (raw)
In-Reply-To: <Y4VlHIpS9UnvWwt/@pendragon.ideasonboard.com>

On 29/11/2022 03:49, Laurent Pinchart wrote:

>> @@ -198,70 +436,53 @@ static void rcar_mipi_dsi_parameters_calc(struct rcar_mipi_dsi *dsi,
>>   	 */
>>   	fout_target = target * mipi_dsi_pixel_format_to_bpp(dsi->format)
>>   		    / (2 * dsi->lanes);
>> -	if (fout_target < 40000000 || fout_target > 1250000000)
>> +	if (fout_target < MHZ(40) || fout_target > MHZ(1250))
>>   		return;
>>   
>>   	/* Find vco_cntrl */
>> -	for (vco_cntrl = vco_cntrl_table; vco_cntrl->min_freq != 0; vco_cntrl++) {
>> -		if (fout_target > vco_cntrl->min_freq &&
>> -		    fout_target <= vco_cntrl->max_freq) {
>> -			setup_info->vco_cntrl = vco_cntrl->value;
>> -			if (fout_target >= 1150000000)
>> -				setup_info->prop_cntrl = 0x0c;
>> -			else
>> -				setup_info->prop_cntrl = 0x0b;
>> +	for (clkset = dsi->info->clk_cfg; clkset->min_freq != 0; clkset++) {
>> +		if (fout_target > clkset->min_freq &&
>> +		    fout_target <= clkset->max_freq) {
>> +			setup_info->clkset = clkset;
>>   			break;
>>   		}
>>   	}
>>   
>> -	/* Add divider */
>> -	setup_info->div = (setup_info->vco_cntrl & 0x30) >> 4;
>> +	switch (dsi->info->model) {
>> +	case RCAR_DSI_R8A779A0:
>> +		setup_info->vclk_divider = 1 << ((clkset->vco_cntrl >> 4) & 0x3);
> 
> If you stored (clkset->vco_cntrl >> 4) & 0x3 in setup_info->vclk_divider
> you wouldn't have to use __ffs() in rcar_mipi_dsi_startup(). You could
> also drop the - 1 there, which would allow dropping one of the
> switch(dsi->info->model). You can store the real divider value in
> setup_info separately for rcar_mipi_dsi_pll_calc_r8a779a0(), or pass it
> to the function.

That's true. The reason I chose this approach was to keep dsi_setup_info 
"neutral", containing only the logical values, and the register specific 
tinkering is done only where the register is written. Mixing the logical 
and the register values in the old dsi_setup_info was confusing, and 
implementing your suggestion would again go that direction. But as you 
noticed, this is uglified a bit by the need to get the divider from the 
vco_cntrl.

We could store the logical divider in the dsi_clk_config table, though, 
which would remove the need for the above code.

  Tomi


  parent reply	other threads:[~2022-11-29 12:59 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  6:59 [PATCH v2 0/7] Renesas V4H DSI & DP output support Tomi Valkeinen
2022-11-23  6:59 ` Tomi Valkeinen
2022-11-23  6:59 ` [PATCH v2 1/7] dt-bindings: display: renesas,du: Provide bindings for r8a779g0 Tomi Valkeinen
2022-11-23  6:59   ` [PATCH v2 1/7] dt-bindings: display: renesas, du: " Tomi Valkeinen
2022-11-23  6:59 ` [PATCH v2 2/7] dt-bindings: display: bridge: renesas,dsi-csi2-tx: Add r8a779g0 Tomi Valkeinen
2022-11-23  6:59   ` [PATCH v2 2/7] dt-bindings: display: bridge: renesas, dsi-csi2-tx: " Tomi Valkeinen
2022-11-23  6:59 ` [PATCH v2 3/7] clk: renesas: r8a779g0: Add display related clocks Tomi Valkeinen
2022-11-23  6:59   ` Tomi Valkeinen
2022-11-30 19:18   ` Geert Uytterhoeven
2022-11-30 19:18     ` Geert Uytterhoeven
2022-12-01  9:06     ` Tomi Valkeinen
2022-12-01  9:06       ` Tomi Valkeinen
2022-12-01  9:34       ` Geert Uytterhoeven
2022-12-01  9:34         ` Geert Uytterhoeven
2022-12-01  9:26     ` Tomi Valkeinen
2022-12-01  9:26       ` Tomi Valkeinen
2022-12-01  9:45       ` Geert Uytterhoeven
2022-12-01  9:45         ` Geert Uytterhoeven
2022-11-23  6:59 ` [PATCH v2 4/7] arm64: dts: renesas: r8a779g0: Add display related nodes Tomi Valkeinen
2022-11-23  6:59   ` Tomi Valkeinen
2022-12-01  9:20   ` Geert Uytterhoeven
2022-12-01  9:20     ` Geert Uytterhoeven
2022-11-23  6:59 ` [PATCH v2 5/7] arm64: dts: renesas: white-hawk-cpu: Add DP output support Tomi Valkeinen
2022-11-23  6:59   ` Tomi Valkeinen
2022-12-01 10:03   ` Geert Uytterhoeven
2022-12-01 10:03     ` Geert Uytterhoeven
2022-11-23  6:59 ` [PATCH v2 6/7] drm: rcar-du: Add r8a779g0 support Tomi Valkeinen
2022-11-23  6:59   ` Tomi Valkeinen
2022-11-23  6:59 ` [PATCH v2 7/7] drm: rcar-du: dsi: " Tomi Valkeinen
2022-11-23  6:59   ` Tomi Valkeinen
2022-11-29  1:49   ` Laurent Pinchart
2022-11-29  1:49     ` Laurent Pinchart
2022-11-29 11:30     ` Tomi Valkeinen
2022-11-29 11:30       ` Tomi Valkeinen
2022-11-29 11:40       ` Biju Das
2022-11-29 11:40         ` Biju Das
2022-11-29 11:49         ` Geert Uytterhoeven
2022-11-29 11:49           ` Geert Uytterhoeven
2022-11-29 12:05       ` Laurent Pinchart
2022-11-29 12:05         ` Laurent Pinchart
2022-11-29 12:59     ` Tomi Valkeinen [this message]
2022-11-29 12:59       ` Tomi Valkeinen
2022-11-29 13:41   ` [PATCH v3 7/7] drm: rcar-du: dsi: Add r8A779g0 support Tomi Valkeinen
2022-11-29 13:41     ` Tomi Valkeinen
2022-11-29 17:44     ` Laurent Pinchart
2022-11-29 17:44       ` Laurent Pinchart
2022-11-30  8:08     ` [PATCH v4 " Tomi Valkeinen
2022-11-30  8:08       ` Tomi Valkeinen
2022-11-29  1:58 ` [PATCH v2 0/7] Renesas V4H DSI & DP output support Laurent Pinchart
2022-11-29  1:58   ` Laurent Pinchart

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=d710ac65-655a-6a5a-ce6e-6dee4fd1760b@ideasonboard.com \
    --to=tomi.valkeinen+renesas@ideasonboard.com \
    --cc=andrzej.hajda@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=geert+renesas@glider.be \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=neil.armstrong@linaro.org \
    --cc=robert.foss@linaro.org \
    --cc=robh+dt@kernel.org \
    /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.