From patchwork Thu Feb 18 05:26:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 384781 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2FC8C433E0 for ; Thu, 18 Feb 2021 05:29:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 76BEA64E79 for ; Thu, 18 Feb 2021 05:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230335AbhBRF3v (ORCPT ); Thu, 18 Feb 2021 00:29:51 -0500 Received: from mail-am6eur05on2057.outbound.protection.outlook.com ([40.107.22.57]:24352 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230211AbhBRF2y (ORCPT ); Thu, 18 Feb 2021 00:28:54 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QOG+rQXv2+dGcWpB9FRmD0iQnemootuHT13OFrSUYFqBHiKOy0y7P7x+y57eaINDO0doHmXnK/oEschtS1eGwlapJ2u79Mb61NZJXGwvn+2owEPFInc3pM4xeVSYu8UxojgBLuAqW3qfftgRkQmhomwwUBGEtPNE7ebilG/Ii+JL7q+TALefnnH/8BpyVq3NKttnD3pnG7G2rI/Rs2KGHzaa8RvwbOuJEJKep2WjHog7ccqitPbml5+mLI6f3b1sXQS1Se0iSnQhA1K3gNwc7HWpB/g5xXux1kmEGCeWzqoslfY7PLUwzmXjKk8n6hwBRDIvMLtH+qi7AYQyaPxOeA== 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-SenderADCheck; bh=psdIIdC5o86VoFSAPcW+NYKghds32St8M1Sjrzx6zwk=; b=kUaoXhbiWrRVh4qciarrQcXpio38XTjOvTgOHANo7EiQszmX2VPe0F4TnJhpL/JmBLyygZdSrXRXGpyqkcGdDvtkNSUgSlIf/6vixrY8nwtkb9kD2NGnZIrW+8xenbYAyjTpoegVy8/oCqQV3EH/yB8f1fXwDAMPtSIpi3OHc4ZF0UxqDvFgKnqm2lYwaAPadaT7u6aylo9IA3BxCo9kYmwT6ZTRkO9cgB/JbrmvrVDPSX1TvhNyzm0Hj77RpxKuVVpULFtDqUOgdhukDuwYsDAs2CDG7Zutj2B2kFMFCO+pXFR/OOuA1M5x2Nb92nSoSpvvh3FSvxjAYyZ3I4232w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=psdIIdC5o86VoFSAPcW+NYKghds32St8M1Sjrzx6zwk=; b=K7MSogCyHL9CtOptV/OUs8xZaKUC4VIMHA42lElSCrc2u4SuA2cSevyC9N6ANaW1ccAeFcbkS+t8KdmzJogLc0gvRVbROZLQg2lIH/IMf14U0GJgOU7xfy+8k2TNegtzRCECsYX6hggjhf+VLgGhpbKGeqzVIhVo9APn1aJ3Tz4= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none; arm.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) by AM0PR0402MB3442.eurprd04.prod.outlook.com (2603:10a6:208:21::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.42; Thu, 18 Feb 2021 05:27:32 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42%6]) with mapi id 15.20.3846.042; Thu, 18 Feb 2021 05:27:32 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, Laurentiu Tudor , Diana Madalina Craciun , linux-arm-kernel@lists.infradead.org, linux.cj@gmail.com, Calvin Johnson , Len Brown , "Rafael J. Wysocki" Subject: [net-next PATCH v6 01/15] Documentation: ACPI: DSD: Document MDIO PHY Date: Thu, 18 Feb 2021 10:56:40 +0530 Message-Id: <20210218052654.28995-2-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> References: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) To AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03152.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 05:27:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9b0dfb8d-6112-4766-64ba-08d8d3cde402 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3442: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fwZjy3mR7XVObJfC9tBlY9YFvGHHBjHojWEk/qV3tv2f9WvsBrKjQQ3UfhE/S38miEFDl1azH13dnPC8fPkg0pgklwM8+OFVoBIILArOODcO9QsflmUtTDJZcCo2nu7LeMlvUwVoUBzvJsmsUiCD2W5h7RsZKruzFob2bZkKHE26IHEbyyWEOg7MV7O+abCcMY82IX7kUc/1bSKatgHj9NtNgohmifNsUQR2lJ7kH4dJtK6wW31w6lFWMESvZqgs7KRl77Pogbvi5rGM53us8doa/AIgcsGqRnfo1W+elrLBGzpUK1rpY4IICBF7XXSdMBv8pnbjn3T1Xt+rYEdSl3xA8LwPQLnWhwdZT/2MYAx4HlJoTqvHOmYuCvugf/o2kd13EDNEtodMAyFJHG80GsxwPpQfnGIrnVUwxD8qbjBimfG9EumL5mLRVM/oNtOpFJbA91Xv46NZFIeN3r6Tvj3cvOfanQjG02bV8K/PFfevPlHSSG1bcszb09EuaUbzs2mc4PJwIQTT0TYK0ko2GlOAuIY2HwlI1AseGa6xabWLRne3oZgaU33rPu1WXprUbsIGULKxlFH+WuArPtjHZuvVbqpEhEWu0nI3QgSpNugGlREFzgta7F/u32YuqdOjJqv85NZR0rMX5CF02Yrwe81QAij/h3uTci9IDwbHan0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(136003)(39860400002)(376002)(396003)(44832011)(6486002)(26005)(7416002)(16526019)(110136005)(956004)(2616005)(186003)(55236004)(83380400001)(1076003)(6666004)(4326008)(316002)(1006002)(54906003)(8936002)(5660300002)(921005)(2906002)(52116002)(478600001)(86362001)(8676002)(6512007)(966005)(66946007)(6506007)(66476007)(66556008)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: bz2omJtklhn6s4o+MH4Ck2n4mxPK5iJ/gQsauzwMhgjbwpAKDAgZE/gkdJjuAErCwSzj+QRVwapVsURr1jkh+qW0Gkqswzgk0Oe3vI5q5dlvHRtvWVn85munZ272HdaC9GrHh/HPwRrQ2KojAeNRccvz4397oCfYpY1Bvba+QYL/1aW3eMg7NojUtp4IxDAvgRTgICCeXovY9yCxBqBkzV94FqiWxrhWNLy4JLl1gZLbh/VP3lDF198JUpFzsM/uOx/XLmIKv52OIyz/eJjrAS36YBAlllW6+OZq3wYuBQ50Np8qkivQNJIJe7rc7EFFlKsyMZ+LbgQ4AR/sL1nmMJDYijlfY+kDt6dmcwBo3P1wlL6cu781Pm0mWUSqZ/2lEyi85U2XDwsn5f1PI62Ek9pU8ot1LjS3bcdHEFPvjFImAoj5m0G1lf27YWs1hxH1E4P2NddeKfuvsQBKZswbkU7pia2D0n9ZMKcombzv1mJ4fn1NsBEAcMudcEwxUMCQxnc+fP20Yh+Pu7ipJAnbADYJT1uVqdBQwS/HjNJo8d+Ejg2mqW9WICSvMMCK9lQ+kjbaHkPi25Sz+XxkrQODvh2sXcXdzvvVkgmf7VTh5TiD02rHLZwyCXrxm27ZbmRS8hJhQWlo7OA0uFjMRdFUs4XIOpUKvTIeiakzhr8CN5Kd/bwUCyRpBncA+/mrQT32Uf3lzeQVqQqCSh1UYmOPjNnTXGuCk/4oagkmyGnlxBYPQJ2adhb7/1nPP+7gA7xqHEAVwxYKnsZTb0VXfwP/Zo73zePoQlPbKL9p/mzwtuKVt9dVfPFbWqboTA4UNuz6ptY5QP8Wiiu60Y+T7CdaJkAoW4QcF4DqR736FWYgyQd+kQg8QyIZbwVnGe+/eqdh1O2ncRJjhJ1lqETkOkdsfFeZbnmYhHyaUERckLNrI/U6w5MPDjiZwQLETv1tLLltjaTCBxf8+ub88JmrgmzvapEgLavefn7rEXmUlsMVVBczb3hwyvP4VK1mTBtOoIqDI9SXIk1WmvPaiYdplEOEH+r5+jplzoRZBbkKgio6yB3vor3HvNs8vwTI25SX74EV9JRqbcpO5aO8iFias784SRRQR552Zx2Zvqjwg5DIFJXCh8oP/dNvVbSKjnQpgj1reyWyqGOJgTuLSQ+cZF3qUIO15LA5FNhc+UO6hmETeseI0TV+EPmc2GGraX6bCDzUsM74dVYZOB06BFTH3lj6n8MmnioSNcLBxr9qCu5hz768fiOkDNKD/0pM++/TJzQ0AUAQcLuHJiCh0DCxdt2XtXcSiv5ysrkBJ2VDxAiksUzjMMiMWIFyYZcW7AjibX/BAZfiTP+M1sMEL5lMG9WRCg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b0dfb8d-6112-4766-64ba-08d8d3cde402 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 05:27:32.4531 (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: MW7WRwujPJKzoML86uDEFBrkQ9mNMRrYdOXYO33SxnitjkdwM+V57zzBn6yz9tuASLuhxCxcv40q4IUYNBvDJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3442 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce ACPI mechanism to get PHYs registered on a MDIO bus and provide them to be connected to MAC. Describe properties "phy-handle" and "phy-mode". Signed-off-by: Calvin Johnson --- Changes in v6: - Minor cleanup Changes in v5: - More cleanup Changes in v4: - More cleanup Changes in v3: None Changes in v2: - Updated with more description in document Documentation/firmware-guide/acpi/dsd/phy.rst | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst diff --git a/Documentation/firmware-guide/acpi/dsd/phy.rst b/Documentation/firmware-guide/acpi/dsd/phy.rst new file mode 100644 index 000000000000..7d01ae8b3cc6 --- /dev/null +++ b/Documentation/firmware-guide/acpi/dsd/phy.rst @@ -0,0 +1,133 @@ +.. SPDX-License-Identifier: GPL-2.0 + +========================= +MDIO bus and PHYs in ACPI +========================= + +The PHYs on an MDIO bus [1] are probed and registered using +fwnode_mdiobus_register_phy(). + +Later, for connecting these PHYs to their respective MACs, the PHYs registered +on the MDIO bus have to be referenced. + +This document introduces two _DSD properties that are to be used +for connecting PHYs on the MDIO bus [3] to the MAC layer. + +These properties are defined in accordance with the "Device +Properties UUID For _DSD" [2] document and the +daffd814-6eba-4d8c-8a91-bc9bbf4aa301 UUID must be used in the Device +Data Descriptors containing them. + +phy-handle +---------- +For each MAC node, a device property "phy-handle" is used to reference +the PHY that is registered on an MDIO bus. This is mandatory for +network interfaces that have PHYs connected to MAC via MDIO bus. + +During the MDIO bus driver initialization, PHYs on this bus are probed +using the _ADR object as shown below and are registered on the MDIO bus. + +:: + Scope(\_SB.MDI0) + { + Device(PHY1) { + Name (_ADR, 0x1) + } // end of PHY1 + + Device(PHY2) { + Name (_ADR, 0x2) + } // end of PHY2 + } + +Later, during the MAC driver initialization, the registered PHY devices +have to be retrieved from the MDIO bus. For this, the MAC driver needs +references to the previously registered PHYs which are provided +as device object references (e.g. \_SB.MDI0.PHY1). + +phy-mode +-------- +The "phy-mode" _DSD property is used to describe the connection to +the PHY. The valid values for "phy-mode" are defined in [4]. + +The following ASL example illustrates the usage of these properties. + +DSDT entry for MDIO node +------------------------ + +The MDIO bus has an SoC component (MDIO controller) and a platform +component (PHYs on the MDIO bus). + +a) Silicon Component +This node describes the MDIO controller, MDI0 +--------------------------------------------- +:: + Scope(_SB) + { + Device(MDI0) { + Name(_HID, "NXP0006") + Name(_CCA, 1) + Name(_UID, 0) + Name(_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, MDI0_BASE, MDI_LEN) + Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) + { + MDI0_IT + } + }) // end of _CRS for MDI0 + } // end of MDI0 + } + +b) Platform Component +The PHY1 and PHY2 nodes represent the PHYs connected to MDIO bus MDI0 +--------------------------------------------------------------------- +:: + Scope(\_SB.MDI0) + { + Device(PHY1) { + Name (_ADR, 0x1) + } // end of PHY1 + + Device(PHY2) { + Name (_ADR, 0x2) + } // end of PHY2 + } + +DSDT entries representing MAC nodes +----------------------------------- + +Below are the MAC nodes where PHY nodes are referenced. +phy-mode and phy-handle are used as explained earlier. +------------------------------------------------------ +:: + Scope(\_SB.MCE0.PR17) + { + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package (2) {"phy-mode", "rgmii-id"}, + Package (2) {"phy-handle", \_SB.MDI0.PHY1} + } + }) + } + + Scope(\_SB.MCE0.PR18) + { + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package (2) {"phy-mode", "rgmii-id"}, + Package (2) {"phy-handle", \_SB.MDI0.PHY2}} + } + }) + } + +References +========== + +[1] Documentation/networking/phy.rst + +[2] https://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf + +[3] Documentation/firmware-guide/acpi/DSD-properties-rules.rst + +[4] Documentation/devicetree/bindings/net/ethernet-controller.yaml From patchwork Thu Feb 18 05:26:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 384779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1176C433E0 for ; Thu, 18 Feb 2021 05:33:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C74A64E68 for ; Thu, 18 Feb 2021 05:33:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231207AbhBRFdK (ORCPT ); Thu, 18 Feb 2021 00:33:10 -0500 Received: from mail-am6eur05on2057.outbound.protection.outlook.com ([40.107.22.57]:24352 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229594AbhBRF3z (ORCPT ); Thu, 18 Feb 2021 00:29:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lspK+Pha5cKSGFsp8JMvvPMYbyFeIGvznp3nW9Zv1kUcS+EJ84MsF7Oks0i1rthnVGYE/PfZcEhbr3N6/d49MA+wycQdMO1551iDl8k5GS5knsEexYXU8aCmu26HtogaQN8VW8zEQ7YJg8zYwbt+j3h8NlsGX467pqqbdUk0Ytn4Skw2OWvHNp2kVhKLUwql6UEC2KavRBI3KS6jYsuTisxrmZV++XTicFi7xV5BVqL7Mw8b4d2qzqv4a2W59JhsLdeDuoL+JSwPC9M8s7VVlfDit8ea5CMj3Npvn/3LeS0t2daYBQ4V6plx8WX+GULh+tkIbDWOxul26I47Je88Dw== 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-SenderADCheck; bh=/hJLB304LdQ/4Q0axIjEskvifwLDS0QY8l75kFdPAwo=; b=jzWiVG29U+wjoKqrR9NI+W726HG9Nbxc/vpN4SsmejtL+VToZlOmbe99CN78bwIrDMR9IZ4Mb9XAkPDeHSzh+RoUa152hUXXZZZQA/me0HkLo2REfBoW3mv07Mg/N6+fSo+adRAfmSduVnEnhoyXRrL93nWNqYy3JyugiXNajr9pZq3lSA1SSbr1S3XHHHkmbmdV/b3e14BvjxOCB3s4sjf5NpKZT6l4dM7HBwoTWdJ0yAbVyIVc/clV+tYHIAW8GZJBSWYyNTryvaNJloYB25Aum9sV/iQCp+Skjhso2KoOuq1k3ksDJGT7qeskizuwi7c/W6kMXpAL6lO3zov8VQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/hJLB304LdQ/4Q0axIjEskvifwLDS0QY8l75kFdPAwo=; b=VhfHvbClcbK84JincCuc/+EbW4QLcYrz8ZCTaH1k/Mt3S+C4zOVHBU8AhSqIPHtXBeL4vlmr4luQpFu7hTzPfRoBd8vRJZirQ14BTyUOr3dEG6hIizB/Z+wsWaY6z0Jy0NwCvhXBazafMQue6uJSD3JZUmnhybKfjuBelF5u4Vc= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none; arm.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) by AM0PR0402MB3442.eurprd04.prod.outlook.com (2603:10a6:208:21::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.42; Thu, 18 Feb 2021 05:28:00 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42%6]) with mapi id 15.20.3846.042; Thu, 18 Feb 2021 05:28:00 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, Laurentiu Tudor , Diana Madalina Craciun , linux-arm-kernel@lists.infradead.org, linux.cj@gmail.com, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v6 05/15] net: phy: Introduce fwnode_get_phy_id() Date: Thu, 18 Feb 2021 10:56:44 +0530 Message-Id: <20210218052654.28995-6-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> References: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) To AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03152.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 05:27:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7a8f3ef7-5f66-4f25-5bc6-08d8d3cdf4de X-MS-TrafficTypeDiagnostic: AM0PR0402MB3442: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qZzoZwnjieoSfY5i43wdfoh1OBTMXnKtvVtI3vNJWpcFrZlLdB1iagxAIzjxOBqnx8CAuluxE7s/gGdVpq/FLCRSR1BlCTG1FvOkol58dwoURumA0yBeUIfdjxqxTBcGNi/+87y2PtvR8s1ghawPjt2PLYikXRGiKoE70lDaHO+m2rp00R9bhWRdUjR3JkPpvSUPGu3fB6du2UYofUt0OOkh7fERh+g5KJggxKODB805mA34nn1+SpZTLPWp+V+4NYjuf83O+NPKKI3RnHzAySB9xFvg2Se5Tn1MndAQDTPZwc4Fvogl37YLRrNmlo9cL6DJybSt3lmkN1H7xSHGFYxYiVLjJaz08Xf12Ocost/lPFLUzB7XJxN6Iv8E/akOuyK8FXbnsMvK0dWnMDhjhmaHc6PLH5NOCp7+vkCn0Hb7m5+g4R0Cq4xjUSZ7PKU89a8qSuCaWpmyEKdjNsCE0Pa836GmsIQvdArY/XXOT9XkHFgALOIiYPfhDPhYu/b2kLhN/cd+pHXII7D3nEK0w2OFYzg70dx9FLTV1bFsEiS6bymTwfUgNN3MlyFVI7so1o5+gvarN5UvlrHaB2Iw42sy6kmACYa2jKrcZeIifqI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(136003)(39860400002)(376002)(396003)(44832011)(6486002)(26005)(7416002)(16526019)(110136005)(956004)(2616005)(186003)(55236004)(1076003)(6666004)(4326008)(316002)(1006002)(54906003)(8936002)(5660300002)(921005)(2906002)(52116002)(478600001)(86362001)(8676002)(6512007)(66946007)(6506007)(66476007)(66556008)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4ZNW2UYpu2qaNsd2f0+Ysls+tdgWZAX3T1byYppWFcwLdsWM+lcGG7mGQ7p75nxHRUNecM9arUl4f4hxbXeOPjwkvUlV3TigUkmqlcF3WRpsv88Nit11stTyBkt9kiAhwnntfQ4oZonjw+oY87cQavBPVlSa0y9Uk2q9HisGqVg5eXaJogbIDKJW8w4K9h51AbMoiNOfoDO3+nOKSC8O/gmHqrlcPMofIfF4wN41OSYB13TUxYGPdN/qphXN0bYaWPIgLHu3kV1zZ6J8jP8FMihQbPeLlwRK3NvL2MJinWECntyqEbP7YC54TBgPDUFOXm5m5xg5diqOl3Vfivo9Ci0z2nWWcLF9nAzVHE01gQgJsVhng85Zvy7VIT0u5UgJw9P2Yo9ghnwVEkDo/hQBVd4uo8zYnTgv3Anxj5tpoh8l7eTYA1WxZsjseAc1AMAPxl3+HLfgl3E1ylwImd2fqpbzvfykHqOSbNNdW/9Q4EADH7u4as/p8C+48itBsm4Adekk1vugI6PBpj/DyhfuDpQe3Uv9c5CShVRh+ucUNgR56Ou0SK/iz3Tvu7V6HJfO/dvVtQe0NEHOuZw8Vq5IwcgeXhp9+BMaMWdWCIkiEicmp1GOsO8zd49P59JAeHTAwaPIqUyaU6A0cfVkJ2RFAD2sO/bNSg7NIe5Nmp7OuDStiHDWQiiZjXkw8jsZAjLxGJe1exlovlyHD9Zhq7lkst0OrFmEj4YMyF3Fe19oMRxBuMartVkIrJfTYYwyTdg2gF5BEC2uYGBUWr89/CG5/wEQ92zJpgmCiOgiKjDGxGbGD6u8LTDkaXVhRrQTUJGjWTLpVEyZohl7DZM6YAUYxrdC/55Hm03uMhJLDyo1XhRbjDwZn/+0PJ/qWLRRF1lzoX31Y/qc2OwLXPXtm9EfEcHhLU6uvknUSNeANORogvTITM5FYMBqFJTfdmIF9VubZEx8ZSx79bs+t74ee4gsofwPTK6JtHGOUBkg8E9lXGjewN6n+oPFxbExlsbSnYRRcRbLpDQEjA22s/8XXqAfFa/0wcOJYCGpoMJ39+g1TMEZaszC523XhsMIYEUpPjLw/67FVhGJmvhkk6ozliSmE5uLrI9kJwiImDADWCz6O9iRJljajc0CjTCnBijcld2khqfmgUm29/OsaJLGwfNi9BlIJU5hxILVsQYWmAajLJ6OuMCFnc9pC7E1FjtmPx6wmwJJ/guZQK+Afl1NddcF5iMvE0xyK2/aSQc81aWHdQfmuVzspDELN+vFr1XDEZLnzsJ3zYHO1d2ZA/7wt00nxBvLrK+QDKzo1Wu06QBKZGyuNOx6gW99E6ObH+hMhz6E X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a8f3ef7-5f66-4f25-5bc6-08d8d3cdf4de X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 05:28:00.7232 (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: oJCphG7TxecaBRMIcyeVBILJtuWEUwxJnV434nv5b2Zq7fs6Z5b3wg4KKuH2k756Mhip4oopK9yKeFVWNlkGFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3442 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Extract phy_id from compatible string. This will be used by fwnode_mdiobus_register_phy() to create phy device using the phy_id. Signed-off-by: Calvin Johnson --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: - Use traditional comparison pattern - Use GENMASK Changes in v2: None drivers/net/phy/phy_device.c | 21 +++++++++++++++++++++ include/linux/phy.h | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 537a25b9ee94..5703d4229821 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -819,6 +819,27 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id) return 0; } +/* Extract the phy ID from the compatible string of the form + * ethernet-phy-idAAAA.BBBB. + */ +int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id) +{ + unsigned int upper, lower; + const char *cp; + int ret; + + ret = fwnode_property_read_string(fwnode, "compatible", &cp); + if (ret) + return ret; + + if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) != 2) + return -EINVAL; + + *phy_id = ((upper & GENMASK(15, 0)) << 16) | (lower & GENMASK(15, 0)); + return 0; +} +EXPORT_SYMBOL(fwnode_get_phy_id); + /** * get_phy_device - reads the specified PHY device and returns its @phy_device * struct diff --git a/include/linux/phy.h b/include/linux/phy.h index 720a2a8cf355..4b004a65762e 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1366,6 +1366,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 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); struct phy_device *device_phy_find_device(struct device *dev); @@ -1374,6 +1375,10 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45); int phy_device_register(struct phy_device *phy); void phy_device_free(struct phy_device *phydev); #else +static inline int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id) +{ + return 0; +} static inline struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode) { From patchwork Thu Feb 18 05:26:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 384780 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E581C433DB for ; Thu, 18 Feb 2021 05:32:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D42664E33 for ; Thu, 18 Feb 2021 05:32:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230282AbhBRFcH (ORCPT ); Thu, 18 Feb 2021 00:32:07 -0500 Received: from mail-eopbgr70050.outbound.protection.outlook.com ([40.107.7.50]:55526 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230380AbhBRFaE (ORCPT ); Thu, 18 Feb 2021 00:30:04 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cYHyXlDwxI/pylN1ZGW7zvEwmHyLGybX5Mti5bksPbybuCIjOuedQEifn/4GZv7WuTfZY5wUksI23gpJ7DB6+tZthqKp950LB7oHWZqm9FIZE3ZUs+XG6PQqADLZggZz1PM6LtrXbcKjHwLOweQWj1763cTAOnsi/9PNLmmAaPOAvq6gGoAhI2Syr//LpycmVxDUoVp/Vc4U3XETHaAtMkr5wYsVM7kybjOMNbZG26gnWmSPcV9/wxmOUcsVB+qbLWgexnynvlHDj86NqSPT5vPUD9/YCuzNFaGiFoMb4M+44YzPbEfQkFCcz15/oC6WR5PZyqcjHX3yf1iC0PPxmA== 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-SenderADCheck; bh=bw3WU28kazDnkrM6BXLcnnpg4zm9KvcXi98KY3KnJbo=; b=gNk+y61iO+yCAbd1oT3LGLyU+Zbk/xT6HZ4kcQJWCTdxBJkzQYOR8VRNyy/3ueOvjb/Ig8lwoKg3PPBB7MJGFpwkUqdDfQHJyve3TxBnUHnYqtkJmph7VUaxkxeynpSMUmkAy9Zflu63ONHBogFuZ0D1FWO5CAf2LlaY4ZTrRdMl95P625fV2RDX1R95kNpRpF3KAwOF/o/TCT9t8Z8tZJQ2JQFE0gtdyH3+4UyABWRHSMNceaGkPq6mik9Jr/y9i2k0RP6P5K7Nuoqo6ZGTupzPQZAk04hbom/2tt6reU4a9gtK6DohNnjZZPP8VAFOvaZSrohcTM1SF1MJFdfi9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bw3WU28kazDnkrM6BXLcnnpg4zm9KvcXi98KY3KnJbo=; b=IYBtX/UJGtRnxZGKzDh/Pqn9ND852Eo9MjSJ/9abP/zJNqcZ7lIRxbyS1Bf87TXaVlfsEmwhAAj/qNFLbJZ8S9Es+Ev+HDEL9HSBGyJ1T4jvii6v7Tutc2FKYolQKpvSdYaOlF5vsOHWtRDgFsYGRI6SlY4eC4oquBidpwP3yFY= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none; arm.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) by AM8PR04MB7730.eurprd04.prod.outlook.com (2603:10a6:20b:242::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27; Thu, 18 Feb 2021 05:28:22 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42%6]) with mapi id 15.20.3846.042; Thu, 18 Feb 2021 05:28:22 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, Laurentiu Tudor , Diana Madalina Craciun , linux-arm-kernel@lists.infradead.org, linux.cj@gmail.com, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v6 08/15] of: mdio: Refactor of_mdiobus_register_phy() Date: Thu, 18 Feb 2021 10:56:47 +0530 Message-Id: <20210218052654.28995-9-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> References: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) To AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03152.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 05:28:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f7f83195-0459-4971-a045-08d8d3ce01bd X-MS-TrafficTypeDiagnostic: AM8PR04MB7730: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0LHYtbaYpEn7whOdUgBmaPiaobIijlhArLZraBOiiBZOh9OPyBxPMzYUaKNn490zvwwmKG62CAiUKOsTBF3sdxgS4jmBtG4i9EZU/hbXrZuEiVWWHox6wO+NrcnqV04zn00C/BPiasd2c0+up0f6YMSVtiaI0J+bOpBS9qZ27QG3oO20LX4bxPbNoCMqYyzKjT4DGN3o1FWvpj2IIRamuFxtCbMc6WkEmM0VM8Qcd9OOc+ucZY5rUqtdTEP4oGhvdcG40QhLhUZfkOeOVoit7WCzxqNCZd1Kx617kcedVYO1AkG3if+51lPEA7aw5aOBwIcWDyXA9Zx0BsQntXxElqh1BbHGH4G0p9dNnCOFgNEtb9l9AtkSGMn79D6FWRZMbzfmKNFSTOy2HWkuoKbd4MoZq2aoJojO+ru+/EYbu9siojbS42rS9VMyUYSsHMP/HWsxFp0C9tRtrXRvi0RlmrIdKFoeYHJNgD7aVrHBWcNdnSKw+7++/XuhUsVmG7ZGZI/VCvk/t7QvoSLohWB/wlH4VhLF23xhajEaeGKsBGDHDRl7SednhfXsq6SVsuPPubM5ENbwaoqaVTq1otRqGw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(39860400002)(136003)(26005)(8936002)(52116002)(16526019)(921005)(478600001)(1076003)(6486002)(8676002)(55236004)(83380400001)(5660300002)(186003)(44832011)(110136005)(6512007)(956004)(54906003)(316002)(66946007)(2906002)(2616005)(1006002)(66476007)(86362001)(7416002)(6506007)(6666004)(4326008)(66556008)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 35ahNdjXgKF81JBMpKXbuFDB8jBJ6fjFIXoOTVmj1iBldqFcRoTwZI+VZgL8eaQ1EHZ8DqtjRPZ8cCI/IG1gOnXPCJ73E/iS+/VhUmVvA1ckxDX9ofDCsNDYBmaxmP7IHrEbSl9sNhTAo5/gzGcDLSPwxZ3OlNS/6yhHRNFogT+LPzBuuWWLeKzTLp9A6lpGP2zvGpFXiSwN5ByHvy6z2zYBIcFkb6YfzHdGML7IqRdEZCviJygZJyWKnVb07ctkUmMmsVhsBiySy2DAT4Qr+9mcWIQO2Bg/yZrSjxPYv1f4fMEi1v3sk+2CTbJnyPbkvrogYY+RCIOErr6BxJolR+2GjT567dBfvgFC83ulpAvDHdoCw1Qip3+LfJ18mGNntaIH+Wm2Na/CvIfYQUKAqk5d53c4xwvJwgRwYW4oRIQ/uHaGsj4Ihr9mzOMhtESpQViggQcxgQiumbKOW2W9TKbisAzk1M61hNTdgPe64qQal1jTCfJSTx1UWrCnQnNZy1Fi0tGl9D6ukwB1Y+mrGjO/MOH6y87Gsu9jLHhZKOPPrhQfXpY3svqcZ9pBjNo+73OFIZm6MSLdV3N3JbBMQoI9G39L0GJb02LpPBGyj4fL4fNXWZvxs9SOTk7TCAS7lKN67KSk8T3qFbdzSgunMIx5w1V1smaUiSNf+FekLc5E/Afcoh7gJELvRltUCQJfgFvAFpOGTSD8d1Kx5+iZlpkiLCETRXgjZvTaawtdjQi1M7thH3yTNWq5xB8CLVYBxZyV/TOafNXHbok1TX7UZZN4slat10CuQEacuxV4VFtVmDS8HSOJAMWBq/buXuX2ilaxsMshJdeoGqONKXFY+dArNkuAifxruBYTZDq0RJ/Vy9ARGSPyushecg2G2JBkA5/UmhEcqgy4qD8TO29CfwLnUR/aUMXMUG3gUW9x6mT7CxBBlgXZjbMuFKh4RNKqe3bmz4QFJao+00NPX3azb2fMmMZtOtj9Tz9eqSwdtyXmt1dxHZL0FltVCX57U9ySUBxH8usk9hsQ93aRqaok7Ff58N/zNG3y/zpmwFU4ZWl1aAM+KyMltMfnjwLmNgpJqiU3LoSHktVMi70zEHdHxud60CkVNDN8lDkYNViIs199wesNJscE4k3B0Vm0lTvAI1PAmoOMV2qscSp8Yxwr4jsVvOxhpkW412ibijlZoSgEj//FLfV1hppS1HAhYsQ3qUfsRVm1KwE/rqQzw/M0FK7SEXWhLmaeT2G0OziEWPgWhpGO7/yCFHuDZXgfjj9LcJktw8iXdtXgFXlmJH2PiuGVwVyM/YNln41dPBvbEHhuo98nrvJJMFIhZEZXQr4z X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7f83195-0459-4971-a045-08d8d3ce01bd X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 05:28:22.1392 (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: lYbxxXjsszG66UL39wzhVIJYJkX5VGYLIf5XWH3+ZtBsMNoBjE4DtIeF0hSQlfdrFH6XjbBrxeVv6QUMY97MPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7730 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Refactor of_mdiobus_register_phy() to use fwnode_mdiobus_register_phy(). Signed-off-by: Calvin Johnson --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None drivers/net/mdio/of_mdio.c | 40 +------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c index d3f7f104f1ed..a0d804cfc1f0 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -98,45 +98,7 @@ EXPORT_SYMBOL(of_mdiobus_phy_device_register); static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *child, u32 addr) { - struct mii_timestamper *mii_ts; - struct phy_device *phy; - bool is_c45; - int rc; - u32 phy_id; - - mii_ts = of_find_mii_timestamper(child); - if (IS_ERR(mii_ts)) - return PTR_ERR(mii_ts); - - is_c45 = of_device_is_compatible(child, - "ethernet-phy-ieee802.3-c45"); - - if (!is_c45 && !of_get_phy_id(child, &phy_id)) - phy = phy_device_create(mdio, addr, phy_id, 0, NULL); - else - phy = get_phy_device(mdio, addr, is_c45); - if (IS_ERR(phy)) { - if (mii_ts) - unregister_mii_timestamper(mii_ts); - return PTR_ERR(phy); - } - - rc = of_mdiobus_phy_device_register(mdio, phy, child, addr); - if (rc) { - if (mii_ts) - unregister_mii_timestamper(mii_ts); - phy_device_free(phy); - return rc; - } - - /* phy->mii_ts may already be defined by the PHY driver. A - * mii_timestamper probed via the device tree will still have - * precedence. - */ - if (mii_ts) - phy->mii_ts = mii_ts; - - return 0; + return fwnode_mdiobus_register_phy(mdio, of_fwnode_handle(child), addr); } static int of_mdiobus_register_device(struct mii_bus *mdio, From patchwork Thu Feb 18 05:26:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 384778 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04E11C433DB for ; Thu, 18 Feb 2021 05:35:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5CCD64E33 for ; Thu, 18 Feb 2021 05:35:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbhBRFeV (ORCPT ); Thu, 18 Feb 2021 00:34:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230427AbhBRFaw (ORCPT ); Thu, 18 Feb 2021 00:30:52 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0603.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::603]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DA5BC0613D6; Wed, 17 Feb 2021 21:30:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CCYcdK5mYmTbExkhF/R2bFN7QfBQGYvAFxvpSEjFRiQWQdeLByWHCru4YyiKh5Z70uFEGKbhnNiecBrNq3EUkdGkFbwCu8PP/yAG+xbZ0M5xyui7vYZDvDZb+37LuYl6EpnTbfitURuoCIixmTbZmjg0i1qIEbCePB7ms/F3EKFRnm53KIsAYLjGzFjI16rFCsOXDcIhpqrU9+5K+9+diNQOkXUEKSWDIxAm6wnnSi6RXkJPIIsTpgxwjBkPs11mMnN15LMNvPcEeb9N1N4wL7NdXcUeuTfvuTE9SiumxqFKEHniI68Fvl6oEP8yJzQa4e5nI8Re6OaqG2jg0K1jeA== 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-SenderADCheck; bh=15LjNqafMe9XbMRxl6wCPfbkpsrCCaKoRRcVNTMs5uo=; b=SdrnS5g3as5BXrgvyYQ8x4y4K9Ao3bGXXrZC9PRa56taHdiVEtmVSnK3n1RczGaor+HeBchdpuB0BxTaoz0YeTbKaKwVO3oG4ee4ttGp1AWxO5AO1EncAl1xRtnOtTgjOefnmUYacUhhjAoWRUOxC9vCn29f2IuA4jPr8vLHkkvpKWpqVVotrAxBIZpkUaPtfoUXmoI0a+fdii3rm7KwKvM6f2qeyoTytOWW0zojOhvka7sh4FLmBYyshX5fq5ebUaBmBk+9GoPf6o8kewY7ofrNRhvWGjnc1KhRUwvO0nE8BO/TnKJRCi1ToAxdK3KFN58AU6uq7QnvfOJ/n7xDkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=15LjNqafMe9XbMRxl6wCPfbkpsrCCaKoRRcVNTMs5uo=; b=WsLf6zGzM9xGl+iQ8pbkMGnNMRZj0+vtEM0z9DHgfIUjauhJ6foc3anOWN7lLj/UrfANRRDLruoKf3etL61ouPO+nW4evyKYAt+YWXO7y4c4/XKm+8JLjhToSnyRsrLSgzOfJZAWHxA8nbxH5yKvsSjOJxRlLv3qMoRx5u6W4Pw= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none; arm.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) by AM8PR04MB7730.eurprd04.prod.outlook.com (2603:10a6:20b:242::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27; Thu, 18 Feb 2021 05:28:35 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42%6]) with mapi id 15.20.3846.042; Thu, 18 Feb 2021 05:28:35 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, Laurentiu Tudor , Diana Madalina Craciun , linux-arm-kernel@lists.infradead.org, linux.cj@gmail.com, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v6 10/15] net: mdio: Add ACPI support code for mdio Date: Thu, 18 Feb 2021 10:56:49 +0530 Message-Id: <20210218052654.28995-11-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> References: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) To AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03152.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 05:28:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5529b96b-9b9a-433e-3d38-08d8d3ce09fe X-MS-TrafficTypeDiagnostic: AM8PR04MB7730: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F3enkKJhhAFDdtpLa9PUxPeVBlFKzblt41G3ME/NDn4Vfqxycm8/0AaUkSHtn/FxADti57Mi3sr0fkFtzg2gJ3tb+xRAijCyZENQnhNJSHohZj5DgpNsgMpTWL/46hbIOGn1sKBR2inL3bBBLJYs4+GxUGeDOeiqjL1zbl0QRasTGnXTN9Yd9UHUY5P5j6r78uRCsH/jSmuXyhNeT7FxFME+om5vEga9L9lNSgg0qDP+VAYTRr/x+l2L4bTpz2oxLcV88iqRFKRxtD5ztGqGoolfv4eINk2hxhyhL2LCA/YX8A3Vkuxs4/JcIBfcvq5aI9WfpQUkDDhVf+bv8Qf0pjokRi6BqfeUSmPGQxywCv0bX1kRHJWxZucZRscHAFva0MLRoUrayyxfAOQVJzbkOGd7w5L66Dv/ENkYuX8V2LUvktS2ZYJ1wVD9BtBOrvoEAkDqn5Zw/bQXJj+MwHj4NQMvTS2JIC98q9J00Wi+4nMcfeHFUUVxwALrV9XVBCQkolGNHOAnL3CiNr6BlaJ/YlJqHZYr88VimezeF+T9hwVjdG+Y6taJUArS85WEevQhK7fEmQzsGiCYcOXA4mh5kQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(39860400002)(136003)(26005)(8936002)(52116002)(16526019)(921005)(478600001)(1076003)(6486002)(8676002)(55236004)(83380400001)(5660300002)(186003)(44832011)(110136005)(6512007)(956004)(54906003)(316002)(66946007)(2906002)(2616005)(1006002)(66476007)(86362001)(7416002)(6506007)(6666004)(4326008)(66556008)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: MEjVIl7JMaBRiegK/lMa5VNc6Xjqw3FKtUQ9GJjHbfmCiqTwj5hzKlp2ft6Ux2oujQ/BLpwThh1U42c3l2kWSITqnegzQxAy4JZvQqjMUfJuI/2XBKBO+Ft8PyecRkqX3OEN4KtMJbzff3dYyYZFAVappM5E+uj/bWRkYtUidlPtBh43BA/TLdHEG5dro+rpyPgxtJaacKeAuoq8l8qoEC9A8NxtXQPyxxdrPjt+HeNbctgVORoPNkEM7/Av+yMBxCOXFHSCBKRbm2KEQkyYJ4c+faE6VEJbGtwm0Di7CnBdbKFvff4HBAzRDOMry827zGJQNv9qRbuoBy1J7B0+t4SG8kAF/aPN3LdX3+Dv27391r2TC9smPZsSpbQMUHbId+Doj2GE/skUIBv/L++DJmnjBLe5FmDIDZDzdr//AR06J8hgso10PszkTw9WrrQdRj/Wk+0gt1B2P2M5GG9/A6R81MATDye8pBEaCii0TIvMBQcDamGFA/JT45SK35pa5PQUjuE1Vdma3d7XQwn9N2S2c+xKxXCsYssRfOvP+0CPaABmE39Xa/qkD5x912awxh8jFlvgSGhftPkp6ejMngjvUpAk5PxuTzm/AZEuDenvAQbk83E9CzOmGdOUd3NCD4vVMNBmBQamPlVNROJ53sxGmd0CvVxxar9Jsme+qI4oFF6pFhQcn+NUB68JwsdcfVe1NiG9KoNXVG5rQXga7zkXpXOsOEahPyp7YCrz/fYMcUdQzTSCKgslSB2BTM1McQ3yuYupGWvVV0YoIFs17t/TE2MrUUc1+e6Pat80sRmG9yWGX4yJB9oPKIERXTqpu5Gh1J6xh8NXTiAYvYoCVRNHHxMn1BdpLIGLzzIoZGf4O0hgGwR8ELqCgJZePbP16wzCrxq6NGOSHaBzJ0lekTGZ9GOm8ehg5KuW4vtMAKb0HLCLjAP1QbXFP+5Ew7gf7nXdWCB4iLOmlAfxYOGVil3PLkuwN7F6rNOeWHmb1mK8o8+A2e4Cwqn9aCL1vC9LpYBKmDVJzjRiL7oy97HYax0UXrXqJujBBbklLHc3xymKBBz1wd37WEXM6VY+cU4XK1KeYj16tPjrTW4eLD9oqOUV72yGnIWDh+L96YDcGleBas3JdRGuqdRilr1DiiKSUzke2lre0W1bFLODlUcW2y4mjrA31+m4+D4xm7ZMzcu8mUm9I4qnAw5NFiQd4wLc2g0K7GozGGVuJDtqYyfDH/JLR4ePbPjEAF/erjd81XyTMUSu1Aqm4LZ9GyRq46rs1RapCVEnNF3t245L59oft0RPJSjaUEZ4LxqeUSm4u6s2oEuY9ldmKm4WfzeJM+nK X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5529b96b-9b9a-433e-3d38-08d8d3ce09fe X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 05:28:35.8734 (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: i0SY10Xk5ry2o5/Mt8hg91seyaH8TuDmfOjBo9O0M2OhGjkn7QNYSXq9IVT7kDY39hinVtGGI3qJUnRYkC360Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7730 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Define acpi_mdiobus_register() to Register mii_bus and create PHYs for each ACPI child node. Signed-off-by: Calvin Johnson --- Changes in v6: - use GENMASK() and ACPI_COMPANION_SET() - some cleanup - remove unwanted header inclusion Changes in v5: - add missing MODULE_LICENSE() - replace fwnode_get_id() with OF and ACPI function calls Changes in v4: None Changes in v3: None Changes in v2: None MAINTAINERS | 1 + drivers/net/mdio/Kconfig | 7 +++++ drivers/net/mdio/Makefile | 1 + drivers/net/mdio/acpi_mdio.c | 51 ++++++++++++++++++++++++++++++++++++ include/linux/acpi_mdio.h | 25 ++++++++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 drivers/net/mdio/acpi_mdio.c create mode 100644 include/linux/acpi_mdio.h diff --git a/MAINTAINERS b/MAINTAINERS index 1a219335efe0..41d16d77b6cf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6680,6 +6680,7 @@ F: Documentation/devicetree/bindings/net/mdio* F: Documentation/devicetree/bindings/net/qca,ar803x.yaml F: Documentation/networking/phy.rst F: drivers/net/mdio/ +F: drivers/net/mdio/acpi_mdio.c F: drivers/net/mdio/of_mdio.c F: drivers/net/pcs/ F: drivers/net/phy/ diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig index a10cc460d7cf..df6bb7837d6a 100644 --- a/drivers/net/mdio/Kconfig +++ b/drivers/net/mdio/Kconfig @@ -27,6 +27,13 @@ config OF_MDIO help OpenFirmware MDIO bus (Ethernet PHY) accessors +config ACPI_MDIO + def_tristate PHYLIB + depends on ACPI + depends on PHYLIB + help + ACPI MDIO bus (Ethernet PHY) accessors + if MDIO_BUS config MDIO_DEVRES diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile index 5c498dde463f..2373ade8af13 100644 --- a/drivers/net/mdio/Makefile +++ b/drivers/net/mdio/Makefile @@ -2,6 +2,7 @@ # Makefile for Linux MDIO bus drivers obj-$(CONFIG_OF_MDIO) += of_mdio.o +obj-$(CONFIG_ACPI_MDIO) += acpi_mdio.o obj-$(CONFIG_MDIO_ASPEED) += mdio-aspeed.o obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o diff --git a/drivers/net/mdio/acpi_mdio.c b/drivers/net/mdio/acpi_mdio.c new file mode 100644 index 000000000000..091c8272e596 --- /dev/null +++ b/drivers/net/mdio/acpi_mdio.c @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * ACPI helpers for the MDIO (Ethernet PHY) API + * + * This file provides helper functions for extracting PHY device information + * out of the ACPI ASL and using it to populate an mii_bus. + */ + +#include +#include + +MODULE_AUTHOR("Calvin Johnson "); +MODULE_LICENSE("GPL"); + +/** + * acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL. + * @mdio: pointer to mii_bus structure + * @fwnode: pointer to fwnode of MDIO bus. + * + * This function registers the mii_bus structure and registers a phy_device + * for each child node of @fwnode. + */ +int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode) +{ + struct fwnode_handle *child; + u32 addr; + int ret; + + /* Mask out all PHYs from auto probing. */ + mdio->phy_mask = GENMASK(31, 0); + ret = mdiobus_register(mdio); + if (ret) + return ret; + + ACPI_COMPANION_SET(&mdio->dev, to_acpi_device_node(fwnode)); + + /* Loop over the child nodes and register a phy_device for each PHY */ + fwnode_for_each_child_node(fwnode, child) { + ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr); + if (ret || addr >= PHY_MAX_ADDR) + continue; + + ret = fwnode_mdiobus_register_phy(mdio, child, addr); + if (ret == -ENODEV) + dev_err(&mdio->dev, + "MDIO device at address %d is missing.\n", + addr); + } + return 0; +} +EXPORT_SYMBOL(acpi_mdiobus_register); diff --git a/include/linux/acpi_mdio.h b/include/linux/acpi_mdio.h new file mode 100644 index 000000000000..748d261fe2f9 --- /dev/null +++ b/include/linux/acpi_mdio.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * ACPI helper for the MDIO (Ethernet PHY) API + */ + +#ifndef __LINUX_ACPI_MDIO_H +#define __LINUX_ACPI_MDIO_H + +#include + +#if IS_ENABLED(CONFIG_ACPI_MDIO) +int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode); +#else /* CONFIG_ACPI_MDIO */ +static inline int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode) +{ + /* + * Fall back to mdiobus_register() function to register a bus. + * This way, we don't have to keep compat bits around in drivers. + */ + + return mdiobus_register(mdio); +} +#endif + +#endif /* __LINUX_ACPI_MDIO_H */ From patchwork Thu Feb 18 05:26:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 384777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9EC1C433DB for ; Thu, 18 Feb 2021 05:36:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E77260238 for ; Thu, 18 Feb 2021 05:36:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230145AbhBRFfh (ORCPT ); Thu, 18 Feb 2021 00:35:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230429AbhBRFaw (ORCPT ); Thu, 18 Feb 2021 00:30:52 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0603.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::603]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1B38C061788; Wed, 17 Feb 2021 21:30:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hXskKfnZRrHlop3BPbsasdw9sC5c/F9Y+LLBMZ3bcNsEDb5gV7WqoWljfT6MVyALTgbyXartk0EgGRUz9qJvCSjyC5oI3W+OhTh7t7yds8K9j8IFTgdgDU2a7aYcn0MBM18/Ta9k/dJjkDP40VqSwnAiXaz+YdkyoMwMAludvQ8tdBQL6GwA7t6LNLXHwqQBswITdfRKFfN77HEIPGc8BUyADRbToShicemS8lj1+zu/cIJ+SXozCH5tjt4FO0DreOlvJDSfu07IvzKcGLUC3Ov2hOqi8chppJTjqtoV4MwZAg72Hbsq/ehhMQVTbbDgzLvrDsy6mu9lyC75DpDcHQ== 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-SenderADCheck; bh=iN8dWrUpI69gm2uQRF7UqhxjIe9OOLdydPVAMK6H8Ds=; b=BQqZArEenG9luvqRDXiL1o1S3YOR+WUyWGY8El2+P5MiX+wnAyyvn1NIQ2ZufCUEcgMWwG0E9ISyMwZShzvtXcnnAhGOuFSEkkaJYBwdV2Lb+fcCP+/7EmKmxbq8l6qn/yWswHsUM2raAw7KRmk8sdUK9Qw/uFGd+1sTYtjazSidXpZwRs1SkOaddophPxi2evvHca1UuLbZUK5IySa/IoSmHfuGaIOZm99OrdF4Y6hllkuYRw338ujReW286IK/8OGhahgnimbnO3at86csCOeJ/7QiW9EUkAnOaN6Xv54dEu7a5Y0QIS7CcjW+Rqxltokxq1tfMQ8GF+tx0dvxsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iN8dWrUpI69gm2uQRF7UqhxjIe9OOLdydPVAMK6H8Ds=; b=MGLlEwtkrQKuOeEmLSnboBUT3yllZkfOieUrNPoBPmRcd93Q2FXePMFF7/ZTRFVxOPwNEOwQbsXN8NaZXvqGlc/vg646BPlxCpppPLwNpQl2UfTn8kogQ5JTdbVwEl5Jh11ASoL23T795JFHU4FaoxTOzPTqXiNaBI7bspkz2bE= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none; arm.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) by AM8PR04MB7730.eurprd04.prod.outlook.com (2603:10a6:20b:242::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27; Thu, 18 Feb 2021 05:28:49 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42%6]) with mapi id 15.20.3846.042; Thu, 18 Feb 2021 05:28:49 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, Laurentiu Tudor , Diana Madalina Craciun , linux-arm-kernel@lists.infradead.org, linux.cj@gmail.com, Calvin Johnson , "David S. Miller" , Jakub Kicinski , Jamie Iles Subject: [net-next PATCH v6 12/15] net/fsl: Use fwnode_mdiobus_register() Date: Thu, 18 Feb 2021 10:56:51 +0530 Message-Id: <20210218052654.28995-13-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> References: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) To AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03152.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 05:28:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 779a09e1-41de-4b37-7064-08d8d3ce1216 X-MS-TrafficTypeDiagnostic: AM8PR04MB7730: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wCv+geqrVACCTi9R3pmgP72f43OWxtwnWiUxFhqGIdz72AjGR7CPEn8bojNT3Vy6FL2MixW3QoIHbroWToBhUxs5wNAEIeNECleM9WvqAZB3vp2uNzIsws2tz9/c4ROKn07iSandrdenvmEURu85pwbFFCd9HKH/oQrfoN9MMwVa9wftbmaD9uZo3BslAQBaaJojs9dtBjjhmzlug2nP9Bd8Gx5hGUZ57t2wrNdPvSC097+r4MIGT2V/mAEhgzd9FaPqUZxdLdo+Hw0f3THtvglc7zwWH4S173JSsrR9gcAWO/Nz5c1a8duLGJ0BKbdxesuqy6W5dr7XL4wE4LLvuoIAvISD9tLIvYHx0IKY52qwmO9L3mdZDyFXm5vYpmeRbZKS6rQgPMRI+8SCnqcLu3XwUHBPKBnlPQIwCS73ljkLuDuRPqc0G986CteXwaq+17XnVTS8xJVVaKMK3fz/qLyoEMKCn2agYpkeMJxeoVpsO9vPXJmCHi2M8APL+IWN5eS8ViVbe+oJWZvZuhUBWUUfV0s1BNA/v3S41QOsvzOclhwTSCPMXrXBYrO6hcesfl0bE+ViKsRFK5D3cq0es0+GYYoz/Y4exaNNJGbWs4U= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(39860400002)(136003)(26005)(8936002)(52116002)(16526019)(921005)(478600001)(1076003)(6486002)(8676002)(55236004)(83380400001)(5660300002)(186003)(44832011)(110136005)(6512007)(956004)(54906003)(316002)(66946007)(2906002)(2616005)(1006002)(66476007)(86362001)(7416002)(6506007)(6666004)(4326008)(66556008)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 5w5TK8yVwHGrfOij9V6wPGZ6xZadJYg33ACMtNZtzDT0wuV9yGNTjwc9P6+o46RToR++7LDM2W62VB6R/NCjGq1TNpXe0+T8xWjYBVncJpIS/Tqw5x9qGFlNsFIKeDEqKMagkgLOwFoa01MCrZxTv+y7RfFYU2tHw17PsyYNimyhcea/WafzWnmkJkoxANSeVT19gYvVaaXQMii2kZCckRi0DZYtMFXnMfWJSa9gAyLXFvoWg64Ii9inOXhUHYdH8M/O65pMlzCGAoZPzcnU/GojfaReMYKRydY3hTUEgXWkUsmUy3uPyqPyfHVuFi2+GakCNo/gDrHoEPDdGtodQwFj8qyWEgmp15BwDA3kUwTflD77YlsJbZam9FuqBV93xba+Ri/LwhTB664/ZAII81qYvfjB4KfRn1u5Tpwce2dxPIp/pO/GJwsTsh2XcaeOmYqMfA6Jo9RF8XLfjc0R6DUmqGd5RBqfyI0E2jfM8sa9Y1PJS17IkWpRIR5bMP50sBdZ3RJo/q6LbetG++blpSt6CQb70qzn+NwD2bTBjHk2CuU+NnNtm30SDb517LS0Q4JKc8jZLlYOJ9tCjpL2QJG2PhLbotFMJe4GfS3PXT1rWifeO1gX+gnOMJrXAjeeyKbPoNFp5l5ZMiCdr/HGQdLI9QMDuM1jiF9V7WEhNTuhlchQIkTZPnhvc4b6ZhPYZElsXsFhJQbHW//Y1rK5uiIJS08G3PWwfzG0639M0fZ1wWC4nW3hZncWAUoOvT+4qSIan4i8y+s+aOQnstrfAkxaMF4WI/UeqOJlij6fUbwEzvGr15HZBV49CMubKfiKrLeTqBSfaVtuDPvqVlt6lGQZVKMnSf0enDRkzvjqPZhhQXh5ro/E/gy7DlS3aFOSiVfWK2otggvatlX09B0+WBeji5ys0x+nMF/rAPYh+OxlX+vymW2WUwibztIH2RNGCZwyhQK1fXj56OYPwJAOksYmBXUgYfH79b9Wxwvi1WhwSF8PPbw8ypgUtvFzr4ii4z2CpTCDBpNBpDU+IsbaX1Fbol9NNjI1iYx6FP9sZutyKws4rPtHnDqDyDrtCBdk2u1UxoKSwNMekGaZuibLXRyxuYTPRLtbJB3gsiU3pWv16xHOPnRXIGUgwluvBhJyBkUpEbDYLq/0mGv+ZilOwHkYyX3vIKD5PS0xatnZuWxap5rZkoT9bw6JwJGWK5HGBqPKl+hI9AmbTd5zQF59v0Gct3IgQKhotAAbX3VTUxeQ10UFoe9932mL5QCB56jx316VZFyzfURWhNfd8J+HGJVb0sHM7t+o/ueOV8v/31SRl//rUpzV7mFFEQu7TkC3 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 779a09e1-41de-4b37-7064-08d8d3ce1216 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 05:28:49.4848 (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: LsazGlH7AIpWonF42JOs1mtir73JEHcBr7fvMUiRuPyAZBk5DtyOxazVcUF7CZhv9h6R2panbrSFQK0UoTgE2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7730 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org fwnode_mdiobus_register() internally takes care of both DT and ACPI cases to register mdiobus. Replace existing of_mdiobus_register() with fwnode_mdiobus_register(). Note: For both ACPI and DT cases, endianness of MDIO controller need to be specified using "little-endian" property. Signed-off-by: Calvin Johnson --- Changes in v6: None Changes in v5: None Changes in v4: - Cleanup xgmac_mdio_probe() Changes in v3: - Avoid unnecessary line removal - Remove unused inclusion of acpi.h Changes in v2: None drivers/net/ethernet/freescale/xgmac_mdio.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index bfa2826c5545..dca5305e7185 100644 --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -2,6 +2,7 @@ * QorIQ 10G MDIO Controller * * Copyright 2012 Freescale Semiconductor, Inc. + * Copyright 2021 NXP * * Authors: Andy Fleming * Timur Tabi @@ -243,10 +244,9 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum) static int xgmac_mdio_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; - struct mii_bus *bus; - struct resource *res; struct mdio_fsl_priv *priv; + struct resource *res; + struct mii_bus *bus; int ret; /* In DPAA-1, MDIO is one of the many FMan sub-devices. The FMan @@ -279,13 +279,16 @@ static int xgmac_mdio_probe(struct platform_device *pdev) goto err_ioremap; } + /* For both ACPI and DT cases, endianness of MDIO controller + * needs to be specified using "little-endian" property. + */ priv->is_little_endian = device_property_read_bool(&pdev->dev, "little-endian"); priv->has_a011043 = device_property_read_bool(&pdev->dev, "fsl,erratum-a011043"); - ret = of_mdiobus_register(bus, np); + ret = fwnode_mdiobus_register(bus, pdev->dev.fwnode); if (ret) { dev_err(&pdev->dev, "cannot register MDIO bus\n"); goto err_registration; From patchwork Thu Feb 18 05:26:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 384776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06E89C433DB for ; Thu, 18 Feb 2021 05:37:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A521F6023C for ; Thu, 18 Feb 2021 05:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230174AbhBRFgy (ORCPT ); Thu, 18 Feb 2021 00:36:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231185AbhBRFdA (ORCPT ); Thu, 18 Feb 2021 00:33:00 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0603.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::603]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D6C9C06178A; Wed, 17 Feb 2021 21:30:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jJZfZAZASkpuCpSFaXlQiNAEZFHkIriRVVXAj+hzpx+wNzf0t2W5T+NkydhS9cBOOIsMubB2iX+SpCT9UiEJdPCdpVSgPANTZNcFO8jzCReTDWO/wn/fv5umv3nUz340KZgLUUqxIFI/1TSpqqY0VuTBBoZDr4if0z4m8GbktdmjTgnNObjHloJfogG6pCuHXgWBqN1ZKKbCegu1yD8JHBf2dX2GiatRYAFOYKIRTLHpG0CVTAJ2Rd19QnXJ3Llt+mTR9JTZyxvb1tn8DeqdzZxflVmw9US3G7E08x3G8YnjdTdT04yCdhuTRbBaPdHt2cJ6n/YbrgREEv1YLhVNTw== 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-SenderADCheck; bh=ohokba/w7wbcANp2/G1JYz10nCUZvl9JMLZYBMWxhD8=; b=Yq6WRkQ3IRfBjn7zJ2ehEO47UdqxfGoyyi/OpBzOGiGalPZnZwrJwtDjgX18SDpqtv3KjWr5TfBCgCP0dH2AjYkHAywkJm0qRfcmuzTSOQCn/c9jSbTXp3Ks3gbwZ80B2Ij9SLX4DaQdwyhY6VQM6n7C+5XdU9RRNVYEYvaWsCs8tgW2vUwWKhS+TR42eXkVc+SKCG2G664v99EtReNtGJwFiOtQGaQXKhRvG7bfOJtIgI3X6PSL8H26/lFePdEYL6hi4zsoofuL3cO2HQ6mCOm9tBbpbURIxSm0KLylDa3OeXklihkjlycg8mM2iumIbSQ+thUv3J91HOOZ+z8Vrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ohokba/w7wbcANp2/G1JYz10nCUZvl9JMLZYBMWxhD8=; b=bZn2ii0VUkX0nKorZgJXNQVVdZxzJ8ejGu/W79naXI5wf6sC+jQtZnSTtMK9Kf6MmdPi8zmCv3lTDryAgy69E8hkC3iHvE1MN8nM3RYssyUnYijR1sySKEZrCYq3vQMrRA02LjEJbhIRGJU5uzZnwvYrd82wAX1CDcbl7Or5qfs= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none; arm.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) by AM8PR04MB7730.eurprd04.prod.outlook.com (2603:10a6:20b:242::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27; Thu, 18 Feb 2021 05:28:56 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42%6]) with mapi id 15.20.3846.042; Thu, 18 Feb 2021 05:28:56 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, Laurentiu Tudor , Diana Madalina Craciun , linux-arm-kernel@lists.infradead.org, linux.cj@gmail.com, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v6 13/15] net: phylink: introduce phylink_fwnode_phy_connect() Date: Thu, 18 Feb 2021 10:56:52 +0530 Message-Id: <20210218052654.28995-14-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> References: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) To AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03152.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 05:28:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 948fa1e6-791e-4758-eb30-08d8d3ce1608 X-MS-TrafficTypeDiagnostic: AM8PR04MB7730: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gASrp7hzPU0VxAYK5N0OKjlbPa9DpF/xWovK9bOt9XaOGwo1HztvCTd3kSRYmnGMKu1epksDN2qS6wsYPUO4Jvp/gx7KS+X9WKzDhlnhR9GUe/nz0d0nk05ScX7VHD6uk1HOtzm52wr/JG6C7FO3X/vb3wgjR/oW9yl6Gf86kKf/nqIRkHl0cP1+HsNHRXX9RXYi2hFUQ7/2FItaSIbJ7ZqCTNovvP+Od3FKuxfSR/kqWAAGLd/kFOtRKrm8id/oi+xoLvj4MG4IzouN8d2ggO30w0xfKcFO8k/pVrrJE1A+yJHWTBtYcNueG1JihU2BtMJR2iMhzpGR2lVAAZMYnpZpQOkeX3ICGRQaXx0PNxDSeUi3xGAgboDHVMN2Tbm6Xe1HU8hNBBwbeuw15yhPC17Ogjv3kqxrBLPxUWLXS72aXM9GkubUUukxunxvlzBflk2pZpDNWUhQLjwkwCz3OqkRc07izzjtB4Ym3OXXWpSbT/a9irASkVeihNKvyKjvNBDJ6K3IKn6RKeyBCRLgjJdiyvRXMiHpyyiK3uEpGvFZ0z0DRecV1UnkacsD6Oex3TqoktEK4/h8rCNXHleowYG/jCWI12s58ucAZ1gAWP0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(39860400002)(136003)(26005)(8936002)(52116002)(16526019)(921005)(478600001)(1076003)(6486002)(8676002)(55236004)(5660300002)(186003)(44832011)(110136005)(6512007)(956004)(54906003)(316002)(66946007)(2906002)(2616005)(1006002)(66476007)(86362001)(7416002)(6506007)(6666004)(4326008)(66556008)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: xCro8pZlpEgvYfwRXhDIniDClKp28sJzHCebkhr6mBesxEwNBF/ePvVWBwr7hYtuwZxCWfUn9YXosAI7h97eMoDjLsuhSFE+CVS9dQAU3nHPNqySAYtUubLdl4Tc3wYuKMqpFIjWSfLmUx+sLgmqflpLE13PFXqK7c5QU1GmEN1p8UW6lE/4Lm0u2DQithKlCKEg4RK9Z2SFHp8Ryc+ykDNZ6umRBv8tptJoHBqmnSNG6LeZGnVRxfX3x7dDXoRlKuPkm8Qr4QvJ8BySusVnajBg2/MSghHGSOgV7LZHrH2j+YEzPk2Wut+PgkncuKMMMTF0iUD/zn19uz4q5yPUXntw4gt14Nuy3c5Ew89vqnydlUYfQYgJrR463NW76M4GWZ/XBJxYUtOHpKK+tdTpYSg4iYEyXe6V/VU+LszT9Y4TRx8nTiqFPRc8eiJFxnMAz12rk6mlg64jzI5ab/JwcusHAgAaGXyzCKn36Ush5bKgf3y14Jx3doF/+RL+Fqi1sdflS0Z8AEwPGmQh+CZXeD4WvMeokC3BS+Z9cmNaczzhCdTFYk+lVuK2dTc8BbTjb8SYqjz5ZWWc5KKVu3vsgFPbtJJVeKsBrL82bxJPzASFWWpQdpb8pvDc91DIS5ttVXqk+a/aMIwY43ot7NAbeCNLSatmvz+x245YiHW0XRt4/vw7bJ9gAzv/jv9EPHBI20meit9aDTGq9kOvQv3/MiDl/vIh5YRweElkUR0mu1Zt48/bwtpBewyjiuR1lMv047D7af6aztTw4VcRfFk1v118AfrTJQTCP/YnRW8MDq/5kP8BVnbGT62d9t6+4JQIdYqBq1NOgzYZBIYsRY+hXdH1FRL5GO9UKZw9jjqNgdXXh8MkhAiJ/kf5fOxV3wNBYfbuSQHq92D3f1m2175phqmYkKqrEsZqKV6XaaZ2iSa0RPhB0LrmtbPLH36BkhQodzIF3RdpBwIwdGW3DSxKjjSlkinZPIUFcT3ugfmbkFfTcfUxqNo7Hx/RFn/USpoiKIDDJXpBqWpC9ixI+YCoWREJNp67mqlP8oKdx71JzsDyZ3ma1qBcniyLDMsArHtNCfZw3RVrrlHqc7bvl4RIOYV41F+FrDmGPxP/ddfv/WDnqC8Q9VnZ2T2lRmpLBRc9qQq0zEP/DXS6reLxRWT9P9PDMnWou2fz2PirH+KJ5Rra/HMRw6A5adfkGF7YH2SzngE+uiyXh8IWmsV+OBqAu3nS2X5GBKGIY8LAe7YMNy0dxLsktXxt9H/Swu9E+sgO4Vsv1suwayicf/pFWIx9fQxsZ2j+degMrwHLsmSc1coDRLRRqfMzWLk8sM5b3Joq X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 948fa1e6-791e-4758-eb30-08d8d3ce1608 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 05:28:56.1341 (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: dZxjyILY4yOy4Siubu9DoR9UAZL1D3SAz9YFN1hdp/aUYPAQe4/lABhnBj4cQEN6ggM3d/6NnCkl7ntji0viBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7730 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Define phylink_fwnode_phy_connect() to connect phy specified by a fwnode to a phylink instance. Signed-off-by: Calvin Johnson --- Changes in v6: - remove OF check for fixed-link Changes in v5: None Changes in v4: - call phy_device_free() before returning Changes in v3: None Changes in v2: None drivers/net/phy/phylink.c | 54 +++++++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 3 +++ 2 files changed, 57 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 053c92e02cd8..23753f92e0a6 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -5,6 +5,7 @@ * * Copyright (C) 2015 Russell King */ +#include #include #include #include @@ -1124,6 +1125,59 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn, } EXPORT_SYMBOL_GPL(phylink_of_phy_connect); +/** + * phylink_fwnode_phy_connect() - connect the PHY specified in the fwnode. + * @pl: a pointer to a &struct phylink returned from phylink_create() + * @fwnode: a pointer to a &struct fwnode_handle. + * @flags: PHY-specific flags to communicate to the PHY device driver + * + * Connect the phy specified @fwnode to the phylink instance specified + * by @pl. + * + * Returns 0 on success or a negative errno. + */ +int phylink_fwnode_phy_connect(struct phylink *pl, + struct fwnode_handle *fwnode, + u32 flags) +{ + struct fwnode_handle *phy_fwnode; + struct phy_device *phy_dev; + int ret; + + /* Fixed links and 802.3z are handled without needing a PHY */ + if (pl->cfg_link_an_mode == MLO_AN_FIXED || + (pl->cfg_link_an_mode == MLO_AN_INBAND && + phy_interface_mode_is_8023z(pl->link_interface))) + return 0; + + phy_fwnode = fwnode_get_phy_node(fwnode); + if (IS_ERR(phy_fwnode)) { + if (pl->cfg_link_an_mode == MLO_AN_PHY) + return -ENODEV; + return 0; + } + + phy_dev = fwnode_phy_find_device(phy_fwnode); + /* We're done with the phy_node handle */ + fwnode_handle_put(phy_fwnode); + if (!phy_dev) + return -ENODEV; + + ret = phy_attach_direct(pl->netdev, phy_dev, flags, + pl->link_interface); + if (ret) { + phy_device_free(phy_dev); + return ret; + } + + ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface); + if (ret) + phy_detach(phy_dev); + + return ret; +} +EXPORT_SYMBOL_GPL(phylink_fwnode_phy_connect); + /** * phylink_disconnect_phy() - disconnect any PHY attached to the phylink * instance. diff --git a/include/linux/phylink.h b/include/linux/phylink.h index d81a714cfbbd..75d4f99090fd 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -439,6 +439,9 @@ void phylink_destroy(struct phylink *); int phylink_connect_phy(struct phylink *, struct phy_device *); int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags); +int phylink_fwnode_phy_connect(struct phylink *pl, + struct fwnode_handle *fwnode, + u32 flags); void phylink_disconnect_phy(struct phylink *); void phylink_mac_change(struct phylink *, bool up); From patchwork Thu Feb 18 05:26:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 384775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16F2FC433DB for ; Thu, 18 Feb 2021 05:38:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D313D6023C for ; Thu, 18 Feb 2021 05:38:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231265AbhBRFhs (ORCPT ); Thu, 18 Feb 2021 00:37:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230309AbhBRFdh (ORCPT ); Thu, 18 Feb 2021 00:33:37 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0603.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::603]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E44DEC06178C; Wed, 17 Feb 2021 21:30:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ep38+QL1G7Ahwsvf++gNP9TJ1A9e82oinQh3Jl+3IbbgUP9bY6ivzLHIq3khEU7wouueCiLkV0XB2vfYxDihbEty/nEsIZmXt5do9+WT992ahAqSMEq/4qqvbuEVtOGer7jktwKOO9pe+nztvT339bqN8DP/xIXdi2NY0VtvBmscxSdHL+1N0YVilNG71WNvDk199PHU+Atnnhpmcj3UwhVGnolZsYD6Wh30R2675dMIXWxcEwxMxsJ3G4F1hrNPBZgEaeqL6DIqv+3Qsp9j8AtZjm7uhw2kpNy1RuOSrxQfp5ObdcaYVcn5zRqPr2ebijJQ3MtSy1ebQa51xxy5Yg== 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-SenderADCheck; bh=kBwdEWmkcu8/U1Y+MFpbmKXP42UUfum/P/awBMJZrPA=; b=PIhjcptJIRlmj8qgvKObwdTJvPXB+Umt5Kbms7Ea4rKwccVzn2puiEQrR6wCdsoYS2I3zfCuYywezPEZgly0xeN5EqhPoJ+FA0FRrwyPLiy1FrqcYF6Fv4piHPcjAm1kriJzBOq9ky69hAbRNBh2jzPRarGJDpu36xUwovnJkQNZh6YYO1lfQbAhyVj+0HxqiL4t3FPX5RmvvuQDDmJJohp65swd3DhW5r9e8YyTJ4wa13OIJU8CgOJn2aQdYrz76AXVhu1cTd2Bo8usGCRBva8SGe+2lFop+Ny2DbQkS8S3fsgjMWXf2CgVK+4RbclT3/VZJD3odahpoUCgqq197g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kBwdEWmkcu8/U1Y+MFpbmKXP42UUfum/P/awBMJZrPA=; b=K4RSaK2nKjy8UPSHoJS/WJyEZMNqPz2kmIR+LzuCriP8ml9U03XfZHFrzSFFEK8cVfEx7cmrQ0gLlUWDFccdwuzv3W5OnrwkZskHeipYpv0mwTcYy9bI8+bBnDaNobtbgt77pST4JQ/AkSNaETKSCWIY7entMZLLaxAQAcv+l6I= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none; arm.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) by AM8PR04MB7730.eurprd04.prod.outlook.com (2603:10a6:20b:242::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27; Thu, 18 Feb 2021 05:29:09 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42%6]) with mapi id 15.20.3846.042; Thu, 18 Feb 2021 05:29:09 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, Laurentiu Tudor , Diana Madalina Craciun , linux-arm-kernel@lists.infradead.org, linux.cj@gmail.com, Calvin Johnson , "David S. Miller" , Ioana Radulescu , Jakub Kicinski Subject: [net-next PATCH v6 15/15] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Date: Thu, 18 Feb 2021 10:56:54 +0530 Message-Id: <20210218052654.28995-16-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> References: <20210218052654.28995-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) To AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03152.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 05:29:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 718cd302-a9e6-48d3-95ea-08d8d3ce1dfd X-MS-TrafficTypeDiagnostic: AM8PR04MB7730: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:972; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rKA9Sqx+hU/NqIwjFUfqs/6rVfUCcdZ2f2tefXCH/VWxJMzMhSYAcp8xoNFNQcwpVhf3GYu8ebNw2fDMm+rjTc6YakZkGkWWsgU2e8oRNdizk8df9L0m/GbW9ZZVmTiVUIBHmcqqm9jFAXsHsK8DqUR76dcSCxl4kWIHZc7oNdHA7y+1nQ4M15qUypCvyfbWXK2XYAi1DowYVWj/Mno4w3Vkt5A2T98/DSQDQO0sAuisCq75DEUZuxdJ2LurH3dsDhtoQ7LGsawQ7TSfXapQd9eN2BkjLplXTzsEieVvyc71DMmnM07Sd08Q2zlSYVonoFS5ojS1HGqoXqJAIbwpeAQGdJ+a0mGkApb37H2/EDSwkeeieRUdH+UtQplkSGRVjTQ2asgxUPM8RaNz6wl88vpiXBu+e9KxvOSXR7cO1LQP79yKeipbReuIcN5Wlu1D0rITfZaq0M7IuqvVxnjMTlxnqMmYveN4fYn3x5YyPF+ZookIt6p0Q4DEXsQzSl7xhjx2TpUr8w5vDuBdwR4E5ZNdHaQ6Lci2lw+yJa7tGS2jYhzNgPEmPIhwHDJiEIakBOFHnAJbm5dIhiZHyJwKMf/kWeOevqZ1VvTmPlJz9Hg= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(39860400002)(136003)(26005)(8936002)(52116002)(16526019)(921005)(478600001)(1076003)(6486002)(8676002)(55236004)(83380400001)(5660300002)(186003)(44832011)(110136005)(6512007)(956004)(54906003)(316002)(66946007)(2906002)(2616005)(1006002)(66476007)(86362001)(7416002)(6506007)(6666004)(4326008)(66556008)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4CkvCq6u4jPrfp4wSzs0yEFA9HVN2upRhrW/wiHpgqx/l5Y0NlAUwyslx90ETrXGZ8j8tGAvFIz2NgNUFLz3I/6VcAWuqTrBqYqSf9mbaWemUPQ9WjvZa7be65HH1Z6D7ZLSbk4VcgWw5SKi0zzMtyk8buYH/CL3GZ8qwixHuHA3gd4FpmmGDS04WWfrzMjHo6UJSrmRu/Ejgp54dRdmEWpo27l1h42csMh5TNCYxitPqJ/UtS+xdyNhjq6XpRRe+Y4FAnvO9f7G5zjg/miPsApDAZrpMdb1XxA1HERaEUDrnd90Vs+TODxbYBmp8jwYfqurJ4c6t0svUlxosv3zQt8uH6XOc4/yOTTMKCZaTw4KBq/tXiavt1RwyD9N4d82vOVBmI6KwecQZlUAw81/ZiX9406IHHmrsE/15/GzmXzsb3PwfrZPe2gWvzf0lq3oN22KbhJKce0zpDSpmh22pveSlbtqCxit5hTQA/BrtROp+vJ/6zEvh4n9J2nW5CDUXT/iOJTrOwwi3RPe3Cem7OGEuRdYZRPa4Csp+KOKP9TRQyiQ92463LnfKUULzhKz5IFWFNzThrHPKOkQrbvIR6GWM3fbZpfrRFHAgn13X9SO+chxbFPX2qn8egG5AAZhozyVUSVXSKrkYug9nOhFRn4vcY+T9DGrSfGDCecBPtAVzfSVhTOt0UImIhZ2tNL56aMoZqG5AKxOoz8W9GjTC0ULdcpLrGXPUX1dHLSXYvFRsIgtk5Sk1v8W7lFFt4EOuNbc1xWdCCvdNYlB+tQayJ0bSdqiN3SScF2oRLKpgKh9FMqYWEpOMOJ3Ar8s6GS0qQf0eHI2jY4DPgOlz2715rBu/x8IpFJF5URIR2gn9mzsDCCH5PqELQnPePQg79ImvJN3ARr6C7EX7iJpWTRpaCw3oTvsw5HvywrAHuVSP4KgsrimX3kuc7WXj1XUCIIjJKJDfaK5hJo1tACasy61HyIwpv3e8UD5HVO1sC9ppyrk+Dt5Kvq1pVbDArAtpNJhsBlyhk3C/gfGufYBvitD2xY/aoHx2QgZaCKnng4e+Pqg1oxfSCwYZuVdIbEJs9wbfjrsd72HemXIHROoqk1tNLOoyyJ0CEmruq9rZNSyD8alettWyXWIH8G4yZzLBhbbT7o+/hbi6d6AUU3SGuUSDx6MSuchcB+PbayfvOJxDtc31y4zPpbQ26VBUNARMQ3cKoTBdHrMZFCHFaggEJ6w/x7x7fW5BNGJ644oL5zTEQ6fh0j17n8n/f+1EXy2BslwqFFWjrixBDrp+Ji7oPTR75sV03rPvG2k8+YhVSp/cthARfrfexVQwmvnQPVLq/zB X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 718cd302-a9e6-48d3-95ea-08d8d3ce1dfd X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 05:29:09.7024 (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: 3A06470WUfiFt/wdlU+P3ohAje3BRSsEcYz4iJjkRALPZhM8/P8Y7zOC1nkLkH2fAMjuLs5hyO89haVeiFXnFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7730 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Modify dpaa2_mac_get_node() to get the dpmac fwnode from either DT or ACPI. Modify dpaa2_mac_get_if_mode() to get interface mode from dpmac_node which is a fwnode. Modify dpaa2_pcs_create() to create pcs from dpmac_node fwnode. Modify dpaa2_mac_connect() to support ACPI along with DT. Signed-off-by: Calvin Johnson --- Changes in v6: - use dev_fwnode() - remove useless else - replace of_device_is_available() to fwnode_device_is_available() Changes in v5: - replace fwnode_get_id() with OF and ACPI function calls Changes in v4: None Changes in v3: None Changes in v2: - Refactor OF functions to use fwnode functions .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 91 +++++++++++-------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index ccaf7e35abeb..3e39a15b001f 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -1,6 +1,9 @@ // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) /* Copyright 2019 NXP */ +#include +#include + #include "dpaa2-eth.h" #include "dpaa2-mac.h" @@ -34,39 +37,53 @@ static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode) return 0; } -/* Caller must call of_node_put on the returned value */ -static struct device_node *dpaa2_mac_get_node(u16 dpmac_id) +static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev, + u16 dpmac_id) { - struct device_node *dpmacs, *dpmac = NULL; - u32 id; + struct fwnode_handle *fwnode, *parent, *child = NULL; + struct device_node *dpmacs = NULL; int err; + u32 id; - dpmacs = of_find_node_by_name(NULL, "dpmacs"); - if (!dpmacs) - return NULL; + fwnode = dev_fwnode(dev->parent); + if (is_of_node(fwnode)) { + dpmacs = of_find_node_by_name(NULL, "dpmacs"); + if (!dpmacs) + return NULL; + parent = of_fwnode_handle(dpmacs); + } else if (is_acpi_node(fwnode)) { + parent = fwnode; + } - while ((dpmac = of_get_next_child(dpmacs, dpmac)) != NULL) { - err = of_property_read_u32(dpmac, "reg", &id); + fwnode_for_each_child_node(parent, child) { + err = -EINVAL; + if (is_acpi_device_node(child)) + err = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &id); + else if (is_of_node(child)) + err = of_property_read_u32(to_of_node(child), "reg", &id); if (err) continue; - if (id == dpmac_id) - break; - } - of_node_put(dpmacs); - - return dpmac; + if (id == dpmac_id) { + if (is_of_node(fwnode)) + of_node_put(dpmacs); + return child; + } + } + if (is_of_node(fwnode)) + of_node_put(dpmacs); + return NULL; } -static int dpaa2_mac_get_if_mode(struct device_node *node, +static int dpaa2_mac_get_if_mode(struct fwnode_handle *dpmac_node, struct dpmac_attr attr) { phy_interface_t if_mode; int err; - err = of_get_phy_mode(node, &if_mode); - if (!err) - return if_mode; + err = fwnode_get_phy_mode(dpmac_node); + if (err > 0) + return err; err = phy_mode(attr.eth_if, &if_mode); if (!err) @@ -235,26 +252,27 @@ static const struct phylink_mac_ops dpaa2_mac_phylink_ops = { }; static int dpaa2_pcs_create(struct dpaa2_mac *mac, - struct device_node *dpmac_node, int id) + struct fwnode_handle *dpmac_node, + int id) { struct mdio_device *mdiodev; - struct device_node *node; + struct fwnode_handle *node; - node = of_parse_phandle(dpmac_node, "pcs-handle", 0); - if (!node) { + node = fwnode_find_reference(dpmac_node, "pcs-handle", 0); + if (IS_ERR(node)) { /* do not error out on old DTS files */ netdev_warn(mac->net_dev, "pcs-handle node not found\n"); return 0; } - if (!of_device_is_available(node)) { + if (!fwnode_device_is_available(node)) { netdev_err(mac->net_dev, "pcs-handle node not available\n"); - of_node_put(node); + fwnode_handle_put(node); return -ENODEV; } - mdiodev = of_mdio_find_device(node); - of_node_put(node); + mdiodev = fwnode_mdio_find_device(node); + fwnode_handle_put(node); if (!mdiodev) return -EPROBE_DEFER; @@ -283,13 +301,12 @@ static void dpaa2_pcs_destroy(struct dpaa2_mac *mac) int dpaa2_mac_connect(struct dpaa2_mac *mac) { struct net_device *net_dev = mac->net_dev; - struct device_node *dpmac_node; + struct fwnode_handle *dpmac_node = NULL; struct phylink *phylink; int err; mac->if_link_type = mac->attr.link_type; - - dpmac_node = dpaa2_mac_get_node(mac->attr.id); + dpmac_node = dpaa2_mac_get_node(&mac->mc_dev->dev, mac->attr.id); if (!dpmac_node) { netdev_err(net_dev, "No dpmac@%d node found.\n", mac->attr.id); return -ENODEV; @@ -306,7 +323,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) * error out if the interface mode requests them and there is no PHY * to act upon them */ - if (of_phy_is_fixed_link(dpmac_node) && + if (of_phy_is_fixed_link(to_of_node(dpmac_node)) && (mac->if_mode == PHY_INTERFACE_MODE_RGMII_ID || mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID || mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) { @@ -327,7 +344,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) mac->phylink_config.type = PHYLINK_NETDEV; phylink = phylink_create(&mac->phylink_config, - of_fwnode_handle(dpmac_node), mac->if_mode, + dpmac_node, mac->if_mode, &dpaa2_mac_phylink_ops); if (IS_ERR(phylink)) { err = PTR_ERR(phylink); @@ -338,13 +355,14 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) if (mac->pcs) phylink_set_pcs(mac->phylink, &mac->pcs->pcs); - err = phylink_of_phy_connect(mac->phylink, dpmac_node, 0); + err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0); if (err) { - netdev_err(net_dev, "phylink_of_phy_connect() = %d\n", err); + netdev_err(net_dev, "phylink_fwnode_phy_connect() = %d\n", err); goto err_phylink_destroy; } - of_node_put(dpmac_node); + if (is_of_node(dpmac_node)) + fwnode_handle_put(dpmac_node); return 0; @@ -353,7 +371,8 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) err_pcs_destroy: dpaa2_pcs_destroy(mac); err_put_node: - of_node_put(dpmac_node); + if (is_of_node(dpmac_node)) + fwnode_handle_put(dpmac_node); return err; }