You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
net-next: stmmac: Add dwmac-sun8i
The dwmac-sun8i is a heavy hacked version of stmmac hardware by allwinner. In fact the only common part is the descriptor management and the first register function. Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
ce5a4ff3c5
commit
9f93ac8d40
@@ -145,6 +145,17 @@ config DWMAC_SUNXI
|
||||
This selects Allwinner SoC glue layer support for the
|
||||
stmmac device driver. This driver is used for A20/A31
|
||||
GMAC ethernet controller.
|
||||
|
||||
config DWMAC_SUN8I
|
||||
tristate "Allwinner sun8i GMAC support"
|
||||
default ARCH_SUNXI
|
||||
depends on OF && (ARCH_SUNXI || COMPILE_TEST)
|
||||
---help---
|
||||
Support for Allwinner H3 A83T A64 EMAC ethernet controllers.
|
||||
|
||||
This selects Allwinner SoC glue layer support for the
|
||||
stmmac device driver. This driver is used for H3/A83T/A64
|
||||
EMAC ethernet controller.
|
||||
endif
|
||||
|
||||
config STMMAC_PCI
|
||||
|
||||
@@ -16,6 +16,7 @@ obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o
|
||||
obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o
|
||||
obj-$(CONFIG_DWMAC_STM32) += dwmac-stm32.o
|
||||
obj-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o
|
||||
obj-$(CONFIG_DWMAC_SUN8I) += dwmac-sun8i.o
|
||||
obj-$(CONFIG_DWMAC_DWC_QOS_ETH) += dwmac-dwc-qos-eth.o
|
||||
obj-$(CONFIG_DWMAC_GENERIC) += dwmac-generic.o
|
||||
stmmac-platform-objs:= stmmac_platform.o
|
||||
|
||||
990
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
Normal file
990
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -235,6 +235,17 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv)
|
||||
else if ((clk_rate >= CSR_F_250M) && (clk_rate < CSR_F_300M))
|
||||
priv->clk_csr = STMMAC_CSR_250_300M;
|
||||
}
|
||||
|
||||
if (priv->plat->has_sun8i) {
|
||||
if (clk_rate > 160000000)
|
||||
priv->clk_csr = 0x03;
|
||||
else if (clk_rate > 80000000)
|
||||
priv->clk_csr = 0x02;
|
||||
else if (clk_rate > 40000000)
|
||||
priv->clk_csr = 0x01;
|
||||
else
|
||||
priv->clk_csr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void print_pkt(unsigned char *buf, int len)
|
||||
@@ -3955,6 +3966,10 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
|
||||
|
||||
priv->hw = mac;
|
||||
|
||||
/* dwmac-sun8i only work in chain mode */
|
||||
if (priv->plat->has_sun8i)
|
||||
chain_mode = 1;
|
||||
|
||||
/* To use the chained or ring mode */
|
||||
if (priv->synopsys_id >= DWMAC_CORE_4_00) {
|
||||
priv->hw->mode = &dwmac4_ring_mode_ops;
|
||||
|
||||
@@ -309,6 +309,12 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
|
||||
struct device_node *np, struct device *dev)
|
||||
{
|
||||
bool mdio = true;
|
||||
static const struct of_device_id need_mdio_ids[] = {
|
||||
{ .compatible = "snps,dwc-qos-ethernet-4.10" },
|
||||
{ .compatible = "allwinner,sun8i-a83t-emac" },
|
||||
{ .compatible = "allwinner,sun8i-h3-emac" },
|
||||
{ .compatible = "allwinner,sun50i-a64-emac" },
|
||||
};
|
||||
|
||||
/* If phy-handle property is passed from DT, use it as the PHY */
|
||||
plat->phy_node = of_parse_phandle(np, "phy-handle", 0);
|
||||
@@ -325,8 +331,7 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
|
||||
mdio = false;
|
||||
}
|
||||
|
||||
/* exception for dwmac-dwc-qos-eth glue logic */
|
||||
if (of_device_is_compatible(np, "snps,dwc-qos-ethernet-4.10")) {
|
||||
if (of_match_node(need_mdio_ids, np)) {
|
||||
plat->mdio_node = of_get_child_by_name(np, "mdio");
|
||||
} else {
|
||||
/**
|
||||
|
||||
@@ -186,6 +186,7 @@ struct plat_stmmacenet_data {
|
||||
struct reset_control *stmmac_rst;
|
||||
struct stmmac_axi *axi;
|
||||
int has_gmac4;
|
||||
bool has_sun8i;
|
||||
bool tso_en;
|
||||
int mac_port_sel_speed;
|
||||
bool en_tx_lpi_clockgating;
|
||||
|
||||
Reference in New Issue
Block a user