Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp188660rdb; Tue, 5 Dec 2023 02:38:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9E7aMI/WW1qMXnsKF5nIotZ+7w8maQT5fFmH7UpH9AmeRw9N9HLq0tez6dHbm3vnm6gXI X-Received: by 2002:a05:6808:f06:b0:3b8:4ced:a40b with SMTP id m6-20020a0568080f0600b003b84ceda40bmr6387648oiw.41.1701772688138; Tue, 05 Dec 2023 02:38:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701772688; cv=none; d=google.com; s=arc-20160816; b=Xwc9uZPpfWymtNGVpE3NZUyv0z2iLn9+MdKDTDcb4BWKOE5iz69tpiqr/VlrbzTfCw jCVIcpdST5eUrnRES7En4FIZtMWftlPwyczf5skKdSEuohIEEjYISkUJ+Ny7CPaHXe7B a2xRGqtytLrmPt9QbANQhSsTwH4dIr6ixZmbNush3W5+YF3DZkaYujp1Q4JAHUA5WsXg jIaaOpZdBdJ7WMRX+g/t+sR48BiFTuLMqdkm/8MVbxMoflojuj+9jbXb8wfuZduRyeQ3 bQkxB/ILRavyzQJodhh/z1H/eNY6WF+x617fnhQZuFqkJFIKlQTHBa3OG9p/sGdnGv1z XXSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7hpm9CJMW8yeGqWkPdTKA3BPaZ3J6DVLqALQqXWpKSU=; fh=NoYD4WQZNjSG2Bb9ocssXw4U79pWAZvdivFB0JgByN0=; b=m1iTOtcqcsuBiEjCjqcfE2TNGja8GNb+BwSl3GOtpMCuNNs/BRFxae9X+r79DvrFgc +1aZ2JHqVO5BJECdEAQXxle26dtvWks1HARI1s4TkHXrI4A3PlqJTaa5Z4voISkA9wJ+ JD+WHDTdEJ+YZEWKQs4p1CB05SSYwBrs1LE6+vrWE4sZvPex2vRbuG8bnzCOURQqGjkb 6p+zsTrqjzMTHqqLQpyjtYujqaNa6jsGMe0BUIn9TBgtKcss+2Id/7cJoHk/BcHoFTlj koVkY14Uoco2pip7W58LH6EZHuGF1ZxTVI011THrbVJ2QYEgAv+jW+YUUmv2nD1NtI8o ZGfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dbS1n4X6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id l3-20020a656803000000b005c680fbab22si3776643pgt.509.2023.12.05.02.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:38:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dbS1n4X6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7263E80A23A2; Tue, 5 Dec 2023 02:38:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235483AbjLEKg7 (ORCPT + 99 others); Tue, 5 Dec 2023 05:36:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345032AbjLEKgd (ORCPT ); Tue, 5 Dec 2023 05:36:33 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7CC91AB; Tue, 5 Dec 2023 02:36:26 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-50c0478f970so640402e87.3; Tue, 05 Dec 2023 02:36:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772584; x=1702377384; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7hpm9CJMW8yeGqWkPdTKA3BPaZ3J6DVLqALQqXWpKSU=; b=dbS1n4X6wa9Gu0ZqNqO6wBhEBGe0fj/H4s3kdDEAP6hHpOx0tfbCuCvzVB/uggJgHE /3HMsP1ec02Zgu999WizLIZ3Cf0Gd+gpuO5GXgc3SzMsVQSy/LFj6NRC616hOID8OofO /sH01iy6AqDTZ6vKpyjyiF3U71YKNYSlz3rg90ArM940phtZPvtffjj1DWvarkAcusDx rYezKBCenQKktkGw8ZluEUV8GbMu/CPpjJuWvWozOsUjD/1+sKVNjY4PHpKGpbmeWEmH Btcf2ixDuWzYK8TnsMRj+hdZjO7xE0gA0dZk6Eci1+/Nzs9diST9nPL3JLdpUQTLhUFD nxHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772584; x=1702377384; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7hpm9CJMW8yeGqWkPdTKA3BPaZ3J6DVLqALQqXWpKSU=; b=kuEeh4JjU/Qbx1R6YbmqPJRZ5KBegxywzBV5uRYbihuRtbNl7vkLw3IwdZUdsiXOxZ xidr6pJoFVh0zQNlCw3HOo06zH5x1cuXXLXTDHY97GHFfXX/3jCA9ROmdWEVV0K/Dp9x eaVQ1wr8Duan2mtmUt8Qn4/cxEsjGBL5OilHDRqWntDAK11YJ+WkzdTlXNMdyPYAXU6A q+MUEhpVE+/xX+P6aknIBAm3fXNooyHXet/5XjGMvtE6sF/E9FcGscGlczFdHekGCAhh b67jXXgOJA76VN43+Vu+GnpQzn5bWpb7feo/WLdLe/uQDLras9E3uwftaX51edsfMsQz mDaw== X-Gm-Message-State: AOJu0Yw47xKD98HqZm/cHMt3gSsHzC9cZL8Q+FhDejlBJpPhK2d9KP02 kMf+UabEg/f2dACa7MNwGsQ= X-Received: by 2002:a05:6512:3e16:b0:50b:f39d:5204 with SMTP id i22-20020a0565123e1600b0050bf39d5204mr2173050lfv.44.1701772584488; Tue, 05 Dec 2023 02:36:24 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id d5-20020a0565123d0500b0050bfbc471b0sm442106lfv.18.2023.12.05.02.36.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:24 -0800 (PST) From: Serge Semin To: Andrew Lunn , Heiner Kallweit , Russell King , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Chevallier , Tomer Maimon , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Serge Semin , openbmc@lists.ozlabs.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 12/16] net: pcs: xpcs: Add xpcs_create_bynode() method Date: Tue, 5 Dec 2023 13:35:33 +0300 Message-ID: <20231205103559.9605-13-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 05 Dec 2023 02:38:05 -0800 (PST) It's now possible to have the DW XPCS device defined as a standard platform device for instance in the platform DT-file. Although it's pointless unless there is a way to have the device found by the client drivers (STMMAC/DW *MAC, NXP SJA1105 Eth Switch, etc). Provide such ability by means of the xpcs_create_bynode() method. It needs to be supplied with the device fwnode which is equipped with the "pcs-handle" property pointing to the DW XPCS fw-node (in this regards it looks similar to the phylink interface). That node will be then used to find the MDIO-device instance in order to create the DW XPCS descriptor. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 26 ++++++++++++++++++++++++++ include/linux/pcs/pcs-xpcs.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index e376e255f1d3..c3336895a124 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -9,9 +9,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -1511,6 +1513,30 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, return ERR_PTR(ret); } +struct dw_xpcs *xpcs_create_bynode(const struct fwnode_handle *fwnode, + phy_interface_t interface) +{ + struct fwnode_handle *pcs_node; + struct mdio_device *mdiodev; + struct dw_xpcs *xpcs; + + pcs_node = fwnode_find_reference(fwnode, "pcs-handle", 0); + if (IS_ERR(pcs_node)) + return ERR_CAST(pcs_node); + + mdiodev = fwnode_mdio_find_device(pcs_node); + fwnode_handle_put(pcs_node); + if (!mdiodev) + return ERR_PTR(-ENODEV); + + xpcs = xpcs_create(mdiodev, interface); + if (IS_ERR(xpcs)) + mdio_device_put(mdiodev); + + return xpcs; +} +EXPORT_SYMBOL_GPL(xpcs_create_bynode); + struct dw_xpcs *xpcs_create_byaddr(struct mii_bus *bus, int addr, phy_interface_t interface) { diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index b11bbb5e820a..2981dcdf65d4 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -8,6 +8,7 @@ #define __LINUX_PCS_XPCS_H #include +#include #include #include #include @@ -73,6 +74,8 @@ int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces); int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable); +struct dw_xpcs *xpcs_create_bynode(const struct fwnode_handle *fwnode, + phy_interface_t interface); struct dw_xpcs *xpcs_create_byaddr(struct mii_bus *bus, int addr, phy_interface_t interface); void xpcs_destroy(struct dw_xpcs *xpcs); -- 2.42.1