From patchwork Tue Jan 12 13:40:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013541 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 CE49CC43381 for ; Tue, 12 Jan 2021 13:42:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E1F422B30 for ; Tue, 12 Jan 2021 13:42:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729714AbhALNm0 (ORCPT ); Tue, 12 Jan 2021 08:42:26 -0500 Received: from mail-eopbgr10085.outbound.protection.outlook.com ([40.107.1.85]:39271 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725843AbhALNmZ (ORCPT ); Tue, 12 Jan 2021 08:42:25 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RrtXBn19Dpr0GCFuYe68C+6WfT0TAEcPurte1oIqBOH5H7L9yzOa25qSavaUiH2o92xL86B0l2fSIIWVfzHeAxVlyWfGaw4mM2QBs2hUdyrkrlRPDf1dRM84dHMYLKH9BCKRr0c9ZHqKSIqTDPA+VwTaUBuFP0KleXiuK3w+j/MWVzCuQSWqKNZdoOQeOC0zSH1x2zEZ1lMfyaQ8wczJD1gUyAuVnm4T1LI+4b2weMrrj3kFhw6ZukGG9UP7bi1ieX64GJ8h7z/AJbMh6cftSC5buk2ftm6ap22s/pRFryAZz7fR7cXrwjc+ZBI22PD9hDQLjpphFPqtnSXUE9DXkQ== 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=qvg99/QHEKQLOMQEtuQ69CsgdJQT8cwBniu9gPnex/k=; b=VoBGq1dO48dnK+L3w46h4rOSVFI6uHnh9AXXOy53bZpaf6goWtQtofQW3WsQBx8Et4DDnQhEHUpC5mxwuBqUufyNOjU148PJwC7cmpfm0M7KAxBURNoSSnfs16jguDJNDok2hK0hTST87AcunsQ/frSLWZdqV9kpeDHYmCDcquRULIdkjUPtEqRu3hccOQjOf2/FryKfbZpqvJ4iZNWzQswWZoe6Y77rKmUPpGGJEku1uUVCgodA1irIOGPjB7miwltMQO9dS4zc5S1wPK7Zhy3DSace9IxBj8i7jAi5wCuBKirHTPgRe6XdOKMDbSfCid5rt64VSRzvP+jF+hANsA== 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=qvg99/QHEKQLOMQEtuQ69CsgdJQT8cwBniu9gPnex/k=; b=Qx8EpRy8NuJejF/GqlszzJQB2g7KaA4TMGS2UsI9CuxRMVOE7gqzAVWCz/GorrKAbbKWog8EUAN4iuAxkqf/UfMLiEuKFKIoA2vcSSwl1lFi4z2WYc0ycQJ0sFrHR18GmX67zqnmW5vafD9t3DlSQ3whdsopHXJFYNRiQcUyKaA= 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 AM0PR0402MB3443.eurprd04.prod.outlook.com (2603:10a6:208:1b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 13:41:34 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:41:33 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , Len Brown , "Rafael J. Wysocki" Subject: [net-next PATCH v3 01/15] Documentation: ACPI: DSD: Document MDIO PHY Date: Tue, 12 Jan 2021 19:10:40 +0530 Message-Id: <20210112134054.342-2-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:41:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d096dbf6-7626-4aea-e0fe-08d8b6ffc6b1 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3443: 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: iPxYBURzv7l14Jg3y840G+gz9bKmakEYEdqWn3Venfcnf/H7OwiEydA1Cwe+fFOtfpahnqraA3TyOZIGhbrBv8L7P9j/Ikjkb7kWyUPWR32b2q2P9vvtP2BaSxPOAtUYQV9qlXRsEuxwugkfOZM2M+d0yNUqdF3PpPN727LksMxd/WnH4tjok/SwjgU+C6WTblvzq5zRytNVENyE+fNVY/BvrbbJnsKwKyCM+c0a8eYcB7Z9Zv4T+H90w2D78IW/YiWh+C1IF88OwNQdZMsHc0fzvbO+ag0vaor1lLIa4aHAH4EMbu2nRNMTFSzASkPnhMb7KeYfnN8rBADGFtrabOH/UKuHul5NeXQQhPscwG2478N37sMqt9hWSow82bg3um2mbwlZz0p3Q81rz8oPQ/X7FtaxtsoeDOoYpLvSmp3wGEBnRz5Q9sOkJmVufmMIu4YTZZuCG9aRpmQC3RWjVm3LM4eS4a+t6eWdTXpfePwkDpPZWV9/jEAojxOikgjF5aljh5CEj/j06CPdiFmRDMKBV8NyUuIrjjSTpIIye5Y= 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)(346002)(136003)(39850400004)(376002)(396003)(366004)(478600001)(1006002)(66946007)(921005)(110136005)(6506007)(54906003)(16526019)(966005)(83380400001)(6666004)(52116002)(2616005)(66556008)(66476007)(186003)(7416002)(4326008)(956004)(1076003)(44832011)(86362001)(55236004)(8676002)(6486002)(6512007)(26005)(5660300002)(316002)(8936002)(2906002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: qVKwrRFnlmMXLyNdlrw6EFt9DgkSZlALw95DK4WE+Nwy5BsEINe/S6rLfKetO6NReGhBsk5TJiRInVvcJhIuyLf3XoSNOpDRP/As7L5HA1vEK3rJosKBm30K6aUDMpPI2H+yR4z2AK5I7X6zmMY0gakYnNYsjYMeCO5hF1q5Nt5DSodzOPdtcg2gCLC+cVDxKXn42DFUg+TK/h+8cajEgMI6nUsjzzR9Xwe66rWJFjfHymsYffdDEYKdqLtrhhk6HTk6TyqpXk/v5UXCrEuceYnHhrWAjRO7SC/hje1/hd0vZwnpBK+dG3+IzCI30/O6LHnYADWqAF4spFQtZJYYNhjJZHJM4Nl12vayPA2IzL2asxWacWW+XhbcGGPGlVi3EVVqQ6A0zK/fRO4Ex8fls3W2Hb1ZjGecgcEG7qmSt9OeG8J5CJ9zb6a9KQylZtnVWo3ZrxNiFDRivpZijQ6HAy+iO7FEL3SsjTlWwuytDw4fnTQDmyyEGKCDJMVUZ5RD1stW1Bz2AEJYdZIJxupyirydQkD9KrnEGOmXg2Lz7cnIqpE72dFz73z8Pwy8i79maWpgZl5aQPRO/vvCMn5lVfX6LYYI7j/UeYABXc0WxTxekznfzEeUQCiJdZeFhAYJuI3CHoTaaZlQ4f2Rkpxyaqs5zgLFvbHgJlN2Ugr+e5l3TTiOLx4VrjksrJIQ8q32kj6BWKcwUMR/zarBExzKaBXyiH7aduc6eGRjpFI5FGCnEvfrphzztYvWnM04FXT2ySbEHHgibot+23JRqkz+y4Bit3jGIuVH8U06ekxvxDylQZKGZ9eKTSSq7t+UtIJ2I8lJ/kWS6SwrBIkE5xcVF7Xuc0YV0oJtfnALIpJPzEAy6ZMgxqh6HGQyk1DmPUvCbDYqAO9ATb60pZ3tvk6A3L5LWM+cnJ3TjvDb+A1wDbwHexeTUWoeIrDbcfxYw/VG/OR/dwaSoYf+Y8PGkcE6WuGPyufoskGML/y2avasihzfFu1wN2RubRFPvRts3Mnf 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: 12 Jan 2021 13:41:33.7947 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: d096dbf6-7626-4aea-e0fe-08d8b6ffc6b1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8Q+YH0jAf3P91+CVk5kvsswan2ClkOBQ9K98PMzK5orMYJZgXBu8HLnUU3weNjq/Yd2VEyIs7/DWj/sYGkTPCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3443 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 v3: None 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 Jan 12 13:40:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013549 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 E3E82C43333 for ; Tue, 12 Jan 2021 13:43:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B331F2311D for ; Tue, 12 Jan 2021 13:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732650AbhALNnI (ORCPT ); Tue, 12 Jan 2021 08:43:08 -0500 Received: from mail-eopbgr80077.outbound.protection.outlook.com ([40.107.8.77]:16694 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726253AbhALNnC (ORCPT ); Tue, 12 Jan 2021 08:43:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QqssI2Y3D0fSA7Y/e6GbnbEDuHYufQy7ZCuOm3Jk2WChzu4mnjjEk3vy20Os4U+lZBKM1vmGR31XBFZNG2ypMlaH9IlhpwwdofxWUdxmS/Dkv9gVJW5ORluA2qo+jU/E0rFh7yjiQKCwFjlyl0mA1caQJmuQDGBOn1DtaTMdNX5bZW2cFkMUOQHFARc8+NteIWb902IF6O1RabCSPVscKUXfdj1bMG+Cux7Nphy50j0qvLs+3CaKKAyNPozaxoiTmfK0AJTrmXfyOeDtPxLe/rTxfc31bRT6xWgdJ9k5C39e+epvKvG75oZUJzaw4rR8FUMuTAJgXWVdDZDF6DPhtQ== 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=yXpABcfmKrz+MvWiOvDhJ1frsNXJUygFo5nom6tv2HY=; b=GCWnzp0rfiqTPX8VPE3BvVPH5Dtl2FLQfAu70mHDAWe1jiZIL6KI0889txnAMi28OAqStkA5SusLiYvU1+vXvRWnFerI2Uzx/mEyaqIcEINEvF5NU6RnYmmD+yXQwJmzazqtmTFLjZUkQwW/PSV3Koy+e88vhOuK3vFautUTEkbzF/0T3lUBweKjXIT/Nn3Q46YLA/5n5GsnyaE/UU6OFOY2ts+4UedQh2oX/kIEAkXyMCcvGOwV1txX6CdUn9HEZixk5gwdmZs+ZULzEPNusjkc0E9GZXGTAqrGQuwrGvZnOJGHHrlP0y5VbzRPaItfFVZ8/kakWfInYrZEWKuUZA== 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=yXpABcfmKrz+MvWiOvDhJ1frsNXJUygFo5nom6tv2HY=; b=iuvbv6QtbYvcTk4FquPA30SoYU5ct450wJZSnaip/7oD5amobNLJtkIua+w0Nwmr87NWBMgjucgPLzET3Y6sPvSf6Gj2ioj9BX2m/IEzZZb4BZOkdxqXgdmpVH8FIX8PMX7hbE4hcbWE7ylN0vlkkZHrzhzZLHBPcdMxM6rN4DY= 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 AM0PR0402MB3443.eurprd04.prod.outlook.com (2603:10a6:208:1b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 13:41:40 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:41:40 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v3 02/15] net: phy: Introduce fwnode_mdio_find_device() Date: Tue, 12 Jan 2021 19:10:41 +0530 Message-Id: <20210112134054.342-3-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:41:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c3f1d1dc-f09b-48ce-eefa-08d8b6ffcaa8 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3443: 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: i8wnilx2HO5l9J9Ja9ErjF0aD5WC8QHZsNmKb8Rug+ozdaIqiCBopIFrX1BoQQ+Mp8JEa8PcFpngrA3SuVn9HhxC1CN/3re3LSJX/rtyEIrRTOXxBgEGdlthNhfcBZCNxy7tcjVvIQ+KXOprQMVX7JH51r6UfKoqEU0McaJVThSQV1DR1aLrylS+CVTzwImP88C7WMtcdvZgYcyWC57G9tlF0BW6ve1hhPCbUGcPMsWdPRGcuvs0rT3NFEXwwRSNZ/SdaGieX/a9PeG+a1VFrMxIcLBDsBi0hOSI6B272bL1V50TGwIcudvaEUCk5F/zn4ASW82S3TImergYXnalrFhcpH/SiHDCJZyK7odfn2f98+Sr8sSd/IRpQiItE3x9CD6r5Ql0achWlUa+IxnXrXvs/B1tZgXZfYuIvJrSae8zaaL/0LoAoKcCjBpcQR9D6qfZPq/saI8qDVluEso2mQ== 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)(346002)(136003)(39850400004)(376002)(396003)(366004)(478600001)(1006002)(66946007)(921005)(110136005)(6506007)(54906003)(16526019)(83380400001)(6666004)(52116002)(2616005)(66556008)(66476007)(186003)(7416002)(4326008)(956004)(1076003)(44832011)(86362001)(55236004)(8676002)(6486002)(6512007)(26005)(5660300002)(316002)(8936002)(2906002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: lUH+lzKW1BaWs0QJPWOZrYMKJvYiu26x0HbZLmeLF0CMmvLx6mIXef667u+MCGxtvQjfq2duePvJs6Ko4k2XEdaFlJvfTI2lCQJdbefct0gMFVte58QlF5sdEIByN9ubanIZaWx80UTvPa1k9hWlt/YK5DRzoOKMd/BoZZ+PNJQ0oBHBqa5/YXThaeclpe31LbU/CoNP8E/0vhxWUmPtF7F2CCePw8DDmoAT5EJ18ePCzV7SBrVcx4tsdTqdLe6X6ycteuZjh6V8zmXgKLfbz76B1KD00TbDhtbQd7Xzqg+kEp1B5SDhkxiP503eNz6MyVlJ9iLCGKB0e5TfNw51smNxxHQG7ypiAGWQtVCJrLA1sXA9QLdeDGtrCXnNbtfoxLTzVtNja0y3ifknEAdBmaZHqwzb4QqkvjWGokVnmdj4W8MO4CGbgevKmH8gzOj54jb7B3S9g1mACfAcRn5gYrrnt+H2juxECfIx3y1u4TjuW/33bqFZOe8vJ/1vFOUTpG2bnLbnOjWfe/SvjH+HSwRIa9pLFYGg8aT9H366Y75skXsfi9BcfwV3tADo57BW200yAzESVAn58/15rxlDEOMzw+lPOuFdJfi0W5ZHlfqyyX02Lf7vJhgtL8bd/26/0aKbVH2miCsxq8cQY4M/1Nk9Qu4h8/LsSYhNzGNNvNWNvE+YptJo/DDtzBMUHr1I8yNoA3+7FDJw+XjFNTBrVyCgMOvTdoqIJtT3R7XcCWNC+B2RcCuOgHnca0vGjwwJc27+SrWYVm2Ck+S2jY5TPtStm6oQrzqLDLQCwz2icG7bhuL2OW3sHKh8hDwvn8ggvbtzO2GwCO9XfNzehRU+XJ39oTisGDpKhK69lQZTmMrIcRpD4e2X4fVcTtrt+0gPXDtguCFUVtozApK5adFv96qrEgi3OoGJa69x5Pa8/2t5LO194EgBawyM0NSe7h1E+ylcEBzjy7w4N/nxvyGxhAswM+gPxIljTJ3gkL5V0JcffRmvjUnK+LGRhLFaH3kR 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: 12 Jan 2021 13:41:40.5190 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: c3f1d1dc-f09b-48ce-eefa-08d8b6ffcaa8 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sBEEGRohFTPPtsIc4YqbRg5YKKCXYqXr3Ge0SbCzzB2Lqbr6mJDwhvku2dQpFsnKJIJ2xYJOrAKfDQp+0ZMaxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3443 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 v3: None 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 4daf94bb56a5..7bd33b930116 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -347,16 +347,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 8447e56ba572..06e0ddcca8c9 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2829,6 +2829,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); + /** * 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 9effb511acde..ce3987e4e615 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1342,11 +1342,17 @@ 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 mdio_device *fwnode_mdio_find_device(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 mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode) +{ + return 0; +} +static inline struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) { return NULL; From patchwork Tue Jan 12 13:40:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013543 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 41D6EC433DB for ; Tue, 12 Jan 2021 13:43:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F145223107 for ; Tue, 12 Jan 2021 13:43:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730938AbhALNmn (ORCPT ); Tue, 12 Jan 2021 08:42:43 -0500 Received: from mail-eopbgr00079.outbound.protection.outlook.com ([40.107.0.79]:33088 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725843AbhALNml (ORCPT ); Tue, 12 Jan 2021 08:42:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K9cJlMBGWwBQ0NJsHiltzWVWQOBT3UZ1is87ArE161gQOrllIXHA1oqxyOFxUXnkXeqHTg6Rf/iC1ZH5RBCrA7cmJpoK6a5V8/XPEjPbnnXV3oszdiZ8mmbf70/ULQYBJ0osKAOqztXSFajwY7kYL1ghLRquesk/HEBwNqc/I74f1Z4O90Mdor7qHEQCBjYa4EYP1AJd6MFc3WGo3zD6nEOVTsIzC7nRTZcksyWy4U6UK1JjHXshcLbyuRCkmrKHG1uuMrzMzluu1SGhk1hfDSaOUvDoRYr5RkdtEfAj+fpNW5kYovYKNd5SewOFupeEoWt8r/tX6UwUYPdPzhZAbA== 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=Sir8v3rNx4GcVDux9K9KZ54i/2RfDh+vbBX2seB4Rw0=; b=Y65DlfGzxRDDCnuv+aI1VvKgOmSc0/7OOr+JH5wgTmPv+7GUVCSUyziCe9xM+3t53Y84OK3hsRa27CWMc4EZsS5Fih6o1BlHoPqBAJFqySScja5gB88ABRiNgmhnH3DrPNjk5zbJnor7emb3N1UX+bISfK1DBLsG2GNSXnjAACDT0I3XYYzmGSvaNtFVkVAQEn3nWqAqnspBJzbGAJjO6IZlWChngMf02Oa6+H1X5gGS8NXkclxtng4asy4GFeMfZaZwpj5Hdlg78A19SjKl3EJBbIHRPByzBLHY5vSV+ylfuhHSKbNGUD3IcH2ClCnLw/SfctE0uDWrti/mzaI8lA== 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=Sir8v3rNx4GcVDux9K9KZ54i/2RfDh+vbBX2seB4Rw0=; b=SchwIt+SiUyfSCuhKnJND5YOGOvdKtY4/4PLlMITNgvglwRf3LIK5r8Ya5l2RV5so6839B64aeg2dpT/PbMuK1G6fczaIqcwbiFdp5ULBC0dGZv9JU9z+6RCz9Xsdyk42i+9KUQqyzdgv4mDL5Q8LpNudU1T8iDd8P5z5MWJxlc= 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 AM0PR04MB6436.eurprd04.prod.outlook.com (2603:10a6:208:16b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Tue, 12 Jan 2021 13:41:50 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:41:50 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v3 03/15] net: phy: Introduce phy related fwnode functions Date: Tue, 12 Jan 2021 19:10:42 +0530 Message-Id: <20210112134054.342-4-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:41:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: eb448f5f-9467-458c-c841-08d8b6ffd06b X-MS-TrafficTypeDiagnostic: AM0PR04MB6436: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zAH2EtLBK4mZ245MBofUwhuGljxo5Ikb1tzUW7bNjZ4xsZidScwdRTSpsJE8HmTrf1v+j9a5eK6Qd8XkyNiGs9KSd4AkpAnavsSWLplf19SAUvbnmK4z9KpIJ/NhtY+Wx7lleLoJg5jLSx6DrfAPrcfrEfz4LJb7GmX5zlc09KVp9CVApkaCEuAOCGiIzdvaQrCC7CnGE0GXXuxReyKBVH6RiDGkoC872BsPNLh8L2HqQVhLdwhbgZ/ocgFct8TfYfPEcfpcXRYFLouarIbz9WiMqUuAvSFDnKbBtSDdXVx8OHW6fsRI62iM8a09ku6KRJmESYDlmqzmUvACpP1UOPP4GP+PXBkRmRyTXjgXXrgpxToXNbPu47MtYyMZQDoyj2BetrylJy++HAYgeY6oAr1eJ7V+RDOxYNBeTBq4FlSg+br7kHWTaQoJFuw6qBYNObN7Qc0TURmkgHzpVWRA8Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(376002)(39850400004)(366004)(8676002)(956004)(83380400001)(921005)(6506007)(66556008)(478600001)(66476007)(66946007)(6486002)(8936002)(55236004)(26005)(2616005)(52116002)(16526019)(44832011)(4326008)(316002)(5660300002)(1076003)(54906003)(2906002)(186003)(1006002)(86362001)(110136005)(6512007)(7416002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: D85EQmdBKB9no9+Rn+gdv+xsplwwChGcn845eLgq/XzK5UFKHo+A9HB+7HNSqYcfbInkO+iFlDLtwgO5yB5MlNV5CNtHTvoBod4qgMpYYEzkjmcTcG6vPxeOZFpWW8wbXwRyy7iiiDp/2621SDkH+xIDOAjl6Z9UlN20rZse5aw6qz2uoztgJWcj60pmlUtL7ATr2/zWLQPM32vgOUDeA8TyaZjFpbJeDlfu/OmC8RmuX1/UuTJUHULg/gYXXq55f7iyVrt7BMg5q3Bz0dTHXQt+sKkD4GhHKBHL/WaIWG+YWQp0f30xEuI5tUpEhFg8Z+Cr0tSaUCKfGBFuJWndluW9JGiZR/Qj9heDvAyeTOSXrh2thJGsTsfaiSrLZSwJ+mMTKy148TfljB8/Ne+dM93dhZWOEZfFFFtENZOJdBSk0eauw43UnVNs0VoM3KITPKG3xV77RIaMUYjGo5StEizT22j3pP3kfsmTwAJzmfVuvir/DvGYeRreR3YD1T35Qi+uvPKeKqCE1+1gdXZWhW9qhjbhwbllovZhUmnA7gDNjfUMYQteiBPrEnt2XAgqV7+a2wr2ueFsVnq5/aq7As0LE3MbARyAnu8839eM3sPXYJyPQqN/48pkfo8lST2AmZjZ5PioZNr0+QHXUoe2maB9Y9W0Pnei1YKX+f+RQjP4OEeL9GkQVvu7m7WaL+bnAlvgtCS3d14rCVpr0A8K4Kyxq4navZ87nDn2uLDovHfeJt/zaxtNgDKxQF95GsmbeGA9gnY3wjugmDAo2xqbDGVy6mkPf0fZJVK2nFqk1dd7URWYgqkcxFnQ/BpjtybUeOUTqZuFMBsRGkfV0TDOn1wqPthMDZ932RY7XJHM7WDLF7BGwoek3m9JOFkIjYMEh+o5TNJSegznVZZZwqnrxmPa6hE7FGiTIc7COYvzGgnhHcpnPvxOUXC7Isygiwg8y9DJltlnf1Z5qa+g8uxkrysAy8VEeWfwyUZ9Dg4udnpjlQe9PlW5TSNlJCM+VfJj 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: 12 Jan 2021 13:41:50.1795 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: eb448f5f-9467-458c-c841-08d8b6ffd06b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uRn7ShkO+U43yU+7G1IlT/rBFtxcfHmDwIniFU1IzG/PmYY5Prf0pql16ZxSebu/kzJ8LjcBrEBVUQLHWgMS7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6436 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 v3: - Add more info on legacy DT properties "phy" and "phy-device" - Redefine fwnode_phy_find_device() to follow of_phy_find_device() Changes in v2: - use reverse christmas tree ordering for local variables drivers/net/phy/phy_device.c | 62 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 20 ++++++++++++ 2 files changed, 82 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 06e0ddcca8c9..66e779cd905a 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 @@ -2852,6 +2853,67 @@ struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode) } EXPORT_SYMBOL(fwnode_mdio_find_device); +/** + * fwnode_phy_find_device - For provided phy_fwnode, find phy_device. + * + * @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; + + mdiodev = fwnode_mdio_find_device(phy_fwnode); + if (!mdiodev) + return NULL; + + if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) + return to_phy_device(&mdiodev->dev); + + put_device(&mdiodev->dev); + + 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. Legacy DT properties "phy" + * and "phy-device" are not supported in ACPI. 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 ce3987e4e615..46b9637dc27e 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1343,6 +1343,9 @@ 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) 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); 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); @@ -1352,6 +1355,23 @@ 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; +} + +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 Jan 12 13:40:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013555 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 644D8C43333 for ; Tue, 12 Jan 2021 13:43:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2049F230F9 for ; Tue, 12 Jan 2021 13:43:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387654AbhALNn1 (ORCPT ); Tue, 12 Jan 2021 08:43:27 -0500 Received: from mail-eopbgr00075.outbound.protection.outlook.com ([40.107.0.75]:21226 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728021AbhALNnW (ORCPT ); Tue, 12 Jan 2021 08:43:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RptJw/x3iK0+LUVz8GR0loPHMeik7BWHXb51t/80wjoFRh1FXlI5rDc05ntLRMpueWYH6Ahe8ie4DaRzTruqrONuKysSr0WtqONbY3ip+jX2Bx/PWksEXfSC0wSwx5RCEm/6i0RzKtznq8Rq8Nyjuug44Z12ZZV5RqefD+8GUk2ndzrv8vfjNBUhO1w5t0o0LC2GlrBTQlNiqc6pP7T94pkH2XELM112QENyq/JhkwcwqAJ4UsnKbTxzGGF0q2kaWtZch/L6j+tPdmMHmnUkd/b6JaRU1Yg9PWQGP1vRh/SlDulC5PIFVwrBIos1K6uCKGcHTWnPZ1oHizXfIF8Kfg== 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=W9F9yZ8Ze53QqqBBVeIkf8/Lnyv/w5MBJCzNaUfT1Wk=; b=i1X5KSKoLQn7qIjHNPUvRresCnu70QxJWls/+O29JhSyO/mLsjl5HksDqnIPnqkcSude53QnFBQIxiEML7fgYK7nAlnXbVt7/1OToppa1aD8pJo0JnO7nY6KAU09CJbg5u+PhZc1JXBysgj8oBBl8aoKtaqNCMWWvbhKwx6WNFb9TfWIn8NivSoBBl1Ad178wVyHEaFb1GF/AmV2JUyWeVi0brvsln03qUt8JiqZyR5Wd3QKpwEvR0QhDvMk6QmUvdRA9WbPKbLZBeQD17mDe4ovsffM+s1Xi5sj6w4txHu9DJtjxeXYo27/Gn1PibM6L5aKNP/+rkt2ZRYlt0me4Q== 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=W9F9yZ8Ze53QqqBBVeIkf8/Lnyv/w5MBJCzNaUfT1Wk=; b=azDlMxMHhzBFxgeahMw+u22X8lSmFYSVR5y1TuKCNLJ2WPhx+EX7BhhhnVYiyI+bimyvD0rvPsydmSDpNFPUb7Rxk26gzJQPpi1iowf/M+0wF+u33CZmcceOvksT+K0NOSSjw7uaReTJ98G6DuLUpOVBslXws61jPXN+duJ3Kdg= 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 AM0PR04MB6436.eurprd04.prod.outlook.com (2603:10a6:208:16b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Tue, 12 Jan 2021 13:41:58 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:41:58 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v3 04/15] of: mdio: Refactor of_phy_find_device() Date: Tue, 12 Jan 2021 19:10:43 +0530 Message-Id: <20210112134054.342-5-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:41:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 58a6ad76-afed-4198-f4a4-08d8b6ffd563 X-MS-TrafficTypeDiagnostic: AM0PR04MB6436: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w5g8eneNNFMD04cOz0tkXL4S8y87nz+a6kmqmAAyyq4ZmPDz50qe5UPw5ojwdF6JteSExQGX/gbSqmfdWXkYtkp4e6XHpK4d0TByHpOjLGF3cUy6gx5m72qaJuAne59lh6pTHOfKnAJcVzimz20WpY1DfyEVwWPBvZPjWIyJFIDvGN4FKPsriO6bV4PHmkThqn6o10OuC+B0Srf1O21zdJT3xXj4VKGj3YTxSFhvzpbKmSqaXM5vWWkjcGWiCTVEl6puWGZP+0bBxcQNj8t+7cCSSqDq75H11aGYBKsE40pUNIW0un2ECYnR5om9icw4vh3ntgNT+D2eCmfyIEl0cHNMrnjnrCl+JmU1Wgf+oD6AnGotSeomRR1aPEM+uvZIrk/CppsfoRccHIQ+fTz92ATEAtj3y5Dj8xH/cumyI3dqGh1OlaTvBofXv5DQp0KzLET4weT+mNQpJjET2V/rXA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(376002)(39850400004)(366004)(4744005)(8676002)(956004)(83380400001)(921005)(6506007)(66556008)(478600001)(66476007)(66946007)(6486002)(8936002)(55236004)(26005)(2616005)(52116002)(16526019)(44832011)(4326008)(316002)(5660300002)(1076003)(54906003)(2906002)(186003)(6666004)(1006002)(86362001)(110136005)(6512007)(7416002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: B+IUVBDX7VbuSMWKELXrvIgQ0BKnhB3eGAx6TGF9955WKRYnJjcRR8xcEUp3G0pDvpnty499+PbmhadSTWnzNnZfIZHh5/5nu7vg/h6LgGj4lFpOZ/F3LQg+BQbphKmjuOQGU4JvBNf63lzS73R2Xd2Svnay87m6I1A3TtLhCSk8SZjflcMWKWiqUe4SOFt0oxIhRJPO5KxwDc3nH4vHghWIUiuQpwPIUr+asF6pk76DsLYdtDcmw4lC3j50p+TSY2Lbkg8Z2szRl2jVaWE9FLjJij9/1XbG3o/pa+SSKmjSrI5I+SxRyLFk/4JzGS4VVmk5I5AE6yC8wLQVExiKbYrEyvjNTcghGOQxegMIamVouw/WBLw+cqxVpi+YqOwpGNq0UsWRIGbWMDkpNnKad7M0T2Ibi7OrhPCdrC5Hqbr8ZpDyeK0jMO29cutbVvYEJghGYefuCJ3Th3szuV33JqZ0hg5fWfIWMjXSEJTwlEsp2W/DSzj4tgigQuzIERPYhmaLD2okEyJeDXj799wOlo9zlRWxjO1REcXDjtGVzUiBKezqcv8s4HRa/9L+/aein9gIn5gy+dTS7nVDGMsZCJQBu4LOykgp0wn+jkqYU+pJTYWpCg9QGk+yUe5NdlCyew5OcnyxsO6p43Nt0SYwMwkoStTdHxpM0UzSOlT4EAWtyodncFYws3UTP7EwC8RTBoVLmDoXiCnV6LbS786aX/Wjw7VOFPvzBL3SswwR/V1KBzFFBdnSjEo7P0t/ZpAALVoLInuwMI/djZRjZ2tuTHKn45ok7FJkBfEdpY3ztQmZ3feBi7a6IWjUDdmj4EEa29xKIa+t/ttkdBwFiOMb98V5HxGwZ0w/mPjPW0mmuAXlr0mUuAOoAL5enmCWGEf5vG0Z60yWeRNv0qeec9Q6YdiWK7idrSLVcRcqSTosTW5cjn+y4T6O1l59SgMu0wryHtDCRcjOZqdpKfyA8m/qNGUurzVJlCKSueNrq6AJXyuMctg/HGeS4l9FlCUIzfw/ 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: 12 Jan 2021 13:41:58.4419 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 58a6ad76-afed-4198-f4a4-08d8b6ffd563 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /qkZIHxChpDC5RssiWw9gEW42OB3myj4ZH/YLS1p+I2pfNd9Kz4lnV9OjHvLJVh1CHKLgTo0arDQnjoyWXKeHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6436 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 v3: None 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 7bd33b930116..94ec421dd91b 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -360,18 +360,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 Jan 12 13:40:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013551 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 1ADBEC433E6 for ; Tue, 12 Jan 2021 13:43:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C82E122B30 for ; Tue, 12 Jan 2021 13:43:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733116AbhALNnQ (ORCPT ); Tue, 12 Jan 2021 08:43:16 -0500 Received: from mail-eopbgr00079.outbound.protection.outlook.com ([40.107.0.79]:33088 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728021AbhALNnD (ORCPT ); Tue, 12 Jan 2021 08:43:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D22Wmb37Yxl02igHI8V13AlJWAxSeX8HNVPqvzKXB2vehGx0oZ2j3Xb+ZQW+e67vbRpY8w5X6rJ5cGprGujU/qkxACCiLL22dlb2BuCnHGINSdApcB3KtG6KDzXg1q3waZSPTlG1gFwUC8c6qTMPcJYWRkuWkCwuBVTxG8W/Bu1o0q4RDSpJW9nCAItjaKIDQFeivmrizK1Ey4WInU07MXtKBvV6x7rspMrlc9fx4HL1Xts0fSKrgo9BGjj0x70Qwc0De/c+j6y6IHGbJjnotf3EqwuY6CewkBVNtRhUZZ4vivwRWB1a8w0tPxfukdVqebPQVx7ewxrPXtFObkAKVg== 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=hU6Agl9BCtvbKwJFUqR1SsXarPnk4DZf6Ftd7c2MPmI=; b=R/P8i9NR4RIBx3C3gRdk/JMe/Ph7AcS3gw2mpt2RdV7UsbS17MxhxO8GLEq2KQ+Cgc8U8BB3I6nzB4/Vl3RTX9wDRWdH7hxMWN3Jo8KxmzKZMZa8Yb0GtPRsdLYOWGttmzcsOCh/qEDtvtZRSytoLV62DtsCHTyKHDL/+KQEBz6TsdCainrt4QA9PbBMum8kTy39GBTO4IppMukC3VgkqLKFX8PNwb9P4H+C6LcnGcy60kG6yyqxj/qBu57+VydD1Iiehv7/1R7BoOZ78ZNeIPB4KS8CfMs/vGhSxJsqrqpLdieF5i/Mbo7UAfbDWFZTplaTc6b/vG+bxdXZZTkEJg== 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=hU6Agl9BCtvbKwJFUqR1SsXarPnk4DZf6Ftd7c2MPmI=; b=JvI1lvDHXWpYYRMHWkkKsFqWvd8JSiJ3s4XVeR8gc9xCNX4ml9HlCr88l5mvxUguRMmZ3wRDiFgtCVojqjg9f4bWCNwM/gXn2AqQTr2bb0QH/jHz0FsbUoS6KBGZa/feQZ/wSRCEJ1mk4h2cT1avdsALaw6/fVvu9LqdVM19keQ= 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 AM0PR04MB6436.eurprd04.prod.outlook.com (2603:10a6:208:16b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Tue, 12 Jan 2021 13:42:06 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:42:06 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v3 05/15] net: phy: Introduce fwnode_get_phy_id() Date: Tue, 12 Jan 2021 19:10:44 +0530 Message-Id: <20210112134054.342-6-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:41:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: cff75985-2acb-4887-c88a-08d8b6ffda34 X-MS-TrafficTypeDiagnostic: AM0PR04MB6436: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YjZKlBlXjp5ST7uNRJ2gerEvPU0roc24tUM8/Y+HCkVqt9HiSsNhloWv1gSavX45yoI3tZ5+j/cPHWtQ09IInw3d9Od2CNSvnxVrJ/DIUVekdZkU6KY9koj34laMZBWlqlnwyubwncdbJD5ZtF3zHpVsQ9vwywSHf1EKp/7WDUG5OEG9dtVS9p7iDmqwWtvcDxUGGVFRl9yOroKtiK7/7nQXUcAS/f/cwBR03v3IwYyuBxnfQQtBSvK3bcEQl7qEKYjn+fgYvxaGE4s6oNGv7/d1V7sqcPN0LkemhCGSx0qQjzXA9RRIctdwe549OoOq2EdNGdWToTNtUfJLziU0h0mo5hE4y0FPdwp6tdocl0agN6XxwSqsXfWxXOjuuKHtqOfw9QS7fOBJ1gY/1Yx/qndTIigygm0dgFeCiOgrKQfhW8wYYXPJNYkbk3+MeDp8vQctZUofUn66lCnHS025XA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(376002)(39850400004)(366004)(8676002)(956004)(921005)(6506007)(66556008)(478600001)(66476007)(66946007)(6486002)(8936002)(55236004)(26005)(2616005)(52116002)(16526019)(44832011)(4326008)(316002)(5660300002)(1076003)(54906003)(2906002)(186003)(6666004)(1006002)(86362001)(110136005)(6512007)(7416002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HU59aoD6GwvG/JrO+ET1w6sbkwBX7aT0/HHnUOE21gp62B9Xmp6TG+efmfXZuuUH548qFxvveHB4Sq+yZdd3VueWCwEzRXaSi3NRoTHGYUJBFZMz4AB/tTJ68mLNTRrMoU5KCbrQbJBs4zBfoY5XCf0KUh/abETqQ8TpB/VPi0csDM/BdNzihdQ8tr28UKNlDzqoZZubcTbmiXMdmAgiSP5nE06nD2B+0B3aGHq/oON+iRWWgKoUjTRmS2qVg5+z1Hmo2MjA2iiK6zEVlj/xC03C5y8IiE0CMJYsTKeJe0YFqAECmi3VNbgY3Njkrg/OoOfgIfx6JkDyM2lsLQSggVA8YaiKhYfAApUZl9j81COpbnrUZ6ai0fwTJMe+HJbeNM48Y2EY9hAGx29KSADRnCWCJUDuJFkLhpJLtBoruRmo0WGyJLITnDvyAZPHjFAKYYwH3hlUj1u9JyyViRgyytQ+RTr0dL73AbxKsTB/vAGCJz8zVv91IfUHMcuwIun7xLFwD8PWxh7V7gq24XwM4E+zqJJU4sf1UjGgfH3bhNWlAnjEnOpQWtECX6v17r7YBORqAPMzhYGmaVmvtpcX4/i379e1SYPC2ztoUoHy3kuLI8Sr10lqjjKVaZUxPmQOB8a48BS7TewHQWn5FVF9sCJ/ibcZlelxOo2kj5a1xSRNUZXuKNfY+ABN5ExX1x1vCBB5+cBH2A28IuSdOZf1laLG9CfySLcZsNpC+NMOgnPINgTbjgctzBDvhkk75p/tvIL4CSxcRVJCkeMidn+33iL9g14vv8u44CjpP3WcOfMl1ODKa2nrXzYY1ZKuFUtiO4QO2KSUh5MxgPYtwF4G9P5dUUSJJzwoOXAnrZiptjowHZQjuUR9Ui6Rek4K8H/LvzUibg5bEpgk5JI2iG6VNO316vKBl9Oo6xy3f5AugB2wvNWPURMZkuwNl5pfugaHLFVax7SmpD0gCQIJWH5AV5IMreUk+PWP0juv2Ecd/dojS3fXq1CSrwAOWGU1uKmQ 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: 12 Jan 2021 13:42:06.5913 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: cff75985-2acb-4887-c88a-08d8b6ffda34 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: i/3QWbxc0Mn0RaDJ0HDNzk74ufrUOvdvDB+ZmsxoNV3APVMuSFZQ+zahe/5HV1921GR+xc90vwSsGzEkGXG15w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6436 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 v3: - Use traditional comparison pattern - Use GENMASK Changes in v2: None drivers/net/phy/phy_device.c | 21 +++++++++++++++++++++ include/linux/phy.h | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 66e779cd905a..6ebb67a19e69 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) + return -EINVAL; + + *phy_id = ((upper & GENMASK(15, 0)) << 16) | (lower & GENMASK(15, 0)); + return 0; +} +EXPORT_SYMBOL(fwnode_get_phy_id); + /** * get_phy_device - reads the specified PHY device and returns its @phy_device * struct diff --git a/include/linux/phy.h b/include/linux/phy.h index 46b9637dc27e..28cd111f1b09 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1342,6 +1342,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, bool is_c45, struct phy_c45_device_ids *c45_ids); #if IS_ENABLED(CONFIG_PHYLIB) +int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id); struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode); struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode); struct phy_device *device_phy_find_device(struct device *dev); @@ -1350,6 +1351,10 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45); int phy_device_register(struct phy_device *phy); void phy_device_free(struct phy_device *phydev); #else +static inline int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id) +{ + return 0; +} static inline struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode) { From patchwork Tue Jan 12 13:40:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013545 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 79ED4C43381 for ; Tue, 12 Jan 2021 13:43:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C10B22B30 for ; Tue, 12 Jan 2021 13:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731594AbhALNms (ORCPT ); Tue, 12 Jan 2021 08:42:48 -0500 Received: from mail-eopbgr130055.outbound.protection.outlook.com ([40.107.13.55]:1476 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726714AbhALNml (ORCPT ); Tue, 12 Jan 2021 08:42:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=itGMdzPABJmeepj2KDB/D/sulxbke2qOn43m3Yol7YRIismPljrBOkgnHcrLCE8t+Z7aJ9WY7r1d6xZ2P6hHoB3TAS7AXRB5z+mKAYIbjMWoMzlLqnxB7K+o8QJ1W/Q+OfIioWbSa2QDT8BQPW9ibhTgBwO+r+LjkvKf05G8PrSLlvOBKzBNo6HlYtYeX/EKIrsDfmrOu8AlOaiou01NiNxDHk72aZiiczmRS8n0tNEX0QnoDeDmxedkEuFwcvqwRk00cwRknVLyHR2hZy+iz/6LSUCdq/ofAJhYgubE88FTQ7sMoLKaebhV3PX3V5PvSykpruReV3FcBCCaVGBPbg== 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=A/GZYEKwN2XEO7X3Ja85i44fA9G+dbp4sg/xUjpRGgw=; b=L+Fmm60Icec2l9/cxcaLs7/5Sx3COLJjjrYh9IwLNTRYyRpuT+lKQP3eJUrQO/6MXZmeJ/Fd44TwTANzAgh0rGflqoH1a96R4JYFlfBkbJUnp0DFvBKwaIPidYqcFLU4aZYG4q/ReePjkL/WcEQx42a4PKGKMZ4dkK5byRum3bE1mYNUHH5VEaKNbhdNxPS3pYGMfVfzNfqBBl0hHyP0C3uxXGqkMfdXlWlR+JtTB6B7yJ0tbniNWw9qlcXD9MYWw0e8VZlB34+VvHovIIBSgNQkHh0P7ox1PcWRtswJsV8A0wZ0c/l0PCu0uLcCdRXPAZ1pVaZdqc36jyPqdXCO+A== 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=A/GZYEKwN2XEO7X3Ja85i44fA9G+dbp4sg/xUjpRGgw=; b=mYMsyIIRVl/12sAilqd5ozTyE3t/5CrLeN+E4IqJLWlVZGLTlA0BrMbFJEune9WV/zOAdjRdhT8/Wueq9AWR3GPfHT8dr2pV/I37bvWd2LM4pkkDHdDX1JMO8WO/KdfPAH6xelQtRazqkQZbv4xDTXqxB5x4YtQv/htWZsxhaOs= 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 AM0PR04MB6964.eurprd04.prod.outlook.com (2603:10a6:208:18a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 13:42:13 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:42:13 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v3 06/15] of: mdio: Refactor of_get_phy_id() Date: Tue, 12 Jan 2021 19:10:45 +0530 Message-Id: <20210112134054.342-7-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:42:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b0435022-5da2-4071-054b-08d8b6ffde3a X-MS-TrafficTypeDiagnostic: AM0PR04MB6964: 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: /I1Zmm0yazXPo5q11rvLOyxaWR6ABfmoIEExhQ6HdBtCQ7GOsnuAS+ZoigOfIT8hDqPQw9WOI+HSEy07jLJdDWHbwAktZV547HflT/XdKtDYLUtJYlTkfmlp5rLnBEgnXC9hgvUKanjbJOCqdFNJ4CoaiBF2b+PHb3B0AjaeHLVj1AlRHaejcXZs8Yzzi4wKw42sB6KIjhOFw5zVgKH+ywG0MWi95p7cxMH8KXV5BpL1wwbGrOJ9TxJLIQc7xP2lMBrpQCTz5YaQgWtO34EMpW66cwCWN0C+KvaoMAfYiEV2OMWrixGN68/aArLiVMt5WprysvD+BWhqIzJelxC+G3olZiBCIocmH/c6OAUudDo/f+oQuJvog1leAErL6QSm8KUJT9feeQSpCRWIBDJPVeQ92XGOkUfHEiZdubfmpBVr1yhZEzqUAykY7SKtLle9ycYE+2X143z9mdbm29NclQ== 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)(39850400004)(346002)(376002)(136003)(396003)(366004)(1076003)(6512007)(7416002)(1006002)(5660300002)(52116002)(6666004)(8936002)(6506007)(16526019)(186003)(26005)(55236004)(66476007)(83380400001)(921005)(478600001)(66946007)(66556008)(6486002)(8676002)(86362001)(44832011)(2906002)(110136005)(2616005)(4326008)(956004)(54906003)(316002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: VOFXFs3zh19u6dH3KiFJ/r5J0++9RGmsDNt58+qBbMCu3KYjLOKuOYlotF54MXPCApOQiJSQ7H8dMvhh/eUTVbbPSbRc9gihDi2jEZgsz5bp/VuD6T+QwIiiyD52AGCacTbVgY7tTUUVWuuFfZlFgucJOsU9tvj6WOkIabDoIQA23FLg+HqwXzSmKY4cHQ48iCus53vNfbTG5Qz8ebpGj7edY4DIklmjKeADrs8RfMV8PWCPATY2TSTO2NcG2Z9P6BOuFO31HlHUCZijmdxidRDl2QdGeOlenJWHtPeWO9hHOyfSUyufuVerE44Y9AZuy1NWKEh9Xdl5siXYwdklwd15PKR0Fp7HQeDM+AqSXIjkXjBi6mRZNEtRXdR1/xwsbAOI57SLXlPYGPhJdN/3zXN75Jdnl/XTnhTtKIR8zDNQGH+prkxSCyzCOpdeu1QTJlnK7K/Sg79qrNSEckqd6gkERKAj1KmbZCuUQZV35zz9wCLMBcM9nexEULXz6MMiOh6Nlo8pBgJi5/o1R0Fn7OLRUBnIMLvcLSB9TJP6Z2Lrt9CLw8iZn8bYi/gyMkjsIYEjFIHsR/LA8F//hgxSK93OycvlQLBUgoF5HZl1B+IpcYPJQpJ8d4MH1sVwanZETM+ykYwmzxgdmc8V9zRJn05Z3nD0k+/hhOppxXigmGz1dJ6lTF/KCVjow1lrMhRPnBArVTJRAFpEkXK+80CgW51wfSH8QYew4AcIwP+BUvGLIYOym7QCkJTKI+t4hYOiZCSiC5SjrzxjE/TcFxVYlslG4W+r3CnEIr2zlSf8OET/uoQx/OODnPzylc+73dcWue7eoZxCjgIPg7xE13K9NZAQdM5SPoADJgkHzTUYQIOHLkOpzWcLfoTRlZIK/CYMA9gEJiV6iPBrnR0X7ikORWaSj8Dz1f7vWQ/Tk89H64/ibyb3Ftg1g8TUY6GYMChvbu4i8FQfpTzQ/rtY9nyz7OydCYz5s4BqZfDT0XrLFmqUcATxpCNloVYNzdf8ujDT 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: 12 Jan 2021 13:42:13.3155 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: b0435022-5da2-4071-054b-08d8b6ffde3a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: b4JjjWawT0yFrAgsoy78B0Qgj2dTtpHzKi69NhV0RW8bIPmF38xWZq/bnbBqqtp26IGSuxhPjWKLlpAhHqueRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6964 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 v3: None 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 94ec421dd91b..d4cc293358f7 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 Jan 12 13:40:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013547 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=-13.9 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, UNWANTED_LANGUAGE_BODY,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 6DA2CC43331 for ; Tue, 12 Jan 2021 13:43:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36DD52311D for ; Tue, 12 Jan 2021 13:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732161AbhALNmy (ORCPT ); Tue, 12 Jan 2021 08:42:54 -0500 Received: from mail-eopbgr10085.outbound.protection.outlook.com ([40.107.1.85]:39271 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726253AbhALNmu (ORCPT ); Tue, 12 Jan 2021 08:42:50 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hAlkPZ0f5jhflk4cWXKkV8ICTh62vUqAXFCZje228nr6otSV+LA4sKTDm7kGZlrKDL+JGLUdZb9LzNiGiASypJzgw0Fw0LMDed/tGPSdz/GhEJ8MWyV8KCsLpa1HlPV5s/+GrnI3Pay6UJLs3n93vgYC00XV8LZuW16lj+A2RyWA0iryEcsjNVRmxDsxu8fqHJJTwh4Qo1EWNHF1tnhRw4KW0PWlI3/siCHqtwXIUFM8Gui5MSGy+x6LwgmXjI7Qb7/coS5kI8uuBPpRrX7Z9yAIQgp3yhAGCDaBImQa2lhTfurj9Js0fXT5ZBSLOEOlsARw9/gQpE5QQ9OCNYGBfA== 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=WsybhVlvbfI3fHXteC4zkRA3UhxDCQnDq/VekuFDeSk=; b=l6W71BpHc55QuO/AcBWvhrLYfx5cuL+d3d4sdwelBRlUSOszD6VeCNH3xo3QGDYQg9t9dc0V36FZTNLWARZR3IowbnSYLTTTHhuHuYRU/Jh2+VPVH0eLiARomCap54nC8DC+dwn/r3dKshJGAKPP10bB2KnSinDaX5oNqkVgMsekVNTfozsEhJkGt8htGsfiyr6DShCemza54q7oowv5kmQ/TZS5IN/jgDeGKHziiSQaPbDE9HvuUYn+BN28CFBgAki2aA3Nt5lyuhEdR3u64LQFcWAt0LEi1X90zNGkO3FFJ5YyHj63gQqE/IrbzIZuN9zkR0kXVawd7HnCPn63wA== 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=WsybhVlvbfI3fHXteC4zkRA3UhxDCQnDq/VekuFDeSk=; b=DMO56kgMLhF4cTKAtTe6X1eDB2zaycz4EJibHFUYMAdC2lAfRWN0hH3Z3ZqB4J8QGzKFZ3VWqZHEaAG823DcMMee/UQIGZmMrC/30cdok5zYOyaX8eGFTw55cme7nzWH0TuEFHHtAZGL1M04FKwwme8NXX/LUK1VTc8nmC3P29w= 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 AM0PR0402MB3443.eurprd04.prod.outlook.com (2603:10a6:208:1b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 13:42:20 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:42:20 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Frank Rowand , Heiner Kallweit , Jakub Kicinski , Rob Herring , devicetree@vger.kernel.org Subject: [net-next PATCH v3 07/15] net: mdiobus: Introduce fwnode_mdiobus_register_phy() Date: Tue, 12 Jan 2021 19:10:46 +0530 Message-Id: <20210112134054.342-8-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:42:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 55ea22e9-b565-4199-ccea-08d8b6ffe23e X-MS-TrafficTypeDiagnostic: AM0PR0402MB3443: 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: Tk4NLfTdNIdnmsVNEw4BcwDak8IHcaeTyuY4IoXBFfzb9n7sAlQj6ThvsUUs7KscigyL8GHtOmULRw97SlX7/jQ2ukmq23Mk6mleH09VxMFIb2nN2WkrVqphJvQdQntbwYX0UW8TQqbjQOkFlQotWBfwOeritjfI2qt3HIyZv0HeY2phG68MFlHCqC7FV0bN82zroFJ4htwiG47x+DegZyVpJ3RD7wrWayTMjgb1a6MbaaoPbCIV5fGPMHvj7dbmSxK4lN2Z/W6ALFABeH17A1q6AXuW2Q6sTXhpg2bPkGMVBvUbsrdlEbEtGVw7OFELEYFVukrjhwXRJzbbJhwws6rZF4Z4hprV/UZNB2fxUhQZe0bmIeWJ2k48LMvteQth5vsdJ0ZLvmLRy44RhBOfu8B8PSMm+YqCtmJr6ejDNuAi5qF3q7TMQCjlGorKVk/aXXftUlZn17PXKfzEaucByA== 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)(346002)(136003)(39850400004)(376002)(396003)(366004)(478600001)(1006002)(66946007)(921005)(110136005)(6506007)(54906003)(16526019)(83380400001)(6666004)(52116002)(2616005)(66556008)(66476007)(186003)(7416002)(4326008)(956004)(1076003)(44832011)(86362001)(55236004)(8676002)(6486002)(6512007)(26005)(5660300002)(316002)(8936002)(2906002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: TgMZjtQIq+oR/MHY6we9svgpvHed0uaxZVnQAbIz+O+iYgYhPg7zJMIp1RxpDmV3pvuWv1m6bzaiemM1FJuplLBXKVV5tdMxYF75gvPkayKj1QXnQ3b9R2DMxEJVAx7B45/yL1senewX3jqBV931UsVhh1SYzPnNQmqe6Pb7LOMCwXIJi6qM6nf67tDZ5b7ICo6mTSk2pJ3v0pbulctM1uH+/m3bkuprM1KgV3F/t3aMwu507m6khs4KkXpPKd3faGBM/t+AKiHFFFOGFqysLMjc99Jz5kc8VoyH7gLa7EESTSStQFk0RYk5VDl39rfWEtcVgj5bnnVorlab0vQjviru1YXraIgp9AgBabN7pnt3FEYpM+WK5YJr+Ew+8SXq5ELCSLts7BB2Dob9P1/K2z9AAYXn5qzrKi9zHmJoVXAWxJsfxtNbTXKenR7YFpoi3aHFlEfMG7p40YiUWpYa7ODM1PDvggdMHcsDaMDf2b4GiKvvV+BljmXYB6n1MvVabzXBaBOSlSvyGJ22d5lcWurWNkVCJe2ptWpDE2lPsErVBFcTakeUd5SYXv2EhLRQOAPibEGtPOQqeZhFAuSMO8iNWiPJheveHEEwOQBh+zkgmgkJjamE5a5wEDS1luGA5y3aaDHX4dhFq1CoY5GE6srNd2fbo2q62Esu2Su4YKUyY5VVf1MMchcbrWIm+qVulYKdMcm+2tzpy/9wqTp2W5w48YzbMCP0h/L897yq4qRUcvEiiIGvew0a9GR2rEdjyfJ3Zcuyo+caY1yviy2YsOoUbWPg+NGptZxkYVqz2GO/vkbfM2Rqbdnh7vMEHgQ6Lwjix7nzHwvGrZEetL02yoP1Q0jAHdl7mCHB7t6R4chEeZtPgcy0+ZyBg0RVPxr7lnF2oMcrKwtnNRWt90dgdPFDtyO3q8ztFDormomr3yGEaekn8tTtY/B3r3H23bJ/XgoBUrd7kl4R1TMI1KXSSwjK3H1f9C1ers9HtpvGzICJKadWvE1osu5a9tALxOt6 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: 12 Jan 2021 13:42:20.0887 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 55ea22e9-b565-4199-ccea-08d8b6ffe23e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UPvMrC7DhL2mZVt1GM7kxGNytlx15daFyvG/LiyJ7pV+PG2MZvE3CzvVZdyY1dVBo5Gbpw9rhN7QPZKzFyuGpQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3443 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 v3: None Changes in v2: None drivers/net/mdio/of_mdio.c | 3 +- drivers/net/phy/mdio_bus.c | 67 ++++++++++++++++++++++++++++++++++++++ include/linux/mdio.h | 2 ++ include/linux/of_mdio.h | 6 +++- 4 files changed, 76 insertions(+), 2 deletions(-) diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c index d4cc293358f7..cd7da38ae763 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) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 040509b81f02..44ddfb0ba99f 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 @@ -106,6 +107,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; + bool is_c45 = false; + 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_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45"); + if (rc >= 0) + is_c45 = true; + + 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 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 Jan 12 13:40:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013553 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 6AE90C433E9 for ; Tue, 12 Jan 2021 13:43:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E888230FD for ; Tue, 12 Jan 2021 13:43:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387495AbhALNnV (ORCPT ); Tue, 12 Jan 2021 08:43:21 -0500 Received: from mail-eopbgr10085.outbound.protection.outlook.com ([40.107.1.85]:39271 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732511AbhALNnR (ORCPT ); Tue, 12 Jan 2021 08:43:17 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LH1nhfvt/92uKEn5Kom68t9D6KlS9foh0jIeWk7yi+M5TtB9hPXXWesvjzcKPLLZqCjJET5JedoSRm0ag2gJwUxUFzGcIInAqPDvGb8ezxRQwrgUk4b6Eaj8uTKDQYklnkoLILeBrEnrPif20n/FG8h8YbGiCzJfSEPZ9xMO4X41ObpF/B6YEe0xN6NJuCN2vUyjq/LgV4Fp5G9MQL7Hwziu/+R0SAYGSN1r3CkzilQUoB3koMh831vdkcb3MFH20gZVKfg8/Bl3LRLRR2GUdBtYJzBMcsRbEqTjQmS48pFh1rktmoyuB3JK2uvA6mP9P0ffWhfe1FFYsoMilW5CQw== 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=gp8+C4+GyIcKgNA/yl43KwX4z7y6gjRWwU9ttMhRdjI=; b=l3xNoINlkE39pJ681rAcgA/0m1nnB76N4K3T/fXNUtqyAhxcaAKByjCiYI7h7rEHWO+2OdZjpkGAhuCLlzi3HR+hNNrsKP2x0YIUDiCWQwKHssDLL79ttjLTP323kmV/WOhLpJTxsWjG5gxuQFvdV8rG3xWEqPsWMKnvI7UBAIuu4Hyu75dOVKFmpMddwp9KGoWFEugGhQ6EjVBtiyRJq+BtjW6w+5V5X/QV6MAwcOrPMDIcMdLjh6Ro11fV3MJJfvVIGMu4ImG9+vt37LCCv2DxXzKvru3U651cvFSM7yNdEQwSWicB5enqAT+dI90eEOo4hGm9RlGh+orOl+JhLg== 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=gp8+C4+GyIcKgNA/yl43KwX4z7y6gjRWwU9ttMhRdjI=; b=mXgiZMnBbxo3FMU53Arlz3Z9pKWbkG9z7aZxCBB8jz8hoErFHmkNpkfz0k++mBnxzGVj+yPB5Gh+I8KqtZ8/4pUqXtMQFeST94H2T+YriKNa74u9Rz438sO5q9B/ByOewuToWUX6chsQF/gWg1IiyiUQM+2hsz6qBQk1CkAjRng= 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 AM0PR0402MB3443.eurprd04.prod.outlook.com (2603:10a6:208:1b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 13:42:27 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:42:27 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v3 08/15] of: mdio: Refactor of_mdiobus_register_phy() Date: Tue, 12 Jan 2021 19:10:47 +0530 Message-Id: <20210112134054.342-9-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:42:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 670108d2-e047-4305-07b4-08d8b6ffe6e2 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3443: 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: e+0TgMcgowGRWj276NL9kifU200Qi2aYgIeV46XjeEUARyL6htWWXfB3LaR+8sR7aJrzqo8m4NrSEy8plgqpFK7wQ+p2MpE7abIb5/459wWurHCIKOacLT32o+tHWncqytS15aU9HQrOm9ErjPMc3c1c9ZDZRZTaPblWBexk6bAWBgTev1Uo5jea4LmQJ7VZ9tU76OanYxcPLeZ9qSZOZoTwGFx9oXnEqKPCX/MZsFw8PmRgbIBLszHag/tcj3eRvDJTt6AXX8FH6tPpqU7dDodzznA2vzwQMgtOcWj10afvIJcdol7tFivTCRB9FiuJNtMc4SXdNM5aSxFkALuOuUAUTyrtkN1MdhHG9v0H8f1+Et6b3wob9ZfBm2WsTsz/MzLJ1V2CVRr9ZVpBxAXTlnoowqQtgMhc0RxeD/EGLI5ldmVTxbGdMlNqaLl589Su6zD3QxNNQxArwgO7o70qGw== 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)(346002)(136003)(39850400004)(376002)(396003)(366004)(478600001)(1006002)(66946007)(921005)(110136005)(6506007)(54906003)(16526019)(83380400001)(6666004)(52116002)(2616005)(66556008)(66476007)(186003)(7416002)(4326008)(956004)(1076003)(44832011)(86362001)(55236004)(8676002)(6486002)(6512007)(26005)(5660300002)(316002)(8936002)(2906002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: XptPvauEbP0x5ldR4DLV69MZtG+X6DRwE403T56rob6HxVTAWEIw8j+HArP2JDam8TSfCgcwjXhq/+j6c+HMFeHjiI1/7ZqdCDSqdg0pDOiNhI36VLGEmTJP3gwyPKvWLE865MayA3DdJ8oTfcBQX+wv/befnyN4JSz6yQPso40QwFOoZni/oa5J53PUncTtnztoGds1MfQidNwdJzYyrLV2WPvUbUTzQ8CoJN1p3NqBDPNoYz37novEXJIpfu6y+0xvfAL91n1M5X55qQtmoTvVhwUeKfgm1jpn9syWFb9PMGFdYp0We41JS9OmRNDggDznWsZ77Fst/RD96d9xM+ay2TLuRluYCgeOVUAKT1FdkWCJ49rijcX2IJy6kgXkNdKVq50n6kBIVySBlw1P2RYd0oK5EUsL+aEHokUPfPepqzxOq0bL2XnhF/p56OdAwKm38h4I4zk9164lf1gw+Hgj940fg8ta71G3CIhBdyeVMGcygX7Nd+NzFodHC5EoiOAp64+YLRHwlQ9dXH7joMsMfQZOyBgWINLDaQxGX2T8s8HD4pcimZHI2uIlGDaxHQ2yswt839B6U5Mbol0zVjW5DwF4ZwGcWDU1X62JLmWBR4zQqQ9rE6MpVJ7xK3StnkxYuFYVj21Z0GTXiyIHqJ94blYoJ4AvsAnLJwhYj3/JCBpS4JLh2rSy3miPs2X82rcHdXFrl5wkQtopvnSA51J51x73tlE60ZByteEAgZWctB0oHouQ4KY62hafOcEngMmTy+rp2lT5T5j14ZKS+sE1isGMsLOY+nfUPK2NdWRAqnlLR9ghEbgZ3r48H0m+DErde0VIO40n0xgKuPS7DhfEe9md23TF/NdQPwHZPAfJcd+zoVlORev0S0WM7ZL5jsughrE2td/rDjwEj8BENrnnnTXhgeT1Yj2rwnIBWfbsGDInk88IA1GouWmZXrMFCeRkTY7APDEkWv2WonQvaR+Hr75dx066pQF0T8xBrR46lfkd2BebCqhTr2sKQ3P6 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: 12 Jan 2021 13:42:27.8494 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 670108d2-e047-4305-07b4-08d8b6ffe6e2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hUQkdQTVh4q3U3pR2qjbHHzwxZ9jRKvA0uupwp539/ilqkI0dKP81hz6Kw+IZZhn8DFUPS+8Rz3vdXolNVCTWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3443 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 v3: None Changes in v2: None drivers/net/mdio/of_mdio.c | 40 +------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c index cd7da38ae763..1b561849269e 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -98,45 +98,7 @@ EXPORT_SYMBOL(of_mdiobus_phy_device_register); static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *child, u32 addr) { - struct mii_timestamper *mii_ts; - struct phy_device *phy; - bool is_c45; - int rc; - u32 phy_id; - - mii_ts = of_find_mii_timestamper(child); - if (IS_ERR(mii_ts)) - return PTR_ERR(mii_ts); - - is_c45 = of_device_is_compatible(child, - "ethernet-phy-ieee802.3-c45"); - - if (!is_c45 && !of_get_phy_id(child, &phy_id)) - phy = phy_device_create(mdio, addr, phy_id, 0, NULL); - else - phy = get_phy_device(mdio, addr, is_c45); - if (IS_ERR(phy)) { - if (mii_ts) - unregister_mii_timestamper(mii_ts); - return PTR_ERR(phy); - } - - rc = of_mdiobus_phy_device_register(mdio, phy, child, addr); - if (rc) { - if (mii_ts) - unregister_mii_timestamper(mii_ts); - phy_device_free(phy); - return rc; - } - - /* phy->mii_ts may already be defined by the PHY driver. A - * mii_timestamper probed via the device tree will still have - * precedence. - */ - if (mii_ts) - phy->mii_ts = mii_ts; - - return 0; + return fwnode_mdiobus_register_phy(mdio, of_fwnode_handle(child), addr); } static int of_mdiobus_register_device(struct mii_bus *mdio, From patchwork Tue Jan 12 13:40:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013559 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 2528DC43332 for ; Tue, 12 Jan 2021 13:43:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F126322285 for ; Tue, 12 Jan 2021 13:43:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387783AbhALNnd (ORCPT ); Tue, 12 Jan 2021 08:43:33 -0500 Received: from mail-eopbgr00079.outbound.protection.outlook.com ([40.107.0.79]:33088 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387542AbhALNn2 (ORCPT ); Tue, 12 Jan 2021 08:43:28 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kxIUEtaa0Tsh+cyPeEqLnzdXS2yTjct01pEVLDjlQQLDd1E+maRVtPFJ6VS/5G0CnaSoxNTHPqH1jgAYGqVMeKmcg9dRkaCyjGr6nQjIPf86JbvKeIw3VUbTGAswpRZi77B5gOOiUObap9sdh1UFeyRGzNQHbY3WIT5fACIZiywKMYxWzAMV3wbsPJs3dK1IT/yKpoBCKPP8b09Heu51ezBB9LNVdCImNO/xjHnimMSCbg9qFyWxSdOD1SBhvR2KHvFR4H4Z2cA6AbjcmMdTzGyRxEombukuNNZDsD5lkUy22JWP7NC5T7XS13IOevzJjletFMkHE8BTbaAcH4+cRQ== 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=ouGFRpLMuIbmZVMl5ZYy3uKZqeV45JbADIdapydMn1w=; b=PxFrTw6tl/Fe+CbTMFh8YGflIB7HPmxMagkLKU2yP6rMiojbEpcjvVB9jVdPuchHksrcxJfxXiOpQwCJ8WL3UTeFWDn73J2vvheagRtgaSxSgclTxWfuWxUD0jEm+4mVzKI3RMe2+B0o3dNGjHkPYiJPj2LoIsFCBTc1TmpMqUjSc8z3dkTBhWEkLqc+Ir78N+SPz7cR99AeqYuQugHeiC+qcBm5t94GIhntYb542FksvAekkM+9mw+mqoOKHQc7dF80sDwGJbUK+R46hpsmX2rnkxNtEBq39qAfVBC36acT1ZIvxIohu8KegHhT1HD6Q3Adqt1jJAG62mTXfG6DZQ== 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=ouGFRpLMuIbmZVMl5ZYy3uKZqeV45JbADIdapydMn1w=; b=OA7GpZSD7oBfKReg9dhM+9QWBXsufs32pthgegDoyiGsSPgRz8Ruo5BPIAIHm2antXX3y+OWiqAZGPVPoaRyR5QyUNnGTRK9CnKBOKCGxc8kVmQcimvlpdCslX6HFybEqrMslMADwp4cZlRiqy/SlyBCeIH9RDav0VlgyHiAq64= 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 AM0PR04MB6436.eurprd04.prod.outlook.com (2603:10a6:208:16b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Tue, 12 Jan 2021 13:42:38 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:42:38 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , Andy Shevchenko , Bartosz Golaszewski , Greg Kroah-Hartman , Laurent Pinchart , Randy Dunlap , Saravana Kannan Subject: [net-next PATCH v3 09/15] device property: Introduce fwnode_get_id() Date: Tue, 12 Jan 2021 19:10:48 +0530 Message-Id: <20210112134054.342-10-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:42:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f3a8946f-1c03-40b0-1095-08d8b6ffece7 X-MS-TrafficTypeDiagnostic: AM0PR04MB6436: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gyrK0owDepij9K57ilP+mXejBPVRnnmZsc7YwkoNZ6M+pudQ3gPPubzRnh3PuLNvpzYb/w5fo38MWxcbDnP1PCY/g7wcUygtY2Z7WImPGz8r/UXc5ymH7I6wj7/SBOO8iTkcZhhYuBtqxNbfGvDTrBb16zRB/iTPllNdwKIGl0VjGvlAR+Npi6dpEDrPQMjFvW3omP33J1eGTkMuXGREj5Wrj/paEW0Kc3pWoX+Vt8wmPhpQKPr0rPWqNS/YQxjvWUROEbjGP3Nq1/gy0YK7Lb66QN55MTsgCPhFTfC17xxNQR5N4C6mUopfwZERCeM1yVxHd2G3Kik8YboOnDlBhVTZhXSvr+d09lgqQ01SBLQZ5bLaM350mBST2FjYgx4XG3Pk4CnpdGxVON8hrQRM4wHMnCAHpP/9vs5WhoYt3OLT75cs4zvYxEVEBMl4G57avHWBuHCOx3YoDZC+rc7gbg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(376002)(39850400004)(366004)(8676002)(956004)(83380400001)(921005)(6506007)(66556008)(478600001)(66476007)(66946007)(6486002)(8936002)(55236004)(26005)(2616005)(52116002)(16526019)(44832011)(4326008)(316002)(5660300002)(1076003)(54906003)(2906002)(186003)(6666004)(1006002)(86362001)(110136005)(6512007)(7416002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: l28qWYgE38+sUJcGLODE7liYlQllDCn4sUB2nWEmSEsS8K8EpCyrb9sdnFRlUyclyo+O1Q0t7/eQ7XDdian4dgxCJm8rCWDlDtLlRflhWbrpTqG0JnuvsrW+1yqnX46I7rAoZpPegdmk5eSxQiNDmWAZy4cpA5uvI7RrzEG7IJXgVZ1jft6NYB80C+agkEJApgDCbmkT/VJ4e29aegP1hqTEoNHMXaIv0UVj3X2W4C9Ka1zN0r3uJqOkgV4c/A9yGM+I940uakRpkWqD5larCI2aRJ5JfGOI+0RiEZ7aBx9yTrASgkSkv6nas3ECeIWvae3VVtOn1qn2yEGSBNHkV4j2W7XSGnD3DgFQm9wB167cxh+o+y0ZnyjhQtxZFOso+3nrfhDVx26C9NM1ZyXT2huKjg96H8Kzft1XyQrJ720grahrxQURwKh4KyJZXL/eoFp4FPwnD3OU0HfnQBENuWstmiqytTalUwumc8kcRoEDFkzUq8ujT/3UvuKZ9sYiMMSP+kuxBvCNBRTMPvKUdQfG8CnF4LqIiMh3zXtp3pSFqg5o0dVi8MtFeRocdLklbVa1DQj/POTeSPLz9OIP+GvLa56VJhHAF/nMcFLVumHVPLHd+jZ/sdDSOS/qAvM190yLYtwVexFKaMr+VaoIM0MOCWRASLbCvyD4090aF4e+bXRxeKsoh6VnRYTRkkDLvF2lWH5Dg6Wco6JyhnVNLSo3YKZhmZiAVsFoitGXYncCpGXpngOkpyG3ZGxBINH8DOGTU6QoTAHzapYYg4/0Yo9KJSsTNr9dNcMs7kkMge7Z87RGpRo8VYVpKqG1+M4nhMuJ0ILtjN5QQZcZbWc6sA9B7XQCAwSF0Muf0ThtCX7oNfkwZhxbBrukAeqG0KKULjNhMEQy0qfERjJtmQa4L+IERg7ZIW7EtufdLKK4JCvPs2KS7RT/ODRbfDUr/OPqb20IdpIP6egTSJagiKyxu+b81yUNLqIxeJivYHUkDhDPAiGfETB1oKzmoiHErjRz 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: 12 Jan 2021 13:42:37.9337 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: f3a8946f-1c03-40b0-1095-08d8b6ffece7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FbTZc7H8tilziRCeOzE9HTh1vfkWdhnfBiMuQbKAqBnD+YekZsTx5olsD7NXcmzIrCZ1aMRrrnTAC0KfQTCLZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6436 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 or get the _ADR object value for ACPI node. Signed-off-by: Calvin Johnson --- Changes in v3: - Modified to retrieve reg property value for ACPI as well - Resolved compilation issue with CONFIG_ACPI = n - Added more info into documentation Changes in v2: None drivers/base/property.c | 33 +++++++++++++++++++++++++++++++++ include/linux/property.h | 1 + 2 files changed, 34 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 35b95c6ac0c6..2d51108cb936 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -580,6 +580,39 @@ 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 + * + * This function provides the id of a fwnode which can be either + * DT or ACPI node. For ACPI, "reg" property value, if present will + * be provided or else _ADR value will be provided. + * Returns 0 on success or a negative errno. + */ +int fwnode_get_id(struct fwnode_handle *fwnode, u32 *id) +{ +#ifdef CONFIG_ACPI + unsigned long long adr; + acpi_status status; +#endif + int ret; + + ret = fwnode_property_read_u32(fwnode, "reg", id); + if (!(ret && is_acpi_node(fwnode))) + return ret; + +#ifdef CONFIG_ACPI + status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(fwnode), + METHOD_NAME__ADR, NULL, &adr); + if (ACPI_FAILURE(status)) + return -EINVAL; + *id = (u32)adr; +#endif + return 0; +} +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 0a9001fe7aea..3f41475f010b 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 Jan 12 13:40:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013557 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 AD50EC432C3 for ; Tue, 12 Jan 2021 13:43:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A140230F9 for ; Tue, 12 Jan 2021 13:43:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387971AbhALNnn (ORCPT ); Tue, 12 Jan 2021 08:43:43 -0500 Received: from mail-eopbgr80077.outbound.protection.outlook.com ([40.107.8.77]:16694 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387526AbhALNn0 (ORCPT ); Tue, 12 Jan 2021 08:43:26 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aBKBqH4M2uwquUKH4wz82YTrb2su3+9jEFoSmssSyM0QkIMWCzNdw0Fplq3Zca0+k+rukG4/vgowFG0TFTkecwdAviet3bhQE3ln4OIonWPM/RJy+p6u4hyx2Nptv7FU1t6GZLzJSgZDXFVhM8FRK9lV++bZPtD0m1YwoRJt8KqShLBVo/LHrIkAkN3uRYfFNzGVbe/PlppU95hcjZv3rRfzoKUuU78E7nBkeeA+aPx5YHUAsGI5MOSk7XZAgk3On9iKAk3bSckc51hA54XYgCZTzwF1/e3EKhu/JjAgawyAqQCxPbEH5EOlNY83boA2fszIiwAoUbJYtkmtSLmwAA== 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=LBFuskpyy3aulS84iesWozcok0irG/Utg82iUgXOxKY=; b=PXgMoymxxUE+G7/3CJML2pjiomXc/ffGY7HNJv9j/Kr3aHtEVqpcjKpPKh/M+rQnPd/prtw3rzjIGIf9XKOG/6DaZeQ+hOdwPG2bXnKXT7oWrt+w6qOPl3uLKzOBrxwWWCWkSGFMG7D3/OkJWYT4a9Cc5jx9odkhBQ/UnVfCZCGBbaoS6SaVu9wVcoKQVm3QEIvSFyZVB8wZvk4Fbwcp9YeITB/Iqf3UT7JYigShZaQYu0QsWvDUk5j9xDikmrQXB2I2neauIhIua5jDlEqxM1auXKgBYxfcEMa/wyVlrMYzFW5Vqtp8RO+DXzDtjQxmTWywNFwgXeYIxdmNBxcPaw== 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=LBFuskpyy3aulS84iesWozcok0irG/Utg82iUgXOxKY=; b=HgddnYcX2qpW2Zo+KGknMPLpNRaCZjFN6heNrcZbgaS6YIi0O5B9rNzkeZ/57OKMx4sgR+BreWvbgDJlHo6DH49RLtz5BezBA+IBi4FFNBQr3zGl8hvQy6D1SpN3FmmpHd5/wh5H66FoXozyURRGW5zLzvG4+eLwBjNGDutVoy0= 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 AM0PR0402MB3443.eurprd04.prod.outlook.com (2603:10a6:208:1b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 13:42:45 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:42:45 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v3 10/15] net: mdio: Add ACPI support code for mdio Date: Tue, 12 Jan 2021 19:10:49 +0530 Message-Id: <20210112134054.342-11-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:42:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 906b8b92-a438-4d15-dd5e-08d8b6fff1a0 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3443: 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: NQShrTTM5H9nra510HUbpo9NYFBpPuAY0voTDUqwh6xsuVO/ho8x/cT9hB6Xa3ujGfOL10OVcbkiUa1LKbte+brDq4lossMZhU23x1zI+T9gIB6govvuObGxCnt7WxT7d6UiMJnr/NfA+0tiQZDpLmSK9c6PRIsAt4VZGuYYPye6veS0F0KUa6cwkK2GnBKHUkc0oZ0uwlMinN/OQRx5ocnCJYvQwVoLsBigiImwxKLW90trfi1RZ1R8wVFVOJpPZj/H8Cgvmuzd9zM44nQeh3baJ3ztmTWhUXJOr5imh0pm9tNyPDXrhbrKYrllRJce5C5lW8YgzI/BLuhkAiBs3zi5qUUxWzllyvEDbWkOzuKJByHRQ1u3eQCINiUT8lJGMcarEGyASCfIUMInrsQVmjl4MM6dZs63UW+A6u/x84JqIg/bry3iCscKAsMzqewf6flysatvPs+p2gChwJiRwQ== 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)(346002)(136003)(39850400004)(376002)(396003)(366004)(478600001)(1006002)(66946007)(921005)(110136005)(6506007)(54906003)(16526019)(83380400001)(6666004)(52116002)(2616005)(66556008)(66476007)(186003)(7416002)(4326008)(956004)(1076003)(44832011)(86362001)(55236004)(8676002)(6486002)(6512007)(26005)(5660300002)(316002)(8936002)(2906002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: vPotSydC7R+3NpuCsZkcg0iDHOP2OHoSd59psHy96PaoWxWjcVnyvOKICHzlKz77j9HjXZOkXTLb+NR8fkLeZIJw41CbhGQfsf90D42PL1i+gBZKj8+hZqg5d2pMdVZgYPl9wgNOZ6SiFIugALYznPGZkSO+HHC+oGT3HngZMjyghZszC0rgDUTnld6O+cg9W1pQQSvTn9mxAtbE6U2gF4S3k4uGjnHflW0jeRbaDmeq8Z6cqKvZB5yFUOy2JOtjOU64xxxebDYMlj6paUQ/pCH+JKbh/CTPA8GbAJXohekhRJqvkxr0DeUQS/d51Pmkrxp3CeOV4kqkt1+nYsoaZJh1tFLoS06e+ScTN3oAhvnboFoLahG0Ft/QNvxMaECbyOiG4qPg84bFGuO0zgMrtRUfwpbiUM+FjZLYxUBLFCr4ofKUxGjjFOt47splfE//iMiaInkrM432MuJA+vKoXO3I57vj8t9FbnB6Tm08/bX/Be/YdqGK0MSQeAsir7m0b4zcjt8/sqfpxK9dkv9S/x2cttBCY55yUvgayUrRavZOPheio0VREHZENNHrF3y8yEqtANG6pl4kPvDvIaB+gFEEKK5y598zgn0NnAd05zfYwlk/zxneZnmCBBxV1pkx6PHojAigpDB2qsFulAbUevkfGfiXa+eZElC82dcti/XUWmZi0bLEZ3pU8kKSRmFJN/m4kn+pRzsmfNazMB7c8+3f35/zTypsmmP9NKBU2gzwrT4nxtFeNFC4z2PVV+buC1iRDMQPkEV5oGjrOx9iQRJYYuI9pP3yLhdJgcmUDhNrXlpPJL5O+T+uDRVQLmuxdCkbliece/6Yb36KCmZVHIADoAfJF38NbRRvkkUVE4RMRlc9x+hr2co7QUW/0L0Qr3+E7H5axD74xf8RwCvGgbXeFjFUEXjq+JAtUjNy3D4zt8bsGIgbUVRoVLJTG280zmR6gUuJT9ETI2sK41W05hLmc3cDNepgqfDvg6Drf2jBXZ+na6KXVf2OfvxZH8lN 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: 12 Jan 2021 13:42:45.8273 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 906b8b92-a438-4d15-dd5e-08d8b6fff1a0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1/MZXKK7Qyuhabq6yLE624v8xY/DJ/oLtBIutfzVhLxTMAV6KpD7s2eqYpwSyaxz17ERmSZLFcNE1TJUOvcxGw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3443 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Define acpi_mdiobus_register() to Register mii_bus and create PHYs for each ACPI child node. Signed-off-by: Calvin Johnson --- Changes in v3: None Changes in v2: None MAINTAINERS | 1 + drivers/net/mdio/Kconfig | 7 ++++++ drivers/net/mdio/Makefile | 1 + drivers/net/mdio/acpi_mdio.c | 49 ++++++++++++++++++++++++++++++++++++ include/linux/acpi_mdio.h | 27 ++++++++++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 drivers/net/mdio/acpi_mdio.c create mode 100644 include/linux/acpi_mdio.h diff --git a/MAINTAINERS b/MAINTAINERS index bfd13ae685d4..efb4bae8d622 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6658,6 +6658,7 @@ F: Documentation/devicetree/bindings/net/mdio* F: Documentation/devicetree/bindings/net/qca,ar803x.yaml F: Documentation/networking/phy.rst F: drivers/net/mdio/ +F: drivers/net/mdio/acpi_mdio.c F: drivers/net/mdio/of_mdio.c F: drivers/net/pcs/ F: drivers/net/phy/ diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig index a10cc460d7cf..df6bb7837d6a 100644 --- a/drivers/net/mdio/Kconfig +++ b/drivers/net/mdio/Kconfig @@ -27,6 +27,13 @@ config OF_MDIO help OpenFirmware MDIO bus (Ethernet PHY) accessors +config ACPI_MDIO + def_tristate PHYLIB + depends on ACPI + depends on PHYLIB + help + ACPI MDIO bus (Ethernet PHY) accessors + if MDIO_BUS config MDIO_DEVRES diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile index 5c498dde463f..2373ade8af13 100644 --- a/drivers/net/mdio/Makefile +++ b/drivers/net/mdio/Makefile @@ -2,6 +2,7 @@ # Makefile for Linux MDIO bus drivers obj-$(CONFIG_OF_MDIO) += of_mdio.o +obj-$(CONFIG_ACPI_MDIO) += acpi_mdio.o obj-$(CONFIG_MDIO_ASPEED) += mdio-aspeed.o obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o diff --git a/drivers/net/mdio/acpi_mdio.c b/drivers/net/mdio/acpi_mdio.c new file mode 100644 index 000000000000..adab5dc9d911 --- /dev/null +++ b/drivers/net/mdio/acpi_mdio.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * ACPI helpers for the MDIO (Ethernet PHY) API + * + * This file provides helper functions for extracting PHY device information + * out of the ACPI ASL and using it to populate an mii_bus. + */ + +#include +#include + +/** + * acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL. + * + * @mdio: pointer to mii_bus structure + * @fwnode: pointer to fwnode of MDIO bus. + * + * This function registers the mii_bus structure and registers a phy_device + * for each child node of @fwnode. + */ +int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode) +{ + struct fwnode_handle *child; + u32 addr; + int ret; + + /* Mask out all PHYs from auto probing. */ + mdio->phy_mask = ~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) { + ret = fwnode_get_id(child, &addr); + + if (addr >= PHY_MAX_ADDR) + continue; + + ret = fwnode_mdiobus_register_phy(mdio, child, addr); + if (ret == -ENODEV) + dev_err(&mdio->dev, + "MDIO device at address %d is missing.\n", + addr); + } + return 0; +} +EXPORT_SYMBOL(acpi_mdiobus_register); diff --git a/include/linux/acpi_mdio.h b/include/linux/acpi_mdio.h new file mode 100644 index 000000000000..9be6f63cde8f --- /dev/null +++ b/include/linux/acpi_mdio.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * ACPI helpers for the MDIO (Ethernet PHY) API + * + */ + +#ifndef __LINUX_ACPI_MDIO_H +#define __LINUX_ACPI_MDIO_H + +#include +#include + +#if IS_ENABLED(CONFIG_ACPI_MDIO) +int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode); +#else /* CONFIG_ACPI_MDIO */ +static inline int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode) +{ + /* + * Fall back to mdiobus_register() function to register a bus. + * This way, we don't have to keep compat bits around in drivers. + */ + + return mdiobus_register(mdio); +} +#endif + +#endif /* __LINUX_ACPI_MDIO_H */ From patchwork Tue Jan 12 13:40:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013561 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 7CB17C433E0 for ; Tue, 12 Jan 2021 13:44:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 30C4C22228 for ; Tue, 12 Jan 2021 13:44:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388277AbhALNny (ORCPT ); Tue, 12 Jan 2021 08:43:54 -0500 Received: from mail-eopbgr10085.outbound.protection.outlook.com ([40.107.1.85]:39271 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387889AbhALNnl (ORCPT ); Tue, 12 Jan 2021 08:43:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fCDtgIJvYMnYgwRSbj45buXzikYhTyQJeVwAfsLCYe5WKu7PBMAe0YXLUKDxN+AEQfkpbAzyimm6q5p69teCuXaPGXYnHmqPHqL86e0mUFrKTo8QBRtxv3sT2iGOs3BTgqstBgc6R5Wfy4WO3yAp0CPSx4mNgOrMew168GztIivYqBCgdRXdEmFFcpA6eNxop7Kt0xf8PNIlWuqyijQozXFQaM5ISaFs2sVVYVMj2g6rU0L402AntN/aw6MGxAqNMA1CdRfK6STOEWzE4/9bnVOzvZ23/h3qeu19qhL+i/0gdMn1Piywh/DnRCwBXygUUS3zB2j+Tj7vX9O6nIlG8w== 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=2PG8h2yOCA+X+lsQ2OIMt46f4ebRFGNxig8GVOvJx8c=; b=ds5tVSLfyCDsBz5cwTEWNPm6vC//ppzC1jel7mhoB0/XpESJ2bQLFeczkrQG7CQNUCatsNI06QBBS2ngbiFL2e2dl4QRCN1dmyYA+Uvi8BT3A3LD22vCn6X/6krWkn3CzGjLOLTJepIdHdZO/ux6f5PzNkWSdgoHICBIT3jWW7otn3vL06KQ5GmMIte5hZjnGLv7ChHAwj6OO1otVMsNHEO7pzBtfNxjO6z46VUFrkwlpMJ2Al2vzKFZD4EFN4nG+FrQbOsxukfGPtN3IIy1OHj9Omqmu/lA+VPxiY8bBHuInfVWto95xXDbd8pN0yQ05wS4cSG++3F0blyNOubtOg== 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=2PG8h2yOCA+X+lsQ2OIMt46f4ebRFGNxig8GVOvJx8c=; b=WfWL8kC2RTlbxsqmUhjI1UQV1yqAtEAyLh965i8gqOgd0IbzghmA4q5r91y5YYMWOXdvMK0bu4SRp6eb9XCExSK2LmsgUEsKcrmZn6H74W7CvjnFNm+it3+rNx7bEDpscwBaGLQk0n+xUYR/t/93bms0vWB9x2TyjBI+OkObbfI= 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 AM0PR0402MB3443.eurprd04.prod.outlook.com (2603:10a6:208:1b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 13:42:54 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:42:54 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v3 11/15] net: mdiobus: Introduce fwnode_mdiobus_register() Date: Tue, 12 Jan 2021 19:10:50 +0530 Message-Id: <20210112134054.342-12-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:42:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 399b47ab-459a-4ce1-b6cd-08d8b6fff6e0 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3443: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7s0TaKxPZtnJ1M2pWyjhpNAukfnlCps5lbF1ecijtODsZjwBDTNmrzzc8RaODdf09fau7iwznsl1lI0XzmURRxMhvN5ID2ykfzaBza7mRQrctmUldYZv4DiKBBJXxQHay81LXAOP6BxwWA/6Bp1o2UECmnRXzlBzEO/uS0YoGyISovQX7boAObN2jKszwgrhBlRA9Ji9GD5it8d4cwMy2Kk0PEbUflEjOEJ2rsZPqt0LJv98rurvd54R/3W/Y44oCiC8SPIqjTsWkOY9dsaDGjAmtQloZEyAlOp2IuJlL1JMoVsirXC8ZUXL2zcprNttFEdsZhWCop7dxPhYcqPzsq0RpBUPzIY75d+Bn8uROClcsBfiDJVsKSBaRjTvYEYBYH/opyCSJ8r3duEIF+GZ6JZUeSGksIISgkzX1Q09oFBfeUHAoQv5yT9PEc0uaohPHv9QagduCMH+DpmLpZxi8Q== 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)(346002)(136003)(39850400004)(376002)(396003)(366004)(478600001)(1006002)(66946007)(921005)(110136005)(6506007)(54906003)(16526019)(6666004)(52116002)(2616005)(66556008)(66476007)(186003)(7416002)(4326008)(956004)(1076003)(44832011)(86362001)(55236004)(8676002)(6486002)(6512007)(26005)(5660300002)(316002)(8936002)(2906002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: dgeACb2MIMRTbSqYFAF0GmadYAjp+rPhiQu2oxySfwAtLuXhTkf+ABKJFR4NzAgz2l6gtcPuZV14fxWknc+6Ab2uOW8kfHyjsxAIHYFzhPX7heATlRw3B4fMY1plVFiz5r0MDv9GW7TGmb8nIq1pxDeShZ7IYE6NGuuaHcjnPGOcmsmeUzDtuquajWokLXEjbEiVFliHClJNHVRzmGnahLjRfPp+YGH+FgY4aoWoegQGIWx/lzj0Uut1s59urGz5X4ug3HobeEn/13AOQaDE8Q0ChOnvtLDdCzBtXboVFueT86pfb/Q/uUjHwJejeIIl7BrNRyYj5rSc02CLZRBxXBfFTN7LP0fAQbx8bjO8PxOuuIFEKEbXf7wNfTUgM++ITz60YzASxLS3SHSsghb/36ahp0wnzI2bonkgcb/g/7U4og+sSBqHOWG++l8zy58W/sLxC7c80GjBQu1jDt3o+k7lAPvxLfO1fQasOiH7obCi4YphwGN1eNxuun4fY9augll8oWa0Miqai4URgVbNRIqdr5hAzY7OIsEWHAei4PvIYdXzsFTO0Nu5GyfzjE9o6q4rfJCt70qi+Q4zLgrD3KNB87JBqPUgrrkdY/Ie90zh8sdTA6zPrbp96VaYweHPg9aDLfblKomYpDRgWUgrvCm5vmaBs0+dyMkgMqxx+dwzwWpBcEgA+7fgJt1BShsv5EIMW71qNnH0Ziq4HqspNR5qlzJnEwWNWWcXfOrHhP4tSweBoPumxeS+aEHjrrMCfrLXV0gaWNRSyL/t7WOmXPUhLz6RoTjG+k5l9n5+zKEX3etGdiHeepv046aieD8439mX9K/eZd1lFAN2XCkHfILaECWMlqaZHMUioRmgKm9fQysVJv6qfawiAhzL+zltHJW2iCSE7pNuNATFq9+A1esju5IUqr0mWSSWKvcaxrj2Y8tc2CSrZVxojePaCNAPuW8e0d1SaseUuRoRpxaPzRQY0ZUYT3XgWgJzniRn49CcModPbYmrgN9kQehNW/l/ 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: 12 Jan 2021 13:42:54.6533 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 399b47ab-459a-4ce1-b6cd-08d8b6fff6e0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ylei9Q+kqDz8Hz7+XviEl6g4unxlGPuY/g86fLFuPqW3vsY3JvZV69A3rwpKTO65S5EqZ5qVmz9VozW7+GmxyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3443 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 call acpi_mdiobus_register(). Signed-off-by: Calvin Johnson --- Changes in v3: - Use acpi_mdiobus_register() Changes in v2: None drivers/net/phy/mdio_bus.c | 20 ++++++++++++++++++++ include/linux/phy.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 44ddfb0ba99f..01bee3c46d12 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -568,6 +569,25 @@ 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 returns of_mdiobus_register() for DT and + * acpi_mdiobus_register() for ACPI. + */ +int fwnode_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode) +{ + if (is_of_node(fwnode)) + return of_mdiobus_register(mdio, to_of_node(fwnode)); + else if (is_acpi_node(fwnode)) + return acpi_mdiobus_register(mdio, fwnode); + + 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 28cd111f1b09..0a5c68eab53a 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 Jan 12 13:40:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013565 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 D2C33C43333 for ; Tue, 12 Jan 2021 13:44:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 883A62222B for ; Tue, 12 Jan 2021 13:44:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388123AbhALNnw (ORCPT ); Tue, 12 Jan 2021 08:43:52 -0500 Received: from mail-eopbgr80077.outbound.protection.outlook.com ([40.107.8.77]:16694 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387526AbhALNnt (ORCPT ); Tue, 12 Jan 2021 08:43:49 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bYYrVYwkw0QpiUAzVZL4vf+FprnoO9OgqbslEAoeCIof3oUj8Tu4EGJ8IP6/wwjdoj/ZKsp5/Pk7fS7tdT6yHCemu6Hf6WBdt6AEKBoxQ9h0CD3gjr/hCaL0w0iQ3sUCS5/DKjx3hVlAazSTY/cYCE8+2UWaeRyQr+PMSETMYtBw2w3mfGQVlh8FFLP+0qKKYh+2wHLqwpB9QZbH2H6EgbVK2Ba25g2DjJQMHaG3SZndOhWWJg3WpOeRStjDMJsjG63vWIlfv9J1VN4+RYM6hxfPa60Q0GMrtvAGZCRnUWAonBBEO9CRqgOO3oHjvUd+T8xnKIozpXvd4EptqLHjeA== 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=4+ac/sHlsjD1wXhT9Y0kXhnbyl8mFnzvRRbk+6v9oA0=; b=Qs0M909GtAbVeZx1x9Wlm7IkupP5uNrNS+YqYzN2omDbElSwWek0ursIlqHF94IJrXHq3UIz4uzg2uBTyhXOV5uEIIq18zoHaZIoGpTuUyeY1ojJ9X7XzbvGbWv2H8KMqqrUIOIxI3c+785Obny26uwrtw2k1SMaXTxcdmHc8xF6bn1g7+6pHeiM1oSxRIWzN0twJd+T7U05+J6QfX0bRKblyR0hEWHqwuFgnYZPlWg+nrdu6i4TnAyLvrvWoBGYaWcEOiC6xi0eT65F7iv8Gf4pzDcvsF6wN+P0WAx3YCeLLkhtZjis/15a0zAqTIdAnGav5FsyxAMa0lbjN4iFew== 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=4+ac/sHlsjD1wXhT9Y0kXhnbyl8mFnzvRRbk+6v9oA0=; b=FeDFGAUsclGnYoHjbJwAmh9Oq3s1FSrOFSrSwMcQ8c8ZkyBkR6mjyJ0NGZSQ9xwB1MarC2uv2MSaPmcS3x8ZnmNG6baxrHPJ6eXDOiZp96B+K3c5L9SNiam05V8kXUC7dVUUMkC2cO9YFXgxGvPGwcMh8kjegtF3JEmATPrBtwo= 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 AM0PR0402MB3443.eurprd04.prod.outlook.com (2603:10a6:208:1b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 13:43:01 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:43:01 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Jakub Kicinski , Jamie Iles Subject: [net-next PATCH v3 12/15] net/fsl: Use fwnode_mdiobus_register() Date: Tue, 12 Jan 2021 19:10:51 +0530 Message-Id: <20210112134054.342-13-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:42:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 62e437ef-a33a-49f7-cf86-08d8b6fffab8 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3443: 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: mANDbPGkr6GqgR9t3lEtcAcYxqVl44piNZmEf8HTskmW7daqa39LVNTWg2I+IpoZ72NutvfNFn8wvExFILQTObwI/qHN5ZvGKqCnW1Qzw6BdWK3NcNcxygnag3bay4yLZ/9L9jzR6NFadDYcy72rK2By4KfFFInvas8j23jqPt/nKeVQjiJOGuNLc+Oak9AEijULOhTmlRSVKPMYefuaABoiyL8aavoMburRLiKpYeYCnkO/3W6lGD4ahwoq7i0RZF0KjuktajF0zU7dKtW700v+5zN3qvb86v8y3dFr1gKRbJrOASYKhE0tU67lCV50b0sTORhIhz0EnOFQ6Pd+9s9YQKIFhQoZ4wHsOvW5rYjTmT6DEBS5Vzu3tXwAIPZqcS8XBkfOTbBibm8ANJ2+6GDFpP4Dr1oFuKoakmXZalCY6/TaVsZkMiqWun1465F75D8Vw01tWd4u3RE3RtcoeA== 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)(346002)(136003)(39850400004)(376002)(396003)(366004)(478600001)(1006002)(66946007)(921005)(110136005)(6506007)(54906003)(16526019)(83380400001)(6666004)(52116002)(2616005)(66556008)(66476007)(186003)(7416002)(4326008)(956004)(1076003)(44832011)(86362001)(55236004)(8676002)(6486002)(6512007)(26005)(5660300002)(316002)(8936002)(2906002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: cmSxqlH/ggVgw9/H2gBsAUFPJNCZ5ZVQ1tv0DLJLra6nOMtCnPtAsVshSe8+7fkflaMouknMMISwRL/ev0I1ZvO4+SYPhvpuiMYRUVaIxvnwOeBoxKQoRZFrndKLw7LBxUPZqd/A7KuP6TAY6PenaWq/yQf40QcUtj2itemc013HvmvccNFhechUe08Fdrfg5veRv8HMimlOxJJdaqxIllvfFG5XHxz6lWcNdVqesdU00YTiE/MWI+dDlueMFQlhKEnHQz6L4hQs7vsrTjZox+czs7KocPnb78OLzoCo3fxSulLu3p27FhwU9/aVu26BqfNsSkp8/YMfh06hNlofC1PHL6QiXSgEcVUKLo1Tc7Jr92zXEilVOqIKzaEw0IWBdwE1hhyGuEg5B9HnaD88wvfZLHEqf6Wm5LR7mRUejbFUwAkatKN8AcJbfaepdNwokhRrS4+YdecQuJbWHKlJOSCE53jBahz0dh6OXZSrQJk7IOS4HubLA73cm0Ss3kJV97Ey/+ATNU4BvqVy5w7LdYN7epXNG3KCeuzd7GLa18R5YY7hKIys7N4VIbIdB1gDmROlA4GAj44FjvJNBR0Qh+awjeF0QMUyUzO6XncF4hOp5NZwExpaS/4CjboRP/94JAKnE0n+dAo+VCYbe4Hs32La/rYSOFWwtrd+PpCwKjktNPnxYkHJqVZJzwyTrzry5EldGiBvimlagTW8iIU4LXsuFHj9d5mwwDwEyBy9YSShEvOY5I6BJVJqAPQmO/c3Jr96Z/yJ4vae4M26yAPLjCxRN3748aDOFFIS3hbkuss3zyOdekFpAG5jixCiIBY6M7qbRNOwO3EBqeb0dFdhMlPvX4lL+Usy/q0BQBXSfCse06lxehbd9Z4Bg2aEEac8wC9yVOggJWVnPs/rrLpefKFOHbox9IUZcb9n0jDPsE0qnKVvIqtHkJFCRmc78B5nObOrCTYuftKHRPrJvRjZrmWkSNH/FN8TMXYCRtkl/HD2aOsrcuOXMc0fQMnGoWeF 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: 12 Jan 2021 13:43:01.1477 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 62e437ef-a33a-49f7-cf86-08d8b6fffab8 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: f6XFfCzOrYy4jKAKW4uOV2Iri/VBzMgYDLmw5yz2B++AnlAYOR64bCA+UKTcu24VAgjYQcaFENI8Dz9b4upqdQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3443 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 v3: - Avoid unnecessary line removal - Remove unused inclusion of acpi.h Changes in v2: None drivers/net/ethernet/freescale/xgmac_mdio.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index bfa2826c5545..d609c08b445a 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 @@ -243,10 +244,9 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum) static int xgmac_mdio_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; - struct mii_bus *bus; - struct resource *res; struct mdio_fsl_priv *priv; + struct resource *res; + struct mii_bus *bus; int ret; /* In DPAA-1, MDIO is one of the many FMan sub-devices. The FMan @@ -279,13 +279,15 @@ 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 Jan 12 13:40:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013563 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 EA5AAC43381 for ; Tue, 12 Jan 2021 13:44:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8EED2222B for ; Tue, 12 Jan 2021 13:44:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732151AbhALNoB (ORCPT ); Tue, 12 Jan 2021 08:44:01 -0500 Received: from mail-eopbgr70083.outbound.protection.outlook.com ([40.107.7.83]:38766 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388323AbhALNn6 (ORCPT ); Tue, 12 Jan 2021 08:43:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jjWMj2TkHl5BjAyPWm06PUj96Wl5JHlrOBYqqO49/fb2w/eMS0mW0GAt4VKsfOAtyeu+g42KMIUV9WO6Zg9SJHWotZOFCWK36a9pQKDZRfd49qAx4C47Dv6+IYDcjjHuiJLgePKindoibD0dKpx1HPgrwAWMUC80j1BM64MvbqstFCeWR3Lp/N2h44VCp0s3UsdCgNDRW0qmGlVSNh/MhXy3hl1gU0BbM/JHZXuJ9C8oKBmNtxnEdr/K97RymGn82XEdA5x3C2z1FP+08U64hscSOduC7YFXD84NK5BCZAJQipRAi9M5dguU2+BzhHcsn6hXyEa1RoJfNmIywR45sA== 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=Ptl58KKlqn7/aQTaIpbfM1YNroxq7pUX0wvLQlVvwkg=; b=i2jn/Cup1CDsCagf+5tgiTc9wuEWI+um0D1Zr9XnwpvLybfQBeWuoFkHCmNx6ZeqRsqzFgEDEnLOHq1aHGWpffAlPlk4JlHKy2IpjegfByM1OSlj3z+nJJruChjlQUERHiQz1ESwIAnXD9ATL1nrbiCkmL+JXNB+K5bngZENVtG+p6KHxrNmlHO3MgDgk8mRYFxNR/4XUPpzhcfFHUlG/Xw13TVpTBvc780jSIVDM1OdreTWzGZagZPas9UEiN+Jeg1BPSJnXyGHaDMaun9vrqeGWh42/FehXDrfSWNIooRxyGeAUwjAfBxooLLFpAkrs4h5fGMgV3CuFOcve8le/g== 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=Ptl58KKlqn7/aQTaIpbfM1YNroxq7pUX0wvLQlVvwkg=; b=MV3NOTPt5o1jfhutpa7F+v73ZLnikGZ3XhRZGi87Hwn2Dm7dVG4bc+nfvafkzo0S0FFx/TlBB7N0EuuRMYPF64M7y7G+lf5m84vF8zOA8bZv/5Ezpgz5GBnWmPzfBG7vVpXerbB/daKGR9Mb32Lz3BPB5Dff7Cc+4oHzlttNvKQ= 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 AM8PR04MB7937.eurprd04.prod.outlook.com (2603:10a6:20b:248::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 13:43:08 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:43:08 +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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v3 13/15] phylink: introduce phylink_fwnode_phy_connect() Date: Tue, 12 Jan 2021 19:10:52 +0530 Message-Id: <20210112134054.342-14-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:43:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 583250bf-d7fe-4cda-0465-08d8b6ffff33 X-MS-TrafficTypeDiagnostic: AM8PR04MB7937: 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: NzHQqq7Z3um0iuFw2B2lAdn9Hcv62h30uCJbjfR3MXBqMYPk6q7Hz3yPDaux15Mj7vCoLYpKbhPrEBf6R8ZAicmIbFk9Y8NJvtYvYH+K1D2HJqiS5KBYNkI7O/pTdaWDHuUxj/bZheqeiXMdCDbts5Ga0EgQGzslvrU5lU3C3o9eJ6257uGD5izdbVpJO5WD7Ch7JssyjAOxcdBT5RJpVDNvYByBimZvyS3QFKe34QmzL3Ow1YIPly6qdrz8un2BIElPwORNvoXO64yrT9EJiJlbM+udkbiPk6p15SUYenMQyAs78Elq9lwFkb+LqNCquISbFlcEhwORglaWd5nhjHGdk1oKPjSs+7hSYJx/kSd6eHUG8FZj7fvB9lqNnxXP7O1j5fwlhlx/9nSu73FojSUmNv0pMDKj5iyxebbNKK1fvkhyJHuysBpv1UU1ZeUIWRDKRRvrkcL4Z96d9zYxgg== 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)(376002)(346002)(136003)(396003)(366004)(39850400004)(16526019)(5660300002)(1076003)(86362001)(52116002)(44832011)(66476007)(110136005)(6512007)(55236004)(26005)(186003)(8676002)(66556008)(316002)(8936002)(4326008)(478600001)(921005)(1006002)(6666004)(2616005)(6486002)(54906003)(6506007)(956004)(7416002)(66946007)(2906002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: g45vaXX99LmbWqQd/gHg95kCiV2/B5SxluQ4KmLDbSc4bOOjifDpNgPEPdTDB6sAX0Xg3oeQPTsv1dIfjGU6/QDIIQ16SUfAUhKTfJiQSTqFAa+iQpZV0kQ7Tfv7b/QF70o1xcJBPPFg9Xgunx2nYR6AeFV0Vo7CDeyAtTilbYLhg3DSgBaYmWG3U9MYxaI3mXRuwcNYc1k8KjpJTBqW6iKQqMIZ+qbKgB1dVqhRI24UFFDuRWeVIlCFUuG8pzBDb1KWSriRIPaC/V5y6nohW5iqrS7t1n1Jd97pYJYhoVDwx13q228weap1H/LTKu12CDxgXHn58I35M7n6lItNuw3JqedtLJw1h6aqjXxGGlsMMIFwd9VFR/Xc21Koc2McJrZI+JhZwF3kcbx3kUrB28F5lOZjoJ6nDXo8cZRU/FZiwY9/Gjr+7LxnlJH5DilejlOqHruLOpgmdH5WvMFqYdghLNx0Y/CUoVeoLuLdLHImnSn6LFKaBuMNgm4g53mHi0pAU+dMG+XV9q6iEXTNhi4oq3ruHzvitw0yL81UsnELkBSH9Rmhcrn9WkjFWoYVhWs/xY39S2sv9MSY4XHd8X9VBIcBmaN0ptJ81pO7rx0pdTwBkuRyOzf3AKCtpi/Cd7jvnXP73NW3c64D+KHX06PcK6XECxckd5O/hw/FRA8bp0ZJX0uK14EiPMDfoxxHxOCifjuvHnzr/9KtYQblFKcpXaQVoWtZTNXinfe3Q8QZqfwFAmFA8hVDEQLpMaY41HQbrD8IvVIjSXdS++548oCLorJWsDUf9hU1MMFulf+n/b8g+lAGR86uG3pO0eAD1Vl0PydVC1bgkACJux02UCikwTgN+yauh33Qd5IxH4Ra1j+PJZ0rNCsddyi1XcdkUxzOuk+H3cDBGcUEYr9WKVSmMMh2vuz5wmK4t+Mr5CNssKN5WVhSEPTTgk0s3pM1GvsOceAgO4KZMMym9tebP8VUc/h6FA70PXHSAhndlIebHKEcN0XggpZLvbL2hZJj 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: 12 Jan 2021 13:43:08.1557 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 583250bf-d7fe-4cda-0465-08d8b6ffff33 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1Xxdn5TeWvrZE8nOQl25UcGcIOpk6fZle4IJvAT8b4F8PcGU/GZhKwVHDEnz9YvRMPmEyzLgkFVklGsI1ny/lw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7937 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 v3: None Changes in v2: None drivers/net/phy/phylink.c | 54 +++++++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 3 +++ 2 files changed, 57 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 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 Jan 12 13:40:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013567 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 76D62C433E6 for ; Tue, 12 Jan 2021 13:45:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C9D022B30 for ; Tue, 12 Jan 2021 13:45:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388882AbhALNok (ORCPT ); Tue, 12 Jan 2021 08:44:40 -0500 Received: from mail-eopbgr70078.outbound.protection.outlook.com ([40.107.7.78]:43716 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727144AbhALNoi (ORCPT ); Tue, 12 Jan 2021 08:44:38 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iaueuGGMCwdNGMWBo9zBNngq2qdiJR3mfnvoAo7on/r+IaUFCoxaGkBadBJ05q6gxCitszlSfrBLG15GeXAe7lU1eB+K2UsUPBIz8lohCjl0r+2JQdMl+TrkAtRLtrdafiP0IYtoaGj+YSq7j++2t8mK2UcF+aKG6qPDNgSxpoqo1SB0wiVPxB5ADmvuNhQYEbiLCQfFINb1PWfPAcMcBGivU1YsxYcJlY7FQOwzGc495eb04Z/NYaGj001efcjbtGmv+4IxE3SEvrOnPMzceVHkekIRj70hKR0CPWMQepFfAFn+r6q5h6pyhSf9+fH7XWHgczr9gT0+KkfZFWqQ9Q== 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=4fAPgvMovsh30mY5OeCsKrwlEmUy/JjBX6LBLUGm58U=; b=kbdJU7Pv3gyZM+Ye+vFA3rFFlfC4gBvYBc0aoj76YuiV1FgxJbJauNJusqepAgIrDSBIrbpjf+Hj+nGL44X0h4UFTxQjy5eSc5G8BafAN/LHzknBud686VdZRR3srdsv+dgKHcsTrko+99geyvxnRnOC3+v2j2NbzD6xnXe5GI226PfFA/yI9R9plK13P8m7CeLCcptm0gyr7/ivggUXUqU1yMQ7Je/G5TQIB7LpD3oantQlWMfBc2/1djyk5zBBONtlJ6X13cHbJgDCc+EdjwYdflHkY+YQgcRht5Pf0++q/bJIwc3ZQABiFWgfZy9+MOawlpm0o6bNtM9HdPKj1g== 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=4fAPgvMovsh30mY5OeCsKrwlEmUy/JjBX6LBLUGm58U=; b=YsTms1WMj7LBZHzah+9LrLjjOKh1W7F8CmnhblA+GqRpp1Vaj8yzEXgqjjR0rxlF5+cfRXzPD6NXtiHYmdVnVJdChAbLiGHP2aDCPdxAHlAZA3zphNMh6sqZ83WASm3CGt1pfGHnGE1qvGeUmKlg8+ZgzI2vXZ+TF7z6P3QEVTQ= 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 AM8PR04MB7937.eurprd04.prod.outlook.com (2603:10a6:20b:248::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 13:43: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%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:43: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: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v3 14/15] net: phylink: Refactor phylink_of_phy_connect() Date: Tue, 12 Jan 2021 19:10:53 +0530 Message-Id: <20210112134054.342-15-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:43:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 00ea4d50-4485-4c7b-342f-08d8b70003b8 X-MS-TrafficTypeDiagnostic: AM8PR04MB7937: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4V3TZ/RmykZNVyU64e2OCF2zDDe9IrSFLzLOzoeHbIzcpyLI8TGCPmuFUFb9DoVYmnpZC3t8Hc+hskv2xxaJ3x/IQX0xr+sCXYesuihOf/RWd4ojKDb4T8aX5asGvfkdqJ3voAz3tmgf4d6iTbF5c85Vl5KHeUQaQVRqWh9JKlbnwQ2M5wT68LyehuZq8DqjRDvD9z0uy33JX/tDM/wrdaOSXW/o8ljkoRutW/S2VFbNKKDeq2RSAdWYBa31OxRsuxNs89IimPnmMw02xB7FnZsf+SJukNg0QsUmSQHvuWOj5ANJrHJ2w9xTXB+LB4A2q3y7G8azn+84v1xa0lVcWjIToJYklffe6Mm9E6A3G/eEiNir5pjkNxicX6bWmQmG1aFTS4rYeEo6mtFnzRHuJqmyJYPQadr3Blrs9EoyCMg2fQNyG4XVbaYFTdpe2R2ABKU/PJ3l3eLJNp/tW4yAkQ== 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)(376002)(346002)(136003)(396003)(366004)(39850400004)(16526019)(5660300002)(1076003)(86362001)(52116002)(44832011)(66476007)(110136005)(6512007)(55236004)(26005)(186003)(8676002)(66556008)(316002)(8936002)(4326008)(478600001)(921005)(1006002)(6666004)(2616005)(6486002)(54906003)(6506007)(83380400001)(956004)(7416002)(66946007)(2906002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: a0b9lrZQttWcFgevrD9z4rFBxg8PSvd6tJR3W41os9Pja85azHj7m5OqvgntZOtHBA36ZEyOpWB+jMpgn4pbOGBjPSKsQuxFqw83Gw55gm2y+B+CaKaySGpdQUIaIJfLQQhogmagx/pL2SBodgkBsVPnVrtFQN3/0k98H3U4j38aBDAQedi8+uBHq9RsRYFx0NMiX5hNcYF4EfFOUy6NKvZ0WnRud0DVe57/SUIPoStBigvbzV7VaYLp00Yq0TuLZAGemmzFUESiJlTYbK0wRYqUQzbE59UX8r7EsxV/or+p/ff3T2p5G/pvt23oD8ty10h5KztnvF+LmhLd2fXgViNa5A4hIJvTm5BEJzv1qRLu01oLPuDdnnbcGIQJbQDefjoFMZsWVixofhFrwnj4oIjOrP8clVBqPKX3UFoVVECUNfKRPAAVDrSv9H/f/nJpln9DBSlq4B7uNzpulHTkqa2/rNpGmPiX2iD8akI0vf78TQCj8QcKBfIwOUqImWGRu877KXp/760fsBnrtq4K+vz/x1aRZ6GB89kk6JQuauWreE775G8H6azOKQXesgl2zbmMXfnpzenI452ZVGNR33B2tueS2hKL7Ek5wy+kIRTqU0FaYgZSamQiQRO+Mg2hk4n8plWgSbox+fDMdkItGqLLP27fk6srK8332zqARWuqcaOulzJXnntOQFukZGpYESTTF0Tvv7t3bI7GNoalk0Qu6ZJfRDJM5oNF6h+bfq0n+iCkAgquo89INe7NuRLT3k3zs162+rcesW3yQUt8qIOjO++RX/nebEefWzl1JUCuySW5Hzx9WU3lR2+PGkq6wKH/vZ2E4WugJ53LIJ54Vb64s6N82zlosszf+as8qfZGze01+OpNnHO6Cmo0y4i+XQRHvY5QMrxvlXs+KbwgyqTx+WPTuohx0j9bWLu1pbQQ+XSo3SaHrn/4iJOvJ0kxVFr+/hWHRhDLZfqGhjrcQVtbKxughN3X2rTra/gADMJ9dO5jFNOCNTL89iaJ7xA6 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: 12 Jan 2021 13:43:16.2432 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 00ea4d50-4485-4c7b-342f-08d8b70003b8 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SOW/nrkwrilCWdfBqT4sonOLBZcT7gR3y1Z9QlmILBgy3vKv/50a2VsopoJen3IFV/SoNtbVzrhPKUUD6IaAfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7937 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 v3: None 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 Jan 12 13:40:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013569 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 7A8FCC433E6 for ; Tue, 12 Jan 2021 13:45:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 369A822285 for ; Tue, 12 Jan 2021 13:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389252AbhALNpL (ORCPT ); Tue, 12 Jan 2021 08:45:11 -0500 Received: from mail-eopbgr70083.outbound.protection.outlook.com ([40.107.7.83]:38766 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388744AbhALNo5 (ORCPT ); Tue, 12 Jan 2021 08:44:57 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cVMkBoNIR79nkEo/hJ4izMw6RICPT/JmvqICy9CkNHy8hLfW3CllqG8ARpeqejOmGheWMWcLFx3sxZmXm5b2yiGCGsrSJc4UknmDnOmangH+yPaExjAb2HOlMp3rr/dVcTo2rM9afCDXYq+c3Fm/8jga2htMT9YfqmoNF2Kf0ctzxEMgB4e7BBl/4WIegunbNT27Fvci9ZtGvjHAZsLuupqhMEi6FdgPdr+W4x1AiEUiG7D0kR1iSk7x3yL0Io91clsKpavS+J7M2aIce6uNp40dP97xhbjmeKTFK5CR+lTIbWus3PfoGBugDya1tO2j9sNLPPjt7etU04/D71tiyw== 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=b//OUlxZ0wCcsSRdenYT5np+MID2Flbpazna4UQS4P0=; b=YVmIiAX3s4M5UbivUS71ewyySes39gayvndFmBoE+cJblHtrxF4VFuSSqaEVID0+ajTPJOYGNpECCUIAeJGf3YdklPOtbLjX8GCtQH6pvvqRcQFRzcSYtdzh7Pqllo2y0roGDOIL6KlxTcumTVrwobEFhl90t3KU5ZFCB67VIFWjjA11VQ4kFS+S1S42VsI9Mn6wTLDCyyyVdIyRe+BIxNiaiOFAUDfUjHHz+++WXLIPpNNz9/Inq2xwINW980/yqlCUz1f/Is3GS4Vj3HDE4ARKwD7m6nqBf3EBIVraoU3cbSlhaf5g4MNZYtnza6zAbT3JTBUjNiUNfjc+3GPpjQ== 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=b//OUlxZ0wCcsSRdenYT5np+MID2Flbpazna4UQS4P0=; b=AEbYcvwAKXhbk7fObbvvBH0hIVWXlQyJij1Ihg3fN30aTz+bfSeQO/qIYdIuPuTnbbkQRoPCdFU0VW5yLTpKBby2UkNprLmNZ9s2dqGm0tusGNeBQTSti5ZW7u/HlxxYFG9RJPMoxgSDvR70q6prOvqTUlIL/XGbCfth00YA4Hg= 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 AM8PR04MB7937.eurprd04.prod.outlook.com (2603:10a6:20b:248::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 13:43: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%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:43:22 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon Cc: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , "David S. Miller" , Ioana Radulescu , Jakub Kicinski Subject: [net-next PATCH v3 15/15] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Date: Tue, 12 Jan 2021 19:10:54 +0530 Message-Id: <20210112134054.342-16-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:43:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7036a4cf-cf97-4617-3556-08d8b70007ac X-MS-TrafficTypeDiagnostic: AM8PR04MB7937: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zn/YhgJLYZTZL1h+VbBZlslDULHnAQ2w0PFZnXU6VUVTcgrgnAQYmzjUR2FT3ru/T4Ic9T9gu3xYg64YbKEuA1nd8uH7JJi4TVstPqWsdVHfBOfjmcta7YAVd3Czku/vn+Iw2opwtxodOrDDFPyAMbrpeM2JemUhZF7mWb/wOSsg2TezNZhZMtPM+twy1ys28m5PaK0hQnFwfTYfitGF+7LjOyoKaidNOVUykbLM64bmojk3wWaBWXO6h5eJjb2VQ2jGjZBddonR9ZdIxgE+VG5R891HcQ7UbRCcGD98l12Fvs6v7Nh7KcGNNIa0uBjd4LhVaM86Ok2VnWrI1ilzq2QeFgKg5laJXvpxxcFuX84OSNVKvs/q/qprYNbm0i6w/k4u5Ie8LuCUm9TjiONAUAfb4AB07VET5LETvMglFiOqJqBHmzQcmJivU7y8KdpcEBYWuAyTb7NofVetu4NfqA== 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)(376002)(346002)(136003)(396003)(366004)(39850400004)(16526019)(5660300002)(1076003)(86362001)(52116002)(44832011)(66476007)(110136005)(6512007)(55236004)(26005)(186003)(8676002)(66556008)(316002)(8936002)(4326008)(478600001)(921005)(1006002)(6666004)(2616005)(6486002)(54906003)(6506007)(83380400001)(956004)(7416002)(66946007)(2906002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YW3ka87G+OIqW5D0ME4C++7kncW9vzgN5mPLgD0Of8FZdK9kNh2r1+pHATJI2aieZcm0g7XiTtPtj3WBbvzMGfiJJCZ9rAp6m+oAc6WpYwN5qes8CSYHgad5Ge16Fi61+64qU4WxZHDkMLEjYrJu9UGizEbKSJfhbjpBB8pVYFxwssKo3lOaVJgvV4xJonsj9ABsgIPeABoAgIRx1QRrZnpU6lPkNgn6vdIqO6eTW6Lw9XerdJ9Xl1800eIuzDZPJaAEUyRYlOFiPgkVwd5hoYkK3WSKWr5bMF51LErh2cKRC6ZniK5P4rtBc6e90j3hJMZefbi0OPJSDV9o2H/ncioRoTJ1uAG9DlsHa1RfNKlxXpY7lEoim/vYgYJxs388hidefJs4IQWJP8XxdNnoLNdUMb4lqnezH+FOQmyHz2YbPeINxAeEByUOo4OjJKLmLyNOVc/efdQkCgpLDZLrMqh2UzSLhSzZlKFd4U45YvCoErGwpYcsVtxQdCHv4tNm07hsFNPuV7BThvXFPWg4K5ZRSphAtVMQ1FEWMVbPYTur/bMClCOTeFzNyPL6NNvW7q0qQWOZSBkEQDsi2t5Kzs7MvIZh1/wDzpMEiuwZNDKJ7v3FwyotC4z+5hyYXNGDyK+cKR+pkcEQuS6HbVbwvYzDVpD+qT/8V5DI8KnpjEiDTnheiyCv0KlB/sgWSyjOKZzzr6Yhx/EH6pyO5p+qOM6CdxxsQZCum8XAFtAt48ax2SFNJy5ZpmI9RmDP8D8XNi8tw8XrT15BRpB7sPnPQIceEKMAzsqNxOQr/bSHBddDucBIvcsjiddTGFbRwEEhl/DbT9jVsYzN+AiDj68xuwS5uFP4FphhFrXrGZ9n5IcjnrVVVTJ6vtJkmK/3KnAh9S6ucTlCke7pC8xA6XpO4fUv7r+KuX1Bw/7DWcXKIHrh6cdvdI3ZIIKxo36WQYiaVsrs+fKuql0W9Z/AWI+eCoeGVMnBkbOj6KKUIGk8zQ1oKUTw7FWRsxcGo7NucnZ/ 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: 12 Jan 2021 13:43:22.8834 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 7036a4cf-cf97-4617-3556-08d8b70007ac X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: suTfehhwn0f7XDQsClMU4CKPCv7qOe3y1dAN8ZUK0hmME+1+CNwM0YqiIs5ZOIL80Yf33L/ymaMcJJCVEyWzTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7937 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 v3: None Changes in v2: - Refactor OF functions to use fwnode functions .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 87 +++++++++++-------- 1 file changed, 50 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 69ad869446cf..2aa320fd84ce 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) @@ -221,26 +232,27 @@ static const struct phylink_mac_ops dpaa2_mac_phylink_ops = { }; static int dpaa2_pcs_create(struct dpaa2_mac *mac, - struct device_node *dpmac_node, int id) + struct fwnode_handle *dpmac_node, + int id) { struct mdio_device *mdiodev; - struct device_node *node; + struct fwnode_handle *node; - node = of_parse_phandle(dpmac_node, "pcs-handle", 0); - if (!node) { + node = fwnode_find_reference(dpmac_node, "pcs-handle", 0); + if (IS_ERR(node)) { /* do not error out on old DTS files */ netdev_warn(mac->net_dev, "pcs-handle node not found\n"); return 0; } - if (!of_device_is_available(node)) { + if (!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; @@ -269,13 +281,12 @@ static void dpaa2_pcs_destroy(struct dpaa2_mac *mac) int dpaa2_mac_connect(struct dpaa2_mac *mac) { struct net_device *net_dev = mac->net_dev; - struct device_node *dpmac_node; + struct fwnode_handle *dpmac_node = NULL; struct phylink *phylink; int err; mac->if_link_type = mac->attr.link_type; - - dpmac_node = dpaa2_mac_get_node(mac->attr.id); + dpmac_node = dpaa2_mac_get_node(&mac->mc_dev->dev, mac->attr.id); if (!dpmac_node) { netdev_err(net_dev, "No dpmac@%d node found.\n", mac->attr.id); return -ENODEV; @@ -292,7 +303,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)) { @@ -312,7 +323,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); @@ -323,13 +334,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; @@ -338,7 +350,8 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) err_pcs_destroy: dpaa2_pcs_destroy(mac); err_put_node: - of_node_put(dpmac_node); + if (is_of_node(dpmac_node)) + fwnode_handle_put(dpmac_node); return err; }