Commit 8d4597b8 authored by Cristian Ciocaltea's avatar Cristian Ciocaltea Committed by David S. Miller

net: stmmac: dwmac-starfive: Add support for JH7100 SoC

Add a missing quirk to enable support for the StarFive JH7100 SoC.

Additionally, for greater flexibility in operation, allow using the
rgmii-rxid and rgmii-txid phy modes.
Co-developed-by: default avatarEmil Renner Berthing <kernel@esmil.dk>
Signed-off-by: default avatarEmil Renner Berthing <kernel@esmil.dk>
Signed-off-by: default avatarCristian Ciocaltea <cristian.ciocaltea@collabora.com>
Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 53e41b76
...@@ -165,9 +165,9 @@ config DWMAC_STARFIVE ...@@ -165,9 +165,9 @@ config DWMAC_STARFIVE
help help
Support for ethernet controllers on StarFive RISC-V SoCs Support for ethernet controllers on StarFive RISC-V SoCs
This selects the StarFive platform specific glue layer support for This selects the StarFive platform specific glue layer support
the stmmac device driver. This driver is used for StarFive JH7110 for the stmmac device driver. This driver is used for the
ethernet controller. StarFive JH7100 and JH7110 ethernet controllers.
config DWMAC_STI config DWMAC_STI
tristate "STi GMAC support" tristate "STi GMAC support"
......
...@@ -19,9 +19,16 @@ ...@@ -19,9 +19,16 @@
#define STARFIVE_DWMAC_PHY_INFT_RMII 0x4 #define STARFIVE_DWMAC_PHY_INFT_RMII 0x4
#define STARFIVE_DWMAC_PHY_INFT_FIELD 0x7U #define STARFIVE_DWMAC_PHY_INFT_FIELD 0x7U
#define JH7100_SYSMAIN_REGISTER49_DLYCHAIN 0xc8
struct starfive_dwmac_data {
unsigned int gtxclk_dlychain;
};
struct starfive_dwmac { struct starfive_dwmac {
struct device *dev; struct device *dev;
struct clk *clk_tx; struct clk *clk_tx;
const struct starfive_dwmac_data *data;
}; };
static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
...@@ -67,6 +74,8 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat) ...@@ -67,6 +74,8 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
case PHY_INTERFACE_MODE_RGMII: case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID: case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_TXID:
mode = STARFIVE_DWMAC_PHY_INFT_RGMII; mode = STARFIVE_DWMAC_PHY_INFT_RGMII;
break; break;
...@@ -89,6 +98,14 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat) ...@@ -89,6 +98,14 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
if (err) if (err)
return dev_err_probe(dwmac->dev, err, "error setting phy mode\n"); return dev_err_probe(dwmac->dev, err, "error setting phy mode\n");
if (dwmac->data) {
err = regmap_write(regmap, JH7100_SYSMAIN_REGISTER49_DLYCHAIN,
dwmac->data->gtxclk_dlychain);
if (err)
return dev_err_probe(dwmac->dev, err,
"error selecting gtxclk delay chain\n");
}
return 0; return 0;
} }
...@@ -114,6 +131,8 @@ static int starfive_dwmac_probe(struct platform_device *pdev) ...@@ -114,6 +131,8 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
if (!dwmac) if (!dwmac)
return -ENOMEM; return -ENOMEM;
dwmac->data = device_get_match_data(&pdev->dev);
dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx"); dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx");
if (IS_ERR(dwmac->clk_tx)) if (IS_ERR(dwmac->clk_tx))
return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx), return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx),
...@@ -144,7 +163,12 @@ static int starfive_dwmac_probe(struct platform_device *pdev) ...@@ -144,7 +163,12 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
} }
static const struct starfive_dwmac_data jh7100_data = {
.gtxclk_dlychain = 4,
};
static const struct of_device_id starfive_dwmac_match[] = { static const struct of_device_id starfive_dwmac_match[] = {
{ .compatible = "starfive,jh7100-dwmac", .data = &jh7100_data },
{ .compatible = "starfive,jh7110-dwmac" }, { .compatible = "starfive,jh7110-dwmac" },
{ /* sentinel */ } { /* sentinel */ }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment