From: Andy Yan <andyshrk@163.com>
To: vkoul@kernel.org
Cc: heiko@sntech.de, kishon@kernel.org,
sebastian.reichel@collabora.com, yubing.zhang@rock-chips.com,
dmitry.baryshkov@linaro.org, frank.wang@rock-chips.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org,
linux-rockchip@lists.infradead.org,
Andy Yan <andy.yan@rock-chips.com>
Subject: [PATCH] phy: rockchip: usbdp: Check these parameters only when the corresponding set flags are set
Date: Thu, 6 Mar 2025 14:59:51 +0800 [thread overview]
Message-ID: <20250306065952.485809-1-andyshrk@163.com> (raw)
From: Andy Yan <andy.yan@rock-chips.com>
According documentation of phy_configure_opts_dp, at the configure
stage, we should only verify/configure the link_rate when set_rate
flag is set, the same applies to lanes and voltage.
So we do it as the documentation says, also record the link rate
and lanes in phy internal for set_voltate stage.
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
---
drivers/phy/rockchip/phy-rockchip-usbdp.c | 63 +++++++++++------------
1 file changed, 31 insertions(+), 32 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
index c04cf64f8a35..d1bbdf382aa2 100644
--- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
+++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
@@ -187,6 +187,8 @@ struct rk_udphy {
u32 dp_aux_din_sel;
bool dp_sink_hpd_sel;
bool dp_sink_hpd_cfg;
+ unsigned int link_rate;
+ unsigned int lanes;
u8 bw;
int id;
@@ -1102,42 +1104,39 @@ static int rk_udphy_dp_phy_power_off(struct phy *phy)
return 0;
}
-static int rk_udphy_dp_phy_verify_link_rate(unsigned int link_rate)
-{
- switch (link_rate) {
- case 1620:
- case 2700:
- case 5400:
- case 8100:
- break;
-
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
static int rk_udphy_dp_phy_verify_config(struct rk_udphy *udphy,
struct phy_configure_opts_dp *dp)
{
- int i, ret;
+ int i;
- /* If changing link rate was required, verify it's supported. */
- ret = rk_udphy_dp_phy_verify_link_rate(dp->link_rate);
- if (ret)
- return ret;
+ /* Verify link rate. */
+ if (dp->set_rate) {
+ switch (dp->link_rate) {
+ case 1620:
+ case 2700:
+ case 5400:
+ case 8100:
+ udphy->link_rate = dp->link_rate;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ }
/* Verify lane count. */
- switch (dp->lanes) {
- case 1:
- case 2:
- case 4:
- /* valid lane count. */
- break;
+ if (dp->set_lanes) {
+ switch (dp->lanes) {
+ case 1:
+ case 2:
+ case 4:
+ /* valid lane count. */
+ udphy->lanes = dp->lanes;
+ break;
- default:
- return -EINVAL;
+ default:
+ return -EINVAL;
+ }
}
/*
@@ -1146,7 +1145,7 @@ static int rk_udphy_dp_phy_verify_config(struct rk_udphy *udphy,
*/
if (dp->set_voltages) {
/* Lane count verified previously. */
- for (i = 0; i < dp->lanes; i++) {
+ for (i = 0; i < udphy->lanes; i++) {
if (dp->voltage[i] > 3 || dp->pre[i] > 3)
return -EINVAL;
@@ -1243,9 +1242,9 @@ static int rk_udphy_dp_phy_configure(struct phy *phy,
}
if (dp->set_voltages) {
- for (i = 0; i < dp->lanes; i++) {
+ for (i = 0; i < udphy->lanes; i++) {
lane = udphy->dp_lane_sel[i];
- switch (dp->link_rate) {
+ switch (udphy->link_rate) {
case 1620:
case 2700:
regmap_update_bits(udphy->pma_regmap,
--
2.34.1
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next reply other threads:[~2025-03-06 8:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 6:59 Andy Yan [this message]
2025-03-10 7:26 ` [PATCH] phy: rockchip: usbdp: Check these parameters only when the corresponding set flags are set Vinod Koul
2025-03-11 0:52 ` Andy Yan
2025-03-11 11:13 ` Vinod Koul
2025-03-11 12:22 ` Andy Yan
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=20250306065952.485809-1-andyshrk@163.com \
--to=andyshrk@163.com \
--cc=andy.yan@rock-chips.com \
--cc=dmitry.baryshkov@linaro.org \
--cc=frank.wang@rock-chips.com \
--cc=heiko@sntech.de \
--cc=kishon@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=sebastian.reichel@collabora.com \
--cc=vkoul@kernel.org \
--cc=yubing.zhang@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