From patchwork Mon Mar 20 22:16:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 72508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1471540wrt; Mon, 20 Mar 2023 15:36:47 -0700 (PDT) X-Google-Smtp-Source: AK7set8DcqpcgQ3HP97QUW1Yum4Qjwq5Nz+96h+8MZVHmLu8DGVzfLO4O4WILiQwdwuhS+hqi/Ym X-Received: by 2002:a17:902:e850:b0:1a1:465b:2d20 with SMTP id t16-20020a170902e85000b001a1465b2d20mr96669plg.2.1679351807045; Mon, 20 Mar 2023 15:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679351807; cv=none; d=google.com; s=arc-20160816; b=IPU9pkrtRP9Drln9V9EE4RPQbiU7rg1VswHNpjfHtcI9t1ocrYk1gtN+/lJ0gJfNy8 UdmJOQIY16Eb+O2X15jrqo4O6H3Y89UxED66wb2AE7abZZLcBOzTmtvIwzP5IzSkta/x MUNKXcTdbvp69NTEAxFV4ksZSKlM1pNm256EfqKjjTzliJ66fMhVimzrjgGugIIYAKC8 Kgl3m8Qw3UMfnqDsV/4cZuPm62I3PCqIY34We9KWE35YMdYT/n6QEeoWI/U56181KP8z mh9pathDQE1nMDP2wrXBn8kkZUfmeIz0IWQrnc+kKlfVuD0AQ7UwdzV6wbA3awDzwNA/ +P/g== 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=pge60lbtNXyjhIC7xM2HbTt6URs0YcanlV/EtqaeLXQ=; b=zwix50zIJ00D8GAy8YyUZTW11V2MOdudsqwtxDEJ1+zjTQu8pq7OVXoOxuKWmVX8D+ v2JULpAwmeOSjIMm6WSFOTl8ucitOO0CbHe+6ZMA+5mTcj2OIvHW9w8o+sp+4d/CHppk wrMyu4kJSzHFS8zB765ynDoestybvRxBzPGJzvRszNCdg02YbIZRiSrxfIOeDGsuoyWA 2qrlCQECS3IqCYdcFLYR0eBDoqT3zNMzfE+GM29O+O+hJWrZiFTiIObuArVdkbOZ1iSM mOrIWmcYLndJjuidBGV4JK1dot5bf8x2YjoQOIeSECll8jT1G2m6mSKhoHiywd+WlYUC HXxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KFNrb6HU; 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=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jy7-20020a17090342c700b001a1ad6fabdesi9378213plb.228.2023.03.20.15.36.32; Mon, 20 Mar 2023 15:36:47 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=KFNrb6HU; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230072AbjCTWTR (ORCPT + 99 others); Mon, 20 Mar 2023 18:19:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbjCTWSe (ORCPT ); Mon, 20 Mar 2023 18:18:34 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C34513668B for ; Mon, 20 Mar 2023 15:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679350634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pge60lbtNXyjhIC7xM2HbTt6URs0YcanlV/EtqaeLXQ=; b=KFNrb6HUDi1OP+kgfmIU+XQ/ahcj6qawmQXTr1c67anO3Kr+i7rl5DdkLmDFFv49iCrbn/ MbGjSBJ1lrWKOgOVdgOwQu+HGiCOJ+jBMer5ZmzNpfJIpZvykdWPmjTN/4E5ewul/Yr+kC hz+em9ACtTY72AH5+5L7lh3zJa+NJNQ= Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-34-LiT23tu9NLGiMexaRVdseQ-1; Mon, 20 Mar 2023 18:17:13 -0400 X-MC-Unique: LiT23tu9NLGiMexaRVdseQ-1 Received: by mail-oi1-f198.google.com with SMTP id r8-20020acada08000000b00387165e151dso876653oig.22 for ; Mon, 20 Mar 2023 15:17:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679350633; 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=pge60lbtNXyjhIC7xM2HbTt6URs0YcanlV/EtqaeLXQ=; b=F6ZoFtEQFkWvSyqKqCWhljGtYlw+TXqDIzEYUZbdVnC9ePE5qZxUNKwdR1P3JF+Zt8 NE4I2+9/szcP/mtVEkJ6eB1EdpzewgZA2tyv6m6v2+ZikBFUEBnumwyNU2p+zT6xjeHF YgI5crWC7rSdwvSOUJ783qQKgFuodz08Km9bMJiGNQ1dilyXznrk/QzZn/Zu1zD7y4aB X64uKxDgFkBog0WIbI0rxuMRIEVKe1iTUnectwAL4GveKM7km9Y6EV8o18pNhlRBRKMk FmvC0Wy6PcBaOr9MGaDcZMm5sGtWaXKjCx3gkAw0ZS/VKw6D80jLMjF/wlCKx+uU9fvj zawA== X-Gm-Message-State: AO0yUKU3HTLXrkEPLQ3nc6dCxtw6Gv7WWWd8uq1if+pDGb18QjPO/8D7 Rlb5DePLPPxdxqnio2iaPvpznXfLuPYYh3mP9wIt3Smt8AhCALd6OepCI0OuDDWtHE8lxsMjAhd Gjx4naOVZePw56sWHUddwK3/cVsbVBZOmOJwM9h4F4sEuzPH5+bJPV7IREP+h5N4w5RStRjjEnZ fUvQ2xjcMZe3A= X-Received: by 2002:a4a:4942:0:b0:536:584c:eb1f with SMTP id z63-20020a4a4942000000b00536584ceb1fmr679576ooa.2.1679350632940; Mon, 20 Mar 2023 15:17:12 -0700 (PDT) X-Received: by 2002:a4a:4942:0:b0:536:584c:eb1f with SMTP id z63-20020a4a4942000000b00536584ceb1fmr679529ooa.2.1679350632616; Mon, 20 Mar 2023 15:17:12 -0700 (PDT) Received: from halaney-x13s.redhat.com (104-53-165-62.lightspeed.stlsmo.sbcglobal.net. [104.53.165.62]) by smtp.gmail.com with ESMTPSA id q204-20020a4a33d5000000b0053853156b5csm4092465ooq.8.2023.03.20.15.17.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 15:17:12 -0700 (PDT) From: Andrew Halaney To: linux-kernel@vger.kernel.org Cc: agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, vkoul@kernel.org, bhupesh.sharma@linaro.org, mturquette@baylibre.com, sboyd@kernel.org, peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, mcoquelin.stm32@gmail.com, richardcochran@gmail.com, linux@armlinux.org.uk, veekhee@apple.com, tee.min.tan@linux.intel.com, mohammad.athari.ismail@intel.com, jonathanh@nvidia.com, ruppala@nvidia.com, bmasney@redhat.com, andrey.konovalov@linaro.org, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, ncai@quicinc.com, jsuraj@qti.qualcomm.com, hisunil@quicinc.com, echanude@redhat.com, Andrew Halaney Subject: [PATCH net-next v2 10/12] net: stmmac: dwmac-qcom-ethqos: Respect phy-mode and TX delay Date: Mon, 20 Mar 2023 17:16:15 -0500 Message-Id: <20230320221617.236323-11-ahalaney@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230320221617.236323-1-ahalaney@redhat.com> References: <20230320221617.236323-1-ahalaney@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760928000854813238?= X-GMAIL-MSGID: =?utf-8?q?1760928000854813238?= The driver currently sets a MAC TX delay of 2 ns no matter what the phy-mode is. If the phy-mode indicates the phy is in charge of the TX delay (rgmii-txid, rgmii-id), don't do it in the MAC. Signed-off-by: Andrew Halaney --- Changes since v1: * Use a consistent subject prefix with other stmmac changes in series (myself) .../stmicro/stmmac/dwmac-qcom-ethqos.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 32763566c214..e89937916741 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -279,6 +279,16 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos) static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) { + int phy_mode; + int phase_shift; + + /* Determine if the PHY adds a 2 ns TX delay or the MAC handles it */ + phy_mode = device_get_phy_mode(ðqos->pdev->dev); + if (phy_mode == PHY_INTERFACE_MODE_RGMII_ID || phy_mode == PHY_INTERFACE_MODE_RGMII_TXID) + phase_shift = 0; + else + phase_shift = RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN; + /* Disable loopback mode */ rgmii_updatel(ethqos, RGMII_CONFIG2_TX_TO_RX_LOOPBACK_EN, 0, RGMII_IO_MACRO_CONFIG2); @@ -300,9 +310,9 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) RGMII_CONFIG_PROG_SWAP, RGMII_IO_MACRO_CONFIG); rgmii_updatel(ethqos, RGMII_CONFIG2_DATA_DIVIDE_CLK_SEL, 0, RGMII_IO_MACRO_CONFIG2); + rgmii_updatel(ethqos, RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN, - RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN, - RGMII_IO_MACRO_CONFIG2); + phase_shift, RGMII_IO_MACRO_CONFIG2); rgmii_updatel(ethqos, RGMII_CONFIG2_RSVD_CONFIG15, 0, RGMII_IO_MACRO_CONFIG2); rgmii_updatel(ethqos, RGMII_CONFIG2_RX_PROG_SWAP, @@ -336,8 +346,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) rgmii_updatel(ethqos, RGMII_CONFIG2_DATA_DIVIDE_CLK_SEL, 0, RGMII_IO_MACRO_CONFIG2); rgmii_updatel(ethqos, RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN, - RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN, - RGMII_IO_MACRO_CONFIG2); + phase_shift, RGMII_IO_MACRO_CONFIG2); rgmii_updatel(ethqos, RGMII_CONFIG_MAX_SPD_PRG_2, BIT(6), RGMII_IO_MACRO_CONFIG); rgmii_updatel(ethqos, RGMII_CONFIG2_RSVD_CONFIG15, @@ -375,7 +384,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) rgmii_updatel(ethqos, RGMII_CONFIG2_DATA_DIVIDE_CLK_SEL, 0, RGMII_IO_MACRO_CONFIG2); rgmii_updatel(ethqos, RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN, - 0, RGMII_IO_MACRO_CONFIG2); + phase_shift, RGMII_IO_MACRO_CONFIG2); rgmii_updatel(ethqos, RGMII_CONFIG_MAX_SPD_PRG_9, BIT(12) | GENMASK(9, 8), RGMII_IO_MACRO_CONFIG);