aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
diff options
context:
space:
mode:
authorLABBE Corentin <clabbe.montjoie@gmail.com>2017-05-24 09:16:47 +0200
committerDavid S. Miller <davem@davemloft.net>2017-05-25 13:08:35 -0400
commitca84dfb9ab70849c2b01f30d658a8900cff9889d (patch)
treef93b8455ab7626c43d9e266ade6bf907fa733045 /drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
parentnet-next: stmmac: Convert old_link to bool (diff)
downloadlinux-dev-ca84dfb9ab70849c2b01f30d658a8900cff9889d.tar.xz
linux-dev-ca84dfb9ab70849c2b01f30d658a8900cff9889d.zip
net-next: stmmac: rework the speed selection
The current stmmac_adjust_link() part which handle speed have some if (has_platform) code and my dwmac-sun8i will add more of them. So we need to handle better speed selection. Moreover the struct link member speed and port are hard to guess their purpose. And their unique usage are to be combined for writing speed. So this patch replace speed/port by simpler speed10/speed100/speed1000/speed_mask variables. In dwmac4_core_init and dwmac1000_core_init, port/speed value was used directly without using the struct link. This patch convert also their usage to speedxxx. Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index f3d9305e5f70..8a86340ff2d3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -45,15 +45,17 @@ static void dwmac1000_core_init(struct mac_device_info *hw, int mtu)
if (hw->ps) {
value |= GMAC_CONTROL_TE;
- if (hw->ps == SPEED_1000) {
- value &= ~GMAC_CONTROL_PS;
- } else {
- value |= GMAC_CONTROL_PS;
-
- if (hw->ps == SPEED_10)
- value &= ~GMAC_CONTROL_FES;
- else
- value |= GMAC_CONTROL_FES;
+ value &= ~hw->link.speed_mask;
+ switch (hw->ps) {
+ case SPEED_1000:
+ value |= hw->link.speed1000;
+ break;
+ case SPEED_100:
+ value |= hw->link.speed100;
+ break;
+ case SPEED_10:
+ value |= hw->link.speed10;
+ break;
}
}
@@ -531,9 +533,11 @@ struct mac_device_info *dwmac1000_setup(void __iomem *ioaddr, int mcbins,
mac->mac = &dwmac1000_ops;
mac->dma = &dwmac1000_dma_ops;
- mac->link.port = GMAC_CONTROL_PS;
mac->link.duplex = GMAC_CONTROL_DM;
- mac->link.speed = GMAC_CONTROL_FES;
+ mac->link.speed10 = GMAC_CONTROL_PS;
+ mac->link.speed100 = GMAC_CONTROL_PS | GMAC_CONTROL_FES;
+ mac->link.speed1000 = 0;
+ mac->link.speed_mask = GMAC_CONTROL_PS | GMAC_CONTROL_FES;
mac->mii.addr = GMAC_MII_ADDR;
mac->mii.data = GMAC_MII_DATA;
mac->mii.addr_shift = 11;