From patchwork Thu Mar 11 06:20:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12130455 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 3C402C433DB for ; Thu, 11 Mar 2021 06:29:08 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5374064FAB for ; Thu, 11 Mar 2021 06:29:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5374064FAB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1AmbxGzemv33kB/3/q8vv62ae8FPzfh3NzEoRc94h+A=; b=GfbC8xm4dYNj7RbIaHVsv+vy1 IOHfasZSxUom+08LgRZwymvTJRaFzcawcl0+Aiw38wlYaoNERpYtcytVwdqdq0fWrFWx6QvG59uwS DP7mbHQ0m99oFeZHy1FzaRzJ+yzUbzOeU7WEhJdJe4EWrIG8TrwuaQO/xVjGaWxQWA25/RNHqG+nw bn0mOm/El3fCTW4K4ILBA5LxS5nle0FtrT6lZ2WNIi6bgc4KYgPk9WDicy7ojPA6kBaqYqcrmg9F2 +jffE+LMFyv8mEctKchcbopNQCo+dn6YyV+WWrM/qTKm7fCSEKOtiPmW7UmnKWWxzMl9IO8KGfANM Ynizcrqfw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKEmo-008UIV-UM; Thu, 11 Mar 2021 06:27:08 +0000 Received: from mail-am6eur05on2081.outbound.protection.outlook.com ([40.107.22.81] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKEih-008Suf-L9 for linux-arm-kernel@lists.infradead.org; Thu, 11 Mar 2021 06:22:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NCve/NF/CZsq6cU+ddS/5IgnguJppb0XEiv77ePjVCY/p4gS3u3GDOlxbNxzGpRU3fZt5tLDYLkOcGNGPdFXpvkNvG7xByRrBSfUKqt350nAjS5cZa2bmfXnv+SAHxDW/VDUJeVADRbx5SzP7zItNh0xYs6hiontliXpvxXq9frTMHv7y5BCeBScht4PnWjp1CAsX0WbkS+uxunVCCKHB2pULeyybCnAgao1mUUsSQmQ1QDNSHhiNAxpukqdpzEjSqxHVmjW6mXZUAA7mbXrHaSI/mudhLYlxFbdObnCB7335eJvXHO/uLwQm5Nn1nCmqkcNQfJINlQuOZd3lRpO+w== 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=o5CCUYQ4PNOtdIpFWUnwN02iQqvVrzm5w1kWzIjVu5E=; b=i1Lo26b0eAWlj9oFvvOJWNFbhWDO5Eyo+owIa+XLHzsnT8kjG3GFH/DyHv8BFTjzmmcDBw0clku352yqwtvorGsnEWTPRWO6mniIdq0lucmkKfwVpO6g60Ihklk5zbOtg0i/4keRQbyVSMPDzq3GrwBdhzXfkVU8h0NprjUv1JANZRxHn1HCt/5NRBdBDbM2WxGLaVjkLwIOz7X1uItLl5XTfEGyww02pIL+yKYrznOcUsFHC8oBV+Q6pU+wxR8yscfaALsm5Xxgp3FCQi5hY+CfjsSCD7+kF3balOSvUXkRoqFFDfWtYtaDwtn86IoQYhJi3De9Md8H2e/eWrohTQ== 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=o5CCUYQ4PNOtdIpFWUnwN02iQqvVrzm5w1kWzIjVu5E=; b=TQx15zqRrAtpJbWPxMpF4PLeU8yUHxEkrD8MmF1kUJqu4A3W5qfheWshR8lfh7oWGg1oo3Eo+QOPWIa9DNvFRazkRCfbJ5aKBdOSF0/dQZYlSM175qC7MycXiAwzem3dztE8drPeLMY9gpHEsMZL+7akFQXbk8Jy5m1eQvWS/7E= 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 AM0PR04MB6611.eurprd04.prod.outlook.com (2603:10a6:208:176::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17; Thu, 11 Mar 2021 06:22:49 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::1cd:7101:5570:cd79]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::1cd:7101:5570:cd79%7]) with mapi id 15.20.3912.027; Thu, 11 Mar 2021 06:22:49 +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 , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap Cc: linux-arm-kernel@lists.infradead.org, Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux.cj@gmail.com, netdev@vger.kernel.org, Laurentiu Tudor , Calvin Johnson , "David S. Miller" , Heiner Kallweit , Jakub Kicinski Subject: [net-next PATCH v7 14/16] net: phylink: introduce phylink_fwnode_phy_connect() Date: Thu, 11 Mar 2021 11:50:09 +0530 Message-Id: <20210311062011.8054-15-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210311062011.8054-1-calvin.johnson@oss.nxp.com> References: <20210311062011.8054-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: HKAPR03CA0026.apcprd03.prod.outlook.com (2603:1096:203:c9::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 HKAPR03CA0026.apcprd03.prod.outlook.com (2603:1096:203:c9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.9 via Frontend Transport; Thu, 11 Mar 2021 06:22:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 975bdc41-d9ed-4dbb-6aed-08d8e45617bd X-MS-TrafficTypeDiagnostic: AM0PR04MB6611: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4k/CzVPQsx0YtWAFnhlfcxa2pI357RncH0Csd1N5RaxTSSUHBIz5CJ/MLXASeYuV7lc4Ka9DHZfPkpgS3d9CQJfwWSt+W/ov5Or6jCtEvCaQV7F9EmQ0/zSRxY3EMX7BPVcOw1QTNyg4cI5AyYq5+fDLfWWXyF+aLlU0vrYt58a+r0wZNm+pgk5slc2fdbDrmo6aL/nXHHw8GqmWAKaP17M0wH4GVb4jgUVWJpXBe+pKqelRIMWib2aP+Vtes4W1DHD4LfMZkbTr/jxhP90t8VKagJyNLTXypfWN7PGloXlcfuAzCVf3FDZDmrFQMpBNSFpeSX7DmVElQVLPVpWBanpLLXNairq6BenU4LKUHRO5GvjbVR+2E+kBehuHvE3wRIgqpYQey2RT+FUbqglTa8ewCTETPeJdkuwFUffOgUEPfDgDKJqeA7c5YnPVfBY78/pXiaHobIJn/AwGB0wFyU7sHXd2vlvRGZnJdI0BqI0Iaqlj1EYwfCfNVydMbmp444m2VbrZf42Bb9d/9KT4vYEJjQr2FEQsFK6fdgsDjV3DyjMw44RBPheMc4I4iLHpRHTq2v2aUsJF4mO5UvN79SaiErE64rie9cA09MlmFJs= 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)(39860400002)(396003)(376002)(366004)(346002)(2906002)(921005)(16526019)(26005)(186003)(6486002)(8936002)(6506007)(66556008)(66946007)(55236004)(66476007)(44832011)(478600001)(6512007)(2616005)(316002)(54906003)(5660300002)(956004)(1006002)(52116002)(8676002)(6666004)(110136005)(86362001)(4326008)(7416002)(1076003)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: d/y2z8slzKSCxOh3yZ+BCH1yXd5lhhKEmfU0bBxe+eUUiO6QEal0XvNDahh49TZ6A6YeqwAnKS0l9AGtY3QgcbdjyzWrwAGjW6oZ21rVdXQYFfgDZx85hNXs8+0WjmXmQXN0lEjHO2hNMGwnwG+DLk8zwnD15kmCmlvZwKDz2HU07A/hpi+tMaVm+1VNZjjPWjxKp3YygMBLQRozyagpKVIBHWZBBrTXRg2BZTj/hpD8KQJt4cC6oNG7P93MjzPVROP4OjJTSxibXrcUn1DrZmnfV+rVn9+FcNv5+hHzbPN36x5utPm5TaWmJ9yQcYxldkZlI6EuzVyFkTvPBFxzh0KwDDNAPLVKJaROOMlMv/NrIqfzg7GjoXNiBQSFwUx+5T9++cXixk84YxiKcqo26J0suQ7+5culFSl38O3EY+0HY9RijoJnWw6U17heg81eqnXZqkgLC+1ZtvGQd+icsDDU/P2lPje/g25lO6BLl8XOrFHI2HIbuSsGT+iCnojmCaHgD666LgBsm0i/Z88wZa0gxuywmQIcALgwsLkt0nKVi/HZje0HY3Uq9x9WLRdUKs+N9wmTMSfKvPD2uI0INx4DYTzkMaOGELZp4YDCFrH9Iw+EGaQ+lN7Xn5e+Rieg3r4jgXMbjF+KwnWPd1BRCI0vL3xBtwUFvngE5VAb00vi/9FK3cDFHLCSEyD/UmiF2nHvlt8l1UJwSDSrC6vajkchfOkFzOpf+oJlaKMaOsx0RO59FMb8oyRmxcCtJ0t7QyDFbeU+eWe427Y2D0W/RawtiRNMDciiwAsVlGeGOhEFboPCnP4z7T5B1rU0/swP3BzINa3Cwb8GOFyGHItU1C5Vs92NHX1ZzSbS9JBRA8VwNf8hrWr1A8ZZe3GEB4iFvUorRRIYqKKZS/bMnI/g2IDLLgerFSah0iSO7eg9a7Z/f+KMPpAbwiCawu4LvsN2fMtPRA4CvLZ/G9jArlwKtFPaxmp1gkbNps8qP0NIWO08ge4tjcqfAY6VBhOGY/0/0Hhl498Te3vySirqcdIyLesb8gZBEJdKvBAHL36BvEZY+QJ90DaP+hIkQ60NywxY1JSU8SN9/GoOKM9N/kYwzBIan8VTMTPQGNZag/Eo8SwGXe+N2MTYHttmTq6Imm0oCNki7KMvwegLzc1a31sJOXq0754g2FitSnI8Me6bucawjIRTtnIGNmp4wIg+Ih4xU4N9h7cqoaXzdwrJeLd2ToKf74fIUDfqX3khQJXbp73XXjeyog5tv5kb/Hnzd5ZqIaGLfsqZnL7ng0OTf4IkAiHmwibLY7xG2ubgerN1U2Um9E5LsoRZeMl/uhw6YCht X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 975bdc41-d9ed-4dbb-6aed-08d8e45617bd X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2021 06:22:49.3153 (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: TegvOFwmObRKHH3PNyQLvQww8tTgB4lnJBZLUyrcRGMaJSstw2+RPJ20pVIzRUUXo9pyAHhF2XRPjeJ6eOLJsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6611 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210311_062253_759266_06B2C4B0 X-CRM114-Status: GOOD ( 17.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Define phylink_fwnode_phy_connect() to connect phy specified by a fwnode to a phylink instance. Signed-off-by: Calvin Johnson --- Changes in v7: None Changes in v6: - remove OF check for fixed-link Changes in v5: None Changes in v4: - call phy_device_free() before returning Changes in v3: None Changes in v2: None drivers/net/phy/phylink.c | 54 +++++++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 3 +++ 2 files changed, 57 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 053c92e02cd8..23753f92e0a6 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 @@ -1124,6 +1125,59 @@ 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; + + /* Fixed links and 802.3z are handled without needing a PHY */ + if (pl->cfg_link_an_mode == MLO_AN_FIXED || + (pl->cfg_link_an_mode == MLO_AN_INBAND && + phy_interface_mode_is_8023z(pl->link_interface))) + return 0; + + 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); + /* We're done with the phy_node handle */ + fwnode_handle_put(phy_fwnode); + if (!phy_dev) + return -ENODEV; + + ret = phy_attach_direct(pl->netdev, phy_dev, flags, + pl->link_interface); + if (ret) { + phy_device_free(phy_dev); + return ret; + } + + ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface); + if (ret) + phy_detach(phy_dev); + + return ret; +} +EXPORT_SYMBOL_GPL(phylink_fwnode_phy_connect); + /** * phylink_disconnect_phy() - disconnect any PHY attached to the phylink * instance. diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 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);