From patchwork Wed Jul 19 06:42:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13318362 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D99C21FC6 for ; Wed, 19 Jul 2023 06:43:26 +0000 (UTC) Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51178119 for ; Tue, 18 Jul 2023 23:43:25 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5216569f9e3so7396621a12.0 for ; Tue, 18 Jul 2023 23:43:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689749003; x=1692341003; 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=HxrSLmt1sdcD9lzS7GfUjGkTdrTEIcrnI8+/q+GNwjk=; b=oXwfzpVT0PPK6fzIYhKCVfKlvTUptHmPyOFDCWG1aCVY1InK2lZeIbkZVIscz4soz/ axKbZw5wohxPhZmcyyNxB+SwlWkms/IJej2KDWJ0VCFg7xELjY3Fy54EW9Ojl5fCVczG MmBWBq1hBlUVy37qaKWR3/mHrBVP45iriVzORZ1U5TCQYe3FPZ29EQBt2DNhsQ/80+Tz 4DI5xetfzpoiuKH/S4tly5tQXqWYVgdh1/tlu/eToI7DaVVC6Si+jBg3GKlY9CiQHcuI 3e8djEqoCgVkgR9IGeTkb5rc3QiWiYGrhYQidpUy0lacDqnmJFtrepbxK7HwjTCll1ao O2Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689749003; x=1692341003; 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=HxrSLmt1sdcD9lzS7GfUjGkTdrTEIcrnI8+/q+GNwjk=; b=QwKfP13WXY7o+qZsuvxzm5fQLNnPwgLP7ib2DOE1r7/ddlP4MV61e5YXbO9xiJoZwM 4BexHRRlIIJI24MHa05f93c4ot2VFn44U5vFgpMLcTFx+eSUoHO0v1DkPoDR3L7Nt/C1 eWwkOWOu/xwJGOaybLtURkvtMLmC1mhsB0khP4/gDTbpRXqMOauu1GwLJ39Rnx2+TPoV jkXs+S/2jzquCb5xEU9s8fCrSkQodSJHPLavoOOANJpSgZer/wBGZxZMYzaCUzfwbvIk 4yBRg38wjg9M+ChSQu0+hsM2FubWuty14F8sZrcF1OzAV8LMM095yDPfdZ/7gEdCbKTD OlJw== X-Gm-Message-State: ABy/qLZDvyoAs1frjCSug6gtCrlwWzVhIEh51bYTYBwDfFcvlblp5aXT 7fUop06JeLPOUPRo0ue4ZwJwOOZMaeGFHQ== X-Google-Smtp-Source: APBJJlGIDo08IUEZI35rB8AD5M5A16iZHmKxFBk3l5BuMTl+xVQsb/bnzet3oKL7UE1ncfM7Tmnr5w== X-Received: by 2002:a50:ed94:0:b0:51b:c714:a2a1 with SMTP id h20-20020a50ed94000000b0051bc714a2a1mr1669418edr.7.1689749003449; Tue, 18 Jul 2023 23:43:23 -0700 (PDT) Received: from eichest-laptop.lan ([2a02:168:af72:0:b88b:69a9:6066:94ef]) by smtp.gmail.com with ESMTPSA id g8-20020a056402180800b0051e0f8aac74sm2301868edy.8.2023.07.18.23.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 23:43:23 -0700 (PDT) From: Stefan Eichenberger To: netdev@vger.kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, francesco.dolcini@toradex.com, kabel@kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, eichest@gmail.com Subject: [PATCH net-next v4 1/5] net: phy: add registers to support 1000BASE-T1 Date: Wed, 19 Jul 2023 08:42:54 +0200 Message-Id: <20230719064258.9746-2-eichest@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230719064258.9746-1-eichest@gmail.com> References: <20230719064258.9746-1-eichest@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add registers and definitions to support 1000BASE-T1. This includes the PCS Control and Status registers (3.2304 and 3.2305) as well as some missing bits on the PMA/PMD extended ability register (1.18) and PMA/PMD CTRL (1.2100) register. Signed-off-by: Stefan Eichenberger Reviewed-by: Andrew Lunn --- include/uapi/linux/mdio.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h index b826598d1e94c..d03863da180e7 100644 --- a/include/uapi/linux/mdio.h +++ b/include/uapi/linux/mdio.h @@ -82,6 +82,8 @@ #define MDIO_AN_10BT1_AN_CTRL 526 /* 10BASE-T1 AN control register */ #define MDIO_AN_10BT1_AN_STAT 527 /* 10BASE-T1 AN status register */ #define MDIO_PMA_PMD_BT1_CTRL 2100 /* BASE-T1 PMA/PMD control register */ +#define MDIO_PCS_1000BT1_CTRL 2304 /* 1000BASE-T1 PCS control register */ +#define MDIO_PCS_1000BT1_STAT 2305 /* 1000BASE-T1 PCS status register */ /* LASI (Link Alarm Status Interrupt) registers, defined by XENPAK MSA. */ #define MDIO_PMA_LASI_RXCTRL 0x9000 /* RX_ALARM control */ @@ -332,6 +334,8 @@ #define MDIO_PCS_10T1L_CTRL_RESET 0x8000 /* PCS reset */ /* BASE-T1 PMA/PMD extended ability register. */ +#define MDIO_PMA_PMD_BT1_B100_ABLE 0x0001 /* 100BASE-T1 Ability */ +#define MDIO_PMA_PMD_BT1_B1000_ABLE 0x0002 /* 1000BASE-T1 Ability */ #define MDIO_PMA_PMD_BT1_B10L_ABLE 0x0004 /* 10BASE-T1L Ability */ /* BASE-T1 auto-negotiation advertisement register [15:0] */ @@ -373,7 +377,19 @@ #define MDIO_AN_10BT1_AN_STAT_LPA_EEE_T1L 0x4000 /* 10BASE-T1L LP EEE ability advertisement */ /* BASE-T1 PMA/PMD control register */ -#define MDIO_PMA_PMD_BT1_CTRL_CFG_MST 0x4000 /* MASTER-SLAVE config value */ +#define MDIO_PMA_PMD_BT1_CTRL_STRAP 0x000F /* Type selection (Strap) */ +#define MDIO_PMA_PMD_BT1_CTRL_STRAP_B1000 0x0001 /* Select 1000BASE-T1 */ +#define MDIO_PMA_PMD_BT1_CTRL_CFG_MST 0x4000 /* MASTER-SLAVE config value */ + +/* 1000BASE-T1 PCS control register */ +#define MDIO_PCS_1000BT1_CTRL_LOW_POWER 0x0800 /* Low power mode */ +#define MDIO_PCS_1000BT1_CTRL_DISABLE_TX 0x4000 /* Global PMA transmit disable */ +#define MDIO_PCS_1000BT1_CTRL_RESET 0x8000 /* Software reset value */ + +/* 1000BASE-T1 PCS status register */ +#define MDIO_PCS_1000BT1_STAT_LINK 0x0004 /* PCS Link is up */ +#define MDIO_PCS_1000BT1_STAT_FAULT 0x0080 /* There is a fault condition */ + /* EEE Supported/Advertisement/LP Advertisement registers. * From patchwork Wed Jul 19 06:42:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13318363 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22D6179DE for ; Wed, 19 Jul 2023 06:43:27 +0000 (UTC) Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEB4E1BF3 for ; Tue, 18 Jul 2023 23:43:25 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-51e29ede885so9229074a12.3 for ; Tue, 18 Jul 2023 23:43:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689749004; x=1692341004; 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=BgY/tIKs7JfRavioVCfjDpc9fCFeRXz+HCPT+5I+NT0=; b=Jc9Z77AUE+0QZCiipp+5cWRB9MzPy6UelJBwQ73l1sl9EUR4ChC6iIUBUPXnzSbBY3 dx4QuFfFfdUKGWRwZ1Cf3MBITcsEpPRswf5akdZ5/L13o3ETl4xMWJdJcsHltIRbNgm5 BW8p3KQhV5AY0t0WWnLoKOYLz2O59hwL3UaeWmLli30dlWFOhI2ROZcg3BxzFzMMF/00 7ORujkpnRw25bj1ISufkVA2jbQQIflKsyASGc4CtXtMr9Pla0uVaNeOBn0i1OZFafQvh jFq36XdSKpa6l2LjiH2WOH5Vh3+sJBfZhOXhXvBHyHUS4iUiUr2bIRxuk8Wre30FDdhC g3eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689749004; x=1692341004; 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=BgY/tIKs7JfRavioVCfjDpc9fCFeRXz+HCPT+5I+NT0=; b=eapLo2wPRFQhv0VIWln1yOWdybqiA4CKZgnifncffN1uam5M49wx4gDQ7HCgs3DF81 w6zO12sqYHusf/0SC6xBZ/i7yR13TCRX0T+RRwIMs/AE+gfetlm/zJsYJUe/lCNuZfSJ 6GvD3Rf9lAV9YqfthhfuDSDI3OoKvflnfQwQA2nj9RyaBXhl+2m0heVEShmM7IDu00ug jtPwwC4irrDnhQ9IhEy/aqXdJvZfrVA4Zea4r573yNLRUtC2OTtuvhF26gsa1fnifub1 jQQQZFAWraEWE6gAbuAihYjTauq4Aw4/iXISq4WjCngYemZpQg4t0Myoe637Y2q0ptbc SWxA== X-Gm-Message-State: ABy/qLZWLwbQya5P31DvJC9iofriWpkHAEeJ6ZLLz4lPaZBak/eiAoSJ 4NkmiEnYz2wN1PGN9aVAUN7gttnqzzn2vQ== X-Google-Smtp-Source: APBJJlH2BLvZ8Osvzf4sF5fOL/EWtcxUHoeAnb/YdrjC+dhgtgv22b1TNxewH1Wcqf/sNDXywo2FBQ== X-Received: by 2002:a05:6402:164d:b0:51e:2664:f695 with SMTP id s13-20020a056402164d00b0051e2664f695mr1536796edx.23.1689749003962; Tue, 18 Jul 2023 23:43:23 -0700 (PDT) Received: from eichest-laptop.lan ([2a02:168:af72:0:b88b:69a9:6066:94ef]) by smtp.gmail.com with ESMTPSA id g8-20020a056402180800b0051e0f8aac74sm2301868edy.8.2023.07.18.23.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 23:43:23 -0700 (PDT) From: Stefan Eichenberger To: netdev@vger.kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, francesco.dolcini@toradex.com, kabel@kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, eichest@gmail.com Subject: [PATCH net-next v4 2/5] net: phy: c45: add support for 1000BASE-T1 forced setup Date: Wed, 19 Jul 2023 08:42:55 +0200 Message-Id: <20230719064258.9746-3-eichest@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230719064258.9746-1-eichest@gmail.com> References: <20230719064258.9746-1-eichest@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add support to force 1000BASE-T1 by setting the correct control bit in the MDIO_MMD_PMA_PMD_BT1_CTRL register. Signed-off-by: Stefan Eichenberger Reviewed-by: Andrew Lunn --- drivers/net/phy/phy-c45.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 93ed072233779..b73c428a15663 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -108,7 +108,7 @@ EXPORT_SYMBOL_GPL(genphy_c45_pma_baset1_setup_master_slave); */ int genphy_c45_pma_setup_forced(struct phy_device *phydev) { - int ctrl1, ctrl2, ret; + int bt1_ctrl, ctrl1, ctrl2, ret; /* Half duplex is not supported */ if (phydev->duplex != DUPLEX_FULL) @@ -176,6 +176,15 @@ int genphy_c45_pma_setup_forced(struct phy_device *phydev) ret = genphy_c45_pma_baset1_setup_master_slave(phydev); if (ret < 0) return ret; + + bt1_ctrl = 0; + if (phydev->speed == SPEED_1000) + bt1_ctrl = MDIO_PMA_PMD_BT1_CTRL_STRAP_B1000; + + ret = phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_PMD_BT1_CTRL, + MDIO_PMA_PMD_BT1_CTRL_STRAP, bt1_ctrl); + if (ret < 0) + return ret; } return genphy_c45_an_disable_aneg(phydev); From patchwork Wed Jul 19 06:42:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13318365 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DF2DBE4C for ; Wed, 19 Jul 2023 06:43:27 +0000 (UTC) Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8496E1FC4 for ; Tue, 18 Jul 2023 23:43:26 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-52176fdad9dso6569417a12.0 for ; Tue, 18 Jul 2023 23:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689749005; x=1692341005; 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=SDEyEI9JbgtX5Cqks53anCgM9gV1GIO80U6Uyh5IHww=; b=lu9KunBVqZthujWdtAxS5lG8PvaxBdAE2ak2kTnNOqoIqWVU+2/mvuTVVCYoCQD6yU sCx02MCfXAqdrYWWwoqoPOVcIljjjwTcev/JhUnBJGddO6cUlT1iUg/oK0wdzyOu10Qs NPYmPbTeUgGHNOpjX05TbbyUO1R/Xnwi6zYn3exk84Zbf3fBMwUREYBwcRPi0X3LMgX6 gPWijlbYNhbpccJOc5KTOCy4Mom0xI8gqWgAxSRzX8KJKCpkd8AuzGzLJyd4LudicmD4 flsNGgNZaH6GYeHXK7ODJkD1X+QLC5ph431DJ3ljxRYLsK4gESGt1iCsgozMdonGT0FN 2Txg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689749005; x=1692341005; 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=SDEyEI9JbgtX5Cqks53anCgM9gV1GIO80U6Uyh5IHww=; b=ft0tTj3Z8STKRqix1ZS1qXZ23pDsgbAuSluclfkxeBrT9FO0Ao9INxf8cZ95ejp1iZ eJcs0RyHc6eWbr/NvOPRzG876f4lOBEAK4OpMN1UcPZ4HZgefd3QzrInYtyx86M0Eg+0 zf440ARWGjaSsbFsetPAQzZ720TDkNnR1hkv+6caVIF8q3o5LExElC/FKflpW6SHHe9t GmLUIXGTPd0voPhKnJbJPRLtKCDU5fN10Mfutwa8Lqis6MBdMl0/oDz6tCoOK8MAw2vx DJ/WojiwIRma8BsyD5YQTAE5qyHkAPn6YMb+qHIRz1dLVNXrC6fPrwBvoFrbjxdslE95 q8vg== X-Gm-Message-State: ABy/qLaNcCxduX87A4k7rzOcnTy7cy0gWO7JCQjBNvSWXe8kCtFJo4aX M3q0ZK/JZE5Z8vmDzsTr+IL09wes53xHbw== X-Google-Smtp-Source: APBJJlGHipLv1iHyemuzM1qF0A+zIB2mooi3FcD7tJtp259G7xl7zYNqiIQma//E5UVflpN+tGI04w== X-Received: by 2002:aa7:c2da:0:b0:51d:d4c3:6858 with SMTP id m26-20020aa7c2da000000b0051dd4c36858mr1762651edp.12.1689749004588; Tue, 18 Jul 2023 23:43:24 -0700 (PDT) Received: from eichest-laptop.lan ([2a02:168:af72:0:b88b:69a9:6066:94ef]) by smtp.gmail.com with ESMTPSA id g8-20020a056402180800b0051e0f8aac74sm2301868edy.8.2023.07.18.23.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 23:43:24 -0700 (PDT) From: Stefan Eichenberger To: netdev@vger.kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, francesco.dolcini@toradex.com, kabel@kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, eichest@gmail.com Subject: [PATCH net-next v4 3/5] net: phy: c45: add a separate function to read BASE-T1 abilities Date: Wed, 19 Jul 2023 08:42:56 +0200 Message-Id: <20230719064258.9746-4-eichest@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230719064258.9746-1-eichest@gmail.com> References: <20230719064258.9746-1-eichest@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add a separate function to read the BASE-T1 abilities. Some PHYs do not indicate the availability of the extended BASE-T1 ability register, so this function must be called separately. Signed-off-by: Stefan Eichenberger Reviewed-by: Andrew Lunn --- drivers/net/phy/phy-c45.c | 44 +++++++++++++++++++++++++++------------ include/linux/phy.h | 1 + 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index b73c428a15663..58a6bbbe8a70c 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -881,6 +881,36 @@ int genphy_c45_an_config_eee_aneg(struct phy_device *phydev) return genphy_c45_write_eee_adv(phydev, phydev->advertising_eee); } +/** + * genphy_c45_pma_baset1_read_abilities - read supported baset1 link modes from PMA + * @phydev: target phy_device struct + * + * Read the supported link modes from the extended BASE-T1 ability register + */ +int genphy_c45_pma_baset1_read_abilities(struct phy_device *phydev) +{ + int val; + + val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_PMD_BT1); + if (val < 0) + return val; + + linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, + phydev->supported, + val & MDIO_PMA_PMD_BT1_B10L_ABLE); + + val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_STAT); + if (val < 0) + return val; + + linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, + phydev->supported, + val & MDIO_AN_STAT1_ABLE); + + return 0; +} +EXPORT_SYMBOL_GPL(genphy_c45_pma_baset1_read_abilities); + /** * genphy_c45_pma_read_abilities - read supported link modes from PMA * @phydev: target phy_device struct @@ -977,21 +1007,9 @@ int genphy_c45_pma_read_abilities(struct phy_device *phydev) } if (val & MDIO_PMA_EXTABLE_BT1) { - val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_PMD_BT1); + val = genphy_c45_pma_baset1_read_abilities(phydev); if (val < 0) return val; - - linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT1L_Full_BIT, - phydev->supported, - val & MDIO_PMA_PMD_BT1_B10L_ABLE); - - val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_STAT); - if (val < 0) - return val; - - linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, - phydev->supported, - val & MDIO_AN_STAT1_ABLE); } } diff --git a/include/linux/phy.h b/include/linux/phy.h index 11c1e91563d47..b254848a9c99a 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1826,6 +1826,7 @@ int genphy_c45_an_config_aneg(struct phy_device *phydev); int genphy_c45_an_disable_aneg(struct phy_device *phydev); int genphy_c45_read_mdix(struct phy_device *phydev); int genphy_c45_pma_read_abilities(struct phy_device *phydev); +int genphy_c45_pma_baset1_read_abilities(struct phy_device *phydev); int genphy_c45_read_eee_abilities(struct phy_device *phydev); int genphy_c45_pma_baset1_read_master_slave(struct phy_device *phydev); int genphy_c45_read_status(struct phy_device *phydev); From patchwork Wed Jul 19 06:42:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13318364 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DE4EBE40 for ; Wed, 19 Jul 2023 06:43:28 +0000 (UTC) Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E22621FCD for ; Tue, 18 Jul 2023 23:43:26 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-52173d4e9f9so6025171a12.0 for ; Tue, 18 Jul 2023 23:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689749005; x=1692341005; 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=dpaSSs34L1Ofk/RcNA0HWtUpf0nn7fQpfE/UPEa1hy8=; b=dsY+2vBkVl1LqJ08WY8sTSAGa6iWBt+M8yRAZh3CYvIPpcKVJC9DxE46MT6egRDig7 8eNxnNZz+g5qqdVXx2yxHbKkztW9YbCtIst6qCTeq2Lv0YlCCnR4hRtSiPJ8smeIJWrG 3znU6dYevP/LCLPws0JLHStf07/nIqlLGwEkB4+MeaDj8tuJSp+z2Mry58WHRtcUFK54 vJEmnmg2uAxiZXMp3KC1LQ9WBii6CYguf1qEemam018UBO4VrRfyV5Q6DIolHyEt1enS AV1zwVTGE7of1rAZvR0GkGwT6FvoPzHi+XbQXV7EM3jM6Q5JhaIUoeiApddTxFnlp0Xa mZqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689749005; x=1692341005; 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=dpaSSs34L1Ofk/RcNA0HWtUpf0nn7fQpfE/UPEa1hy8=; b=PON/3K7MYFrJOqBqEP9Fe0g9oBZ/vuzKSLcmE/osJfBgoKKBChT6c1eEo5NsDlYBiz ozDLBrWGRX4g2cuSt9ZwoDGr6/opEW85YR8usoSvoYTc3YP/JaMinzo9DFYIdevIPQEm 3UWlZOmZvTZFd9mCV9uWLf1PueBV38x/fM3pMrpq4gS9/xxI+upqX3Kk15C4JjNzTEn/ y3254CLZ/dpmXyXfdqyrsFzItB8tNaTBItnQCzTTgaTZXzSFHM1ksbpL8WlwlFF0ZaRi souV1uLwdP+TLWhDYtKi4WpoktLD+jFpFSDw6gxoveBsjR3xET9EvsCl13qIFSfQn2GA rv5g== X-Gm-Message-State: ABy/qLZm8kcqeTW556MzCJrr+YExDD5MJc7D2cAVvgqTuGRzTqaXeJcu GpHfaqtsnb6dASQVJbwURsxlsmpnkkfpzw== X-Google-Smtp-Source: APBJJlF6GILGg6bqD2jaXTbYOVRnISWk9BYE1HkXm26qFj44FLIccmS6A20stj3iOND8y8c5Bs6xtg== X-Received: by 2002:aa7:c755:0:b0:51d:e975:bea8 with SMTP id c21-20020aa7c755000000b0051de975bea8mr1567937eds.13.1689749005149; Tue, 18 Jul 2023 23:43:25 -0700 (PDT) Received: from eichest-laptop.lan ([2a02:168:af72:0:b88b:69a9:6066:94ef]) by smtp.gmail.com with ESMTPSA id g8-20020a056402180800b0051e0f8aac74sm2301868edy.8.2023.07.18.23.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 23:43:24 -0700 (PDT) From: Stefan Eichenberger To: netdev@vger.kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, francesco.dolcini@toradex.com, kabel@kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, eichest@gmail.com Subject: [PATCH net-next v4 4/5] net: phy: c45: detect the BASE-T1 speed from the ability register Date: Wed, 19 Jul 2023 08:42:57 +0200 Message-Id: <20230719064258.9746-5-eichest@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230719064258.9746-1-eichest@gmail.com> References: <20230719064258.9746-1-eichest@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Read the ability to do 100BASE-T1 and 1000BASE-T1 from the extended BASE-T1 ability register of the PHY. Signed-off-by: Stefan Eichenberger Reviewed-by: Andrew Lunn --- drivers/net/phy/phy-c45.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 58a6bbbe8a70c..8e6fd4962c486 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -899,6 +899,14 @@ int genphy_c45_pma_baset1_read_abilities(struct phy_device *phydev) phydev->supported, val & MDIO_PMA_PMD_BT1_B10L_ABLE); + linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT1_Full_BIT, + phydev->supported, + val & MDIO_PMA_PMD_BT1_B100_ABLE); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT1_Full_BIT, + phydev->supported, + val & MDIO_PMA_PMD_BT1_B1000_ABLE); + val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_T1_STAT); if (val < 0) return val; From patchwork Wed Jul 19 06:42:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13318366 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CBEDC8C0 for ; Wed, 19 Jul 2023 06:43:29 +0000 (UTC) Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E48DC1FCE for ; Tue, 18 Jul 2023 23:43:27 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-51e57870becso8659837a12.2 for ; Tue, 18 Jul 2023 23:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689749006; x=1692341006; 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=yixXqZX7eF/4cDROyITTMI6IjRRU7qXkpHSTf8PAF+8=; b=dF4AzClD6ps09v7vhPqd9BNVLM5OF8fY9kXM9jc0xMAhQm6Zf5l4dI1HExPiNu4U4W cnot1qtD16VvXCN8yjcqlxaI2XX5i7R0U+YIUukEUpi+me3lxMSmlJ9eYzpJ0jajpqZs AXP6w2WoDIkBw2VagEcTU9YU6pAUDazlGfEryxcz4rx2czv3fTNuTip3qcgupueOz4ky kwyny3ae+11q1Ptcf1VLVUyEGBW8At5FS2e7U78BjGh9vMEO1MoN+imz/rM4FowVp6Pj u6iPBFcfmiMJkNYIAvWuRj7+xufiGHmtZV2ju8vA/KbnzeUotsw1/RQUN78g5oFmABBf UHTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689749006; x=1692341006; 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=yixXqZX7eF/4cDROyITTMI6IjRRU7qXkpHSTf8PAF+8=; b=gF5iJVGUhDp/TlPaag60JeHPNg4yRTWuJea3K3QeSCAUBM4fjtPTll9m8DvTw1uyJF vO5/wSGp9orE0hHdsSiNqQD0Af75gzoF1IkMKp3vO3ZxCaIWZEhsxPjd+crnj4ENOC0X Lg4UvElM7utr43avFerDvztWpP98S9Ktn80ayT/YErB82tQr94HM+vEGbyuM+tc7c37/ lCtsS82KznbwLv+t0Erm2UcAX2Hth86z/QoKLIlMk1Rbt3QTIAllKOKx8Mz55ibkXura OFSLu08YbH5bEPXdKEuFBAtTyDWg/OSZPqDV+RbtA2KnhCGwk7q9XfMXW4nuj+wouThu GXuQ== X-Gm-Message-State: ABy/qLZIe46i13HRgH5m7PGBRJyDzQ0vrwIeFBVurBGFHbcuOJJqtarw QfUIboipvpX624lqAjLeL3/dNvXLNnoNvA== X-Google-Smtp-Source: APBJJlHE/BpLtC06qsBdMCysHS01sSgdlXeJogZKzugenLvDRqPvlfpurWuKpopBwjJ+ECXs0O1IMg== X-Received: by 2002:aa7:d1d8:0:b0:51d:9f71:23e2 with SMTP id g24-20020aa7d1d8000000b0051d9f7123e2mr1565499edp.21.1689749006053; Tue, 18 Jul 2023 23:43:26 -0700 (PDT) Received: from eichest-laptop.lan ([2a02:168:af72:0:b88b:69a9:6066:94ef]) by smtp.gmail.com with ESMTPSA id g8-20020a056402180800b0051e0f8aac74sm2301868edy.8.2023.07.18.23.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 23:43:25 -0700 (PDT) From: Stefan Eichenberger To: netdev@vger.kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, francesco.dolcini@toradex.com, kabel@kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, eichest@gmail.com Subject: [PATCH net-next v4 5/5] net: phy: marvell-88q2xxx: add driver for the Marvell 88Q2110 PHY Date: Wed, 19 Jul 2023 08:42:58 +0200 Message-Id: <20230719064258.9746-6-eichest@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230719064258.9746-1-eichest@gmail.com> References: <20230719064258.9746-1-eichest@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add a driver for the Marvell 88Q2110. This driver allows to detect the link, switch between 100BASE-T1 and 1000BASE-T1 and switch between master and slave mode. Autonegotiation supported by the PHY does not yet work. Signed-off-by: Stefan Eichenberger Reviewed-by: Andrew Lunn --- drivers/net/phy/Kconfig | 6 + drivers/net/phy/Makefile | 1 + drivers/net/phy/marvell-88q2xxx.c | 263 ++++++++++++++++++++++++++++++ include/linux/marvell_phy.h | 1 + 4 files changed, 271 insertions(+) create mode 100644 drivers/net/phy/marvell-88q2xxx.c diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 78e6981650d94..87b8238587173 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -217,6 +217,12 @@ config MARVELL_10G_PHY help Support for the Marvell Alaska MV88X3310 and compatible PHYs. +config MARVELL_88Q2XXX_PHY + tristate "Marvell 88Q2XXX PHY" + help + Support for the Marvell 88Q2XXX 100/1000BASE-T1 Automotive Ethernet + PHYs. + config MARVELL_88X2222_PHY tristate "Marvell 88X2222 PHY" help diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 2fe51ea83babe..35142780fc9da 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o obj-$(CONFIG_LXT_PHY) += lxt.o obj-$(CONFIG_MARVELL_10G_PHY) += marvell10g.o obj-$(CONFIG_MARVELL_PHY) += marvell.o +obj-$(CONFIG_MARVELL_88Q2XXX_PHY) += marvell-88q2xxx.o obj-$(CONFIG_MARVELL_88X2222_PHY) += marvell-88x2222.o obj-$(CONFIG_MAXLINEAR_GPHY) += mxl-gpy.o obj-$(CONFIG_MEDIATEK_GE_PHY) += mediatek-ge.o diff --git a/drivers/net/phy/marvell-88q2xxx.c b/drivers/net/phy/marvell-88q2xxx.c new file mode 100644 index 0000000000000..1c3ff77de56b4 --- /dev/null +++ b/drivers/net/phy/marvell-88q2xxx.c @@ -0,0 +1,263 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Marvell 88Q2XXX automotive 100BASE-T1/1000BASE-T1 PHY driver + */ +#include +#include +#include + +#define MDIO_MMD_AN_MV_STAT 32769 +#define MDIO_MMD_AN_MV_STAT_ANEG 0x0100 +#define MDIO_MMD_AN_MV_STAT_LOCAL_RX 0x1000 +#define MDIO_MMD_AN_MV_STAT_REMOTE_RX 0x2000 +#define MDIO_MMD_AN_MV_STAT_LOCAL_MASTER 0x4000 +#define MDIO_MMD_AN_MV_STAT_MS_CONF_FAULT 0x8000 + +#define MDIO_MMD_PCS_MV_100BT1_STAT1 33032 +#define MDIO_MMD_PCS_MV_100BT1_STAT1_IDLE_ERROR 0x00FF +#define MDIO_MMD_PCS_MV_100BT1_STAT1_JABBER 0x0100 +#define MDIO_MMD_PCS_MV_100BT1_STAT1_LINK 0x0200 +#define MDIO_MMD_PCS_MV_100BT1_STAT1_LOCAL_RX 0x1000 +#define MDIO_MMD_PCS_MV_100BT1_STAT1_REMOTE_RX 0x2000 +#define MDIO_MMD_PCS_MV_100BT1_STAT1_LOCAL_MASTER 0x4000 + +#define MDIO_MMD_PCS_MV_100BT1_STAT2 33033 +#define MDIO_MMD_PCS_MV_100BT1_STAT2_JABBER 0x0001 +#define MDIO_MMD_PCS_MV_100BT1_STAT2_POL 0x0002 +#define MDIO_MMD_PCS_MV_100BT1_STAT2_LINK 0x0004 +#define MDIO_MMD_PCS_MV_100BT1_STAT2_ANGE 0x0008 + +static int mv88q2xxx_soft_reset(struct phy_device *phydev) +{ + int ret; + int val; + + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, + MDIO_PCS_1000BT1_CTRL, MDIO_PCS_1000BT1_CTRL_RESET); + if (ret < 0) + return ret; + + return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_PCS, + MDIO_PCS_1000BT1_CTRL, val, + !(val & MDIO_PCS_1000BT1_CTRL_RESET), + 50000, 600000, true); +} + +static int mv88q2xxx_read_link_gbit(struct phy_device *phydev) +{ + int ret; + bool link = false; + + /* Read vendor specific Auto-Negotiation status register to get local + * and remote receiver status according to software initialization + * guide. + */ + ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_MMD_AN_MV_STAT); + if (ret < 0) { + return ret; + } else if ((ret & MDIO_MMD_AN_MV_STAT_LOCAL_RX) && + (ret & MDIO_MMD_AN_MV_STAT_REMOTE_RX)) { + /* The link state is latched low so that momentary link + * drops can be detected. Do not double-read the status + * in polling mode to detect such short link drops except + * the link was already down. + */ + if (!phy_polling_mode(phydev) || !phydev->link) { + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_1000BT1_STAT); + if (ret < 0) + return ret; + else if (ret & MDIO_PCS_1000BT1_STAT_LINK) + link = true; + } + + if (!link) { + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_1000BT1_STAT); + if (ret < 0) + return ret; + else if (ret & MDIO_PCS_1000BT1_STAT_LINK) + link = true; + } + } + + phydev->link = link; + + return 0; +} + +static int mv88q2xxx_read_link_100m(struct phy_device *phydev) +{ + int ret; + + /* The link state is latched low so that momentary link + * drops can be detected. Do not double-read the status + * in polling mode to detect such short link drops except + * the link was already down. In case we are not polling, + * we always read the realtime status. + */ + if (!phy_polling_mode(phydev) || !phydev->link) { + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_100BT1_STAT1); + if (ret < 0) + return ret; + else if (ret & MDIO_MMD_PCS_MV_100BT1_STAT1_LINK) + goto out; + } + + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_100BT1_STAT1); + if (ret < 0) + return ret; + +out: + /* Check if we have link and if the remote and local receiver are ok */ + if ((ret & MDIO_MMD_PCS_MV_100BT1_STAT1_LINK) && + (ret & MDIO_MMD_PCS_MV_100BT1_STAT1_LOCAL_RX) && + (ret & MDIO_MMD_PCS_MV_100BT1_STAT1_REMOTE_RX)) + phydev->link = true; + else + phydev->link = false; + + return 0; +} + +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); + else + ret = mv88q2xxx_read_link_100m(phydev); + + return ret; +} + +static int mv88q2xxx_read_status(struct phy_device *phydev) +{ + int ret; + + ret = mv88q2xxx_read_link(phydev); + if (ret < 0) + return ret; + + return genphy_c45_read_pma(phydev); +} + +static int mv88q2xxx_get_features(struct phy_device *phydev) +{ + int ret; + + ret = genphy_c45_pma_read_abilities(phydev); + if (ret) + return ret; + + /* We need to read the baset1 extended abilities manually because the + * PHY does not signalize it has the extended abilities register + * available. + */ + ret = genphy_c45_pma_baset1_read_abilities(phydev); + if (ret) + return ret; + + /* The PHY signalizes it supports autonegotiation. Unfortunately, so + * far it was not possible to get a link even when following the init + * 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); + + return 0; +} + +static int mv88q2xxx_config_aneg(struct phy_device *phydev) +{ + int ret; + + ret = genphy_c45_config_aneg(phydev); + if (ret) + return ret; + + return mv88q2xxx_soft_reset(phydev); +} + +static int mv88q2xxx_config_init(struct phy_device *phydev) +{ + int ret; + + /* The 88Q2XXX PHYs do have the extended ability register available, but + * register MDIO_PMA_EXTABLE where they should signalize it does not + * work according to specification. Therefore, we force it here. + */ + phydev->pma_extable = MDIO_PMA_EXTABLE_BT1; + + /* Read the current PHY configuration */ + ret = genphy_c45_read_pma(phydev); + if (ret) + return ret; + + return mv88q2xxx_config_aneg(phydev); +} + +static int mv88q2xxxx_get_sqi(struct phy_device *phydev) +{ + int ret; + + if (phydev->speed == SPEED_100) { + /* Read the SQI from the vendor specific receiver status + * register + */ + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, 0x8230); + if (ret < 0) + return ret; + + ret = ret >> 12; + } else { + /* Read from vendor specific registers, they are not documented + * but can be found in the Software Initialization Guide. Only + * revisions >= A0 are supported. + */ + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, 0xFC5D, 0x00FF, 0x00AC); + if (ret < 0) + return ret; + + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, 0xfc88); + if (ret < 0) + return ret; + } + + return ret & 0x0F; +} + +static int mv88q2xxxx_get_sqi_max(struct phy_device *phydev) +{ + return 15; +} + +static struct phy_driver mv88q2xxx_driver[] = { + { + .phy_id = MARVELL_PHY_ID_88Q2110, + .phy_id_mask = MARVELL_PHY_ID_MASK, + .name = "mv88q2110", + .get_features = mv88q2xxx_get_features, + .config_aneg = mv88q2xxx_config_aneg, + .config_init = mv88q2xxx_config_init, + .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, + }, +}; + +module_phy_driver(mv88q2xxx_driver); + +static struct mdio_device_id __maybe_unused mv88q2xxx_tbl[] = { + { MARVELL_PHY_ID_88Q2110, MARVELL_PHY_ID_MASK }, + { /*sentinel*/ } +}; +MODULE_DEVICE_TABLE(mdio, mv88q2xxx_tbl); + +MODULE_DESCRIPTION("Marvell 88Q2XXX 100/1000BASE-T1 Automotive Ethernet PHY driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h index 0f06c2287b527..9b54c4f0677f8 100644 --- a/include/linux/marvell_phy.h +++ b/include/linux/marvell_phy.h @@ -25,6 +25,7 @@ #define MARVELL_PHY_ID_88X3310 0x002b09a0 #define MARVELL_PHY_ID_88E2110 0x002b09b0 #define MARVELL_PHY_ID_88X2222 0x01410f10 +#define MARVELL_PHY_ID_88Q2110 0x002b0980 /* Marvel 88E1111 in Finisar SFP module with modified PHY ID */ #define MARVELL_PHY_ID_88E1111_FINISAR 0x01ff0cc0