From patchwork Sat Sep 23 13:48:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13396764 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50B771BDDA; Sat, 23 Sep 2023 13:49:32 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44C671A5; Sat, 23 Sep 2023 06:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GdbFsbOjx7DB6aazzpGNBagMAWV2z6aQ/1FwX3kTBMnE1K9ifS6vB0SureYgTeLj170NVCYTtgGsdI2Mo1KmRUPL0ckICjsr6O9a+FUY3v+cwKRdTDrNRQLxlHJHg9Rw6l1XFjTlwoVa14oe2PJPEgoQ7HMaJ0Dc0MtbMQXXpkSbQ0VH5aNl9KJnkIrecmZKaaRcrWxzZ3Y/k6I3YYZR/5FcA2vEPSZh7hnJJ+7X1ev1ooZB/veM3ALbHu+8jozf7eAPI88GEA/JXv0/PVhVJW+pjt6vohPIQ50JRtJs27QdS48KWINoaHAZQ8vSQu5kf3IYjsR1KzVTZmkNLfm0mA== 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=5vY9X0usskXKpLQcnQGAHoEgjxFUewnZMRLemH6ly+w=; b=hrgXd+Qa8MUOuOSJKoSncjWUYp4kojlbJ+VDgGZHIq9LMVUUjWgUcjZNKT+Izi2XjeRo6CfLpKkUxALQWbpYsFnztNwTOoXd1xfCqvunVf4yQ1yGah6hcN1TmsAiJObj8LYWQhKTFJubZaf23ddglmI6jF+TRgKMlDGr8Q6a/3u30av4UMy5i+OlelFxDuZDArVD1Q0j45K6vF0exj8PfzqFZ26U8RlKh4EvPQy13GTbVXRKZqChlb5m1UZjO03bOX6HJqnqwmgJrFwjcD48v2crvkAxIfL4ykuqCDcmdevaoAygqN7sc61K/SZiWcZn0+Q6hz4LT2Y+RIcS4K90NA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5vY9X0usskXKpLQcnQGAHoEgjxFUewnZMRLemH6ly+w=; b=qB5wW8SqQfQONuS4pStOTgYnb2yym+fg0nD4Z0wENrjp9k85U41RQZX97FSbnel2ceCIwP0ND+WiGo4qw+cI4bGdZdCN7y7a2Wic3sZZujKeecx+jvoL++mpKLYucTDRuYmDKBgaLS9EKXyMmtzMXv2ltnJDHV5LpDD4gdmAdBE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS1PR04MB9454.eurprd04.prod.outlook.com (2603:10a6:20b:4d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 13:49:27 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6813.024; Sat, 23 Sep 2023 13:49:27 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH v2 net-next 04/15] phy: allow querying the address of protocol converters through phy_get_status() Date: Sat, 23 Sep 2023 16:48:53 +0300 Message-Id: <20230923134904.3627402-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923134904.3627402-1-vladimir.oltean@nxp.com> References: <20230923134904.3627402-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS1PR04MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: 11e97d8b-fd6a-40fa-a83f-08dbbc3be70c X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iWNzmBY2sZVJJGtTFhZNJcuT1yXmrnFcEdTzjX5pi7YXQDqhLMxp3E9LfAK2FYco1San/qxnCxdHV9+0uufPlpdrribo7LjIUJAUl9kbRyIUkDxgGWSKHJbzMJVOabEDf4jzrPraghu1vcyFHTjQP0KnBUX8JM9a+D4VFAVuVVuXnbn8iIaJ2SDG5RUwR6Yjeih/hzHGPIzvm50+eMgfXgdSZJVXbcMIJoBRTtzQoopLikD1p5bwFKVmqsRfb135ufM30g0sKLIx9lSVH6YRA7qb3B53/lxEPv8WCvuLCc+hP11voaTw1V7F4rLgjreMXGdbz5M9WHkdKCe45py5PRtAVYLQimNDz2pGCRPMp3NPQUMe8xPWcuAwAuKzRDHvjIoxfkxbPLI2lUo1UTMJIH4VaAEAuPLWncf5PsHH4ujGUQyC66Pd7igXUVrap5TxsT1e+NEltRsdV7fg6bAe6/FZoSy9TYL5diilzhW/0g0s2j98quVkjZzDDEonRCBeBVnZtFJ//y66m5XGoE0/ljixnotv/tzSZ2qpHQc+w6cG1+AZWRTlN43eyhE/fBNd+qxTDj7awRFBohfHiEPCtGtAMkFwIgwV3oPUyog0BKJgFGFMeCtM+nKGcKzjs6e8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(451199024)(186009)(66556008)(52116002)(2616005)(6506007)(6512007)(316002)(5660300002)(66946007)(38350700002)(6666004)(478600001)(1076003)(66476007)(26005)(44832011)(2906002)(4326008)(36756003)(41300700001)(7416002)(54906003)(38100700002)(6486002)(8936002)(86362001)(8676002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GVUfj2vFfBEu+jR/WPmo37tC/4h9xX/OtLEfmF7RUKydKH23VDbZL1agbVQISFv3HeGCiAe8IZPc72woJCBdrlaNe0pK3SeL9kLbGUTPd2sHrO/SO/dmqUNsJM6rdlVZmyxlICloThQLnh3f88PkGydroTuks4opjL6qbJlH8mBpJwgO33U8AGEv2oZERvdZOM2EQ69rbRpjfyiSbSNjm4HuVxtDGt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DDWe5Tl1ZN2NnHt7cijvcMMm5P21xvqWQEOk1rQ7RXE2HkK6pynVoTpVaKUXd6dJKoM8rrWm03iYlcBZgivRVAOWbxcmud4Wd+A58O/TMB8I1HXlCwrIYv+JvzyAsbU5vj5iVSOVRIvADjZg2MeGyDTg2vdnHDSvfZLrsWJlBcPkRiOby/VAKR0ftBrLf2K0NgmLaMJ1AzRYOyv5f3NIa+dY9otLXRSB6A0NrVOAkEVOq7OwAvwBYr2Y/DdbkOOnVpmZ0nO+F7YAcLUteBm/FCEVNss6I7AXzsE8dywJ1ryQQ91MgtUPJm+nLUadbWc6bpQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11e97d8b-fd6a-40fa-a83f-08dbbc3be70c X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2023 13:49:26.9984 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: l+B8SSMcfwA6PPASudIaOCjpU9rmfGhOihqkByKF/YDkaYIyPyAwwGqbBFrt8wSnBQYmdwc+ISHDyYiav9KCmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9454 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The bit stream handled by a SerDes lane needs protocol converters to be usable for Ethernet. On Freescale/NXP SoCs, those protocol converters are located on the internal MDIO buses of the Ethernet MACs that need them. The location on that MDIO bus, on these SoCs, is not fixed, but given by some control registers of the SerDes block itself. Because no one modifies those addresses from the power-on default, so far we've relied on hardcoding the default values in the device trees, resulting in something like this: pcs_mdio1: mdio@8c07000 { compatible = "fsl,fman-memac-mdio"; pcs1: ethernet-phy@0 { reg = <0>; }; }; where the "reg" of "pcs1" can actually be retrieved from "serdes_1". That was for the PCS. For AN/LT blocks, that can also be done, but the MAC to PCS to AN/LT block mapping is non-trivial and extremely easy to get wrong, which will confuse and frustrate any device tree writers. The proposal is to take advantage of the fact that these protocol converters *are* discoverable, and to side-step that entire device tree mapping issue by not putting them in the device tree at all. So, one of the consumers of the SerDes PHY uses the phy_get_status() API to figure out the address on the MDIO bus, it also has a reference to the MDIO bus => it can create the mdio_device in a non OF-based manner. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new include/linux/phy/phy.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index f1f03fa66943..ee721067517b 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -56,6 +56,33 @@ enum phy_media { enum phy_status_type { /* Valid for PHY_MODE_ETHERNET and PHY_MODE_ETHTOOL */ PHY_STATUS_CDR_LOCK, + PHY_STATUS_PCVT_ADDR, +}; + +/* enum phy_pcvt_type - PHY protocol converter type + * + * @PHY_PCVT_ETHERNET_PCS: Ethernet Physical Coding Sublayer, top-most layer of + * an Ethernet PHY. Connects through MII to the MAC, + * and handles link status detection and the conversion + * of MII signals to link-specific code words (8b/10b, + * 64b/66b etc). + * @PHY_PCVT_ETHERNET_ANLT: Ethernet Auto-Negotiation and Link Training, + * bottom-most layer of an Ethernet PHY, beneath the + * PMA and PMD. Its activity is only visible on the + * physical medium, and it is responsible for + * selecting the most adequate PCS/PMA/PMD set that + * can operate on that medium. + */ +enum phy_pcvt_type { + PHY_PCVT_ETHERNET_PCS, + PHY_PCVT_ETHERNET_ANLT, +}; + +struct phy_status_opts_pcvt { + enum phy_pcvt_type type; + union { + unsigned int mdio; + } addr; }; /* If the CDR (Clock and Data Recovery) block is able to lock onto the RX bit @@ -71,9 +98,11 @@ struct phy_status_opts_cdr { * union phy_status_opts - Opaque generic phy status * * @cdr: Configuration set applicable for PHY_STATUS_CDR_LOCK. + * @pcvt: Configuration set applicable for PHY_STATUS_PCVT_ADDR. */ union phy_status_opts { struct phy_status_opts_cdr cdr; + struct phy_status_opts_pcvt pcvt; }; /**