From patchwork Tue Dec 15 16:43:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975323 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 C0938C2BB48 for ; Tue, 15 Dec 2020 17:00:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 896822251E for ; Tue, 15 Dec 2020 17:00:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729635AbgLOQpe (ORCPT ); Tue, 15 Dec 2020 11:45:34 -0500 Received: from mail-eopbgr20071.outbound.protection.outlook.com ([40.107.2.71]:62181 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729523AbgLOQpV (ORCPT ); Tue, 15 Dec 2020 11:45:21 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OTkBtLrvgj4ErsAJTK4nXz1u7Fe5GjtsVWjtdVLRXYnPBGCL27H2ZccYEgYDjwvtFmic79UX4lwdQId6IVKhoSy6FHAeagqxR9NIOJV+a8PtvV1Hfe4CdtczVH6i1sczy18YJ+rasq64eq8m2TRoG0jp2d97ykE8N4rLFd6u4fCosbaglU9rqPrOy4k36ERpRxoAqXFDIi8Pwt/sUtowfcHkTRIbA2TS7pvBPKiztZg+MHbJzBwqi3izUleH9R4A6e5JqQ8kj4IzzYFQxVc3/h9ngRpTaPM93o0u0CkDa7h35dkyUBuHSLmATiMZpPwNYIjSid7C0MQdcovsHXp61Q== 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=k0Q2UiM5AbjyRcb73lkL0nNYCTf71tN2dPXnwglWh+E=; b=ns6YAZTjnk76p5RM69kZu8sUNu2GePzqvcNE+XnKL0GuYklMQPcZ3sD0xaYfMb5HetUASv+HcgrOpQ6QCXtndRI6TeiXfqSpgE9vVfBA/+unN3oD2ZOP4S22KZ5+E//daHV4MH7sBbec87AZd3YGSmQZ6711yGSg3ri3JgbWN6V1OeMBXrSfB5eXCnMcRBWHEMaeXkCLN+1iAgjnVcaqzb0hQlsFMDcYRA9vU5+aSJYfyhmqkNkyicSGycOoxxcaGvdMryq0LoO8digZs7FoDtjgy+xGapHlx0YvpMsu7dW4AkIRBv6JehNAtblNigdJT00NFcujuLuAMaqxFz4tSw== 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=k0Q2UiM5AbjyRcb73lkL0nNYCTf71tN2dPXnwglWh+E=; b=eD9KPsmnej9thPFNuiN4aM2rdQkXRDx4QLDxkQ0H4M2sBXT01xGB0Cd8evRXoSbZtiDfnGN91iIaxFRqA4Wu0tVs5aIMYQyVaYxqpgUMJh2VFTtmEO4X5KkDMmzivBD8evshjlRZQuo9LeFQAJF/LqrhZkyiIp3E/vcDHXUbd4s= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:43:57 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:43: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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , Len Brown , "Rafael J. Wysocki" Subject: [net-next PATCH v2 01/14] Documentation: ACPI: DSD: Document MDIO PHY Date: Tue, 15 Dec 2020 22:13:02 +0530 Message-Id: <20201215164315.3666-2-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:43:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 79d14ee5-2895-4de3-18e1-08d8a1189db0 X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: 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: BiaW/SIdeZC5k7Kaykm0mTajYiyERoMBaUZMnsc9BGZQKLRmW1Kf/9mtYMkvXusa0VD8r1HtIDKxmebXHXh8ZbXuii+/Hd4Nr0SsSuidLhacYnAGMkHQdsxYCgw6T4HFiUT/SURaOmi/N/uXBVvQfKTFH3eTJ+j8i8CJLWg8OxvUyI45QNK+y2J+APC2l5+6udFYkh/20niu0sBlI9pmbIgekKHMfHvnf2ibI5A27pd7j962BrGHEjVcIMsno2hoUbg/zuO4jhsg6mgceZ112EYcW1ljZbONNlAczCPlnfrV0DbM16L1kEYQGDUm55ws3gikRGuzuuB8Xl16TpPy5otyWFV2Xq+kXaxL4DwcT1iyuNoTINyhqVIVUbpYp9D1SwPP1oTDdhde5yj/l8HvPnlWqpEwg6oE2cSiqWMC/3m0ndSuDYjrGoiQv8bGLfNa6WAI3EeMZJZWQHYRTrQDCQimmZktvhxpEMyPKX4cPiQ= 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)(54906003)(8936002)(4326008)(6506007)(498600001)(83380400001)(66946007)(921005)(966005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(6666004)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ha4xAf2U4XSU1/qXmGOwDstEYOnncS07EeL8uL0Kk2Zt/qS7l0Z42RxjOm1v4b+HQdNx+09GfeUTucTElEeAFt7l/OD2MM8xlPmcZSAJoMF8X8W7YVx/JbqA1QszdQtNGEbVaFp1ZPEaJZ2mR0lqkKRVEwXc1W8lPeRydjVT/KtClZnbY/p/E2ca7d127aNmUGWos+bv1Vvr8pngAQ2B9c+1DDl0evXjouSl5GwyfYhTKWsxbNRCNArdZoDMU+QxQeS90aRj8UPukz0JvKPFrMsH4zADDyP9u9RSqhpr1+SjZs9MbSwXfWmuyflLbfkuigO52PFmFjd7+9LRhl111GVIb8CdvsTVTCRxMDz7cwi85zJfVwDfV8UiU1OP41AjF2j15UQlX62qZVT/0Ag4x3RYwsK6kZjkX4AqYedfDEUjleBAzaNsMyynubWt9HGi3w66EXcsrQpee0axF1pa/BI0ZkLSQWlZZw2qrq3bVGTZ85pnd3MtjpMVGMh9ZDWPHjcdMX/7tT6oajSHUYac2nNQ8/tw1EdAonKMjgiSnCk+XBnI/j4kAzfpVhieYieJen/3c79jjnGCPTrRKj01lF2kI8mC7NUa3iTIsXU7gLrpoh6tE/XudcGtEnucvy7V3/igjMdOlP3iZRPQ4kuhadcAir5DRjF2AISLgPhue0w9OC/7lkYnlMDLoV6AH6iNrwXz9UclM2T65y9FmdxVGvFX1+4SGuS9hTyI7+Y8SL/ax6ei9iJrde0TrPCQgoYdDazCfiZEqPql/KbXJ5UPlPWPS6Etwk39K9cTowHL/SJbSkO41m5k+fmqtMlZq+IHl6gwW3AkgiiZGA/C1KaC7STJpLM2Aetij46JefKHA+c499s1+pmLtq8pVYgTqlAhPiG9sAzDr/R+2NsKPERegAKl8T6chhP1SM2w0ZD59/cgJoqh3KGdgK59sd8vJ92cwt0bRoCmn4odHVFusw1P4/+8gcqdkG3O/Gz3+xx+W0hneh70ut+L9cdMbXNXuobM X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:43:56.9276 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 79d14ee5-2895-4de3-18e1-08d8a1189db0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: J9g1EplVuaoSWvLIybFPdpGLTbQsQ93bEGA+I8pifzjW1IMDZDtyt25hhOtYtwoyhEnJ2s/6SSyC6aZrENh4fg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 v2: - Updated with more description in document Documentation/firmware-guide/acpi/dsd/phy.rst | 129 ++++++++++++++++++ 1 file changed, 129 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..a2e4fdcdbf53 --- /dev/null +++ b/Documentation/firmware-guide/acpi/dsd/phy.rst @@ -0,0 +1,129 @@ +.. 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 MAC, the PHYs registered on the +mdiobus have to be referenced. + +UUID given below should be used as mentioned in the "Device Properties +UUID For _DSD" [2] document. + - UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 + +This document introduces two _DSD properties that are to be used +for PHYs on the MDIO bus.[3] + +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, MAC driver needs +reference to the previously registered PHYs which are provided +using reference to the device as {\_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]. + + +An ASL example of this is shown below. + +DSDT entry for MDIO node +------------------------ +The MDIO bus has an SoC component(mdio controller) and a platform +component(PHYs on the mdiobus). + +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 +This node defines the PHYs that are connected to the MDIO bus, MDI0 +------------------------------------------------------------------- +:: + Scope(\_SB.MDI0) + { + Device(PHY1) { + Name (_ADR, 0x1) + } // end of PHY1 + + Device(PHY2) { + Name (_ADR, 0x2) + } // end of PHY2 + } + + +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 Tue Dec 15 16:43:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975243 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 36F51C2BB9A for ; Tue, 15 Dec 2020 16:45:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01381225A9 for ; Tue, 15 Dec 2020 16:45:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729695AbgLOQpf (ORCPT ); Tue, 15 Dec 2020 11:45:35 -0500 Received: from mail-eopbgr20054.outbound.protection.outlook.com ([40.107.2.54]:56934 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729453AbgLOQpL (ORCPT ); Tue, 15 Dec 2020 11:45:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GJZtJlpgwYh5QUyE8S4l7JneGNHZy78sLTG3nwuBFGzcfvSrzkKpxyvDuy09T/htdU2BrdUyqsR7fV6JQD6ntE3lqNbIi4yuXDu1Y+pQ9tJ72L58wsmpoQ8C5u3hqHZ8VhibJlhj8HQQfzZInTa6TLYOYPBD+yS8hKBq32wkfzQFoS078YiiwRZBWMuGX5cblczZ3Fr+6n3ZuYGFy5vMQsEtKDDDiWYjJQBpJQ06YYb7Bqm445gA5bQZnTR1W9tcHvwZsLRfIIp+wyA4E7NIwE4MrzbxXRIOCoUr9Q+IF18HDCvpTh92hm/I334/K5YF6eayskvAEfjLFyy4KC2WuA== 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=p4X4WQhBWjreYs41FUyUmSUAhA1txuBBdVGLOwpyqK8=; b=esk45H7m/v/acplSKEkQWlzZPAzXdi7VLjN2T2zm6v1tuwrxE2i6I0spKSRpQBp54zGl8euvi4NVUQmGQMDtnMxRvrwDqyx8pZmNwtkzif1zQn/JnC97Yp4kqHD4NXn8O/P9yH1GyTtwHd0FoawD10BwO8tauWCglAVeMmHBztLHsU2cyIXjEFooN0jO/3tL2Xc5ATQIocK7HIPX1J1xHULwfg33ACrnhDbHdBnhO/2jfQ3bAqorenA6MEGtZYmM0N0zq5J4WCyFemby8HD+FcntYTwZ6vvbDGJEI6fv6xIJqe87k7hCiwbdKeP3RU4GpXUiofJnynvKAM4VjwNgBA== 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=p4X4WQhBWjreYs41FUyUmSUAhA1txuBBdVGLOwpyqK8=; b=ZPNjCZkiG03cXlP4XNkQw4Rg715cLn/8WRyCOiaKmWO2l9BadfguKv7yrdOTMN3KVsrjnVfkyiYfnFKLhLd4exzKW/Z2imi4+pLjwg64Yiwd2jcnxqgHHkAIC0xaOgVaW8lu7MuCbPntCIjBvAumwk5d5hpyRswsa4ULxqhuNvg= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:44:03 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:44:03 +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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v2 02/14] net: phy: Introduce phy related fwnode functions Date: Tue, 15 Dec 2020 22:13:03 +0530 Message-Id: <20201215164315.3666-3-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:43:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 22de5d48-859a-408e-a6bd-08d8a118a1c5 X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IYxM4SBTonhlz78F2/tPGhVCXsM2kXeXSBFmoAMcm/UxVvU8EWQ+KkfnPe9Q3e37NWZeS38og9uVp5rzYBkfA3byXmIl68XOiXMpzirmrz6ajizOFLyfnrmzZRm96lH1mISuzJ9FhFbJ5wZsTldJzQjv5JOtm2JUG+27dMoUQYt8wKk8TiYp6U4jd3KG0+vryr5hJquNxFEylLSkFKoViIc8jwmnVJbLd6fr2hmIZcCKoW+vEC0Rt7WKqKnGOb+djph/y2ehIM0/P8gGtTPKoUKAZNfneUNB2o3/c981ccdQ3oMoXpcSLZw8ebN6kcsTjoVAQsCGfacaRfr3vUd+ueHmVkJF9G79SxpuM/PJYVdbSFdnQao8AprETwon1U93qOyOwXDOfHWKIkCT/jzRFg== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(83380400001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(6666004)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: WFwvzYQ6tCmYu1NNG7hhbUqZMvC2+YugBqa4VBPriqPiHnC20wN/C/eloJyynk1pukh3kOB/3cA4ga5KsOCMKvhr+cw9FT3FuqTP/CvaD95XM/Usf0Dwg1R97wPa/fkydBAxMBABYwOtiDaG6UqWsUdkW9Cm2RazpM0QGejzl3rwpeXor51tySM4I97bQMcx5+102NBQ6HDoxJAK+S0BIZZOzJJRl/08uPtMdfZH7B9jFElWxqm6oRnw1uJhWAPim/QS9mGUGAxs1JLmz6AgaNwYyAsjdHdV/LhyJWeMai4qFjchFeJwUL1tEoKPTOmjdYFqKUm/ARxd1DJSPy42fCFbTmz++JJRfIkrw98UhFLrjopgthimpKH6zU6Ur6DZlhvwriiHin4B4hAbT5DZY/Sn0JSF2uuVHBGVFMLlt+9wfft6s5f3O5cCuXWmklVsMEv+RukOMqwqSuXsSbItg5EFDXsHQXSZ93Htxe4+hYNFRpD59k/kJbCNeghpvr5qemKcA6jyE/o1eABpuYDuLJERTtorrmsZNc9wGlOuZN7maQdXjN+WjRK5RGJQbYw/moaPnT2xG/a6Bbf51G7I2qVkn/Xuo1eaJ9dEmD7uwGDa2M757cT2xGQGhynRntLG4zmfPmeCBpTHtWkvGp7d/E5jcZmabuL8n8t72xnfGvG++/3PCkKT50QUqkbnZcdbLIFys8PV4xc7bz8ZGrX1gUB/6FrcH6FUepxrTGbb7BVFhz7SFGfw/nzG5G9i3eEa+TAu4qlYq4nAHDUNJptAwqYuij73H8HLhnm5mZo8Al8eOdzCjXStSFuLFp17QAFGcUHb9/li9CEDMswEOhuqLk3gXV7H2xxT3eOJ5bgSqVy38fjN/qY8hv4DQqbJGwSjuUyG0ZuZ/sdv1Q0dsL3wVQwekmY/mY9e++VYJVrSc7S7eNKNOjPjlAwRvFdGi1A2GSsgISOQ+oKP3aqUofy6h8Jddq3skq+UGjwudsMBA1SVifU6dvTZI/8zBCod2cnM X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:44:03.6878 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 22de5d48-859a-408e-a6bd-08d8a118a1c5 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: U6EdF8+zifbYL1RsEYztA6ENtoa4bRUhDiXiZJnmircGsF/hs0dRAMsrDaqiTtZza3c4nwfZvhheClOYxVw+Dw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Define fwnode_phy_find_device() to iterate an mdiobus and find the phy device of the provided phy fwnode. Additionally define device_phy_find_device() to find phy device of provided device. Define fwnode_get_phy_node() to get phy_node using named reference. Signed-off-by: Calvin Johnson --- Changes in v2: - use reverse christmas tree ordering for local variables drivers/net/phy/phy_device.c | 64 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 20 +++++++++++ 2 files changed, 84 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 80c2e646c093..c153273606c1 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -2829,6 +2830,69 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv) return phydrv->config_intr && phydrv->handle_interrupt; } +/** + * fwnode_phy_find_device - Find phy_device on the mdiobus for the provided + * phy_fwnode. + * @phy_fwnode: Pointer to the phy's fwnode. + * + * If successful, returns a pointer to the phy_device with the embedded + * struct device refcount incremented by one, or NULL on failure. + */ +struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode) +{ + struct mdio_device *mdiodev; + struct device *d; + + if (!phy_fwnode) + return NULL; + + d = bus_find_device_by_fwnode(&mdio_bus_type, phy_fwnode); + if (d) { + mdiodev = to_mdio_device(d); + if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) + return to_phy_device(d); + put_device(d); + } + + return NULL; +} +EXPORT_SYMBOL(fwnode_phy_find_device); + +/** + * device_phy_find_device - For the given device, get the phy_device + * @dev: Pointer to the given device + * + * Refer return conditions of fwnode_phy_find_device(). + */ +struct phy_device *device_phy_find_device(struct device *dev) +{ + return fwnode_phy_find_device(dev_fwnode(dev)); +} +EXPORT_SYMBOL_GPL(device_phy_find_device); + +/** + * fwnode_get_phy_node - Get the phy_node using the named reference. + * @fwnode: Pointer to fwnode from which phy_node has to be obtained. + * + * Refer return conditions of fwnode_find_reference(). + * For ACPI, only "phy-handle" is supported. DT supports all the three + * named references to the phy node. + */ +struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode) +{ + struct fwnode_handle *phy_node; + + /* Only phy-handle is used for ACPI */ + phy_node = fwnode_find_reference(fwnode, "phy-handle", 0); + if (is_acpi_node(fwnode) || !IS_ERR(phy_node)) + return phy_node; + phy_node = fwnode_find_reference(fwnode, "phy", 0); + if (IS_ERR(phy_node)) + phy_node = fwnode_find_reference(fwnode, "phy-device", 0); + return phy_node; +} +EXPORT_SYMBOL_GPL(fwnode_get_phy_node); + /** * phy_probe - probe and init a PHY device * @dev: device to probe and init diff --git a/include/linux/phy.h b/include/linux/phy.h index 381a95732b6a..7790a9a56d0f 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1341,10 +1341,30 @@ 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) +struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode); +struct phy_device *device_phy_find_device(struct device *dev); +struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode); 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 +struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode) +{ + return NULL; +} + +static inline struct phy_device *device_phy_find_device(struct device *dev) +{ + return NULL; +} + +static inline +struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode) +{ + return NULL; +} + static inline struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) { From patchwork Tue Dec 15 16:43:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975317 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 3B927C4361B for ; Tue, 15 Dec 2020 16:56:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECC8D225A9 for ; Tue, 15 Dec 2020 16:56:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730321AbgLOQqP (ORCPT ); Tue, 15 Dec 2020 11:46:15 -0500 Received: from mail-eopbgr20074.outbound.protection.outlook.com ([40.107.2.74]:21124 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730214AbgLOQp7 (ORCPT ); Tue, 15 Dec 2020 11:45:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LWoMwptZoUa2V6d9N4lg3/oJQ1dDwVxr+LsbIyCuKP651Cvofez2b4XFuOcZGWjXf+y74Lf3wrc1xDnCUaIckXtAmD8Rhrh5j0foApWpjUW8TSHNf3g0k8p+zKvamARV65EAM3KgUSWvdpgSJ5khCzbXlq51Il886Yhd9xRf4yBuaXkQLy6rWeBDifmTCJ9DdoZZDuLKx0pr5GSmjHJTyeqwg9ddIaPlQkyIvncncZFMnBbm3DDgpgeMfS2ahHCP37xHRUTtUkPWYKk0m5okMZ64otLjNxz9MTv3tsTmZ9rlt5PgJlIg8UzShSBOO9qIA2tFTYPAwGOvZ4NUTIspTQ== 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=MPUWc9b5sQAylHp9YXwciwmzvBd36tMUDg4/MdJI/V4=; b=GyuQV90B31X0na/GdJHxEzjIfGv0S0fYdaT3XcdjHs6KgkGymuN7W5N7rVJq+PXH/UZUKUxonapDxOKg4xyfQlRYRT9wBynglNrPI64bX9g2CrB37M0wF0Y8Ep5bq4rmC7NDRU8jXwGB6L8cI4+p0gohXXl6pF/1Wv7kb390WylAY2lLjLuCCci+I0fYWlataHtFYjo7oGJSfDVONbBl6zy1Ylatbqi9VT/X7EKp6whg+PaLJyB4uQm92zI3PeUtVWEq52WIEc5Vnae99Bd6zcA9J4sDmB22LodkfCaCop3bA/12E4P+d4MSvYbxKP4U5PQ2jviXwQyGdtFZsOWPTg== 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=MPUWc9b5sQAylHp9YXwciwmzvBd36tMUDg4/MdJI/V4=; b=FBBCzPAvMXnLwqKee0Qk87sEwBd5mNStI7q02IiFueOVpzhMDgPoacrDkpvCBB66s/acWEEo8IzWvYtBPSm48s6VmSlcFw798qoRDki6TvwM4hDI21S0v5L1cgRoH1+UPniOuTlL3jiysDrn9mDnKrAAWl6x3kFp6Bee0GNORKU= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:44:10 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:44:10 +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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v2 03/14] of: mdio: Refactor of_phy_find_device() Date: Tue, 15 Dec 2020 22:13:04 +0530 Message-Id: <20201215164315.3666-4-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:44:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 88429c5e-aa01-4818-be9f-08d8a118a5a6 X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2043; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JSG9pu3wOxv1YckrAnXh/QebWdSL0dh4Q/ELlY10tD0P4Xxpm50fU8JXzgi5eUnECaBzN4Vj/+Z5Fyz1o4KHSXgcdHI3zxiWT0gH9v1Fj62eC58JVgIaUtDGBjFZ4xcs2EpvhmRXR0jYGQHSwAHKpWt/xuBdfM/sv1gl14fFqOQUhBCHA10fzzTgD+yBdY9IMhiZrW94SBBf+LT01LLYJIvb6Gvmy7Ih3ljDJmbI1huIebr8K7tO2rltrqsHM6rr0F2C+K4hK2Ms/q2mhzp/JC+1KbfUfARsyOwS2CleqsRxxrCAb0gFRkwNq88xj6RYouNojd9hB636OFVz+nbO0GDLYVp1+15G24YV61CDSzfgEQ0yns2/rdD5t01MVOZwpokjoU5gUIggs8iaD48q8A== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(83380400001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(4744005)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /WR5cFbtFdcinwoJQZDiJCLx5DqhiVIasu7pSEZlOxph2uYZ8UzwL2zM6ZLUh7o2utk3V58bHN2qjMfKbuVrCZlvmSvm/Y44ikVsApZAJpQZP/2+L/XFQKAS+EtzF3nKCoBAqsAsGUG/dyNscgsTBAbLKeVrt05dMzED9i/BazU8l7R+NGiu6E1oyqEwU6M9ismtYynLN0DxKMwrxZpIGUAuL5fQkLaRiMiXzxyuueIuqtmZRxFF2cR+1zYqLfXuYDWu88GNrUYWjjPS3Yrlzn1T+MZCN+Z3FsuxwyiGV8dXqMmw7gCnT522HMf8KwQ3ZZkZm3KI0YwMzPZBETPlU8B4xATHCxHafx+sr5qvlHwRZd/slePpUgHoPVmQ1qrzelz1e06RA1/pErkPxbEMxLKHT8/ZcH7tMsM/f7d17pK9OzMx9MNPsGA8wI1yaElbo/yvkPBPUD5uGKBmlFxx4U6SGNf3qMq8GKFulpTFL2bqzTBs99hnVdHPGHOpNhaUcpaEFdYY0dBnT0JmNQML6yXrOoCfe+SUM7WfuPhY4OvZ/wRpvOMet+YXowGn5F69BfNjiUT7Hn1qPOvlt/DintFEoTdRAJhBoBaFomtI+OQ5Q+OofHFWLdIULF34Glq41HAm5PXmMRyTu1TZDJdn1xpZXjDFdASD/VgoXzlecdZY5JycTxUzpffJ1Y5gk+Wo0ou1I1XTGse+/x0Wsir14O0zMg/86YdZMAta9p6ixc2ZTyRIJg9GZbq2qYEAGBqaTS3ENlguDbzt6ipvhAiM6MlaoGAiDmTMpAK0odM0SMA3lSqwpY534FjNMoaD16eXAjdBZHhMclM/oZHXjgDOzlf6VrFhZg743ETSF1g4R01Ed5OyuPxDGwqLIcqc985dOVkP/biRhqc/5q3I+xXDnJQ2+ObW/bEMJJGKvJA7I7DO8SRwtPyFIXfkU5SykkeCT5t84UzwauPVudIGUOst8aC6voTLaokgSXKAiJhdROt88nMZY9UoZsIfPT9UWIr7 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:44:10.2671 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 88429c5e-aa01-4818-be9f-08d8a118a5a6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pBGf5ov+yKJEu+A+8JTYJpNLPBW10KqIgW1IZQP7Am07hNMzuCozY6xWsKNrqSwtVlu9dCi9avbz2nb3hidKnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Refactor of_phy_find_device() to use fwnode_phy_find_device(). Signed-off-by: Calvin Johnson --- Changes in v2: None drivers/net/mdio/of_mdio.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c index 4daf94bb56a5..fde76bee78b3 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -369,18 +369,7 @@ EXPORT_SYMBOL(of_mdio_find_device); */ struct phy_device *of_phy_find_device(struct device_node *phy_np) { - struct mdio_device *mdiodev; - - mdiodev = of_mdio_find_device(phy_np); - if (!mdiodev) - return NULL; - - if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) - return to_phy_device(&mdiodev->dev); - - put_device(&mdiodev->dev); - - return NULL; + return fwnode_phy_find_device(of_fwnode_handle(phy_np)); } EXPORT_SYMBOL(of_phy_find_device); From patchwork Tue Dec 15 16:43:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975321 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 54DF7C4361B for ; Tue, 15 Dec 2020 17:00:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1CAD822515 for ; Tue, 15 Dec 2020 17:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730064AbgLOQpx (ORCPT ); Tue, 15 Dec 2020 11:45:53 -0500 Received: from mail-eopbgr20054.outbound.protection.outlook.com ([40.107.2.54]:56934 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729854AbgLOQpl (ORCPT ); Tue, 15 Dec 2020 11:45:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dGgvtW1bpfJaXZN+0M9ICc4KeKYtVUVhuEIxjWg3MY0mU3BNuj0TIUr0LV4rqd2+z+EqTi7pRsAlhJ9THmF1zj3/GrcDpg1BlNzGKj2nr6/5BqMEFf+dZp6aEoWjzKX2BIg2hr65rQq65yzoM4p35XijfZ3x4HpbMSUQRS5COHyXq7n5js/ofz2bvwKli9E/w+XCGTos5Koje6p5H2ZAJd+4GjoIN4YNXEhXckfq0Km1oPAnqe4Cuuki8uybhxZdxiOT0RRhM3V4t+biFxvJv5Su22ev7ZFnkqYLbdRM6dlWPcBg0TS8w9r4Ec+XcqknfVN0Z/kImKG4njVXnt1L4w== 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=iKVabve3Epmt/PcG9wmnhbYs48xlkriLAVvEOXJnIF0=; b=S/XtUzevyzbNEF799Uco61GKspN8U9VJ3EsQjAJlPqKwY00+ZAKp7esh4Z1+CIpLhjCWD9VHliKnM4jstklEbFWwegW6/HwnLD4GCTdV+mpg1M7ZYAEGIPga3r4EfJ26W5hNojUfcqxXVN0X+bBfRvs7dHc3KH07y5psyvw18PLjEYDu4ePQEYF4Mbamji3yD0l/3KB+swVHHX4BCOnR43CgcpWJ+VmNxVpJAYJ1pO8f8aiKYY9M4q9GffULZWboswSONVIY9j49GlmIKy0awEfyAqmdVhNGQT8B7HSsCwGvk83vNBwAj91oHqeFQD/pOJaUEQEWFlvdStH3fArNKQ== 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=iKVabve3Epmt/PcG9wmnhbYs48xlkriLAVvEOXJnIF0=; b=JvTsi0xKvcoEvfVb3pHT3OQ2tdUmp+oxWoYvaHpP9ZESoYbTwaWtc9WMdqGy/QmrsnhBa10TvNGPQQpyHrrnMnVhuqzfbQPE2dU9PG23bZJLP2EVrthJWeKcQ0JnHEpTKrYPHvhC8SMMTJEO5S9M3gW9vWZ1zyaFIqMAgS5lnG4= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:44:16 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:44:16 +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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v2 04/14] net: phy: Introduce fwnode_get_phy_id() Date: Tue, 15 Dec 2020 22:13:05 +0530 Message-Id: <20201215164315.3666-5-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:44:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a5be8dd6-7e48-4e03-7b06-08d8a118a98d X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: 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: n5ncozxHOtrJ0jfEw7V5s9n+2VcZk2soHGbWdOR8P9zaWbc2ljuUqMjqUzYj5EhxYavwkXSsGnF41SK1eL9s4barjLtHWA/Xqjbm4TwnRVPVx8PJ4qaZ2wOqIrLl7iuoPq1lYfeLRjIgiIT2ftL9BPVWZJemchThenJFObyL+M7B4FCoi4hFql6nlSPnWBoVPSdUOC+jDmc8IQ/ZSbl5aIcwTh1aCnPWOp+bQvwUM12MbACIQARCEriFQLToKTfoaje0z7AJZpDiBFtFzXvrb5Ml9Qo01RDF2XhA57AcV+Ey8kOtgEcUSm/s62YQpoVs2D5W5prg9Gh6C2eHQIIg5SiEsbeooPpCHTXG1cI3gyKo3JLuJP2cQzwc74shxH3jLejQNdgSCfCaI9tPajDqxg== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(6666004)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: IPl2M5c7waTGfhdeYnyuCUK5w7xHoiZuSIAZgOqTBfaMnaJ4zpW4jj0sPP7s9Q2lY+008y5QHvNZzGWR3enXxonrQJHa5nmZKVYBNDfmHbDM3TMcmTSYjQn4bELJu+Scc7dmU5xetqZyas4zJEYEX839C/trxpAoDkJwxuwedyOCL6jctsN29IOJHMAGnzBR0iTtY3zGZ9hz8tsk+voNbUgVoC7UhMiP9V2iuOm9Rrfs2CQOtLdvLvHlhXUrT1AmNg2z2DpfWfF95Zrg2CBoaYBQJk8V0PGY2qhLiMBwfzbQwiqDXaIe/BLgJfPd1+hFm/bWCsNSYzsGRA2DkLWDA9zrBvynopZENkPunUVWABWX6caaJ22pdnocD7rXq5mraol87cYnAHG2INMRPIQi8JSREtDkA8JT7u6Trufz6aVqxe0TEvsU0gNLLR6CSH6gxUiMWRA8T4/ISdGV1nW2bvF8lyrZBUfEaplu20OSUJ4KpqrDKncQCoeFgruz2H/EJknR286gZMI/h4P/G2YnZO8NJ799xJIQqic7ldre8lxZGtXER24CRZAWsasr1t7LiGH+dQ3n1QL0tqly6EVlT6YpoCOoKmpu8o1FCvn2hD3yRrTSgqaVjU3gcHGXyXj3y+tjuq7GR/+T7dILwr2B/PdibbixJ5MjtpVFzKhZvpu6R2vO/Xd1PCEFMigswI1iE3/bjOTqr51HcIo/AxZcrfGgfP+nrslaJ1kC+YfGRGsx56MulHvPE6HssGVtDErBGsu0XVDj7bVF/nTI4S/YHvGXOVgxLZOhICwAWpBJxqc8PE4Qwx3sW9+rie1AmvbczIEfaUDOMfJsMQdvsTrFZDA0SZ82KKi2ok3dufMUj/1nSgkOrQPtxNJOK2hAzIpJOObNS4jiVFll2P9n+JldeJAxtEGWSAUjHtsTKzS78mdyn6f4v7M5uwRCKJ4Zxsi76r4+frrgdec8lSeu3eFaASZAr1xjS03Kly6FR1EM2sVVozzyw86cuuqPjuPB8/D+ X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:44:16.7834 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: a5be8dd6-7e48-4e03-7b06-08d8a118a98d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BFmeaO7UfsuiusTzzhELY/D+/VAz7T8/x8v70yPqzhPFLdpI+4qAGPkVafCD8PDalUMvIctae/1PUcUZNFgyZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 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 c153273606c1..6fad89c02c5a 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -846,6 +846,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) { + *phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF); + return 0; + } + return -EINVAL; +} +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 7790a9a56d0f..10a66b65a008 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1341,6 +1341,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 phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode); struct phy_device *device_phy_find_device(struct device *dev); struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode); @@ -1348,6 +1349,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 phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode) { From patchwork Tue Dec 15 16:43:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975245 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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=ham 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 11616C2BB48 for ; Tue, 15 Dec 2020 16:46:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8E7B22581 for ; Tue, 15 Dec 2020 16:46:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730149AbgLOQp4 (ORCPT ); Tue, 15 Dec 2020 11:45:56 -0500 Received: from mail-eopbgr20071.outbound.protection.outlook.com ([40.107.2.71]:62181 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729543AbgLOQpr (ORCPT ); Tue, 15 Dec 2020 11:45:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W6gcD8ry+XE4gg8ivjAb+t8iGf2fYypLR27vSI81s0VR3XukEnOVyTqy9zN+u9K4ooAE8m/94g0xSjddeQomPUzsorQKDRCD3KGSIN5FGjCg53FWOUkMSi2MXCD5uNtzH4ryTHvScIxQgBl6So5AqF0CtcnUhgAWnpbTAyYZyL4+PIpmaLNKpFIX+FhKSRpfbizFCnavw2lvpUsS7yODq4KDuxQHXO4eETrZw32X3MtUrkJJYHZfHM8/8Hu/pbRkNagqfozKoNUdJfFaj6yzatvJva8c99G0NnN2IeOHXK2p+jmp7ewqz9VNiRsPM40knTp4skl1xPtsZc5DJ/gNWQ== 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=asm2PzMG5yff/FKwtgbKubq/h7PudquNTP+i5mWk6oc=; b=htWJUbQnceuYHseJUTFTRhx/5+ZQi8+S37typQ1tyEQBwUhRsW+TGIJGrtPq7lPa5ljPBI4I7cd4edfbDmQEHk8L3IJHYDvV/B9CsqrZop8WbD9pqHLU+WkpnayvKII6h4irdhDWJWuadP8wBLhJU+5Vq86G1QDyUxP6QhkOH7Cb4XzvIiqb8w8N4reOv61MeKJAbS4kP+ohPU+e9sKRdKkPKy/h4bP8UB+K7GrFEKiOU9kEoZcLfV1CWQvgYllE325k9cv2sjvNEqkw6fjXtB8nZfkKuxX3EbF2BqRU9gqCGBJdGEVF2d56m9BykG3uHaKKiCQrD9cBMkl9XyMJrg== 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=asm2PzMG5yff/FKwtgbKubq/h7PudquNTP+i5mWk6oc=; b=OQDTKrX2EJTQc0NTkVGjs0GSt+qLlFnolirwSmb5DzQpQ2wQvhq+vuKFoEeZUk0I98Rq6BSQzHQuXzKknVi7ugNbr1X8Wz68RBeFa+PLZAiVX+liP1EQ5K57CUrTn1oTKoNNdE1gEiuTefaPgpr+fHZ5XZssesv7D05IERwzqw4= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:44:23 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:44:23 +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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v2 05/14] of: mdio: Refactor of_get_phy_id() Date: Tue, 15 Dec 2020 22:13:06 +0530 Message-Id: <20201215164315.3666-6-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:44:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: bef3b0fa-4e7f-48ba-be71-08d8a118ad6c X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qAQ4LUxD3viAXy2BR3ol/rHqpLIUYW4njsZcdil0RP6KCcK65A7SXKW1EpFbJzG8jefkGzFk688QuR37hz+yieZM/+WIf7dba9ni1BRHlTYRLqt92QISbrqqm9kbPOyxrmRzbgkosNATyFyRU3p6CrV+0CiRycEHIiZHmvvy5jt0krssO4IXnTHR1SYchwwMSOJEVoOtHtxEyN9kHtBTjTLDB56GfKM2QOUA6BSzEcmUURVkl9uwmJfG+YMPWPTnaQu6+iYH8M3ov8gi7rqeVOGbI2Yzbs6fbqPo3DFHoraSIY2UEpzl47KUTAMJgAQBl8V1X7P6gl2H94bDXm+Ya4wT7ONW5boYiGhaFZYepzDen3TcC1cZWZCIFm3KvQ+pcOU/ZnOyKVT0NG4pwdRMrA== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(83380400001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(6666004)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: S0mH11kB8AvtWWwJDFpjl0Ao7KwtkJMYA31eoyh8GCMBhL1t8vsvp9WIwGjpYC3xlqW/3D1lz3Xg4/X6kmET8+jFa9JDCgGpPzbEuuC2T58MR3PC07qLn67iT2Fg7XoRFJXZDpkExFJvaDM1CopdRn6/FyJKS+PYzEA3gYGouOKYfhdACa7l2zOdYLHjpTAc8mT6BagOICSiI/QwIM5IvfMAC/Q5pDcAfHKaogX/tQnNxIvmYpEUSq0DBnQ4MQx8+dfOMMvg9jilpqn4HeFxcT9ueLU1sVZq1PAS/08asZzj/cKEVmQ6XOwC2B8haKAPomOmuwZ8m+U34u09R3/5GG4GO/Tl9APuGafOspWe/ospbHYeISqVA73Gvh4DhlBpRp5yorEGbRX45Q9+7+F6fk4ueGGyE2RP697dc7PcvTgBRs01ezU1KFMQIkpuoC9yKIh/Nw8EHHYM+12P0K6iZT6FM+nzlal86JzCZNbiKkMCjWLpmiOmoyUkKXwIvTfkX/nAalJAmlGaMFhujNIyRCZKtwtua72JgTDg5gM8KJHbgl1YPvmG0wR7UZeZ2oP46fQw8lNbN181t8OE0pd/2DqiK93ES4qUETaqiauiDqRHX7KDW9lfVrWx2/88YqVjsfsggLrBDpEia3FUT+jcuWGqud+FhTiuQcI1oL3b44Xe40ca7WXUxmvRQROSvUXCagcoo5ijly14RtMuQ+xOAxhqYrM4mneS9qYoRkJIMfL+bb91ObQm7+T1yv03nOLuKvlERXNXNtIOKBa/+I8WYu3d3EEvd0IBsJO9+CtmoSfdLuT4nlx8zCZvML7TR8JSEk+Dlx9rfV17ao7zAyGc9qf1ts/B0CpGtu/BjPhNCV0lzzevJcxdLTm5ezs+o78s6xtMZBNs6YQPMJbwHx2nRTmt28TIhUSoHTU7SLDrRT75XEwHRqF4eiN9aavbMInWb2N32HMMTQnK81LPws7v42LLqB4rsHcX+CDMW/bQRW37e1bfWsIYIY3hVKkXPESM X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:44:23.2957 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: bef3b0fa-4e7f-48ba-be71-08d8a118ad6c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sMluvdSlMwm+frMfcvLjM61fkMIKG3JUIar/+4FQINcdREep/S49gkGnAdQmw7tk7x2oJUxJMwAHZ7dUpuvbIw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org With the introduction of fwnode_get_phy_id(), refactor of_get_phy_id() to use fwnode equivalent. Signed-off-by: Calvin Johnson --- Changes in v2: None drivers/net/mdio/of_mdio.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c index fde76bee78b3..31e6435dcc9f 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -29,17 +29,7 @@ MODULE_LICENSE("GPL"); * ethernet-phy-idAAAA.BBBB */ static int of_get_phy_id(struct device_node *device, u32 *phy_id) { - struct property *prop; - const char *cp; - unsigned int upper, lower; - - of_property_for_each_string(device, "compatible", prop, cp) { - if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) == 2) { - *phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF); - return 0; - } - } - return -EINVAL; + return fwnode_get_phy_id(of_fwnode_handle(device), phy_id); } static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node) From patchwork Tue Dec 15 16:43:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975281 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 E051AC2BB48 for ; Tue, 15 Dec 2020 16:46:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF60622582 for ; Tue, 15 Dec 2020 16:46:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730419AbgLOQqW (ORCPT ); Tue, 15 Dec 2020 11:46:22 -0500 Received: from mail-eopbgr20054.outbound.protection.outlook.com ([40.107.2.54]:56934 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725878AbgLOQqJ (ORCPT ); Tue, 15 Dec 2020 11:46:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Epl/Z+2vAfICw2zoLgHXiTTSaduWRMJ47PGZZstm5WCmIhTF/Esdna1K/9Who5eiuqkPakrBZDmccPcTuo3YFyXeQPco7p7agQPma6GqjjYVXL1uT48juqJP5dPm9blzO/gzcCm1SNe8rflYW2gsmej0pPGDbbBAoLyM20WI74KkbfppeN9MOYUm0HK2ReiFYuzbaSJwVE/gwwqGuebxpTSq9QcXNq07rKkDTMT7sxrkk33jutVseAouCKb9EBkRhDx5Bv0Zt3GsoGJXqFnntfQ8vBGEdQLJHC6IBtNIEVsH+TUfBoP0u97MSCGsbFWzJzUVJSyR/oci7mARXrIA/A== 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=d4AHKzV+1bGiW8uqR7tQ++4j7WdZj9FYiDJkFQfAZyo=; b=gp+pCV3onsIW9Q4AO0Fy8x81Yy8t8COBdbAi5DMhNlxE5ErfZ+ZLmRxYNK6Y2Vm9zfFcpe15nPtXdqM8IoIFSR2TmUDDGvigLc9EiJ5oiQ+Scm2cgSatorKtvsnYdPHP6ek23fGaGlr3nJzdY8FuCOx8CtUiJP37Y25wa31QiT+7m+9D1xWy2lcFTuGI3sCrYoI39/1wYqfuRngdOZXmnKDNhUOEmutlwXpCb6pIxgZ2Fc+foY9R77ZwtpJopSblG++b0xD+ZR+uu0c3cUVSreAkbJdf5uYEgM6ZR50XG66oDKc3wpcI0q5DyaHvOqKzNS/UMt9cpUmlajF3OBfL3A== 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=d4AHKzV+1bGiW8uqR7tQ++4j7WdZj9FYiDJkFQfAZyo=; b=LYckWNdVfsdTpeWPySHI8tkWUCMW15EPQM41Q106bGsRr+9OCRAHYyZ6oOhKHeHntwfQyUiNpbilUQ7NUzNG+hZUR1hdzbH/jSl4dARDlVqvcPRh5lb3Ls26Z98mAmkTwjLCBbE1/JSs8zyMyI6+OpDDoxwF6M58QTslmLTUcTY= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:44:29 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:44:29 +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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v2 06/14] net: mdiobus: Introduce fwnode_mdiobus_register_phy() Date: Tue, 15 Dec 2020 22:13:07 +0530 Message-Id: <20201215164315.3666-7-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:44:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5a8c0489-43fe-436c-b8e4-08d8a118b140 X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: 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: u4dBRTpm7AbWUlWVooWouegBheOPmN9BgnvYjPx2acWAxF2WkFgcJmP2YNsOvoccuiPXJnU6B9JyX6RwAzOM39DTb5ZiWGvOz2IhK0nFAQ0ri7uCVLUJo1AvomvKsxlNsfYtHb7qh7g3F9QiBRDqXSmB5llDja3ucra97d/qy+M0ui7Ae6UkCB0CqEPxj6El6MF4vxzBNnKt1AOc53B2SFUgGeubRuN2Xa+kP/znu9RJmwI/owqNS9m3BGqb9r1dF21g8IPjVyWvHXJmEZ8R1MbSPFgjsEle82TWBbjgxYWYoq6+upGmS4iuYIR5yj8XCtrBtoWJQ9y/Cv68cP8lbxGJuSHwAvUk2rvzNgXrPqnQMcNX6ZopsVNDrsjOxqxkC5jaJgvf0KdKoKGvsFhZuA== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(6666004)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: rhwQ9jT9kWAn1ivonlt1f01UlYehhDE//ft+MiwHLCqiz2gCXgW1U3Z/0d5ODeApJAMFTogfVH7EFm1qhPzFGYvW3NYNtpDpYR3iyXTu55FdgJLE3yHQFY5o2tmf5o0jpp9+oeq0XZEHuC6F1d/K4e7A8Q4DiAg3WydCrG/cm4ZqLgWTHuhWcJ6GsfdWG2VZxaZHELc2bMeIW/xp3HGjdAyUxbVP5Zq9Kgd3wTBbwwv1bIKKLS3X3FZqf9FSYVgmS17i1shCiaYEH0V/E9LutLU0Fxx1L0UU5Ujohh69k6OiH5Kraf6da22nLRRiWMOFgVzaL9fIpPuqKkq8lbolDDEJd0bwj1cCZO9mGCg07yMRSKSH4tmAaORx7p7CPI3+ijmrnA+nVo4WLG74wpEYGCPOuJxDTPulvyClGiMYaofiaUcwdxRsKvMeLep+FKMG1vSUpm5MI6w2IEK6cwBqlN6bInuE+5xyZ7CyGGL3y63i7PyxisH2fo3p8QKaCLngYKvDoT5X2HAz9DDjH07nCz8e86yMA/xDDhiQpcuKRNGSeT1Wmy6aAOAK0R3DsA/TTMiZdQCvxdq5uHTqNxvjw9GRzSsioHiPceolfUcH4fcZdT3+gUDQtsnYDml2n3xK7Lil5KodJK3crcJvBLuBFnCfINrjjtpnFsCoWudrVgwy31D6gbfswmlOVIIXjHEjnQOK3ZK8KSxE/wMSII0yT7TYXd0cWTWKDCACmAtnv6TGjc0b738/zz3MtwSBZmoJfxSqKaFhXHI2ByYXWxJ6/6WgtsGH1ygQa0nQVzlPgFHgUFzUq4JJqw34tWyH7A/rroxR8fWlBW7abKXRHNip10ZjIndSBYhYKyFo+SKjtnL5mXzRkoTDsfReawWekIzxoXgmjXW9zYYV8vIVF3Fn9Q13fGPk3usKHB8ZiiqvtN7jEJa6fTyLN/3RzAdIPOBpqoQKM2tLLCDyraSSrzYj/BmEzIlj+v57D4mEYoHi96FtZwbs9smWC9oKHmcnJXAt X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:44:29.7351 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 5a8c0489-43fe-436c-b8e4-08d8a118b140 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wtngo5gBbQqMBqWje2MWF0LU8imJbp2znKai1ISmTMCJwY3e0LJD7VgAcMsJaXj4YzkfGn506skb+Bb3hBZvhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Introduce fwnode_mdiobus_register_phy() to register PHYs on the mdiobus. From the compatible string, identify whether the PHY is c45 and based on this create a PHY device instance which is registered on the mdiobus. Signed-off-by: Calvin Johnson --- Changes in v2: None drivers/net/phy/mdio_bus.c | 66 ++++++++++++++++++++++++++++++++++++++ include/linux/mdio.h | 2 ++ 2 files changed, 68 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 2b42e46066b4..3361a1a86e97 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -106,6 +106,72 @@ int mdiobus_unregister_device(struct mdio_device *mdiodev) } EXPORT_SYMBOL(mdiobus_unregister_device); +int fwnode_mdiobus_register_phy(struct mii_bus *bus, + struct fwnode_handle *child, u32 addr) +{ + struct mii_timestamper *mii_ts; + struct phy_device *phy; + const char *cp; + bool is_c45; + u32 phy_id; + int rc; + + if (is_of_node(child)) { + mii_ts = of_find_mii_timestamper(to_of_node(child)); + if (IS_ERR(mii_ts)) + return PTR_ERR(mii_ts); + } + + rc = fwnode_property_read_string(child, "compatible", &cp); + is_c45 = !(rc || strcmp(cp, "ethernet-phy-ieee802.3-c45")); + + if (is_c45 || fwnode_get_phy_id(child, &phy_id)) + phy = get_phy_device(bus, addr, is_c45); + else + phy = phy_device_create(bus, addr, phy_id, 0, NULL); + if (IS_ERR(phy)) { + if (mii_ts && is_of_node(child)) + unregister_mii_timestamper(mii_ts); + return PTR_ERR(phy); + } + + if (is_acpi_node(child)) { + phy->irq = bus->irq[addr]; + + /* Associate the fwnode with the device structure so it + * can be looked up later. + */ + phy->mdio.dev.fwnode = child; + + /* All data is now stored in the phy struct, so register it */ + rc = phy_device_register(phy); + if (rc) { + phy_device_free(phy); + fwnode_handle_put(phy->mdio.dev.fwnode); + return rc; + } + + dev_dbg(&bus->dev, "registered phy at address %i\n", addr); + } else if (is_of_node(child)) { + rc = of_mdiobus_phy_device_register(bus, phy, to_of_node(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; +} +EXPORT_SYMBOL(fwnode_mdiobus_register_phy); + struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr) { struct mdio_device *mdiodev = bus->mdio_map[addr]; diff --git a/include/linux/mdio.h b/include/linux/mdio.h index dbd69b3d170b..f138ec333725 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -368,6 +368,8 @@ int mdiobus_register_device(struct mdio_device *mdiodev); int mdiobus_unregister_device(struct mdio_device *mdiodev); bool mdiobus_is_registered_device(struct mii_bus *bus, int addr); struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr); +int fwnode_mdiobus_register_phy(struct mii_bus *bus, + struct fwnode_handle *child, u32 addr); /** * mdio_module_driver() - Helper macro for registering mdio drivers From patchwork Tue Dec 15 16:43:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975319 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 70B8FC2BB9A for ; Tue, 15 Dec 2020 16:58:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23BB02251E for ; Tue, 15 Dec 2020 16:58:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727527AbgLOQ56 (ORCPT ); Tue, 15 Dec 2020 11:57:58 -0500 Received: from mail-eopbgr20071.outbound.protection.outlook.com ([40.107.2.71]:62181 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730262AbgLOQqP (ORCPT ); Tue, 15 Dec 2020 11:46:15 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k0gMkmaBZUFi5d4ZKRpmaDMaz2Xy/5YDsWpA7Z3Fxy2m+CCh698My/b5vvK06LB0HKU2b/T1Bi/9RjIRGn2ai7kZNMWKPcL1Ezz8PWGAm1WgE/zCK8MtJ7S3uExH0cFgEeptM8T/y6xjt97CTd4hhGIcqSzS0n6G1ik9oxgGxSMl4D7R1cbj2N8EWNpHJWYWR4D8xZBbadk2uEtA1ZCrtFJGrUscVBTnwBXnUnAX92lp/CYrumO9Q9KWrJEklj55s75xiiJQQk7nExtbyglo0UpgrBZmPYQHvHlr5HFwBS75XMXesDh3dPim9IywBZnMZl32MaP2CZJiPt61KSG4vw== 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=aexVt/cpYazIPkDXQqEordDVbjaFJ0Sm/ZxGwEUD2fU=; b=KZwRk+uOs5npysyEn9VgOa7WiTyZC3DXocG3oEsII0W3OxUfLEa3G6GM/tNSsUIo4urUVRy/dftRdNmrwtmpVaG230/HHdm/t/Ty4OvRxP7ZVNpmWdBDfAqyfgkDTqLDfZkts0numWu9cO8BSVdyEiN1+2mF4dC45xZkJl+pqi7udjT2Dm4Kfb6Arpk9ZmRoQ9a6DqmhxTlE7dNGJQypNyu10vmaFf6vxqLJ7wD6SzqoxSLGouXSdPbPpymYzFFEKrUbjnJKhaswwSKHR8LpIlLqDSaguxocEtTVttCWpFKS9XiHUsRcRbjS5gjYdvQ8NbcCcz0rgxbhgS3zja3weA== 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=aexVt/cpYazIPkDXQqEordDVbjaFJ0Sm/ZxGwEUD2fU=; b=GQIZFb26dqnxLr8qeUBNtJt6wue7WrtDHFVhxYNZbKa6oVVqNCNYBuohhEfj+bCeljd3HoUAaK5V8gzUAVB30IHINobvvE1qVZedZNl4HxRhsjmIOr3sub/pVZqyap2hXSGG0LTRjsEkCErcoXS/485Dv+rRXxuaONga22Tk9rQ= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:44:36 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:44:36 +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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , "David S. Miller" , Frank Rowand , Heiner Kallweit , Jakub Kicinski , Rob Herring , devicetree@vger.kernel.org Subject: [net-next PATCH v2 07/14] of: mdio: Refactor of_mdiobus_register_phy() Date: Tue, 15 Dec 2020 22:13:08 +0530 Message-Id: <20201215164315.3666-8-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:44:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9fbe0371-ddc2-492e-ba0b-08d8a118b571 X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1186; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZzHF/h6f9Fr7dlG2KDVnhWcxko8bDP9zEW+d+djh+eWHrNaOgQpgQS5en+/DUCyx1r+M9FsqE4KyGr/rdiR2yYZ/Ch/dc34o0s6HTqGvZ4M8101dkNYNHZSCpdYYnrNSU+z1Qpi7s90Wty6yH/IOJiFnvuD5B0a1Q+4JvsqIhpy0VCTd4IUlrDPubOPCBbJ/DgElMliFeFvAypBmGiO2IeQCD9jy+NKvrqOh3vLqphMNDwm/2aHpsx1FhgpfoFQikCq/DAxE2J40XDxPNG16h5JAC1373xjtdbkjfOZfjTSTdMeskTEeMTRD5pqr8Mh6RvcevLVQqq4MYGFN9D8rGs8zyDiINaT/VpXcm0ChJiD6Qxj8Ae+PzpP4ucNMQzHgEZ90NCQ7gn1NEn+bLVqXvg== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(83380400001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(6666004)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: pYsqc21oyGx5FX32P7f02PqHdtW39WGcV9BmQAr/36d+tkZePTOBcXBbZDVPZbUvsySUX+cuS+d73WdNuuSU6U3BzB+CNB4M7bC7ab6MKhF5rYl0wVnbek3WueFlSagmvr0J21jHblLAEBxpP2+QONFLLpUTnn6daHTMAhrWTmfi1nD+MVWvz5MbbnVz2FDDEMgC/WH0sYGrJSFpjp/iCGVEonIjp/6CbElGa2gI5vq6P+tkdajhSoaAJZa11iFJBx2GKK3mR0BlBKU44QAkXcXUaiI1xtqDtU7pxbYRbGxrWcBrFz9+q9WWB0oxB+It/X4xPdCyHTEzZlVva1RfdhhsKsWnpUVKiDcWYA9vloKmJIzpNNLR7Q3giNWKOEYet2l54LSmI13aS4ZPd+DMJzAinNTPnO75MX0oeKkl+yNYiqBbLYsF32/WiRRZ3IMkRTG6q65KFzCPocCBGLMMQxa9Zrkp6jB27o6wa58VVlybTtziFLner07+CWgBws09WmmvLt6/GrRRtPH8wm1Grch0cATGcf1oYKQB8U08m6H68OoT/3+/0O94MbgWP65etEpbmMjtEblIkCtlMV/yCy7Sm0iFNe6p6tyNcjoc9ZtGs2sSqxEkFjhVCP1KpUBb3DvR4g1jYiDW4/8g+v2CzMqCULZv77G1DwFOt1UVy4UZ3Pd8H/0rM2XEVbTVP3ebsPzIbCcYlFHZeY7OuZUNiY2Om4TOMjqPTkjFX5pbItGuCKgG/DZijVDwMkm/h8IerCT6Lz+UjjEOsmqn/Ro4LDbqTDCgTD/fX6L+7fzpl3Ai5wJtcIst7iqyTdecXPdaj4Oaxi+6VDuM70xSz6/Ax8rzu+zqr7xFHxe1EHJVFJfh6Tq+jDwmqo4+DpUfhFdkP71XoD4wueAaJJqh4Lb7NxK+Se/tJH/EqwIVYPrDDfDuVHMyNrVO8P5KfD2P6mwTRNMIszYQafPuGGP8McunmUnaVjSNvqIykdsWmg/p5ar3PJ325SeKB7XNpJnCD9Qa X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:44:36.6982 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 9fbe0371-ddc2-492e-ba0b-08d8a118b571 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 147WMYDlvXP1ojhwdTpomqlED4NYNOsZ2qEwSiPFbowWX+sxTT9vzyJVGpp+Jn50peN0hdU8Mey+ziSdnChSWQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Refactor of_mdiobus_register_phy() to use fwnode_mdiobus_register_phy(). Signed-off-by: Calvin Johnson --- Changes in v2: None drivers/net/mdio/of_mdio.c | 43 +++----------------------------------- include/linux/of_mdio.h | 6 +++++- 2 files changed, 8 insertions(+), 41 deletions(-) diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c index 31e6435dcc9f..fa914d285271 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -32,7 +32,7 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id) return fwnode_get_phy_id(of_fwnode_handle(device), phy_id); } -static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node) +struct mii_timestamper *of_find_mii_timestamper(struct device_node *node) { struct of_phandle_args arg; int err; @@ -49,6 +49,7 @@ static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node) return register_mii_timestamper(arg.np, arg.args[0]); } +EXPORT_SYMBOL(of_find_mii_timestamper); int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, struct device_node *child, u32 addr) @@ -97,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, diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h index cfe8c607a628..3b66016f18aa 100644 --- a/include/linux/of_mdio.h +++ b/include/linux/of_mdio.h @@ -34,6 +34,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np); int of_phy_register_fixed_link(struct device_node *np); void of_phy_deregister_fixed_link(struct device_node *np); bool of_phy_is_fixed_link(struct device_node *np); +struct mii_timestamper *of_find_mii_timestamper(struct device_node *np); int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, struct device_node *child, u32 addr); @@ -128,7 +129,10 @@ static inline bool of_phy_is_fixed_link(struct device_node *np) { return false; } - +static inline struct mii_timestamper *of_find_mii_timestamper(struct device_node *np) +{ + return NULL; +} static inline int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, struct device_node *child, u32 addr) From patchwork Tue Dec 15 16:43:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975283 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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=ham 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 7148FC2BBCA for ; Tue, 15 Dec 2020 16:46:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4604122B2C for ; Tue, 15 Dec 2020 16:46:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730648AbgLOQqq (ORCPT ); Tue, 15 Dec 2020 11:46:46 -0500 Received: from mail-eopbgr20074.outbound.protection.outlook.com ([40.107.2.74]:21124 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730338AbgLOQqX (ORCPT ); Tue, 15 Dec 2020 11:46:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N18v9Qt75fz91SxDFqfv1FVfxuS83qLsBRTbSBEhCigKWmVkmLAicaQN1BDrg2GERJ6ejgAbgZoiHL4YfDEZ3peWhO6g5XzLk9wsav/GUpdMf1n8YbxJWSSH2RG43ZLyyp9XoitqEkYwXifWz/IO7z5A6t8ab+x9TOSOjfrkqoQVtQ1x70E5iM6Ms9RXsbfrqSEgFkL7uggvlfZUUsW2K6ct9ll1PB4ZPUOSbVhMGJyJ/HML3h1Jx0IuF8U5VBrTiGOBWtPoNwexsWS5U9++Zsq96AvB1hV4WKB4rYF/XRcPVBfOu3BQdk6xWi0NOBZSLyQudMEMQP9HVLG4qdAVrw== 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=VHbCuoxmfnEibEpVrFYAQn7nvS884hvxUBnc2q6VQHg=; b=O/sjVRychL8DLmoOU4VezSyL5jSbx1WCr0yRxmA3CigRmdjyJpUm+Ym4iOMy8YB2R/Pc7GN1GMDf8YyR1lKNwBvQOYM+NGUUoLFJRGlrZPwQ6PoCFCHqhob9exVFsrQiS22Qvfkip169HyPBD7c9fWjx46VAdXfsYAjS9V2Q+g311TCZ+VcSgoET5Bpg6kozc7nCgj1jHqfietr33wKTwjcs4bLUKE5B8uRRzHwvU3z+mQILuoR2nBLJSQ2+9VUxfKQhNxASCgek9zgeoWeSbI+DyIxwGGvKpFWIyCV/GN43e1MRhPN4Oq8nMhDfC9+yDHh4cmbNXn1Dsnl74JZ7AA== 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=VHbCuoxmfnEibEpVrFYAQn7nvS884hvxUBnc2q6VQHg=; b=CmjX0VvwvH8Y7Qq7cZTgQtU5eVZCYmv0f7w18mM2TLrGl1uxir5tWAJMPAbN0JuRUMOx7OK8SYyG7PfnTwdCSg7a/5EGBv21YPiWH8w/e3zJYV7RVI3q6Reu+IPDDKjYOVQ0n4EFs5OJ/B6KRf+s1kYYQKaVYHHlu7TXTIHOe9c= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:44:43 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:44:43 +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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v2 08/14] net: mdiobus: Introduce fwnode_mdiobus_register() Date: Tue, 15 Dec 2020 22:13:09 +0530 Message-Id: <20201215164315.3666-9-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:44:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9e0b2ea9-85ec-42db-8483-08d8a118b949 X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hr6OcMjCFPxYLUYuK1jyIbhPBChf/RBwfT8rVdsPZMlhlKuf2P1kn3kwL2QyuRKfV2dmnNIr5bqL9wfin90isxFjQjJKb1NZ0AVcX4GFqrL5wWw5Be2OX1F39g5gEj1Xg90RCkFVc659v4JELDP0gUCOGCladOokBZ7Gu4iLDDjcAGHiKj61iR6n9cISKbGU0G3ATCQMgDgzxkPDABvYSKVV4VTbACxWZTThdivPmXCLraBWi2BNHU8f46vNqUAqFMhHioZ1p7yLmio9d7wd/jdcqzZs4/SVM4S/iAWqVKzAHceW5rHWm8C+Q5YC8GfCDNO6umsgcxyI1v+KhDbpeYhE6qS3ocAXCgWV3OulrINIFCseDhN7iwlujkB4+mNppoiUsRieCBzKoMhsTny7YQ== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(83380400001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(6666004)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: IskicbV8uy7tPwMaWewdy4OB/TodnmaYra1vsxh8PgOw1+GzEDuikjYlq+r94plLSOW/PQHV3ed+WXX7CpV4NImsDGj433m+45xQD6DdFSUOj/uKGpf+IUUHv8ESdatPykWLoXWJdrVehjGdaFLXV0Z7TN3wzk1FkJGvvSuQWPJQTldlt8li7aaiwVDeY742KKmozwdpPv+Bq18sHBRF+H4n9q796mEIWwPTLLDMH9PgCCULnBZ7YVfwHg/KQ9ADOJ5/42p9GuADaccunWC12KpRHIuydEMlDy3JzD+Z260S2OVIzYczXSPCT61/4FgThytj2ePb5vOv6RafujbdTBJg8DT9zd9kjy7iqNzC5ToBYUxmiUoLhN5oW4Lzwj4FiKvbtN1vg2wdQtpISGXSnXndqfD/xgo0GHZyRkxrdQw2zyp5HlkRmeQ5DejBj3YvID0KWQ41m3OCLvckVWYwI/OpCBbVTSDptoTlFCjc8qlqoswn7VxokdZ/6foduPeLte6hjmDsLftpMRoiFjbLa77nqZ7CQHJ/k57DmwvluuXgwazr7xO/GjmN03pW5WzeSzXlKFJb8K0/l1QhRxvUd611Oe6YzsJ1k/35KvAjyNbZ2SfieIEpnNP7/z4F9dHqqQEVEF6vuvwwlDkqQFdHrBVtaPKmS+8goz/FIWQnSQvVu0saxCRwvOHvqgVFcytMMwPfsdWS+TgeJR3gC03l32Jylh78JZnNR9IYxAb4Ej/Xfx9ZPBp6ZFs1a56GvNte18OOoAHCob759Z3EyX4974sDoLvdS+Gi6yi7MRk75DMYQ4L2q5XGr0Zzg2Dgh3fNv7P9lvNraG6pycM7kUAUd4CQPsOhHkTNQsYScRdFhvKm7VzUbYiSaXgWZvpyrQjWV+TKjj92MSPxSMN5/HzIVV/V0mxwDwt2eJnNZy241u+KRe85/Se3OPNq/P7hAAklG6ysgRjQoB/2KT+pTxyij68XW3tLrOSQ9/YV0twmb7V7MYe7bSGKDUmxiOZQ+Gu/ X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:44:43.2235 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 9e0b2ea9-85ec-42db-8483-08d8a118b949 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LB90F5j+BKGGLiV3lQcMdciHV7ITcW68xIPU9yb/kL54UkMY+k1aWBbBC5h76lliuoM31RInpb34eYUoYW5udg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Introduce fwnode_mdiobus_register() to register PHYs on the mdiobus. If the fwnode is DT node, then call of_mdiobus_register(). If it is an ACPI node, then: - disable auto probing of mdiobus - register mdiobus - save fwnode to mdio structure - loop over child nodes & register a phy_device for each PHY Signed-off-by: Calvin Johnson --- Changes in v2: None drivers/net/phy/mdio_bus.c | 50 ++++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 1 + 2 files changed, 51 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 3361a1a86e97..e7ad34908936 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -567,6 +568,55 @@ static int mdiobus_create_device(struct mii_bus *bus, return ret; } +/** + * fwnode_mdiobus_register - Register mii_bus and create PHYs from fwnode + * @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 fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode) +{ + struct fwnode_handle *child; + unsigned long long addr; + acpi_status status; + int ret; + + if (is_of_node(fwnode)) { + return of_mdiobus_register(mdio, to_of_node(fwnode)); + } else if (is_acpi_node(fwnode)) { + /* Mask out all PHYs from auto probing. */ + mdio->phy_mask = ~0; + ret = mdiobus_register(mdio); + if (ret) + return ret; + + mdio->dev.fwnode = fwnode; + /* Loop over the child nodes and register a phy_device for each PHY */ + fwnode_for_each_child_node(fwnode, child) { + status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(child), + "_ADR", NULL, &addr); + if (ACPI_FAILURE(status)) { + pr_debug("_ADR returned %d\n", status); + continue; + } + + if (addr < 0 || addr >= PHY_MAX_ADDR) + continue; + + ret = fwnode_mdiobus_register_phy(mdio, child, addr); + if (ret == -ENODEV) + dev_err(&mdio->dev, + "MDIO device at address %lld is missing.\n", + addr); + } + return 0; + } + return -EINVAL; +} +EXPORT_SYMBOL(fwnode_mdiobus_register); + /** * __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus * @bus: target mii_bus diff --git a/include/linux/phy.h b/include/linux/phy.h index 10a66b65a008..67ea4ca6f76f 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -383,6 +383,7 @@ static inline struct mii_bus *mdiobus_alloc(void) return mdiobus_alloc_size(0); } +int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode); int __mdiobus_register(struct mii_bus *bus, struct module *owner); int __devm_mdiobus_register(struct device *dev, struct mii_bus *bus, struct module *owner); From patchwork Tue Dec 15 16:43:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975309 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 89B99C2BBCA for ; Tue, 15 Dec 2020 16:54:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52A0F2251E for ; Tue, 15 Dec 2020 16:54:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730401AbgLOQyr (ORCPT ); Tue, 15 Dec 2020 11:54:47 -0500 Received: from mail-eopbgr20054.outbound.protection.outlook.com ([40.107.2.54]:56934 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730531AbgLOQqf (ORCPT ); Tue, 15 Dec 2020 11:46:35 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B2N2kXOnixKCx8090hL6VEV45vbukElCQm4ipyZ4JvRP22L9jjddPGT8O73vj0c+FH7gkHKJNbLCEvl9sQExPilHcMuT8SnSz3KtaWuBVQwkC3zMXG81b5q2QADXfRNMgdbKUygVHal0jnDO+D4OZVLnM0klCbUvIEzRrJqi21tO+Xhq+38CVrxYcLu2/AkWTrMoKvlSnin4EDpm8puCEf+oXbfKBSuHKHh5QdAi2C3TlZ5uu0zjP0S6PIO3ScoAQgIFNkTFSLR1Egpc7filO5UY9sTegIflCtM77EVNiD2RDya4Uc/WKFkxO12ppNMUcdvlAT4OoAdAYtXuruYtfA== 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=J99a8bnRoMTGOgkgCKVorR1cedCBY9YEIkc2W+vFOAE=; b=mAizbbCS8UNWWkKnjvLui8/PR5l4SZjtg1jylQO/dxZMMQi7AW4+keP4yWhYuUGqmda97CGtwJkok0POojDRoUfZdmDJpiZJz2SDEcCn0tSqUQ3Rao90D1xYOU7lL4vUieKhCUNV+aLXynEOA8PzYzsFJ1LVTM8VP0MmPcSf8rkF+30fnUQEKGNgTv0KN9fnd6So1yv0oc4+9bMjFz3vBeHCVZauXyRB53EnrD5Fg8sE/LIp4zsNQumd45DvYEFV3pGcroSglbomktCPdei/hEFz0bz+Zn9It5lEMYsIRdQLVlRUaEavOEXR0DMlmIDXz8inFbcH++5bhp3TLtrGBA== 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=J99a8bnRoMTGOgkgCKVorR1cedCBY9YEIkc2W+vFOAE=; b=VZlI/3RXJU32N0uy31xcJZkYw1ZSnDNTMUtpw5KRmbWWKA9elwW1jb/WaTPtBqy6iPwI794mDqTAM++DRa8MUSswvKvzLFPFwcx6axT4FXDn9FZBy3SvU47NQRpKV7b3pG80AliLhw7Y0c1jBPzrPooNV7NMBSTwu6WYYMwDu2M= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:44:49 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:44: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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , "David S. Miller" , Jakub Kicinski , Jamie Iles Subject: [net-next PATCH v2 09/14] net/fsl: Use fwnode_mdiobus_register() Date: Tue, 15 Dec 2020 22:13:10 +0530 Message-Id: <20201215164315.3666-10-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:44:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e0e0592b-4c54-4bc8-537a-08d8a118bd1f X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BhD9vBia6SZ/boJzhb8OsiPnfyG5lOBSL1XtnQb28vqUJXGwHcry9TfP7NSET+W4PiCboMSbxwYnV7fycC4QFETYYy0DqijlamVBPCf4Wp8HlrizYZ0mBCtWalvU5xCY1QcwPZ0XWmGh1K28wIhxcKpIZi0JU9nchzNWe/W6o0rM6ecrZLu8gu4b2pZfYLVAGJY+scBfeDDbaJmgBCQtxsfV5LLgVmmP7LT6r8vZcDZ0BKhs93/5/T8whwkoqO2nJkj/tR1v7gzVC5zjpmwEkqITgquzfA/moEgUlD0aSxTyz2UlLx+FE7O8d8jaXHHsMqndRmxotVwxl/AJ3kBM4fRmJiFTVmqdqvvn3KUdH6l8Y7rH739IVJrgjj26lzRebFVLqkp+otapzVu40JYKGQ== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(83380400001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(6666004)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: goEkRGcYzblQ3he3SKrjQPJ+vE70KdjC/N00AeEhYHbKJ72xwRiU2XdtzSxsuF/c2DPFOkFSabF9KDCCvJaDrMIEbjDli6aWz6DMkH2g+WhfASAR3saChE7rTvctUPHCq3aQ1gWIyUm9aYAAteKzVe+tB4D4t8upIDrNLymFAC7u7UsdorZBz7vqtGU/8/MidK3TNhWZjFYT+dUGGDhwEwAmiR8/Y8pXN+4iHiFjhg4c4YUvWoEQBiE6ooHyIX1L0V7cfPhxOzqz1zk4lzM7UcvUD/mulms0/I7vSzizZgXULJRvXSR14XscYWaeqaoyGD/pCQV+zIk+Pav9keiwFnDk4YQ9lJzuSniF55RCBhNwIRlWr1Hc87MyRjqh7Dw50JZpOWKVLyxUO9AtU55imUReJDy8pDVPChM68W3QchspMeYMrgrOUttfoBhHLL7AtfFCINV3apVReJgR55sdARrf5vQh5PA2RradAul62aaeCUMOlWc3TZClXnGzdjdJYD7b2KgvfixHQh4RAsCELSQTZLGIv7MLGkb2xzKNmnwcIZJJcviea7aI1fGwwtLxucah0oXqFjW56w9PrDWm0QGCQZagiHxbcJ0FVdcdf1cnMnGm6T4fvrvZaHZKqShEyEUJ8/Q3IvCCFbRO4WEjJoWnGEDhxFpMuImaFcqKFeJlzZsSbpMkVE3//XBZf0u7HTDE5NmcWxsGxC9NxJ5DA0x9gFhMT1LQm7IA6v+AvSJ6C2VuNrLxEDtIUk+9p6uSremIa1FuVoiPfFujxxi1xqwALlMXumm6OLglVhpUO4pckc1h1DW8cqJurjHZe9YygsZa2P5cTavOJRm6tavm/xGzmqUW04Zi3i2i2YkelOpbb404EupJFTuL0/pxGKZmR7GOzwGvgNAwHx0JBauOuKr6KabkcBV3HyDyyD3iN9hYFmv73G6QF5hLn8rT0KaZdJI2Y33ObA7/AHIV7trMvhwUV+eMolTwrO0jn3gUt697yRZCnjouRX5rET5pLJtS X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:44:49.5819 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: e0e0592b-4c54-4bc8-537a-08d8a118bd1f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CQr0KsITjJPY99JHbA0zuNsIcuUDHkjaMQzUhXSL8hWc/dmISE4tORsG7vsAQ2y0sZ7oZGTBTLOo3Ls6VqCpiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 v2: None drivers/net/ethernet/freescale/xgmac_mdio.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index bfa2826c5545..ae2593abac96 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 2020 NXP * * Authors: Andy Fleming * Timur Tabi @@ -11,6 +12,7 @@ * kind, whether express or implied. */ +#include #include #include #include @@ -243,10 +245,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 +280,14 @@ static int xgmac_mdio_probe(struct platform_device *pdev) goto err_ioremap; } + /* For both ACPI and DT cases, endianness of MDIO controller + * need 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 Tue Dec 15 16:43:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975307 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 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, 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 19035C4361B for ; Tue, 15 Dec 2020 16:54:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C42BA224B8 for ; Tue, 15 Dec 2020 16:53:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730895AbgLOQqy (ORCPT ); Tue, 15 Dec 2020 11:46:54 -0500 Received: from mail-eopbgr20071.outbound.protection.outlook.com ([40.107.2.71]:62181 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730497AbgLOQqi (ORCPT ); Tue, 15 Dec 2020 11:46:38 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G1XZr97BhJ7iDVUYjU14/zz0p39SUnDiu93krkPPH77kcUrxzhj9UtzDYMHvgInZP5heIbzqj7n4BqTOHsMg98CEF7zFqaety8RHwiN7o08w0jAcNbiTCgr3DOf1IYAfiB7936hWFSL92zEmBRVT7rklm1kZMdFN8Y0job+GV0cgvXrXzXH7jrSsS8tD5BM2lSXR6r6rAOfMXfxvLC3vjpvNBpLxEhyedc3bNf4mr6BuG3QG/SQiyRbj5QoXOu4B/win4QWBGc9Wj2dcDCMFEkqvZhtaG+B945b2uGqDzHyFwk3jxGfoEp0Y21Hmur3SsM4tLcv8yNiJR0jQrnioRg== 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=sQ6HcTkyHQIVmKPxdbmZEPyIPAR9U5iBIGkWl+KATAY=; b=JZDbecoHcPpXUSrcctU4pDCp0FjV+q818W3Z+yf8anbYeLdKZJ1YPSH6R733etxBEPL26218RYJteyBPiq0medaGtOW2ypSFX6A/GmF46hVSecLLxYTWjYVA8v5GxyGLAthvTzHa0TAkHwnaUYMXxujKsFqeQbm+76heFClz2jbXPvXN0dFC9CfJVsswZxpnXmEU0aWWj44xlpwHtcc8wb72+lZrogLknWAeKqxLmkPwNXOIkVgD8JyjS8uDL9O6GavFOmZNWEkdAjESOGo9/SvwkjxNBgryzdENwJKDTagQcoMsIsLlfAZth6pHz2NHzrIRWBfNCRhCtbgmWC4YRg== 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=sQ6HcTkyHQIVmKPxdbmZEPyIPAR9U5iBIGkWl+KATAY=; b=eoW+gR0BSl31BLZVP0Angf5y0a7kJeXknNW03ef0Fwg8YGTPIM0adwPGfT6GEzzvMjQQKNq3ENV/HL3DseCD68EhDt8JRu3M3qszRiruWN52eLyPCvE6ikGnRW06KgzEmzWY1b+kgfDVD/Hd/nlwg9Xy2jcW7VK3bxL9QtTFJO8= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:44:56 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:44: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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , Andy Shevchenko , Bartosz Golaszewski , Greg Kroah-Hartman , Laurent Pinchart , Randy Dunlap Subject: [net-next PATCH v2 10/14] device property: Introduce fwnode_get_id() Date: Tue, 15 Dec 2020 22:13:11 +0530 Message-Id: <20201215164315.3666-11-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:44:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ee438216-99bc-43c5-9476-08d8a118c122 X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:989; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BEaygabXVpukKNM0fKAbtAS/7ALZyJ/63v6Tt+HwJfN4Vkr2Y3gs1LS/BlGO3LUGDjC3SXi5ZgOl8HcJvIEgqkvlaF2G5OXeK830AlecsX3l0jStNcWvsCfn7Upy24kGEZTV7PMYvTSw4yYr5UnhS3WqWofbj33LXbWlvz1AvykKFRrw9Qv3S76Gn3lQZsGp+IIGjsWj78VcByO+qz+W53Vs+x0uo+8dMoPhmg6elKrhFLVO6iSDfWRTMcR29g7V925A9la4hdz4J1yA/Oh5Rmi1OiSCMj3AMjlmtNQQJDboqJvqTQFyggRb8kNajrqNJcns/HN+rfzRVePn4tjbRtmioXXdcl84osrOrX4Go2ZognH4avqesbSraIaUatZv084XJCEBv3TBiTsw8rdx3Q== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(83380400001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(6666004)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: nvaxuruIKkFJkLwBEztILrPmnZFBneifyUiAis8Itpo2nESJwVzYmzvG8jF20nViSUCbkhggJ5xHig+v+yNEsB7SXqdcHrd5X3XvRgOb9mfKVu3N30cii8sFnL7IWfeLgIajTC1pQPVgKLy/A+XOp2EFfRarAEiJ58JbW83ShxyUJxJL7l8BkH6cSyu4RWJJdQicnqLlXpt7BF0AZLaIoOYdEN/+QC7PsTBn+WZ1bgBmCmRqyHuXnt9FuqpWID45oLr+fgIcfVRAoLpUvY+JTvhwVOeg3x6hNHw0Bjp5jTGyTfOzR9hApWd3/DfO4bvZvqCxF76hc5yVvTjp1vhUvwXlf18AJ8dC1mBK7ZyXE3L7zzEQWnYZ3rRnVaYznolxSGOR0VAfwpLg3XbVQSUvc+sjaxykjRUZNj/2uTIQy/w6f804+DmpljYOUquGK+yqbRCm/rc82bixbtfPDblnnELFa1kv8KF+liqhmbXThx2E6zbUtmRBEQl0s4gbUbogdQwJGLXrFvqLgiUR9CoDIsTJNDJUMyGGFcvPUvU26RCrE5cFPLEbW7CvJH7A/A0okjNlmAVKxOlwjm3lZYrWG0L3Rf/mG22ZyYn9Af/igdyvk/AG2m5SGrWMRvldsBpDkA78t8MwGeZTDFM1CNwhzZcUQNqlHEKfPXmLcMbwZGoCvUMSX8X8xfYei0n0stJZwI9obs/hNsYKT6UimUNHASjuIpLYauzGRyBncP8Ai62HZg07IxDJxlOC6fqh8P09N5T/HZBgltKHq0mpbmCC7A43BTyCqXAXYoHou6EoZgRLpDZ+m+OOyZQWzNtpnu4rr8OyT9/7dX/mvGPxPeJeI+tV2MFKMfkk+/2CFhgW9mnR+EJtQkqHU6viJ1ewcx2kzxl7UWaeu/SPKqihifovjUwGry/BTU/wX+7UYW8AF9tqkEgQ6STA6NNdER4NorteceChNNJNfJ2X8uDiyMCpKb8cf7iRs//TnBmun1D6YoJSFRk3We8ug4gXVdPzA2Eq X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:44:56.3791 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: ee438216-99bc-43c5-9476-08d8a118c122 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Q1XyKmVQ9iIqoN/woLbC/EdI4Vz4OQJ+/6cMlBFeFaWgW8G/K2iyIm5prQIuWJqPhoDhMHuc362EYYCr8oAH8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Using fwnode_get_id(), get the reg property value for DT node and get the _ADR object value for ACPI node. Signed-off-by: Calvin Johnson --- Changes in v2: None drivers/base/property.c | 26 ++++++++++++++++++++++++++ include/linux/property.h | 1 + 2 files changed, 27 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 4c43d30145c6..1c50e17ae879 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -580,6 +580,32 @@ const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode) return fwnode_call_ptr_op(fwnode, get_name_prefix); } +/** + * fwnode_get_id - Get the id of a fwnode. + * @fwnode: firmware node + * @id: id of the fwnode + * + * Returns 0 on success or a negative errno. + */ +int fwnode_get_id(struct fwnode_handle *fwnode, u32 *id) +{ + unsigned long long adr; + acpi_status status; + + if (is_of_node(fwnode)) { + return of_property_read_u32(to_of_node(fwnode), "reg", id); + } else if (is_acpi_node(fwnode)) { + status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(fwnode), + METHOD_NAME__ADR, NULL, &adr); + if (ACPI_FAILURE(status)) + return -ENODATA; + *id = (u32)adr; + return 0; + } + return -EINVAL; +} +EXPORT_SYMBOL_GPL(fwnode_get_id); + /** * fwnode_get_parent - Return parent firwmare node * @fwnode: Firmware whose parent is retrieved diff --git a/include/linux/property.h b/include/linux/property.h index 2d4542629d80..92d405cf2b07 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -82,6 +82,7 @@ struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode, const char *fwnode_get_name(const struct fwnode_handle *fwnode); const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode); +int fwnode_get_id(struct fwnode_handle *fwnode, u32 *id); struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode); struct fwnode_handle *fwnode_get_next_parent( struct fwnode_handle *fwnode); From patchwork Tue Dec 15 16:43:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975289 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 CCDD9C4361B for ; Tue, 15 Dec 2020 16:50:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9BC4C22581 for ; Tue, 15 Dec 2020 16:50:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731062AbgLOQrC (ORCPT ); Tue, 15 Dec 2020 11:47:02 -0500 Received: from mail-eopbgr20074.outbound.protection.outlook.com ([40.107.2.74]:21124 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730706AbgLOQqv (ORCPT ); Tue, 15 Dec 2020 11:46:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P/WVPCAIs+r8RUBY0ewuhASsR8vb8LQWIFZdPdbHqKkg6lSZTvqzTdt3/Sktt0FwIUbsRYqn0pirEKIjNwrqM/Zy2yyWS0tQf8fJpL3lVFbd58FJ8kpSdykIyVJIF1Rkx42kNEx8lDOKBTV2d7kPK0HmJ1ijYSEQIvH5ElV+HCqnxVOzJ7HNFgGl23Bx/+Y5gULLSg5kGI3zjaqziw/LHBawydj5+T6bhq87csXBQ0dHRPPUfnT+Y4gA5wPMJwOyPv9QL7Eqt16VeEue4S4RUU4CWhCxWQyR7efbFr8XrDZ0BRh2T2MsArGsBjCy0yy5wCqy9tniM7r8jHkNMS75LA== 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=cR5uxtAJAfifm5l9IKMnUt7DAtEalUAeBPie9OfBW7k=; b=nX5obz3WHHMd6K6vGY40ySHLhppGKapHfn9cLqz/N/35LDMhGE89Xhgpf/v3zbPl6t2LMaPjiHSCkeLouXn0QRRKBnTrdwHXtNOuxeuhw/kqWSjajkQBh1/j4Ij4Czb3KztobeL2px4kkhsMGBEczyvfvGbwSgQ+TXbrobjouaXR/oeIUfNKjxALt+9/Sol2ZbUFvTB19DqJvGrXFl9ayGWLdI7MrReadzqN4T7eWu2SQUF24nIOn8BO4zC2h4IkazUk2qeA3YKwPjvszLPg4+KWlEZSbuR6BCRblMRjyfG+VsuhrbVfsmMK2FDCvQf7uXaGV2EDXdXZ/ZZwSC9gIg== 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=cR5uxtAJAfifm5l9IKMnUt7DAtEalUAeBPie9OfBW7k=; b=VKEr5Ed5rORCwyHPV2DzKU1FO2ssJvJ7gWAeEmy+eBtLlE0GhFTK7riE4BpdDnk07nVOsGRcgshbJfwe8cVy1/xpFsFx20A5bVI8A5raNgjGaKsk4JJfzZJf8c9aeaQM9Y/3u/FnObn9eSqCWL4twTJzsz4MLWgcggy+Lbhuvpc= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:45:02 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:45:02 +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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v2 11/14] phylink: introduce phylink_fwnode_phy_connect() Date: Tue, 15 Dec 2020 22:13:12 +0530 Message-Id: <20201215164315.3666-12-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:44:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 686d251b-1694-4bd2-1177-08d8a118c4f1 X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 68/Lrz3Uj+ZgE5wRKqsVE+zRjfw4C4DB/VRQ1ULbitubz5fi4MIV01quanYdJY91c4lP2YRpEvKsAQvUcIaoFI9oPAJ8Rcnyb9MLGbwZ2pqbgAH7SM3BNiSaaWg2Zj4DdE87mY3PSHa21qmAAcqd2lgmfj4gcMl8mDYhsocDnBJE9GH0YeHTBNn52hIYT27+y05YZ7lhsiVmXm2H/JZl9NaA+Y83cbfGI061XCOeySFKpn/yTVs0wBP0wzLYZslpANUmG0Kh9U4hydrgwYO4NjHUbVTYnuzwKy7F58J+MP+PMgaHqiSNAHVZyghI0wp6T+twlOXdiWuXSSPpjvImD46rddXFK08/NNTjM6UGwscRfeNwQ+BAhPBZNs0gyV/sRtluQcXAwzSONwqLFklpXg== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(6666004)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: IVwwQd0qh+dUdRR66h45q/IDgJrr8bdcAsGF/bJTc9N1nhXKPhgwYvr0t5TxR7m758rZpbi1rzrvX8PyKS0FdOh/bfVtHcNpBVDK/um0+wOYYofUUvtpXlaUOPD3TeJo4LLeMbYpmNN7fP517+avmMg+A5moAWvh4Hb2YbEig+vjinB/9IVUfyEAdwI+8k9hjIyw9U7lSNbbVPCdwVo3HjNMuk4DTf38dEpdXwNsRWdBEW1KjVbt9jQ6uRz7IHBUofv2xncTLaXQGDtPd9UCN/uREJOnO5MCtZV8mbmMuewE2pq5yQRallOr2N2ciknf8XcbzM5Le0ppNZ/p/plFLEVzdpugxMyRHwqlJS8CA5AsS1teX1ZyhfWF4fyhIWDJXK2bRQ2duRv0Pq35q2zuku5zRYmG4Po233dPV4RhwmN+h8XO0xrR4HpxlDkdgIT50vzGBHmHJgRB1RT53Zbre2LP88ZgQJrS/qu2mo+d3M7T0/kot9Y1i1+c76lbyOAUhHHWQ+OChXX80YDiXc5GShXyktGA8SHC080M8s0vEwvp3Hu2JqcJCcIZLQMyNN1n/X9P2cF5Jgn/zZGtv8hPLuMc5H19YLMcLMoJ/nKyzCTir+wWgtaeZ4jkfiL+AS75QJ0o7dnmYa97NikpSVvK8YdkpAPQz/w9y1HKaMPN0+MFsrQZjPTZFA6sJj2pYdxWUE7wyf3/YUfG76vBg6S+XWpi4YE/LEBB9lhXXEF+FQw4tmbDxGXraWUys7ARAQDe/MQECppJIWBRxGNWZYfULVkzRuOTPX8GYZIM1U/NeGwB4Y/AJauj0UilFkkJi0VQn+tXKTNavGlPfV1AY8jnBfX0/B1nqgwHcyK4W5PIJNJN1L0seYqu5N3pggRqhBoO1+kUj+B5xz7sYaVUS1e1jFQlSOQ7/EktDiEQyv3/4SuhDcEcCeWmaJzzn13Vm6kNRsZaNhzEsybhXtvwdy6IbhJXnfOcgFyUJI1oMcturP46qfJCUfjxFq2ecM75bPfc X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:45:02.7355 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 686d251b-1694-4bd2-1177-08d8a118c4f1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: A+3fatH/X1/YbXPgCJ3SRiXACez+wgxjesK2FFzqQnT1hSDqw+EuwRoX54ia8/fTgne/59M6GlXVVAPA/yH9pA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 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 84f6e197f965..389dc3ec165e 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 @@ -1120,6 +1121,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; + + if (is_of_node(fwnode)) { + /* 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) + 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 Tue Dec 15 16:43:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975287 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 D25A2C2BB9A for ; Tue, 15 Dec 2020 16:49:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A494D22581 for ; Tue, 15 Dec 2020 16:49:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731109AbgLOQrM (ORCPT ); Tue, 15 Dec 2020 11:47:12 -0500 Received: from mail-eopbgr20054.outbound.protection.outlook.com ([40.107.2.54]:56934 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731008AbgLOQq5 (ORCPT ); Tue, 15 Dec 2020 11:46:57 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gPLD+y3g6ZN3IaoXtsSAw9nhiEOzucBOajEr/ebKrk9a7XvYzlC+EoCkgcc2JaOA9pOdmKSjAplXgvIKHbVOy/IDbD7ciO7U1PuqhQR7x7ROo8RDPEaHSNZ9uEuYO5RgcrXXyfGKTfnF+NRrjRK4IAgc5eZvOG/PijeMk/bcGNRvBIia2rpwSdR4sA5bNIBqDYN08th+3JO+3I0cYdyDC0Ls4Te8D+GVq1FG/yJwqIbB0PMj6IgBTdXyjMOCCHE/IvJqrRwSd94ovQydws1oFxdDJVIbu2nZcYSrngYLusqT+jzWlg87SOf634zfm5gdeyeI8FzIPmQKL5L4BF1Mmg== 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=4yIDn0BW1D9Z1aLCgK/7Y9oGXzsNuSW4w10DVYjjodg=; b=U0ebrjGMFJjQChRSCI/eGwN8KnTpiygKS2ANxJQXJh2krkfuwA177i4yVCLCjRi0BuQAQwp8ImEYoAgnYA5pnKbw2F8B2h5zVU22KHyYcsrffYc3QjPrArXcGgcw7ntpi4oUEmeeEKPhHoPv3YXWCo3MELQHkpACAqJBWp4br0kd1FuWb/E+famwWY4KYTHX3dKcWFR5KONO+s/XEgAPAATyvC3xIYhpA/+djVRsdrRR1ft5lvMHHzGa9lE0MJQP2qRhtqJFf6Kw/Jpc16A5gIT+UoTIqmg/s58MbpL67GuJHVeXOJRmtCjwMWcZ1VxTIpj2HfuZ1hefcJNz5Qubww== 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=4yIDn0BW1D9Z1aLCgK/7Y9oGXzsNuSW4w10DVYjjodg=; b=CbPCS/roNhdX33vw6cTvsQHm6R/xyacxyiilcwbJHMUqhfGAtFxttpxR9QxV8a+yyUv04jqc46ctN85esZcJRGEdEsfaU9h0UIP8OJ3sAgPWaHtcngNj/2Lwzdesb8R7bJbd+E0RQeeh/0D1A2L69SuliweLvSiVVns8P18feJY= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:45:09 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:45: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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v2 12/14] net: phylink: Refactor phylink_of_phy_connect() Date: Tue, 15 Dec 2020 22:13:13 +0530 Message-Id: <20201215164315.3666-13-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:45:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2c4a2bdf-c5e3-447f-9771-08d8a118c8bb X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2887; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xUHl1ggdPvyJagLz15cW9dZSPE2WKQbXM+oD+N7QsS57yXWOmELi3OohfxMJPc8B/NJbAlR+f47aujZHLO97/54Ws9kP1Zho1/oJQp7F1lBXRyspHW/AKQrkzE0Kzv80B65vLh92FwploK6hwPdLDBlP80F/mb3MAgAHobmBa4zy4EB3QsWTWy3SsGgsXXbcIfpnTz3xuouWNo8j5JS6jUdoGTXqb+sgomMeZvAwD1B6Cnn7DgMdpxwED3NlNXvW8HTG1qm/xmGAKHWLQuWKudlbvQc/TyOL9A1rw2PXssRMEKtZd194YC6LdHdCPUNd5yIh+LXoLewujKeKxZEQzDrIH4N+Sd0OV+XknG8TDKlPvpfH8K/VBRQ/T60sspz9LDqFojU0Rd8B7ESHGT8HtA== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(83380400001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(6666004)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1sd1QQFk46NJrXb3/pZn9svsbTj6BMl8VEDsfiDvuNJ4wXmq+3ojxNigsTPL7ilUUCIEHlW7OscsLKk1aXPU2AXojjb4hsv7r6U97bYcbqQEaIzmyDPB1/PP3CEud3ASsffRfCJNHSdyz9YxWpo8daWk7Tqrftnhsl77zrxlL+9dOhKuXdeUpfAu0Y/PBCzzrjHqVAQeJgDokbfLJYC9Dc0sy0/BmwQHThVNlOufGTytWa6mBwlI0nVhZGhAOcW7WRTsfH9eLEUI4ZxBTLPIlaE/3l/eB8vnWT4wHPAzrH0tsBVjKd36iZfg0afPDcx1fmeHDQRKtorww3jgzIfKtg4o+AM4nADnTFxgA+tGGWbHoP0bQkODLAlfM8KfDRMo0hzDTJaeNFAGao/ySY5gi3eOswaDOW1waeuj9+tl0MMkVpX48C4hL87W9ZH3vol1Jju+IYNP4FvSXh+XH4eBDF2vRlIS00OBX9Z9N5LF268z1GJH/bsduMImQRhCBg2t9ctF0YiRtuXsSbUpH7AzI9g0WjuxxqNTE6WGVl94JuJqZSRB3CTqhNBTq9206pVcL/AR+5JM3TICsCJL6/YddJCCueW/4A2KvXHVHu+l9J9APhfwIMBfbbwi3RXwupkWphbYARuPcU/czQ6BkBe5BdYvuTUyilgNqhe6Ko+mmaBIT8tLO3aab7ip5UuqwZ6OYvy6UsaeKDgViMOT1fSXp0Z5kKccdndwzgxibPE4lnZgfgSN2bY2BWjiUGRsLP8ZgBEz+uSYePxO+Y64U9BeSDfZoLbQzWdjOWTFc/kSBzYEE1CHmUBxcrN/D3vQ+hjblr29c5mCqkSIwI2G162pwrflIhuoLhPo9nWMaXvcj6TGQZS5uMJOlc4YB3IE2krRpOsQzQ7wtABULQ5n/Rj+ke0at4aib+Sf9Ec746curP/H4F8Dh/JfCVhV5ZxNzK1jWWmQReGe2nE9RjghhC07vRLsvfdCLVoHFSzMXjGBiht+Hk5GMddEjBbkEGJhWTJE X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:45:09.1259 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 2c4a2bdf-c5e3-447f-9771-08d8a118c8bb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Z2rAORW8WHDQXnaZHQ+3UA2U1/9Ec1DT1/3VeTJZd81h+L7T7BFvR4dKOJhwzHRFGibtARbqMnO7QLkTZvj+aQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Refactor phylink_of_phy_connect() to use phylink_fwnode_phy_connect(). Signed-off-by: Calvin Johnson --- Changes in v2: None drivers/net/phy/phylink.c | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 389dc3ec165e..26f014f0ad42 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1080,44 +1080,7 @@ EXPORT_SYMBOL_GPL(phylink_connect_phy); int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn, u32 flags) { - struct device_node *phy_node; - 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_node = of_parse_phandle(dn, "phy-handle", 0); - if (!phy_node) - phy_node = of_parse_phandle(dn, "phy", 0); - if (!phy_node) - phy_node = of_parse_phandle(dn, "phy-device", 0); - - if (!phy_node) { - if (pl->cfg_link_an_mode == MLO_AN_PHY) - return -ENODEV; - return 0; - } - - phy_dev = of_phy_find_device(phy_node); - /* We're done with the phy_node handle */ - of_node_put(phy_node); - if (!phy_dev) - return -ENODEV; - - ret = phy_attach_direct(pl->netdev, phy_dev, flags, - pl->link_interface); - if (ret) - return ret; - - ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface); - if (ret) - phy_detach(phy_dev); - - return ret; + return phylink_fwnode_phy_connect(pl, of_fwnode_handle(dn), flags); } EXPORT_SYMBOL_GPL(phylink_of_phy_connect); From patchwork Tue Dec 15 16:43:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975291 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 E8ECBC2BB9A for ; Tue, 15 Dec 2020 16:50:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B91C422582 for ; Tue, 15 Dec 2020 16:50:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730368AbgLOQtx (ORCPT ); Tue, 15 Dec 2020 11:49:53 -0500 Received: from mail-eopbgr20071.outbound.protection.outlook.com ([40.107.2.71]:62181 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731085AbgLOQrG (ORCPT ); Tue, 15 Dec 2020 11:47:06 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gxfCJ6uwZBOmHW7Fl2O06FYUoWMwkhRp6TcKiTApoQgtj0ZSJlooZ5Dhm4Gnx16Cv7qr4a9nkLgvMM4v/AgdkEAfQfQzWFXbUuRiqUIwguDid+/azPZ3xSWCKgok13TqL+Pge3RiYVVyAG1+7cUS1KE9Diad2ttdxM3GyHD5XjXSshYcf28lAlKnuGcGpZvyR1owzL5QgsVTI07JYtXjDuK6prIPRi+X7wPvna2uN5NuS4h/B30iW7jRly7q7dZ7HxFeGT7pjvxUcqeKPVV04ogWboEfzcCrmaWwksSlxYTSokWRgQywf58uIpmPosQZVZiW+QjOaWwTI62flVISDg== 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=UND/pck996DSy75bBqT6ZgaCDoQq7DUyw8eyoRx8PCU=; b=mEHff8PefSSw7NIVFGUg4bHrDo7Mbino/B3jJulaQPdzIF1xpoOv3XUfeWQ05VGULAUVFxcLiCTZ06APXw4JURThbZMgoMLG4Ht+eymyGQJchs8bF9inkr9pWpVMlP2t6ZgotPKBh41QG0yWDEQx1M7su4yMS/zEqtSk8eWlHF4F9bK4bzw40C/cCS0UW1+wZBJ2zgRRxErAt7s/zJ43s3fBFpWozA4FthqQK52eN2wCRhhWmGxC+vDTbTntNf5avcqHOguFdD8pE7ZY0L4l3qDDnlAVAUw8TxXKUCVdMAgNh4Jj0c2rfTNbI5wIvUTELKp9ESV/yY0wPIIOG8zAdw== 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=UND/pck996DSy75bBqT6ZgaCDoQq7DUyw8eyoRx8PCU=; b=PpHnXjJt82RGf9/lQ1zWhcobrLXBbV1ZGiubHnDpg+y1UaSodnle8I0LSYtW3R2Cqtw5Uqbh4+vhAsVymrMUd/ysPJUiVQUMll0+nVWz0QIWV5u2ESEyVjGgBf6tqOl89M0U+yO3O9Zt8EIfJOeN/frkNzQHJq7vqZ2CL0et6M0= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:45:15 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:45:15 +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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v2 13/14] net: phy: Introduce fwnode_mdio_find_device() Date: Tue, 15 Dec 2020 22:13:14 +0530 Message-Id: <20201215164315.3666-14-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:45:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 78729b63-e677-4417-5a36-08d8a118cc85 X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QIblWHtQniyAXw6dXcDfAAvbN16NeFwqQP6aaYRXTMkpPPxwTYBcqGl/x150i4sGzRapKG0540q8IeuFSmJmnyv+v+C8n3yz1CLcB+Cw9Q6yED8hMydyYJHZu/xc9daBupqANVDBb3kbw1W4V6y7dFmOCX0fyj6zz+GIzC34jjRoxcR0A9JCy7oQx2tD/e3tzCXL70exJfJgB4Q/Ny+/sgKsIt2v28oIqIU+xtTH24itdGdwq8Aqi90DnSNBxtrQX5V++bB49O+1IrKASuloQ/LpAONcJPNJcVOqwDl8DyYYaxmZjZszwww/OXZ4EELT2L4gVAtqc47HxjbrqpIkReqWwY2R20zGeB+UkkeqMudc118DE36ojbRmU4y4XDYyPR64rEiqlbhYx40TFtHLsw== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(83380400001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(6666004)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: xDsOUT3fhyYEwnQJF0AeNCDQGyCPwnX3L/2lAiLNs6G6ti1oZoCPYOk1/FLsSFj/nwng1djD/PmoYnAY9AQhTTy5Oxvuq28f33th6e83zLHMcNivNNXJ26/Cr7Fl8xIHk7QEWAEYX2yaOfaRfLGE9XejOCKTY4dFMiZ/3TCy5XJrx5vy/p05nOrG3P4Y9HOiItX/IcFB+IZDNP0J/Y+OjODJCe00v55wtaxabZi8C024mAO/x9VQ/Cqkx0O8OIuWt5yoqPTCMQ8nm3QAWzg06oY4zOb+K1k1WHJOkJgtNrj7wRskgXTospi6rMq9KrbzlRFFQTGO97FhllRRDAl9joW9K14P/vgvDUkeYMSmBQJqv0Ge26qdi8JHLHLKt48cuopr+OuxhHij6unO2QszQ5g+ZQctCngOtm2ZY82yihKqL74myKfqaCgb6R8dbVkt+UUgzQTdogN9c+G9Oy7122MNUYR4/z9tItTyr3QROXHRKVvbToJMDji3BVQOH+TiCiHOfJGhYVW36saCmGUQ5GFkyd6P09SzzB3T0lmKi9t+VeENmn9mqvXkh9MXEwrNILICFT155Uy29ZJMT5rotSWY05jW4VKgPXRW9xkaK/o8nUb2Odhez13GwD19x4OhtP7cqxo/xXD+f5MWyTiSjuoC3kl+rV9/dY/JxsncA93mcpa3v97x/GTjkDrhJ42DBOcsCiCDVVTVq3hbyxLuaDVy3KP1Yvh4Wn/3eMtF2A/xtYY+hM1vTRuvazzX4dUiiWUx2jpBOv58fet4VvB+ry73VwkJKW+S1lyRnkPb93p/gszQ0lGcruPNWEWfU9jEEhBjpVf3PPMH8I9ubXa8h4AGkU7oSdovReAj4fWDbGdFlSqaVNJfAU/aRJk1A3yI5HPKr2pxVo/L0mYAMVbxRn6bx35YgBso5jEzWi5ocY8L9HYzGlUkacaDb704OoTr9kBL3FmDPbILirE0GHwW1ugFw3P0ug8P8Ty60B/crSkv7Z50FFs7QxPJ7m12VIqy X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:45:15.4624 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 78729b63-e677-4417-5a36-08d8a118cc85 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GCqdCpQ/SlUuGV6/WUhTK+5nKJfUNs3JRle4exiimznbhE1oQu8uDyE78R+hYvo+0CPQNQZbXfZ2nvhWyhEHKg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Define fwnode_mdio_find_device() to get a pointer to the mdio_device from fwnode passed to the function. Signed-off-by: Calvin Johnson --- Changes in v2: None drivers/net/mdio/of_mdio.c | 11 +---------- drivers/net/phy/phy_device.c | 23 +++++++++++++++++++++++ include/linux/phy.h | 6 ++++++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c index fa914d285271..1b561849269e 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -300,16 +300,7 @@ EXPORT_SYMBOL(of_mdiobus_register); */ struct mdio_device *of_mdio_find_device(struct device_node *np) { - struct device *d; - - if (!np) - return NULL; - - d = bus_find_device_by_of_node(&mdio_bus_type, np); - if (!d) - return NULL; - - return to_mdio_device(d); + return fwnode_mdio_find_device(of_fwnode_handle(np)); } EXPORT_SYMBOL(of_mdio_find_device); diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 6fad89c02c5a..17d20e6d5416 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2851,6 +2851,29 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv) return phydrv->config_intr && phydrv->handle_interrupt; } +/** + * fwnode_mdio_find_device - Given a fwnode, find the mdio_device + * @np: pointer to the mdio_device's fwnode + * + * If successful, returns a pointer to the mdio_device with the embedded + * struct device refcount incremented by one, or NULL on failure. + * The caller should call put_device() on the mdio_device after its use + */ +struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode) +{ + struct device *d; + + if (!fwnode) + return NULL; + + d = bus_find_device_by_fwnode(&mdio_bus_type, fwnode); + if (!d) + return NULL; + + return to_mdio_device(d); +} +EXPORT_SYMBOL(fwnode_mdio_find_device); + /** * fwnode_phy_find_device - Find phy_device on the mdiobus for the provided * phy_fwnode. diff --git a/include/linux/phy.h b/include/linux/phy.h index 67ea4ca6f76f..5a0c290ff0f4 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1343,6 +1343,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, 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); struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode); @@ -1355,6 +1356,11 @@ 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) +{ + return 0; +} +static inline struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode) { return NULL; From patchwork Tue Dec 15 16:43:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11975285 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 9229FC4361B for ; Tue, 15 Dec 2020 16:49:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 572C722581 for ; Tue, 15 Dec 2020 16:49:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730497AbgLOQr3 (ORCPT ); Tue, 15 Dec 2020 11:47:29 -0500 Received: from mail-eopbgr20074.outbound.protection.outlook.com ([40.107.2.74]:21124 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731124AbgLOQrR (ORCPT ); Tue, 15 Dec 2020 11:47:17 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J4RhQTziVVhMWQUJTXnNcZVOAwLh92ixgpBde/b+wKb0ULJ1vjF37JC6BGZ7KJRA0s5oei4C8JTFfP2iZmr4ld96dd7HcXFrd3Tr5fFZ+VyfsuPdgW4NWt6hgnlbLyVlJh+tzf4tx4duMuWQCXd5/tytBUMrk5bP/SxqExSj+tiaWJIgTIjCqqNJzKud9iKCcZNOzCTtKIvoLolHSJWb6Fr+imnhw4cXc3X71MqBzzqdra9HapdNHf6Nbk7Eax9ctgHhaIxuYSGno2u/lrHNwJCNQPMDJANOlZhCy4iGpq4hdIP7UDoGcWgJqY4Tsg/OHhWYK6qRS2ti1MIsADqNIQ== 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=xMRbpQD0LVMf6T7TrGvafn1q8NLPEbIyAAG44pHcTDk=; b=b2JkVvdJz/AgJ451vS4FBbuucrA8HFLRn7XDyZKHgk1qv7pnnKzj69gZ0W1VU1Ru7GDUJ+5kTs+C/2jU1XMUQlYT8qlCFqY7wdBrNJOgyAlgtWVB0IpTOjIqiTsB5F922+TO1fOBK57FO4SfWJGSvO0w4fvcqoke+PiA/m1QKxF+VjqkgvlM0fiNovSqEdMn7F8KClkrBPAqhqwtoi4J8oVFIJhMoRjBSecJhomoAaeVi0O+aO0RKsYtXkNqRlN3v5UYpII/n8fT0IEdDjf94S50o14KH59fyg41w4Mx2vy3bTdcuo2JFb0c1EdKsVfPKXoz23NzohDeXnKoqb2JKw== 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=xMRbpQD0LVMf6T7TrGvafn1q8NLPEbIyAAG44pHcTDk=; b=gQsqxxG2KgNDFf2atX344OaqJn2STyyT/09V2u7AOj8YwcaWfJKgItxhzoBmuGSVLIzGGcyK5saKX4ZxYBk1YV7Il+9bO3n/TsbC+37MTVMy0U7yjRT5fiikl3K3+VR0LKRQHlaljJpV/3JKZAc6IfQFZlHn9tRIwMVWNcppOcU= 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 AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.13; Tue, 15 Dec 2020 16:45:22 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%6]) with mapi id 15.20.3654.020; Tue, 15 Dec 2020 16:45:21 +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 Cc: linux.cj@gmail.com, Laurentiu Tudor , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Calvin Johnson , "David S. Miller" , Ioana Radulescu , Jakub Kicinski Subject: [net-next PATCH v2 14/14] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Date: Tue, 15 Dec 2020 22:13:15 +0530 Message-Id: <20201215164315.3666-15-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) 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 SG2PR06CA0152.apcprd06.prod.outlook.com (2603:1096:1:1f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 16:45:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d06ff694-e5f6-49be-72c4-08d8a118d05d X-MS-TrafficTypeDiagnostic: AM0PR04MB6963: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1850; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: elnx3THHH3+kCoIf8Q6bUaXuGyQ0ubTUroN5ZKf2RGU3qVzna2xy0/UuFaFUyROMNGc5HV3xyGBy5RYP2FKd9hTCYFFC31hWE/FCO+K110MReXx7cI9e6XpcCT0Xpayd2FfOo68HPnjTFW+XRO+ADZu6nacTpGEZXaBfMIBIfTXb2mQIP5mRQcJtdSo/UAIMEbdTCrESfBoJ0uXnUakrPw9+LdwbILrDhCmmsI6W7b8mK12gz9RCWheRDfv6M25cp17XZ3seJo3faTqImaznRb4VPJGFYAZ+gsT9kBvtJa3J8oLQAN0pVVBnhKjAlQcSzB7V79JcCxk/bT45OmJ5Wyh0mMPjwmUvsFz5pWpxPqr1KQFdl4pZGPSbhC+DJ9BH3yYdDMjIjdLzZC46sBs7Fw== 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)(54906003)(8936002)(4326008)(6506007)(498600001)(83380400001)(66946007)(921005)(2616005)(956004)(86362001)(52116002)(16526019)(8676002)(2906002)(26005)(6512007)(44832011)(7416002)(186003)(5660300002)(55236004)(1006002)(1076003)(66476007)(110136005)(6486002)(66556008)(110426006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: y3vF0z4qAYuJ2t3Ox2z83vYXumT2Yja6sh8CVKoIj+GKOjEL6C4nI94jzMkmFqkRWyRhIsfs9IPSXQg6kK4B8pwin8goXKhoxuT3kOi10egVagdeO4jMz8F54fy7v/ngSY/ufhhfVfJZgYKkAqkUR/jGO2vEGaW4MmO38/rnoM9BCDJXgcas5o3F0jTxQouQJMPZ1ikW3tTC1bvtiyxdakDwLgvmWZn7g/qd4oFqAjUbM5PSASY3HyShJ4oRDhcBQzqLbz3SbvSi4qsBBX1lBzoWIqqNTAxh4xmLUDrQ3zPxBZj3SI9XiDKDF7EwooC0NdgTNfijM0IDLyG0G8Sn0oYaPipTjWTXri4oZqUIrXSPbNIAg0BRO09jv1BCU55TsVQ0VygK1mX1NSdd7bA5GuUZPiLOx1AdZ07KZRhjLURm0W/2U0dMqaepifPt9hvdtBMW+bPTueuyJ4oey1VqXYPf7KSGhwpkAdTreY9XG+x89HoWI7gTCToYZL0yR8zFr8rnqrJnpfOBQKLbEpuJmPi4T/KoolOCz2+t2Zf4GUy2Nf38k0+/pX9gVlgiXsmLHcqDWmHiyGR21PO637L7wOQblVrZcDanFiKxAkm0DH3c2JFJejc0qzNVSYwr0VCVneOMtWuoKIrzrz59sYwgMU6k9ZF4MBu9EUrSppvuPs+vxzgFkm3fj3CvVEZeUUjA9wnmRdpei/lxeD4yj83GPlOsmiuhXLoud2/J0jrotCbHieQErFvZXxxtxWZZ4SqQs/XIp4LP6pNAVERwvgYpupubjvYtv/cUgFK79iKx+htquSyD96m4jJUDX64use/kJty079QF/yNv8rkuTU2oI4VFrrnC93zcASOKkO3180Ex1DOUbowyj8vb9v8usjpEdTKe63ZoYGE6ZcdJghaBlVB7elrZ/GkL5K69UgcFs7Wd9X/UmXoitK2xUdL9qAShfqFSASFSjJY0F0OTJAHr04QOEppg/hoxPkTPu6bwuSNZsJl9oEn8aOy6iPeMT6nN X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 16:45:21.9287 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: d06ff694-e5f6-49be-72c4-08d8a118d05d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: u+agCN1c9BAEgW5I4ygxpXc8o7GDd+ys6xTqx/1oPQDtUTJv+xcAIw7LtL3qxlSv8GWtZ2sr76JGp8RShcPdxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Modify dpaa2_mac_connect() to support ACPI along with DT. Modify dpaa2_mac_get_node() to get the dpmac fwnode from either DT or ACPI. Replace of_get_phy_mode with fwnode_get_phy_mode to get phy-mode for a dpmac_node. Use helper function phylink_fwnode_phy_connect() to find phy_dev and connect to mac->phylink. Signed-off-by: Calvin Johnson --- Changes in v2: - Refactor OF functions to use fwnode functions .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 86 +++++++++++-------- 1 file changed, 50 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 828c177df03d..c242d5c2a9ed 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,47 @@ 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 device_node *dpmacs = NULL; + struct fwnode_handle *parent, *child = NULL; int err; + u32 id; - dpmacs = of_find_node_by_name(NULL, "dpmacs"); - if (!dpmacs) - return NULL; + if (is_of_node(dev->parent->fwnode)) { + dpmacs = of_find_node_by_name(NULL, "dpmacs"); + if (!dpmacs) + return NULL; + parent = of_fwnode_handle(dpmacs); + } else if (is_acpi_node(dev->parent->fwnode)) { + parent = dev->parent->fwnode; + } - while ((dpmac = of_get_next_child(dpmacs, dpmac)) != NULL) { - err = of_property_read_u32(dpmac, "reg", &id); - if (err) + fwnode_for_each_child_node(parent, child) { + err = fwnode_get_id(child, &id); + if (err) { continue; - if (id == dpmac_id) - break; + } else if (id == dpmac_id) { + if (is_of_node(dev->parent->fwnode)) + of_node_put(dpmacs); + return child; + } } - - of_node_put(dpmacs); - - return dpmac; + if (is_of_node(dev->parent->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) @@ -255,26 +266,27 @@ bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev, } 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 (!of_device_is_available(to_of_node(node))) { netdev_err(mac->net_dev, "pcs-handle node not available\n"); - of_node_put(node); + of_node_put(to_of_node(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; @@ -304,7 +316,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) { struct fsl_mc_device *dpmac_dev = mac->mc_dev; struct net_device *net_dev = mac->net_dev; - struct device_node *dpmac_node; + struct fwnode_handle *dpmac_node = NULL; struct phylink *phylink; struct dpmac_attr attr; int err; @@ -324,7 +336,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) mac->if_link_type = attr.link_type; - dpmac_node = dpaa2_mac_get_node(attr.id); + dpmac_node = dpaa2_mac_get_node(&mac->mc_dev->dev, attr.id); if (!dpmac_node) { netdev_err(net_dev, "No dpmac@%d node found.\n", attr.id); err = -ENODEV; @@ -342,7 +354,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)) { @@ -362,7 +374,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); @@ -373,13 +385,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; @@ -388,7 +401,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); err_close_dpmac: dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); return err;