Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp106662pxf; Wed, 10 Mar 2021 22:26:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJztry4i5sRao/I4g83CozD+l8qj3WjrZ+2GdDls578ISbNGtQZgR0mzaTZoUhcSYaeitO2j X-Received: by 2002:a05:6402:38f:: with SMTP id o15mr6753645edv.361.1615443989890; Wed, 10 Mar 2021 22:26:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1615443989; cv=pass; d=google.com; s=arc-20160816; b=xB6a2lO0ZnPKVqqfjzP1T1c37gF0KtbJ5TwOWem991InFFZfnmUBjQWV9iXChtebA8 R80+6VY+sqYuUag704cAoG0V7yQU8QaPY5r+dYrupChvVlQcU44QLGuOqznPslLAPPw1 JqWmHMU8R7Yhfrz04w6rPOjnK1YwTCtUaXrijEbRf0ZQHdCnd5MJ2RQF0npPWe92ttsX 0Ga+Kofjl9FA3z5JvfJAarRC1T/uoHHQbDZkKKYOlT1LPerT44dw8FID3MWJQPwn2mMa gpc5Ej2Vus//Z4fFbgKFcIJaFgyrf6i7OALV1gveK34vocFiLqw8kblK2QOeCmkDVpkg dzfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=o5CCUYQ4PNOtdIpFWUnwN02iQqvVrzm5w1kWzIjVu5E=; b=SEsN2oANlnEO17t7Klo3yfBCvRsuPlAWa6w3L041eljw0CmRotnAVFujy2QYqIUEha aPyiSbhcSlxNjiNTNWx15SzivEraThfsxIcwYcKWxkDj2Ob6/ZetKvQCeHMsYCxHf541 rIuDU90fL7Jw3HixD7Z7NHHaW8sxoZl1ZQ8Y+H9koBppGvA0DdG7R9pyrgr191TimGfW Oaj3PyVeqlsznS6w/1MWM/NZG+IO9c8gq8RUmNgA7cpqWU0be45F2swzooQqJfP12PEb WGqsR0SVlJ/Ugrsg4WPWj4h8xqgQDTUellbfGew8UpMe3/XGd/i41vwOkIAnW2qX9goP XFxg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=TQx15zqR; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z22si1057052edc.427.2021.03.10.22.26.07; Wed, 10 Mar 2021 22:26:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=TQx15zqR; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231504AbhCKGXN (ORCPT + 99 others); Thu, 11 Mar 2021 01:23:13 -0500 Received: from mail-eopbgr20066.outbound.protection.outlook.com ([40.107.2.66]:53349 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231570AbhCKGWw (ORCPT ); Thu, 11 Mar 2021 01:22:52 -0500 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> Content-Type: text/plain 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: =?us-ascii?Q?d/y2z8slzKSCxOh3yZ+BCH1yXd5lhhKEmfU0bBxe+eUUiO6QEal0XvNDahh4?= =?us-ascii?Q?9TZ6A6YeqwAnKS0l9AGtY3QgcbdjyzWrwAGjW6oZ21rVdXQYFfgDZx85hNXs?= =?us-ascii?Q?8+0WjmXmQXN0lEjHO2hNMGwnwG+DLk8zwnD15kmCmlvZwKDz2HU07A/hpi+t?= =?us-ascii?Q?MaVm+1VNZjjPWjxKp3YygMBLQRozyagpKVIBHWZBBrTXRg2BZTj/hpD8KQJt?= =?us-ascii?Q?4cC6oNG7P93MjzPVROP4OjJTSxibXrcUn1DrZmnfV+rVn9+FcNv5+hHzbPN3?= =?us-ascii?Q?6x5utPm5TaWmJ9yQcYxldkZlI6EuzVyFkTvPBFxzh0KwDDNAPLVKJaROOMlM?= =?us-ascii?Q?v/NrIqfzg7GjoXNiBQSFwUx+5T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Xjeyog5tv5kb/Hnzd5ZqIaGLfsqZnL7ng0OTf4IkAiHmwibLY7xG2ubgerN1?= =?us-ascii?Q?U2Um9E5LsoRZeMl/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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.17.1