Skip to content

Commit

Permalink
stmmac: add DT property so JL2101 can be loaded
Browse files Browse the repository at this point in the history
This adds a DT property jl2xx1_delay to the stmmac driver, it accepts
an integer value in millesecond

Setting the jl2xx1_delay property under the ethernet node to any value
larger than 0 will enable the PHY SoC handling for JL2xx1:
1. Stmmac driver waits the given delay before DMA engine initialized
2. Specific code injected through MDIO before MII bus initialized

The default value is 0, which will disable the handling. And 1500(ms)
is suggested for JL2101, which will delay the DMA engien initializa-
tion by 1.5 second, and inject the code before MII bus initialization

Co-authored-by: Portisch <hugo.portisch@yahoo.de>
  • Loading branch information
7Ji and Portisch committed Jul 24, 2022
1 parent 5a21a03 commit 588b389
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Documentation/devicetree/bindings/net/stmmac.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ Optional properties:
MAC HW capability register.
- mdio: with compatible = "snps,dwmac-mdio", create and register mdio bus.

- JL2XX1:
- jl2xx1_delay: add property with a value bigger than zero enables jl2xx1
PHY SoC handling, integer (delay in millesecond).
default 0, suggested 1500 for JL2101

Examples:

stmmac_axi_setup: stmmac-axi-config {
Expand Down
14 changes: 14 additions & 0 deletions drivers/net/ethernet/stmicro/stmmac/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ config STMMAC_PLATFORM

if STMMAC_PLATFORM

config STMMAC_JL2XX1
tristate "Allow STMMAC delay/MAC inject for JL2XXX"
default n
depends on STMMAC_PLATFORM
---help---
This allows the STMMAC driver to be delayed and essential
MAC control codes injected when MII bus is initialized
through setting device-tree property jl2xx1_delay in the
ethernet node

jl2xx1_delay: integer, millesecond
only add the delay and inject when larger than 0
default 0, suggested 1500 for JL2101

config DWMAC_GENERIC
tristate "Generic driver for DWMAC"
default STMMAC_PLATFORM
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,12 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)
if (priv->extend_desc && (priv->mode == STMMAC_RING_MODE))
atds = 1;

#ifdef CONFIG_STMMAC_JL2XX1
if (priv->plat->jl2xx1_delay) {
msleep(priv->plat->jl2xx1_delay);
}
#endif

ret = priv->hw->dma->reset(priv->ioaddr);
if (ret) {
dev_err(priv->device, "Failed to reset the dma\n");
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,15 @@ int stmmac_mdio_register(struct net_device *ndev)
goto bus_register_fail;
}

#ifdef CONFIG_STMMAC_JL2XX1
if (priv->plat->jl2xx1_delay) {
stmmac_mdio_write(new_bus,0,31,2627);
stmmac_mdio_write(new_bus,0,25,0x1801);
stmmac_mdio_write(new_bus,0,31,0);
stmmac_mdio_write(new_bus,0,0,0x8000);
}
#endif

if (priv->plat->phy_node || mdio_node)
goto bus_register_done;

Expand Down
5 changes: 5 additions & 0 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
plat->force_sf_dma_mode =
of_property_read_bool(np, "snps,force_sf_dma_mode");

#ifdef CONFIG_STMMAC_JL2XX1
if (of_property_read_u32(np, "jl2xx1_delay", &plat->jl2xx1_delay))
plat->jl2xx1_delay = 0;
#endif

/* Set the maxmtu to a default of JUMBO_LEN in case the
* parameter is not present in the device tree.
*/
Expand Down
3 changes: 3 additions & 0 deletions include/linux/stmmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,8 @@ struct plat_stmmacenet_data {
int has_gmac4;
bool tso_en;
int mac_port_sel_speed;
#ifdef CONFIG_STMMAC_JL2XX1
int jl2xx1_delay;
#endif
};
#endif

0 comments on commit 588b389

Please sign in to comment.