From patchwork Thu Dec 21 07:28:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri Fedrau X-Patchwork-Id: 13501258 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.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 CF5EF156EF; Thu, 21 Dec 2023 07:29:17 +0000 (UTC) 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="MzFM9HcM" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-50e18689828so605550e87.2; Wed, 20 Dec 2023 23:29:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703143756; x=1703748556; 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=jjNyfg9b/oa8PqsdonOr0+sP3WwEoMGtYWMIoH9NCVc=; b=MzFM9HcMGk/SHpHGn2yddyRZEUFTynpP5hQ9j5v2r5mBh+lBbp1/pv89clrFEfifF5 U8hwhhqDaiQ2JP0rrvnTX4RrckIxZ3s5igCGHEuZvhlUX08ab33657kSnwPOKGocj52a sJF1wUtnE91ODf24Cmy4wW1k4d+8WBZJ/JCSv7ma/NOVSA1wyE8MR11Ss52Pz3Dm6/zP YG3yfsdkbS0pD5nyohpniG1eLtIsuWF5V0/RDc3w537fE955CRsWu4cpzK2WPzhFjDEO oAdFB4O963yRvjZCJ0QDvj+aX+X25YK96yE9X8gj5JSNGWUYlydUXfsd0+d5ZV2J6vmF GZUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703143756; x=1703748556; 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=jjNyfg9b/oa8PqsdonOr0+sP3WwEoMGtYWMIoH9NCVc=; b=XNPM3AoaWnuy6ITIcr450aSOhCsK8orvCnhg+MYfaAE7k+KaoqJeT/T0hUeoYk6qBd D92DfepyvTng8UO78q+iNbirs5nUSn7t1RM6r98pgZoInraEeos5/RcTPxNLF/9W+54g GJT55Qun9ysmT1ril+MnCt8cOeDp27a9zfduHMTZ5LPnRCjVkIqsmSJzmntWwFOfJxwt iHqyK/2km6TMwErIa0GV3jmVeTPUvomYcDHoI88jY3ITCVUY98oXIEzbJvgyZwty4nVb S8fTN4VcecS8qh3sEcyTEFP3grzqu9vvHi80gpxupTWTbewlfk6D4oRGCnS6PbG+oCT4 wuZg== X-Gm-Message-State: AOJu0YwVCuO6iSNDyEBInaemPlZ73k/9LuWUfVx9C6Vm7TQvPT8E/0M0 fwJ36vVOVmKlJQY9/CqVmVQ= X-Google-Smtp-Source: AGHT+IEHCBGZ0DhiMdxR4anMGWX2eOZLz6T0JDXNpnpOMZ1qQ1tKA/raIEm5tx5reXntv2zgLwASpA== X-Received: by 2002:a05:6512:e98:b0:50e:5901:7916 with SMTP id bi24-20020a0565120e9800b0050e59017916mr658174lfb.128.1703143756106; Wed, 20 Dec 2023 23:29:16 -0800 (PST) Received: from debian.fritz.box ([93.184.186.109]) by smtp.gmail.com with ESMTPSA id en22-20020a056402529600b00553830eb2fcsm787819edb.64.2023.12.20.23.29.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 23:29:15 -0800 (PST) From: Dimitri Fedrau To: Cc: Dimitri Fedrau , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Stefan Eichenberger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/4] net: phy: Add BaseT1 auto-negotiation constants Date: Thu, 21 Dec 2023 08:28:48 +0100 Message-Id: <20231221072853.107678-2-dima.fedrau@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221072853.107678-1-dima.fedrau@gmail.com> References: <20231219093554.GA6393@debian> <20231221072853.107678-1-dima.fedrau@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Added constants for advertising 100BT1 and 1000BT1 in register BASE-T1 auto-negotiation advertisement register [31:16] (Register 7.515) Signed-off-by: Dimitri Fedrau Reviewed-by: Andrew Lunn --- include/uapi/linux/mdio.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h index d03863da180e..020ccc810d23 100644 --- a/include/uapi/linux/mdio.h +++ b/include/uapi/linux/mdio.h @@ -348,6 +348,8 @@ /* BASE-T1 auto-negotiation advertisement register [31:16] */ #define MDIO_AN_T1_ADV_M_B10L 0x4000 /* device is compatible with 10BASE-T1L */ +#define MDIO_AN_T1_ADV_M_1000BT1 0x0080 /* advertise 1000BASE-T1 */ +#define MDIO_AN_T1_ADV_M_100BT1 0x0020 /* advertise 100BASE-T1 */ #define MDIO_AN_T1_ADV_M_MST 0x0010 /* advertise master preference */ /* BASE-T1 auto-negotiation advertisement register [47:32] */ From patchwork Thu Dec 21 07:28:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri Fedrau X-Patchwork-Id: 13501259 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.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 793FA1642A; Thu, 21 Dec 2023 07:29:21 +0000 (UTC) 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="Tg2zd1Ol" Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5532b348d30so492390a12.1; Wed, 20 Dec 2023 23:29:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703143760; x=1703748560; 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=ejo7wkMYCp9JjGzkF+F3cQyIjCmI1lLvd98NTJgc+sk=; b=Tg2zd1Ol2h0Z/FC7cQDpL7o8GdJncVVsuG7JIoThkj3DdTSblxph5wkDYNg9pl0Xmg tDnaZnuMBZ59Ts21vFvizoTcj5NfGmcCalPfVjH7U6z/bgDcCU7PdEnUX4xamjFDep5h h0/UucoslLgqVSfFWG4mWQoYWLQi+a0EXzMnZTq7I15ci+Je8zrkK9m6AjYGrG6lOOVQ vK8X+aIsonrz5URrhZGZx67R4FsM4TBdKqP9Ai4jeATCrEGZ2EX4QxDB14wcnjEqTci5 8/utjsf2XcME1hsyD5XSJcNES4b09QAIFmjYwpjYpPH+0I75L8NkGkk4ZEhWBZu6Ft2Q bzQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703143760; x=1703748560; 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=ejo7wkMYCp9JjGzkF+F3cQyIjCmI1lLvd98NTJgc+sk=; b=gFqmRA5Q01dbHoPeoX6bYbck3/43EIoNJJFquuRfE2iBjOmo/XuOAjbBoQhQoaC5w5 JDnB2Bc56lmfJzJVbAOvcBVpSiNOiMnN6DABqbOKUCdo6Ijuml1xHuwSdu9TrNkDaB2z S9mHczyyNYvfxOZM6WfKoKYKrxqUbecbpvExTK1diU5BUkGeZEfEm2ZFCD+a+lDY2yQK aOdEkJOSS6sgefiUBA8rgNKoL1a6okr0u9tkS7BDlPcFpc4r4GFnZWrSXX7DDyTTJKl4 d7YFKDEPZIprxuTafYJPRlCRqyszElddscrEgUQhk8IRH6FiiGYVuQhUi57eXmnFyM9R +cYg== X-Gm-Message-State: AOJu0Yx8HVdf0+nhDVBUhRQXTBsnnQenIAzBplBbo/d/DcSVz634k//i qwGHNiHEmQQ+nRaH/rK+TA1L5P/dWUdXdA== X-Google-Smtp-Source: AGHT+IH7yGg/Ns5KOnK4mfcQDFx0W0vpoxuqVHVxZ8KxmZHCsbNzUNupXvfKONBQN/wk4wTuslrzOw== X-Received: by 2002:a50:a455:0:b0:552:3044:1df9 with SMTP id v21-20020a50a455000000b0055230441df9mr6605753edb.67.1703143759673; Wed, 20 Dec 2023 23:29:19 -0800 (PST) Received: from debian.fritz.box ([93.184.186.109]) by smtp.gmail.com with ESMTPSA id en22-20020a056402529600b00553830eb2fcsm787819edb.64.2023.12.20.23.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 23:29:19 -0800 (PST) From: Dimitri Fedrau To: Cc: Dimitri Fedrau , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Stefan Eichenberger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/4] net: phy: Support 100/1000BT1 linkmode advertisements Date: Thu, 21 Dec 2023 08:28:49 +0100 Message-Id: <20231221072853.107678-3-dima.fedrau@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221072853.107678-1-dima.fedrau@gmail.com> References: <20231219093554.GA6393@debian> <20231221072853.107678-1-dima.fedrau@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Extend helper functions mii_t1_adv_m_mod_linkmode_t and linkmode_adv_to_mii_t1_adv_m_t to support 100BT1 and 1000BT1 linkmode advertisements. Signed-off-by: Dimitri Fedrau Reviewed-by: Andrew Lunn --- include/linux/mdio.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/mdio.h b/include/linux/mdio.h index 007fd9c3e4b6..3d177f265cd3 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -372,6 +372,10 @@ static inline void mii_t1_adv_m_mod_linkmode_t(unsigned long *advertising, u32 l { linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, advertising, lpa & MDIO_AN_T1_ADV_M_B10L); + linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT1_Full_BIT, + advertising, lpa & MDIO_AN_T1_ADV_M_100BT1); + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT1_Full_BIT, + advertising, lpa & MDIO_AN_T1_ADV_M_1000BT1); } /** @@ -408,6 +412,10 @@ static inline u32 linkmode_adv_to_mii_t1_adv_m_t(unsigned long *advertising) if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, advertising)) result |= MDIO_AN_T1_ADV_M_B10L; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT1_Full_BIT, advertising)) + result |= MDIO_AN_T1_ADV_M_100BT1; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT1_Full_BIT, advertising)) + result |= MDIO_AN_T1_ADV_M_1000BT1; return result; } From patchwork Thu Dec 21 07:28:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri Fedrau X-Patchwork-Id: 13501260 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (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 1B72D17736; Thu, 21 Dec 2023 07:29:24 +0000 (UTC) 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="mYOlgOl1" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-552fba34d69so512136a12.3; Wed, 20 Dec 2023 23:29:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703143763; x=1703748563; 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=N8LbFzfRGhyEo7Z2rCSlcZvKPzGkHjgBRwyUpOjEIyo=; b=mYOlgOl1+R/AzIrLlQJSUaVRq5kF6uqQaAzDuUaAVwV83oLYSGIhZAXCqUtmHlniGx RymLjNF0GZne6Kjg7Fy8H/MtFPYIiMtM1e4ZC3UmodN7LBRAxD2RZ52nj5YdhMtDKSfk wSS4eMWGoREXG42ooYQXyPe7VgSvcBNFp1LtMDG4qlq4kzr1sbkvdd8iunes3B+l+N8L cPtceum5HKaZf+W7/ysrbSDUA+Ehmc/ZnWxEw7rLtMvFZJe6sDgkkMalR816mqbYNEtZ KItqXSMRDA5lcwp/rTLDsrkslCf26PyBBupWskehi0qWesGJJovJOYgEzp6iPmgjuYA6 5DiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703143763; x=1703748563; 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=N8LbFzfRGhyEo7Z2rCSlcZvKPzGkHjgBRwyUpOjEIyo=; b=k0SnozMwARQkCFG4/Gr3SDtHFuk/9rvslwwx8OJVuurPpY0QMvAB2Hg0TJI8oTtwyP W2UyWh26Zo8iGgXmRrikkWbdPBhzvpM/hT7+q0Yi/XcIKWsXkXd6C+8FxWxVK7KZ2auO PqZSEyHHOH9tj+ozqh7z6gWaxXvZ8C8SHNWV14NUZl8ctV169T7h1XheOS47FQM+leP0 Ew+GXpMwEdeb9z2qAZFOaUeRCQ+xlp+fxpWtuqowCkpQShEze1yrg8g1+ECkdACctm8P sxnUnMPJJ/aPCz+B9zYh0Ltdqbzna5a1L4Roo7EjJtN0ZdNgJ/26QQr/TOpDhgy6dQwl btWw== X-Gm-Message-State: AOJu0YyETpvyJgGeqjqxELKggsvEdHneByk2GCxcONL8SAxVpewAAGhC vaAs7F4N9dtlsJqk41Gj+fk= X-Google-Smtp-Source: AGHT+IEYeYYj+MIyh63kgMuWG38T243oBrSQ8LXQuntoCvMz328oRVA+s9Ukj/S8pnwkH7zInK1lJg== X-Received: by 2002:a50:cbcc:0:b0:54c:d2:ea39 with SMTP id l12-20020a50cbcc000000b0054c00d2ea39mr11263707edi.18.1703143763176; Wed, 20 Dec 2023 23:29:23 -0800 (PST) Received: from debian.fritz.box ([93.184.186.109]) by smtp.gmail.com with ESMTPSA id en22-20020a056402529600b00553830eb2fcsm787819edb.64.2023.12.20.23.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 23:29:22 -0800 (PST) From: Dimitri Fedrau To: Cc: Dimitri Fedrau , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Stefan Eichenberger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/4] net: phy: c45: detect 100/1000BASE-T1 linkmode advertisements Date: Thu, 21 Dec 2023 08:28:50 +0100 Message-Id: <20231221072853.107678-4-dima.fedrau@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221072853.107678-1-dima.fedrau@gmail.com> References: <20231219093554.GA6393@debian> <20231221072853.107678-1-dima.fedrau@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 Set 100BT1 and 1000BT1 linkmode advertisement bits to adv_l_mask to enable detection. Signed-off-by: Dimitri Fedrau Reviewed-by: Andrew Lunn --- drivers/net/phy/phy-c45.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 8e6fd4962c48..81ee2915bfc7 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -208,7 +208,8 @@ static int genphy_c45_baset1_an_config_aneg(struct phy_device *phydev) adv_l_mask = MDIO_AN_T1_ADV_L_FORCE_MS | MDIO_AN_T1_ADV_L_PAUSE_CAP | MDIO_AN_T1_ADV_L_PAUSE_ASYM; - adv_m_mask = MDIO_AN_T1_ADV_M_MST | MDIO_AN_T1_ADV_M_B10L; + adv_m_mask = MDIO_AN_T1_ADV_M_1000BT1 | MDIO_AN_T1_ADV_M_100BT1 | + MDIO_AN_T1_ADV_M_MST | MDIO_AN_T1_ADV_M_B10L; switch (phydev->master_slave_set) { case MASTER_SLAVE_CFG_MASTER_FORCE: From patchwork Thu Dec 21 07:28:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri Fedrau X-Patchwork-Id: 13501261 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 E69BA18043; Thu, 21 Dec 2023 07:29:28 +0000 (UTC) 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="eI0noVOE" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2cc6eecd319so4945691fa.1; Wed, 20 Dec 2023 23:29:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703143767; x=1703748567; 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=PPdCSrZU/ppC+mMBGRL49lqPFHzTuO4Z9sjETscMlk4=; b=eI0noVOEJ4PjwkWzqxGTCrsSWCVgRMcA8Lm4LLDsQfV/Ot6rgvUmum0PquGr/QMtF8 e18ltNEWngNzYLo7PCTz/McmW5R6sk/3Xfd6VyJu3GeACDSbvvUQ2HEG4M4bQe5jR+Xf EhP4F6mXzaCDQEaB1hiV8AYPDh8Wcs1sCDaexljbzMhr07yYIT8IX0r5ca61AdHIYcVO onZpX1GuiyCqxDCNUiC7KVsZwmxTFZeo2/ZgQExn1I728B/1ZNrpf1qEnqlKdP1EOOJK 29FVOUKvnAOoCBhh6G58O8eN6vN/9WhkLKqQdyRzTxeUbesgWvY2qc2wqFVA/Dq0Mbvu 0LLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703143767; x=1703748567; 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=PPdCSrZU/ppC+mMBGRL49lqPFHzTuO4Z9sjETscMlk4=; b=EC2D55oty3phnNKr784fGo4FH5fF23okYoum5eqWCuotwI3M43l314B0yM0js4XV7R eqhdyc8X9JuEQRG+kikInWtg7RHd4eVKp1MSftEcU1f1hDuoKTdf0EvrHSTphPKme24r CAcZG9twXfci85o/J+5mhSQz2l1+B1E0DTKfOjxbVST+dEv2baAlAckPfpCH8iUKLkcX Q/l3qNApNCmkldXCSIuq+tf8rj6PJBUMsM5UPddgDvlaP9x93rjMMUwXEXMk6GPEuU4E LGYlJPNZLo6F0LaofQksmKlQLlxeJngLTP1dA3z51XHhrRXRbiOKz80OzfZlsMkEYQCd Wwcw== X-Gm-Message-State: AOJu0Yw36jAch+Yr1VfY7uMcZCW1NG45a2iV1k4HRCyk3dhrj4A4l3tA h73Glk12aj7Zxacuq7lt6UwYzjPSn3G82w== X-Google-Smtp-Source: AGHT+IFMkCBhbH+bePn8Fz68KcxB5T/NMaWm2H8YzNHOFOoAZ7yDiyQzcVMePnpNAqLyT8dTNjkkKQ== X-Received: by 2002:a2e:9c8e:0:b0:2cc:5cf4:c394 with SMTP id x14-20020a2e9c8e000000b002cc5cf4c394mr4828585lji.15.1703143766822; Wed, 20 Dec 2023 23:29:26 -0800 (PST) Received: from debian.fritz.box ([93.184.186.109]) by smtp.gmail.com with ESMTPSA id en22-20020a056402529600b00553830eb2fcsm787819edb.64.2023.12.20.23.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 23:29:26 -0800 (PST) From: Dimitri Fedrau To: Cc: Dimitri Fedrau , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Stefan Eichenberger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/4] net: phy: marvell-88q2xxx: add driver for the Marvell 88Q2220 PHY Date: Thu, 21 Dec 2023 08:28:51 +0100 Message-Id: <20231221072853.107678-5-dima.fedrau@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221072853.107678-1-dima.fedrau@gmail.com> References: <20231219093554.GA6393@debian> <20231221072853.107678-1-dima.fedrau@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 Add a driver for the Marvell 88Q2220. This driver allows to detect the link, switch between 100BASE-T1 and 1000BASE-T1 and switch between master and slave mode and autonegotiation. Signed-off-by: Dimitri Fedrau --- drivers/net/phy/marvell-88q2xxx.c | 310 ++++++++++++++++++++++++++++-- include/linux/marvell_phy.h | 1 + 2 files changed, 300 insertions(+), 11 deletions(-) diff --git a/drivers/net/phy/marvell-88q2xxx.c b/drivers/net/phy/marvell-88q2xxx.c index 1c3ff77de56b..4e930b5ffaef 100644 --- a/drivers/net/phy/marvell-88q2xxx.c +++ b/drivers/net/phy/marvell-88q2xxx.c @@ -27,6 +27,13 @@ #define MDIO_MMD_PCS_MV_100BT1_STAT2_LINK 0x0004 #define MDIO_MMD_PCS_MV_100BT1_STAT2_ANGE 0x0008 +#define MDIO_MMD_PCS_MV_RX_STAT 33328 + +#define MDIO_MMD_AN_MV_STAT2 32794 +#define MDIO_MMD_AN_MV_STAT2_AN_RESOLVED 0x0800 +#define MDIO_MMD_AN_MV_STAT2_100BT1 0x2000 +#define MDIO_MMD_AN_MV_STAT2_1000BT1 0x4000 + static int mv88q2xxx_soft_reset(struct phy_device *phydev) { int ret; @@ -120,24 +127,87 @@ static int mv88q2xxx_read_link_100m(struct phy_device *phydev) static int mv88q2xxx_read_link(struct phy_device *phydev) { - int ret; - /* The 88Q2XXX PHYs do not have the PMA/PMD status register available, * therefore we need to read the link status from the vendor specific * registers depending on the speed. */ + if (phydev->speed == SPEED_1000) - ret = mv88q2xxx_read_link_gbit(phydev); + return mv88q2xxx_read_link_gbit(phydev); + else if (phydev->speed == SPEED_100) + return mv88q2xxx_read_link_100m(phydev); + + phydev->link = false; + return 0; +} + +static int mv88q2xxx_read_master_slave_state(struct phy_device *phydev) +{ + int ret; + + phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; + ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_MMD_AN_MV_STAT); + if (ret < 0) + return ret; + + if (ret & MDIO_MMD_AN_MV_STAT_LOCAL_MASTER) + phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; else - ret = mv88q2xxx_read_link_100m(phydev); + phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; + + return 0; +} + +static int mv88q2xxx_read_aneg_speed(struct phy_device *phydev) +{ + int ret; - return ret; + phydev->speed = SPEED_UNKNOWN; + + ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_MMD_AN_MV_STAT2); + if (ret < 0) + return ret; + + if (!(ret & MDIO_MMD_AN_MV_STAT2_AN_RESOLVED)) + return 0; + + if (ret & MDIO_MMD_AN_MV_STAT2_100BT1) + phydev->speed = SPEED_100; + else if (ret & MDIO_MMD_AN_MV_STAT2_1000BT1) + phydev->speed = SPEED_1000; + + return 0; } static int mv88q2xxx_read_status(struct phy_device *phydev) { int ret; + if (phydev->autoneg == AUTONEG_ENABLE) { + phydev->duplex = DUPLEX_FULL; + + /* We have to get the negotiated speed first, otherwise we are + * not able to read the link. + */ + ret = mv88q2xxx_read_aneg_speed(phydev); + if (ret < 0) + return ret; + + ret = mv88q2xxx_read_link(phydev); + if (ret < 0) + return ret; + + ret = genphy_c45_read_lpa(phydev); + if (ret < 0) + return ret; + + ret = genphy_c45_baset1_read_status(phydev); + if (ret < 0) + return ret; + + return mv88q2xxx_read_master_slave_state(phydev); + } + ret = mv88q2xxx_read_link(phydev); if (ret < 0) return ret; @@ -166,7 +236,9 @@ static int mv88q2xxx_get_features(struct phy_device *phydev) * sequence provided by Marvell. Disable it for now until a proper * workaround is found or a new PHY revision is released. */ - linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported); + if (phydev->drv->phy_id == MARVELL_PHY_ID_88Q2110) + linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, + phydev->supported); return 0; } @@ -192,6 +264,9 @@ static int mv88q2xxx_config_init(struct phy_device *phydev) */ phydev->pma_extable = MDIO_PMA_EXTABLE_BT1; + if (phydev->drv->phy_id == MARVELL_PHY_ID_88Q2220) + return 0; + /* Read the current PHY configuration */ ret = genphy_c45_read_pma(phydev); if (ret) @@ -200,7 +275,7 @@ static int mv88q2xxx_config_init(struct phy_device *phydev) return mv88q2xxx_config_aneg(phydev); } -static int mv88q2xxxx_get_sqi(struct phy_device *phydev) +static int mv88q2xxx_get_sqi(struct phy_device *phydev) { int ret; @@ -208,7 +283,8 @@ static int mv88q2xxxx_get_sqi(struct phy_device *phydev) /* Read the SQI from the vendor specific receiver status * register */ - ret = phy_read_mmd(phydev, MDIO_MMD_PCS, 0x8230); + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, + MDIO_MMD_PCS_MV_RX_STAT); if (ret < 0) return ret; @@ -230,11 +306,208 @@ static int mv88q2xxxx_get_sqi(struct phy_device *phydev) return ret & 0x0F; } -static int mv88q2xxxx_get_sqi_max(struct phy_device *phydev) +static int mv88q2xxx_get_sqi_max(struct phy_device *phydev) { return 15; } +static int mv88q222x_soft_reset(struct phy_device *phydev) +{ + int ret; + + /* Enable RESET of DCL */ + if (phydev->autoneg == AUTONEG_ENABLE || phydev->speed == SPEED_1000) { + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe1b, 0x48); + if (ret < 0) + return ret; + } + + /* Soft reset */ + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_1000BT1_CTRL, + MDIO_PCS_1000BT1_CTRL_RESET); + if (ret < 0) + return ret; + + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xffe4, 0xc); + if (ret < 0) + return ret; + + /* Disable RESET of DCL */ + if (phydev->autoneg == AUTONEG_ENABLE || phydev->speed == SPEED_1000) + return phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe1b, 0x58); + else + return ret; +} + +static int mv88q222x_config_aneg_gbit(struct phy_device *phydev) +{ + int ret; + + /* send_s detection threshold, slave and master */ + ret = phy_write_mmd(phydev, MDIO_MMD_AN, 0x8032, 0x2020); + if (ret < 0) + return ret; + + ret = phy_write_mmd(phydev, MDIO_MMD_AN, 0x8031, 0xa28); + if (ret < 0) + return ret; + + ret = phy_write_mmd(phydev, MDIO_MMD_AN, 0x8031, 0xc28); + if (ret < 0) + return ret; + + /* Disable DCL calibratin during tear down */ + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xffdb, 0xfc10); + if (ret < 0) + return ret; + + /* Disable RESET of DCL*/ + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe1b, 0x58); + if (ret < 0) + return ret; + + /* Turn CM Clamp ON */ + return phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe79, 0x4); +} + +static int mv88q222x_config_aneg_100m(struct phy_device *phydev) +{ + int ret; + + /* Update Initial FFE Coefficients */ + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfbba, 0xcb2); + if (ret < 0) + return ret; + + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfbbb, 0xc4a); + if (ret < 0) + return ret; + + /* Turn CM Clamp ON */ + return phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe79, 0x4); +} + +static int mv88q222x_config_aneg_preinit(struct phy_device *phydev) +{ + int ret, val, i; + + /* Enable txdac */ + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0x8033, 0x6801); + if (ret < 0) + return ret; + + /* Disable ANEG */ + ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_CTRL, 0x0); + if (ret < 0) + return ret; + + /* Set IEEE power down */ + ret = phy_write_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1, + MDIO_CTRL1_LPOWER | MDIO_PMA_CTRL1_SPEED1000); + if (ret < 0) + return ret; + + /* Exit standby state(internal state) */ + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe1b, 0x48); + if (ret < 0) + return ret; + + /* Set power management state breakpoint (internal state) */ + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xffe4, 0x6b6); + if (ret < 0) + return ret; + + /* Exit IEEE power down */ + ret = phy_write_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1, 0x0); + if (ret < 0) + return ret; + + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, 0x0); + if (ret < 0) + return ret; + + /* Wait up to 5ms to enter to power management state, if we do not meet + * the target value, it is still ok to proceed + */ + for (i = 0; i < 5; i++) { + val = phy_read_mmd(phydev, MDIO_MMD_PCS, 0xffe4); + if (val == 0x6ba) + break; + + usleep_range(1000, 2000); + } + + /* Turn CM Clamp OFF */ + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe79, 0x0); + if (ret < 0) + return ret; + + /* mdi vcm */ + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe07, 0x125a); + if (ret < 0) + return ret; + + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe09, 0x1288); + if (ret < 0) + return ret; + + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe08, 0x2588); + if (ret < 0) + return ret; + + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe11, 0x1105); + if (ret < 0) + return ret; + + /* aux_boost */ + return phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe72, 0x042c); +} + +static int mv88q222x_config_aneg_init_b0(struct phy_device *phydev) +{ + int ret; + + ret = mv88q222x_config_aneg_preinit(phydev); + if (ret < 0) + return ret; + + if (phydev->autoneg == AUTONEG_DISABLE) { + if (phydev->speed == SPEED_100) + return mv88q222x_config_aneg_100m(phydev); + else + return mv88q222x_config_aneg_gbit(phydev); + } + + ret = mv88q222x_config_aneg_100m(phydev); + if (ret) + return ret; + + ret = mv88q222x_config_aneg_gbit(phydev); + if (ret) + return ret; + + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe5f, 0xe8); + if (ret) + return ret; + + return phy_write_mmd(phydev, MDIO_MMD_PCS, 0xfe05, 0x755c); +} + +static int mv88q222x_config_aneg(struct phy_device *phydev) +{ + int ret; + + ret = mv88q222x_config_aneg_init_b0(phydev); + if (ret < 0) + return ret; + + ret = genphy_c45_config_aneg(phydev); + if (ret) + return ret; + + return mv88q222x_soft_reset(phydev); +} + static struct phy_driver mv88q2xxx_driver[] = { { .phy_id = MARVELL_PHY_ID_88Q2110, @@ -246,8 +519,22 @@ static struct phy_driver mv88q2xxx_driver[] = { .read_status = mv88q2xxx_read_status, .soft_reset = mv88q2xxx_soft_reset, .set_loopback = genphy_c45_loopback, - .get_sqi = mv88q2xxxx_get_sqi, - .get_sqi_max = mv88q2xxxx_get_sqi_max, + .get_sqi = mv88q2xxx_get_sqi, + .get_sqi_max = mv88q2xxx_get_sqi_max, + }, + { + .phy_id = MARVELL_PHY_ID_88Q2220, + .phy_id_mask = MARVELL_PHY_ID_MASK, + .name = "mv88q2220", + .get_features = mv88q2xxx_get_features, + .config_aneg = mv88q222x_config_aneg, + .aneg_done = genphy_c45_aneg_done, + .config_init = mv88q2xxx_config_init, + .read_status = mv88q2xxx_read_status, + .soft_reset = mv88q222x_soft_reset, + .set_loopback = genphy_c45_loopback, + .get_sqi = mv88q2xxx_get_sqi, + .get_sqi_max = mv88q2xxx_get_sqi_max, }, }; @@ -255,6 +542,7 @@ module_phy_driver(mv88q2xxx_driver); static struct mdio_device_id __maybe_unused mv88q2xxx_tbl[] = { { MARVELL_PHY_ID_88Q2110, MARVELL_PHY_ID_MASK }, + { MARVELL_PHY_ID_88Q2220, MARVELL_PHY_ID_MASK }, { /*sentinel*/ } }; MODULE_DEVICE_TABLE(mdio, mv88q2xxx_tbl); diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h index 9b54c4f0677f..693eba9869e4 100644 --- a/include/linux/marvell_phy.h +++ b/include/linux/marvell_phy.h @@ -26,6 +26,7 @@ #define MARVELL_PHY_ID_88E2110 0x002b09b0 #define MARVELL_PHY_ID_88X2222 0x01410f10 #define MARVELL_PHY_ID_88Q2110 0x002b0980 +#define MARVELL_PHY_ID_88Q2220 0x002b0b20 /* Marvel 88E1111 in Finisar SFP module with modified PHY ID */ #define MARVELL_PHY_ID_88E1111_FINISAR 0x01ff0cc0