From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-m49210.qiye.163.com (mail-m49210.qiye.163.com [45.254.49.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B477219FC for ; Wed, 4 Mar 2026 14:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.210 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772634204; cv=none; b=RQlms+bdHwDrr1fHqvY/0aGrAoK8ODfafD+RPwWFt9PsEVLZPZ02cjVifE3BZTcFoKFLAckHXAJXC2KPw9cOPRbE47ttMRCbZTtCDrCFmEeSafGGKlCmoOWBYxR342QNVNUxrYZ4GM42o3Q1fR9PSwSdbs+mSJZjZcF997ZRnwg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772634204; c=relaxed/simple; bh=PnbBnmU+agWZSAM27D0/EsxMmtTVhEcuYtUCIhVy3Yk=; h=Cc:Subject:To:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=In3FXt6AuaG/z3R17uy5e6croYWN0+Kuf6CkCoIDv2mmqcAcd6FmZbnL/DTEp5rKVU3yKsbLi/wGqlS/AMnTVXMs7OraRXXhy88spbr95Og9lI8SNsAjlrpepVpXWOybYvEVGVXmRm1yqoReZpC13og4WUH5WKKEBRnWuxcl71Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com; spf=pass smtp.mailfrom=rock-chips.com; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b=bUTpIk6D; arc=none smtp.client-ip=45.254.49.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rock-chips.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=rock-chips.com header.i=@rock-chips.com header.b="bUTpIk6D" Received: from [172.16.12.14] (unknown [58.22.7.114]) by smtp.qiye.163.com (Hmail) with ESMTP id 35bf2ed81; Wed, 4 Mar 2026 21:47:52 +0800 (GMT+08:00) Cc: shawn.lin@rock-chips.com, linux-phy@lists.infradead.org, Heiko Stuebner , Neil Armstrong , linux-kernel@vger.kernel.org Subject: Re: [PATCH] phy: rockchip: naneng-combphy: configure SSC for PCIe on rk3588 and rk3576 To: Vinod Koul , linux-rockchip@lists.infradead.org References: <1772619211-99875-1-git-send-email-shawn.lin@rock-chips.com> From: Shawn Lin Message-ID: <2aca186f-e252-19cf-f9ac-08cb15174bc9@rock-chips.com> Date: Wed, 4 Mar 2026 21:47:50 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <1772619211-99875-1-git-send-email-shawn.lin@rock-chips.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-HM-Tid: 0a9cb91ae19909cckunmb1b70496122a5ef X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZQ05MQlZMS0hMGh5OGUxOSElWFRQJFh oXVRMBExYaEhckFA4PWVdZGBILWUFZTkNVSUlVTFVKSk9ZV1kWGg8SFR0UWUFZT0tIVUpLSU9PT0 hVSktLVUpCS0tZBg++ DKIM-Signature: a=rsa-sha256; b=bUTpIk6De4Zk+Z8tVlqztc8LU4LztXPBJW1UU+X/dRJEYD8iQwMQcFQE03B81MY8YIL/mbU/jgqUUzypsOr0jFwksl2bEWhGdjzm1g/UtHTRToGDxZHKGqxEHGD37IgMvlsaALbjqHfK+JEUlBviihebvpHQMXBz9qpz5ybas5E=; s=default; c=relaxed/relaxed; d=rock-chips.com; v=1; bh=+OeyBAAAjTeMYjPetfU4d2PR9NHaM+Szdg+cNZThpQw=; h=date:mime-version:subject:message-id:from; ÔÚ 2026/03/04 ÐÇÆÚÈý 18:13, Shawn Lin дµÀ: > Add a dedicated function rk_combphy_cfg_ssc_for_pcie() to configure > Spread Spectrum Clocking (SSC) for the PCIe PHY on compatible platforms. > > The function first checks the device tree node's compatible string. > Currently, SSC tuning is specifically implemented and applied only for > "rockchip,rk3588-naneng-combphy" and "rockchip,rk3576-naneng-combphy". > Sorry, I amended the patch in the last minute before sending it which seems not able to work after re-testing. Will update v2. > The correct SSC configuration for these platforms involves: > 1. Enabling SSC via the RK3568_PHYREG8_SSC_EN bit. > 2. Setting the PLL SSC module control via the newly defined > RK3568_PHYREG33_PLL_SSC_CTRL bit. > 3. For PCIe phys with a 24MHz reference clock, additional PLL loop > divider and signal adjustment values are programmed to optimiz > performance. > > This SSC configuration is intended to improve EMI characteristics or > meet specific clock tolerance requirements for PCIe interfaces on > these SoCs. > > Signed-off-by: Shawn Lin > --- > > drivers/phy/rockchip/phy-rockchip-naneng-combphy.c | 93 +++++++++++++--------- > 1 file changed, 55 insertions(+), 38 deletions(-) > > diff --git a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c > index b60d6bf..aa09d71 100644 > --- a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c > +++ b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c > @@ -121,6 +121,7 @@ > #define RK3568_PHYREG32_SSC_OFFSET_500PPM 1 > > #define RK3568_PHYREG33 0x80 > +#define RK3568_PHYREG33_PLL_SSC_CTRL BIT(5) > #define RK3568_PHYREG33_PLL_KVCO_MASK GENMASK(4, 2) > #define RK3568_PHYREG33_PLL_KVCO_SHIFT 2 > #define RK3568_PHYREG33_PLL_KVCO_VALUE 2 > @@ -964,6 +965,56 @@ static const struct rockchip_combphy_cfg rk3568_combphy_cfgs = { > .combphy_cfg = rk3568_combphy_cfg, > }; > > +static void rk_combphy_cfg_ssc_for_pcie(struct rockchip_combphy_priv *priv, unsigned long rate) > +{ > + struct device_node *np = priv->dev->of_node; > + u32 val; > + > + /* Some SoCs' combphys share the same PCIe SSC tuning result */ > + if (!of_device_is_compatible(np, "rockchip,rk3588-naneng-combphy") || > + !of_device_is_compatible(np, "rockchip,rk3576-naneng-combphy")) { > + dev_warn(priv->dev, "Incompatible platform\n"); > + return; > + } > + > + val = readl(priv->mmio + RK3568_PHYREG8); > + val |= RK3568_PHYREG8_SSC_EN; > + writel(val, priv->mmio + RK3568_PHYREG8); > + > + /* PLL control SSC module period should be set */ > + val = readl(priv->mmio + RK3568_PHYREG33); > + val |= RK3568_PHYREG33_PLL_SSC_CTRL; > + writel(val, priv->mmio + RK3568_PHYREG33); > + > + if (priv->type == PHY_TYPE_PCIE && rate == REF_CLOCK_24MHz) { > + /* Set PLL loop divider */ > + writel(0x00, priv->mmio + RK3576_PHYREG17); > + writel(RK3568_PHYREG18_PLL_LOOP, priv->mmio + RK3568_PHYREG18); > + > + /* Set up rx_pck invert and rx msb to disable */ > + writel(0x00, priv->mmio + RK3588_PHYREG27); > + > + /* > + * Set up SU adjust signal: > + * su_trim[7:0], PLL KVCO adjust bits[2:0] to min > + * su_trim[15:8], PLL LPF R1 adujst bits[9:7]=3'b101 > + * su_trim[23:16], CKRCV adjust > + * su_trim[31:24], CKDRV adjust > + */ > + writel(0x90, priv->mmio + RK3568_PHYREG11); > + writel(0x02, priv->mmio + RK3568_PHYREG12); > + writel(0x08, priv->mmio + RK3568_PHYREG13); > + writel(0x57, priv->mmio + RK3568_PHYREG14); > + writel(0x40, priv->mmio + RK3568_PHYREG15); > + > + writel(RK3568_PHYREG16_SSC_CNT_VALUE, priv->mmio + RK3568_PHYREG16); > + > + val = FIELD_PREP(RK3568_PHYREG33_PLL_KVCO_MASK, > + RK3576_PHYREG33_PLL_KVCO_VALUE); > + writel(val, priv->mmio + RK3568_PHYREG33); > + } > +} > + > static int rk3576_combphy_cfg(struct rockchip_combphy_priv *priv) > { > const struct rockchip_combphy_grfcfg *cfg = priv->cfg->grfcfg; > @@ -1156,39 +1207,8 @@ static int rk3576_combphy_cfg(struct rockchip_combphy_priv *priv) > } > } > > - if (priv->enable_ssc) { > - val = readl(priv->mmio + RK3568_PHYREG8); > - val |= RK3568_PHYREG8_SSC_EN; > - writel(val, priv->mmio + RK3568_PHYREG8); > - > - if (priv->type == PHY_TYPE_PCIE && rate == REF_CLOCK_24MHz) { > - /* Set PLL loop divider */ > - writel(0x00, priv->mmio + RK3576_PHYREG17); > - writel(RK3568_PHYREG18_PLL_LOOP, priv->mmio + RK3568_PHYREG18); > - > - /* Set up rx_pck invert and rx msb to disable */ > - writel(0x00, priv->mmio + RK3588_PHYREG27); > - > - /* > - * Set up SU adjust signal: > - * su_trim[7:0], PLL KVCO adjust bits[2:0] to min > - * su_trim[15:8], PLL LPF R1 adujst bits[9:7]=3'b101 > - * su_trim[23:16], CKRCV adjust > - * su_trim[31:24], CKDRV adjust > - */ > - writel(0x90, priv->mmio + RK3568_PHYREG11); > - writel(0x02, priv->mmio + RK3568_PHYREG12); > - writel(0x08, priv->mmio + RK3568_PHYREG13); > - writel(0x57, priv->mmio + RK3568_PHYREG14); > - writel(0x40, priv->mmio + RK3568_PHYREG15); > - > - writel(RK3568_PHYREG16_SSC_CNT_VALUE, priv->mmio + RK3568_PHYREG16); > - > - val = FIELD_PREP(RK3568_PHYREG33_PLL_KVCO_MASK, > - RK3576_PHYREG33_PLL_KVCO_VALUE); > - writel(val, priv->mmio + RK3568_PHYREG33); > - } > - } > + if (priv->enable_ssc) > + rk_combphy_cfg_ssc_for_pcie(priv, rate); > > return 0; > } > @@ -1371,11 +1391,8 @@ static int rk3588_combphy_cfg(struct rockchip_combphy_priv *priv) > } > } > > - if (priv->enable_ssc) { > - val = readl(priv->mmio + RK3568_PHYREG8); > - val |= RK3568_PHYREG8_SSC_EN; > - writel(val, priv->mmio + RK3568_PHYREG8); > - } > + if (priv->enable_ssc) > + rk_combphy_cfg_ssc_for_pcie(priv, rate); > > return 0; > } >