Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp697794rwb; Wed, 14 Dec 2022 01:26:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf4sZtvmCWrTeAHW3NFJh45xlrFiAF2MUFcEV9OmtTMVbWqgdqYA2WWLk4vy2m0ysoTUs1kG X-Received: by 2002:a17:906:1709:b0:7ad:b286:2184 with SMTP id c9-20020a170906170900b007adb2862184mr18492336eje.71.1671009960924; Wed, 14 Dec 2022 01:26:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671009960; cv=none; d=google.com; s=arc-20160816; b=hjUfXJzc1BbfdDbQPmrAt8zixcel8iIXdtvHZ32nGY6zEFkHOtZbLWyHYmZ0J69fjd dG17z4b+FcmzQdDdFm05J2F6QbN5UxN5EP7IYjFahRe5xrLI2kaw1FCUBa1w6a9LPhJi JTcoXMV19iynYeWpMlCI2RyN3tld0+qhhdGQBGyz2Vsg9r6Pwho67zRtikcfSNbho+xu CYynxhy2Jn/klh4dx0zdB9pgns1K8JU8Cd6fBxdhsCBE/4eoNFLIPAEVdbh3XPsB/Y9T QsDtndZtwTbt6dZOPp5KEj9HOQbJSq7oASjpsko5xrg1OSgzQLHWKY6A8UimyQs3Esf3 wSHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=fgWU8Yg0+sU8NwJqb5GlAbwZgv6sv9MmlowDKdTHk5s=; b=v41trkyrjn/zzchH2rN/mdFClcgXoxY+IbBVu2TWRIunV3Tj+Lb4CQVmilevNbkYFj k1fhyjBdULkn6TmKBmeKpgYzzCxiLqeFjpt9cH49WjMzvgIqVDKLrD0t5y9ffN2bgC/F /cSw6k+NDTKE07jph23p8lT7kRkfayF615AGJgMvLE6++LNEm7tUdUJ317oS8MVWJYyS 2e7BHrebqqKXS6FOmt11eQebwFLB/ix6J1kSK3KrmFUzV7drah5R9y+q5pY9XtPXtPH9 wRBlYAmno+3VKHTroUQnX+TuuHLS/mbDxPkXmdOUS86OSbhKOu7B7/D5CgKPfL8ERzu/ kv1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sGE11KMz; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb13-20020a170907160d00b007c16e4d5e9esi8006976ejc.412.2022.12.14.01.25.43; Wed, 14 Dec 2022 01:26:00 -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=@kernel.org header.s=k20201202 header.b=sGE11KMz; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237673AbiLNJSV (ORCPT + 70 others); Wed, 14 Dec 2022 04:18:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237767AbiLNJR6 (ORCPT ); Wed, 14 Dec 2022 04:17:58 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CF231DF24 for ; Wed, 14 Dec 2022 01:17:50 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 888CA61806 for ; Wed, 14 Dec 2022 09:17:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D799C433D2; Wed, 14 Dec 2022 09:17:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671009469; bh=LhfxboEowfTBAIAnIsZQ33ABn//iM5+t2VumPb1Kwzs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=sGE11KMznVEngn0T0Y4SA29AZSuAx2qm08w/V7uwRA8HUaft6kOQ/Kuh8TLXwIe5T VyI3Kv2OZO0qG/hyTcxT18h1iBrMCIf8lwOjgKFy7AGFGnbTcv+CDkSXb2/bEjEAto HQUrzdlDy4TPZLrs9zRWE4JCPGtmCEl3Ez/sOE6fZpKeySQ5zWbkcPUvWYy+Z3dpnM ozVNWAgSbW6cr9APL5zRsDG9Ocw0HdEYDsUj4u5+AN+bJ6f2EXlRdhn2wvZVmqze8e A6ngVOMzMID0Cr+xu9pxCxeofes2IUKksrUzKUtw/NxBjz0ezA2avLF3SUGUBbm13I 0quiyfifGgwZA== Message-ID: <47c159b6-a1d3-dd7f-265e-6acbfc06ead0@kernel.org> Date: Wed, 14 Dec 2022 11:17:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH 2/2] phy: ti: j721e-wiz: Add support to enable LN23 Type-C swap Content-Language: en-US To: Sinthu Raja , Vinod Koul , Ravi Gunasekaran , Siddharth Vadapalli Cc: Vignesh Raghavendra , linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Sinthu Raja References: <20221213124854.3779-1-sinthu.raja@ti.com> <20221213124854.3779-3-sinthu.raja@ti.com> From: Roger Quadros In-Reply-To: <20221213124854.3779-3-sinthu.raja@ti.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,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: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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