Message ID | 20221213124854.3779-3-sinthu.raja@ti.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp100712wrn; Tue, 13 Dec 2022 04:58:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf5z9e40VJ5nKzLRI5dxff3TNvp9yv851j+yBCKst6iqh3hirQkyas9J1EwwsMXrkXs8XtxQ X-Received: by 2002:a05:6a00:1687:b0:56b:f566:600f with SMTP id k7-20020a056a00168700b0056bf566600fmr26395254pfc.12.1670936287060; Tue, 13 Dec 2022 04:58:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670936287; cv=none; d=google.com; s=arc-20160816; b=Ho35kKZIonMuGcf6ZoGfNP0VJM/YSa95CynvEIQyCFoNcseiSxZ1Xu26nZxapfGe3I KPEBX8k1u9lKmhW8JIBlf9f+QpSko0uBnhOZyqetxFzJz9jIy8QF5lbJtRFl0+ptOGeT eLw/SvyCDDqjnPqCMidWH6cglfe0lrubF2yu5IHQzd6SIjgTckt4PZPDXB/A9fxluWG3 oSSdfyFj8Mz4XncoGw9oE45fvl5UyjcS6mGEWVBgfycrhMkv2yUGB2PlL6WK1h7pElDo qSQou27VOwecMP3IfYE7Cb/ykZgb3r7CutpPlxSOCMszN9JZ6BD8MTxsSDT7ZTRlbMvS wARQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=j4XCC2SNWD3YZuAByZlmhT1HNH2lwLYNZczilwjwoq8=; b=d0bI27jDi5nCKiV9H6SFj0LjoVmbjX8jv6lj4f2q+C9xTECcY9acabu+MTVSbYoUSb jCrqnaAsUCV5qxZl/M30P/3tvgHSfFIU+3rec7MckPaMj/4G1iNHZI6Hd4ezg6k3Aqli ln2j7n8/8U3k6kpx20tZF4oXMHgPQ75niCfxv5x3hz5oe6JXU2qO+sFMszbXLDC3gp+w bqfptrr0r0nLbzX4BBLXku/yxFQyrFXFvUm0n4oqbwLNdT8KWTflysZwtavWuRgLpvb/ zcriHhVwRyk3WdmBQfTGsfBSfQO6Emm54NOKuNBup3cbFuPJ/qwNIW6DTLtizhrL/5ce GWLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mistralsolutions.com header.s=google header.b=ntUrA3y4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mistralsolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb19-20020a056a004c9300b0056ec686183fsi11855073pfb.366.2022.12.13.04.57.51; Tue, 13 Dec 2022 04:58:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mistralsolutions.com header.s=google header.b=ntUrA3y4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mistralsolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235542AbiLMMtc (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Tue, 13 Dec 2022 07:49:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235180AbiLMMtS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 13 Dec 2022 07:49:18 -0500 Received: from egress-ip4a.ess.de.barracuda.com (egress-ip4a.ess.de.barracuda.com [18.184.203.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED5D21BEA9 for <linux-kernel@vger.kernel.org>; Tue, 13 Dec 2022 04:49:17 -0800 (PST) Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by mx-outbound46-236.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 13 Dec 2022 12:49:15 +0000 Received: by mail-pl1-f199.google.com with SMTP id b17-20020a170903229100b00189da3b178bso12987564plh.7 for <linux-kernel@vger.kernel.org>; Tue, 13 Dec 2022 04:49:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mistralsolutions.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j4XCC2SNWD3YZuAByZlmhT1HNH2lwLYNZczilwjwoq8=; b=ntUrA3y4KwnbuSPFOpGeXbFZS994aN7CbbPZvsvQY3PU9CtDofaTWlURW3hJYm4piF A66eOcFeGRqyEFm8dIVPjXxBamT5ucn0otb8CI1bLk5XJz9moaDp5oEgpEV2JTV+QcpM X40o4VrWxhPAf+u0Rfru6DLlA8tcnZbaACL1c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j4XCC2SNWD3YZuAByZlmhT1HNH2lwLYNZczilwjwoq8=; b=GMr8mNPbh+MM4O0PHAtLpgUI2dL0fhXgZBmNfmp3SDJ7t2YeKhzWrMrqlAvNvwZlFJ tGdp64s6IaZjkDmzXasOR/ETTRsqlh2w3m+dh7trfaGNfYIbwjeUpFZR/cEHsEF69Uey klw2M4Jq2MbuGnajjKO4pwEi3Sh8o9v+liYCXvgQDB+3PDtXPVr8ZegZ4LazyegFJG+9 vlJc0b/TV+IqivsG9rsYUMj1zBxQUtpr9D9uhWgFRnSog2Az/324QXobIzw2Gao1UaRV +MKDy9md7wbGjlPNCVmf7Ir2SZ2YrGOSVXEsncSyfw7XoZQ9Is7t3mjRPz9+c9q8zNzV olMw== X-Gm-Message-State: ANoB5pl4toIS8U51YAcQ/nvCjJEgT3FKA0VUniCQwKuucW8mVxtOrPoS iflhdn8hJEEXyCaqESyxJZNlqM4RRAE0Zgai/ee49NAzAE+h+PwI86cyqYl4GnPRSJ/0nafFObl ym2sAxZ3cyFEMNvMK94VuS7iyAOJuJ23Q6EdiKic2LnRYVT/qk7cqnSUxBojf X-Received: by 2002:aa7:8250:0:b0:572:75f0:8010 with SMTP id e16-20020aa78250000000b0057275f08010mr18208292pfn.14.1670935753754; Tue, 13 Dec 2022 04:49:13 -0800 (PST) X-Received: by 2002:aa7:8250:0:b0:572:75f0:8010 with SMTP id e16-20020aa78250000000b0057275f08010mr18208275pfn.14.1670935753461; Tue, 13 Dec 2022 04:49:13 -0800 (PST) Received: from LAP568U.mistral.in ([106.51.227.150]) by smtp.gmail.com with ESMTPSA id y15-20020aa7942f000000b0057622e8e82csm7605485pfo.191.2022.12.13.04.49.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 04:49:12 -0800 (PST) From: Sinthu Raja <sinthu.raja@mistralsolutions.com> X-Google-Original-From: Sinthu Raja <sinthu.raja@ti.com> To: Vinod Koul <vkoul@kernel.org>, Ravi Gunasekaran <r-gunasekaran@ti.com>, Siddharth Vadapalli <s-vadapalli@ti.com> Cc: Vignesh Raghavendra <vigneshr@ti.com>, Roger Quadros <rogerq@kernel.org>, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Sinthu Raja <sinthu.raja@ti.com> Subject: [PATCH 2/2] phy: ti: j721e-wiz: Add support to enable LN23 Type-C swap Date: Tue, 13 Dec 2022 18:18:54 +0530 Message-Id: <20221213124854.3779-3-sinthu.raja@ti.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221213124854.3779-1-sinthu.raja@ti.com> References: <20221213124854.3779-1-sinthu.raja@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BESS-ID: 1670935754-312012-5635-5406-1 X-BESS-VER: 2019.1_20221212.2317 X-BESS-Apparent-Source-IP: 209.85.214.199 X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.244774 [from cloudscan15-174.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS91090 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, BSF_BESS_OUTBOUND, BSF_SC0_MISMATCH_TO X-BESS-BRTS-Status: 1 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752103688236192930?= X-GMAIL-MSGID: =?utf-8?q?1752103688236192930?= |
Series |
phy: ti: j721e-wiz: Add support to manage type-C swap on Lane2 and lane3
|
|
Commit Message
Sinthu Raja
Dec. 13, 2022, 12:48 p.m. UTC
Serdes wiz supports both LN23 and LN10 Type-C swap. Add support to
configure LN23 bit to swap between lane2 or lane3 if required.
Signed-off-by: Sinthu Raja <sinthu.raja@ti.com>
---
drivers/phy/ti/phy-j721e-wiz.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
Comments
On 13/12/2022 14:48, Sinthu Raja wrote: > Serdes wiz supports both LN23 and LN10 Type-C swap. Add support to SerDes? what is wiz? It has nothing to do with Type-C. It is just a lane swap. There may or may not be a Type-C port. > configure LN23 bit to swap between lane2 or lane3 if required. What do you mean by "swap between lane2 or lane3"? Do you mean "swap lanes 2 and 3"? Is LN23 bit supported on all variants? > > Signed-off-by: Sinthu Raja <sinthu.raja@ti.com> > --- > drivers/phy/ti/phy-j721e-wiz.c | 33 +++++++++++++++++++++++++++++---- > 1 file changed, 29 insertions(+), 4 deletions(-) > > diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c > index b17eec632d49..0091892af0b0 100644 > --- a/drivers/phy/ti/phy-j721e-wiz.c > +++ b/drivers/phy/ti/phy-j721e-wiz.c > @@ -58,6 +58,11 @@ enum wiz_lane_standard_mode { > LANE_MODE_GEN4, > }; > > +enum wiz_lane_typec_swap_mode { > + LANE10_SWAP = 0, > + LANE23_SWAP = 2, > +}; What is this? Is it a register setting? > + > enum wiz_refclk_mux_sel { > PLL0_REFCLK, > PLL1_REFCLK, > @@ -194,6 +199,9 @@ static const struct reg_field p_mac_div_sel1[WIZ_MAX_LANES] = { > static const struct reg_field typec_ln10_swap = > REG_FIELD(WIZ_SERDES_TYPEC, 30, 30); > > +static const struct reg_field typec_ln23_swap = > + REG_FIELD(WIZ_SERDES_TYPEC, 31, 31); > + > struct wiz_clk_mux { > struct clk_hw hw; > struct regmap_field *field; > @@ -366,6 +374,7 @@ struct wiz { > struct regmap_field *mux_sel_field[WIZ_MUX_NUM_CLOCKS]; > struct regmap_field *div_sel_field[WIZ_DIV_NUM_CLOCKS_16G]; > struct regmap_field *typec_ln10_swap; > + struct regmap_field *typec_ln23_swap; > struct regmap_field *sup_legacy_clk_override; > > struct device *dev; > @@ -675,6 +684,13 @@ static int wiz_regfield_init(struct wiz *wiz) > return PTR_ERR(wiz->typec_ln10_swap); > } > > + wiz->typec_ln23_swap = devm_regmap_field_alloc(dev, regmap, > + typec_ln23_swap); > + if (IS_ERR(wiz->typec_ln23_swap)) { > + dev_err(dev, "LN23_SWAP reg field init failed\n"); > + return PTR_ERR(wiz->typec_ln23_swap); > + } > + > wiz->phy_en_refclk = devm_regmap_field_alloc(dev, regmap, phy_en_refclk); > if (IS_ERR(wiz->phy_en_refclk)) { > dev_err(dev, "PHY_EN_REFCLK reg field init failed\n"); > @@ -1242,15 +1258,24 @@ static int wiz_phy_reset_deassert(struct reset_controller_dev *rcdev, > regmap_field_write(wiz->typec_ln10_swap, 0); > } else { > /* if no typec-dir gpio was specified, and USB lines > - * are connected to Lane 0 then set LN10 SWAP bit to 1. > + * are connected to SWAP lanes '0' or '2' then set LN10 SWAP > + * or LN23 bit to 1 respectively. > */ > u32 num_lanes = wiz->num_lanes; > int i; > > for (i = 0; i < num_lanes; i++) { > - if ((wiz->lane_phy_type[i] == PHY_TYPE_USB3) \ > - && wiz->lane_phy_reg[i] == 0) { > - regmap_field_write(wiz->typec_ln10_swap, 1); > + if (wiz->lane_phy_type[i] == PHY_TYPE_USB3) { > + switch (wiz->lane_phy_reg[i]) { > + case LANE10_SWAP: > + regmap_field_write(wiz->typec_ln10_swap, 1); > + break; > + case LANE23_SWAP: > + regmap_field_write(wiz->typec_ln23_swap, 1); > + break; > + default: > + break; > + } Could you please explain what is going on here? What is the basis for deciding if LN10 or LN23 bit must be set or not? What about clearing those bits? > } > } > } cheers, -roger
Hi Roger, On Wed, Dec 14, 2022 at 2:47 PM Roger Quadros <rogerq@kernel.org> wrote: > > > > On 13/12/2022 14:48, Sinthu Raja wrote: > > Serdes wiz supports both LN23 and LN10 Type-C swap. Add support to > > SerDes? > > what is wiz? The WIZ acts as a wrapper for the SerDes and can send control signals to and report status signals from the SerDes, and muxes SerDes to peripherals. > > It has nothing to do with Type-C. It is just a lane swap. > There may or may not be a Type-C port. According to the SerDes design, in the case of 4 lanes SerDes, Lane 0 and Lane 2 are reserved for USB for type-C lane swap if Lane 1 and Lane 3 are integrated into USB3 PHY. The C-type lane swap is responsible for swapping lanes 0 and 1 or lanes 2 and 3 based on the configuration register. This allows a Type C USB connector to deal with the connector orientation. > > > configure LN23 bit to swap between lane2 or lane3 if required. > > What do you mean by "swap between lane2 or lane3"? > > Do you mean "swap lanes 2 and 3"? Yes. > > Is LN23 bit supported on all variants? Yes, it is supported in all J7 variants if it is a 4 Lanes SerDes and USB3 PHY is supported. > > > > > Signed-off-by: Sinthu Raja <sinthu.raja@ti.com> > > --- > > drivers/phy/ti/phy-j721e-wiz.c | 33 +++++++++++++++++++++++++++++---- > > 1 file changed, 29 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c > > index b17eec632d49..0091892af0b0 100644 > > --- a/drivers/phy/ti/phy-j721e-wiz.c > > +++ b/drivers/phy/ti/phy-j721e-wiz.c > > @@ -58,6 +58,11 @@ enum wiz_lane_standard_mode { > > LANE_MODE_GEN4, > > }; > > > > +enum wiz_lane_typec_swap_mode { > > + LANE10_SWAP = 0, > > + LANE23_SWAP = 2, > > +}; > > What is this? Is it a register setting? These are the master lane numbers that support the C-type lane swap. Will change the enum name relatable and also shall add a comment for more clarification. > > > + > > enum wiz_refclk_mux_sel { > > PLL0_REFCLK, > > PLL1_REFCLK, > > @@ -194,6 +199,9 @@ static const struct reg_field p_mac_div_sel1[WIZ_MAX_LANES] = { > > static const struct reg_field typec_ln10_swap = > > REG_FIELD(WIZ_SERDES_TYPEC, 30, 30); > > > > +static const struct reg_field typec_ln23_swap = > > + REG_FIELD(WIZ_SERDES_TYPEC, 31, 31); > > + > > struct wiz_clk_mux { > > struct clk_hw hw; > > struct regmap_field *field; > > @@ -366,6 +374,7 @@ struct wiz { > > struct regmap_field *mux_sel_field[WIZ_MUX_NUM_CLOCKS]; > > struct regmap_field *div_sel_field[WIZ_DIV_NUM_CLOCKS_16G]; > > struct regmap_field *typec_ln10_swap; > > + struct regmap_field *typec_ln23_swap; > > struct regmap_field *sup_legacy_clk_override; > > > > struct device *dev; > > @@ -675,6 +684,13 @@ static int wiz_regfield_init(struct wiz *wiz) > > return PTR_ERR(wiz->typec_ln10_swap); > > } > > > > + wiz->typec_ln23_swap = devm_regmap_field_alloc(dev, regmap, > > + typec_ln23_swap); > > + if (IS_ERR(wiz->typec_ln23_swap)) { > > + dev_err(dev, "LN23_SWAP reg field init failed\n"); > > + return PTR_ERR(wiz->typec_ln23_swap); > > + } > > + > > wiz->phy_en_refclk = devm_regmap_field_alloc(dev, regmap, phy_en_refclk); > > if (IS_ERR(wiz->phy_en_refclk)) { > > dev_err(dev, "PHY_EN_REFCLK reg field init failed\n"); > > @@ -1242,15 +1258,24 @@ static int wiz_phy_reset_deassert(struct reset_controller_dev *rcdev, > > regmap_field_write(wiz->typec_ln10_swap, 0); > > } else { > > /* if no typec-dir gpio was specified, and USB lines > > - * are connected to Lane 0 then set LN10 SWAP bit to 1. > > + * are connected to SWAP lanes '0' or '2' then set LN10 SWAP > > + * or LN23 bit to 1 respectively. > > */ > > u32 num_lanes = wiz->num_lanes; > > int i; > > > > for (i = 0; i < num_lanes; i++) { > > - if ((wiz->lane_phy_type[i] == PHY_TYPE_USB3) \ > > - && wiz->lane_phy_reg[i] == 0) { > > - regmap_field_write(wiz->typec_ln10_swap, 1); > > + if (wiz->lane_phy_type[i] == PHY_TYPE_USB3) { > > + switch (wiz->lane_phy_reg[i]) { > > + case LANE10_SWAP: > > + regmap_field_write(wiz->typec_ln10_swap, 1); > > + break; > > + case LANE23_SWAP: > > + regmap_field_write(wiz->typec_ln23_swap, 1); > > + break; > > + default: > > + break; > > + } > > Could you please explain what is going on here? > What is the basis for deciding if LN10 or LN23 bit must be set or not? This snippet is used to configure the SerDes Type C control register that allows the external lanes selection to be swapped. Based on the master lane number and if the PHY type is USB3, we are configuring the lane swap bits. > > What about clearing those bits? According to the design this does not need to be cleared if it is set. By default, it is set to 0. > > > } > > } > > } > > cheers, > -roger
diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c index b17eec632d49..0091892af0b0 100644 --- a/drivers/phy/ti/phy-j721e-wiz.c +++ b/drivers/phy/ti/phy-j721e-wiz.c @@ -58,6 +58,11 @@ enum wiz_lane_standard_mode { LANE_MODE_GEN4, }; +enum wiz_lane_typec_swap_mode { + LANE10_SWAP = 0, + LANE23_SWAP = 2, +}; + enum wiz_refclk_mux_sel { PLL0_REFCLK, PLL1_REFCLK, @@ -194,6 +199,9 @@ static const struct reg_field p_mac_div_sel1[WIZ_MAX_LANES] = { static const struct reg_field typec_ln10_swap = REG_FIELD(WIZ_SERDES_TYPEC, 30, 30); +static const struct reg_field typec_ln23_swap = + REG_FIELD(WIZ_SERDES_TYPEC, 31, 31); + struct wiz_clk_mux { struct clk_hw hw; struct regmap_field *field; @@ -366,6 +374,7 @@ struct wiz { struct regmap_field *mux_sel_field[WIZ_MUX_NUM_CLOCKS]; struct regmap_field *div_sel_field[WIZ_DIV_NUM_CLOCKS_16G]; struct regmap_field *typec_ln10_swap; + struct regmap_field *typec_ln23_swap; struct regmap_field *sup_legacy_clk_override; struct device *dev; @@ -675,6 +684,13 @@ static int wiz_regfield_init(struct wiz *wiz) return PTR_ERR(wiz->typec_ln10_swap); } + wiz->typec_ln23_swap = devm_regmap_field_alloc(dev, regmap, + typec_ln23_swap); + if (IS_ERR(wiz->typec_ln23_swap)) { + dev_err(dev, "LN23_SWAP reg field init failed\n"); + return PTR_ERR(wiz->typec_ln23_swap); + } + wiz->phy_en_refclk = devm_regmap_field_alloc(dev, regmap, phy_en_refclk); if (IS_ERR(wiz->phy_en_refclk)) { dev_err(dev, "PHY_EN_REFCLK reg field init failed\n"); @@ -1242,15 +1258,24 @@ static int wiz_phy_reset_deassert(struct reset_controller_dev *rcdev, regmap_field_write(wiz->typec_ln10_swap, 0); } else { /* if no typec-dir gpio was specified, and USB lines - * are connected to Lane 0 then set LN10 SWAP bit to 1. + * are connected to SWAP lanes '0' or '2' then set LN10 SWAP + * or LN23 bit to 1 respectively. */ u32 num_lanes = wiz->num_lanes; int i; for (i = 0; i < num_lanes; i++) { - if ((wiz->lane_phy_type[i] == PHY_TYPE_USB3) \ - && wiz->lane_phy_reg[i] == 0) { - regmap_field_write(wiz->typec_ln10_swap, 1); + if (wiz->lane_phy_type[i] == PHY_TYPE_USB3) { + switch (wiz->lane_phy_reg[i]) { + case LANE10_SWAP: + regmap_field_write(wiz->typec_ln10_swap, 1); + break; + case LANE23_SWAP: + regmap_field_write(wiz->typec_ln23_swap, 1); + break; + default: + break; + } } } }