Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1299594lqd; Thu, 25 Apr 2024 11:06:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9fGxfIW1h9zT6H3TuqXG2nFkBr//eYu6OqYIxGF0XxwJMlfQl3UbddLsm12YQhRZp41CueQVfTEP+ljey9vomD5fI4oZVFbCFIADwjw== X-Google-Smtp-Source: AGHT+IGRUQBOhs+ulQ9qn5Y72xuPPFqB6jDnzPBzGWjM0tSUHJTsFPA9ntMr2pYqwogPa4kvT+sk X-Received: by 2002:a05:6512:3e08:b0:51c:1fb4:2329 with SMTP id i8-20020a0565123e0800b0051c1fb42329mr67911lfv.65.1714068415874; Thu, 25 Apr 2024 11:06:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714068415; cv=pass; d=google.com; s=arc-20160816; b=D4VyaRTC9GQhQhcKnx+KzEQ3gT2oHq8q855AubDpXjPA9FVFo7WJifON2OeAZYlmyj 414snCNtI7RQnNuGs87S1RGN3K7H/b3WTCG4P42xg3MyZR7+Av9Jvq93NC7W/iCvGYNM 5hdoR84erW7uKKP09oR+pwqb+kPxnwoVkLIH9YMKIATf5LJGdcf1LrGGGR/zCS9Z2PKG N/kk5iG+2tbZOnC06R3xvRkfBCuirOqWqUHlM8J3YtRbK8CtpFVSh9hFywsBNPFoYcZx wrMYCrjDeAD67dDSM0h8bTlxYdPu8yJ4kyXVNv3D2B1UVp8q82w4f0HS3rDHf6U7QSvJ RdOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+nXxaAUOW4lfzHbDCaI6nz0stAky/8ykgKzIVjuNI0U=; fh=XfG3To2iOTA5O8FMXEBj/z4p7vH51SLWWAoCGfMh1iA=; b=u7gOgUX5eRzCrjV5+f4Kcro92RMLFQh2jjDTDAzPe+k41LfoUKEdhlNIL5clmm+Kgz XEcYvtV4BNJ7ZTFVZkMQZj8E5ScdszR8uTUd2cwYoorK7Efbue0Map2MPcDord6q+0iJ EzIxy8Xo33bU9YfPPdNTFWmMY0pycOvQTBoA+RVTV0m0QupGAxBREIdtE8qIDJPViN3Q 4Rs2IsWzrpdWJ5EbO9XIHFYZ+QU0HmTrDbhcXGdlFdCHXLwnwBVJVmTk6eTRno+WW73t YvmT5X8z2eLdDUQ24Wjh5rlr/BDr7dbjuPOF3K/jPAnnMWVuLFrfMQjafz5lKRqXjbpG n4Kw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="B/tLuWPl"; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-158819-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158819-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id e6-20020a170906c00600b00a4e85cde33fsi10415755ejz.886.2024.04.25.11.06.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 11:06:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158819-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="B/tLuWPl"; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-158819-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158819-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EB3D41F23B5D for ; Thu, 25 Apr 2024 15:38:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6CA0414BF8D; Thu, 25 Apr 2024 15:37:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="B/tLuWPl" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (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 2781184D2D; Thu, 25 Apr 2024 15:37:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714059475; cv=none; b=uELu/YQhykgLbU7hk1q6Q+6n9N5852ufpxIoShhTwQ+oVTB/o3jXe1fBcx0KQya8Hg8bG5dO0ERsdy2a7inhrOPYFGQ0KQvrXglDzFo/i3XWqiBIevnTkUQSYTWgika2sryJ1OafZ1udjrFeTq+EmCFwYllC41grgYDuJJyjau4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714059475; c=relaxed/simple; bh=TQ/IMaQSQUBfEjQdb7XmGSR/6+c5RT7iuARKdBoCyR4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cdCn2urSFcPjlSG9vXfQebeoFqgCVSDdS7FUjAaz06GnyhR5cmTiLoCH+IaUVAXt2Ce3xGPtNWAVpbqK1271VoX4g9IqTmntKI8nDf+MdQ4PcAP9WgqAw3yr6grWrBeMf3+Zw8ssLtntqbHJl6eb+7xNzyaGaBGMLVzQiJSavgc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=B/tLuWPl; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=+nXxaAUOW4lfzHbDCaI6nz0stAky/8ykgKzIVjuNI0U=; b=B/tLuWPlOLDKNO1iW2Ezj29OUk WTMG4duEi+g4B0typzSnuggrUlh9x2pZTGhPfKXGUUvCXYLFgH5IMK3cqlerAJgQfMVh3iKFJFkr0 KDEF6viTCHIuWiU3GplSzav2mpfHD229evx7m2eAWN6lKdeCEvHS/Q0NGqqEuJDCut40=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1s01AM-00Dzys-Pb; Thu, 25 Apr 2024 17:37:42 +0200 Date: Thu, 25 Apr 2024 17:37:42 +0200 From: Andrew Lunn To: Sky Huang Cc: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Daniel Golle , Qingfang Deng , Matthias Brugger , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Steven Liu Subject: Re: [PATCH 3/3] net: phy: mediatek: add support for built-in 2.5G ethernet PHY on MT7988 Message-ID: <9241a551-1547-41c6-aae2-54dd45e49c2f@lunn.ch> References: <20240425023325.15586-1-SkyLake.Huang@mediatek.com> <20240425023325.15586-4-SkyLake.Huang@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240425023325.15586-4-SkyLake.Huang@mediatek.com> > +static int mt7988_2p5ge_phy_config_init(struct phy_device *phydev) > +{ > + int ret, i; > + const struct firmware *fw; > + struct device *dev = &phydev->mdio.dev; > + struct device_node *np; > + void __iomem *pmb_addr; > + void __iomem *md32_en_cfg_base; > + struct mtk_i2p5ge_phy_priv *priv = phydev->priv; > + u16 reg; > + struct pinctrl *pinctrl; Reverse Christmas Tree please. > +static int mt7988_2p5ge_phy_config_aneg(struct phy_device *phydev) > +{ > + bool changed = false; > + u32 adv; > + int ret; > + > + if (phydev->autoneg == AUTONEG_DISABLE) { > + /* Configure half duplex with genphy_setup_forced, > + * because genphy_c45_pma_setup_forced does not support. > + */ The English in that comment is wrong. Ah, it appears to be a copy/paste, e.g. from mxl-gpy.c. In fact, a lot of this function is identical to gpy_config_aneg(). Maybe it should be pulled out into a helper. > +static int mt7988_2p5ge_phy_get_features(struct phy_device *phydev) > +{ > + int ret; > + > + ret = genphy_read_abilities(phydev); > + if (ret) > + return ret; > + > + /* We don't support HDX at MAC layer on mt7988. > + * So mask phy's HDX capabilities, too. > + */ This comment seems to contradict the comment above? Also, this code does not mask anything, it sets bits. What does genphy_read_abilities() find out about the device? If the hardware confirms to the standard, it should not indicate is supports 1/2 duplex, genphy_read_abilities() should then not return those link modes, but it should return 10, 100 and 1000 full duplex. > + linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, > + phydev->supported); > + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, > + phydev->supported); > + linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, > + phydev->supported); > + linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, > + phydev->supported); > + linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported); What does genphy_c45_pma_read_abilities() report about the device? > +static int mt7988_2p5ge_phy_read_status(struct phy_device *phydev) > +{ > + int ret; > + > + ret = genphy_update_link(phydev); > + if (ret) > + return ret; > + > + phydev->speed = SPEED_UNKNOWN; > + phydev->duplex = DUPLEX_UNKNOWN; > + phydev->pause = 0; > + phydev->asym_pause = 0; > + > + if (phydev->autoneg == AUTONEG_ENABLE) { > + if (phydev->autoneg_complete) { > + ret = genphy_c45_read_lpa(phydev); > + if (ret < 0) > + return ret; > + > + /* Read the link partner's 1G advertisement */ > + ret = phy_read(phydev, MII_STAT1000); > + if (ret < 0) > + return ret; > + mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, ret); > + } else if (!linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, > + phydev->advertising) && > + linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, > + phydev->advertising)) { > + extend_an_new_lp_cnt_limit(phydev); > + } A comment about what is happening here would be good. > + } else if (phydev->autoneg == AUTONEG_DISABLE) { > + linkmode_zero(phydev->lp_advertising); > + } This if does not make much sense. > + ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LINK_STATUS_MISC); > + if (ret < 0) > + return ret; > + phydev->duplex = (ret & MTK_PHY_FDX_ENABLE) ? DUPLEX_FULL : DUPLEX_HALF; Do does it support half duplex or not? Andrew