From patchwork Mon Oct 4 19:15:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534559 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34739C433FE for ; Mon, 4 Oct 2021 19:15:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13B6761458 for ; Mon, 4 Oct 2021 19:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238700AbhJDTRp (ORCPT ); Mon, 4 Oct 2021 15:17:45 -0400 Received: from mail-eopbgr60088.outbound.protection.outlook.com ([40.107.6.88]:55525 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236024AbhJDTRj (ORCPT ); Mon, 4 Oct 2021 15:17:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EQNUBS3akYODomCiN3x1ac/YYBd99+Px7xupYHvHCY1zyo+vtY8YMWxNspHp66hxfg96cZucw4G0XPBWcx5uqkzm9M86RjBVEe03ETiOnQ06PBsd7WwM7Y4jTegLyk1QRsaeTcbS2kMvyHDcjGp5pKKG3bJcSyeUKVOtu7n3zdrZcK87vlcx9k2QstDF4df3FdZfUIug99v/ek9pmEXupPF87wcCWFUZRJDr5zT5NvtpUCASFPwxEI4lbg6J3xNCvAKyyW5LHiFJSYziCIQGKylwhdQ69nFcU3bgZDAcCCecHl6TSQhaYpF4414eqj7qIIcO3RcBYjk1fpCTfWNiEA== 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=PUISQ9T9H/VOPco1fyucgWrbR4Z0SCRT5jht9oSvTOM=; b=k1bBmSkYTEj+vcejWca7SXI1Mrf8LwEMXtuyqrtsYa5dwHwWdcdNmiWq1L/L+qraIGjoGw6ZiNlUl0LDyeTUjOPdlkazn59wfQ97GRM9qW6stx5u/obwS39ay7WceC/aGC17diLiswrABzZgyngLFieZL9mmvH2Sp63Fgbrl+wY4LDvPEgh5fLhrL/KImJSHiFfV4A/rpWuwx7uluSjZNBSNB7k068ZqHl6nrTW9pGWrX0eHfhbh9hiiuRhNiN7brtL+/vqqT3p5nGEJLGMRZgwrphMbf1/jcazr3ndBr2S3W4VPT7APdC5ECiGiwIAQrRIInkM43xN5HxG2kyMN2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PUISQ9T9H/VOPco1fyucgWrbR4Z0SCRT5jht9oSvTOM=; b=vexHImE1A2+TBYWlZhXVHSnaOjPge8dooKy+lFOIkvzFoNgQqwFd9Di5H1kll+MnffarQ5MW71wYsNvrmZVKisE2Zn0UIXtGGuz+nZ2cHW7T+tYfYS0VWYNx001lf9SOqbEa5bMStTtcRms+r4dxAxMyIt4zwzOBC59oNYMbhIY= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7434.eurprd03.prod.outlook.com (2603:10a6:10:22c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 19:15:48 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:15:48 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson , Rob Herring , devicetree@vger.kernel.org Subject: [RFC net-next PATCH 01/16] dt-bindings: net: Add pcs property Date: Mon, 4 Oct 2021 15:15:12 -0400 Message-Id: <20211004191527.1610759-2-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:15:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 84aa43d4-f72d-49bc-8864-08d9876b5f4a X-MS-TrafficTypeDiagnostic: DB9PR03MB7434: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ihs9FU0ikdDxcNX2txzrar0bXj3mMTCN+L9QwOLt47NNa4Ndx46qQWjJzYSrvysYiLY0Oi0vRLFSICQn01cPJe7Hp0bkMhS4y961yntjyRLi7YZSNr3V7jctLECdX8PGWhC9TpdAybdNLyUWPl1U7EVbCQzCGFAhI0axC7e+rlOUK10X+huAXPAbYTlI49AhtOQrV2xTRgLTOROoWUeKdpQOkLymyN9oYs0JNFwhmXKRUNYzAxEmIAR+V8jpVroqsjNmElXknWA4bNjlu6ujFsjIspzyvGWJ2Eeh4Gz5HNyVjFmDDfuCwZru4yc3g6GaEqXJrsjijdHabeVfc8Jl2jpW3a8tqavoI8Ny6VKYUaxa2qQwx3fmCP4G7enpe1xThG2tE0AwezIUGKOa/NIxxi9w1ayAAQpraCJfPZPP02g9+wyQ3ndOXkFGfZa0a6SFKvKDb1bE277KCv1d6mHjhVmJ5Am7+VDQX9t+ZnkN1STj2YzRvc8BTZP/HFsblf+OuZFsUwn0Z742lW5lFv+/rU/GHHMYk42QPINx+H5iUaiYTx2uXFZvQArP3mXavWj0WskZHb8MCD/v1kMJHyE7h4wnFAe73kp/VWOW68DyF6jxjIAyriSitD/PGNrIHFW97js2+Wgx0CA30iIFvGwb/7bSajDDK4dq0xRaNzJSo82odm8n4OYQwI1IalDUEhFZuW2vxi/78egrsaT0iGMe4w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(1076003)(86362001)(4326008)(44832011)(6486002)(5660300002)(66946007)(508600001)(38350700002)(52116002)(956004)(66556008)(66476007)(38100700002)(110136005)(6506007)(2906002)(186003)(8936002)(316002)(8676002)(4744005)(2616005)(54906003)(26005)(6666004)(36756003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UqWHr7xH6EFELpxIRTYb+RqrakRl5thObZfKHXrt/NqssCqiFSU99ZVyFi5f7wKZA0ZAQQFaSukefA94zYAgdPYcz/YOI7wr3ZMwBmqtZG60uPQeFpfnXnMalYECsjczOfFOIrLminDGs/dyajPQ8xkeZgA/q0M5dYz0lMfWUEJUq8ZuPkpNP9zAYcT49ic0TNb5F5m7+QZZmCXMTq1Lh31hrXNx+f10iwqc1EJKW9Z+d6hSmUvFbsXm97nJJf5gi87Sz/sKHXEhPh1mBE6uHWhpOHMlQ2ixqbql/aBvbTo9f8vu6Z6Qy0HPyiPU0r4s5RQEWjfsXA1zHyLs4MNOHuj/XuQtOkiKux6qbD0jz7Etgwdn6DLEHHWL8ZrI3NsBgFh0GQsGVifl3H4dPG4ZYlF9mitPzx/swetrT5DwTOjTNgHkZuzY4rAmWm/uTOcOEwrXqbGePhg4SwWTpu8F8jj2RGlF7+y96X543GJjZ0+MciXiXLbDhr+XhjpiyX1ikkoBRUfOtkUpc0n+lRH0OI5uVsC51s5YS8SOWSCI9ArODJ8slZWcndicj9H45K3+7wBzm43ABn9c93sF27myTVYUyQCWjetIde2j7vzteU07MV/Hd21dXb5SQTTgn0SiA3e9XI3oQdJQfGpufBJaYjweHIS94+HHzyiFp7PhuZu0s4+CAvNrkVfok3xmRSGuIJX7geoFECHsJ/2gdtzSe+ys83BtDfRdsYMqut1Tnws/Q/cveiFA9Y/zh6mB7kLhzMpiEsq+XfJB2C/ctiU5qdq3UweQX8PjAu+w34zW7SAL5VvBhsp/q4i5viubwTJrf8A4c942Va2CHZ7rusIrfFyP68V9KExWYZZlX/MjuUsQZY4P/ChNqbYCte2bkOgWxvNQCeWWag0KA/OAfvr0+ZXsO8c+64FMyIpVtBMqFBdX99KwxRwzr0cM1naFJ8vER9yInIsSH8IWYimii9/ZoYyz3Tc/eAys6118ceiETsiAAFL2Xclxu8qB45gmJWs02mVeUOZhtUJEm2+BmFR6AN5sE7p1Xn+MEmmV1y47PtvCqnCd/jipgEtUWb4kVgWOUzjFfdSEluxivV8z6tQDRxyMJFUG7S0QaOj5b3yHn5gZAZO5oYXNGkQJPIlOkgYG/W5So8JLcFN4lCkTUPZwQIreruBx+f3qX1HiZFVRUowAVy63oZto3m+ptL6j5Ww0FXt8cKPAQTshYlfcOxx6GHSEwjidXSABOYIsQdNZlRdFS7D1aBOdpHWWeyE7b7r6ddxwg6nLGiLK/NUg3tjtoHCBXTkadni4hMJwubZdD+TFwi8I3l6S1wxbqNXpl4ff X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84aa43d4-f72d-49bc-8864-08d9876b5f4a X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:15:48.2481 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4MFKdNqQCzO/CMmw2S5kbLzpdJwsFKcTPvwAvQn8G4A16Z4VISkuQOigCVCJLlnOyuJQgCLVbxj0TwDxdrCPDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7434 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Add a property for associating PCS devices with ethernet controllers. Because PCS has no generic analogue like PHY, I have left off the -handle suffix. Signed-off-by: Sean Anderson --- .../devicetree/bindings/net/ethernet-controller.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml index b0933a8c295a..def95fa6a315 100644 --- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml @@ -116,6 +116,11 @@ properties: $ref: "#/properties/phy-handle" deprecated: true + pcs: + $ref: /schemas/types.yaml#definitions/phandle + description: + Specifies a reference to a node representing a PCS device. + rx-fifo-depth: $ref: /schemas/types.yaml#/definitions/uint32 description: From patchwork Mon Oct 4 19:15:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534561 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D67A3C433EF for ; Mon, 4 Oct 2021 19:15:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C04C96124C for ; Mon, 4 Oct 2021 19:15:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238590AbhJDTRr (ORCPT ); Mon, 4 Oct 2021 15:17:47 -0400 Received: from mail-eopbgr60088.outbound.protection.outlook.com ([40.107.6.88]:55525 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238501AbhJDTRk (ORCPT ); Mon, 4 Oct 2021 15:17:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cGC8264jgEkkgBtrFWqKryk9wttea7ANKl4pxOg+UxpxYoDXmugIXThaJpxyp+EPKXxsucMy71Dw3OIsjCusAyL7d1CLvB2Ujgsd1gNoWDl6pmyVShJDNq4j9BDWG6LKXAgyvaR4gO2ws9XRGGdPdM2KPhAk3vbWNnUslqsL+RF7PjnbYWl3uYbHCOLuG1BzVNvXZLoF+452zPUSZLu1KxhjzUnjKySPnBEwuRKXEn24/o79WsQRw26jvUKpqgRXMcWEgxy7Dy+pBkR0xHIer51n4xb/sMd2u12kYVnoX2meqOR3B7lLNYlgqLi6t0855f1fOh1I7aMLEAGJYfITRQ== 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=p9UlkUu6sxJFXBIxo3jZuwWY1oxP/LYIeHhe83CUWic=; b=P8NteS0acuSPhwwEjlJSRBJVI/0DQorrtqw4lWGXrgoVVwg5a8x7SXjbOqynVil177KRnSEILCMbNPdPXM1AZL4zdaAQX+pbASxOzN63WKitz3d9gUge3AQ5hejCE8PbkFFmYKBTLlz+qRLiOVS1CLuYm9nWLoqhIQP5jWCMXux+YybEwQs/XY3+PobYllqKgI4iqs3PqppKyN8FDCjc+SQ3hZ+656siNus6KO+37HXvO3MgQyn9skGScF/MAEoVFe86lQJ8oiGtwsq7nL+THS9w2RuKtcF1NfmWf2EcJYJb1Lqmf63DfeqJVjKSE0iKh6cl/P3YXiH6PSEJaNtYRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p9UlkUu6sxJFXBIxo3jZuwWY1oxP/LYIeHhe83CUWic=; b=sgnWL/R/1K5hblIIQFI746lHLNESk9aAAn4IrHVk4kJ1XGqmNnCaYdK42vXfcXXTAvXv6bqg5Hidjp6liId12bKsKxLzZYLvQTDk7bffiEL8n25oDeJ5vaWsKpFAtRGFgde/PJf7l2PzhRQImG1OLK2t9pJgZvPCGLIQ74BHwcc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7434.eurprd03.prod.outlook.com (2603:10a6:10:22c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 19:15:50 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:15:50 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson , Michal Simek , Rob Herring , devicetree@vger.kernel.org Subject: [RFC net-next PATCH 02/16] dt-bindings: net: Add binding for Xilinx PCS Date: Mon, 4 Oct 2021 15:15:13 -0400 Message-Id: <20211004191527.1610759-3-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:15:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5778b41-6ec6-4122-5118-08d9876b6072 X-MS-TrafficTypeDiagnostic: DB9PR03MB7434: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3KaFzLR6x5stWllMcAygW4xopQ4LhduUiXQUJqBcdAs09PSECv2LXVQEtttw3bh/iw1wf7HZbzRJFjNsIqQsus7sWnqAnm1wf9bQb3lwV6MDVc0raeKDnBXilkA1RUP3y9VaDsB0Yl3XOFv4G0R7kuqXaXcPjKqtkSxIdMaAI78loIbqP/39WEF22cM3aqrXl96hnJ0U+sJ+FoCi73hHn9/RID+ooaWqkdfawuac9o5+ZRNyuG8X6WMooZdqlo1VbdCFyY/5qYGS9Qa92RogBnhtlaqTr8hjt0BWo3TEn0EhkR26/YomqbBY/QMCBVxktOABjA6n9U8CgFoAhJ8GApmQTgSU3UhSQw+9rN3hL80u6/XyFUZv4QeUyy+7UUTNcZxXf6GXztK/gMwYx5dnykLC7k+NVuqOQ3r9M9FeWbFca+S/nvB5nvgjCUwx/j6lTVhbUI0Z0Pmkk88pFIiX2w3ampgvFuza5baftbW4IebfoYS49d/xaj23kv53KvZPB1LdHRk6i1D6QRIQ2hvqzVzreGONJwP9yPylvcjdJlMFvK4MYuSLIWt+vquFL2RAQ44+iLk7mOMgL1FwFwSXH0qxan/IM56r7dOg8y/s8fXBv+h5dW6jzLlhVBAUcaynBP0kAMTdNgVchcBqyJOmmqPTgwPBYsBx2+o4Gu1uEe3bX4SmZNC5WYx/B8STzlt0ciifPDJ/aWK+y+4/xgs17i9yehtvVLZZuUQh7W2xMNh2uz73rskr4xvSU0TJxR0Ejh5+5nydDIPuRiVch4nc6o4gZfAcX0Yv95YFke9KN2A= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(1076003)(86362001)(4326008)(44832011)(6486002)(5660300002)(66946007)(508600001)(38350700002)(83380400001)(52116002)(956004)(66556008)(966005)(66476007)(38100700002)(110136005)(6506007)(2906002)(186003)(8936002)(316002)(8676002)(2616005)(7416002)(54906003)(26005)(6666004)(36756003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /rapiSpOwr3F8Y/BspyboF+V+nl9G4QVH+kNj+LFdptPOllesv62JK7EGXxq2XmxBg1gC6zzzkBDdNuvbEDLMzayszg1GsRI83z9PlxIygXckL3PmqQinB+3Rpl3bE1M4ACquVIDBxGOcv0SU7l0N2mKTzIFnqu949sLqGComhL4kttsQZMjURLgts0uI/JP1NnSFmrOi2LMq3SWBiQBZRE+kn3qjb6tRoE30rI0dRbabsmkI5GvKfMByaK2yYM0UmYdMb7vmtyC5q8vZ0bpIj45cYaNr+F9QgRVsYh+qkT85bJhTDLec55DsMlPQmUKTulFQbgM1It4YXHlFe/emmorIK4H8cjDmKKdquUHGyFjI7MEh+hIlvyv7McHIUdGc5NlNe42mHU2Xx/oaCQZAHnHfwrTq/TD3joQUe8HNNzCC3YF7diuii8HGci61DVFmDJP+Pkt3ObP9O/pbzkLQYBLbn9SpIDrgM/JT8eG9ZT0XzijdA/LPdjTx79MBOeLvnPJ8VBrbfgtpXeBFWmoYhEAzc2NEvY0kvGw23JClq0ajLUKrqEWsRBh/gWUm0dMFTAQzjkGQ6Pf7Z8ds+fKRgZTY40O/b+fNGP/kPevQaeGSR+SzMcineVRPH8OI4LJD6hHTnEC1ophHrcp2CewOuodCyF95FAfG0rWgHrMdIoKl6MOV5Irkg8OBoQ4fKazdluvH9uGTeWB+gu02IzuONkV8xAgDg54BuxWePJG2HokW8KC/EtqcObqW3WsxAGDd9BaEkiOHxzcOX+RKFaNb2ebByVhb7uYiRlsGtapHHBPUSsxB4axxTkVv9FFBuf5Pyj8qLnv9g/KewKTtxpWdnNyqZvfxn4zq/D2uosAVuw0GjqewX/nttfScqUkOs/IOJUcfxyvYxJrs8/zrRdSi/hj5+PT8RMTjFatoDwOHOlhapR7Qv1VPbg1fYXKOOaXXW9JXZuhlSQ/LgC9mrwdnj00OO0XwPLncNk7EoP+Zcl/U49+i1KeyXcxfOCT6i0DZuDPcoqYUP7VvZe6EM4+73FgmbUr0B5stYnOFDcHH+k6rNRhXVDuYjrjKg2KveHWZ2c4yr+V4zxUtsbAnawGd0XstA5S09F+nZsqhQkzhx3JJPhIzdrn/xtZ9plyMcfcKCMG3VitxvaaKcnE3Fywox3rFuJfF6VkZ6STYFTstKPT8OPAKaoVRt8MmfF6dqcE/iRhd8BJ38AK6BY0U94fv64TKEg+3OgDmXO5MJHatr0kfFQ7uJUwvdKAT075Te7P9MPOqZLvnc3ViwnKSiov20/epaPKem2NfL54xFxfIuNS6NRkm4XY02a9x2Q1LZMu X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5778b41-6ec6-4122-5118-08d9876b6072 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:15:50.1606 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3MQpZJf4zouuU9jbiSIXKBsImwZOZbFfg0QS8PbtfeOC2pwHSmV98P3ZJm0TCJfCkZegrxdAhxMugww9q2DNzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7434 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This adds a binding for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII LogiCORE IP. This device is a soft device typically used to adapt between GMII and SGMII or 1000BASE-X (in combination with a suitable SERDES). The standard property is roughly analogous to the interface property of ethernet controllers, except that it has an additional value used to indicate that dynamic switching is supported. Note that switching is supported only between SGMII and 1000BASE-X, and only if the appropriate parameter is set when the device is synthesized. The property name was chosen to align with the terminology in the datasheet. I also considered "mdi", but that is a bit of a misnomer in the case of SGMII. Signed-off-by: Sean Anderson --- .../devicetree/bindings/net/xilinx,pcs.yaml | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/xilinx,pcs.yaml diff --git a/Documentation/devicetree/bindings/net/xilinx,pcs.yaml b/Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file mode 100644 index 000000000000..43750dcb4b11 --- /dev/null +++ b/Documentation/devicetree/bindings/net/xilinx,pcs.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/xilinx,pcs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII LogiCORE IP + +maintainers: + - Sean Anderson + +description: + This is a soft device which converts between GMII and SGMII, 2.5G SGMII, + 1000BASE-X, or 2500BASE-X. It may have an attached SERDES, or may talk + directly to LVDS. + +allOf: + - $ref: "ethernet-controller.yaml#" + +properties: + compatible: + contains: + const: + - xilinx,pcs-16.2 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + items: + - description: The reference clock for the PMD, which is typically a + SERDES but may be a direct interface to LVDS I/Os. + Depending on your setup, this may be the gtrefclk, refclk, + or clk125m signal. + + clock-names: + const: refclk + + resets: + maxItems: 1 + + reset-names: + const: pcs + + standard: + description: + The interface standard that the PCS supports. The sgmii/1000base-x + setting indicates that the PCS supports dynamically switching between + SGMII and 1000BASE-X. + enum: + - sgmii + - 1000base-x + - sgmii/1000base-x + - 2500base-x + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + - standard + +additionalProperties: false + +examples: + - | + mdio { + #address-cells = <1>; + #size-cells = <0>; + + pcs0: ethernet-pcs@0 { + compatible = "xlnx,pcs-16.2"; + reg = <0>; + clocks = <&si570>; + clock-names = "refclk"; + resets = <&pcs_reset 1>; + reset-names = "pcs"; + standard = "sgmii/1000base-x"; + }; + }; From patchwork Mon Oct 4 19:15:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534563 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 143EEC433EF for ; Mon, 4 Oct 2021 19:16:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F10B961452 for ; Mon, 4 Oct 2021 19:16:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238588AbhJDTRt (ORCPT ); Mon, 4 Oct 2021 15:17:49 -0400 Received: from mail-eopbgr50077.outbound.protection.outlook.com ([40.107.5.77]:3542 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238664AbhJDTRo (ORCPT ); Mon, 4 Oct 2021 15:17:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bJynDbyzYcWmVoypoUqDzN4m08JgJvkx/8/6kF9AhFFmzkZHbj9SUeEQSLnL/BxkKlBr1DY8Co1Zj2O5sqsnM8fGETyCDGl1PQ2wg71sl5rUHz+gvujsXbxfnNyQtH1yGZLYdJpHKpa9/bgjX8HIeY8LUoFr1l5x09C68vOrpq1jbmn+pQrcEiC2G+bdUIkB50HPr6yX8EQuc3dp/Sq/U4tRxbhcqwnrOGrBAHosxJarQF0JXQxL9SnZwrBg2sJDdKm3Pv1iOOEJY9OthHZEIfUQ5rb/JpqcMJY3mRo1+glsIUGDzTSQZJaYWwAVMFr/AVGe9yaW81ucaPX+GuyXiw== 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=VCIe0IukDIjAiicnw2Cbu3bzzlO0kk7AeA7piE7rXEo=; b=c1BYt3l4ArzvRchDfDZVOVcxtjUCw8948d9DHfyOei8raNKVYj3IAaWIr8Tm8t4Q+c3d4WT9ROWAXYoeUsvE2Krk4B24pAFBlUF7CjSNMcn0PRW99SeVh+oFqE5N6uN8uiwt1jeTjjjQKfx7rOHLeskEve7hSllVg8S9o4hpiKtg2D9G2GvxhQQJrq7PGWCnxktKR3y3BGtdHneE7a5VZDq9F5pe5cplAJb2dx0C2jcEtU8eFWJZSRRLjjBDAnh4wlgsjjxyLFP5jOqXrclbKy6VnvOPTNQ3c8m8U1XCjvEraumkVwAWH3xTS+HBhlbJ+APSXXV+NfN58QJKI2KSfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VCIe0IukDIjAiicnw2Cbu3bzzlO0kk7AeA7piE7rXEo=; b=Dn+DykDJ/QxwCgOGG8J+Y7joyPXayu50+jwB+vK1D9SX87Ue410f0QzPdMJJx7eZL3fcF2Wba+hOPrMpjZiEMf+Y0E71D+7ikoQzJxZMEIOsaW5Zd++QIuZzy0rwxLXA4gjm0elBNwcBzu4mw3+GXsfzNI1IvIDfbT5poX2px0o= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7434.eurprd03.prod.outlook.com (2603:10a6:10:22c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 19:15:51 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:15:51 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson Subject: [RFC net-next PATCH 03/16] net: sfp: Fix typo in state machine debug string Date: Mon, 4 Oct 2021 15:15:14 -0400 Message-Id: <20211004191527.1610759-4-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:15:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b8df990f-5ff9-47ae-e8a9-08d9876b6160 X-MS-TrafficTypeDiagnostic: DB9PR03MB7434: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:612; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WfBUDOaoeUL6NdDmxAusbPyFMdsxezcIuX43pZImETBDnzHC8X+gW6K3K0GoIV4uN2TRBWcZrhTzndD7RfIgY0m7qal30aW53YzRrvQ9SSj2umtqBej4BAS2+6dpeFujPciuZwkkM0goMIcwBk4YSJdvVo1MF8wqZ6EUfC9rG8FfsPeV31irUZg38/l5cvwauxjMrZoMeUr8oE8RYlnCAF9UEar0EYtQignaqo2PMHM7NXrg2SIv7iRlbUmQkDBwdtUMUGwbF+P3WKvFxDYgjeLcDyN50JDSsQ+LFIGXGj9Lk9qsO4fD1Gm8Mks2F3I+wjQwAM4hrOuARMYRjlp+QUMOfmg8ubqyALqVMx0A80AzzrNRvyIfDfBsnNS/+b0T9Pqyv+KUHUJ/oKxgiah4vTiLleGqeQgHNWRNNrtDJh6412SIP+taqOY6QQivlLvOHmVzvDbg02dRofrKeL9rFmJLKqMMTvblcZcWMOdEIIfVBxIh/+d0k7qhoWNiWRm0sKuRKoJkjnukbIYlfDef9wPUUKJA35MqzYs9xUn+tZgjoh2YHFPDbB1i+83zbPOnDsJh8t4N6vNze4+BNJatcHy2C2DKPMG6mEzeA/Nzy9sV/+paq7xOEiJVHsITCBG5ImEyfbjipUGxLcakNWyCoB5YdmZ2ZxgH7ePENqnK+Z+BhCk99mD8GsFiAgy5rrU643UuArR/K+PH+VoUDcmj6g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(1076003)(86362001)(4326008)(44832011)(6486002)(5660300002)(66946007)(508600001)(38350700002)(83380400001)(52116002)(956004)(66556008)(66476007)(38100700002)(110136005)(6506007)(2906002)(186003)(8936002)(316002)(8676002)(4744005)(2616005)(54906003)(26005)(6666004)(107886003)(36756003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nwrz9QETLIgdxkc7z1kauugPf0c907lft2KcZdtfq+Lq25I8MYb/KWECh9oQ5Hx+nYlDVoqJJq4ClWKU40rx1rDpQQfrGEuzAgqg7iQBEcL7t780y0XE/1Wi0xLHQIzZYs/qC90zbYr2y1quiaCVKUwSrO13l3rjOv2BXa4DL/2VvD8WBZOA6XO5oRbiZfZjlWKU3pMWz3RTjxVteA/Y+Urq625rJM2xU1VELNI1m/mDddG78wWGYe4WXI2fxn3NAKXSQuRMNBLnWXL9xKCqp7dSrSHx4cl9gNBGVYzcfYWgwPY28m8KBKT0t4LUQmJr6B/DYxj/Cf+r2JXulFHyhdJVEaKGs0jIxCU7M/0vn90v/3t20owYq/h9mwvSopwEWj/TArT9Yy65qT7sakH8SvzlpQw5JL+SRHvSaNEx5P7x4B/N9wpfxLJGsXiJkfyyEF79z57BQnN6qlzul+2R2sxXHfBp1bISgZTbIziQzbWCqRRsSK4nJ6CttEZWnLZKSHFDUjlSherQvLMfgOtte/EO0GsnoRmKUWE7z6gXlvLjbG1VqzcwLW/pgfYVMrxEFFyZ8RrWT9GuKEXrtCZlbQPDo8jp9kKhVXOOHBkf7oG9DT6VOwSq1kHGTqoG3SI33c0h6hyFQrlWpD3Fgfhhz+R9yPfH6N6S+eQA2tVmuO9BOHMXQE9+KvadYdVtmbU1gVYhdfMp90JLzlOQkHxI2hy1M1dA4cNNOypULBfvGqPBpQPMK6j7UYv6WuLPGIWRnQj52oVj5MmQfsgUkpWRLTJtc6RnsbYeTYb8GFcocR6NeiIe/sv7Qu6OJKwAJ7V0ZucbEjCQJwubab4SPnc29IczxNcP4XKfreWwpRXOcBqvL8kxJEpKvw41eZzXLn+3XxV7hk3QiKrWZVrxZ8Dcg/q/D36pLkKvjfUYGkU6ZEFsWvVUnpBqfTgHhwhLQ5W/WmFwChUBJInr6hmb5RSUO7tRWIPtkIWD4Q+S1AIkkbpTiHpzIi5QQ98N8ga5X9IOkcS5UVv2nlmNLeZUInb+bP8smVjMQaZ7DMKCOJKcmLVGmtHqiW6Mc7dXS0lL9//bAz7NjK45v+HHGWY+xQpRM9toPgz7fl3SMPgnlYxkKsLicpCHwnMZTVgrtx0pGRE9A++VyypFAUJdANuM9CmObOPaTj7DXcWqYPpSF+0yMVqiiYZba9a2A04NQxNsR+CE5GyUN1Ui7EWBflXN21Lw4rJNgsjkP7/9eMFsx3k5rwt4J9NbNhC3i3qMBB89NZfU5M2bSt2LBH/mraglpkAl3ldWH4Bn/H56TTn4l3tkeEEnn5w5xluWtMoGMDYCWTT1 X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8df990f-5ff9-47ae-e8a9-08d9876b6160 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:15:51.6438 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9mKx57bO6yE99WIhEGcZyLXuPvn3LwM6GTIKDRg7MeNlZ2IEbVvEhHD0+gat+k99+KqtdxvwqwgpHgvvRIPxeg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7434 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The string should be "tx_disable" to match the state enum. Signed-off-by: Sean Anderson Reviewed-by: Andrew Lunn --- drivers/net/phy/sfp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 34e90216bd2c..ab77a9f439ef 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -134,7 +134,7 @@ static const char * const sm_state_strings[] = { [SFP_S_LINK_UP] = "link_up", [SFP_S_TX_FAULT] = "tx_fault", [SFP_S_REINIT] = "reinit", - [SFP_S_TX_DISABLE] = "rx_disable", + [SFP_S_TX_DISABLE] = "tx_disable", }; static const char *sm_state_to_str(unsigned short sm_state) From patchwork Mon Oct 4 19:15:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534573 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19779C4332F for ; Mon, 4 Oct 2021 19:16:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFF8961213 for ; Mon, 4 Oct 2021 19:16:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238914AbhJDTSU (ORCPT ); Mon, 4 Oct 2021 15:18:20 -0400 Received: from mail-eopbgr50077.outbound.protection.outlook.com ([40.107.5.77]:3542 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238724AbhJDTRq (ORCPT ); Mon, 4 Oct 2021 15:17:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XxjqSql4yruz6A5gAaKOZUZRExm+cXJNCLk1a96tOnI74IiwgdCYu6NCVjZxw5Qqj+INo/OWVfw9gXw0yCp7GVdtk9VPTa6WkQF4tqIYOF3h3nfQloEIpmL8fF2DLs3qLE+VSIALaDxnendH2LW1jNPHmELetzkfaJXiwMvQHw+A/i2mK/x8qkmbZ0RnzvOJ+lmXRuOy4m5lobVQHIqkLmVtM1u0EivDLzbBFZMvBV4mhXzNqhdJfoMQgxDPE1M+Kr1RdEv96DgM1OgOkLhBA6UTkFD0zDg4+9F8Y2d2UIQYuccMD2jqjgXA7SZNpB+jJyq4zu3CSrL1PBGgwEpyKg== 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=LKZqJ0sgev5MsfQyJguFFctJotHX/1i6njJFjmv6XtI=; b=AKVRSdM/XLz1oL/lFV76A5a38yZeiOuxhxDX2ZVhR5w/AAtxFuhjd8jpbrhkHudqKBMxXiFVZWbIH4MX8O58WvXgZiNjRWyOwFSFp02LNYWZd+x5R1lRHttuesMrMHLs2UciS/R8CN72MfYiF7CXw1XHRsgXbz/407M5leXCAfpWMEI3IZQsrNYuwPgR6Z76K7RvdSOLh7w7+sERAVVTZGiZAPQNkQGMcIOdiN5+NxkhkebXqfQTRO4Z+V9YnTpZyDSLEL8W3MAlM7URu/D0s+ics8uxyK2HBGqJBb8hT29UMpx10okevrt++H2syCB7afQqEQZtzU4ZRJTcHXiYbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LKZqJ0sgev5MsfQyJguFFctJotHX/1i6njJFjmv6XtI=; b=lw9tS1A6VNRRorLUU95VJvLPCo+/sEjpbUCJmClm0v8emlVoZy3+eGttkwO5a8wjluBNiFoAID1qZoFV1UbV5dTjEqnpOzJjSXukiHLvd5D2pgjSMi6GjItgu/hFSFI18ZoGFnuM5cQVAoSmbMXumCLQMwWXyrHik/slMeOhJE0= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7434.eurprd03.prod.outlook.com (2603:10a6:10:22c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 19:15:53 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:15:53 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson Subject: [RFC net-next PATCH 04/16] net: phylink: Move phylink_set_pcs before phylink_create Date: Mon, 4 Oct 2021 15:15:15 -0400 Message-Id: <20211004191527.1610759-5-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:15:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15c1e49f-3457-40fe-5aca-08d9876b6256 X-MS-TrafficTypeDiagnostic: DB9PR03MB7434: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: elTd1vd9awL3MupVhmSjZWxwKB7Tte1VlBW3RvagR4s5FEbOGra5gHwvyL1wxQIhZ7hCWNT6yKmaNP2urI3TkMQMCqWOI5lUEZFTmhIEQl076+SlHjeOq0dRX50AXCipgjnn2Nu9Fw6rHL/JcKGGcNKPxqzOGag6aZ4/B6Gm+OxB8k3BFvdljkz7epklt2sQAj/BJHRpKAfGfT01aIVwMAAhXc/mtM3AHjM+dO8Yx77h2KJWT5YnYOYeAdmslLWxIJI+nB0tDXDALlVfo3JVXJa/UHmT9tj+aga5wIkin/6bKTA6TZvChKMMRUg4MVNLQZs6OmUN8J6SrOO9woW1Z5L6YgtWcEqJAhYZuc4t3KJpgyC5pBubfWBTrsPM8GdmyDDjONR7MZMHRZEUuZaw6+R+KcRoz+wn2uO8G5SQvJDJyWzNZuEnP8i0kqmza9O08JAweaUTt2dGz9IYIbcpNTAPn8FOKE2qCbxFnrmGVbIrShFuUP9agl7Ohzs2JRbo3WpSwPbFSoFZE/iwOPjXoiyRpziZnQxd43YG30crJNyZs+b2IibpJm6jJfYWHCFWJsyPEoEb5Jt2AQCjgeaYmy86Y3yeeWBLMNJN2I2qGL9rO5EQ6Kbt+3fFGfZkfZHjy7j/ZvGmt4zUFeK9gXuqRCL5WczR32ZrfB704d7uok4w46puvnKR7WhLwopOQ6nxlUKyWmIxXoSZTteVAqEIPA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(1076003)(86362001)(4326008)(44832011)(6486002)(5660300002)(66946007)(508600001)(38350700002)(83380400001)(52116002)(956004)(66556008)(66476007)(38100700002)(110136005)(6506007)(2906002)(186003)(8936002)(316002)(8676002)(2616005)(54906003)(26005)(6666004)(107886003)(36756003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wXsRBc9Sp2ejMue515ioy5MiSm8SRtp3zrowYzgAtIX7gkTHNsG+xiv6vFUN7Bs/79TfINnBEvJiFTB3hcr/nQmrvOimZjrczudMG5IKj5XbmFWNF1zeGR3D8ORzxQJYxH1RXB2DH8ck0NhsJEUFk9BTDG98YXbBGX8HLMlwqM+WavgQu3yvVX7PxHGWSszn31wvIm+WEjhmRWj7yFvLRtSq0ZmGWyj62kMSSMFqR090iGlvu/giLrS/F655MDGmklj/pM9vzLcRy/yy3LeNa2Yklji6NIICoH82Mr5uUOIWPeiloyDzcdSJl2noGDOLmYCxuW8UtWklRaAvm4putJ9AwydMlAo2rDmWvZaNDKqp9zt573kT0goZEVnDXaa4ItNEMfWbJI21f1UNuUIm87Tyo/ixKtwnCec9DHsGokVFZAKvuEBD/n/huTwXdl79JKyods6PQbFZ9LxH9QMQNa6N88H9h7/6UlF72rEfIbDWubFee33PyyaCOQ624MMkiUOtSgiqtgp8WsonOQUGYkGHLFUTWetTRrmm0L49Az2NCsRMcOfRSISz5KSNVbGqCOmJiIh66umtmUXsVNcR31/859CXlbeNxhVQvuwB/P36b/yAJen66Mn4h+Wg76ABwZ3u/pmzM39h0kao41+XDKukApMhVIvQIpmJnnsGxcqnIfbpjLavip9uiJY2S72KBpoyxLb9G8ZAGazX4+aeE9MN2poNHYM0XmB5t3Yw8bLMkXg5pi2XovWjXohvc4WXC9b7OkVNAUi5OES9kwdp0tuJPJUZ70t2U5NLTVGAoGguzbYelHlqcMfGrcffR+a4OR6BqEMvdR04kXfTOBDsB//u+xShedO9BAAH532r0RiSzmQf2S99i/h5xs08HJ+xBAbRJhi4OZd8QF8m4N3TmdYY+zeMWz7+gr7IhIHgS2QKgnS6pdOYWSxXUhAOUu40UlDhbmxHFGGBzOSPOXfy5zTdUfCwMfE1MHL5ypQUqh+WbvuncYOZuC7LQ5V7vCZvgYiRCWo3P5G5UwjVSLaekenmVYzEbLRUvVUpndi5AGmVoEYP3WnNTV7aIpE965PbzWamIvXQYCQsEgp8EKIK+la5wQzoyeh/9Nn3jcOD/M8kZwu9sReyWgArqrxVkpQPZYA6YE4CDwDODJL3AuW70LmvnLYEN0TB6kZn8odbyMeFXP4a2sKFPtJKKnk9PX89ZsI9adqNpj0wT2uytft756hKE2BDytuPhCBHqNvQAqsP/BTD7oHDrtkqG92iSbRs6e6AmeElu18HYqowufg4U5f2k6eBucqemKl/g0NMuObYw4L0EYs7Qm771tE+G1dQ X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15c1e49f-3457-40fe-5aca-08d9876b6256 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:15:53.1561 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pXQhCOUowEt3YVCFJRmHCYzJgIUl2XH/fjkvoidt895hZaOgR4bon2LzTpTRPJUpKdlfidpHYN7zhWy5ahXykw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7434 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The new pcs-related functions in the next few commits fit better before phylink_create, so move phylink_set_pcs in preparation. No functional change intended. Signed-off-by: Sean Anderson Reviewed-by: Russell King (Oracle) --- drivers/net/phy/phylink.c | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 5a58c77d0002..6387c40c5592 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -795,6 +795,27 @@ static int phylink_register_sfp(struct phylink *pl, return ret; } +/** + * phylink_set_pcs() - set the current PCS for phylink to use + * @pl: a pointer to a &struct phylink returned from phylink_create() + * @pcs: a pointer to the &struct phylink_pcs + * + * Bind the MAC PCS to phylink. This may be called after phylink_create(), + * in mac_prepare() or mac_config() methods if it is desired to dynamically + * change the PCS. + * + * Please note that there are behavioural changes with the mac_config() + * callback if a PCS is present (denoting a newer setup) so removing a PCS + * is not supported, and if a PCS is going to be used, it must be registered + * by calling phylink_set_pcs() at the latest in the first mac_config() call. + */ +void phylink_set_pcs(struct phylink *pl, struct phylink_pcs *pcs) +{ + pl->pcs = pcs; + pl->pcs_ops = pcs->ops; +} +EXPORT_SYMBOL_GPL(phylink_set_pcs); + /** * phylink_create() - create a phylink instance * @config: a pointer to the target &struct phylink_config @@ -881,27 +902,6 @@ struct phylink *phylink_create(struct phylink_config *config, } EXPORT_SYMBOL_GPL(phylink_create); -/** - * phylink_set_pcs() - set the current PCS for phylink to use - * @pl: a pointer to a &struct phylink returned from phylink_create() - * @pcs: a pointer to the &struct phylink_pcs - * - * Bind the MAC PCS to phylink. This may be called after phylink_create(), - * in mac_prepare() or mac_config() methods if it is desired to dynamically - * change the PCS. - * - * Please note that there are behavioural changes with the mac_config() - * callback if a PCS is present (denoting a newer setup) so removing a PCS - * is not supported, and if a PCS is going to be used, it must be registered - * by calling phylink_set_pcs() at the latest in the first mac_config() call. - */ -void phylink_set_pcs(struct phylink *pl, struct phylink_pcs *pcs) -{ - pl->pcs = pcs; - pl->pcs_ops = pcs->ops; -} -EXPORT_SYMBOL_GPL(phylink_set_pcs); - /** * phylink_destroy() - cleanup and destroy the phylink instance * @pl: a pointer to a &struct phylink returned from phylink_create() From patchwork Mon Oct 4 19:15:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534565 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02214C433FE for ; Mon, 4 Oct 2021 19:16:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E284161425 for ; Mon, 4 Oct 2021 19:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238883AbhJDTRw (ORCPT ); Mon, 4 Oct 2021 15:17:52 -0400 Received: from mail-eopbgr50077.outbound.protection.outlook.com ([40.107.5.77]:3542 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238741AbhJDTRt (ORCPT ); Mon, 4 Oct 2021 15:17:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jxHN6lJbayswf7To9j6wJ0H88erHzQhCZEWy0ePfBNSZYuW7xA4pcQC54o9Ito1IVjUb0UFXA5IuPv1j3xdQGmDSYfWFjSwn+rgObfY8Kvji1qtEyXLLsRaR5KmdNqs9QpiT3W69qgBYLdU7Cq0bYHjCLAuv28EWqPEZ9XD19FVrAWIwaQRpHCVVx0Kzh49S4k8WbnIooAmn3aNi6S00y9jZw+/rEs4RJbq4HC+nkSJwJG/GLa3uLQUtsG5TynldYyuqPS5VlZbksN/rjQ3dSPVizUCOcMlA613jbXpKuCvXd3qZJkX7P5yOdhyMGdhENWY7rvQTpsVEqRd9KPce4w== 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=YQP7iSAnhKghUcqfAdxPrHW+lbwz7EmbO548HV2diTQ=; b=M5mFzwEhCRVa9wOSO06g7MVIOV4THe1ROjBbw5IbL07NDAXDyhlgMis6QXiCskFgZa4M4ffUF+lTFTwwHMi5z3pSoH2jzaUtcHuTNIc3ou0gK+V6JCGGcIB0cdu3c2ezTCRzmOqhESTHJlsdNTXdxI1rfSMNbLNRgIEnqJq2qp4bxCAneCTnF/cjj28Mz9CrHNjTf8A7usre4mKIvHvwevR3ORv4kv1pEvsl6k+jIq1W5+A+McXFjlzmNWJHT/BL3jF83FD3LLHsK0LHtbVi5iqPTIBPsr0hCgWAIZpQ6c3sTgBtGKnyW+SHeI9kYUcetWNR7XhTak9K9RdeVBlfVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YQP7iSAnhKghUcqfAdxPrHW+lbwz7EmbO548HV2diTQ=; b=w6FvBryX0nN5xgn4QlNEG0JZzwFSIv600ej7Sjtv/psFj6HOA+9yrqY9W9D9K0E6NwLRiEooj/e2R+V9y2s64J/NiTBaIDfS8RPMAaESmoJ3jscn1CC9iorlbXaJ0uB9AVGXv5e/ySdMG38SCbpDYwxbfCpubsH41zi6HBmQcNk= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7434.eurprd03.prod.outlook.com (2603:10a6:10:22c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 19:15:54 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:15:54 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson , Saravana Kannan Subject: [RFC net-next PATCH 05/16] net: phylink: Automatically attach PCS devices Date: Mon, 4 Oct 2021 15:15:16 -0400 Message-Id: <20211004191527.1610759-6-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:15:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: efc22294-5544-42ab-2001-08d9876b634a X-MS-TrafficTypeDiagnostic: DB9PR03MB7434: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xkPk1HkYR5mArSUx6AlJjsZQvqLUv3tKE7SjBhlgqbcnFWyEVZzVkyWI3DzN/vUgicc4LoX0EbGbdKNI5kjoyQTKuJybKqeDRpttMByQ0R7y4Mk6CD4197kjvsM7qQgopSVCt0DDiYYKUbmzXxkcAuIBOqvAD/8UJVcJAK+Pw6r07MC3IkiGP0KjiWrp0niy9w3jPbXT5pgKrCKn/uE4bNnSeRuzF4ZxXRKXt2rQlayzaVy0Q6U/v01PXwm1fPYJTziWeMmN4s6uee0urd3nU6uDc1a/TeR7/li8kWv8nWOU/dvkURZkoatdYcHBRUJ3iSU47ylYHAHtALVPjVAe2MTouF+QFbG+TUSElHizygVKFmlD9EbsDEeJPjwEo6Qm5ChSpIP7RwPvlV0tkWSx0nC5gYNA/QG3hZ4MCko7vZeJbacqggWSGyGxJO9Xyr1Aj/W87eP78rNQcbFwLwR0HlcUeCKD3DHierMPK42PY9linRidCuiSg83vu8phgpyWlTH52iPywx+gBNR4/OfQ9E67+8JxXA7HFw66Z8K9f6wi+E8imfNKW/DqBZfH2b0KWUkLXTyUt788j4OsfjlgHbB+ZiivPzxr5SywVgnWyS8nrOnLQDrjkKCyMVPUTqcPHduGeNIC6jZJkG1Zs+bmw3nhoa9xeaPi3Wi/Nypv6BZazrDYAwYhVGySuIADzvT5VNE+LzvrLQWWKX2IfIOxPg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(1076003)(86362001)(4326008)(44832011)(6486002)(5660300002)(66946007)(508600001)(38350700002)(83380400001)(52116002)(956004)(66556008)(66476007)(38100700002)(110136005)(6506007)(2906002)(186003)(8936002)(316002)(8676002)(2616005)(54906003)(26005)(6666004)(36756003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8CJX875Y8Z9KZpNE9SaMSBkbrMrOVhZIyiPjCHeNn4BjDF7PJZ3M82rBeROpfvKeyTi8/r1I5sXl5iNvdbJYNgvlLLdHQYXHdxX+RbozhJvdd333e5NzMFRDP668z4uFeN6ezTwPB8Cv15bp92sXwftfUf6wWVQTxiO8OkXn+tGH2xh/xHh9wXqywRS6wGRyvezQfwkOnsMMtUPEhjqprcdfJ3YX97nPVCZmRyJRPrhTDechWFL0cuIrfyL0DagznDnZd/7t+3hDwKhblOSudqQQpc2uHG+pEGSdDclVncOv7r0WZQOnDysMoGFpsiJx4vPiSS5COpfDnJqaRCXvnbZCMSm0iw67TTU5u66H0My3RgZ9eJgAmn7SiMtGZcfbHvyah2HSfMBlmgQEIF4m4fqR07vYuVJDVyVCmAZxevyr0CfjFxenn3v5LdVXebTx7Q2bbGbge3b8l3Rhl8or2pLsKn3BKEIa55HKDVQBTWR1f2kkg3wp7rPxkGcBzFYxM0jRoH6DKnDbVfuT9E+ObQvtABqtlRbs6Q42rCh6ZhSQe98Yt1oJptVuQap5rOVL9m/f//3jE6q1cM+wQUmr2nJdytYjiea8r3wAIbzPK8Xaaatr50jX+A8pKxxVfsC1TpiuhVCqLo+vjGcaqPBuz5niHIbvOVfeeP+k5Pg3JehNLXglUKuzubnEGiuathsn7ZP/Kbj4RArTFMS7nk+EH9Agfp9fz/QclFuXUy/e9Ej7ysWSYUy1Nb7Vr6qrWdLWIwUGV2TvxUpVaj+QswJLEBjLbXP41nhQHFUf6tkEVP/DAymfLrFnCF5a8wpryLmK2SLshFZCuaNQFJ62Ox2SiW7SJEq45oMa9HpgCTqd1WPlCQi0CJMA9ARxRJJH3bDOMrdWpDJp/hNbbLBudShlNElal9gCe2XYQS8+CgSkTDm4gqhsLMsSiUzxNTSmY9p9cyRXRKesdcz6dMePBUT4B9Q8I41y8Z8BxQ90/8k/iWUrinjQHdoVUTaTrT0/+K9uGmiJN4v7xN5Xj6l9ygiKD+9jmqAwH34ksI+rAGFMF1hglVyXFWY4xhhY/UddjHBnt+Mna3oH+CVfwfynhS+es3G9fz49OmIn6Kzs+fFLSYe4c6uz5qCSqW71y3TzgdwQl7AhKVSPjJ5FMH7c1gidWIfYzDOxPE9uyEHGDm9OTenBTPX1ni/DY4HCF7o6/+OvoqAp7/hROkZAVeRPtPLRXobejOct2ZexffCMmh6xdyMqiLLkh5/o1cpQ9IJgppJdS4p7ZuMpKuenkgXdk9yhqn1W55Glv0XkwQ8BXZvCzYYLBPmDfoz3yJIaZuNflqUJ X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: efc22294-5544-42ab-2001-08d9876b634a X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:15:54.7831 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NgyMAEOXYg89VNqdW1gjyHJuoapT1wj/4s25HatiR6Ynm/P1WL4OsgUo/UlaW7dsmdVf044DazclJ/mqssNc9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7434 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This adds support for automatically attaching PCS devices when creating a phylink. To do this, drivers must first register with phylink_register_pcs. After that, new phylinks will attach the PCS device specified by the "pcs" property. At the moment there is no support for specifying the interface used to talk to the PCS. The MAC driver is expected to know how to talk to the PCS. This is not a change, but it is perhaps an area for improvement. I believe this is mostly correct with regard to registering/ unregistering. However I am not too familiar with the guts of Linux's device subsystem. It is possible (likely, even) that the current system is insufficient to prevent removing PCS devices which are still in-use. I would really appreciate any feedback, or suggestions of subsystems to use as reference. In particular: do I need to manually create device links? Should I instead add an entry to of_supplier_bindings? Do I need a call to try_module_get? Signed-off-by: Sean Anderson --- drivers/net/phy/phylink.c | 115 ++++++++++++++++++++++++++++++++++++-- include/linux/phylink.h | 11 +++- 2 files changed, 120 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 6387c40c5592..046fdac3597d 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -795,6 +795,42 @@ static int phylink_register_sfp(struct phylink *pl, return ret; } +static LIST_HEAD(pcs_devices); +static DEFINE_MUTEX(pcs_mutex); + +/** + * phylink_register_pcs() - register a new PCS + * @pcs: the PCS to register + * + * Registers a new PCS which can be automatically attached to a phylink. + * + * Return: 0 on success, or -errno on error + */ +int phylink_register_pcs(struct phylink_pcs *pcs) +{ + if (!pcs->dev || !pcs->ops) + return -EINVAL; + + INIT_LIST_HEAD(&pcs->list); + mutex_lock(&pcs_mutex); + list_add(&pcs->list, &pcs_devices); + mutex_unlock(&pcs_mutex); + return 0; +} +EXPORT_SYMBOL_GPL(phylink_register_pcs); + +/** + * phylink_unregister_pcs() - unregister a PCS + * @pcs: a PCS previously registered with phylink_register_pcs() + */ +void phylink_unregister_pcs(struct phylink_pcs *pcs) +{ + mutex_lock(&pcs_mutex); + list_del(&pcs->list); + mutex_unlock(&pcs_mutex); +} +EXPORT_SYMBOL_GPL(phylink_unregister_pcs); + /** * phylink_set_pcs() - set the current PCS for phylink to use * @pl: a pointer to a &struct phylink returned from phylink_create() @@ -808,14 +844,72 @@ static int phylink_register_sfp(struct phylink *pl, * callback if a PCS is present (denoting a newer setup) so removing a PCS * is not supported, and if a PCS is going to be used, it must be registered * by calling phylink_set_pcs() at the latest in the first mac_config() call. + * + * Context: may sleep. + * Return: 0 on success or -errno on failure. */ -void phylink_set_pcs(struct phylink *pl, struct phylink_pcs *pcs) +int phylink_set_pcs(struct phylink *pl, struct phylink_pcs *pcs) { + if (pl->pcs && pl->pcs->dev) + device_link_remove(pl->dev, pl->pcs->dev); + + if (pcs->dev) { + struct device_link *dl = + device_link_add(pl->dev, pcs->dev, 0); + + if (IS_ERR(dl)) { + dev_err(pl->dev, + "failed to create device link to %s\n", + dev_name(pcs->dev)); + return PTR_ERR(dl); + } + } + pl->pcs = pcs; pl->pcs_ops = pcs->ops; + return 0; } EXPORT_SYMBOL_GPL(phylink_set_pcs); +static struct phylink_pcs *phylink_find_pcs(struct fwnode_handle *fwnode) +{ + struct phylink_pcs *pcs; + + mutex_lock(&pcs_mutex); + list_for_each_entry(pcs, &pcs_devices, list) { + if (pcs->dev && pcs->dev->fwnode == fwnode) { + mutex_unlock(&pcs_mutex); + return pcs; + } + } + mutex_unlock(&pcs_mutex); + + return NULL; +} + +static int phylink_attach_pcs(struct phylink *pl, struct fwnode_handle *fwnode) +{ + int ret; + struct phylink_pcs *pcs; + struct fwnode_reference_args ref; + + ret = fwnode_property_get_reference_args(fwnode, "pcs", NULL, + 0, 0, &ref); + if (ret == -ENOENT) + return 0; + else if (ret) + return ret; + + pcs = phylink_find_pcs(ref.fwnode); + if (pcs) + ret = phylink_set_pcs(pl, pcs); + else + ret = -EPROBE_DEFER; + + fwnode_handle_put(ref.fwnode); + return ret; +} + /** * phylink_create() - create a phylink instance * @config: a pointer to the target &struct phylink_config @@ -893,12 +987,20 @@ struct phylink *phylink_create(struct phylink_config *config, pl->cur_link_an_mode = pl->cfg_link_an_mode; ret = phylink_register_sfp(pl, fwnode); - if (ret < 0) { - kfree(pl); - return ERR_PTR(ret); - } + if (ret < 0) + goto err_sfp; + + ret = phylink_attach_pcs(pl, fwnode); + if (ret) + goto err_pcs; return pl; + +err_pcs: + sfp_bus_del_upstream(pl->sfp_bus); +err_sfp: + kfree(pl); + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(phylink_create); @@ -913,6 +1015,9 @@ EXPORT_SYMBOL_GPL(phylink_create); */ void phylink_destroy(struct phylink *pl) { + if (pl->pcs && pl->pcs->dev) + device_link_remove(pl->dev, pl->pcs->dev); + sfp_bus_del_upstream(pl->sfp_bus); if (pl->link_gpio) gpiod_put(pl->link_gpio); diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 237291196ce2..d60756b36ad3 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -331,14 +331,20 @@ struct phylink_pcs_ops; /** * struct phylink_pcs - PHYLINK PCS instance + * @dev: the device associated with this PCS, or %NULL if the PCS doesn't have + * a device of its own. Typically, @dev should only be %NULL for internal + * PCS devices which do not need to be looked up via phandle. * @ops: a pointer to the &struct phylink_pcs_ops structure + * @list: internal list of PCS devices * @poll: poll the PCS for link changes * * This structure is designed to be embedded within the PCS private data, * and will be passed between phylink and the PCS. */ struct phylink_pcs { + struct device *dev; const struct phylink_pcs_ops *ops; + struct list_head list; bool poll; }; @@ -433,10 +439,13 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, phy_interface_t interface, int speed, int duplex); #endif +int phylink_register_pcs(struct phylink_pcs *pcs); +void phylink_unregister_pcs(struct phylink_pcs *pcs); +int phylink_set_pcs(struct phylink *pl, struct phylink_pcs *pcs); + struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *, phy_interface_t iface, const struct phylink_mac_ops *mac_ops); -void phylink_set_pcs(struct phylink *, struct phylink_pcs *pcs); void phylink_destroy(struct phylink *); int phylink_connect_phy(struct phylink *, struct phy_device *); From patchwork Mon Oct 4 19:15:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534567 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C9BCC433EF for ; Mon, 4 Oct 2021 19:16:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3133861213 for ; Mon, 4 Oct 2021 19:16:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238876AbhJDTSA (ORCPT ); Mon, 4 Oct 2021 15:18:00 -0400 Received: from mail-eopbgr50077.outbound.protection.outlook.com ([40.107.5.77]:3542 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238701AbhJDTRu (ORCPT ); Mon, 4 Oct 2021 15:17:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QgzV2I2lu0BEklaDiP9qLsnGv6EfTc9vM2zsRrjBwtLoeg+c5Ldy2fVRl7qUqAnHNQ0PU9/lFmnf6FJ2Icw0ppiBRhdfZ1SYAMhMOyToyNuFNeq3VBOyeZu8ptvEv+15y9GoKZvTNTketN28UIfDB+Bej6S0ieMAR+Or4j7zgbyjDmpWUVw/6SHqw9Ge4POsPUGDBZLTASlZ0kD88Dvy9kfh0qg4KBFnyoo7lB+CIcEpjsOSH4rgTAQwbGgNBn499McVjsaJLJdfxyq5dsu95DsU8r/k4zewA/5RG31Ns5u4FosFU5E/iPeXFBdudFq7YBnYEnz02pcUXQh9xlrZ0g== 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=0zcV+V9vqx4I0QGoauP9o3uHlpdQvHAU4lLAVs78ndY=; b=EHvI0l81PCZmhaBEd79rqxdWnfYDmJangYKicZUG5+xG76aG2W+Iz94QZAnxMNcGVJMq1kzOZRR0wIkJxgB7TeXhVMpN1bLeYVE0RBML3lxzt3LNQLxvsPkL91Feo6CDapmKJ66vGxMUcEbfnOfegfWSDY1v1/wAztNeGVEww2UdYZUmscRNsVJVeircAqiqEdtmJzBF+gCXLRdHJ5sjhAGKpnPtjxonCiPPmiAghJCr6CWxNqXlLffs5BZspoeOr0QqTwwzIxyc4eTGoyB9sb7n4TRRH7hA278Dbgac0Lr6WcLA/8GCUQeVuduo1OrGip4usgZR4M66Rf5Qt3EMqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0zcV+V9vqx4I0QGoauP9o3uHlpdQvHAU4lLAVs78ndY=; b=NGo7QVRavTna30zeCBQfVa1zsQF0VNLDtroo1p970A0F1jC8ssx1LHD7pY+BFWu8gGfeHY4Ddu4FtKtfNOtowYVMz3uq6IddrNYpkikrLqeteF5PPpuukz+DEFBXoRzFhcH+wQ89TDUz+Zj6lYVPVIianB+S6uUHvZvkXkeyBEU= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7434.eurprd03.prod.outlook.com (2603:10a6:10:22c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 19:15:56 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:15:56 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson Subject: [RFC net-next PATCH 06/16] net: phylink: Add function for optionally adding a PCS Date: Mon, 4 Oct 2021 15:15:17 -0400 Message-Id: <20211004191527.1610759-7-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:15:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8605d6c2-d4bc-42d7-fe2c-08d9876b6424 X-MS-TrafficTypeDiagnostic: DB9PR03MB7434: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ajGPar/7hmVms+Qk6ZlCa4BKsbQjF+7wwsoTo7O2Nw6MvIyq+j68DvU8udMJXafgs1dC+IOiEg9GnD9LrV4gqouWae+d1Hg/X6cRuF4UYp49W1ukgE8yBQoqDLqVJT3ecN1Ki+APymebhHbFP1MWJYtUWhVJVKw85Xiz9iHKUBc0KjSOh4NaZibdJsCY5As6IlZ6y899Bx7UcFVYKOYwhFcvbzJSVe/ZM7Uom6gEGkLaLVaA2tAHUX1HggZZ/OrBawtjMW1Dae4YmBm3Qhr2PXuvBbvWRA12PwYPnn0TxSXqZ/iFUuCke2G1H2ss07Rz9YIekv9z9xNFA0FmzhBT5nSvBj1MiPXQD0agVoUlGMtPcM+MX4Qay+4U57xsLL2LaySIG59ive+9IcJtjJ7QAbH4OOFiECUGQJWp5H0Fd+SD4YY8zD7mzk+6QMzSQVDeUXkke0pik0PrC1GWJ/Iqdk2XQwxCAHhMvRwIORPNYt8r3NYhHOC6wlDrczNTzPqGnn1TwZ/IAOcnaTHIEOS/ul1vCyd8L9kLwhFhBoX4VXn0lB4kF2lt2/Y7RiycKN9Izg+n2bCXIgfqWPS+rqrDY1DJFg5uvapP95PMpvYKGMVxaDhjUOwv4WyOoGO3HWgArn+oC8T101YGgLUL8GFmXG9vAG0QVOzreO3yo/TxhJcQVdMtWuzeE4Yu+jOpgwFvWGbDPtyUiJK2p8Udz9R6Og== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(1076003)(86362001)(4326008)(44832011)(6486002)(5660300002)(66946007)(508600001)(38350700002)(83380400001)(52116002)(956004)(66556008)(66476007)(38100700002)(110136005)(6506007)(2906002)(186003)(8936002)(316002)(8676002)(2616005)(54906003)(26005)(6666004)(107886003)(36756003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gxEYax9fKPQGhI1cspgJdzPSTyHyOgVZiN2/8AINVPik+72xhCiAE27uL+gPrN1eGH3Uk9jTv6rOGaR5ntkKh99hXiHpGhek7bY2QsMSuhYr3cveJGFQZ9aSKZJdQIZo6LYvKusYR772n9abdYuUTmBd7srNf+pnANrgNSsxwNzFlmYOgep6qQcQmcJY7utx/0g03uztlrBMS0f9xN1cz93h2i6EbKDekPYp+R3CJeMYPxzSaWV1jYOFuUKWdLIEzoH9EUFEfoTzFP6TJcKoWyn2NQOLK0ZKBSd2Xd6Cbfi1DZraMfcsoMDTtorptSGS1tuuVBAgExM1nJQvLGOlUFiqdIVl8PX78tyC2oEr0iD/n5Xg++dc1wth2Qa+/NSM2sr1hNt9dLJT42xVfeV8is4vD7iRiUJQntFHKHWG8cHBZScveQAhnj8iXRhCxOMVrrJa0iRRlcTL1m96/QQmLnJjrUT0Af2SsBH+GTCRJ2FoBcvgpclKvB4FSCD5mibGmty8dm9hddDBH5CR6Hk9ltf/kseHBUFi78SU/JIOcrm7U1LtKGDj+n+x1r35RWH2hEA8TKU1vCW/QM94re2/PQjTiswuY4wXuvpL2isfiOadCvaT/0U3WZGj2ddpUANzRocvj5bFWIDviMsTx9b7LtyHkvx6QpbfGcvjVzErvhot14fNf9oUM5wIA+4Qs10tJsHMwNPKL3/X3dP7cj4lRxr6y15oOquFXkHu3AbPeno3H9Md3Wb/9BY6cWKMibZaLlPKW+iggdZgsheD7DESLg2TQpA/tD/OTRzfA88aCTz7xFTVbYnQNH9pTuS/uQCQRBLCTW0yqCnIXEZyys8aLj4RiC7HdlUFGAPjqcuRidpbtkOaUWMZbNsf3O9H4jsvcMjyaytyt0incyDEcL4BsD0TYfNxrcrP/BiwImVCr3EFT4R/yAdbYtNuFwip/t+C81V0o8x34wVSGn+NtAL85cVbYgf5b63kwMwxPeUUrVhN9Ldc1RiCLbDcWGVBdk3+KCJtUimMEZALE9szaHUN+1e2Mg+DjrZgFvqN9TyUiSlQHasyGDQMkIaklbpyRMQEh8+7IKNMpomyDKIgCkM3he2UIc5XlIonzmt+udslceQdmCpeBeGywWF9JRG2F8AA00h7fNgsaoWzpjWhzQCpMugT9QsjV7UiyX+fxN0ETjoFmG1bAAm5RC/hL1OjPnAPTolZDxwWI4HB4/7a8LcRAgxF3XLoHGjEHzK/Abm7u3eeLvdvf0IvqxQ6OfAJt9IxpqPCnrvhrrn+GJxkuORxvUa+/h8QYnKnFl9ZPmZ7cXqxguWbuE+L2H3VIhvchEd5 X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8605d6c2-d4bc-42d7-fe2c-08d9876b6424 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:15:56.2833 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XrOZ1w1wCz7LRfyzlBeggUJwWTnk0i92v1OdpylDF/5G10fz1UWaU9Ojmw67GH54co7PEZnd/H2QS57AP8wugA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7434 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This adds a function to set the PCS only if there is not one currently set. The intention here is to allow MAC drivers to have a "default" PCS (such as an internal one) which may be used when one has not been set via the device tree. This allows for backwards compatibility for cases where a PCS was automatically attached if necessary. Signed-off-by: Sean Anderson --- drivers/net/phy/phylink.c | 26 ++++++++++++++++++++++++++ include/linux/phylink.h | 1 + 2 files changed, 27 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 046fdac3597d..f82dc0f87f40 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -871,6 +871,32 @@ int phylink_set_pcs(struct phylink *pl, struct phylink_pcs *pcs) } EXPORT_SYMBOL_GPL(phylink_set_pcs); +/** + * phylink_set_pcs_weak() - optionally set the current PCS for phylink to use + * @pl: a pointer to a &struct phylink returned from phylink_create() + * @pcs: a pointer to the &struct phylink_pcs + * + * Bind the MAC PCS to phylink only if there is no currently-bound PCS. This + * may be called to set a "default" PCS, such as an internal PCS which was + * previously handled by the MAC driver directly. Otherwise, this function + * behaves like phylink_set_pcs(); + * + * Context: may sleep. + * Return: 1 if the PCS was set, 0 if it was not, or -errno on failure. + */ +int phylink_set_pcs_weak(struct phylink *pl, struct phylink_pcs *pcs) +{ + int ret; + + if (!pl->pcs) { + ret = phylink_set_pcs(pl, pcs); + return ret ? ret : 1; + } + + return 0; +} +EXPORT_SYMBOL_GPL(phylink_set_pcs_weak); + static struct phylink_pcs *phylink_find_pcs(struct fwnode_handle *fwnode) { struct phylink_pcs *pcs; diff --git a/include/linux/phylink.h b/include/linux/phylink.h index d60756b36ad3..bd0ce707d098 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -442,6 +442,7 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, int phylink_register_pcs(struct phylink_pcs *pcs); void phylink_unregister_pcs(struct phylink_pcs *pcs); int phylink_set_pcs(struct phylink *pl, struct phylink_pcs *pcs); +int phylink_set_pcs_weak(struct phylink *pl, struct phylink_pcs *pcs); struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *, phy_interface_t iface, From patchwork Mon Oct 4 19:15:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534569 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08776C433EF for ; Mon, 4 Oct 2021 19:16:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E11AE6124C for ; Mon, 4 Oct 2021 19:16:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238941AbhJDTSI (ORCPT ); Mon, 4 Oct 2021 15:18:08 -0400 Received: from mail-eopbgr50077.outbound.protection.outlook.com ([40.107.5.77]:3542 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238821AbhJDTRv (ORCPT ); Mon, 4 Oct 2021 15:17:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lo/AYTi4MfeO0lwKNzh2/jppUhxMK2PibWQpYXcMZetB0IvsRvywpiaAkiXRGUbJvaKK2Kc6AL3hnw672Jw2NhwwO0CbYEdyUa0fAFw6ML+WYMsCJNJiEUDjxe+ALanrXOOENYs/6hoqVepqS4VDnwQuoqrXolUdOWCW+e0XW/CZb0LayfghOHg+7acC7V3cZJq0afCrET4iq4SsuFwQWd0yIzeUCSqaW0EECWvnmVglijFfwZWgXmuD5wG8obretafm3sD8q8am9o/DrDT5cLTPs5TIklDZK+rXXYXbwh299A0EmGAUdEbrc6/tpjTf7v2VIXZUQE9yZju4/LStuA== 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=PzFxzqMFq+sNXDIXeWvtYTkChDz6300NfcmKe2BB//4=; b=ifygFTCY52Rv82PZnr+m5C74AeHWKGBV/wt2hr38wQ3DTKPdzvp5HlkztAVyat+cCYL6KI7do55vRBpqJAfXVV4eCmWnjOL1TlJCCh96uOcnuyGYmL1Iqt5yZ86H1sfqd8Yt7Bsa9Mlc29Vw9zQB79L1jbvGdIowsjSlei007LFyUpp0N8b/AUvYeWzTaBb/Mix5AIbvN+vJDOFR6t6bHjsCOwhrAnySHv6NV5P2G6q9KR/Onz7abmI00TexcZY5tvO+Z1mWIiBdQ4hfN6/hcTn5998Kf3PgsMy7gMxjaCZacyAdhzWNIhvUlXiotIFaN7b2XO7EDgXcwd0m1ju/3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PzFxzqMFq+sNXDIXeWvtYTkChDz6300NfcmKe2BB//4=; b=AnKkcZLHbjbSnMJFa1dmVdFTP9J+dhxBARSGRJmd36y4MCWKxPg35brWtszZwHGjm44+DZ7PAhbn7pXsg32btvxgF0OvgfXA71xOGoWSDhicPwkWqPbK7CSvgjL4MJ6/75G/5u0TrqNGrI//wgSBNZn7qLhLacfqvEN3ltt4+0k= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7434.eurprd03.prod.outlook.com (2603:10a6:10:22c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 19:15:57 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:15:57 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson Subject: [RFC net-next PATCH 07/16] net: phylink: Add helpers for c22 registers without MDIO Date: Mon, 4 Oct 2021 15:15:18 -0400 Message-Id: <20211004191527.1610759-8-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:15:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 85f90e25-7fd0-4c45-7b7d-08d9876b650e X-MS-TrafficTypeDiagnostic: DB9PR03MB7434: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6AEhaTzGJCJxM2YYSErNUTL3B764XrVGgkT0Km2Vynq6kBElp4v9ztqNCPr/GYB2c4Bw7cza49aIQhUOEp5fcICojiJWXgwSPDLBJdamD2F/dv/Y71waMwoXbfjYXpgOHdBSUynIj/V6JwczdGpWmcIlnScqMBIA97TQaxcYrVi5r09V0NsW8dUePy/biVVHX9w3boIm0v9MoS9Ha/B5On3xzqVvgeSEjzjISn0k8d4vcobeQJxPOy6MCTU9sVJ0F+y0+TVmBETlOKWwaM2hNI62fk7SBVW/5rZ+KC5rwK5j0r8hITWN3/baGC88FW5erhhFnPFGmCa3vyTQGYBN4OAGsPTmumieG2lr3PeW9c1CN5xkBlwLs1Uc/tcOZv4R7M+OUdzp13SL7DqFrP7eI+PhfpU5lmhClWg4mv2wo8/S+xNXJgsrImTCOHEL1vlnb4UqQZuGoIDxeeEzg7ZAGPh8UwFd81VHWCnJJbV6YLquoGOwGZXge7aXr//xqaKBO82A1OYnZCPVQSwpLGJTnufFEdl7K5gNFSLrfIwhR15CE4DmsOjnMVxS5UsnieK+M8ta3QhPU5PVCJt7zxQt//t+/q4jADYKzRWncmecu8KZNQn18CbucSR+AV0AsGzj8PUVt6lDXe8D9yGzxZpBUqdxBeFOgQjJRl0WiKIoAF9QQoDl+cSDtFGuFjRm2EVH29tXZN1VFq+OuSoYQOijBg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(1076003)(86362001)(4326008)(44832011)(6486002)(5660300002)(66946007)(508600001)(38350700002)(83380400001)(52116002)(956004)(66556008)(66476007)(38100700002)(110136005)(6506007)(2906002)(186003)(8936002)(316002)(8676002)(2616005)(54906003)(26005)(6666004)(107886003)(36756003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cyT1jPdFgze51qsZG/bnWJwFT3fWxEf9zz+CdtQ6J35xAW/XHTr6cuevLJj1qVATxSKtyvCqazDnrpNtk3xB0J+i/eHn77BGrasSgwiqbAN7IHz4yHGf0RAF3whC/cD+zsWXut0dlpVfaBSpVwAAb25qXLUUXquw0Xq4pTx3vGOCyRpsHkkjK/R2d25cqbwHzNOO2iV82MQMaIkhpnEnkgeAOp16lIzD0e/1046PC5rH4O7bm1x665IvH0LJgG51lNIVjpy17aLAN6aff8n9c+gbt3DbXHCZ8LHO/D1l5lqxOEBPUweClRl23wbqap2qK+eBNSl6APlKqeddTtyG0KvX9hpk3MLxJfq8CsNAIUUv1q7QjLI6vHt5xvL6sb/yIDfkJ1pbbbRuZaa29uxKHqhZqwMJMS7PBAx1Lgsa1kxYnOrDlTbv/OLiCwT2xW8Xn/jHxVWG+8aem9nsrbFhMCP6ddURrUx9zQQmOX2fAh24LdBv9bQKunN+nSqJMcq/fSLME6NuMnuq3lmgD0TmTJUGlQTzsSYf+x43WXJK1hwqggeTV9cy8l3ik4OZmO7VHdt5a+9XbC+BVD5EK9qFqp+VG+nZSDP+Rr1j2czUWIfqVLs/qovvHftEc8MMklTdGvRagzhIsdA5ricWy6enfGBVLgacfHqv3r9J3MHuvhOMbVQGqo9pAjEHtlb4kafwxc4m/8ZcdBtHkN5nsz7sjfSYzzVK97pblUwpeYL2/7XLxPftpW+SAbQMX6oMD2H9IQeiig2W2RG0xKqI69AKfNDuskUeZhMsRShQgLd0QdpN1fozj1cLbagvS0naWyt1Plyz8A7wOCMpAFk2ovZSwKIOA57k0RNLti7hEeKHhAZV52Ybr817n8OwmuzMd8x3dWLMl/MpHZCDq6OGP8oVWCGh/TrY07YlNMl9aiYopE93bSmU+NXwnpJks8GjLXUaXwVESZSLlUawhwVgUFdmkGDI8Wz7QwnCK6AulA3GFLv1RpEFmTjRSa60vh8JMSrMWC9CPG/qw56I4poAZGZYTJd+iCb/ds+4tqiLEHYXXB6Y273rT6UIiu9xP3GWz5I317I1MlES6CLtnjp+nKcVjbB0imCaBNjD0lbcwX0r7cJz/wBBJoS0eD9VJ3wMYFCH+bRDnNjNCMqZwCd+LcMamK9qs4C+TCF0tBh4nuGxUEqRdKqnkQTeWLRfS6hOgCfE46zml0MP4YoP5AmSdXLfvKy8F8qRaqECqB4oQGiNir3p4mxuovWfix9wPUW11HESuPdfCcBevqwpnflZAEe6V5Cky267OK31YkJjLHQS1CQubtF6eNxGmhqUnAZ64SFC X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85f90e25-7fd0-4c45-7b7d-08d9876b650e X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:15:57.7227 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NqhXiyEnI9oGMzIa07nStLIAWykVbOjTL2MbgqbEMTMMJkZM0T/vrjLSuPy7SwMHXe1p2XodbZ9paTrna4nvOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7434 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Some devices expose memory-mapped c22-compliant PHYs. Because these devices do not have an MDIO bus, we cannot use the existing helpers. Refactor the existing helpers to allow supplying the values for c22 registers directly, instead of using MDIO to access them. Only get_state and set_adversisement are converted, since they contain the most complex logic. Signed-off-by: Sean Anderson --- drivers/net/phy/phylink.c | 154 ++++++++++++++++++++++---------------- include/linux/phylink.h | 5 ++ 2 files changed, 96 insertions(+), 63 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index f82dc0f87f40..1b6077557e31 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -2639,6 +2639,49 @@ void phylink_decode_usxgmii_word(struct phylink_link_state *state, } EXPORT_SYMBOL_GPL(phylink_decode_usxgmii_word); +/** + * phylink_mii_c22_pcs_decode_state() - Decode MAC PCS state from MII registers + * @state: a pointer to a &struct phylink_link_state. + * @bmsr: The value of the %MII_BMSR register + * @lpa: The value of the %MII_LPA register + * + * Helper for MAC PCS supporting the 802.3 clause 22 register set for + * clause 37 negotiation and/or SGMII control. + * + * Parse the Clause 37 or Cisco SGMII link partner negotiation word into + * the phylink @state structure. This is suitable to be used for implementing + * the mac_pcs_get_state() member of the struct phylink_mac_ops structure if + * accessing @bmsr and @lpa cannot be done with MDIO directly. + */ +void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state, + u16 bmsr, u16 lpa) +{ + state->link = !!(bmsr & BMSR_LSTATUS); + state->an_complete = !!(bmsr & BMSR_ANEGCOMPLETE); + if (!state->link) + return; + + switch (state->interface) { + case PHY_INTERFACE_MODE_1000BASEX: + phylink_decode_c37_word(state, lpa, SPEED_1000); + break; + + case PHY_INTERFACE_MODE_2500BASEX: + phylink_decode_c37_word(state, lpa, SPEED_2500); + break; + + case PHY_INTERFACE_MODE_SGMII: + case PHY_INTERFACE_MODE_QSGMII: + phylink_decode_sgmii_word(state, lpa); + break; + + default: + state->link = false; + break; + } +} +EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_decode_state); + /** * phylink_mii_c22_pcs_get_state() - read the MAC PCS state * @pcs: a pointer to a &struct mdio_device. @@ -2667,32 +2710,48 @@ void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs, return; } - state->link = !!(bmsr & BMSR_LSTATUS); - state->an_complete = !!(bmsr & BMSR_ANEGCOMPLETE); - if (!state->link) - return; - - switch (state->interface) { - case PHY_INTERFACE_MODE_1000BASEX: - phylink_decode_c37_word(state, lpa, SPEED_1000); - break; - - case PHY_INTERFACE_MODE_2500BASEX: - phylink_decode_c37_word(state, lpa, SPEED_2500); - break; - - case PHY_INTERFACE_MODE_SGMII: - case PHY_INTERFACE_MODE_QSGMII: - phylink_decode_sgmii_word(state, lpa); - break; - - default: - state->link = false; - break; - } + phylink_mii_c22_pcs_decode_state(state, bmsr, lpa); } EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_get_state); +/** + * phylink_mii_c22_pcs_encode_advertisement() - configure the clause 37 PCS + * advertisement + * @interface: the PHY interface mode being configured + * @advertising: the ethtool advertisement mask + * @adv: the value of the %MII_ADVERTISE register + * + * Helper for MAC PCS supporting the 802.3 clause 22 register set for + * clause 37 negotiation and/or SGMII control. + * + * Encode the clause 37 PCS advertisement as specified by @interface and + * @advertising. Callers should write @adv if it has been modified. + * + * Return: The new value for @adv. + */ +u16 phylink_mii_c22_pcs_encode_advertisement(phy_interface_t interface, + const unsigned long *advertising, + u16 adv) +{ + switch (interface) { + case PHY_INTERFACE_MODE_1000BASEX: + case PHY_INTERFACE_MODE_2500BASEX: + adv = ADVERTISE_1000XFULL; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, + advertising)) + adv |= ADVERTISE_1000XPAUSE; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, + advertising)) + adv |= ADVERTISE_1000XPSE_ASYM; + return adv; + case PHY_INTERFACE_MODE_SGMII: + return 0x0001; + default: + /* Nothing to do for other modes */ + return adv; + } +} + /** * phylink_mii_c22_pcs_set_advertisement() - configure the clause 37 PCS * advertisement @@ -2719,48 +2778,17 @@ int phylink_mii_c22_pcs_set_advertisement(struct mdio_device *pcs, int val, ret; u16 adv; - switch (interface) { - case PHY_INTERFACE_MODE_1000BASEX: - case PHY_INTERFACE_MODE_2500BASEX: - adv = ADVERTISE_1000XFULL; - if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, - advertising)) - adv |= ADVERTISE_1000XPAUSE; - if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, - advertising)) - adv |= ADVERTISE_1000XPSE_ASYM; + val = mdiobus_read(bus, addr, MII_ADVERTISE); + if (val < 0) + return val; - val = mdiobus_read(bus, addr, MII_ADVERTISE); - if (val < 0) - return val; - - if (val == adv) - return 0; - - ret = mdiobus_write(bus, addr, MII_ADVERTISE, adv); - if (ret < 0) - return ret; - - return 1; - - case PHY_INTERFACE_MODE_SGMII: - val = mdiobus_read(bus, addr, MII_ADVERTISE); - if (val < 0) - return val; - - if (val == 0x0001) - return 0; - - ret = mdiobus_write(bus, addr, MII_ADVERTISE, 0x0001); - if (ret < 0) - return ret; - - return 1; - - default: - /* Nothing to do for other modes */ + adv = phylink_mii_c22_pcs_encode_advertisement(interface, advertising, + adv); + if (adv == val) return 0; - } + + ret = mdiobus_write(bus, addr, MII_ADVERTISE, adv); + return ret < 0 ? ret : 1; } EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_set_advertisement); diff --git a/include/linux/phylink.h b/include/linux/phylink.h index bd0ce707d098..b28ed8b569ee 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -496,8 +496,13 @@ int phylink_speed_up(struct phylink *pl); void phylink_set_port_modes(unsigned long *bits); void phylink_helper_basex_speed(struct phylink_link_state *state); +void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state, + u16 bmsr, u16 lpa); void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs, struct phylink_link_state *state); +u16 phylink_mii_c22_pcs_encode_advertisement(phy_interface_t interface, + const unsigned long *advertising, + u16 adv); int phylink_mii_c22_pcs_set_advertisement(struct mdio_device *pcs, phy_interface_t interface, const unsigned long *advertising); From patchwork Mon Oct 4 19:15:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534571 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2667CC433F5 for ; Mon, 4 Oct 2021 19:16:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FF9B61425 for ; Mon, 4 Oct 2021 19:16:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238908AbhJDTSS (ORCPT ); Mon, 4 Oct 2021 15:18:18 -0400 Received: from mail-eopbgr50077.outbound.protection.outlook.com ([40.107.5.77]:3542 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238892AbhJDTRx (ORCPT ); Mon, 4 Oct 2021 15:17:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X05O5LrFPJP6ul+v3NJvdkPae1YaVnbpMbyHCgNworyabA45wtt5vn1/9sf8Jc5Yi6GotqPL152vrBAnGJFsJeIfgoGqLF/Kq079ga0mTpNPZGXMB3Kff3uJYGxKRs+z6hEvwUW7r9Y2axJkx2X0DqkUhVRoBv/4UDSZ1iLyZO1i0vBHic+qzeKgMGKMimdbAyLt3KMSNyI0bK8nSdnvcYRkgi4BU6tvyF64SCRDQgfxFd+hzn2Rl5bBwcVB/TkmaRU/GwjGjgqTSBDocJmRxomRE1HP/eH/QhQ4R+WuDV32R6b3+0GQl/Xpx9xYYF1THidM2pciTRncjhDxiKic/Q== 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=dbm4/gf8fjTyn1w5yeJgzTRX9XqtUglzxN5ttU8NXAE=; b=K4ZREWkCKh1p6CzmLp2JNIb3DzEnY9qmZtrB5VU2l0KIh4aXCgQrHqUJt4uo7TgS+pwH64dg6tz8II1ruynPEylOiHEzpctOqFFiYo/sy8aShlGDHDT3e0Uz+k43E98oX25LyIcXV2WZyp0Q1BaZrMre3pJ3h8HdNJ1fTW0Z9QjmBfgjvgBbxoIakpGJyVdClF7AwJhIFFPuMJGICgPsTM6pzvnvBytWUFrf2iyUxPJne8zSEUspNcZuztud0ofHvdr1JhEbejVgv/pbG0wEwO/DirKKMnYjNFJtMHnljG7F9ngtxaiKjxMwOWZ70xLBF3UlVwCSxWZ2i836c20Cfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dbm4/gf8fjTyn1w5yeJgzTRX9XqtUglzxN5ttU8NXAE=; b=CUWewRaQiXMUeXJgJ7aeNYfUKcT6Sc2iBy+8WRkxDqN8jdlMd74A0xME7Oz+tXRxi1yXyEmMUCKAcMnxq0PlDGCoxHkEKXkLM6MtiVYG4AfCvSq+AHQoex7G2IUUHjSyy9UJ4YEk3uuPAVs8MSwhYaCi06ygidtkCD/OvSvWWGU= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7434.eurprd03.prod.outlook.com (2603:10a6:10:22c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 19:15:59 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:15:59 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson , Claudiu Beznea , Nicolas Ferre Subject: [RFC net-next PATCH 08/16] net: macb: Clean up macb_validate Date: Mon, 4 Oct 2021 15:15:19 -0400 Message-Id: <20211004191527.1610759-9-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:15:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e02bd6a3-185a-4542-9656-08d9876b65ff X-MS-TrafficTypeDiagnostic: DB9PR03MB7434: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qP8ANFVVpw+6V7Omo11hiEQHZjn20pRStG/JSZ/qCv1TCa/PkuVh1BzSusrUtizCvJfRAZE4nr4a1zDAg48MMKdpgKyPDJRpuOZHJHaOlCLuQK5BkZUebz2UL7AulHJTT23ulvSJpbjuEu5cIPJtROTfiCIe6ziKuvCCA0u2lB/ZuSnzaNvA5vJgsGvVrPTLHD6QzWNNUXCGla0TEgweDObJQpSf7nPiZd59TqLdgfdsxsq6ToAGl9c5Ll2BSwb+HlZhUdAGdq7+JntfNvB1drg9o+KirpMLBKyfP9fIS5pYYXrgerNCEYu6UDnB+dozf3cL8iEBixk/zUFXFiVnqIKhdK0S/C2yeCqRIH+17mdLVtvKjgqvUHPH0o2ALZABzvhNFKLogETcu6+mfR0qzbYHpecDjNLYk0HFLTGKN9E/x9PbyvYbg+kOrxoy+IJeE+JA2/PZ+2Busz/4liJXQnMYHtxLpF6yYbLdFIL3DI0x67LC2OoQMiqXeLetoYhsFmeB/zFpvSwIPB08Nm1ub+ztjQbjd8vuyTkxR3J7THHoPNnjrp0VPefIjYOWjru0BG0Rstve8B5JVIjn2FBucJm9awzpkprJwjkDMti/K5U1ar5XKF06y4b4Cy97HunLo7QmAFcYmHfN5Yt/bnEUdTZP3tLm5+no7M3HW7t2pmS9M6MvIWIlblTVdyaJJPhbdhz8Rvx7mysXNkt+3d5EqQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(1076003)(86362001)(4326008)(44832011)(6486002)(5660300002)(66946007)(508600001)(38350700002)(83380400001)(52116002)(956004)(66556008)(66476007)(38100700002)(110136005)(6506007)(2906002)(186003)(8936002)(316002)(8676002)(2616005)(54906003)(26005)(6666004)(36756003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ebg7k1uEQi/JojvSj7NfJf7YXJfEld9A1zaZiBQ9cwTL3HyejQwfOAnV29BvqWLs80ADiAnpeEa04bV6Q4GlTe2N8uJV2/0S/Blbd0kGt+alDycLkiP8aH0VqkAyu3yfu1op3ziS6PC9ApVmfmP5/6aJ+vMS6wT9rAVpMfyWUTZFBqub+Ad7DPEwUx3Itmh+wG6CSAnA6MT/XdUKpsJyv/QHRKGWtoe2ksOSWc9MsSefVJu3aHfC5282vQzznbnx47kHRul6vtfJzz4iHYBqEdfTFqdCCRHJsnxY2y9qwlX0zA0qxqbdV76DUrI5HlRUcdY3OqvN0hqRtXbJjEgDmjA0xQ85Gwh+UmnD2aADDnyG89vQ8XIPeK4YlvaB73aG+xTiZquDBd2zy999LHoTWCe/h9fsyh3M8Tr8oPPRJg9db54vmtqkAPD4+L3fXm2dkU34JatgjFereVA2N0fNsMW78C3LtbjYgyovHcxOF0/tIaVYL/Fv6H16qkcywdWuHArM68Qniye6vbftAmCyjWCspSQsZfC2QHc5vN0F7LU8WMSSkB94IUJkLMtaHrmmi+JhRJzY8g+NHqAtEyomCWo6mgjddZE379soi+3yKnvDcDe0ithoxgP5l0WdjYzJoAh19IVikYjETAvstXzTjMtK79Gbg4N7cc4zEXIOBlA45ojQ7CJRaIx+CPC0hzCCjb7LnrSApBF49PATgWrE9ff0hir2so71AMXF/O2wipgfX435cHlvy18iOGeBVL0cAThTqxFbF0zPLGdNiWr5xJ31Fwajb6IbbfEfQ4EWUc/tZ0Qaa2zYlOUrEl7PEp9/Cjn/Zj6/jySJ0tA5Cu/SmTkdaa3A2f96ef7cG3Kh4DGvqyklUHf/1vfJtV7Vw3PenxBfhO8fvg8+iQvUIsftEGF3Qq/HtxaxO8AGl+UzQX2oVrYI1TN0Qsn9AKfKGqZaeCrqeyYDRqr9ECo22ZKQrjhY4Fpe6UbFkKHFd/fn2F0/rMdSGdmNKVBEA34jCc+jATth9am4nVkoNRhnu4o4hLGM7SP08fFIdMBvQvJTtwummssy3EO0/caFCdRkqY6dBbcngOYrYsAFl/T5sxxu+LSkLOyk+JXk5tvkpimHUPCTxPQRaMkUt/RTNhmbwpm/yh7DYL0wVFBUEF74a5/JAmaX6qVloOc1oWtNL8q4GAuXRo8Zdcio9oaBFyaPsHRlpcE7rsPISHthVOFX0aavvfg+qglzKL3jk1YBex7OXmn//hGA3+jrD084rqAiNo61u2eSldqB8y77dpUOX+UHvyzC7DHy3XEojRt+hhGg1z32mr+nRvPYh87pJ2s2qu/l X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: e02bd6a3-185a-4542-9656-08d9876b65ff X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:15:59.3168 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EJO9pfe0W0l+OFOxXDeHwU9dRkQKCCKx3ABvgttz1pgRCk3j9TwyLg3udIMX8hCOT0zR+/P4wK6x6lESbKmqmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7434 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC As the number of interfaces grows, the number of if statements grows ever more unweildy. Clean everything up a bit by using a switch statement. No functional change intended. While we're on the subject, could someone clarify the relationship between the various speed capabilities? What's the difference between MACB_CAPS_GIGABIT_MODE_AVAILABLE, MACB_CAPS_HIGH_SPEED, MACB_CAPS_PCS, and macb_is_gem()? Would there ever be a GEM without GIGABIT_MODE? HIGH_SPEED without PCS? Why doesn't SGMII care if we're a gem (I think this one is a bug, because it cares later on)? Signed-off-by: Sean Anderson --- drivers/net/ethernet/cadence/macb_main.c | 99 +++++++++++------------- 1 file changed, 45 insertions(+), 54 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index e2730b3e1a57..18afa544b623 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -510,32 +510,55 @@ static void macb_validate(struct phylink_config *config, unsigned long *supported, struct phylink_link_state *state) { + bool one = state->interface == PHY_INTERFACE_MODE_NA; struct net_device *ndev = to_net_dev(config->dev); __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; struct macb *bp = netdev_priv(ndev); - /* We only support MII, RMII, GMII, RGMII & SGMII. */ - if (state->interface != PHY_INTERFACE_MODE_NA && - state->interface != PHY_INTERFACE_MODE_MII && - state->interface != PHY_INTERFACE_MODE_RMII && - state->interface != PHY_INTERFACE_MODE_GMII && - state->interface != PHY_INTERFACE_MODE_SGMII && - state->interface != PHY_INTERFACE_MODE_10GBASER && - !phy_interface_mode_is_rgmii(state->interface)) { - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); - return; - } - - if (!macb_is_gem(bp) && - (state->interface == PHY_INTERFACE_MODE_GMII || - phy_interface_mode_is_rgmii(state->interface))) { - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); - return; - } - - if (state->interface == PHY_INTERFACE_MODE_10GBASER && - !(bp->caps & MACB_CAPS_HIGH_SPEED && - bp->caps & MACB_CAPS_PCS)) { + switch (state->interface) { + case PHY_INTERFACE_MODE_NA: + case PHY_INTERFACE_MODE_10GBASER: + if (bp->caps & MACB_CAPS_HIGH_SPEED && + bp->caps & MACB_CAPS_PCS && + bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE) { + phylink_set(mask, 10000baseCR_Full); + phylink_set(mask, 10000baseER_Full); + phylink_set(mask, 10000baseKR_Full); + phylink_set(mask, 10000baseLR_Full); + phylink_set(mask, 10000baseLRM_Full); + phylink_set(mask, 10000baseSR_Full); + phylink_set(mask, 10000baseT_Full); + } else if (one) { + goto none; + } + if (one) + break; + fallthrough; + case PHY_INTERFACE_MODE_GMII: + case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_TXID: + if (!macb_is_gem(bp) && one) + goto none; + fallthrough; + case PHY_INTERFACE_MODE_SGMII: + if (bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE) { + phylink_set(mask, 1000baseT_Full); + phylink_set(mask, 1000baseX_Full); + if (!(bp->caps & MACB_CAPS_NO_GIGABIT_HALF)) + phylink_set(mask, 1000baseT_Half); + } + fallthrough; + case PHY_INTERFACE_MODE_MII: + case PHY_INTERFACE_MODE_RMII: + phylink_set(mask, 10baseT_Half); + phylink_set(mask, 10baseT_Full); + phylink_set(mask, 100baseT_Half); + phylink_set(mask, 100baseT_Full); + break; + none: + default: bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); return; } @@ -543,38 +566,6 @@ static void macb_validate(struct phylink_config *config, phylink_set_port_modes(mask); phylink_set(mask, Autoneg); phylink_set(mask, Asym_Pause); - - if (bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE && - (state->interface == PHY_INTERFACE_MODE_NA || - state->interface == PHY_INTERFACE_MODE_10GBASER)) { - phylink_set(mask, 10000baseCR_Full); - phylink_set(mask, 10000baseER_Full); - phylink_set(mask, 10000baseKR_Full); - phylink_set(mask, 10000baseLR_Full); - phylink_set(mask, 10000baseLRM_Full); - phylink_set(mask, 10000baseSR_Full); - phylink_set(mask, 10000baseT_Full); - if (state->interface != PHY_INTERFACE_MODE_NA) - goto out; - } - - phylink_set(mask, 10baseT_Half); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 100baseT_Half); - phylink_set(mask, 100baseT_Full); - - if (bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE && - (state->interface == PHY_INTERFACE_MODE_NA || - state->interface == PHY_INTERFACE_MODE_GMII || - state->interface == PHY_INTERFACE_MODE_SGMII || - phy_interface_mode_is_rgmii(state->interface))) { - phylink_set(mask, 1000baseT_Full); - phylink_set(mask, 1000baseX_Full); - - if (!(bp->caps & MACB_CAPS_NO_GIGABIT_HALF)) - phylink_set(mask, 1000baseT_Half); - } -out: bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); bitmap_and(state->advertising, state->advertising, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); From patchwork Mon Oct 4 19:15:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534579 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D68EC433F5 for ; Mon, 4 Oct 2021 19:16:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C48A61130 for ; Mon, 4 Oct 2021 19:16:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238988AbhJDTSd (ORCPT ); Mon, 4 Oct 2021 15:18:33 -0400 Received: from mail-eopbgr50077.outbound.protection.outlook.com ([40.107.5.77]:3542 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236730AbhJDTSE (ORCPT ); Mon, 4 Oct 2021 15:18:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KW1mQMutyecBfbs2YAgmUKK/ok8mQuDjE9yKHC53L2NAo1WugWEPIIoKhca5Jt0VYJwQ8z4hNWjRDN6sn2UY1zNY5KXVjRF/4rK3VqhKYabxNWKDUjDmYqQOoSfUQAntImgI/AlxyYuG4tmoHOWmqkGAPy3wfYWw06yVVzJqBibvlAiv7r1aZj9Azn/La4uj2kcUw7+jHdjAuL0cNxcjkBX1pHv5Yy3RRFCU/JRk47+YjGs/vqjBfVYLx5ErIrh7dlfkVkm/2muD2+mU9tuW4YlXFC1i2Z3pg9Dp8tuqLyNhWknc83oUe7wT0+jpM5yekPCQ268hQ48oLgCq+6nPRQ== 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=L66uG51At974MAUQSnBjVhCL/2RhbvnkweDp9b/ye1g=; b=amC/fW1fEbvw8gy4AExChP1acEdkvmpFSVxLQrhZRt5ZTwCMZNuE3dymBezR5MdLq2CrxEjBJ4+2I6TSyYBynb3bLW0fcjTGgvxxmzfeN78rhY2VaXr0oyYos+pY6xYb+aC2P4h5pz5mizVm/HHx0fiGiB8Y9z57LvkKx7O7sFbe4YRVg6xTXVF6KNiEMJa0XeTs/BoquO9NaJGrmMVbLmWwILFpJyFdSEiyg+ThpnyfsuxFGb0ACC4TEQ+CxrP6ZkYo91VomQ63I26qRlY/I5Quh9tmz4O0brSsJqYuaoh/YxDppPegXqFRV71Gi9fsYE63Re4Qo9Tgmwg+MZ2otg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L66uG51At974MAUQSnBjVhCL/2RhbvnkweDp9b/ye1g=; b=RVbzzhmqM11/oFP+c60bsRi5j1IAfxlgVM7fI4Z/tDvJatiAuYUU4CxE7NA8fwR56GefvbCoVrUfZQCVtFj3gXmL+HeiqDDZnjcrZ/deKNVCbLv0O2RsZo8T3QeLP4H6XxFWc9Lz61JyUizwWhB+GNqVrRbEZxM2b6ofweqB3Qc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7434.eurprd03.prod.outlook.com (2603:10a6:10:22c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 19:16:01 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:16:01 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson , Claudiu Beznea , Nicolas Ferre Subject: [RFC net-next PATCH 09/16] net: macb: Move most of mac_prepare to mac_config Date: Mon, 4 Oct 2021 15:15:20 -0400 Message-Id: <20211004191527.1610759-10-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:15:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 01029646-a41a-48a7-4a82-08d9876b672f X-MS-TrafficTypeDiagnostic: DB9PR03MB7434: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xCvjDAkTFys3OaTaLOQ98sELCekV40yQVH2RVOs6fighGfJq0W+cgmaRxufuOtkVg5L6pOkvQnX8Iv0FhegISChwxGjRvu9NVTy3b9c2+4C8IfFwCXZFOJvssraxnngR0It8Lru1UaeSoJ9kgTki7focL/qK3tS7lKuR/hDHe8+OINHqnF6FhvmmPuKYPB4VswVvlHHw5rak7m6zrZdIiSTDXQPF48/536CuNULlr92lQOOkeJqp1kXgknVX9xbTE4A8AnW2qe40sLApVH6PkrKdQD6hNXzdvT6U9xXvETBSJ4uqx2EFgISEDN4jQW2Ua2+x5giKBIxm2EXXKh5OwuymNcuolbZ1TAcmRxi90rvq8zL+4fb8vPYM/Ix1DV3dMmGOW26QYRPhtsRHbFO+KbzancK4SKZXhMBtEnluSBaLA+4A7kjxmEQ+pSO8yor5NbMsiqCb1+1YxZWipy/CdnHR8LgOa5srVbMOIPweJK6HmfadBHxT56h9fBDOHHOMZHQVP80S1mXexYfbfrbjN8sQFln8J6FpvkCBCMQA+ewYoDIS/JfSxrzub3u8es3EqAOVE/+K9GyPkoaT/RdoxnndldfL9T6SQtGP1gZ8K3B/Q0ROqUd5Tpy1jGf+64CwYypPb/V3A/z4Y6v55D2yDIYz555544TUDKpAKKQgW8EguEnlqHHiSEczEwEhI78JUfdw7+fsew3rspo1lkONdQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(1076003)(86362001)(4326008)(44832011)(6486002)(5660300002)(66946007)(508600001)(38350700002)(83380400001)(52116002)(956004)(66556008)(66476007)(38100700002)(110136005)(6506007)(2906002)(186003)(8936002)(316002)(8676002)(2616005)(54906003)(26005)(6666004)(36756003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VoyvYH+dilqBF9kihCWdHvLtwBIIwfevLdGtL4uI9d5U7pNYOXSGcjVixGgPFC9XAKxhjFk3Ssxtw1GcvRBWNGjKdMLWfFlF0tIE4MIYEPevdHefv+S7lief6ar86AVRv9kIsscrbJjibD+gYv4AwIObH+k0jJ2IsI7TrfRRh2giDScG7VCXzk1Qc8rOidTWuoXS7L2MjacHTzYEAlP5tcF74FSqi1OUqCS3IvchredJlyzfw2J8VU3qGevSjWgC8/FKVElb9LnPLOMYUTCbpalgG1vVKGWlvjyG8xcCh/oN3IhRZsJjRhdocm0CIg+LPeDr/SxtoOFpNCkcuavtaVDHldTuC78X/RZpOf6NAyGpt4oieLzySQe4t/qt5YDhbmhqHlXOBzk3y3IC28icxo2uQiPo6YcTPKFy/QfHuoNNfP8qvc3Gn4OW0gP422kDCERIhlVxxuFnRI0hf1WArYoyU4xyNMG3t/Dh0DNPwgtyz2WKtSj0/GYDED/tU7RLxX+zvTcYAOd7FTdYJM4g0OEcGWJfGWkf1y+2v+0sv499pKJ909c8tDYEnuUvGpYHN5omKKBmai/zxC2D1DhcpryIoAfLTHS+8nTTjC3X9IfAVZLBqeBg1goJzAlkDjonyDJAAWGqpg+8XuLVSL6qT4tHkK17gdJ2uOHFlGRR6GsLE6LYRipw/PfWLozWzGcsfxo/GR1WUjYlN0q2PJfkg29/9rA1XrEkweOmJgdR9tnbQpKlRjK5R69NHZCSZrPopx3Lu0XqZFXpYbXeaP7W0Iv0WfEFaIjZpeQfFBonQAPPHL7wgrTj4tcFZ9rT+y5H3TvJLU9TmiAMpLgQKFqWHACIanPrWQj+TvqbuSskbFUpMYlQhZhqAIvcikuUQ9zLPKo1BWqt0OUET3+5zu71nY4S1bkSnEm9joyMgxjNA6o4+3clrGKH2kp3c1C/bVuf1EQ52nKCuHtdaW3xlo5P0JN/MMIdcgoypi2AqxqNb/QvONCDhURpHxFQoXHCY3Kz15cVZo8zwVwMu0oxO3f5oaE7bKKUzsYcUKF9U4ixZ+7McXMw2jKJ12vKe4fA1AKir5lASqsKpjDfDpn2O7o7XX9KI/ujEc5YRI4yTFTWtszGsqlpzugyHpP+aXrjSAUX25038o8fOrQ+OG7DPIfNr8+OzxsB06XFoUrDkJ9MYt32jVhOfq0uQ4GOZnwcnX3glfPFHz9LL2Ntzzdni2QKRP3ObiyX81WUjvBR2wcay/+/rjFjzfs0JMibsVkyyoNk/Mo8cn/ib2TiggDzT5ytZa3iEI6AaTfLx9YvFGNtm9l2WrR7rPcsHVy3V6aQga1r X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01029646-a41a-48a7-4a82-08d9876b672f X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:16:01.2732 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7AWGk8Lztci63Bd2QFV9Iie6C9ter5WT/e5WqjiasnZjtUVMlrSNnViQlImD6AtCpzuaPc40gouPB6IWULnczQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7434 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC mac_prepare is called every time the interface is changed, so we can do all of our configuration there, instead of in mac_config. This will be useful for the next patch where we will set the PCS bit based on whether we are using our internal PCS. No functional change intended. Signed-off-by: Sean Anderson --- drivers/net/ethernet/cadence/macb_main.c | 67 +++++++++++++----------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 18afa544b623..db7acce42a27 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -652,42 +652,10 @@ static const struct phylink_pcs_ops macb_phylink_pcs_ops = { static void macb_mac_config(struct phylink_config *config, unsigned int mode, const struct phylink_link_state *state) { - struct net_device *ndev = to_net_dev(config->dev); - struct macb *bp = netdev_priv(ndev); unsigned long flags; - u32 old_ctrl, ctrl; - u32 old_ncr, ncr; spin_lock_irqsave(&bp->lock, flags); - old_ctrl = ctrl = macb_or_gem_readl(bp, NCFGR); - old_ncr = ncr = macb_or_gem_readl(bp, NCR); - - if (bp->caps & MACB_CAPS_MACB_IS_EMAC) { - if (state->interface == PHY_INTERFACE_MODE_RMII) - ctrl |= MACB_BIT(RM9200_RMII); - } else if (macb_is_gem(bp)) { - ctrl &= ~(GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL)); - ncr &= ~GEM_BIT(ENABLE_HS_MAC); - - if (state->interface == PHY_INTERFACE_MODE_SGMII) { - ctrl |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL); - } else if (state->interface == PHY_INTERFACE_MODE_10GBASER) { - ctrl |= GEM_BIT(PCSSEL); - ncr |= GEM_BIT(ENABLE_HS_MAC); - } else if (bp->caps & MACB_CAPS_MIIONRGMII && - bp->phy_interface == PHY_INTERFACE_MODE_MII) { - ncr |= MACB_BIT(MIIONRGMII); - } - } - - /* Apply the new configuration, if any */ - if (old_ctrl ^ ctrl) - macb_or_gem_writel(bp, NCFGR, ctrl); - - if (old_ncr ^ ncr) - macb_or_gem_writel(bp, NCR, ncr); - /* Disable AN for SGMII fixed link configuration, enable otherwise. * Must be written after PCSSEL is set in NCFGR, * otherwise writes will not take effect. @@ -797,6 +765,9 @@ static int macb_mac_prepare(struct phylink_config *config, unsigned int mode, { struct net_device *ndev = to_net_dev(config->dev); struct macb *bp = netdev_priv(ndev); + unsigned long flags; + u32 old_ctrl, ctrl; + u32 old_ncr, ncr; if (interface == PHY_INTERFACE_MODE_10GBASER) bp->phylink_pcs.ops = &macb_phylink_usx_pcs_ops; @@ -808,6 +779,38 @@ static int macb_mac_prepare(struct phylink_config *config, unsigned int mode, if (bp->phylink_pcs.ops) phylink_set_pcs(bp->phylink, &bp->phylink_pcs); + spin_lock_irqsave(&bp->lock, flags); + + old_ctrl = ctrl = macb_or_gem_readl(bp, NCFGR); + old_ncr = ncr = macb_or_gem_readl(bp, NCR); + + if (bp->caps & MACB_CAPS_MACB_IS_EMAC) { + if (interface == PHY_INTERFACE_MODE_RMII) + ctrl |= MACB_BIT(RM9200_RMII); + } else if (macb_is_gem(bp)) { + ctrl &= ~(GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL)); + ncr &= ~GEM_BIT(ENABLE_HS_MAC); + + if (state->interface == PHY_INTERFACE_MODE_SGMII) { + ctrl |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL); + } else if (state->interface == PHY_INTERFACE_MODE_10GBASER) { + ctrl |= GEM_BIT(PCSSEL); + ncr |= GEM_BIT(ENABLE_HS_MAC); + } else if (bp->caps & MACB_CAPS_MIIONRGMII && + bp->phy_interface == PHY_INTERFACE_MODE_MII) { + ncr |= MACB_BIT(MIIONRGMII); + } + } + + /* Apply the new configuration, if any */ + if (old_ctrl ^ ctrl) + macb_or_gem_writel(bp, NCFGR, ctrl); + + if (old_ncr ^ ncr) + macb_or_gem_writel(bp, NCR, ncr); + + spin_unlock_irqrestore(&bp->lock, flags); + return 0; } From patchwork Mon Oct 4 19:15:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534583 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B17BBC433EF for ; Mon, 4 Oct 2021 19:16:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A5F761215 for ; Mon, 4 Oct 2021 19:16:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239037AbhJDTSl (ORCPT ); Mon, 4 Oct 2021 15:18:41 -0400 Received: from mail-eopbgr50077.outbound.protection.outlook.com ([40.107.5.77]:3542 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238664AbhJDTST (ORCPT ); Mon, 4 Oct 2021 15:18:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WEALprFNDm2poRYMMslh2XD7mdp2k5UzQR5TDpOhOU5tgEqJapbLMl4uHPJuHC0msYWtWFaUILaJsIX06H5omv/anWcaJYQsB+ubfVd9eMw7z6eEY/XgNDo3a2729N/Alrr0vhUb3Csxr8zk47wUztbbMTx9iQb8eOX5PzUBw2av4gOzx8pQAnRa6LKtyj6hPfXZcq2pE/66vEs6AC5D4kRzJIoOBgsvEqX02sWfp1K3cdFEO9BeyRw2Z8D11l8PI+vbprgNvC//1K23cMgDWtnMywUNGiGYZDm6GOXylGKYkcFQ2030sWHG/0qYMZjseAABp3tuJKAEazpgE39XSw== 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=lmcxz4GB/axDr592bHvxU7Pq0EtIAijWW90fWtk/waI=; b=PDhs7g4zpMYHzKaYz93QSYMcmQKbG8k/g1m/OnUHqnrRSCXy1nTdjPb1VYWRla2BTh06BqtprcvW+qnU8AM1eATw7UgVBn1fAI5e1qkKv+fViZdGkzn8auB5GUlM889dr23+XF199V5RIZ9U6wx69EHS0kUvGWaY4XLoyXlem5X1dKkzvvI1untayL830JgvgbNuTpPLPsXGNYwzm2pPUjUZEv6oKLPQiF+rG8yS8LwyifCyowI0xRULolnVSyLM6YTtD+s+ftUvU+gbO5D0flL4VKNu+D58IlmZg+Fx0CPT7h1SjjEjM6YRnaRVoCGtgJweaakLm+5VVYvIIFlOkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lmcxz4GB/axDr592bHvxU7Pq0EtIAijWW90fWtk/waI=; b=swNm27Hrk5VaGiWCg9Iq3yBLkWNGXDF7Zotfwfq2X86yqDo1azs51uvE4DrJ1XL0eYiI6OAgJY2qH3E9cdeJyUJvbH/pNp9Ju1YtTOlCHuSJLHUxcyZHZvqIvLqAbu3hI1CjwWWPifMlSYMadqCFUjsnrXVkaYeHWQEzmFEzYNM= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7434.eurprd03.prod.outlook.com (2603:10a6:10:22c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 19:16:03 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:16:03 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson , Claudiu Beznea , Nicolas Ferre Subject: [RFC net-next PATCH 10/16] net: macb: Move PCS settings to PCS callbacks Date: Mon, 4 Oct 2021 15:15:21 -0400 Message-Id: <20211004191527.1610759-11-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:16:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0a2a52f0-0529-4ede-2c18-08d9876b683e X-MS-TrafficTypeDiagnostic: DB9PR03MB7434: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y2+em+AGOHf9aZDGFlvWcdSOmcjAKnNrD/RKdH8RtPMgxASUynBtNNpwBJsAq/76qySZ2ov2eRyfiuVWmVgUNvKHrA8i9H/+dXvkY2rmevAFCFgLPDCJTDzx0uzIzNbF2C7AJfayCHJecuezmd8gNMu3vaNtc3amjlTz5RCyEuF2RFYkoB+nkbUVtETM+tC3NCVk9GLqH/nTB8ao+TtXAtCtiroltL38AiEUxA09iEvTnsKagVkbExZWkJHZP5MjNOcnjMHaUAONUhmKlTo0lJCMgRZp3bF0YZEvt1Xsl5JYv02yTcWxBQAdFNDWsKdQBt6ha6ztJLfLeZydpB3T4Dddl7sv19IEmRMxbkhLPPKOm5BPLle3Zvb2lRktFR7+FC1Xt9+vX/tW6eoiyzgb2Ohgf/yXeJgIsorjJyMnV15vaFeqE7unYyC+aA2pBJwN3qKTiNQZrHigjmdLgWDwnOaQO5ugzveTzcHTtLl//45VMAbrFBz1nwGdBIMaEWsKr9Pm5gRvZJey3qJmwBABnMsY5TzF9GoB02VJojcLK/C9/w6dY84/N785+lyAKVDI4DhlDp0ApOwOMWPQrP1bdkEHa1C2sl6UglwrRSkzJg1VPvESI6Xk63LV6iKmkPAhuHGksa5TOyefcIYGDTLCHByD9GJAEegVcNOzzvseuUVP8Z74VGZpPrEYLFNU3sbkESMqXmq8QJrFVE4UsVeH6A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(1076003)(86362001)(4326008)(44832011)(6486002)(5660300002)(66946007)(508600001)(38350700002)(83380400001)(52116002)(956004)(66556008)(66476007)(38100700002)(110136005)(6506007)(2906002)(186003)(8936002)(316002)(8676002)(2616005)(54906003)(26005)(6666004)(36756003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: R1Vw3TWKBOCkImL1fNxmYe/XonikpdEjeZRY19Uw6TDxscv+AWp7EWAzV4gbdiV1kbeJ0qcIMqF8cSKfWKBCYFe9625cP17UDuoriKp2og59ojy1nlNmdv6U1gw/nWze595y0jc1Hhp/2JK1SsOEKKZrYyPp3HrC5BNwJ5i2/BFDpPvrmYbkidTO0InM9px9+D+/+xE2lsP7mBK2I94g1sn0F6Ph5LckcgI1CBAXJCE8OKDMXVQU10weu66X8c92MrAEaHcmEvkCrc8ml+j2vQ014EOhRWoS79fRkbIgaKEuIjhY7gNGC/+lVI9Brm9qJ5PE1q/IR9ztc8Db6u+OtI2yTHhXx9FSl8q6XhKtUpBZAA1IB/6HyWyBboLGT3ao44Ej/OHypbCcGFSSYG0IsCcuhy4KWd9B1nutk+9X1Wi5qgie24cayV78uG/8HhKj9aauckFP7pdSaUaARL+eel3hsLeOi+SJqkKDw/zbwkaPIzWgBsj2zwpUMKdXQZSjNXQBBj5hdNT0OjpAr2mQ8wy1zo4ybuMgIknInReABbSKqKxEaVCe6LCbxpmazFMZ1wyLz4vGYyIx39xHbHCfIPwkNwWAJ1QJyx0bhFHwXz3xe86rs3j7Ylaim3z1N6M/wfr8U4Ct4AXhekg0cQ7tIk33hXnS/oHas5lk665FEyDR31+2VVUNLM3VuCu/cOkmKYUtpIA3Ym1Ai0Et2aBXn7DjKFd9ZDyIE2Q7aRPCRM4Qz3LCQTw486cqZg9YNIA31SQR5aElX5mGFe7LE4lx4nLkSn0YAb9jjnCNvJm930/eLp+OHGts8ELPPaJ6B8JODXcOdaTe1osANCS0VteWuohU9n4DcP8GxokUVZCWXMDC1VhxZLrC7XP+I2+dKnxOfyFnHYtJqx+T9HX1bsUV3GvjJuNJS6oCgTAk8VlWtEBwL+MgFXeLZpmYGwXsybL7ua99xVIT51+qNfFnMSIRwnAySE8eekB/I8hygmIgG1i/n+6fns5eRAdZvwQWOIA25eLTy5ze4EjP4xxZfKuzZjiVa8IGkaxt29rcnfUgGhc1GIu1mbYT+T8Wis8Fe3VC6x5/fER7a6LX2mz8Q6cDDG7OM2sp+JmEGMbGAyqdaUF66qLipWQoCqbBGSPwEtVhtJrZWuH2ZRa5hMh+j/xsntgOUeIeCRGshJYnl1lKZ4xr8HyiGyXhWBCo8XsEz0zG0g2ttclEHoxZqqscKeH5KOUBVAG62v3TaV6GKhmJW2msMdSMxN81J7Y2ise4G/O2G5rSiD5Iy8uNfTTIk2VCXVyAC7gYQWhMxyBU7W0bqz19q2z1zKLMOTSYoh24xxdD X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a2a52f0-0529-4ede-2c18-08d9876b683e X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:16:03.2970 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: e5t8PtCzxD8Vkmx0NsP5pw+MqypMNeqj6k1cJhop0xjDRzZLAsIn07/inqdm9gFZWowleBqYeNRE5T03l6hK9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7434 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This moves all PCS-related settings to the pcs callbacks. This makes it easy to support external PCSs. In addition, support for 1000BASE-X is added (since we need it to set the SGMII mux). pcs_config should set all registers necessary to bring the link up. In addition, it needs to keep track of whether it modified anything so that phylink can restart autonegotiation. config is also the right time to veto configuration parameters, such as using the wrong interface. This catches someone trying to use a slower speed (which could be supported otherwise) after using a faster speed. We can't support this because phylink doesn't support detaching PCSs. pcs_link_up is necessary IFF the mode is not in-band and the speed and duplex are different from what was set in config. However, because the PCS supports only fixed speed (SPEED_1000 or SPEED_10000) and full duplex, there is nothing to configure. Therefore, link_up has been removed. Now that the autonegotiation is done in pcs_config, we no longer need to do it in macb_mac_config. Signed-off-by: Sean Anderson --- drivers/net/ethernet/cadence/macb_main.c | 214 +++++++++++++++-------- 1 file changed, 138 insertions(+), 76 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index db7acce42a27..08dcccd94f87 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -543,6 +543,7 @@ static void macb_validate(struct phylink_config *config, goto none; fallthrough; case PHY_INTERFACE_MODE_SGMII: + case PHY_INTERFACE_MODE_1000BASEX: if (bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE) { phylink_set(mask, 1000baseT_Full); phylink_set(mask, 1000baseX_Full); @@ -571,25 +572,100 @@ static void macb_validate(struct phylink_config *config, __ETHTOOL_LINK_MODE_MASK_NBITS); } -static void macb_usx_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, - phy_interface_t interface, int speed, - int duplex) -{ - struct macb *bp = container_of(pcs, struct macb, phylink_pcs); - u32 config; - - config = gem_readl(bp, USX_CONTROL); - config = GEM_BFINS(SERDES_RATE, MACB_SERDES_RATE_10G, config); - config = GEM_BFINS(USX_CTRL_SPEED, HS_SPEED_10000M, config); - config &= ~(GEM_BIT(TX_SCR_BYPASS) | GEM_BIT(RX_SCR_BYPASS)); - config |= GEM_BIT(TX_EN); - gem_writel(bp, USX_CONTROL, config); +static inline struct macb *pcs_to_macb(struct phylink_pcs *pcs) +{ + return container_of(pcs, struct macb, phylink_pcs); +} + +static void macb_pcs_get_state(struct phylink_pcs *pcs, + struct phylink_link_state *state) +{ + struct macb *bp = pcs_to_macb(pcs); + + if (gem_readl(bp, NCFGR) & GEM_BIT(SGMIIEN)) + state->interface = PHY_INTERFACE_MODE_SGMII; + else + state->interface = PHY_INTERFACE_MODE_1000BASEX; + + phylink_mii_c22_pcs_decode_state(state, gem_readl(bp, PCSSTS), + gem_readl(bp, PCSANLPBASE)); +} + +/** + * macb_pcs_config_an() - Configure autonegotiation settings for PCSs + * @bp - The macb to operate on + * @mode - The autonegotiation mode + * @interface - The interface to use + * @advertising - The advertisement mask + * + * This provides common configuration for PCS autonegotiation. + * + * Context: Call with @bp->lock held. + * Return: 1 if any registers were changed; 0 otherwise + */ +static int macb_pcs_config_an(struct macb *bp, unsigned int mode, + phy_interface_t interface, + const unsigned long *advertising) +{ + bool changed = false; + u16 old, new; + + old = gem_readl(bp, PCSANADV); + new = phylink_mii_c22_pcs_encode_advertisement(interface, advertising, + old); + if (old != new) { + changed = true; + gem_writel(bp, PCSANADV, new); + } + + old = new = gem_readl(bp, PCSCNTRL); + if (mode == MLO_AN_INBAND) + new |= BMCR_ANENABLE; + else + new &= ~BMCR_ANENABLE; + if (old != new) { + changed = true; + gem_writel(bp, PCSCNTRL, new); + } + return changed; +} + +static int macb_pcs_config(struct phylink_pcs *pcs, unsigned int mode, + phy_interface_t interface, + const unsigned long *advertising, + bool permit_pause_to_mac) +{ + bool changed = false; + struct macb *bp = pcs_to_macb(pcs); + u16 old, new; + unsigned long flags; + + spin_lock_irqsave(&bp->lock, flags); + old = new = gem_readl(bp, NCFGR); + if (interface == PHY_INTERFACE_MODE_SGMII) { + new |= GEM_BIT(SGMIIEN); + } else if (interface == PHY_INTERFACE_MODE_1000BASEX) { + new &= ~GEM_BIT(SGMIIEN); + } else { + spin_lock_irqsave(&bp->lock, flags); + return -EOPNOTSUPP; + } + if (old != new) { + changed = true; + gem_writel(bp, NCFGR, new); + } + + if (macb_pcs_config_an(bp, mode, interface, advertising)) + changed = true; + + spin_unlock_irqrestore(&bp->lock, flags); + return changed; } static void macb_usx_pcs_get_state(struct phylink_pcs *pcs, struct phylink_link_state *state) { - struct macb *bp = container_of(pcs, struct macb, phylink_pcs); + struct macb *bp = pcs_to_macb(pcs); u32 val; state->speed = SPEED_10000; @@ -609,70 +685,60 @@ static int macb_usx_pcs_config(struct phylink_pcs *pcs, const unsigned long *advertising, bool permit_pause_to_mac) { - struct macb *bp = container_of(pcs, struct macb, phylink_pcs); + bool changed; + struct macb *bp = pcs_to_macb(pcs); + u16 old, new; + unsigned long flags; - gem_writel(bp, USX_CONTROL, gem_readl(bp, USX_CONTROL) | - GEM_BIT(SIGNAL_OK)); + if (interface != PHY_INTERFACE_MODE_10GBASER) + return -EOPNOTSUPP; - return 0; -} + spin_lock_irqsave(&bp->lock, flags); + old = new = gem_readl(bp, NCR); + new |= GEM_BIT(ENABLE_HS_MAC); + if (old != new) { + changed = true; + gem_writel(bp, NCFGR, new); + } -static void macb_pcs_get_state(struct phylink_pcs *pcs, - struct phylink_link_state *state) -{ - state->link = 0; -} + if (macb_pcs_config_an(bp, mode, interface, advertising)) + changed = true; -static void macb_pcs_an_restart(struct phylink_pcs *pcs) -{ - /* Not supported */ -} + old = new = gem_readl(bp, USX_CONTROL); + new |= GEM_BIT(SIGNAL_OK); + if (old != new) { + changed = true; + gem_writel(bp, USX_CONTROL, new); + } -static int macb_pcs_config(struct phylink_pcs *pcs, - unsigned int mode, - phy_interface_t interface, - const unsigned long *advertising, - bool permit_pause_to_mac) -{ - return 0; + old = new = gem_readl(bp, USX_CONTROL); + new = GEM_BFINS(SERDES_RATE, MACB_SERDES_RATE_10G, new); + new = GEM_BFINS(USX_CTRL_SPEED, HS_SPEED_10000M, new); + new &= ~(GEM_BIT(TX_SCR_BYPASS) | GEM_BIT(RX_SCR_BYPASS)); + new |= GEM_BIT(TX_EN); + if (old != new) { + changed = true; + gem_writel(bp, USX_CONTROL, new); + } + + spin_unlock_irqrestore(&bp->lock, flags); + return changed; } static const struct phylink_pcs_ops macb_phylink_usx_pcs_ops = { .pcs_get_state = macb_usx_pcs_get_state, .pcs_config = macb_usx_pcs_config, - .pcs_link_up = macb_usx_pcs_link_up, }; static const struct phylink_pcs_ops macb_phylink_pcs_ops = { .pcs_get_state = macb_pcs_get_state, - .pcs_an_restart = macb_pcs_an_restart, .pcs_config = macb_pcs_config, }; static void macb_mac_config(struct phylink_config *config, unsigned int mode, const struct phylink_link_state *state) { - unsigned long flags; - - spin_lock_irqsave(&bp->lock, flags); - - /* Disable AN for SGMII fixed link configuration, enable otherwise. - * Must be written after PCSSEL is set in NCFGR, - * otherwise writes will not take effect. - */ - if (macb_is_gem(bp) && state->interface == PHY_INTERFACE_MODE_SGMII) { - u32 pcsctrl, old_pcsctrl; - - old_pcsctrl = gem_readl(bp, PCSCNTRL); - if (mode == MLO_AN_FIXED) - pcsctrl = old_pcsctrl & ~GEM_BIT(PCSAUTONEG); - else - pcsctrl = old_pcsctrl | GEM_BIT(PCSAUTONEG); - if (old_pcsctrl != pcsctrl) - gem_writel(bp, PCSCNTRL, pcsctrl); - } - - spin_unlock_irqrestore(&bp->lock, flags); + /* Nothing to do */ } static void macb_mac_link_down(struct phylink_config *config, unsigned int mode, @@ -763,20 +829,23 @@ static void macb_mac_link_up(struct phylink_config *config, static int macb_mac_prepare(struct phylink_config *config, unsigned int mode, phy_interface_t interface) { + int set_pcs = 0; struct net_device *ndev = to_net_dev(config->dev); struct macb *bp = netdev_priv(ndev); unsigned long flags; u32 old_ctrl, ctrl; u32 old_ncr, ncr; - if (interface == PHY_INTERFACE_MODE_10GBASER) + if (interface == PHY_INTERFACE_MODE_10GBASER) { bp->phylink_pcs.ops = &macb_phylink_usx_pcs_ops; - else if (interface == PHY_INTERFACE_MODE_SGMII) + set_pcs = 1; + } else if (interface == PHY_INTERFACE_MODE_SGMII || + interface == PHY_INTERFACE_MODE_1000BASEX) { bp->phylink_pcs.ops = &macb_phylink_pcs_ops; - else - bp->phylink_pcs.ops = NULL; + set_pcs = 1; + } - if (bp->phylink_pcs.ops) + if (set_pcs) phylink_set_pcs(bp->phylink, &bp->phylink_pcs); spin_lock_irqsave(&bp->lock, flags); @@ -787,21 +856,14 @@ static int macb_mac_prepare(struct phylink_config *config, unsigned int mode, if (bp->caps & MACB_CAPS_MACB_IS_EMAC) { if (interface == PHY_INTERFACE_MODE_RMII) ctrl |= MACB_BIT(RM9200_RMII); - } else if (macb_is_gem(bp)) { - ctrl &= ~(GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL)); - ncr &= ~GEM_BIT(ENABLE_HS_MAC); - - if (state->interface == PHY_INTERFACE_MODE_SGMII) { - ctrl |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL); - } else if (state->interface == PHY_INTERFACE_MODE_10GBASER) { - ctrl |= GEM_BIT(PCSSEL); - ncr |= GEM_BIT(ENABLE_HS_MAC); - } else if (bp->caps & MACB_CAPS_MIIONRGMII && - bp->phy_interface == PHY_INTERFACE_MODE_MII) { - ncr |= MACB_BIT(MIIONRGMII); - } + } else if (bp->caps & MACB_CAPS_MIIONRGMII && + bp->phy_interface == PHY_INTERFACE_MODE_MII) { + ncr |= MACB_BIT(MIIONRGMII); } + if (macb_is_gem(bp) && set_pcs) + ctrl |= GEM_BIT(PCSSEL); + /* Apply the new configuration, if any */ if (old_ctrl ^ ctrl) macb_or_gem_writel(bp, NCFGR, ctrl); From patchwork Mon Oct 4 19:15:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534585 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10C46C433F5 for ; Mon, 4 Oct 2021 19:16:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5EA261215 for ; Mon, 4 Oct 2021 19:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239016AbhJDTSq (ORCPT ); Mon, 4 Oct 2021 15:18:46 -0400 Received: from mail-eopbgr50077.outbound.protection.outlook.com ([40.107.5.77]:3542 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238700AbhJDTSc (ORCPT ); Mon, 4 Oct 2021 15:18:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GWYBkXJzrHatYr0+owH6DWs99SAmZkjrzzhPSfNewwy8NmoSd7vQgxn1w+UAnS7v0MEQzxd/LPB7ceX/xux+UDU6uT2MvxdBSXj+thT0aS6C2Q4cwIRjk0Ek96qdUL1Y0/kJEWrrtMeUtW8UHTMTIRTMZIvstf8IfNg77z3sXVnsZ1XK2PdpnIyFZq6VcteW6rQ/lNLZ7GZsf/WbGgP0rDEoBlwZz9Gu7pZLPIo5hPvQNphtGNCvQChOxprX2IK0Is/p5I16YNCDG+f0x4pHK/22aEVaPNaI1NqbDCAIRJMuURqOk3LVlgaH0UQ5fSaSU8XoLBmjJLrj37AOG0jYng== 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=MwqogHcbsow8dBZ9T8Dw1UllQRhGDdyQ20Ce5cmhTTc=; b=b1WCVfV/uRfPYweCTQmdwfmf3h3/ZfScQ3+xPdY8n6eEITpbIo1FoBbZcoXI68XV/Vf0cTWTUSAs0e4sxVqmMWOdrtHJm112XGjagr/JWZTQAKpmk7aJYDPFaa4srA2DQDnITUGjfEqrVvKe106RWFkaaG/USx/z69Z/1y1TdS1hWpND8O0T/bOzixYMeUrFuh8uUk5sdXF6GxmsNaihUaOBs/fOYgz9GWPnugoSpJAX+k+MIvVX+oGcOhT76s4BtjqNrhHKw8W9Cpvi6acyIEFqeS4GGCeCgNbcwMwQMYhHb+Nh1SZj4u4B8ZgowX6IQxbk5fh6cBFlhgrqoAARAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MwqogHcbsow8dBZ9T8Dw1UllQRhGDdyQ20Ce5cmhTTc=; b=R+zZqDN00zLvWpXWW73cwOPfTdKp/T12N9jdyfNLeGOhEczs9MscO1Ja5YJe4L22UYzj18WIP9vrIByKz6+sKiSyA/qrIMHsnVoLye4v8JAwjU4mZD0Vt5pSyIEmCFBgVnnKVuceOZeVWrUPPH3nKOLgpR62yjEij5o0Epz5cb8= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7434.eurprd03.prod.outlook.com (2603:10a6:10:22c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 19:16:05 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:16:05 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson , Claudiu Beznea , Nicolas Ferre Subject: [RFC net-next PATCH 11/16] net: macb: Support restarting PCS autonegotiation Date: Mon, 4 Oct 2021 15:15:22 -0400 Message-Id: <20211004191527.1610759-12-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:16:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fe3b666a-cb2a-4349-49c1-08d9876b6954 X-MS-TrafficTypeDiagnostic: DB9PR03MB7434: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZUp5O0RQ5hEgKdtCT2jHOWxSE55vV0wDRNdVNPds1KdI9HdQV3sWOWEhCQDbZThv+xWd9kRBTOdhAkdnLZhXCsdwMAKehexj1fSpKdcHlraPoymVDW8T29+pslODSTT0nkx7id+c7IvpZxZhcLhuRi1u6fGj8ScplXwOagaQcYhfpkKASY7YPk5hFo2H+3WyAjhmNkeexEQ2QX6ZW8pkf+hqVbHNlbynZCxVGzv3cioMptlL6K6tN14xP0VoR4eL+Pj1nGSjzfnaLJwf2L8eriUrBbRKljqcQOqalbr3ihdQaP3fa77cdy+4buqRxzeq+LFg4QHRHmYlYzIMGTNJ5YmzWssTpHbmmT7+FQy06Bl9o0fPPDzEhd0LiKmPiryrJ0BjY1bEvgaupRHs7TE9TdDHwtp8QaCcTe2Lw/7+YVW2Q7bwXiY/TBQElsQoZ3nazbTzrY83BuDfHFeneZ4pFOcD1s11ByHU+1IytyvQvansIcpxkmDMefcxtmFtl3+3ec6mbypRuWxkqm7mJFvAG+uPDF0UIIiwJPOBRXFZOkYiNnpppb1A9qN60VuPjPM3MSq5cMrnmrvNZtmq+nWcgarXfanmsrxm3dEJRFeajgoquA/UmYJoX3pY+U3hrBnxFlD1pum1EVfM/3mDN0BYh6EGZjk4DIbsfMFPPoxJb0uIT8VT6mQJfQUcGFyzoY50abJkYmhIzZcS0MaEPizL8g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(1076003)(86362001)(4326008)(44832011)(6486002)(5660300002)(66946007)(508600001)(38350700002)(83380400001)(52116002)(956004)(66556008)(66476007)(38100700002)(110136005)(6506007)(2906002)(186003)(8936002)(316002)(8676002)(2616005)(54906003)(26005)(6666004)(36756003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: otb40rf4lZwuXT61DX6N7+Joe8U9M4BE3qR72vVyLugsXQ5Lyp9JC04eTNEeg1R4npzp2FeiX1Yhpdj5x4jpQtF+eP797SzOujT2zjbs7iG29zoQa3MkFJmfY0mCleHH5iyZbNouCnhFdsFXIrPIYhdo2TvUULonaPmbrexXRds1QOYTTWarcy4DwxpOMq1fe80M8e4+7lKS6UqD90hkEwnRiyy7+b5lsnbiCTlNtZ4CnEervuTYcUXEeV1Oy0Js6Kia47+QEv09qVK7ejWLuBEClKjdmSNmFUaSY4aXdj6BZT6AH5zNlg7ZWvks6FIUbN4K9EJkasWHzsBR6sETYCrTCkfJbyqnXlExL4t+wEOR2B7aCSvcKV2YY1zXekKvf8Px/MU1LfbFxAoYjfV3VHqHdJOJNV5DQwo4tLASI+2z43VA98ExST5O06mGwe67JPsTPt4YXQas4lz52IjKlIwwJr6whreWBUfknETW5I7QLBpVUEl74zc79SQ3SVQ1oviBNlJWk2YnECM6mbxAB513hwp6Kyu6IyoZzgfQNA/gOLaE5aBV7LhdNsBH0mNG/uJRm9TrWFUEDfxngT03Kbe2ayQhzGSXU+X4a5Mt+F0wNiedJKxtIn4VDaTf9g66EFhLZIXqCQEGFWU/FhBZBGdN2TozxlVoMvsbqJ816OPXkuuiJ47fMoFFKeecAElx7dnIdjcf3Fd98sUIRatFVP+5aHl6sBRCnNl+bMg2pSzgQlmAJ3Mzx8n1behfIghL22drVjSw90Sczd5O9vWNVHlSMRhktcSPVrjbGCeKjS7U3aUvRPo6/JsSjmpjoC6W8uiE6gNsUA9Cnie599J7/t7rXOKrqCXphc5wUA37emES15qbLYBt2zgK2dnuP4yi6x8LRX0i9PL67I+/ann+bslIp12XRQOTYUH1AB3Gu5yyPJwT/TMP84jlVi0oyLSXdnjgHgo6XXAt2JJWstKAVLJKu4QyTTcLshgxhE/fJwq75RPTdmb36//rKWIfMITKr9wMJ/tborjirQ5jHgdlOudYcje49Gb6OY+p3RjOyIJRvRrHMFIBdnMApzbcantlbPEKVWSoGdWjQuZnFKLEDsDakSDMu3uFHg9hPuJhZkzTB+7FMVI9/PDdtGMX6IVabs9Mi2JdC6iOuh1VtBvcHlAqqI+fsyQ2Qsc+NVVhNuL2vkM4MLaSMhc/JiYgPRPc0ts83FWXoyqS0ijEJbspLXcw+SYZLk8ysS/2fpSEnb28jDxeQO47awPVRXPRM31+RHzuMNbWOgfpAm/Cm1MFTlPjlSmq09mYZNtBT8JZ9ssfmLaUcFeF545ZetmXcXyD X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe3b666a-cb2a-4349-49c1-08d9876b6954 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:16:05.0328 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yLKgB4Fuq7lhYCCOqvVZTYUoa2A9dB/bej2maRf88IJeQ5FKHeg/nnIzv4gSGCmN36cvlwDrR7s8zB/rZaTEHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7434 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This adds support for restarting autonegotiation using the internal PCS. Signed-off-by: Sean Anderson --- drivers/net/ethernet/cadence/macb_main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 08dcccd94f87..b938cdf4bb59 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -662,6 +662,21 @@ static int macb_pcs_config(struct phylink_pcs *pcs, unsigned int mode, return changed; } +static void macb_pcs_an_restart(struct phylink_pcs *pcs) +{ + struct macb *bp = pcs_to_macb(pcs); + u32 bmcr; + unsigned long flags; + + spin_lock_irqsave(&bp->lock, flags); + + bmcr = gem_readl(bp, PCSCNTRL); + bmcr |= BMCR_ANENABLE; + gem_writel(bp, PCSCNTRL, bmcr); + + spin_lock_irqsave(&bp->lock, flags); +} + static void macb_usx_pcs_get_state(struct phylink_pcs *pcs, struct phylink_link_state *state) { @@ -733,6 +748,7 @@ static const struct phylink_pcs_ops macb_phylink_usx_pcs_ops = { static const struct phylink_pcs_ops macb_phylink_pcs_ops = { .pcs_get_state = macb_pcs_get_state, .pcs_config = macb_pcs_config, + .pcs_an_restart = macb_pcs_an_restart, }; static void macb_mac_config(struct phylink_config *config, unsigned int mode, From patchwork Mon Oct 4 19:15:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534575 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4511C433FE for ; Mon, 4 Oct 2021 19:16:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97D32600D4 for ; Mon, 4 Oct 2021 19:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238992AbhJDTSW (ORCPT ); Mon, 4 Oct 2021 15:18:22 -0400 Received: from mail-am6eur05on2057.outbound.protection.outlook.com ([40.107.22.57]:12353 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238862AbhJDTR6 (ORCPT ); Mon, 4 Oct 2021 15:17:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lGn0iWBZhw6fF8OYbOwweXPLJZo9BMehNgqmVKA429nzicrtrMt8xzmuiTLh0LoMVYjDkM48TvqRV79Dxi/uQMWh0ORIFmDXlywbYYCynnOGtDUtm4sADCnD5KsvNzFY53h8JnQWcYm72cDJEVyYoYFl6irv3qLFtMc900f/txTNa0ve0eQ9ladr6Kd66kmsfvIuU1gMskiHoyzs2W4BxM/znL3pc4KXK2sa37mKv2KOZoBd+/64kMSZ7QwzgEYDJEiTnqOD+CnOfFC2F2jj2jcAhw0NTHCjQtlRPo+/ECTqgisgkcuZvub5dzYLxJllDAalJEdYeyrGYhHJlgytPQ== 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=0dhPr8MGXC9UUahNrbi/O4wBvyRmOPYg1jFblu+Lxzg=; b=AuSNOGpZ4rrydxSFGX8CKxOyvA6xDsjNvIGGjFkFwTKpkyIWUGU3J5NuvSM0Hahp/vyu1rcjyh8x8A97sdP9wky2EFO7PxGZXDppX609Fe+OD0DmA+1htXniZDPPKm6fOlVBvGZhDLcdF8zNMp8mDVW1F4bytREnFhjiInD/3OlrSM+q9+J0IAbpNIdBb4JDY056YzxQaLqshf+nJkQaAnw5kEIJthjhGsIMUunCDXXS3P0nzHWVz6h5bJqvckM56soHgCTlnbFLnBwnj0rK0Aas5XEJaT2//7YxzsGAoXP5IIFJYXhOY+NBwm3LeU1MyuABK6g00rIPAL35Id0FMQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0dhPr8MGXC9UUahNrbi/O4wBvyRmOPYg1jFblu+Lxzg=; b=EcaqNHoKtu+YAIWNO4UdVybwELBzHgwGNFICQLcfdEm9jfBv0wYaIqdVNLo4KksnNsVNxhe6PbOq1nBJQQsMw3MAAxI8UDB/OBpsiyh7dtKnFBo+Y69N/rBk/l0UVT0d9aJyLrtnBQljbC6wBc3QznOcf+xztPWIe0QH986eTUk= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB6PR0301MB2183.eurprd03.prod.outlook.com (2603:10a6:4:47::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.22; Mon, 4 Oct 2021 19:16:06 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:16:06 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson , Claudiu Beznea , Nicolas Ferre Subject: [RFC net-next PATCH 12/16] net: macb: Support external PCSs Date: Mon, 4 Oct 2021 15:15:23 -0400 Message-Id: <20211004191527.1610759-13-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:16:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cca3a8c1-2275-452b-1e86-08d9876b6a68 X-MS-TrafficTypeDiagnostic: DB6PR0301MB2183: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L2vLfpQuMTgU2H530aB9qwRAhyiIO5908VqZ5eD92Bde2rvdzsliB3jTjDXa4c5vPY9xFTLYUjnKCdhZlhnRRceci15+Mfuut3bGuyt4MxQSqgdhfWvPjljq/r6m9IX0O1NZ6QqjGcpQHWGYAUdoehgi4CJwobRjZqjo7VkKsfZdKOe5J6F9xbV7qvuXkjxF5J2vbgvW/oX40STTJOGdIUg4t9GvQPF2VXNCzSetgm1kkteyvZPa/Nqz60VOr0Q18P9CA/ZMkPf+sy3nQ1X8/WQDuh0Rt/ZdfPE6vflOjwC15mm+VLra6OaOlM2QPVMq9X8RnAd7cVqRf3PP8EK7qXtotgbZGr0vq1O+2xZ5xCv2U+KFLwbsqoonDYmDjyCVcdeJuujA94lFfTAagZyvpCOE05qOQxY5EaqIQlvP1MuYNBhQQKuLbAd+J2IFQvyM3GooOB3FXIRVP9lTJtbEVE+TWRCNeo+ptnCtqcc3rZrpF3AQTnNPIaccy+Jel3O2g6tdm/0grQtlVeTmMIvlzuAVaG3Iu0SjxBZ4aX1navRdCAq1eY2zlZaTerb224xLWhfo6wWwkqqDGyZo3bjpWT7xDvvjrn3YMgVLlbC3NZDwLCEqMvhjnwwauY6cnDYDDRakMdHOo+nEHID1XFWYB0cyt0GXtJooWExpUiNH/6n7s54OIgZlzYHWsZ7I+BJ3n0aGlupNEQ6MdJwQ+X75Vw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(508600001)(186003)(83380400001)(2906002)(54906003)(5660300002)(1076003)(52116002)(26005)(66946007)(66476007)(66556008)(44832011)(8936002)(110136005)(6506007)(2616005)(316002)(6486002)(6666004)(36756003)(8676002)(4326008)(956004)(38350700002)(6512007)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 58dAl8FwAeXlhOR7WJtawK00yzUELmrtUWng6Mu1XokQ+BX7DbGWcQ654OkrhrCOaxGHC05FMQQo/STd6bPPtL5eyxQHLJSAfvocRBh+7Bdloc73YGwOLe76zq4hjMW/F8HNd/MMu33fSGsO1qvhwzjPjAFqyXgAuv8sN6Y7Xa8AqjApXuzohzKxq8pLVHMw/wmd1qlbbXG8/ClGzmHwoyDppQKIRAZGYn4dTRbGUQXS2dDQ6dRopqs0XluZrLFhVfYqMH7hCuA2D9XtxvE48+ETx2rOFSLtdSDJeR6j73jH1vDif7l95sDVwspt2qHYk6i5aGMPG6bezPK0jodyawo2QttP72eTNxj8f/igyvfwFgadPDDUR9Uy3QJtElI1Nnx0T0NFgghMpnvl93q+jP8X24sijdJ22SRW5CfpZ1SjlJHQvlcbPiZpG8hoYhmqt1BGDyzA4LWikhY26XhFBaQSLz61RMhY3m5YWIyIPuv+JLuc3mGZYpGWqdk3UDcrJHCPi/o3ousJU+F9Iv981L+adZhiZEczktOsQzU09sC2vfvaJ22MLijSQCD+W+qop8wItIjEDCk8eBfkd4T+UOmxnTk6XralO4d3JOalAWuLLHEZ6NJoJNvcMGGpoprQlcvx1fEUvGHeqQIDSA8AH9nue3A3QkKjxXT4DFbIsHB9k81+k3ncBt3vdAnl/jviwEUCCBFNVNB2sjS33gW2QrtVLn2L8ZvVlhuKUTNFBdrsZ8PfYzXhAznHb/O/xZeWN1xAvbxwCKpIwUwz5BYU7lElx2TuvWEmYRJkd6AkPSMIll3DV9xnbAe1cbF/EK02vEnsM9YyrCjPu+iwlx+v1u0mk90Umq8GxopMCc0/lj8wHYhyIFqpD7epjHM2TXPTXY3Q0r7c9kQdhxQH+0NKE5ZL3pyBkURYi67q2FZs9dKGjuW3MQQR7H5NU2Ka19+tS0iXzG4e/e1hV7Wm8AOnQOHnUX4kbcg9DeHtp94DmK2cI/2oI3yLgl77LxFUWfcMpfSYpZIp/TPkRGZk0PhPFv2H1SUUAixUnqZzIcfJ3b28GLq/ix9wOTci+66bba164Wo0mtnLRg9PTdnlNFUl4z56ySQbbOqMYoIlHrbau5aolJkedOT/IPdUnxAnGKuPGnTQB/9/0mKL3Pjr+qD1gWdr1PlcfT24+TESXNOsebQyuuVQ4HcmsK3Ziu0lhuyyVopDPf1vHBk7kcdpC1gmoqAzOVor1diJxUbjyVLNDzTSomAniahfXJhxBJCeMS4Ipmi6acZ43SSYcFRzhpbVm2C+R3fmcoHidIXKrpGQFowMzJXnbI8Kg1kh6lvmwSSG X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: cca3a8c1-2275-452b-1e86-08d9876b6a68 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:16:06.7881 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VXb8ABwaRf+GNNg27Nyxh9eloqlueDDDzOH3ooEysl0JIIKNuBl/0NVLAbic4c+o+FZRySAqJ0bprm/+3Y03ZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0301MB2183 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This adds support for using an external PCS. If someone else has set the PCS beforehand, then we will use it instead of the internal PCS. Signed-off-by: Sean Anderson --- drivers/net/ethernet/cadence/macb_main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index b938cdf4bb59..7e9fd12c09c8 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -862,7 +862,7 @@ static int macb_mac_prepare(struct phylink_config *config, unsigned int mode, } if (set_pcs) - phylink_set_pcs(bp->phylink, &bp->phylink_pcs); + set_pcs = phylink_set_pcs_weak(bp->phylink, &bp->phylink_pcs); spin_lock_irqsave(&bp->lock, flags); @@ -877,8 +877,11 @@ static int macb_mac_prepare(struct phylink_config *config, unsigned int mode, ncr |= MACB_BIT(MIIONRGMII); } - if (macb_is_gem(bp) && set_pcs) - ctrl |= GEM_BIT(PCSSEL); + if (macb_is_gem(bp)) { + ctrl &= ~GEM_BIT(PCSSEL); + if (set_pcs) + ctrl |= GEM_BIT(PCSSEL); + } /* Apply the new configuration, if any */ if (old_ctrl ^ ctrl) From patchwork Mon Oct 4 19:15:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534577 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B1FDC433F5 for ; Mon, 4 Oct 2021 19:16:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4593E614C8 for ; Mon, 4 Oct 2021 19:16:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238970AbhJDTSa (ORCPT ); Mon, 4 Oct 2021 15:18:30 -0400 Received: from mail-am6eur05on2057.outbound.protection.outlook.com ([40.107.22.57]:12353 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233226AbhJDTSN (ORCPT ); Mon, 4 Oct 2021 15:18:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gw3rzR+qH/UGaQStnSdRRtVy0YtVcn7kyRCrAEVdaH0gYWbeA5aObiRfG/4WOSbiKgebr+n85H4akX6KNbrzNC7hzWSN6qHmDxKnpktp8vz6I8d8dgrU/JUyjNO2EulsX3t99jN7czydUOZkDJDB3i/BLzhuHorgIrCn3j0hfIfk0rUTKVpDiT3aCC1Ajsd/1q6vLWj5WFnguaIXwGEWfL5Evu2uIKZ+Wx6NyX6lbrWYvZua00LG93WAqnRbWkxJHUarJyJX+BS0f/boi51thcoUhAIFVHjwUTJLLoAEtADP9LmrjeYvbV3d4x7AtaOCU//pAeAFxtzscReFFkFEaA== 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=iQpI/SKiZJcryo5tqQ5tICaSSYyykdGzHbcj4S8x5MU=; b=UDliIK4DEmYZ3DO/RoY7cxY1F61gS+JNuePcSUIKcPjntNMPDRFaGgfOJ1jxvPR8pJ7vDredp5AeUe2rVb7d9RoboIBCIkeLQe7GL30Jp7ZXyRlAECJtokAQxGEwT4R9gL0H9Gl9cetoRZbqVA2a/xpE9yQ7HGd8rGcMpQGP2h8xEoTDYD/YHwI8IkolcTWy+Cz6wgujRM/PeOegUVNhHubJKjOGcxTtREx6yBfJL9Fto2iylyQMkhtqUn+x6g3qRiovdRfFv56FWvxsnvod6m55GCMbn7u/G+Al/XPitpCCuroYcoVZ0w+dogu2HWFbQCRfnKjE+qx1y/i+nl64Jw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iQpI/SKiZJcryo5tqQ5tICaSSYyykdGzHbcj4S8x5MU=; b=R34QqN+okyh+ZcRdXRYOi8IVNpeZTgr+VjD4703UKPebcerfZjRC3+FEqUJdbxEYnZkjbz9SGDfJijuk3vLoejjqrem2jtIWF07WnyoYEJEi0MtRuc4R1o85pHXKhnOxquULyVoE3x9TIfg6YH4B4YzzGh+hUx+lf9krf+tYawE= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB6PR0301MB2183.eurprd03.prod.outlook.com (2603:10a6:4:47::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.22; Mon, 4 Oct 2021 19:16:08 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:16:08 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson Subject: [RFC net-next PATCH 13/16] net: phy: Export get_phy_c22_id Date: Mon, 4 Oct 2021 15:15:24 -0400 Message-Id: <20211004191527.1610759-14-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:16:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7d3f5270-1169-4c60-f3ff-08d9876b6b4d X-MS-TrafficTypeDiagnostic: DB6PR0301MB2183: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:446; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: csXIrHgTdbS29XW9ld/JmT/W1yZ5QTogyMbAxe5/FqmO/qQVNO/fM8FkJvHr7iGPE+CIvRxOaaVej3kKkVQVXei4sqisV4GaxT1pwh46bEg7fDqmk/3+V8GEniBrgVhn1dB3HgJVBr7BpB0Znf6gOaM8Hk23AHwodrs2kkfDCIzCApvuX9ddmSOW7y7K+p3NHMEVd1AqlJ93fu3ZEBoK1FO4S8a41QYOHPNg3aDNhl5r20rRbuwGHSj4mkWambwsfbgSwfjSOaQN9bB9dakGYmhut7h11dFusMfRt5EghhQsZiZAWWIfY1o8JEiSicb1D9AER/xePTDsVjuECP3X+W1RfIwqvRGHCHeNiNnCRx5g6AYaZeMDNuUTlWBx4ct0fuJyHiWMD+so3AtP7UcB66opZvaAX0PFfP+OyFNwVPvS9hsmWv+V3b84l92Cr3WoENQV8t2mwNJ5X9Itm+yn0Xhtv8orBU7rBoPod+opLC+cFmfU+YCyArm8zWV4Wkk90CIgAuB73g/D2ozzi/h67y7a4SNGVKGzn2wnR9qtILTaiQqNzLlqbAAXNqCk7L6x/RXUplJBeSXUhQRsjeYKYTiR13dFAgCPGG3ZzDJ9nud9OQo6j/l2Y06HgH0ClXjkkW85v2B4oIa2y5izxv56YZ6F0bryz7xxHetBydCn9O6BvJZeoCcb1Bi/YI7iNsddYstUoOPFChYg5IjNrFch6g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(508600001)(186003)(83380400001)(2906002)(54906003)(5660300002)(1076003)(52116002)(26005)(66946007)(66476007)(66556008)(44832011)(8936002)(110136005)(6506007)(2616005)(107886003)(316002)(6486002)(6666004)(36756003)(8676002)(4326008)(956004)(38350700002)(6512007)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nC/iYoJ6kSdaSvIKRUI9cJHR9jRarNxdo6Dvg4Y89JhrgkHJ+e6DWDWThjID/3/IZEgfbI2iil92r9n/29TKBLyeLHFXfR9p/zp6Ozm0Y2ZKXJ5R3YHE0davop8YlL/MLTdUS6UvY6YUCMDWxutfXKzrAZJmbGDLnLnPFoSElHe+VP/ilA5E13USWc4IE6iwnf00iiJAbrbnz33EWSsy+IaStK+a2tC5dqh0hqRImy9BdBP1UmJtKdtDJKDFLkEfcA2NRlhGPLvLnI+ndIzls4X31rR6iwJ1REUMK5xxpflykYbrV/gUiJuUxu3LRBMxbIN+C8teA7/DWnYxwYACehdBFzuNO/gscxCy+sa5wBE9j7y3/DQWApKVm5VFjlZypP5ubE7qgXk4jn220d8+C9xlodTpjEI8cPyI528TzjHWkRwGe3ELbM07qw1apZzEtdWTPKCSiNBda6d36Ay7NM3xXs9DhO2jdb0gyulKiN5jV0QlRPE7GC7cMCsyfXtXKVU523XGMQBzqnXgpEfPfH9TCM15vJK3LVYjrb5KhTpD8vmRszd1+ZfEg515VIR/xtCW4wvAUZ6fWetD5EzSKQblQ2Lso0wh/1LoTQLntzRTgxNJJwRHYHDd84CeP/M5QjNXjB1fl00xZQ7vvli2MfLXo1yj61LnrnQUue91xcVybZ4T9rI6ELAipNjiFt4mXGuvilKiMu81Y3L4TLHyeCU6Jj6gmQswD71G5Cz4c1pqgFVV4vaIF3NSmukcWTp76eD32mjWp7ZweAR3tvBHC9pMe7HAaA6ZjDGC/7lOivSaNtkIPA8kE9LrYxVccL/1NO+HMl3OIRGVfJrd0Umb8csFB9hyafDGKOIsbDpPdsRNj9PsraukLV6BWh5kA31hBTsl0NhjHrINWx8Yn/S+cmxFWQuehJ+VX3y2lRw9jdSQf0R3LMXSxX5f3WaeKUfLbOi6Z+GaR3ijgvSx+N1tIYG775oJs9Ykf4DOsW3gGgayRSt9VyqTA0VMHKcIUkLRKHBuY19XCHdjQbUq2EfDI10u4BNGWqmlWgTx7dROfmZYOhw+LuXgZ4w9kOC4wrtYMgDyXe0nBgBa1NHcigfiB2Zv3gcijniv9LpEudDemb+7/j0NIXBNk1HJJGppr/ENAjYuZpZEFTBVUVVbJ4Jf+EQpKIj1nJl6PF68XBATc2djUuP809runl+5Y46uc2cAnx2sVsrTdzdEQA24lqRHSklLmlxezlGmGSQv24qZzqpbl7zyh8BkV7ndyDnFPWE+x0LOrAADB1hRHSvPXL1cFe1z6AnIKcj+FX4y/8DKVvzm9j+DnzzskKPsvc5eMD1n X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d3f5270-1169-4c60-f3ff-08d9876b6b4d X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:16:08.4261 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kb+AUXvTe3Hi7wgu+p5M6E60+Go4CBxjlTGQdXThK7EbZfOEfjllhBfl4C1lHnmQHfEr9B0aomd41LKXQTGijw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0301MB2183 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This function is useful when probing MDIO devices which present a phy-like interface despite not using the Linux ethernet phy subsystem. Signed-off-by: Sean Anderson --- drivers/net/phy/phy_device.c | 3 ++- include/linux/phy.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index ba5ad86ec826..c75b189f1a3e 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -805,7 +805,7 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, * valid, %-EIO on bus access error, or %-ENODEV if no device responds * or invalid ID. */ -static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id) +int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id) { int phy_reg; @@ -833,6 +833,7 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id) return 0; } +EXPORT_SYMBOL_GPL(get_phy_c22_id); /* Extract the phy ID from the compatible string of the form * ethernet-phy-idAAAA.BBBB. diff --git a/include/linux/phy.h b/include/linux/phy.h index 736e1d1a47c4..206049c0f587 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1381,6 +1381,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, bool is_c45, struct phy_c45_device_ids *c45_ids); #if IS_ENABLED(CONFIG_PHYLIB) +int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id); int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id); struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode); struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode); From patchwork Mon Oct 4 19:15:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534581 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EF35C433F5 for ; Mon, 4 Oct 2021 19:16:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38AE861130 for ; Mon, 4 Oct 2021 19:16:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239014AbhJDTSh (ORCPT ); Mon, 4 Oct 2021 15:18:37 -0400 Received: from mail-am6eur05on2057.outbound.protection.outlook.com ([40.107.22.57]:12353 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238982AbhJDTS2 (ORCPT ); Mon, 4 Oct 2021 15:18:28 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n9ikpar5h8VioDvmOnAiQV4RMR1Mb0fcPS/04UvQqCQ9695necD2esLPNeutZG/+EPmCDo/sqAiolYysO09DQgi0NlLuR/xxOjmQpeVyoIs393Qd0IL7UAAN4QLuaQx34lZTCZVAG8WoPDqLJVhz6x1yiAMmJ1Z1kS5AhTOw/3MD2EUFsekxFhbgkEacthkLxkVmryPw0gjxhKT5ZivuUAHxGYMRl5w9mMMxhQz6PN0C78FpbSJFC8pPu96iG/y/PuaH5m46+n6ckd3vUUuvR2WxcbqBdXHjZmcckPZXyN3g8S/hmgd9P6n0MjhmQqdVvjcopj9fUDyN+VpOHmpMBA== 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=ChK7Kts7N990eCny/qEgkvUuCqEcxWqd7slt78ttkQ8=; b=lRyUCqp4L/GLcrkT28hIFoPP78KutgOlBEtaO1J/daCluX4/Ck/vixuNLkh3exE6Uz7miox/AF2kizWw0/T83y2fEkG96Dx17b67d+1/NCjK1q3IECu2wHrUC/YjeCuVnFNycmIy8hSeeZ9DxEBqEQvhVNijOGFliHGq4TXVmTPqR4On69LNu8kTFSYC4mWdxgkHOoKCegBRkjQ+88Ns49dKYXNpQaJWot7byQEH9bsmkb7l6yDf6SZHHYE6bt25+HGoVBEIl+sagp25VIYcHFCU9N3VrRmqN5G88dnqPHTSF4VXqOgZzQEpNFUxmyUpoXQruBtjWa5+V6O4AtqvmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ChK7Kts7N990eCny/qEgkvUuCqEcxWqd7slt78ttkQ8=; b=LQkGMktt/FG/lVbRhqLUeUSXo2PtO2Oj1SCnC69q5QeLUakI/2Ecm9YIjxWb6NMD+0E9ozVfgo+XFTu/pf1xFoHLVFU7aP2u58uaU0jJT57HfrB9aZC+l6Ge31O0NbZFRWA/q5cH6wb61R/N3l/87MG4NfUiKKvFdO4xKlhT2Tw= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB6PR0301MB2183.eurprd03.prod.outlook.com (2603:10a6:4:47::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.22; Mon, 4 Oct 2021 19:16:10 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:16:10 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson Subject: [RFC net-next PATCH 14/16] net: mdio: Add helper functions for accessing MDIO devices Date: Mon, 4 Oct 2021 15:15:25 -0400 Message-Id: <20211004191527.1610759-15-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:16:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cad7f027-18c3-472d-40a5-08d9876b6c4a X-MS-TrafficTypeDiagnostic: DB6PR0301MB2183: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WHugdG8EFCks6JF3KdXpl8b/EL+M5boiKSu2Au4EAzQu1WPhrwIFSwxETXK/L0gFLED4nGylpAj6Cw+xf1RPwXw2XpDuiWRu91d+KhgNmrl9q2qWcOsrU192MypTLZAQmveEONgv/LwjKNyFF+XJouSp71URqgWIZLGwAG5rvdqdmCQXqggUupkeElFmc/cR+FrpO+bHEGLQ+LTQyrWWMkK2RqZkQzyEPJiqEDZEfp2v8y8vgfyXSNiz9qy0Yu/pz65yFDPUSd/bjoMYU513biRe8a/tAEBX4SDnI/Du2l5h0K16l+B2WLQD04W5F6AL3roxC7YcCpU4XnjYBspvDD7KgoiA3qKllUX8EEPZb3fTPfOkumw3X7vmXIpCYTpkMM7lYzvCvwMmMlNoGQc7UOEpFiUoz8asNW9IxUZIUbxTICqxTJs8IwElHAd1M/fVkVnoHhAhhR9CzLJHqPrAKE5InRLN+v1PNDRzCixzKkC3V1WkfkMlN62eEimBkYL+RuFfu0sDQ5n89t3f+DhTBWOSx01fr8HnthaBOr9bxIM5VM5acRMqxomPwTeb2obxtgzki9nl/FISj6eeSzEP7zT3OIpvg6F5+HOwzOOAaSo77P4atA6utnJIZ/Nc7eOWp+Eng2qNQCzuDfixYLjnaahWnjM8GIV4L7o1mMNppDKZYsHOXRsX0s+Em9WHwwbRnrzu997Ss9pKrUZqbhXbiQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(508600001)(186003)(83380400001)(2906002)(54906003)(5660300002)(1076003)(52116002)(26005)(66946007)(66476007)(66556008)(44832011)(8936002)(110136005)(6506007)(2616005)(107886003)(316002)(6486002)(6666004)(36756003)(8676002)(4326008)(956004)(38350700002)(6512007)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qYoz0kL4/78vROObXpIOOb4DwDHev08IxD0rmVGI/91yzsAemSgCm7H3vUdLizwRwqFV/f4ENBUhzXSPeCYKnjaEZdaYvZ43Mr/IgTua+norC75y2lactt947C+fzcZpQsAdOOHYbNUD1UrsCiE7FcMsnNURprtrIGQfZGsJwWQFJ6FacmHghMDE6zXJ3WO9By7pUO/Z3vXwwlGd6yXBEXtBLp+xpuqBVu5mmAXTbEuNAMZ/Je2H+zY52m5v7h66YKMR6zUrBA+/wMpC+pKQZg3gPqzAK5sI7Onx0DtKDPFB7rADwSnqAaWfJrC8tvJulBs6BPbnK62d5mNZqTidxeWziC7ISzPxjKOoMxSEbHB343/K6ubWXxV7Z2wpPnSTY6+TVNSSw5ocYBsB2BEaAkmLGO++K8tzkDR0c09QhiKtHKstp3gG/tFLQzlyhFhyzzeeNQoKt3G170CwXwYZWQSfj/zuos/Ak5bZc+h4hGeM0HRz7v9ku+fLpSicYR0FQfzy2H9pNWe1YTc1bKh34eFnQPEH9NhMW+QvmENckTlmIsP3GW7r4ySsAEcDwIOs+EJPOIPvj9AiCrkMdzutpVaTZpO54lYUyOQ9nD6YcKre0YihXDbPPSPv5eKIhHqVCDATQy9d7LBVTZQ+LqAuHwgktlRodnhcaCyI8AMeOOGw4tVFi7LZd9LZC2xIOkoyhklhNDImdpRgLL6DQdQ6I6+Ten36SrVdT3YTasBRMHGNs8bId6ujUBLmbzepdsurzVWRSPgSNhy2R6EFtY7B6TCPbgM/NcXM9nyQESDhoCQ/m2eqYGx2qO28rR9JGU3HP3f4daRTD9rKItgvGtdn0yCnTGdozAq+nWnTaiXs54xmh3qQjtcVwR4Gg1EQrU/KKYYvHrtJ7r1gnuwQwbogP04ARsxrMk+XYcC0sAyxqcU1LHcNeBBIwl6qducVh9miI06iaZOz5kma0nAm0fWPC/EZoOvwjVFQp9xWOf/yqe5y2bfYyQQZWlBiyY2/3052V491CNhL0w5DuDFMCpmT+0yAjsUNGQ2xCQeQO0zE977kDKUOnsemk7tsekWuLrtfW5YolL7pafsywQ614YDcdMDpO0oMAmeiswwrIE5e72OD6fXYtmQaufm0DRR3NtD2lS9fcN16xyA9lCaZK35XoGKoI37bP02zwiyzRWB0opjWh1BBLVbMyr/Fcp9SsTslLPsFXEA3drX2223nzWjLFcekP0JIRzFd0u+7VN4CxTgejLcSxzOnli2iuUor1j//DEHK49h0OQqZrvsm4744qKbFzVnk8oZ22UqHndjTvlLrfMneHsFIovkxo26rWCXq X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: cad7f027-18c3-472d-40a5-08d9876b6c4a X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:16:09.9563 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MoahedUCgJsKY/PaiASL3t/8ZlfV6zeTVRI0bRIwpeGijW3tHj4WnWWpGDsxQ3rfzYHT6n0UaKjXqxWhLUBiew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0301MB2183 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This adds some helpers for accessing non-phy MDIO devices. They are analogous to phy_(read|write|modify), except that they take an mdio_device and not a phy_device. Signed-off-by: Sean Anderson --- include/linux/mdio.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/mdio.h b/include/linux/mdio.h index 5e6dc38f418e..1342bbb6ef0c 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -350,6 +350,23 @@ int mdiobus_write_nested(struct mii_bus *bus, int addr, u32 regnum, u16 val); int mdiobus_modify(struct mii_bus *bus, int addr, u32 regnum, u16 mask, u16 set); +static inline int mdiodev_read(struct mdio_device *mdiodev, u32 regnum) +{ + return mdiobus_read(mdiodev->bus, mdiodev->addr, regnum); +} + +static inline int mdiodev_write(struct mdio_device *mdiodev, u32 regnum, + u16 val) +{ + return mdiobus_write(mdiodev->bus, mdiodev->addr, regnum, val); +} + +static inline int mdiodev_modify(struct mdio_device *mdiodev, u32 regnum, + u16 mask, u16 set) +{ + return mdiobus_modify(mdiodev->bus, mdiodev->addr, regnum, mask, set); +} + static inline u32 mdiobus_c45_addr(int devad, u16 regnum) { return MII_ADDR_C45 | devad << MII_DEVADDR_C45_SHIFT | regnum; From patchwork Mon Oct 4 19:15:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534587 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E02DC433EF for ; Mon, 4 Oct 2021 19:17:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A5326113A for ; Mon, 4 Oct 2021 19:17:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239082AbhJDTSu (ORCPT ); Mon, 4 Oct 2021 15:18:50 -0400 Received: from mail-am6eur05on2057.outbound.protection.outlook.com ([40.107.22.57]:12353 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238862AbhJDTSg (ORCPT ); Mon, 4 Oct 2021 15:18:36 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UxgKfNkogelYIifoAiDN6a9ZSePNLSgEtp/HBkMXnmAeB/aWTCGrrE5TNEA6Ydo/D/VkuFU1JQ3BOLnQDJWXRyCpq7J805QJreDBzTBsSPhCBZDNrRXUmsJXJm7T2l6fousy7WqGrFISnhUF6mbOlPRX6bLgkM2KT75wK2skhYJNC87GKf08SALFohB5QD5bDb0Ux7EsZaQfPEvNbTzWPXlB2T1ab8njJB9CxZDbIbProzA41mr9VLXb/8DhRX3BQwuiglEOPhDWFuLCUfGSSbf7N/p4HVIRpS8WZHpvjhITh2SYaTBQVPP532sS0qyN5KtOhQVYcJsXIAE6fHb1aQ== 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=JM4Gz0V/pcZJ1u232n0DuEUc2N2uXYMdMrNM3a0f5e8=; b=McYWftkhlXAPPX9YxzfLUXtjMbKJr+MJIJPTUd4So56T/ECS9AcLiBqQY5xPiJIHuCSzTA5hSY+QtGoJeTySQXWFuAgu8E1R1lNgAS3plZuCtWGJ4MrUB14hSomEPrXjDWA8mcZHwzMAjB6mj347SO/iSJZPgN8qVuZN7aiEcT5JrPJ/8MVIukH6ntO5qehl1UBr6d6iwUJ9QS9QbvBdUZyFP/wQQ/cuTyb3P3gElph19+vPYJxsNOT8H6RASoBYEtnXGBQ/U3nY7kXhhwaOI2vQWpr+sroUIHIm5PdvDfszeomk4MwpkpFc9ZRU1PkuwyEh5lrzXfsvK28TIwYzEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JM4Gz0V/pcZJ1u232n0DuEUc2N2uXYMdMrNM3a0f5e8=; b=riCjBLJpjVkngevTME+BY/YfJs3Xd6X1yqWsSvSsuV0dv0bbF2Rxq+xd4QUsGz/i8IlFJtFfc2e+xpjB3j8Uw64EX2iuBI83jpwqD9QCjE7wu1i1Wox0GGhQdKPRKgqJ16ec4Vg/RXsUMALdKjiRgHcW+7C27aIayxB+odAzJVQ= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB6PR0301MB2183.eurprd03.prod.outlook.com (2603:10a6:4:47::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.22; Mon, 4 Oct 2021 19:16:12 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:16:12 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson , Michal Simek , Robert Hancock Subject: [RFC net-next PATCH 15/16] net: pcs: Add Xilinx PCS driver Date: Mon, 4 Oct 2021 15:15:26 -0400 Message-Id: <20211004191527.1610759-16-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:16:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c5add22d-8bf8-4b1e-5083-08d9876b6d6d X-MS-TrafficTypeDiagnostic: DB6PR0301MB2183: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bb+Fz6IGRhNPFND9xnQljUau61KgCpdW9Y+reyXHJYkb7F9dE+0/rpNJceNXhXT1tgWb260n2TL+E+UrwSIvK+HyT0/ge2qO8hNJcjfjxYkmtmzco0UdS1+nU4TvQD51T/UnCF45grcP4nKUR3+fMV/Zdd055kwJ6QSVR6TGgIQrG/P2aIwSqanLIqBKIYSLy58vkGkw6gXHCBPekoyEvyxnAdFN3mOkxy2ChIThR60gZ4RcMa78K6mqTHyNwOLeOtTyP+edjYz5iN7SITSxAraQM8d5jOlbU8RLBKfc2AFbb3UyikVPwi3Yte+4/MlLtYwMdjYiGebBuCppKto6DPh7cMGuEDFjTZLhJeFUOp9a2VMmwO2URSs0i5JB56RpOuJn/05yLudmG5gGqLRR7yEiEWM+ZNq91s5MivDhEVgtJU/7zUHLLPGMnyTM+8sGSmxB+gEnZc0txhwzaQ3Day4k+nKBqRvJ99sHxuMI9Eamhvm15MOLFNVKPfE3eKqTJDWGBSnJ+8HgIhez4wKPBc3pyTZH/Hil9rO/TQ2Ni4wp6n7lNAGxv5YXeHkrNfgmvMkdocqPi0/hy5Z6hg3KTs/AR761xZ+M5rKvOnM7n2f0fjFAn71D/NHYvtvthKsd1kyoivJvtBT+zWGN/4pXtJDuFWbcsaerQWrYQicoEoaBY72T4nKiqtMenwjRh5I2srSolLFpTpZ1EezxFUUEAEvldfKN6JvUrOYuOqdNRC2yko5LIHVC2c3Y1Q9vC+Sd8sfTVxTl/rv3XE9EjoTTm4f4fuUaCU9FBh7qldfHRy8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(508600001)(186003)(30864003)(83380400001)(2906002)(54906003)(5660300002)(1076003)(52116002)(26005)(66946007)(66476007)(66556008)(966005)(44832011)(8936002)(110136005)(6506007)(2616005)(316002)(6486002)(6666004)(36756003)(8676002)(4326008)(956004)(38350700002)(6512007)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 50G30l6XOwdgfXTKuiKyx9sLso7A8vA5AE32M9Ct9ET1TpOL15qufcbTbrUMA3klbReWvUYXnexUp5h98rbpZI3Connvf99WilwxLI9yQh9BevkGwv7mKy9Ix035MricWSKxeIjcyt0JC/NtiYc+ocP7FsejSM+/D5VKWVhbg/6K2eKIrkXPrZ13DcUM0aSM12RLgFGFY9bU+UIA04NRUSPr/k4g0JAF4Ykf3xMVKYM/DfnHdDzAhSXGgDDq3l5ABMCv6x0iG7+ARuOEJZUgqR3lzlXYjx1kpK1/7G+FI1RJ9YigalbrfqnPAhKjMp+4Qqhj2WwDLol1ugwKn992FSDNhEws6XJ0K8UyVA8vjq5jcpmNCZqf5EDB8QAIjvOdmvh1Q6PzTPQeZXXoXEQg7JlEQ5Xu3IAyau0KDG3EGeYTkGdBCg0Akyo8RgOYKnog3lUfBAM+WWseMZC5+/PFe1mRIA7eQAOAl9bjbZYLmt/0Jhzj8TansvDky+67sZUOaVAVDp1+U5Tg9d5FoyX90xw13ULA1RYWzoWw7AECkYvDSlpD0vrINFXZ9/TUwnco9821hSMUV6bByX8IAvkG8FKM0Vp1IfNpanlbHtyxm0N90RiZZSMCbw53gXYPevxqv+rvfGmqY+/pPtIl9Lyt6fAIJ1mxFh0PIBCQZK+QPUVd5+Tmms+P7vvqZAqlA31MayVIkBq74fPcu+dvELo2mtrKTyCN+nfVW49mTS1dI+thOPAMLx3dlob47B9Fvqu+M7zMFOa0gmFaasIxl8Bk8X0ycIdUb5v6zo7U6sroJPqg7auFTBTCngS6ZnFV3VdD8mV0RgHRfXMlcGGDP7815LvOb2ZH74lYCqXaiRD3wH1qUhuSSiO+tdejpo6Id8N6aH384suJaUJcIB60proVb8f9IP8A3gLBRT8JHvaDMqkva1BwYdQmBGdugQfLszDdFn7tjhSRA/78VWpBhDfP8Pu4J2OQ2HwvFrPE00YKOR7w8Cm6V7Vl/1rlmb4vnmODJ0/Ofr06Pb6GWS+dIe4kW19SP8I666iZ/sotLNFdsHcjMwtKif5cOH2PsCeYSihR103VKk1uWJpjH2taWRQZIrNhPr5/NELKmjejYu9AL3RSf9hFARHNHzeOATMwcuO84FNzVnEMAuQgjbu9XgiwmrqHAgL4TyR4v8k4l7iIbSpzdIKPY8TykQfqnU/l9dUiiFZuml0P/Z5sssN/rUXJQ63+9jS8t2DkwjzG080GvYYoqv4zJL33nsj1dwoXZEztTDOzVtTiT1nEVjsRAOsxbiUaMwPSaNp6mt95dDR0e49o36QYFpDjIEPgh7tHizpx X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: c5add22d-8bf8-4b1e-5083-08d9876b6d6d X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:16:11.8488 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dDusAr09LsgmlAVIq/wxopcdyipnP5LVTZLUQRXhZ8KmMnPTKI/qvLxQB4RdKlcLZWz58/yksSDIEGzJv3IuEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0301MB2183 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This adds support for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII device. This is a soft device which converts between GMII and either SGMII, 2.5G SGMII, 1000BASE-X, or 2500BASE-X. If configured correctly, it can also switch between SGMII and 1000BASE-X at runtime. Internally, these are referred to as the "standard" to match the terminology in the datasheet. I am not sure how to handle the 2.5G SGMII case yet (since AIUI Linux doesn't think it exists), and I do not have the hardware to test it, so I have left out support. This device has a c22-compliant PHY interface, so for the most part we can just use the phylink helpers. Where we have to do things manually is usually just to set the interface. We also set the speed and duplex when the link comes up. I don't know what the permit_pause_to_mac parameter is for in pcs_config, so I ignore it... This device supports an interrupt which is triggered on link status change. While according to Documentation/networking/sfp-phylink.rst the mac should call phylink_mac_change on link state change, it is unclear to me what the PCS should call. For now I have just set the PCS to poll. This device supports sharing some logic between different implementations of the device. In this case, one device has the shared logic, and several output (clocks, resets, etc.) are connected between it and the consuming devices. I am not sure how to model this (create a clock? add a devlink?) so I have left it out, but I would like to include support for this use-case. Signed-off-by: Sean Anderson --- MAINTAINERS | 6 + drivers/net/pcs/Kconfig | 19 ++ drivers/net/pcs/Makefile | 1 + drivers/net/pcs/pcs-xilinx.c | 326 +++++++++++++++++++++++++++++++++++ 4 files changed, 352 insertions(+) create mode 100644 drivers/net/pcs/pcs-xilinx.c diff --git a/MAINTAINERS b/MAINTAINERS index 7f4615336fa5..eaee1028a7ba 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20591,6 +20591,12 @@ F: Documentation/devicetree/bindings/gpio/gpio-zynq.yaml F: drivers/gpio/gpio-xilinx.c F: drivers/gpio/gpio-zynq.c +XILINX PCS DRIVER +M: Sean Anderson +S: Maintained +F: Documentation/devicetree/bindings/net/xilinx,pcs.yaml +F: drivers/net/pcs/pcs-xilinx.c + XILINX SD-FEC IP CORES M: Derek Kiernan M: Dragan Cvetic diff --git a/drivers/net/pcs/Kconfig b/drivers/net/pcs/Kconfig index 22ba7b0b476d..3ee415504eeb 100644 --- a/drivers/net/pcs/Kconfig +++ b/drivers/net/pcs/Kconfig @@ -18,4 +18,23 @@ config PCS_LYNX This module provides helpers to phylink for managing the Lynx PCS which is part of the Layerscape and QorIQ Ethernet SERDES. +config PCS_XILINX + depends on OF + depends on GPIOLIB + depends on COMMON_CLK + depends on PHYLINK + tristate "Xilinx PCS driver" + help + PCS driver for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII device. + This device can either act as a PCS+PMA for 1000BASE-X or 2500BASE-X, + or as a GMII-to-SGMII bridge. It can also switch between 1000BASE-X + and SGMII dynamically if configured correctly when synthesized. + Typical applications use this device on an FPGA connected to a GEM or + TEMAC on the GMII side. The other side is typically connected to + on-device gigabit transceivers, off-device SERDES devices using TBI, + or LVDS IO resources directly. + + To compile this driver as a module, choose M here: the module + will be called pcs-xilinx. + endmenu diff --git a/drivers/net/pcs/Makefile b/drivers/net/pcs/Makefile index 0603d469bd57..4a8580ca4134 100644 --- a/drivers/net/pcs/Makefile +++ b/drivers/net/pcs/Makefile @@ -5,3 +5,4 @@ pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-nxp.o obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o +obj-$(CONFIG_PCS_XILINX) += pcs-xilinx.o diff --git a/drivers/net/pcs/pcs-xilinx.c b/drivers/net/pcs/pcs-xilinx.c new file mode 100644 index 000000000000..297c9881b401 --- /dev/null +++ b/drivers/net/pcs/pcs-xilinx.c @@ -0,0 +1,326 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2021 Sean Anderson + * + * This is the driver for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII LogiCORE + * IP. A typical setup will look something like + * + * MAC <--GMII--> PCS+PMA <--internal/TBI--> PMD (SERDES) <--SGMII/1000BASE-X + * + * The link to the PMD is not modeled by this driver, except for refclk. It is + * assumed that the SERDES needs no configuration. It is also possible to go + * from SGMII to GMII (PHY mode), but this is not supported. + * + * This driver was written with reference to PG047: + * https://www.xilinx.com/support/documentation/ip_documentation/gig_ethernet_pcs_pma/v16_2/pg047-gig-eth-pcs-pma.pdf + */ + +#include +#include +#include +#include +#include + +/* Vendor-specific MDIO registers */ +#define XILINX_PCS_ANICR 16 /* Auto-Negotiation Interrupt Control Register */ +#define XILINX_PCS_SSR 17 /* Standard Selection Register */ + +#define XILINX_PCS_ANICR_IE BIT(0) /* Interrupt Enable */ +#define XILINX_PCS_ANICR_IS BIT(1) /* Interrupt Status */ + +#define XILINX_PCS_SSR_SGMII BIT(0) /* Select SGMII standard */ + +/** + * enum xilinx_pcs_standard - Support for interface standards + * @XILINX_PCS_STD_SGMII: SGMII for 10/100/1000BASE-T + * @XILINX_PCS_STD_1000BASEX: 1000BASE-X PMD Support Interface + * @XILINX_PCS_STD_BOTH: Support for both SGMII and 1000BASE-X + * @XILINX_PCS_STD_2500BASEX: 2500BASE-X PMD Support Interface + * @XILINX_PCS_STD_2500SGMII: 2.5G SGMII for 2.5GBASE-T + */ +enum xilinx_pcs_standard { + XILINX_PCS_STD_SGMII, + XILINX_PCS_STD_1000BASEX, + XILINX_PCS_STD_BOTH, + XILINX_PCS_STD_2500BASEX, + XILINX_PCS_STD_2500SGMII, +}; + +/** + * struct xilinx_pcs - Private data for Xilinx PCS devices + * @pcs: The phylink PCS + * @mdiodev: The mdiodevice used to access the PCS + * @refclk: The reference clock for the PMD + * @reset: The reset controller for the PCS + * @standard: The supported interface standard + */ +struct xilinx_pcs { + struct phylink_pcs pcs; + struct mdio_device *mdiodev; + struct clk *refclk; + struct reset_control *reset; + enum xilinx_pcs_standard standard; +}; + +static inline struct xilinx_pcs *pcs_to_xilinx(struct phylink_pcs *pcs) +{ + return container_of(pcs, struct xilinx_pcs, pcs); +} + +static void xilinx_pcs_get_state(struct phylink_pcs *pcs, + struct phylink_link_state *state) +{ + struct xilinx_pcs *xp = pcs_to_xilinx(pcs); + + switch (xp->standard) { + case XILINX_PCS_STD_SGMII: + state->interface = PHY_INTERFACE_MODE_SGMII; + break; + case XILINX_PCS_STD_1000BASEX: + state->interface = PHY_INTERFACE_MODE_1000BASEX; + break; + case XILINX_PCS_STD_BOTH: { + int ssr = mdiodev_read(xp->mdiodev, XILINX_PCS_SSR); + + if (ssr < 0) { + dev_err(pcs->dev, "could not read SSR (err=%d)\n", ssr); + return; + } + + if (ssr & XILINX_PCS_SSR_SGMII) + state->interface = PHY_INTERFACE_MODE_SGMII; + else + state->interface = PHY_INTERFACE_MODE_1000BASEX; + break; + } + case XILINX_PCS_STD_2500BASEX: + state->interface = PHY_INTERFACE_MODE_2500BASEX; + break; + default: + return; + } + + phylink_mii_c22_pcs_get_state(xp->mdiodev, state); +} + +static int xilinx_pcs_config(struct phylink_pcs *pcs, unsigned int mode, + phy_interface_t interface, + const unsigned long *advertising, + bool permit_pause_to_mac) +{ + int ret; + bool changed = false; + struct xilinx_pcs *xp = pcs_to_xilinx(pcs); + + switch (xp->standard) { + case XILINX_PCS_STD_SGMII: + if (interface != PHY_INTERFACE_MODE_SGMII) + return -EOPNOTSUPP; + break; + case XILINX_PCS_STD_1000BASEX: + if (interface != PHY_INTERFACE_MODE_1000BASEX) + return -EOPNOTSUPP; + break; + case XILINX_PCS_STD_BOTH: { + u16 ssr; + + if (interface == PHY_INTERFACE_MODE_SGMII) + ssr = XILINX_PCS_SSR_SGMII; + else if (interface == PHY_INTERFACE_MODE_1000BASEX) + ssr = 0; + else + return -EOPNOTSUPP; + + ret = mdiodev_read(xp->mdiodev, XILINX_PCS_SSR); + if (ret < 0) + return ret; + + if (ret == ssr) + break; + + changed = true; + ret = mdiodev_write(xp->mdiodev, XILINX_PCS_SSR, ssr); + if (ret) + return ret; + break; + } + case XILINX_PCS_STD_2500BASEX: + if (interface != PHY_INTERFACE_MODE_2500BASEX) + return -EOPNOTSUPP; + break; + default: + return -EOPNOTSUPP; + } + + ret = phylink_mii_c22_pcs_config(xp->mdiodev, mode, interface, + advertising); + if (ret) + return ret; + return changed; +} + +static void xilinx_pcs_an_restart(struct phylink_pcs *pcs) +{ + struct xilinx_pcs *xp = pcs_to_xilinx(pcs); + + phylink_mii_c22_pcs_an_restart(xp->mdiodev); +} + +static void xilinx_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, + phy_interface_t interface, int speed, int duplex) +{ + int bmcr; + struct xilinx_pcs *xp = pcs_to_xilinx(pcs); + + if (phylink_autoneg_inband(mode)) + return; + + bmcr = mdiodev_read(xp->mdiodev, MII_BMCR); + if (bmcr < 0) { + dev_err(pcs->dev, "could not read BMCR (err=%d)\n", bmcr); + return; + } + + bmcr &= ~BMCR_FULLDPLX; + if (duplex == DUPLEX_FULL) + bmcr |= BMCR_FULLDPLX; + else if (duplex != DUPLEX_HALF) + dev_err(pcs->dev, "unknown duplex %d\n", duplex); + + bmcr &= ~(BMCR_SPEED1000 | BMCR_SPEED100); + switch (speed) { + case SPEED_2500: + case SPEED_1000: + bmcr |= BMCR_SPEED1000; + break; + case SPEED_100: + bmcr |= BMCR_SPEED100; + break; + case SPEED_10: + bmcr |= BMCR_SPEED10; + break; + default: + dev_err(pcs->dev, "invalid speed %d\n", speed); + } + + bmcr = mdiodev_write(xp->mdiodev, MII_BMCR, bmcr); + if (bmcr < 0) + dev_err(pcs->dev, "could not write BMCR (err=%d)\n", bmcr); +} + +static const struct phylink_pcs_ops xilinx_pcs_ops = { + .pcs_get_state = xilinx_pcs_get_state, + .pcs_config = xilinx_pcs_config, + .pcs_an_restart = xilinx_pcs_an_restart, + .pcs_link_up = xilinx_pcs_link_up, +}; + +static int xilinx_pcs_probe(struct mdio_device *mdiodev) +{ + const char *standard; + int ret; + struct xilinx_pcs *xp; + struct device *dev = &mdiodev->dev; + struct device_node *np = dev->of_node; + u32 phy_id; + + xp = devm_kzalloc(dev, sizeof(*xp), GFP_KERNEL); + if (!xp) + return -ENOMEM; + xp->mdiodev = mdiodev; + dev_set_drvdata(dev, xp); + + ret = of_property_read_string(np, "standard", &standard); + if (ret) + return dev_err_probe(dev, ret, "could not read standard\n"); + + if (!strncmp(standard, "1000base-x", 10)) + xp->standard = XILINX_PCS_STD_1000BASEX; + else if (!strncmp(standard, "sgmii/1000base-x", 16)) + xp->standard = XILINX_PCS_STD_BOTH; + else if (!strncmp(standard, "sgmii", 5)) + xp->standard = XILINX_PCS_STD_SGMII; + else if (!strncmp(standard, "2500base-x", 10)) + xp->standard = XILINX_PCS_STD_2500BASEX; + /* TODO: 2.5G SGMII support */ + else + return dev_err_probe(dev, -EINVAL, + "unknown/unsupported standard %s\n", + standard); + + xp->refclk = devm_clk_get(dev, "refclk"); + if (IS_ERR(xp->refclk)) + return dev_err_probe(dev, PTR_ERR(xp->refclk), + "could not get reference clock\n"); + + xp->reset = devm_reset_control_get_exclusive(dev, "pcs"); + if (IS_ERR(xp->reset)) + return dev_err_probe(dev, PTR_ERR(xp->reset), + "could not get reset\n"); + + ret = reset_control_assert(xp->reset); + if (ret) + return dev_err_probe(dev, ret, "could not enter reset\n"); + + ret = clk_prepare_enable(xp->refclk); + if (ret) + return dev_err_probe(dev, ret, + "could not enable reference clock\n"); + + ret = reset_control_deassert(xp->reset); + if (ret) { + dev_err_probe(dev, ret, "could not exit reset\n"); + goto err_unprepare; + } + + /* Sanity check */ + ret = get_phy_c22_id(mdiodev->bus, mdiodev->addr, &phy_id); + if (ret) { + dev_err_probe(dev, ret, "could not read id\n"); + goto err_unprepare; + } + if ((phy_id & 0xfffffff0) != 0x01740c00) + dev_warn(dev, "unknown phy id %x\n", phy_id); + + xp->pcs.dev = dev; + xp->pcs.ops = &xilinx_pcs_ops; + xp->pcs.poll = true; + ret = phylink_register_pcs(&xp->pcs); + if (ret) + return dev_err_probe(dev, ret, "could not register PCS\n"); + dev_info(dev, "probed (standard=%s)\n", standard); + return 0; + +err_unprepare: + clk_disable_unprepare(xp->refclk); + return ret; +} + +static void xilinx_pcs_remove(struct mdio_device *mdiodev) +{ + struct xilinx_pcs *xp = dev_get_drvdata(&mdiodev->dev); + + phylink_unregister_pcs(&xp->pcs); + reset_control_assert(xp->reset); + clk_disable_unprepare(xp->refclk); +} + +static const struct of_device_id xilinx_pcs_of_match[] = { + { .compatible = "xlnx,pcs-16.2", }, + {}, +}; +MODULE_DEVICE_TABLE(of, xilinx_timer_of_match); + +static struct mdio_driver xilinx_pcs_driver = { + .probe = xilinx_pcs_probe, + .remove = xilinx_pcs_remove, + .mdiodrv.driver = { + .name = "xilinx-pcs", + .of_match_table = of_match_ptr(xilinx_pcs_of_match), + }, +}; +mdio_module_driver(xilinx_pcs_driver); + +MODULE_ALIAS("platform:xilinx-pcs"); +MODULE_DESCRIPTION("Xilinx PCS driver"); +MODULE_LICENSE("GPL v2"); From patchwork Mon Oct 4 19:15:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12534589 X-Patchwork-Delegate: kuba@kernel.org 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55603C433EF for ; Mon, 4 Oct 2021 19:17:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3605C61163 for ; Mon, 4 Oct 2021 19:17:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239051AbhJDTT1 (ORCPT ); Mon, 4 Oct 2021 15:19:27 -0400 Received: from mail-am6eur05on2057.outbound.protection.outlook.com ([40.107.22.57]:12353 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235428AbhJDTSt (ORCPT ); Mon, 4 Oct 2021 15:18:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NuvbJ7hXMa0Ma7nYmWzRmdNA0r3W9fjzgWSRvE1OjY/lV9fKC29jjoXHpC13mffoyQ0KDkPrdb1MxLzPISZjIjQxZJNPW8W56VFAakiWMuDrGao92Eow1yKtjnEIQVQUZ/HsP4/7WQINEdaoDWmCnaJ1aqgkxDRW+AB1Pi3+eozqg8V4DS1rGSyBi1d9dyj9idvFFMDCgw5VKx52u7fsXmnlqb2WbV7vFmYyAIZFZkP4APdZcPYT0QHCJ9YOocVvGgmaZ2BpXcwbsJnd1Dw2/GMtP/0jZhwGsbR3jaltKcBmYJTW0iB6/m3eqmt1nc2kdwYSRvxvG8yhxdoZFDzffQ== 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=Z4bBuZ/vP65aPiqKv60GuXTqaKsZnUjlk6Au5WgResk=; b=OefMocCrTpW4zSS1gzjmpUy0Z996i4E4kuyn2Eqz/AKzkx2RoDvo/osErZwrnkqSY45dRWsPD9uoll0xwn/gjWIca5sTUonrpCg16/wmnHott5M5xuGdYoQin0fKojTXP+436y3g1TPHc3611vtQPmos2d3pEv8tPSiTicMuHmRjPgc11zlFLhZZo3/9PxmBPoveC8bC+5ME5Zgns07a5+S1FCN3sf3ko6aqLeZSWtrS6wFeNqWqLkRer8HWCeV79w7sFTXXFcoFT4h68mb6AcEeOPvviFkjjPL1XdyNVMNPSOzylN/Zn+RYSUG67x8AIsQPJdApb3S618ZVNGjpXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z4bBuZ/vP65aPiqKv60GuXTqaKsZnUjlk6Au5WgResk=; b=iiXOF3XI2FWh6HhZBvoTcety7kSDt2lIcr7O0Ik5ABndDJJby6hUL90mQP/Q0LSNlgtMFJ/VMkkgq5owMj3iJvuL4TlEk7bfrrl0+27uS+jcvLYVWsqaH7XuDw440lK8uzsfauY7atPhBg3QlgDcLGobG2tESwGzEm2+T/91f4E= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB6PR0301MB2183.eurprd03.prod.outlook.com (2603:10a6:4:47::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.22; Mon, 4 Oct 2021 19:16:13 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:16:13 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , Sean Anderson Subject: [RFC net-next PATCH 16/16] net: sfp: Add quirk to ignore PHYs Date: Mon, 4 Oct 2021 15:15:27 -0400 Message-Id: <20211004191527.1610759-17-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004191527.1610759-1-sean.anderson@seco.com> References: <20211004191527.1610759-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 19:16:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b36caed-e8df-4475-6fcd-08d9876b6e4d X-MS-TrafficTypeDiagnostic: DB6PR0301MB2183: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WfyMG1Y+HZHXAsKXQ/ejFlIQxp3hmR2XACxvR1wyxpeMH5qX7D4Y5jiE0SEvt1swq1L7cD4ol4hDayPFhkTduEKb1UAQaeJa5UTuG+Fh/Q3ifL7SpqwcppcgzG8EN8a4X7QSbaJU4UapYN8t0Nziy5b7D95tr24gIdgufdUDdwaDqbfeqIVljrrdqmm87ymH/zd94nH7R/102woMIaqUkoNoP/WOv6K56pNDhh54wvnjp3M0Q8ZyCg5HFzPReoZalRKdxuGYVVTb6tTDMxNmoXxTteav+WpfXxadpBw6jgy4K66Zlj7sSig5cC9/Y1WXaSxiufX7rKsQMvHNUSaVprppsxaCNCVIjaYqNJepUzfjskureLO2QtNGqIpBtCarYDQoUY+GLuHAbuIiJM14a11sZSoakP6pwxBqct0MD9FfBwquys06LoI6ItWDpBpqP3PuMvJg7cuBTBdPPPKlLV4PGuiMTZoQc4hi4x6pQhh2vzQKL2/45kjmVpBDDHpkLpegxmYXXUzK18dB0LFGt6ONxxjKsF4T366TWmiY+f7K45aBr8JFz0f2HE2+mR2zjImLEnHLwPpqA4omFeoOa1KUwQqHctWkNd6eU8iT4iTTQjC3Jk1Vqz8HhP2HTx2wRSuhuYhV8mPkBTl7eMQJARU97tyW9Gm2gs78wqp+eCc1bF4G0XxYGzkvAcXFNjwzM2zh/cHmNIfEonD8EWTxYw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(508600001)(186003)(83380400001)(2906002)(54906003)(5660300002)(1076003)(52116002)(26005)(66946007)(66476007)(66556008)(44832011)(8936002)(110136005)(6506007)(2616005)(107886003)(316002)(6486002)(6666004)(36756003)(8676002)(4326008)(956004)(38350700002)(6512007)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KPa9KC6fOXkGQ66Foa87shBA6BfiCv4ATnlCc6txsD0SavuXgHvR41AwOrXwKTfwwCCx+9Y5ozDi6HUL65j1X1lRu1rzB7hrGKA45VEnKbyKkvFKcc3u2+cuY707AAp0mVrvMUPezJDxWJKug5dm8u+cOIlgLxhfWR0ooaV5D4MT39pksY80GGRAwN1Z43K+LpdoTnptQDJdMoUcevmFHCS4ygfr05XwYBanR6INTsOYD4/08Z4oKRDYyhmfSVqgW8cbz+IXZ/b0SnJ81TTq22QcFc/ofr0eyw6cc+DynZVOrZdqpNz0hFpfuRLvbLFH7VhyxMWpKgR/TzFB/EgbNRUxTVW1kZ51PJ9OUXyt2M/KQ+l/AiFEck/F5fRTXJqDMwfH4F5iu6MiHDiKNvl44s1B9yhOBypkr4cgnd43fi3AGmRSWMO5QCan0C/pBPriVs7cQ33+n+P7feJyhc29NCkzgQlDc9BldbVk9qGQyZrpSdU0bsx42L6rYy8gaEhvndF8zJ20Ei3H31intZrr887TCoRYjukiHZgm4V1QB/F7o8QT+klpFRL/cA/H2tMLiLazfHIhSBRpRVyxZT1XfvvekiLp6akA+OOIRLGd8seuwm+BLSwG5IBQyLm6b6ysQ0p1Xdsm7DNb09pQ5UF8InX6gu5VAKHUCKo0wXMytsoDPuAQZe5HqvQB1ltBJ2zHR0lezn/z979vdUE4PRCZZuP49L5V+gqil1RZZ0NyulVw+enG4UXC8m7jCh1yG5muo9SwFpsCBdsXepwE8uXhzBoKyrds/LVon+y6/p6HhDZMcrsqtQGN9Lj5ydOw4gdFt7FNM8W1NCszcsc1rAsEU2lLnxgxe44bAELOwKeelqIZsbvNIveMhAOrvrJb7xyQaCqR3S2/AAUKA5ZXGWAJBMBxe6xECEutgLGvhclUprK/xOIy96qMBUxPTNHVGCV2oSR7H7XoeWXFdn9SN+KVq8M32LM+2X/phe91IQkolUfJG0+8IDhuHSP0wXet0JELw/LAVGozfAd2AQd2b0lJ8fOFYt3WWv0hAm4WEMhVqakMymE70aRwNLiFBU7PvHOnB0vKF6lPJqzESKDFRGDalyW3vT4LtiLZZcDYI/wPqEwgrwTFRUnKebfSmmCAMjRXgIC2LTJuelonjti5Dfa7gpymhY4JiX6DoOteAKUQ99swlks/YtjhJ/DYDv8Iel3UlIKY7+bh78IuX68zBi1pn6Gx+hmw14Ei3OIIZqW3TofXERJm0ItKESEGnzZN3li56YVs6e+JD0zlcmdHJZuFji/MT3b1m6cL+TnsrtrZnw67qNjht4a+91c5L18AlK/A X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b36caed-e8df-4475-6fcd-08d9876b6e4d X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:16:13.2997 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: X9K6uMdKSguVsyfueiBmWwhOiVfox713ty+kKEypJtx4TZZabygYAxx4ZheIGcZaeIPgPGF38GRBmzdmXPW+kQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0301MB2183 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Some modules have something at SFP_PHY_ADDR which isn't a PHY. If we try to probe it, we might attach genphy anyway if addresses 2 and 3 return something other than all 1s. To avoid this, add a quirk for these modules so that we do not probe their PHY. The particular module in this case is a Finisar SFP-GB-GE-T. This module is also worked around in xgbe_phy_finisar_phy_quirks() by setting the support manually. However, I do not believe that it has a PHY in the first place: $ i2cdump -y -r 0-31 $BUS 0x56 w 0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f 00: ff01 ff01 ff01 c20c 010c 01c0 0f00 0120 08: fc48 000e ff78 0000 0000 0000 0000 00f0 10: 7800 00bc 0000 401c 680c 0300 0000 0000 18: ff41 0000 0a00 8890 0000 0000 0000 0000 The first several addresses contain the same value, which should almost never be the case for a proper phy. In addition, the "OUI" 00-7F-C3 does not match Finisar's OUI of 00-90-65 (or any other OUI for that matter). Signed-off-by: Sean Anderson --- drivers/net/phy/sfp-bus.c | 12 +++++++++++- drivers/net/phy/sfp.c | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c index 7362f8c3271c..0b79893a79ea 100644 --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c @@ -14,6 +14,7 @@ struct sfp_quirk { const char *vendor; const char *part; void (*modes)(const struct sfp_eeprom_id *id, unsigned long *modes); + bool ignore_phy; }; /** @@ -68,6 +69,12 @@ static const struct sfp_quirk sfp_quirks[] = { .vendor = "ALCATELLUCENT", .part = "3FE46541AA", .modes = sfp_quirk_2500basex, + }, { + // Finisar SFP-GB-GE-T has something on its I2C bus at + // SFP_PHY_ADDR, but it is not a (c22-compliant) phy + .vendor = "FS", + .part = "SFP-GB-GE-T", + .ignore_phy = true, }, { // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd // NRZ in their EEPROM @@ -204,6 +211,9 @@ EXPORT_SYMBOL_GPL(sfp_parse_port); */ bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id) { + if (bus->sfp_quirk && bus->sfp_quirk->ignore_phy) + return false; + if (id->base.e1000_base_t) return true; @@ -370,7 +380,7 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, phylink_set(modes, 2500baseX_Full); } - if (bus->sfp_quirk) + if (bus->sfp_quirk && bus->sfp_quirk->modes) bus->sfp_quirk->modes(id, modes); bitmap_or(support, support, modes, __ETHTOOL_LINK_MODE_MASK_NBITS); diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index ab77a9f439ef..35c414eb1ecb 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -1512,6 +1512,9 @@ static int sfp_sm_probe_phy(struct sfp *sfp, bool is_c45) struct phy_device *phy; int err; + if (!sfp_may_have_phy(sfp->sfp_bus, &sfp->id)) + return 0; + phy = get_phy_device(sfp->i2c_mii, SFP_PHY_ADDR, is_c45); if (phy == ERR_PTR(-ENODEV)) return PTR_ERR(phy);