Lines Matching refs:hp
104 static __inline__ void tx_add_log(struct happy_meal *hp, unsigned int a, unsigned int s)
112 tlp->tx_new = hp->tx_new;
113 tlp->tx_old = hp->tx_old;
133 #define tx_add_log(hp, a, s) argument
252 static inline u32 hme_read_desc32(struct happy_meal *hp, hme32 *p) in hme_read_desc32() argument
261 static void BB_PUT_BIT(struct happy_meal *hp, void __iomem *tregs, int bit) in BB_PUT_BIT() argument
263 hme_write32(hp, tregs + TCVR_BBDATA, bit); in BB_PUT_BIT()
264 hme_write32(hp, tregs + TCVR_BBCLOCK, 0); in BB_PUT_BIT()
265 hme_write32(hp, tregs + TCVR_BBCLOCK, 1); in BB_PUT_BIT()
269 static u32 BB_GET_BIT(struct happy_meal *hp, void __iomem *tregs, int internal)
273 hme_write32(hp, tregs + TCVR_BBCLOCK, 0);
274 hme_write32(hp, tregs + TCVR_BBCLOCK, 1);
275 ret = hme_read32(hp, tregs + TCVR_CFG);
285 static u32 BB_GET_BIT2(struct happy_meal *hp, void __iomem *tregs, int internal) in BB_GET_BIT2() argument
289 hme_write32(hp, tregs + TCVR_BBCLOCK, 0); in BB_GET_BIT2()
291 retval = hme_read32(hp, tregs + TCVR_CFG); in BB_GET_BIT2()
296 hme_write32(hp, tregs + TCVR_BBCLOCK, 1); in BB_GET_BIT2()
303 static int happy_meal_bb_read(struct happy_meal *hp, in happy_meal_bb_read() argument
311 hme_write32(hp, tregs + TCVR_BBOENAB, 1); in happy_meal_bb_read()
315 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
318 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_read()
319 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
320 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
321 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_read()
324 tmp = hp->paddr & 0xff; in happy_meal_bb_read()
326 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_read()
331 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_read()
334 hme_write32(hp, tregs + TCVR_BBOENAB, 0); in happy_meal_bb_read()
337 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); 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()
347 static void happy_meal_bb_write(struct happy_meal *hp, in happy_meal_bb_write() argument
357 hme_write32(hp, tregs + TCVR_BBOENAB, 1); in happy_meal_bb_write()
361 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
364 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
365 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
366 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
367 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
370 tmp = (hp->paddr & 0xff); in happy_meal_bb_write()
372 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_write()
377 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_write()
380 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
381 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
384 BB_PUT_BIT(hp, tregs, ((value >> i) & 1)); in happy_meal_bb_write()
387 hme_write32(hp, tregs + TCVR_BBOENAB, 0); in happy_meal_bb_write()
392 static int happy_meal_tcvr_read(struct happy_meal *hp, in happy_meal_tcvr_read() argument
398 if (hp->tcvr_type == none) { in happy_meal_tcvr_read()
403 if (!(hp->happy_flags & HFLAG_FENABLE)) { in happy_meal_tcvr_read()
405 return happy_meal_bb_read(hp, tregs, reg); in happy_meal_tcvr_read()
408 hme_write32(hp, tregs + TCVR_FRAME, 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()
416 retval = hme_read32(hp, tregs + TCVR_FRAME) & 0xffff; in happy_meal_tcvr_read()
423 static void happy_meal_tcvr_write(struct happy_meal *hp, in happy_meal_tcvr_write() argument
432 if (!(hp->happy_flags & HFLAG_FENABLE)) { in happy_meal_tcvr_write()
433 happy_meal_bb_write(hp, tregs, reg, value); in happy_meal_tcvr_write()
438 hme_write32(hp, tregs + TCVR_FRAME, 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()
483 static int try_next_permutation(struct happy_meal *hp, void __iomem *tregs) in try_next_permutation() argument
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()
507 static void display_link_mode(struct happy_meal *hp, void __iomem *tregs) in display_link_mode() argument
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()
518 static void display_forced_link_mode(struct happy_meal *hp, void __iomem *tregs) in display_forced_link_mode() argument
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()
529 static int set_happy_link_modes(struct happy_meal *hp, void __iomem *tregs) in set_happy_link_modes() argument
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()
589 static int is_lucent_phy(struct happy_meal *hp) in is_lucent_phy() argument
591 void __iomem *tregs = hp->tcvregs; in is_lucent_phy()
595 mr2 = happy_meal_tcvr_read(hp, tregs, 2); in is_lucent_phy()
596 mr3 = happy_meal_tcvr_read(hp, tregs, 3); in is_lucent_phy()
606 happy_meal_begin_auto_negotiation(struct happy_meal *hp, in happy_meal_begin_auto_negotiation() argument
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()
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()
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()
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()
679 hp->timer_state = arbwait; in happy_meal_begin_auto_negotiation()
692 hp->sw_bmcr = BMCR_SPEED100; 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()
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()
703 if (!is_lucent_phy(hp)) { 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()
711 happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, 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()
724 struct happy_meal *hp = from_timer(hp, t, happy_timer); in happy_meal_timer() local
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()
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()
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()
745 if (!is_lucent_phy(hp)) { 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()
764 ret = set_happy_link_modes(hp, tregs); 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()
795 display_link_mode(hp, tregs); 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()
819 if (!is_lucent_phy(hp)) { in happy_meal_timer()
823 hp->sw_csconfig |= CSCONFIG_TCVDISAB; in happy_meal_timer()
824 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
825 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
830 if (hp->timer_ticks == 2) { in happy_meal_timer()
831 if (!is_lucent_phy(hp)) { in happy_meal_timer()
832 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_timer()
833 happy_meal_tcvr_write(hp, tregs, 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()
841 display_forced_link_mode(hp, tregs); in happy_meal_timer()
842 set_happy_link_modes(hp, tregs); /* XXX error? then what? */ 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()
849 ret = try_next_permutation(hp, tregs); in happy_meal_timer()
856 netdev_notice(hp->dev, in happy_meal_timer()
859 happy_meal_begin_auto_negotiation(hp, tregs, NULL); in happy_meal_timer()
862 if (!is_lucent_phy(hp)) { 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()
866 happy_meal_tcvr_write(hp, tregs, 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()
901 static void happy_meal_tx_reset(struct happy_meal *hp, void __iomem *bregs) in happy_meal_tx_reset() argument
908 hme_write32(hp, bregs + BMAC_TXSWRESET, 0); in happy_meal_tx_reset()
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()
921 static void happy_meal_rx_reset(struct happy_meal *hp, void __iomem *bregs) in happy_meal_rx_reset() argument
928 hme_write32(hp, bregs + BMAC_RXSWRESET, 0); in happy_meal_rx_reset()
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()
943 static void happy_meal_stop(struct happy_meal *hp, void __iomem *gregs) in happy_meal_stop() argument
950 hme_write32(hp, gregs + GREG_SWRESET, GREG_RESET_ALL); in happy_meal_stop()
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()
963 static void happy_meal_get_counters(struct happy_meal *hp, void __iomem *bregs) in happy_meal_get_counters() argument
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()
968 hme_write32(hp, bregs + BMAC_RCRCECTR, 0); in happy_meal_get_counters()
970 stats->rx_frame_errors += hme_read32(hp, bregs + BMAC_UNALECTR); in happy_meal_get_counters()
971 hme_write32(hp, bregs + BMAC_UNALECTR, 0); in happy_meal_get_counters()
973 stats->rx_length_errors += hme_read32(hp, bregs + BMAC_GLECTR); in happy_meal_get_counters()
974 hme_write32(hp, bregs + BMAC_GLECTR, 0); in happy_meal_get_counters()
976 stats->tx_aborted_errors += hme_read32(hp, bregs + BMAC_EXCTR); in happy_meal_get_counters()
979 (hme_read32(hp, bregs + BMAC_EXCTR) + in happy_meal_get_counters()
980 hme_read32(hp, bregs + BMAC_LTCTR)); in happy_meal_get_counters()
981 hme_write32(hp, bregs + BMAC_EXCTR, 0); in happy_meal_get_counters()
982 hme_write32(hp, bregs + BMAC_LTCTR, 0); in happy_meal_get_counters()
992 static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs) in happy_meal_tcvr_reset() argument
997 tconfig = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_tcvr_reset()
999 if (hp->tcvr_type == external) { in happy_meal_tcvr_reset()
1000 hme_write32(hp, tregs + TCVR_CFG, tconfig & ~(TCV_CFG_PSELECT)); 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()
1003 happy_meal_tcvr_write(hp, tregs, MII_BMCR, in happy_meal_tcvr_reset()
1005 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1011 hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT); 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()
1016 hme_write32(hp, tregs + TCVR_CFG, (tconfig | TCV_CFG_PSELECT)); in happy_meal_tcvr_reset()
1017 happy_meal_tcvr_write(hp, tregs, MII_BMCR, in happy_meal_tcvr_reset()
1019 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1025 hme_write32(hp, tregs + TCVR_CFG, (tconfig & ~(TCV_CFG_PSELECT))); 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()
1032 happy_meal_tcvr_write(hp, tregs, MII_BMCR, BMCR_RESET); in happy_meal_tcvr_reset()
1035 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1038 hp->sw_bmcr = result; 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()
1061 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1073 if (!is_lucent_phy(hp)) { in happy_meal_tcvr_reset()
1074 result = happy_meal_tcvr_read(hp, tregs, in happy_meal_tcvr_reset()
1076 happy_meal_tcvr_write(hp, tregs, in happy_meal_tcvr_reset()
1086 static void happy_meal_transceiver_check(struct happy_meal *hp, void __iomem *tregs) in happy_meal_transceiver_check() argument
1088 unsigned long tconfig = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_transceiver_check()
1089 u32 reread = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_transceiver_check()
1093 hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT); in happy_meal_transceiver_check()
1094 hp->paddr = TCV_PADDR_ETX; in happy_meal_transceiver_check()
1095 hp->tcvr_type = external; in happy_meal_transceiver_check()
1099 hme_write32(hp, tregs + TCVR_CFG, 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()
1157 static void happy_meal_clean_rings(struct happy_meal *hp) in happy_meal_clean_rings() argument
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()
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()
1209 static void happy_meal_init_rings(struct happy_meal *hp) in happy_meal_init_rings() argument
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()
1218 happy_meal_clean_rings(hp); 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()
1250 hme_write_txd(hp, &hb->happy_meal_txd[i], 0, 0); in happy_meal_init_rings()
1256 static int happy_meal_init(struct happy_meal *hp) in happy_meal_init() argument
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()
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()
1274 happy_meal_get_counters(hp, bregs); in happy_meal_init()
1279 happy_meal_stop(hp, gregs); in happy_meal_init()
1283 happy_meal_init_rings(hp); in happy_meal_init()
1286 if (hp->happy_flags & HFLAG_FENABLE) { in happy_meal_init()
1288 hme_read32(hp, tregs + TCVR_CFG)); in happy_meal_init()
1289 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_init()
1290 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE)); in happy_meal_init()
1293 hme_read32(hp, tregs + TCVR_CFG)); in happy_meal_init()
1294 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_init()
1295 hme_read32(hp, tregs + TCVR_CFG) | TCV_CFG_BENABLE); in happy_meal_init()
1300 happy_meal_transceiver_check(hp, tregs); in happy_meal_init()
1303 switch(hp->tcvr_type) { in happy_meal_init()
1312 hme_write32(hp, bregs + BMAC_XIFCFG, 0); in happy_meal_init()
1318 hme_write32(hp, bregs + BMAC_XIFCFG, BIGMAC_XCFG_MIIDISAB); in happy_meal_init()
1322 if (happy_meal_tcvr_reset(hp, tregs)) in happy_meal_init()
1327 happy_meal_tx_reset(hp, bregs); in happy_meal_init()
1328 happy_meal_rx_reset(hp, bregs); in happy_meal_init()
1331 hme_write32(hp, bregs + BMAC_JSIZE, DEFAULT_JAMSIZE); in happy_meal_init()
1332 hme_write32(hp, bregs + BMAC_IGAP1, DEFAULT_IPG1); in happy_meal_init()
1333 hme_write32(hp, bregs + BMAC_IGAP2, DEFAULT_IPG2); in happy_meal_init()
1338 hme_write32(hp, bregs + BMAC_RSEED, ((e[5] | e[4]<<8)&0x3ff)); in happy_meal_init()
1340 hme_write32(hp, bregs + BMAC_MACADDR2, ((e[4] << 8) | e[5])); in happy_meal_init()
1341 hme_write32(hp, bregs + BMAC_MACADDR1, ((e[2] << 8) | e[3])); in happy_meal_init()
1342 hme_write32(hp, bregs + BMAC_MACADDR0, ((e[0] << 8) | e[1])); 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()
1346 hme_write32(hp, bregs + BMAC_HTABLE0, 0xffff); in happy_meal_init()
1347 hme_write32(hp, bregs + BMAC_HTABLE1, 0xffff); in happy_meal_init()
1348 hme_write32(hp, bregs + BMAC_HTABLE2, 0xffff); in happy_meal_init()
1349 hme_write32(hp, bregs + BMAC_HTABLE3, 0xffff); 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()
1361 hme_write32(hp, bregs + BMAC_HTABLE0, hash_table[0]); in happy_meal_init()
1362 hme_write32(hp, bregs + BMAC_HTABLE1, hash_table[1]); in happy_meal_init()
1363 hme_write32(hp, bregs + BMAC_HTABLE2, hash_table[2]); in happy_meal_init()
1364 hme_write32(hp, bregs + BMAC_HTABLE3, hash_table[3]); in happy_meal_init()
1366 hme_write32(hp, bregs + BMAC_HTABLE3, 0); in happy_meal_init()
1367 hme_write32(hp, bregs + BMAC_HTABLE2, 0); in happy_meal_init()
1368 hme_write32(hp, bregs + BMAC_HTABLE1, 0); in happy_meal_init()
1369 hme_write32(hp, bregs + BMAC_HTABLE0, 0); 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()
1376 hme_write32(hp, erxregs + ERX_RING, in happy_meal_init()
1377 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0))); in happy_meal_init()
1378 hme_write32(hp, etxregs + ETX_RING, in happy_meal_init()
1379 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_txd, 0))); in happy_meal_init()
1386 if (hme_read32(hp, erxregs + ERX_RING) != in happy_meal_init()
1387 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0))) in happy_meal_init()
1388 hme_write32(hp, erxregs + ERX_RING, in happy_meal_init()
1389 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0)) in happy_meal_init()
1395 hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST64); 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()
1410 if ((hp->happy_flags & HFLAG_PCI) == 0) { in happy_meal_init()
1411 struct platform_device *op = hp->happy_dev; in happy_meal_init()
1414 hp->happy_bursts); in happy_meal_init()
1421 hme_write32(hp, gregs + GREG_CFG, gcfg); in happy_meal_init()
1422 } else if (hp->happy_bursts & DMA_BURST32) { in happy_meal_init()
1424 hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST32); in happy_meal_init()
1425 } else if (hp->happy_bursts & DMA_BURST16) { in happy_meal_init()
1427 hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST16); in happy_meal_init()
1430 hme_write32(hp, gregs + GREG_CFG, 0); in happy_meal_init()
1435 hme_read32(hp, gregs + GREG_CFG), bursts); in happy_meal_init()
1438 hme_write32(hp, gregs + GREG_IMASK, in happy_meal_init()
1444 hme_read32(hp, etxregs + ETX_RSIZE)); in happy_meal_init()
1445 hme_write32(hp, etxregs + ETX_RSIZE, (TX_RING_SIZE >> ETX_RSIZE_SHIFT) - 1); in happy_meal_init()
1448 HMD("tx dma enable old[%08x]\n", hme_read32(hp, etxregs + ETX_CFG)); in happy_meal_init()
1449 hme_write32(hp, etxregs + ETX_CFG, in happy_meal_init()
1450 hme_read32(hp, etxregs + ETX_CFG) | ETX_CFG_DMAENABLE); in happy_meal_init()
1458 hme_read32(hp, erxregs + ERX_CFG)); in happy_meal_init()
1459 hme_write32(hp, erxregs + ERX_CFG, ERX_CFG_DEFAULT(RX_OFFSET)); in happy_meal_init()
1460 regtmp = hme_read32(hp, erxregs + ERX_CFG); in happy_meal_init()
1461 hme_write32(hp, erxregs + ERX_CFG, ERX_CFG_DEFAULT(RX_OFFSET)); in happy_meal_init()
1462 if (hme_read32(hp, erxregs + ERX_CFG) != ERX_CFG_DEFAULT(RX_OFFSET)) { in happy_meal_init()
1463 netdev_err(hp->dev, in happy_meal_init()
1465 netdev_err(hp->dev, in happy_meal_init()
1473 hme_read32(hp, bregs + BMAC_RXCFG)); in happy_meal_init()
1475 if (hp->dev->flags & IFF_PROMISC) in happy_meal_init()
1477 hme_write32(hp, bregs + BMAC_RXCFG, rxcfg); in happy_meal_init()
1485 if (hp->happy_flags & HFLAG_FULL) in happy_meal_init()
1491 hme_write32(hp, bregs + BMAC_TXCFG, regtmp /*| BIGMAC_TXCFG_DGIVEUP*/); in happy_meal_init()
1494 hme_write32(hp, bregs + BMAC_ALIMIT, 16); in happy_meal_init()
1500 if (hp->happy_flags & HFLAG_LANCE) in happy_meal_init()
1504 if (hp->tcvr_type == external) in happy_meal_init()
1507 HMD("XIF config old[%08x]\n", hme_read32(hp, bregs + BMAC_XIFCFG)); in happy_meal_init()
1508 hme_write32(hp, bregs + BMAC_XIFCFG, regtmp); in happy_meal_init()
1512 hme_read32(hp, bregs + BMAC_TXCFG), in happy_meal_init()
1513 hme_read32(hp, bregs + BMAC_RXCFG)); in happy_meal_init()
1516 hme_write32(hp, bregs + BMAC_TXMAX, ETH_FRAME_LEN + 8); in happy_meal_init()
1517 hme_write32(hp, bregs + BMAC_RXMAX, ETH_FRAME_LEN + 8); in happy_meal_init()
1519 hme_write32(hp, bregs + BMAC_TXCFG, in happy_meal_init()
1520 hme_read32(hp, bregs + BMAC_TXCFG) | BIGMAC_TXCFG_ENABLE); in happy_meal_init()
1521 hme_write32(hp, bregs + BMAC_RXCFG, in happy_meal_init()
1522 hme_read32(hp, bregs + BMAC_RXCFG) | BIGMAC_RXCFG_ENABLE); in happy_meal_init()
1525 happy_meal_begin_auto_negotiation(hp, tregs, NULL); in happy_meal_init()
1532 static void happy_meal_set_initial_advertisement(struct happy_meal *hp) in happy_meal_set_initial_advertisement() argument
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()
1538 happy_meal_stop(hp, gregs); in happy_meal_set_initial_advertisement()
1539 if (hp->happy_flags & HFLAG_FENABLE) in happy_meal_set_initial_advertisement()
1540 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_set_initial_advertisement()
1541 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE)); in happy_meal_set_initial_advertisement()
1543 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_set_initial_advertisement()
1544 hme_read32(hp, tregs + TCVR_CFG) | TCV_CFG_BENABLE); in happy_meal_set_initial_advertisement()
1545 happy_meal_transceiver_check(hp, tregs); in happy_meal_set_initial_advertisement()
1546 switch(hp->tcvr_type) { in happy_meal_set_initial_advertisement()
1550 hme_write32(hp, bregs + BMAC_XIFCFG, 0); in happy_meal_set_initial_advertisement()
1553 hme_write32(hp, bregs + BMAC_XIFCFG, BIGMAC_XCFG_MIIDISAB); in happy_meal_set_initial_advertisement()
1556 if (happy_meal_tcvr_reset(hp, tregs)) 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()
1583 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_set_initial_advertisement()
1591 static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status) in happy_meal_is_not_so_happy() argument
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()
1689 happy_meal_init(hp); in happy_meal_is_not_so_happy()
1696 static void happy_meal_tx(struct happy_meal *hp) in happy_meal_tx() argument
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()
1720 flags = hme_read_desc32(hp, &txbase[last].tx_flags); in happy_meal_tx()
1724 hp->tx_skbs[elem] = NULL; 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()
1744 hp->tx_old = elem; in happy_meal_tx()
1747 TX_BUFFS_AVAIL(hp) > (MAX_SKB_FRAGS + 1)) in happy_meal_tx()
1760 static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev) in happy_meal_rx() argument
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()
1788 hme_write_rxd(hp, this, 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()
1816 hme_write_rxd(hp, this, in happy_meal_rx()
1833 dma_sync_single_for_cpu(hp->dma_dev, dma_addr, len + 2, DMA_FROM_DEVICE); in happy_meal_rx()
1835 dma_sync_single_for_device(hp->dma_dev, dma_addr, len + 2, DMA_FROM_DEVICE); in happy_meal_rx()
1837 hme_write_rxd(hp, this, 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()
1866 struct happy_meal *hp = netdev_priv(dev); in happy_meal_interrupt() local
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()
1881 happy_meal_tx(hp); in happy_meal_interrupt()
1884 happy_meal_rx(hp, dev); in happy_meal_interrupt()
1888 spin_unlock(&hp->happy_lock); in happy_meal_interrupt()
1895 struct happy_meal *hp = netdev_priv(dev); in happy_meal_open() local
1898 res = request_irq(hp->irq, happy_meal_interrupt, IRQF_SHARED, 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()
1908 res = happy_meal_init(hp); 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()
1918 struct happy_meal *hp = netdev_priv(dev); in happy_meal_close() local
1920 spin_lock_irq(&hp->happy_lock); in happy_meal_close()
1921 happy_meal_stop(hp, hp->gregs); in happy_meal_close()
1922 happy_meal_clean_rings(hp); 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()
1936 struct happy_meal *hp = netdev_priv(dev); in happy_meal_tx_timeout() local
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()
1946 happy_meal_init(hp); in happy_meal_tx_timeout()
1947 spin_unlock_irq(&hp->happy_lock); in happy_meal_tx_timeout()
1952 static void unmap_partial_tx_skb(struct happy_meal *hp, u32 first_mapping, in unmap_partial_tx_skb() argument
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()
1974 struct happy_meal *hp = netdev_priv(dev); in happy_meal_start_xmit() local
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()
1999 hp->tx_skbs[entry] = skb; 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()
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()
2035 unmap_partial_tx_skb(hp, first_mapping, first_len, 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()
2054 if (TX_BUFFS_AVAIL(hp) <= (MAX_SKB_FRAGS + 1)) 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()
2062 tx_add_log(hp, TXLOG_ACTION_TXMIT, 0); 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()
2076 struct happy_meal *hp = netdev_priv(dev); in happy_meal_get_stats() local
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()
2087 struct happy_meal *hp = netdev_priv(dev); in happy_meal_set_multicast() local
2088 void __iomem *bregs = hp->bigmacregs; in happy_meal_set_multicast()
2092 spin_lock_irq(&hp->happy_lock); in happy_meal_set_multicast()
2095 hme_write32(hp, bregs + BMAC_HTABLE0, 0xffff); in happy_meal_set_multicast()
2096 hme_write32(hp, bregs + BMAC_HTABLE1, 0xffff); in happy_meal_set_multicast()
2097 hme_write32(hp, bregs + BMAC_HTABLE2, 0xffff); in happy_meal_set_multicast()
2098 hme_write32(hp, bregs + BMAC_HTABLE3, 0xffff); in happy_meal_set_multicast()
2100 hme_write32(hp, bregs + BMAC_RXCFG, in happy_meal_set_multicast()
2101 hme_read32(hp, bregs + BMAC_RXCFG) | BIGMAC_RXCFG_PMISC); in happy_meal_set_multicast()
2111 hme_write32(hp, bregs + BMAC_HTABLE0, hash_table[0]); in happy_meal_set_multicast()
2112 hme_write32(hp, bregs + BMAC_HTABLE1, hash_table[1]); in happy_meal_set_multicast()
2113 hme_write32(hp, bregs + BMAC_HTABLE2, hash_table[2]); in happy_meal_set_multicast()
2114 hme_write32(hp, bregs + BMAC_HTABLE3, hash_table[3]); in happy_meal_set_multicast()
2117 spin_unlock_irq(&hp->happy_lock); in happy_meal_set_multicast()
2124 struct happy_meal *hp = netdev_priv(dev); in hme_get_link_ksettings() local
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()
2145 speed = ((hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ? in hme_get_link_ksettings()
2149 (hp->sw_lpa & (LPA_100FULL)) ? in hme_get_link_ksettings()
2153 (hp->sw_lpa & (LPA_10FULL)) ? in hme_get_link_ksettings()
2157 speed = (hp->sw_bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10; in hme_get_link_ksettings()
2159 (hp->sw_bmcr & BMCR_FULLDPLX) ? in hme_get_link_ksettings()
2172 struct happy_meal *hp = netdev_priv(dev); in hme_set_link_ksettings() local
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()
2196 struct happy_meal *hp = netdev_priv(dev); in hme_get_drvinfo() local
2199 if (hp->happy_flags & HFLAG_PCI) { in hme_get_drvinfo()
2200 struct pci_dev *pdev = hp->happy_dev; in hme_get_drvinfo()
2206 struct platform_device *op = hp->happy_dev; in hme_get_drvinfo()
2218 struct happy_meal *hp = netdev_priv(dev); in hme_get_link() local
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()
2392 static void happy_meal_addr_init(struct happy_meal *hp, in happy_meal_addr_init() argument
2407 eth_hw_addr_set(hp->dev, addr); 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()
2435 static int happy_meal_common_probe(struct happy_meal *hp, in happy_meal_common_probe() argument
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()
2457 hp->linkcheck = 0; 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()
2477 spin_lock_irq(&hp->happy_lock); in happy_meal_common_probe()
2478 happy_meal_set_initial_advertisement(hp); 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()
2492 struct happy_meal *hp; in happy_meal_sbus_probe_one() local
2519 hp = netdev_priv(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()
2523 happy_meal_addr_init(hp, dp, qfe_slot); 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()
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()
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()
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()
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()
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()
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()
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()
2588 err = happy_meal_common_probe(hp, dp); in happy_meal_sbus_probe_one()
2592 platform_set_drvdata(op, hp); in happy_meal_sbus_probe_one()
2617 struct happy_meal *hp; in happy_meal_pci_probe() local
2659 hp = netdev_priv(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()
2696 happy_meal_addr_init(hp, dp, qfe_slot); 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()
2731 err = happy_meal_common_probe(hp, dp); in happy_meal_pci_probe()
2735 pci_set_drvdata(pdev, hp); in happy_meal_pci_probe()