From f3a840a49ef0c2efaceadcbf8974ec92c49166fe Mon Sep 17 00:00:00 2001 From: David Wu Date: Mon, 8 May 2023 18:14:20 +0800 Subject: [PATCH] ethernet: stmmac: Add flow ctrl configuration from DTB If flow control is configured in DTB, the priority is the highest, otherwise the default value in the code is used. Signed-off-by: David Wu Change-Id: I21afeb537426473d6edf7ce40317cdaf99d64a93 --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++-- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 +++ include/linux/stmmac.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e8358a1a02df..705b708c2c4b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -826,8 +826,8 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex) { u32 tx_cnt = priv->plat->tx_queues_to_use; - stmmac_flow_ctrl(priv, priv->hw, duplex, priv->flow_ctrl, - priv->pause, tx_cnt); + stmmac_flow_ctrl(priv, priv->hw, duplex, priv->flow_ctrl & priv->plat->flow_ctrl, + priv->pause, tx_cnt); } static void stmmac_validate(struct phylink_config *config, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 6539b9276c09..471c8c3517c6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -570,6 +570,9 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) of_property_read_u32(np, "snps,ps-speed", &plat->mac_port_sel_speed); + if (of_property_read_u32(np, "snps,flow-ctrl", &plat->flow_ctrl)) + plat->flow_ctrl = FLOW_AUTO; + plat->axi = stmmac_axi_setup(pdev); rc = stmmac_mtl_setup(pdev, plat); diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 9e8df66738c3..90f8ef6e457c 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -173,6 +173,7 @@ struct plat_stmmacenet_data { int rx_fifo_size; int dma_tx_size; int dma_rx_size; + int flow_ctrl; u32 addr64; u32 rx_queues_to_use; u32 tx_queues_to_use;