Message ID | 20230511120808.28646-3-harini.katakam@amd.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4333868vqo; Thu, 11 May 2023 05:34:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6eYRpsUZjjzn9hy6PGLKtDJZ6/xsi00V6A+JZ1kUEkDl205kwUVavChy6sCeT9oYrfyTls X-Received: by 2002:a17:90a:a587:b0:250:1f6e:a84 with SMTP id b7-20020a17090aa58700b002501f6e0a84mr21822961pjq.23.1683808478539; Thu, 11 May 2023 05:34:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683808478; cv=pass; d=google.com; s=arc-20160816; b=GWa81OPxFZl2st75JErBRc+pOvsNbB0UVEfvBQ4XmXNT4tyz0GRkwz4eieVY84EaWX PzZw3ZDp7XCCCDjMmm+hOwii4RpgSYJxnm7p0hTKCItMEr8s2K6ec3FvpME8o01LV83o mZnm67Wh0nyqyZKSYfRUlBm2Hmtqjw0nIHKbWablzHUwNZbS1FAeRCE2m+ZUIdXxhBUA QOX5Hr01cr7UHkDkcz2VTnN+vXYZpERdbTeiJmaR5onx7Z5grFXgdIH4Bbj30wpWWQnL OiSbXsImDIW6UO8TBr1HWiAO/AmkocQK1gpG2TlAURPZ3BsIYQvtLR3gEdjqJWGWvqbx WtiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=R578/ZAwyPw4Zbv8Rszn4UrKMKi8DO9LSCgUrzUNIAA=; b=LAE2yqtXFguJpVuh5V34oOuyO3LbwJsTQW8jx7ycgRJjbc/5dkr1Zmb5m+OBmWoLNo rJsD4jo+oRnbW3eo/9wazC6x7KSGdTu+2CF7BjkzD2HJ0JEBP4b8762ZAlCqQXC2lJ72 Kh7zt2nYxPnLrneOtvikSpLoca0UH1hIy0rER9tMH/EirtUHkqRrDXdT9jGySWFrNNCC NNx/31ho/HrniCC0hPaBaXEMMRs/Y232f7QbpvzjoZJq6CFxWj4w3BywyqKp64KRBayQ aM9WgABp9L89DnhlLp3mi/VTvyxJa2D8ggAKdd6tlIklQdDyNDiozz4iFqVJ6kYcHYMB LoQw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=3li8acMB; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); 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=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mh12-20020a17090b4acc00b0024784735e4esi22207986pjb.115.2023.05.11.05.34.25; Thu, 11 May 2023 05:34:38 -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=@amd.com header.s=selector1 header.b=3li8acMB; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); 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=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237760AbjEKMJL (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Thu, 11 May 2023 08:09:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237751AbjEKMJI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 11 May 2023 08:09:08 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2063.outbound.protection.outlook.com [40.107.220.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA37B9001; Thu, 11 May 2023 05:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LUyqJ89kxPemJ4nRoiWDDMEX4NFM0RSEN13GGP1lOflOneIF/lcHvi4lUR5KxQ5j+ZjMvb8Jr2KUA4AakNkfh+ft6IbLi/XMkFVjhBrqU0wzhxgmRUFeFNTAOV4kovq34eUB4o41bWlK8T4jMZUqqLEznHzXHIeA6bteStbbGxdc0mZEh441uMbpBuGPAoMSTFqAcZ/Nr3lULBpP7erFnume4OQX7GEmz8e31aG78FH/i2kim12CwRSxjbcD0lUZtvpH1MrGjhFwgTDTvsRYlTeqq+rNS72kcbM02nNP/V3RdZu8ap3Hf41BMj7JMEMeQWaxH+hXa9pRl40KT2roTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=R578/ZAwyPw4Zbv8Rszn4UrKMKi8DO9LSCgUrzUNIAA=; b=XzLN94zPqCiuOCJK9P1Aq0F24w4Aga/4UtWxQn1uW5TBHBfrcX3bV88hWaVkJbGZLScj4/Vlq9sC8hu8gYMnzAO8UyehfSr+FC3dMNXWwDeCw35eGcfxOQj8vc93g7pL+RTi1nVdjk4z4mEye6kYFsxhN40NOCW2XIUZJANxasN/Zo5KzGgUdLE2lFmqBdzh927YdXnMgwOBE8aBx6Jtg/+55zhjY3xT9QYAObn8yiALuHT6DpA7q1L32/tAR1W7p4/wedVSO0asMz+cPIs2kfY/a+ZalYJ5KfEZjCnOfG5NMmcK92J3bI9ngEjBm0n/cpn5WigtR22E2iIPJ6F+bQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lunn.ch smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R578/ZAwyPw4Zbv8Rszn4UrKMKi8DO9LSCgUrzUNIAA=; b=3li8acMBBXgaZpbXZVG8yD4qCUz74ndQvR7oWBduOqyHiSOn+iAwCaCbfDxdLJU1o8ZGLbcQqXVELLkxZ6FJNKqe37P37oFQWpdtKXeYnKfobaBNK7XmdtzgHOi81d1LyKXayuKrAxsBM3gNyK+pRYsBjF3az38C07b9odzSY4k= Received: from MW4PR02CA0015.namprd02.prod.outlook.com (2603:10b6:303:16d::6) by PH0PR12MB8798.namprd12.prod.outlook.com (2603:10b6:510:28d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Thu, 11 May 2023 12:08:28 +0000 Received: from CO1NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:303:16d:cafe::24) by MW4PR02CA0015.outlook.office365.com (2603:10b6:303:16d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.22 via Frontend Transport; Thu, 11 May 2023 12:08:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT049.mail.protection.outlook.com (10.13.175.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6387.22 via Frontend Transport; Thu, 11 May 2023 12:08:28 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 11 May 2023 07:08:28 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 11 May 2023 07:08:27 -0500 Received: from xhdharinik40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Thu, 11 May 2023 07:08:23 -0500 From: Harini Katakam <harini.katakam@amd.com> To: <andrew@lunn.ch>, <hkallweit1@gmail.com>, <linux@armlinux.org.uk>, <davem@davemloft.net>, <kuba@kernel.org>, <edumazet@google.com>, <pabeni@redhat.com>, <vladimir.oltean@nxp.com>, <wsa+renesas@sang-engineering.com>, <simon.horman@corigine.com>, <mkl@pengutronix.de> CC: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <harinikatakamlinux@gmail.com>, <michal.simek@amd.com>, <harini.katakam@amd.com>, <radhey.shyam.pandey@amd.com> Subject: [PATCH net-next v3 2/3] phy: mscc: Add support for RGMII delay configuration Date: Thu, 11 May 2023 17:38:07 +0530 Message-ID: <20230511120808.28646-3-harini.katakam@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230511120808.28646-1-harini.katakam@amd.com> References: <20230511120808.28646-1-harini.katakam@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT049:EE_|PH0PR12MB8798:EE_ X-MS-Office365-Filtering-Correlation-Id: a5efe008-b101-4362-e359-08db52186e48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kKHv6GCAGJuU9vebXE3Tlqj2IyCci6qmd1VsbbI3AhuS8trxd2PhQ3yTq5Kf8hs7fZGs/AdIWjx1R/fcQIP9+StnV75Y6BznD4S1KfKarNDF7S8e7JZPaGCNtKnq10OwNvRbBAr3G0ZjM1C+zzPuOSjTUTWUr4OTuHuv2zC33g+AHn+xjkcT0dlJxy08fFqUAO7PpGhaTZKnnllQoonEHXgIt5s37mYqc6SpsZpGRttMSU4aTmA76Z19LzGm58okfgdEvWbdYV15BSER/eeHf2Sm6H0xYxuhZfQ6HUlHinLu7ePmveOf9JED+J32qh4AUw6arJOW/OMndm+2cpTy78Eb0Od3/2Z9UDuDCyluMfgae6D0c9D6TaAItyagcXCTfuZGI7cS5FRJiV3lu6X4EKMMMrT1F9B92O1tII5PArh8ececsPkm3E39thc6FaAkt6byDhVgfUUR40sqDR3ZJ9Ws+/PEaL2YW3YCrL+PbBzBXUJk2gX5it6hFoXNMEvFMUsLvzltKEmclDJoYJaSByjGYCdT6HOV2qwx/PH0wC9mp6UUkRqWTnEY+E4I6/4LN1uK2545hw2ivOLbra6nspumSSCU0JHdmGrYNet3/ygSjILeUxXWnyD8QA2W72GZBmt0cee64uE/Q0F+Ajf9WQCYNwmfe4IcKwsgCZlu4qf9BKnGE0qFS5lAwzFUQMAAimqgRVviK4E9pe7fPSTvpw9nRwFuFolSrsDyqoQaL52IxSj86x3laQymRamIzVqI X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(39860400002)(376002)(346002)(451199021)(36840700001)(46966006)(40470700004)(478600001)(54906003)(83380400001)(47076005)(426003)(36860700001)(2616005)(336012)(6666004)(86362001)(40480700001)(26005)(1076003)(356005)(82740400003)(316002)(921005)(110136005)(70206006)(4326008)(70586007)(41300700001)(186003)(81166007)(8936002)(7416002)(8676002)(5660300002)(44832011)(40460700003)(2906002)(40140700001)(82310400005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2023 12:08:28.4458 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5efe008-b101-4362-e359-08db52186e48 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8798 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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?1765601158922872768?= X-GMAIL-MSGID: =?utf-8?q?1765601158922872768?= |
Series |
Add support for VSC8531_02 PHY and DT RGMII tuning
|
|
Commit Message
Harini Katakam
May 11, 2023, 12:08 p.m. UTC
Add support for optional rx/tx-internal-delay-ps from devicetree.
- When rx/tx-internal-delay-ps is/are specified, these take priority
- When either is absent,
1) use 2ns for respective settings if rgmii-id/rxid/txid is/are present
2) use 0.2ns for respective settings if mode is rgmii
Signed-off-by: Harini Katakam <harini.katakam@amd.com>
---
v3 - Patch split:
- Use rx/tx-internal-delay-ps with phy_get_internal_delay
- Change RGMII delay selection precedence
- Update commit description and subject everywhere to say RGMII delays
instead of RGMII tuning.
drivers/net/phy/mscc/mscc.h | 2 ++
drivers/net/phy/mscc/mscc_main.c | 35 +++++++++++++++++++++++++-------
2 files changed, 30 insertions(+), 7 deletions(-)
Comments
On Thu, May 11, 2023 at 05:38:07PM +0530, Harini Katakam wrote: > Add support for optional rx/tx-internal-delay-ps from devicetree. > - When rx/tx-internal-delay-ps is/are specified, these take priority > - When either is absent, > 1) use 2ns for respective settings if rgmii-id/rxid/txid is/are present > 2) use 0.2ns for respective settings if mode is rgmii > > Signed-off-by: Harini Katakam <harini.katakam@amd.com> > --- > v3 - Patch split: > - Use rx/tx-internal-delay-ps with phy_get_internal_delay > - Change RGMII delay selection precedence > - Update commit description and subject everywhere to say RGMII delays > instead of RGMII tuning. > > drivers/net/phy/mscc/mscc.h | 2 ++ > drivers/net/phy/mscc/mscc_main.c | 35 +++++++++++++++++++++++++------- > 2 files changed, 30 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/phy/mscc/mscc.h b/drivers/net/phy/mscc/mscc.h > index 9acee8759105..ab6c0b7c2136 100644 > --- a/drivers/net/phy/mscc/mscc.h > +++ b/drivers/net/phy/mscc/mscc.h > @@ -374,6 +374,8 @@ struct vsc8531_private { > * package. > */ > unsigned int base_addr; > + u32 rx_delay; > + u32 tx_delay; rx_delay and tx_delay are unsigned... > > #if IS_ENABLED(CONFIG_MACSEC) > /* MACsec fields: > diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c > index 91010524e03d..9e856231e464 100644 > --- a/drivers/net/phy/mscc/mscc_main.c > +++ b/drivers/net/phy/mscc/mscc_main.c > @@ -525,17 +525,14 @@ static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl, > { > u16 rgmii_rx_delay_pos = ffs(rgmii_rx_delay_mask) - 1; > u16 rgmii_tx_delay_pos = ffs(rgmii_tx_delay_mask) - 1; > + struct vsc8531_private *vsc8531 = phydev->priv; > u16 reg_val = 0; > int rc; > > mutex_lock(&phydev->lock); > > - if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID || > - phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) > - reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_rx_delay_pos; > - if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID || > - phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) > - reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_tx_delay_pos; > + reg_val |= vsc8531->rx_delay << rgmii_rx_delay_pos; > + reg_val |= vsc8531->tx_delay << rgmii_tx_delay_pos; > > rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2, > rgmii_cntl, > @@ -1808,10 +1805,34 @@ static irqreturn_t vsc8584_handle_interrupt(struct phy_device *phydev) > return IRQ_HANDLED; > } > > +static const int vsc8531_internal_delay[] = {200, 800, 1100, 1700, 2000, 2300, > + 2600, 3400}; > static int vsc85xx_config_init(struct phy_device *phydev) > { > - int rc, i, phy_id; > + int delay_size = ARRAY_SIZE(vsc8531_internal_delay); > struct vsc8531_private *vsc8531 = phydev->priv; > + struct device *dev = &phydev->mdio.dev; > + int rc, i, phy_id; > + > + vsc8531->rx_delay = phy_get_internal_delay(phydev, dev, &vsc8531_internal_delay[0], > + delay_size, true); But phy_get_internal_delay a signed value. > + if (vsc8531->rx_delay < 0) { This comparison can never be true due to the unsigned type of rx_delay. > + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID || > + phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) > + vsc8531->rx_delay = RGMII_CLK_DELAY_2_0_NS; > + else > + vsc8531->rx_delay = RGMII_CLK_DELAY_0_2_NS; > + } > + > + vsc8531->tx_delay = phy_get_internal_delay(phydev, dev, &vsc8531_internal_delay[0], > + delay_size, false); > + if (vsc8531->tx_delay < 0) { Here too. > + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID || > + phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) > + vsc8531->rx_delay = RGMII_CLK_DELAY_2_0_NS; > + else > + vsc8531->rx_delay = RGMII_CLK_DELAY_0_2_NS; > + } > > rc = vsc85xx_default_config(phydev); > if (rc) --- pw-bot: cr
Hi Harini, kernel test robot noticed the following build warnings: [auto build test WARNING on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Harini-Katakam/phy-mscc-Use-PHY_ID_MATCH_VENDOR-to-minimize-PHY-ID-table/20230511-200935 base: net-next/main patch link: https://lore.kernel.org/r/20230511120808.28646-3-harini.katakam%40amd.com patch subject: [PATCH net-next v3 2/3] phy: mscc: Add support for RGMII delay configuration config: openrisc-randconfig-m041-20230509 (https://download.01.org/0day-ci/archive/20230514/202305140248.lh4LUw2j-lkp@intel.com/config) compiler: or1k-linux-gcc (GCC) 12.1.0 If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202305140248.lh4LUw2j-lkp@intel.com/ smatch warnings: drivers/net/phy/mscc/mscc_main.c:1819 vsc85xx_config_init() warn: unsigned 'vsc8531->rx_delay' is never less than zero. drivers/net/phy/mscc/mscc_main.c:1829 vsc85xx_config_init() warn: unsigned 'vsc8531->tx_delay' is never less than zero. vim +1819 drivers/net/phy/mscc/mscc_main.c 1807 1808 static const int vsc8531_internal_delay[] = {200, 800, 1100, 1700, 2000, 2300, 1809 2600, 3400}; 1810 static int vsc85xx_config_init(struct phy_device *phydev) 1811 { 1812 int delay_size = ARRAY_SIZE(vsc8531_internal_delay); 1813 struct vsc8531_private *vsc8531 = phydev->priv; 1814 struct device *dev = &phydev->mdio.dev; 1815 int rc, i, phy_id; 1816 1817 vsc8531->rx_delay = phy_get_internal_delay(phydev, dev, &vsc8531_internal_delay[0], 1818 delay_size, true); > 1819 if (vsc8531->rx_delay < 0) { 1820 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID || 1821 phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) 1822 vsc8531->rx_delay = RGMII_CLK_DELAY_2_0_NS; 1823 else 1824 vsc8531->rx_delay = RGMII_CLK_DELAY_0_2_NS; 1825 } 1826 1827 vsc8531->tx_delay = phy_get_internal_delay(phydev, dev, &vsc8531_internal_delay[0], 1828 delay_size, false); > 1829 if (vsc8531->tx_delay < 0) { 1830 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID || 1831 phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) 1832 vsc8531->rx_delay = RGMII_CLK_DELAY_2_0_NS; 1833 else 1834 vsc8531->rx_delay = RGMII_CLK_DELAY_0_2_NS; 1835 } 1836 1837 rc = vsc85xx_default_config(phydev); 1838 if (rc) 1839 return rc; 1840 1841 rc = vsc85xx_mac_if_set(phydev, phydev->interface); 1842 if (rc) 1843 return rc; 1844 1845 rc = vsc85xx_edge_rate_cntl_set(phydev, vsc8531->rate_magic); 1846 if (rc) 1847 return rc; 1848 1849 phy_id = phydev->drv->phy_id & phydev->drv->phy_id_mask; 1850 if (PHY_ID_VSC8531 == phy_id || PHY_ID_VSC8541 == phy_id || 1851 PHY_ID_VSC8530 == phy_id || PHY_ID_VSC8540 == phy_id) { 1852 rc = vsc8531_pre_init_seq_set(phydev); 1853 if (rc) 1854 return rc; 1855 } 1856 1857 rc = vsc85xx_eee_init_seq_set(phydev); 1858 if (rc) 1859 return rc; 1860 1861 for (i = 0; i < vsc8531->nleds; i++) { 1862 rc = vsc85xx_led_cntl_set(phydev, i, vsc8531->leds_mode[i]); 1863 if (rc) 1864 return rc; 1865 } 1866 1867 return 0; 1868 } 1869
diff --git a/drivers/net/phy/mscc/mscc.h b/drivers/net/phy/mscc/mscc.h index 9acee8759105..ab6c0b7c2136 100644 --- a/drivers/net/phy/mscc/mscc.h +++ b/drivers/net/phy/mscc/mscc.h @@ -374,6 +374,8 @@ struct vsc8531_private { * package. */ unsigned int base_addr; + u32 rx_delay; + u32 tx_delay; #if IS_ENABLED(CONFIG_MACSEC) /* MACsec fields: diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c index 91010524e03d..9e856231e464 100644 --- a/drivers/net/phy/mscc/mscc_main.c +++ b/drivers/net/phy/mscc/mscc_main.c @@ -525,17 +525,14 @@ static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl, { u16 rgmii_rx_delay_pos = ffs(rgmii_rx_delay_mask) - 1; u16 rgmii_tx_delay_pos = ffs(rgmii_tx_delay_mask) - 1; + struct vsc8531_private *vsc8531 = phydev->priv; u16 reg_val = 0; int rc; mutex_lock(&phydev->lock); - if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID || - phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) - reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_rx_delay_pos; - if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID || - phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) - reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_tx_delay_pos; + reg_val |= vsc8531->rx_delay << rgmii_rx_delay_pos; + reg_val |= vsc8531->tx_delay << rgmii_tx_delay_pos; rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2, rgmii_cntl, @@ -1808,10 +1805,34 @@ static irqreturn_t vsc8584_handle_interrupt(struct phy_device *phydev) return IRQ_HANDLED; } +static const int vsc8531_internal_delay[] = {200, 800, 1100, 1700, 2000, 2300, + 2600, 3400}; static int vsc85xx_config_init(struct phy_device *phydev) { - int rc, i, phy_id; + int delay_size = ARRAY_SIZE(vsc8531_internal_delay); struct vsc8531_private *vsc8531 = phydev->priv; + struct device *dev = &phydev->mdio.dev; + int rc, i, phy_id; + + vsc8531->rx_delay = phy_get_internal_delay(phydev, dev, &vsc8531_internal_delay[0], + delay_size, true); + if (vsc8531->rx_delay < 0) { + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID || + phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) + vsc8531->rx_delay = RGMII_CLK_DELAY_2_0_NS; + else + vsc8531->rx_delay = RGMII_CLK_DELAY_0_2_NS; + } + + vsc8531->tx_delay = phy_get_internal_delay(phydev, dev, &vsc8531_internal_delay[0], + delay_size, false); + if (vsc8531->tx_delay < 0) { + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID || + phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) + vsc8531->rx_delay = RGMII_CLK_DELAY_2_0_NS; + else + vsc8531->rx_delay = RGMII_CLK_DELAY_0_2_NS; + } rc = vsc85xx_default_config(phydev); if (rc)