summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/stmicro
diff options
context:
space:
mode:
authorYanteng Si <siyanteng@loongson.cn>2024-08-07 21:48:04 +0800
committerPaolo Abeni <pabeni@redhat.com>2024-08-13 09:48:00 +0200
commit0ec04d32b5e7f03f1a18713a4958a056240763c8 (patch)
treebf7fe2a0aefb0cacc41ab1fdf59e7cc909174680 /drivers/net/ethernet/stmicro
parent849dc7341d1f48dacdeadb86eb09f6d7777b1e5e (diff)
downloadlinux-0ec04d32b5e7f03f1a18713a4958a056240763c8.tar.gz
linux-0ec04d32b5e7f03f1a18713a4958a056240763c8.tar.bz2
linux-0ec04d32b5e7f03f1a18713a4958a056240763c8.zip
net: stmmac: dwmac-loongson: Introduce PCI device info data
The Loongson GNET device support is about to be added in one of the next commits. As another preparation for that introduce the PCI device info data with a setup() callback performing the device-specific platform data initializations. Currently it is utilized for the already supported Loongson GMAC device only. Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn> Signed-off-by: Yinggang Gu <guyinggang@loongson.cn> Reviewed-by: Serge Semin <fancer.lancer@gmail.com> Acked-by: Huacai Chen <chenhuacai@loongson.cn> Signed-off-by: Yanteng Si <siyanteng@loongson.cn> Tested-by: Serge Semin <fancer.lancer@gmail.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'drivers/net/ethernet/stmicro')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 7d3f284b9176..10b49bea8e3c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -11,6 +11,10 @@
#define PCI_DEVICE_ID_LOONGSON_GMAC 0x7a03
+struct stmmac_pci_info {
+ int (*setup)(struct plat_stmmacenet_data *plat);
+};
+
static void loongson_default_data(struct plat_stmmacenet_data *plat)
{
plat->clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */
@@ -57,9 +61,14 @@ static int loongson_gmac_data(struct plat_stmmacenet_data *plat)
return 0;
}
+static struct stmmac_pci_info loongson_gmac_pci_info = {
+ .setup = loongson_gmac_data,
+};
+
static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct plat_stmmacenet_data *plat;
+ struct stmmac_pci_info *info;
struct stmmac_resources res;
struct device_node *np;
int ret, i, phy_mode;
@@ -125,10 +134,14 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
pci_set_master(pdev);
- loongson_gmac_data(plat);
memset(&res, 0, sizeof(res));
res.addr = pcim_iomap_table(pdev)[0];
+ info = (struct stmmac_pci_info *)id->driver_data;
+ ret = info->setup(plat);
+ if (ret)
+ goto err_disable_device;
+
res.irq = of_irq_get_byname(np, "macirq");
if (res.irq < 0) {
dev_err(&pdev->dev, "IRQ macirq not found\n");
@@ -220,7 +233,7 @@ static SIMPLE_DEV_PM_OPS(loongson_dwmac_pm_ops, loongson_dwmac_suspend,
loongson_dwmac_resume);
static const struct pci_device_id loongson_dwmac_id_table[] = {
- { PCI_DEVICE_DATA(LOONGSON, GMAC, NULL) },
+ { PCI_DEVICE_DATA(LOONGSON, GMAC, &loongson_gmac_pci_info) },
{}
};
MODULE_DEVICE_TABLE(pci, loongson_dwmac_id_table);