From patchwork Wed Jul 15 09:03:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1329309 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=V/zv+qxO; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B6BKN2B90z9s1x for ; Wed, 15 Jul 2020 19:04:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730410AbgGOJEi (ORCPT ); Wed, 15 Jul 2020 05:04:38 -0400 Received: from mail-eopbgr140074.outbound.protection.outlook.com ([40.107.14.74]:46210 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727930AbgGOJEi (ORCPT ); Wed, 15 Jul 2020 05:04:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ofpuwDb9c3Roj936upXSDSjoiFUsW4+T3x2p7TE6X0WEY7J26GkjsK6WdddqNkHsYXHWoQC8u1ldvnY4xmmcP1qzo2xmBGqfB6NYwMJj+M5sH1ZT09jpPr+itYCnW9aTt/7bWfV5XdW/fPOMrkKE5Aw1tHaMX1R+Ya0jvkPzxStG89ou1je9wkRS+5/2lYpVeaV9LkX2IZoPhE9ZlSz/iM+80dPoBMevWtF/RIM9kobzYWNBAJBdgwjwweU+FDI2kXSfuap90Cqr7vUXedn2+LvMNR/rvfet4/xczCKyOnU6tIpAw2YtDQ7MqwJ+EKihncw6CJPt0dKXxLvhwWrxsw== 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=BJ5XZbCs8RAzB9lYlq+k6vXcMgO69MZn9141tCuCJnc=; b=c0A1gBsbPDqmaHQzEjZIWMWNDOQlnAL7o5kC3UoiWiB9/Y8APQOrHXBVk54iGvkubtVE81abXnKEQjLN3hbEtm1eHNsdhUqz8BwdZyR/pQ0AiP59kJH6CaW7dhFoCH7PfekNLdKjON5KRX0EqYqRnq3mWY7gb+9Qr4N2IbSzAyuHqpaYNfhWNvLJLF6YUSHNRp5CXrDbFDGQ4y9u8aMopLXYzS4rBQJbzuyzpYeHiJuWGxFWd2hgPeQ6cc3KMDQlYpfazt/wxopi7/n+AhxVld2PFcUJWHmrdUnwXzp3olm9/0vpimOV2rmUPLw3O+e9+D2LDyt5fQDXfYKxvAcm4g== 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=BJ5XZbCs8RAzB9lYlq+k6vXcMgO69MZn9141tCuCJnc=; b=V/zv+qxOIQL9J1JmDG0VranoeInquNJkCdZPbVGCSWJzliTH1Id8S6Wn+0j8BBBBRUaF+GKl5ERg9oXOsuHPtb/CeTWvrHUmbBWI1wFWnNLYLemrWxkWVn1oKOOu47oZqikOWEI3KpB9HIsAJDl5Om8BtI02yzSmOFO4OI2dVvE= 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 AM0PR04MB5203.eurprd04.prod.outlook.com (2603:10a6:208:c1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Wed, 15 Jul 2020 09:04:34 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.026; Wed, 15 Jul 2020 09:04:34 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: netdev@vger.kernel.org, linux.cj@gmail.com, linux-acpi@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v7 1/6] Documentation: ACPI: DSD: Document MDIO PHY Date: Wed, 15 Jul 2020 14:33:55 +0530 Message-Id: <20200715090400.4733-2-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200715090400.4733-1-calvin.johnson@oss.nxp.com> References: <20200715090400.4733-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0070.apcprd02.prod.outlook.com (2603:1096:4:54::34) 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 SG2PR02CA0070.apcprd02.prod.outlook.com (2603:1096:4:54::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18 via Frontend Transport; Wed, 15 Jul 2020 09:04:30 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 342b8908-4354-4e8d-d8c6-08d8289e1790 X-MS-TrafficTypeDiagnostic: AM0PR04MB5203: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KBkCSq+3odw7n6NsoUNF2XOta3Pd+JSjoMUU9LgGZNOQbIXOrTj9v98LinO32QZRy6oVA2cQQTEuaVIGB6joKpFoe9TFZC+u0n+FZUz8N01i3/fnFmZmf2Dr/G2gOQua031fYYe9PVWXUKvYptEk+U9+71/a8Kx80IwUSceIJbhqNGp80J3MaksegvrrMvwjkIp8zw23V5XqNAjWt2Yv0rV+U8wMcQtzh5FPjmhlgQWhN0/LId0LciuAxZ/g/d3PIiY5tYsdmfZ9p3SwoRgTrU/XPi3pcO8yla7AKqTC/c8E0DphasCg9WEXYZFxCKxgYMSvRzo/ZkgNIeHXK4bMQ0VmrNjJYz42TCguDm45YN+scG0q14/xFHc0tICcxLdh X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(396003)(39860400002)(346002)(376002)(366004)(86362001)(6512007)(8676002)(55236004)(6486002)(6506007)(8936002)(5660300002)(52116002)(316002)(1076003)(4326008)(6666004)(1006002)(110136005)(2906002)(6636002)(478600001)(16526019)(66556008)(186003)(66476007)(956004)(2616005)(44832011)(26005)(66946007)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 9t97ghRdAd/CkaQvE6X/i07710+nmR644TWb+xCCVsX0/74ScMm5vrH1rqZj/4/TIgQCnBYM63TdxlzIUCbXx/x5T0vnZBszSJyli+/SLmLVJnb9Ig8lcjVHh9uSD7kJf93h39N3oBLfb4CWJrKeryVOQaFfj40ZSSW+z1eXpyRP7csKbRrMUnP9M5CYtgiyMIvFkEnld0aJAhcIAb4NXQIEX9mYrxfIQpQmYNJP6bW3IgqINoE2MOt/MWy68kWKIzGdPmFVIE9ieOSrEEdiP3840v8jlAxtvzCdF4J4cCuP7FyfTQ4saH/QOH0y+uUvvjWowXgY8grw+iHR2B5n5rdeVxSSGzWIzWrirD0X3juxX1naqFFKuEe9J2bC90Fy3AzBZ2umioDuIYhz28n6nXgajBr4cXhKeanDpnsNTaKf0/h8f0WehCIGjxCh5iAUZCMs+53cBM67SfX7leAF5uBRiry1/547cmAk6KDvDhmJe1wy6XwjWRvAFdnwqpll X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 342b8908-4354-4e8d-d8c6-08d8289e1790 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2020 09:04:34.0036 (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: lCxwYTqmbg8fa0EIbHZJx6oMAt/6aIcdzNbOADS99J4064CIQbvttFfN6U7Ahx8iphEqICXM4tQRnIC3CkALbw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5203 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce ACPI mechanism to get PHYs registered on a MDIO bus and provide them to be connected to MAC. An ACPI node property "mdio-handle" is introduced to reference the MDIO bus on which PHYs are registered with autoprobing method used by mdiobus_register(). Describe properties "phy-channel" and "phy-mode" Signed-off-by: Calvin Johnson Reviewed-by: Florian Fainelli --- Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: - cleanup based on v2 comments - Added description for more properties - Added MDIO node DSDT entry Changes in v2: None Documentation/firmware-guide/acpi/dsd/phy.rst | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst diff --git a/Documentation/firmware-guide/acpi/dsd/phy.rst b/Documentation/firmware-guide/acpi/dsd/phy.rst new file mode 100644 index 000000000000..0132fee10b45 --- /dev/null +++ b/Documentation/firmware-guide/acpi/dsd/phy.rst @@ -0,0 +1,90 @@ +.. SPDX-License-Identifier: GPL-2.0 + +========================= +MDIO bus and PHYs in ACPI +========================= + +The PHYs on an mdiobus are probed and registered using mdiobus_register(). +Later, for connecting these PHYs to MAC, the PHYs registered on the +mdiobus have to be referenced. + +mdio-handle +----------- +For each MAC node, a property "mdio-handle" is used to reference the +MDIO bus on which the PHYs are registered. On getting hold of the MDIO +bus, use find_phy_device() to get the PHY connected to the MAC. + +phy-channel +----------- +Property "phy-channel" defines the address of the PHY on the mdiobus. + +phy-mode +-------- +Property "phy-mode" defines the type of PHY interface. + +An example of this is shown below:: + +DSDT entry for MAC where MDIO node is referenced +------------------------------------------------ + Scope(\_SB.MCE0.PR17) // 1G + { + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"phy-channel", 1}, + Package () {"phy-mode", "rgmii-id"}, + Package () {"mdio-handle", Package (){\_SB.MDI0}} + } + }) + } + + Scope(\_SB.MCE0.PR18) // 1G + { + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"phy-channel", 2}, + Package () {"phy-mode", "rgmii-id"}, + Package () {"mdio-handle", Package (){\_SB.MDI0}} + } + }) + } + +DSDT entry for MDIO node +------------------------ +a) Silicon Component +-------------------- + Scope(_SB) + { + Device(MDI0) { + Name(_HID, "NXP0006") + Name(_CCA, 1) + Name(_UID, 0) + Name(_CRS, ResourceTemplate() { + Memory32Fixed(ReadWrite, MDI0_BASE, MDI_LEN) + Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) + { + MDI0_IT + } + }) // end of _CRS for MDI0 + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () {"little-endian", 1}, + } + }) + } // end of MDI0 + } + +b) Platform Component +--------------------- + Scope(\_SB.MDI0) + { + Device(PHY1) { + Name (_ADR, 0x1) + } // end of PHY1 + + Device(PHY2) { + Name (_ADR, 0x2) + } // end of PHY2 + } From patchwork Wed Jul 15 09:03:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1329310 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=Pxg5WXtq; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B6BKQ59grz9s1x for ; Wed, 15 Jul 2020 19:04:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730430AbgGOJEm (ORCPT ); Wed, 15 Jul 2020 05:04:42 -0400 Received: from mail-eopbgr60086.outbound.protection.outlook.com ([40.107.6.86]:24900 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730412AbgGOJEl (ORCPT ); Wed, 15 Jul 2020 05:04:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ss+HzU9JWlz/J6nCuautPtWIBpKEbvGbNQEqcIe+P3PrW5ZMZt21W59zdp5p53h1exGx/IHFTCsN8Ct7/QhBO/AKpjiog7u9Q/FCZqrNsQFtYWycnZnIB4O0CJOf4C5mKXQ5hWrf3YdSelv8fPnFQhspxi3yeaC4s9osXwvrTIUdVmy6dylEJYv9Jg9Qag89v0ZK7UBIYnebA2hPnh0kRVqoj1PbT2ACCxjL+s+SCV0JGT9+ljoyvvrfNBqPGwC20TbuyiefbgzSKYGO0jh4/IddwAXV8Di/HpfgxLVGVtd5iuOJU9Oiiu2117imzzmQhVpWHw8Za1g5B8KFf0+M7A== 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=s3kdm1lDYjdzIJwkMrYd/NBbXanHVS+ZY/kzco22Wpw=; b=catEqQAf+clxN+gIYKZFL76P8UPz2f++EVpTefAP0uMC+z5VBbTTMxCfePxB3OiNLQ+MZGn9lWrDjXqSP403pEsT6jy4EIvelK9kypX0B1DDx8MkZYtFf9ZbzYmyHAsCsS8pdGLsRp0lEXQb5OHbsVrm+Bm0RvM21v1c0sTMRn4ghA2cqrmxxBZ3C1ZWPtqJ6ZAA0TqjnhpqlfylnnV1EURP938s0C+Z6ztKclWoVI88EP3zMRPmo9ZQjKPVqvjy/EUcSUsQp0uAs0H3PLW7m6slLX8a5Ut17dm3/slIM3mf/779Hxy9rQNUt0+qvKD6PS2r2ZJSRI6p3Ovqqpf3kw== 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=s3kdm1lDYjdzIJwkMrYd/NBbXanHVS+ZY/kzco22Wpw=; b=Pxg5WXtq7uSA0QW0HG52rI+vUTbTkoIHaloVHRZ1dT62pY/aBR+fbMi9YFN5Rj5sc8BDligl70Q64zU8pfb0JmTo0Kfac4zKMRgjqJsBEb3VA5+Xzu/87QNEweeqahrK3DO0JOKwypDPkdZDTjosLAy2no54/GzVbBqkR+Rmsq0= 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 AM0PR0402MB3763.eurprd04.prod.outlook.com (2603:10a6:208:e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.23; Wed, 15 Jul 2020 09:04:37 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.026; Wed, 15 Jul 2020 09:04:37 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: netdev@vger.kernel.org, linux.cj@gmail.com, linux-acpi@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v7 2/6] net: phy: introduce device_mdiobus_register() Date: Wed, 15 Jul 2020 14:33:56 +0530 Message-Id: <20200715090400.4733-3-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200715090400.4733-1-calvin.johnson@oss.nxp.com> References: <20200715090400.4733-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0070.apcprd02.prod.outlook.com (2603:1096:4:54::34) 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 SG2PR02CA0070.apcprd02.prod.outlook.com (2603:1096:4:54::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18 via Frontend Transport; Wed, 15 Jul 2020 09:04:34 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 86710861-b159-41dc-6aa5-08d8289e19bc X-MS-TrafficTypeDiagnostic: AM0PR0402MB3763: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vuo1QGClgtZo+p9c/sdL178DbMpg39awxTubZa1f2FLVe7D2T3AlDvV0vqpNLyZI7g26nU14IsonSRkQxGbhq7DwdszwXwYdvtai4nf/7OU8yTlm/YK0JshYm7f8kbrhD+TP0hEt31Jt0+BIALsVHX0taAyVhi8OhWeYfMtn4kJKLApWE2m1Bwt02d4Te2khBbgZXM+UZQgYTHRtPlPWJuybMVVB9kEkr6hxaDsQC6FP3vEZmXt+g/YOI/a9Weh6/GvD0W6Bgmm6GxsGOA3+OgRvY7m31mPCpLBLK8u1EuCnOsRg9W13WHosBd0jk78AfPnZ/XxGvCHAFdIQu5RShFgf+hHV4MbD1oIUHHMmUpBRA/Hmg6s1zY3vHBzXw/Zh X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(346002)(39860400002)(376002)(366004)(396003)(5660300002)(110136005)(2906002)(6512007)(66946007)(6666004)(66476007)(86362001)(1006002)(4326008)(66556008)(52116002)(44832011)(316002)(956004)(83380400001)(26005)(6486002)(2616005)(6636002)(6506007)(55236004)(1076003)(186003)(16526019)(8676002)(8936002)(478600001)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: iT4TRdtar11Te06A3N6lJbU5fjQa8g3Mm/xmp8oeRUhl+tbgJUktXozfSdWJ1Vz5VL9He3K/QW80g9Ug8JaXrho9ATaHystDSIIjJ39yv9+z2bICiOLfect6OSyQspPM0h/S4S6jQbmTNB6Hb6omiAj5KVtAlJtbbKpXU1tQ83MhDivZs2FxApRQXvlzW1GgBvILSQiZ3Vu7sulkmbghX3/lmvbRGHLdol451F7Z5Xz74rGQ2uucZ65DDZJXbwmjxRg2YDI4U1/bT54X5GoEv014ogFJ77j4ce1E60MkjSOpj4AHIJtUgqvG8OqrLz7CLWuNpz9WR+rWzTo6l2mPyxLFX5C6x71sBYfyF9n+tvr4L9jTO6ygQmi4C5anZeqackgjjNPgjNiOmFfQycfJNLzmExvckurxAk7VFruX7XTpJSchX5epqDL+mjJ2GuVNqpFszg/EAD/C8KVl1lEttoGyXBHgYKoP03bQ7+mi2epx1pu2HHyEZKySRyoppbkf X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86710861-b159-41dc-6aa5-08d8289e19bc X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2020 09:04:37.6436 (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: Trsy4b5wqWuge9sERsPtjSw508hpQIR+sCCpvkBVMorAhk5E9C252zQmghf6/irLVpQRH5BteKBvYXdrJ9wT/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3763 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce device_mdiobus_register() to register mdiobus in cases of either DT or ACPI. Signed-off-by: Calvin Johnson Reviewed-by: Florian Fainelli --- Changes in v7: None Changes in v6: - change device_mdiobus_register() parameter position - improve documentation Changes in v5: - add description - clean up if else Changes in v4: None Changes in v3: None Changes in v2: None drivers/net/phy/mdio_bus.c | 26 ++++++++++++++++++++++++++ include/linux/mdio.h | 1 + 2 files changed, 27 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 46b33701ad4b..8610f938f81f 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -501,6 +501,32 @@ static int mdiobus_create_device(struct mii_bus *bus, return ret; } +/** + * device_mdiobus_register - register mdiobus for either DT or ACPI + * @bus: target mii_bus + * @dev: given MDIO device + * + * Description: Given an MDIO device and target mii bus, this function + * calls of_mdiobus_register() for DT node and mdiobus_register() in + * case of ACPI. + * + * Returns 0 on success or negative error code on failure. + */ +int device_mdiobus_register(struct device *dev, + struct mii_bus *bus) +{ + struct fwnode_handle *fwnode = dev_fwnode(dev); + + if (is_of_node(fwnode)) + return of_mdiobus_register(bus, to_of_node(fwnode)); + if (fwnode) { + bus->dev.fwnode = fwnode; + return mdiobus_register(bus); + } + return -ENODEV; +} +EXPORT_SYMBOL(device_mdiobus_register); + /** * __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus * @bus: target mii_bus diff --git a/include/linux/mdio.h b/include/linux/mdio.h index 898cbf00332a..f454c5435101 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -358,6 +358,7 @@ static inline int mdiobus_c45_read(struct mii_bus *bus, int prtad, int devad, return mdiobus_read(bus, prtad, mdiobus_c45_addr(devad, regnum)); } +int device_mdiobus_register(struct device *dev, struct mii_bus *bus); int mdiobus_register_device(struct mdio_device *mdiodev); int mdiobus_unregister_device(struct mdio_device *mdiodev); bool mdiobus_is_registered_device(struct mii_bus *bus, int addr); From patchwork Wed Jul 15 09:03:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1329311 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=WmlUZOtF; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B6BKT6GXZz9s1x for ; Wed, 15 Jul 2020 19:04:45 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730228AbgGOJEp (ORCPT ); Wed, 15 Jul 2020 05:04:45 -0400 Received: from mail-eopbgr60060.outbound.protection.outlook.com ([40.107.6.60]:28226 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730370AbgGOJEo (ORCPT ); Wed, 15 Jul 2020 05:04:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bc49v4TMAMNiY66kbb+iLAwCeuImlPumQW61+0yvEDoia1h6HfDEl67qDX1Jig8x0Fpq2wlPZ82iMY8OU5joZtlW8DroGYaC2RMDE2yqKKevEfaAX95IhI9qlfgpcCKIusuif486rBccrUxn0IJ0kv8bpitUW3C6VBpV4NOkaPpK/6m/Qatk1JrLKwK+RfHMsw9oZREdOMAIvSSazFUO8IjT9G0BFMow3Soo8ClgOyhh0GWfepn1YWeiiIsBrB9pqS+35wV/6PD+tErGJ8xhDGfhnB9NETGCZppOj8VR4YFIm13lrMzHCHxrffVALiWKiEMcXMyoyd/DXoVuUd22eQ== 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=f1viDoyHHBQierD0TQySliftKgcLbKdXUmBXhtUvd9o=; b=V/CCpQmF1cWpuMOpPGxwQf8PmW06BKwuklOViH0WesbYR0dPL9pFkY9XfmnmHFqHL3fnPO2ypGpOaWp/864/uGcuUXkxLPF8VR9QmstA2JiRr8vCODLtTwmw09IaqaL7RywqPl+W3WU6dRZg5rW7ezvMHMqnJi9wNt9atPWX0MWi51Ej+zWyUXavsS8C99Ny2uAptsUbedKcdqn3rJJs4E0FTDXwMs31uI+pefe/I8jV0ruoLxrwGuDmc6C4yoyRG6g1TUmbM8JYSsA81dLIP5fGmbibQWV5A0UacDtgp6XqnjPy1J3tu1QzJ7fWgtVzMKOa+NUZTkBJX2wT9dsqdg== 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=f1viDoyHHBQierD0TQySliftKgcLbKdXUmBXhtUvd9o=; b=WmlUZOtFOkDNG6MtY2Jl6HZVAKlFJTonxvOj4mydT2VO0UuSqFC9LbbcC+m+lwwNQHvSdcQyClPdCxTuFCRE8faSjYlTCDO9HWNFATeTkNue52APQ0J3X8DAEhiw/KHJrZbh42DJZe5fau4heH8I2OHxThNUMbkxZ3RS3Uq5r0A= 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 AM0PR0402MB3763.eurprd04.prod.outlook.com (2603:10a6:208:e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.23; Wed, 15 Jul 2020 09:04:41 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.026; Wed, 15 Jul 2020 09:04:41 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: netdev@vger.kernel.org, linux.cj@gmail.com, linux-acpi@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v7 3/6] net/fsl: use device_mdiobus_register() Date: Wed, 15 Jul 2020 14:33:57 +0530 Message-Id: <20200715090400.4733-4-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200715090400.4733-1-calvin.johnson@oss.nxp.com> References: <20200715090400.4733-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0070.apcprd02.prod.outlook.com (2603:1096:4:54::34) 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 SG2PR02CA0070.apcprd02.prod.outlook.com (2603:1096:4:54::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18 via Frontend Transport; Wed, 15 Jul 2020 09:04:38 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f6b36dfb-32dd-47cb-e623-08d8289e1bf1 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3763: 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: oxp5pWqddGXQ8ARqWmgSjv4n+Yi7+Wyk/dx4Cuxy6SCrTw9zWzXlqkdVT3a49I4y0eAK8bYG7ZsOdItvXQeNsWwXfLZ9jrrB1UcyObeVtvmqnkUsLJMb3HWyIaurwM4YEKtZ7efSudWHz+a8jm4VbVU+ilEkrZwgmY2awXLTwERvMT5CyfM7ZC3HA+VH8bsCMGT1jg106ug/ONotTSm/4W4P5YhwcKvvfNws01Xi87MrTCIleR1xTyKT809Ht9gjnTDluXcJ+GECJriNzHjA6HqZ35LaPODsRfT5KmbrImBeESKROsMImQU16y0mxAT/V9GoCFS/2ir4XJ9VdTTjOi2gdff3LGZ6l1v09/Y0OODVtJXJoQRZiBE5ac41zV9Y X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(346002)(39860400002)(376002)(366004)(396003)(5660300002)(110136005)(2906002)(6512007)(66946007)(6666004)(66476007)(86362001)(1006002)(4326008)(66556008)(52116002)(44832011)(316002)(956004)(83380400001)(26005)(6486002)(2616005)(6636002)(6506007)(55236004)(1076003)(186003)(16526019)(8676002)(8936002)(478600001)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: INyn4coI+tks7/HQT9zoefLtZD9v7xM30pg2lVpZpaF0iUmUX34EAGaxxeelng1xNgYUmK/gPT+RtUmBRUKuyvUyhVx1/B6VwOsP+2gUbFMF/7Ha3ymEwfB2hex/0CAm2yagsx0TDhC5Jtb4pJbr+JnmNWEnjiWns344Ovkd2Es08a2FesJT+my9mvPTC7XFUEtMlr3aRaLI7brAfT7NSbyYgpLPoXNz+TgxJoF0Vxi3nQ8pmywLH8EcN8wpERe8KbKVz/L3YKQsddhr2bLgRhZesjotZYjcgIJq0D8wgr67olJU4dpUxQP3uOks4Wwu4+GT6pIEcVdeJFdSVK5aIzHVpgKDXNAGocWaqapY7Rd+I8dygGH0W9JPXD3W5IODDdU5yicmGz+X6ZA52JnbqFyammAX19nRjZCk9gXNCfRKMKRoJn82bS/ll6RK1+LN6Ln3K0SpzqGFKEqmrP0dtTf1tl9eZjkJhRxmILPQ2ZB5oCZU4Wt3ioye2UGucMbd X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6b36dfb-32dd-47cb-e623-08d8289e1bf1 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2020 09:04:41.3495 (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: uACUj4AohJv8Y2n/ZSJTWuAhzLEAcRFTd1NmzUpj+Gdo90vaTHJQ2u1p4QDflOdbvVkvrm3yWAQPyB2xeJj5BQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3763 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Replace of_mdiobus_register() with device_mdiobus_register() to take care of both DT and ACPI mdiobus_register. Remove unused device_node pointer. Signed-off-by: Calvin Johnson Reviewed-by: Florian Fainelli --- Changes in v7: None Changes in v6: - change device_mdiobus_register() parameter position Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None drivers/net/ethernet/freescale/xgmac_mdio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index 98be51d8b08c..704f2b166d0a 100644 --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -243,7 +243,6 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum) static int xgmac_mdio_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; struct mii_bus *bus; struct resource *res; struct mdio_fsl_priv *priv; @@ -285,7 +284,7 @@ static int xgmac_mdio_probe(struct platform_device *pdev) priv->has_a011043 = device_property_read_bool(&pdev->dev, "fsl,erratum-a011043"); - ret = of_mdiobus_register(bus, np); + ret = device_mdiobus_register(&pdev->dev, bus); if (ret) { dev_err(&pdev->dev, "cannot register MDIO bus\n"); goto err_registration; From patchwork Wed Jul 15 09:03:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1329312 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=HP4zznee; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B6BKb1hFRz9s1x for ; Wed, 15 Jul 2020 19:04:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730474AbgGOJEu (ORCPT ); Wed, 15 Jul 2020 05:04:50 -0400 Received: from mail-eopbgr60073.outbound.protection.outlook.com ([40.107.6.73]:41219 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730370AbgGOJEu (ORCPT ); Wed, 15 Jul 2020 05:04:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PvYwfURkNsyNR4Iq5Vy8zqr7j2VJ8LjMkm0N5lU6lJSKIbFcyZkyw8/W9hgT14YJHZ2ZjHLR5EbLhlP5rYv6wdgjWZAZDX4VArBsZuGZGlTW665Ew0WBEOkYZDAZj38ZTPa5WZzgK7nGxnmCQjwfg9Wu4VidpUmHbXi6NUfUAhsB8LDsJJU+5+UhdjLgARKolT2vuKUenKraN+Vsbbt/jnxvNoZiLYyePqf8JF0dmsjxvE2frc9loyq9RHc8LXBg/1S4nvVFfH9Q+syZgaRZanFEkuQt26rm5bVlWj7NOydMW4pRUQv1zFpuxh6mzvpLmgLBLIj4wK9Olro07bfkuQ== 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=YW8t4Fe6YahYDhgUrcxeVM4KS7MCNZdMblIwRp13UBo=; b=Ddx/P9cuAIYWKxnDscjLJn6B0IrnTkYdZTgpNzHl4krykob1ej3B9kL69agGpox7v+TxtpaTndHqWR3VhOksA/pMF8aov8rY0v8/EZbFrYM84Gsg6y1Alx29tG1BU5/WdkIlf7GRLwE7SomEP4GPvBJniKKN7qqsKZh6CYo6w3G/dCOUF11rak1Kr5fkW1Ax5MQlEI4B2B1AcdNBcmDbXJay/KpqmE/WNCvjyxcjEpXmb4yi133B/PzHi+3F9sjWhBJBtEu7CWNF3Bz9FelRwc5TCgjbOP3tRn9plUlCjbI0dEYtaSHBczATAbGXQIZGncH/nyomLS4ULe1yAtkD0Q== 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=YW8t4Fe6YahYDhgUrcxeVM4KS7MCNZdMblIwRp13UBo=; b=HP4zznee/dz/HS24nzkS6zeFuONlcU3iy3MgEYVhV8U1adG188rfNji34R1lR2japQaAaTON1G9RVJmgE+4DlbGD/YlbDXiaJ6QkgZpeMe5zmsEfGVzG8Q0RLikX6MDElSYOC4aR4XQGsmGFOVj3dd+nvwjdLkjklO99c+3XgIA= 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 AM0PR0402MB3763.eurprd04.prod.outlook.com (2603:10a6:208:e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.23; Wed, 15 Jul 2020 09:04:45 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.026; Wed, 15 Jul 2020 09:04:45 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: netdev@vger.kernel.org, linux.cj@gmail.com, linux-acpi@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v7 4/6] net: phy: introduce phy_find_by_mdio_handle() Date: Wed, 15 Jul 2020 14:33:58 +0530 Message-Id: <20200715090400.4733-5-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200715090400.4733-1-calvin.johnson@oss.nxp.com> References: <20200715090400.4733-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0070.apcprd02.prod.outlook.com (2603:1096:4:54::34) 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 SG2PR02CA0070.apcprd02.prod.outlook.com (2603:1096:4:54::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18 via Frontend Transport; Wed, 15 Jul 2020 09:04:41 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3c023b04-7904-4a0e-6071-08d8289e1e39 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3763: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R+w4HxdD+PGTBSlW6yO9+OFB/CW63psGk9m0noIDzDFELzd9BzMXTyZ017W8ztaTtljVcgqR3A+hwRo1p1VizEGgCiJ+ODjpSKNwP5qAnuTSELglQqn5VyQzfVRfhABqyM66VLvZnwgYXutwn831IIRzg25B/06Q9paouHFw7PniLZEJYiztlD5ES/TLPPNHnrC7m4HXl+QK5mc+H9ve3koWkWdfJ2hz6IvCCig3U4aiqERPjB2G5TuE0o+BM9jo2ixeYo4LSi1Tu212zkh9EjALowAMogWDz4YrvBrXmg4bYHZSGZMx+98lE29mYUEowAKTkWJkuJYPY4GN2L5BvZ4yTQl0sMieaZlw/Y0zdQ4IOE1M5JbFhcPisEwdCdUs X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(346002)(39860400002)(376002)(366004)(396003)(5660300002)(110136005)(2906002)(6512007)(66946007)(6666004)(66476007)(86362001)(1006002)(4326008)(66556008)(52116002)(44832011)(316002)(956004)(83380400001)(26005)(6486002)(2616005)(6636002)(6506007)(55236004)(1076003)(186003)(16526019)(8676002)(8936002)(478600001)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1cAAqOqVp3sZit1tYHsjLDKL2emzOTQ3ANgU51aa8jEh0q0WHYSC0wx1imd8+xJfwwrNmdyECQ0EkW+yWcyot5y/gvWsTMi/8sUcmp1a3M/F2cilDbXD0pQg/Tqrsmog8bbu+HOHX8SBNatbghm3HzjHQF+2EYp8SaM2+RfhbSd0k3imF2kEcBWTc7ofjhAtCfHyfMCYQxXxLfYvn/3tYpEJTZ5dGaGWC8s6HNnlDaEqCi27RQzOhJKC6CxXMKut1xVAHG7L86kRnD2zzIlSYlaNQ8+2siF40vDmvn2fCNN0/DO9VuuR/I6kFEI1TYXgmzxfk5KeivRqPS8oHh8iGrpuckrYWj8IFNhxo3b9nJ0JOgUv3sHb9PwG29J32YvTvwMHYFMX3It2K1tfYokrwB+9TCGKJhlejw67fdGjFg8OSAploAcs39bdwJwJmzOY8mw/LBPymeofg7rayRnwav/Td+gbrIMNXcxS8w4oivQ= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c023b04-7904-4a0e-6071-08d8289e1e39 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2020 09:04:45.1484 (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: V+DD6Mn/7csg59vLnjgYfzLR8ctxKBgsUI5+FZWvj0WTWrLaQPqWu85KwdL4EkE/aw93TuKP9aYrW+Vj80xdJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3763 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The PHYs on an mdiobus are probed and registered using mdiobus_register(). Later, for connecting these PHYs to MAC, the PHYs registered on the mdiobus have to be referenced. For each MAC node, a property "mdio-handle" is used to reference the MDIO bus on which the PHYs are registered. On getting hold of the MDIO bus, use phy_find_by_fwnode() to get the PHY connected to the MAC. Introduce fwnode_mdio_find_bus() to find the mii_bus that corresponds to given mii_bus fwnode. Signed-off-by: Calvin Johnson Reviewed-by: Florian Fainelli --- Changes in v7: - remove unnecessary -ve check for u32 var Changes in v6: None Changes in v5: - rename phy_find_by_fwnode() to phy_find_by_mdio_handle() - add docment for phy_find_by_mdio_handle() - error out DT in phy_find_by_mdio_handle() - clean up err return Changes in v4: - release fwnode_mdio after use - return ERR_PTR instead of NULL Changes in v3: - introduce fwnode_mdio_find_bus() - renamed and improved phy_find_by_fwnode() Changes in v2: None drivers/net/phy/mdio_bus.c | 25 ++++++++++++++++++++++ drivers/net/phy/phy_device.c | 40 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 2 ++ 3 files changed, 67 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 8610f938f81f..d9597c5b55ae 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -435,6 +435,31 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np) } EXPORT_SYMBOL(of_mdio_find_bus); +/** + * fwnode_mdio_find_bus - Given an mii_bus fwnode, find the mii_bus. + * @mdio_bus_fwnode: fwnode of the mii_bus. + * + * Returns a reference to the mii_bus, or NULL if none found. The + * embedded struct device will have its reference count incremented, + * and this must be put once the bus is finished with. + * + * Because the association of a fwnode and mii_bus is made via + * mdiobus_register(), the mii_bus cannot be found before it is + * registered with mdiobus_register(). + * + */ +struct mii_bus *fwnode_mdio_find_bus(struct fwnode_handle *mdio_bus_fwnode) +{ + struct device *d; + + if (!mdio_bus_fwnode) + return NULL; + + d = class_find_device_by_fwnode(&mdio_bus_class, mdio_bus_fwnode); + return d ? to_mii_bus(d) : NULL; +} +EXPORT_SYMBOL(fwnode_mdio_find_bus); + /* Walk the list of subnodes of a mdio bus and look for a node that * matches the mdio device's address with its 'reg' property. If * found, set the of_node pointer for the mdio device. This allows diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 7cda95330aea..38d781720670 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -23,8 +23,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -964,6 +966,44 @@ struct phy_device *phy_find_first(struct mii_bus *bus) } EXPORT_SYMBOL(phy_find_first); +/** + * phy_find_by_mdio_handle - get phy device from mdio-handle and phy-channel + * @fwnode: a pointer to a &struct fwnode_handle to get mdio-handle and + * phy-channel + * + * Find fwnode_mdio using mdio-handle reference. Using fwnode_mdio get the + * mdio bus. Property phy-channel provides the phy address on the mdio bus. + * Pass mdio bus and phy address to mdiobus_get_phy() and get corresponding + * phy_device. This method is used for ACPI and not for DT. + * + * Returns pointer to the phy device on success, else ERR_PTR. + */ +struct phy_device *phy_find_by_mdio_handle(struct fwnode_handle *fwnode) +{ + struct fwnode_handle *fwnode_mdio; + struct mii_bus *mdio; + int addr; + int err; + + if (is_of_node(fwnode)) + return ERR_PTR(-EINVAL); + + fwnode_mdio = fwnode_find_reference(fwnode, "mdio-handle", 0); + mdio = fwnode_mdio_find_bus(fwnode_mdio); + fwnode_handle_put(fwnode_mdio); + if (!mdio) + return ERR_PTR(-ENODEV); + + err = fwnode_property_read_u32(fwnode, "phy-channel", &addr); + if (err) + return ERR_PTR(err); + if (addr >= PHY_MAX_ADDR) + return ERR_PTR(-EINVAL); + + return mdiobus_get_phy(mdio, addr); +} +EXPORT_SYMBOL(phy_find_by_mdio_handle); + static void phy_link_change(struct phy_device *phydev, bool up) { struct net_device *netdev = phydev->attached_dev; diff --git a/include/linux/phy.h b/include/linux/phy.h index 0403eb799913..fd383a22eb61 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -334,6 +334,7 @@ static inline struct mii_bus *devm_mdiobus_alloc(struct device *dev) } struct mii_bus *mdio_find_bus(const char *mdio_name); +struct mii_bus *fwnode_mdio_find_bus(struct fwnode_handle *mdio_bus_fwnode); struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr); #define PHY_INTERRUPT_DISABLED false @@ -1245,6 +1246,7 @@ int phy_sfp_probe(struct phy_device *phydev, struct phy_device *phy_attach(struct net_device *dev, const char *bus_id, phy_interface_t interface); struct phy_device *phy_find_first(struct mii_bus *bus); +struct phy_device *phy_find_by_mdio_handle(struct fwnode_handle *fwnode); int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, u32 flags, phy_interface_t interface); int phy_connect_direct(struct net_device *dev, struct phy_device *phydev, From patchwork Wed Jul 15 09:03:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1329313 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=Bw4yMHXz; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B6BKh61MKz9sQt for ; Wed, 15 Jul 2020 19:04:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730491AbgGOJEy (ORCPT ); Wed, 15 Jul 2020 05:04:54 -0400 Received: from mail-eopbgr60073.outbound.protection.outlook.com ([40.107.6.73]:41219 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730453AbgGOJEx (ORCPT ); Wed, 15 Jul 2020 05:04:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bcv7AbcSYlFyI04m8vXKM9OW+GpQz+hjVq5zZPR/+S4POiSwfmKuJdGTwTdDffouXvR1RB7AUAqmtqbsOgWHgrmrDNdXvhiQCstW7bV4UteJndLFRvaRaMrg25+DTRB2ntFs8ZYukQl3s/hb7BrxDSPhFqOTXSR8+cf2ZaBB4xCr9kJS3cqAlOB9mXhiQGn06cMNUH7g9B9LChuTahplDcOGDey+lWCp/Q6jSV4dBIB+JeeJY3HzANNuX4JMnUtCEQ5f536XiFKaibTumzB86YrXHmVrJJbVo+WRZzOjz6LgZiCaC+OY/Akwb/sYNzpiPzHo1K9S94v5qn2gkQRDug== 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=9sODrw04aGrwduWestRssW7UvryYt3hnrjEEqn4hX1k=; b=R2STxK4hrL1C4hRtgRR2jW5wwjw4z98SDSekgVQoRWawIhRj11NL4DDwcgFc+Sr5ncduBx/0iNxMWV3eVPrByQyVxArN/c9fXu7ElzZCqshw4wqPtnnX/hvQJkyWDmUq3d4eo8TzCebtXvhsBhkg0L8Nhv07Z3B0WzIlyfn1EYPMcsGBYpnRaU9LhHXzqKV8H8goRJkvF7ZdkC2VKpfA2TxC/goMf87vqO3cN5oXiX4UkaZi/J9Z9BJuw95R9gDyfRMOVFvo7azgQfjhtowIHEnyn4EB2RdxySy5Y5JB2IIY4qYQWLAr/FMXkE+vOKRDK1dug4sXObJLc+xpQ5XOUA== 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=9sODrw04aGrwduWestRssW7UvryYt3hnrjEEqn4hX1k=; b=Bw4yMHXzGZjWp11BHhHnYOROW6n4EqHnTHfYHcWfUDRCygKEOa4fWkX5+cycj6Tq6iZHbIVAehqu2TS/S2wVS9QvhtOm+z1EQucyyGmM1oOS8qwIBnolOYq7OO6LNsTk8VJWm4Y1KK34WJUEkpG1zp14TWsYsfBwehHRBAhFq9Q= 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 AM0PR0402MB3763.eurprd04.prod.outlook.com (2603:10a6:208:e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.23; Wed, 15 Jul 2020 09:04:49 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.026; Wed, 15 Jul 2020 09:04:49 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: netdev@vger.kernel.org, linux.cj@gmail.com, linux-acpi@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v7 5/6] phylink: introduce phylink_fwnode_phy_connect() Date: Wed, 15 Jul 2020 14:33:59 +0530 Message-Id: <20200715090400.4733-6-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200715090400.4733-1-calvin.johnson@oss.nxp.com> References: <20200715090400.4733-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0070.apcprd02.prod.outlook.com (2603:1096:4:54::34) 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 SG2PR02CA0070.apcprd02.prod.outlook.com (2603:1096:4:54::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18 via Frontend Transport; Wed, 15 Jul 2020 09:04:45 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 647c450f-9360-4950-62a4-08d8289e20ad X-MS-TrafficTypeDiagnostic: AM0PR0402MB3763: 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: juphYzqxgz7pE/h3TgAClHrc+23fEKTDtyrID7/L6F4xRYu9Z+vc1HGEdVckGHg43n09tj3L/TEzeN0T6Dy0722XFBej/Ww+Ktq1aDnX8DnlEThkVMG3U/XpMI2x1NovZnDYcK/j4zMPZenb2RyjkSm80y18Y12U8sSglAPAZicsFWZmNU5xh+sT6Si7cIE9xASnW8urGhXCByE/BDJ8tLqWAR2jjn/au8FvyyFsq7dX/3w4b5yhjPT8+LDjpoFkogEI0Evm2Kp77oK9+wvBPAcOMOnKx8TLDqJ7/wQLWBpXTLS0ymzMXFd5LAUhUViPakUWaT/nHLoocIanPIePHDTKAq6g27iAQTUyH65N1gkoh2aDoqj5NvJErrtQzGJf X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(346002)(39860400002)(376002)(366004)(396003)(5660300002)(110136005)(2906002)(6512007)(66946007)(6666004)(66476007)(86362001)(1006002)(4326008)(66556008)(52116002)(44832011)(316002)(956004)(26005)(6486002)(2616005)(6636002)(6506007)(55236004)(1076003)(186003)(16526019)(8676002)(8936002)(478600001)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: WdU/nGdi3z5SLpK+nlDraO14MBf3sD9YxEcmE2OD7JUPNlfQIROOyKlEeB/QR5uhJYDSnYASSW3qPvgGFLZUzyZAELe0pxYjwCGtEZ7GpbUWljyf7h9SSUT7Mm5ZTf+rGUkzT7Zw8Buh5R1xevJ3OzC76H2NDocCcrWGL76dO8rNqUI/ejZYOafqbyMAuedg+AJDSXBRUVFcOXaznCT1Lfr9zMwpS/tv3VeMYKBikFQDJoMXDgDZ47ZJ6dowTvucT+dh8uS7PVJKkTQqygsG0VXFtdOXLRqLbbHzBNAOkrMNWga30hGMUuL0yUdt5kwv+FX/XAi/6DlvoLAX/jJf/DoG3OOoD7DTbLHg1yolWAHWeVMY0tZEZq4r/zgSHW58HbdlMbhahlaORgCogIqIII3pZQudPtxhT876pNzxvFEq94GuTAbVkSwT2aRl2x5u9gL5CoEoYpE2nCcEfO4DDdaxtj0zGo/soQShVjyFDZ6LclMbDAZs9lNY+67I/0IA X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 647c450f-9360-4950-62a4-08d8289e20ad X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2020 09:04:49.3861 (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: wvBcksVyCXTGNGSLSXmc8mh5RB8ZgqTom9oBNXXGniPU28pUEtIEUGEVj7EAcojhHEWJ+0YmfkCm9rmvorOcOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3763 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Define phylink_fwnode_phy_connect() to connect phy specified by a fwnode to a phylink instance. Signed-off-by: Calvin Johnson Reviewed-by: Florian Fainelli --- Changes in v7: - assign flags to phy_dev Changes in v6: - clean up phylink_fwnode_phy_connect() Changes in v5: - return -EINVAL for invalid fwnode Changes in v4: None Changes in v3: None Changes in v2: None drivers/net/phy/phylink.c | 32 ++++++++++++++++++++++++++++++++ include/linux/phylink.h | 3 +++ 2 files changed, 35 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index dae6c8b51d7f..ba40d3bfa986 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -5,6 +5,7 @@ * * Copyright (C) 2015 Russell King */ +#include #include #include #include @@ -1017,6 +1018,37 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn, } EXPORT_SYMBOL_GPL(phylink_of_phy_connect); +/** + * phylink_fwnode_phy_connect() - connect the PHY specified in the fwnode. + * @pl: a pointer to a &struct phylink returned from phylink_create() + * @fwnode: a pointer to a &struct fwnode_handle. + * @flags: PHY-specific flags to communicate to the PHY device driver + * + * Connect the phy specified @fwnode to the phylink instance specified + * by @pl. Actions specified in phylink_connect_phy() will be + * performed. + * + * Returns 0 on success or a negative errno. + */ +int phylink_fwnode_phy_connect(struct phylink *pl, + struct fwnode_handle *fwnode, + u32 flags) +{ + struct phy_device *phy_dev; + + if (is_of_node(fwnode)) + return phylink_of_phy_connect(pl, to_of_node(fwnode), flags); + if (is_acpi_device_node(fwnode)) { + phy_dev = phy_find_by_mdio_handle(fwnode); + if (!phy_dev) + return -ENODEV; + phy_dev->dev_flags |= flags; + return phylink_connect_phy(pl, phy_dev); + } + 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 b32b8b45421b..b27eed5e49a9 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -368,6 +368,9 @@ void phylink_destroy(struct phylink *); int phylink_connect_phy(struct phylink *, struct phy_device *); int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags); +int phylink_fwnode_phy_connect(struct phylink *pl, + struct fwnode_handle *fwnode, + u32 flags); void phylink_disconnect_phy(struct phylink *); void phylink_mac_change(struct phylink *, bool up); From patchwork Wed Jul 15 09:04:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 1329314 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=TeobDDkm; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B6BKp3smpz9s1x for ; Wed, 15 Jul 2020 19:05:02 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730501AbgGOJE7 (ORCPT ); Wed, 15 Jul 2020 05:04:59 -0400 Received: from mail-eopbgr60055.outbound.protection.outlook.com ([40.107.6.55]:26718 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730490AbgGOJE6 (ORCPT ); Wed, 15 Jul 2020 05:04:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hUrGJyCZHN0gDRhnzwd2S7bzpyuHmERK3uEfrA5mturOPyLI3qewi7GwHlj2OXaOT7uRF7lT9e5CYK2d/xt6NZvKHa8K+dfDLB7Q797at344ONcRD5U4SSk71OLUmHzRxH1xj08Aw3yFIWibIUrlA7NdJiGz5xUcw64CCwG298+6Vs9gthyX3Ni6v7stLPvKAxu0MzSnrPnb5a0iUzX8nhMupHgYt3s1Jy9y2N821IHHO6HHWBt7C63uCWemG3+oa/dbb8UkxZzevQr3DCnAMj285XQ5W9AObNpnX3FK4NkSlFwtmaPkN2UC4xxh2fDnEUONnI7KGE77wkqL6u0p7g== 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=D1a+LynARogaUE+B20N8pKJgKotImA1s+9CwVCTT63w=; b=WOnS7x67UhT1FU+0aHhsv317h2nw7/gidhfjFnrNwSyZ6wwJkLz+hlWF5j9zRQuFJMe0eBPk2J/D2pMSVCkTzd1vU+mTjxOl2CCwO3+NzmPSdHGiQ18dzOMYEECPimXhD/1LF8dJ+/nV01odXGF0zxT8ElCQBFEjnOkhNG4FDDFFzH9t0I8VuhWSMYZtbVBay4I+H1TYC2GQzDgZ9du/KxmN/AkpajnqG1dyzQZNFX1Dauo8nlQx/ijR5gumTFLQXFl3X2FMlKb45aGuX2XXCz6JT/Cf3ZB06ErJp7mo0LyjRKbsoyW0Gaf+ZrgkC7knslJEZdHnLLC4C3t058TwhA== 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=D1a+LynARogaUE+B20N8pKJgKotImA1s+9CwVCTT63w=; b=TeobDDkmtCGpPhkl/YlDKd0Bl6jStATpL9oY4wsrIlEmw8A7dWi1QAa2emG+dq3rjG9Tt9b70jqAUvd4hQE5sy/R7UqSggSgLDHvvDfWJ5OYND35bqRqSBddXhiHAJoioN7Wqycn/SAAIdo9LbVbKlKrecPrMQrZv04qNsotNSI= 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 AM0PR0402MB3763.eurprd04.prod.outlook.com (2603:10a6:208:e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.23; Wed, 15 Jul 2020 09:04:53 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.026; Wed, 15 Jul 2020 09:04:53 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: netdev@vger.kernel.org, linux.cj@gmail.com, linux-acpi@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v7 6/6] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Date: Wed, 15 Jul 2020 14:34:00 +0530 Message-Id: <20200715090400.4733-7-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200715090400.4733-1-calvin.johnson@oss.nxp.com> References: <20200715090400.4733-1-calvin.johnson@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0070.apcprd02.prod.outlook.com (2603:1096:4:54::34) 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 SG2PR02CA0070.apcprd02.prod.outlook.com (2603:1096:4:54::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18 via Frontend Transport; Wed, 15 Jul 2020 09:04:49 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 076f0d0a-7bd3-4e31-f562-08d8289e230c X-MS-TrafficTypeDiagnostic: AM0PR0402MB3763: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f8W+kUD4qlwbnUPPVED2t8VGaBDknXAhX4XCh1Gh03bdt6XJv7vLXkBxepqzkw2HKbymmMwpB9sc3mgvpwyDTau7NEDvQkcbafl0v5Qaeb6ams/OG5BhvN6wnNGg7/AQ+seXiKzRrBAL+h7O7gPj+OylQBwjfPD7u7RdJVsQPmGOxhWQ7eaRWodSvJNx+e9Bhc6j2ukMEeBkGMjZCmR4++hRV6VuPNPiDT5n7MKh4Td0pqBfjyKMEd2xUrQ3U/jDdbdvxJMk3YC4Fby4PaUGTdv/t9CENH+qfYi99gdqi0dDrrkjhOfyWAmFnobXGiDbL5wgUzcY0FSOiAdSj04U7hDYbFYHN1dW6ltcwjpQ0zV2OT/Pvj0E81iI7ibQlyIO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(346002)(39860400002)(376002)(366004)(396003)(5660300002)(110136005)(2906002)(6512007)(66946007)(6666004)(66476007)(86362001)(1006002)(4326008)(66556008)(52116002)(44832011)(316002)(956004)(83380400001)(26005)(6486002)(2616005)(6636002)(6506007)(55236004)(1076003)(186003)(16526019)(8676002)(8936002)(478600001)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 9ygtOeEc6v3Bc2J5QJFsiHTvrmmtYQdrateCuiPcak3fJthd68oVAbqqhf41hvEoznSzMyAcIWs+3er2mOZuioY151O2U/BFXpzIwW+UsaEMnOFHvF8zfbBC2KNOTL7vFOkJPJvwuvjzN0S3L5Xeg/CuT3SmMRhRk0N/P75w1XAZsEJVq7c225iOthm9y1eOPH8EBRWYxbpXXwZzRd2APTUTFqBmqltPr0gu+dF+IefPQ6carx+XTShmfkA7Wiqq+vhVUj5wVKY3EDwJWJp+9yUNuIN8lCeZ7N+8cbN27yezVk1T8lgMPRgQeAfvdGRsLI+JDVKdoGEkJClWZSnguqd9hSMEgE0b+LTN99x3ve1LJW5IkbCm1AiGDHkOYzp+5CSwgAhYXdggSmqTSZtFdc5kmBlg1P1CrbSsZCjRcC6EEdJaJiP/75EiwrJdcTuuZ3zkUTcm/S6uQErhhBk6U4H6rCU08wQz4Hh78UThugpx8VjNy4D/wW9tU8BF02nE X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 076f0d0a-7bd3-4e31-f562-08d8289e230c X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2020 09:04:53.2999 (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: 7WZM4Sn181VUHH1z1PC5pezxU9SamFNppBMau6HELG6a9+DZNMf4x5YtgYUs5+Mk3HbnJcDvRUDQ25U7LWDB+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3763 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Modify dpaa2_mac_connect() to support ACPI along with DT. Modify dpaa2_mac_get_node() to get the dpmac fwnode from either DT or ACPI. Replace of_get_phy_mode with fwnode_get_phy_mode to get phy-mode for a dpmac_node. Define and use helper function find_phy_device() to find phy_dev that is later connected to mac->phylink. Signed-off-by: Calvin Johnson --- Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: - introduce device_mdiobus_register() Changes in v3: - cleanup based on v2 comments - move code into phylink_fwnode_phy_connect() Changes in v2: - clean up dpaa2_mac_get_node() - introduce find_phy_device() - use acpi_find_child_device() .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 70 +++++++++++-------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 3ee236c5fc37..297d2dab9e97 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -1,6 +1,9 @@ // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) /* Copyright 2019 NXP */ +#include +#include + #include "dpaa2-eth.h" #include "dpaa2-mac.h" @@ -23,38 +26,46 @@ static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode) } /* Caller must call of_node_put on the returned value */ -static struct device_node *dpaa2_mac_get_node(u16 dpmac_id) +static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev, + u16 dpmac_id) { - struct device_node *dpmacs, *dpmac = NULL; - u32 id; + struct fwnode_handle *fsl_mc_fwnode = dev_fwnode(dev->parent->parent); + struct fwnode_handle *dpmacs, *dpmac = NULL; + struct acpi_device *adev; int err; + u32 id; - dpmacs = of_find_node_by_name(NULL, "dpmacs"); - if (!dpmacs) - return NULL; - - while ((dpmac = of_get_next_child(dpmacs, dpmac)) != NULL) { - err = of_property_read_u32(dpmac, "reg", &id); - if (err) - continue; - if (id == dpmac_id) - break; + if (is_of_node(fsl_mc_fwnode)) { + dpmacs = fwnode_get_named_child_node(fsl_mc_fwnode, "dpmacs"); + if (!dpmacs) + return NULL; + + while ((dpmac = fwnode_get_next_child_node(dpmacs, dpmac))) { + err = fwnode_property_read_u32(dpmac, "reg", &id); + if (err) + continue; + if (id == dpmac_id) + return dpmac; + } + fwnode_handle_put(dpmacs); + } else if (is_acpi_device_node(fsl_mc_fwnode)) { + adev = acpi_find_child_device(ACPI_COMPANION(dev->parent), + dpmac_id, false); + if (adev) + return acpi_fwnode_handle(adev); } - - of_node_put(dpmacs); - - return dpmac; + return NULL; } -static int dpaa2_mac_get_if_mode(struct device_node *node, +static int dpaa2_mac_get_if_mode(struct fwnode_handle *dpmac_node, struct dpmac_attr attr) { phy_interface_t if_mode; int err; - err = of_get_phy_mode(node, &if_mode); - if (!err) - return if_mode; + err = fwnode_get_phy_mode(dpmac_node); + if (err > 0) + return err; err = phy_mode(attr.eth_if, &if_mode); if (!err) @@ -231,7 +242,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) { struct fsl_mc_device *dpmac_dev = mac->mc_dev; struct net_device *net_dev = mac->net_dev; - struct device_node *dpmac_node; + struct fwnode_handle *dpmac_node = NULL; struct phylink *phylink; struct dpmac_attr attr; int err; @@ -251,7 +262,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) mac->if_link_type = attr.link_type; - dpmac_node = dpaa2_mac_get_node(attr.id); + dpmac_node = dpaa2_mac_get_node(&dpmac_dev->dev, attr.id); if (!dpmac_node) { netdev_err(net_dev, "No dpmac@%d node found.\n", attr.id); err = -ENODEV; @@ -269,7 +280,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) * error out if the interface mode requests them and there is no PHY * to act upon them */ - if (of_phy_is_fixed_link(dpmac_node) && + if (of_phy_is_fixed_link(to_of_node(dpmac_node)) && (mac->if_mode == PHY_INTERFACE_MODE_RGMII_ID || mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID || mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) { @@ -282,7 +293,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) mac->phylink_config.type = PHYLINK_NETDEV; phylink = phylink_create(&mac->phylink_config, - of_fwnode_handle(dpmac_node), mac->if_mode, + dpmac_node, mac->if_mode, &dpaa2_mac_phylink_ops); if (IS_ERR(phylink)) { err = PTR_ERR(phylink); @@ -290,20 +301,19 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) } mac->phylink = phylink; - err = phylink_of_phy_connect(mac->phylink, dpmac_node, 0); + err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0); if (err) { - netdev_err(net_dev, "phylink_of_phy_connect() = %d\n", err); + netdev_err(net_dev, "phylink_fwnode_phy_connect() = %d\n", err); goto err_phylink_destroy; } - of_node_put(dpmac_node); - + fwnode_handle_put(dpmac_node); return 0; err_phylink_destroy: phylink_destroy(mac->phylink); err_put_node: - of_node_put(dpmac_node); + fwnode_handle_put(dpmac_node); err_close_dpmac: dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); return err;