Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6003417rwl; Tue, 11 Apr 2023 13:09:16 -0700 (PDT) X-Google-Smtp-Source: AKy350a2g378x0mhztYzKvKjbGKLLEdt/swNZw8s4/wKB6RvFe99jRdogpfFT259twLBpzcUAswY X-Received: by 2002:aa7:cd96:0:b0:502:70e9:2c14 with SMTP id x22-20020aa7cd96000000b0050270e92c14mr3189456edv.29.1681243756306; Tue, 11 Apr 2023 13:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681243756; cv=none; d=google.com; s=arc-20160816; b=a8T4GYlZ7GL5yBQxph3Dkc8lxaKY90c/TDFmXSXYM5YA0M5YSvR0HCvLHdy9rUvnT2 L21ItdZ5wMfBlBJ28S8lQVom6nMTGVBuaxaNggVzskJdeHMwtL0KRf/4j4snTmvwepjP /oP6QwPM1Y6+97GP7XUP7EIwWAuKwcmRf+5qKxzIFK41MFPBP8bMsXgqL68XZqV8DqC6 I001ItGLD9ky7c0IYPNtFI5y59qGt3SWLON1vHEGN82/khAFD/k2o/iXMbH26GAI3m8Z PicYm8A7tQQ6QBuEIDA0b0Qs2OuE8HiF+4vNcif/lfkB14r1xEVJJy9LqoRt4q0s0XBH hF7Q== 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=FIepYQlnjXM9bxkwUBsKDpgLvRy+HeIo31cmLx81ItE=; b=PsoHbDPY6S5zmWYrDL6fFuG5KuZ6AcZa+mepXL0Lu1me8epwMruXHx5Cu6C3o9aPKl A8nHGv7UPj49p66U70u8JVgYzJ5x47b310qmbGfWmQF/B4nI5pdgOIGVsKaJYJRoHx6e YJhxkP9eB28aNyTTPEl1AWB9TwUXqSWDJ66bAi44TOgj4Y5d5MrW+WoVC6LDdOylRUSq NZvFobIcmCi9evbdXijUySyJx0qSNNyU5R5z3u5/N02zHy2ciEXv2bAvvSqqReAG38oG /3zVDL5LrmLGKTcYhSjKsYKA+YEuvsDiBC30ugNtDw4k1pfqWImrAv0rEHztqlA+0A5q uyig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="h//7HNXL"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g25-20020a056402181900b005048b915cc1si128027edy.132.2023.04.11.13.08.35; Tue, 11 Apr 2023 13:09:16 -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="h//7HNXL"; 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 S229972AbjDKUHf (ORCPT + 99 others); Tue, 11 Apr 2023 16:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229922AbjDKUHK (ORCPT ); Tue, 11 Apr 2023 16:07:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0032155BF for ; Tue, 11 Apr 2023 13:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681243524; 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=FIepYQlnjXM9bxkwUBsKDpgLvRy+HeIo31cmLx81ItE=; b=h//7HNXLXDUkZpgm1IX6CLvvbqf24rruc6YLmxV9jPrVgnAc1v08WvwTW4RhsUH97dM7Ta rjVUAzjmNa7GAQh9E5X+DfEEhM8UWJBWUrqc70iFdqzC9HtR/OjRApalRjc00/NnL56Hun jqwCzo87DoLbPBVd1BlfVViujr6yjHI= 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-647-GD6aTAmIOm2Zl9A4bJZUdg-1; Tue, 11 Apr 2023 16:05:23 -0400 X-MC-Unique: GD6aTAmIOm2Zl9A4bJZUdg-1 Received: by mail-oi1-f198.google.com with SMTP id z5-20020a056808064500b0038b9a7d81cdso3180337oih.9 for ; Tue, 11 Apr 2023 13:05:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681243522; 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=FIepYQlnjXM9bxkwUBsKDpgLvRy+HeIo31cmLx81ItE=; b=SJ8sVSIDV8gsvyayI8f5aa6azW3m/FzQEVuMjFaxTSXAjhDtZEyLkIdy9IffG8QIoO XwYCCldI0CgxMQBzc43B53c+CrLWHKMWZSQJhoin9Cp0On5kuVyMxc3XngQiVXeuT972 9pcuo6QiFyTd5E9jfcwAhzorsd7WHj2Btv7RzLxYyaSPDRkIPDUqjV3W69nNp4OuaAEr GslO7jLYWMINoUT39PmjRAOSSFqXmjZJAxYrMWT4y8CnwZtaij5Tz9Xup854L0y2oa40 SywWCDN1FRILO/Y0kUxebQlwPOoMfAu6aOqnPS8qcl2Ww96fN3A8H/AbGK+tkx45w6sR vRrQ== X-Gm-Message-State: AAQBX9fYKcxP9bbNC73A41Hii79nECpXV+WevVwIwTblNfjGDK/LHqsP V0OHJ/+bh3SHQiQUkkZ9Fy7LRsr24bZDiLbCrCPsC4QqvQEZmK7JZWn+wU8q8x8TiD3HSrlr6az J5m3Kx84NiXppmMJQHJQKiVkmZAdT87E1KlYGpV/rXBa957pw8DQdkzn/a5eznu7TDyPVvhph+f /xs7LoIFJ9tKg= X-Received: by 2002:a05:6808:1806:b0:387:7c32:f338 with SMTP id bh6-20020a056808180600b003877c32f338mr243391oib.5.1681243522277; Tue, 11 Apr 2023 13:05:22 -0700 (PDT) X-Received: by 2002:a05:6808:1806:b0:387:7c32:f338 with SMTP id bh6-20020a056808180600b003877c32f338mr243345oib.5.1681243521920; Tue, 11 Apr 2023 13:05:21 -0700 (PDT) Received: from halaney-x13s.attlocal.net (104-53-165-62.lightspeed.stlsmo.sbcglobal.net. [104.53.165.62]) by smtp.gmail.com with ESMTPSA id e20-20020a056808149400b00387764759a3sm5868545oiw.24.2023.04.11.13.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 13:05:21 -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, wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, mturquette@baylibre.com, 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-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 v4 10/12] net: stmmac: dwmac-qcom-ethqos: Respect phy-mode and TX delay Date: Tue, 11 Apr 2023 15:04:07 -0500 Message-Id: <20230411200409.455355-11-ahalaney@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411200409.455355-1-ahalaney@redhat.com> References: <20230411200409.455355-1-ahalaney@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit 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 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 v3: * None Changes since v2: * Fix spacing, reverse xmas tree (Jakub) Changes since v1: * Use a consistent subject prefix with other stmmac changes in series (myself) .../stmicro/stmmac/dwmac-qcom-ethqos.c | 20 ++++++++++++++----- 1 file changed, 15 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..abec6dd27992 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -279,6 +279,17 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos) static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) { + int phase_shift; + int phy_mode; + + /* 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 +311,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 +347,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 +385,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); -- 2.39.2