From patchwork Tue Feb 27 07:51:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Woudstra X-Patchwork-Id: 13573316 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E075054BCB for ; Tue, 27 Feb 2024 07:52:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709020335; cv=none; b=Tmlc+MNh2c7cX0Ny2IqXstV6d5h31vRoHPysDta6qiMHToQq4p+YpCKleZHlV5fxVP6e6KbvyK5nzPUrNs34QTpBoz1BhSY30eXOZ7dil3i8ATq3prCvBLmwv50pgBqYTMp6+Ew/9Yx4+p3JyxatPPQNPMAJEFA99wDiVgR40tw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709020335; c=relaxed/simple; bh=D9d2gLGV+H9Dx1o5hWwuRB09liSlDPYfHq5pJrxtpAg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fqeofVW+hyPFqBwmQsuYhu2BxO0/CmETVI/cW93wmaJehebKtSgg72Xi5i2wFF5sc+puxItSXr688CSzXGouMeKdwaunBNZpgt38hF7rnHkKW5UIh/o+J0x7C9QPThPTw8m1jQBqFfSZ6SAUpKQAdlTQx5XWmzKdr3+l5TP2hqk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bdZUkPJ5; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bdZUkPJ5" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a3e891b5e4eso472257166b.0 for ; Mon, 26 Feb 2024 23:52:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709020332; x=1709625132; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xm73J2e9NjYnil3Gq+K1miusdQf03+KpV2uG6yda8Rg=; b=bdZUkPJ5FEzLLD3yC/n8M6/oy1hC3Hrg0fGRdD+FZbKrJ0L+fTfRsUa+zsqlrBAmKg i6+zENcOLH6GFuKI51W84UjB5jtZgVnJjCtI/PUz/evuv4NKCsFw60RLU/Bo1afB3wsd sw2YYOzEWaR4AwVIkO4+oJekccXTkLpcqXtmRtn3iWUHszP0REZXmf4qWTvMKXPPHraG Qwtpa84TyP4RR/H/GuyKte5fngSC0jK3jkct/v4YaF1WYoekEIzXOozDJEoLRn4srnyU xfO9+fIpDiFS5LYtKiHlfXCNkz0yuhLOv0PUCW+abM5aRbyVaBjmHpawqUvaPpvt4pEq Dh0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709020332; x=1709625132; 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=Xm73J2e9NjYnil3Gq+K1miusdQf03+KpV2uG6yda8Rg=; b=U9L39blT7KXByfASMtyAUA1PyUney/M6gqdtQ2xO5m1FwxdUsfU5P/+UE8s6YTqDji ip0dglvoL/Tdka1WUbRgGXxGw+m4l3hGAH05PGC8q79TOLmtzVQ2NvTOl2K7eK26yIB9 KZS4jNSQzwNF8AcOonUZQQvmU0uoG8wuEsb9yigKkWeq91AhCcfy/KF99ISeiaR4fj0A IqL7eExjHimE5kvXEKm//aW+ObRmnyEINLTvtRXnhalv+GCJexx+oqbIq30FRbGIRGbi lLySYlJHCOKwbpS0nFeG3gAzMOZruEqq4uhP61JMvfhobPVd1Es65Y0hUQYIjKJJzquK 7HyQ== X-Gm-Message-State: AOJu0YwAMR7d4wmJUNfIjPR1BK3MBYsHGk0sWy9FJTJ37T3bvn76WL2W DqEX5TnwHcOTbBmHdKZJxZoeB7rzHIpBPvmzsLjmle6Gl9yoLIpq X-Google-Smtp-Source: AGHT+IGySedehGx7O7YS1LEWj1oupS64QZkkUgSPZbTM+r4vJ6XI7128IAn1YljMgObnz7VDIBFjSA== X-Received: by 2002:a17:906:135b:b0:a40:2998:567c with SMTP id x27-20020a170906135b00b00a402998567cmr5697310ejb.41.1709020332064; Mon, 26 Feb 2024 23:52:12 -0800 (PST) Received: from corebook.localdomain (2001-1c00-020d-1300-1b1c-4449-176a-89ea.cable.dynamic.v6.ziggo.nl. [2001:1c00:20d:1300:1b1c:4449:176a:89ea]) by smtp.gmail.com with ESMTPSA id un6-20020a170907cb8600b00a3f0dbdf106sm496460ejc.105.2024.02.26.23.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 23:52:11 -0800 (PST) From: Eric Woudstra To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Marek_Beh=C3=BAn?= , "Frank Wunderlich" , Daniel Golle Cc: netdev@vger.kernel.org, Alexander Couzens , Eric Woudstra Subject: [PATCH RFC net-next 1/6] net: phy: realtek: configure SerDes mode for rtl822x/8251b PHYs Date: Tue, 27 Feb 2024 08:51:46 +0100 Message-ID: <20240227075151.793496-2-ericwouds@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240227075151.793496-1-ericwouds@gmail.com> References: <20240227075151.793496-1-ericwouds@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Alexander Couzens The rtl822x series and rtl8251b support switching SerDes mode between 2500base-x and sgmii based on the negotiated copper speed. Configure this switching mode according to SerDes modes supported by host. Signed-off-by: Alexander Couzens [ refactored, dropped HiSGMII mode and changed commit message ] Signed-off-by: Marek Behún [ changed rtl822x_update_interface() to use vendor register ] Signed-off-by: Eric Woudstra --- drivers/net/phy/realtek.c | 96 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 1fa70427b2a2..67cffe9b7d5d 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -54,6 +54,16 @@ RTL8201F_ISR_LINK) #define RTL8201F_IER 0x13 +#define RTL822X_VND1_SERDES_OPTION 0x697a +#define RTL822X_VND1_SERDES_OPTION_MODE_MASK GENMASK(5, 0) +#define RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII 0 +#define RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX 2 + +#define RTL822X_VND1_SERDES_CTRL3 0x7580 +#define RTL822X_VND1_SERDES_CTRL3_MODE_MASK GENMASK(5, 0) +#define RTL822X_VND1_SERDES_CTRL3_MODE_SGMII 0x02 +#define RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX 0x16 + #define RTL8366RB_POWER_SAVE 0x15 #define RTL8366RB_POWER_SAVE_ON BIT(12) @@ -659,6 +669,60 @@ static int rtl822x_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, return ret; } +static int rtl822x_config_init(struct phy_device *phydev) +{ + bool has_2500, has_sgmii; + u16 mode; + int ret; + + has_2500 = test_bit(PHY_INTERFACE_MODE_2500BASEX, + phydev->host_interfaces) || + phydev->interface == PHY_INTERFACE_MODE_2500BASEX; + + has_sgmii = test_bit(PHY_INTERFACE_MODE_SGMII, + phydev->host_interfaces) || + phydev->interface == PHY_INTERFACE_MODE_SGMII; + + if (!has_2500 && !has_sgmii) + return 0; + + /* fill in possible interfaces */ + __assign_bit(PHY_INTERFACE_MODE_2500BASEX, phydev->possible_interfaces, + has_2500); + __assign_bit(PHY_INTERFACE_MODE_SGMII, phydev->possible_interfaces, + has_sgmii); + + /* determine SerDes option mode */ + if (has_2500 && !has_sgmii) + mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX; + else + mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII; + + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x75f3, 0); + if (ret < 0) + return ret; + + ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND1, + RTL822X_VND1_SERDES_OPTION, + RTL822X_VND1_SERDES_OPTION_MODE_MASK, + mode); + if (ret < 0) + return ret; + + /* the following 3 writes into SerDes control are needed for 2500base-x + * mode to work properly + */ + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6a04, 0x0503); + if (ret < 0) + return ret; + + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f10, 0xd455); + if (ret < 0) + return ret; + + return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020); +} + static int rtl822x_get_features(struct phy_device *phydev) { int val; @@ -695,6 +759,25 @@ static int rtl822x_config_aneg(struct phy_device *phydev) return __genphy_config_aneg(phydev, ret); } +static void rtl822x_update_interface(struct phy_device *phydev) +{ + int val; + + /* Change interface according to serdes mode */ + val = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_CTRL3); + if (val < 0) + return; + + switch (val & RTL822X_VND1_SERDES_CTRL3_MODE_MASK) { + case RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX: + phydev->interface = PHY_INTERFACE_MODE_2500BASEX; + break; + case RTL822X_VND1_SERDES_CTRL3_MODE_SGMII: + phydev->interface = PHY_INTERFACE_MODE_SGMII; + break; + } +} + static int rtl822x_read_status(struct phy_device *phydev) { int ret; @@ -709,11 +792,13 @@ static int rtl822x_read_status(struct phy_device *phydev) lpadv); } - ret = genphy_read_status(phydev); + ret = rtlgen_read_status(phydev); if (ret < 0) return ret; - return rtlgen_get_speed(phydev); + rtl822x_update_interface(phydev); + + return 0; } static bool rtlgen_supports_2_5gbps(struct phy_device *phydev) @@ -976,6 +1061,7 @@ static struct phy_driver realtek_drvs[] = { .match_phy_device = rtl8226_match_phy_device, .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, + .config_init = rtl822x_config_init, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -988,6 +1074,7 @@ static struct phy_driver realtek_drvs[] = { .name = "RTL8226B_RTL8221B 2.5Gbps PHY", .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, + .config_init = rtl822x_config_init, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1000,6 +1087,7 @@ static struct phy_driver realtek_drvs[] = { .name = "RTL8226-CG 2.5Gbps PHY", .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, + .config_init = rtl822x_config_init, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1010,6 +1098,7 @@ static struct phy_driver realtek_drvs[] = { .name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY", .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, + .config_init = rtl822x_config_init, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1019,6 +1108,7 @@ static struct phy_driver realtek_drvs[] = { PHY_ID_MATCH_EXACT(0x001cc849), .name = "RTL8221B-VB-CG 2.5Gbps PHY", .get_features = rtl822x_get_features, + .config_init = rtl822x_config_init, .config_aneg = rtl822x_config_aneg, .read_status = rtl822x_read_status, .suspend = genphy_suspend, @@ -1030,6 +1120,7 @@ static struct phy_driver realtek_drvs[] = { .name = "RTL8221B-VM-CG 2.5Gbps PHY", .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, + .config_init = rtl822x_config_init, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1040,6 +1131,7 @@ static struct phy_driver realtek_drvs[] = { .name = "RTL8251B 5Gbps PHY", .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, + .config_init = rtl822x_config_init, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, From patchwork Tue Feb 27 07:51:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Woudstra X-Patchwork-Id: 13573317 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8206455E64 for ; Tue, 27 Feb 2024 07:52:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709020337; cv=none; b=pKEpZSrd5zEgiUsESb+GB9Ri/SJ7szUkXSFFFjZaHU6dxzAoimZWA6OUY5jMtqPHGEI0yKObE7L/Vxv6KXrELlqx6e8JOyHIfYzXAnJGv81Xc0eVTrwCpAd3ReEzEzQ2iO2yOKrESP3ppWX/zftytj1lhp4Cex7C8Zlui61oZyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709020337; c=relaxed/simple; bh=WXBN17EZgGUH6eWcK8F7nRi3ldI0G96Q5Mq+ECjAY6Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cbvYcGz/9R6CN4XwYPLBn5WJo1HH8+SPn2XgeA2Mrz6g9CoCm2AdHB+Z7yXmgyMdl5hLp2CIwfwWfxbA63K/mwJoBRVWjzhSbBQpvyCSCcBEWVsJOvExitagPsNhK840/KxiUoex0iXISMf87OrMPm3x/Wc5nmc12rDBt6M8nA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UuMj8elG; arc=none smtp.client-ip=209.85.208.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UuMj8elG" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2d1094b5568so44036871fa.1 for ; Mon, 26 Feb 2024 23:52:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709020333; x=1709625133; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lV0JEslqQX7lSZDJO/0feKiEgQjMhrNlSGIZWQa9fZ4=; b=UuMj8elGNxUsQsVaNK0qel2FzApQYJUVaBDLOW34vatCZCnPTmuA+z/oqd1gE0dgx7 yn5JBdXoFApyXsX5FzXhEHQ2kJt8pWI5y1gMFdvvpq8MPL9O43xHkOB8wfzjL0n/8SAH HO3b8v11o2athbHTtNdzprOzTXmZBeQzst9RTVFAm+5KcfgjYyfl5kSP9X1Dj9kKSUn4 eFMe7Odc91m3+mopMbUDSV8ogHxsELFQrzIka/wvN8/+jcvwZ4cT9/IqI428FjWaZ4aV CRojfqlT82sOBJ5N5mxggBzbEKhQePTy16Wpxf6IBcesK2lN9x4Ih+thR6RyFn+HLkZb NU1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709020333; x=1709625133; 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=lV0JEslqQX7lSZDJO/0feKiEgQjMhrNlSGIZWQa9fZ4=; b=ScOaphzBjuvIaUqY8Nd9DPEa/8fjKUN5r9ZDYD4tc1eXxnAvyltcs75Q8EFGUYCBPA EFogu99fBkgYwNIx2FV2/5XwwCHWfEUqbhAHJk3UiScPe/nu4hrVh+ESPLn16NUCFwRo 4rX0eH6nWAlQLuvUuDrRqKmYX+SY9g7FQDPOWnOwVYn8Frb0E347seCy4XxvpwDbibLN lEfMTdy8bBJ89Svc1thMr4vJA2F5+8cTYwnzce7HvfV004c0u5DbTjZvhl2/ILdJkJUi JddttZIEiyK4MfjQNmGwaSOwYOs3BOoaB/5sqtJyi7wtp0mTicnQgUDLX/HxaVGBMn0J I7tA== X-Gm-Message-State: AOJu0Yzhti7otdTCqQTvZg+r2fsCZrwubeV3eNoHZSdca/rgpOiOgGGd bZJ9UrG0sQrZtcIuIcWBA4md/hO9NGTBXGMksDZQIECeB+EVO+6b X-Google-Smtp-Source: AGHT+IGBssLLT1LntYrPHQTqNHja27lsZLZtzwkitpKXRXEpqu4qgDnePiH5s556DLr9PCTdB2tPVg== X-Received: by 2002:a05:6512:3c97:b0:513:ece:8f7d with SMTP id h23-20020a0565123c9700b005130ece8f7dmr554295lfv.9.1709020333380; Mon, 26 Feb 2024 23:52:13 -0800 (PST) Received: from corebook.localdomain (2001-1c00-020d-1300-1b1c-4449-176a-89ea.cable.dynamic.v6.ziggo.nl. [2001:1c00:20d:1300:1b1c:4449:176a:89ea]) by smtp.gmail.com with ESMTPSA id un6-20020a170907cb8600b00a3f0dbdf106sm496460ejc.105.2024.02.26.23.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 23:52:13 -0800 (PST) From: Eric Woudstra To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Marek_Beh=C3=BAn?= , "Frank Wunderlich" , Daniel Golle Cc: netdev@vger.kernel.org, Eric Woudstra Subject: [PATCH RFC net-next 2/6] net: phy: realtek: add get_rate_matching() for rtl822x/8251b PHYs Date: Tue, 27 Feb 2024 08:51:47 +0100 Message-ID: <20240227075151.793496-3-ericwouds@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240227075151.793496-1-ericwouds@gmail.com> References: <20240227075151.793496-1-ericwouds@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Uses vendor register to determine if SerDes is setup in rate-matching mode. Rate-matching only supported when SerDes is set to 2500base-x. Signed-off-by: Eric Woudstra Reviewed-by: Russell King (Oracle) --- drivers/net/phy/realtek.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 67cffe9b7d5d..75c4f3e14371 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -723,6 +723,28 @@ static int rtl822x_config_init(struct phy_device *phydev) return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020); } +static int rtl822x_get_rate_matching(struct phy_device *phydev, + phy_interface_t iface) +{ + int val; + + /* Only rate matching at 2500base-x */ + if (iface != PHY_INTERFACE_MODE_2500BASEX) + return RATE_MATCH_NONE; + + val = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_OPTION); + if (val < 0) + return val; + + switch (val & RTL822X_VND1_SERDES_OPTION_MODE_MASK) { + case RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX: + return RATE_MATCH_PAUSE; + /* case RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII: */ + default: + return RATE_MATCH_NONE; + } +} + static int rtl822x_get_features(struct phy_device *phydev) { int val; @@ -1062,6 +1084,7 @@ static struct phy_driver realtek_drvs[] = { .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .config_init = rtl822x_config_init, + .get_rate_matching = rtl822x_get_rate_matching, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1075,6 +1098,7 @@ static struct phy_driver realtek_drvs[] = { .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .config_init = rtl822x_config_init, + .get_rate_matching = rtl822x_get_rate_matching, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1088,6 +1112,7 @@ static struct phy_driver realtek_drvs[] = { .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .config_init = rtl822x_config_init, + .get_rate_matching = rtl822x_get_rate_matching, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1099,6 +1124,7 @@ static struct phy_driver realtek_drvs[] = { .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .config_init = rtl822x_config_init, + .get_rate_matching = rtl822x_get_rate_matching, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1109,6 +1135,7 @@ static struct phy_driver realtek_drvs[] = { .name = "RTL8221B-VB-CG 2.5Gbps PHY", .get_features = rtl822x_get_features, .config_init = rtl822x_config_init, + .get_rate_matching = rtl822x_get_rate_matching, .config_aneg = rtl822x_config_aneg, .read_status = rtl822x_read_status, .suspend = genphy_suspend, @@ -1121,6 +1148,7 @@ static struct phy_driver realtek_drvs[] = { .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .config_init = rtl822x_config_init, + .get_rate_matching = rtl822x_get_rate_matching, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1132,6 +1160,7 @@ static struct phy_driver realtek_drvs[] = { .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .config_init = rtl822x_config_init, + .get_rate_matching = rtl822x_get_rate_matching, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, From patchwork Tue Feb 27 07:51:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Woudstra X-Patchwork-Id: 13573318 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BF6E54F94 for ; Tue, 27 Feb 2024 07:52:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709020337; cv=none; b=P0/GlOpCHpdFHdW8Wq2rQe0nUTBIKvQljuHepna7RHBU0qh0MCiOQGPCEbJ5aWEGBssUnEJnn4mTpC2FaeffQEPTQCO1Otc/SBuoDeMEJQTrscJMUqvWntg7bmKPjDSI+M5j9DGVRljuU7uUws3209R2ACo0Aw/QSM03Kzmyi68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709020337; c=relaxed/simple; bh=IbBUCH9a8BhHyPlprzScPjuJgo74gSBae89ejOzHT9E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=POuM/PollaOYDSMQTq32oraCiHMpBH1lqGIF5e5oBK6h76xXVlAJZ4gIQ99RVQfMuUbQBb+i+M1EYwJm++C/ta7PR/oRfgmtzxgzYruYx9luJh9MGz4qABzWCHNkakyLlkw5YL/7ZJFNvEoiP3Xw5n5GKrLzrtdVamv9hu94ArU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=j/yhQV7f; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j/yhQV7f" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a3e5d82ad86so547106566b.2 for ; Mon, 26 Feb 2024 23:52:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709020334; x=1709625134; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7gHVelXeXSgnMtA/zAd3Bprx2pS/mZvAhKsCp7WWu54=; b=j/yhQV7f1dve81++gxMeBKaVjxfqpksW6KuU4IDb3Vgc3rGvNsH4QmRjZcOESwpj4R V5bcyF/Aad+M4JsE6exnOKuKqEgoanOlw9yUUPHPNddmcFSEXeJVjfyDwfD29FTpsi5A TfsGvv2a03yFuJa5lpsyrHu7daAuVbalI3V5LiRewXMndnL8d5Vrirjmd2Mz1MHZQGGI JoWTCtNmP6DmcJUHjp1vB3zYETLZ/lILXduJdh9JHhuABAzDos8e4TQOuY9LBHBfXUN7 m4MhFo5wv5I4T3Fffjdi/BVqIGBcM3Woq2OlHYGdyuMqmmk8yigrFWaJDSoU7otX7nn4 Ig7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709020334; x=1709625134; 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=7gHVelXeXSgnMtA/zAd3Bprx2pS/mZvAhKsCp7WWu54=; b=duW3Kc70HGdsxUPlQtxOOxwYCCGbPP6ES1TBKmoSQ7307hKbO+bj42OdbBzGFJaXFD GI2row/NJUyykZ3exQQS949VSRuIInBXOv9Om9cXFWVIEmcroCVuyJLDozmYLfjOpdxj C/6HZV6E6lp4bzrOyKv0p9HbY4mdIeRXsGBY7C0nwkKhxYMkVJDNReEHdx77jkJFBNrg KA6eVvIWfRdkHicG5tYRN0OiA6Xq0IXAM2tvJhaEqH080rtwR3Fxoeos4Jp0LOpQ9awy cnbYGr6u7Um+DWq6yrO8TTwI/VuzU+3QVqp3StjwDr/QIAaPNfoZbZygHT+esG6AghYM OWng== X-Gm-Message-State: AOJu0YyRcQwKZMf/pLJ30vfOt39gqdEBJrizhYKHOapJu7dXUVtFTdFh tniGbLSTV3961CNGC/HpdTi4emFgxL1aURHn5Vkd+aXDb1447kzg X-Google-Smtp-Source: AGHT+IHyJolNG79mN40aL7R9k9Wt+E1cnJqmdaFk0zQNRdGM9cGqWbisOiZaFtcu8eqtYB9Zpai1Cw== X-Received: by 2002:a17:906:a992:b0:a3e:eebe:7a2f with SMTP id jr18-20020a170906a99200b00a3eeebe7a2fmr6195640ejb.35.1709020334427; Mon, 26 Feb 2024 23:52:14 -0800 (PST) Received: from corebook.localdomain (2001-1c00-020d-1300-1b1c-4449-176a-89ea.cable.dynamic.v6.ziggo.nl. [2001:1c00:20d:1300:1b1c:4449:176a:89ea]) by smtp.gmail.com with ESMTPSA id un6-20020a170907cb8600b00a3f0dbdf106sm496460ejc.105.2024.02.26.23.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 23:52:14 -0800 (PST) From: Eric Woudstra To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Marek_Beh=C3=BAn?= , "Frank Wunderlich" , Daniel Golle Cc: netdev@vger.kernel.org, Eric Woudstra Subject: [PATCH RFC net-next 3/6] net: phy: realtek: rtlgen_get_speed(): Pass register value as argument Date: Tue, 27 Feb 2024 08:51:48 +0100 Message-ID: <20240227075151.793496-4-ericwouds@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240227075151.793496-1-ericwouds@gmail.com> References: <20240227075151.793496-1-ericwouds@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The value of the register to determine the speed, is retrieved differently when using Clause 45 only. To use the rtlgen_get_speed() function in this case, pass the value of the register as argument to rtlgen_get_speed(). The function would then always return 0, so change it to void. Signed-off-by: Eric Woudstra Reviewed-by: Russell King (Oracle) --- drivers/net/phy/realtek.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 75c4f3e14371..e7c42ec18971 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -541,16 +541,10 @@ static int rtl8366rb_config_init(struct phy_device *phydev) } /* get actual speed to cover the downshift case */ -static int rtlgen_get_speed(struct phy_device *phydev) +static void rtlgen_get_speed(struct phy_device *phydev, int val) { - int val; - if (!phydev->link) - return 0; - - val = phy_read_paged(phydev, 0xa43, 0x12); - if (val < 0) - return val; + return; switch (val & RTLGEN_SPEED_MASK) { case 0x0000: @@ -574,19 +568,23 @@ static int rtlgen_get_speed(struct phy_device *phydev) default: break; } - - return 0; } static int rtlgen_read_status(struct phy_device *phydev) { - int ret; + int ret, val; ret = genphy_read_status(phydev); if (ret < 0) return ret; - return rtlgen_get_speed(phydev); + val = phy_read_paged(phydev, 0xa43, 0x12); + if (val < 0) + return val; + + rtlgen_get_speed(phydev, val); + + return 0; } static int rtlgen_read_mmd(struct phy_device *phydev, int devnum, u16 regnum) From patchwork Tue Feb 27 07:51:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Woudstra X-Patchwork-Id: 13573319 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAEC556441 for ; Tue, 27 Feb 2024 07:52:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709020338; cv=none; b=RxmCXkVLfFPRgePvUCrkB/ejpAEPzXsrUndZMftf0kByBM09AcLGv83SUI9v63zxo/Z3GT51SOci09gUAW+KeNfASO8DKIE1k37g6tpAdYczQGYYOwQvsn7H01Kt2bPa+Thk1jKHXaWsAUvkJZYaUU9nqQ70uwVPzV0XBh0DgrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709020338; c=relaxed/simple; bh=VIGHiCdx7SNXX7Nu6+QrVq5iUlV4cziKIYKF/N3cJvw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s7mYJ0WAP1yChPHAP2AVqaJmuXZJKAMU5D3VLKUTpSeLXaPBYKpG+KrQuFu2bu2v9EtjIoSNx1o/IHsk1EIoKYCnL8sW4wlTKXuYy9TzwFfCj7hT+fLXjnIRGcW/LL4x1niL7U+EefkmsSag5YBxbBIRyllTRbFnQ3HRmAlvOQ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DWLrJQcg; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DWLrJQcg" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-56647babfe6so152232a12.3 for ; Mon, 26 Feb 2024 23:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709020335; x=1709625135; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qIaNztM01O7/22vlhTB8ChN0VbTm6XWSFtGnNH9aomg=; b=DWLrJQcgFQTaf3+u8Cbp7UlMz/hjKadI6+gSGhIB1sCuJy/s+AQE4dsS6Ci/Sz74Il wj+wf28PoHatBKgKsHA12ZK1B/HjwPw5RT1vVc7Z2I4VXVpeiTcBl3H5MZYXGCnHCNDs qrGaJTl+y6bwkRolDzq2VQvuI/iqRVFNVXNtlBSSlU3cKCYSI4hO1RjvP7NdDSk1QS7p 9kHutoDHb6uS0Ug1uVdl8vGp/jjnpfPI2ESIsRUI+E2ik3qfgE09mkf9JZBgEAvjo+ts 6TWdnwxByltYeYjrvyJMN/Hq+Dais2JXCQ+mWry234GOHMnc05YeSNcvXzS8Z7GMFSwI B33w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709020335; x=1709625135; 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=qIaNztM01O7/22vlhTB8ChN0VbTm6XWSFtGnNH9aomg=; b=lMCz8gdkjsqQ437PS95p5dm9STJXREvv/zjrKlNzk+nn0gOqy3YDmXfx8aZzOReA8a 1yFEP/0U0fviIAomgmyrXKnJEjzFQOdJCvkOJL4U9m3y/Ra8AzGIT8FGQ13arb1prAAu Wc28dvnYDuZkJyb9h+7n0aZNy9zlPSp39GOzEh3pvGXHaRPPvk+POSAIQPsI1FQ2so5d qcm3cYHvRLDcGEwUaZ/yurux36WmyOnxHsAN4cTveL5X4nZhRrR+T5jZ2qGTrr+vj13q A1gOHm9eUZwEilNjf7r0LcS6bE6EJ30DkMlxald8yajJxbC9Z96Wzx4G/kSRmtpic2zG srZw== X-Gm-Message-State: AOJu0Yy2lTzF/t/ZMTIVXHSR/OXPhOYPM3Lnl26JY79SxuUkbtQyplgr mjF2NMvSmvclhXwsnUX8wCmew8PCHZNLSlZdiZ+l0ORwnsofxWnf X-Google-Smtp-Source: AGHT+IGQZVUGLbZkpfHwRLGDAFErmAypIDa7ydK5bKtdUMU3jeyo0c0p6qrfj+3uiquexg+aPLEkbA== X-Received: by 2002:a17:906:3685:b0:a3f:ac54:eb68 with SMTP id a5-20020a170906368500b00a3fac54eb68mr5946385ejc.69.1709020335285; Mon, 26 Feb 2024 23:52:15 -0800 (PST) Received: from corebook.localdomain (2001-1c00-020d-1300-1b1c-4449-176a-89ea.cable.dynamic.v6.ziggo.nl. [2001:1c00:20d:1300:1b1c:4449:176a:89ea]) by smtp.gmail.com with ESMTPSA id un6-20020a170907cb8600b00a3f0dbdf106sm496460ejc.105.2024.02.26.23.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 23:52:14 -0800 (PST) From: Eric Woudstra To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Marek_Beh=C3=BAn?= , "Frank Wunderlich" , Daniel Golle Cc: netdev@vger.kernel.org, Eric Woudstra Subject: [PATCH RFC net-next 4/6] net: phy: realtek: Add driver instances for rtl8221b/8251b via Clause 45 Date: Tue, 27 Feb 2024 08:51:49 +0100 Message-ID: <20240227075151.793496-5-ericwouds@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240227075151.793496-1-ericwouds@gmail.com> References: <20240227075151.793496-1-ericwouds@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Add driver instances for Clause 45 communication with the RTL8221B/8251B. This is used by Clause 45 only accessible PHY's on several sfp modules, which are using RollBall protocol. Signed-off-by: Eric Woudstra Reviewed-by: Russell King (Oracle) --- drivers/net/phy/realtek.c | 171 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 165 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index e7c42ec18971..e7964ce158c3 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -64,6 +64,15 @@ #define RTL822X_VND1_SERDES_CTRL3_MODE_SGMII 0x02 #define RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX 0x16 +/* RTL822X_VND2_XXXXX registers are only accessible when phydev->is_c45 + * is set, they cannot be accessed by C45-over-C22. + */ +#define RTL822X_VND2_GBCR 0xa412 + +#define RTL822X_VND2_GANLPAR 0xa414 + +#define RTL822X_VND2_PHYSR 0xa434 + #define RTL8366RB_POWER_SAVE 0x15 #define RTL8366RB_POWER_SAVE_ON BIT(12) @@ -74,6 +83,9 @@ #define RTL_GENERIC_PHYID 0x001cc800 #define RTL_8211FVD_PHYID 0x001cc878 +#define RTL_8221B_VB_CG 0x001cc849 +#define RTL_8221B_VN_CG 0x001cc84a +#define RTL_8251B 0x001cc862 MODULE_DESCRIPTION("Realtek PHY driver"); MODULE_AUTHOR("Johnson Leung"); @@ -821,6 +833,76 @@ static int rtl822x_read_status(struct phy_device *phydev) return 0; } +static int rtl822x_c45_get_features(struct phy_device *phydev) +{ + linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT, + phydev->supported); + linkmode_set_bit(ETHTOOL_LINK_MODE_MII_BIT, + phydev->supported); + + return genphy_c45_pma_read_abilities(phydev); +} + +static int rtl822x_c45_config_aneg(struct phy_device *phydev) +{ + bool changed = false; + int ret, val; + + if (phydev->autoneg == AUTONEG_DISABLE) + return genphy_c45_pma_setup_forced(phydev); + + ret = genphy_c45_an_config_aneg(phydev); + if (ret < 0) + return ret; + if (ret > 0) + changed = true; + + val = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising); + + /* Vendor register as C45 has no standardized support for 1000BaseT */ + ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, RTL822X_VND2_GBCR, + ADVERTISE_1000FULL, val); + if (ret < 0) + return ret; + if (ret > 0) + changed = true; + + return genphy_c45_check_and_restart_aneg(phydev, changed); +} + +static int rtl822x_c45_read_status(struct phy_device *phydev) +{ + int ret, val; + + ret = genphy_c45_read_status(phydev); + if (ret < 0) + return ret; + + /* Vendor register as C45 has no standardized support for 1000BaseT */ + if (phydev->autoneg == AUTONEG_ENABLE) { + val = phy_read_mmd(phydev, MDIO_MMD_VEND2, + RTL822X_VND2_GANLPAR); + if (val < 0) + return val; + + mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val); + } + + if (!phydev->link) + return 0; + + /* Read actual speed from vendor register. */ + val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_PHYSR); + if (val < 0) + return val; + + rtlgen_get_speed(phydev, val); + + rtl822x_update_interface(phydev); + + return 0; +} + static bool rtlgen_supports_2_5gbps(struct phy_device *phydev) { int val; @@ -844,6 +926,44 @@ static int rtl8226_match_phy_device(struct phy_device *phydev) rtlgen_supports_2_5gbps(phydev); } +static int rtlgen_is_c45_match(struct phy_device *phydev, unsigned int id, bool is_c45) +{ + if (phydev->is_c45) + return is_c45 && (id == phydev->c45_ids.device_ids[1]); + else + return !is_c45 && (id == phydev->phy_id); +} + +static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev) +{ + return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false); +} + +static int rtl8221b_vb_cg_c45_match_phy_device(struct phy_device *phydev) +{ + return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true); +} + +static int rtl8221b_vn_cg_c22_match_phy_device(struct phy_device *phydev) +{ + return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, false); +} + +static int rtl8221b_vn_cg_c45_match_phy_device(struct phy_device *phydev) +{ + return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, true); +} + +static int rtl8251b_c22_match_phy_device(struct phy_device *phydev) +{ + return rtlgen_is_c45_match(phydev, RTL_8251B, false); +} + +static int rtl8251b_c45_match_phy_device(struct phy_device *phydev) +{ + return rtlgen_is_c45_match(phydev, RTL_8251B, true); +} + static int rtlgen_resume(struct phy_device *phydev) { int ret = genphy_resume(phydev); @@ -854,6 +974,15 @@ static int rtlgen_resume(struct phy_device *phydev) return ret; } +static int rtlgen_c45_resume(struct phy_device *phydev) +{ + int ret = genphy_c45_pma_resume(phydev); + + msleep(20); + + return ret; +} + static int rtl9000a_config_init(struct phy_device *phydev) { phydev->autoneg = AUTONEG_DISABLE; @@ -1129,8 +1258,8 @@ static struct phy_driver realtek_drvs[] = { .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, }, { - PHY_ID_MATCH_EXACT(0x001cc849), - .name = "RTL8221B-VB-CG 2.5Gbps PHY", + .match_phy_device = rtl8221b_vb_cg_c22_match_phy_device, + .name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)", .get_features = rtl822x_get_features, .config_init = rtl822x_config_init, .get_rate_matching = rtl822x_get_rate_matching, @@ -1141,8 +1270,18 @@ static struct phy_driver realtek_drvs[] = { .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, }, { - PHY_ID_MATCH_EXACT(0x001cc84a), - .name = "RTL8221B-VM-CG 2.5Gbps PHY", + .match_phy_device = rtl8221b_vb_cg_c45_match_phy_device, + .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)", + .config_init = rtl822x_config_init, + .get_rate_matching = rtl822x_get_rate_matching, + .get_features = rtl822x_c45_get_features, + .config_aneg = rtl822x_c45_config_aneg, + .read_status = rtl822x_c45_read_status, + .suspend = genphy_c45_pma_suspend, + .resume = rtlgen_c45_resume, + }, { + .match_phy_device = rtl8221b_vn_cg_c22_match_phy_device, + .name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)", .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .config_init = rtl822x_config_init, @@ -1153,8 +1292,18 @@ static struct phy_driver realtek_drvs[] = { .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, }, { - PHY_ID_MATCH_EXACT(0x001cc862), - .name = "RTL8251B 5Gbps PHY", + .match_phy_device = rtl8221b_vn_cg_c45_match_phy_device, + .name = "RTL8221B-VN-CG 2.5Gbps PHY (C45)", + .config_init = rtl822x_config_init, + .get_rate_matching = rtl822x_get_rate_matching, + .get_features = rtl822x_c45_get_features, + .config_aneg = rtl822x_c45_config_aneg, + .read_status = rtl822x_c45_read_status, + .suspend = genphy_c45_pma_suspend, + .resume = rtlgen_c45_resume, + }, { + .match_phy_device = rtl8251b_c22_match_phy_device, + .name = "RTL8251B 5Gbps PHY (C22)", .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .config_init = rtl822x_config_init, @@ -1164,6 +1313,16 @@ static struct phy_driver realtek_drvs[] = { .resume = rtlgen_resume, .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, + }, { + .match_phy_device = rtl8251b_c45_match_phy_device, + .name = "RTL8251B 5Gbps PHY (C45)", + .config_init = rtl822x_config_init, + .get_rate_matching = rtl822x_get_rate_matching, + .get_features = rtl822x_c45_get_features, + .config_aneg = rtl822x_c45_config_aneg, + .read_status = rtl822x_c45_read_status, + .suspend = genphy_c45_pma_suspend, + .resume = rtlgen_c45_resume, }, { PHY_ID_MATCH_EXACT(0x001cc961), .name = "RTL8366RB Gigabit Ethernet", From patchwork Tue Feb 27 07:51:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Woudstra X-Patchwork-Id: 13573320 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6E5F5645A for ; Tue, 27 Feb 2024 07:52:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709020339; cv=none; b=CdBjY2NJdJFw/TPxGAI6cDGSnYgwRbuG+p0FDArmTIdjNustwT1yjeEIiNg4gqU/q0f32s9Fu4fNOMMKIqHZxM1SBd5Fz+G2U2JEx8VvGcH9fpWdUxhLpmNN4uCbmG7fRsn//I+PnZ4X1y9znNHl9xrFUcbhDPnBKs17BuIDglk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709020339; c=relaxed/simple; bh=iNUVONiCgXWIdBbyX3aMxuHW1SaejZ9p096IqdLXhX4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a1MSBDJ30UvN6ocCkZezU1MSEyljGT21a7m71c9jdK1drD/Kuss0KBmtFElqK8e1SvhTYYlLBCH00STyA+GFtASwmcV9wt7/Uui3ust62Dpft2R0Xt8GJ4nkxXzClRmSZiHJ+ZjuwK5TdS0HCrOwHlQCzFDVUyFJ6Ql1+wSrWiA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bkLibyer; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bkLibyer" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a3e706f50beso492513066b.0 for ; Mon, 26 Feb 2024 23:52:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709020336; x=1709625136; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AcQFpI+Jx90bvTbBWSDvWvM5mR00vIVjwL1CQlQ/ueQ=; b=bkLibyer4b4vJ8XCFKeYkEXYZnAKjsqFXzGLlYrFdH8BABaFlFofcb4KSfODQyHPGk I7mIWV1cxwN+nSiUDg2qG1l/qiFP/bTA5zn0pJusGyCsgFa3N//imAAyvVwOF5Zfh5gk qwbxcoRfUBiw0tRZ3VoPe80VL1kpZTPtviTGLKhA4WDkCAD6JhUXbGK8brIRYwGTO9iF UKG2o7YSoZ0w3/LSWpYAsWqGYoa4kSTob/piLoXEVvHCxgeEoS0Cblr31mt69vf2FVt0 HD220W5uNS7eJi769MD3YJCO8HXDt9RgATCB42s/woResC4rUhsdJoOsocUfYa3o136f N8BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709020336; x=1709625136; 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=AcQFpI+Jx90bvTbBWSDvWvM5mR00vIVjwL1CQlQ/ueQ=; b=ATQtdY2hLZmx7ppK0RnI5F8RuaxFm4o78qqpj7vkqmijZ0wYtUmiuUAbwie9u4o3VY bUa/UqDZkO9MvlruNkInDRyxA304c6wQcjW4Av5jcI1Aha1v2P8Z+hQjvPbgiLZcCe+B a/qvOCut5lDTys7gZlwCAv270vKtBfuyj2P+Pfwuw+PmlBICbloaBNGMAqx9TUgXiq37 eJnyU1dKm7J26J2tQYeBFzhrXxJz26vef4w7iaZKODfv0e5qFTgcWnpDzjD5Feky88nq UzY3KjnsANpHgqqRKXq4ciZ12wqSiPmDG5Cie+5ux+yUIwipWZGmF3HtAtKimLKe1PNE 1n9Q== X-Gm-Message-State: AOJu0YwpT4lEtcwjhd+uN+DRjTBK0Go3jeqMcURzSnWlFRytEMX7i9uN awqUelXtBaTGWGTVm3l2OwZeHOz/LSAY36/sWPDSDGXLhHgSr/g7 X-Google-Smtp-Source: AGHT+IFYRiVJrhFvzYS9R5LqIoW+RmlX5z5Xg5r2eYBEJvkaZs1N7v7+ZzxGpNjGUDjR4Fs2IkWT5Q== X-Received: by 2002:a17:906:565a:b0:a3e:6a25:2603 with SMTP id v26-20020a170906565a00b00a3e6a252603mr6379614ejr.33.1709020336180; Mon, 26 Feb 2024 23:52:16 -0800 (PST) Received: from corebook.localdomain (2001-1c00-020d-1300-1b1c-4449-176a-89ea.cable.dynamic.v6.ziggo.nl. [2001:1c00:20d:1300:1b1c:4449:176a:89ea]) by smtp.gmail.com with ESMTPSA id un6-20020a170907cb8600b00a3f0dbdf106sm496460ejc.105.2024.02.26.23.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 23:52:15 -0800 (PST) From: Eric Woudstra To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Marek_Beh=C3=BAn?= , "Frank Wunderlich" , Daniel Golle Cc: netdev@vger.kernel.org, Eric Woudstra Subject: [PATCH RFC net-next 5/6] net: phy: sfp: Fixup for OEM SFP-2.5G-T module Date: Tue, 27 Feb 2024 08:51:50 +0100 Message-ID: <20240227075151.793496-6-ericwouds@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240227075151.793496-1-ericwouds@gmail.com> References: <20240227075151.793496-1-ericwouds@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Change from quirk to fixup for the OEM SFP-2.5G-T module. Implementing this fixup, the rtl8221b phy is attached and the quirk is no longer used. The module is re-branded to different brands, the one I have that applies to this patch is branded LuLeey. Signed-off-by: Eric Woudstra --- drivers/net/phy/sfp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index f75c9eb3958e..144feffe09f9 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -385,6 +385,13 @@ static void sfp_fixup_rollball(struct sfp *sfp) sfp->phy_t_retry = msecs_to_jiffies(1000); } +// For 2.5GBASE-T short-reach modules +static void sfp_fixup_oem_2_5g(struct sfp *sfp) +{ + sfp_fixup_rollball(sfp); + sfp->id.base.extended_cc = SFF8024_ECC_2_5GBASE_T; +} + static void sfp_fixup_fs_10gt(struct sfp *sfp) { sfp_fixup_10gbaset_30m(sfp); @@ -503,7 +510,7 @@ static const struct sfp_quirk sfp_quirks[] = { SFP_QUIRK_F("Walsun", "HXSX-ATRI-1", sfp_fixup_fs_10gt), SFP_QUIRK_F("OEM", "SFP-10G-T", sfp_fixup_rollball_cc), - SFP_QUIRK_M("OEM", "SFP-2.5G-T", sfp_quirk_oem_2_5g), + SFP_QUIRK_F("OEM", "SFP-2.5G-T", sfp_fixup_oem_2_5g), SFP_QUIRK_F("OEM", "RTSFP-10", sfp_fixup_rollball_cc), SFP_QUIRK_F("OEM", "RTSFP-10G", sfp_fixup_rollball_cc), SFP_QUIRK_F("Turris", "RTSFP-10", sfp_fixup_rollball), From patchwork Tue Feb 27 07:51:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Woudstra X-Patchwork-Id: 13573321 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3EF054FA4 for ; Tue, 27 Feb 2024 07:52:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709020340; cv=none; b=r9OwxeP2XcMHv/rurYcsOr8/IYHzMaPINneR9dK8L9qKVBjcCL85/asfDlOjMvvojJjNwmXwTfNFpr/wJyLyKtdrUBC+AtcLnivBN7dYnu0pvQp7intSK7GMkgJrNK8HqwGjAj/fyWW48kzvvBhJWs4TsX80EgxSRUGlsZP9lT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709020340; c=relaxed/simple; bh=biYd82PDEigmAvdh5G6NkcNTZbakF4ljEFl2XGnggjw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FEn9EaVD06yLohuVYnXGi4fHKvjfELrxnObVB3VPPRhuI67P6ydfT/NBKDJC836NjG0GL//hJPDe6YiyxuTe82f4Ah86VYY7OMSUj2pZ+Z1m2mxnYIjsGODpr6hucZ5PLxogqG+pUidJ0amy1K5o6ooQJyXI/AginxuCUDqWYVM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mUnQzSol; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mUnQzSol" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a3f5808b0dfso534744366b.1 for ; Mon, 26 Feb 2024 23:52:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709020337; x=1709625137; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a1p6UsSs+EQQxO64HZ57uYteqPXE6zBiSjX5gQ9IKv4=; b=mUnQzSolzOq19pbKfm1RWQog9Yoe6JACvRLKg+3DhH3B9WeoZW6LrF5uovxQZY8HHR KunCFIoCRB988ELu39xWzsebY34QIe7OgcTyM5SDtRD1WKvUOwy8sX9k8brJMEyhQAs5 BcqEauJb+ifZRBmmdNw81T2UmdSpinJfhpyrYiBFpQQu4VubeYNRpaVLXd1VfAVbSt/u 8sI0KY7hxkgoT9wpGapRwORnlthQh+w2vp9QUWn/7sB9ve6b1Mn2SsbAVNzVQQuSyhif PKOT0xfqYFJPxsBglfafCzrtuJ0JdJmNWv7a+SwflrvrQfahiiBSl1A4kAT0An+/+8NU 6oIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709020337; x=1709625137; 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=a1p6UsSs+EQQxO64HZ57uYteqPXE6zBiSjX5gQ9IKv4=; b=szdQWd54pkRHktoyv3eyzHgYGRzKHKubC+Ids+DUNMV2Yy8LfbSH4WmRL2d6PTNDhs wQw2sdh7VYg1E+fOE9ENDOw4jBTUgy06pKuikdVOxCcBD7DYW26DNQDDIOoRewMvAySl W807iNE8Qb6FydI9/oAoVxhKJBuqDCE3xqKyZfIF0/RuoTf5Nqb8lhQ8OGknvm/XnJqU azWvzza/TmWm07Ioq8sRmbkGymN3qHggINL1brxb9hkn+dxmhJbhUg/V5rRBA5ZqUJkC OUzy4ikSxnz8eE8DbzU9133HcONHL+L08qRB6xOsGuua0KbJxE6H8x4xT5WFvfe4wIwB EJ7A== X-Gm-Message-State: AOJu0YwXum/Zrqa6qcI/bqYqpsSFPGzyh/wJSt1osc0Vy0J4LPVBV057 /XzjaI3wK8ydi+d0XGuQuat8l+R/0EiYf/u/uUBm6WvusXtIaccF X-Google-Smtp-Source: AGHT+IHTrcOrNV/7T58KkGuTM5UrA3VD3DpjVoGkDNCEKNRiK5KNQEHF1KxmH9cMpfjPepsVNFITeQ== X-Received: by 2002:a17:906:f28e:b0:a42:fcf2:1077 with SMTP id gu14-20020a170906f28e00b00a42fcf21077mr5039521ejb.23.1709020337189; Mon, 26 Feb 2024 23:52:17 -0800 (PST) Received: from corebook.localdomain (2001-1c00-020d-1300-1b1c-4449-176a-89ea.cable.dynamic.v6.ziggo.nl. [2001:1c00:20d:1300:1b1c:4449:176a:89ea]) by smtp.gmail.com with ESMTPSA id un6-20020a170907cb8600b00a3f0dbdf106sm496460ejc.105.2024.02.26.23.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 23:52:16 -0800 (PST) From: Eric Woudstra To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Marek_Beh=C3=BAn?= , "Frank Wunderlich" , Daniel Golle Cc: netdev@vger.kernel.org, Eric Woudstra Subject: [PATCH RFC net-next 6/6] net: sfp: add quirk for another multigig RollBall transceiver Date: Tue, 27 Feb 2024 08:51:51 +0100 Message-ID: <20240227075151.793496-7-ericwouds@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240227075151.793496-1-ericwouds@gmail.com> References: <20240227075151.793496-1-ericwouds@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Marek Behún Add quirk for another RollBall copper transceiver: Turris RTSFP-2.5G, containing 2.5g capable RTL8221B PHY. Signed-off-by: Marek Behún Signed-off-by: Eric Woudstra Reviewed-by: Russell King (Oracle) --- drivers/net/phy/sfp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 144feffe09f9..6d7dfbcda30b 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -513,6 +513,7 @@ static const struct sfp_quirk sfp_quirks[] = { SFP_QUIRK_F("OEM", "SFP-2.5G-T", sfp_fixup_oem_2_5g), SFP_QUIRK_F("OEM", "RTSFP-10", sfp_fixup_rollball_cc), SFP_QUIRK_F("OEM", "RTSFP-10G", sfp_fixup_rollball_cc), + SFP_QUIRK_F("Turris", "RTSFP-2.5G", sfp_fixup_rollball), SFP_QUIRK_F("Turris", "RTSFP-10", sfp_fixup_rollball), SFP_QUIRK_F("Turris", "RTSFP-10G", sfp_fixup_rollball), };