From nobody Thu Dec 18 18:51:34 2025 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (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 4780F30C360; Mon, 3 Nov 2025 12:19:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762172350; cv=none; b=mC3IpBga/0JYQpGNg5VcM66GpRs6+etzMpiFFQZYrqHbKtQzTjkRURKD98RU8cG3OYpM/OgnyCdsJUBwmxR5pHKTyMc0CIw1U0cwl0vHSGboNKI1Nks5AXZIsNn8jkqaQm/UjhhGajYPTj27tkDuRB/KfA4jHO6uXGz3numu1Zs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762172350; c=relaxed/simple; bh=YtyC0SRDrpKEBzGnewtGhden22b6OkdiEw8CPdvYHrI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HRoUlNDoqaK4JfkU+yDK9aiJfN2fq7IlOobY1Nk3uhtlE6IRjmfATbKOGV8yCe0OnkYU40McVpN2tSDz2rCxVMIj/hd51dVHdwtZbiUHGVQDyMmwWPOnsQrsegsDQ4NSFonb8cqeXwOEm6OtL9nh7QRpfi7iUQB7giDtfKOyXAo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.98.2) (envelope-from ) id 1vFtWZ-000000000oY-2BM3; Mon, 03 Nov 2025 12:19:03 +0000 Date: Mon, 3 Nov 2025 12:19:00 +0000 From: Daniel Golle To: Hauke Mehrtens , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Simon Horman , Russell King , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andreas Schirm , Lukas Stockmann , Alexander Sverdlin , Peter Christen , Avinash Jayaraman , Bing tao Xu , Liang Xu , Juraj Povazanec , "Fanni (Fang-Yi) Chan" , "Benny (Ying-Tsan) Weng" , "Livia M. Rosu" , John Crispin Subject: [PATCH net-next v7 03/12] net: dsa: lantiq_gswip: support Energy Efficient Ethernet Message-ID: <753e45acb25e185689ca1afd8a9bd0c199d1c15b.1762170107.git.daniel@makrotopia.org> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce support for Energy Efficient Ethernet (EEE) on hardware version 2.2 or later. Signed-off-by: Daniel Golle Reviewed-by: Russell King (Oracle) --- v7: no changes v6: no changes v5: no changes v4: no changes v3: no changes v2: no changes since RFC: no changes drivers/net/dsa/lantiq/lantiq_gswip.h | 7 +++ drivers/net/dsa/lantiq/lantiq_gswip_common.c | 47 ++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.h b/drivers/net/dsa/lantiq= /lantiq_gswip.h index fb7d2c02bde9..56de869fc472 100644 --- a/drivers/net/dsa/lantiq/lantiq_gswip.h +++ b/drivers/net/dsa/lantiq/lantiq_gswip.h @@ -2,6 +2,7 @@ #ifndef __LANTIQ_GSWIP_H #define __LANTIQ_GSWIP_H =20 +#include #include #include #include @@ -193,6 +194,12 @@ #define GSWIP_MAC_CTRL_2p(p) (0x905 + ((p) * 0xC)) #define GSWIP_MAC_CTRL_2_LCHKL BIT(2) /* Frame Length Check Long Enable */ #define GSWIP_MAC_CTRL_2_MLEN BIT(3) /* Maximum Untagged Frame Lnegth */ +#define GSWIP_MAC_CTRL_4p(p) (0x907 + ((p) * 0xC)) +#define GSWIP_MAC_CTRL_4_LPIEN BIT(7) /* LPI Mode Enable */ +#define GSWIP_MAC_CTRL_4_GWAIT_MASK GENMASK(14, 8) /* LPI Wait Time 1G */ +#define GSWIP_MAC_CTRL_4_GWAIT(t) u16_encode_bits((t), GSWIP_MAC_CTRL_4_G= WAIT_MASK) +#define GSWIP_MAC_CTRL_4_WAIT_MASK GENMASK(6, 0) /* LPI Wait Time 100M */ +#define GSWIP_MAC_CTRL_4_WAIT(t) u16_encode_bits((t), GSWIP_MAC_CTRL_4_WA= IT_MASK) =20 /* Ethernet Switch Fetch DMA Port Control Register */ #define GSWIP_FDMA_PCTRLp(p) (0xA80 + ((p) * 0x6)) diff --git a/drivers/net/dsa/lantiq/lantiq_gswip_common.c b/drivers/net/dsa= /lantiq/lantiq_gswip_common.c index f130bf6642a7..092187603dea 100644 --- a/drivers/net/dsa/lantiq/lantiq_gswip_common.c +++ b/drivers/net/dsa/lantiq/lantiq_gswip_common.c @@ -1537,6 +1537,49 @@ static int gswip_get_sset_count(struct dsa_switch *d= s, int port, int sset) return ARRAY_SIZE(gswip_rmon_cnt); } =20 +static int gswip_set_mac_eee(struct dsa_switch *ds, int port, + struct ethtool_keee *e) +{ + if (e->tx_lpi_timer > 0x7f) + return -EINVAL; + + return 0; +} + +static void gswip_phylink_mac_disable_tx_lpi(struct phylink_config *config) +{ + struct dsa_port *dp =3D dsa_phylink_to_port(config); + struct gswip_priv *priv =3D dp->ds->priv; + + regmap_clear_bits(priv->gswip, GSWIP_MAC_CTRL_4p(dp->index), + GSWIP_MAC_CTRL_4_LPIEN); +} + +static int gswip_phylink_mac_enable_tx_lpi(struct phylink_config *config, + u32 timer, bool tx_clock_stop) +{ + struct dsa_port *dp =3D dsa_phylink_to_port(config); + struct gswip_priv *priv =3D dp->ds->priv; + + return regmap_update_bits(priv->gswip, GSWIP_MAC_CTRL_4p(dp->index), + GSWIP_MAC_CTRL_4_LPIEN | + GSWIP_MAC_CTRL_4_GWAIT_MASK | + GSWIP_MAC_CTRL_4_WAIT_MASK, + GSWIP_MAC_CTRL_4_LPIEN | + GSWIP_MAC_CTRL_4_GWAIT(timer) | + GSWIP_MAC_CTRL_4_WAIT(timer)); +} + +static bool gswip_support_eee(struct dsa_switch *ds, int port) +{ + struct gswip_priv *priv =3D ds->priv; + + if (GSWIP_VERSION_GE(priv, GSWIP_VERSION_2_2)) + return true; + + return false; +} + static struct phylink_pcs *gswip_phylink_mac_select_pcs(struct phylink_con= fig *config, phy_interface_t interface) { @@ -1553,6 +1596,8 @@ static const struct phylink_mac_ops gswip_phylink_mac= _ops =3D { .mac_config =3D gswip_phylink_mac_config, .mac_link_down =3D gswip_phylink_mac_link_down, .mac_link_up =3D gswip_phylink_mac_link_up, + .mac_disable_tx_lpi =3D gswip_phylink_mac_disable_tx_lpi, + .mac_enable_tx_lpi =3D gswip_phylink_mac_enable_tx_lpi, .mac_select_pcs =3D gswip_phylink_mac_select_pcs, }; =20 @@ -1580,6 +1625,8 @@ static const struct dsa_switch_ops gswip_switch_ops = =3D { .get_strings =3D gswip_get_strings, .get_ethtool_stats =3D gswip_get_ethtool_stats, .get_sset_count =3D gswip_get_sset_count, + .set_mac_eee =3D gswip_set_mac_eee, + .support_eee =3D gswip_support_eee, }; =20 void gswip_disable_switch(struct gswip_priv *priv) --=20 2.51.2