From patchwork Thu Jul 9 17:57:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1326102 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=VU7MkBbz; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B2kRZ2dvRz9sRR for ; Fri, 10 Jul 2020 03:58:02 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728497AbgGIR6B (ORCPT ); Thu, 9 Jul 2020 13:58:01 -0400 Received: from mail-db8eur05on2077.outbound.protection.outlook.com ([40.107.20.77]:27872 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728442AbgGIR6B (ORCPT ); Thu, 9 Jul 2020 13:58:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dyt3YrhxREu1kBjAsQfSs1at079uR1iOoO80JgLWzQb3q8nOHZx9wXqJ6831k8uUSlB9VGXRDbzYF80Xg+sm00WzjVbcf2MVkSI0ZcDS3Wru4PqKI9kYi//+znklRCkZ6i4lAguE351WgZrsSpb4gnqxuZ9n4kCew5KCXLInP9IfosXbz9zA2V0MflzzKqkHD61lorvs05VySr8jW6kRPLbTMt/O77ABuqFRT3+gcK+zLqBbKT/GmU1Cxm6+3ahlGanudrfAGlGfpydFnmo/JEoqgGdfOn0ZCutSYgiLpy/2mCstPCly5zof4BJygb69sXzRgKLKoZkAmXaYDfAdmQ== 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=IWmHZJSc1YyebAZEHJKHiy1Xi2FWngIbcOZ5SgJIbmI=; b=c9+51X1Zoi7Pq6U8OdSz03rT9LOom+u9SbjQdEYDzka8P6PjxzMAmR9G1BOPmQ7Gx8vcmC5Ceh3sa5FHxtx02iFKAmGpdXrzqnCS2YlF/1qHYgRgRt7kxKjiumWAVJ8im9j8fYZWw68vm2Gsz06mgcyO+mzbVxEvmuMXCiTG34URWtZ9hKfN1gpQNGCY6SrFAOQ3U7PxfgSG5lkmZINRF0UZTLWeng+gTxF1gnQhJ2IFo/1rlWKGzvUJPUB3OCcFmzMWaLicDb1MWiA9TjoF9h3Kz8y+FWDvMPp12mlvlKlr/KqJYIKEOxaORsIZGENxve6zYfFBquBXBldFOsu1nQ== 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=IWmHZJSc1YyebAZEHJKHiy1Xi2FWngIbcOZ5SgJIbmI=; b=VU7MkBbzjD1C7Rs+vQVRss4r8oBm0YPqmQtW7P0n47DLmXQBzYWfyuFi96jOx+Pg/XuuzSxn7FdIkknCnZolARVl0zf0VjZJEYH6eUYZwFgCojjcx481EOK0X37kXy2mKU4KmlPtxTp1PgGmqoTGp7hCRkDz5y06KfKJ2Cnz6J0= 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 AM0PR04MB6898.eurprd04.prod.outlook.com (2603:10a6:208:185::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Thu, 9 Jul 2020 17:57:47 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.021; Thu, 9 Jul 2020 17:57:47 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: linux-acpi@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v4 1/6] Documentation: ACPI: DSD: Document MDIO PHY Date: Thu, 9 Jul 2020 23:27:17 +0530 Message-Id: <20200709175722.5228-2-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> References: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) 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 SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Thu, 9 Jul 2020 17:57:43 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: efbe856b-0d50-4c66-7c33-08d824319685 X-MS-TrafficTypeDiagnostic: AM0PR04MB6898: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UQNkIsgp0YZb0fiPzzRVR+yqyl9NL0txLRgbtDMhtgZSgmqdRoq6yXDfkjfGCnp/fB22DnnVmySlYwnVJbN/DE4BoIvquH6vWreFZNBKBzTAYPkDcatKaEfRHtmxZfZAucw23ZzcpKLNUXmn6ZEuOwxiP2n6t2IYmyU98ayyQ5ROMugULz5+Y2pXO1iOvDURlmSGmRMvbWcRK2KXJZ9FzXiBkC2+TK9jQFqA08UIJueB3fNsR96aIguf9Hh1nEpj8IlYdxc5dSeUDNMWkOv+t+swqJQhmEssTFtl+pKdGjmZ4Tc1Zq3BRld54MqNOyYILgrmrCy3dV4OoDs8zoR8FI/16wLUbPpOGSpmySyno2I706os2aQMRRV2vHw7xIQ1 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;SFTY:;SFS:(4636009)(396003)(346002)(376002)(366004)(136003)(39860400002)(6666004)(44832011)(1006002)(8936002)(2906002)(52116002)(2616005)(956004)(110136005)(4326008)(316002)(6512007)(66476007)(8676002)(66946007)(86362001)(66556008)(6636002)(16526019)(26005)(5660300002)(478600001)(55236004)(6506007)(6486002)(186003)(1076003)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: KKL3hL0YB9XcQo67yzHth4KpJNsTU+MMA+cAuWY4a+VZVL10jlpn+vR9p1VWYaqGQY4gFwH1fhyzfuWG4AD6lCTLlAFH604sMtfdCt4LTV0Je6uFxlAAj711MC4rFu6a3ZK/ub89L1CDE1ZA5QuvAhaafX33O3vmK5/cp7JLJdeynxnI7GoU91mqr4a6N7O7wR7grMHM+PrVHD8TCeZLO7g0C7Rm9ct2Fyus7urfPHlxfKbfIjoOvPsDMLnBYHv6OjJIKQNaqeyQz3F9xX5E5Q2Ckqil2OLOhtBEyKVZqRu6wGUUspsMvfG+WMXmqb7LoB9TnUE1IYZpyUAhFz1OdOgeZ0DlVpjaabmLKG+Zsu5SsV/hh97pMuk5rVgKsdPsWKtqLvCvbz1s+kHP6gbrEdnxIW+WsKjCOJ/LZtijmvPAvPyiWOQ3TV/lF+1/kTDlNg95ldPA9b1p2sHRiYpGSXoa7O2FHKH4gOScVp7K/Fc= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: efbe856b-0d50-4c66-7c33-08d824319685 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 17:57:47.2072 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: O/3bkz/9iyNGE0hMd0vlwJQTZyIUw1v3AEWhoW38y2ex0sZDcXj9Di9YcQumRIAMkubanWluf5+Aoox6fsbaKg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6898 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce ACPI mechanism to get PHYs registered on a MDIO bus and provide them to be connected to MAC. An ACPI node property "mdio-handle" is introduced to reference the MDIO bus on which PHYs are registered with autoprobing method used by mdiobus_register(). Describe properties "phy-channel" and "phy-mode" Signed-off-by: Calvin Johnson --- Changes in v4: None Changes in v3: - cleanup based on v2 comments - Added description for more properties - Added MDIO node DSDT entry Changes in v2: None Documentation/firmware-guide/acpi/dsd/phy.rst | 90 +++++++++++++++++++ 1 file changed, 90 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..0132fee10b45 --- /dev/null +++ b/Documentation/firmware-guide/acpi/dsd/phy.rst @@ -0,0 +1,90 @@ +.. SPDX-License-Identifier: GPL-2.0 + +========================= +MDIO bus and PHYs in ACPI +========================= + +The PHYs on an mdiobus are probed and registered using mdiobus_register(). +Later, for connecting these PHYs to MAC, the PHYs registered on the +mdiobus have to be referenced. + +mdio-handle +----------- +For each MAC node, a property "mdio-handle" is used to reference the +MDIO bus on which the PHYs are registered. On getting hold of the MDIO +bus, use find_phy_device() to get the PHY connected to the MAC. + +phy-channel +----------- +Property "phy-channel" defines the address of the PHY on the mdiobus. + +phy-mode +-------- +Property "phy-mode" defines the type of PHY interface. + +An example of this is shown below:: + +DSDT entry for MAC where MDIO node is referenced +------------------------------------------------ + Scope(\_SB.MCE0.PR17) // 1G + { + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"phy-channel", 1}, + Package () {"phy-mode", "rgmii-id"}, + Package () {"mdio-handle", Package (){\_SB.MDI0}} + } + }) + } + + Scope(\_SB.MCE0.PR18) // 1G + { + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"phy-channel", 2}, + Package () {"phy-mode", "rgmii-id"}, + Package () {"mdio-handle", Package (){\_SB.MDI0}} + } + }) + } + +DSDT entry for MDIO node +------------------------ +a) Silicon Component +-------------------- + 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 + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"little-endian", 1}, + } + }) + } // end of MDI0 + } + +b) Platform Component +--------------------- + Scope(\_SB.MDI0) + { + Device(PHY1) { + Name (_ADR, 0x1) + } // end of PHY1 + + Device(PHY2) { + Name (_ADR, 0x2) + } // end of PHY2 + } From patchwork Thu Jul 9 17:57:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1326103 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=FkMGwFO1; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B2kRd2M5Dz9sT6 for ; Fri, 10 Jul 2020 03:58:05 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbgGIR6E (ORCPT ); Thu, 9 Jul 2020 13:58:04 -0400 Received: from mail-db8eur05on2077.outbound.protection.outlook.com ([40.107.20.77]:27872 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726758AbgGIR6E (ORCPT ); Thu, 9 Jul 2020 13:58:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DWsrxFoK1RS/SihpHc4/9wD1q1zCEiDw/EFcOYCYezPvhxGawyMreya3K+iGymzPeucfQ6iw0j7pdnmwoV+oBnPw+HacHmbKuAkZvCHf024zxKVWR13yiO2MR02ZB/81gjsEAQNAuJRQgN32xedBiPrEW5ZjtyDBy1AK6eq3cmGqCXsQOCbSwo/JWh2o+jn6R6mdyZZPajvsymhPPQe3vDBxoIv1PjN7dIHPUnE31LtKRMX0TX6KtdfT6hQeaVCrUENwnnxw6kCruQ46ULndIQhJ1nXH5S2Wjt0G99pyu0c0SDaaKmfOX3s8DVtFrh8n6Mcu/82AiUnCTZifIb5Jpg== 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=Bk9p6H8qNbcCUkvmOrxI5CZ3cWq403VPhMDFnqXj33Y=; b=PPVt8yb3Sbau1WqZt5IKLXxHoob0mAPWM1+BFzisnYpmjYuv1Ws2TzWlp4kMwzUeDtBd6mm85nCd4okyeHKbqUgXgae8l/tbolXdkRSSgdyKvK/9ohj5ymWlGX6CNgpzIi1oza82rxzF2GG2Zknax2V8RrerHSA6BhUwXYL9JPmHt9bAns0siXFFCCoVtCNYFrUzrhKFYf6W1xxHCaspqKVbMP5ORxvmSA1gMIaYl1Rtn1Ab/pZ63j/w1U1/UYLbJzJxrKFs3g4wmx1+EpJHeQmje7PJ7Qa6u7QQoqwmw8A9/KsyRWt58g7iueG1yYrOpkA9L3AdA0yNpgRxEGTo3w== 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=Bk9p6H8qNbcCUkvmOrxI5CZ3cWq403VPhMDFnqXj33Y=; b=FkMGwFO1dvMT8scf8CGkZL3B319h5ecSO6KcezqgY+SZTVBwbnuD5FOIxxCEuQiHnYnRIXsBx7j1drVlDpv/5euLzv1QxVULUjg4lRvtxxpKqpTfj9+OiMr0y/Mh53tyPsFh3mP2PIcM9mE/RvOSYCX0nY9kKg5gGBFrqq16zRU= 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 AM0PR04MB6898.eurprd04.prod.outlook.com (2603:10a6:208:185::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Thu, 9 Jul 2020 17:57:50 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.021; Thu, 9 Jul 2020 17:57:50 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: linux-acpi@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v4 2/6] net: phy: introduce device_mdiobus_register() Date: Thu, 9 Jul 2020 23:27:18 +0530 Message-Id: <20200709175722.5228-3-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> References: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) 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 SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Thu, 9 Jul 2020 17:57:47 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 19c04bef-a3ed-4876-52cf-08d8243198a5 X-MS-TrafficTypeDiagnostic: AM0PR04MB6898: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mO0T9M9WxpR09pWOyVvz1mkuSo+LEJmoQlaH7ZtrXl0+cuL7uNVs+xEMK/x/LOH3ilkBY6g1UfnID84xzpHff79aq46ivlNsH4jN2uEPHtgNiZtNPnbpXDWzAFTnKBkbjd0WS37BP8piuiencQAS0j+PCupO40IK4X1PZIFb5FeYcQ8JmxLwyPjyFvmH7ggQBGeS0Nbtk3nqK65HmZdBSqQ83chsYRj06tFxwCEn8h/LsQv+8RRbDv2idHzlnz08g86hkl8oQMqYnOzvMjvijxMh+0kjCvzxqzHbu+2uJcLEnxXcJG0M3bAQkI254K+AMNKmZbM+uvsOwc9FZAU6qU4QEvW46ACdg4AQw6cnbZy9iLECqjGK2MBHoiZhkEv8 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;SFTY:;SFS:(4636009)(396003)(346002)(376002)(366004)(136003)(39860400002)(6666004)(44832011)(1006002)(8936002)(2906002)(52116002)(2616005)(956004)(110136005)(4326008)(316002)(6512007)(66476007)(8676002)(66946007)(86362001)(66556008)(6636002)(16526019)(26005)(5660300002)(478600001)(55236004)(6506007)(6486002)(186003)(1076003)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Z5UaiH+iHAB2xJrUQEJF6m3Ty6tbBach7vIAmertpwmu6USVyysYojuvVro97kdAREJSpegWHxn1h5vnDmjCVhhjxC8jfHnP9m6FQl2bLuTQyGS41vb+o9kINPGYDWfIno5S8BPBaJ/hpzqyJjMiGtrpLrUv/9RGGZO1DIpCsSB6k4SR9JLYm4UyJZdy7pgDt4Jh8Uk9tZDo4bKSSpmo5jpiUvmT+qL+UxvSRMXtr4EFhJ7UdfMhWUfWGuAw3Ea88A0gLQ15qKn5mSlz/AcnOhmpHTr2D7mHuvyHfVIqANdwZIDKjMN3+rte+rVeZdojpOyS4oeeN1x25GOgaDtbRn/Jckr/WaGdEtrZPeehbQuxDLecs+vBcnmYd65ZBciwGl6fZz6OfWCg7qXTOmoxwY+93bi5txbLF6R9zUO1H93WrteBkDYNKSagAkJrLhilFMZ+8X17hqXx693MRwR9gwfbB5QVBKK5umrr2zTvNwFvIQ28uC+kf9ny3sdPP2YE X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19c04bef-a3ed-4876-52cf-08d8243198a5 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 17:57:50.8822 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iTNSZe8hea+cTCFeGcOxMI4mAZ3aJfwznOwXz84VBMGt6c1NhkRfi8xjbqvCTQLqFK4+aw9keEYl0ZYamuMW7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6898 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce device_mdiobus_register() to register mdiobus in cases of either DT or ACPI. Signed-off-by: Calvin Johnson --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/net/phy/mdio_bus.c | 22 ++++++++++++++++++++++ include/linux/mdio.h | 1 + 2 files changed, 23 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 46b33701ad4b..3c2749e84f74 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -501,6 +501,28 @@ static int mdiobus_create_device(struct mii_bus *bus, return ret; } +/** + * device_mdiobus_register - bring up all the PHYs on a given bus and + * attach them to bus. This handles both DT and ACPI methods. + * @bus: target mii_bus + * @dev: given MDIO device + * + * Returns 0 on success or < 0 on error. + */ +int device_mdiobus_register(struct mii_bus *bus, + struct device *dev) +{ + if (dev->of_node) { + return of_mdiobus_register(bus, dev->of_node); + } else if (dev_fwnode(dev)) { + bus->dev.fwnode = dev_fwnode(dev); + return mdiobus_register(bus); + } else { + return -ENODEV; + } +} +EXPORT_SYMBOL(device_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/mdio.h b/include/linux/mdio.h index 898cbf00332a..f78c6a7f8eb7 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -358,6 +358,7 @@ static inline int mdiobus_c45_read(struct mii_bus *bus, int prtad, int devad, return mdiobus_read(bus, prtad, mdiobus_c45_addr(devad, regnum)); } +int device_mdiobus_register(struct mii_bus *bus, struct device *dev); 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); From patchwork Thu Jul 9 17:57:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1326104 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=jmgPFLSr; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B2kRh3Sm8z9sSn for ; Fri, 10 Jul 2020 03:58:08 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728528AbgGIR6H (ORCPT ); Thu, 9 Jul 2020 13:58:07 -0400 Received: from mail-db8eur05on2077.outbound.protection.outlook.com ([40.107.20.77]:27872 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728442AbgGIR6G (ORCPT ); Thu, 9 Jul 2020 13:58:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pz62C+sX0GKUKhRvdY4+51GVQLhLhLc9/0Ceq/w5cTao+/kA69XIZ5Y2FKURKTGXA90+5+QUWZHWt7pDTB7UMuoUAQ7xhXK5by1SuumghSgeas8Z1+lP/oxjZqAGp6pmiMnnXlZ9ioRPw3a1r6Gg7u6dzOpdKbb8AaLt+6dSUnzgr8JKBB8DJ7QYwVmcf5xZ0Oc/ixwYAXSy+GTZ+Qv3aOkBycihFs+pes3Sx22QPZWCUy/ixXBNHg5chzWUe/GQXdZxfiqlhwJhHvk95D6aOl9eYLqOwTz2Rpl21cFd41Y8ZARZvuRLJyytH6O54v0P5CDuP8HRAK1wobk0ByLVQw== 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=75s6VZEwt82miux0ZDgs13j2jIZivF+xUAmUbIHZQKE=; b=CAPv9RYewxhHQQeVeaLtYJyTf9vik2cFDe0YK1CPBdHrWoBp66prrX4ITzw1ZI6yrpAmQeBOo5bJF3dq85MmFDN+9S8dkow1JtJjqp/zaMfxfFUb2aAEJCIVjxWF/eqSoSyjZvLxZUh8Mb7h5ZIpSRBY9OAuDrRs9PMXVRu4gT5Ivv9KzJFD4oRjzQ+dizLhcO1/kDEGVceCAsPpYlFKzp9waUWyHMvt+kRSNVlvoKji+fHpzGn8liZSslUOB0C5wQR/7vR3rSIe2t+mDu8NHnltVPdLYpL2Ba+WPKUU92lX1icSgdxozj7KXpAkrL7s2iVCSyFRF6de5DiSDbhhGA== 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=75s6VZEwt82miux0ZDgs13j2jIZivF+xUAmUbIHZQKE=; b=jmgPFLSr8aJxT0goe7U81MaJ3e+sMDxMSQQLZr2bmqON4f14wccnVRPWlbrR88MVBloazUqUHaItrfwTYuRaI/ajWcIDanfJoCUt+LxCjVNuU1eSzwY31xOObmO9siao54M/qdXyjtSkmUpKRb7KceafMKGrmVFmF/a5SVHTcl4= 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 AM0PR04MB6898.eurprd04.prod.outlook.com (2603:10a6:208:185::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Thu, 9 Jul 2020 17:57:54 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.021; Thu, 9 Jul 2020 17:57:54 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: linux-acpi@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v4 3/6] net/fsl: use device_mdiobus_register() Date: Thu, 9 Jul 2020 23:27:19 +0530 Message-Id: <20200709175722.5228-4-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> References: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) 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 SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Thu, 9 Jul 2020 17:57:51 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1b9f1e5f-dd6f-4eae-3498-08d824319ae3 X-MS-TrafficTypeDiagnostic: AM0PR04MB6898: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2089; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3B74TNaQNKsbElVj5LkO/wrUNluwuIdDuM7wgiyvxsblEk8V/FJpK0rZDfans58aLBH0ascl3UR4I0kt6jsckkYgl5KrpjuN96u7Do3a4pEB4vHMbGfgcNZ8AMBvFeDoHEOJMKtfOOCp3x6vy9pEAHxgNS+K1DMvPDmESBa+wWVGO+H2CYc/Ihy6ifB2dRd9v2kY+OvFa6q2ZvJ1pRSTIJRUAoUJWhlamYF+HDihpnsR171SIxsuJPn2RMG0WAHVTYuaASY/QekGY92z1kWUrPjNBpYSMuzWjFWKJL2O4Y9fdtMWu6oXBZ8N1jJBd9oAHwDAZ1slCftmKNedHTN0nJfV3sdWpqDgc3Rk2R9gToiDy0RmexjhFn4ZsM2Oh91d 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;SFTY:;SFS:(4636009)(396003)(346002)(376002)(366004)(136003)(39860400002)(83380400001)(6666004)(44832011)(1006002)(8936002)(2906002)(52116002)(2616005)(956004)(110136005)(4326008)(316002)(6512007)(66476007)(8676002)(66946007)(86362001)(66556008)(6636002)(16526019)(26005)(5660300002)(478600001)(55236004)(6506007)(6486002)(186003)(1076003)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: yXY1U+0OPEEx9suNvJyi9f5Y1j/wNlHQBJpuLA8T9kzMzsS/F06a8Pz54e77dRVasCh6/esS9y+fwADDSTQP5YYOm0ZESdEcu001JgkD3qAHh0cFvEREmsBMbKQpnpMp/mdBt9YafBB6bCQzr96T0bOik8iK0cZpy15usCARpsELuuDSDcR+s7sEDkE5eNbMv1Hnj5dnLztqsd3A5qjLeU6DJdsb333J1eK5bIR9v3I5NAj4Vg5zEV28vLEVAYgmU6XTNoAAT17fTd7FU36jRbYKpU3VGWzM72h2C+5SgmjXwLlt9uqQtdjCZweP7NTyaShPgOc70U4ULEMGC6PjyP0NL/eZUn29LqFnovypbip+I5kUOuE9BOxiDoUwmK4CdkiFgIjGQuPaAjJzvyuVdpF9TMbuKFLSGvmaUAF4XOR7sj+yPeTyT4jvrEMkPgBc3u2jjTUjvZq3bD1nHDxyMPzZP8ZowQ36VEXSgbkmCCE= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b9f1e5f-dd6f-4eae-3498-08d824319ae3 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 17:57:54.7581 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TMTbWTqrWUKH/6y/uKHtdHCwvWQMr68ddDOqT4ZeqhAsi7XdYXgtpDaWRsxGsbFcMRkCPFgJMBoPcxwMLgHCnA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6898 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Replace of_mdiobus_register() with device_mdiobus_register() to take care of both DT and ACPI mdiobus_register. Remove unused device_node pointer. Signed-off-by: Calvin Johnson --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/net/ethernet/freescale/xgmac_mdio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index 98be51d8b08c..51a77a29c563 100644 --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -243,7 +243,6 @@ 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; @@ -285,7 +284,7 @@ static int xgmac_mdio_probe(struct platform_device *pdev) priv->has_a011043 = device_property_read_bool(&pdev->dev, "fsl,erratum-a011043"); - ret = of_mdiobus_register(bus, np); + ret = device_mdiobus_register(bus, &pdev->dev); if (ret) { dev_err(&pdev->dev, "cannot register MDIO bus\n"); goto err_registration; From patchwork Thu Jul 9 17:57:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1326105 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=b7+2jgTQ; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B2kRy0Rhxz9sRR for ; Fri, 10 Jul 2020 03:58:22 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728542AbgGIR6V (ORCPT ); Thu, 9 Jul 2020 13:58:21 -0400 Received: from mail-db8eur05on2077.outbound.protection.outlook.com ([40.107.20.77]:27872 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728516AbgGIR6U (ORCPT ); Thu, 9 Jul 2020 13:58:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K47VKwfG5bqSWQNLbeEbeHg6VHbIrlI0WiXscyz8rf5FkQUEJlzojKSqD4IUQcMrmDGO8fPHR1Sp9DsFDxzJxjAQp7wa57UmPRgmSU4pVxtfv0gF8H/xNWJjmV5Bq9aBgzTvTxfFhvO22tX+DXbxhYrswnDqq1aCmp6dYRoShkH/YmGjMK+9wxKkNyIjxs6zVjs8OHTwTCuhf+/ZScfZaRL+PjM7SOpV0p4VU2yTBu83vdY+A2KPaBnQS+nhQcyvL35DR+KMCYCEqIcwQRgpul+wK+d4ELTfKlltc+tF3hc/+6lnKLb7I4WsFPhjsrW2+nb7CjfKVY0Dc6bbG/3o1w== 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=XdRg6sR1TUq43RIrXNFXsG3dBFGKjBg/B00Zc+zjA6U=; b=IBgJgtaX+IOBQNjXl9/ew/cpjvyym5deCGHd8gG72Z+iHTwN338B2lBmAFcGXKDIzxmGWghNE8k2ZhLiY8jPFCdonsTwzDw/G9Qe4DLrH2HvJikOjwCOg+SxxOGDAcj5KfIDCr8l/WQ3ZQlIBq8Z4hOFG49pJUA0HTDXdRved0WmYQciYE349+jTV1cQj1w9rrTfgMfpz1OEQRjA6D7t3+f3G1HXf9elCY6DYoK3jcRO+IO0ovSQRJ7pUT4cjrhLLIWTH6qcutjt5DwpXy6m4jsivyo1azpuLq4XBfLtE9E71QFfxg+iOPGaM/ICijVi+hYn5dyUprqTf5+Q5CATMg== 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=XdRg6sR1TUq43RIrXNFXsG3dBFGKjBg/B00Zc+zjA6U=; b=b7+2jgTQWzJHHyYygqrugrx9X5LC+huCmAqEbOEhd98qKIPizuRhaSqi9qaAaK5NtQvT9BQWFDXwjBQjTLDWqG2IEwg2xtK6zKF7qr2s9QrxBGOMHg7P5q2F5Ko78KRP8EO7EdpWlYxLdemLHaxZfrJjjm+10cIBWk5Y28pgGp4= 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 AM0PR04MB6898.eurprd04.prod.outlook.com (2603:10a6:208:185::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Thu, 9 Jul 2020 17:57:58 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.021; Thu, 9 Jul 2020 17:57:58 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: linux-acpi@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v4 4/6] net: phy: introduce phy_find_by_fwnode() Date: Thu, 9 Jul 2020 23:27:20 +0530 Message-Id: <20200709175722.5228-5-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> References: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) 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 SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Thu, 9 Jul 2020 17:57:55 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b175964d-e87c-4ac5-a98f-08d824319d25 X-MS-TrafficTypeDiagnostic: AM0PR04MB6898: 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: IwPkTpR0jntUya25Fg+DyHXK1YE1zXMsDmuZ3zWU/BiZUKxQ7AVuYJqCzBDC1aUm/L3uI+ykaQg9RQM/s/qxq5aFJrqtRbXV+EERLbmOZnRyhXWWf201vJ8d5uHOVFjh8PS/ykDkf5T71v9NijgFxXDLeBDd4J6kxT/Te8dkzPKsVSIIo6cCC2QVE2Bbp3PT+Tk+aammKM5bFi/SZxN1xYQQ7QJFJAFPdIWFVhIAukbAx8E1gCL68+4gv7QYU+x1ul/nijnIDJq3oJ4tw60FSTtT3FMisFPvemNBrgkISYWK+6Qa4qhDC2MqzKGYQk9fJyrfjhMI0zu/LZBucFibJIfGNw+U0kiMeZ3MVHC2XLbVgklMhJPuzrUj5lHjMuB+ 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;SFTY:;SFS:(4636009)(396003)(346002)(376002)(366004)(136003)(39860400002)(83380400001)(6666004)(44832011)(1006002)(8936002)(2906002)(52116002)(2616005)(956004)(110136005)(4326008)(316002)(6512007)(66476007)(8676002)(66946007)(86362001)(66556008)(6636002)(16526019)(26005)(5660300002)(478600001)(55236004)(6506007)(6486002)(186003)(1076003)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: I8Xx/41kJ2OyHHm6eeI74Soz8RshPjpI2ciR6BUJ2UbSzogL9/36GzU8FS1eOmit+lAYLJtcJZUUCjkE51GvnmnDu4hTqSObNMHbKB69ZhgMp0eUSdsfmct7Ct6p667+KgujW1iickx9KFDXYi6q3sgLKsCCv98li6c+UaKqWfpanSjJcGVKHUxu67CbPSt5MVDCVbCVHjpkplrgTvCjPtc+j9xBDGYrPc5FXRGD+Y/7B/i9sKtw2voVLJHBePp47KS9t1QPLhyvEzsfqLhmVpn7ytY5+awwxfKeUboWfPlOWl2WM334qnZGcleCE+OatDVgUn/rJ+GvwBXWGMmAdvUgpcaXq7+A1Ulznc3MsHKY5RLg6GTx9RrTarMSJi0aIpUjQxVaV7JJT2BCiCXzFqtY7vYc+wgjidwrDaBEkRqayWIx3rDL/s8+JZ4gJRAMfSW6P7K8strp4dzwyDtNbsa4RXeRM2/Kd79yfq0zNNc= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b175964d-e87c-4ac5-a98f-08d824319d25 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 17:57:58.4002 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kaR136Qv8FzwyekbwdBDkF4s2yElf0UKGJHZnkNUtjUFQnrfTGJVg9fOysP0uTGEFZ/U1kcZa1dcOzkhLLMFyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6898 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The PHYs on an mdiobus are probed and registered using mdiobus_register(). Later, for connecting these PHYs to MAC, the PHYs registered on the mdiobus have to be referenced. For each MAC node, a property "mdio-handle" is used to reference the MDIO bus on which the PHYs are registered. On getting hold of the MDIO bus, use phy_find_by_fwnode() to get the PHY connected to the MAC. Introduce fwnode_mdio_find_bus() to find the mii_bus that corresponds to given mii_bus fwnode. Signed-off-by: Calvin Johnson --- Changes in v4: - release fwnode_mdio after use - return ERR_PTR instead of NULL Changes in v3: - introduce fwnode_mdio_find_bus() - renamed and improved phy_find_by_fwnode() Changes in v2: None drivers/net/phy/mdio_bus.c | 25 +++++++++++++++++++++++++ drivers/net/phy/phy_device.c | 22 ++++++++++++++++++++++ include/linux/phy.h | 2 ++ 3 files changed, 49 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 3c2749e84f74..dcac8cd8f5cd 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -435,6 +435,31 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np) } EXPORT_SYMBOL(of_mdio_find_bus); +/** + * fwnode_mdio_find_bus - Given an mii_bus fwnode, find the mii_bus. + * @mdio_bus_fwnode: fwnode of the mii_bus. + * + * Returns a reference to the mii_bus, or NULL if none found. The + * embedded struct device will have its reference count incremented, + * and this must be put once the bus is finished with. + * + * Because the association of a fwnode and mii_bus is made via + * mdiobus_register(), the mii_bus cannot be found before it is + * registered with mdiobus_register(). + * + */ +struct mii_bus *fwnode_mdio_find_bus(struct fwnode_handle *mdio_bus_fwnode) +{ + struct device *d; + + if (!mdio_bus_fwnode) + return NULL; + + d = class_find_device_by_fwnode(&mdio_bus_class, mdio_bus_fwnode); + return d ? to_mii_bus(d) : NULL; +} +EXPORT_SYMBOL(fwnode_mdio_find_bus); + /* Walk the list of subnodes of a mdio bus and look for a node that * matches the mdio device's address with its 'reg' property. If * found, set the of_node pointer for the mdio device. This allows diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 7cda95330aea..97a25397348c 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -964,6 +965,27 @@ struct phy_device *phy_find_first(struct mii_bus *bus) } EXPORT_SYMBOL(phy_find_first); +struct phy_device *phy_find_by_fwnode(struct fwnode_handle *fwnode) +{ + struct fwnode_handle *fwnode_mdio; + struct mii_bus *mdio; + int addr; + int err; + + fwnode_mdio = fwnode_find_reference(fwnode, "mdio-handle", 0); + mdio = fwnode_mdio_find_bus(fwnode_mdio); + fwnode_handle_put(fwnode_mdio); + if (!mdio) + return ERR_PTR(-ENODEV); + + err = fwnode_property_read_u32(fwnode, "phy-channel", &addr); + if (err < 0 || addr < 0 || addr >= PHY_MAX_ADDR) + return ERR_PTR(-EINVAL); + + return mdiobus_get_phy(mdio, addr); +} +EXPORT_SYMBOL(phy_find_by_fwnode); + static void phy_link_change(struct phy_device *phydev, bool up) { struct net_device *netdev = phydev->attached_dev; diff --git a/include/linux/phy.h b/include/linux/phy.h index 0403eb799913..a2ec1c288db0 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -334,6 +334,7 @@ static inline struct mii_bus *devm_mdiobus_alloc(struct device *dev) } struct mii_bus *mdio_find_bus(const char *mdio_name); +struct mii_bus *fwnode_mdio_find_bus(struct fwnode_handle *mdio_bus_fwnode); struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr); #define PHY_INTERRUPT_DISABLED false @@ -1245,6 +1246,7 @@ int phy_sfp_probe(struct phy_device *phydev, struct phy_device *phy_attach(struct net_device *dev, const char *bus_id, phy_interface_t interface); struct phy_device *phy_find_first(struct mii_bus *bus); +struct phy_device *phy_find_by_fwnode(struct fwnode_handle *fwnode); int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, u32 flags, phy_interface_t interface); int phy_connect_direct(struct net_device *dev, struct phy_device *phydev, From patchwork Thu Jul 9 17:57:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1326106 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=FOc46dYj; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B2kS11mC2z9sRR for ; Fri, 10 Jul 2020 03:58:25 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728556AbgGIR6Y (ORCPT ); Thu, 9 Jul 2020 13:58:24 -0400 Received: from mail-db8eur05on2077.outbound.protection.outlook.com ([40.107.20.77]:27872 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726758AbgGIR6X (ORCPT ); Thu, 9 Jul 2020 13:58:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e6fUIXrxTWhEvqZNA6ZgTf9RUZZg3gbMTu2aP1cz8rIB72rlOUiop7K496uJNzxHFyjwDxtZDPzqbN7bE8GHLW1yHXYPz6LHcIPEk23HTc1/1u0oV3dgUOIfOoZWZ71+1rbA1Tqm7CuPS3yhN27gWNDJYFFVaXBKhxm7vyHejIv2uuH4POYdcgTUinr7iB2slZlxRAKuHuXvYjoiMdAqBJhCNL0/HwBNufdRj1aYdsQpzj5v2YWu1tE/ItyMTuuvIJLe90lbsWrbY/mzLrHWteBd37PFsCLjt0ZeYzmSqSuP9IDNnG2SHnnnND2OMxn4aWnZBH/oUO8iCd0hTci4lQ== 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=mCXJp5k0L5AS/FHvBl/Z6w7G3K0qDovYA4QZYZNdzBc=; b=K3iq5KA2dGLmAhDVtxCKW9bIxykC3MypvBeQPVZSMgBGU3aL99ZJf19ovZDWPrcgTIBJWXnSK7Y/erCHdfReZ02fpm2ZDNU0Oy7Vtm+O0Wztm09F9lq56tW7Eqy4cG634KN1C713OqdB/DDJZE0h4Dw6XCeAYGvnxM7/ryOGF5fruBltjm+nZeK0Si130cXWvZFq3DAMjqzyFkSx0FjI+l+19Xmq2B1oSp95gDNYJZysK8BApHwTFHWlISVSXKn1E0cwTgfqKnv7UoWleAz5lqWRFgIHC8o8jJy+6415zcwvxN0XmOl6OSl+M7W9Kt9NJXokElRhuBanQoGlOLOlbw== 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=mCXJp5k0L5AS/FHvBl/Z6w7G3K0qDovYA4QZYZNdzBc=; b=FOc46dYjYkP/8PGvmtI/b0n6xU18UN6hnuT0me159flVH93KMfN/uyEoplg/v3Xv7e+6F07SX4XckMRsorentCj0ND/NcdtTFt/0G3+YxJQvBBfG7Km23lyPif6uEJmZKYKWFc4/zgnT7fqxClGwKkNvT7B7mfVYQ304r1iOfMA= 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 AM0PR04MB6898.eurprd04.prod.outlook.com (2603:10a6:208:185::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Thu, 9 Jul 2020 17:58:02 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.021; Thu, 9 Jul 2020 17:58:02 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: linux-acpi@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v4 5/6] phylink: introduce phylink_fwnode_phy_connect() Date: Thu, 9 Jul 2020 23:27:21 +0530 Message-Id: <20200709175722.5228-6-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> References: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) 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 SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Thu, 9 Jul 2020 17:57:58 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f99e72f7-a704-4107-161f-08d824319f63 X-MS-TrafficTypeDiagnostic: AM0PR04MB6898: 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: wauimv8RstcknTqvycyuer5//hoiVvTuF1lt5HiCPfu5R4apY7eh+dbgABylGJm6Lu2sSwbfMUg8mHUjPwGHeEXXegMQALZOYT8OoCXd3HEqaiXZZy85iZCvXjmaq6JGvzgVSTJPbAGUqBdvcl7MIKaHZoVzYWpQ2sQfJgPP4EEwglVTvTD3BXG/DiDraTGOiMAymTYZAcdVQzUSh3WuvDw3/uvAoHekNxa6pQhUaH+xp6e8Dr+6lWeSCJU72MyEFpWHH1L2xwyo1VcZ4lK9QMPChJpRlecHEBKW+t03qzIdkoIeV+YK9UbUEoeWTOcqercTkCrSBRuhjo5toOR0d8Nybi+pX7YqmqNe6B+gmIo6h0jT3ZecdDeoM8Mbgx7h 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;SFTY:;SFS:(4636009)(396003)(346002)(376002)(366004)(136003)(39860400002)(6666004)(44832011)(1006002)(8936002)(2906002)(52116002)(2616005)(956004)(110136005)(4326008)(316002)(6512007)(66476007)(8676002)(66946007)(86362001)(66556008)(6636002)(16526019)(26005)(5660300002)(478600001)(55236004)(6506007)(6486002)(186003)(1076003)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Sf/vIq7g5+2b+o/YuMkwLrHQuWLqMkLE/EoMGPaXeymXrYDkgmk6RvfqEJZi1Dqu4ucPY50SFl1VeLLxyEuFgOcbvO+6Ll/iPRYAssSO23WO61/1HHWChw5KAKm0Atf/YnHn44LQI00IkiEWjr5u206eEC/+hJGuqRMtVcPUHfFbWkq9BHiH+/xMDdQOCS9K3oNvxxSyN9ODa58hJ8H6bhjbebJpIxqgS1cliHtw3gv9/+RKzv9/2H50FTUo7CZmhdg6DHevGG5tg7SSZtGb8TSoanE+3DeQp4iP5SWBvrEVCeyhAmwxidJUk12DG8wrspfcQld6RvAPOOtw+58v7IvtunXwRIrF7gx7YX/yW6GWf9Ew1arYVlnnON/ceyUsTMtZNgE2GgzI21Rck10AhAn//Pli4yVOI7W4KyVYyzqUgWbssDlHjZk7elPAQ0BP4g2JoAEShcpmD4YyITvKxW9jv+gw01xQPKsxQd7T6/k= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f99e72f7-a704-4107-161f-08d824319f63 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 17:58:02.1472 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hgH0JhOglIk494K5oxOTWJ9b3lsKepLk+cyZDR8ZvxfZG3Tf/37yWdQjiG+RfJYxW3NRp3XYoXEku8QlQV/dVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6898 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Define phylink_fwnode_phy_connect() to connect phy specified by a fwnode to a phylink instance. Signed-off-by: Calvin Johnson --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/net/phy/phylink.c | 33 +++++++++++++++++++++++++++++++++ include/linux/phylink.h | 3 +++ 2 files changed, 36 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index dae6c8b51d7f..35d4dfbf5567 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 @@ -1017,6 +1018,38 @@ 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. Actions specified in phylink_connect_phy() will be + * performed. + * + * Returns 0 on success or a negative errno. + */ +int phylink_fwnode_phy_connect(struct phylink *pl, + struct fwnode_handle *fwnode, + u32 flags) +{ + struct phy_device *phy_dev; + int ret = 0; + + if (is_of_node(fwnode)) { + ret = phylink_of_phy_connect(pl, to_of_node(fwnode), flags); + } else if (is_acpi_device_node(fwnode)) { + phy_dev = phy_find_by_fwnode(fwnode); + if (!phy_dev) + return -ENODEV; + ret = phylink_connect_phy(pl, 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 b32b8b45421b..b27eed5e49a9 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -368,6 +368,9 @@ void phylink_destroy(struct phylink *); int phylink_connect_phy(struct phylink *, struct phy_device *); int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags); +int phylink_fwnode_phy_connect(struct phylink *pl, + struct fwnode_handle *fwnode, + u32 flags); void phylink_disconnect_phy(struct phylink *); void phylink_mac_change(struct phylink *, bool up); From patchwork Thu Jul 9 17:57:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1326107 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=kKP8IIyp; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B2kS42qmKz9sRR for ; Fri, 10 Jul 2020 03:58:28 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728575AbgGIR61 (ORCPT ); Thu, 9 Jul 2020 13:58:27 -0400 Received: from mail-db8eur05on2077.outbound.protection.outlook.com ([40.107.20.77]:27872 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728246AbgGIR60 (ORCPT ); Thu, 9 Jul 2020 13:58:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OGqj9QGOTKle0tHTm1VBU2ZFrasoG2OkGgQMyLkjRLfPZjZeRQwEYTmwTAgka4VHz42U57D8sxGIAle0DWRUzAm626XRVQd7ncDKr/1MnDdOmEUT6tBt4EYJ1ZYp+HxkFO1ryk96schYpxqiY2Di68vRJ98VZxrb3cCWPuOhedH4+h7XPbT3lDGt1M12bH1yxn6Z6Vo7htFeiTxW3bYRDiUxX9WW278BBJNvMVWZWkROi9FLDzQv3BpccagkXY3S6blRGiYNQO9yjDJ0lCJdZM/hvCSmiBV3BCwcac+zi0t1G7pHeN2jvaCydhnM41UZjO4i85CgsOLzA+l6JatXzQ== 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=Fss45xKt62SlrWpJp25LA0ziCYork6kewBoZxwWNBnM=; b=B7Snk+NDv/eQaMnvhYaK28r86mTQOWVVy762YmpeJQVKiSxyoQPb8i3RUlpplR2XoOkjIg37qa6UX50fLR+bo1AtgcJoyaKA4Y+zbjIj4OANQEtttlpC1WMwlPXitH9GPddnR/P0k31o4G3nXS1p8FZBx/9VQVBGEu9sEICN/xsUFx5o9XECn8+8sis9rll1vWPBi0Xmv9oa5Wu52FDJspDkdrydvfptixG4W2O50lLnKlv4RvQCRTFU/n5FoKZqZDVp59DESwMrGHmqLapiQy2qQDS+koNr+4hLWhrl9DYRhbMwXvmoeZtiKjzqLvpLvfb3fUQZ80hZc7CVgw1XtA== 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=Fss45xKt62SlrWpJp25LA0ziCYork6kewBoZxwWNBnM=; b=kKP8IIyp1xDP9VZ1fCmeEdfR1Gb0DlLh/YGQya7mySnkiOGuCPPPZOM9nrxmQXtUUKsJ7TOnHLmmJcv4SSMU9RaQeAV6c+GH+2WRJXANO7oMwuWZ121b4ZPmqZoE4NXhDutYDqxJKjJnib8nMMIpYJ51tVGz3xwcGGb4k1OxYbA= 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 AM0PR04MB6898.eurprd04.prod.outlook.com (2603:10a6:208:185::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Thu, 9 Jul 2020 17:58:06 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.021; Thu, 9 Jul 2020 17:58:05 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: linux-acpi@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v4 6/6] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Date: Thu, 9 Jul 2020 23:27:22 +0530 Message-Id: <20200709175722.5228-7-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> References: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) 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 SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Thu, 9 Jul 2020 17:58:02 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 578154f0-127c-4467-3c53-08d82431a1ae X-MS-TrafficTypeDiagnostic: AM0PR04MB6898: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UYEznWhCFNk8fNdIxCYkhSzwoC1hep/ChQT/dks7qCRay+b9UFmuo13bAlV8FJMQyf+Qb+n3+q4KAPZaICxIDRaJz7yc2hu1HPxuSzMOVCB4EFf3ocrDSwc5thwCICr2RMweb+8W9XPKtcWIC9sAXbKsXut8yKw7eViSjXlCLVsXFQwjps7PDBgk9aHVEum+ieK6BHd5+T5bzr5S6InEo/CM+9EbmnORgUTr1/jCrvBKL2xax0op/cp+49s6uS4yEZqXux+uuHZL+rfGzxELixUhq0D4DKOXp1lj4rrnFYDXuFJkqK3xtH4qMFvUMNQKEAmlyyTqlT4UCDTUNLlCjKxGNcd7rZ0EOzCA1hw4u+/LLElJgahDVdfHpddX1AHb 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;SFTY:;SFS:(4636009)(396003)(346002)(376002)(366004)(136003)(39860400002)(83380400001)(6666004)(44832011)(1006002)(8936002)(2906002)(52116002)(2616005)(956004)(110136005)(4326008)(316002)(6512007)(66476007)(8676002)(66946007)(86362001)(66556008)(6636002)(16526019)(26005)(5660300002)(478600001)(55236004)(6506007)(6486002)(186003)(1076003)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: bXsbqlJByhn40ZuN6k47sMul+nGNk9SRnCCDyN/LNw4zbfx3mHj0XAtCxmj+Z16D7C3E6Z79kj9BwmP34d8ziAOCSWy42yZDep7Pbf9mY/d2b6sxEilKPGdmh+EPRbUiw0VMV6M5J8pre5Ha63fYgz5auGTtkd8HcbjNd1gDuzOyuA6UfnYf5IiYhuII1+dsNyyQvtH/J8IJqXQ9pUdc+8pn7Tl9hs6RZum35szBvr1BBqM37YPbPNjy5+a6usEMPKsXFj7aJEyYeIn5PfOg8G65pLZuZUGOvkD0xDvMUC8ALijHqPiOKVgtPm042nzCih18dK3AScNYn5mfFuhTfzF1Fm8HCbbsDVjZxetnFORGiNfifMPJ4E57zJbeUr0exyzPe5rlHdUVGskqNrRISyOJbgdDeJoCG2PUObbtYfdMt9zr/gYWBSV5flrEZB7QcsRjaRptfDhx8SPvcJ0sDQ9oQReesM/eZW92hskrSns= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 578154f0-127c-4467-3c53-08d82431a1ae X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 17:58:05.9522 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WdTF7XMQIrJD4JFnYlyY9wXg2VLJvErt+JtdHP1CpSgbEfYo6KLyao+ws7SEClHeG07XKnbIb5qaTLfr65o9eA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6898 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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. Define and use helper function find_phy_device() to find phy_dev that is later connected to mac->phylink. Signed-off-by: Calvin Johnson --- Changes in v4: - introduce device_mdiobus_register() Changes in v3: - cleanup based on v2 comments - move code into phylink_fwnode_phy_connect() Changes in v2: - clean up dpaa2_mac_get_node() - introduce find_phy_device() - use acpi_find_child_device() .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 70 +++++++++++-------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 3ee236c5fc37..297d2dab9e97 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" @@ -23,38 +26,46 @@ static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode) } /* Caller must call of_node_put on the returned value */ -static struct device_node *dpaa2_mac_get_node(u16 dpmac_id) +static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev, + u16 dpmac_id) { - struct device_node *dpmacs, *dpmac = NULL; - u32 id; + struct fwnode_handle *fsl_mc_fwnode = dev_fwnode(dev->parent->parent); + struct fwnode_handle *dpmacs, *dpmac = NULL; + struct acpi_device *adev; int err; + u32 id; - dpmacs = of_find_node_by_name(NULL, "dpmacs"); - if (!dpmacs) - return NULL; - - while ((dpmac = of_get_next_child(dpmacs, dpmac)) != NULL) { - err = of_property_read_u32(dpmac, "reg", &id); - if (err) - continue; - if (id == dpmac_id) - break; + if (is_of_node(fsl_mc_fwnode)) { + dpmacs = fwnode_get_named_child_node(fsl_mc_fwnode, "dpmacs"); + if (!dpmacs) + return NULL; + + while ((dpmac = fwnode_get_next_child_node(dpmacs, dpmac))) { + err = fwnode_property_read_u32(dpmac, "reg", &id); + if (err) + continue; + if (id == dpmac_id) + return dpmac; + } + fwnode_handle_put(dpmacs); + } else if (is_acpi_device_node(fsl_mc_fwnode)) { + adev = acpi_find_child_device(ACPI_COMPANION(dev->parent), + dpmac_id, false); + if (adev) + return acpi_fwnode_handle(adev); } - - of_node_put(dpmacs); - - return dpmac; + 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) @@ -231,7 +242,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) { struct fsl_mc_device *dpmac_dev = mac->mc_dev; struct net_device *net_dev = mac->net_dev; - struct device_node *dpmac_node; + struct fwnode_handle *dpmac_node = NULL; struct phylink *phylink; struct dpmac_attr attr; int err; @@ -251,7 +262,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) mac->if_link_type = attr.link_type; - dpmac_node = dpaa2_mac_get_node(attr.id); + dpmac_node = dpaa2_mac_get_node(&dpmac_dev->dev, attr.id); if (!dpmac_node) { netdev_err(net_dev, "No dpmac@%d node found.\n", attr.id); err = -ENODEV; @@ -269,7 +280,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)) { @@ -282,7 +293,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); @@ -290,20 +301,19 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) } mac->phylink = phylink; - 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); - + fwnode_handle_put(dpmac_node); return 0; err_phylink_destroy: phylink_destroy(mac->phylink); err_put_node: - of_node_put(dpmac_node); + fwnode_handle_put(dpmac_node); err_close_dpmac: dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); return err;