Skip to content

Commit

Permalink
Merge branch 'dwmac-mediatek'
Browse files Browse the repository at this point in the history
Biao Huang says:

====================
complete dwmac-mediatek driver and fix flow control issue

Changes in v2:
        patch#1: there is no extra action in mediatek_dwmac_remove, remove it

v1:
This series mainly complete dwmac-mediatek driver:
        1. add power on/off operations for dwmac-mediatek.
        2. disable rx watchdog to reduce rx path reponding time.
        3. change the default value of tx-frames from 25 to 1, so
           ptp4l will test pass by default.

and also fix the issue that flow control won't be disabled any more
once being enabled.
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Jun 6, 2019
2 parents 478db1f + ee326fd commit dceebd4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/stmicro/stmmac/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ struct stmmac_safety_stats {
#define STMMAC_COAL_TX_TIMER 1000
#define STMMAC_MAX_COAL_TX_TICK 100000
#define STMMAC_TX_MAX_FRAMES 256
#define STMMAC_TX_FRAMES 25
#define STMMAC_TX_FRAMES 1

/* Packets types */
enum packets_types {
Expand Down
8 changes: 8 additions & 0 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_net.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/stmmac.h>

Expand Down Expand Up @@ -298,6 +299,9 @@ static int mediatek_dwmac_init(struct platform_device *pdev, void *priv)
return ret;
}

pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);

return 0;
}

Expand All @@ -307,6 +311,9 @@ static void mediatek_dwmac_exit(struct platform_device *pdev, void *priv)
const struct mediatek_dwmac_variant *variant = plat->variant;

clk_bulk_disable_unprepare(variant->num_clks, plat->clks);

pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
}

static int mediatek_dwmac_probe(struct platform_device *pdev)
Expand Down Expand Up @@ -349,6 +356,7 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)
plat_dat->has_gmac4 = 1;
plat_dat->has_gmac = 0;
plat_dat->pmt = 0;
plat_dat->riwt_off = 1;
plat_dat->maxmtu = ETH_DATA_LEN;
plat_dat->bsp_priv = priv_plat;
plat_dat->init = mediatek_dwmac_init;
Expand Down
8 changes: 6 additions & 2 deletions drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,23 +479,27 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex,
if (fc & FLOW_RX) {
pr_debug("\tReceive Flow-Control ON\n");
flow |= GMAC_RX_FLOW_CTRL_RFE;
writel(flow, ioaddr + GMAC_RX_FLOW_CTRL);
}
writel(flow, ioaddr + GMAC_RX_FLOW_CTRL);

if (fc & FLOW_TX) {
pr_debug("\tTransmit Flow-Control ON\n");

if (duplex)
pr_debug("\tduplex mode: PAUSE %d\n", pause_time);

for (queue = 0; queue < tx_cnt; queue++) {
flow |= GMAC_TX_FLOW_CTRL_TFE;
flow = GMAC_TX_FLOW_CTRL_TFE;

if (duplex)
flow |=
(pause_time << GMAC_TX_FLOW_CTRL_PT_SHIFT);

writel(flow, ioaddr + GMAC_QX_TX_FLOW_CTRL(queue));
}
} else {
for (queue = 0; queue < tx_cnt; queue++)
writel(0, ioaddr + GMAC_QX_TX_FLOW_CTRL(queue));
}
}

Expand Down

0 comments on commit dceebd4

Please sign in to comment.