From patchwork Wed Sep 30 16:04:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11809801 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D12192C for ; Wed, 30 Sep 2020 16:05:57 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F81820789 for ; Wed, 30 Sep 2020 16:05:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ol+EuWIR"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="adZ3Hh9f" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F81820789 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/12pfM/iSrA2IkTqhvuVZHEj+5O4VMc7877JSC+AiZY=; b=Ol+EuWIRsrHJe9Pz6v1sFvLKa +vRxdjKPurlOwflVO0pwSaOYzUCw87R63iSketAhJivzESVeJ2JXTXH0B/Mj1sfeXLZKsKlrPaU/y MtP0vWz1llScfq3UNVlYwmb3fwrxakJHOnJtaL/LXaejtz/2OnL3XElK/012xhZd/1JEeNFEWFi5d h+0bx3EDWNQwUZcEyBnKJSdY+DvDPB1B9GOGOkEmmnQ4sS8q5nPnMnIRjH9Bx4680EcsHUYJ9spSL NBisEuyLEHbx+ScCJVlf9PcXR5mhFouRa0tETc0PEGSQ95+iAUykGrcqK9zZlCHTUaBbdq2dbfcyT AagPzaXNg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNebu-0005Wj-Fx; Wed, 30 Sep 2020 16:05:42 +0000 Received: from mail-vi1eur05on2079.outbound.protection.outlook.com ([40.107.21.79] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNebp-0005Vq-BV for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 16:05:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m6i1Bh/F8qLzc5Z+6qRYgmDk44vo7aGn3zNXoIGTvSr+0hJNMYRTqzewBAbYaYR7mHiSWZiPOiUSPQ1Ei4cuK8YSEth7Ut6k9rfQ7ujhTwas7dWq21HDIdZZQCAEFFdGtFyZVzJuh4kJze9Yb+jQl8SS7TRJzXUYQCcpM0b4pirf07eJto5R+ywOsXnr6VwcKSrNJtmEmRRGVu4NzySub5sjuhz/aQbUGw2F4xY5xYkc+xhgLVi01B9T91CNK+BiADtmWewY7EVgoyyVt0WPsGUr7uJXyqGD2PA0SYnNJHDAWE5cDtSfCkNzjvWkEJWWgIMN4loMbQYnkShkJY4V4g== 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=wSrKRNJfdd3fpwcgvzczrJ4gMILmcG/Q02XaX9uDaro=; b=f6b1zfurSGwMJa2QMaaVc+8ODU/JEhLyHgh17aAupvh/4+mJH1DWXHGH1HDDuXIymsASswdlhEt3FWT5mRiM5grfFXuXLNmiSxIR260k3gtQdYCXYqu3VJ+muWE6Kkg2aUzNDyiQoIkwATbL4rD+/o2jhXQSx8VGytdVxsGb6m2DXDzAlsOsWBnUn/f3B5HhcnWomvFGcHIGYSh2IqJZFzfYRc0kMGw7uVAc8qWRmw7XtkD7q1sKDcNSyqp7QSTwxbvtBGPKNUNajBGd4uPFmQyau8wHgSi9qfTzlG4hcttYnvkboab6bTudkxwyi6VsrWz5QK27tp/2TapxGedqCw== 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=wSrKRNJfdd3fpwcgvzczrJ4gMILmcG/Q02XaX9uDaro=; b=adZ3Hh9fYpDbhWQf2YCieJ8W4uWCEG8Jg0bVq8fK3kiiOScZclfFrine00692lNrAa3HwuBWSbsw1wB+q/y3odV2EqKJmd+NWEQNhGhn6+vjRXOoMfLIYJrAOG9hf7ZvAR1oxZLntp3dVAZmu4Olkat690QLhnhm2drDnCduhiQ= 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 AM0PR04MB4385.eurprd04.prod.outlook.com (2603:10a6:208:74::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.25; Wed, 30 Sep 2020 16:05:34 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef%7]) with mapi id 15.20.3433.032; Wed, 30 Sep 2020 16:05:34 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus Subject: [net-next PATCH v1 1/7] Documentation: ACPI: DSD: Document MDIO PHY Date: Wed, 30 Sep 2020 21:34:24 +0530 Message-Id: <20200930160430.7908-2-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> References: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) 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 SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.16 via Frontend Transport; Wed, 30 Sep 2020 16:05:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 93d4abed-5197-4b2a-9d6c-08d8655aa9f2 X-MS-TrafficTypeDiagnostic: AM0PR04MB4385: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DVYBmxncU1AMpypelXXIo2+WmN857MuXq3NYNC0N/9o/r0so+Kwr6k+obU1RDr7uVXWse5gxBVY4CZtq7P5c4flPIgXREeK+kNcMO9pc9OnYcTaaSAb9D7mBlne+f14jFwCDXbE9SpNOWPgr3Wc/+ev8MkwfZEBE6oZ00AeQ3jdRe5YRSzhj3QrsThw8L0XwUQYaa6PnYgALWFctYnPJngx1/gcuJAFkf/+D9RMp4rl0lA1fN4xNTAYtBNxBkZ8KohvE6cWiUONNPXQlr4dlPXGN4JKszdpOW2ci60BpalH23flOCvrmHeO50GV68hnB8vVF5p8p8r3H4LxVTPjl5rRc71IKldoG8Y5DNJOuz/FB7ysgEaDZnFBkldJTEhyY5OiyjEeto/qU0gNkzJ4T4I3z03AHEm0g8Q7fQVYjH6JwNrJTEWjnAUq6k2Ixwic5 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(4326008)(2906002)(16526019)(186003)(956004)(2616005)(86362001)(8936002)(55236004)(44832011)(7416002)(66556008)(66476007)(1076003)(26005)(66946007)(8676002)(1006002)(478600001)(6666004)(52116002)(6486002)(6512007)(5660300002)(54906003)(110136005)(316002)(6506007)(110426005)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: GX0OQ9jSPzdrAL4E7AGK7yKwIfQeIhKDDU+DNzlj+LIrisUObs6FbbwliltRJe/1P6vSroLc3Uc6wzH/CyNfuTrSN1OOY/omnwtIZaAPwl070D0+4wLtMLsMv3CTnnOOVSIbhkncFfxCFcuX8ILYonBnlNJpQUYqkrMJKXTm4pqG9wiV/ZyTN/QnYwzC1bq7VrpAmDKTrkvoGG1DXFQOhgD8sfPDwPUaKTqTWoHEL47KhHBCUMaNZl986rCQWCMCgZSciMyg7ZsoS6IBtz7sMfkHrfZTgftutQ4bvq8S/i9BnkZSH3ipQ3Kw+QKL2+jfmbIDolSzvGaZ80ZBFEI1dIaGaQMTG8irhm9z+xnftTCFnZqN65Gt6iULiIOJfaRXkFKF0Xl2B3/75SNj99mK3C79GL9JvUjjGNw5IVeYn0dPQQJilrnh3VHxZPrdps5f870mI0HapKhHnUiUjCAReAlmEyPZZsTvQSuDbT7Qqlr/1JFlNV7rri7Vm8Y5HhoKaO1Kg15pHe7syLmOr/X+TgWR1XvEVaImZfUl6SfONhG4hJKo8NkM5fRki65OcyCPz7EebcMl7NbfwpPcKMC389i7fsFnxitG9LjagreeqW2jyq05d/uo2S01yiWhXzuIA9jjT+y533oVwsR2JYWg+A== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93d4abed-5197-4b2a-9d6c-08d8655aa9f2 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2020 16:05:34.7275 (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: iZtcJd+17V9hkueCUgbJ/EW1n/AlAM8vQdh6ozfZMF8t1guCpElHexai/27AEJ/t32QnyKZNmr+ErlGWGU6A+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4385 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_120537_458213_22FFE500 X-CRM114-Status: GOOD ( 16.35 ) X-Spam-Score: -0.4 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.21.79 listed in list.dnswl.org] -0.4 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.21.79 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay 0.0 T_FILL_THIS_FORM_SHORT Fill in a short form with personal information X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Calvin Johnson , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux.cj@gmail.com, Len Brown , linux-arm-kernel@lists.infradead.org, Laurentiu Tudor Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Introduce ACPI mechanism to get PHYs registered on a MDIO bus and provide them to be connected to MAC. Describe properties "phy-handle" and "phy-mode". Signed-off-by: Calvin Johnson --- Documentation/firmware-guide/acpi/dsd/phy.rst | 78 +++++++++++++++++++ 1 file changed, 78 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..f10feb24ec1c --- /dev/null +++ b/Documentation/firmware-guide/acpi/dsd/phy.rst @@ -0,0 +1,78 @@ +.. SPDX-License-Identifier: GPL-2.0 + +========================= +MDIO bus and PHYs in ACPI +========================= + +The PHYs on an mdiobus are probed and registered using +fwnode_mdiobus_register_phy(). +Later, for connecting these PHYs to MAC, the PHYs registered on the +mdiobus have to be referenced. + +phy-handle +----------- +For each MAC node, a property "phy-handle" is used to reference the +PHY that is registered on an MDIO bus. + +phy-mode +-------- +Property "phy-mode" defines the type of PHY interface. + +An example of this is shown below:: + +DSDT entry for MACs where PHY nodes are referenced +-------------------------------------------------- + Scope(\_SB.MCE0.PR17) // 1G + { + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package (2) {"phy-mode", "rgmii-id"}, + Package (2) {"phy-handle", Package (){\_SB.MDI0.PHY1}} + } + }) + } + + Scope(\_SB.MCE0.PR18) // 1G + { + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package (2) {"phy-mode", "rgmii-id"}, + Package (2) {"phy-handle", Package (){\_SB.MDI0.PHY2}} + } + }) + } + +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 + } // 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 Sep 30 16:04:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11809805 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 950981580 for ; Wed, 30 Sep 2020 16:06:02 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 37B7420789 for ; Wed, 30 Sep 2020 16:06:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nKUTL+mS"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="T5OKGQMz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37B7420789 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zZ7I4ZAwIHtv8vzDtdvdxgB1skPlbNLSKDCNnMfNBQQ=; b=nKUTL+mS/4NkIMLVoVqwk/aN4 pjdtnjHOGso3S1BC0oumeLkkk1ZR58iRpMZm8y+jlVJgVMglp6fxq8jYH/eZqzJ7+R+fMIcW3AKru g4N/Ab+9FymTCV3mjvGzsp+hi2GrdDA45sTo0Xs08TrIjwp53flZgy3cmTkm73I6LrXlqQfu2pQss rV1dw+OQLeiA9y1bjDr3C53tmH1XcR34+tbLk74M590c3lYEh1WtH28jfmllnSEjGL1xo61m3VdJn z6BiKIPZiirhrydN0t2RIqs6bDTNk/4m6IV77Ocw3kz22E8SV04HdDu4azLgvPSDM8CryJmM/043E lVPxGCk+g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNec0-0005Xn-Or; Wed, 30 Sep 2020 16:05:48 +0000 Received: from mail-eopbgr150049.outbound.protection.outlook.com ([40.107.15.49] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNebu-0005Wh-Qn for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 16:05:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VhWdIkfritXMkDjkbVR29rf2145tzZyBWwQChmkUxjvLZswnKw9txfXaWniHsgVg/rNqBlYa1yTuCHBnlHO8VYzK4V9vGLpV/ZlC5yrg5g+ZFr6lSG/XNvYgQ+YK74l6nerFt+umnbHDR672WyElVLjxA3hLtEXf8NH9C6ez9GsqcTHE4Gm2R8cac+Zf9L4d87vSMbg3YK0KDDWHXn4cICsB1PMZJvjPg/vlPL29CaUNVh5tpWg4NuDB3dL1+9fdza8k+Aaz0txpdHq16ShDGk8uBRIaxBpcEaUaIxvppr4UTdGUKfLTKFZ3BSi3C2wKQX9NOpNxYGrKAu/gZELO0w== 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=hvuhkCx3lRZ8GvposQdIeMpiQvSYrGhhCoLfujqF/TY=; b=cRnhX4qnT34rHOsfJdJ5p42UzDN9iWN2nSeQhYOQvgU8XvyHxdhOeInWQrjkYbBGXb9sDc2tEXZO6GNyAlAQNZKkuqvtDtlL2lmFDB2Vr0vJe3McKKSJSWYUaaUXNh7o5aBavwmNzy5bkL7SIXzvm+eybIG3lZ+lH+3MtxWbIIK+GvjNp2mNNETtaE9H3/d0lBKvU6g870/xkCtd4Byk3yk4NSPGQbRIFdKWFkXW74S053dXRlHRGqO3Z4Ec5ZnINdHuNTqDLDSc+iHKqeOcP81/jYpzFBvqGOBsl7SXSNdDFt3kxU27fDGTvLcT8Y0OHmzIgvjwtDI5ph72YAt7qQ== 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=hvuhkCx3lRZ8GvposQdIeMpiQvSYrGhhCoLfujqF/TY=; b=T5OKGQMzk4ByzkAwljqQGo5bHNOR7qou9ojfXYusP5qxAhaqFIreQa1QUWzAbggolCkugltJfyi4LoGgJon5cccxEcSAbQEPCoOjfDKxJ2a0v6mWeBxrZf7fs388jrcXK40cCyPVStEBLUj3mfSzLrM3njtTaOj2jSxmwoxKe+o= 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 AM0PR04MB4225.eurprd04.prod.outlook.com (2603:10a6:208:59::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.23; Wed, 30 Sep 2020 16:05:40 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef%7]) with mapi id 15.20.3433.032; Wed, 30 Sep 2020 16:05:40 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus Subject: [net-next PATCH v1 2/7] net: phy: Introduce phy related fwnode functions Date: Wed, 30 Sep 2020 21:34:25 +0530 Message-Id: <20200930160430.7908-3-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> References: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) 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 SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.16 via Frontend Transport; Wed, 30 Sep 2020 16:05:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 06c94dc9-82c0-4c1d-7b91-08d8655aad48 X-MS-TrafficTypeDiagnostic: AM0PR04MB4225: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KBdusoZ8X5RGhJWYsYdJzvUErZgrJ/Ie0p5OrxgcOyYbxVpb3ZexffViX5AOkU8RuHBrrohGtQolwFwWpVIoIdB2kxAIuPq5QxVHKew4RcasTMN/ZbzFUbpmss57n8w8Gr9Tb8uSL4yyGhl7O0+yo3upPeXbqihpBh3FbwEj5n7p5IEOKDK2qpD2W9PqU4o6YjoCBfNzxG9R8N+N3ux5PuMceO8eC7IG3Oy+AY8b5D3bIptxyyqSE6VNzcsYPCW7T0Spv7xoeNE7frpOqM8dFcTvqLBiO4xejYIfTDz1ABTOylnx2KzVpxAEiSb65ayLiYINyQfoUFKLSNo5HDfo4/2dXFibn/puViS6lFk/rkHhariEUuw4gFo04bHiEkYqbAVVfdkeHXPfRnb2twbgku9PPnxP4odc9OzFZN2TsYXsN1IT/jnpDQ1FO7U5+9C9 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(136003)(39860400002)(2906002)(8676002)(1076003)(26005)(4326008)(54906003)(6506007)(316002)(478600001)(8936002)(6512007)(55236004)(86362001)(66556008)(66476007)(5660300002)(956004)(52116002)(44832011)(1006002)(6666004)(110136005)(7416002)(2616005)(66946007)(83380400001)(186003)(16526019)(6486002)(110426005)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: vjl1YUh0RzurcNFTEBFBaLiys8NWMzNgMZBQh5eK6UUpEtjWgI1EHa6hpnT+i1aqXfnBW0lpWiWTLEro6D8wFz2jtIysco/85RW8SWXuHuCW6hq/GRT6OTmhqllJkmLtoyT9wpB+X4xIVGltrzPMbYSdL3NfxBdZ2f7fWFnSHuuWj9Ox31Hxq5kPhTv1k57ghiZVeT12aOUDAubDyI1mztbDc9gSwvq6uOkKEsRQiYRcYUvxrLaeTSQyxGZfj9GZGC9rB5PUYiOdTNd82bD9KYB2rexORLdAptZwnotWtv6lZuav+Vdd4SwFw/+9TsPHxb8Ps/i0j/oiePamvI03plFgFz5E8MxGLxdb4fSI/7E3S2c0Zp4ZoYw3Qf1Dbnop5uk15DqV7to+CVju7W2sY7YQOqRxXX2Hz/wFmSbGSTU8CU8bcMdUfWgHF+87KO3xouAx3P+LsqgoSfAdVNFMmjcg/65BU+8L9Jxszhukef5HYLtfsPU3QegE1ZqLupLagtnrRP2F4onxKSYOxgdRYNGiAXNzN2ZE9lWRUtGdkFqbqWWroP2FngDqdwG+24RuzM+/zbKZM7qCF3B+sAvdCjG34ychMTGIXo4fOR+5ZjurG7K2EuARfe06xCCuaBFFKqVg2p6dvexLZJ3G9ZF/ZA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06c94dc9-82c0-4c1d-7b91-08d8655aad48 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2020 16:05:40.3964 (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: 8ppAQOYJXvQaPpMrD9lRawujuYsgURFs7gSNthpAkhlyR8Rt5oszWNOQbL369uicvPMugFxiuj0ZP0RLRz8tIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4225 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_120542_903309_6AC1C490 X-CRM114-Status: GOOD ( 18.67 ) X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [40.107.15.49 listed in list.dnswl.org] -0.4 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.15.49 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Calvin Johnson , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux.cj@gmail.com, Jakub Kicinski , Heiner Kallweit , "David S. Miller" , linux-arm-kernel@lists.infradead.org, Laurentiu Tudor Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Define fwnode_phy_find_device() to iterate an mdiobus and find the phy device of the provided phy fwnode. Additionally define device_phy_find_device() to find phy device of provided device. Define fwnode_get_phy_node() to get phy_node using named reference. Signed-off-by: Calvin Johnson --- drivers/net/phy/phy_device.c | 52 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 20 ++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 5dab6be6fc38..c4aec56d0a95 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2818,6 +2818,58 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv) return phydrv->config_intr && phydrv->ack_interrupt; } +/** + * fwnode_phy_find_device - Find phy_device on the mdiobus for the provided + * phy_fwnode. + * @phy_fwnode: Pointer to the phy's fwnode. + * + * If successful, returns a pointer to the phy_device with the embedded + * struct device refcount incremented by one, or NULL on failure. + */ +struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode) +{ + struct device *d; + struct mdio_device *mdiodev; + + if (!phy_fwnode) + return NULL; + + d = bus_find_device_by_fwnode(&mdio_bus_type, phy_fwnode); + if (d) { + mdiodev = to_mdio_device(d); + if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) + return to_phy_device(d); + put_device(d); + } + + return NULL; +} +EXPORT_SYMBOL(fwnode_phy_find_device); + +/** + * device_phy_find_device - For the given device, get the phy_device + * @dev: Pointer to the given device + * + * Refer return conditions of fwnode_phy_find_device(). + */ +struct phy_device *device_phy_find_device(struct device *dev) +{ + return fwnode_phy_find_device(dev_fwnode(dev)); +} +EXPORT_SYMBOL_GPL(device_phy_find_device); + +/** + * fwnode_get_phy_node - Get the phy_node using the named reference. + * @fwnode: Pointer to fwnode from which phy_node has to be obtained. + * + * Refer return conditions of fwnode_find_reference(). + */ +struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode) +{ + return fwnode_find_reference(fwnode, "phy-handle", 0); +} +EXPORT_SYMBOL_GPL(fwnode_get_phy_node); + /** * phy_probe - probe and init a PHY device * @dev: device to probe and init diff --git a/include/linux/phy.h b/include/linux/phy.h index eb3cb1a98b45..7b1bf3d46fd3 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1378,10 +1378,30 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, bool is_c45, struct phy_c45_device_ids *c45_ids); #if IS_ENABLED(CONFIG_PHYLIB) +struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode); +struct phy_device *device_phy_find_device(struct device *dev); +struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode); struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45); int phy_device_register(struct phy_device *phy); void phy_device_free(struct phy_device *phydev); #else +static inline +struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode) +{ + return NULL; +} + +static inline struct phy_device *device_phy_find_device(struct device *dev) +{ + return NULL; +} + +static inline +struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode) +{ + return NULL; +} + static inline struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) { From patchwork Wed Sep 30 16:04:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11809811 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3993F1580 for ; Wed, 30 Sep 2020 16:06:13 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F16C32087D for ; Wed, 30 Sep 2020 16:06:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="snGIArkZ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="FcgL0HzM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F16C32087D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pGuqa7IpaqB+SYI9bvGHxllguTpeTm2EwBQf8m/2/O4=; b=snGIArkZvvlABJUsklbF00rhP 8Vy1YAeu2FnFrrkD7Q1xkd4Yt0O80zK7zWwIv+O7c89PVWKxbBV+0s3WJbmgietRadR83ua0ndg89 r/654qus2q+K65VgjSbI1GtLtQ2lX0FAE0CKYrWggGGA2JDNywBpPr09ILgLb8QmG9rXOzJAWZtQe vMllD4fSQBoSiXWNHl8KwHdMI4Xcy/PFOvcRPR3mFF6mYKuQcb1cMQUnCVg/a1iR9ebXsoZDlRFGJ N0NlEZTSB/hgrkFLrk5u5+3QaFhJ4FNusGEldWVW6jEvZgBt+OxUAKyV6j99phz3PLnFncFCcWJ99 P1bd5Oa1Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNec9-0005au-Rt; Wed, 30 Sep 2020 16:05:57 +0000 Received: from mail-am6eur05on2047.outbound.protection.outlook.com ([40.107.22.47] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNec0-0005Xf-A0 for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 16:05:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=glA3pAeIa7y0jrOhNodRPEbZLfImljO1rGfjiYgXnXgEY09FDg9DYS/mLXM8+62B1xq3jfFDcPt4+yg6EVhClpevI1/1gWv1fSM+vOFUfYK+MFwxR0Y4ULJQg4pOCnzcQH9hHiqCgB4kpWIBPnChLrsUPZ+pY3zv7wiAFSqA/36TO5ziHjkQX8UF/Bgrx75kARn4Ov1WQmsi+xoC5RccKKr8gtBqLkVHGG9v29roT/Xanj4Sk0HfAd6TnnWFmT1+itcuvomUY1JeAQSDQKBpnFfiRl74VeutSjFhVhFx694DitC+zdI3L04JgiPc6RKxqaTBVLV+k29PGHUpGBeo3w== 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=eIXDmHS9ks/6wpJhz35sSqYKFvC6qQutKaOvCkH8Kb4=; b=GMGNWatp1hivAFOoSbPt9O/H5fGGfunCnJyZpkW2lyBP94dmXqPqBdjB/+CXnM32LC038+rI73DaqRr1aEA605ItWR7GS7nfT3N2+XS94W0dUnVVgZx+7/nLT9OobIb1Ythe+gt+jR6Q12Etib76MOeKvdKI7XykUh6oZUNUhtDbNJaOGt3bdqTf2VTX9BKgbuI56cWRz4STLn4P+uiOOu+Vyz40LTPXYNyczgfU86Qu2j/4X0g8G7hFdstymBbIqDPzJp7nXO+nbfrxz/UwJiJgpA6+2bdqnYHTghp4+GIo74cNKPHiOksbZrwEeIXUOkPrGK1L61hzjXOXcefyXg== 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=eIXDmHS9ks/6wpJhz35sSqYKFvC6qQutKaOvCkH8Kb4=; b=FcgL0HzMOG84HsMLW4anRsKtKizePlYzf/O+8Of/3E/nAtW3XrgjaFlBUOmcro3X/samgiag0KpCM0nwj+/Dgz7Jyiz9rRefx88zlo0PHPDBZsStHcJtOshHpi9woPgmJ90ttdSCrKJBlMzaXkltrFJM6p8h6K4qFhlSYAWeZiw= 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 AM0PR04MB4385.eurprd04.prod.outlook.com (2603:10a6:208:74::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.25; Wed, 30 Sep 2020 16:05:46 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef%7]) with mapi id 15.20.3433.032; Wed, 30 Sep 2020 16:05:46 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus Subject: [net-next PATCH v1 3/7] net: phy: Introduce fwnode_get_phy_id() Date: Wed, 30 Sep 2020 21:34:26 +0530 Message-Id: <20200930160430.7908-4-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> References: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) 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 SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.16 via Frontend Transport; Wed, 30 Sep 2020 16:05:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 13137ea6-e512-4183-3a5e-08d8655ab0ac X-MS-TrafficTypeDiagnostic: AM0PR04MB4385: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0EWGBmYVE+ahIPF789tk3FMRNq20HXPS2PK8qInSI4w1OF5tXsN6YF0MC8CJDAZMVkrIyLntZQquvQQuuE0OajhRqlpdfT3xCjCl+BlAJXKgQGzvQLatSQPJ7G2yTPM3cjPJRYgb5vFANBQaoPvtkC5S5mTw3TtOLbyd0cqMqzL/RAan57PL53ZwcnoxLSgn2PqkwX76xa/RuO0ZrI+M63cbzbWjw6GVpZQSOE8GUti/r0jZ0j+lWecToGV9rJSk8PsAqielZfEdBVWsGqV2EQ8ETdx7cqHcmF4oaZtuCcQ5FxNELMd4u8vxhvXP14mtmtmMtn5WUt9yPU/5bVISngmFCwj6QjvY9Oot9U5a6xcLrSHZ1V4Gjv1KdwAg8c6eI56kDsSVLHvDtquPobZnNuql4didJvQoBOKCwVf+XN/4UcHvU1p3UZRdXRz9Rq7k X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(4326008)(2906002)(16526019)(186003)(956004)(2616005)(86362001)(8936002)(55236004)(44832011)(7416002)(66556008)(66476007)(1076003)(26005)(66946007)(8676002)(1006002)(478600001)(6666004)(52116002)(6486002)(6512007)(5660300002)(83380400001)(54906003)(110136005)(316002)(6506007)(110426005)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1wFwIIcr0TcJjxTHBV9UGOKnkIGqHliko/Xr6/U/1iKhrVH6RNi7ei7uYHXTArZWy90CHsk8bQAXdMCGAGmXzRxMQ7i7WmkSPTJekTownPKXi9/ncsXq7LNFmg1F/FU+rBpW41VmHgklRfrOr7g+QRL8sqh80k5Dh0H6fGrJIKTGEur9PCrXO8iaKkL5CYnZ6RORYK1UsK6Ikwe6Zz+U0RU6SiM3leKRu/rPyWIM+fE2bByq370sz9Di4GYHUWhNP2JOFtDxXByEvBcNDQZieCMNVMtV2L68BC9RaRMuvqNPWkUs6X7N+Nz0K5k27Ew65tsxv8I4LrF8qP9HBsu8CKUO5i13mlVMJ33iigftYUDV4MFryldQyOTD5jsz0p4zWVtZM/HZNAOcahBnvDMLVLwgOhCvF+UlFhNxz3dzGm+dx1ZlEWOkqt7HuQ84HVnJJTdRyWkKcNUJ2tnNdPTRRFfLGuNMd6qHbV+ChO/3XNSMPd1OLbuX6XXdPbUJqicASXFHyYLPFgS4BGzkF0ijvgtU96iIGucsk2U9SnmfiqLxccPPikziqKf7B63wRluVx7UvFAW72YSpDu8fPqwVH3S1M0jAJ2x4nOxe2zldVtZ2YJACm6NYgC4Vviv9bA0cQ1gDqbsTbQhk7jg2O8wRAQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13137ea6-e512-4183-3a5e-08d8655ab0ac X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2020 16:05:46.0183 (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: SHW4eILHgCGFi5JcoEjsQsxG9OCj0tYmsamJ9KAHyzhIgXrghtRfHCWLAcI7K3wr05E3NrJSroJqvXSIavdaew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4385 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_120548_382317_8DAFB7C7 X-CRM114-Status: GOOD ( 18.45 ) X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [40.107.22.47 listed in list.dnswl.org] -0.4 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.22.47 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Calvin Johnson , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux.cj@gmail.com, Jakub Kicinski , Heiner Kallweit , "David S. Miller" , linux-arm-kernel@lists.infradead.org, Laurentiu Tudor Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Extract phy_id from compatible string. This will be used by fwnode_mdiobus_register_phy() to create phy device using the phy_id. Signed-off-by: Calvin Johnson --- drivers/net/phy/phy_device.c | 32 +++++++++++++++++++++++++++++++- include/linux/phy.h | 5 +++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index c4aec56d0a95..162abde6223d 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -845,6 +846,27 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id) return 0; } +/* Extract the phy ID from the compatible string of the form + * ethernet-phy-idAAAA.BBBB. + */ +int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id) +{ + unsigned int upper, lower; + const char *cp; + int ret; + + ret = fwnode_property_read_string(fwnode, "compatible", &cp); + if (ret) + return ret; + + if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) == 2) { + *phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF); + return 0; + } + return -EINVAL; +} +EXPORT_SYMBOL(fwnode_get_phy_id); + /** * get_phy_device - reads the specified PHY device and returns its @phy_device * struct @@ -2866,7 +2888,15 @@ EXPORT_SYMBOL_GPL(device_phy_find_device); */ struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode) { - return fwnode_find_reference(fwnode, "phy-handle", 0); + struct fwnode_handle *phy_node; + + phy_node = fwnode_find_reference(fwnode, "phy-handle", 0); + if (is_acpi_node(fwnode) || !IS_ERR(phy_node)) + return phy_node; + phy_node = fwnode_find_reference(fwnode, "phy", 0); + if (IS_ERR(phy_node)) + phy_node = fwnode_find_reference(fwnode, "phy-device", 0); + return phy_node; } EXPORT_SYMBOL_GPL(fwnode_get_phy_node); diff --git a/include/linux/phy.h b/include/linux/phy.h index 7b1bf3d46fd3..b6814e04092f 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1378,6 +1378,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, bool is_c45, struct phy_c45_device_ids *c45_ids); #if IS_ENABLED(CONFIG_PHYLIB) +int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id); struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode); struct phy_device *device_phy_find_device(struct device *dev); struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode); @@ -1385,6 +1386,10 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45); int phy_device_register(struct phy_device *phy); void phy_device_free(struct phy_device *phydev); #else +static inline int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id) +{ + return 0; +} static inline struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode) { From patchwork Wed Sep 30 16:04:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11809817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 987BE13B2 for ; Wed, 30 Sep 2020 16:06:32 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5EBAD20789 for ; Wed, 30 Sep 2020 16:06:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="b4DFfSR2"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="MaDeF1PE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EBAD20789 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hJEb9ZLf0lXxi8ma0y7Ae8oIfYPlR5Xhv4QiVcjUXVY=; b=b4DFfSR25AraAoBbbx1fNPcqD QPXxvFVZn6XVzU35KOYPBOdEpC5BVN1B80ny7oUAku5Upwosn9izRtJBWPuLLwAb8A6aEKgyZ+L3j pcO7hWK10kOcm5IIpQ6b5CNLVqu2j9j05S/e7CXEJ8FX3fJJkWUceO0ZZv2asnPjNhQstdu2E49Fj p+lySb/yP0qwpMunBGEPPbL9s9cR585YF7F8zV9TUqTZ/dEcgIpCQKhymLenbfzNWAq15KgeGBYbS eetcHAHOciDHh/SaO3i7eJWWzLkstpfrxltFrVM7qP46Ck2b01TDdr2vXGVvXnD+PkNG+74tj9XxO I9/Xv8JcA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNecR-0005gu-UX; Wed, 30 Sep 2020 16:06:15 +0000 Received: from mail-eopbgr140080.outbound.protection.outlook.com ([40.107.14.80] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNec6-0005Z5-79 for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 16:05:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MgXuj3gRiG/oXKx0hw3r5x+aiC8Wrm0L/hKGDkPHhL+TrWThbOe35fQ5lzhIoIrdddbFcc4KRieng1CZyMk6vuNWsoKH65KIaJNi1B3m5vtLsk9NgD9f4wfRaVOHZ+FUqWldXviiT2m1mYq0aWndXn79Kyq+I/grVOU4xoU/Mu4ukdY83aJjkSaKoicFTxptY8kOfyFOCbBvrv42weU1s2pPWRhBfOojsdnKB7gWEyal29OKWrJ2gaNnNO3OQFsviPQ+uCYfjwHF0i46n4WaY1DCWUQWSi1bCC/QijNmYFq0IdnGy/QiOKAckdaddjNIT1mHX6vSgaDvHUkvmB7xcQ== 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=ECb2GyBugw5snyNW/PRg8YO/P7eoSKSgffoQ/QXTua4=; b=avqCdujzzYWN5U5AJuorySqsRUjQgfLq0rfZBFpzNPE5XKh8nJsW3ZBHft1a04EvdSr1FmtmmbQpmvJVpyw3wIWUZfySvy9v9e3F26P+Qn7TTSyJKqUce39crmpfTD4WEU6TQVTx/Rc8+hFvquuMw4vfG666OvxYdySgua6UzFZ8xET2mGL7snvUjoRkqwPSzKwHVRX1EBNM2c2tWHYrfwinHAMNZVqzGO060IKc1PZDWOKOUTA+HbOvTHz4n05i4g+2XxhuB2zUfv0O/T+JXU9yp1PaLRgMr/GuDLccGQVbRewihyvcxOXifGtRfuRXm1Il71Ku/O+eJ7q0v7Aykw== 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=ECb2GyBugw5snyNW/PRg8YO/P7eoSKSgffoQ/QXTua4=; b=MaDeF1PExqLNbxgpvhKRG8bkhChuHO+iEv4IznTnqSA2mNemuLIOZIDRK4ihGT1/7I6dGGV+NB30bBi0pB+ml1WtRk6yKrrhlR4nB4FWH81SUCLpP9cVYqpLD9k1vWmDhBcn9INeQT3GTRTXoQtMgPzuPYA7V+QUulBbzYf67v0= 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 AM0PR04MB4225.eurprd04.prod.outlook.com (2603:10a6:208:59::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.23; Wed, 30 Sep 2020 16:05:51 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef%7]) with mapi id 15.20.3433.032; Wed, 30 Sep 2020 16:05:51 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus Subject: [net-next PATCH v1 4/7] net: mdiobus: Introduce fwnode_mdiobus_register_phy() Date: Wed, 30 Sep 2020 21:34:27 +0530 Message-Id: <20200930160430.7908-5-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> References: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) 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 SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.16 via Frontend Transport; Wed, 30 Sep 2020 16:05:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 00e5a9e9-7c77-452c-a341-08d8655ab401 X-MS-TrafficTypeDiagnostic: AM0PR04MB4225: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QyCFf+9xlUDSg34y1rl48368mpaEEi0SFjuhS5Op1vkappbebVARvnr5sWjblYQ0k5ia45ejTnKWbiB//T3VTs1p1aAHma0TstNP31uykEIL29hE4snQRaG4UBjhdbmRnC8ggKeM4mmA6f53EbKwSWbIyjeH5vwl3bL/va0V1qFX/3krCDDOT9SvFIZWrMO2gCmALN/ZQrXUTQltD5lTsGUWl5MZUnGf6NllOS91ralgd85Szh24N50+BVS9v6AGyQwG90YDe/Cna2uJRCQQflDlc/nXbaeYfXtK1hDDpA8GknkxfZxkdf8YsxPFqXMnwdwnnhGpPCTzt/maFAPUFRWNy9+gvG5dj4vfblyh+IESSMMrENfSTfaFnVaF2Hw3rhLg0gcFw4xf47pps/VDxOaJDyS3QRbzjH/Xqk2FCcUh/0tfiuGzPT37mNF/uqo6 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(136003)(39860400002)(2906002)(8676002)(1076003)(26005)(4326008)(54906003)(6506007)(316002)(478600001)(8936002)(6512007)(55236004)(86362001)(66556008)(66476007)(5660300002)(956004)(52116002)(44832011)(1006002)(6666004)(110136005)(7416002)(2616005)(66946007)(186003)(16526019)(6486002)(110426005)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: qF0bpZoqNwSNsGBLagmpedbSO8LttvqRoOoXb+Kq9Wh+Qh2Y+SBgPzJSTfwwnqRGk0rBHqIA8jb+yXdB1D6AKgmne916eg7H6RZXfVO5OJqGdMSx2IrIez5YJPtF6lX+12U+T1rh3UKYQMQjqlYUuzsG+uLJh9PzI+Z20HAsBOmBbDe4+Ox3rYTtTLw4nLpeL07L2CtSFuERmS+YMYqnHr+i5DHQy3t2vk40Cio0CXIiD0sH1+o1lwVRaoL9pjxznW0TsA8IHiE/TufDxAODcleKUuFZleST9LpQUqg6Ffscpm9/GGb0oO5otyWK3AEni9RxUHnMk5JZU+w4Qca0zsUuLoZocVq24RnNFHjFKm25RaT23L6mc8JlOX55VwwII0f3mEg/Ro9OIdSGS0nrd9fxtQC9mBT5vEop60kPsO+tfqVcgsT/1A86OZj16CKK2wcNKAi2NfGCyysUCHk9MOu/AGTsfz08X/VKTqoU2nOeiXSOptDe+JQCBalTbC7m0WfLuGDs1p7Cb1E6iwAilTuagTIOrQXTcGbaQPKm3kUH8nJU1nZyS2nUfteaqhnkUZ3aJCjDDGY1VJR4paQSZUMAqbnpdsThwzfVfLVCjLxU8MxOhaB1TRJfiPFQ5yZcs347Kb6ycjuXm0roeipC9g== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00e5a9e9-7c77-452c-a341-08d8655ab401 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2020 16:05:51.6092 (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: eKR9Ux5Kb3Ra8HgjLTXWpoQfdhzcnY82J0Mud3YWONKSzi8Ty0nvhmTwSG/KN4BORDS0bo4CVD8bUJOFkfIk5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4225 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_120554_308746_F5AA11E8 X-CRM114-Status: GOOD ( 18.30 ) X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [40.107.14.80 listed in list.dnswl.org] -0.4 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.14.80 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Calvin Johnson , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux.cj@gmail.com, Jakub Kicinski , Heiner Kallweit , "David S. Miller" , linux-arm-kernel@lists.infradead.org, Laurentiu Tudor Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Introduce fwnode_mdiobus_register_phy() to register PHYs on the mdiobus. From the compatible string, identify whether the PHY is c45 and based on this create a PHY device instance which is registered on the mdiobus. Signed-off-by: Calvin Johnson --- drivers/net/phy/mdio_bus.c | 40 ++++++++++++++++++++++++++++++++++++++ include/linux/mdio.h | 2 ++ 2 files changed, 42 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 0af20faad69d..693eb752cbf7 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -106,6 +106,46 @@ int mdiobus_unregister_device(struct mdio_device *mdiodev) } EXPORT_SYMBOL(mdiobus_unregister_device); +int fwnode_mdiobus_register_phy(struct mii_bus *bus, + struct fwnode_handle *child, u32 addr) +{ + struct phy_device *phy; + bool is_c45; + const char *cp; + u32 phy_id; + int rc; + + rc = fwnode_property_read_string(child, "compatible", &cp); + is_c45 = !(rc || strcmp(cp, "ethernet-phy-ieee802.3-c45")); + + if (is_c45 || fwnode_get_phy_id(child, &phy_id)) + phy = get_phy_device(bus, addr, is_c45); + else + phy = phy_device_create(bus, addr, phy_id, 0, NULL); + if (IS_ERR(phy)) + return PTR_ERR(phy); + + phy->irq = bus->irq[addr]; + + /* Associate the fwnode with the device structure so it + * can be looked up later. + */ + phy->mdio.dev.fwnode = child; + + /* All data is now stored in the phy struct, so register it */ + rc = phy_device_register(phy); + if (rc) { + phy_device_free(phy); + fwnode_handle_put(phy->mdio.dev.fwnode); + return rc; + } + + dev_dbg(&bus->dev, "registered phy at address %i\n", addr); + + return 0; +} +EXPORT_SYMBOL(fwnode_mdiobus_register_phy); + struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr) { struct mdio_device *mdiodev = bus->mdio_map[addr]; diff --git a/include/linux/mdio.h b/include/linux/mdio.h index dbd69b3d170b..f138ec333725 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -368,6 +368,8 @@ int mdiobus_register_device(struct mdio_device *mdiodev); int mdiobus_unregister_device(struct mdio_device *mdiodev); bool mdiobus_is_registered_device(struct mii_bus *bus, int addr); struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr); +int fwnode_mdiobus_register_phy(struct mii_bus *bus, + struct fwnode_handle *child, u32 addr); /** * mdio_module_driver() - Helper macro for registering mdio drivers From patchwork Wed Sep 30 16:04:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11809823 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7896F618 for ; Wed, 30 Sep 2020 16:07:16 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 490A220789 for ; Wed, 30 Sep 2020 16:07:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bf2JRc8z"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="J/F8/nV/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 490A220789 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ikH5rmtE/sKfVthsSHXyS7P5R72FRjRubWgWy+h0GGY=; b=bf2JRc8z768zTTXizUt96A+Q6 x9l29c51oHZewvRY9Q8xztyeaZwaSontjyoup0gdnNafsHFXQ0oR+Y7uOU81ZhEh2CtuzEWhFTCrw NAjAS2CYxEEKPuhUD8VkFpRjockadh8i7vmVF92kek8fBNBTbuPkftap0J71DIi0lpTl8aLAypnRA 9/xtFQAu0vXDddPuEPxYh1pojRTtJXuCQRP/knMgDKICvlRLWCddIq4Uq+3I36bQVd8hwSIStDpE4 IY1sHEL4S7Jm2z2X2kq6cS9AnzYcdzOB2LrDSSE/gTOz5+4XRgE37p6bNi9yzm5HydFa4qsvedj6O 4KCIeaM7Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNed8-0005sh-H4; Wed, 30 Sep 2020 16:06:58 +0000 Received: from mail-eopbgr150052.outbound.protection.outlook.com ([40.107.15.52] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNecB-0005b7-IZ for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 16:06:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=huJ+t8VQhLwzYVWhimJO0CxNStgAR31Z2YkbTLuDrVLSgKDtJMLvVTpneSzAc0JTayOBscMcIYlRJ5ntQhud4x2coUBmsr7SsEDr2117cj3WKpDKngCWv7074q27R4M9YmBeh7vGk6f3KHF/Nc5OlDthIj5BV8GNRlc9+2cCplgqlB1JgsvEfNfwry0CNmper/U+G2qpUVGUN+SNBx1Er+Z7pOcKwny7KpCL4GNMmFxH4nT0NdZGm7vxSt+GakFvu6fjpsmN22UiGZCyBXMfxpANPT9SbvMEZqlcjGosEu/R0QexrN2mBLIWu+8uP6P1V8zgLwsqSMw6w6BVz51zXA== 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=jFmMyIB7Zx9V7suMoZ3VxseToPJ27dpe5XUAiZVXv7I=; b=lKAohQwjHUJ9xJsgwpmYxbO6j4cJ9GX6LfCNg7F+e3o5S5zItVUAJozb1jr1oVAK19a+ZHd/7gP0hl8QIVAvhQ8r8RZjKiSj/kSUMFrnKGCtuBxHfV3Ap1XTc5KcxHkvxxu6EjzOkB7u50Nvlh8WmronTEq6c7KNZNa0+2XASptNtWs2C2Wg1WGRx0SmCal9PMhw1dhCRQZmg5n8BW3WbLYsk12JA8l7nGa/W0zjJX7GOidB8jA8LwQbSzGUYF8iz9NCol4/OetuvMtZvO9qhdyyKMO+INZfOzax7DV490dX/nLBOmuOImW4LdHsv/D7go6G3XEJPm98WtwZP3gpnA== 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=jFmMyIB7Zx9V7suMoZ3VxseToPJ27dpe5XUAiZVXv7I=; b=J/F8/nV/IymxM9kd4pZtNQJNXJLWFZILkOMgB+/3t9aBDYinxVFXjztoo+KtaDqv/LlWn0mTD2bAj7SkxqjE/el5r3Aj6RTbxXLJQbVGeHvnxSpCLQhLlbLgx1Cs7TyZC5ZWhPDjrlI6z2fw/6eQoDdbkMoCS/OrtJQ5JBiJdao= 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 AM0PR04MB4225.eurprd04.prod.outlook.com (2603:10a6:208:59::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.23; Wed, 30 Sep 2020 16:05:57 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef%7]) with mapi id 15.20.3433.032; Wed, 30 Sep 2020 16:05:57 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus Subject: [net-next PATCH v1 5/7] phylink: introduce phylink_fwnode_phy_connect() Date: Wed, 30 Sep 2020 21:34:28 +0530 Message-Id: <20200930160430.7908-6-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> References: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) 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 SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.16 via Frontend Transport; Wed, 30 Sep 2020 16:05:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1282ceb7-846f-4094-e0a5-08d8655ab758 X-MS-TrafficTypeDiagnostic: AM0PR04MB4225: 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: vyqAg/ozWlInm6T3j8aZTHpYuujDjAsxm9y/n/nJKYwE5gIi5anMjjSuH8BmS8c/wuVhxs9f/uHaEN8FW0LzlBn0/dx1fTnfMfoZpxFyKRN/FYdVbc+0YU7TaRhjWfFcTi3iDzDH0RR0pqK15KVTJOi6CdlfR+/1XizwaBTJv/QQNwZZ8dEKoB783u7AtEVD6vzoRSePduyGVbDdI4Nda6hwuKaDXqqbh23lBzrRD2bIyrofGwXFW5ThAYAqTjnUqU23stnqCcqbEUqGvMrN6rw5suhJ63yPLkwSBDjm0exvCBmTCLL1pi5EfZdCvzWVVNbIiWZkomBa7jj6o/uz1V7Y+pe46Vniu5bsZGXPS/op3zxsYfJcCaNgriXEiW9Z7VAOu0MXaxg3FqyPM2f+QkT7sjKbtxXUCgW8MsnzUMq1rucjJWVPk9Z9ymsJh99C X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(136003)(39860400002)(2906002)(8676002)(1076003)(26005)(4326008)(54906003)(6506007)(316002)(478600001)(8936002)(6512007)(55236004)(86362001)(66556008)(66476007)(5660300002)(956004)(52116002)(44832011)(1006002)(6666004)(110136005)(7416002)(2616005)(66946007)(186003)(16526019)(6486002)(110426005)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: SXNZHeZ+6pH9ulDd0JHG+eoYx9W6JhJAxVx7n4tVC33J4LBDRNnSmlAHuVu4IXUAAaM9SbGC3oaSdOdTmq+sPkkgNtk8C/I+aEMxCBHE/14xkfYJaO8tdIHPoRVqDwSt+VbinwvtFZcof3KLnNNudRVnhtpwiHQ3uT6LiT5hZqwodcYFNofPqB2ohXGzpDBR5F9eQNxoqqLijiZUAXIWQe8HJfA6TB9GMZDzixvmq6l4RL7TgZDk1K/DYHMtifmgBsdUK9DnGFiCapj8Uj7tBjVlUfS7CpL1xbYIkrsX8fsrfBOsER1WKjZlLXuggjiEoFpPmLmZNsXi4ALSjoBGqmHqA3XSZR9MaGKWJCOc/unAhm6uOjJgEq8Mww+Oj1SLLTI8xzOqrn50OYpCd7RxWqGtUCN06rD9aDgGPDm/8SFjPK5w2IoqCF4WcUUM9ilF7cSuXRq8p4eTjBvc+PwPqBx766qVO05koaEyx0v3qAcDxx9q9HAJk/K2LxCwhQ8XSy3hfbOrpNpOinW5XEdS/Lb1aw3gMZ0ZUA4GDBEKeiK8xqpQfEWDn7jFHLaFpbIulZbEXTfrROlQzCNCuPIGPI9iT8u9Kj0GZJ4Fq0bYGELq/vFKSs3qDEbnjGIzsGawkRAjGSLCMj6vmYJT6XeuAg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1282ceb7-846f-4094-e0a5-08d8655ab758 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2020 16:05:57.3200 (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: 6NllGopYDWmMfjMZLz3UkSQ5v/IZpZ0PXDgrgdS0ltKsXgzu7fpTq1phD5U2e4l0+4G7nff2rr4ruI0CMAWqJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4225 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_120559_720316_E9AA8BDF X-CRM114-Status: GOOD ( 17.86 ) X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [40.107.15.52 listed in list.dnswl.org] -0.4 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.15.52 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Calvin Johnson , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux.cj@gmail.com, Jakub Kicinski , Heiner Kallweit , "David S. Miller" , linux-arm-kernel@lists.infradead.org, Laurentiu Tudor Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Define phylink_fwnode_phy_connect() to connect phy specified by a fwnode to a phylink instance. Signed-off-by: Calvin Johnson --- drivers/net/phy/phylink.c | 51 +++++++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 3 +++ 2 files changed, 54 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index fe2296fdda19..ca88bd90d605 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -5,6 +5,7 @@ * * Copyright (C) 2015 Russell King */ +#include #include #include #include @@ -1120,6 +1121,56 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn, } EXPORT_SYMBOL_GPL(phylink_of_phy_connect); +/** + * phylink_fwnode_phy_connect() - connect the PHY specified in the fwnode. + * @pl: a pointer to a &struct phylink returned from phylink_create() + * @fwnode: a pointer to a &struct fwnode_handle. + * @flags: PHY-specific flags to communicate to the PHY device driver + * + * Connect the phy specified @fwnode to the phylink instance specified + * by @pl. + * + * Returns 0 on success or a negative errno. + */ +int phylink_fwnode_phy_connect(struct phylink *pl, + struct fwnode_handle *fwnode, + u32 flags) +{ + struct fwnode_handle *phy_fwnode; + struct phy_device *phy_dev; + int ret; + + if (is_of_node(fwnode)) + return phylink_of_phy_connect(pl, to_of_node(fwnode), flags); + if (is_acpi_device_node(fwnode)) { + phy_fwnode = fwnode_get_phy_node(fwnode); + if (IS_ERR(phy_fwnode)) { + if (pl->cfg_link_an_mode == MLO_AN_PHY) + return -ENODEV; + return 0; + } + + phy_dev = fwnode_phy_find_device(phy_fwnode); + fwnode_handle_put(phy_fwnode); + if (!phy_dev) + return -ENODEV; + + ret = phy_attach_direct(pl->netdev, phy_dev, flags, + pl->link_interface); + if (ret) + return ret; + + ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface); + if (ret) + phy_detach(phy_dev); + + return ret; + } + + return -EINVAL; +} +EXPORT_SYMBOL_GPL(phylink_fwnode_phy_connect); + /** * phylink_disconnect_phy() - disconnect any PHY attached to the phylink * instance. diff --git a/include/linux/phylink.h b/include/linux/phylink.h index d81a714cfbbd..75d4f99090fd 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -439,6 +439,9 @@ void phylink_destroy(struct phylink *); int phylink_connect_phy(struct phylink *, struct phy_device *); int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags); +int phylink_fwnode_phy_connect(struct phylink *pl, + struct fwnode_handle *fwnode, + u32 flags); void phylink_disconnect_phy(struct phylink *); void phylink_mac_change(struct phylink *, bool up); From patchwork Wed Sep 30 16:04:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11809819 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B8B213B2 for ; Wed, 30 Sep 2020 16:06:44 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E3B920789 for ; Wed, 30 Sep 2020 16:06:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Wu1JC+X3"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="a/5QarEn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E3B920789 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=x/hIsPvwW0Po9ImEAg2D1nabL3IhsBFJBYIvPBmz+uc=; b=Wu1JC+X3V9g8RZgIKQ0u1Y/88 xeFibXVC31dFT6idzK5om2KU6857jqiA+lID1PQDk8ns6nFtzmDCugdqOVNWRVzPSEXJqJOy34ZjI P8HAHa7oqGDtwx2KyKQs3Yu9TIID++OLvzulFM8EmgtpJ4a5b6b7+PsPsSBv1A4SRT8TYsW51Tih3 bQUuPiOmEgauT8WqQWc9uygbL0kbVdGSi7CoRSGqvqnzfribyz2cbvYRrNNG+4lNtRB1GEpPJ5FYP 82q+MQeBOxonyuZ5/MAoLUKkVUvx2VkkZqI3CFzY1lk93IgSNfltC8Qh1+R+9yNY7VTbqFLycq0KP SEt27mzPA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNece-0005lr-Qv; Wed, 30 Sep 2020 16:06:28 +0000 Received: from mail-eopbgr140089.outbound.protection.outlook.com ([40.107.14.89] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNecI-0005dP-0k for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 16:06:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iLOoSlgoqnAv3r8yelG40ETLFZ5M5a4BuEI5eY0U9rj1JYz4BMt7X0NknAO6+hWcDDciIZIrCy8AFUvXWVgl+Nq35Jey2z9noLKOzyfDRPG+EwrZNpgSuG5A2QMmmI+6zAnz5OjKGq813xtnWEyRE3JVpcM4seeW/h3731f0z8tDCxo1Cytk0TBcn4Yhl0ZHLesa7CgsnMz5uD5hx4xvDESYapbcBnYn37Hk/SOU40CKXco8YrmlAy0Nrx2FNfICR0S6qxMLlvNl9j8bv987hWNT65wm0aZvK7V6d9my4Jji6Lu/3vx6QvAPwQa51pUTLMs4KhtYhzWZ2xOK3+WrFA== 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=wyMoqU/rBUT3Rgvjcn5APWweuSROhJSwJIUOFfJvq4k=; b=B60AVjSpo5E6XemDib11hKD0Bt7Vs48osF9JsdPZ0Qmq3/Vk541d7RR6jqoiXYNXIug54jdKgEYRztp+9MOZ2oPKULAh4STiLmB6rSck8IFeBc9PZ+hNQV0lAeD9c9agxoHWIHIfhXQuUarktJGeIuEkXKFutwsugsPphZMZdOiyg8kEaJBMq7awaoKAeW0/mGYH2U5DbCXcfp/qATVI5n2VEz+0xX4tZn9u2D3OAnHm35n2f+3S387+Ql7/cqDpg8KJ1M9zLkvhLUMOzxvfdNRugIcofXdaWSvFcsF8UkfmwzuA35NvbkOrGTk9Q+qT8PHJUlooNXBKZ38/c8Ou/w== 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=wyMoqU/rBUT3Rgvjcn5APWweuSROhJSwJIUOFfJvq4k=; b=a/5QarEnKKpxjhAc5pJIVxr0ftgY4ym1ig9Xmzjkn5CZ461m954Cs7BqkcuxFh/GpgBxCxYbmNOkmdNGapx8BQvMxVtw6XPCkMHSRIH8DLCbBwOHjGYPEa1I33sc99WcA/pGGsUN+o83i3Aa6Epq+3GqvyLgAUZTQE6jb4uC4ts= 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 AM0PR04MB4225.eurprd04.prod.outlook.com (2603:10a6:208:59::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.23; Wed, 30 Sep 2020 16:06:03 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef%7]) with mapi id 15.20.3433.032; Wed, 30 Sep 2020 16:06:03 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus Subject: [net-next PATCH v1 6/7] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Date: Wed, 30 Sep 2020 21:34:29 +0530 Message-Id: <20200930160430.7908-7-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> References: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) 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 SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.16 via Frontend Transport; Wed, 30 Sep 2020 16:05:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f548f740-6652-4f75-1cc6-08d8655abac2 X-MS-TrafficTypeDiagnostic: AM0PR04MB4225: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:628; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P1aoRShlpJl9qt0b7tpfQuUnyUMBkom49WE2IKamj26DOz9voh941W8cHNlahqhp8lq1xrsGdl/Kw6rIGb3pgxZLN3JSRLSXJWYLYQ7/K+4tLB34jipkq2GCM2VaKBv6gI627R29n9tZirF5DyZLuLNjcnyxKamkyIl53Ebs5XkxfM+QT+3SFd37nQRbOTlEMeIhfnBdqFUXYPknNbp2ks2NqVNXKP4pBRwtAv6ZHvmif31gQ5srG4yl1OwMOsgGUO1ZfYrL/PWS3cP9QOHQNq185TtfcGQ7MJrx3BHKs/RFtPQq7Tu6lDSr6GF2W9ZWwipYPI88hiXN3cScefdkvlE3uAx1mAoXeFcWT+cZLT33JtXv8ZGL9h7wFbh1IrFd4Q3FoYNU3mUEUDqQ/EFqSap1GTyuR9HjzvaL5sWyv5DyMRDo3aEBbP4+XafcjE+d X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(136003)(39860400002)(2906002)(8676002)(1076003)(26005)(4326008)(54906003)(6506007)(316002)(478600001)(8936002)(6512007)(55236004)(86362001)(66556008)(66476007)(5660300002)(956004)(52116002)(44832011)(1006002)(6666004)(110136005)(7416002)(2616005)(66946007)(83380400001)(186003)(16526019)(6486002)(110426005)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HaUoV1FQpnMYR6LZrITZQV8F+rIJ1aE5qg4cB7wI9l3ozAzRnXpHjjbkcJWUctFMa8xlGaz5TXKxHeSVSWf7qn3bL05KlhdntoQnNpXEG/WdXXPhZkqfJ0Pcidi45zdZCb99Vx282mhcvTV3+xzNCwIddt7zpaMrdEnqg0TAyuWCJuAbruPRcpKT0dTKm/2kup4M3L+qZNktAjhoayqqOc/Wm9u3esuupp7P8w167LAAmWJ1k+BwFEWAvgm7jZqtEYqPFsTbcs7fDbjWzpHdO4H8S6sIN9CEeOJTFaq2wnfM61PiKYRIMzxh5+6mSEl+A+XIUsH0BRl0r9Zri/nOPnCQCiF1EvRPh2Igjlz6KRYN9kL3c3WQ3UDYxeT+32/PYW+1/RcovIdvE+3cXJIg/yZqVRSGEquVmvhk8KwQoUKBt/1m1st8UwCe6+IOT1d/Kz5wM1jfbRRhJa0N3Dr5fOzH3lPD2taDrb5pZsfelTKXzLJLaqahloCdeKs+emzE9cp0KNdGe8Uu/JTEbF6vmxhgFjqy5GnFFC1q0gWRmYaoj4aQdAl5GvlcwZIssio7S75wzQkt58gDENgT/gpNciU8vPO1JGt2SS8cv8bSCc1bMLvlELIG7y/RnlUN3Q2NZSlGfVUmf2XmmMuK05UCnw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f548f740-6652-4f75-1cc6-08d8655abac2 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2020 16:06:02.9319 (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: +nMUC9GymHGHOmeYVdBsehUDg8pyvoCQcocglICCmeFKXtS/RQo3Fa2rLEZRg6xjHzm5DhFlJ00fTjCbRXToLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4225 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_120606_193248_329F0E24 X-CRM114-Status: GOOD ( 22.36 ) X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [40.107.14.89 listed in list.dnswl.org] -0.4 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.14.89 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ioana Radulescu , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Calvin Johnson , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux.cj@gmail.com, Jakub Kicinski , "David S. Miller" , linux-arm-kernel@lists.infradead.org, Laurentiu Tudor Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Modify dpaa2_mac_connect() to support ACPI along with DT. Modify dpaa2_mac_get_node() to get the dpmac fwnode from either DT or ACPI. Replace of_get_phy_mode with fwnode_get_phy_mode to get phy-mode for a dpmac_node. Use helper function phylink_fwnode_phy_connect() to find phy_dev and connect to mac->phylink. Signed-off-by: Calvin Johnson --- .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 79 ++++++++++++------- 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 90cd243070d7..18502ee83e46 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -3,6 +3,7 @@ #include "dpaa2-eth.h" #include "dpaa2-mac.h" +#include #define phylink_to_dpaa2_mac(config) \ container_of((config), struct dpaa2_mac, phylink_config) @@ -35,38 +36,56 @@ 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 acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct fwnode_handle *dpmacs, *dpmac = NULL; + unsigned long long adr; + acpi_status status; int err; + u32 id; - dpmacs = of_find_node_by_name(NULL, "dpmacs"); - if (!dpmacs) - return NULL; + if (is_of_node(dev->parent->fwnode)) { + dpmacs = device_get_named_child_node(dev->parent, "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; + } - 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; + } else if (is_acpi_node(dev->parent->fwnode)) { + device_for_each_child_node(dev->parent, dpmac) { + status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(dpmac), + "_ADR", NULL, &adr); + if (ACPI_FAILURE(status)) { + pr_debug("_ADR returned %d on %s\n", + status, (char *)buffer.pointer); + continue; + } else { + id = (u32)adr; + if (id == dpmac_id) + return dpmac; + } + } } - - 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) @@ -303,7 +322,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; @@ -323,7 +342,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) mac->if_link_type = attr.link_type; - dpmac_node = dpaa2_mac_get_node(attr.id); + dpmac_node = dpaa2_mac_get_node(&mac->mc_dev->dev, attr.id); if (!dpmac_node) { netdev_err(net_dev, "No dpmac@%d node found.\n", attr.id); err = -ENODEV; @@ -341,7 +360,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)) { @@ -352,7 +371,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) if (attr.link_type == DPMAC_LINK_TYPE_PHY && attr.eth_if != DPMAC_ETH_IF_RGMII) { - err = dpaa2_pcs_create(mac, dpmac_node, attr.id); + err = dpaa2_pcs_create(mac, to_of_node(dpmac_node), attr.id); if (err) goto err_put_node; } @@ -361,7 +380,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); @@ -372,13 +391,14 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) if (mac->pcs) phylink_set_pcs(mac->phylink, &mac->pcs->pcs); - err = phylink_of_phy_connect(mac->phylink, dpmac_node, 0); + err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0); if (err) { - netdev_err(net_dev, "phylink_of_phy_connect() = %d\n", err); + netdev_err(net_dev, "phylink_fwnode_phy_connect() = %d\n", err); goto err_phylink_destroy; } - of_node_put(dpmac_node); + if (is_of_node(dpmac_node)) + of_node_put(to_of_node(dpmac_node)); return 0; @@ -387,7 +407,8 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) err_pcs_destroy: dpaa2_pcs_destroy(mac); err_put_node: - of_node_put(dpmac_node); + if (is_of_node(dpmac_node)) + of_node_put(to_of_node(dpmac_node)); err_close_dpmac: dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); return err; From patchwork Wed Sep 30 16:04:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 11809825 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D3B2618 for ; Wed, 30 Sep 2020 16:08:25 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0CE9E20789 for ; Wed, 30 Sep 2020 16:08:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nAbPKX1s"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="dx/OQS5g" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0CE9E20789 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WDusA43IFOulPqPS7JYZr0e3A9Lbaplc6JS9rPOvOzQ=; b=nAbPKX1sAjT/535zzFqOD6lMW 0SQA/rcf6nWBbdXwN6dKJeT2U1lfrBS2hCM0GVylQpzt2MiFcT6POiV7EYFik79elgs41d1QhEMrF 3sY1uiG1aUT+hDXfv3Que8Vs5eIeDI+JeWxiiukrnVB9Shg9LNS6iK0kXwiCYoxcr3sMot4ymXDY2 EpTzAVwSHRwZVpIF4ciBdIQiYPv48IP7XjouqiOE8D8MvEpLYCuhqdK/17/U7RujN3ofmXnHlpa07 KxWUA0awsMWnW5TCu2fHg+/4AUH+woNcd4xYMzW2HAar6tcHguar3Gfv3ySkpruvIG/MF37e/j81w pLG+F1pCw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNeck-0005ns-Er; Wed, 30 Sep 2020 16:06:34 +0000 Received: from mail-eopbgr140089.outbound.protection.outlook.com ([40.107.14.89] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNecM-0005dP-CI for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 16:06:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fpNWtlKm5v5payReNSIwqhgO0qeYjnzjmcfqNwDD27cUXMFxutDf8/Cu1BAd0GvcX8u1MaAYTfjIdxWj/SV8Y/+MEX7CamoCy7mGb2wPTS2vIdnw6MjKvlEQcBGX0ijq/BIxMUQFF4NPTj6ZOqp4deIrfarxa7VRFQeK1hkWIBURsBpiW8BKO1r0O8Jyw8YFmdNp1EjZdVvtW4aA0F4UBiBJJJVWA3zK/C3BhaAaYU476QR84dBU+n6gpvSSXVKxmVEBLQ01p8BHGsQe66ZfMel1Ws0tZpLcBwS8WCi/649fPcTCqV6BXMdM5nc652EE+BwUnUJL1vzoPb+OWv5BPQ== 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=fcw4Olba4XlQcbHT3A0pSm4t3j7bkW95YCFrAvkECx8=; b=V2t+Tz+2dKnDjQJfNMm+ftTJvwsQr+bahZeT0oAG0+ugkq7lyVAbwrfdPltyV0n5q8hu8I0OGqfCQWNB/JT5//54nL0RFayR27UNs9007d32j+718IX7Fo7hBmROOlHQhF+YG99ra9HW+8QqhFkluI/1i3MSZ4Blst5rUPsEg8EED6uU3el8bUyU87FHE7feiEN+i05hIOF2Mad6gBG9LE4FDzxorNUPV1+d1n+hV5+FZwW3jyhdRFvK3shbbeXqzRMtSFCNi3FKqztfTyYIQwVvQ174Ob0xItT91nOTOemccMkywUiAb2GMHesQrI8aXizp15nwwFFU7jLLH2BPSg== 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=fcw4Olba4XlQcbHT3A0pSm4t3j7bkW95YCFrAvkECx8=; b=dx/OQS5gRJCBs8B0uxtz/0TlbnszLoaBPVuriIoSXNpZigjs4w1N3BsDMPmVjygPtKrB0wnewLOatl+FwyfH4KuIbZczuuQUZMysstmH1t88PcnGwuKvhZ+dB3Z6MJHUJherl27uwgLXuaJJdtycOWOHrc2b3kkNsGq0SSlmlDU= 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 AM0PR04MB4225.eurprd04.prod.outlook.com (2603:10a6:208:59::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.23; Wed, 30 Sep 2020 16:06:08 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a997:35ae:220c:14ef%7]) with mapi id 15.20.3433.032; Wed, 30 Sep 2020 16:06:08 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus Subject: [net-next PATCH v1 7/7] net/fsl: Use _ADR ACPI object to register PHYs Date: Wed, 30 Sep 2020 21:34:30 +0530 Message-Id: <20200930160430.7908-8-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> References: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) 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 SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.16 via Frontend Transport; Wed, 30 Sep 2020 16:06:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9cb46d27-7367-4d58-875a-08d8655abdfc X-MS-TrafficTypeDiagnostic: AM0PR04MB4225: 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: Xch5JSiI+Bph6bq1XjLsgkGmDeoBYyIK/3etOEFYHEV2ujLNtHM9BDvQeI0nYrNbyCwqBGZPPx7+ijNb9+dyXje33prQ+UrYfdT2m2EfUlVV+Em6WHuhK7bzLlg0NIel9Zx5d0LAVMlX/GwAaUpOqjIlQkaHYOaKoA6IpdxzOf/lbV9htE5DTTcy3T1qNfu1sealVExYZ7veox6cZoIPGNCKN/ZLjDjrTweX02pT2YnubCsRX6ZrSqc2d3vQcTCXfiHD3WsJBfqH3SCaXmSOE4kHW1y58VxkpxfKZK1rNfYunqDpCz6uukUUbnUd7AwBAPrCrdq2sy8HXPlLl81mZ5oJLDALPYYSzh/p4yTTJRFJYzN9f69LA6m8tJnayV1GpyZtrXK1z5CzQiDOZAc72oka5YWG/YWQ2IjjIsG38mzy8fnhNa5BN1xyFMjXe9Mp X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(136003)(39860400002)(2906002)(8676002)(1076003)(26005)(4326008)(54906003)(6506007)(316002)(478600001)(8936002)(6512007)(55236004)(86362001)(66556008)(66476007)(5660300002)(956004)(52116002)(44832011)(1006002)(6666004)(110136005)(7416002)(2616005)(66946007)(83380400001)(186003)(16526019)(6486002)(110426005)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: TakG4wmKmqRn6nPhL5CNMV83dyvD3l5ABM/vmSB7twjjs4rtBcrtP76MCQ14dZY01u0sp/bwrYt4QSkY+Bn5jLdWoNROfeDLRrfn6lSBNQcz31iPF6vvX1yKlECoBlJI1eY0egCXEgmr6+SbkOiiwPNMHgE1RWfjk3sQP1G31lL5ghUSd9IDHFcH/trmqek+g6R/3sV2iNsR7+EKzkpJVXe6HiwChr9G5IcEkk3wyElzdSNYcC5OMVlHaeJ9ju3Ek8MYrYbxMj5S/a34loqQK6R/YBMG7ymhcujgfQbKqBR5IZmoGVQvDJVuAR8pEHXpEWWuqUHdHcq4hQmt+X4JaeLwkFP1h9ICpGInLXdopJuspD+flAcfpqUwYxAs4XHabv2+r8S0FURVBpIheW3MfV0rRbfbPKhdZmbo6axZD1OpWEEz34tgDwDVG4pPM542HJVuvQlJj536iRgzbs8kA97OurDUyMeRJGjT0Q2TUGcDQ6xI09yWJlQy5vz/ioTRga2ZttTJyjTRxoEKpswW7oB5xFjDnE625MukKNDj9xMmRnXemlDP3nzMVwmz/ofq/Iryp3ej+c9XollLejWh40msPzDN9s+lIFXehof+fOB3zn/IHracX49VP/i6JYCfrdvE3pH03kWyM99qe4aT/g== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cb46d27-7367-4d58-875a-08d8655abdfc X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2020 16:06:08.3889 (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: gPV+8aPcgUhp4Q4JO83vBlhBlONpDMyYxkedBiQVmRbnt0YqS5zxdOfPEH34VAP/hek7FbARdXmy10r3JIU28Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4225 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_120611_557242_8B580D04 X-CRM114-Status: GOOD ( 19.96 ) X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.4 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.14.89 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [40.107.14.89 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Calvin Johnson , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux.cj@gmail.com, Jakub Kicinski , "David S. Miller" , linux-arm-kernel@lists.infradead.org, Laurentiu Tudor Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org PHYs on an mdio bus has address which can be obtained from ACPI DSDT table using the _ADR object. DSDT Eg: PHYs connected to MDI0 bus. ------------------------- Scope(\_SB.MDI0) { Device(PHY1) { Name (_ADR, 0x1) } // end of PHY1 Device(PHY2) { Name (_ADR, 0x2) } // end of PHY2 } // end of MDI0 ------------------------- Signed-off-by: Calvin Johnson --- drivers/net/ethernet/freescale/xgmac_mdio.c | 48 +++++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index 98be51d8b08c..fb272564855e 100644 --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -2,6 +2,7 @@ * QorIQ 10G MDIO Controller * * Copyright 2012 Freescale Semiconductor, Inc. + * Copyright 2020 NXP * * Authors: Andy Fleming * Timur Tabi @@ -11,6 +12,7 @@ * kind, whether express or implied. */ +#include #include #include #include @@ -248,6 +250,10 @@ static int xgmac_mdio_probe(struct platform_device *pdev) struct resource *res; struct mdio_fsl_priv *priv; int ret; + struct fwnode_handle *fwnode; + struct fwnode_handle *child; + unsigned long long addr; + acpi_status status; /* In DPAA-1, MDIO is one of the many FMan sub-devices. The FMan * defines a register space that spans a large area, covering all the @@ -284,10 +290,44 @@ 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); - if (ret) { - dev_err(&pdev->dev, "cannot register MDIO bus\n"); + if (is_of_node(pdev->dev.fwnode)) { + ret = of_mdiobus_register(bus, np); + if (ret) { + dev_err(&pdev->dev, "cannot register MDIO bus\n"); + goto err_registration; + } + } else if (is_acpi_node(pdev->dev.fwnode)) { + priv->is_little_endian = true; + /* Mask out all PHYs from auto probing. */ + bus->phy_mask = ~0; + ret = mdiobus_register(bus); + if (ret) { + dev_err(&pdev->dev, "mdiobus register err(%d)\n", ret); + return ret; + } + + fwnode = pdev->dev.fwnode; + /* Loop over the child nodes and register a phy_device for each PHY */ + fwnode_for_each_child_node(fwnode, child) { + status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(child), + "_ADR", NULL, &addr); + if (ACPI_FAILURE(status)) { + pr_debug("_ADR returned %d\n", status); + continue; + } + + if (addr < 0 || addr >= PHY_MAX_ADDR) + continue; + + ret = fwnode_mdiobus_register_phy(bus, child, addr); + if (ret == -ENODEV) + dev_err(&bus->dev, + "MDIO device at address %lld is missing.\n", + addr); + } + } else { + dev_err(&pdev->dev, "Cannot get cfg data from DT or ACPI\n"); + ret = -ENXIO; goto err_registration; }