Lines Matching +full:force +full:- +full:external +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0
10 * 2000/11/11 Willy Tarreau <willy AT meta-x.org>
11 * - port to non-sparc architectures. Tested only on x86 and
13 * - ability to specify the MAC address at module load time by passing this
20 #include <linux/dma-mapping.h>
83 /* "Auto Switch Debug" aka phy debug */
111 tlp->tstamp = (unsigned int)jiffies;
112 tlp->tx_new = hp->tx_new;
113 tlp->tx_old = hp->tx_old;
114 tlp->action = a;
115 tlp->status = s;
116 txlog_cur_entry = (txlog_cur_entry + 1) & (TX_LOG_LEN - 1);
129 this = (this + 1) & (TX_LOG_LEN - 1);
137 #define DEFAULT_IPG0 16 /* For lance-mode only */
146 * the two stores so that I can sleep well at night... -DaveM
162 rxd->rx_addr = (__force hme32)addr; in sbus_hme_write_rxd()
164 rxd->rx_flags = (__force hme32)flags; in sbus_hme_write_rxd()
169 txd->tx_addr = (__force hme32)addr; in sbus_hme_write_txd()
171 txd->tx_flags = (__force hme32)flags; in sbus_hme_write_txd()
191 rxd->rx_addr = (__force hme32)cpu_to_le32(addr); in pci_hme_write_rxd()
193 rxd->rx_flags = (__force hme32)cpu_to_le32(flags); in pci_hme_write_rxd()
198 txd->tx_addr = (__force hme32)cpu_to_le32(addr); in pci_hme_write_txd()
200 txd->tx_flags = (__force hme32)cpu_to_le32(flags); in pci_hme_write_txd()
209 ((__hp)->write32((__reg), (__val)))
211 ((__hp)->read32(__reg))
213 ((__hp)->write_rxd((__rxd), (__flags), (__addr)))
215 ((__hp)->write_txd((__txd), (__flags), (__addr)))
217 ((__hp)->read_desc32(__p))
226 do { (__rxd)->rx_addr = (__force hme32)(u32)(__addr); \
228 (__rxd)->rx_flags = (__force hme32)(u32)(__flags); \
231 do { (__txd)->tx_addr = (__force hme32)(u32)(__addr); \
233 (__txd)->tx_flags = (__force hme32)(u32)(__flags); \
243 do { (__rxd)->rx_addr = (__force hme32)cpu_to_le32(__addr); \
245 (__rxd)->rx_flags = (__force hme32)cpu_to_le32(__flags); \
248 do { (__txd)->tx_addr = (__force hme32)cpu_to_le32(__addr); \
250 (__txd)->tx_flags = (__force hme32)cpu_to_le32(__flags); \
313 /* Force BitBang into the idle state. */ in happy_meal_bb_read()
323 /* Give it the PHY address. */ in happy_meal_bb_read()
324 tmp = hp->paddr & 0xff; in happy_meal_bb_read()
325 for (i = 4; i >= 0; i--) in happy_meal_bb_read()
330 for (i = 4; i >= 0; i--) in happy_meal_bb_read()
337 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
338 for (i = 15; i >= 0; i--) in happy_meal_bb_read()
339 retval |= BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
340 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
341 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
342 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
359 /* Force BitBang into the idle state. */ in happy_meal_bb_write()
369 /* Give it the PHY address. */ in happy_meal_bb_write()
370 tmp = (hp->paddr & 0xff); in happy_meal_bb_write()
371 for (i = 4; i >= 0; i--) in happy_meal_bb_write()
376 for (i = 4; i >= 0; i--) in happy_meal_bb_write()
383 for (i = 15; i >= 0; i--) in happy_meal_bb_write()
398 if (hp->tcvr_type == none) { in happy_meal_tcvr_read()
403 if (!(hp->happy_flags & HFLAG_FENABLE)) { in happy_meal_tcvr_read()
409 (FRAME_READ | (hp->paddr << 23) | ((reg & 0xff) << 18))); in happy_meal_tcvr_read()
410 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries) in happy_meal_tcvr_read()
413 netdev_err(hp->dev, "Aieee, transceiver MIF read bolixed\n"); in happy_meal_tcvr_read()
432 if (!(hp->happy_flags & HFLAG_FENABLE)) { in happy_meal_tcvr_write()
439 (FRAME_WRITE | (hp->paddr << 23) | in happy_meal_tcvr_write()
441 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries) in happy_meal_tcvr_write()
446 netdev_err(hp->dev, "Aieee, transceiver MIF write bolixed\n"); in happy_meal_tcvr_write()
448 /* Fifty-two cents is your change, have a nice day. */ in happy_meal_tcvr_write()
457 * if the auto negotiation has completed, we assume here that the DP83840 PHY
461 * This "other" strategy is to force the interface into various speed/duplex
462 * configurations and we stop when we see a link-up condition before the
469 * 100 Base-T Full Duplex
470 * 100 Base-T Half Duplex
471 * 10 Base-T Full Duplex
472 * 10 Base-T Half Duplex
475 * been detected. This timer just waits for the link-up bit to get set in
485 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in try_next_permutation()
490 if (hp->sw_bmcr & BMCR_FULLDPLX) { in try_next_permutation()
491 hp->sw_bmcr &= ~(BMCR_FULLDPLX); in try_next_permutation()
492 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in try_next_permutation()
497 if (hp->sw_bmcr & BMCR_SPEED100) { in try_next_permutation()
498 hp->sw_bmcr &= ~(BMCR_SPEED100); in try_next_permutation()
499 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in try_next_permutation()
504 return -1; in try_next_permutation()
509 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in display_link_mode()
511 netdev_info(hp->dev, in display_link_mode()
513 hp->tcvr_type == external ? "external" : "internal", in display_link_mode()
514 hp->sw_lpa & (LPA_100HALF | LPA_100FULL) ? 100 : 10, in display_link_mode()
515 hp->sw_lpa & (LPA_100FULL | LPA_10FULL) ? "Full" : "Half"); in display_link_mode()
520 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in display_forced_link_mode()
522 netdev_info(hp->dev, in display_forced_link_mode()
524 hp->tcvr_type == external ? "external" : "internal", in display_forced_link_mode()
525 hp->sw_bmcr & BMCR_SPEED100 ? 100 : 10, in display_forced_link_mode()
526 hp->sw_bmcr & BMCR_FULLDPLX ? "Full" : "Half"); in display_forced_link_mode()
536 if (hp->timer_state == arbwait) { in set_happy_link_modes()
537 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in set_happy_link_modes()
538 if (!(hp->sw_lpa & (LPA_10HALF | LPA_10FULL | LPA_100HALF | LPA_100FULL))) in set_happy_link_modes()
540 if (hp->sw_lpa & LPA_100FULL) in set_happy_link_modes()
542 else if (hp->sw_lpa & LPA_100HALF) in set_happy_link_modes()
544 else if (hp->sw_lpa & LPA_10FULL) in set_happy_link_modes()
550 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in set_happy_link_modes()
551 if (hp->sw_bmcr & BMCR_FULLDPLX) in set_happy_link_modes()
565 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
566 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) & in set_happy_link_modes()
568 while (hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) & BIGMAC_TXCFG_ENABLE) in set_happy_link_modes()
571 hp->happy_flags |= HFLAG_FULL; in set_happy_link_modes()
572 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
573 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) | in set_happy_link_modes()
576 hp->happy_flags &= ~(HFLAG_FULL); in set_happy_link_modes()
577 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
578 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) & in set_happy_link_modes()
581 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
582 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) | in set_happy_link_modes()
591 void __iomem *tregs = hp->tcvregs; in is_lucent_phy()
604 /* hp->happy_lock must be held */
613 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_begin_auto_negotiation()
614 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
615 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_begin_auto_negotiation()
616 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_begin_auto_negotiation()
620 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_begin_auto_negotiation()
621 if (!ep || ep->base.autoneg == AUTONEG_ENABLE) { in happy_meal_begin_auto_negotiation()
623 if (hp->sw_bmsr & BMSR_10HALF) in happy_meal_begin_auto_negotiation()
624 hp->sw_advertise |= (ADVERTISE_10HALF); in happy_meal_begin_auto_negotiation()
626 hp->sw_advertise &= ~(ADVERTISE_10HALF); in happy_meal_begin_auto_negotiation()
628 if (hp->sw_bmsr & BMSR_10FULL) in happy_meal_begin_auto_negotiation()
629 hp->sw_advertise |= (ADVERTISE_10FULL); in happy_meal_begin_auto_negotiation()
631 hp->sw_advertise &= ~(ADVERTISE_10FULL); in happy_meal_begin_auto_negotiation()
632 if (hp->sw_bmsr & BMSR_100HALF) in happy_meal_begin_auto_negotiation()
633 hp->sw_advertise |= (ADVERTISE_100HALF); in happy_meal_begin_auto_negotiation()
635 hp->sw_advertise &= ~(ADVERTISE_100HALF); in happy_meal_begin_auto_negotiation()
636 if (hp->sw_bmsr & BMSR_100FULL) in happy_meal_begin_auto_negotiation()
637 hp->sw_advertise |= (ADVERTISE_100FULL); in happy_meal_begin_auto_negotiation()
639 hp->sw_advertise &= ~(ADVERTISE_100FULL); in happy_meal_begin_auto_negotiation()
640 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_begin_auto_negotiation()
649 hp->sw_advertise & ADVERTISE_10HALF ? "10H " : "", in happy_meal_begin_auto_negotiation()
650 hp->sw_advertise & ADVERTISE_10FULL ? "10F " : "", in happy_meal_begin_auto_negotiation()
651 hp->sw_advertise & ADVERTISE_100HALF ? "100H " : "", in happy_meal_begin_auto_negotiation()
652 hp->sw_advertise & ADVERTISE_100FULL ? "100F " : ""); in happy_meal_begin_auto_negotiation()
654 /* Enable Auto-Negotiation, this is usually on already... */ in happy_meal_begin_auto_negotiation()
655 hp->sw_bmcr |= BMCR_ANENABLE; in happy_meal_begin_auto_negotiation()
656 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
659 hp->sw_bmcr |= BMCR_ANRESTART; in happy_meal_begin_auto_negotiation()
660 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
665 while (--timeout) { in happy_meal_begin_auto_negotiation()
666 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
667 if (!(hp->sw_bmcr & BMCR_ANRESTART)) in happy_meal_begin_auto_negotiation()
672 netdev_err(hp->dev, in happy_meal_begin_auto_negotiation()
674 hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
675 netdev_notice(hp->dev, in happy_meal_begin_auto_negotiation()
676 "Performing force link detection.\n"); in happy_meal_begin_auto_negotiation()
679 hp->timer_state = arbwait; in happy_meal_begin_auto_negotiation()
683 /* Force the link up, trying first a particular mode. in happy_meal_begin_auto_negotiation()
688 /* Disable auto-negotiation in BMCR, enable the duplex and in happy_meal_begin_auto_negotiation()
691 if (!ep || ep->base.autoneg == AUTONEG_ENABLE) { in happy_meal_begin_auto_negotiation()
692 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_begin_auto_negotiation()
694 if (ep->base.speed == SPEED_100) in happy_meal_begin_auto_negotiation()
695 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_begin_auto_negotiation()
697 hp->sw_bmcr = 0; in happy_meal_begin_auto_negotiation()
698 if (ep->base.duplex == DUPLEX_FULL) in happy_meal_begin_auto_negotiation()
699 hp->sw_bmcr |= BMCR_FULLDPLX; in happy_meal_begin_auto_negotiation()
701 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
708 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_begin_auto_negotiation()
710 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_begin_auto_negotiation()
712 hp->sw_csconfig); in happy_meal_begin_auto_negotiation()
714 hp->timer_state = ltrywait; in happy_meal_begin_auto_negotiation()
717 hp->timer_ticks = 0; in happy_meal_begin_auto_negotiation()
718 hp->happy_timer.expires = jiffies + (12 * HZ)/10; /* 1.2 sec. */ in happy_meal_begin_auto_negotiation()
719 add_timer(&hp->happy_timer); in happy_meal_begin_auto_negotiation()
725 void __iomem *tregs = hp->tcvregs; in happy_meal_timer()
728 spin_lock_irq(&hp->happy_lock); in happy_meal_timer()
730 hp->timer_ticks++; in happy_meal_timer()
731 switch(hp->timer_state) { in happy_meal_timer()
736 if (hp->timer_ticks >= 10) { in happy_meal_timer()
737 /* Enter force mode. */ in happy_meal_timer()
739 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_timer()
740 netdev_notice(hp->dev, in happy_meal_timer()
741 "Auto-Negotiation unsuccessful, trying force link mode\n"); in happy_meal_timer()
742 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_timer()
743 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_timer()
750 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, DP83840_CSCONFIG); in happy_meal_timer()
751 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_timer()
752 happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
754 hp->timer_state = ltrywait; in happy_meal_timer()
755 hp->timer_ticks = 0; in happy_meal_timer()
759 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
760 if (hp->sw_bmsr & BMSR_ANEGCOMPLETE) { in happy_meal_timer()
766 /* Ooops, something bad happened, go to force in happy_meal_timer()
770 * XXX auto-negotiation make this happen as well. in happy_meal_timer()
776 hp->timer_state = lupwait; in happy_meal_timer()
790 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
791 if (hp->sw_bmsr & BMSR_LSTATUS) { in happy_meal_timer()
796 hp->timer_state = asleep; in happy_meal_timer()
799 if (hp->timer_ticks >= 10) { in happy_meal_timer()
800 netdev_notice(hp->dev, in happy_meal_timer()
802 hp->timer_ticks = 0; in happy_meal_timer()
816 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
817 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, DP83840_CSCONFIG); in happy_meal_timer()
818 if (hp->timer_ticks == 1) { in happy_meal_timer()
820 /* Re-enable transceiver, we'll re-enable the transceiver next in happy_meal_timer()
823 hp->sw_csconfig |= CSCONFIG_TCVDISAB; in happy_meal_timer()
825 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
830 if (hp->timer_ticks == 2) { in happy_meal_timer()
832 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_timer()
834 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
839 if (hp->sw_bmsr & BMSR_LSTATUS) { in happy_meal_timer()
840 /* Force mode selection success. */ in happy_meal_timer()
843 hp->timer_state = asleep; in happy_meal_timer()
846 if (hp->timer_ticks >= 4) { /* 6 seconds or so... */ in happy_meal_timer()
850 if (ret == -1) { in happy_meal_timer()
856 netdev_notice(hp->dev, in happy_meal_timer()
863 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_timer()
865 hp->sw_csconfig |= CSCONFIG_TCVDISAB; in happy_meal_timer()
867 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
869 hp->timer_ticks = 0; in happy_meal_timer()
880 netdev_err(hp->dev, in happy_meal_timer()
883 hp->timer_ticks = 0; in happy_meal_timer()
884 hp->timer_state = asleep; /* foo on you */ in happy_meal_timer()
889 hp->happy_timer.expires = jiffies + ((12 * HZ)/10); /* 1.2 sec. */ in happy_meal_timer()
890 add_timer(&hp->happy_timer); in happy_meal_timer()
894 spin_unlock_irq(&hp->happy_lock); in happy_meal_timer()
900 /* hp->happy_lock must be held */
909 while ((hme_read32(hp, bregs + BMAC_TXSWRESET) & 1) && --tries) in happy_meal_tx_reset()
914 netdev_err(hp->dev, "Transceiver BigMac ATTACK!"); in happy_meal_tx_reset()
920 /* hp->happy_lock must be held */
929 while ((hme_read32(hp, bregs + BMAC_RXSWRESET) & 1) && --tries) in happy_meal_rx_reset()
934 netdev_err(hp->dev, "Receiver BigMac ATTACK!\n"); in happy_meal_rx_reset()
942 /* hp->happy_lock must be held */
951 while (hme_read32(hp, gregs + GREG_SWRESET) && --tries) in happy_meal_stop()
956 netdev_err(hp->dev, "Fry guys.\n"); in happy_meal_stop()
962 /* hp->happy_lock must be held */
965 struct net_device_stats *stats = &hp->dev->stats; in happy_meal_get_counters()
967 stats->rx_crc_errors += hme_read32(hp, bregs + BMAC_RCRCECTR); in happy_meal_get_counters()
970 stats->rx_frame_errors += hme_read32(hp, bregs + BMAC_UNALECTR); in happy_meal_get_counters()
973 stats->rx_length_errors += hme_read32(hp, bregs + BMAC_GLECTR); in happy_meal_get_counters()
976 stats->tx_aborted_errors += hme_read32(hp, bregs + BMAC_EXCTR); in happy_meal_get_counters()
978 stats->collisions += in happy_meal_get_counters()
989 #define TCVR_UNISOLATE_TRIES 32 /* Dis-isolation can take longer. */
991 /* hp->happy_lock must be held */
999 if (hp->tcvr_type == external) { in happy_meal_tcvr_reset()
1001 hp->tcvr_type = internal; in happy_meal_tcvr_reset()
1002 hp->paddr = TCV_PADDR_ITX; in happy_meal_tcvr_reset()
1008 return -1; in happy_meal_tcvr_reset()
1010 ASD("external: ISOLATE, phyread_ok, PSELECT\n"); in happy_meal_tcvr_reset()
1012 hp->tcvr_type = external; in happy_meal_tcvr_reset()
1013 hp->paddr = TCV_PADDR_ETX; in happy_meal_tcvr_reset()
1022 return -1; in happy_meal_tcvr_reset()
1026 hp->tcvr_type = internal; in happy_meal_tcvr_reset()
1027 hp->paddr = TCV_PADDR_ITX; in happy_meal_tcvr_reset()
1034 while (--tries) { in happy_meal_tcvr_reset()
1037 return -1; in happy_meal_tcvr_reset()
1038 hp->sw_bmcr = result; in happy_meal_tcvr_reset()
1045 return -1; in happy_meal_tcvr_reset()
1049 /* Get fresh copies of the PHY registers. */ in happy_meal_tcvr_reset()
1050 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_tcvr_reset()
1051 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_tcvr_reset()
1052 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_tcvr_reset()
1053 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_tcvr_reset()
1056 hp->sw_bmcr &= ~(BMCR_ISOLATE); in happy_meal_tcvr_reset()
1057 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_tcvr_reset()
1060 while (--tries) { in happy_meal_tcvr_reset()
1063 return -1; in happy_meal_tcvr_reset()
1070 return -1; in happy_meal_tcvr_reset()
1082 /* Figure out whether we have an internal or external transceiver.
1084 * hp->happy_lock must be held
1094 hp->paddr = TCV_PADDR_ETX; in happy_meal_transceiver_check()
1095 hp->tcvr_type = external; in happy_meal_transceiver_check()
1096 ASD("not polling, external\n"); in happy_meal_transceiver_check()
1101 hp->paddr = TCV_PADDR_ITX; in happy_meal_transceiver_check()
1102 hp->tcvr_type = internal; in happy_meal_transceiver_check()
1105 netdev_err(hp->dev, in happy_meal_transceiver_check()
1107 hp->tcvr_type = none; /* Grrr... */ in happy_meal_transceiver_check()
1120 * also program the etxregs->cfg register to use an offset of 2. This
1141 * this from the skb->length. Then we just pass the packet up to the
1152 * skb->csum = rxd->rx_flags & 0xffff;
1153 * skb->ip_summed = CHECKSUM_COMPLETE;
1162 if (hp->rx_skbs[i] != NULL) { in happy_meal_clean_rings()
1163 struct sk_buff *skb = hp->rx_skbs[i]; in happy_meal_clean_rings()
1167 rxd = &hp->happy_block->happy_meal_rxd[i]; in happy_meal_clean_rings()
1168 dma_addr = hme_read_desc32(hp, &rxd->rx_addr); in happy_meal_clean_rings()
1169 dma_unmap_single(hp->dma_dev, dma_addr, in happy_meal_clean_rings()
1172 hp->rx_skbs[i] = NULL; in happy_meal_clean_rings()
1177 if (hp->tx_skbs[i] != NULL) { in happy_meal_clean_rings()
1178 struct sk_buff *skb = hp->tx_skbs[i]; in happy_meal_clean_rings()
1183 hp->tx_skbs[i] = NULL; in happy_meal_clean_rings()
1185 for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) { in happy_meal_clean_rings()
1186 txd = &hp->happy_block->happy_meal_txd[i]; in happy_meal_clean_rings()
1187 dma_addr = hme_read_desc32(hp, &txd->tx_addr); in happy_meal_clean_rings()
1189 dma_unmap_single(hp->dma_dev, dma_addr, in happy_meal_clean_rings()
1190 (hme_read_desc32(hp, &txd->tx_flags) in happy_meal_clean_rings()
1194 dma_unmap_page(hp->dma_dev, dma_addr, in happy_meal_clean_rings()
1195 (hme_read_desc32(hp, &txd->tx_flags) in happy_meal_clean_rings()
1199 if (frag != skb_shinfo(skb)->nr_frags) in happy_meal_clean_rings()
1208 /* hp->happy_lock must be held */
1211 struct hmeal_init_block *hb = hp->happy_block; in happy_meal_init_rings()
1215 hp->rx_new = hp->rx_old = hp->tx_new = hp->tx_old = 0; in happy_meal_init_rings()
1228 hme_write_rxd(hp, &hb->happy_meal_rxd[i], 0, 0); in happy_meal_init_rings()
1231 hp->rx_skbs[i] = skb; in happy_meal_init_rings()
1235 mapping = dma_map_single(hp->dma_dev, skb->data, RX_BUF_ALLOC_SIZE, in happy_meal_init_rings()
1237 if (dma_mapping_error(hp->dma_dev, mapping)) { in happy_meal_init_rings()
1239 hme_write_rxd(hp, &hb->happy_meal_rxd[i], 0, 0); in happy_meal_init_rings()
1242 hme_write_rxd(hp, &hb->happy_meal_rxd[i], in happy_meal_init_rings()
1243 (RXFLAG_OWN | ((RX_BUF_ALLOC_SIZE - RX_OFFSET) << 16)), in happy_meal_init_rings()
1250 hme_write_txd(hp, &hb->happy_meal_txd[i], 0, 0); in happy_meal_init_rings()
1255 /* hp->happy_lock must be held */
1258 const unsigned char *e = &hp->dev->dev_addr[0]; in happy_meal_init()
1259 void __iomem *gregs = hp->gregs; in happy_meal_init()
1260 void __iomem *etxregs = hp->etxregs; in happy_meal_init()
1261 void __iomem *erxregs = hp->erxregs; in happy_meal_init()
1262 void __iomem *bregs = hp->bigmacregs; in happy_meal_init()
1263 void __iomem *tregs = hp->tcvregs; in happy_meal_init()
1267 /* If auto-negotiation timer is running, kill it. */ in happy_meal_init()
1268 del_timer(&hp->happy_timer); in happy_meal_init()
1270 HMD("happy_flags[%08x]\n", hp->happy_flags); in happy_meal_init()
1271 if (!(hp->happy_flags & HFLAG_INIT)) { in happy_meal_init()
1273 hp->happy_flags |= HFLAG_INIT; in happy_meal_init()
1286 if (hp->happy_flags & HFLAG_FENABLE) { in happy_meal_init()
1303 switch(hp->tcvr_type) { in happy_meal_init()
1307 return -EAGAIN; in happy_meal_init()
1315 case external: in happy_meal_init()
1317 HMD("external, disable MII\n"); in happy_meal_init()
1323 return -EAGAIN; in happy_meal_init()
1330 /* Set jam size and inter-packet gaps to reasonable defaults. */ in happy_meal_init()
1344 if ((hp->dev->flags & IFF_ALLMULTI) || in happy_meal_init()
1345 (netdev_mc_count(hp->dev) > 64)) { in happy_meal_init()
1350 } else if ((hp->dev->flags & IFF_PROMISC) == 0) { in happy_meal_init()
1356 netdev_for_each_mc_addr(ha, hp->dev) { in happy_meal_init()
1357 crc = ether_crc_le(6, ha->addr); in happy_meal_init()
1374 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0)), in happy_meal_init()
1375 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_txd, 0))); in happy_meal_init()
1377 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0))); in happy_meal_init()
1379 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_txd, 0))); in happy_meal_init()
1387 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0))) in happy_meal_init()
1389 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0)) in happy_meal_init()
1397 if ((hp->happy_bursts & DMA_BURST64) && in happy_meal_init()
1398 ((hp->happy_flags & HFLAG_PCI) != 0 in happy_meal_init()
1407 * do not. -DaveM in happy_meal_init()
1410 if ((hp->happy_flags & HFLAG_PCI) == 0) { in happy_meal_init()
1411 struct platform_device *op = hp->happy_dev; in happy_meal_init()
1413 sbus_set_sbus64(&op->dev, in happy_meal_init()
1414 hp->happy_bursts); in happy_meal_init()
1422 } else if (hp->happy_bursts & DMA_BURST32) { in happy_meal_init()
1425 } else if (hp->happy_bursts & DMA_BURST16) { in happy_meal_init()
1445 hme_write32(hp, etxregs + ETX_RSIZE, (TX_RING_SIZE >> ETX_RSIZE_SHIFT) - 1); in happy_meal_init()
1463 netdev_err(hp->dev, in happy_meal_init()
1465 netdev_err(hp->dev, in happy_meal_init()
1475 if (hp->dev->flags & IFF_PROMISC) in happy_meal_init()
1485 if (hp->happy_flags & HFLAG_FULL) in happy_meal_init()
1489 * to deadlock with the PHY if a Jabber occurs. in happy_meal_init()
1500 if (hp->happy_flags & HFLAG_LANCE) in happy_meal_init()
1503 /* Disable the MII buffers if using external transceiver. */ in happy_meal_init()
1504 if (hp->tcvr_type == external) in happy_meal_init()
1531 /* hp->happy_lock must be held */
1534 void __iomem *tregs = hp->tcvregs; in happy_meal_set_initial_advertisement()
1535 void __iomem *bregs = hp->bigmacregs; in happy_meal_set_initial_advertisement()
1536 void __iomem *gregs = hp->gregs; in happy_meal_set_initial_advertisement()
1539 if (hp->happy_flags & HFLAG_FENABLE) in happy_meal_set_initial_advertisement()
1546 switch(hp->tcvr_type) { in happy_meal_set_initial_advertisement()
1552 case external: in happy_meal_set_initial_advertisement()
1559 /* Latch PHY registers as of now. */ in happy_meal_set_initial_advertisement()
1560 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_set_initial_advertisement()
1561 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_set_initial_advertisement()
1564 if (hp->sw_bmsr & BMSR_10HALF) in happy_meal_set_initial_advertisement()
1565 hp->sw_advertise |= (ADVERTISE_10HALF); in happy_meal_set_initial_advertisement()
1567 hp->sw_advertise &= ~(ADVERTISE_10HALF); in happy_meal_set_initial_advertisement()
1569 if (hp->sw_bmsr & BMSR_10FULL) in happy_meal_set_initial_advertisement()
1570 hp->sw_advertise |= (ADVERTISE_10FULL); in happy_meal_set_initial_advertisement()
1572 hp->sw_advertise &= ~(ADVERTISE_10FULL); in happy_meal_set_initial_advertisement()
1573 if (hp->sw_bmsr & BMSR_100HALF) in happy_meal_set_initial_advertisement()
1574 hp->sw_advertise |= (ADVERTISE_100HALF); in happy_meal_set_initial_advertisement()
1576 hp->sw_advertise &= ~(ADVERTISE_100HALF); in happy_meal_set_initial_advertisement()
1577 if (hp->sw_bmsr & BMSR_100FULL) in happy_meal_set_initial_advertisement()
1578 hp->sw_advertise |= (ADVERTISE_100FULL); in happy_meal_set_initial_advertisement()
1580 hp->sw_advertise &= ~(ADVERTISE_100FULL); in happy_meal_set_initial_advertisement()
1582 /* Update the PHY advertisement register. */ in happy_meal_set_initial_advertisement()
1583 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_set_initial_advertisement()
1587 * the hardware, so we cannot re-read it and get a correct value.
1589 * hp->happy_lock must be held
1595 /* Only print messages for non-counter related interrupts. */ in happy_meal_is_not_so_happy()
1602 netdev_err(hp->dev, in happy_meal_is_not_so_happy()
1609 netdev_dbg(hp->dev, "Happy Meal receive FIFO overflow.\n"); in happy_meal_is_not_so_happy()
1614 netdev_err(hp->dev, "Happy Meal BigMAC SQE test failed.\n"); in happy_meal_is_not_so_happy()
1620 netdev_err(hp->dev, in happy_meal_is_not_so_happy()
1629 netdev_err(hp->dev, "Happy Meal MAX Packet size error.\n"); in happy_meal_is_not_so_happy()
1639 netdev_info(hp->dev, in happy_meal_is_not_so_happy()
1645 netdev_err(hp->dev, "Happy Meal rx DMA errors [ %s%s%s]\n", in happy_meal_is_not_so_happy()
1656 netdev_err(hp->dev, in happy_meal_is_not_so_happy()
1663 netdev_err(hp->dev, "Happy Meal MIF interrupt.\n"); in happy_meal_is_not_so_happy()
1669 netdev_err(hp->dev, "Happy Meal tx DMA errors [ %s%s%s%s]\n", in happy_meal_is_not_so_happy()
1681 netdev_err(hp->dev, in happy_meal_is_not_so_happy()
1688 netdev_notice(hp->dev, "Resetting...\n"); in happy_meal_is_not_so_happy()
1695 /* hp->happy_lock must be held */
1698 struct happy_meal_txd *txbase = &hp->happy_block->happy_meal_txd[0]; in happy_meal_tx()
1700 struct net_device *dev = hp->dev; in happy_meal_tx()
1703 elem = hp->tx_old; in happy_meal_tx()
1704 while (elem != hp->tx_new) { in happy_meal_tx()
1709 netdev_vdbg(hp->dev, "TX[%d]\n", elem); in happy_meal_tx()
1711 flags = hme_read_desc32(hp, &this->tx_flags); in happy_meal_tx()
1714 skb = hp->tx_skbs[elem]; in happy_meal_tx()
1715 if (skb_shinfo(skb)->nr_frags) { in happy_meal_tx()
1718 last = elem + skb_shinfo(skb)->nr_frags; in happy_meal_tx()
1719 last &= (TX_RING_SIZE - 1); in happy_meal_tx()
1724 hp->tx_skbs[elem] = NULL; in happy_meal_tx()
1725 dev->stats.tx_bytes += skb->len; in happy_meal_tx()
1727 for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) { in happy_meal_tx()
1728 dma_addr = hme_read_desc32(hp, &this->tx_addr); in happy_meal_tx()
1729 dma_len = hme_read_desc32(hp, &this->tx_flags); in happy_meal_tx()
1733 dma_unmap_single(hp->dma_dev, dma_addr, dma_len, DMA_TO_DEVICE); in happy_meal_tx()
1735 dma_unmap_page(hp->dma_dev, dma_addr, dma_len, DMA_TO_DEVICE); in happy_meal_tx()
1742 dev->stats.tx_packets++; in happy_meal_tx()
1744 hp->tx_old = elem; in happy_meal_tx()
1758 * hp->happy_lock must be held
1762 struct happy_meal_rxd *rxbase = &hp->happy_block->happy_meal_rxd[0]; in happy_meal_rx()
1764 int elem = hp->rx_new, drops = 0; in happy_meal_rx()
1768 while (!((flags = hme_read_desc32(hp, &this->rx_flags)) & RXFLAG_OWN)) { in happy_meal_rx()
1772 u32 dma_addr = hme_read_desc32(hp, &this->rx_addr); in happy_meal_rx()
1777 dev->stats.rx_errors++; in happy_meal_rx()
1779 dev->stats.rx_length_errors++; in happy_meal_rx()
1781 dev->stats.rx_over_errors++; in happy_meal_rx()
1782 dev->stats.rx_fifo_errors++; in happy_meal_rx()
1787 dev->stats.rx_dropped++; in happy_meal_rx()
1789 (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), in happy_meal_rx()
1793 skb = hp->rx_skbs[elem]; in happy_meal_rx()
1805 mapping = dma_map_single(hp->dma_dev, new_skb->data, in happy_meal_rx()
1808 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) { in happy_meal_rx()
1814 dma_unmap_single(hp->dma_dev, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE); in happy_meal_rx()
1815 hp->rx_skbs[elem] = new_skb; in happy_meal_rx()
1817 (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), in happy_meal_rx()
1833 dma_sync_single_for_cpu(hp->dma_dev, dma_addr, len + 2, DMA_FROM_DEVICE); in happy_meal_rx()
1834 skb_copy_from_linear_data(skb, copy_skb->data, len); in happy_meal_rx()
1835 dma_sync_single_for_device(hp->dma_dev, dma_addr, len + 2, DMA_FROM_DEVICE); in happy_meal_rx()
1838 (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), in happy_meal_rx()
1845 skb->csum = csum_unfold(~(__force __sum16)htons(csum)); in happy_meal_rx()
1846 skb->ip_summed = CHECKSUM_COMPLETE; in happy_meal_rx()
1849 skb->protocol = eth_type_trans(skb, dev); in happy_meal_rx()
1852 dev->stats.rx_packets++; in happy_meal_rx()
1853 dev->stats.rx_bytes += len; in happy_meal_rx()
1858 hp->rx_new = elem; in happy_meal_rx()
1860 netdev_info(hp->dev, "Memory squeeze, deferring packet.\n"); in happy_meal_rx()
1867 u32 happy_status = hme_read32(hp, hp->gregs + GREG_STAT); in happy_meal_interrupt()
1873 spin_lock(&hp->happy_lock); in happy_meal_interrupt()
1876 if (happy_meal_is_not_so_happy(hp, /* un- */ happy_status)) in happy_meal_interrupt()
1888 spin_unlock(&hp->happy_lock); in happy_meal_interrupt()
1898 res = request_irq(hp->irq, happy_meal_interrupt, IRQF_SHARED, in happy_meal_open()
1899 dev->name, dev); in happy_meal_open()
1901 netdev_err(dev, "Can't order irq %d to go.\n", hp->irq); in happy_meal_open()
1907 spin_lock_irq(&hp->happy_lock); in happy_meal_open()
1909 spin_unlock_irq(&hp->happy_lock); in happy_meal_open()
1912 free_irq(hp->irq, dev); in happy_meal_open()
1920 spin_lock_irq(&hp->happy_lock); in happy_meal_close()
1921 happy_meal_stop(hp, hp->gregs); in happy_meal_close()
1924 /* If auto-negotiation timer is running, kill it. */ in happy_meal_close()
1925 del_timer(&hp->happy_timer); in happy_meal_close()
1927 spin_unlock_irq(&hp->happy_lock); in happy_meal_close()
1929 free_irq(hp->irq, dev); in happy_meal_close()
1941 hme_read32(hp, hp->gregs + GREG_STAT), in happy_meal_tx_timeout()
1942 hme_read32(hp, hp->etxregs + ETX_CFG), in happy_meal_tx_timeout()
1943 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG)); in happy_meal_tx_timeout()
1945 spin_lock_irq(&hp->happy_lock); in happy_meal_tx_timeout()
1947 spin_unlock_irq(&hp->happy_lock); in happy_meal_tx_timeout()
1955 struct happy_meal_txd *txbase = &hp->happy_block->happy_meal_txd[0]; in unmap_partial_tx_skb()
1957 dma_unmap_single(hp->dma_dev, first_mapping, first_len, DMA_TO_DEVICE); in unmap_partial_tx_skb()
1964 addr = hme_read_desc32(hp, &this->tx_addr); in unmap_partial_tx_skb()
1965 len = hme_read_desc32(hp, &this->tx_flags); in unmap_partial_tx_skb()
1967 dma_unmap_page(hp->dma_dev, addr, len, DMA_TO_DEVICE); in unmap_partial_tx_skb()
1979 if (skb->ip_summed == CHECKSUM_PARTIAL) { in happy_meal_start_xmit()
1981 const u32 csum_stuff_off = csum_start_off + skb->csum_offset; in happy_meal_start_xmit()
1988 spin_lock_irq(&hp->happy_lock); in happy_meal_start_xmit()
1990 if (TX_BUFFS_AVAIL(hp) <= (skb_shinfo(skb)->nr_frags + 1)) { in happy_meal_start_xmit()
1992 spin_unlock_irq(&hp->happy_lock); in happy_meal_start_xmit()
1997 entry = hp->tx_new; in happy_meal_start_xmit()
1998 netdev_vdbg(dev, "SX<l[%d]e[%d]>\n", skb->len, entry); in happy_meal_start_xmit()
1999 hp->tx_skbs[entry] = skb; in happy_meal_start_xmit()
2001 if (skb_shinfo(skb)->nr_frags == 0) { in happy_meal_start_xmit()
2004 len = skb->len; in happy_meal_start_xmit()
2005 mapping = dma_map_single(hp->dma_dev, skb->data, len, DMA_TO_DEVICE); in happy_meal_start_xmit()
2006 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) in happy_meal_start_xmit()
2009 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], in happy_meal_start_xmit()
2021 first_mapping = dma_map_single(hp->dma_dev, skb->data, first_len, in happy_meal_start_xmit()
2023 if (unlikely(dma_mapping_error(hp->dma_dev, first_mapping))) in happy_meal_start_xmit()
2027 for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) { in happy_meal_start_xmit()
2028 const skb_frag_t *this_frag = &skb_shinfo(skb)->frags[frag]; in happy_meal_start_xmit()
2032 mapping = skb_frag_dma_map(hp->dma_dev, this_frag, in happy_meal_start_xmit()
2034 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) { in happy_meal_start_xmit()
2040 if (frag == skb_shinfo(skb)->nr_frags - 1) in happy_meal_start_xmit()
2042 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], in happy_meal_start_xmit()
2047 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[first_entry], in happy_meal_start_xmit()
2052 hp->tx_new = entry; in happy_meal_start_xmit()
2058 hme_write32(hp, hp->etxregs + ETX_PENDING, ETX_TP_DMAWAKEUP); in happy_meal_start_xmit()
2060 spin_unlock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2066 hp->tx_skbs[hp->tx_new] = NULL; in happy_meal_start_xmit()
2067 spin_unlock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2070 dev->stats.tx_dropped++; in happy_meal_start_xmit()
2078 spin_lock_irq(&hp->happy_lock); in happy_meal_get_stats()
2079 happy_meal_get_counters(hp, hp->bigmacregs); in happy_meal_get_stats()
2080 spin_unlock_irq(&hp->happy_lock); in happy_meal_get_stats()
2082 return &dev->stats; in happy_meal_get_stats()
2088 void __iomem *bregs = hp->bigmacregs; in happy_meal_set_multicast()
2092 spin_lock_irq(&hp->happy_lock); in happy_meal_set_multicast()
2094 if ((dev->flags & IFF_ALLMULTI) || (netdev_mc_count(dev) > 64)) { in happy_meal_set_multicast()
2099 } else if (dev->flags & IFF_PROMISC) { in happy_meal_set_multicast()
2107 crc = ether_crc_le(6, ha->addr); in happy_meal_set_multicast()
2117 spin_unlock_irq(&hp->happy_lock); in happy_meal_set_multicast()
2134 cmd->base.port = PORT_TP; /* XXX no MII support */ in hme_get_link_ksettings()
2135 cmd->base.phy_address = 0; /* XXX fixed PHYAD */ in hme_get_link_ksettings()
2137 /* Record PHY settings. */ in hme_get_link_ksettings()
2138 spin_lock_irq(&hp->happy_lock); in hme_get_link_ksettings()
2139 hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR); in hme_get_link_ksettings()
2140 hp->sw_lpa = happy_meal_tcvr_read(hp, hp->tcvregs, MII_LPA); in hme_get_link_ksettings()
2141 spin_unlock_irq(&hp->happy_lock); in hme_get_link_ksettings()
2143 if (hp->sw_bmcr & BMCR_ANENABLE) { in hme_get_link_ksettings()
2144 cmd->base.autoneg = AUTONEG_ENABLE; in hme_get_link_ksettings()
2145 speed = ((hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ? in hme_get_link_ksettings()
2148 cmd->base.duplex = in hme_get_link_ksettings()
2149 (hp->sw_lpa & (LPA_100FULL)) ? in hme_get_link_ksettings()
2152 cmd->base.duplex = in hme_get_link_ksettings()
2153 (hp->sw_lpa & (LPA_10FULL)) ? in hme_get_link_ksettings()
2156 cmd->base.autoneg = AUTONEG_DISABLE; in hme_get_link_ksettings()
2157 speed = (hp->sw_bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10; in hme_get_link_ksettings()
2158 cmd->base.duplex = in hme_get_link_ksettings()
2159 (hp->sw_bmcr & BMCR_FULLDPLX) ? in hme_get_link_ksettings()
2162 cmd->base.speed = speed; in hme_get_link_ksettings()
2163 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, in hme_get_link_ksettings()
2175 if (cmd->base.autoneg != AUTONEG_ENABLE && in hme_set_link_ksettings()
2176 cmd->base.autoneg != AUTONEG_DISABLE) in hme_set_link_ksettings()
2177 return -EINVAL; in hme_set_link_ksettings()
2178 if (cmd->base.autoneg == AUTONEG_DISABLE && in hme_set_link_ksettings()
2179 ((cmd->base.speed != SPEED_100 && in hme_set_link_ksettings()
2180 cmd->base.speed != SPEED_10) || in hme_set_link_ksettings()
2181 (cmd->base.duplex != DUPLEX_HALF && in hme_set_link_ksettings()
2182 cmd->base.duplex != DUPLEX_FULL))) in hme_set_link_ksettings()
2183 return -EINVAL; in hme_set_link_ksettings()
2186 spin_lock_irq(&hp->happy_lock); in hme_set_link_ksettings()
2187 del_timer(&hp->happy_timer); in hme_set_link_ksettings()
2188 happy_meal_begin_auto_negotiation(hp, hp->tcvregs, cmd); in hme_set_link_ksettings()
2189 spin_unlock_irq(&hp->happy_lock); in hme_set_link_ksettings()
2198 strscpy(info->driver, DRV_NAME, sizeof(info->driver)); in hme_get_drvinfo()
2199 if (hp->happy_flags & HFLAG_PCI) { in hme_get_drvinfo()
2200 struct pci_dev *pdev = hp->happy_dev; in hme_get_drvinfo()
2201 strscpy(info->bus_info, pci_name(pdev), sizeof(info->bus_info)); in hme_get_drvinfo()
2206 struct platform_device *op = hp->happy_dev; in hme_get_drvinfo()
2207 regs = of_get_property(op->dev.of_node, "regs", NULL); in hme_get_drvinfo()
2209 snprintf(info->bus_info, sizeof(info->bus_info), in hme_get_drvinfo()
2211 regs->which_io); in hme_get_drvinfo()
2220 spin_lock_irq(&hp->happy_lock); in hme_get_link()
2221 hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR); in hme_get_link()
2222 spin_unlock_irq(&hp->happy_lock); in hme_get_link()
2224 return hp->sw_bmsr & BMSR_LSTATUS; in hme_get_link()
2242 struct device *parent = child->dev.parent; in quattro_sbus_find()
2255 qp->quattro_dev = child; in quattro_sbus_find()
2256 qp->next = qfe_sbus_list; in quattro_sbus_find()
2268 struct pci_dev *bdev = pdev->bus->self; in quattro_pci_find()
2272 return ERR_PTR(-ENODEV); in quattro_pci_find()
2274 for (qp = qfe_pci_list; qp != NULL; qp = qp->next) { in quattro_pci_find()
2275 struct pci_dev *qpdev = qp->quattro_dev; in quattro_pci_find()
2283 return ERR_PTR(-ENOMEM); in quattro_pci_find()
2286 qp->happy_meals[i] = NULL; in quattro_pci_find()
2288 qp->quattro_dev = bdev; in quattro_pci_find()
2289 qp->next = qfe_pci_list; in quattro_pci_find()
2293 qp->nranges = 0; in quattro_pci_find()
2312 struct pci_dev *busdev = pdev->bus->self; in is_quattro_p()
2316 if (!busdev || busdev->vendor != PCI_VENDOR_ID_DEC || in is_quattro_p()
2317 busdev->device != PCI_DEVICE_ID_DEC_21153) in is_quattro_p()
2321 list_for_each_entry(this_pdev, &pdev->bus->devices, bus_list) { in is_quattro_p()
2322 if (this_pdev->vendor == PCI_VENDOR_ID_SUN && in is_quattro_p()
2323 this_pdev->device == PCI_DEVICE_ID_SUN_HAPPYMEAL) in is_quattro_p()
2357 index--; in find_eth_addr_in_vpd()
2374 index = PCI_SLOT(pdev->devfn); in get_hme_mac_nonsparc()
2407 eth_hw_addr_set(hp->dev, addr); in happy_meal_addr_init()
2415 * the Quattro local-mac-address property... in happy_meal_addr_init()
2417 if (qfe_slot != -1) { in happy_meal_addr_init()
2418 addr = of_get_property(dp, "local-mac-address", &len); in happy_meal_addr_init()
2420 eth_hw_addr_set(hp->dev, addr); in happy_meal_addr_init()
2425 eth_hw_addr_set(hp->dev, idprom->id_ethaddr); in happy_meal_addr_init()
2429 get_hme_mac_nonsparc(hp->happy_dev, addr); in happy_meal_addr_init()
2430 eth_hw_addr_set(hp->dev, addr); in happy_meal_addr_init()
2438 struct net_device *dev = hp->dev; in happy_meal_common_probe()
2442 hp->hm_revision = of_getintprop_default(dp, "hm-rev", hp->hm_revision); in happy_meal_common_probe()
2446 if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21) in happy_meal_common_probe()
2447 hp->happy_flags |= HFLAG_20_21; in happy_meal_common_probe()
2448 else if (hp->hm_revision != 0xa0) in happy_meal_common_probe()
2449 hp->happy_flags |= HFLAG_NOT_A0; in happy_meal_common_probe()
2451 hp->happy_block = dmam_alloc_coherent(hp->dma_dev, PAGE_SIZE, in happy_meal_common_probe()
2452 &hp->hblock_dvma, GFP_KERNEL); in happy_meal_common_probe()
2453 if (!hp->happy_block) in happy_meal_common_probe()
2454 return -ENOMEM; in happy_meal_common_probe()
2456 /* Force check of the link first time we are brought up. */ in happy_meal_common_probe()
2457 hp->linkcheck = 0; in happy_meal_common_probe()
2459 /* Force timer state to 'asleep' with count of zero. */ in happy_meal_common_probe()
2460 hp->timer_state = asleep; in happy_meal_common_probe()
2461 hp->timer_ticks = 0; in happy_meal_common_probe()
2463 timer_setup(&hp->happy_timer, happy_meal_timer, 0); in happy_meal_common_probe()
2465 dev->netdev_ops = &hme_netdev_ops; in happy_meal_common_probe()
2466 dev->watchdog_timeo = 5 * HZ; in happy_meal_common_probe()
2467 dev->ethtool_ops = &hme_ethtool_ops; in happy_meal_common_probe()
2470 dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM; in happy_meal_common_probe()
2471 dev->features |= dev->hw_features | NETIF_F_RXCSUM; in happy_meal_common_probe()
2477 spin_lock_irq(&hp->happy_lock); in happy_meal_common_probe()
2479 spin_unlock_irq(&hp->happy_lock); in happy_meal_common_probe()
2481 err = devm_register_netdev(hp->dma_dev, dev); in happy_meal_common_probe()
2483 dev_err(hp->dma_dev, "Cannot register net device, aborting.\n"); in happy_meal_common_probe()
2490 struct device_node *dp = op->dev.of_node, *sbus_dp; in happy_meal_sbus_probe_one()
2494 int qfe_slot = -1; in happy_meal_sbus_probe_one()
2497 sbus_dp = op->dev.parent->of_node; in happy_meal_sbus_probe_one()
2501 return -ENODEV; in happy_meal_sbus_probe_one()
2506 return -ENODEV; in happy_meal_sbus_probe_one()
2508 if (qp->happy_meals[qfe_slot] == NULL) in happy_meal_sbus_probe_one()
2511 return -ENODEV; in happy_meal_sbus_probe_one()
2514 dev = devm_alloc_etherdev(&op->dev, sizeof(struct happy_meal)); in happy_meal_sbus_probe_one()
2516 return -ENOMEM; in happy_meal_sbus_probe_one()
2517 SET_NETDEV_DEV(dev, &op->dev); in happy_meal_sbus_probe_one()
2520 hp->dev = dev; in happy_meal_sbus_probe_one()
2521 hp->happy_dev = op; in happy_meal_sbus_probe_one()
2522 hp->dma_dev = &op->dev; in happy_meal_sbus_probe_one()
2525 spin_lock_init(&hp->happy_lock); in happy_meal_sbus_probe_one()
2528 hp->qfe_parent = qp; in happy_meal_sbus_probe_one()
2529 hp->qfe_ent = qfe_slot; in happy_meal_sbus_probe_one()
2530 qp->happy_meals[qfe_slot] = dev; in happy_meal_sbus_probe_one()
2533 hp->gregs = devm_platform_ioremap_resource(op, 0); in happy_meal_sbus_probe_one()
2534 if (IS_ERR(hp->gregs)) { in happy_meal_sbus_probe_one()
2535 dev_err(&op->dev, "Cannot map global registers.\n"); in happy_meal_sbus_probe_one()
2536 err = PTR_ERR(hp->gregs); in happy_meal_sbus_probe_one()
2540 hp->etxregs = devm_platform_ioremap_resource(op, 1); in happy_meal_sbus_probe_one()
2541 if (IS_ERR(hp->etxregs)) { in happy_meal_sbus_probe_one()
2542 dev_err(&op->dev, "Cannot map MAC TX registers.\n"); in happy_meal_sbus_probe_one()
2543 err = PTR_ERR(hp->etxregs); in happy_meal_sbus_probe_one()
2547 hp->erxregs = devm_platform_ioremap_resource(op, 2); in happy_meal_sbus_probe_one()
2548 if (IS_ERR(hp->erxregs)) { in happy_meal_sbus_probe_one()
2549 dev_err(&op->dev, "Cannot map MAC RX registers.\n"); in happy_meal_sbus_probe_one()
2550 err = PTR_ERR(hp->erxregs); in happy_meal_sbus_probe_one()
2554 hp->bigmacregs = devm_platform_ioremap_resource(op, 3); in happy_meal_sbus_probe_one()
2555 if (IS_ERR(hp->bigmacregs)) { in happy_meal_sbus_probe_one()
2556 dev_err(&op->dev, "Cannot map BIGMAC registers.\n"); in happy_meal_sbus_probe_one()
2557 err = PTR_ERR(hp->bigmacregs); in happy_meal_sbus_probe_one()
2561 hp->tcvregs = devm_platform_ioremap_resource(op, 4); in happy_meal_sbus_probe_one()
2562 if (IS_ERR(hp->tcvregs)) { in happy_meal_sbus_probe_one()
2563 dev_err(&op->dev, "Cannot map TCVR registers.\n"); in happy_meal_sbus_probe_one()
2564 err = PTR_ERR(hp->tcvregs); in happy_meal_sbus_probe_one()
2568 hp->hm_revision = 0xa0; in happy_meal_sbus_probe_one()
2571 hp->happy_flags |= HFLAG_QUATTRO; in happy_meal_sbus_probe_one()
2573 hp->irq = op->archdata.irqs[0]; in happy_meal_sbus_probe_one()
2576 hp->happy_bursts = of_getintprop_default(sbus_dp, in happy_meal_sbus_probe_one()
2577 "burst-sizes", 0x00); in happy_meal_sbus_probe_one()
2581 hp->read_desc32 = sbus_hme_read_desc32; in happy_meal_sbus_probe_one()
2582 hp->write_txd = sbus_hme_write_txd; in happy_meal_sbus_probe_one()
2583 hp->write_rxd = sbus_hme_write_rxd; in happy_meal_sbus_probe_one()
2584 hp->read32 = sbus_hme_read32; in happy_meal_sbus_probe_one()
2585 hp->write32 = sbus_hme_write32; in happy_meal_sbus_probe_one()
2594 if (qfe_slot != -1) in happy_meal_sbus_probe_one()
2597 qfe_slot, dev->dev_addr); in happy_meal_sbus_probe_one()
2600 dev->dev_addr); in happy_meal_sbus_probe_one()
2606 qp->happy_meals[qfe_slot] = NULL; in happy_meal_sbus_probe_one()
2622 int qfe_slot = -1; in happy_meal_pci_probe()
2623 int err = -ENODEV; in happy_meal_pci_probe()
2647 if (!qp->happy_meals[qfe_slot]) in happy_meal_pci_probe()
2651 return -ENODEV; in happy_meal_pci_probe()
2654 dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct happy_meal)); in happy_meal_pci_probe()
2656 return -ENOMEM; in happy_meal_pci_probe()
2657 SET_NETDEV_DEV(dev, &pdev->dev); in happy_meal_pci_probe()
2660 hp->dev = dev; in happy_meal_pci_probe()
2661 hp->happy_dev = pdev; in happy_meal_pci_probe()
2662 hp->dma_dev = &pdev->dev; in happy_meal_pci_probe()
2664 spin_lock_init(&hp->happy_lock); in happy_meal_pci_probe()
2667 hp->qfe_parent = qp; in happy_meal_pci_probe()
2668 hp->qfe_ent = qfe_slot; in happy_meal_pci_probe()
2669 qp->happy_meals[qfe_slot] = dev; in happy_meal_pci_probe()
2672 err = -EINVAL; in happy_meal_pci_probe()
2674 dev_err(&pdev->dev, in happy_meal_pci_probe()
2679 hpreg_res = devm_request_mem_region(&pdev->dev, in happy_meal_pci_probe()
2684 err = -EBUSY; in happy_meal_pci_probe()
2685 dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting.\n"); in happy_meal_pci_probe()
2691 err = -ENOMEM; in happy_meal_pci_probe()
2692 dev_err(&pdev->dev, "Unable to remap card memory.\n"); in happy_meal_pci_probe()
2699 hp->gregs = (hpreg_base + 0x0000UL); in happy_meal_pci_probe()
2700 hp->etxregs = (hpreg_base + 0x2000UL); in happy_meal_pci_probe()
2701 hp->erxregs = (hpreg_base + 0x4000UL); in happy_meal_pci_probe()
2702 hp->bigmacregs = (hpreg_base + 0x6000UL); in happy_meal_pci_probe()
2703 hp->tcvregs = (hpreg_base + 0x7000UL); in happy_meal_pci_probe()
2706 hp->hm_revision = 0xc0 | (pdev->revision & 0x0f); in happy_meal_pci_probe()
2708 hp->hm_revision = 0x20; in happy_meal_pci_probe()
2711 hp->happy_flags |= HFLAG_QUATTRO; in happy_meal_pci_probe()
2714 hp->happy_flags |= HFLAG_PCI; in happy_meal_pci_probe()
2718 hp->happy_bursts = DMA_BURSTBITS; in happy_meal_pci_probe()
2720 hp->irq = pdev->irq; in happy_meal_pci_probe()
2724 hp->read_desc32 = pci_hme_read_desc32; in happy_meal_pci_probe()
2725 hp->write_txd = pci_hme_write_txd; in happy_meal_pci_probe()
2726 hp->write_rxd = pci_hme_write_rxd; in happy_meal_pci_probe()
2727 hp->read32 = pci_hme_read32; in happy_meal_pci_probe()
2728 hp->write32 = pci_hme_write32; in happy_meal_pci_probe()
2738 struct pci_dev *qpdev = qp->quattro_dev; in happy_meal_pci_probe()
2741 if (!strncmp(dev->name, "eth", 3)) { in happy_meal_pci_probe()
2742 int i = simple_strtoul(dev->name + 3, NULL, 10); in happy_meal_pci_probe()
2743 sprintf(prom_name, "-%d", i + 3); in happy_meal_pci_probe()
2747 prom_name, qpdev->vendor, qpdev->device); in happy_meal_pci_probe()
2750 if (qfe_slot != -1) in happy_meal_pci_probe()
2753 qfe_slot, dev->dev_addr); in happy_meal_pci_probe()
2757 dev->dev_addr); in happy_meal_pci_probe()
2763 qp->happy_meals[qfe_slot] = NULL; in happy_meal_pci_probe()
2791 struct quattro *next = qfe->next; in happy_meal_pci_exit()
2806 struct device_node *dp = op->dev.of_node; in hme_sbus_probe()
2810 match = of_match_device(hme_sbus_match, &op->dev); in hme_sbus_probe()
2812 return -EINVAL; in hme_sbus_probe()
2813 is_qfe = (match->data != NULL); in hme_sbus_probe()
2815 if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe")) in hme_sbus_probe()
2857 struct quattro *next = qfe->next; in happy_meal_sbus_exit()