Skip to content

Commit

Permalink
Merge branch 'net-stmmac-deprecate-snps-en-tx-lpi-clockgating-property'
Browse files Browse the repository at this point in the history
Russell King says:

====================
net: stmmac: deprecate "snps,en-tx-lpi-clockgating" property

This series deprecates the "snps,en-tx-lpi-clockgating" property for
stmmac.

MII Transmit clock gating, where the MAC hardware supports gating this
clock, is a function of the connected PHY capabilities, which it
reports through its status register.

GMAC versions that support transmit clock gating twiddle the LPITCSE
bit accordingly in the LPI control/status register, which is handled
by the GMAC core specific code.

So, "snps,en-tx-lpi-clockgating" not something that is a GMAC property,
but is a work-around for phylib not providing an interface to determine
whether the PHY allows the transmit clock to be disabled.

This series converts the two SoCs that make use of this property (which,
I hasten to add, is set in the SoC code) to use the PHY capability bit
instead of a DT property, then removes the DT property from the .dtsi,
deprecates it in the snps,dwmac binding, and finally in the stmmac code.

I am expecting some discussion on how to merge this, as I think the
order in which these changes is made is important - we don't want to
deprecate the old way until the new code has landed.
====================

Link: https://patch.msgid.link/Z9FVHEf3uUqtKzyt@shell.armlinux.org.uk
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Paolo Abeni committed Mar 19, 2025
2 parents 4df2ebf + cf0a96d commit 7602eb8
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/net/snps,dwmac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ properties:

snps,en-tx-lpi-clockgating:
$ref: /schemas/types.yaml#/definitions/flag
deprecated: true
description:
Enable gating of the MAC TX clock during TX low-power mode

Expand Down
1 change: 0 additions & 1 deletion arch/arm/boot/dts/st/stm32mp151.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,6 @@
st,syscon = <&syscfg 0x4>;
snps,mixed-burst;
snps,pbl = <2>;
snps,en-tx-lpi-clockgating;
snps,axi-config = <&stmmac_axi_config_0>;
snps,tso;
access-controllers = <&etzpc 94>;
Expand Down
2 changes: 0 additions & 2 deletions arch/riscv/boot/dts/starfive/jh7110.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,6 @@
snps,force_thresh_dma_mode;
snps,axi-config = <&stmmac_axi_setup>;
snps,tso;
snps,en-tx-lpi-clockgating;
snps,txpbl = <16>;
snps,rxpbl = <16>;
starfive,syscon = <&aon_syscon 0xc 0x12>;
Expand Down Expand Up @@ -1053,7 +1052,6 @@
snps,force_thresh_dma_mode;
snps,axi-config = <&stmmac_axi_setup>;
snps,tso;
snps,en-tx-lpi-clockgating;
snps,txpbl = <16>;
snps,rxpbl = <16>;
starfive,syscon = <&sys_syscon 0x90 0x2>;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;

dwmac->dev = &pdev->dev;
plat_dat->flags |= STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP;
plat_dat->bsp_priv = dwmac;
plat_dat->dma_cfg->dche = true;

Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ static int stm32_dwmac_probe(struct platform_device *pdev)
return ret;
}

plat_dat->flags |= STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP;
plat_dat->bsp_priv = dwmac;

ret = stm32_dwmac_init(plat_dat, false);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/stmicro/stmmac/stmmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ struct stmmac_priv {
struct timer_list eee_ctrl_timer;
int lpi_irq;
u32 tx_lpi_timer;
bool tx_lpi_clk_stop;
bool eee_enabled;
bool eee_active;
bool eee_sw_timer_en;
Expand Down
16 changes: 12 additions & 4 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,7 @@ static void stmmac_try_to_start_sw_lpi(struct stmmac_priv *priv)
/* Check and enter in LPI mode */
if (!priv->tx_path_in_lpi_mode)
stmmac_set_lpi_mode(priv, priv->hw, STMMAC_LPI_FORCED,
priv->plat->flags & STMMAC_FLAG_EN_TX_LPI_CLOCKGATING,
0);
priv->tx_lpi_clk_stop, 0);
}

/**
Expand Down Expand Up @@ -1104,13 +1103,18 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,

priv->eee_enabled = true;

/* Update the transmit clock stop according to PHY capability if
* the platform allows
*/
if (priv->plat->flags & STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP)
priv->tx_lpi_clk_stop = tx_clk_stop;

stmmac_set_eee_timer(priv, priv->hw, STMMAC_DEFAULT_LIT_LS,
STMMAC_DEFAULT_TWT_LS);

/* Try to cnfigure the hardware timer. */
ret = stmmac_set_lpi_mode(priv, priv->hw, STMMAC_LPI_TIMER,
priv->plat->flags & STMMAC_FLAG_EN_TX_LPI_CLOCKGATING,
priv->tx_lpi_timer);
priv->tx_lpi_clk_stop, priv->tx_lpi_timer);

if (ret) {
/* Hardware timer mode not supported, or value out of range.
Expand Down Expand Up @@ -1269,6 +1273,10 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
if (!(priv->plat->flags & STMMAC_FLAG_RX_CLK_RUNS_IN_LPI))
priv->phylink_config.eee_rx_clk_stop_enable = true;

/* Set the default transmit clock stop bit based on the platform glue */
priv->tx_lpi_clk_stop = priv->plat->flags &
STMMAC_FLAG_EN_TX_LPI_CLOCKGATING;

mdio_bus_data = priv->plat->mdio_bus_data;
if (mdio_bus_data)
priv->phylink_config.default_an_inband =
Expand Down
5 changes: 4 additions & 1 deletion drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,11 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
plat->force_sf_dma_mode =
of_property_read_bool(np, "snps,force_sf_dma_mode");

if (of_property_read_bool(np, "snps,en-tx-lpi-clockgating"))
if (of_property_read_bool(np, "snps,en-tx-lpi-clockgating")) {
dev_warn(&pdev->dev,
"OF property snps,en-tx-lpi-clockgating is deprecated, please convert driver to use STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP\n");
plat->flags |= STMMAC_FLAG_EN_TX_LPI_CLOCKGATING;
}

/* Set the maxmtu to a default of JUMBO_LEN in case the
* parameter is not present in the device tree.
Expand Down
3 changes: 2 additions & 1 deletion include/linux/stmmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ struct dwmac4_addrs {
#define STMMAC_FLAG_INT_SNAPSHOT_EN BIT(9)
#define STMMAC_FLAG_RX_CLK_RUNS_IN_LPI BIT(10)
#define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING BIT(11)
#define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY BIT(12)
#define STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP BIT(12)
#define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY BIT(13)

struct plat_stmmacenet_data {
int bus_id;
Expand Down

0 comments on commit 7602eb8

Please sign in to comment.