Lines Matching +full:multi +full:- +full:gmac
1 // SPDX-License-Identifier: GPL-2.0
5 #include <linux/clk-provider.h>
85 plat->bus_id = pci_dev_id(pdev); in loongson_default_data()
87 plat->clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */ in loongson_default_data()
88 plat->has_gmac = 1; in loongson_default_data()
89 plat->force_sf_dma_mode = 1; in loongson_default_data()
92 plat->multicast_filter_bins = 256; in loongson_default_data()
94 plat->mac_interface = PHY_INTERFACE_MODE_NA; in loongson_default_data()
97 plat->unicast_filter_entries = 1; in loongson_default_data()
100 plat->maxmtu = JUMBO_LEN; in loongson_default_data()
103 plat->tx_queues_cfg[0].use_prio = false; in loongson_default_data()
104 plat->rx_queues_cfg[0].use_prio = false; in loongson_default_data()
107 plat->rx_queues_cfg[0].pkt_route = 0x0; in loongson_default_data()
109 plat->clk_ref_rate = 125000000; in loongson_default_data()
110 plat->clk_ptp_rate = 125000000; in loongson_default_data()
112 /* Default to phy auto-detection */ in loongson_default_data()
113 plat->phy_addr = -1; in loongson_default_data()
115 plat->dma_cfg->pbl = 32; in loongson_default_data()
116 plat->dma_cfg->pblx8 = true; in loongson_default_data()
125 ld = plat->bsp_priv; in loongson_gmac_data()
129 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) { in loongson_gmac_data()
130 plat->rx_queues_to_use = CHANNEL_NUM; in loongson_gmac_data()
131 plat->tx_queues_to_use = CHANNEL_NUM; in loongson_gmac_data()
137 plat->tx_queues_cfg[i].coe_unsupported = 1; in loongson_gmac_data()
139 plat->tx_queues_to_use = 1; in loongson_gmac_data()
140 plat->rx_queues_to_use = 1; in loongson_gmac_data()
143 plat->phy_interface = PHY_INTERFACE_MODE_RGMII_ID; in loongson_gmac_data()
156 struct net_device *ndev = dev_get_drvdata(ld->dev); in loongson_gnet_fix_speed()
160 * speeds to 1000Mbps mode. The speedup procedure requires the PHY-link in loongson_gnet_fix_speed()
161 * re-negotiation. in loongson_gnet_fix_speed()
164 if (readl(ptr->ioaddr + MAC_CTRL_REG) & in loongson_gnet_fix_speed()
167 phy_restart_aneg(ndev->phydev); in loongson_gnet_fix_speed()
177 ld = plat->bsp_priv; in loongson_gnet_data()
181 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) { in loongson_gnet_data()
182 plat->rx_queues_to_use = CHANNEL_NUM; in loongson_gnet_data()
183 plat->tx_queues_to_use = CHANNEL_NUM; in loongson_gnet_data()
189 plat->tx_queues_cfg[i].coe_unsupported = 1; in loongson_gnet_data()
191 plat->tx_queues_to_use = 1; in loongson_gnet_data()
192 plat->rx_queues_to_use = 1; in loongson_gnet_data()
195 plat->phy_interface = PHY_INTERFACE_MODE_GMII; in loongson_gnet_data()
196 plat->mdio_bus_data->phy_mask = ~(u32)BIT(2); in loongson_gnet_data()
197 plat->fix_mac_speed = loongson_gnet_fix_speed; in loongson_gnet_data()
211 int txpbl = dma_cfg->txpbl ?: dma_cfg->pbl; in loongson_dwmac_dma_init_channel()
212 int rxpbl = dma_cfg->rxpbl ?: dma_cfg->pbl; in loongson_dwmac_dma_init_channel()
217 if (dma_cfg->pblx8) in loongson_dwmac_dma_init_channel()
226 if (dma_cfg->fixed_burst) in loongson_dwmac_dma_init_channel()
230 if (dma_cfg->mixed_burst) in loongson_dwmac_dma_init_channel()
233 if (dma_cfg->atds) in loongson_dwmac_dma_init_channel()
236 if (dma_cfg->aal) in loongson_dwmac_dma_init_channel()
251 struct stmmac_pcpu_stats *stats = this_cpu_ptr(priv->xstats.pcpu_stats); in loongson_dwmac_dma_interrupt()
277 x->tx_undeflow_irq++; in loongson_dwmac_dma_interrupt()
280 x->tx_jabber_irq++; in loongson_dwmac_dma_interrupt()
282 x->rx_overflow_irq++; in loongson_dwmac_dma_interrupt()
284 x->rx_buf_unav_irq++; in loongson_dwmac_dma_interrupt()
286 x->rx_process_stopped_irq++; in loongson_dwmac_dma_interrupt()
288 x->rx_watchdog_irq++; in loongson_dwmac_dma_interrupt()
290 x->tx_early_irq++; in loongson_dwmac_dma_interrupt()
292 x->tx_process_stopped_irq++; in loongson_dwmac_dma_interrupt()
296 x->fatal_bus_error_irq++; in loongson_dwmac_dma_interrupt()
306 u64_stats_update_begin(&stats->syncp); in loongson_dwmac_dma_interrupt()
307 u64_stats_inc(&stats->rx_normal_irq_n[chan]); in loongson_dwmac_dma_interrupt()
308 u64_stats_update_end(&stats->syncp); in loongson_dwmac_dma_interrupt()
313 u64_stats_update_begin(&stats->syncp); in loongson_dwmac_dma_interrupt()
314 u64_stats_inc(&stats->tx_normal_irq_n[chan]); in loongson_dwmac_dma_interrupt()
315 u64_stats_update_end(&stats->syncp); in loongson_dwmac_dma_interrupt()
319 x->rx_early_irq++; in loongson_dwmac_dma_interrupt()
326 /* Clear the interrupt by writing a logic 1 to the CSR5[19-0] */ in loongson_dwmac_dma_interrupt()
340 ld = priv->plat->bsp_priv; in loongson_dwmac_setup()
341 pdev = to_pci_dev(priv->device); in loongson_dwmac_setup()
343 mac = devm_kzalloc(priv->device, sizeof(*mac), GFP_KERNEL); in loongson_dwmac_setup()
347 dma = devm_kzalloc(priv->device, sizeof(*dma), GFP_KERNEL); in loongson_dwmac_setup()
351 /* The Loongson GMAC and GNET devices are based on the DW GMAC in loongson_dwmac_setup()
352 * v3.50a and v3.73a IP-cores. But the HW designers have changed the in loongson_dwmac_setup()
354 * network controllers with the multi-channels feature in loongson_dwmac_setup()
355 * available to emphasize the differences: multiple DMA-channels, in loongson_dwmac_setup()
357 * original value so the correct HW-interface would be selected. in loongson_dwmac_setup()
359 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) { in loongson_dwmac_setup()
360 priv->synopsys_id = DWMAC_CORE_3_70; in loongson_dwmac_setup()
362 dma->init_chan = loongson_dwmac_dma_init_channel; in loongson_dwmac_setup()
363 dma->dma_interrupt = loongson_dwmac_dma_interrupt; in loongson_dwmac_setup()
364 mac->dma = dma; in loongson_dwmac_setup()
367 priv->dev->priv_flags |= IFF_UNICAST_FLT; in loongson_dwmac_setup()
369 /* Pre-initialize the respective "mac" fields as it's done in in loongson_dwmac_setup()
372 mac->pcsr = priv->ioaddr; in loongson_dwmac_setup()
373 mac->multicast_filter_bins = priv->plat->multicast_filter_bins; in loongson_dwmac_setup()
374 mac->unicast_filter_entries = priv->plat->unicast_filter_entries; in loongson_dwmac_setup()
375 mac->mcast_bits_log2 = 0; in loongson_dwmac_setup()
377 if (mac->multicast_filter_bins) in loongson_dwmac_setup()
378 mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins); in loongson_dwmac_setup()
380 /* Loongson GMAC doesn't support the flow control. LS2K2000 in loongson_dwmac_setup()
381 * GNET doesn't support the half-duplex link mode. in loongson_dwmac_setup()
383 if (pdev->device == PCI_DEVICE_ID_LOONGSON_GMAC) { in loongson_dwmac_setup()
384 mac->link.caps = MAC_10 | MAC_100 | MAC_1000; in loongson_dwmac_setup()
386 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) in loongson_dwmac_setup()
387 mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | in loongson_dwmac_setup()
390 mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | in loongson_dwmac_setup()
394 mac->link.duplex = GMAC_CONTROL_DM; in loongson_dwmac_setup()
395 mac->link.speed10 = GMAC_CONTROL_PS; in loongson_dwmac_setup()
396 mac->link.speed100 = GMAC_CONTROL_PS | GMAC_CONTROL_FES; in loongson_dwmac_setup()
397 mac->link.speed1000 = 0; in loongson_dwmac_setup()
398 mac->link.speed_mask = GMAC_CONTROL_PS | GMAC_CONTROL_FES; in loongson_dwmac_setup()
399 mac->mii.addr = GMAC_MII_ADDR; in loongson_dwmac_setup()
400 mac->mii.data = GMAC_MII_DATA; in loongson_dwmac_setup()
401 mac->mii.addr_shift = 11; in loongson_dwmac_setup()
402 mac->mii.addr_mask = 0x0000F800; in loongson_dwmac_setup()
403 mac->mii.reg_shift = 6; in loongson_dwmac_setup()
404 mac->mii.reg_mask = 0x000007C0; in loongson_dwmac_setup()
405 mac->mii.clk_csr_shift = 2; in loongson_dwmac_setup()
406 mac->mii.clk_csr_mask = GENMASK(5, 2); in loongson_dwmac_setup()
420 dev_warn(&pdev->dev, "Failed to allocate MSI IRQs\n"); in loongson_dwmac_msi_config()
424 res->irq = pci_irq_vector(pdev, 0); in loongson_dwmac_msi_config()
426 for (i = 0; i < plat->rx_queues_to_use; i++) { in loongson_dwmac_msi_config()
427 res->rx_irq[CHANNEL_NUM - 1 - i] = in loongson_dwmac_msi_config()
431 for (i = 0; i < plat->tx_queues_to_use; i++) { in loongson_dwmac_msi_config()
432 res->tx_irq[CHANNEL_NUM - 1 - i] = in loongson_dwmac_msi_config()
436 plat->flags |= STMMAC_FLAG_MULTI_MSI_EN; in loongson_dwmac_msi_config()
450 struct device_node *np = dev_of_node(&pdev->dev); in loongson_dwmac_dt_config()
453 plat->mdio_node = of_get_child_by_name(np, "mdio"); in loongson_dwmac_dt_config()
454 if (plat->mdio_node) { in loongson_dwmac_dt_config()
455 dev_info(&pdev->dev, "Found MDIO subnode\n"); in loongson_dwmac_dt_config()
456 plat->mdio_bus_data->needs_reset = true; in loongson_dwmac_dt_config()
461 plat->bus_id = ret; in loongson_dwmac_dt_config()
463 res->irq = of_irq_get_byname(np, "macirq"); in loongson_dwmac_dt_config()
464 if (res->irq < 0) { in loongson_dwmac_dt_config()
465 dev_err(&pdev->dev, "IRQ macirq not found\n"); in loongson_dwmac_dt_config()
466 ret = -ENODEV; in loongson_dwmac_dt_config()
470 res->wol_irq = of_irq_get_byname(np, "eth_wake_irq"); in loongson_dwmac_dt_config()
471 if (res->wol_irq < 0) { in loongson_dwmac_dt_config()
472 dev_info(&pdev->dev, in loongson_dwmac_dt_config()
474 res->wol_irq = res->irq; in loongson_dwmac_dt_config()
477 res->lpi_irq = of_irq_get_byname(np, "eth_lpi"); in loongson_dwmac_dt_config()
478 if (res->lpi_irq < 0) { in loongson_dwmac_dt_config()
479 dev_err(&pdev->dev, "IRQ eth_lpi not found\n"); in loongson_dwmac_dt_config()
480 ret = -ENODEV; in loongson_dwmac_dt_config()
484 ret = device_get_phy_mode(&pdev->dev); in loongson_dwmac_dt_config()
486 dev_err(&pdev->dev, "phy_mode not found\n"); in loongson_dwmac_dt_config()
487 ret = -ENODEV; in loongson_dwmac_dt_config()
491 plat->phy_interface = ret; in loongson_dwmac_dt_config()
496 of_node_put(plat->mdio_node); in loongson_dwmac_dt_config()
504 of_node_put(plat->mdio_node); in loongson_dwmac_dt_clear()
511 if (!pdev->irq) in loongson_dwmac_acpi_config()
512 return -EINVAL; in loongson_dwmac_acpi_config()
514 res->irq = pdev->irq; in loongson_dwmac_acpi_config()
527 plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); in loongson_dwmac_probe()
529 return -ENOMEM; in loongson_dwmac_probe()
531 plat->mdio_bus_data = devm_kzalloc(&pdev->dev, in loongson_dwmac_probe()
532 sizeof(*plat->mdio_bus_data), in loongson_dwmac_probe()
534 if (!plat->mdio_bus_data) in loongson_dwmac_probe()
535 return -ENOMEM; in loongson_dwmac_probe()
537 plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), GFP_KERNEL); in loongson_dwmac_probe()
538 if (!plat->dma_cfg) in loongson_dwmac_probe()
539 return -ENOMEM; in loongson_dwmac_probe()
541 ld = devm_kzalloc(&pdev->dev, sizeof(*ld), GFP_KERNEL); in loongson_dwmac_probe()
543 return -ENOMEM; in loongson_dwmac_probe()
548 dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n", __func__); in loongson_dwmac_probe()
567 plat->bsp_priv = ld; in loongson_dwmac_probe()
568 plat->setup = loongson_dwmac_setup; in loongson_dwmac_probe()
569 ld->dev = &pdev->dev; in loongson_dwmac_probe()
570 ld->loongson_id = readl(res.addr + GMAC_VERSION) & 0xff; in loongson_dwmac_probe()
572 info = (struct stmmac_pci_info *)id->driver_data; in loongson_dwmac_probe()
573 ret = info->setup(pdev, plat); in loongson_dwmac_probe()
577 if (dev_of_node(&pdev->dev)) in loongson_dwmac_probe()
584 /* Use the common MAC IRQ if per-channel MSIs allocation failed */ in loongson_dwmac_probe()
585 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) in loongson_dwmac_probe()
588 ret = stmmac_dvr_probe(&pdev->dev, plat, &res); in loongson_dwmac_probe()
595 if (dev_of_node(&pdev->dev)) in loongson_dwmac_probe()
597 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) in loongson_dwmac_probe()
606 struct net_device *ndev = dev_get_drvdata(&pdev->dev); in loongson_dwmac_remove()
611 ld = priv->plat->bsp_priv; in loongson_dwmac_remove()
612 stmmac_dvr_remove(&pdev->dev); in loongson_dwmac_remove()
614 if (dev_of_node(&pdev->dev)) in loongson_dwmac_remove()
615 loongson_dwmac_dt_clear(pdev, priv->plat); in loongson_dwmac_remove()
617 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) in loongson_dwmac_remove()
669 { PCI_DEVICE_DATA(LOONGSON, GMAC, &loongson_gmac_pci_info) },
676 .name = "dwmac-loongson-pci",