1 // SPDX-License-Identifier: GPL-2.0+
3 * ENETC ethernet controller driver
4 * Copyright 2017-2021 NXP
10 #include <fdt_support.h>
14 #include <asm/cache.h>
18 #include <linux/bug.h>
19 #include <linux/delay.h>
21 #include "fsl_enetc.h"
23 #define ENETC_DRIVER_NAME "enetc_eth"
26 * sets the MAC address in IERB registers, this setting is persistent and
27 * carried over to Linux.
29 static void enetc_set_ierb_primary_mac(struct udevice *dev, int devfn,
32 #ifdef CONFIG_ARCH_LS1028A
34 * LS1028A is the only part with IERB at this time and there are plans to change
35 * its structure, keep this LS1028A specific for now
37 #define IERB_BASE 0x1f0800000ULL
38 #define IERB_PFMAC(pf, vf, n) (IERB_BASE + 0x8000 + (pf) * 0x100 + (vf) * 8 \
41 static int ierb_fn_to_pf[] = {0, 1, 2, -1, -1, -1, 3};
43 u16 lower = *(const u16 *)(enetaddr + 4);
44 u32 upper = *(const u32 *)enetaddr;
46 if (ierb_fn_to_pf[devfn] < 0)
49 out_le32(IERB_PFMAC(ierb_fn_to_pf[devfn], 0, 0), upper);
50 out_le32(IERB_PFMAC(ierb_fn_to_pf[devfn], 0, 1), (u32)lower);
54 /* sets up primary MAC addresses in DT/IERB */
55 void fdt_fixup_enetc_mac(void *blob)
57 struct pci_child_plat *ppdata;
58 struct eth_pdata *pdata;
65 uclass_get(UCLASS_ETH, &uc);
66 uclass_foreach_dev(dev, uc) {
67 if (!dev->driver || !dev->driver->name ||
68 strcmp(dev->driver->name, ENETC_DRIVER_NAME))
71 pdata = dev_get_plat(dev);
72 ppdata = dev_get_parent_plat(dev);
73 devfn = PCI_FUNC(ppdata->devfn);
75 enetc_set_ierb_primary_mac(dev, devfn, pdata->enetaddr);
77 snprintf(path, 256, "/soc/pcie@1f0000000/ethernet@%x,%x",
78 PCI_DEV(ppdata->devfn), PCI_FUNC(ppdata->devfn));
79 offset = fdt_path_offset(blob, path);
82 fdt_setprop(blob, offset, "mac-address", pdata->enetaddr, 6);
88 * - set a more explicit name on the interface
90 static int enetc_bind(struct udevice *dev)
93 static int eth_num_devices;
96 * prefer using PCI function numbers to number interfaces, but these
97 * are only available if dts nodes are present. For PCI they are
98 * optional, handle that case too. Just in case some nodes are present
99 * and some are not, use different naming scheme - enetc-N based on
100 * PCI function # and enetc#N based on interface count
102 if (ofnode_valid(dev_ofnode(dev)))
103 sprintf(name, "enetc-%u", PCI_FUNC(pci_get_devfn(dev)));
105 sprintf(name, "enetc#%u", eth_num_devices++);
106 device_set_name(dev, name);
111 /* MDIO wrappers, we're using these to drive internal MDIO to get to serdes */
112 static int enetc_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)
114 struct enetc_mdio_priv priv;
116 priv.regs_base = bus->priv;
117 return enetc_mdio_read_priv(&priv, addr, devad, reg);
120 static int enetc_mdio_write(struct mii_dev *bus, int addr, int devad, int reg,
123 struct enetc_mdio_priv priv;
125 priv.regs_base = bus->priv;
126 return enetc_mdio_write_priv(&priv, addr, devad, reg, val);
129 /* only interfaces that can pin out through serdes have internal MDIO */
130 static bool enetc_has_imdio(struct udevice *dev)
132 struct enetc_priv *priv = dev_get_priv(dev);
134 return !!(priv->imdio.priv);
137 /* set up serdes for SGMII */
138 static int enetc_init_sgmii(struct udevice *dev)
140 struct enetc_priv *priv = dev_get_priv(dev);
144 if (!enetc_has_imdio(dev))
147 if (priv->if_type == PHY_INTERFACE_MODE_2500BASEX)
151 * Set to SGMII mode, for 1Gbps enable AN, for 2.5Gbps set fixed speed.
152 * Although fixed speed is 1Gbps, we could be running at 2.5Gbps based
153 * on PLL configuration. Setting 1G for 2.5G here is counter intuitive
156 reg = ENETC_PCS_IF_MODE_SGMII;
157 reg |= is2500 ? ENETC_PCS_IF_MODE_SPEED_1G : ENETC_PCS_IF_MODE_SGMII_AN;
158 enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, MDIO_DEVAD_NONE,
159 ENETC_PCS_IF_MODE, reg);
161 /* Dev ability - SGMII */
162 enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, MDIO_DEVAD_NONE,
163 ENETC_PCS_DEV_ABILITY, ENETC_PCS_DEV_ABILITY_SGMII);
165 /* Adjust link timer for SGMII */
166 enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, MDIO_DEVAD_NONE,
167 ENETC_PCS_LINK_TIMER1, ENETC_PCS_LINK_TIMER1_VAL);
168 enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, MDIO_DEVAD_NONE,
169 ENETC_PCS_LINK_TIMER2, ENETC_PCS_LINK_TIMER2_VAL);
171 reg = ENETC_PCS_CR_DEF_VAL;
172 reg |= is2500 ? ENETC_PCS_CR_RST : ENETC_PCS_CR_RESET_AN;
174 enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, MDIO_DEVAD_NONE,
180 /* set up MAC for RGMII */
181 static void enetc_init_rgmii(struct udevice *dev, struct phy_device *phydev)
183 struct enetc_priv *priv = dev_get_priv(dev);
186 old_val = val = enetc_read_port(priv, ENETC_PM_IF_MODE);
188 /* disable unreliable RGMII in-band signaling and force the MAC into
189 * the speed negotiated by the PHY.
191 val &= ~ENETC_PM_IF_MODE_AN_ENA;
193 if (phydev->speed == SPEED_1000) {
194 val &= ~ENETC_PM_IFM_SSP_MASK;
195 val |= ENETC_PM_IFM_SSP_1000;
196 } else if (phydev->speed == SPEED_100) {
197 val &= ~ENETC_PM_IFM_SSP_MASK;
198 val |= ENETC_PM_IFM_SSP_100;
199 } else if (phydev->speed == SPEED_10) {
200 val &= ~ENETC_PM_IFM_SSP_MASK;
201 val |= ENETC_PM_IFM_SSP_10;
204 if (phydev->duplex == DUPLEX_FULL)
205 val |= ENETC_PM_IFM_FULL_DPX;
207 val &= ~ENETC_PM_IFM_FULL_DPX;
212 enetc_write_port(priv, ENETC_PM_IF_MODE, val);
215 /* set up MAC configuration for the given interface type */
216 static void enetc_setup_mac_iface(struct udevice *dev,
217 struct phy_device *phydev)
219 struct enetc_priv *priv = dev_get_priv(dev);
222 switch (priv->if_type) {
223 case PHY_INTERFACE_MODE_RGMII:
224 case PHY_INTERFACE_MODE_RGMII_ID:
225 case PHY_INTERFACE_MODE_RGMII_RXID:
226 case PHY_INTERFACE_MODE_RGMII_TXID:
227 enetc_init_rgmii(dev, phydev);
229 case PHY_INTERFACE_MODE_USXGMII:
230 case PHY_INTERFACE_MODE_10GBASER:
231 /* set ifmode to (US)XGMII */
232 if_mode = enetc_read_port(priv, ENETC_PM_IF_MODE);
233 if_mode &= ~ENETC_PM_IF_IFMODE_MASK;
234 enetc_write_port(priv, ENETC_PM_IF_MODE, if_mode);
239 /* set up serdes for SXGMII */
240 static int enetc_init_sxgmii(struct udevice *dev)
242 struct enetc_priv *priv = dev_get_priv(dev);
244 if (!enetc_has_imdio(dev))
247 /* Dev ability - SXGMII */
248 enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, ENETC_PCS_DEVAD_REPL,
249 ENETC_PCS_DEV_ABILITY, ENETC_PCS_DEV_ABILITY_SXGMII);
252 enetc_mdio_write(&priv->imdio, ENETC_PCS_PHY_ADDR, ENETC_PCS_DEVAD_REPL,
254 ENETC_PCS_CR_RST | ENETC_PCS_CR_RESET_AN);
259 /* Apply protocol specific configuration to MAC, serdes as needed */
260 static void enetc_start_pcs(struct udevice *dev)
262 struct enetc_priv *priv = dev_get_priv(dev);
264 /* register internal MDIO for debug purposes */
265 if (enetc_read_port(priv, ENETC_PCAPR0) & ENETC_PCAPRO_MDIO) {
266 priv->imdio.read = enetc_mdio_read;
267 priv->imdio.write = enetc_mdio_write;
268 priv->imdio.priv = priv->port_regs + ENETC_PM_IMDIO_BASE;
269 strlcpy(priv->imdio.name, dev->name, MDIO_NAME_LEN);
270 if (!miiphy_get_dev_by_name(priv->imdio.name))
271 mdio_register(&priv->imdio);
274 if (!ofnode_valid(dev_ofnode(dev))) {
275 enetc_dbg(dev, "no enetc ofnode found, skipping PCS set-up\n");
279 priv->if_type = dev_read_phy_mode(dev);
280 if (priv->if_type == PHY_INTERFACE_MODE_NA) {
282 "phy-mode property not found, defaulting to SGMII\n");
283 priv->if_type = PHY_INTERFACE_MODE_SGMII;
286 switch (priv->if_type) {
287 case PHY_INTERFACE_MODE_SGMII:
288 case PHY_INTERFACE_MODE_2500BASEX:
289 enetc_init_sgmii(dev);
291 case PHY_INTERFACE_MODE_USXGMII:
292 case PHY_INTERFACE_MODE_10GBASER:
293 enetc_init_sxgmii(dev);
298 /* Configure the actual/external ethernet PHY, if one is found */
299 static int enetc_config_phy(struct udevice *dev)
301 struct enetc_priv *priv = dev_get_priv(dev);
304 priv->phy = dm_eth_phy_connect(dev);
308 supported = PHY_GBIT_FEATURES | SUPPORTED_2500baseX_Full;
309 priv->phy->supported &= supported;
310 priv->phy->advertising &= supported;
312 return phy_config(priv->phy);
316 * Probe ENETC driver:
317 * - initialize port and station interface BARs
319 static int enetc_probe(struct udevice *dev)
321 struct enetc_priv *priv = dev_get_priv(dev);
323 if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_available(dev_ofnode(dev))) {
324 enetc_dbg(dev, "interface disabled\n");
328 priv->enetc_txbd = memalign(ENETC_BD_ALIGN,
329 sizeof(struct enetc_tx_bd) * ENETC_BD_CNT);
330 priv->enetc_rxbd = memalign(ENETC_BD_ALIGN,
331 sizeof(union enetc_rx_bd) * ENETC_BD_CNT);
333 if (!priv->enetc_txbd || !priv->enetc_rxbd) {
334 /* free should be able to handle NULL, just free all pointers */
335 free(priv->enetc_txbd);
336 free(priv->enetc_rxbd);
341 /* initialize register */
342 priv->regs_base = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, 0, 0, PCI_REGION_TYPE, 0);
343 if (!priv->regs_base) {
344 enetc_dbg(dev, "failed to map BAR0\n");
347 priv->port_regs = priv->regs_base + ENETC_PORT_REGS_OFF;
349 dm_pci_clrset_config16(dev, PCI_COMMAND, 0, PCI_COMMAND_MEMORY);
351 enetc_start_pcs(dev);
353 return enetc_config_phy(dev);
357 * Remove the driver from an interface:
358 * - free up allocated memory
360 static int enetc_remove(struct udevice *dev)
362 struct enetc_priv *priv = dev_get_priv(dev);
364 if (miiphy_get_dev_by_name(priv->imdio.name))
365 mdio_unregister(&priv->imdio);
367 free(priv->enetc_txbd);
368 free(priv->enetc_rxbd);
374 * LS1028A is the only part with IERB at this time and there are plans to
375 * change its structure, keep this LS1028A specific for now.
377 #define LS1028A_IERB_BASE 0x1f0800000ULL
378 #define LS1028A_IERB_PSIPMAR0(pf, vf) (LS1028A_IERB_BASE + 0x8000 \
379 + (pf) * 0x100 + (vf) * 8)
380 #define LS1028A_IERB_PSIPMAR1(pf, vf) (LS1028A_IERB_PSIPMAR0(pf, vf) + 4)
382 static int enetc_ls1028a_write_hwaddr(struct udevice *dev)
384 struct pci_child_plat *ppdata = dev_get_parent_plat(dev);
385 const int devfn_to_pf[] = {0, 1, 2, -1, -1, -1, 3};
386 struct eth_pdata *plat = dev_get_plat(dev);
387 int devfn = PCI_FUNC(ppdata->devfn);
388 u8 *addr = plat->enetaddr;
392 if (devfn >= ARRAY_SIZE(devfn_to_pf))
395 pf = devfn_to_pf[devfn];
399 lower = *(const u16 *)(addr + 4);
400 upper = *(const u32 *)addr;
402 out_le32(LS1028A_IERB_PSIPMAR0(pf, 0), upper);
403 out_le32(LS1028A_IERB_PSIPMAR1(pf, 0), lower);
408 static int enetc_write_hwaddr(struct udevice *dev)
410 struct eth_pdata *plat = dev_get_plat(dev);
411 struct enetc_priv *priv = dev_get_priv(dev);
412 u8 *addr = plat->enetaddr;
414 if (IS_ENABLED(CONFIG_ARCH_LS1028A))
415 return enetc_ls1028a_write_hwaddr(dev);
417 u16 lower = *(const u16 *)(addr + 4);
418 u32 upper = *(const u32 *)addr;
420 enetc_write_port(priv, ENETC_PSIPMAR0, upper);
421 enetc_write_port(priv, ENETC_PSIPMAR1, lower);
426 /* Configure port parameters (# of rings, frame size, enable port) */
427 static void enetc_enable_si_port(struct enetc_priv *priv)
431 /* set Rx/Tx BDR count */
432 val = ENETC_PSICFGR_SET_TXBDR(ENETC_TX_BDR_CNT);
433 val |= ENETC_PSICFGR_SET_RXBDR(ENETC_RX_BDR_CNT);
434 enetc_write_port(priv, ENETC_PSICFGR(0), val);
435 /* set Rx max frame size */
436 enetc_write_port(priv, ENETC_PM_MAXFRM, ENETC_RX_MAXFRM_SIZE);
437 /* enable MAC port */
438 enetc_write_port(priv, ENETC_PM_CC, ENETC_PM_CC_RX_TX_EN);
440 enetc_write_port(priv, ENETC_PMR, ENETC_PMR_SI0_EN);
441 /* set SI cache policy */
442 enetc_write(priv, ENETC_SICAR0,
443 ENETC_SICAR_RD_CFG | ENETC_SICAR_WR_CFG);
445 enetc_write(priv, ENETC_SIMR, ENETC_SIMR_EN);
448 /* returns DMA address for a given buffer index */
449 static inline u64 enetc_rxb_address(struct udevice *dev, int i)
451 return cpu_to_le64(dm_pci_virt_to_mem(dev, net_rx_packets[i]));
455 * Setup a single Tx BD Ring (ID = 0):
456 * - set Tx buffer descriptor address
458 * - initialize the producer and consumer index
460 static void enetc_setup_tx_bdr(struct udevice *dev)
462 struct enetc_priv *priv = dev_get_priv(dev);
463 struct bd_ring *tx_bdr = &priv->tx_bdr;
464 u64 tx_bd_add = (u64)priv->enetc_txbd;
466 /* used later to advance to the next Tx BD */
467 tx_bdr->bd_count = ENETC_BD_CNT;
468 tx_bdr->next_prod_idx = 0;
469 tx_bdr->next_cons_idx = 0;
470 tx_bdr->cons_idx = priv->regs_base +
471 ENETC_BDR(TX, ENETC_TX_BDR_ID, ENETC_TBCIR);
472 tx_bdr->prod_idx = priv->regs_base +
473 ENETC_BDR(TX, ENETC_TX_BDR_ID, ENETC_TBPIR);
475 /* set Tx BD address */
476 enetc_bdr_write(priv, TX, ENETC_TX_BDR_ID, ENETC_TBBAR0,
477 lower_32_bits(tx_bd_add));
478 enetc_bdr_write(priv, TX, ENETC_TX_BDR_ID, ENETC_TBBAR1,
479 upper_32_bits(tx_bd_add));
480 /* set Tx 8 BD count */
481 enetc_bdr_write(priv, TX, ENETC_TX_BDR_ID, ENETC_TBLENR,
484 /* reset both producer/consumer indexes */
485 enetc_write_reg(tx_bdr->cons_idx, tx_bdr->next_cons_idx);
486 enetc_write_reg(tx_bdr->prod_idx, tx_bdr->next_prod_idx);
489 enetc_bdr_write(priv, TX, ENETC_TX_BDR_ID, ENETC_TBMR, ENETC_TBMR_EN);
493 * Setup a single Rx BD Ring (ID = 0):
494 * - set Rx buffer descriptors address (one descriptor per buffer)
495 * - set buffer size as max frame size
497 * - reset consumer and producer indexes
498 * - set buffer for each descriptor
500 static void enetc_setup_rx_bdr(struct udevice *dev)
502 struct enetc_priv *priv = dev_get_priv(dev);
503 struct bd_ring *rx_bdr = &priv->rx_bdr;
504 u64 rx_bd_add = (u64)priv->enetc_rxbd;
507 /* used later to advance to the next BD produced by ENETC HW */
508 rx_bdr->bd_count = ENETC_BD_CNT;
509 rx_bdr->next_prod_idx = 0;
510 rx_bdr->next_cons_idx = 0;
511 rx_bdr->cons_idx = priv->regs_base +
512 ENETC_BDR(RX, ENETC_RX_BDR_ID, ENETC_RBCIR);
513 rx_bdr->prod_idx = priv->regs_base +
514 ENETC_BDR(RX, ENETC_RX_BDR_ID, ENETC_RBPIR);
516 /* set Rx BD address */
517 enetc_bdr_write(priv, RX, ENETC_RX_BDR_ID, ENETC_RBBAR0,
518 lower_32_bits(rx_bd_add));
519 enetc_bdr_write(priv, RX, ENETC_RX_BDR_ID, ENETC_RBBAR1,
520 upper_32_bits(rx_bd_add));
521 /* set Rx BD count (multiple of 8) */
522 enetc_bdr_write(priv, RX, ENETC_RX_BDR_ID, ENETC_RBLENR,
524 /* set Rx buffer size */
525 enetc_bdr_write(priv, RX, ENETC_RX_BDR_ID, ENETC_RBBSR, PKTSIZE_ALIGN);
528 memset(priv->enetc_rxbd, 0,
529 rx_bdr->bd_count * sizeof(union enetc_rx_bd));
530 for (i = 0; i < rx_bdr->bd_count; i++) {
531 priv->enetc_rxbd[i].w.addr = enetc_rxb_address(dev, i);
532 /* each RX buffer must be aligned to 64B */
533 WARN_ON(priv->enetc_rxbd[i].w.addr & (ARCH_DMA_MINALIGN - 1));
536 /* reset producer (ENETC owned) and consumer (SW owned) index */
537 enetc_write_reg(rx_bdr->cons_idx, rx_bdr->next_cons_idx);
538 enetc_write_reg(rx_bdr->prod_idx, rx_bdr->next_prod_idx);
541 enetc_bdr_write(priv, RX, ENETC_RX_BDR_ID, ENETC_RBMR, ENETC_RBMR_EN);
545 * Start ENETC interface:
547 * - enable access to port and SI registers
549 * - setup TX/RX buffer descriptors
550 * - enable Tx/Rx rings
552 static int enetc_start(struct udevice *dev)
554 struct enetc_priv *priv = dev_get_priv(dev);
556 /* reset and enable the PCI device */
558 dm_pci_clrset_config16(dev, PCI_COMMAND, 0,
559 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
561 enetc_enable_si_port(priv);
563 /* setup Tx/Rx buffer descriptors */
564 enetc_setup_tx_bdr(dev);
565 enetc_setup_rx_bdr(dev);
567 enetc_setup_mac_iface(dev, priv->phy);
569 return phy_startup(priv->phy);
573 * Stop the network interface:
574 * - just quiesce it, we can wipe all configuration as _start starts from
577 static void enetc_stop(struct udevice *dev)
579 /* FLR is sufficient to quiesce the device */
581 /* leave the BARs accessible after we stop, this is needed to use
582 * internal MDIO in command line.
584 dm_pci_clrset_config16(dev, PCI_COMMAND, 0, PCI_COMMAND_MEMORY);
588 * ENETC transmit packet:
589 * - check if Tx BD ring is full
590 * - set buffer/packet address (dma address)
591 * - set final fragment flag
592 * - try while producer index equals consumer index or timeout
594 static int enetc_send(struct udevice *dev, void *packet, int length)
596 struct enetc_priv *priv = dev_get_priv(dev);
597 struct bd_ring *txr = &priv->tx_bdr;
598 void *nv_packet = (void *)packet;
599 int tries = ENETC_POLL_TRIES;
602 pi = txr->next_prod_idx;
603 ci = enetc_read_reg(txr->cons_idx) & ENETC_BDR_IDX_MASK;
604 /* Tx ring is full when */
605 if (((pi + 1) % txr->bd_count) == ci) {
606 enetc_dbg(dev, "Tx BDR full\n");
609 enetc_dbg(dev, "TxBD[%d]send: pkt_len=%d, buff @0x%x%08x\n", pi, length,
610 upper_32_bits((u64)nv_packet), lower_32_bits((u64)nv_packet));
613 memset(&priv->enetc_txbd[pi], 0x0, sizeof(struct enetc_tx_bd));
614 priv->enetc_txbd[pi].addr =
615 cpu_to_le64(dm_pci_virt_to_mem(dev, nv_packet));
616 priv->enetc_txbd[pi].buf_len = cpu_to_le16(length);
617 priv->enetc_txbd[pi].frm_len = cpu_to_le16(length);
618 priv->enetc_txbd[pi].flags = cpu_to_le16(ENETC_TXBD_FLAGS_F);
620 /* send frame: increment producer index */
621 pi = (pi + 1) % txr->bd_count;
622 txr->next_prod_idx = pi;
623 enetc_write_reg(txr->prod_idx, pi);
624 while ((--tries >= 0) &&
625 (pi != (enetc_read_reg(txr->cons_idx) & ENETC_BDR_IDX_MASK)))
628 return tries > 0 ? 0 : -ETIMEDOUT;
633 * - wait for the next BD to get ready bit set
634 * - clean up the descriptor
635 * - move on and indicate to HW that the cleaned BD is available for Rx
637 static int enetc_recv(struct udevice *dev, int flags, uchar **packetp)
639 struct enetc_priv *priv = dev_get_priv(dev);
640 struct bd_ring *rxr = &priv->rx_bdr;
641 int tries = ENETC_POLL_TRIES;
642 int pi = rxr->next_prod_idx;
643 int ci = rxr->next_cons_idx;
650 status = le32_to_cpu(priv->enetc_rxbd[pi].r.lstatus);
651 /* check if current BD is ready to be consumed */
652 rdy = ENETC_RXBD_STATUS_R(status);
653 } while (--tries >= 0 && !rdy);
659 len = le16_to_cpu(priv->enetc_rxbd[pi].r.buf_len);
660 *packetp = (uchar *)enetc_rxb_address(dev, pi);
661 enetc_dbg(dev, "RxBD[%d]: len=%d err=%d pkt=0x%x%08x\n", pi, len,
662 ENETC_RXBD_STATUS_ERRORS(status),
663 upper_32_bits((u64)*packetp), lower_32_bits((u64)*packetp));
665 /* BD clean up and advance to next in ring */
666 memset(&priv->enetc_rxbd[pi], 0, sizeof(union enetc_rx_bd));
667 priv->enetc_rxbd[pi].w.addr = enetc_rxb_address(dev, pi);
668 rxr->next_prod_idx = (pi + 1) % rxr->bd_count;
669 ci = (ci + 1) % rxr->bd_count;
670 rxr->next_cons_idx = ci;
672 /* free up the slot in the ring for HW */
673 enetc_write_reg(rxr->cons_idx, ci);
678 static const struct eth_ops enetc_ops = {
679 .start = enetc_start,
683 .write_hwaddr = enetc_write_hwaddr,
686 U_BOOT_DRIVER(eth_enetc) = {
687 .name = ENETC_DRIVER_NAME,
690 .probe = enetc_probe,
691 .remove = enetc_remove,
693 .priv_auto = sizeof(struct enetc_priv),
694 .plat_auto = sizeof(struct eth_pdata),
697 static struct pci_device_id enetc_ids[] = {
698 { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, PCI_DEVICE_ID_ENETC_ETH) },
702 U_BOOT_PCI_DEVICE(eth_enetc, enetc_ids);