devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Heiko Stübner" <heiko@sntech.de>
To: vkoul@kernel.org, kishon@kernel.org, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org,
	Frank Wang <frawang.cn@gmail.com>,
	Shawn Lin <shawn.lin@rock-chips.com>
Cc: shawn.lin@rock-chips.com, linux-phy@lists.infradead.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
	william.wu@rock-chips.com, tim.chen@rock-chips.com,
	Kever Yang <kever.yang@rock-chips.com>,
	Frank Wang <frank.wang@rock-chips.com>
Subject: Re: [PATCH 2/2] phy: rockchip-naneng-combo: Support rk3576
Date: Tue, 15 Oct 2024 10:47:23 +0200	[thread overview]
Message-ID: <1904911.CQOukoFCf9@diego> (raw)
In-Reply-To: <aac59920-db0b-4b3a-af1b-58e8e4d3a08b@rock-chips.com>

Hi Shawn,

Am Dienstag, 15. Oktober 2024, 10:39:28 CEST schrieb Shawn Lin:
> 在 2024/10/15 14:15, Heiko Stübner 写道:
> > Am Dienstag, 15. Oktober 2024, 03:33:51 CEST schrieb Frank Wang:
> >> From: Kever Yang <kever.yang@rock-chips.com>
> >>
> 
> ...
> 
> >> +			writel(0x02, priv->mmio + (0xb << 2));
> >> +			writel(0x57, priv->mmio + (0xd << 2));
> >> +
> >> +			writel(0x5f, priv->mmio + (0xf << 2));
> > 
> > This does includes both the value as well as the register addresses,
> > because a hex-value with a bit shift makes that even less readable.
> > 
> 
> Actually, it's more readable when we need to debug, IMO. Because the
> PHY document provided is listing the registers just like what the patch
> did(0xb/0xd/0xf). So for example, we could easily find 0xb in the 
> document, which refers to su_trim[15:8].

Documentation-wise the rk3576 has gotten worse, compared to the
rk3588 and before.  I guess you're refering to a document that is not
part of the trm-part1 pdf I guess.

So I guess using register numbers somewhat matching the sparse
document you have can be fine, but I guess try to use constants where
possible.

The block above though at least needs a comment about what is
happening there.


Heiko

> >> +		}
> >> +		break;
> >> +	case REF_CLOCK_25MHz:
> >> +		rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_clk_25m, true);
> >> +		break;
> >> +	case REF_CLOCK_100MHz:
> >> +		rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_clk_100m, true);
> >> +		if (priv->type == PHY_TYPE_PCIE) {
> >> +			/* gate_tx_pck_sel length select work for L1SS */
> >> +			writel(0xc0, priv->mmio + 0x74);
> >> +
> >> +			/* PLL KVCO tuning fine */
> >> +			rockchip_combphy_updatel(priv, GENMASK(4, 2), 0x4 << 2, 0x20 << 2);
> >> +
> >> +			/* Set up rx_trim: PLL LPF C1 85pf R1 1.25kohm */
> >> +			writel(0x4c, priv->mmio + (0x1b << 2));
> >> +
> >> +			/* Set up su_trim: T3_P1 650mv */
> >> +			writel(0x90, priv->mmio + (0xa << 2));
> >> +			writel(0x43, priv->mmio + (0xb << 2));
> >> +			writel(0x88, priv->mmio + (0xc << 2));
> >> +			writel(0x56, priv->mmio + (0xd << 2));
> >> +		} else if (priv->type == PHY_TYPE_SATA) {
> >> +			/* downward spread spectrum +500ppm */
> >> +			rockchip_combphy_updatel(priv, GENMASK(7, 4), 0x50, 0x1f << 2);
> >> +
> >> +			/* ssc ppm adjust to 3500ppm */
> >> +			rockchip_combphy_updatel(priv, GENMASK(3, 0), 0x7, 0x9 << 2);
> >> +		}
> >> +		break;
> >> +	default:
> >> +		dev_err(priv->dev, "Unsupported rate: %lu\n", rate);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	if (priv->ext_refclk) {
> >> +		rockchip_combphy_param_write(priv->phy_grf, &cfg->pipe_clk_ext, true);
> >> +		if (priv->type == PHY_TYPE_PCIE && rate == REF_CLOCK_100MHz) {
> >> +			writel(0x10, priv->mmio + (0x20 << 2));
> >> +
> >> +			writel(0x0c, priv->mmio + (0x1b << 2));
> >> +
> >> +			/* Set up su_trim: T3_P1 650mv */
> >> +			writel(0x90, priv->mmio + (0xa << 2));
> >> +			writel(0x43, priv->mmio + (0xb << 2));
> >> +			writel(0x88, priv->mmio + (0xc << 2));
> >> +			writel(0x56, priv->mmio + (0xd << 2));
> >> +		}
> >> +	}
> >> +
> >> +	if (priv->enable_ssc) {
> >> +		rockchip_combphy_updatel(priv, GENMASK(4, 4), BIT(4), 0x7 << 2);
> >> +
> >> +		if (priv->type == PHY_TYPE_PCIE && rate == REF_CLOCK_24MHz) {
> >> +			/* Xin24M T0_1 650mV */
> >> +			writel(0x00, priv->mmio + (0x10 << 2));
> >> +			writel(0x32, priv->mmio + (0x11 << 2));
> >> +			writel(0x00, priv->mmio + (0x1b << 2));
> >> +			writel(0x90, priv->mmio + (0x0a << 2));
> >> +			writel(0x02, priv->mmio + (0x0b << 2));
> >> +			writel(0x08, priv->mmio + (0x0c << 2));
> >> +			writel(0x57, priv->mmio + (0x0d << 2));
> >> +			writel(0x40, priv->mmio + (0x0e << 2));
> >> +			writel(0x5f, priv->mmio + (0x0f << 2));
> >> +			writel(0x10, priv->mmio + (0x20 << 2));
> >> +		}
> >> +	}
> >> +
> >> +	return 0;
> >> +}
> > 
> > 
> > 
> > 
> > _______________________________________________
> > Linux-rockchip mailing list
> > Linux-rockchip@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-rockchip
> 
> 





  parent reply	other threads:[~2024-10-15  8:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-15  1:33 [PATCH 1/2] dt-bindings: phy: rockchip: add rk3576 compatible Frank Wang
2024-10-15  1:33 ` [PATCH 2/2] phy: rockchip-naneng-combo: Support rk3576 Frank Wang
2024-10-15  6:15   ` Heiko Stübner
2024-10-15  6:58     ` Frank Wang
     [not found]     ` <aac59920-db0b-4b3a-af1b-58e8e4d3a08b@rock-chips.com>
2024-10-15  8:47       ` Heiko Stübner [this message]
2024-10-15  6:06 ` [PATCH 1/2] dt-bindings: phy: rockchip: add rk3576 compatible Heiko Stübner
2024-10-15 20:20 ` Rob Herring (Arm)

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=1904911.CQOukoFCf9@diego \
    --to=heiko@sntech.de \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frank.wang@rock-chips.com \
    --cc=frawang.cn@gmail.com \
    --cc=kever.yang@rock-chips.com \
    --cc=kishon@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=robh@kernel.org \
    --cc=shawn.lin@rock-chips.com \
    --cc=tim.chen@rock-chips.com \
    --cc=vkoul@kernel.org \
    --cc=william.wu@rock-chips.com \
    /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;
as well as URLs for NNTP newsgroup(s).