Lines Matching +full:speed +full:- +full:bins

1 // SPDX-License-Identifier: GPL-2.0
5 #include <linux/clk-provider.h>
14 #define DRIVER_NAME "dwmac-loongson-pci"
88 struct loongson_data *ld = plat->bsp_priv;
91 plat->bus_id = pci_dev_id(pdev);
93 plat->clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */
94 plat->has_gmac = 1;
95 plat->force_sf_dma_mode = 1;
97 /* Set default value for multicast hash bins */
98 plat->multicast_filter_bins = 256;
100 plat->mac_interface = PHY_INTERFACE_MODE_NA;
103 plat->unicast_filter_entries = 1;
106 plat->maxmtu = JUMBO_LEN;
109 plat->tx_queues_cfg[0].use_prio = false;
110 plat->rx_queues_cfg[0].use_prio = false;
113 plat->rx_queues_cfg[0].pkt_route = 0x0;
115 plat->clk_ref_rate = 125000000;
116 plat->clk_ptp_rate = 125000000;
118 /* Default to phy auto-detection */
119 plat->phy_addr = -1;
121 plat->dma_cfg->pbl = 32;
122 plat->dma_cfg->pblx8 = true;
124 switch (ld->loongson_id) {
126 ld->multichan = 1;
127 plat->rx_queues_to_use = 8;
128 plat->tx_queues_to_use = 8;
134 plat->tx_queues_cfg[i].coe_unsupported = 1;
138 ld->multichan = 1;
139 plat->rx_queues_to_use = 4;
140 plat->tx_queues_to_use = 4;
143 ld->multichan = 0;
144 plat->tx_queues_to_use = 1;
145 plat->rx_queues_to_use = 1;
155 plat->phy_interface = PHY_INTERFACE_MODE_RGMII_ID;
164 static void loongson_gnet_fix_speed(void *priv, int speed, unsigned int mode)
167 struct net_device *ndev = dev_get_drvdata(ld->dev);
171 * speeds to 1000Mbps mode. The speedup procedure requires the PHY-link
172 * re-negotiation.
174 if (speed == SPEED_1000) {
175 if (readl(ptr->ioaddr + MAC_CTRL_REG) &
178 phy_restart_aneg(ndev->phydev);
187 plat->phy_interface = PHY_INTERFACE_MODE_GMII;
188 plat->mdio_bus_data->phy_mask = ~(u32)BIT(2);
189 plat->fix_mac_speed = loongson_gnet_fix_speed;
203 int txpbl = dma_cfg->txpbl ?: dma_cfg->pbl;
204 int rxpbl = dma_cfg->rxpbl ?: dma_cfg->pbl;
209 if (dma_cfg->pblx8)
218 if (dma_cfg->fixed_burst)
222 if (dma_cfg->mixed_burst)
225 if (dma_cfg->atds)
228 if (dma_cfg->aal)
243 struct stmmac_pcpu_stats *stats = this_cpu_ptr(priv->xstats.pcpu_stats);
269 x->tx_undeflow_irq++;
272 x->tx_jabber_irq++;
274 x->rx_overflow_irq++;
276 x->rx_buf_unav_irq++;
278 x->rx_process_stopped_irq++;
280 x->rx_watchdog_irq++;
282 x->tx_early_irq++;
284 x->tx_process_stopped_irq++;
288 x->fatal_bus_error_irq++;
298 u64_stats_update_begin(&stats->syncp);
299 u64_stats_inc(&stats->rx_normal_irq_n[chan]);
300 u64_stats_update_end(&stats->syncp);
305 u64_stats_update_begin(&stats->syncp);
306 u64_stats_inc(&stats->tx_normal_irq_n[chan]);
307 u64_stats_update_end(&stats->syncp);
311 x->rx_early_irq++;
318 /* Clear the interrupt by writing a logic 1 to the CSR5[19-0] */
332 ld = priv->plat->bsp_priv;
333 pdev = to_pci_dev(priv->device);
335 mac = devm_kzalloc(priv->device, sizeof(*mac), GFP_KERNEL);
339 dma = devm_kzalloc(priv->device, sizeof(*dma), GFP_KERNEL);
344 * v3.50a and v3.73a IP-cores. But the HW designers have changed
346 * on the network controllers with the multi-channels feature
347 * available to emphasize the differences: multiple DMA-channels,
349 * original value so the correct HW-interface would be selected.
351 if (ld->multichan) {
352 priv->synopsys_id = DWMAC_CORE_3_70;
354 dma->init_chan = loongson_dwmac_dma_init_channel;
355 dma->dma_interrupt = loongson_dwmac_dma_interrupt;
356 mac->dma = dma;
359 priv->dev->priv_flags |= IFF_UNICAST_FLT;
361 /* Pre-initialize the respective "mac" fields as it's done in
364 mac->pcsr = priv->ioaddr;
365 mac->multicast_filter_bins = priv->plat->multicast_filter_bins;
366 mac->unicast_filter_entries = priv->plat->unicast_filter_entries;
367 mac->mcast_bits_log2 = 0;
369 if (mac->multicast_filter_bins)
370 mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
373 * without multi-channel doesn't support the half-duplex link mode.
375 if (pdev->device != PCI_DEVICE_ID_LOONGSON_GNET) {
376 mac->link.caps = MAC_10 | MAC_100 | MAC_1000;
378 if (ld->multichan)
379 mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
382 mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
386 mac->link.duplex = GMAC_CONTROL_DM;
387 mac->link.speed10 = GMAC_CONTROL_PS;
388 mac->link.speed100 = GMAC_CONTROL_PS | GMAC_CONTROL_FES;
389 mac->link.speed1000 = 0;
390 mac->link.speed_mask = GMAC_CONTROL_PS | GMAC_CONTROL_FES;
391 mac->mii.addr = GMAC_MII_ADDR;
392 mac->mii.data = GMAC_MII_DATA;
393 mac->mii.addr_shift = 11;
394 mac->mii.addr_mask = 0x0000F800;
395 mac->mii.reg_shift = 6;
396 mac->mii.reg_mask = 0x000007C0;
397 mac->mii.clk_csr_shift = 2;
398 mac->mii.clk_csr_mask = GENMASK(5, 2);
409 ch_num = min(plat->tx_queues_to_use, plat->rx_queues_to_use);
414 dev_warn(&pdev->dev, "Failed to allocate MSI IRQs\n");
418 res->irq = pci_irq_vector(pdev, 0);
421 res->rx_irq[ch_num - 1 - i] = pci_irq_vector(pdev, 1 + i * 2);
425 res->tx_irq[ch_num - 1 - i] = pci_irq_vector(pdev, 2 + i * 2);
428 plat->flags |= STMMAC_FLAG_MULTI_MSI_EN;
442 struct device_node *np = dev_of_node(&pdev->dev);
445 plat->mdio_node = of_get_child_by_name(np, "mdio");
446 if (plat->mdio_node) {
447 dev_info(&pdev->dev, "Found MDIO subnode\n");
448 plat->mdio_bus_data->needs_reset = true;
453 plat->bus_id = ret;
455 res->irq = of_irq_get_byname(np, "macirq");
456 if (res->irq < 0) {
457 dev_err(&pdev->dev, "IRQ macirq not found\n");
458 ret = -ENODEV;
462 res->wol_irq = of_irq_get_byname(np, "eth_wake_irq");
463 if (res->wol_irq < 0) {
464 dev_info(&pdev->dev,
466 res->wol_irq = res->irq;
469 res->lpi_irq = of_irq_get_byname(np, "eth_lpi");
470 if (res->lpi_irq < 0) {
471 dev_err(&pdev->dev, "IRQ eth_lpi not found\n");
472 ret = -ENODEV;
476 ret = device_get_phy_mode(&pdev->dev);
478 dev_err(&pdev->dev, "phy_mode not found\n");
479 ret = -ENODEV;
483 plat->phy_interface = ret;
488 of_node_put(plat->mdio_node);
496 of_node_put(plat->mdio_node);
503 if (!pdev->irq)
504 return -EINVAL;
506 res->irq = pdev->irq;
532 plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
534 return -ENOMEM;
536 plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
537 sizeof(*plat->mdio_bus_data),
539 if (!plat->mdio_bus_data)
540 return -ENOMEM;
542 plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg), GFP_KERNEL);
543 if (!plat->dma_cfg)
544 return -ENOMEM;
546 ld = devm_kzalloc(&pdev->dev, sizeof(*ld), GFP_KERNEL);
548 return -ENOMEM;
553 dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n", __func__);
565 plat->bsp_priv = ld;
566 plat->setup = loongson_dwmac_setup;
567 plat->fix_soc_reset = loongson_dwmac_fix_reset;
568 ld->dev = &pdev->dev;
569 ld->loongson_id = readl(res.addr + GMAC_VERSION) & 0xff;
571 info = (struct stmmac_pci_info *)id->driver_data;
572 ret = info->setup(pdev, plat);
576 plat->tx_fifo_size = SZ_16K * plat->tx_queues_to_use;
577 plat->rx_fifo_size = SZ_16K * plat->rx_queues_to_use;
579 if (dev_of_node(&pdev->dev))
586 /* Use the common MAC IRQ if per-channel MSIs allocation failed */
587 if (ld->multichan)
590 ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
597 if (dev_of_node(&pdev->dev))
599 if (ld->multichan)
608 struct net_device *ndev = dev_get_drvdata(&pdev->dev);
612 ld = priv->plat->bsp_priv;
613 stmmac_dvr_remove(&pdev->dev);
615 if (dev_of_node(&pdev->dev))
616 loongson_dwmac_dt_clear(pdev, priv->plat);
618 if (ld->multichan)