Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 336DCC7618E for ; Fri, 21 Apr 2023 09:30:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C3B488617E; Fri, 21 Apr 2023 11:30:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 94E2786178; Fri, 21 Apr 2023 11:30:37 +0200 (CEST) Received: from mail-m118111.qiye.163.com (mail-m118111.qiye.163.com [115.236.118.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7ED2885D4A for ; Fri, 21 Apr 2023 11:30:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kever.yang@rock-chips.com Received: from [172.16.12.93] (unknown [58.22.7.114]) by mail-m118111.qiye.163.com (Hmail) with ESMTPA id C464B5801A0; Fri, 21 Apr 2023 17:30:23 +0800 (CST) Message-ID: Date: Fri, 21 Apr 2023 17:30:23 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 4/7] phy: rockchip: naneng-combphy: Support rk3588 Content-Language: en-US To: Eugen Hristev , u-boot@lists.denx.de, jonas@kwiboo.se Cc: jagan@edgeble.ai, Jon Lin References: <20230417091951.4640-1-eugen.hristev@collabora.com> <20230417091951.4640-4-eugen.hristev@collabora.com> From: Kever Yang In-Reply-To: <20230417091951.4640-4-eugen.hristev@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZQ0gaS1ZKGUhJH0gYS0geGklVEwETFh oSFyQUDg9ZV1kYEgtZQVlOQ1VJSVVMVUpKT1lXWRYaDxIVHRRZQVlPS0hVSkpLSEpMVUpLS1VLWQ Y+ X-HM-Tid: 0a87a32687f62eb7kusnc464b5801a0 X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NzI6MTo6FD0OKAsWNDUUTTIv Ck0aFDdVSlVKTUNJS01CT0lPTUNMVTMWGhIXVRAeDR4JVQIaFRw7CRQYEFYYExILCFUYFBZFWVdZ EgtZQVlOQ1VJSVVMVUpKT1lXWQgBWUFNTEtINwY+ X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On 2023/4/17 17:19, Eugen Hristev wrote: > From: Jon Lin > > Add support for rk3588 phy variant. > The PHY clock is fixed at 100MHz. > > Signed-off-by: Jon Lin > [kever.yang@rock-chips.com: update pcie pll parameters] > Co-developed-by: Kever Yang > Signed-off-by: Kever Yang > [eugen.hristev@collabora.com: squashed, tidy up] > Signed-off-by: Eugen Hristev Reviewed-by: Kever Yang Thanks, - Kever > --- > .../rockchip/phy-rockchip-naneng-combphy.c | 95 +++++++++++++++++++ > 1 file changed, 95 insertions(+) > > diff --git a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c > index b673a8da9f8e..d5408ccac976 100644 > --- a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c > +++ b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c > @@ -58,6 +58,7 @@ struct rockchip_combphy_grfcfg { > struct combphy_reg con2_for_sata; > struct combphy_reg con3_for_sata; > struct combphy_reg pipe_con0_for_sata; > + struct combphy_reg pipe_con1_for_sata; > struct combphy_reg pipe_sgmii_mac_sel; > struct combphy_reg pipe_xpcs_phy_ready; > struct combphy_reg u3otg0_port_en; > @@ -423,11 +424,105 @@ static const struct rockchip_combphy_cfg rk3568_combphy_cfgs = { > .combphy_cfg = rk3568_combphy_cfg, > }; > > +static int rk3588_combphy_cfg(struct rockchip_combphy_priv *priv) > +{ > + const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg; > + u32 val; > + > + switch (priv->mode) { > + case PHY_TYPE_PCIE: > + param_write(priv->phy_grf, &cfg->con0_for_pcie, true); > + param_write(priv->phy_grf, &cfg->con1_for_pcie, true); > + param_write(priv->phy_grf, &cfg->con2_for_pcie, true); > + param_write(priv->phy_grf, &cfg->con3_for_pcie, true); > + break; > + case PHY_TYPE_USB3: > + param_write(priv->phy_grf, &cfg->pipe_txcomp_sel, false); > + param_write(priv->phy_grf, &cfg->pipe_txelec_sel, false); > + param_write(priv->phy_grf, &cfg->usb_mode_set, true); > + break; > + case PHY_TYPE_SATA: > + param_write(priv->phy_grf, &cfg->con0_for_sata, true); > + param_write(priv->phy_grf, &cfg->con1_for_sata, true); > + param_write(priv->phy_grf, &cfg->con2_for_sata, true); > + param_write(priv->phy_grf, &cfg->con3_for_sata, true); > + param_write(priv->pipe_grf, &cfg->pipe_con0_for_sata, true); > + param_write(priv->pipe_grf, &cfg->pipe_con1_for_sata, true); > + break; > + case PHY_TYPE_SGMII: > + case PHY_TYPE_QSGMII: > + default: > + dev_err(priv->dev, "incompatible PHY type\n"); > + return -EINVAL; > + } > + > + /* 100MHz refclock signal is good */ > + clk_set_rate(&priv->ref_clk, 100000000); > + param_write(priv->phy_grf, &cfg->pipe_clk_100m, true); > + if (priv->mode == PHY_TYPE_PCIE) { > + /* PLL KVCO tuning fine */ > + val = readl(priv->mmio + (0x20 << 2)); > + val &= ~GENMASK(4, 2); > + val |= 0x4 << 2; > + writel(val, priv->mmio + (0x20 << 2)); > + > + /* Set up rx_trim: PLL LPF C1 85pf R1 1.25kohm */ > + val = 0x4c; > + writel(val, priv->mmio + (0x1b << 2)); > + > + /* Set up su_trim: T3 */ > + val = 0xb0; > + writel(val, priv->mmio + (0xa << 2)); > + val = 0x47; > + writel(val, priv->mmio + (0xb << 2)); > + val = 0x57; > + writel(val, priv->mmio + (0xd << 2)); > + } > + > + return 0; > +} > + > +static const struct rockchip_combphy_grfcfg rk3588_combphy_grfcfgs = { > + /* pipe-phy-grf */ > + .pcie_mode_set = { 0x0000, 5, 0, 0x00, 0x11 }, > + .usb_mode_set = { 0x0000, 5, 0, 0x00, 0x04 }, > + .pipe_rxterm_set = { 0x0000, 12, 12, 0x00, 0x01 }, > + .pipe_txelec_set = { 0x0004, 1, 1, 0x00, 0x01 }, > + .pipe_txcomp_set = { 0x0004, 4, 4, 0x00, 0x01 }, > + .pipe_clk_25m = { 0x0004, 14, 13, 0x00, 0x01 }, > + .pipe_clk_100m = { 0x0004, 14, 13, 0x00, 0x02 }, > + .pipe_rxterm_sel = { 0x0008, 8, 8, 0x00, 0x01 }, > + .pipe_txelec_sel = { 0x0008, 12, 12, 0x00, 0x01 }, > + .pipe_txcomp_sel = { 0x0008, 15, 15, 0x00, 0x01 }, > + .pipe_clk_ext = { 0x000c, 9, 8, 0x02, 0x01 }, > + .pipe_phy_status = { 0x0034, 6, 6, 0x01, 0x00 }, > + .con0_for_pcie = { 0x0000, 15, 0, 0x00, 0x1000 }, > + .con1_for_pcie = { 0x0004, 15, 0, 0x00, 0x0000 }, > + .con2_for_pcie = { 0x0008, 15, 0, 0x00, 0x0101 }, > + .con3_for_pcie = { 0x000c, 15, 0, 0x00, 0x0200 }, > + .con0_for_sata = { 0x0000, 15, 0, 0x00, 0x0129 }, > + .con1_for_sata = { 0x0004, 15, 0, 0x00, 0x0040 }, > + .con2_for_sata = { 0x0008, 15, 0, 0x00, 0x80c1 }, > + .con3_for_sata = { 0x000c, 15, 0, 0x00, 0x0407 }, > + /* pipe-grf */ > + .pipe_con0_for_sata = { 0x0000, 11, 5, 0x00, 0x22 }, > + .pipe_con1_for_sata = { 0x0000, 2, 0, 0x00, 0x2 }, > +}; > + > +static const struct rockchip_combphy_cfg rk3588_combphy_cfgs = { > + .grfcfg = &rk3588_combphy_grfcfgs, > + .combphy_cfg = rk3588_combphy_cfg, > +}; > + > static const struct udevice_id rockchip_combphy_ids[] = { > { > .compatible = "rockchip,rk3568-naneng-combphy", > .data = (ulong)&rk3568_combphy_cfgs > }, > + { > + .compatible = "rockchip,rk3588-naneng-combphy", > + .data = (ulong)&rk3588_combphy_cfgs > + }, > { } > }; >