Skip to content

Commit

Permalink
BACKPORT: PHYTIUM: net/stmmac: Add phytium DWMAC driver support v2
Browse files Browse the repository at this point in the history
Modify stmmmac driver to support phytium DWMAC controler.

Signed-off-by: Li Wencheng <liwencheng@phytium.com.cn>
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Change-Id: I878377c5fb88935dcbc7b83f368ae5408938f890

Link: https://gitee.com/phytium_embedded/phytium-linux-kernel/commit/f18feb0bef4216b257a29d176e7366c7025f3115
[Kexy: Resolved minor conflict in MAINTAINERS]
Signed-off-by: Kexy Biscuit <kexybiscuit@aosc.io>
  • Loading branch information
Li Wencheng authored and KexyBiscuit committed Nov 7, 2024
1 parent 1ab87d3 commit 126d82a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
12 changes: 6 additions & 6 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2797,12 +2797,6 @@ S: Maintained
W: http://www.digriz.org.uk/ts78xx/kernel
F: arch/arm/mach-orion5x/ts78xx-*

ARM/PHYTIUM SOC SUPPORT
M: Chen Baozi <chenbaozi@phytium.com.cn>
S: Maintained
W: https://www.phytium.com.cn
F: drivers/net/ethernet/stmicro/stmmac/dwmac-phytium.c

ARM/QUALCOMM CHROMEBOOK SUPPORT
R: cros-qcom-dts-watchers@chromium.org
F: arch/arm64/boot/dts/qcom/sc7180*
Expand Down Expand Up @@ -18765,6 +18759,12 @@ F: include/sound/pxa2xx-lib.h
F: sound/arm/pxa*
F: sound/soc/pxa/

ARM/PHYTIUM SOC SUPPORT
M: Wang Yinfeng <wangyinfeng@phytium.com.cn>
S: Maintained
W: https://www.phytium.com.cn
F: drivers/net/ethernet/stmicro/stmmac/dwmac-phytium.c

QAT DRIVER
M: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
L: qat-linux@intel.com
Expand Down
37 changes: 15 additions & 22 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-phytium.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ static int phytium_get_mac_mode(struct fwnode_handle *fwnode)
static int phytium_dwmac_acpi_phy(struct plat_stmmacenet_data *plat,
struct fwnode_handle *np, struct device *dev)
{
plat->mdio_bus_data =
devm_kzalloc(dev, sizeof(struct stmmac_mdio_bus_data), GFP_KERNEL);
plat->mdio_bus_data = devm_kzalloc(dev, sizeof(struct stmmac_mdio_bus_data), GFP_KERNEL);

if (!plat->mdio_bus_data)
return -ENOMEM;
Expand All @@ -60,8 +59,7 @@ static int phytium_dwmac_probe(struct platform_device *pdev)
if (!plat)
return -ENOMEM;

plat->dma_cfg =
devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), GFP_KERNEL);
plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), GFP_KERNEL);
if (!plat->dma_cfg)
return -ENOMEM;

Expand Down Expand Up @@ -113,12 +111,10 @@ static int phytium_dwmac_probe(struct platform_device *pdev)
&plat->unicast_filter_entries))
plat->unicast_filter_entries = 1;

if (fwnode_property_read_u32(fwnode, "tx-fifo-depth",
&plat->tx_fifo_size))
if (fwnode_property_read_u32(fwnode, "tx-fifo-depth", &plat->tx_fifo_size))
plat->tx_fifo_size = 0x1000;

if (fwnode_property_read_u32(fwnode, "rx-fifo-depth",
&plat->rx_fifo_size))
if (fwnode_property_read_u32(fwnode, "rx-fifo-depth", &plat->rx_fifo_size))
plat->rx_fifo_size = 0x1000;

if (phytium_dwmac_acpi_phy(plat, fwnode, &pdev->dev))
Expand All @@ -133,11 +129,9 @@ static int phytium_dwmac_probe(struct platform_device *pdev)
clk_freq = 125000000;

/* Set system clock */
snprintf(clk_name, sizeof(clk_name), "%s-%d", "stmmaceth",
plat->bus_id);
snprintf(clk_name, sizeof(clk_name), "%s-%d", "stmmaceth", plat->bus_id);

plat->stmmac_clk = clk_register_fixed_rate(&pdev->dev, clk_name, NULL,
0, clk_freq);
plat->stmmac_clk = clk_register_fixed_rate(&pdev->dev, clk_name, NULL, 0, clk_freq);
if (IS_ERR(plat->stmmac_clk)) {
dev_warn(&pdev->dev, "Fail to register stmmac-clk\n");
plat->stmmac_clk = NULL;
Expand All @@ -158,13 +152,10 @@ static int phytium_dwmac_probe(struct platform_device *pdev)
fwnode_property_read_u32(fwnode, "snps,txpbl", &plat->dma_cfg->txpbl);
fwnode_property_read_u32(fwnode, "snps,rxpbl", &plat->dma_cfg->rxpbl);

plat->dma_cfg->pblx8 =
!fwnode_property_read_bool(fwnode, "snps,no-pbl-x8");
plat->dma_cfg->pblx8 = !fwnode_property_read_bool(fwnode, "snps,no-pbl-x8");
plat->dma_cfg->aal = fwnode_property_read_bool(fwnode, "snps,aal");
plat->dma_cfg->fixed_burst =
fwnode_property_read_bool(fwnode, "snps,fixed-burst");
plat->dma_cfg->mixed_burst =
fwnode_property_read_bool(fwnode, "snps,mixed-burst");
plat->dma_cfg->fixed_burst = fwnode_property_read_bool(fwnode, "snps,fixed-burst");
plat->dma_cfg->mixed_burst = fwnode_property_read_bool(fwnode, "snps,mixed-burst");

plat->axi->axi_lpi_en = false;
plat->axi->axi_xit_frm = false;
Expand All @@ -182,23 +173,25 @@ static int phytium_dwmac_probe(struct platform_device *pdev)
stmmac_res.wol_irq = stmmac_res.irq;
stmmac_res.lpi_irq = -1;

return stmmac_dvr_probe(&pdev->dev, plat, &stmmac_res);
return stmmac_dvr_probe(&pdev->dev, plat, &stmmac_res);
}

void phytium_dwmac_remove(struct platform_device *pdev)
int phytium_dwmac_remove(struct platform_device *pdev)
{
struct net_device *ndev = platform_get_drvdata(pdev);
struct stmmac_priv *priv = netdev_priv(ndev);
struct plat_stmmacenet_data *plat = priv->plat;

stmmac_pltfr_remove(pdev);
clk_unregister_fixed_rate(plat->stmmac_clk);

return 0;
}

#ifdef CONFIG_OF
static const struct of_device_id phytium_dwmac_of_match[] = {
{ .compatible = "phytium,gmac" },
{}
{ }
};
MODULE_DEVICE_TABLE(of, phytium_dwmac_of_match);
#endif
Expand All @@ -213,7 +206,7 @@ MODULE_DEVICE_TABLE(acpi, phytium_dwmac_acpi_ids);

static struct platform_driver phytium_dwmac_driver = {
.probe = phytium_dwmac_probe,
.remove_new = phytium_dwmac_remove,
.remove = phytium_dwmac_remove,
.driver = {
.name = "phytium-dwmac",
.of_match_table = of_match_ptr(phytium_dwmac_of_match),
Expand Down

0 comments on commit 126d82a

Please sign in to comment.