From mboxrd@z Thu Jan 1 00:00:00 1970 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 3D945C7618B for ; Mon, 13 Mar 2023 12:43:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 31C4386154; Mon, 13 Mar 2023 13:42:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=mistralsolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mistralsolutions.com header.i=@mistralsolutions.com header.b="Ywwt8QYt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CC5FB86140; Mon, 13 Mar 2023 13:42:41 +0100 (CET) Received: from egress-ip33a.ess.de.barracuda.com (egress-ip33a.ess.de.barracuda.com [18.185.115.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D68AD86140 for ; Mon, 13 Mar 2023 13:42:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=mistralsolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sinthu.raja@mistralsolutions.com Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx-outbound11-86.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 13 Mar 2023 12:42:37 +0000 Received: by mail-pl1-f197.google.com with SMTP id s8-20020a170902b18800b0019c92f56a8aso7200415plr.22 for ; Mon, 13 Mar 2023 05:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mistralsolutions.com; s=google; t=1678711356; 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=6DF+wam/31jCLNkDUKkgvFNkJG6vdxT/CDKBENcDvVI=; b=Ywwt8QYtn37YWdl1yAjRZLh8sgRS5OePWl5KP1TTRdEbbTTaeyQfvZGvRlA/PUsj9z VJd9DXh6LizrDrBlN/qCXWJwQ4nkBkrHOTB9eK78s9bOriUvg8sgfEzhbV4VJu2SXebj 4xd2yMuibfFXaPWhr2bNJqVRPHJYxGrHBwb/M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678711356; 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=6DF+wam/31jCLNkDUKkgvFNkJG6vdxT/CDKBENcDvVI=; b=dNfMucr1Iudyc+lodiQ6rRfKaGhjz5ioh+Ke1Ev5BIEGgW2jbF0DBo2A1C15VwBp2y B95Hw1wVtpfandxvUno0iS0kLLrzFBjtxGpLmTB7AepY1BTmX6BhDDyvgjVp4j1JTsZK XRUTpN0B373ZJg5P+q2TAE7Fglk0za0Xp8VwGhwNWA/e/HVaFiaem7aUHzgZifOO8nR/ hCgLt8SAGHhaFYRxOjlmP3n4NxtxmyQN0GUHZyZgC2/nNB1s4L/Uda5NNg3zRl0lSzQv IzIsTAT+jIx3aNmuyZUdEjUV4V1Mi538HDILQl9nciGEPz3qMOi1K0VwEC/zs+8ck2yU O4GQ== X-Gm-Message-State: AO0yUKVw3ycRluBHEVEMWnzLPi1NuWz/GPB8IrTS+EdliQGAOLnP5G2u F3zbPkUPAedcBmQKYsqdIsLttL+kUCKMt8oILSe/cvRhQzu5G8DGbCQ2ucokSqvZmssc6RW3JK+ gLf5S+7b0E/+VA5RamBuDwkIx7XTiCjxQnhbvwJ0P7dNwtcqB7/tSQCOx5Q== X-Received: by 2002:a17:903:22cc:b0:19c:d5a5:1f52 with SMTP id y12-20020a17090322cc00b0019cd5a51f52mr40152085plg.18.1678711356295; Mon, 13 Mar 2023 05:42:36 -0700 (PDT) X-Google-Smtp-Source: AK7set/66dfcJRiEAtO2na/LJLqbPlgqZuYgTdgNlyP6SHSMRrir/MuELhEgQ1XxybTNXk27vhAXiw== X-Received: by 2002:a17:903:22cc:b0:19c:d5a5:1f52 with SMTP id y12-20020a17090322cc00b0019cd5a51f52mr40152059plg.18.1678711355983; Mon, 13 Mar 2023 05:42:35 -0700 (PDT) Received: from localhost.localdomain ([49.207.199.108]) by smtp.gmail.com with ESMTPSA id jy3-20020a17090342c300b0019eae6fd925sm4695238plb.115.2023.03.13.05.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Mar 2023 05:42:35 -0700 (PDT) From: Sinthu Raja X-Google-Original-From: Sinthu Raja To: u-boot@lists.denx.de, Tom Rini , Ravi Gunasekaran , Vignesh Raghavendra Cc: Sinthu Raja Subject: [PATCH 1/2] phy: ti: j721e-wiz: Manage TypeC lane swap if typec-dir-gpios not specified Date: Mon, 13 Mar 2023 18:12:23 +0530 Message-Id: <20230313124224.24757-2-sinthu.raja@ti.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230313124224.24757-1-sinthu.raja@ti.com> References: <20230313124224.24757-1-sinthu.raja@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BESS-ID: 1678711357-302902-5442-15876-1 X-BESS-VER: 2019.1_20230310.1716 X-BESS-Apparent-Source-IP: 209.85.214.197 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUirNy1bSUcovVrIyMjcyAbIygIIGqUkmZkYWaW lmaWkWiZapiZaWBhZGyWkmpkZmqSbGiUq1sQCYdgHaQQAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.246765 [from cloudscan16-100.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_SC0_MISMATCH_TO META: Envelope rcpt doesn't match header 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS91090 scores of KILL_LEVEL=7.0 tests=BSF_SC0_MISMATCH_TO, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 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 From: Sinthu Raja It's possible that the Type-C plug orientation on the DIR line will be implemented through hardware design. In that situation, there won't be an external GPIO line available, but the driver still needs to address this since the DT won't use the typec-dir-gpios property. Add code to handle LN10 Type-C swap if typec-dir-gpios property is not specified in DT. Signed-off-by: Sinthu Raja --- drivers/phy/ti/phy-j721e-wiz.c | 38 ++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c index 6646b15d41..8e29f39cd8 100644 --- a/drivers/phy/ti/phy-j721e-wiz.c +++ b/drivers/phy/ti/phy-j721e-wiz.c @@ -329,6 +329,7 @@ struct wiz { u32 num_lanes; struct gpio_desc *gpio_typec_dir; u32 lane_phy_type[WIZ_MAX_LANES]; + u32 master_lane_num[WIZ_MAX_LANES]; struct clk *input_clks[WIZ_MAX_INPUT_CLOCKS]; unsigned int id; const struct wiz_data *data; @@ -586,14 +587,31 @@ static int wiz_reset_deassert(struct reset_ctl *reset_ctl) return ret; /* if typec-dir gpio was specified, set LN10 SWAP bit based on that */ - if (id == 0 && wiz->gpio_typec_dir) { - if (dm_gpio_get_value(wiz->gpio_typec_dir)) { - regmap_update_bits(wiz->regmap, WIZ_SERDES_TYPEC, - WIZ_SERDES_TYPEC_LN10_SWAP, - WIZ_SERDES_TYPEC_LN10_SWAP); - } else { - regmap_update_bits(wiz->regmap, WIZ_SERDES_TYPEC, - WIZ_SERDES_TYPEC_LN10_SWAP, 0); + if (id == 0) { + if (wiz->gpio_typec_dir) { + if (dm_gpio_get_value(wiz->gpio_typec_dir)) { + regmap_update_bits(wiz->regmap, WIZ_SERDES_TYPEC, + WIZ_SERDES_TYPEC_LN10_SWAP, + WIZ_SERDES_TYPEC_LN10_SWAP); + } else { + regmap_update_bits(wiz->regmap, WIZ_SERDES_TYPEC, + WIZ_SERDES_TYPEC_LN10_SWAP, 0); + } + } + } else { + /* if no typec-dir gpio was specified and PHY type is + * USB3 with master lane number is '0', set LN10 SWAP + * bit to '1' + */ + u32 num_lanes = wiz->num_lanes; + int i; + + for (i = 0; i < num_lanes; i++) { + if (wiz->lane_phy_type[i] == PHY_TYPE_USB3) + if (wiz->master_lane_num[i] == 0) + regmap_update_bits(wiz->regmap, WIZ_SERDES_TYPEC, + WIZ_SERDES_TYPEC_LN10_SWAP, + WIZ_SERDES_TYPEC_LN10_SWAP); } } @@ -1100,8 +1118,10 @@ static int wiz_get_lane_phy_types(struct udevice *dev, struct wiz *wiz) dev_dbg(dev, "%s: Lanes %u-%u have phy-type %u\n", __func__, reg, reg + num_lanes - 1, phy_type); - for (i = reg; i < reg + num_lanes; i++) + for (i = reg; i < reg + num_lanes; i++) { wiz->lane_phy_type[i] = phy_type; + wiz->master_lane_num[i] = reg; + } } return 0; -- 2.36.1