From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.7 required=3.0 tests=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 01FCCC433DF for ; Thu, 9 Jul 2020 17:58:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA4CA207DA for ; Thu, 9 Jul 2020 17:58:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="kKP8IIyp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726758AbgGIR61 (ORCPT ); Thu, 9 Jul 2020 13:58:27 -0400 Received: from mail-db8eur05on2077.outbound.protection.outlook.com ([40.107.20.77]:27872 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728246AbgGIR60 (ORCPT ); Thu, 9 Jul 2020 13:58:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OGqj9QGOTKle0tHTm1VBU2ZFrasoG2OkGgQMyLkjRLfPZjZeRQwEYTmwTAgka4VHz42U57D8sxGIAle0DWRUzAm626XRVQd7ncDKr/1MnDdOmEUT6tBt4EYJ1ZYp+HxkFO1ryk96schYpxqiY2Di68vRJ98VZxrb3cCWPuOhedH4+h7XPbT3lDGt1M12bH1yxn6Z6Vo7htFeiTxW3bYRDiUxX9WW278BBJNvMVWZWkROi9FLDzQv3BpccagkXY3S6blRGiYNQO9yjDJ0lCJdZM/hvCSmiBV3BCwcac+zi0t1G7pHeN2jvaCydhnM41UZjO4i85CgsOLzA+l6JatXzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fss45xKt62SlrWpJp25LA0ziCYork6kewBoZxwWNBnM=; b=B7Snk+NDv/eQaMnvhYaK28r86mTQOWVVy762YmpeJQVKiSxyoQPb8i3RUlpplR2XoOkjIg37qa6UX50fLR+bo1AtgcJoyaKA4Y+zbjIj4OANQEtttlpC1WMwlPXitH9GPddnR/P0k31o4G3nXS1p8FZBx/9VQVBGEu9sEICN/xsUFx5o9XECn8+8sis9rll1vWPBi0Xmv9oa5Wu52FDJspDkdrydvfptixG4W2O50lLnKlv4RvQCRTFU/n5FoKZqZDVp59DESwMrGHmqLapiQy2qQDS+koNr+4hLWhrl9DYRhbMwXvmoeZtiKjzqLvpLvfb3fUQZ80hZc7CVgw1XtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fss45xKt62SlrWpJp25LA0ziCYork6kewBoZxwWNBnM=; b=kKP8IIyp1xDP9VZ1fCmeEdfR1Gb0DlLh/YGQya7mySnkiOGuCPPPZOM9nrxmQXtUUKsJ7TOnHLmmJcv4SSMU9RaQeAV6c+GH+2WRJXANO7oMwuWZ121b4ZPmqZoE4NXhDutYDqxJKjJnib8nMMIpYJ51tVGz3xwcGGb4k1OxYbA= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) by AM0PR04MB6898.eurprd04.prod.outlook.com (2603:10a6:208:185::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Thu, 9 Jul 2020 17:58:06 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::7dda:a30:6b25:4d45%7]) with mapi id 15.20.3174.021; Thu, 9 Jul 2020 17:58:05 +0000 From: Calvin Johnson To: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Madalin Bucur Cc: linux-acpi@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, Calvin Johnson Subject: [net-next PATCH v4 6/6] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Date: Thu, 9 Jul 2020 23:27:22 +0530 Message-Id: <20200709175722.5228-7-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> References: <20200709175722.5228-1-calvin.johnson@oss.nxp.com> Content-Type: text/plain X-ClientProxiedBy: SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) To AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03152.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR04CA0151.apcprd04.prod.outlook.com (2603:1096:4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Thu, 9 Jul 2020 17:58:02 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 578154f0-127c-4467-3c53-08d82431a1ae X-MS-TrafficTypeDiagnostic: AM0PR04MB6898: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UYEznWhCFNk8fNdIxCYkhSzwoC1hep/ChQT/dks7qCRay+b9UFmuo13bAlV8FJMQyf+Qb+n3+q4KAPZaICxIDRaJz7yc2hu1HPxuSzMOVCB4EFf3ocrDSwc5thwCICr2RMweb+8W9XPKtcWIC9sAXbKsXut8yKw7eViSjXlCLVsXFQwjps7PDBgk9aHVEum+ieK6BHd5+T5bzr5S6InEo/CM+9EbmnORgUTr1/jCrvBKL2xax0op/cp+49s6uS4yEZqXux+uuHZL+rfGzxELixUhq0D4DKOXp1lj4rrnFYDXuFJkqK3xtH4qMFvUMNQKEAmlyyTqlT4UCDTUNLlCjKxGNcd7rZ0EOzCA1hw4u+/LLElJgahDVdfHpddX1AHb X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(346002)(376002)(366004)(136003)(39860400002)(83380400001)(6666004)(44832011)(1006002)(8936002)(2906002)(52116002)(2616005)(956004)(110136005)(4326008)(316002)(6512007)(66476007)(8676002)(66946007)(86362001)(66556008)(6636002)(16526019)(26005)(5660300002)(478600001)(55236004)(6506007)(6486002)(186003)(1076003)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: bXsbqlJByhn40ZuN6k47sMul+nGNk9SRnCCDyN/LNw4zbfx3mHj0XAtCxmj+Z16D7C3E6Z79kj9BwmP34d8ziAOCSWy42yZDep7Pbf9mY/d2b6sxEilKPGdmh+EPRbUiw0VMV6M5J8pre5Ha63fYgz5auGTtkd8HcbjNd1gDuzOyuA6UfnYf5IiYhuII1+dsNyyQvtH/J8IJqXQ9pUdc+8pn7Tl9hs6RZum35szBvr1BBqM37YPbPNjy5+a6usEMPKsXFj7aJEyYeIn5PfOg8G65pLZuZUGOvkD0xDvMUC8ALijHqPiOKVgtPm042nzCih18dK3AScNYn5mfFuhTfzF1Fm8HCbbsDVjZxetnFORGiNfifMPJ4E57zJbeUr0exyzPe5rlHdUVGskqNrRISyOJbgdDeJoCG2PUObbtYfdMt9zr/gYWBSV5flrEZB7QcsRjaRptfDhx8SPvcJ0sDQ9oQReesM/eZW92hskrSns= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 578154f0-127c-4467-3c53-08d82431a1ae X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 17:58:05.9522 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WdTF7XMQIrJD4JFnYlyY9wXg2VLJvErt+JtdHP1CpSgbEfYo6KLyao+ws7SEClHeG07XKnbIb5qaTLfr65o9eA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6898 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Modify dpaa2_mac_connect() to support ACPI along with DT. Modify dpaa2_mac_get_node() to get the dpmac fwnode from either DT or ACPI. Replace of_get_phy_mode with fwnode_get_phy_mode to get phy-mode for a dpmac_node. Define and use helper function find_phy_device() to find phy_dev that is later connected to mac->phylink. Signed-off-by: Calvin Johnson --- Changes in v4: - introduce device_mdiobus_register() Changes in v3: - cleanup based on v2 comments - move code into phylink_fwnode_phy_connect() Changes in v2: - clean up dpaa2_mac_get_node() - introduce find_phy_device() - use acpi_find_child_device() .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 70 +++++++++++-------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 3ee236c5fc37..297d2dab9e97 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -1,6 +1,9 @@ // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) /* Copyright 2019 NXP */ +#include +#include + #include "dpaa2-eth.h" #include "dpaa2-mac.h" @@ -23,38 +26,46 @@ static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode) } /* Caller must call of_node_put on the returned value */ -static struct device_node *dpaa2_mac_get_node(u16 dpmac_id) +static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev, + u16 dpmac_id) { - struct device_node *dpmacs, *dpmac = NULL; - u32 id; + struct fwnode_handle *fsl_mc_fwnode = dev_fwnode(dev->parent->parent); + struct fwnode_handle *dpmacs, *dpmac = NULL; + struct acpi_device *adev; int err; + u32 id; - dpmacs = of_find_node_by_name(NULL, "dpmacs"); - if (!dpmacs) - return NULL; - - while ((dpmac = of_get_next_child(dpmacs, dpmac)) != NULL) { - err = of_property_read_u32(dpmac, "reg", &id); - if (err) - continue; - if (id == dpmac_id) - break; + if (is_of_node(fsl_mc_fwnode)) { + dpmacs = fwnode_get_named_child_node(fsl_mc_fwnode, "dpmacs"); + if (!dpmacs) + return NULL; + + while ((dpmac = fwnode_get_next_child_node(dpmacs, dpmac))) { + err = fwnode_property_read_u32(dpmac, "reg", &id); + if (err) + continue; + if (id == dpmac_id) + return dpmac; + } + fwnode_handle_put(dpmacs); + } else if (is_acpi_device_node(fsl_mc_fwnode)) { + adev = acpi_find_child_device(ACPI_COMPANION(dev->parent), + dpmac_id, false); + if (adev) + return acpi_fwnode_handle(adev); } - - of_node_put(dpmacs); - - return dpmac; + return NULL; } -static int dpaa2_mac_get_if_mode(struct device_node *node, +static int dpaa2_mac_get_if_mode(struct fwnode_handle *dpmac_node, struct dpmac_attr attr) { phy_interface_t if_mode; int err; - err = of_get_phy_mode(node, &if_mode); - if (!err) - return if_mode; + err = fwnode_get_phy_mode(dpmac_node); + if (err > 0) + return err; err = phy_mode(attr.eth_if, &if_mode); if (!err) @@ -231,7 +242,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) { struct fsl_mc_device *dpmac_dev = mac->mc_dev; struct net_device *net_dev = mac->net_dev; - struct device_node *dpmac_node; + struct fwnode_handle *dpmac_node = NULL; struct phylink *phylink; struct dpmac_attr attr; int err; @@ -251,7 +262,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) mac->if_link_type = attr.link_type; - dpmac_node = dpaa2_mac_get_node(attr.id); + dpmac_node = dpaa2_mac_get_node(&dpmac_dev->dev, attr.id); if (!dpmac_node) { netdev_err(net_dev, "No dpmac@%d node found.\n", attr.id); err = -ENODEV; @@ -269,7 +280,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) * error out if the interface mode requests them and there is no PHY * to act upon them */ - if (of_phy_is_fixed_link(dpmac_node) && + if (of_phy_is_fixed_link(to_of_node(dpmac_node)) && (mac->if_mode == PHY_INTERFACE_MODE_RGMII_ID || mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID || mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) { @@ -282,7 +293,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) mac->phylink_config.type = PHYLINK_NETDEV; phylink = phylink_create(&mac->phylink_config, - of_fwnode_handle(dpmac_node), mac->if_mode, + dpmac_node, mac->if_mode, &dpaa2_mac_phylink_ops); if (IS_ERR(phylink)) { err = PTR_ERR(phylink); @@ -290,20 +301,19 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) } mac->phylink = phylink; - err = phylink_of_phy_connect(mac->phylink, dpmac_node, 0); + err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0); if (err) { - netdev_err(net_dev, "phylink_of_phy_connect() = %d\n", err); + netdev_err(net_dev, "phylink_fwnode_phy_connect() = %d\n", err); goto err_phylink_destroy; } - of_node_put(dpmac_node); - + fwnode_handle_put(dpmac_node); return 0; err_phylink_destroy: phylink_destroy(mac->phylink); err_put_node: - of_node_put(dpmac_node); + fwnode_handle_put(dpmac_node); err_close_dpmac: dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); return err; -- 2.17.1