mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 18:43:33 +02:00
Merge branch 'riscv-sophgo-add-ethernet-support-for-sg2044'
Inochi Amaoto says: ==================== riscv: sophgo: Add ethernet support for SG2044 The ethernet controller of SG2044 is Synopsys DesignWare IP with custom clock. Add glue layer for it. v6: https://lore.kernel.org/20250305063920.803601-1-inochiama@gmail.com v5: https://lore.kernel.org/20250216123953.1252523-1-inochiama@gmail.com v4: https://lore.kernel.org/20250209013054.816580-1-inochiama@gmail.com v3: https://lore.kernel.org/20241223005843.483805-1-inochiama@gmail.com RFC: https://lore.kernel.org/20241101014327.513732-1-inochiama@gmail.com v2: https://lore.kernel.org/20241025011000.244350-1-inochiama@gmail.com v1: https://lore.kernel.org/20241021103617.653386-1-inochiama@gmail.com ==================== Link: https://patch.msgid.link/20250307011623.440792-1-inochiama@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
ed3d10f3ca
|
|
@ -32,6 +32,7 @@ select:
|
|||
- snps,dwmac-4.20a
|
||||
- snps,dwmac-5.10a
|
||||
- snps,dwmac-5.20
|
||||
- snps,dwmac-5.30a
|
||||
- snps,dwxgmac
|
||||
- snps,dwxgmac-2.10
|
||||
|
||||
|
|
@ -98,8 +99,10 @@ properties:
|
|||
- snps,dwmac-4.20a
|
||||
- snps,dwmac-5.10a
|
||||
- snps,dwmac-5.20
|
||||
- snps,dwmac-5.30a
|
||||
- snps,dwxgmac
|
||||
- snps,dwxgmac-2.10
|
||||
- sophgo,sg2044-dwmac
|
||||
- starfive,jh7100-dwmac
|
||||
- starfive,jh7110-dwmac
|
||||
- tesla,fsd-ethqos
|
||||
|
|
@ -632,6 +635,7 @@ allOf:
|
|||
- snps,dwmac-4.20a
|
||||
- snps,dwmac-5.10a
|
||||
- snps,dwmac-5.20
|
||||
- snps,dwmac-5.30a
|
||||
- snps,dwxgmac
|
||||
- snps,dwxgmac-2.10
|
||||
- st,spear600-gmac
|
||||
|
|
|
|||
126
Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
Normal file
126
Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/net/sophgo,sg2044-dwmac.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: Sophgo SG2044 DWMAC glue layer
|
||||
|
||||
maintainers:
|
||||
- Inochi Amaoto <inochiama@gmail.com>
|
||||
|
||||
select:
|
||||
properties:
|
||||
compatible:
|
||||
contains:
|
||||
enum:
|
||||
- sophgo,sg2044-dwmac
|
||||
required:
|
||||
- compatible
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
items:
|
||||
- const: sophgo,sg2044-dwmac
|
||||
- const: snps,dwmac-5.30a
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
clocks:
|
||||
items:
|
||||
- description: GMAC main clock
|
||||
- description: PTP clock
|
||||
- description: TX clock
|
||||
|
||||
clock-names:
|
||||
items:
|
||||
- const: stmmaceth
|
||||
- const: ptp_ref
|
||||
- const: tx
|
||||
|
||||
dma-noncoherent: true
|
||||
|
||||
interrupts:
|
||||
maxItems: 1
|
||||
|
||||
interrupt-names:
|
||||
maxItems: 1
|
||||
|
||||
resets:
|
||||
maxItems: 1
|
||||
|
||||
reset-names:
|
||||
const: stmmaceth
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
- clocks
|
||||
- clock-names
|
||||
- interrupts
|
||||
- interrupt-names
|
||||
- resets
|
||||
- reset-names
|
||||
|
||||
allOf:
|
||||
- $ref: snps,dwmac.yaml#
|
||||
|
||||
unevaluatedProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
#include <dt-bindings/interrupt-controller/irq.h>
|
||||
|
||||
ethernet@30006000 {
|
||||
compatible = "sophgo,sg2044-dwmac", "snps,dwmac-5.30a";
|
||||
reg = <0x30006000 0x4000>;
|
||||
clocks = <&clk 151>, <&clk 152>, <&clk 154>;
|
||||
clock-names = "stmmaceth", "ptp_ref", "tx";
|
||||
interrupt-parent = <&intc>;
|
||||
interrupts = <296 IRQ_TYPE_LEVEL_HIGH>;
|
||||
interrupt-names = "macirq";
|
||||
resets = <&rst 30>;
|
||||
reset-names = "stmmaceth";
|
||||
snps,multicast-filter-bins = <0>;
|
||||
snps,perfect-filter-entries = <1>;
|
||||
snps,aal;
|
||||
snps,tso;
|
||||
snps,txpbl = <32>;
|
||||
snps,rxpbl = <32>;
|
||||
snps,mtl-rx-config = <&gmac0_mtl_rx_setup>;
|
||||
snps,mtl-tx-config = <&gmac0_mtl_tx_setup>;
|
||||
snps,axi-config = <&gmac0_stmmac_axi_setup>;
|
||||
status = "disabled";
|
||||
|
||||
gmac0_mtl_rx_setup: rx-queues-config {
|
||||
snps,rx-queues-to-use = <8>;
|
||||
snps,rx-sched-wsp;
|
||||
queue0 {};
|
||||
queue1 {};
|
||||
queue2 {};
|
||||
queue3 {};
|
||||
queue4 {};
|
||||
queue5 {};
|
||||
queue6 {};
|
||||
queue7 {};
|
||||
};
|
||||
|
||||
gmac0_mtl_tx_setup: tx-queues-config {
|
||||
snps,tx-queues-to-use = <8>;
|
||||
queue0 {};
|
||||
queue1 {};
|
||||
queue2 {};
|
||||
queue3 {};
|
||||
queue4 {};
|
||||
queue5 {};
|
||||
queue6 {};
|
||||
queue7 {};
|
||||
};
|
||||
|
||||
gmac0_stmmac_axi_setup: stmmac-axi-config {
|
||||
snps,blen = <16 8 4 0 0 0 0>;
|
||||
snps,wr_osr_lmt = <1>;
|
||||
snps,rd_osr_lmt = <2>;
|
||||
};
|
||||
};
|
||||
|
|
@ -181,6 +181,17 @@ config DWMAC_SOCFPGA
|
|||
for the stmmac device driver. This driver is used for
|
||||
arria5 and cyclone5 FPGA SoCs.
|
||||
|
||||
config DWMAC_SOPHGO
|
||||
tristate "Sophgo dwmac support"
|
||||
depends on OF && (ARCH_SOPHGO || COMPILE_TEST)
|
||||
default m if ARCH_SOPHGO
|
||||
help
|
||||
Support for ethernet controllers on Sophgo RISC-V SoCs
|
||||
|
||||
This selects the Sophgo SoC specific glue layer support
|
||||
for the stmmac device driver. This driver is used for the
|
||||
ethernet controllers on various Sophgo SoCs.
|
||||
|
||||
config DWMAC_STARFIVE
|
||||
tristate "StarFive dwmac support"
|
||||
depends on OF && (ARCH_STARFIVE || COMPILE_TEST)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ obj-$(CONFIG_DWMAC_ROCKCHIP) += dwmac-rk.o
|
|||
obj-$(CONFIG_DWMAC_RZN1) += dwmac-rzn1.o
|
||||
obj-$(CONFIG_DWMAC_S32) += dwmac-s32.o
|
||||
obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o
|
||||
obj-$(CONFIG_DWMAC_SOPHGO) += dwmac-sophgo.o
|
||||
obj-$(CONFIG_DWMAC_STARFIVE) += dwmac-starfive.o
|
||||
obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o
|
||||
obj-$(CONFIG_DWMAC_STM32) += dwmac-stm32.o
|
||||
|
|
|
|||
75
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
Normal file
75
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Sophgo DWMAC platform driver
|
||||
*
|
||||
* Copyright (C) 2024 Inochi Amaoto <inochiama@gmail.com>
|
||||
*/
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include "stmmac_platform.h"
|
||||
|
||||
static int sophgo_sg2044_dwmac_init(struct platform_device *pdev,
|
||||
struct plat_stmmacenet_data *plat_dat,
|
||||
struct stmmac_resources *stmmac_res)
|
||||
{
|
||||
plat_dat->clk_tx_i = devm_clk_get_enabled(&pdev->dev, "tx");
|
||||
if (IS_ERR(plat_dat->clk_tx_i))
|
||||
return dev_err_probe(&pdev->dev, PTR_ERR(plat_dat->clk_tx_i),
|
||||
"failed to get tx clock\n");
|
||||
|
||||
plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE;
|
||||
plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
|
||||
plat_dat->multicast_filter_bins = 0;
|
||||
plat_dat->unicast_filter_entries = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sophgo_dwmac_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct plat_stmmacenet_data *plat_dat;
|
||||
struct stmmac_resources stmmac_res;
|
||||
struct device *dev = &pdev->dev;
|
||||
int ret;
|
||||
|
||||
ret = stmmac_get_platform_resources(pdev, &stmmac_res);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret,
|
||||
"failed to get platform resources\n");
|
||||
|
||||
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
|
||||
if (IS_ERR(plat_dat))
|
||||
return dev_err_probe(dev, PTR_ERR(plat_dat),
|
||||
"failed to parse DT parameters\n");
|
||||
|
||||
ret = sophgo_sg2044_dwmac_init(pdev, plat_dat, &stmmac_res);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return stmmac_dvr_probe(dev, plat_dat, &stmmac_res);
|
||||
}
|
||||
|
||||
static const struct of_device_id sophgo_dwmac_match[] = {
|
||||
{ .compatible = "sophgo,sg2044-dwmac" },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, sophgo_dwmac_match);
|
||||
|
||||
static struct platform_driver sophgo_dwmac_driver = {
|
||||
.probe = sophgo_dwmac_probe,
|
||||
.remove = stmmac_pltfr_remove,
|
||||
.driver = {
|
||||
.name = "sophgo-dwmac",
|
||||
.pm = &stmmac_pltfr_pm_ops,
|
||||
.of_match_table = sophgo_dwmac_match,
|
||||
},
|
||||
};
|
||||
module_platform_driver(sophgo_dwmac_driver);
|
||||
|
||||
MODULE_AUTHOR("Inochi Amaoto <inochiama@gmail.com>");
|
||||
MODULE_DESCRIPTION("Sophgo DWMAC platform driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
@ -405,6 +405,17 @@ static int stmmac_of_get_mac_mode(struct device_node *np)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Compatible string array for all gmac4 devices */
|
||||
static const char * const stmmac_gmac4_compats[] = {
|
||||
"snps,dwmac-4.00",
|
||||
"snps,dwmac-4.10a",
|
||||
"snps,dwmac-4.20a",
|
||||
"snps,dwmac-5.10a",
|
||||
"snps,dwmac-5.20",
|
||||
"snps,dwmac-5.30a",
|
||||
NULL
|
||||
};
|
||||
|
||||
/**
|
||||
* stmmac_probe_config_dt - parse device-tree driver parameters
|
||||
* @pdev: platform_device structure
|
||||
|
|
@ -538,11 +549,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
|
|||
plat->pmt = 1;
|
||||
}
|
||||
|
||||
if (of_device_is_compatible(np, "snps,dwmac-4.00") ||
|
||||
of_device_is_compatible(np, "snps,dwmac-4.10a") ||
|
||||
of_device_is_compatible(np, "snps,dwmac-4.20a") ||
|
||||
of_device_is_compatible(np, "snps,dwmac-5.10a") ||
|
||||
of_device_is_compatible(np, "snps,dwmac-5.20")) {
|
||||
if (of_device_compatible_match(np, stmmac_gmac4_compats)) {
|
||||
plat->has_gmac4 = 1;
|
||||
plat->has_gmac = 0;
|
||||
plat->pmt = 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user