3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
17 DECLARE_GLOBAL_DATA_PTR;
19 /* define WANT_MII when MII support is required */
20 #if defined(CONFIG_SYS_DISCOVER_PHY) || defined(CONFIG_FEC1_PHY) || defined(CONFIG_FEC2_PHY)
29 #if !(defined(CONFIG_MII) || defined(CONFIG_CMD_MII))
30 #error "CONFIG_MII has to be defined!"
35 #if defined(CONFIG_RMII) && !defined(WANT_MII)
36 #error RMII support is unusable without a working PHY.
39 #ifdef CONFIG_SYS_DISCOVER_PHY
40 static int mii_discover_phy(struct eth_device *dev);
43 int fec8xx_miiphy_read(struct mii_dev *bus, int addr, int devad, int reg);
44 int fec8xx_miiphy_write(struct mii_dev *bus, int addr, int devad, int reg,
47 static struct ether_fcc_info_s
56 #if defined(CONFIG_ETHER_ON_FEC1)
59 offsetof(immap_t, im_cpm.cp_fec1),
66 #if defined(CONFIG_ETHER_ON_FEC2)
69 offsetof(immap_t, im_cpm.cp_fec2),
77 /* Ethernet Transmit and Receive Buffers */
78 #define DBUF_LENGTH 1520
84 #define PKT_MAXBUF_SIZE 1518
85 #define PKT_MINBUF_SIZE 64
86 #define PKT_MAXBLR_SIZE 1520
89 static char txbuf[DBUF_LENGTH] __aligned(8);
91 #error txbuf must be aligned.
94 static uint rxIdx; /* index of the current RX buffer */
95 static uint txIdx; /* index of the current TX buffer */
98 * FEC Ethernet Tx and Rx buffer descriptors allocated at the
99 * immr->udata_bd address on Dual-Port RAM
100 * Provide for Double Buffering
103 struct common_buf_desc {
104 cbd_t rxbd[PKTBUFSRX]; /* Rx BD */
105 cbd_t txbd[TX_BUF_CNT]; /* Tx BD */
108 static struct common_buf_desc __iomem *rtx;
110 static int fec_send(struct eth_device *dev, void *packet, int length);
111 static int fec_recv(struct eth_device *dev);
112 static int fec_init(struct eth_device *dev, bd_t *bd);
113 static void fec_halt(struct eth_device *dev);
114 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
115 static void __mii_init(void);
118 int fec_initialize(bd_t *bis)
120 struct eth_device *dev;
121 struct ether_fcc_info_s *efis;
124 for (i = 0; i < ARRAY_SIZE(ether_fcc_info); i++) {
125 dev = malloc(sizeof(*dev));
129 memset(dev, 0, sizeof(*dev));
131 /* for FEC1 make sure that the name of the interface is the same
132 as the old one for compatibility reasons */
134 strcpy(dev->name, "FEC");
136 sprintf(dev->name, "FEC%d",
137 ether_fcc_info[i].ether_index + 1);
139 efis = ðer_fcc_info[i];
142 * reset actual phy addr
144 efis->actual_phy_addr = -1;
147 dev->init = fec_init;
148 dev->halt = fec_halt;
149 dev->send = fec_send;
150 dev->recv = fec_recv;
154 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
156 struct mii_dev *mdiodev = mdio_alloc();
159 strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
160 mdiodev->read = fec8xx_miiphy_read;
161 mdiodev->write = fec8xx_miiphy_write;
163 retval = mdio_register(mdiodev);
171 static int fec_send(struct eth_device *dev, void *packet, int length)
174 struct ether_fcc_info_s *efis = dev->priv;
175 fec_t __iomem *fecp =
176 (fec_t __iomem *)(CONFIG_SYS_IMMR + efis->fecp_offset);
182 while ((in_be16(&rtx->txbd[txIdx].cbd_sc) & BD_ENET_TX_READY) &&
188 printf("TX not ready\n");
190 out_be32(&rtx->txbd[txIdx].cbd_bufaddr, (uint)packet);
191 out_be16(&rtx->txbd[txIdx].cbd_datlen, length);
192 setbits_be16(&rtx->txbd[txIdx].cbd_sc,
193 BD_ENET_TX_READY | BD_ENET_TX_LAST);
195 /* Activate transmit Buffer Descriptor polling */
196 /* Descriptor polling active */
197 out_be32(&fecp->fec_x_des_active, 0x01000000);
200 while ((in_be16(&rtx->txbd[txIdx].cbd_sc) & BD_ENET_TX_READY) &&
206 printf("TX timeout\n");
208 /* return only status bits */;
209 rc = in_be16(&rtx->txbd[txIdx].cbd_sc) & BD_ENET_TX_STATS;
211 txIdx = (txIdx + 1) % TX_BUF_CNT;
216 static int fec_recv(struct eth_device *dev)
218 struct ether_fcc_info_s *efis = dev->priv;
219 fec_t __iomem *fecp =
220 (fec_t __iomem *)(CONFIG_SYS_IMMR + efis->fecp_offset);
224 /* section 16.9.23.2 */
225 if (in_be16(&rtx->rxbd[rxIdx].cbd_sc) & BD_ENET_RX_EMPTY) {
227 break; /* nothing received - leave for() loop */
230 length = in_be16(&rtx->rxbd[rxIdx].cbd_datlen);
232 if (!(in_be16(&rtx->rxbd[rxIdx].cbd_sc) & 0x003f)) {
233 uchar *rx = net_rx_packets[rxIdx];
237 #if defined(CONFIG_CMD_CDP)
238 if ((rx[0] & 1) != 0 &&
239 memcmp((uchar *)rx, net_bcast_ethaddr, 6) != 0 &&
240 !is_cdp_packet((uchar *)rx))
244 * Pass the packet up to the protocol layers.
247 net_process_received_packet(rx, length);
250 /* Give the buffer back to the FEC. */
251 out_be16(&rtx->rxbd[rxIdx].cbd_datlen, 0);
253 /* wrap around buffer index when necessary */
254 if ((rxIdx + 1) >= PKTBUFSRX) {
255 out_be16(&rtx->rxbd[PKTBUFSRX - 1].cbd_sc,
256 BD_ENET_RX_WRAP | BD_ENET_RX_EMPTY);
259 out_be16(&rtx->rxbd[rxIdx].cbd_sc, BD_ENET_RX_EMPTY);
263 /* Try to fill Buffer Descriptors */
264 /* Descriptor polling active */
265 out_be32(&fecp->fec_r_des_active, 0x01000000);
271 /**************************************************************
273 * FEC Ethernet Initialization Routine
275 *************************************************************/
277 #define FEC_ECNTRL_PINMUX 0x00000004
278 #define FEC_ECNTRL_ETHER_EN 0x00000002
279 #define FEC_ECNTRL_RESET 0x00000001
281 #define FEC_RCNTRL_BC_REJ 0x00000010
282 #define FEC_RCNTRL_PROM 0x00000008
283 #define FEC_RCNTRL_MII_MODE 0x00000004
284 #define FEC_RCNTRL_DRT 0x00000002
285 #define FEC_RCNTRL_LOOP 0x00000001
287 #define FEC_TCNTRL_FDEN 0x00000004
288 #define FEC_TCNTRL_HBC 0x00000002
289 #define FEC_TCNTRL_GTS 0x00000001
291 #define FEC_RESET_DELAY 50
293 #if defined(CONFIG_RMII)
295 static inline void fec_10Mbps(struct eth_device *dev)
297 struct ether_fcc_info_s *efis = dev->priv;
298 int fecidx = efis->ether_index;
299 uint mask = (fecidx == 0) ? 0x0000010 : 0x0000008;
300 immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR;
302 if ((unsigned int)fecidx >= 2)
305 setbits_be32(&immr->im_cpm.cp_cptr, mask);
308 static inline void fec_100Mbps(struct eth_device *dev)
310 struct ether_fcc_info_s *efis = dev->priv;
311 int fecidx = efis->ether_index;
312 uint mask = (fecidx == 0) ? 0x0000010 : 0x0000008;
313 immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR;
315 if ((unsigned int)fecidx >= 2)
318 clrbits_be32(&immr->im_cpm.cp_cptr, mask);
323 static inline void fec_full_duplex(struct eth_device *dev)
325 struct ether_fcc_info_s *efis = dev->priv;
326 fec_t __iomem *fecp =
327 (fec_t __iomem *)(CONFIG_SYS_IMMR + efis->fecp_offset);
329 clrbits_be32(&fecp->fec_r_cntrl, FEC_RCNTRL_DRT);
330 setbits_be32(&fecp->fec_x_cntrl, FEC_TCNTRL_FDEN); /* FD enable */
333 static inline void fec_half_duplex(struct eth_device *dev)
335 struct ether_fcc_info_s *efis = dev->priv;
336 fec_t __iomem *fecp =
337 (fec_t __iomem *)(CONFIG_SYS_IMMR + efis->fecp_offset);
339 setbits_be32(&fecp->fec_r_cntrl, FEC_RCNTRL_DRT);
340 clrbits_be32(&fecp->fec_x_cntrl, FEC_TCNTRL_FDEN); /* FD disable */
343 static void fec_pin_init(int fecidx)
346 immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR;
349 * Set MII speed to 2.5 MHz or slightly below.
351 * According to the MPC860T (Rev. D) Fast ethernet controller user
353 * the MII management interface clock must be less than or equal
355 * This MDC frequency is equal to system clock / (2 * MII_SPEED).
356 * Then MII_SPEED = system_clock / 2 * 2,5 MHz.
358 * All MII configuration is done via FEC1 registers:
360 out_be32(&immr->im_cpm.cp_fec1.fec_mii_speed,
361 ((bd->bi_intfreq + 4999999) / 5000000) << 1);
363 #if defined(CONFIG_MPC885) && defined(WANT_MII)
364 /* use MDC for MII */
365 setbits_be16(&immr->im_ioport.iop_pdpar, 0x0080);
366 clrbits_be16(&immr->im_ioport.iop_pddir, 0x0080);
370 #if defined(CONFIG_ETHER_ON_FEC1)
372 #if defined(CONFIG_MPC885) /* MPC87x/88x have got 2 FECs and different pinout */
374 #if !defined(CONFIG_RMII)
376 setbits_be16(&immr->im_ioport.iop_papar, 0xf830);
377 setbits_be16(&immr->im_ioport.iop_padir, 0x0830);
378 clrbits_be16(&immr->im_ioport.iop_padir, 0xf000);
380 setbits_be32(&immr->im_cpm.cp_pbpar, 0x00001001);
381 clrbits_be32(&immr->im_cpm.cp_pbdir, 0x00001001);
383 setbits_be16(&immr->im_ioport.iop_pcpar, 0x000c);
384 clrbits_be16(&immr->im_ioport.iop_pcdir, 0x000c);
386 setbits_be32(&immr->im_cpm.cp_pepar, 0x00000003);
387 setbits_be32(&immr->im_cpm.cp_pedir, 0x00000003);
388 clrbits_be32(&immr->im_cpm.cp_peso, 0x00000003);
390 clrbits_be32(&immr->im_cpm.cp_cptr, 0x00000100);
394 #if !defined(CONFIG_FEC1_PHY_NORXERR)
395 setbits_be16(&immr->im_ioport.iop_papar, 0x1000);
396 clrbits_be16(&immr->im_ioport.iop_padir, 0x1000);
398 setbits_be16(&immr->im_ioport.iop_papar, 0xe810);
399 setbits_be16(&immr->im_ioport.iop_padir, 0x0810);
400 clrbits_be16(&immr->im_ioport.iop_padir, 0xe000);
402 setbits_be32(&immr->im_cpm.cp_pbpar, 0x00000001);
403 clrbits_be32(&immr->im_cpm.cp_pbdir, 0x00000001);
405 setbits_be32(&immr->im_cpm.cp_cptr, 0x00000100);
406 clrbits_be32(&immr->im_cpm.cp_cptr, 0x00000050);
408 #endif /* !CONFIG_RMII */
412 * Configure all of port D for MII.
414 out_be16(&immr->im_ioport.iop_pdpar, 0x1fff);
415 out_be16(&immr->im_ioport.iop_pddir, 0x1fff);
418 #endif /* CONFIG_ETHER_ON_FEC1 */
419 } else if (fecidx == 1) {
420 #if defined(CONFIG_ETHER_ON_FEC2)
422 #if defined(CONFIG_MPC885) /* MPC87x/88x have got 2 FECs and different pinout */
424 #if !defined(CONFIG_RMII)
425 setbits_be32(&immr->im_cpm.cp_pepar, 0x0003fffc);
426 setbits_be32(&immr->im_cpm.cp_pedir, 0x0003fffc);
427 clrbits_be32(&immr->im_cpm.cp_peso, 0x000087fc);
428 setbits_be32(&immr->im_cpm.cp_peso, 0x00037800);
430 clrbits_be32(&immr->im_cpm.cp_cptr, 0x00000080);
433 #if !defined(CONFIG_FEC2_PHY_NORXERR)
434 setbits_be32(&immr->im_cpm.cp_pepar, 0x00000010);
435 setbits_be32(&immr->im_cpm.cp_pedir, 0x00000010);
436 clrbits_be32(&immr->im_cpm.cp_peso, 0x00000010);
438 setbits_be32(&immr->im_cpm.cp_pepar, 0x00039620);
439 setbits_be32(&immr->im_cpm.cp_pedir, 0x00039620);
440 setbits_be32(&immr->im_cpm.cp_peso, 0x00031000);
441 clrbits_be32(&immr->im_cpm.cp_peso, 0x00008620);
443 setbits_be32(&immr->im_cpm.cp_cptr, 0x00000080);
444 clrbits_be32(&immr->im_cpm.cp_cptr, 0x00000028);
445 #endif /* CONFIG_RMII */
447 #endif /* CONFIG_MPC885 */
449 #endif /* CONFIG_ETHER_ON_FEC2 */
453 static int fec_reset(fec_t __iomem *fecp)
458 * A delay is required between a reset of the FEC block and
459 * initialization of other FEC registers because the reset takes
460 * some time to complete. If you don't delay, subsequent writes
461 * to FEC registers might get killed by the reset routine which is
465 out_be32(&fecp->fec_ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_RESET);
466 for (i = 0; (in_be32(&fecp->fec_ecntrl) & FEC_ECNTRL_RESET) &&
467 (i < FEC_RESET_DELAY); ++i)
470 if (i == FEC_RESET_DELAY)
476 static int fec_init(struct eth_device *dev, bd_t *bd)
478 struct ether_fcc_info_s *efis = dev->priv;
479 immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR;
480 fec_t __iomem *fecp =
481 (fec_t __iomem *)(CONFIG_SYS_IMMR + efis->fecp_offset);
484 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
485 /* the MII interface is connected to FEC1
486 * so for the miiphy_xxx function to work we must
487 * call mii_init since fec_halt messes the thing up
489 if (efis->ether_index != 0)
493 if (fec_reset(fecp) < 0)
494 printf("FEC_RESET_DELAY timeout\n");
496 /* We use strictly polling mode only
498 out_be32(&fecp->fec_imask, 0);
500 /* Clear any pending interrupt
502 out_be32(&fecp->fec_ievent, 0xffc0);
504 /* No need to set the IVEC register */
506 /* Set station address
508 #define ea dev->enetaddr
509 out_be32(&fecp->fec_addr_low, (ea[0] << 24) | (ea[1] << 16) |
510 (ea[2] << 8) | ea[3]);
511 out_be16(&fecp->fec_addr_high, (ea[4] << 8) | ea[5]);
514 #if defined(CONFIG_CMD_CDP)
516 * Turn on multicast address hash table
518 out_be32(&fecp->fec_hash_table_high, 0xffffffff);
519 out_be32(&fecp->fec_hash_table_low, 0xffffffff);
521 /* Clear multicast address hash table
523 out_be32(&fecp->fec_hash_table_high, 0);
524 out_be32(&fecp->fec_hash_table_low, 0);
527 /* Set maximum receive buffer size.
529 out_be32(&fecp->fec_r_buff_size, PKT_MAXBLR_SIZE);
531 /* Set maximum frame length
533 out_be32(&fecp->fec_r_hash, PKT_MAXBUF_SIZE);
536 * Setup Buffers and Buffer Descriptors
542 rtx = (struct common_buf_desc __iomem *)
543 (immr->im_cpm.cp_dpmem + CPM_FEC_BASE);
545 * Setup Receiver Buffer Descriptors (13.14.24.18)
549 for (i = 0; i < PKTBUFSRX; i++) {
550 out_be16(&rtx->rxbd[i].cbd_sc, BD_ENET_RX_EMPTY);
551 out_be16(&rtx->rxbd[i].cbd_datlen, 0); /* Reset */
552 out_be32(&rtx->rxbd[i].cbd_bufaddr, (uint)net_rx_packets[i]);
554 setbits_be16(&rtx->rxbd[PKTBUFSRX - 1].cbd_sc, BD_ENET_RX_WRAP);
557 * Setup Ethernet Transmitter Buffer Descriptors (13.14.24.19)
561 for (i = 0; i < TX_BUF_CNT; i++) {
562 out_be16(&rtx->txbd[i].cbd_sc, BD_ENET_TX_LAST | BD_ENET_TX_TC);
563 out_be16(&rtx->txbd[i].cbd_datlen, 0); /* Reset */
564 out_be32(&rtx->txbd[i].cbd_bufaddr, (uint)txbuf);
566 setbits_be16(&rtx->txbd[TX_BUF_CNT - 1].cbd_sc, BD_ENET_TX_WRAP);
568 /* Set receive and transmit descriptor base
570 out_be32(&fecp->fec_r_des_start, (__force unsigned int)rtx->rxbd);
571 out_be32(&fecp->fec_x_des_start, (__force unsigned int)rtx->txbd);
575 /* Half duplex mode */
576 out_be32(&fecp->fec_r_cntrl, FEC_RCNTRL_MII_MODE | FEC_RCNTRL_DRT);
577 out_be32(&fecp->fec_x_cntrl, 0);
579 /* Enable big endian and don't care about SDMA FC.
581 out_be32(&fecp->fec_fun_code, 0x78000000);
584 * Setup the pin configuration of the FEC
586 fec_pin_init(efis->ether_index);
592 * Now enable the transmit and receive processing
594 out_be32(&fecp->fec_ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN);
596 if (efis->phy_addr == -1) {
597 #ifdef CONFIG_SYS_DISCOVER_PHY
599 * wait for the PHY to wake up after reset
601 efis->actual_phy_addr = mii_discover_phy(dev);
603 if (efis->actual_phy_addr == -1) {
604 printf("Unable to discover phy!\n");
608 efis->actual_phy_addr = -1;
611 efis->actual_phy_addr = efis->phy_addr;
614 #if defined(CONFIG_MII) && defined(CONFIG_RMII)
616 * adapt the RMII speed to the speed of the phy
618 if (miiphy_speed(dev->name, efis->actual_phy_addr) == _100BASET)
624 #if defined(CONFIG_MII)
626 * adapt to the half/full speed settings
628 if (miiphy_duplex(dev->name, efis->actual_phy_addr) == FULL)
629 fec_full_duplex(dev);
631 fec_half_duplex(dev);
634 /* And last, try to fill Rx Buffer Descriptors */
635 /* Descriptor polling active */
636 out_be32(&fecp->fec_r_des_active, 0x01000000);
638 efis->initialized = 1;
644 static void fec_halt(struct eth_device *dev)
646 struct ether_fcc_info_s *efis = dev->priv;
647 fec_t __iomem *fecp =
648 (fec_t __iomem *)(CONFIG_SYS_IMMR + efis->fecp_offset);
651 /* avoid halt if initialized; mii gets stuck otherwise */
652 if (!efis->initialized)
656 * A delay is required between a reset of the FEC block and
657 * initialization of other FEC registers because the reset takes
658 * some time to complete. If you don't delay, subsequent writes
659 * to FEC registers might get killed by the reset routine which is
663 out_be32(&fecp->fec_ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_RESET);
664 for (i = 0; (in_be32(&fecp->fec_ecntrl) & FEC_ECNTRL_RESET) &&
665 (i < FEC_RESET_DELAY); ++i)
668 if (i == FEC_RESET_DELAY) {
669 printf("FEC_RESET_DELAY timeout\n");
673 efis->initialized = 0;
676 #if defined(CONFIG_SYS_DISCOVER_PHY) || defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
678 /* Make MII read/write commands for the FEC.
681 #define mk_mii_read(ADDR, REG) (0x60020000 | ((ADDR << 23) | \
684 #define mk_mii_write(ADDR, REG, VAL) (0x50020000 | ((ADDR << 23) | \
685 (REG & 0x1f) << 18) | \
688 /* Interrupt events/masks.
690 #define FEC_ENET_HBERR ((uint)0x80000000) /* Heartbeat error */
691 #define FEC_ENET_BABR ((uint)0x40000000) /* Babbling receiver */
692 #define FEC_ENET_BABT ((uint)0x20000000) /* Babbling transmitter */
693 #define FEC_ENET_GRA ((uint)0x10000000) /* Graceful stop complete */
694 #define FEC_ENET_TXF ((uint)0x08000000) /* Full frame transmitted */
695 #define FEC_ENET_TXB ((uint)0x04000000) /* A buffer was transmitted */
696 #define FEC_ENET_RXF ((uint)0x02000000) /* Full frame received */
697 #define FEC_ENET_RXB ((uint)0x01000000) /* A buffer was received */
698 #define FEC_ENET_MII ((uint)0x00800000) /* MII interrupt */
699 #define FEC_ENET_EBERR ((uint)0x00400000) /* SDMA bus error */
701 /* send command to phy using mii, wait for result */
703 mii_send(uint mii_cmd)
708 immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR;
710 ep = &immr->im_cpm.cp_fec;
712 out_be32(&ep->fec_mii_data, mii_cmd); /* command to phy */
714 /* wait for mii complete */
716 while (!(in_be32(&ep->fec_ievent) & FEC_ENET_MII)) {
718 printf("mii_send STUCK!\n");
722 mii_reply = in_be32(&ep->fec_mii_data); /* result from phy */
723 out_be32(&ep->fec_ievent, FEC_ENET_MII); /* clear MII complete */
724 return mii_reply & 0xffff; /* data read from phy */
728 #if defined(CONFIG_SYS_DISCOVER_PHY)
729 static int mii_discover_phy(struct eth_device *dev)
731 #define MAX_PHY_PASSES 11
737 phyaddr = -1; /* didn't find a PHY yet */
738 for (pass = 1; pass <= MAX_PHY_PASSES && phyaddr < 0; ++pass) {
740 /* PHY may need more time to recover from reset.
741 * The LXT970 needs 50ms typical, no maximum is
742 * specified, so wait 10ms before try again.
743 * With 11 passes this gives it 100ms to wake up.
745 udelay(10000); /* wait 10ms */
747 for (phyno = 0; phyno < 32 && phyaddr < 0; ++phyno) {
748 phytype = mii_send(mk_mii_read(phyno, MII_PHYSID2));
749 if (phytype != 0xffff) {
751 phytype |= mii_send(mk_mii_read(phyno,
757 printf("No PHY device found.\n");
761 #endif /* CONFIG_SYS_DISCOVER_PHY */
763 #if (defined(CONFIG_MII) || defined(CONFIG_CMD_MII)) && !defined(CONFIG_BITBANGMII)
765 /****************************************************************************
766 * mii_init -- Initialize the MII via FEC 1 for MII command without ethernet
767 * This function is a subset of eth_init
768 ****************************************************************************
770 static void __mii_init(void)
772 immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR;
773 fec_t __iomem *fecp = &immr->im_cpm.cp_fec;
775 if (fec_reset(fecp) < 0)
776 printf("FEC_RESET_DELAY timeout\n");
778 /* We use strictly polling mode only
780 out_be32(&fecp->fec_imask, 0);
782 /* Clear any pending interrupt
784 out_be32(&fecp->fec_ievent, 0xffc0);
786 /* Now enable the transmit and receive processing
788 out_be32(&fecp->fec_ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN);
797 /* Setup the pin configuration of the FEC(s)
799 for (i = 0; i < ARRAY_SIZE(ether_fcc_info); i++)
800 fec_pin_init(ether_fcc_info[i].ether_index);
803 /*****************************************************************************
804 * Read and write a MII PHY register, routines used by MII Utilities
806 * FIXME: These routines are expected to return 0 on success, but mii_send
807 * does _not_ return an error code. Maybe 0xFFFF means error, i.e.
808 * no PHY connected...
809 * For now always return 0.
810 * FIXME: These routines only work after calling eth_init() at least once!
811 * Otherwise they hang in mii_send() !!! Sorry!
812 *****************************************************************************/
814 int fec8xx_miiphy_read(struct mii_dev *bus, int addr, int devad, int reg)
816 unsigned short value = 0;
817 short rdreg; /* register working value */
819 rdreg = mii_send(mk_mii_read(addr, reg));
825 int fec8xx_miiphy_write(struct mii_dev *bus, int addr, int devad, int reg,
828 (void)mii_send(mk_mii_write(addr, reg, value));