Lines Matching +full:mixed +full:- +full:burst
1 // SPDX-License-Identifier: GPL-2.0
5 #include <linux/clk-provider.h>
14 #define DRIVER_NAME "dwmac-loongson-pci"
87 plat->bus_id = pci_dev_id(pdev); in loongson_default_data()
89 plat->clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */ in loongson_default_data()
90 plat->has_gmac = 1; in loongson_default_data()
91 plat->force_sf_dma_mode = 1; in loongson_default_data()
94 plat->multicast_filter_bins = 256; in loongson_default_data()
96 plat->mac_interface = PHY_INTERFACE_MODE_NA; in loongson_default_data()
99 plat->unicast_filter_entries = 1; in loongson_default_data()
102 plat->maxmtu = JUMBO_LEN; in loongson_default_data()
105 plat->tx_queues_cfg[0].use_prio = false; in loongson_default_data()
106 plat->rx_queues_cfg[0].use_prio = false; in loongson_default_data()
109 plat->rx_queues_cfg[0].pkt_route = 0x0; in loongson_default_data()
111 plat->clk_ref_rate = 125000000; in loongson_default_data()
112 plat->clk_ptp_rate = 125000000; in loongson_default_data()
114 /* Default to phy auto-detection */ in loongson_default_data()
115 plat->phy_addr = -1; in loongson_default_data()
117 plat->dma_cfg->pbl = 32; in loongson_default_data()
118 plat->dma_cfg->pblx8 = true; in loongson_default_data()
127 ld = plat->bsp_priv; in loongson_gmac_data()
131 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) { in loongson_gmac_data()
132 plat->rx_queues_to_use = CHANNEL_NUM; in loongson_gmac_data()
133 plat->tx_queues_to_use = CHANNEL_NUM; in loongson_gmac_data()
139 plat->tx_queues_cfg[i].coe_unsupported = 1; in loongson_gmac_data()
141 plat->tx_queues_to_use = 1; in loongson_gmac_data()
142 plat->rx_queues_to_use = 1; in loongson_gmac_data()
145 plat->phy_interface = PHY_INTERFACE_MODE_RGMII_ID; in loongson_gmac_data()
158 struct net_device *ndev = dev_get_drvdata(ld->dev); in loongson_gnet_fix_speed()
162 * speeds to 1000Mbps mode. The speedup procedure requires the PHY-link in loongson_gnet_fix_speed()
163 * re-negotiation. in loongson_gnet_fix_speed()
166 if (readl(ptr->ioaddr + MAC_CTRL_REG) & in loongson_gnet_fix_speed()
169 phy_restart_aneg(ndev->phydev); in loongson_gnet_fix_speed()
179 ld = plat->bsp_priv; in loongson_gnet_data()
183 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) { in loongson_gnet_data()
184 plat->rx_queues_to_use = CHANNEL_NUM; in loongson_gnet_data()
185 plat->tx_queues_to_use = CHANNEL_NUM; in loongson_gnet_data()
191 plat->tx_queues_cfg[i].coe_unsupported = 1; in loongson_gnet_data()
193 plat->tx_queues_to_use = 1; in loongson_gnet_data()
194 plat->rx_queues_to_use = 1; in loongson_gnet_data()
197 plat->phy_interface = PHY_INTERFACE_MODE_GMII; in loongson_gnet_data()
198 plat->mdio_bus_data->phy_mask = ~(u32)BIT(2); in loongson_gnet_data()
199 plat->fix_mac_speed = loongson_gnet_fix_speed; in loongson_gnet_data()
213 int txpbl = dma_cfg->txpbl ?: dma_cfg->pbl; in loongson_dwmac_dma_init_channel()
214 int rxpbl = dma_cfg->rxpbl ?: dma_cfg->pbl; in loongson_dwmac_dma_init_channel()
219 if (dma_cfg->pblx8) in loongson_dwmac_dma_init_channel()
227 /* Set the Fixed burst mode */ in loongson_dwmac_dma_init_channel()
228 if (dma_cfg->fixed_burst) in loongson_dwmac_dma_init_channel()
231 /* Mixed Burst has no effect when fb is set */ in loongson_dwmac_dma_init_channel()
232 if (dma_cfg->mixed_burst) in loongson_dwmac_dma_init_channel()
235 if (dma_cfg->atds) in loongson_dwmac_dma_init_channel()
238 if (dma_cfg->aal) in loongson_dwmac_dma_init_channel()
253 struct stmmac_pcpu_stats *stats = this_cpu_ptr(priv->xstats.pcpu_stats); in loongson_dwmac_dma_interrupt()
279 x->tx_undeflow_irq++; in loongson_dwmac_dma_interrupt()
282 x->tx_jabber_irq++; in loongson_dwmac_dma_interrupt()
284 x->rx_overflow_irq++; in loongson_dwmac_dma_interrupt()
286 x->rx_buf_unav_irq++; in loongson_dwmac_dma_interrupt()
288 x->rx_process_stopped_irq++; in loongson_dwmac_dma_interrupt()
290 x->rx_watchdog_irq++; in loongson_dwmac_dma_interrupt()
292 x->tx_early_irq++; in loongson_dwmac_dma_interrupt()
294 x->tx_process_stopped_irq++; in loongson_dwmac_dma_interrupt()
298 x->fatal_bus_error_irq++; in loongson_dwmac_dma_interrupt()
308 u64_stats_update_begin(&stats->syncp); in loongson_dwmac_dma_interrupt()
309 u64_stats_inc(&stats->rx_normal_irq_n[chan]); in loongson_dwmac_dma_interrupt()
310 u64_stats_update_end(&stats->syncp); in loongson_dwmac_dma_interrupt()
315 u64_stats_update_begin(&stats->syncp); in loongson_dwmac_dma_interrupt()
316 u64_stats_inc(&stats->tx_normal_irq_n[chan]); in loongson_dwmac_dma_interrupt()
317 u64_stats_update_end(&stats->syncp); in loongson_dwmac_dma_interrupt()
321 x->rx_early_irq++; in loongson_dwmac_dma_interrupt()
328 /* Clear the interrupt by writing a logic 1 to the CSR5[19-0] */ in loongson_dwmac_dma_interrupt()
342 ld = priv->plat->bsp_priv; in loongson_dwmac_setup()
343 pdev = to_pci_dev(priv->device); in loongson_dwmac_setup()
345 mac = devm_kzalloc(priv->device, sizeof(*mac), GFP_KERNEL); in loongson_dwmac_setup()
349 dma = devm_kzalloc(priv->device, sizeof(*dma), GFP_KERNEL); in loongson_dwmac_setup()
354 * v3.50a and v3.73a IP-cores. But the HW designers have changed the in loongson_dwmac_setup()
356 * network controllers with the multi-channels feature in loongson_dwmac_setup()
357 * available to emphasize the differences: multiple DMA-channels, in loongson_dwmac_setup()
359 * original value so the correct HW-interface would be selected. in loongson_dwmac_setup()
361 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) { in loongson_dwmac_setup()
362 priv->synopsys_id = DWMAC_CORE_3_70; in loongson_dwmac_setup()
364 dma->init_chan = loongson_dwmac_dma_init_channel; in loongson_dwmac_setup()
365 dma->dma_interrupt = loongson_dwmac_dma_interrupt; in loongson_dwmac_setup()
366 mac->dma = dma; in loongson_dwmac_setup()
369 priv->dev->priv_flags |= IFF_UNICAST_FLT; in loongson_dwmac_setup()
371 /* Pre-initialize the respective "mac" fields as it's done in in loongson_dwmac_setup()
374 mac->pcsr = priv->ioaddr; in loongson_dwmac_setup()
375 mac->multicast_filter_bins = priv->plat->multicast_filter_bins; in loongson_dwmac_setup()
376 mac->unicast_filter_entries = priv->plat->unicast_filter_entries; in loongson_dwmac_setup()
377 mac->mcast_bits_log2 = 0; in loongson_dwmac_setup()
379 if (mac->multicast_filter_bins) in loongson_dwmac_setup()
380 mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins); in loongson_dwmac_setup()
383 * GNET doesn't support the half-duplex link mode. in loongson_dwmac_setup()
385 if (pdev->device == PCI_DEVICE_ID_LOONGSON_GMAC) { in loongson_dwmac_setup()
386 mac->link.caps = MAC_10 | MAC_100 | MAC_1000; in loongson_dwmac_setup()
388 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) in loongson_dwmac_setup()
389 mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | in loongson_dwmac_setup()
392 mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | in loongson_dwmac_setup()
396 mac->link.duplex = GMAC_CONTROL_DM; in loongson_dwmac_setup()
397 mac->link.speed10 = GMAC_CONTROL_PS; in loongson_dwmac_setup()
398 mac->link.speed100 = GMAC_CONTROL_PS | GMAC_CONTROL_FES; in loongson_dwmac_setup()
399 mac->link.speed1000 = 0; in loongson_dwmac_setup()
400 mac->link.speed_mask = GMAC_CONTROL_PS | GMAC_CONTROL_FES; in loongson_dwmac_setup()
401 mac->mii.addr = GMAC_MII_ADDR; in loongson_dwmac_setup()
402 mac->mii.data = GMAC_MII_DATA; in loongson_dwmac_setup()
403 mac->mii.addr_shift = 11; in loongson_dwmac_setup()
404 mac->mii.addr_mask = 0x0000F800; in loongson_dwmac_setup()
405 mac->mii.reg_shift = 6; in loongson_dwmac_setup()
406 mac->mii.reg_mask = 0x000007C0; in loongson_dwmac_setup()
407 mac->mii.clk_csr_shift = 2; in loongson_dwmac_setup()
408 mac->mii.clk_csr_mask = GENMASK(5, 2); in loongson_dwmac_setup()
422 dev_warn(&pdev->dev, "Failed to allocate MSI IRQs\n"); in loongson_dwmac_msi_config()
426 res->irq = pci_irq_vector(pdev, 0); in loongson_dwmac_msi_config()
428 for (i = 0; i < plat->rx_queues_to_use; i++) { in loongson_dwmac_msi_config()
429 res->rx_irq[CHANNEL_NUM - 1 - i] = in loongson_dwmac_msi_config()
433 for (i = 0; i < plat->tx_queues_to_use; i++) { in loongson_dwmac_msi_config()
434 res->tx_irq[CHANNEL_NUM - 1 - i] = in loongson_dwmac_msi_config()
438 plat->flags |= STMMAC_FLAG_MULTI_MSI_EN; in loongson_dwmac_msi_config()
452 struct device_node *np = dev_of_node(&pdev->dev); in loongson_dwmac_dt_config()
455 plat->mdio_node = of_get_child_by_name(np, "mdio"); in loongson_dwmac_dt_config()
456 if (plat->mdio_node) { in loongson_dwmac_dt_config()
457 dev_info(&pdev->dev, "Found MDIO subnode\n"); in loongson_dwmac_dt_config()
458 plat->mdio_bus_data->needs_reset = true; in loongson_dwmac_dt_config()
463 plat->bus_id = ret; in loongson_dwmac_dt_config()
465 res->irq = of_irq_get_byname(np, "macirq"); in loongson_dwmac_dt_config()
466 if (res->irq < 0) { in loongson_dwmac_dt_config()
467 dev_err(&pdev->dev, "IRQ macirq not found\n"); in loongson_dwmac_dt_config()
468 ret = -ENODEV; in loongson_dwmac_dt_config()
472 res->wol_irq = of_irq_get_byname(np, "eth_wake_irq"); in loongson_dwmac_dt_config()
473 if (res->wol_irq < 0) { in loongson_dwmac_dt_config()
474 dev_info(&pdev->dev, in loongson_dwmac_dt_config()
476 res->wol_irq = res->irq; in loongson_dwmac_dt_config()
479 res->lpi_irq = of_irq_get_byname(np, "eth_lpi"); in loongson_dwmac_dt_config()
480 if (res->lpi_irq < 0) { in loongson_dwmac_dt_config()
481 dev_err(&pdev->dev, "IRQ eth_lpi not found\n"); in loongson_dwmac_dt_config()
482 ret = -ENODEV; in loongson_dwmac_dt_config()
486 ret = device_get_phy_mode(&pdev->dev); in loongson_dwmac_dt_config()
488 dev_err(&pdev->dev, "phy_mode not found\n"); in loongson_dwmac_dt_config()
489 ret = -ENODEV; in loongson_dwmac_dt_config()
493 plat->phy_interface = ret; in loongson_dwmac_dt_config()
498 of_node_put(plat->mdio_node); in loongson_dwmac_dt_config()
506 of_node_put(plat->mdio_node); in loongson_dwmac_dt_clear()
513 if (!pdev->irq) in loongson_dwmac_acpi_config()
514 return -EINVAL; in loongson_dwmac_acpi_config()
516 res->irq = pdev->irq; in loongson_dwmac_acpi_config()
542 plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); in loongson_dwmac_probe()
544 return -ENOMEM; in loongson_dwmac_probe()
546 plat->mdio_bus_data = devm_kzalloc(&pdev->dev, in loongson_dwmac_probe()
547 sizeof(*plat->mdio_bus_data), in loongson_dwmac_probe()
549 if (!plat->mdio_bus_data) in loongson_dwmac_probe()
550 return -ENOMEM; in loongson_dwmac_probe()
552 plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), GFP_KERNEL); in loongson_dwmac_probe()
553 if (!plat->dma_cfg) in loongson_dwmac_probe()
554 return -ENOMEM; in loongson_dwmac_probe()
556 ld = devm_kzalloc(&pdev->dev, sizeof(*ld), GFP_KERNEL); in loongson_dwmac_probe()
558 return -ENOMEM; in loongson_dwmac_probe()
563 dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n", __func__); in loongson_dwmac_probe()
582 plat->bsp_priv = ld; in loongson_dwmac_probe()
583 plat->setup = loongson_dwmac_setup; in loongson_dwmac_probe()
584 plat->fix_soc_reset = loongson_dwmac_fix_reset; in loongson_dwmac_probe()
585 ld->dev = &pdev->dev; in loongson_dwmac_probe()
586 ld->loongson_id = readl(res.addr + GMAC_VERSION) & 0xff; in loongson_dwmac_probe()
588 info = (struct stmmac_pci_info *)id->driver_data; in loongson_dwmac_probe()
589 ret = info->setup(pdev, plat); in loongson_dwmac_probe()
593 if (dev_of_node(&pdev->dev)) in loongson_dwmac_probe()
600 /* Use the common MAC IRQ if per-channel MSIs allocation failed */ in loongson_dwmac_probe()
601 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) in loongson_dwmac_probe()
604 ret = stmmac_dvr_probe(&pdev->dev, plat, &res); in loongson_dwmac_probe()
611 if (dev_of_node(&pdev->dev)) in loongson_dwmac_probe()
613 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) in loongson_dwmac_probe()
622 struct net_device *ndev = dev_get_drvdata(&pdev->dev); in loongson_dwmac_remove()
627 ld = priv->plat->bsp_priv; in loongson_dwmac_remove()
628 stmmac_dvr_remove(&pdev->dev); in loongson_dwmac_remove()
630 if (dev_of_node(&pdev->dev)) in loongson_dwmac_remove()
631 loongson_dwmac_dt_clear(pdev, priv->plat); in loongson_dwmac_remove()
633 if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) in loongson_dwmac_remove()