Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp343986rdh; Sat, 23 Sep 2023 13:01:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgA0f9sZifeY9IAI8zqT3axR6H7InvKZcsvW3wNy6kg2ELIbj19I8pH/jBjOxjf8AvSrp6 X-Received: by 2002:a05:6870:d68c:b0:1d1:2605:bb0a with SMTP id z12-20020a056870d68c00b001d12605bb0amr4148431oap.26.1695499314470; Sat, 23 Sep 2023 13:01:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695499314; cv=pass; d=google.com; s=arc-20160816; b=E58OHDGLTA6kZvnMbBqWnksLdFG06HNoYsAPSKmPkCNH/Nhboz9EbblgdW/cXIxDc5 YKI18KUEDpxjwZDqHw+u7ig82BBJzXaKR2gse+c1bED3ydQO+RrldBbvzVW1jKhta1CX R0rIPaUCLmKkaqMGpnmkVoNSCykhpWzxmb3pnR7VYGs4XvXIRNeXGTQdOdl1shY7gA0c RKd10hICK2jSGntmCAeOdeGB4Oxj4antG8DOOO1FMctWx5h9R4qIOz64a6zOYdda3DR2 J5xs7a0UoBFSqBA/6B/elRWBCadbMgZfs8ZJysthHj3+92uEDf/v3nXX4LEN2/7bizun qwOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5vY9X0usskXKpLQcnQGAHoEgjxFUewnZMRLemH6ly+w=; fh=sSbSqKsgQl6bZIJ9lyFWPlnKSNp5H5PO3vcPlNDguAg=; b=Ly+ENElo3NjHB0Mgf45gzQ989CihSleCqL5QIraIGPwx3K0HSVx/1cSf0ph3ENs5aJ REeXSomErP5txAC69POP6NzWXowRDHJ1SD4N5JQQCH1GXOYwgorMlzWFAlqbwjH6/LQk rlYy2lC7rg8JvGi0cnwnyeEKwy5ZQc4HOfNHyr91j7MdhJ2gj1GNumbYqyIWVWmHyQRX 77j4sShmul7eyKpsP9TTVcSzfvi9rhzx/rNe3U/eeOjhp+6lpEYF0yK9iPyurDiXAlfj iDWl9I1yTOI4HD3sJRpPfmpY996s0YYIUd0yEKTj14QHH3WwrqqhBc3SoyBxZDUdEWMz 9dyg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=qB5wW8Sq; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id b13-20020a056a000ccd00b0068fef37e5bdsi6697656pfv.244.2023.09.23.13.01.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 13:01:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=qB5wW8Sq; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id A94C68535F00; Sat, 23 Sep 2023 06:49:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231307AbjIWNtp (ORCPT + 99 others); Sat, 23 Sep 2023 09:49:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230212AbjIWNtg (ORCPT ); Sat, 23 Sep 2023 09:49:36 -0400 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> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) 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: =?us-ascii?Q?GVUfj2vFfBEu+jR/WPmo37tC/4h9xX/OtLEfmF7RUKydKH23VDbZL1agbVQI?= =?us-ascii?Q?SFv3HeGCiAe8IZPc72woJCBdrlaNe0pK3SeL9kLbGUTPd2sHrO/SO/dmqUNs?= =?us-ascii?Q?JM6rdlVZmyxlICloThQLnh3f88PkGydroTuks4opjL6qbJlH8mBpJwgO33U8?= =?us-ascii?Q?AGEv2oZERvdZOM2EQ69rbRpjfyiSbSNjm4HuVxtDGtHqKnH2WpBqlXc/ovYG?= =?us-ascii?Q?7M0oY6sqz8LmPpg89sik3rt7158b9HO7Jt2mdprV4E0SdvmKn7HzN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XZDyWiN4rlgFZYyVzMB8PVjIAL8izuOA?= =?us-ascii?Q?4DQUajpCTDcIaP8qirEtwyJ8p2CJ2IGsLl7e7dGhV2Y6yMST7kj+Sl6kWAJO?= =?us-ascii?Q?CLLu8vo9JThxERg3VrrqEjZl4CToP6pIJB4Rz9oDDWe5Tl1ZN2NnHt7cijvc?= =?us-ascii?Q?MMm5P21xvqWQEOk1rQ7RXE2HkK6pynVoTpVaKUXd6dJKoM8rrWm03iYlcBZg?= =?us-ascii?Q?ivRVAOWbxcmud4Wd+A58O/TMB8I1HXlCwrIYv+JvzyAsbU5vj5iVSOVRIvAD?= =?us-ascii?Q?jZg2MeGyDTg2vdnHDSvfZLrsWJlBcPkRiOby/VAKR0ftBrLf2K0NgmLaMJ1A?= =?us-ascii?Q?zRYOyv5f3NIa+dY9otLXRSB6A0NrVOAkEVOq7OwAvwBYr2Y/DdbkOOnVpmZ0?= =?us-ascii?Q?nO+F7YAcLUteBm/FCEVNss6I7AXzsE8dywJ1ryQQ91MgtUPJm+nLUadbWc6b?= =?us-ascii?Q?pQ=3D=3D?= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 23 Sep 2023 06:49:44 -0700 (PDT) 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; }; /** -- 2.34.1