From patchwork Tue Jan 12 13:40:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Johnson X-Patchwork-Id: 12013535 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 2076BC433E0 for ; Tue, 12 Jan 2021 13:47:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 9E01E22B30 for ; Tue, 12 Jan 2021 13:47:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E01E22B30 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CdMSxt+BvFuKu+8xzm/hD6xHGPn8dj9iFLR2Ec+JBQQ=; b=KFqM19JEGtvP345PmJ6trFV7X htJ4+X8GD9TCvaNX5mXjLA1aA7GrQvfNW1Vv0TaPz7RClrxKcfnd86SQy1/T9LoKH1c/LSQn5F6yX MmXY12LjgYqTPSEwandhozary7rV1I9L5o/nd/fly61pL7FBcoFc7+pF6iPliNtpyUnZpfBUGr1EM /JyOjy12YtMAgujeEaiGtJBZy7GzPZxQh8eEqFIoe0smGhLf3DKBTqOlJaJqYgMECEI2EkO27tLqW qKiCCN1XXYgoImKZc1mNo5SopSEr+ARXFjKjZJxLVfRvt6iU2OUrcEmbEgH5nBe16dlCFGCmQGi6P EvOLj+iTg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzJzK-0001np-Sc; Tue, 12 Jan 2021 13:45:34 +0000 Received: from mail-eopbgr20052.outbound.protection.outlook.com ([40.107.2.52] helo=EUR02-VE1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzJx2-0000XI-8Z for linux-arm-kernel@lists.infradead.org; Tue, 12 Jan 2021 13:43:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jjWMj2TkHl5BjAyPWm06PUj96Wl5JHlrOBYqqO49/fb2w/eMS0mW0GAt4VKsfOAtyeu+g42KMIUV9WO6Zg9SJHWotZOFCWK36a9pQKDZRfd49qAx4C47Dv6+IYDcjjHuiJLgePKindoibD0dKpx1HPgrwAWMUC80j1BM64MvbqstFCeWR3Lp/N2h44VCp0s3UsdCgNDRW0qmGlVSNh/MhXy3hl1gU0BbM/JHZXuJ9C8oKBmNtxnEdr/K97RymGn82XEdA5x3C2z1FP+08U64hscSOduC7YFXD84NK5BCZAJQipRAi9M5dguU2+BzhHcsn6hXyEa1RoJfNmIywR45sA== 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=Ptl58KKlqn7/aQTaIpbfM1YNroxq7pUX0wvLQlVvwkg=; b=i2jn/Cup1CDsCagf+5tgiTc9wuEWI+um0D1Zr9XnwpvLybfQBeWuoFkHCmNx6ZeqRsqzFgEDEnLOHq1aHGWpffAlPlk4JlHKy2IpjegfByM1OSlj3z+nJJruChjlQUERHiQz1ESwIAnXD9ATL1nrbiCkmL+JXNB+K5bngZENVtG+p6KHxrNmlHO3MgDgk8mRYFxNR/4XUPpzhcfFHUlG/Xw13TVpTBvc780jSIVDM1OdreTWzGZagZPas9UEiN+Jeg1BPSJnXyGHaDMaun9vrqeGWh42/FehXDrfSWNIooRxyGeAUwjAfBxooLLFpAkrs4h5fGMgV3CuFOcve8le/g== 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=Ptl58KKlqn7/aQTaIpbfM1YNroxq7pUX0wvLQlVvwkg=; b=MV3NOTPt5o1jfhutpa7F+v73ZLnikGZ3XhRZGi87Hwn2Dm7dVG4bc+nfvafkzo0S0FFx/TlBB7N0EuuRMYPF64M7y7G+lf5m84vF8zOA8bZv/5Ezpgz5GBnWmPzfBG7vVpXerbB/daKGR9Mb32Lz3BPB5Dff7Cc+4oHzlttNvKQ= 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 AM8PR04MB7937.eurprd04.prod.outlook.com (2603:10a6:20b:248::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 13:43:08 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:43:08 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon Subject: [net-next PATCH v3 13/15] phylink: introduce phylink_fwnode_phy_connect() Date: Tue, 12 Jan 2021 19:10:52 +0530 Message-Id: <20210112134054.342-14-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) 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 SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:43:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 583250bf-d7fe-4cda-0465-08d8b6ffff33 X-MS-TrafficTypeDiagnostic: AM8PR04MB7937: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NzHQqq7Z3um0iuFw2B2lAdn9Hcv62h30uCJbjfR3MXBqMYPk6q7Hz3yPDaux15Mj7vCoLYpKbhPrEBf6R8ZAicmIbFk9Y8NJvtYvYH+K1D2HJqiS5KBYNkI7O/pTdaWDHuUxj/bZheqeiXMdCDbts5Ga0EgQGzslvrU5lU3C3o9eJ6257uGD5izdbVpJO5WD7Ch7JssyjAOxcdBT5RJpVDNvYByBimZvyS3QFKe34QmzL3Ow1YIPly6qdrz8un2BIElPwORNvoXO64yrT9EJiJlbM+udkbiPk6p15SUYenMQyAs78Elq9lwFkb+LqNCquISbFlcEhwORglaWd5nhjHGdk1oKPjSs+7hSYJx/kSd6eHUG8FZj7fvB9lqNnxXP7O1j5fwlhlx/9nSu73FojSUmNv0pMDKj5iyxebbNKK1fvkhyJHuysBpv1UU1ZeUIWRDKRRvrkcL4Z96d9zYxgg== 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)(376002)(346002)(136003)(396003)(366004)(39850400004)(16526019)(5660300002)(1076003)(86362001)(52116002)(44832011)(66476007)(110136005)(6512007)(55236004)(26005)(186003)(8676002)(66556008)(316002)(8936002)(4326008)(478600001)(921005)(1006002)(6666004)(2616005)(6486002)(54906003)(6506007)(956004)(7416002)(66946007)(2906002)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: g45vaXX99LmbWqQd/gHg95kCiV2/B5SxluQ4KmLDbSc4bOOjifDp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-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2021 13:43:08.1557 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 583250bf-d7fe-4cda-0465-08d8b6ffff33 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1Xxdn5TeWvrZE8nOQl25UcGcIOpk6fZle4IJvAT8b4F8PcGU/GZhKwVHDEnz9YvRMPmEyzLgkFVklGsI1ny/lw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7937 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210112_084312_384945_486DC340 X-CRM114-Status: GOOD ( 18.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Calvin Johnson , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux.cj@gmail.com, Jakub Kicinski , Heiner Kallweit , "David S. Miller" , linux-arm-kernel@lists.infradead.org, Laurentiu Tudor 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 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 84f6e197f965..389dc3ec165e 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -5,6 +5,7 @@ * * Copyright (C) 2015 Russell King */ +#include #include #include #include @@ -1120,6 +1121,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; + + if (is_of_node(fwnode)) { + /* 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) + 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);