From patchwork Wed Jul 8 17:34:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1325363 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=lRK9jQ0H; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B25zh2dmxz9sRN for ; Thu, 9 Jul 2020 03:35:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726836AbgGHRfL (ORCPT ); Wed, 8 Jul 2020 13:35:11 -0400 Received: from mail-eopbgr20042.outbound.protection.outlook.com ([40.107.2.42]:43335 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726806AbgGHRfI (ORCPT ); Wed, 8 Jul 2020 13:35:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y9nHVLN0Bfej7m0BEsqrmApWbOsEBeQeR/rSlvkC7aUJAYhZ1s6k7bZ8SbMMfACKDDjgNdJ+VJcVBJgaWUVF9TfcIVUqNKXF7OQfFaCuGkLef2bJpCvdqkpfpuMiREqAfYDEXrNx5t5HcDgiqBYtb7OIQQfPqOn2Q+8HqsF+ygI2eTjzCa39q+8CvDqdlTgPMXdBww+e+VPgtJDNmQDFsOxqwUI+z1NJy1cO+3B+xUxqN+l1m+AkNtaUIxwxNDCspJKuHd5P9u+Mof1lhj1fZqgdFItaPGoH2L46GOXqeeMagU0rAldD+gIy2OzGFV9frhBzNhqMTTIld3L8yUDLDA== 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=tSEk3yiu/72qlamL/tARgk+t6Hx6AevGNzkASxvnVJA=; b=fiY1BP8Mryd/hgVpzpQQmMHhNfk/eseRj63tN1W343uHN1wTz14zzRYBpRLEUPxZhfdqvQWls2rjpY6r1p3TDaCqvfv8zce3Jo/MNgkTwC5PZIe3CgdAYfomnWC2+8YEwDYCoXeURltEYjnWpH88UprEKBxoWFb6Ar9mECxNQKV3KufmaKCHsrIg7d+Y059HGkdtlQFS6aMaV6+7xNGTEjrWHoXxghqpMTm3gewcqWLwUZgjzHyqoUdNSxAXIXLtbl7Ll2MMznWcunSx+E6XV3Mo5n1amPrXG03hFQ8ptFS7oOleCZ22LLtDpKigb9QGWKY5smenHvLjfRtS8xIifA== 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=tSEk3yiu/72qlamL/tARgk+t6Hx6AevGNzkASxvnVJA=; b=lRK9jQ0Hp+fd7Dn7zIM9DwcxWW/Y4TL6yFrHfJPgpt3e/NI+Icvy/U9Zjmy6R2ZYniv+qs4vhnYEwrnuos4mkmRrjyMfXShl4WRNGNwTNgfTmZFOuZC8RcXpAJgmoECdNniJiuw5DFPWGTboCvrxX5IFiZte5ovXOSqxZAk1L5Q= 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 AM0PR04MB5730.eurprd04.prod.outlook.com (2603:10a6:208:12c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Wed, 8 Jul 2020 17:35:04 +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; Wed, 8 Jul 2020 17:35:04 +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.cj@gmail.com, linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v3 1/5] Documentation: ACPI: DSD: Document MDIO PHY Date: Wed, 8 Jul 2020 23:04:31 +0530 Message-Id: <20200708173435.16256-2-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200708173435.16256-1-calvin.johnson@oss.nxp.com> References: <20200708173435.16256-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR01CA0100.apcprd01.prod.exchangelabs.com (2603:1096:3:15::26) 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 SG2PR01CA0100.apcprd01.prod.exchangelabs.com (2603:1096:3:15::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Wed, 8 Jul 2020 17:35:00 +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: 4ab4375a-091c-4fe9-1a69-08d823653f88 X-MS-TrafficTypeDiagnostic: AM0PR04MB5730: 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-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: huBWg4rvyxYGUvSGVgil4QhthuE3bi2/XqrKXedZzREhdTw0cQDcsLJaSesVlO26Kw4XhcONFN3wfxTUqULeUfEoZBD6kzYOhgLXm9jKmHmg2oO/rN8GdiFNa11VMPl8a/ZfbrW8pEM/usV+y6rgW1UR/SAeYO0ksaeocKZC0yqQXN7FlREc4Zaw7V3kp6PguZWmnoAKTahOM+6MBPzuLwQxuC3+cR5dHhU/5sUco6iABIHpdmuyxJMbEyC3iIMqV4PR5Nj79Uy/ZWQWe45AZy8isClpE1Tkajw5A+1APYnpP+7Nyn2xofmB8wiIfTdHSA2amysmj+sBWlrvwYegmbeOPEbUc+m+CUpQzY2gNL+UcEWciHI1IbiD/Kvt5k/b 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)(136003)(366004)(396003)(346002)(39860400002)(376002)(2906002)(186003)(16526019)(956004)(2616005)(8676002)(316002)(8936002)(1006002)(6666004)(478600001)(6512007)(5660300002)(44832011)(55236004)(66556008)(1076003)(66476007)(6636002)(86362001)(6506007)(66946007)(52116002)(26005)(110136005)(4326008)(6486002)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +EcWecnwO+D49n2w/eeQ8dDDHo0HTNChf5xttv4E1Da0fZpbqAXPpLtkO/IxOATwtvfgclQ6O+FroYOSa3pmyQqdloqh678WENMwm8NJjfD6tXyIAAEch/1IrilW4IIYpBxD0TezZmnE1TPJfUcdL3Wgfca2BGCCpl0psEZSovJTty4/k4dyoP6poL8yk6ob5/D1M20rgXV5dHvTpexzUeCCWinwIEDmSV61QFv664BqUerYx8XtCVeIudcnOPmSA9LzXIOwBBq6Ud8vZRujIakjO0uH380ZunMMllgpdvpYG/MGDFlMklLc+y9X7+UbtshLfhn6P7ACKr5kKVHKjJh4sKcUs89hSj7bc2lCMWoZ7raczBDOebfWKnwoDNmRp70bZ8KBQNhxXCl/2O8sfQtTDsSN3P602jP43MUFcJlSDGqLFsy4i7/I093sV81YGJlss0abo6J+M+acRztRdIhaRI2hDitHfuRt/2jV1d8= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ab4375a-091c-4fe9-1a69-08d823653f88 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 17:35:03.9857 (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: Pacjqd9Xo67PdK20W6pQpjR0FHL1VciLk5Hfncv4xBKEYNf9mDVFgDXJjDR825JrbISFKYc441Vy6oHwTIvpnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5730 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 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 Wed Jul 8 17:34:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1325364 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=FIZx8piJ; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B25zl2ck6z9sRW for ; Thu, 9 Jul 2020 03:35:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726806AbgGHRfO (ORCPT ); Wed, 8 Jul 2020 13:35:14 -0400 Received: from mail-eopbgr20042.outbound.protection.outlook.com ([40.107.2.42]:43335 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725810AbgGHRfM (ORCPT ); Wed, 8 Jul 2020 13:35:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fEIQxZriP6nN/KmSS6+mZcy/z/VMiOpKuv5NqP0/N9hMoZQnhSiGoAkjvLoVC9IzRkIjsydaqjRHrFlAQ5Qh6VicxRie7SFyk4BsA1jBPo76hxG4SBuxMMyuLTCfcwx2xR+lGoL/CXjVN1P5RcI8k647S8VjszaygTasNGIRwvb8+FKuPQUMwCn9WDLkqit9cUB8hRg6oS0PocLXNU7YSmsb7iFUdrGH1ouj6N50lQLdZGwmrT9/v3oHDWIp1BR+Vh3SLKX1TspCigQcUGfmYwO+MbxLu9mro/GZzfoNLJ5QIfFuwl/qdFVdraCX53V5RgV6LCOwLOPu+7SunQ6EGg== 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=Mpyk3909EXqa8teYZxfF+BCdEL9rGeVAzf8kyTwKhsE=; b=VB7rq7eReyfrJZIfopCZmhrGThArXAdUXTv03UxAmBGP3Uj1PDhrWuW3IiRfvev/9S5t4llk7WU8E+j3Ho0VKoc0gyeBW/fUelco8gMOXIxmg5ih/Ph0bzUvwCdTEW/8xxk0MezcfkwEb3BzMmYYwZcQQJJTmTE4LOittcBMVE0F3UjcDMIGLqNhh5NYF9vBr02leyrGXe2/x/ejxtbLckGpuveIbjbQJ2z/pc0fOlG29ix6Yi8ixCjwrIu/Y11mPLke0GaKJEsp+edQ8rBFTsvepiIaAjTOa5v5qki+il9YoW7bL1OpqGNZtX5LVp2Dvb8SR7DdCrwcOHrTxiYfvQ== 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=Mpyk3909EXqa8teYZxfF+BCdEL9rGeVAzf8kyTwKhsE=; b=FIZx8piJFhhzK1zRIk1kMD/UU0E17dJ8pkvYGf/FOaS0HBHbLTJ2ryZJfBxbipsf6yB6qtiIX7C7sJfMM2Q4izF+qVHrDHcJd07StyCb3rVKLXD1jjR/eWgK1AFV/YNy1lTdREcbbr9kPKfmkfeuEqXKMM10AamONI1I5Yrc7XI= 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 AM0PR04MB5730.eurprd04.prod.outlook.com (2603:10a6:208:12c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Wed, 8 Jul 2020 17:35:08 +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; Wed, 8 Jul 2020 17:35:08 +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.cj@gmail.com, linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v3 2/5] net/fsl: store mdiobus fwnode Date: Wed, 8 Jul 2020 23:04:32 +0530 Message-Id: <20200708173435.16256-3-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200708173435.16256-1-calvin.johnson@oss.nxp.com> References: <20200708173435.16256-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR01CA0100.apcprd01.prod.exchangelabs.com (2603:1096:3:15::26) 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 SG2PR01CA0100.apcprd01.prod.exchangelabs.com (2603:1096:3:15::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Wed, 8 Jul 2020 17:35:04 +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: 47aa6738-430d-4be3-7b32-08d8236541c0 X-MS-TrafficTypeDiagnostic: AM0PR04MB5730: 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-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rupE9HOxhz0HPcEU6EIybysYTFfQ6+1bJYbkOpmGJrtP91tS+F8CvJ5QAxXa0DSIbABErM5RSVxFKfQf0cEiZdzuZQ+FnmeHzgW7C2Wa+uiO5PL3o+8+UuV625kd3GxGEgjt7pZvUeVzF0gi5eBcOqZPvlUZRajG6nDaWF5N2k2ahgLCOJvHHsd93l0T3KyL8fjBd8GW+5VI5sXZamB07UfuTrVxeFSPkzVCVHKnUAVl0nh6SslPQ8dSeVJVQw4ov0yel8zLwOt3O0hpsY7Wm5Rl1xe3kJ0A4MYL2KIVBzgUSWB/Ee9jIwHl6ArgRi7ZT8g7QpDJez53PqW7rn36M7yJWl1288aE+q0zDd1Y8w5q2ClsnivsMGYHR9m3DCcJ 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)(136003)(366004)(396003)(346002)(39860400002)(376002)(2906002)(186003)(16526019)(956004)(2616005)(8676002)(316002)(8936002)(1006002)(6666004)(478600001)(6512007)(5660300002)(44832011)(55236004)(66556008)(1076003)(66476007)(6636002)(86362001)(6506007)(66946007)(52116002)(26005)(4744005)(110136005)(4326008)(6486002)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: wK8Hljf3xrFnLcJe6pBC6nG1ROJWguH2G+5Jrx1ZVkhNFjHeFY+uP//ka/GuKj9vO7t+HBUzZ2h9R092E5z5lSUoyFZ47lYd1JUMTLUkvmz4zO5Am2MuNoF6cLtU0fU97mcnppfzV52xnsWs6MLGYnDA3rJC4G5Mx6uDI7qLRYaKgVNz+Wry0NRItbknwOmLxvouQCN2xUcx7VH+49U0NPxs5dv47qkMdAigmb2qBiEiqyNojpQIrVQTZpvi04ILnQ/4x2qDwRDcDaYUCJZWIHpfKs6J/eeLq1okWLw8ZQUepVjCfnSlUSRMwWqvdTqFUPBSpXd8I67PGjtp0Ygf3VnIHRPijyty6wid7PW3l1PSwEoCrqfQAEyVegq55DCuJjrcxHC3RkZgGriep3XVRjDTowXPiGCJ7TUi9fEghl8FKqWQ5HekVHdtQQy+WmPkqb2J4N8Y8UPLjBtw0Jm+pKTHyLHmaE6mqrCTSO61vYc= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47aa6738-430d-4be3-7b32-08d8236541c0 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 17:35:07.8525 (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: iw2mbbVchf17KyinndIud7OHx9gwRO/Xhzch3NzPs19TwnD0xy6GW/kgyy77pAq1+ha0caFLYtaOqGM6fsg3gA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5730 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Store fwnode for mdiobus in the bus structure so that it can later be retrieved and used whenever mdiobus fwnode information is required. Signed-off-by: Calvin Johnson --- Changes in v3: None Changes in v2: None drivers/net/ethernet/freescale/xgmac_mdio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index 98be51d8b08c..8189c86d5a44 100644 --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -269,6 +269,8 @@ static int xgmac_mdio_probe(struct platform_device *pdev) bus->write = xgmac_mdio_write; bus->parent = &pdev->dev; bus->probe_capabilities = MDIOBUS_C22_C45; + if (pdev->dev.fwnode) + bus->dev.fwnode = pdev->dev.fwnode; snprintf(bus->id, MII_BUS_ID_SIZE, "%pa", &res->start); /* Set the PHY base address */ From patchwork Wed Jul 8 17:34:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1325365 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=gUjlAGF1; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B25zq1z3Hz9sRN for ; Thu, 9 Jul 2020 03:35:19 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726864AbgGHRfS (ORCPT ); Wed, 8 Jul 2020 13:35:18 -0400 Received: from mail-eopbgr20042.outbound.protection.outlook.com ([40.107.2.42]:43335 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726837AbgGHRfQ (ORCPT ); Wed, 8 Jul 2020 13:35:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QvgDG5Qkc6YnXuNFyQ83anFAamoBQMKwnHP5SME73DadiGscu1xG7vwVY5RdRSTM+QMh9P5EWw0IUy4r4dsnxUt2eWJztE1vlYAWvqZZcc4jKHqSoJS4Hqgm4nAcSY/LSl1gRiqz9k4/u/KrXA8Qj8ucO73twhnp45XM10KaUVOh0tfMAIxotR1MCku41qGglp5sjOXpUQesZLfD6wsbS3hj278BevhSiGmYv9NUKDUd3u7AqlavFPs8LC6yMj+0Exffpy811tQIblh1e/F9HdjWSQBYm6uHIH+Gu+T6NrA6bfr2OXix2Fh/H4CO9WpJrv9EDJOKHmpu9dnnDi6CCQ== 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=UI1vJHTy3Ch7GWT7z2o43wIWGa3e3aZwgT1QeiFNjMQ=; b=SI0fxI5k8ZwWwZuabVMKmBDswZVG5/YFrD7WvFNYdRKRG5TNzLa6Kl5b3X1vYp83d6Qf9zBzHa7kFz9LvPa6i2sEgxGZmLTs2R3YleawZ3atre8ZvFF8WfTeMUnF1V/JZF1Q1OePsdTpww3dSGNCaRQTxujKv2iX4ow/eyz8UAa/dAeXyMbcm+j8aewrv+hpiSl5gpoEibHO8QEhC7W/BdxyAW3ZjkdKVwY8mrNgxAjl0Y3JRlfQEGuwNoQjV97Bmq27LTxo64LBWBdbBl05YmLfzmNmgf/eF37kHkmHA0tqY6U/qoG15QRpuHpWuEZnBPN73+nRIZhxmARK3KBUww== 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=UI1vJHTy3Ch7GWT7z2o43wIWGa3e3aZwgT1QeiFNjMQ=; b=gUjlAGF12DZQjT0c1pSpivvTH1/P1hLWUj6l3ghwKLJom2HeUnFHPv3MW0/kGPMOBFjSBbFFBmVqVo068963jHNl6D+AmsaekaV3IzoB9pMhXotaZrgKRviaPUZ5zq6LHcKC+gK4NUD0Eje4B9KY19FxvZpPSHvmsji0VbvYIQA= 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 AM0PR04MB5730.eurprd04.prod.outlook.com (2603:10a6:208:12c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Wed, 8 Jul 2020 17:35:11 +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; Wed, 8 Jul 2020 17:35:11 +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.cj@gmail.com, linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v3 3/5] net: phy: introduce phy_find_by_fwnode() Date: Wed, 8 Jul 2020 23:04:33 +0530 Message-Id: <20200708173435.16256-4-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200708173435.16256-1-calvin.johnson@oss.nxp.com> References: <20200708173435.16256-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR01CA0100.apcprd01.prod.exchangelabs.com (2603:1096:3:15::26) 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 SG2PR01CA0100.apcprd01.prod.exchangelabs.com (2603:1096:3:15::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Wed, 8 Jul 2020 17:35:08 +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: 25e2e28d-51d8-4a00-c983-08d823654409 X-MS-TrafficTypeDiagnostic: AM0PR04MB5730: 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-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zxNVu2y0qKh0bh35qkgxnXRb78y4+Qed/lnHcKio82GpPCnh3xb8VJGcwX0G92vP9E6c1mBPbAaq8+iNib8wz+3YiCpEDlZsxN2CihJ4MzVkpJvnxw7snEyRSUpQNsQOdNvfjRuy+sIr/J2o1ayrpkwDTn9ycLJJH3QXYpFDEMVoFtr607nAqsR5TmShKcTXuAK+I3C6YoCRELC7UYPQ44dXThOIyx5RwSY1C2DdLx3gBNjP+U+GWMymHY8zrZ5ktAhJLxatY/UOaiUwoP1Lmmyu4XY8zGP5v2p+m0rlLRIuT1CAskzJzSwMG+XZfvBtBjOECEhYPxrcmrfgSagBIghtLHjqfBiB0ZP09fkLf2co2cZv0R01Fb+jI7LXfJ1F 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)(136003)(366004)(396003)(346002)(39860400002)(376002)(2906002)(186003)(16526019)(956004)(2616005)(8676002)(316002)(8936002)(1006002)(6666004)(478600001)(6512007)(5660300002)(44832011)(55236004)(66556008)(1076003)(66476007)(6636002)(86362001)(6506007)(66946007)(52116002)(26005)(110136005)(4326008)(6486002)(83380400001)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: mjzfy5GAL88ECkMN6r2KdEgqwqIKYmP3wn3O9MsvkpTZQJ7PTBWgHn7Vrsvm+vrSA0y9j8kluua8vW+/Mc7E3MEt+/E8p91JkLEc57oIdJid2R75LgtKBCprxhJKIak5Qih5B5pmohzgXQWc05wMnK2PNNfMe3USXmXLky6/KWt9mgjpvq1Ua8hnr0meWIbuvAHtsE1E1cCtCzLx/hxF+vGZj97vaLCzb6eogeLdZP3KcInXBZR+NG6xdIPFD6I5m4+svcJOR0afyZB0KOOSmyDO2eubgbPrqYu9QRjEG0YCH6scxieedMj+5/m12ITxgRMuTKxuDh8cpkY4q7IR4RVgwOU4SaBCpGQz+5KnSD5YMJdUSxFFPqlnY0HH3XBwaGVI7s66yoYU4Naz58uXONIRubvsHFFeNglLinnYbaWnuOl5eWpc5oGkQfh8Eb41uKBrjmew1I7o2ICnq2roZy/9VTXxclaB/r5g2WJ7O4o= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25e2e28d-51d8-4a00-c983-08d823654409 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 17:35:11.6614 (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: kRCe8uW6n4mfVPHiPLQjrTwcT7Cdt254l779ye7mn2yjJg3ER+2khv/AcWjgJL74LfKx8vLkG5znXsBVFFknJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5730 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 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 | 21 +++++++++++++++++++++ include/linux/phy.h | 2 ++ 3 files changed, 48 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 46b33701ad4b..626da1070392 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 cf3505e2f587..6d113ae9eaa0 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,26 @@ 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); + if (!mdio) + return NULL; + + err = fwnode_property_read_u32(fwnode, "phy-channel", &addr); + if (err < 0 || addr < 0 || addr >= PHY_MAX_ADDR) + return NULL; + + 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 1592c3d0e12f..6f283789d6d3 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 Wed Jul 8 17:34:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1325366 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=GLU9+bl4; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B25zt5ftRz9sRN for ; Thu, 9 Jul 2020 03:35:22 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726883AbgGHRfW (ORCPT ); Wed, 8 Jul 2020 13:35:22 -0400 Received: from mail-eopbgr20042.outbound.protection.outlook.com ([40.107.2.42]:43335 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725810AbgGHRfS (ORCPT ); Wed, 8 Jul 2020 13:35:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HwUqQWTMwoKdmf7qFU+vr8+4mMrjJTY0s6W8ozitJ6uEpxSdO+fgTlhW45N6BZLJrciM+VWwh9+CRboMZB6bYQUEu3/GAWkMuZ2/vG382fbJ6yzsF9UEbJ9g/44H5uzfNuKb5MtYV8MGOcren1Sei05J1fx0PSORJdEU3rNVqQhqFkRewYVWuKxTIGns6c981NsGiESv96siu+HICofC5aaYH41JWt5ayxHAUQrEhdy1tAFoYR630C4oN1zFojGKm6CekZ3WblUeW+oKP7LX5y/q1GwGGwzGjbwVMTKEppzga/FT70NRvZWAGSapMj1M2LVi4QxqZYMm0yKZJ30Log== 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=wZVPsyvVBYEzD9P7EAvb/lFnlgEL76tyGLwECCXfxe4=; b=dGuoM6snB43yKyiGWtzK0f5dqdX3gt1B8YUQu9x54tDOdQ+M56wwLHQAHUUSlwFHNxjCUnOXvKoLIpJaL9S7f3PY/Oyt47DLJzwb7VGmGVzwcVcAzbpH4qpSIZUIxX7y99Pk/7L3oVtY6+QcMDqCdYV9q+8k2LkwwfHo7mJqs2Js0EAPdZi6BqwFUsGuhWX4cPfsCeu56ENzimaKQUQRGWLKlk6aKnLTDVhNvYmyUT5uVS5AEqkYYpLBOV1pXFrNejWvSSyJl0OpWsC3C0uZ6+a83BsuiW7aUhCYidELKJt3owP3Hecc+JIszCeBleTLjvAbdU6udb/ZLoSnKNOGuw== 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=wZVPsyvVBYEzD9P7EAvb/lFnlgEL76tyGLwECCXfxe4=; b=GLU9+bl4YXbwB9pVnh5l4KEUYPs15DCbr1NgyxW5K0C/qgxfRVef8RqOPuFjsiP8qnLqbQUuQN1kTwGBS3Z6EHA6pktG+NglTZxuwZXUoKB2+S5tGIbed10BJrIQvWZ5VhwHHHNmIiQO8g0QtkUdJWkR1PNJKWgvIuRgVFSCwO0= 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 AM0PR04MB5730.eurprd04.prod.outlook.com (2603:10a6:208:12c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Wed, 8 Jul 2020 17:35:15 +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; Wed, 8 Jul 2020 17:35:15 +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.cj@gmail.com, linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v3 4/5] phylink: introduce phylink_fwnode_phy_connect() Date: Wed, 8 Jul 2020 23:04:34 +0530 Message-Id: <20200708173435.16256-5-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200708173435.16256-1-calvin.johnson@oss.nxp.com> References: <20200708173435.16256-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR01CA0100.apcprd01.prod.exchangelabs.com (2603:1096:3:15::26) 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 SG2PR01CA0100.apcprd01.prod.exchangelabs.com (2603:1096:3:15::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Wed, 8 Jul 2020 17:35:12 +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: b1247e1c-f167-42b5-4ba3-08d823654656 X-MS-TrafficTypeDiagnostic: AM0PR04MB5730: 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-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wJ8j7jeRpkcpwooD2wcwo1RH9thjTI9rzcfawrhnk3bjmFaOKAGBE0e5FYO5aiyNTZorMRSOMfuUv4Eyzv4O+KOb5Cef80s1rNqqohJFz+9Gu/xVbR/HmvjZ/ASWmF1/1DSgpl/wcUUY8bubbjSdrrPzLNWXMO5Ko2Z5qICGCVHBHiNZn1jQ3ZDvLHg8wdOyZDchMR29ETP0WSo0GQBPVAbBSuZV3MXxQrHZLRFpdI6h++RW0ijbJ7rsXMroIdy3LbHIAPT1IrkOYygxwwDDlL8oHSMekcVu1SznvhHsmYTLbCsRSS2YljtMNth6wW12JSk72U4YhL10QD1NlIFyFtdn5L2V4ySMRWBThsxmYcd81WQiZEfCTq9zlJurBGTe 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)(376002)(346002)(396003)(39860400002)(366004)(136003)(86362001)(6506007)(66946007)(55236004)(1076003)(66476007)(66556008)(6636002)(110136005)(4326008)(26005)(6486002)(52116002)(8936002)(956004)(2616005)(316002)(8676002)(186003)(2906002)(16526019)(6512007)(5660300002)(44832011)(6666004)(1006002)(478600001)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: XgzT1FIkCEWhSLETMiqZ57mrZ5NPLECfPeCKSjubGDb8JhLzyR0Rl31KHEs9a4vkVPvMooQtJpy1lw9tAJ3TLlkdMkDu7FnJVfzPbiFRfpgRK8LCZEIBnf4sG2Ql+rOcc9yYJTBQRT1O+dMfTI1w3bVgKldT0Nk0bwxQ8Iyzz1GMFmLTvbyL7sztIOlofobk+5UoUjtXtH9ecoopsp6q0xn3iSyRFGmFbEe0VlPJWOaymMvhWbNKXL1jprlOL5t0k76ibJz57mcEustMJiV1ntlUy8UgbZhIfrK87ej0vNyYO+i7uU4VIzf4NMYuI1pe76F3n28E67SLfrvlSxWifm5uv5gpnTycZuwxzqTid+gFGU3kVBUn7WeZcwo4LgqSWf3asufvW5C7QN1hNm4inmaHo1VuDdxekhoKjrbilGc/ATw87J191e/Cra4Rn7eJZqFRVbFxhQPGfvb9/ILa5stxxnWcqOqlt+8FimmCGnA= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1247e1c-f167-42b5-4ba3-08d823654656 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 17:35:15.3763 (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: Dr/NZfNd4HdybLfYbum/kRE7eEt9JMwJO2jDI7Vyni5y8PTrOn1a7xfViZjF1FxrLle+jIqQgPNLlCXjeQQUlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5730 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 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 Wed Jul 8 17:34:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1325367 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=AXjX/HR3; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B25zz23p8z9sRN for ; Thu, 9 Jul 2020 03:35:27 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726900AbgGHRfZ (ORCPT ); Wed, 8 Jul 2020 13:35:25 -0400 Received: from mail-eopbgr20042.outbound.protection.outlook.com ([40.107.2.42]:43335 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726837AbgGHRfY (ORCPT ); Wed, 8 Jul 2020 13:35:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KZWvbe3GNlJzq46Jz4hcieubAoGPBisqMyhlijooUftP+g1qIvu30fGV+FjLj533PZmpuzyVOUo9c2y76qlDmtQLrT1UQ+gedAHK0KKQr9OGny8LXK0izCzqo/NJSLjtm+Y9DhM7plx7OLHOUDhUAN2OjC1ogUDqE4ToTuTxcD7AGZpE+7JAjec3hbeAU4aBSEkbjyIefx9YWHpQ81OsfSobUPzGSb5usUXYaOxfkY1i1JgAhRBSiPgZGza6E8Rt9lCPXIeX8WEaj6l2bELR/CEcMqjPx3Oz3oS7nwH4G53LNOGUGPdV7xqJCPw17t/QzY3H3+9F4LuTSXNlibv5jA== 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=rP45jMIru9NwB2O9CaVgGBFnRSd2VPj2JSK3MfAm52U=; b=Xf6peZpbY6LFRRFPwMLVZUEjMMxuREdydim5P9n3O7dga0pEtDS70ApyHxjKjj6D3GWpZ93bPsbl2WPVrXRTUFfSrYnpmuE9qBZyGoFRlt3idfXc/3YBqpV5AquAROKbvQ0illXbAnl0HJxLJol7KnlHYsO5HHJvaf77wGG6RSI5iPKYpBiJoHHQwtSJi4+fUYD8YcjzadnVnqAqBhVI6unITVR9C9Tim29w5zFiV83EwAMBHIS8CxDugXmxU5t+BuqTWl7kQwCtfsnuY3oPzJXqsOYi6rnXfE/9mc80L1vHNDelPyUfxGOnW/u1NVmNCiSpeMpxNEdo7UBIwSmRQQ== 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=rP45jMIru9NwB2O9CaVgGBFnRSd2VPj2JSK3MfAm52U=; b=AXjX/HR3XuJcjzYMHskxECJSkm3H0+u4y6WPv83IOYTi4VxtY0NjG/N3rQxpo/WYfglnpWxDDPOQTSrj2IYXvimrib3PA/A+2SQetyihb0mnU1BrcrskXEXHY00num2l2lB4rhW9hELuscz28EBg9oJFmQTgTjflFa7J2aZjZFY= 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 AM0PR04MB5730.eurprd04.prod.outlook.com (2603:10a6:208:12c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Wed, 8 Jul 2020 17:35:19 +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; Wed, 8 Jul 2020 17:35:19 +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.cj@gmail.com, linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v3 5/5] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Date: Wed, 8 Jul 2020 23:04:35 +0530 Message-Id: <20200708173435.16256-6-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200708173435.16256-1-calvin.johnson@oss.nxp.com> References: <20200708173435.16256-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR01CA0100.apcprd01.prod.exchangelabs.com (2603:1096:3:15::26) 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 SG2PR01CA0100.apcprd01.prod.exchangelabs.com (2603:1096:3:15::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Wed, 8 Jul 2020 17:35:15 +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: 40801395-0d28-48f1-8216-08d82365487e X-MS-TrafficTypeDiagnostic: AM0PR04MB5730: 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-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k9AtAngfnpn1PrTIYhx9BLELV+Lt3KKeibTFNHit6JuYB7BetEo4A7fipp918zMScEnQqEUTPUMbkMXMBdTfwAMj/H1BBmFKR68SWzQXj3jYcLuUNnOUQmLo8HedqINPQHdguAj6G0ak8eHpQDAAZwld8CRSsLpvg5xJCDaR9GaXIQWS8nkL9Tzvv2IZRhfWIKLurYfOZXAm7rlJ0qteizRRUDxWwxeGv9r8AP9kmpV+Ps1BqkAhhmDwMHq/anXC54OuCG9RfDr6vf83JhJMpgAfppqNEu0+crQbsYxYD+aRIiGy3CBXces2l3QbC9kkiU0O7IFt2dYon53ZsBDdpzCHsBPbiXZiia/asXnqKBGg4Q9joDss4Ku6Gyn8rvoU 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)(376002)(346002)(396003)(39860400002)(366004)(136003)(86362001)(6506007)(66946007)(55236004)(1076003)(66476007)(66556008)(6636002)(110136005)(4326008)(26005)(83380400001)(6486002)(52116002)(8936002)(956004)(2616005)(316002)(8676002)(186003)(2906002)(16526019)(6512007)(5660300002)(44832011)(6666004)(1006002)(478600001)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ozrdjNVbpalG8EwRvDFyuOWOrlx4g+Lvt8NU5YMHwGHKQvySUoPNH0/g0/IU/EVTn8xteU7ukRAV3RetkqcLwGx3Tso7Z4I+0Gt4AqzXN0dqGPmLSb2Uh+G5wa671dsTb0d8my4WPfVJhWY2r6DP5WRAMhukFeBNnWTOYVunbcQSysyXmT0cmpTOZyjcKV1sMAcyenrH2tDM2qvhcgbfyz6a188L85e4UYNC7zD8hI8msGkDSipYFLGkIjSxD6dQCngYjVwgPZym4tA9/U2ZCgr7emByXVY2YVplQHLqQwx79nbgAT46fJEp86XDGntZf9StSlIam2xfZsZJ5Ns1wzfZAU1xrG7QUiyXjzIhNG5kHGrxmvt0NUda8mW9MZXXusQcsWxJEMMQu+cRFlc2mpsu2jqteY/si/1bKYRKPcqKPCARTDmZGRxICz1sFzvVILGtMPHRUHRRro9StagO+raikLHSmvETd8oFZ+1UzXw= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40801395-0d28-48f1-8216-08d82365487e X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 17:35:18.9913 (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: Tq39UQfqvyOyRTpTdsa7ovWTLfPson1anXT9OAJNrs34U5lDuON6vbaTXo8AiQiBT7xyHCafQa9zHNT/9NlD5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5730 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 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;