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: 251538 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE100C4727C for ; Wed, 30 Sep 2020 16:05:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68AF220759 for ; Wed, 30 Sep 2020 16:05:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="adZ3Hh9f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731003AbgI3QFl (ORCPT ); Wed, 30 Sep 2020 12:05:41 -0400 Received: from mail-am6eur05on2070.outbound.protection.outlook.com ([40.107.22.70]:14817 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725355AbgI3QFj (ORCPT ); Wed, 30 Sep 2020 12:05:39 -0400 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 Cc: linux-kernel@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Diana Madalina Craciun , Laurentiu Tudor , Calvin Johnson , Len Brown , "Rafael J. Wysocki" 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 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Introduce ACPI mechanism to get PHYs registered on a MDIO bus and provide them to be connected to MAC. Describe properties "phy-handle" and "phy-mode". Signed-off-by: Calvin Johnson --- 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: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: 251537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28435C4741F for ; Wed, 30 Sep 2020 16:06:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C15682085B for ; Wed, 30 Sep 2020 16:06:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="FcgL0HzM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731139AbgI3QF6 (ORCPT ); Wed, 30 Sep 2020 12:05:58 -0400 Received: from mail-vi1eur05on2078.outbound.protection.outlook.com ([40.107.21.78]:4929 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725355AbgI3QFt (ORCPT ); Wed, 30 Sep 2020 12:05:49 -0400 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 Cc: linux-kernel@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Diana Madalina Craciun , Laurentiu Tudor , Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski 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 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Extract phy_id from compatible string. This will be used by fwnode_mdiobus_register_phy() to create phy device using the phy_id. Signed-off-by: Calvin Johnson --- 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: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: 251536 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00594C4727E for ; Wed, 30 Sep 2020 16:06:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A37CD2085B for ; Wed, 30 Sep 2020 16:06:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="J/F8/nV/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728480AbgI3QGT (ORCPT ); Wed, 30 Sep 2020 12:06:19 -0400 Received: from mail-eopbgr150042.outbound.protection.outlook.com ([40.107.15.42]:11246 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731140AbgI3QGB (ORCPT ); Wed, 30 Sep 2020 12:06:01 -0400 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 Cc: linux-kernel@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Diana Madalina Craciun , Laurentiu Tudor , Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski 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 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.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: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: 251535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AB6FC4741F for ; Wed, 30 Sep 2020 16:06:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D1D52085B for ; Wed, 30 Sep 2020 16:06:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="dx/OQS5g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730984AbgI3QGg (ORCPT ); Wed, 30 Sep 2020 12:06:36 -0400 Received: from mail-eopbgr150042.outbound.protection.outlook.com ([40.107.15.42]:11246 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725837AbgI3QGa (ORCPT ); Wed, 30 Sep 2020 12:06:30 -0400 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 Cc: linux-kernel@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Diana Madalina Craciun , Laurentiu Tudor , Calvin Johnson , "David S. Miller" , Jakub Kicinski 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 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.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; }