public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
To: u-boot@lists.denx.de
Subject: [patch 2/8] RFC: drivers/video/rockchip/rk_edp.c: Add rk3399 support
Date: Fri, 23 Oct 2020 13:14:49 +0300	[thread overview]
Message-ID: <3cc0a5bc-bbc7-1ef9-a85e-a74765bdee47@gmail.com> (raw)
In-Reply-To: <87d0194990.fsf@lechat.rtp-net.org>

On 23/10/2020 11:49, Arnaud Patard (Rtp) wrote:
> Alper Nebi Yasak <alpernebiyasak@gmail.com> writes:
>> I think instead of supporting both devices in the same driver, it'd be
>> cleaner to split chip-specific parts into rk3288_edp.c and rk3399_edp.c
>> like the other ones for vop, hdmi, etc; the common parts would stay here
>> in rk_edp.c, and maybe a new rk_edp.h.
> 
> From what I understand the 3288 and 3399 are using the same HW IP and
> there's no other rk SoC using it. At the beginning of this work I used
> #ifdef but in the end I found it was making the code harder to read (and
> checkpatch.pl unhappy iirc). I'm also not convinced that splitting for
> only two SoCs worths it.
> 
> btw, code inside #ifdef tends to bitrot so using runtime detection
> will at least give build testing.

I don't think anything has to be in #ifdef, chip-specific files would be
conditionally built and linked in based on Kconfig. The chip-specific
versions would be called first on driver probe, then they'd use the
common parts as they see fit.

As you said it might not be worth splitting it, I don't really know.

>>> @@ -1037,16 +1062,17 @@ static int rk_edp_probe(struct udevice *
>>>  	int vop_id = uc_plat->source_id;
>>>  	debug("%s, uc_plat=%p, vop_id=%u\n", __func__, uc_plat, vop_id);
>>>  
>>> -	ret = clk_get_by_index(dev, 1, &clk);
>>> -	if (ret >= 0) {
>>> -		ret = clk_set_rate(&clk, 0);
>>> -		clk_free(&clk);
>>> -	}
>>> -	if (ret) {
>>> -		debug("%s: Failed to set EDP clock: ret=%d\n", __func__, ret);
>>> -		return ret;
>>> +	if (edp_data->chip_type == RK3288_DP) {
>>> +		ret = clk_get_by_index(dev, 1, &clk);
>>> +		if (ret >= 0) {
>>> +			ret = clk_set_rate(&clk, 0);
>>> +			clk_free(&clk);
>>> +		}
>>> +		if (ret) {
>>> +			debug("%s: Failed to set EDP clock: ret=%d\n", __func__, ret);
>>> +			return ret;
>>> +		}
>>
>> Both these clocks don't look like they're unique to rk3288 but the
>> current code that sets them definitely is, could be split out to
>> chip-specific drivers.
>>
>> Maybe you could get and set the clocks by name for both devices in the
>> common part while checking at least one of the equivalent clocks were
>> set (but the clock driver currently ignores some clocks and e.g. sets
>> them to a known constant).
>>
> 
> I've been wondering a lot about this clock stuff and in the end, choose
> to not modify current behaviour. For instance, I'm not sure to
> understand why the clock rate is set to 0 and in linux, there's no
> difference between 3288 and 3399 clocks handling. I really think that if
> the clock part has to change, it has to be in a different patchset than
> here.

I think this is SCLK_EDP_24M, looks like the rk3288 clock driver can
configure it for 24M but not set it to a specific rate, so it ignores
the parameter and pretends it set what you gave it. On rk3399 it'd be
trying to set PCLK_EDP_CTRL (?), which its clock driver doesn't know
about.

I agree clock changes would be better in a different patchset (unless
you'd go with the chip-specific files and want to maximize the common
parts).

>>> @@ -232,8 +232,9 @@ check_member(rk3288_edp, pll_reg_5, 0xa0
>>>  #define PD_CH0					(0x1 << 0)
>>>  
>>>  /* pll_reg_1 */
>>> -#define REF_CLK_24M				(0x1 << 1)
>>> -#define REF_CLK_27M				(0x0 << 1)
>>> +#define REF_CLK_24M				(0x1 << 0)
>>> +#define REF_CLK_27M				(0x0 << 0)
>>> +#define REF_CLK_MASK				(0x1 << 0)
>>
>> AFAIK the old definitions were already wrong and just happened to work
>> because both set bit-0 to 0, which chooses 24M on rk3288, which is what
>> was requested anyway. As I said above, you might define the two
>> constants here differently with #if defined(CONFIG_ROCKCHIP_RK3399).
> 
> why using two set of constants ? there's no difference on linux for
> this between rk3399 and rk3288. I'm only fixing things according to
> what's done in linux. See
> drivers/gpu/drm/bridge/analogix/analogix_dp_reg.{c,h}.

I assumed the meaning of the bit was explicitly chosen to be different
for the two chips, so I though that'd match the hardware better
semantically. But Linux commit 7bdc07208693 ("drm/bridge: analogix_dp:
some rockchip chips need to flip REF_CLK bit setting") which adds that
bit flipping code says it's due to a "IC PHY layout mistake" so I guess
I was wrong about that.

  reply	other threads:[~2020-10-23 10:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25 18:36 [patch 0/8] RFC: Pinebook pro EDP support Arnaud Patard
2020-09-25 18:36 ` [patch 1/8] RFC: drivers/video/rockchip/rk_vop.c: Use endpoint compatible string to find VOP mode Arnaud Patard
2020-09-28  2:44   ` Kever Yang
2020-09-25 18:36 ` [patch 2/8] RFC: drivers/video/rockchip/rk_edp.c: Add rk3399 support Arnaud Patard
2020-10-22 18:32   ` Alper Nebi Yasak
2020-10-23  8:49     ` Arnaud Patard
2020-10-23 10:14       ` Alper Nebi Yasak [this message]
2020-09-25 18:36 ` [patch 3/8] RFC: drivers/video/rockchip/rk_edp.c: Change interrupt polarity configuration Arnaud Patard
2020-10-22 18:39   ` Alper Nebi Yasak
2020-10-23  8:51     ` Arnaud Patard
2020-09-25 18:36 ` [patch 4/8] RFC: drivers/video/rockchip/rk_edp.c: Change clock rate Arnaud Patard
2020-10-22 18:49   ` Alper Nebi Yasak
2020-10-23  9:01     ` Arnaud Patard
2020-09-25 18:36 ` [patch 5/8] RFC: drivers/video/rockchip/rk_vop.c: Reserve efi fb memory Arnaud Patard
2020-09-25 18:37 ` [patch 6/8] RFC: rk3399-pinebook-pro-u-boot.dtsi: Enable edp Arnaud Patard
2020-09-25 18:37 ` [patch 7/8] RFC: configs/pinebook-pro-rk3399_defconfig: enable SYS_USB_EVENT_POLL_VIA_INT_QUEUE Arnaud Patard
2020-09-25 18:37 ` [patch 8/8] RFC: drivers/pwm/rk_pwm.c: Fix default polarity Arnaud Patard
2020-09-27 15:53 ` [patch 0/8] RFC: Pinebook pro EDP support Alper Nebi Yasak
2020-09-28  6:41   ` Arnaud Patard
2020-09-28 17:18     ` Alper Nebi Yasak

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=3cc0a5bc-bbc7-1ef9-a85e-a74765bdee47@gmail.com \
    --to=alpernebiyasak@gmail.com \
    --cc=u-boot@lists.denx.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