Lines Matching full:hp

110 static __inline__ void tx_add_log(struct happy_meal *hp, unsigned int a, unsigned int s)  in tx_add_log()  argument
118 tlp->tx_new = hp->tx_new; in tx_add_log()
119 tlp->tx_old = hp->tx_old; in tx_add_log()
138 static __inline__ void tx_dump_ring(struct happy_meal *hp) in tx_dump_ring() argument
140 struct hmeal_init_block *hb = hp->happy_block; in tx_dump_ring()
154 #define tx_add_log(hp, a, s) do { } while(0) argument
156 #define tx_dump_ring(hp) do { } while(0) argument
304 static inline u32 hme_read_desc32(struct happy_meal *hp, hme32 *p) in hme_read_desc32() argument
321 static void BB_PUT_BIT(struct happy_meal *hp, void __iomem *tregs, int bit) in BB_PUT_BIT() argument
323 hme_write32(hp, tregs + TCVR_BBDATA, bit); in BB_PUT_BIT()
324 hme_write32(hp, tregs + TCVR_BBCLOCK, 0); in BB_PUT_BIT()
325 hme_write32(hp, tregs + TCVR_BBCLOCK, 1); in BB_PUT_BIT()
329 static u32 BB_GET_BIT(struct happy_meal *hp, void __iomem *tregs, int internal)
333 hme_write32(hp, tregs + TCVR_BBCLOCK, 0);
334 hme_write32(hp, tregs + TCVR_BBCLOCK, 1);
335 ret = hme_read32(hp, tregs + TCVR_CFG);
345 static u32 BB_GET_BIT2(struct happy_meal *hp, void __iomem *tregs, int internal) in BB_GET_BIT2() argument
349 hme_write32(hp, tregs + TCVR_BBCLOCK, 0); in BB_GET_BIT2()
351 retval = hme_read32(hp, tregs + TCVR_CFG); in BB_GET_BIT2()
356 hme_write32(hp, tregs + TCVR_BBCLOCK, 1); in BB_GET_BIT2()
363 static int happy_meal_bb_read(struct happy_meal *hp, in happy_meal_bb_read() argument
373 hme_write32(hp, tregs + TCVR_BBOENAB, 1); in happy_meal_bb_read()
377 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
380 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_read()
381 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
382 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
383 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_read()
386 tmp = hp->paddr & 0xff; in happy_meal_bb_read()
388 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_read()
393 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_read()
396 hme_write32(hp, tregs + TCVR_BBOENAB, 0); in happy_meal_bb_read()
399 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
401 retval |= BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
402 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
403 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
404 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
409 static void happy_meal_bb_write(struct happy_meal *hp, in happy_meal_bb_write() argument
419 hme_write32(hp, tregs + TCVR_BBOENAB, 1); in happy_meal_bb_write()
423 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
426 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
427 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
428 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
429 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
432 tmp = (hp->paddr & 0xff); in happy_meal_bb_write()
434 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_write()
439 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_write()
442 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
443 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
446 BB_PUT_BIT(hp, tregs, ((value >> i) & 1)); in happy_meal_bb_write()
449 hme_write32(hp, tregs + TCVR_BBOENAB, 0); in happy_meal_bb_write()
454 static int happy_meal_tcvr_read(struct happy_meal *hp, in happy_meal_tcvr_read() argument
461 if (hp->tcvr_type == none) { in happy_meal_tcvr_read()
466 if (!(hp->happy_flags & HFLAG_FENABLE)) { in happy_meal_tcvr_read()
468 return happy_meal_bb_read(hp, tregs, reg); in happy_meal_tcvr_read()
471 hme_write32(hp, tregs + TCVR_FRAME, in happy_meal_tcvr_read()
472 (FRAME_READ | (hp->paddr << 23) | ((reg & 0xff) << 18))); in happy_meal_tcvr_read()
473 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries) in happy_meal_tcvr_read()
479 retval = hme_read32(hp, tregs + TCVR_FRAME) & 0xffff; in happy_meal_tcvr_read()
486 static void happy_meal_tcvr_write(struct happy_meal *hp, in happy_meal_tcvr_write() argument
495 if (!(hp->happy_flags & HFLAG_FENABLE)) { in happy_meal_tcvr_write()
496 happy_meal_bb_write(hp, tregs, reg, value); in happy_meal_tcvr_write()
501 hme_write32(hp, tregs + TCVR_FRAME, in happy_meal_tcvr_write()
502 (FRAME_WRITE | (hp->paddr << 23) | in happy_meal_tcvr_write()
504 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries) in happy_meal_tcvr_write()
546 static int try_next_permutation(struct happy_meal *hp, void __iomem *tregs) in try_next_permutation() argument
548 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in try_next_permutation()
553 if (hp->sw_bmcr & BMCR_FULLDPLX) { in try_next_permutation()
554 hp->sw_bmcr &= ~(BMCR_FULLDPLX); in try_next_permutation()
555 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in try_next_permutation()
560 if (hp->sw_bmcr & BMCR_SPEED100) { in try_next_permutation()
561 hp->sw_bmcr &= ~(BMCR_SPEED100); in try_next_permutation()
562 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in try_next_permutation()
570 static void display_link_mode(struct happy_meal *hp, void __iomem *tregs) in display_link_mode() argument
572 printk(KERN_INFO "%s: Link is up using ", hp->dev->name); in display_link_mode()
573 if (hp->tcvr_type == external) in display_link_mode()
578 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in display_link_mode()
579 if (hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) { in display_link_mode()
580 if (hp->sw_lpa & LPA_100FULL) in display_link_mode()
585 if (hp->sw_lpa & LPA_10FULL) in display_link_mode()
592 static void display_forced_link_mode(struct happy_meal *hp, void __iomem *tregs) in display_forced_link_mode() argument
594 printk(KERN_INFO "%s: Link has been forced up using ", hp->dev->name); in display_forced_link_mode()
595 if (hp->tcvr_type == external) in display_forced_link_mode()
600 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in display_forced_link_mode()
601 if (hp->sw_bmcr & BMCR_SPEED100) in display_forced_link_mode()
605 if (hp->sw_bmcr & BMCR_FULLDPLX) in display_forced_link_mode()
611 static int set_happy_link_modes(struct happy_meal *hp, void __iomem *tregs) in set_happy_link_modes() argument
618 if (hp->timer_state == arbwait) { in set_happy_link_modes()
619 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in set_happy_link_modes()
620 if (!(hp->sw_lpa & (LPA_10HALF | LPA_10FULL | LPA_100HALF | LPA_100FULL))) in set_happy_link_modes()
622 if (hp->sw_lpa & LPA_100FULL) in set_happy_link_modes()
624 else if (hp->sw_lpa & LPA_100HALF) in set_happy_link_modes()
626 else if (hp->sw_lpa & LPA_10FULL) in set_happy_link_modes()
632 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in set_happy_link_modes()
633 if (hp->sw_bmcr & BMCR_FULLDPLX) in set_happy_link_modes()
647 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
648 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) & in set_happy_link_modes()
650 while (hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) & BIGMAC_TXCFG_ENABLE) in set_happy_link_modes()
653 hp->happy_flags |= HFLAG_FULL; in set_happy_link_modes()
654 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
655 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) | in set_happy_link_modes()
658 hp->happy_flags &= ~(HFLAG_FULL); in set_happy_link_modes()
659 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
660 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) & in set_happy_link_modes()
663 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
664 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) | in set_happy_link_modes()
671 static int happy_meal_init(struct happy_meal *hp);
673 static int is_lucent_phy(struct happy_meal *hp) in is_lucent_phy() argument
675 void __iomem *tregs = hp->tcvregs; in is_lucent_phy()
679 mr2 = happy_meal_tcvr_read(hp, tregs, 2); in is_lucent_phy()
680 mr3 = happy_meal_tcvr_read(hp, tregs, 3); in is_lucent_phy()
690 struct happy_meal *hp = from_timer(hp, t, happy_timer); in happy_meal_timer() local
691 void __iomem *tregs = hp->tcvregs; in happy_meal_timer()
694 spin_lock_irq(&hp->happy_lock); in happy_meal_timer()
696 hp->timer_ticks++; in happy_meal_timer()
697 switch(hp->timer_state) { in happy_meal_timer()
702 if (hp->timer_ticks >= 10) { in happy_meal_timer()
705 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_timer()
707 hp->dev->name); in happy_meal_timer()
708 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_timer()
709 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_timer()
711 if (!is_lucent_phy(hp)) { in happy_meal_timer()
716 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, DP83840_CSCONFIG); in happy_meal_timer()
717 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_timer()
718 happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
720 hp->timer_state = ltrywait; in happy_meal_timer()
721 hp->timer_ticks = 0; in happy_meal_timer()
725 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
726 if (hp->sw_bmsr & BMSR_ANEGCOMPLETE) { in happy_meal_timer()
730 ret = set_happy_link_modes(hp, tregs); in happy_meal_timer()
742 hp->timer_state = lupwait; in happy_meal_timer()
756 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
757 if (hp->sw_bmsr & BMSR_LSTATUS) { in happy_meal_timer()
761 display_link_mode(hp, tregs); in happy_meal_timer()
762 hp->timer_state = asleep; in happy_meal_timer()
765 if (hp->timer_ticks >= 10) { in happy_meal_timer()
767 "not completely up.\n", hp->dev->name); in happy_meal_timer()
768 hp->timer_ticks = 0; in happy_meal_timer()
782 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
783 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, DP83840_CSCONFIG); in happy_meal_timer()
784 if (hp->timer_ticks == 1) { in happy_meal_timer()
785 if (!is_lucent_phy(hp)) { in happy_meal_timer()
789 hp->sw_csconfig |= CSCONFIG_TCVDISAB; in happy_meal_timer()
790 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
791 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
796 if (hp->timer_ticks == 2) { in happy_meal_timer()
797 if (!is_lucent_phy(hp)) { in happy_meal_timer()
798 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_timer()
799 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
800 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
805 if (hp->sw_bmsr & BMSR_LSTATUS) { in happy_meal_timer()
807 display_forced_link_mode(hp, tregs); in happy_meal_timer()
808 set_happy_link_modes(hp, tregs); /* XXX error? then what? */ in happy_meal_timer()
809 hp->timer_state = asleep; in happy_meal_timer()
812 if (hp->timer_ticks >= 4) { /* 6 seconds or so... */ in happy_meal_timer()
815 ret = try_next_permutation(hp, tregs); in happy_meal_timer()
823 hp->dev->name); in happy_meal_timer()
825 ret = happy_meal_init(hp); in happy_meal_timer()
829 "Happy Meal.\n", hp->dev->name); in happy_meal_timer()
833 if (!is_lucent_phy(hp)) { in happy_meal_timer()
834 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_timer()
836 hp->sw_csconfig |= CSCONFIG_TCVDISAB; in happy_meal_timer()
837 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
838 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
840 hp->timer_ticks = 0; in happy_meal_timer()
852 hp->dev->name); in happy_meal_timer()
854 hp->timer_ticks = 0; in happy_meal_timer()
855 hp->timer_state = asleep; /* foo on you */ in happy_meal_timer()
860 hp->happy_timer.expires = jiffies + ((12 * HZ)/10); /* 1.2 sec. */ in happy_meal_timer()
861 add_timer(&hp->happy_timer); in happy_meal_timer()
865 spin_unlock_irq(&hp->happy_lock); in happy_meal_timer()
871 /* hp->happy_lock must be held */
872 static void happy_meal_tx_reset(struct happy_meal *hp, void __iomem *bregs) in happy_meal_tx_reset() argument
879 hme_write32(hp, bregs + BMAC_TXSWRESET, 0); in happy_meal_tx_reset()
880 while ((hme_read32(hp, bregs + BMAC_TXSWRESET) & 1) && --tries) in happy_meal_tx_reset()
891 /* hp->happy_lock must be held */
892 static void happy_meal_rx_reset(struct happy_meal *hp, void __iomem *bregs) in happy_meal_rx_reset() argument
899 hme_write32(hp, bregs + BMAC_RXSWRESET, 0); in happy_meal_rx_reset()
900 while ((hme_read32(hp, bregs + BMAC_RXSWRESET) & 1) && --tries) in happy_meal_rx_reset()
913 /* hp->happy_lock must be held */
914 static void happy_meal_stop(struct happy_meal *hp, void __iomem *gregs) in happy_meal_stop() argument
921 hme_write32(hp, gregs + GREG_SWRESET, GREG_RESET_ALL); in happy_meal_stop()
922 while (hme_read32(hp, gregs + GREG_SWRESET) && --tries) in happy_meal_stop()
933 /* hp->happy_lock must be held */
934 static void happy_meal_get_counters(struct happy_meal *hp, void __iomem *bregs) in happy_meal_get_counters() argument
936 struct net_device_stats *stats = &hp->dev->stats; in happy_meal_get_counters()
938 stats->rx_crc_errors += hme_read32(hp, bregs + BMAC_RCRCECTR); in happy_meal_get_counters()
939 hme_write32(hp, bregs + BMAC_RCRCECTR, 0); in happy_meal_get_counters()
941 stats->rx_frame_errors += hme_read32(hp, bregs + BMAC_UNALECTR); in happy_meal_get_counters()
942 hme_write32(hp, bregs + BMAC_UNALECTR, 0); in happy_meal_get_counters()
944 stats->rx_length_errors += hme_read32(hp, bregs + BMAC_GLECTR); in happy_meal_get_counters()
945 hme_write32(hp, bregs + BMAC_GLECTR, 0); in happy_meal_get_counters()
947 stats->tx_aborted_errors += hme_read32(hp, bregs + BMAC_EXCTR); in happy_meal_get_counters()
950 (hme_read32(hp, bregs + BMAC_EXCTR) + in happy_meal_get_counters()
951 hme_read32(hp, bregs + BMAC_LTCTR)); in happy_meal_get_counters()
952 hme_write32(hp, bregs + BMAC_EXCTR, 0); in happy_meal_get_counters()
953 hme_write32(hp, bregs + BMAC_LTCTR, 0); in happy_meal_get_counters()
956 /* hp->happy_lock must be held */
957 static void happy_meal_poll_stop(struct happy_meal *hp, void __iomem *tregs) in happy_meal_poll_stop() argument
962 if ((hp->happy_flags & (HFLAG_POLLENABLE | HFLAG_POLL)) != in happy_meal_poll_stop()
970 hme_write32(hp, tregs + TCVR_IMASK, 0xffff); in happy_meal_poll_stop()
974 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_poll_stop()
975 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_PENABLE)); in happy_meal_poll_stop()
978 hp->happy_flags &= ~(HFLAG_POLL); in happy_meal_poll_stop()
991 /* hp->happy_lock must be held */
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()
1001 hme_write32(hp, tregs + TCVR_CFG, tconfig & ~(TCV_CFG_PSELECT)); in happy_meal_tcvr_reset()
1002 hp->tcvr_type = internal; in happy_meal_tcvr_reset()
1003 hp->paddr = TCV_PADDR_ITX; in happy_meal_tcvr_reset()
1005 happy_meal_tcvr_write(hp, tregs, MII_BMCR, in happy_meal_tcvr_reset()
1007 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1013 hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT); in happy_meal_tcvr_reset()
1014 hp->tcvr_type = external; in happy_meal_tcvr_reset()
1015 hp->paddr = TCV_PADDR_ETX; in happy_meal_tcvr_reset()
1019 hme_write32(hp, tregs + TCVR_CFG, (tconfig | TCV_CFG_PSELECT)); in happy_meal_tcvr_reset()
1021 happy_meal_tcvr_write(hp, tregs, MII_BMCR, in happy_meal_tcvr_reset()
1023 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1029 hme_write32(hp, tregs + TCVR_CFG, (tconfig & ~(TCV_CFG_PSELECT))); in happy_meal_tcvr_reset()
1030 hp->tcvr_type = internal; in happy_meal_tcvr_reset()
1031 hp->paddr = TCV_PADDR_ITX; in happy_meal_tcvr_reset()
1036 happy_meal_tcvr_write(hp, tregs, MII_BMCR, BMCR_RESET); in happy_meal_tcvr_reset()
1039 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1042 hp->sw_bmcr = result; in happy_meal_tcvr_reset()
1054 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_tcvr_reset()
1055 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_tcvr_reset()
1056 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_tcvr_reset()
1057 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_tcvr_reset()
1060 hp->sw_bmcr &= ~(BMCR_ISOLATE); in happy_meal_tcvr_reset()
1061 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_tcvr_reset()
1065 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1077 if (!is_lucent_phy(hp)) { in happy_meal_tcvr_reset()
1078 result = happy_meal_tcvr_read(hp, tregs, in happy_meal_tcvr_reset()
1080 happy_meal_tcvr_write(hp, tregs, in happy_meal_tcvr_reset()
1088 * hp->happy_lock must be held
1090 static void happy_meal_transceiver_check(struct happy_meal *hp, void __iomem *tregs) in happy_meal_transceiver_check() argument
1092 unsigned long tconfig = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_transceiver_check()
1095 if (hp->happy_flags & HFLAG_POLL) { in happy_meal_transceiver_check()
1098 if (hp->tcvr_type == internal) { in happy_meal_transceiver_check()
1101 happy_meal_poll_stop(hp, tregs); in happy_meal_transceiver_check()
1102 hp->paddr = TCV_PADDR_ETX; in happy_meal_transceiver_check()
1103 hp->tcvr_type = external; in happy_meal_transceiver_check()
1107 hme_write32(hp, tregs + TCVR_CFG, tconfig); in happy_meal_transceiver_check()
1110 if (hp->tcvr_type == external) { in happy_meal_transceiver_check()
1112 if (!(hme_read32(hp, tregs + TCVR_STATUS) >> 16)) { in happy_meal_transceiver_check()
1114 happy_meal_poll_stop(hp, tregs); in happy_meal_transceiver_check()
1115 hp->paddr = TCV_PADDR_ITX; in happy_meal_transceiver_check()
1116 hp->tcvr_type = internal; in happy_meal_transceiver_check()
1118 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_transceiver_check()
1119 hme_read32(hp, tregs + TCVR_CFG) & in happy_meal_transceiver_check()
1128 u32 reread = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_transceiver_check()
1133 hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT); in happy_meal_transceiver_check()
1134 hp->paddr = TCV_PADDR_ETX; in happy_meal_transceiver_check()
1135 hp->tcvr_type = external; in happy_meal_transceiver_check()
1139 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_transceiver_check()
1141 hp->paddr = TCV_PADDR_ITX; in happy_meal_transceiver_check()
1142 hp->tcvr_type = internal; in happy_meal_transceiver_check()
1146 hp->tcvr_type = none; /* Grrr... */ in happy_meal_transceiver_check()
1197 static void happy_meal_clean_rings(struct happy_meal *hp) in happy_meal_clean_rings() argument
1202 if (hp->rx_skbs[i] != NULL) { in happy_meal_clean_rings()
1203 struct sk_buff *skb = hp->rx_skbs[i]; in happy_meal_clean_rings()
1207 rxd = &hp->happy_block->happy_meal_rxd[i]; in happy_meal_clean_rings()
1208 dma_addr = hme_read_desc32(hp, &rxd->rx_addr); in happy_meal_clean_rings()
1209 dma_unmap_single(hp->dma_dev, dma_addr, in happy_meal_clean_rings()
1212 hp->rx_skbs[i] = NULL; in happy_meal_clean_rings()
1217 if (hp->tx_skbs[i] != NULL) { in happy_meal_clean_rings()
1218 struct sk_buff *skb = hp->tx_skbs[i]; in happy_meal_clean_rings()
1223 hp->tx_skbs[i] = NULL; in happy_meal_clean_rings()
1226 txd = &hp->happy_block->happy_meal_txd[i]; in happy_meal_clean_rings()
1227 dma_addr = hme_read_desc32(hp, &txd->tx_addr); in happy_meal_clean_rings()
1229 dma_unmap_single(hp->dma_dev, dma_addr, in happy_meal_clean_rings()
1230 (hme_read_desc32(hp, &txd->tx_flags) in happy_meal_clean_rings()
1234 dma_unmap_page(hp->dma_dev, dma_addr, in happy_meal_clean_rings()
1235 (hme_read_desc32(hp, &txd->tx_flags) in happy_meal_clean_rings()
1248 /* hp->happy_lock must be held */
1249 static void happy_meal_init_rings(struct happy_meal *hp) in happy_meal_init_rings() argument
1251 struct hmeal_init_block *hb = hp->happy_block; in happy_meal_init_rings()
1255 hp->rx_new = hp->rx_old = hp->tx_new = hp->tx_old = 0; in happy_meal_init_rings()
1259 happy_meal_clean_rings(hp); in happy_meal_init_rings()
1269 hme_write_rxd(hp, &hb->happy_meal_rxd[i], 0, 0); in happy_meal_init_rings()
1272 hp->rx_skbs[i] = skb; in happy_meal_init_rings()
1276 mapping = dma_map_single(hp->dma_dev, skb->data, RX_BUF_ALLOC_SIZE, in happy_meal_init_rings()
1278 if (dma_mapping_error(hp->dma_dev, mapping)) { in happy_meal_init_rings()
1280 hme_write_rxd(hp, &hb->happy_meal_rxd[i], 0, 0); in happy_meal_init_rings()
1283 hme_write_rxd(hp, &hb->happy_meal_rxd[i], in happy_meal_init_rings()
1291 hme_write_txd(hp, &hb->happy_meal_txd[i], 0, 0); in happy_meal_init_rings()
1296 /* hp->happy_lock must be held */
1298 happy_meal_begin_auto_negotiation(struct happy_meal *hp, in happy_meal_begin_auto_negotiation() argument
1305 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_begin_auto_negotiation()
1306 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
1307 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_begin_auto_negotiation()
1308 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_begin_auto_negotiation()
1312 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_begin_auto_negotiation()
1315 if (hp->sw_bmsr & BMSR_10HALF) in happy_meal_begin_auto_negotiation()
1316 hp->sw_advertise |= (ADVERTISE_10HALF); in happy_meal_begin_auto_negotiation()
1318 hp->sw_advertise &= ~(ADVERTISE_10HALF); in happy_meal_begin_auto_negotiation()
1320 if (hp->sw_bmsr & BMSR_10FULL) in happy_meal_begin_auto_negotiation()
1321 hp->sw_advertise |= (ADVERTISE_10FULL); in happy_meal_begin_auto_negotiation()
1323 hp->sw_advertise &= ~(ADVERTISE_10FULL); in happy_meal_begin_auto_negotiation()
1324 if (hp->sw_bmsr & BMSR_100HALF) in happy_meal_begin_auto_negotiation()
1325 hp->sw_advertise |= (ADVERTISE_100HALF); in happy_meal_begin_auto_negotiation()
1327 hp->sw_advertise &= ~(ADVERTISE_100HALF); in happy_meal_begin_auto_negotiation()
1328 if (hp->sw_bmsr & BMSR_100FULL) in happy_meal_begin_auto_negotiation()
1329 hp->sw_advertise |= (ADVERTISE_100FULL); in happy_meal_begin_auto_negotiation()
1331 hp->sw_advertise &= ~(ADVERTISE_100FULL); in happy_meal_begin_auto_negotiation()
1332 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_begin_auto_negotiation()
1341 ASD(("%s: Advertising [ ", hp->dev->name)); in happy_meal_begin_auto_negotiation()
1342 if (hp->sw_advertise & ADVERTISE_10HALF) in happy_meal_begin_auto_negotiation()
1344 if (hp->sw_advertise & ADVERTISE_10FULL) in happy_meal_begin_auto_negotiation()
1346 if (hp->sw_advertise & ADVERTISE_100HALF) in happy_meal_begin_auto_negotiation()
1348 if (hp->sw_advertise & ADVERTISE_100FULL) in happy_meal_begin_auto_negotiation()
1353 hp->sw_bmcr |= BMCR_ANENABLE; in happy_meal_begin_auto_negotiation()
1354 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1357 hp->sw_bmcr |= BMCR_ANRESTART; in happy_meal_begin_auto_negotiation()
1358 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1364 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
1365 if (!(hp->sw_bmcr & BMCR_ANRESTART)) in happy_meal_begin_auto_negotiation()
1371 "BMCR=0x%04x\n", hp->dev->name, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1373 hp->dev->name); in happy_meal_begin_auto_negotiation()
1376 hp->timer_state = arbwait; in happy_meal_begin_auto_negotiation()
1389 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_begin_auto_negotiation()
1392 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_begin_auto_negotiation()
1394 hp->sw_bmcr = 0; in happy_meal_begin_auto_negotiation()
1396 hp->sw_bmcr |= BMCR_FULLDPLX; in happy_meal_begin_auto_negotiation()
1398 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1400 if (!is_lucent_phy(hp)) { in happy_meal_begin_auto_negotiation()
1405 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_begin_auto_negotiation()
1407 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_begin_auto_negotiation()
1408 happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, in happy_meal_begin_auto_negotiation()
1409 hp->sw_csconfig); in happy_meal_begin_auto_negotiation()
1411 hp->timer_state = ltrywait; in happy_meal_begin_auto_negotiation()
1414 hp->timer_ticks = 0; in happy_meal_begin_auto_negotiation()
1415 hp->happy_timer.expires = jiffies + (12 * HZ)/10; /* 1.2 sec. */ in happy_meal_begin_auto_negotiation()
1416 add_timer(&hp->happy_timer); in happy_meal_begin_auto_negotiation()
1419 /* hp->happy_lock must be held */
1420 static int happy_meal_init(struct happy_meal *hp) in happy_meal_init() argument
1422 void __iomem *gregs = hp->gregs; in happy_meal_init()
1423 void __iomem *etxregs = hp->etxregs; in happy_meal_init()
1424 void __iomem *erxregs = hp->erxregs; in happy_meal_init()
1425 void __iomem *bregs = hp->bigmacregs; in happy_meal_init()
1426 void __iomem *tregs = hp->tcvregs; in happy_meal_init()
1428 unsigned char *e = &hp->dev->dev_addr[0]; in happy_meal_init()
1431 del_timer(&hp->happy_timer); in happy_meal_init()
1434 hp->happy_flags)); in happy_meal_init()
1435 if (!(hp->happy_flags & HFLAG_INIT)) { in happy_meal_init()
1437 hp->happy_flags |= HFLAG_INIT; in happy_meal_init()
1438 happy_meal_get_counters(hp, bregs); in happy_meal_init()
1443 happy_meal_poll_stop(hp, tregs); in happy_meal_init()
1447 happy_meal_stop(hp, gregs); in happy_meal_init()
1451 happy_meal_init_rings(hp); in happy_meal_init()
1455 hme_read32(hp, tregs + TCVR_IMASK))); in happy_meal_init()
1456 hme_write32(hp, tregs + TCVR_IMASK, 0xffff); in happy_meal_init()
1459 if (hp->happy_flags & HFLAG_FENABLE) { in happy_meal_init()
1461 hme_read32(hp, tregs + TCVR_CFG))); in happy_meal_init()
1462 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_init()
1463 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE)); in happy_meal_init()
1466 hme_read32(hp, tregs + TCVR_CFG))); in happy_meal_init()
1467 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_init()
1468 hme_read32(hp, tregs + TCVR_CFG) | TCV_CFG_BENABLE); in happy_meal_init()
1473 happy_meal_transceiver_check(hp, tregs); in happy_meal_init()
1477 switch(hp->tcvr_type) { in happy_meal_init()
1486 hme_write32(hp, bregs + BMAC_XIFCFG, 0); in happy_meal_init()
1492 hme_write32(hp, bregs + BMAC_XIFCFG, BIGMAC_XCFG_MIIDISAB); in happy_meal_init()
1496 if (happy_meal_tcvr_reset(hp, tregs)) in happy_meal_init()
1501 happy_meal_tx_reset(hp, bregs); in happy_meal_init()
1502 happy_meal_rx_reset(hp, bregs); in happy_meal_init()
1506 hme_write32(hp, bregs + BMAC_JSIZE, DEFAULT_JAMSIZE); in happy_meal_init()
1507 hme_write32(hp, bregs + BMAC_IGAP1, DEFAULT_IPG1); in happy_meal_init()
1508 hme_write32(hp, bregs + BMAC_IGAP2, DEFAULT_IPG2); in happy_meal_init()
1514 hme_write32(hp, bregs + BMAC_RSEED, ((e[5] | e[4]<<8)&0x3ff)); in happy_meal_init()
1516 hme_write32(hp, bregs + BMAC_MACADDR2, ((e[4] << 8) | e[5])); in happy_meal_init()
1517 hme_write32(hp, bregs + BMAC_MACADDR1, ((e[2] << 8) | e[3])); in happy_meal_init()
1518 hme_write32(hp, bregs + BMAC_MACADDR0, ((e[0] << 8) | e[1])); in happy_meal_init()
1521 if ((hp->dev->flags & IFF_ALLMULTI) || in happy_meal_init()
1522 (netdev_mc_count(hp->dev) > 64)) { in happy_meal_init()
1523 hme_write32(hp, bregs + BMAC_HTABLE0, 0xffff); in happy_meal_init()
1524 hme_write32(hp, bregs + BMAC_HTABLE1, 0xffff); in happy_meal_init()
1525 hme_write32(hp, bregs + BMAC_HTABLE2, 0xffff); in happy_meal_init()
1526 hme_write32(hp, bregs + BMAC_HTABLE3, 0xffff); in happy_meal_init()
1527 } else if ((hp->dev->flags & IFF_PROMISC) == 0) { in happy_meal_init()
1533 netdev_for_each_mc_addr(ha, hp->dev) { in happy_meal_init()
1538 hme_write32(hp, bregs + BMAC_HTABLE0, hash_table[0]); in happy_meal_init()
1539 hme_write32(hp, bregs + BMAC_HTABLE1, hash_table[1]); in happy_meal_init()
1540 hme_write32(hp, bregs + BMAC_HTABLE2, hash_table[2]); in happy_meal_init()
1541 hme_write32(hp, bregs + BMAC_HTABLE3, hash_table[3]); in happy_meal_init()
1543 hme_write32(hp, bregs + BMAC_HTABLE3, 0); in happy_meal_init()
1544 hme_write32(hp, bregs + BMAC_HTABLE2, 0); in happy_meal_init()
1545 hme_write32(hp, bregs + BMAC_HTABLE1, 0); in happy_meal_init()
1546 hme_write32(hp, bregs + BMAC_HTABLE0, 0); in happy_meal_init()
1551 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0)), in happy_meal_init()
1552 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_txd, 0)))); in happy_meal_init()
1553 hme_write32(hp, erxregs + ERX_RING, in happy_meal_init()
1554 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0))); in happy_meal_init()
1555 hme_write32(hp, etxregs + ETX_RING, in happy_meal_init()
1556 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_txd, 0))); in happy_meal_init()
1563 if (hme_read32(hp, erxregs + ERX_RING) != in happy_meal_init()
1564 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0))) in happy_meal_init()
1565 hme_write32(hp, erxregs + ERX_RING, in happy_meal_init()
1566 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0)) in happy_meal_init()
1571 hme_read32(hp, gregs + GREG_CFG))); in happy_meal_init()
1575 hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST64); in happy_meal_init()
1577 if ((hp->happy_bursts & DMA_BURST64) && in happy_meal_init()
1578 ((hp->happy_flags & HFLAG_PCI) != 0 in happy_meal_init()
1590 if ((hp->happy_flags & HFLAG_PCI) == 0) { in happy_meal_init()
1591 struct platform_device *op = hp->happy_dev; in happy_meal_init()
1594 hp->happy_bursts); in happy_meal_init()
1601 hme_write32(hp, gregs + GREG_CFG, gcfg); in happy_meal_init()
1602 } else if (hp->happy_bursts & DMA_BURST32) { in happy_meal_init()
1604 hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST32); in happy_meal_init()
1605 } else if (hp->happy_bursts & DMA_BURST16) { in happy_meal_init()
1607 hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST16); in happy_meal_init()
1610 hme_write32(hp, gregs + GREG_CFG, 0); in happy_meal_init()
1616 hme_write32(hp, gregs + GREG_IMASK, in happy_meal_init()
1622 hme_read32(hp, etxregs + ETX_RSIZE))); in happy_meal_init()
1623 hme_write32(hp, etxregs + ETX_RSIZE, (TX_RING_SIZE >> ETX_RSIZE_SHIFT) - 1); in happy_meal_init()
1627 hme_read32(hp, etxregs + ETX_CFG))); in happy_meal_init()
1628 hme_write32(hp, etxregs + ETX_CFG, in happy_meal_init()
1629 hme_read32(hp, etxregs + ETX_CFG) | ETX_CFG_DMAENABLE); in happy_meal_init()
1637 hme_read32(hp, erxregs + ERX_CFG))); in happy_meal_init()
1638 hme_write32(hp, erxregs + ERX_CFG, ERX_CFG_DEFAULT(RX_OFFSET)); in happy_meal_init()
1639 regtmp = hme_read32(hp, erxregs + ERX_CFG); in happy_meal_init()
1640 hme_write32(hp, erxregs + ERX_CFG, ERX_CFG_DEFAULT(RX_OFFSET)); in happy_meal_init()
1641 if (hme_read32(hp, erxregs + ERX_CFG) != ERX_CFG_DEFAULT(RX_OFFSET)) { in happy_meal_init()
1650 hme_read32(hp, bregs + BMAC_RXCFG))); in happy_meal_init()
1652 if (hp->dev->flags & IFF_PROMISC) in happy_meal_init()
1654 hme_write32(hp, bregs + BMAC_RXCFG, rxcfg); in happy_meal_init()
1662 if (hp->happy_flags & HFLAG_FULL) in happy_meal_init()
1668 hme_write32(hp, bregs + BMAC_TXCFG, regtmp /*| BIGMAC_TXCFG_DGIVEUP*/); in happy_meal_init()
1671 hme_write32(hp, bregs + BMAC_ALIMIT, 16); in happy_meal_init()
1677 if (hp->happy_flags & HFLAG_LANCE) in happy_meal_init()
1681 if (hp->tcvr_type == external) in happy_meal_init()
1685 hme_read32(hp, bregs + BMAC_XIFCFG))); in happy_meal_init()
1686 hme_write32(hp, bregs + BMAC_XIFCFG, regtmp); in happy_meal_init()
1690 hme_read32(hp, bregs + BMAC_TXCFG), in happy_meal_init()
1691 hme_read32(hp, bregs + BMAC_RXCFG))); in happy_meal_init()
1694 hme_write32(hp, bregs + BMAC_TXMAX, ETH_FRAME_LEN + 8); in happy_meal_init()
1695 hme_write32(hp, bregs + BMAC_RXMAX, ETH_FRAME_LEN + 8); in happy_meal_init()
1697 hme_write32(hp, bregs + BMAC_TXCFG, in happy_meal_init()
1698 hme_read32(hp, bregs + BMAC_TXCFG) | BIGMAC_TXCFG_ENABLE); in happy_meal_init()
1699 hme_write32(hp, bregs + BMAC_RXCFG, in happy_meal_init()
1700 hme_read32(hp, bregs + BMAC_RXCFG) | BIGMAC_RXCFG_ENABLE); in happy_meal_init()
1703 happy_meal_begin_auto_negotiation(hp, tregs, NULL); in happy_meal_init()
1709 /* hp->happy_lock must be held */
1710 static void happy_meal_set_initial_advertisement(struct happy_meal *hp) in happy_meal_set_initial_advertisement() argument
1712 void __iomem *tregs = hp->tcvregs; in happy_meal_set_initial_advertisement()
1713 void __iomem *bregs = hp->bigmacregs; in happy_meal_set_initial_advertisement()
1714 void __iomem *gregs = hp->gregs; in happy_meal_set_initial_advertisement()
1716 happy_meal_stop(hp, gregs); in happy_meal_set_initial_advertisement()
1717 hme_write32(hp, tregs + TCVR_IMASK, 0xffff); in happy_meal_set_initial_advertisement()
1718 if (hp->happy_flags & HFLAG_FENABLE) in happy_meal_set_initial_advertisement()
1719 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_set_initial_advertisement()
1720 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE)); in happy_meal_set_initial_advertisement()
1722 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_set_initial_advertisement()
1723 hme_read32(hp, tregs + TCVR_CFG) | TCV_CFG_BENABLE); in happy_meal_set_initial_advertisement()
1724 happy_meal_transceiver_check(hp, tregs); in happy_meal_set_initial_advertisement()
1725 switch(hp->tcvr_type) { in happy_meal_set_initial_advertisement()
1729 hme_write32(hp, bregs + BMAC_XIFCFG, 0); in happy_meal_set_initial_advertisement()
1732 hme_write32(hp, bregs + BMAC_XIFCFG, BIGMAC_XCFG_MIIDISAB); in happy_meal_set_initial_advertisement()
1735 if (happy_meal_tcvr_reset(hp, tregs)) in happy_meal_set_initial_advertisement()
1739 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_set_initial_advertisement()
1740 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_set_initial_advertisement()
1743 if (hp->sw_bmsr & BMSR_10HALF) in happy_meal_set_initial_advertisement()
1744 hp->sw_advertise |= (ADVERTISE_10HALF); in happy_meal_set_initial_advertisement()
1746 hp->sw_advertise &= ~(ADVERTISE_10HALF); in happy_meal_set_initial_advertisement()
1748 if (hp->sw_bmsr & BMSR_10FULL) in happy_meal_set_initial_advertisement()
1749 hp->sw_advertise |= (ADVERTISE_10FULL); in happy_meal_set_initial_advertisement()
1751 hp->sw_advertise &= ~(ADVERTISE_10FULL); in happy_meal_set_initial_advertisement()
1752 if (hp->sw_bmsr & BMSR_100HALF) in happy_meal_set_initial_advertisement()
1753 hp->sw_advertise |= (ADVERTISE_100HALF); in happy_meal_set_initial_advertisement()
1755 hp->sw_advertise &= ~(ADVERTISE_100HALF); in happy_meal_set_initial_advertisement()
1756 if (hp->sw_bmsr & BMSR_100FULL) in happy_meal_set_initial_advertisement()
1757 hp->sw_advertise |= (ADVERTISE_100FULL); in happy_meal_set_initial_advertisement()
1759 hp->sw_advertise &= ~(ADVERTISE_100FULL); in happy_meal_set_initial_advertisement()
1762 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_set_initial_advertisement()
1768 * hp->happy_lock must be held
1770 static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status) in happy_meal_is_not_so_happy() argument
1782 hp->dev->name, status); in happy_meal_is_not_so_happy()
1787 printk(KERN_DEBUG "%s: Happy Meal receive FIFO overflow.\n", hp->dev->name); in happy_meal_is_not_so_happy()
1792 printk(KERN_ERR "%s: Happy Meal BigMAC SQE test failed.\n", hp->dev->name); in happy_meal_is_not_so_happy()
1799 hp->dev->name); in happy_meal_is_not_so_happy()
1807 printk(KERN_ERR "%s: Happy Meal MAX Packet size error.\n", hp->dev->name); in happy_meal_is_not_so_happy()
1819 hp->dev->name); in happy_meal_is_not_so_happy()
1824 printk(KERN_ERR "%s: Happy Meal rx DMA errors [ ", hp->dev->name); in happy_meal_is_not_so_happy()
1840 hp->dev->name); in happy_meal_is_not_so_happy()
1846 printk(KERN_ERR "%s: Happy Meal MIF interrupt.\n", hp->dev->name); in happy_meal_is_not_so_happy()
1852 printk(KERN_ERR "%s: Happy Meal tx DMA errors [ ", hp->dev->name); in happy_meal_is_not_so_happy()
1870 hp->dev->name, in happy_meal_is_not_so_happy()
1876 printk(KERN_NOTICE "%s: Resetting...\n", hp->dev->name); in happy_meal_is_not_so_happy()
1877 happy_meal_init(hp); in happy_meal_is_not_so_happy()
1883 /* hp->happy_lock must be held */
1884 static void happy_meal_mif_interrupt(struct happy_meal *hp) in happy_meal_mif_interrupt() argument
1886 void __iomem *tregs = hp->tcvregs; in happy_meal_mif_interrupt()
1888 printk(KERN_INFO "%s: Link status change.\n", hp->dev->name); in happy_meal_mif_interrupt()
1889 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_mif_interrupt()
1890 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in happy_meal_mif_interrupt()
1893 if (hp->sw_lpa & LPA_100FULL) { in happy_meal_mif_interrupt()
1894 printk(KERN_INFO "%s: Switching to 100Mbps at full duplex.", hp->dev->name); in happy_meal_mif_interrupt()
1895 hp->sw_bmcr |= (BMCR_FULLDPLX | BMCR_SPEED100); in happy_meal_mif_interrupt()
1896 } else if (hp->sw_lpa & LPA_100HALF) { in happy_meal_mif_interrupt()
1897 printk(KERN_INFO "%s: Switching to 100MBps at half duplex.", hp->dev->name); in happy_meal_mif_interrupt()
1898 hp->sw_bmcr |= BMCR_SPEED100; in happy_meal_mif_interrupt()
1899 } else if (hp->sw_lpa & LPA_10FULL) { in happy_meal_mif_interrupt()
1900 printk(KERN_INFO "%s: Switching to 10MBps at full duplex.", hp->dev->name); in happy_meal_mif_interrupt()
1901 hp->sw_bmcr |= BMCR_FULLDPLX; in happy_meal_mif_interrupt()
1903 printk(KERN_INFO "%s: Using 10Mbps at half duplex.", hp->dev->name); in happy_meal_mif_interrupt()
1905 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_mif_interrupt()
1908 happy_meal_poll_stop(hp, tregs); in happy_meal_mif_interrupt()
1917 /* hp->happy_lock must be held */
1918 static void happy_meal_tx(struct happy_meal *hp) in happy_meal_tx() argument
1920 struct happy_meal_txd *txbase = &hp->happy_block->happy_meal_txd[0]; in happy_meal_tx()
1922 struct net_device *dev = hp->dev; in happy_meal_tx()
1925 elem = hp->tx_old; in happy_meal_tx()
1927 while (elem != hp->tx_new) { in happy_meal_tx()
1934 flags = hme_read_desc32(hp, &this->tx_flags); in happy_meal_tx()
1937 skb = hp->tx_skbs[elem]; in happy_meal_tx()
1943 flags = hme_read_desc32(hp, &txbase[last].tx_flags); in happy_meal_tx()
1947 hp->tx_skbs[elem] = NULL; in happy_meal_tx()
1951 dma_addr = hme_read_desc32(hp, &this->tx_addr); in happy_meal_tx()
1952 dma_len = hme_read_desc32(hp, &this->tx_flags); in happy_meal_tx()
1956 dma_unmap_single(hp->dma_dev, dma_addr, dma_len, DMA_TO_DEVICE); in happy_meal_tx()
1958 dma_unmap_page(hp->dma_dev, dma_addr, dma_len, DMA_TO_DEVICE); in happy_meal_tx()
1967 hp->tx_old = elem; in happy_meal_tx()
1971 TX_BUFFS_AVAIL(hp) > (MAX_SKB_FRAGS + 1)) in happy_meal_tx()
1988 * hp->happy_lock must be held
1990 static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev) in happy_meal_rx() argument
1992 struct happy_meal_rxd *rxbase = &hp->happy_block->happy_meal_rxd[0]; in happy_meal_rx()
1994 int elem = hp->rx_new, drops = 0; in happy_meal_rx()
1999 while (!((flags = hme_read_desc32(hp, &this->rx_flags)) & RXFLAG_OWN)) { in happy_meal_rx()
2003 u32 dma_addr = hme_read_desc32(hp, &this->rx_addr); in happy_meal_rx()
2021 hme_write_rxd(hp, this, in happy_meal_rx()
2026 skb = hp->rx_skbs[elem]; in happy_meal_rx()
2038 mapping = dma_map_single(hp->dma_dev, new_skb->data, in happy_meal_rx()
2041 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) { in happy_meal_rx()
2047 dma_unmap_single(hp->dma_dev, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE); in happy_meal_rx()
2048 hp->rx_skbs[elem] = new_skb; in happy_meal_rx()
2049 hme_write_rxd(hp, this, in happy_meal_rx()
2066 dma_sync_single_for_cpu(hp->dma_dev, dma_addr, len, DMA_FROM_DEVICE); in happy_meal_rx()
2068 dma_sync_single_for_device(hp->dma_dev, dma_addr, len, DMA_FROM_DEVICE); in happy_meal_rx()
2070 hme_write_rxd(hp, this, in happy_meal_rx()
2091 hp->rx_new = elem; in happy_meal_rx()
2093 printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n", hp->dev->name); in happy_meal_rx()
2100 struct happy_meal *hp = netdev_priv(dev); in happy_meal_interrupt() local
2101 u32 happy_status = hme_read32(hp, hp->gregs + GREG_STAT); in happy_meal_interrupt()
2105 spin_lock(&hp->happy_lock); in happy_meal_interrupt()
2109 if (happy_meal_is_not_so_happy(hp, /* un- */ happy_status)) in happy_meal_interrupt()
2115 happy_meal_mif_interrupt(hp); in happy_meal_interrupt()
2120 happy_meal_tx(hp); in happy_meal_interrupt()
2125 happy_meal_rx(hp, dev); in happy_meal_interrupt()
2130 spin_unlock(&hp->happy_lock); in happy_meal_interrupt()
2143 struct happy_meal *hp = netdev_priv(dev); in quattro_sbus_interrupt() local
2144 u32 happy_status = hme_read32(hp, hp->gregs + GREG_STAT); in quattro_sbus_interrupt()
2154 spin_lock(&hp->happy_lock); in quattro_sbus_interrupt()
2158 if (happy_meal_is_not_so_happy(hp, happy_status)) in quattro_sbus_interrupt()
2164 happy_meal_mif_interrupt(hp); in quattro_sbus_interrupt()
2169 happy_meal_tx(hp); in quattro_sbus_interrupt()
2174 happy_meal_rx(hp, dev); in quattro_sbus_interrupt()
2178 spin_unlock(&hp->happy_lock); in quattro_sbus_interrupt()
2188 struct happy_meal *hp = netdev_priv(dev); in happy_meal_open() local
2196 if ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO) { in happy_meal_open()
2197 res = request_irq(hp->irq, happy_meal_interrupt, IRQF_SHARED, in happy_meal_open()
2202 hp->irq); in happy_meal_open()
2210 spin_lock_irq(&hp->happy_lock); in happy_meal_open()
2211 res = happy_meal_init(hp); in happy_meal_open()
2212 spin_unlock_irq(&hp->happy_lock); in happy_meal_open()
2214 if (res && ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO)) in happy_meal_open()
2215 free_irq(hp->irq, dev); in happy_meal_open()
2221 struct happy_meal *hp = netdev_priv(dev); in happy_meal_close() local
2223 spin_lock_irq(&hp->happy_lock); in happy_meal_close()
2224 happy_meal_stop(hp, hp->gregs); in happy_meal_close()
2225 happy_meal_clean_rings(hp); in happy_meal_close()
2228 del_timer(&hp->happy_timer); in happy_meal_close()
2230 spin_unlock_irq(&hp->happy_lock); in happy_meal_close()
2236 if ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO) in happy_meal_close()
2237 free_irq(hp->irq, dev); in happy_meal_close()
2250 struct happy_meal *hp = netdev_priv(dev); in happy_meal_tx_timeout() local
2255 hme_read32(hp, hp->gregs + GREG_STAT), in happy_meal_tx_timeout()
2256 hme_read32(hp, hp->etxregs + ETX_CFG), in happy_meal_tx_timeout()
2257 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG)); in happy_meal_tx_timeout()
2259 spin_lock_irq(&hp->happy_lock); in happy_meal_tx_timeout()
2260 happy_meal_init(hp); in happy_meal_tx_timeout()
2261 spin_unlock_irq(&hp->happy_lock); in happy_meal_tx_timeout()
2266 static void unmap_partial_tx_skb(struct happy_meal *hp, u32 first_mapping, in unmap_partial_tx_skb() argument
2269 struct happy_meal_txd *txbase = &hp->happy_block->happy_meal_txd[0]; in unmap_partial_tx_skb()
2271 dma_unmap_single(hp->dma_dev, first_mapping, first_len, DMA_TO_DEVICE); in unmap_partial_tx_skb()
2278 addr = hme_read_desc32(hp, &this->tx_addr); in unmap_partial_tx_skb()
2279 len = hme_read_desc32(hp, &this->tx_flags); in unmap_partial_tx_skb()
2281 dma_unmap_page(hp->dma_dev, addr, len, DMA_TO_DEVICE); in unmap_partial_tx_skb()
2288 struct happy_meal *hp = netdev_priv(dev); in happy_meal_start_xmit() local
2302 spin_lock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2304 if (TX_BUFFS_AVAIL(hp) <= (skb_shinfo(skb)->nr_frags + 1)) { in happy_meal_start_xmit()
2306 spin_unlock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2312 entry = hp->tx_new; in happy_meal_start_xmit()
2314 hp->tx_skbs[entry] = skb; in happy_meal_start_xmit()
2320 mapping = dma_map_single(hp->dma_dev, skb->data, len, DMA_TO_DEVICE); in happy_meal_start_xmit()
2321 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) in happy_meal_start_xmit()
2324 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], in happy_meal_start_xmit()
2336 first_mapping = dma_map_single(hp->dma_dev, skb->data, first_len, in happy_meal_start_xmit()
2338 if (unlikely(dma_mapping_error(hp->dma_dev, first_mapping))) in happy_meal_start_xmit()
2347 mapping = skb_frag_dma_map(hp->dma_dev, this_frag, in happy_meal_start_xmit()
2349 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) { in happy_meal_start_xmit()
2350 unmap_partial_tx_skb(hp, first_mapping, first_len, in happy_meal_start_xmit()
2357 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], in happy_meal_start_xmit()
2362 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[first_entry], in happy_meal_start_xmit()
2367 hp->tx_new = entry; in happy_meal_start_xmit()
2369 if (TX_BUFFS_AVAIL(hp) <= (MAX_SKB_FRAGS + 1)) in happy_meal_start_xmit()
2373 hme_write32(hp, hp->etxregs + ETX_PENDING, ETX_TP_DMAWAKEUP); in happy_meal_start_xmit()
2375 spin_unlock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2377 tx_add_log(hp, TXLOG_ACTION_TXMIT, 0); in happy_meal_start_xmit()
2381 hp->tx_skbs[hp->tx_new] = NULL; in happy_meal_start_xmit()
2382 spin_unlock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2391 struct happy_meal *hp = netdev_priv(dev); in happy_meal_get_stats() local
2393 spin_lock_irq(&hp->happy_lock); in happy_meal_get_stats()
2394 happy_meal_get_counters(hp, hp->bigmacregs); in happy_meal_get_stats()
2395 spin_unlock_irq(&hp->happy_lock); in happy_meal_get_stats()
2402 struct happy_meal *hp = netdev_priv(dev); in happy_meal_set_multicast() local
2403 void __iomem *bregs = hp->bigmacregs; in happy_meal_set_multicast()
2407 spin_lock_irq(&hp->happy_lock); in happy_meal_set_multicast()
2410 hme_write32(hp, bregs + BMAC_HTABLE0, 0xffff); in happy_meal_set_multicast()
2411 hme_write32(hp, bregs + BMAC_HTABLE1, 0xffff); in happy_meal_set_multicast()
2412 hme_write32(hp, bregs + BMAC_HTABLE2, 0xffff); in happy_meal_set_multicast()
2413 hme_write32(hp, bregs + BMAC_HTABLE3, 0xffff); in happy_meal_set_multicast()
2415 hme_write32(hp, bregs + BMAC_RXCFG, in happy_meal_set_multicast()
2416 hme_read32(hp, bregs + BMAC_RXCFG) | BIGMAC_RXCFG_PMISC); in happy_meal_set_multicast()
2426 hme_write32(hp, bregs + BMAC_HTABLE0, hash_table[0]); in happy_meal_set_multicast()
2427 hme_write32(hp, bregs + BMAC_HTABLE1, hash_table[1]); in happy_meal_set_multicast()
2428 hme_write32(hp, bregs + BMAC_HTABLE2, hash_table[2]); in happy_meal_set_multicast()
2429 hme_write32(hp, bregs + BMAC_HTABLE3, hash_table[3]); in happy_meal_set_multicast()
2432 spin_unlock_irq(&hp->happy_lock); in happy_meal_set_multicast()
2439 struct happy_meal *hp = netdev_priv(dev); in hme_get_link_ksettings() local
2453 spin_lock_irq(&hp->happy_lock); in hme_get_link_ksettings()
2454 hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR); in hme_get_link_ksettings()
2455 hp->sw_lpa = happy_meal_tcvr_read(hp, hp->tcvregs, MII_LPA); in hme_get_link_ksettings()
2456 spin_unlock_irq(&hp->happy_lock); in hme_get_link_ksettings()
2458 if (hp->sw_bmcr & BMCR_ANENABLE) { in hme_get_link_ksettings()
2460 speed = ((hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ? in hme_get_link_ksettings()
2464 (hp->sw_lpa & (LPA_100FULL)) ? in hme_get_link_ksettings()
2468 (hp->sw_lpa & (LPA_10FULL)) ? in hme_get_link_ksettings()
2472 speed = (hp->sw_bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10; in hme_get_link_ksettings()
2474 (hp->sw_bmcr & BMCR_FULLDPLX) ? in hme_get_link_ksettings()
2487 struct happy_meal *hp = netdev_priv(dev); in hme_set_link_ksettings() local
2501 spin_lock_irq(&hp->happy_lock); in hme_set_link_ksettings()
2502 del_timer(&hp->happy_timer); in hme_set_link_ksettings()
2503 happy_meal_begin_auto_negotiation(hp, hp->tcvregs, cmd); in hme_set_link_ksettings()
2504 spin_unlock_irq(&hp->happy_lock); in hme_set_link_ksettings()
2511 struct happy_meal *hp = netdev_priv(dev); in hme_get_drvinfo() local
2515 if (hp->happy_flags & HFLAG_PCI) { in hme_get_drvinfo()
2516 struct pci_dev *pdev = hp->happy_dev; in hme_get_drvinfo()
2522 struct platform_device *op = hp->happy_dev; in hme_get_drvinfo()
2534 struct happy_meal *hp = netdev_priv(dev); in hme_get_link() local
2536 spin_lock_irq(&hp->happy_lock); in hme_get_link()
2537 hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR); in hme_get_link()
2538 spin_unlock_irq(&hp->happy_lock); in hme_get_link()
2540 return hp->sw_bmsr & BMSR_LSTATUS; in hme_get_link()
2685 struct happy_meal *hp; in happy_meal_sbus_probe_one() local
2739 hp = netdev_priv(dev); in happy_meal_sbus_probe_one()
2741 hp->happy_dev = op; in happy_meal_sbus_probe_one()
2742 hp->dma_dev = &op->dev; in happy_meal_sbus_probe_one()
2744 spin_lock_init(&hp->happy_lock); in happy_meal_sbus_probe_one()
2748 hp->qfe_parent = qp; in happy_meal_sbus_probe_one()
2749 hp->qfe_ent = qfe_slot; in happy_meal_sbus_probe_one()
2753 hp->gregs = of_ioremap(&op->resource[0], 0, in happy_meal_sbus_probe_one()
2755 if (!hp->gregs) { in happy_meal_sbus_probe_one()
2760 hp->etxregs = of_ioremap(&op->resource[1], 0, in happy_meal_sbus_probe_one()
2762 if (!hp->etxregs) { in happy_meal_sbus_probe_one()
2767 hp->erxregs = of_ioremap(&op->resource[2], 0, in happy_meal_sbus_probe_one()
2769 if (!hp->erxregs) { in happy_meal_sbus_probe_one()
2774 hp->bigmacregs = of_ioremap(&op->resource[3], 0, in happy_meal_sbus_probe_one()
2776 if (!hp->bigmacregs) { in happy_meal_sbus_probe_one()
2781 hp->tcvregs = of_ioremap(&op->resource[4], 0, in happy_meal_sbus_probe_one()
2783 if (!hp->tcvregs) { in happy_meal_sbus_probe_one()
2788 hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); in happy_meal_sbus_probe_one()
2789 if (hp->hm_revision == 0xff) in happy_meal_sbus_probe_one()
2790 hp->hm_revision = 0xa0; in happy_meal_sbus_probe_one()
2793 if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21) in happy_meal_sbus_probe_one()
2794 hp->happy_flags = HFLAG_20_21; in happy_meal_sbus_probe_one()
2795 else if (hp->hm_revision != 0xa0) in happy_meal_sbus_probe_one()
2796 hp->happy_flags = HFLAG_NOT_A0; in happy_meal_sbus_probe_one()
2799 hp->happy_flags |= HFLAG_QUATTRO; in happy_meal_sbus_probe_one()
2802 hp->happy_bursts = of_getintprop_default(sbus_dp, in happy_meal_sbus_probe_one()
2805 hp->happy_block = dma_alloc_coherent(hp->dma_dev, in happy_meal_sbus_probe_one()
2807 &hp->hblock_dvma, in happy_meal_sbus_probe_one()
2810 if (!hp->happy_block) in happy_meal_sbus_probe_one()
2814 hp->linkcheck = 0; in happy_meal_sbus_probe_one()
2817 hp->timer_state = asleep; in happy_meal_sbus_probe_one()
2818 hp->timer_ticks = 0; in happy_meal_sbus_probe_one()
2820 timer_setup(&hp->happy_timer, happy_meal_timer, 0); in happy_meal_sbus_probe_one()
2822 hp->dev = dev; in happy_meal_sbus_probe_one()
2831 hp->irq = op->archdata.irqs[0]; in happy_meal_sbus_probe_one()
2835 hp->read_desc32 = sbus_hme_read_desc32; in happy_meal_sbus_probe_one()
2836 hp->write_txd = sbus_hme_write_txd; in happy_meal_sbus_probe_one()
2837 hp->write_rxd = sbus_hme_write_rxd; in happy_meal_sbus_probe_one()
2838 hp->read32 = sbus_hme_read32; in happy_meal_sbus_probe_one()
2839 hp->write32 = sbus_hme_write32; in happy_meal_sbus_probe_one()
2845 spin_lock_irq(&hp->happy_lock); in happy_meal_sbus_probe_one()
2846 happy_meal_set_initial_advertisement(hp); in happy_meal_sbus_probe_one()
2847 spin_unlock_irq(&hp->happy_lock); in happy_meal_sbus_probe_one()
2849 err = register_netdev(hp->dev); in happy_meal_sbus_probe_one()
2856 platform_set_drvdata(op, hp); in happy_meal_sbus_probe_one()
2870 dma_free_coherent(hp->dma_dev, in happy_meal_sbus_probe_one()
2872 hp->happy_block, in happy_meal_sbus_probe_one()
2873 hp->hblock_dvma); in happy_meal_sbus_probe_one()
2876 if (hp->gregs) in happy_meal_sbus_probe_one()
2877 of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); in happy_meal_sbus_probe_one()
2878 if (hp->etxregs) in happy_meal_sbus_probe_one()
2879 of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); in happy_meal_sbus_probe_one()
2880 if (hp->erxregs) in happy_meal_sbus_probe_one()
2881 of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); in happy_meal_sbus_probe_one()
2882 if (hp->bigmacregs) in happy_meal_sbus_probe_one()
2883 of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); in happy_meal_sbus_probe_one()
2884 if (hp->tcvregs) in happy_meal_sbus_probe_one()
2885 of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); in happy_meal_sbus_probe_one()
2990 struct happy_meal *hp; in happy_meal_pci_probe() local
3035 hp = netdev_priv(dev); in happy_meal_pci_probe()
3037 hp->happy_dev = pdev; in happy_meal_pci_probe()
3038 hp->dma_dev = &pdev->dev; in happy_meal_pci_probe()
3040 spin_lock_init(&hp->happy_lock); in happy_meal_pci_probe()
3043 hp->qfe_parent = qp; in happy_meal_pci_probe()
3044 hp->qfe_ent = qfe_slot; in happy_meal_pci_probe()
3092 hp->gregs = (hpreg_base + 0x0000UL); in happy_meal_pci_probe()
3093 hp->etxregs = (hpreg_base + 0x2000UL); in happy_meal_pci_probe()
3094 hp->erxregs = (hpreg_base + 0x4000UL); in happy_meal_pci_probe()
3095 hp->bigmacregs = (hpreg_base + 0x6000UL); in happy_meal_pci_probe()
3096 hp->tcvregs = (hpreg_base + 0x7000UL); in happy_meal_pci_probe()
3099 hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); in happy_meal_pci_probe()
3100 if (hp->hm_revision == 0xff) in happy_meal_pci_probe()
3101 hp->hm_revision = 0xc0 | (pdev->revision & 0x0f); in happy_meal_pci_probe()
3104 hp->hm_revision = 0x20; in happy_meal_pci_probe()
3108 if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21) in happy_meal_pci_probe()
3109 hp->happy_flags = HFLAG_20_21; in happy_meal_pci_probe()
3110 else if (hp->hm_revision != 0xa0 && hp->hm_revision != 0xc0) in happy_meal_pci_probe()
3111 hp->happy_flags = HFLAG_NOT_A0; in happy_meal_pci_probe()
3114 hp->happy_flags |= HFLAG_QUATTRO; in happy_meal_pci_probe()
3117 hp->happy_flags |= HFLAG_PCI; in happy_meal_pci_probe()
3121 hp->happy_bursts = DMA_BURSTBITS; in happy_meal_pci_probe()
3124 hp->happy_block = dma_alloc_coherent(&pdev->dev, PAGE_SIZE, in happy_meal_pci_probe()
3125 &hp->hblock_dvma, GFP_KERNEL); in happy_meal_pci_probe()
3127 if (!hp->happy_block) in happy_meal_pci_probe()
3130 hp->linkcheck = 0; in happy_meal_pci_probe()
3131 hp->timer_state = asleep; in happy_meal_pci_probe()
3132 hp->timer_ticks = 0; in happy_meal_pci_probe()
3134 timer_setup(&hp->happy_timer, happy_meal_timer, 0); in happy_meal_pci_probe()
3136 hp->irq = pdev->irq; in happy_meal_pci_probe()
3137 hp->dev = dev; in happy_meal_pci_probe()
3148 hp->read_desc32 = pci_hme_read_desc32; in happy_meal_pci_probe()
3149 hp->write_txd = pci_hme_write_txd; in happy_meal_pci_probe()
3150 hp->write_rxd = pci_hme_write_rxd; in happy_meal_pci_probe()
3151 hp->read32 = pci_hme_read32; in happy_meal_pci_probe()
3152 hp->write32 = pci_hme_write32; in happy_meal_pci_probe()
3158 spin_lock_irq(&hp->happy_lock); in happy_meal_pci_probe()
3159 happy_meal_set_initial_advertisement(hp); in happy_meal_pci_probe()
3160 spin_unlock_irq(&hp->happy_lock); in happy_meal_pci_probe()
3162 err = register_netdev(hp->dev); in happy_meal_pci_probe()
3169 pci_set_drvdata(pdev, hp); in happy_meal_pci_probe()
3200 iounmap(hp->gregs); in happy_meal_pci_probe()
3217 struct happy_meal *hp = pci_get_drvdata(pdev); in happy_meal_pci_remove() local
3218 struct net_device *net_dev = hp->dev; in happy_meal_pci_remove()
3222 dma_free_coherent(hp->dma_dev, PAGE_SIZE, in happy_meal_pci_remove()
3223 hp->happy_block, hp->hblock_dvma); in happy_meal_pci_remove()
3224 iounmap(hp->gregs); in happy_meal_pci_remove()
3225 pci_release_regions(hp->happy_dev); in happy_meal_pci_remove()
3287 struct happy_meal *hp = platform_get_drvdata(op); in hme_sbus_remove() local
3288 struct net_device *net_dev = hp->dev; in hme_sbus_remove()
3294 of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); in hme_sbus_remove()
3295 of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); in hme_sbus_remove()
3296 of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); in hme_sbus_remove()
3297 of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); in hme_sbus_remove()
3298 of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); in hme_sbus_remove()
3299 dma_free_coherent(hp->dma_dev, in hme_sbus_remove()
3301 hp->happy_block, in hme_sbus_remove()
3302 hp->hblock_dvma); in hme_sbus_remove()