From patchwork Tue Dec 5 10:35:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872063 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=cpNCIxAm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Skxr337rNz1yST for ; Tue, 5 Dec 2023 21:40:03 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=cpNCIxAm; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Skxr32Ghpz3cVS for ; Tue, 5 Dec 2023 21:40:03 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=cpNCIxAm; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::22a; helo=mail-lj1-x22a.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxld54cBz3c3g for ; Tue, 5 Dec 2023 21:36:12 +1100 (AEDT) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2c9f7fe6623so31466061fa.3 for ; Tue, 05 Dec 2023 02:36:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772564; x=1702377364; darn=lists.ozlabs.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=a4aEtBuTh0UC9CrFmY+V3IFx8owY/yY3vgzi9PmzSa0=; b=cpNCIxAmMA+Lgj0na+lH9VnFlawvWf8Jv21wxxS/kOy6tdCdO1K1kstG+kP4loQGWU ra/1TBZ1xBJ0YdQScaZjP+m9EEBAhCQBO0V5Q3Z7HlFVBa2TGn7QqzuQ/A45pSD40ziJ jjq7ltTzCFqaxUddycZHbKyWEdayXat9rJB3OgHP3ceB4cSf2CBT7Iqcuud9N2Si+D/S BwNAc+Z2YQ8GEvsT10R6v8+Je/aItHvCxb+NPxd4G/Jhy0YSokgtn2W3GUO7LftecxLi /UgAmbAu7VmUhQRrzFx/uIQEcd56p3HoUD8SiLeaa94NNyNdD2z65QpxtybkNh6eAzZ6 quYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772564; x=1702377364; 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=a4aEtBuTh0UC9CrFmY+V3IFx8owY/yY3vgzi9PmzSa0=; b=Egl6xxLqEaS0fwlF/MLAqNBga2TOZy9J7ob5DQd2Dl4IL8aE51KHcigqQsfzjUmZrh j1f227DV5SbEbMvfvo8rZ/nz30C9d3Zjq1JXbjzMkK/geYdBX8/DLwPcvYRC7UrMcoqB Ybba2XRh9EK0+XERK3vTMzQ3ik9kHSpWM0mGCBXW+MSKA/KsFsvNewOqeYmOvQfnXipu IVTKKb8mXZ6LdQHPH0s+5cQqqMRBlC+STjSRoYkmOnOjwOpYRyOQjKi/F1umtDI3X7+r vlRZ8FMYBk9Q0giik7cK2Ywl+3JfFNdEp3Hp/YoBvVqOAdcnD3ncnEsUUI5GbfZBNDtI +2EA== X-Gm-Message-State: AOJu0Yx3zdYdyNRX0yM5ru0onKO8S+L5bsvePFYbA7ugMlpz+cgu0fB9 rU25UdFR+yS3lIkRjT6Uo2g= X-Google-Smtp-Source: AGHT+IFZKr4mte8mEyBn5TUCZn71LfadvBGTszjO/emPzCHL8qpyDtiAvPGC3HEYzGHAFjI4CXkWeA== X-Received: by 2002:a2e:b24d:0:b0:2c0:17bc:124e with SMTP id n13-20020a2eb24d000000b002c017bc124emr2510299ljm.38.1701772563975; Tue, 05 Dec 2023 02:36:03 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id h20-20020a2e5314000000b002c9bb53ee68sm849784ljb.136.2023.12.05.02.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:03 -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 Subject: [PATCH net-next 01/16] net: pcs: xpcs: Drop sentinel entry from 2500basex ifaces list Date: Tue, 5 Dec 2023 13:35:22 +0300 Message-ID: <20231205103559.9605-2-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , devicetree@vger.kernel.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" There are currently two methods (xpcs_find_compat() and xpcs_get_interfaces()) defined in the driver which loop over the available interfaces. All of them rely on the xpcs_compat.num_interfaces field value to get the number of interfaces. That field is initialized with the ARRAY_SIZE(xpcs_*_interfaces) macro function call. Thus the interface arrays are supposed to be filled with actual interface IDs and there is no need in the dummy terminating ID placed at the end of the arrays. Let's drop the redundant PHY_INTERFACE_MODE_MAX entry from the xpcs_2500basex_interfaces list and the redundant PHY_INTERFACE_MODE_MAX-based conditional statement from the xpcs_get_interfaces() method then. Signed-off-by: Serge Semin Reviewed-by: Vladimir Oltean --- drivers/net/pcs/pcs-xpcs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 31f0beba638a..dc7c374da495 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -130,7 +130,6 @@ static const phy_interface_t xpcs_1000basex_interfaces[] = { static const phy_interface_t xpcs_2500basex_interfaces[] = { PHY_INTERFACE_MODE_2500BASEX, - PHY_INTERFACE_MODE_MAX, }; enum { @@ -636,8 +635,7 @@ void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces) const struct xpcs_compat *compat = &xpcs->id->compat[i]; for (j = 0; j < compat->num_interfaces; j++) - if (compat->interface[j] < PHY_INTERFACE_MODE_MAX) - __set_bit(compat->interface[j], interfaces); + __set_bit(compat->interface[j], interfaces); } } EXPORT_SYMBOL_GPL(xpcs_get_interfaces); From patchwork Tue Dec 5 10:35:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Ze86+rHL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Skxp24zNRz1yST for ; Tue, 5 Dec 2023 21:38:18 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Ze86+rHL; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Skxp218SLz3cc0 for ; Tue, 5 Dec 2023 21:38:18 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Ze86+rHL; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::231; helo=mail-lj1-x231.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxld64Txz3c8r for ; Tue, 5 Dec 2023 21:36:12 +1100 (AEDT) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2ca0d14976aso18976211fa.2 for ; Tue, 05 Dec 2023 02:36:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772566; x=1702377366; darn=lists.ozlabs.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=aU0vmmGkk5jZZzl83+7pZTLNraC38rsdaXbaqMF+jj8=; b=Ze86+rHLa/0EeI1LzXK8B5b+GihuYmSNb7Lsfc58TMK8bmevgH344Y+xWmaHVikMnn pSm+cWx2Ei62Ntnh9hMktdWiLXIJNkaRHigklxGvxaOpdATFbBR6PFQHJXWZDouE3b0L rAUe5588RWpvCtzeOpWay543GVArXYm9X7cv9OjkuWC2RBzaeyy3CMCY5CArZv5C0V5s IO5qU3Wtuj+tot6L8/OKLEJzLAlR8Z1AEiNj9zQXP+qRQ+7/s+K/5GFLDebu7/TL6AgQ 5/wiqLc3aF/qr5UzugfRjESMJ5xGGk2CBeRotzivopXY9psYV0HtCK8whJVpTl+FNy35 GcPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772566; x=1702377366; 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=aU0vmmGkk5jZZzl83+7pZTLNraC38rsdaXbaqMF+jj8=; b=MKjJWlyvvFnRoj4MMlmPFOJkj5VJw4ODS0e/6/pjcRFemJhJzZexRYn4NQ8lK5KbnL VtF+Qs6rpXwp65oUafA5H/aclnh7HWVdZhcKI3700S0Dd9QNxIhsF9AFBF7Qtz0B3tiK vxEGM3rvvl/59U61u7hV3cblbTWa4JEI/O16mvoeFakiAWIXiucoKZLmqEkL0x0OwiAr NyFzO0nUQjvxCDBAvOmWy7Nber19vpM6xusRYZzyYMnuYZPMCxh5i57Z12CXskXVDNUy AUPkRW5GZW3Yd43exuTyQHDAXmttZY4JDWUFN4Zvmehqbf5v9/p08xqVCtMSReiJl2l8 E6Ow== X-Gm-Message-State: AOJu0Yz8GuD9hIDNOSGiPCbdyUU2i5vNnBHitUwhnvPNYFPXfgmxXRSz P0lSwI1CPfDkLihxM8bA8+c= X-Google-Smtp-Source: AGHT+IEyzagyInlkk1nPyBZ4FwyLEwY/Eu+fMNUrVKFjMERCNTvfyTC7suwpCzoymVY+rBHcqsbPYg== X-Received: by 2002:a2e:9a94:0:b0:2ca:fa5:83ef with SMTP id p20-20020a2e9a94000000b002ca0fa583efmr844131lji.6.1701772565635; Tue, 05 Dec 2023 02:36:05 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id u8-20020a2e9f08000000b002c9f1436d86sm1029551ljk.92.2023.12.05.02.36.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:05 -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 Subject: [PATCH net-next 02/16] net: pcs: xpcs: Drop redundant workqueue.h include directive Date: Tue, 5 Dec 2023 13:35:23 +0300 Message-ID: <20231205103559.9605-3-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , devicetree@vger.kernel.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" There is nothing CM workqueue-related in the driver. So the respective include directive can be dropped. While at it add an empty line delimiter between the generic and local path include directives. Signed-off-by: Serge Semin Tested-by: Andrew Lunn --- drivers/net/pcs/pcs-xpcs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index dc7c374da495..7f8c63922a4b 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -10,7 +10,7 @@ #include #include #include -#include + #include "pcs-xpcs.h" #define phylink_pcs_to_xpcs(pl_pcs) \ From patchwork Tue Dec 5 10:35:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=gPuRqTBy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Skxq30ZhQz1yST for ; Tue, 5 Dec 2023 21:39:11 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=gPuRqTBy; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Skxq26WJSz3cnZ for ; Tue, 5 Dec 2023 21:39:10 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=gPuRqTBy; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::130; helo=mail-lf1-x130.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxld5hqDz3c5j for ; Tue, 5 Dec 2023 21:36:12 +1100 (AEDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-50c0bd61d21so399452e87.3 for ; Tue, 05 Dec 2023 02:36:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772567; x=1702377367; darn=lists.ozlabs.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=U54qqy6N0N2c+9OxOcQWdVdaen6MX6mbtv2CDF+JdLE=; b=gPuRqTBy/OcSJGQjJZ+YlscJeP/lzhFAIxXV4xMplKhophzd05Q4YH6swgARwi0n99 VU7emxMVVidJtIpCJBshUn0r6DE3YdcTYSISL92F4r+OYlcPVsDv8inG/vCOoZt695Hv VSLTZaX6emPaHUZmMECPmw65yNT7L9K52Md5RKxcrtKv4VEMvIUgyD6q7jL9T3KOcyIE SnpSdqqZFf1/jCLwEXSEHq15pY32ZdaWD7u6i6gEgYwcsFVJTzMqkcQng0a9yEs803Et rzIatVWHWqoB9NySXVrehkrevUBdWhj2kMf5aUTmLg6z0SNvZkzLY5XdrE61D4LJDsHm T/Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772567; x=1702377367; 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=U54qqy6N0N2c+9OxOcQWdVdaen6MX6mbtv2CDF+JdLE=; b=Ethn5gy6WSHTRqHGCtHd7IxQVIz1FcNb0XY03AFR3s81dgpZp/cJ6QPnreScyv27Ky rzeQ0rj1gqI7KHG8ZozGeREYppeR7bZkqZBJ5rXyLJNsL7FwscITQD/Y1H0UV4a7CW47 h3pi/0MyZ2ZdV3lsBGaOX6yfX0KVin20tAWFnoBrgDrkLCWujwIKHCAkeogPbKtOK9Es GS2dYMthaMrdphNsB1AYcWh2/mpCCToqxpH0gWPrh820ggYWuzI0Gx9hSUG39EL0XybH QdG8TCEdH6yUCWBiBCWPuQQzepOW1R3PQypmWMQlDTdY6bKujKyp/2EYbprW5/i77LQH nn9g== X-Gm-Message-State: AOJu0Yxv4VD7Vba9MkIy4Aeq1JFZOxlZCFUuP8y6LK2Essw4ilJTXouy iNyLVsJVcFj1nyHTVyQwQe8= X-Google-Smtp-Source: AGHT+IFEi6gEzVmRxQZn6LenJ7+2db8n7eaJ31ccEDBnMQFSlfYTfUEXX/pYGky6DeUkP1qWbJfG3g== X-Received: by 2002:a05:6512:e89:b0:50b:e384:2c5c with SMTP id bi9-20020a0565120e8900b0050be3842c5cmr3164864lfb.136.1701772567319; Tue, 05 Dec 2023 02:36:07 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id d10-20020ac241ca000000b0050be6252444sm991214lfi.133.2023.12.05.02.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:06 -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 Subject: [PATCH net-next 03/16] net: pcs: xpcs: Return EINVAL in the internal methods Date: Tue, 5 Dec 2023 13:35:24 +0300 Message-ID: <20231205103559.9605-4-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , devicetree@vger.kernel.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" In particular the xpcs_soft_reset() and xpcs_do_config() functions currently return -1 if invalid auto-negotiation mode is specified. That value can be then passed to the generic kernel subsystems which require a standard kernel errno value. Even though the error conditions are very specific (memory corruption or buggy implementation) using a hard-coded -1 literal doesn't seem correct anyway. Signed-off-by: Serge Semin Tested-by: Andrew Lunn --- drivers/net/pcs/pcs-xpcs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 7f8c63922a4b..92c47da61db4 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -292,7 +292,7 @@ static int xpcs_soft_reset(struct dw_xpcs *xpcs, dev = MDIO_MMD_VEND2; break; default: - return -1; + return -EINVAL; } ret = xpcs_write(xpcs, dev, MDIO_CTRL1, MDIO_CTRL1_RESET); @@ -889,7 +889,7 @@ int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, return ret; break; default: - return -1; + return -EINVAL; } if (compat->pma_config) { From patchwork Tue Dec 5 10:35:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872058 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=GXGU7MuA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Skxm90mB7z1yST for ; Tue, 5 Dec 2023 21:36:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=GXGU7MuA; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Skxm019Ycz3cTh for ; Tue, 5 Dec 2023 21:36:32 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=GXGU7MuA; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::22e; helo=mail-lj1-x22e.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxld5WLDz3c4s for ; Tue, 5 Dec 2023 21:36:12 +1100 (AEDT) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2c9f166581dso37155591fa.2 for ; Tue, 05 Dec 2023 02:36:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772569; x=1702377369; darn=lists.ozlabs.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=U7nbPSVfDOj9VhJDoGLXG/VirsAsAqdDlwTrxuDOen8=; b=GXGU7MuAsmvpuPqfF8bV8uTnont+wQGQCKpewfNY3JhBCJekJ15rf6YWM4xuKNQVun 40nmePuHTxILF+mO/ZQ1wp94Mj41+9WH/Q/STgJBC4OEg2E4SKnYdRIsIZfx5/42uABP XHIHS3NlbDuEebXHfRzyWJhwymjOxvz9uWN081FdtX41ISM6xCGGUaRDQDmQg5Y+g6OL ClmO2y4iMB+HgKJnA2J0g8JKlrUGXP8fBJ3Yytqgz7i3oRgg/ouTZdZgeU2n796Dq2j0 ikSos/pwyiprcHAZRL+XcSOwz5jv2KrEpCl1Q08seo732yQEPg+BIN2hNckugqZNPEgc a4OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772569; x=1702377369; 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=U7nbPSVfDOj9VhJDoGLXG/VirsAsAqdDlwTrxuDOen8=; b=XTt3XkatxjgTm/eiVEYspjwoA58yrOBElUSTefqPhxGRAB/85J6sd6Zu+kprok76Jv YJqExB/iLAzKQDReR7/TuVPhAfbwPQzixdiO+uLokzxPLbbLX0qft0zqe0Lm32zmM4B1 hiIyBvrbzdgeWjpK+CGzOweYMIlaYPIZqkkktKltmdQfqB468GYWZ3RWNEQipGfgqiYz bxlE9cdldPOyqv3uyI3pwmh3KlqVerElCwlmDQTHvqySS9gTi/BowsEdWIVvsyWQBm/+ amyXU2ZCLv9kLcoZM9U+bDzinYURxYx60NkepsSvPCF8FW9vEn6Xaa2rdjjjraKk+Rbl LT/g== X-Gm-Message-State: AOJu0Yw2a3/xZZeVd/mKNE/1BDOrmQcpdZ7abQhqYnPSSb9QtL16A3xu 8hjwalZ6Fqs4B1BEeQz7l20= X-Google-Smtp-Source: AGHT+IEbTWXqnS6pqxWsiTO7y9txYu3nwyDInKx5fND8GB0zHKszkEr00SZIdi7cH2zlataH173Zeg== X-Received: by 2002:a2e:7c0a:0:b0:2c9:f564:b414 with SMTP id x10-20020a2e7c0a000000b002c9f564b414mr2095991ljc.24.1701772569144; Tue, 05 Dec 2023 02:36:09 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id s22-20020a2e98d6000000b002c9b899c449sm809872ljj.59.2023.12.05.02.36.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:08 -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 Subject: [PATCH net-next 04/16] net: pcs: xpcs: Explicitly return error on caps validation Date: Tue, 5 Dec 2023 13:35:25 +0300 Message-ID: <20231205103559.9605-5-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , devicetree@vger.kernel.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" If an unsupported interface is requested to be validated then there is no need in further capabilities and-ing since the local array will be left initialized with zeros. Let's explicitly return EINVAL error in that case in order to inform the caller about invalid link-state interface. In any case the phylink_validate_mac_and_pcs() would terminate with error further link-state validation so the suggested update won't change the validation procedure semantics. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 92c47da61db4..46afeb5510c0 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -613,14 +613,15 @@ static int xpcs_validate(struct phylink_pcs *pcs, unsigned long *supported, xpcs = phylink_pcs_to_xpcs(pcs); compat = xpcs_find_compat(xpcs->id, state->interface); + if (!compat) + return -EINVAL; /* Populate the supported link modes for this PHY interface type. * FIXME: what about the port modes and autoneg bit? This masks * all those away. */ - if (compat) - for (i = 0; compat->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) - set_bit(compat->supported[i], xpcs_supported); + for (i = 0; compat->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) + set_bit(compat->supported[i], xpcs_supported); linkmode_and(supported, supported, xpcs_supported); From patchwork Tue Dec 5 10:35:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=UKtWyGET; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Skxs45Xqcz23mf for ; Tue, 5 Dec 2023 21:40:56 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=UKtWyGET; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Skxs44WY3z3cVS for ; Tue, 5 Dec 2023 21:40:56 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=UKtWyGET; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::22b; helo=mail-lj1-x22b.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxlg2tRnz3c3g for ; Tue, 5 Dec 2023 21:36:15 +1100 (AEDT) Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2c9f099cf3aso43246771fa.1 for ; Tue, 05 Dec 2023 02:36:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772571; x=1702377371; darn=lists.ozlabs.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=dFMu8yHYAxfVLVvDj+B8IqaslSN1vZ5XWG3YsW0hTQA=; b=UKtWyGET3JjGcneD8x8K/af6VmXNNsNssOHKi+317nKdLz/mZiQluCfGbCTJlpYBaH ti6EkfCUkSO9tmVXMyIxfgBJjAX6TTy3g24RRcDK03J4ShGTnOLZZzf0pb7WN2mxvehZ X+7kJzYcMlsZ3Xmj0flWTFEtFN6huPJCu9EY9olqGl7CoTdn2QvCHea3pdlGL1DNwanC yHBZQ7CbLtRZZSJ0QdpJI4E7Z12z5JuAZwnAoej6ZPWYCEVwSi1fLuyzT2JDzxWtbL8d pSGJhA59pJsT/kuPtbmWWwP/dX8OTWhPodlUYe6LSJBLcpDrjaY1ioYQVdiBHDPCBtJv 6D4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772571; x=1702377371; 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=dFMu8yHYAxfVLVvDj+B8IqaslSN1vZ5XWG3YsW0hTQA=; b=oTO3t/wU3XR/H7FLXiLyCkxfALX8ymdl2/uiFq1BxUuF01xkfsIJpsLiwxYomgizA5 C+OErSFNtEwlqKczKeqmXzsgz7gaYrmMcbpLsZn7bhGue7infCYExC6+C73kwfmyL0VH Mn1P3kvKBsxP0hTP177KJmv1vkdAiLH0DEV8JsMQTC0Zpr9q94y10AoH7aqpqG3FlSES NfagB68PM1YmR0nAggmJ6inDO7H07htWQkafeETTrYKmzuxIJe78mMJD10nMKt7JbZaq f2/zeqNAwU6NJqg+DvsvsHwIgv6K8A5B+mskIXOvGIOzOsZbmMRM7+jHH74+Dtx11uDm 0zgA== X-Gm-Message-State: AOJu0YyXEP/uXvp8n1TglPkFQU/xW4xMrNn9MexIkxxSEw27and/tzb5 G+hrLos9LruOcanD2ROA1/c= X-Google-Smtp-Source: AGHT+IH0HyLEqm5MstBhJhll+ilWNbLcAbUlRzT66sgkeFhmYOZXWSY29xW02fWBkRMGmVcZxYa/xQ== X-Received: by 2002:a2e:994c:0:b0:2c9:f3b6:522 with SMTP id r12-20020a2e994c000000b002c9f3b60522mr2596361ljj.57.1701772571048; Tue, 05 Dec 2023 02:36:11 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id l21-20020a2e3e15000000b002ca0689190fsm548139lja.31.2023.12.05.02.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:10 -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 Subject: [PATCH net-next 05/16] net: pcs: xpcs: Move native device ID macro to linux/pcs/pcs-xpcs.h Date: Tue, 5 Dec 2023 13:35:26 +0300 Message-ID: <20231205103559.9605-6-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , devicetree@vger.kernel.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" Generic MDIO-device driver will support setting a custom device ID for the particular MDIO-device. Generic DW XPCS ID can be used for that as well just in case if the DW XPCS-device was erroneously synthesized with no or some undefined ID. In addition to that having all supported DW XPCS device IDs defined in a sinle place will improve the code maintainability and readability. Note while at it rename the macros to be shorter and looking alike to the already defined NXP XPCS ID macro. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 8 ++++---- drivers/net/pcs/pcs-xpcs.h | 3 --- include/linux/pcs/pcs-xpcs.h | 2 ++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 46afeb5510c0..2850122f354a 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -1343,16 +1343,16 @@ static const struct xpcs_compat nxp_sja1110_xpcs_compat[DW_XPCS_INTERFACE_MAX] = static const struct xpcs_id xpcs_id_list[] = { { - .id = SYNOPSYS_XPCS_ID, - .mask = SYNOPSYS_XPCS_MASK, + .id = DW_XPCS_ID, + .mask = DW_XPCS_ID_MASK, .compat = synopsys_xpcs_compat, }, { .id = NXP_SJA1105_XPCS_ID, - .mask = SYNOPSYS_XPCS_MASK, + .mask = DW_XPCS_ID_MASK, .compat = nxp_sja1105_xpcs_compat, }, { .id = NXP_SJA1110_XPCS_ID, - .mask = SYNOPSYS_XPCS_MASK, + .mask = DW_XPCS_ID_MASK, .compat = nxp_sja1110_xpcs_compat, }, }; diff --git a/drivers/net/pcs/pcs-xpcs.h b/drivers/net/pcs/pcs-xpcs.h index 96c36b32ca99..369e9196f45a 100644 --- a/drivers/net/pcs/pcs-xpcs.h +++ b/drivers/net/pcs/pcs-xpcs.h @@ -6,9 +6,6 @@ * Author: Jose Abreu */ -#define SYNOPSYS_XPCS_ID 0x7996ced0 -#define SYNOPSYS_XPCS_MASK 0xffffffff - /* Vendor regs access */ #define DW_VENDOR BIT(15) diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index da3a6c30f6d2..8dfe90295f12 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -12,6 +12,8 @@ #define NXP_SJA1105_XPCS_ID 0x00000010 #define NXP_SJA1110_XPCS_ID 0x00000020 +#define DW_XPCS_ID 0x7996ced0 +#define DW_XPCS_ID_MASK 0xffffffff /* AN mode */ #define DW_AN_C73 1 From patchwork Tue Dec 5 10:35:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872066 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=NTye8OZm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Skxt61NLYz23mf for ; Tue, 5 Dec 2023 21:41:50 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=NTye8OZm; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Skxt561BQz3ckp for ; Tue, 5 Dec 2023 21:41:49 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=NTye8OZm; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::132; helo=mail-lf1-x132.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxlh5njcz3cNt for ; Tue, 5 Dec 2023 21:36:16 +1100 (AEDT) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-50bf2d9b3fdso3010284e87.3 for ; Tue, 05 Dec 2023 02:36:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772572; x=1702377372; darn=lists.ozlabs.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=HGpa0GtJpSi8L3mCQm30bghRnsn1XAa98foEtQJ/KWs=; b=NTye8OZmGFsqCan4QD/X5IC4euxd+EGELwU2mxHwPDS/zdktMdtwz4pMPBDHAat3AK 6DFLh9GfIWjNoQWUS0b94aJTmnLg9jvmAWj240KW122POaVCLxpiRKq6VLA/2UYZII/t 8vvgTlrLRpoBGl8UJXl/uQN5ZEg8PPc1RkhdeL9iBJeOPMgGchp1RcT/S2w+PjOSKSrf GBufpBCr8/n7iXl0QugArxv1Pp6bQmJGAN6UrD89uA46aH26gIQpo4lAreQUm+2kyvlR VOY+yCiA9uxmtiSExTuIOsAs8FafEA3VQxqPhgogMcLOVGUV6ny6p6hbXMaEqrynpK1M PWsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772572; x=1702377372; 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=HGpa0GtJpSi8L3mCQm30bghRnsn1XAa98foEtQJ/KWs=; b=CdjKe/JyFIwriF1lIdsQNFUxB27+OxptdlTyzpgmzfcFzcapyYVjCUlsy1QJLaWgat 9cbOnlx2TyF6Eqa3U70qjShj92GldOvrLnLjr9hQNLdkMmKZ1AE8H6nmJ8NUJA/UgsqL KnuS0Yke2kHKYFv3HA5Eqio5+yvF0h/c+IO9kqOxlglcuyG4BnlCCqDejQRYvOoDxYHE BjVowJw+lFpd2+yJzMG318QzIB0oq/zV+Gh7vSBbVxchZD7empd13FDmtSYLF1ZrVOc9 EIKZ+1f1nOMeDPQxrXF8hoacwgOuoGOMq4AlPYVsmQBgjbYPi3gCIBNiW92LXGTys6hw eMUQ== X-Gm-Message-State: AOJu0YyEW71IIwsa3w0LZ2DjbCbzsqu1uxNEZATOy2hwcDtRkvJHy/5I nKNsm8yDN40O3TMBjlvczps= X-Google-Smtp-Source: AGHT+IFIhxBRZreE0ykFzf7E++LBQs6vRs4czi1iz3uLMDedC+tOqSVXU3dh9yp28YVSHIo1DRs6Rg== X-Received: by 2002:a05:6512:2343:b0:50b:fcd6:cb10 with SMTP id p3-20020a056512234300b0050bfcd6cb10mr1522544lfu.130.1701772572652; Tue, 05 Dec 2023 02:36:12 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id t6-20020a199106000000b0050bfdb1392fsm377230lfd.221.2023.12.05.02.36.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:12 -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 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device Date: Tue, 5 Dec 2023 13:35:27 +0300 Message-ID: <20231205103559.9605-7-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , devicetree@vger.kernel.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" If the DW XPCS MDIO devices are either left unmasked for being auto-probed or explicitly registered in the MDIO subsystem by means of the mdiobus_register_board_info() method there is no point in creating the dummy MDIO device instance in order to get the DW XPCS handler since the MDIO core subsystem will create the device during the MDIO bus registration procedure. All what needs to be done is to just reuse the MDIO-device instance available in the mii_bus.mdio_map array (using some getter for it would look better though). It shall prevent the XPCS devices been accessed over several MDIO-device instances. Note since the MDIO-device instance might be retrieved from the MDIO-bus map array its reference counter shall be increased. If the MDIO-device instance is created in the xpcs_create_mdiodev() method its reference counter will be already increased. So there is no point in toggling the reference counter in the xpcs_create() function. Just drop it from there. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 2850122f354a..a53376472394 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -1376,7 +1376,6 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, if (!xpcs) return ERR_PTR(-ENOMEM); - mdio_device_get(mdiodev); xpcs->mdiodev = mdiodev; xpcs_id = xpcs_get_id(xpcs); @@ -1417,7 +1416,6 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, ret = -ENODEV; out: - mdio_device_put(mdiodev); kfree(xpcs); return ERR_PTR(ret); @@ -1437,19 +1435,21 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, struct mdio_device *mdiodev; struct dw_xpcs *xpcs; - mdiodev = mdio_device_create(bus, addr); - if (IS_ERR(mdiodev)) - return ERR_CAST(mdiodev); + if (addr >= PHY_MAX_ADDR) + return ERR_PTR(-EINVAL); - xpcs = xpcs_create(mdiodev, interface); + if (mdiobus_is_registered_device(bus, addr)) { + mdiodev = bus->mdio_map[addr]; + mdio_device_get(mdiodev); + } else { + mdiodev = mdio_device_create(bus, addr); + if (IS_ERR(mdiodev)) + return ERR_CAST(mdiodev); + } - /* xpcs_create() has taken a refcount on the mdiodev if it was - * successful. If xpcs_create() fails, this will free the mdio - * device here. In any case, we don't need to hold our reference - * anymore, and putting it here will allow mdio_device_put() in - * xpcs_destroy() to automatically free the mdio device. - */ - mdio_device_put(mdiodev); + xpcs = xpcs_create(mdiodev, interface); + if (IS_ERR(xpcs)) + mdio_device_put(mdiodev); return xpcs; } From patchwork Tue Dec 5 10:35:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872067 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=O/lKgHZq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Skxv64HHNz23mf for ; Tue, 5 Dec 2023 21:42:42 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=O/lKgHZq; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Skxv63F1Zz2yLr for ; Tue, 5 Dec 2023 21:42:42 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=O/lKgHZq; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::236; helo=mail-lj1-x236.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxlk47T3z3cTh for ; Tue, 5 Dec 2023 21:36:18 +1100 (AEDT) Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2ca03103155so25428241fa.0 for ; Tue, 05 Dec 2023 02:36:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772574; x=1702377374; darn=lists.ozlabs.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=fzWpHNK+8WZxV0Za4rmkABjOws2ounqa1/6k9XNQavs=; b=O/lKgHZqlsOx05i9jO9Ugd5oXMXJyyQ/VcTvws6Q59UF1Bkry/gc7im1+nqyAUHigM iuBPydFZ+VcOv0r4vEWFlCf9q9IcsQcp4JiyNtBpBrZ0EDEzN03gzkezr6N7NI0a9KYO gDlutejGtaPQ2zNFPmrDpwenGh2JVW4rADOaMKCYMVVManr406guuju1PC0wwkUJtJwY MJmCZkTl8LUo9BIDWl0F5xm1WsnWPQG3rimNGfPP/itw61NYAF/9Jr+p3iuErU2sNJdH 1ee+o77YtEYvtJ7CGm6EdgX35BwqHONMUKVFm4n0rONzg2x+M4P7WfpEA2GPrlnTFShf YHpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772574; x=1702377374; 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=fzWpHNK+8WZxV0Za4rmkABjOws2ounqa1/6k9XNQavs=; b=UkOghqu6Ng5G0ZioEDtOTLAhtXIdu4EkzdlGmmSjN1jizOL5jnaMP6PIIaJhnIHhHG kFNyOmtGEMV4gCCqs9qCNWpA3wuzm09z1jtamORHpCTIUZg9Hs7Rot4xnngCfArPsSf/ mE/n/Me0/p++6V5p5n94xZBbYzaQkzqKP6ZnDeTVdPFf7xj1bauLlkcZThz92Gj21C6X nfNhByrZa1qMhdqyAxVjs3GqEeynnmowDutLCW85tO9G8it8tHuG9Jdi2NZcvsiiN2ZE 0FVrtnMOcT/i+5iTtNBDMWAtyOR/svDkbQjguTu2ZP+5tXm+1s2o3kW/r2KbcJ0AvqR3 9TyQ== X-Gm-Message-State: AOJu0YxFGyODSAz/zKISpjMN2CihLA9Igl2oGbFqgftSJmUpi8/FnV60 5Mcd5zhhMZLcwGq5sG2o7UU= X-Google-Smtp-Source: AGHT+IGUtfUmSCuTX2LjP6ZYjajVSxD8N2Lsw/qkhIm5j6xbwj8CD37zCqa+WxpE9jr2rYmSCkIo7Q== X-Received: by 2002:a05:6512:2803:b0:50b:f8e6:caa2 with SMTP id cf3-20020a056512280300b0050bf8e6caa2mr1274366lfb.31.1701772574341; Tue, 05 Dec 2023 02:36:14 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id y23-20020a197517000000b0050aaa716c15sm720366lfe.51.2023.12.05.02.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:13 -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 Subject: [PATCH net-next 07/16] net: pcs: xpcs: Split up xpcs_create() content to sub-functions Date: Tue, 5 Dec 2023 13:35:28 +0300 Message-ID: <20231205103559.9605-8-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , devicetree@vger.kernel.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" As a final preparation before adding the DW XPCS MDIO-device driver support let's split the xpcs_create() function code up to a set of small sub-functions. Thus the method implementation will get to look simpler and turn to be more coherent. Further updates will just touch the new methods a bit: add platform-specific device info, add device reference clock getting and enabling. This update implies the xpcs_create() to call the next static methods: xpcs_create_data() - create the DW XPCS device descriptor, xpcs_init_id() - find XPCS ID instance and save it in the device descriptor, xpcs_init_iface() - find MAC/PCS interface descriptor and perform basice initialization specific to it: soft-reset, disable polling. The update doesn't cause any semantic change but merely makes the code better looking and ready for adding new features support. Note in addition to that the xpcs_destroy() is moved to be below the xpcs_create_mdiodev() function as the driver now implies having the protagonist-then-antagonist functions definition order. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 102 +++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 32 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index a53376472394..ea6f56339595 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -1365,70 +1365,97 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = { .pcs_link_up = xpcs_link_up, }; -static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, - phy_interface_t interface) +static struct dw_xpcs *xpcs_create_data(struct mdio_device *mdiodev) { struct dw_xpcs *xpcs; - u32 xpcs_id; - int i, ret; xpcs = kzalloc(sizeof(*xpcs), GFP_KERNEL); if (!xpcs) return ERR_PTR(-ENOMEM); xpcs->mdiodev = mdiodev; + xpcs->pcs.ops = &xpcs_phylink_ops; + xpcs->pcs.neg_mode = true; + xpcs->pcs.poll = true; + + return xpcs; +} + +static void xpcs_free_data(struct dw_xpcs *xpcs) +{ + kfree(xpcs); +} + +static int xpcs_init_id(struct dw_xpcs *xpcs) +{ + u32 xpcs_id; + int i, ret; xpcs_id = xpcs_get_id(xpcs); for (i = 0; i < ARRAY_SIZE(xpcs_id_list); i++) { const struct xpcs_id *entry = &xpcs_id_list[i]; - const struct xpcs_compat *compat; if ((xpcs_id & entry->mask) != entry->id) continue; xpcs->id = entry; - compat = xpcs_find_compat(entry, interface); - if (!compat) { - ret = -ENODEV; - goto out; - } + break; + } - ret = xpcs_dev_flag(xpcs); - if (ret) - goto out; + if (!xpcs->id) + return -ENODEV; - xpcs->pcs.ops = &xpcs_phylink_ops; - xpcs->pcs.neg_mode = true; + ret = xpcs_dev_flag(xpcs); + if (ret < 0) + return ret; - if (xpcs->dev_flag != DW_DEV_TXGBE) { - xpcs->pcs.poll = true; + return 0; +} - ret = xpcs_soft_reset(xpcs, compat); - if (ret) - goto out; - } +static int xpcs_init_iface(struct dw_xpcs *xpcs, phy_interface_t interface) +{ + const struct xpcs_compat *compat; - return xpcs; + compat = xpcs_find_compat(xpcs->id, interface); + if (!compat) + return -EINVAL; + + if (xpcs->dev_flag == DW_DEV_TXGBE) { + xpcs->pcs.poll = false; + return 0; } - ret = -ENODEV; + return xpcs_soft_reset(xpcs, compat); +} + +static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, + phy_interface_t interface) +{ + struct dw_xpcs *xpcs; + int ret; + + xpcs = xpcs_create_data(mdiodev); + if (IS_ERR(xpcs)) + return xpcs; + + ret = xpcs_init_id(xpcs); + if (ret) + goto out; + + ret = xpcs_init_iface(xpcs, interface); + if (ret) + goto out; + + return xpcs; out: - kfree(xpcs); + xpcs_free_data(xpcs); return ERR_PTR(ret); } -void xpcs_destroy(struct dw_xpcs *xpcs) -{ - if (xpcs) - mdio_device_put(xpcs->mdiodev); - kfree(xpcs); -} -EXPORT_SYMBOL_GPL(xpcs_destroy); - struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, phy_interface_t interface) { @@ -1455,4 +1482,15 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, } EXPORT_SYMBOL_GPL(xpcs_create_mdiodev); +void xpcs_destroy(struct dw_xpcs *xpcs) +{ + if (!xpcs) + return; + + mdio_device_put(xpcs->mdiodev); + + xpcs_free_data(xpcs); +} +EXPORT_SYMBOL_GPL(xpcs_destroy); + MODULE_LICENSE("GPL v2"); From patchwork Tue Dec 5 10:35:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872068 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Pt+4I0+M; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Skxw80sK7z23mf for ; Tue, 5 Dec 2023 21:43:36 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Pt+4I0+M; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Skxw76lpgz3cYP for ; Tue, 5 Dec 2023 21:43:35 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Pt+4I0+M; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::12a; helo=mail-lf1-x12a.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxlm74tQz3cJN for ; Tue, 5 Dec 2023 21:36:20 +1100 (AEDT) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-50bfa5a6cffso2284922e87.0 for ; Tue, 05 Dec 2023 02:36:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772576; x=1702377376; darn=lists.ozlabs.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=kkWrOF+Tbg1zeu9NCdUddDmIHRAWNVNjds7PaG64M2Y=; b=Pt+4I0+MrXC91ZsJKjute8lq9XUU267f9GCJ4/9Mh9L7gSx3tUG8574Fu+ROLlydAp B5A76SAt77p45U7K/d6qEzcPIsfNoCQpI4WZ1kicNxdtmSTtisgVH/Vzx4wnjOV/FT+o lqDoHetPchBCtyEaZ+cRLjfptQ1xyGqt9dkk3zaHk8yKHHKUAv9QiuxUFeeN1WccDowO +ZNmoSi+BZ79HzoY6QVNkD855aV60nj1k5+Qc4Iy7x0ovtAxHRE3MXziNJJD51eG5ylU cATh8stK7CcqG02xpK3KtsgDaxaXimK49o5k4FeCmr9bFi9oC+dbFUJpGB94Gj5MWe6I /lCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772576; x=1702377376; 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=kkWrOF+Tbg1zeu9NCdUddDmIHRAWNVNjds7PaG64M2Y=; b=izz8EIpFFR3lXhLctvqDL2kPG3mS8RcjM2H3R9CnKFRLxL/larag6GHznB3dKiF3Dn 4gQa9DLPh8kImF9dKzPwbrLn1NGO1nLOkc9u/Lxs+OplvZ/ymVQjvBSKC/jWcph8Dy5P +AR3ew5Ec15Hlw+w/tZ5M+0bemWbZ+QOVjwAH2Tuw0Vn6vb3jsDbIGwhCjs+Ty5jcaqZ qmmmtvyx+P1j5rloHXrNKUg93euhHR4lwxNP12CUYjfe2Z4xbDak7ydPyzxNJDBwsipi JhjxexRKoF9QuJz/fMxq0gFHfFHEgio3BDHE8qnRVMk6zNOPuZru2MgU7LaInJPO9GmX GalA== X-Gm-Message-State: AOJu0YxNpX2r4VHHbfDoKtE1MBoEHlA4IjWfbSP4grtMXwde/cxOnA95 3+TwZjz0JPXsGgfH8bSR2Yg= X-Google-Smtp-Source: AGHT+IHW1p9aU8tTY9sg91uEzIDkgdKT+nrzGfXjbWF3melerUTwy66MPZnO/elp4AuS+/rL2RSIaQ== X-Received: by 2002:a05:6512:ac8:b0:50c:e6c:685a with SMTP id n8-20020a0565120ac800b0050c0e6c685amr187819lfu.124.1701772576328; Tue, 05 Dec 2023 02:36:16 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id fc5-20020a056512138500b0050bfbb6a388sm445422lfb.22.2023.12.05.02.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:15 -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 Subject: [PATCH net-next 08/16] dt-bindings: net: Add Synopsys DW xPCS bindings Date: Tue, 5 Dec 2023 13:35:29 +0300 Message-ID: <20231205103559.9605-9-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , devicetree@vger.kernel.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" Synopsys DesignWare XPCS IP-core is a Physical Coding Sublayer (PCS) layer providing an interface between the Media Access Control (MAC) and Physical Medium Attachment Sublayer (PMA) through a Media independent interface. From software point of view it exposes IEEE std. Clause 45 CSR space and can be accessible either by MDIO or MCI/APB3 bus interfaces. The later case is described by means of a dedicated DT-bindings which imply having the DW XPCS Management Interface defined as a DT-supernode which child the PCSs nodes would be (in the same way as the standard MDIO buses and devices are normally defined). Besides of that DW XPCS DT-nodes can have the interrupts and clock source properties specified. The former one indicates the Clause 73/37 auto-negotiation events like: negotiation page received, AN is completed or incompatible link partner. The clock DT-properties can describe up to two clock sources: internal one and the one connected to the chip pad. Either of them is supposed to be used as the device reference clocks. Finally the DW XPCS IP-core can be optionally synthesized with a vendor-specific interface connected to Synopsys PMA (also called DesignWare Consumer/Enterprise PHY). Alas that isn't auto-detectable anyhow so if the DW XPCS device has the respective PMA attached then it should be reflected in the DT-node compatible string so the driver would be aware of the PMA-specific device capabilities (mainly connected with CSRs available for the fine-tunings). Signed-off-by: Serge Semin --- .../bindings/net/pcs/snps,dw-xpcs.yaml | 88 +++++++++++++++++++ .../bindings/net/snps,dw-xpcs-mi.yaml | 88 +++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml create mode 100644 Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml diff --git a/Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml b/Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml new file mode 100644 index 000000000000..9694ef51abad --- /dev/null +++ b/Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml @@ -0,0 +1,88 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/pcs/snps,dw-xpcs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Synopsys DesignWare Ethernet PCS + +maintainers: + - Jose Abreu + +description: + Synopsys DesignWare Ethernet Physical Coding Sublayer provides an interface + between Media Access Control and Physical Medium Attachment Sublayer through + the Media Independent Interface (XGMII, USXGMII, XLGMII, GMII, etc) + controlled by means of the IEEE std. Clause 45 registers set. The PCS can be + optionally synthesized with a vendor-specific interface connected to + Synopsys PMA (also called DesignWare Consumer/Enterprise PHY) although in + general it can be used to communicate with any compatible PHY. + +properties: + compatible: + oneOf: + - description: Synopsys DesignWare XPCS with none or unknown PMA + const: snps,dw-xpcs + - description: Synopsys DesignWare XPCS with Consumer Gen1 3G PMA + const: snps,dw-xpcs-gen1-3g + - description: Synopsys DesignWare XPCS with Consumer Gen2 3G PMA + const: snps,dw-xpcs-gen2-3g + - description: Synopsys DesignWare XPCS with Consumer Gen2 6G PMA + const: snps,dw-xpcs-gen2-6g + - description: Synopsys DesignWare XPCS with Consumer Gen4 3G PMA + const: snps,dw-xpcs-gen4-3g + - description: Synopsys DesignWare XPCS with Consumer Gen4 6G PMA + const: snps,dw-xpcs-gen4-6g + - description: Synopsys DesignWare XPCS with Consumer Gen5 10G PMA + const: snps,dw-xpcs-gen5-10g + - description: Synopsys DesignWare XPCS with Consumer Gen5 12G PMA + const: snps,dw-xpcs-gen5-12g + + reg: + maxItems: 1 + + interrupts: + description: + System interface interrupt output (sbd_intr_o) indicating Clause 73/37 + auto-negotiation events like':' Page received, AN is completed or + incompatible link partner. + maxItems: 1 + + clocks: + description: + PCS/PMA interface be can clocked either by internal reference clock + source or by an externally connected (via a pad) clock generator. + minItems: 1 + maxItems: 2 + + clock-names: + minItems: 1 + maxItems: 2 + items: + enum: [ core, pad ] + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + + mdio-bus { + #address-cells = <1>; + #size-cells = <0>; + + xgmac_pcs: ethernet-pcs@0 { + compatible = "snps,dw-xpcs"; + reg = <0>; + + interrupts = <79 IRQ_TYPE_LEVEL_HIGH>; + + clocks = <&ccu_core>, <&ccu_pad>; + clock-names = "core", "pad"; + }; + }; +... diff --git a/Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml b/Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml new file mode 100644 index 000000000000..67ddba9d61fd --- /dev/null +++ b/Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml @@ -0,0 +1,88 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/snps,dw-xpcs-mi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Synopsys DesignWare Ethernet PCS Management Interface + +maintainers: + - Serge Semin + +description: + Synopsys DesignWare Ethernet PCS provides an interface between MAC and PMA + through the Media Independent Interface. The PCS CSRs can be accessible over + the Ethernet MDIO bus or directly by means of the APB3/MCI interfaces. In the + later case the XPCS can be mapped right to the system IO memory space. + +allOf: + - $ref: mdio.yaml# + +properties: + compatible: + const: snps,dw-xpcs-mi + + reg: + items: + - description: + DW XPCS CSRs space can be either 'directly' or 'indirectly' + accessible. In the former case all Clause 45 registers are + contiguously mapped within the address space MMD '[20:16]', + Reg '[15:0]'. In the later case the space is divided to the + multiple 256 register sets. There is a special viewport CSR + which is responsible for the set selection. The upper part of + the CSR address is supposed to be written in there thus the + corresponding subset would be mapped over the lowest 255 CSRs. + + reg-names: + items: + - enum: [ direct, indirect ] + + reg-io-width: + description: + The way the CSRs are mapped to the memory is platform depended. Since + each Clause 45 CSR is of 16-bits wide the access instructions must be + two bytes aligned at least. + default: 2 + enum: [ 2, 4 ] + + clocks: + items: + - description: Peripheral MCI/APB3 bus clock source + + clock-names: + items: + - const: pclk + +patternProperties: + 'ethernet-pcs@[0-9a-f]+$': + type: object + + $ref: pcs/snps,dw-xpcs.yaml# + +required: + - compatible + - reg + - reg-names + +unevaluatedProperties: false + +examples: + - | + mdio@1f05d000 { + compatible = "snps,dw-xpcs-mi"; + reg = <0x1f05d000 0x1000>; + reg-names = "indirect"; + #address-cells = <1>; + #size-cells = <0>; + + clocks = <&ccu_pclk>; + clock-names = "pclk"; + + reg-io-width = <4>; + + ethernet-pcs@0 { + compatible = "snps,dw-xpcs"; + reg = <0>; + }; + }; From patchwork Tue Dec 5 10:35:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872069 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=eruoJ0HT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Skxx93RRtz23mf for ; Tue, 5 Dec 2023 21:44:29 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=eruoJ0HT; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Skxx92M9vz3c3g for ; Tue, 5 Dec 2023 21:44:29 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=eruoJ0HT; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::130; helo=mail-lf1-x130.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxln3srXz3cTg for ; Tue, 5 Dec 2023 21:36:21 +1100 (AEDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-50be9e6427dso3183943e87.1 for ; Tue, 05 Dec 2023 02:36:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772578; x=1702377378; darn=lists.ozlabs.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=1k7lWyrahDo5SYtgc/iFqm9GbNDF7pT46/C/AsBzOrs=; b=eruoJ0HTDHVkM/JTQTMHLkc32LYQW02ccCPAPbPP01srgX9T6eAM7xBRZQ7co8wVlt yjc884NEKpPSsJTJepL2EuOmw5IACiDyp4P/FMOVg7R89nGssQfrl8UOl7mNK1pzMo2X 92XFpx7L0eebBjNqAKE/f/qRoiuBQghF1BK4kfTNtWBaUrMUR5n9LX55cQ645SnoNtXq CIIyQb497NCSIRWfawgfVYmX9yLPS9rw3/IdoZi0zdZI+c3qeRy0/MpWu5/d2kTWb6/0 wBBMrzNN0eHzj+5VNhqp/wqWs2moS4uLfYOmAD/o6oQ4f9+ChuWSFaCbWKl0glJEKr72 Kgxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772578; x=1702377378; 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=1k7lWyrahDo5SYtgc/iFqm9GbNDF7pT46/C/AsBzOrs=; b=ULsC7WEhcJzatuo6QdyAkcAvYXL/hKQiUZ0mvmmUIvyg8usAGQXsxMoUUZTvo2wr33 r/S51dkfRDQcYqiKdyq2OUoQF6y1telLN1ZBShNiUi8fL1GXqRBem7RZiOV8AnvBRAWg 96RKkK+m/rOBKNJj2seCnByYOFMjYhqBiUFoy04qTbq+kwvBxV05UdieJuUsMFe/ZRE0 kGN3/zF8a7fD8Bmw2bubFi01dUylSLS21u9FndYl6Ef4sh1s5qK6d7kw5Pp5ulVUEpnV vg//rsT+jFBJEclB2Tr1rArIZ6RmM43kJFuBl1nps10YhRnL31yd6QDrBSNcq3suAq+9 b1SQ== X-Gm-Message-State: AOJu0Yz0gqXa+K4yajp5kJV5xw5iwxMhFt1QWjC/TEH9nU8lEqVhgUNN Z70DoBwpf2xbh1mj6Q2xmE0= X-Google-Smtp-Source: AGHT+IHiQBmXNoe+RQLiP7bM9J3YBFryfD6UtciM5O4MFeuegXmFDkM36Hx7vUyDh05FWBDXGXAVbg== X-Received: by 2002:ac2:59c6:0:b0:50b:e45b:efc9 with SMTP id x6-20020ac259c6000000b0050be45befc9mr2154973lfn.50.1701772578250; Tue, 05 Dec 2023 02:36:18 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id i22-20020a056512225600b0050bf5188390sm633346lfu.167.2023.12.05.02.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:17 -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 Subject: [PATCH net-next 09/16] net: mdio: Add Synopsys DW XPCS management interface support Date: Tue, 5 Dec 2023 13:35:30 +0300 Message-ID: <20231205103559.9605-10-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , devicetree@vger.kernel.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" Synopsys DesignWare XPCS IP-core can be synthesized with the device CSRs being accessible over MCI or APB3 interface instead of the MDIO bus (see the CSR_INTERFACE HDL parameter). Thus all the PCS registers can be just memory mapped and be a subject of standard MMIO operations of course taking into account the way the Clause C45 CSRs mapping is defined. This commit is about adding a device driver for the DW XPCS Management Interface platform device and registering it in the framework of the kernel MDIO subsystem. DW XPCS platform device is supposed to be described by the respective compatible string "snps,dw-xpcs-mi", CSRs memory space and optional peripheral bus clock source. Note depending on the INDIRECT_ACCESS DW XPCS IP-core synthesize parameter the memory-mapped reg-space can be represented as either directly or indirectly mapped Clause 45 space. In the former case the particular address is determined based on the MMD device and the registers offset (5 + 16 bits all together) within the device reg-space. In the later case there is only 256 lower address bits are utilized for the registers mapping. The upper bits are supposed to be written into the respective viewport CSR in order to reach the entire C45 space. Signed-off-by: Serge Semin --- drivers/net/mdio/Kconfig | 8 + drivers/net/mdio/Makefile | 1 + drivers/net/mdio/mdio-dw-xpcs.c | 384 ++++++++++++++++++++++++++++++++ 3 files changed, 393 insertions(+) create mode 100644 drivers/net/mdio/mdio-dw-xpcs.c diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig index 4a7a303be2f7..39f7ce8087bf 100644 --- a/drivers/net/mdio/Kconfig +++ b/drivers/net/mdio/Kconfig @@ -185,6 +185,14 @@ config MDIO_IPQ8064 This driver supports the MDIO interface found in the network interface units of the IPQ8064 SoC +config MDIO_DW_XPCS + tristate "Synopsys DesignWare XPCS MI bus support" + depends on HAS_IOMEM + select MDIO_DEVRES + help + This driver supports the MCI/APB3 Management Interface responsible + for communicating with the Synopsys DesignWare XPCS devices. + config MDIO_REGMAP tristate help diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile index 1015f0db4531..6389d4c3b862 100644 --- a/drivers/net/mdio/Makefile +++ b/drivers/net/mdio/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o obj-$(CONFIG_MDIO_BCM_UNIMAC) += mdio-bcm-unimac.o obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o obj-$(CONFIG_MDIO_CAVIUM) += mdio-cavium.o +obj-$(CONFIG_MDIO_DW_XPCS) += mdio-dw-xpcs.o obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o obj-$(CONFIG_MDIO_HISI_FEMAC) += mdio-hisi-femac.o obj-$(CONFIG_MDIO_I2C) += mdio-i2c.o diff --git a/drivers/net/mdio/mdio-dw-xpcs.c b/drivers/net/mdio/mdio-dw-xpcs.c new file mode 100644 index 000000000000..c47f0a54d31b --- /dev/null +++ b/drivers/net/mdio/mdio-dw-xpcs.c @@ -0,0 +1,384 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Synopsys DesignWare XPCS Management Interface driver + * + * Copyright (C) 2023 BAIKAL ELECTRONICS, JSC + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Page select register for the indirect MMIO CSRs access */ +#define DW_VR_CSR_VIEWPORT 0xff + +struct dw_xpcs_mi { + struct platform_device *pdev; + struct mii_bus *bus; + bool reg_indir; + int reg_width; + void __iomem *reg_base; + struct clk *pclk; +}; + +static inline ptrdiff_t dw_xpcs_mmio_addr_format(int dev, int reg) +{ + return FIELD_PREP(0x1f0000, dev) | FIELD_PREP(0xffff, reg); +} + +static inline u16 dw_xpcs_mmio_addr_page(ptrdiff_t csr) +{ + return FIELD_GET(0x1fff00, csr); +} + +static inline ptrdiff_t dw_xpcs_mmio_addr_offset(ptrdiff_t csr) +{ + return FIELD_GET(0xff, csr); +} + +static int dw_xpcs_mmio_read_reg_indirect(struct dw_xpcs_mi *dxmi, + int dev, int reg) +{ + ptrdiff_t csr, ofs; + u16 page; + int ret; + + csr = dw_xpcs_mmio_addr_format(dev, reg); + page = dw_xpcs_mmio_addr_page(csr); + ofs = dw_xpcs_mmio_addr_offset(csr); + + ret = pm_runtime_resume_and_get(&dxmi->pdev->dev); + if (ret) + return ret; + + switch (dxmi->reg_width) { + case 4: + writel(page, dxmi->reg_base + (DW_VR_CSR_VIEWPORT << 2)); + ret = readl(dxmi->reg_base + (ofs << 2)); + break; + default: + writew(page, dxmi->reg_base + (DW_VR_CSR_VIEWPORT << 1)); + ret = readw(dxmi->reg_base + (ofs << 1)); + break; + } + + pm_runtime_put(&dxmi->pdev->dev); + + return ret; +} + +static int dw_xpcs_mmio_write_reg_indirect(struct dw_xpcs_mi *dxmi, + int dev, int reg, u16 val) +{ + ptrdiff_t csr, ofs; + u16 page; + int ret; + + csr = dw_xpcs_mmio_addr_format(dev, reg); + page = dw_xpcs_mmio_addr_page(csr); + ofs = dw_xpcs_mmio_addr_offset(csr); + + ret = pm_runtime_resume_and_get(&dxmi->pdev->dev); + if (ret) + return ret; + + switch (dxmi->reg_width) { + case 4: + writel(page, dxmi->reg_base + (DW_VR_CSR_VIEWPORT << 2)); + writel(val, dxmi->reg_base + (ofs << 2)); + break; + default: + writew(page, dxmi->reg_base + (DW_VR_CSR_VIEWPORT << 1)); + writew(val, dxmi->reg_base + (ofs << 1)); + break; + } + + pm_runtime_put(&dxmi->pdev->dev); + + return 0; +} + +static int dw_xpcs_mmio_read_reg_direct(struct dw_xpcs_mi *dxmi, + int dev, int reg) +{ + ptrdiff_t csr; + int ret; + + csr = dw_xpcs_mmio_addr_format(dev, reg); + + ret = pm_runtime_resume_and_get(&dxmi->pdev->dev); + if (ret) + return ret; + + switch (dxmi->reg_width) { + case 4: + ret = readl(dxmi->reg_base + (csr << 2)); + break; + default: + ret = readw(dxmi->reg_base + (csr << 1)); + break; + } + + pm_runtime_put(&dxmi->pdev->dev); + + return ret; +} + +static int dw_xpcs_mmio_write_reg_direct(struct dw_xpcs_mi *dxmi, + int dev, int reg, u16 val) +{ + ptrdiff_t csr; + int ret; + + csr = dw_xpcs_mmio_addr_format(dev, reg); + + ret = pm_runtime_resume_and_get(&dxmi->pdev->dev); + if (ret) + return ret; + + switch (dxmi->reg_width) { + case 4: + writel(val, dxmi->reg_base + (csr << 2)); + break; + default: + writew(val, dxmi->reg_base + (csr << 1)); + break; + } + + pm_runtime_put(&dxmi->pdev->dev); + + return 0; +} + +static int dw_xpcs_mmio_read_c22(struct mii_bus *bus, int addr, int reg) +{ + struct dw_xpcs_mi *dxmi = bus->priv; + + if (addr != 0) + return -ENODEV; + + if (dxmi->reg_indir) + return dw_xpcs_mmio_read_reg_indirect(dxmi, MDIO_MMD_VEND2, reg); + else + return dw_xpcs_mmio_read_reg_direct(dxmi, MDIO_MMD_VEND2, reg); +} + +static int dw_xpcs_mmio_write_c22(struct mii_bus *bus, int addr, int reg, u16 val) +{ + struct dw_xpcs_mi *dxmi = bus->priv; + + if (addr != 0) + return -ENODEV; + + if (dxmi->reg_indir) + return dw_xpcs_mmio_write_reg_indirect(dxmi, MDIO_MMD_VEND2, reg, val); + else + return dw_xpcs_mmio_write_reg_direct(dxmi, MDIO_MMD_VEND2, reg, val); +} + +static int dw_xpcs_mmio_read_c45(struct mii_bus *bus, int addr, int dev, int reg) +{ + struct dw_xpcs_mi *dxmi = bus->priv; + + if (addr != 0) + return -ENODEV; + + if (dxmi->reg_indir) + return dw_xpcs_mmio_read_reg_indirect(dxmi, dev, reg); + else + return dw_xpcs_mmio_read_reg_direct(dxmi, dev, reg); +} + +static int dw_xpcs_mmio_write_c45(struct mii_bus *bus, int addr, int dev, + int reg, u16 val) +{ + struct dw_xpcs_mi *dxmi = bus->priv; + + if (addr != 0) + return -ENODEV; + + if (dxmi->reg_indir) + return dw_xpcs_mmio_write_reg_indirect(dxmi, dev, reg, val); + else + return dw_xpcs_mmio_write_reg_direct(dxmi, dev, reg, val); +} + +static struct dw_xpcs_mi *dw_xpcs_mi_create_data(struct platform_device *pdev) +{ + struct dw_xpcs_mi *dxmi; + + dxmi = devm_kzalloc(&pdev->dev, sizeof(*dxmi), GFP_KERNEL); + if (!dxmi) + return ERR_PTR(-ENOMEM); + + dxmi->pdev = pdev; + + dev_set_drvdata(&pdev->dev, dxmi); + + return dxmi; +} + +static int dw_xpcs_mi_init_res(struct dw_xpcs_mi *dxmi) +{ + struct device *dev = &dxmi->pdev->dev; + struct resource *res; + + if (!device_property_read_u32(dev, "reg-io-width", &dxmi->reg_width)) { + if (dxmi->reg_width != 2 && dxmi->reg_width != 4) { + dev_err(dev, "Invalid regspace data width\n"); + return -EINVAL; + } + } else { + dxmi->reg_width = 2; + } + + res = platform_get_resource_byname(dxmi->pdev, IORESOURCE_MEM, "direct") ?: + platform_get_resource_byname(dxmi->pdev, IORESOURCE_MEM, "indirect"); + if (!res) { + dev_err(dev, "No regspace found\n"); + return -EINVAL; + } + + if (!strcmp(res->name, "indirect")) + dxmi->reg_indir = true; + + if ((dxmi->reg_indir && resource_size(res) < dxmi->reg_width * SZ_256) || + (!dxmi->reg_indir && resource_size(res) < dxmi->reg_width * SZ_2M)) { + dev_err(dev, "Invalid regspace size\n"); + return -EINVAL; + } + + dxmi->reg_base = devm_ioremap_resource(dev, res); + if (IS_ERR(dxmi->reg_base)) { + dev_err(dev, "Failed to map regspace\n"); + return PTR_ERR(dxmi->reg_base); + } + + return 0; +} + +static int dw_xpcs_mi_init_clk(struct dw_xpcs_mi *dxmi) +{ + struct device *dev = &dxmi->pdev->dev; + int ret; + + dxmi->pclk = devm_clk_get_optional(dev, "pclk"); + if (IS_ERR(dxmi->pclk)) + return dev_err_probe(dev, PTR_ERR(dxmi->pclk), + "Failed to get ref clock\n"); + + pm_runtime_set_active(dev); + ret = devm_pm_runtime_enable(dev); + if (ret) { + dev_err(dev, "Failed to enable runtime-PM\n"); + return ret; + } + + return 0; +} + +static int dw_xpcs_mi_init_mdio(struct dw_xpcs_mi *dxmi) +{ + struct device *dev = &dxmi->pdev->dev; + static atomic_t id = ATOMIC_INIT(-1); + int ret; + + dxmi->bus = devm_mdiobus_alloc_size(dev, 0); + if (!dxmi->bus) + return -ENOMEM; + + dxmi->bus->name = "DW XPCS MI"; + dxmi->bus->read = dw_xpcs_mmio_read_c22; + dxmi->bus->write = dw_xpcs_mmio_write_c22; + dxmi->bus->read_c45 = dw_xpcs_mmio_read_c45; + dxmi->bus->write_c45 = dw_xpcs_mmio_write_c45; + dxmi->bus->phy_mask = ~0; + dxmi->bus->parent = dev; + dxmi->bus->priv = dxmi; + + snprintf(dxmi->bus->id, MII_BUS_ID_SIZE, + "dwxpcs-%x", atomic_inc_return(&id)); + + ret = devm_of_mdiobus_register(dev, dxmi->bus, dev_of_node(dev)); + if (ret) { + dev_err(dev, "Failed to create MDIO bus\n"); + return ret; + } + + return 0; +} + +static int dw_xpcs_mi_probe(struct platform_device *pdev) +{ + struct dw_xpcs_mi *dxmi; + int ret; + + dxmi = dw_xpcs_mi_create_data(pdev); + if (IS_ERR(dxmi)) + return PTR_ERR(dxmi); + + ret = dw_xpcs_mi_init_res(dxmi); + if (ret) + return ret; + + ret = dw_xpcs_mi_init_clk(dxmi); + if (ret) + return ret; + + ret = dw_xpcs_mi_init_mdio(dxmi); + if (ret) + return ret; + + return 0; +} + +static int __maybe_unused dw_xpcs_mi_pm_runtime_suspend(struct device *dev) +{ + struct dw_xpcs_mi *dxmi = dev_get_drvdata(dev); + + clk_disable_unprepare(dxmi->pclk); + + return 0; +} + +static int __maybe_unused dw_xpcs_mi_pm_runtime_resume(struct device *dev) +{ + struct dw_xpcs_mi *dxmi = dev_get_drvdata(dev); + + return clk_prepare_enable(dxmi->pclk); +} + +const struct dev_pm_ops dw_xpcs_mi_pm_ops = { + SET_RUNTIME_PM_OPS(dw_xpcs_mi_pm_runtime_suspend, dw_xpcs_mi_pm_runtime_resume, NULL) +}; + +static const struct of_device_id dw_xpcs_mi_of_ids[] = { + { .compatible = "snps,dw-xpcs-mi" }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, dw_xpcs_mi_of_ids); + +static struct platform_driver dw_xpcs_mi_driver = { + .probe = dw_xpcs_mi_probe, + .driver = { + .name = "dw-xpcs-mi", + .pm = &dw_xpcs_mi_pm_ops, + .of_match_table = dw_xpcs_mi_of_ids, + }, +}; + +module_platform_driver(dw_xpcs_mi_driver); + +MODULE_DESCRIPTION("Synopsys DesignWare XPCS Management Interface driver"); +MODULE_AUTHOR("Serge Semin "); +MODULE_LICENSE("GPL v2"); From patchwork Tue Dec 5 10:35:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872070 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=M4lsMQ6F; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SkxyC1bt2z1ySd for ; Tue, 5 Dec 2023 21:45:23 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=M4lsMQ6F; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4SkxyC0T4Sz3d9L for ; Tue, 5 Dec 2023 21:45:23 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=M4lsMQ6F; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::129; helo=mail-lf1-x129.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxlr5Jrrz3cW3 for ; Tue, 5 Dec 2023 21:36:24 +1100 (AEDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-50c0bd61d21so399745e87.3 for ; Tue, 05 Dec 2023 02:36:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772580; x=1702377380; darn=lists.ozlabs.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=DuEP+uQWEz5IeeuWDx+rXfktVLzDKREZ21gC+/GyIBY=; b=M4lsMQ6F6iNg86Duwcd15YpqKw08+NX+uNw8b5wYUgDb7zGI4n/Y/ex43LXo48x/2n kKvh5pUraUDoxYUux+DDyY3x8ECjnQSVuL4jLnK5WiMwJTF2YqzzQp5Is7pJwjsoyjaE dXfVgrw3HjZ6DwYKdnMnbP7Q1K7HjaRcgaEmmQv6K3wJT5VnzztxFRn14o1eJRjx2Ail 2KiHLwsHZo0ntI48/7Iaq58SR1AUQQqtYImp3iYe1ITcwMtQiMjwHfRLv03o8XiYuA69 cVpsSonoeCOb+Q/x0CPJ4ohAi/Ve6E/YsVaTsQL4mS7ttZ9bsk0VicPFkWhFDR/kRdfv 2jYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772580; x=1702377380; 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=DuEP+uQWEz5IeeuWDx+rXfktVLzDKREZ21gC+/GyIBY=; b=QwGWFokaMvT5ViCntQexTkninoxu6oWXTSVok8tvfpkM5OELGqckXUkGAtV5ytMMVk svmeKOIy6Z3Z/3nIW5G/qMhLYRfQY4jqeHehIM+s8Nd5RIAUI4rxGgeRV5XB/6oPkMgJ f1MXhxA0lI6vyUwVrJxEceL9AQDXaEQRQhVOvEMJvjbiCMH+Q9Xt5xEfbLmPtnRDHeHq 38E0VME1HLmd5fYtZr5mFiXMbkMKQPcp1qh4GU7a/cbivzNuwl+DmPaDSgtlJgdVo+7l GGtijflSNnDXumBf53MKSqaG6k6pWDZwVPdgH16J3wqq6VmVqEqr7679SwLQ3maKguAX zL7g== X-Gm-Message-State: AOJu0Yx66/Ip+5ou3tTAg5ou1tK3iG0YJgcG4EFy1bW4q8UGRYyLplTN DBCtWFf50/LDAG4l9uqeG1g= X-Google-Smtp-Source: AGHT+IF2gRKmV84qVxXi1M+5W27kf62+M3aukMfAcptcsu0Anuvo7HvEc1fIHQySmQeecOmwdbDEXQ== X-Received: by 2002:a19:7901:0:b0:50b:ef6c:bc8b with SMTP id u1-20020a197901000000b0050bef6cbc8bmr1801111lfc.134.1701772580383; Tue, 05 Dec 2023 02:36:20 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id m15-20020a0565120a8f00b0050bfda10057sm372593lfu.85.2023.12.05.02.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:20 -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 Subject: [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support Date: Tue, 5 Dec 2023 13:35:31 +0300 Message-ID: <20231205103559.9605-11-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , devicetree@vger.kernel.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" Recently the memory mapped Synopsys DW XPCS management interface support was added to the kernel. In that case the DW XPCS device can be registered via a standard MDIO-bus subsystem. In order to have such devices fully accessible and properly configured let's add a respective functionality to the DW XPCS driver. The main goal of this update is to add a functionality to activate vendor-specific XPCS capabilities in the driver (like a limited number of network interfaces, linkmodes, PMA-specific initializations). It's reached by having DW XPCS devices registered as the platform devices (OF, ACPI, legacy platform ,etc). From that point of view the suggested update is threefold. First the driver is now capable to be attached to the OF-devices registered on the MDIO-bus with the "snps,dw-xpcs*" compatible string. Second it's possible to have the driver bound to the DW XPCS device with no OF/ACPI-nodes by means of defining the mdio_board_info descriptor and registering one with mdiobus_register_board_info() (see dwmac-intel.c for example). Thirdly it's still possible to use the unregistered device to auto-detect the DW XPCS device on the MDIO bus. In all these cases the DW XPCS device info can be passed by means of the driver-data pointer (of_device_id.data or device.platform_data). In addition to that the update provides the DW XPCS reference clock sources request and enabling. These clocks are named as "core" and "pad" as per the DT-bindings. Note normally they are mutually exclusive: only one of them can be used at a time, but the system software is responsible for switching between them. Such functionality will be added later in the framework of the pma_config() internal callback. Note all the platform resources initialization is performed in the externally called xpcs_create() method as before this update. The only crucial update is that it now makes sure that the device is bound to the DW XPCS driver if it's possible. Otherwise the legacy auto-detection procedure takes place as before. Moreover due to that semantic there is no device probe() and remove() methods defined since there is nothing left to initialize/de-initialize on these stages. Signed-off-by: Serge Semin --- drivers/net/pcs/Kconfig | 6 +- drivers/net/pcs/pcs-xpcs.c | 112 ++++++++++++++++++++++++++++++++--- drivers/net/pcs/pcs-xpcs.h | 6 ++ include/linux/pcs/pcs-xpcs.h | 27 +++++++++ 4 files changed, 141 insertions(+), 10 deletions(-) diff --git a/drivers/net/pcs/Kconfig b/drivers/net/pcs/Kconfig index 87cf308fc6d8..f6aa437473de 100644 --- a/drivers/net/pcs/Kconfig +++ b/drivers/net/pcs/Kconfig @@ -6,11 +6,11 @@ menu "PCS device drivers" config PCS_XPCS - tristate + tristate "Synopsys DesignWare Ethernet XPCS" select PHYLINK help - This module provides helper functions for Synopsys DesignWare XPCS - controllers. + This module provides a driver and helper functions for Synopsys + DesignWare XPCS controllers. config PCS_LYNX tristate diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index ea6f56339595..183a37929b60 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -6,10 +6,14 @@ * Author: Jose Abreu */ +#include #include -#include +#include #include +#include +#include #include +#include #include "pcs-xpcs.h" @@ -1386,17 +1390,57 @@ static void xpcs_free_data(struct dw_xpcs *xpcs) kfree(xpcs); } +static int xpcs_init_clks(struct dw_xpcs *xpcs) +{ + static const char *ids[DW_XPCS_NUM_CLKS] = { + [DW_XPCS_CLK_CORE] = "core", + [DW_XPCS_CLK_PAD] = "pad", + }; + struct device *dev = &xpcs->mdiodev->dev; + int ret, i; + + for (i = 0; i < DW_XPCS_NUM_CLKS; ++i) + xpcs->clks[i].id = ids[i]; + + ret = clk_bulk_get_optional(dev, DW_XPCS_NUM_CLKS, xpcs->clks); + if (ret) + return dev_err_probe(dev, ret, "Failed to get clocks\n"); + + ret = clk_bulk_prepare_enable(DW_XPCS_NUM_CLKS, xpcs->clks); + if (ret) + return dev_err_probe(dev, ret, "Failed to enable clocks\n"); + + return 0; +} + +static void xpcs_clear_clks(struct dw_xpcs *xpcs) +{ + clk_bulk_disable_unprepare(DW_XPCS_NUM_CLKS, xpcs->clks); + + clk_bulk_put(DW_XPCS_NUM_CLKS, xpcs->clks); +} + static int xpcs_init_id(struct dw_xpcs *xpcs) { - u32 xpcs_id; + const struct dw_xpcs_info *info; int i, ret; - xpcs_id = xpcs_get_id(xpcs); + info = device_get_match_data(&xpcs->mdiodev->dev) ?: + dev_get_platdata(&xpcs->mdiodev->dev); + if (!info) { + xpcs->info.did = DW_XPCS_ID_NATIVE; + xpcs->info.pma = DW_XPCS_PMA_UNKNOWN; + } else { + xpcs->info = *info; + } + + if (xpcs->info.did == DW_XPCS_ID_NATIVE) + xpcs->info.did = xpcs_get_id(xpcs); for (i = 0; i < ARRAY_SIZE(xpcs_id_list); i++) { const struct xpcs_id *entry = &xpcs_id_list[i]; - if ((xpcs_id & entry->mask) != entry->id) + if ((xpcs->info.did & entry->mask) != entry->id) continue; xpcs->id = entry; @@ -1436,21 +1480,32 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, struct dw_xpcs *xpcs; int ret; + ret = device_attach(&mdiodev->dev); + if (ret < 0 && ret != -ENODEV) + return ERR_PTR(ret); + xpcs = xpcs_create_data(mdiodev); if (IS_ERR(xpcs)) return xpcs; + ret = xpcs_init_clks(xpcs); + if (ret) + goto out_free_data; + ret = xpcs_init_id(xpcs); if (ret) - goto out; + goto out_clear_clks; ret = xpcs_init_iface(xpcs, interface); if (ret) - goto out; + goto out_clear_clks; return xpcs; -out: +out_clear_clks: + xpcs_clear_clks(xpcs); + +out_free_data: xpcs_free_data(xpcs); return ERR_PTR(ret); @@ -1489,8 +1544,51 @@ void xpcs_destroy(struct dw_xpcs *xpcs) mdio_device_put(xpcs->mdiodev); + xpcs_clear_clks(xpcs); + xpcs_free_data(xpcs); } EXPORT_SYMBOL_GPL(xpcs_destroy); +DW_XPCS_INFO_DECLARE(xpcs_generic, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_UNKNOWN); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen1_3g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN1_3G); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen2_3g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN2_3G); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen2_6g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN2_6G); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen4_3g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN4_3G); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen4_6g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN4_6G); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen5_10g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN5_10G); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen5_12g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN5_12G); + +static const struct of_device_id xpcs_of_ids[] = { + { .compatible = "snps,dw-xpcs", .data = &xpcs_generic }, + { .compatible = "snps,dw-xpcs-gen1-3g", .data = &xpcs_pma_gen1_3g }, + { .compatible = "snps,dw-xpcs-gen2-3g", .data = &xpcs_pma_gen2_3g }, + { .compatible = "snps,dw-xpcs-gen2-6g", .data = &xpcs_pma_gen2_6g }, + { .compatible = "snps,dw-xpcs-gen4-3g", .data = &xpcs_pma_gen4_3g }, + { .compatible = "snps,dw-xpcs-gen4-6g", .data = &xpcs_pma_gen4_6g }, + { .compatible = "snps,dw-xpcs-gen5-10g", .data = &xpcs_pma_gen5_10g }, + { .compatible = "snps,dw-xpcs-gen5-12g", .data = &xpcs_pma_gen5_12g }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, xpcs_of_ids); + +static struct mdio_device_id __maybe_unused xpcs_mdio_ids[] = { + { DW_XPCS_ID, DW_XPCS_ID_MASK }, + { NXP_SJA1105_XPCS_ID, DW_XPCS_ID_MASK }, + { NXP_SJA1110_XPCS_ID, DW_XPCS_ID_MASK }, + { } +}; +MODULE_DEVICE_TABLE(mdio, xpcs_mdio_ids); + +static struct mdio_driver xpcs_driver = { + .mdiodrv.driver = { + .name = "dwxpcs", + .of_match_table = xpcs_of_ids, + .probe_type = PROBE_FORCE_SYNCHRONOUS, + }, +}; +mdio_module_driver(xpcs_driver); + +MODULE_DESCRIPTION("DWC Ethernet XPCS platform driver"); +MODULE_AUTHOR("Jose Abreu "); MODULE_LICENSE("GPL v2"); diff --git a/drivers/net/pcs/pcs-xpcs.h b/drivers/net/pcs/pcs-xpcs.h index 369e9196f45a..45fea2641d23 100644 --- a/drivers/net/pcs/pcs-xpcs.h +++ b/drivers/net/pcs/pcs-xpcs.h @@ -6,6 +6,9 @@ * Author: Jose Abreu */ +#include +#include + /* Vendor regs access */ #define DW_VENDOR BIT(15) @@ -117,6 +120,9 @@ /* VR MII EEE Control 1 defines */ #define DW_VR_MII_EEE_TRN_LPI BIT(0) /* Transparent Mode Enable */ +#define DW_XPCS_INFO_DECLARE(_name, _did, _pma) \ + static const struct dw_xpcs_info _name = { .did = _did, .pma = _pma } + int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg); int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val); int xpcs_read_vpcs(struct dw_xpcs *xpcs, int reg); diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 8dfe90295f12..53adbffb4c0a 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -7,9 +7,12 @@ #ifndef __LINUX_PCS_XPCS_H #define __LINUX_PCS_XPCS_H +#include +#include #include #include +#define DW_XPCS_ID_NATIVE 0x00000000 #define NXP_SJA1105_XPCS_ID 0x00000010 #define NXP_SJA1110_XPCS_ID 0x00000020 #define DW_XPCS_ID 0x7996ced0 @@ -30,9 +33,33 @@ struct xpcs_id; +enum dw_xpcs_pma { + DW_XPCS_PMA_UNKNOWN = 0, + DW_XPCS_PMA_GEN1_3G, + DW_XPCS_PMA_GEN2_3G, + DW_XPCS_PMA_GEN2_6G, + DW_XPCS_PMA_GEN4_3G, + DW_XPCS_PMA_GEN4_6G, + DW_XPCS_PMA_GEN5_10G, + DW_XPCS_PMA_GEN5_12G, +}; + +enum dw_xpcs_clock { + DW_XPCS_CLK_CORE, + DW_XPCS_CLK_PAD, + DW_XPCS_NUM_CLKS, +}; + +struct dw_xpcs_info { + u32 did; + u32 pma; +}; + struct dw_xpcs { struct mdio_device *mdiodev; + struct dw_xpcs_info info; const struct xpcs_id *id; + struct clk_bulk_data clks[DW_XPCS_NUM_CLKS]; struct phylink_pcs pcs; phy_interface_t interface; int dev_flag; From patchwork Tue Dec 5 10:35:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=SCHxaSOP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SkxzD18vGz1ySd for ; Tue, 5 Dec 2023 21:46:16 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=SCHxaSOP; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4SkxzD05FZz3dJs for ; Tue, 5 Dec 2023 21:46:16 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=SCHxaSOP; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::22f; helo=mail-lj1-x22f.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxlt62tBz3cTh for ; Tue, 5 Dec 2023 21:36:26 +1100 (AEDT) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2c9f413d6b2so33426741fa.1 for ; 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=1701772583; x=1702377383; darn=lists.ozlabs.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=WIQUz6kTrVuZdOXLZo+ge/Lp9pWSfj/oMDcXilwbtBU=; b=SCHxaSOPYlGouNK5Akuyt0FU1xNum61A7STqh9kYCGYY2T/u7G26KkEBsfykwy6NPL /bTIC9QYHDOJWPaGv0QHEthO90eHX1rFHhFIiy/7iEt9Zfh7+p9NmpEB1/3Jfz1Ht84j ubR+mNx2PZ+RpzgHgMaSPCGZDBDzzMxHfsu1d8xIq4rWwIEsfj9pWZvrWPoiPiNmK7Az La2rSlaRoeWOxOVEJLUXrsvEKjSfJDtv9XEre9JvVxbSRad1moOk1/N0H/75MKCJjeib 875gqpfhy8EEjCFMACA+9QLfBGfdL+hpPKyR/gRdyWh79s6OtuN+5wecbIcxVtCc6FUr IRsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772583; x=1702377383; 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=WIQUz6kTrVuZdOXLZo+ge/Lp9pWSfj/oMDcXilwbtBU=; b=PHGbWKR/R9xFnYNFoXVroT4/leF5AHJPFWrKmc42qsuhTK+3sI7j/zpG4qQxPe12jH EWNPIJvqsm1wkkR8PfA5PwHbqwf4/M5/dgd/+mUqupWxNx0qe8qUguErFbxLgmNrB0r6 +zVtjTLU75eooLw1bDxiQUzwqp3RfXcd0Nc+fzC85xK9AHMLO/tDmfYS2BjiovZFoWrR Zeh+cdU+LcCJVlzgIDn2L50Nh+D/E2tZy4HEmlp+rVSsP5JTO3wOkUQAtuc3gg2gCkfU igVxXN7JBQQpC5gU8B3g7Bv1LA+J+lpEfdekXF6JEEEvRt9mQVZp6LJqFHT7hpd49pkz miPg== X-Gm-Message-State: AOJu0YwvvhCLvVYSRqO/oUrCvilT+0v1Q/DRh4cJaDy6ari855pOWqBw +8tpa1CYGB30nmp8XnzkTLk= X-Google-Smtp-Source: AGHT+IGX6hxolloUWCXauP85aEGl4KFj8FADRPvac0Qo990dFIzZotJOwEw2Nm39AzLMj98ISD+EcQ== X-Received: by 2002:ac2:5a50:0:b0:50b:fea2:4cdc with SMTP id r16-20020ac25a50000000b0050bfea24cdcmr583327lfn.172.1701772582731; Tue, 05 Dec 2023 02:36:22 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id c10-20020ac25f6a000000b0050c0514fdf4sm146106lfc.127.2023.12.05.02.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:22 -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 , Vladimir Oltean , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Subject: [PATCH net-next 11/16] net: pcs: xpcs: Change xpcs_create_mdiodev() suffix to "byaddr" Date: Tue, 5 Dec 2023 13:35:32 +0300 Message-ID: <20231205103559.9605-12-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" The fwnode-based way of creating XPCS descriptor is about to be added. In order to have a function name distinguishable from the already implemented xpcs_create_mdiodev() method convert the later name to be xpcs_create_byaddr() which BTW better describes the method semantic in anyway. Signed-off-by: Serge Semin --- drivers/net/dsa/sja1105/sja1105_mdio.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 +- drivers/net/pcs/pcs-xpcs.c | 6 +++--- include/linux/pcs/pcs-xpcs.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_mdio.c b/drivers/net/dsa/sja1105/sja1105_mdio.c index 833e55e4b961..9101079e365d 100644 --- a/drivers/net/dsa/sja1105/sja1105_mdio.c +++ b/drivers/net/dsa/sja1105/sja1105_mdio.c @@ -409,7 +409,7 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv) priv->phy_mode[port] != PHY_INTERFACE_MODE_2500BASEX) continue; - xpcs = xpcs_create_mdiodev(bus, port, priv->phy_mode[port]); + xpcs = xpcs_create_byaddr(bus, port, priv->phy_mode[port]); if (IS_ERR(xpcs)) { rc = PTR_ERR(xpcs); goto out_pcs_free; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index fa9e7e7040b9..aa75e4f1e212 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -507,7 +507,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus) /* Try to probe the XPCS by scanning all addresses. */ for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - xpcs = xpcs_create_mdiodev(bus, addr, mode); + xpcs = xpcs_create_byaddr(bus, addr, mode); if (IS_ERR(xpcs)) continue; diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 183a37929b60..e376e255f1d3 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -1511,8 +1511,8 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, return ERR_PTR(ret); } -struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, - phy_interface_t interface) +struct dw_xpcs *xpcs_create_byaddr(struct mii_bus *bus, int addr, + phy_interface_t interface) { struct mdio_device *mdiodev; struct dw_xpcs *xpcs; @@ -1535,7 +1535,7 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, return xpcs; } -EXPORT_SYMBOL_GPL(xpcs_create_mdiodev); +EXPORT_SYMBOL_GPL(xpcs_create_byaddr); void xpcs_destroy(struct dw_xpcs *xpcs) { diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 53adbffb4c0a..b11bbb5e820a 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -73,8 +73,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_mdiodev(struct mii_bus *bus, int addr, - 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); #endif /* __LINUX_PCS_XPCS_H */ From patchwork Tue Dec 5 10:35:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=jRXoqEZi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sky0D5yjqz1ySd for ; Tue, 5 Dec 2023 21:47:08 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=jRXoqEZi; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Sky0D4m3Gz3cTg for ; Tue, 5 Dec 2023 21:47:08 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=jRXoqEZi; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::12d; helo=mail-lf1-x12d.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxlw35ZSz3cVN for ; Tue, 5 Dec 2023 21:36:28 +1100 (AEDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-50bee606265so3004982e87.2 for ; Tue, 05 Dec 2023 02:36:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772584; x=1702377384; darn=lists.ozlabs.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=jRXoqEZif6JTLKLB/3Hq4e6SCXWW6YgMBDYcvUbU8MZwiVJ1iyo53yMrswD9pCQBXd 6LDfs/TVPbHZW+wKUYPL3QgRjtxru9LyIc32tWtQs/R5ECKsP3iwAgy6k9SxKyT5J9PE Kqn/jnYPfI0/DHtJMSxowgMpioaSVTa+eCRznpsQjvrCNupWoNxxw4xHuegZhJ2fNRPp wFt3uyJzD83R1L96VQ+TLTFR7UNHnME2JCZLNecKFMN73cEE75IFJwVUP/37ThNMcrth 3bcgqlaaZkrsOl4NW7CuwgVj3JDq61UJbMlU5HiKdIiFH9eEBtA66bd4bOTp8UnFRDUm 6BVA== 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=E3NMq0gJMmRRBhRvQQ4QBRMc+F50NUukpseClORXNgvhT/UwmsAf9zt1EB6wUSPcdn YtrrEvXgw9MwiR9SAdHmrUmfoQudBOGr63FcjS9k9gmvS5TaxRdZOmzISLpXKXX6eus2 Fvr2mYQubnPZ3TfPrYE5plOFfCugWTOxaNKVnWn4onGAK+5fhhCkgcGRl0i35x5EQUHW 6JW/RgJo9evmkycq1vN2q/GOpuk1XK4J4CzUPZwsB+luW5g3f6n+hWzhI8Ae85MfAljS FpZERhglR9xprpSrzJvmEOuxXxNackQKFQzl6fFXk0J2uLGm6sIsiwqv182o3NVScXxB d2fQ== X-Gm-Message-State: AOJu0YxuaaghPHKw8bNmPapRtc/pYTuxtBEWmenG59kp/lSjLscczK07 wvAWstbJnjeKfmQvDEH1S4kNgl2wpPlTSg== X-Google-Smtp-Source: AGHT+IHUCyh6fTgOz+IpheRuxzuTVvMVIazUtogkrsNd/ECy8uXTfUSwsV4TsLItWinwQ4JF0eHc9g== 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 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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , devicetree@vger.kernel.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" 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); From patchwork Tue Dec 5 10:35:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872073 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MPZSrwUA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sky1m0Xzlz1ySd for ; Tue, 5 Dec 2023 21:48:28 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MPZSrwUA; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Sky1l6YKjz3cYh for ; Tue, 5 Dec 2023 21:48:27 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MPZSrwUA; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::12f; helo=mail-lf1-x12f.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxly3rLBz3cF1 for ; Tue, 5 Dec 2023 21:36:30 +1100 (AEDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-50bce78f145so6567894e87.0 for ; Tue, 05 Dec 2023 02:36:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772586; x=1702377386; darn=lists.ozlabs.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=9/W7bRr2FIytmHTP+ve4vRfpj/k8/yIBrLP2P8LnNEk=; b=MPZSrwUAIgfKZEbxJet/hBOkEyL2IV9lFhMRKjpnXZ9zkWpU/2giy/8bRRup40nc2J h8HMFelWVzE3xJiagYCOkhRKadXmFXsTARCl2eRH2c4YJUAbVS3ZLAlUfDJtNyteZNMO 95bQujStC62znRE7O2gtRP1eNgHhEBL7rKQUWwtRPqVf9S3RuShy0+sLeNXsy4R/XePM p/wN8vnz8BhGFTST8IseAhLjwgVPkLOXRGZu+Ej+yCn1gTXBDzXmj3+9ebtN3CyUg9TH j9k88HFv2L5Amze4KKSKsQnXrav3JvH/WxRK02PRFeQKvXaG/j05cfAaho3eYa1cyoaB 5fMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772586; x=1702377386; 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=9/W7bRr2FIytmHTP+ve4vRfpj/k8/yIBrLP2P8LnNEk=; b=D64M2Laj4kW1VQVWZNpUzzsRgk5AagZh4BhgF75ZBv069QQRoCVSPpY3HE1BCZWjXA B3I31zYKz2CfU2KeGJjDY/4iTXlFiLmsuDoKCCN0P8cOO1OXwgWiv0I8jYhaSMPXxfR2 wGNBsCUiulASES+KYIqDSd16AxmtAgEf2YAKwUhAX3CCCJE8SWn51EnFxuc3m09OAw5F DhzHlgjn/wGK1I3WJh26sV+VqtOsPKdsB8SBXNCfPDrVGv19UguanvPJoa1EbA3cEu5I gZ859cjqkA+6h9qiX3rqZB/LdlcmiAIJi9fhNr/abX94ODiUoo/N5ZiPHUNJNEviDXEi tD0w== X-Gm-Message-State: AOJu0YwBtEgxhaR3ecHG2H4kQuD4xpMwDgoiPZvukDYHvD3KQ2GtIzzT 9gxOMD3+tE/F0ilLU8fQV7E= X-Google-Smtp-Source: AGHT+IES81scnB9OAc2hliG1AqfHqUzn12268APbl0b9mr/HfSY9+lceF3Al8CkH/xAT+wtxcOc+8g== X-Received: by 2002:a19:3848:0:b0:50c:4e7:87b8 with SMTP id d8-20020a193848000000b0050c04e787b8mr175943lfj.23.1701772586273; Tue, 05 Dec 2023 02:36:26 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id v8-20020ac25928000000b0050bf7a9c4adsm567335lfi.225.2023.12.05.02.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:25 -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 , Maxime Coquelin Subject: [PATCH net-next 13/16] net: stmmac: intel: Register generic MDIO device Date: Tue, 5 Dec 2023 13:35:34 +0300 Message-ID: <20231205103559.9605-14-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" The DW XPCS driver has been updated to being bindable with the respective MDIO device registered during the MDIO bus probe procedure. As an example of using that feature let's convert the Intel mGBE low-level driver to registering the MDIO-device board info. Thus the registered DW XPCS device will be a subject of the fine-tunings performed during the MDIO-device probe procedures. Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 60283543ffc8..7642c11abc59 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -4,6 +4,7 @@ #include #include +#include #include #include "dwmac-intel.h" #include "dwmac4.h" @@ -585,6 +586,28 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, /* Intel mgbe SGMII interface uses pcs-xcps */ if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII || plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) { + struct mdio_board_info *xpcs_info; + + xpcs_info = devm_kzalloc(&pdev->dev, + sizeof(*xpcs_info) + MII_BUS_ID_SIZE, + GFP_KERNEL); + if (!xpcs_info) { + ret = -ENOMEM; + goto err_alloc_info; + } + + xpcs_info->bus_id = (void *)xpcs_info + sizeof(*xpcs_info); + snprintf((char *)xpcs_info->bus_id, MII_BUS_ID_SIZE, + "stmmac-%x", plat->bus_id); + + snprintf(xpcs_info->modalias, MDIO_NAME_SIZE, "dwxpcs"); + + xpcs_info->mdio_addr = INTEL_MGBE_XPCS_ADDR; + + ret = mdiobus_register_board_info(xpcs_info, 1); + if (ret) + goto err_alloc_info; + plat->mdio_bus_data->has_xpcs = true; plat->mdio_bus_data->xpcs_an_inband = true; } @@ -600,7 +623,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, fwnode_handle_put(fixed_node); } - /* Ensure mdio bus scan skips intel serdes and pcs-xpcs */ + /* Ensure mdio bus PHY-scan skips intel serdes and pcs-xpcs */ plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR; plat->mdio_bus_data->phy_mask |= 1 << INTEL_MGBE_XPCS_ADDR; @@ -618,6 +641,12 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->msi_tx_base_vec = 1; return 0; + +err_alloc_info: + clk_disable_unprepare(clk); + clk_unregister_fixed_rate(clk); + + return ret; } static int ehl_common_data(struct pci_dev *pdev, From patchwork Tue Dec 5 10:35:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872074 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=T51VdFYe; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sky2m55hLz1ySd for ; Tue, 5 Dec 2023 21:49:20 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=T51VdFYe; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Sky2m3ytbz2yLr for ; Tue, 5 Dec 2023 21:49:20 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=T51VdFYe; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::135; helo=mail-lf1-x135.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxm03qzrz3cTF for ; Tue, 5 Dec 2023 21:36:32 +1100 (AEDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-50be10acaf9so3449264e87.1 for ; Tue, 05 Dec 2023 02:36:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772588; x=1702377388; darn=lists.ozlabs.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=eSce1rQ1um+oY77DdZG8yrBJ6NEyKdJwNZU1ix0Nv7k=; b=T51VdFYeYBn/aQ4ziWm36XqRQQ6nrPpjqPv6qCNMKJ1GMB1OMjM6bGf/zYjloFGmZ4 GFxKlELPZDtE/i7Wsal6rtq6ePiADlTWTYBCA2T0j7Gthy0zXCCIVT5xP/2kjMMrPp0B dIqNCYHmFeMAg8ITl6ObDHzs8/QkQk+BavwNyjHpcWSjhQSPDpJQJ233J4HUl2h24sCp kwxYA8o1aeHKxaFNiF5s/andkvT5S72pgjIRhLtk9E0R+vcvnwq4eW8Vg2CdPeVrM4Ix UBjP8eZE/K4zrGkaJ6VYvRtnQxtKvRyc9YUwvAYCRCtKoceHJ2veSpCZ3t/kOCr4EJqK 22FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772588; x=1702377388; 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=eSce1rQ1um+oY77DdZG8yrBJ6NEyKdJwNZU1ix0Nv7k=; b=uhan+N4u0j380k8mS6UuUX7p5PNV2uee83XMxmf4BmkbGXJVB9PlSQsI25GkOjJAo/ bEpdOSn4nEZM8hIzr2DRkZ32MMTgO1dVaTryVkt5dn5uM9+JQGsdhk+0JpHGYRpnVKw6 ss/BT3T8Q0RngLfOLzYIYGcvxcw2Cx74Qhd05uH9uOLKxL5kZXAGpboNfoNsi6Iu81/d dR3959x2QnHRxtpeTk90dLpNKhepg+liKxPuOxPYfASGgpbcMaXYgl5otAhpn711Y/vZ 4Pv800yQ5FlUqfiNaYEQXceeMyHfZ+pZNpZND6seR0e6dVZrNf59xBpGU/MNrk2nIAQk RPFw== X-Gm-Message-State: AOJu0YwrkMf3blXyi5b/z75/ToBdeueyj5qcyh9V2hadoRdmqo1cYyJZ pAmkE3qZ5qQAQ3db4MNxjD8= X-Google-Smtp-Source: AGHT+IHCPdpPY0zKceA3SRi5ga/xIyMFSxmCiObH9MLWtgGsZTqmrUo8sVBhomQ2MmR96xpeV6v2vw== X-Received: by 2002:a05:6512:2809:b0:50b:f0a9:1e3e with SMTP id cf9-20020a056512280900b0050bf0a91e3emr834935lfb.3.1701772588437; Tue, 05 Dec 2023 02:36:28 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id x3-20020a056512046300b0050c0215a806sm185275lfd.83.2023.12.05.02.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:27 -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 , Maxime Coquelin Subject: [PATCH net-next 14/16] net: stmmac: Pass netdev to XPCS setup function Date: Tue, 5 Dec 2023 13:35:35 +0300 Message-ID: <20231205103559.9605-15-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" It's possible to have the XPCS device accessible over a dedicated management interface which makes the XPCS device available over the MMIO space. In that case the management interface will be registered as a separate MDIO bus and the DW xGMAC device will be equipped with the "pcs-handle" property pointing to the XPCS device instead of auto-detecting it on the internal MDIO bus. In such configurations the SMA interface (embedded into the DW xGMAC MDIO interface) might be absent. Thus passing the MII bus interface handler to the stmmac_xpcs_setup() method won't let us reach the externally supplied XPCS device especially if the SMA bus isn't configured. Let's fix it by converting the stmmac_xpcs_setup(struct mii_bus *bus) prototype to stmmac_xpcs_setup(struct net_device *ndev). Note this is a preparation patch before adding the support of the XPCS devices specified via the "pcs-handle" property. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index cd7a9768de5f..d8a1c84880c5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -343,7 +343,7 @@ enum stmmac_state { int stmmac_mdio_unregister(struct net_device *ndev); int stmmac_mdio_register(struct net_device *ndev); int stmmac_mdio_reset(struct mii_bus *mii); -int stmmac_xpcs_setup(struct mii_bus *mii); +int stmmac_xpcs_setup(struct net_device *ndev); void stmmac_set_ethtool_ops(struct net_device *netdev); int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 3e50fd53a617..c3641db00f96 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7605,7 +7605,7 @@ int stmmac_dvr_probe(struct device *device, priv->plat->speed_mode_2500(ndev, priv->plat->bsp_priv); if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { - ret = stmmac_xpcs_setup(priv->mii); + ret = stmmac_xpcs_setup(ndev); if (ret) goto error_xpcs_setup; } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index aa75e4f1e212..e6133510e28d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -495,9 +495,8 @@ int stmmac_mdio_reset(struct mii_bus *bus) return 0; } -int stmmac_xpcs_setup(struct mii_bus *bus) +int stmmac_xpcs_setup(struct net_device *ndev) { - struct net_device *ndev = bus->priv; struct stmmac_priv *priv; struct dw_xpcs *xpcs; int mode, addr; @@ -507,7 +506,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus) /* Try to probe the XPCS by scanning all addresses. */ for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - xpcs = xpcs_create_byaddr(bus, addr, mode); + xpcs = xpcs_create_byaddr(priv->mii, addr, mode); if (IS_ERR(xpcs)) continue; From patchwork Tue Dec 5 10:35:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872075 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=gOoaBZwU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sky4J1SjVz1yST for ; Tue, 5 Dec 2023 21:50:40 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=gOoaBZwU; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Sky4J0L6Lz3cRF for ; Tue, 5 Dec 2023 21:50:40 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=gOoaBZwU; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::136; helo=mail-lf1-x136.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxm25n4Bz3cYh for ; Tue, 5 Dec 2023 21:36:34 +1100 (AEDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-50bf3efe2cbso2548866e87.2 for ; Tue, 05 Dec 2023 02:36:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772590; x=1702377390; darn=lists.ozlabs.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=KnWeBpfqtvqCDqeZAExTorADExkavt7pqbm3ec9WO1c=; b=gOoaBZwUvHEbShvsM+gQLlqzCb30Dqg1XQG8mDwf5SRn+0zGDuMJ84eRCScHUVzu1h cL96m9QrybNu3xvT0LsZ4TFhrbayxpcV+4UQpnuA0WT2op6K5Jh7fv5B4Q4sHp1P4bIm 3XeaZgkMZqNged7SGERTTDk+Sl2dWfOT6DD2f8PCTaAEO3YoChEL0uLO7/kCpTA3k85i Ndfb9WpqUaDnLAFT52inbNlq4FJGkh5iu5IWbRL01KeG8nFhEOCjJvXcyzV7urD3YpCI NhTXKFNkFsGh5IOM5TFagzfBjdlCR8VvyZEIkRQo3IjO+hP9ZrFPfAOyMPBTtRTyplme cdTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772590; x=1702377390; 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=KnWeBpfqtvqCDqeZAExTorADExkavt7pqbm3ec9WO1c=; b=tZxh4UzVRX+5v6VCMvLKQj01LsNlNy2Z39j92rqgACdAuHURlRiEw87mpQ939QCwAX vRU5Ercy4mO/hekYTj1WD8EAEbdM8V13dEcIv6PNkgi0z3S28Lf0eKBs/mwaA1w3ki1y 1QtkiZvu1XGNxpEbii5/wws/73lpjdchQXXwHwBDn9Zw9Iy1rnWQKv49Fo25I8df7foj fdeKY0gL1T8oVEufvwBmHFnNcPGIW89N/OURuBeM3ccZJkdTMfYFddyJo+py3AlI05Ii qraSY0bfp9LyP7imHmgp6QfrbiICMe+XCQszQ6vhylkeBOa5yf58ildzr7w9mXpbdmYz XAyw== X-Gm-Message-State: AOJu0YxCCSkL3KHmcB9P/Mqfx4X2OdHO6aInaTrXcbyRhQaDWeWFgLN8 fsguqhLpYaWbVAkP4nbINyQ= X-Google-Smtp-Source: AGHT+IFCUWZhdYHhKb8nG0l8H2uVfvXP7CMp59To4aI5jWsBTPXwOd7IoX4cD7Nlfspv3sfeyfBb1A== X-Received: by 2002:ac2:5f43:0:b0:50b:ccc1:201e with SMTP id 3-20020ac25f43000000b0050bccc1201emr1469322lfz.0.1701772590456; Tue, 05 Dec 2023 02:36:30 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id d19-20020a196b13000000b0050bf365e8c8sm679554lfa.63.2023.12.05.02.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:30 -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 , Maxime Coquelin Subject: [PATCH net-next 15/16] net: stmmac: Add dedicated XPCS cleanup method Date: Tue, 5 Dec 2023 13:35:36 +0300 Message-ID: <20231205103559.9605-16-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" Currently the XPCS handler destruction is performed in the stmmac_mdio_unregister() method. It doesn't look well because the handler isn't originally created in the corresponding protagonist stmmac_mdio_unregister(), but in the stmmac_xpcs_setup() function. In order to have a bit more coherent MDIO and XPCS setup/cleanup procedures let's move the DW XPCS destruction to the dedicated stmmac_xpcs_clean() method. Note besides of that this change is a preparation to adding the PCS device supplied by means of the "pcs-handle" property. It's required since DW XPCS IP-core can be synthesized embedded into the chip with directly accessible CSRs. In that case the SMA interface can be absent so no corresponding MDIO bus will be registered. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++++- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 14 +++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index d8a1c84880c5..1709de519813 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -344,6 +344,7 @@ int stmmac_mdio_unregister(struct net_device *ndev); int stmmac_mdio_register(struct net_device *ndev); int stmmac_mdio_reset(struct mii_bus *mii); int stmmac_xpcs_setup(struct net_device *ndev); +void stmmac_xpcs_clean(struct net_device *ndev); void stmmac_set_ethtool_ops(struct net_device *netdev); int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index c3641db00f96..379552240ac9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7639,8 +7639,9 @@ int stmmac_dvr_probe(struct device *device, error_netdev_register: phylink_destroy(priv->phylink); -error_xpcs_setup: error_phy_setup: + stmmac_xpcs_clean(ndev); +error_xpcs_setup: if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); @@ -7682,6 +7683,9 @@ void stmmac_dvr_remove(struct device *dev) if (priv->plat->stmmac_rst) reset_control_assert(priv->plat->stmmac_rst); reset_control_assert(priv->plat->stmmac_ahb_rst); + + stmmac_xpcs_clean(ndev); + if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index e6133510e28d..101fa50c3c96 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -522,6 +522,17 @@ int stmmac_xpcs_setup(struct net_device *ndev) return 0; } +void stmmac_xpcs_clean(struct net_device *ndev) +{ + struct stmmac_priv *priv = netdev_priv(ndev); + + if (!priv->hw->xpcs) + return; + + xpcs_destroy(priv->hw->xpcs); + priv->hw->xpcs = NULL; +} + /** * stmmac_mdio_register * @ndev: net device structure @@ -674,9 +685,6 @@ int stmmac_mdio_unregister(struct net_device *ndev) if (!priv->mii) return 0; - if (priv->hw->xpcs) - xpcs_destroy(priv->hw->xpcs); - mdiobus_unregister(priv->mii); priv->mii->priv = NULL; mdiobus_free(priv->mii); From patchwork Tue Dec 5 10:35:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 1872076 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MmqvYDND; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sky5p5QfYz1yST for ; Tue, 5 Dec 2023 21:51:58 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MmqvYDND; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Sky5p2BxNz3c5j for ; Tue, 5 Dec 2023 21:51:58 +1100 (AEDT) X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MmqvYDND; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::233; helo=mail-lj1-x233.google.com; envelope-from=fancer.lancer@gmail.com; receiver=lists.ozlabs.org) Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Skxm43jdyz3cRF for ; Tue, 5 Dec 2023 21:36:36 +1100 (AEDT) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2ca0715f0faso24566131fa.0 for ; Tue, 05 Dec 2023 02:36:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772592; x=1702377392; darn=lists.ozlabs.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=KjKEFhPSgLN5vGtDlHZQvN1ZMYBQW2UNIHEU4iW11KA=; b=MmqvYDNDu6Ih+u/mssEkiSVI6eLv9FXL5owkY04Ajm1YvsUebtXx/buiN2Vg4fymXd htTVG/e6xqyGxysWAI9jAThEZR3eCCxNiQ3BME+Qd4QTLph9VKj2NY23HW/dxQsOHndY 69aSgN8/jXJJe+Fh92iF4yKeIHvl2kzgqlFFpYmo6osZkYnDeBRoHctnzJSJkKjAwu1Q XNWW91enAvmjINJ/stloPfcxoYcmPN4XrPljroaB4Edmw9UHIhxndAXARC3RZXPw8pbJ 2/Gr2nrc5hV77h0167EZ3TyrFiePitEtQCu3oq9WoIDRQcO0mHMxXi0QLOhCWMQ+TLfc G0jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772592; x=1702377392; 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=KjKEFhPSgLN5vGtDlHZQvN1ZMYBQW2UNIHEU4iW11KA=; b=n218nLU+rR9oUC53vSsrBVJwba8wnCW7yOHoYsJKky1BKOkig9Y3IcJ00YW03q7kS+ qdvCBLFdihov7L5uVDRh+jBKbMsAxmF4B5nogmGlrPP70ULj6O3cCxLvkCa7oeTJ2q3H +esegFwea293nZn1CD0QdFPPTU8+Y2KxSQ6snqsP3JWLC+kfkEbACsndIdk7tUkOr105 I9xYluJWp0k83bQZXjbYNuubTiZ74bT6wXc5eIESs7Q7QMregH/UviwWFI39ZxEVSdJE HrdFkt+gY2zI2rcdYJ0tkIWVDo7VUroNYV/4WPhDFRR6r42e5Yu6iOpzj7+yL4q+kEMx 3Q8Q== X-Gm-Message-State: AOJu0YyyZBbC+PfwACfyK/SV+X42tbnuXRyLO2KzDtzPp8YVHvcfnaX4 NHxmByXMngls4JDS8mhtlO4= X-Google-Smtp-Source: AGHT+IEV4/NEvKyiG2pISjXXhGEzBDyRRwcjqLkOq0cFAE1HY0eO+MjW4de0kYE72+xi26ZTN01x/w== X-Received: by 2002:a05:651c:85:b0:2ca:30a:8390 with SMTP id 5-20020a05651c008500b002ca030a8390mr1586235ljq.85.1701772592265; Tue, 05 Dec 2023 02:36:32 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id a21-20020a05651c031500b002c9e9c29670sm1153531ljp.47.2023.12.05.02.36.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:31 -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 , Maxime Coquelin Subject: [PATCH net-next 16/16] net: stmmac: Add externally detected DW XPCS support Date: Tue, 5 Dec 2023 13:35:37 +0300 Message-ID: <20231205103559.9605-17-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 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Serge Semin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" It's possible to have the DW XPCS device accessible over an external bus (external MDIO or DW XPCS management interface). Thus it will be futile to try to detect the device on the local SMA interface. Besides such platform setup isn't supported by the STMMAC driver anyway since the stmmac_mdio_bus_data instance might not be created and even if it is there is no code path which would set the stmmac_mdio_bus_data.has_xpcs flag thus activating the XPCS device setup. So in order to solve the denoted problem a pretty much standard approach is implemented: DT "pcs-handle" property is used to get the phandle referencing the DT-node describing the DW XPCS device; device node will be parsed by the xpcs_create_bynode() method implemented in the DW XPCS driver in a way as it's done for PHY-node; the node is used to find the MDIO-device instance, which in its turn will be used to create the XPCS descriptor. Note as a nice side effect of the provided change the conditional stmmac_xpcs_setup() method execution can be converted to the conditional statements implemented in the function itself. Thus the stmmac_open() will turn to look a bit simpler meanwhile stmmac_xpcs_setup() will provide the optional XPCS device semantic. Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++--- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 34 ++++++++++++------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 379552240ac9..a33ba00d091d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7604,11 +7604,9 @@ int stmmac_dvr_probe(struct device *device, if (priv->plat->speed_mode_2500) priv->plat->speed_mode_2500(ndev, priv->plat->bsp_priv); - if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { - ret = stmmac_xpcs_setup(ndev); - if (ret) - goto error_xpcs_setup; - } + ret = stmmac_xpcs_setup(ndev); + if (ret) + goto error_xpcs_setup; ret = stmmac_phy_setup(priv); if (ret) { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 101fa50c3c96..b906be363b61 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -499,25 +499,33 @@ int stmmac_xpcs_setup(struct net_device *ndev) { struct stmmac_priv *priv; struct dw_xpcs *xpcs; - int mode, addr; + int ret, mode, addr; priv = netdev_priv(ndev); mode = priv->plat->phy_interface; - /* Try to probe the XPCS by scanning all addresses. */ - for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - xpcs = xpcs_create_byaddr(priv->mii, addr, mode); - if (IS_ERR(xpcs)) - continue; - - priv->hw->xpcs = xpcs; - break; + /* If PCS-node is specified use it to create the XPCS descriptor */ + if (fwnode_property_present(priv->plat->port_node, "pcs-handle")) { + xpcs = xpcs_create_bynode(priv->plat->port_node, mode); + ret = PTR_ERR_OR_ZERO(xpcs); + } else if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { + /* Try to probe the XPCS by scanning all addresses */ + for (ret = -ENODEV, addr = 0; addr < PHY_MAX_ADDR; addr++) { + xpcs = xpcs_create_byaddr(priv->mii, addr, mode); + if (IS_ERR(xpcs)) + continue; + + ret = 0; + break; + } + } else { + return 0; } - if (!priv->hw->xpcs) { - dev_warn(priv->device, "No xPCS found\n"); - return -ENODEV; - } + if (ret) + return dev_err_probe(priv->device, ret, "No xPCS found\n"); + + priv->hw->xpcs = xpcs; return 0; }