Lines Matching refs: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 = (struct happy_meal *) data; 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()
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()
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()
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()
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->net_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()
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()
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()
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()
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()
1297 static void happy_meal_begin_auto_negotiation(struct happy_meal *hp, in happy_meal_begin_auto_negotiation() argument
1304 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_begin_auto_negotiation()
1305 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
1306 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_begin_auto_negotiation()
1307 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_begin_auto_negotiation()
1311 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_begin_auto_negotiation()
1314 if (hp->sw_bmsr & BMSR_10HALF) in happy_meal_begin_auto_negotiation()
1315 hp->sw_advertise |= (ADVERTISE_10HALF); in happy_meal_begin_auto_negotiation()
1317 hp->sw_advertise &= ~(ADVERTISE_10HALF); in happy_meal_begin_auto_negotiation()
1319 if (hp->sw_bmsr & BMSR_10FULL) in happy_meal_begin_auto_negotiation()
1320 hp->sw_advertise |= (ADVERTISE_10FULL); in happy_meal_begin_auto_negotiation()
1322 hp->sw_advertise &= ~(ADVERTISE_10FULL); in happy_meal_begin_auto_negotiation()
1323 if (hp->sw_bmsr & BMSR_100HALF) in happy_meal_begin_auto_negotiation()
1324 hp->sw_advertise |= (ADVERTISE_100HALF); in happy_meal_begin_auto_negotiation()
1326 hp->sw_advertise &= ~(ADVERTISE_100HALF); in happy_meal_begin_auto_negotiation()
1327 if (hp->sw_bmsr & BMSR_100FULL) in happy_meal_begin_auto_negotiation()
1328 hp->sw_advertise |= (ADVERTISE_100FULL); in happy_meal_begin_auto_negotiation()
1330 hp->sw_advertise &= ~(ADVERTISE_100FULL); in happy_meal_begin_auto_negotiation()
1331 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_begin_auto_negotiation()
1340 ASD(("%s: Advertising [ ", hp->dev->name)); in happy_meal_begin_auto_negotiation()
1341 if (hp->sw_advertise & ADVERTISE_10HALF) in happy_meal_begin_auto_negotiation()
1343 if (hp->sw_advertise & ADVERTISE_10FULL) in happy_meal_begin_auto_negotiation()
1345 if (hp->sw_advertise & ADVERTISE_100HALF) in happy_meal_begin_auto_negotiation()
1347 if (hp->sw_advertise & ADVERTISE_100FULL) in happy_meal_begin_auto_negotiation()
1352 hp->sw_bmcr |= BMCR_ANENABLE; in happy_meal_begin_auto_negotiation()
1353 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1356 hp->sw_bmcr |= BMCR_ANRESTART; in happy_meal_begin_auto_negotiation()
1357 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1363 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
1364 if (!(hp->sw_bmcr & BMCR_ANRESTART)) in happy_meal_begin_auto_negotiation()
1370 "BMCR=0x%04x\n", hp->dev->name, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1372 hp->dev->name); in happy_meal_begin_auto_negotiation()
1375 hp->timer_state = arbwait; in happy_meal_begin_auto_negotiation()
1388 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_begin_auto_negotiation()
1391 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_begin_auto_negotiation()
1393 hp->sw_bmcr = 0; in happy_meal_begin_auto_negotiation()
1395 hp->sw_bmcr |= BMCR_FULLDPLX; in happy_meal_begin_auto_negotiation()
1397 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1399 if (!is_lucent_phy(hp)) { in happy_meal_begin_auto_negotiation()
1404 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_begin_auto_negotiation()
1406 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_begin_auto_negotiation()
1407 happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, in happy_meal_begin_auto_negotiation()
1408 hp->sw_csconfig); in happy_meal_begin_auto_negotiation()
1410 hp->timer_state = ltrywait; in happy_meal_begin_auto_negotiation()
1413 hp->timer_ticks = 0; in happy_meal_begin_auto_negotiation()
1414 hp->happy_timer.expires = jiffies + (12 * HZ)/10; /* 1.2 sec. */ in happy_meal_begin_auto_negotiation()
1415 hp->happy_timer.data = (unsigned long) hp; in happy_meal_begin_auto_negotiation()
1416 hp->happy_timer.function = happy_meal_timer; in happy_meal_begin_auto_negotiation()
1417 add_timer(&hp->happy_timer); in happy_meal_begin_auto_negotiation()
1421 static int happy_meal_init(struct happy_meal *hp) in happy_meal_init() argument
1423 void __iomem *gregs = hp->gregs; in happy_meal_init()
1424 void __iomem *etxregs = hp->etxregs; in happy_meal_init()
1425 void __iomem *erxregs = hp->erxregs; in happy_meal_init()
1426 void __iomem *bregs = hp->bigmacregs; in happy_meal_init()
1427 void __iomem *tregs = hp->tcvregs; in happy_meal_init()
1429 unsigned char *e = &hp->dev->dev_addr[0]; in happy_meal_init()
1432 del_timer(&hp->happy_timer); in happy_meal_init()
1435 hp->happy_flags)); in happy_meal_init()
1436 if (!(hp->happy_flags & HFLAG_INIT)) { in happy_meal_init()
1438 hp->happy_flags |= HFLAG_INIT; in happy_meal_init()
1439 happy_meal_get_counters(hp, bregs); in happy_meal_init()
1444 happy_meal_poll_stop(hp, tregs); in happy_meal_init()
1448 happy_meal_stop(hp, gregs); in happy_meal_init()
1452 happy_meal_init_rings(hp); in happy_meal_init()
1456 hme_read32(hp, tregs + TCVR_IMASK))); in happy_meal_init()
1457 hme_write32(hp, tregs + TCVR_IMASK, 0xffff); in happy_meal_init()
1460 if (hp->happy_flags & HFLAG_FENABLE) { in happy_meal_init()
1462 hme_read32(hp, tregs + TCVR_CFG))); in happy_meal_init()
1463 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_init()
1464 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE)); in happy_meal_init()
1467 hme_read32(hp, tregs + TCVR_CFG))); in happy_meal_init()
1468 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_init()
1469 hme_read32(hp, tregs + TCVR_CFG) | TCV_CFG_BENABLE); in happy_meal_init()
1474 happy_meal_transceiver_check(hp, tregs); in happy_meal_init()
1478 switch(hp->tcvr_type) { in happy_meal_init()
1487 hme_write32(hp, bregs + BMAC_XIFCFG, 0); in happy_meal_init()
1493 hme_write32(hp, bregs + BMAC_XIFCFG, BIGMAC_XCFG_MIIDISAB); in happy_meal_init()
1497 if (happy_meal_tcvr_reset(hp, tregs)) in happy_meal_init()
1502 happy_meal_tx_reset(hp, bregs); in happy_meal_init()
1503 happy_meal_rx_reset(hp, bregs); in happy_meal_init()
1507 hme_write32(hp, bregs + BMAC_JSIZE, DEFAULT_JAMSIZE); in happy_meal_init()
1508 hme_write32(hp, bregs + BMAC_IGAP1, DEFAULT_IPG1); in happy_meal_init()
1509 hme_write32(hp, bregs + BMAC_IGAP2, DEFAULT_IPG2); in happy_meal_init()
1515 hme_write32(hp, bregs + BMAC_RSEED, ((e[5] | e[4]<<8)&0x3ff)); in happy_meal_init()
1517 hme_write32(hp, bregs + BMAC_MACADDR2, ((e[4] << 8) | e[5])); in happy_meal_init()
1518 hme_write32(hp, bregs + BMAC_MACADDR1, ((e[2] << 8) | e[3])); in happy_meal_init()
1519 hme_write32(hp, bregs + BMAC_MACADDR0, ((e[0] << 8) | e[1])); in happy_meal_init()
1522 if ((hp->dev->flags & IFF_ALLMULTI) || in happy_meal_init()
1523 (netdev_mc_count(hp->dev) > 64)) { in happy_meal_init()
1524 hme_write32(hp, bregs + BMAC_HTABLE0, 0xffff); in happy_meal_init()
1525 hme_write32(hp, bregs + BMAC_HTABLE1, 0xffff); in happy_meal_init()
1526 hme_write32(hp, bregs + BMAC_HTABLE2, 0xffff); in happy_meal_init()
1527 hme_write32(hp, bregs + BMAC_HTABLE3, 0xffff); in happy_meal_init()
1528 } else if ((hp->dev->flags & IFF_PROMISC) == 0) { in happy_meal_init()
1534 netdev_for_each_mc_addr(ha, hp->dev) { in happy_meal_init()
1539 hme_write32(hp, bregs + BMAC_HTABLE0, hash_table[0]); in happy_meal_init()
1540 hme_write32(hp, bregs + BMAC_HTABLE1, hash_table[1]); in happy_meal_init()
1541 hme_write32(hp, bregs + BMAC_HTABLE2, hash_table[2]); in happy_meal_init()
1542 hme_write32(hp, bregs + BMAC_HTABLE3, hash_table[3]); in happy_meal_init()
1544 hme_write32(hp, bregs + BMAC_HTABLE3, 0); in happy_meal_init()
1545 hme_write32(hp, bregs + BMAC_HTABLE2, 0); in happy_meal_init()
1546 hme_write32(hp, bregs + BMAC_HTABLE1, 0); in happy_meal_init()
1547 hme_write32(hp, bregs + BMAC_HTABLE0, 0); in happy_meal_init()
1552 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0)), in happy_meal_init()
1553 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_txd, 0)))); in happy_meal_init()
1554 hme_write32(hp, erxregs + ERX_RING, in happy_meal_init()
1555 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0))); in happy_meal_init()
1556 hme_write32(hp, etxregs + ETX_RING, in happy_meal_init()
1557 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_txd, 0))); in happy_meal_init()
1564 if (hme_read32(hp, erxregs + ERX_RING) != in happy_meal_init()
1565 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0))) in happy_meal_init()
1566 hme_write32(hp, erxregs + ERX_RING, in happy_meal_init()
1567 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0)) in happy_meal_init()
1572 hme_read32(hp, gregs + GREG_CFG))); in happy_meal_init()
1576 hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST64); in happy_meal_init()
1578 if ((hp->happy_bursts & DMA_BURST64) && in happy_meal_init()
1579 ((hp->happy_flags & HFLAG_PCI) != 0 in happy_meal_init()
1591 if ((hp->happy_flags & HFLAG_PCI) == 0) { in happy_meal_init()
1592 struct platform_device *op = hp->happy_dev; in happy_meal_init()
1595 hp->happy_bursts); in happy_meal_init()
1602 hme_write32(hp, gregs + GREG_CFG, gcfg); in happy_meal_init()
1603 } else if (hp->happy_bursts & DMA_BURST32) { in happy_meal_init()
1605 hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST32); in happy_meal_init()
1606 } else if (hp->happy_bursts & DMA_BURST16) { in happy_meal_init()
1608 hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST16); in happy_meal_init()
1611 hme_write32(hp, gregs + GREG_CFG, 0); in happy_meal_init()
1617 hme_write32(hp, gregs + GREG_IMASK, in happy_meal_init()
1623 hme_read32(hp, etxregs + ETX_RSIZE))); in happy_meal_init()
1624 hme_write32(hp, etxregs + ETX_RSIZE, (TX_RING_SIZE >> ETX_RSIZE_SHIFT) - 1); in happy_meal_init()
1628 hme_read32(hp, etxregs + ETX_CFG))); in happy_meal_init()
1629 hme_write32(hp, etxregs + ETX_CFG, in happy_meal_init()
1630 hme_read32(hp, etxregs + ETX_CFG) | ETX_CFG_DMAENABLE); in happy_meal_init()
1638 hme_read32(hp, erxregs + ERX_CFG))); in happy_meal_init()
1639 hme_write32(hp, erxregs + ERX_CFG, ERX_CFG_DEFAULT(RX_OFFSET)); in happy_meal_init()
1640 regtmp = hme_read32(hp, erxregs + ERX_CFG); in happy_meal_init()
1641 hme_write32(hp, erxregs + ERX_CFG, ERX_CFG_DEFAULT(RX_OFFSET)); in happy_meal_init()
1642 if (hme_read32(hp, erxregs + ERX_CFG) != ERX_CFG_DEFAULT(RX_OFFSET)) { in happy_meal_init()
1651 hme_read32(hp, bregs + BMAC_RXCFG))); in happy_meal_init()
1653 if (hp->dev->flags & IFF_PROMISC) in happy_meal_init()
1655 hme_write32(hp, bregs + BMAC_RXCFG, rxcfg); in happy_meal_init()
1663 if (hp->happy_flags & HFLAG_FULL) in happy_meal_init()
1669 hme_write32(hp, bregs + BMAC_TXCFG, regtmp /*| BIGMAC_TXCFG_DGIVEUP*/); in happy_meal_init()
1672 hme_write32(hp, bregs + BMAC_ALIMIT, 16); in happy_meal_init()
1678 if (hp->happy_flags & HFLAG_LANCE) in happy_meal_init()
1682 if (hp->tcvr_type == external) in happy_meal_init()
1686 hme_read32(hp, bregs + BMAC_XIFCFG))); in happy_meal_init()
1687 hme_write32(hp, bregs + BMAC_XIFCFG, regtmp); in happy_meal_init()
1691 hme_read32(hp, bregs + BMAC_TXCFG), in happy_meal_init()
1692 hme_read32(hp, bregs + BMAC_RXCFG))); in happy_meal_init()
1695 hme_write32(hp, bregs + BMAC_TXMAX, ETH_FRAME_LEN + 8); in happy_meal_init()
1696 hme_write32(hp, bregs + BMAC_RXMAX, ETH_FRAME_LEN + 8); in happy_meal_init()
1698 hme_write32(hp, bregs + BMAC_TXCFG, in happy_meal_init()
1699 hme_read32(hp, bregs + BMAC_TXCFG) | BIGMAC_TXCFG_ENABLE); in happy_meal_init()
1700 hme_write32(hp, bregs + BMAC_RXCFG, in happy_meal_init()
1701 hme_read32(hp, bregs + BMAC_RXCFG) | BIGMAC_RXCFG_ENABLE); in happy_meal_init()
1704 happy_meal_begin_auto_negotiation(hp, tregs, NULL); in happy_meal_init()
1711 static void happy_meal_set_initial_advertisement(struct happy_meal *hp) in happy_meal_set_initial_advertisement() argument
1713 void __iomem *tregs = hp->tcvregs; in happy_meal_set_initial_advertisement()
1714 void __iomem *bregs = hp->bigmacregs; in happy_meal_set_initial_advertisement()
1715 void __iomem *gregs = hp->gregs; in happy_meal_set_initial_advertisement()
1717 happy_meal_stop(hp, gregs); in happy_meal_set_initial_advertisement()
1718 hme_write32(hp, tregs + TCVR_IMASK, 0xffff); in happy_meal_set_initial_advertisement()
1719 if (hp->happy_flags & HFLAG_FENABLE) in happy_meal_set_initial_advertisement()
1720 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_set_initial_advertisement()
1721 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE)); in happy_meal_set_initial_advertisement()
1723 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_set_initial_advertisement()
1724 hme_read32(hp, tregs + TCVR_CFG) | TCV_CFG_BENABLE); in happy_meal_set_initial_advertisement()
1725 happy_meal_transceiver_check(hp, tregs); in happy_meal_set_initial_advertisement()
1726 switch(hp->tcvr_type) { in happy_meal_set_initial_advertisement()
1730 hme_write32(hp, bregs + BMAC_XIFCFG, 0); in happy_meal_set_initial_advertisement()
1733 hme_write32(hp, bregs + BMAC_XIFCFG, BIGMAC_XCFG_MIIDISAB); in happy_meal_set_initial_advertisement()
1736 if (happy_meal_tcvr_reset(hp, tregs)) in happy_meal_set_initial_advertisement()
1740 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_set_initial_advertisement()
1741 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_set_initial_advertisement()
1744 if (hp->sw_bmsr & BMSR_10HALF) in happy_meal_set_initial_advertisement()
1745 hp->sw_advertise |= (ADVERTISE_10HALF); in happy_meal_set_initial_advertisement()
1747 hp->sw_advertise &= ~(ADVERTISE_10HALF); in happy_meal_set_initial_advertisement()
1749 if (hp->sw_bmsr & BMSR_10FULL) in happy_meal_set_initial_advertisement()
1750 hp->sw_advertise |= (ADVERTISE_10FULL); in happy_meal_set_initial_advertisement()
1752 hp->sw_advertise &= ~(ADVERTISE_10FULL); in happy_meal_set_initial_advertisement()
1753 if (hp->sw_bmsr & BMSR_100HALF) in happy_meal_set_initial_advertisement()
1754 hp->sw_advertise |= (ADVERTISE_100HALF); in happy_meal_set_initial_advertisement()
1756 hp->sw_advertise &= ~(ADVERTISE_100HALF); in happy_meal_set_initial_advertisement()
1757 if (hp->sw_bmsr & BMSR_100FULL) in happy_meal_set_initial_advertisement()
1758 hp->sw_advertise |= (ADVERTISE_100FULL); in happy_meal_set_initial_advertisement()
1760 hp->sw_advertise &= ~(ADVERTISE_100FULL); in happy_meal_set_initial_advertisement()
1763 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_set_initial_advertisement()
1771 static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status) in happy_meal_is_not_so_happy() argument
1783 hp->dev->name, status); in happy_meal_is_not_so_happy()
1788 printk(KERN_DEBUG "%s: Happy Meal receive FIFO overflow.\n", hp->dev->name); in happy_meal_is_not_so_happy()
1793 printk(KERN_ERR "%s: Happy Meal BigMAC SQE test failed.\n", hp->dev->name); in happy_meal_is_not_so_happy()
1800 hp->dev->name); in happy_meal_is_not_so_happy()
1808 printk(KERN_ERR "%s: Happy Meal MAX Packet size error.\n", hp->dev->name); in happy_meal_is_not_so_happy()
1820 hp->dev->name); in happy_meal_is_not_so_happy()
1825 printk(KERN_ERR "%s: Happy Meal rx DMA errors [ ", hp->dev->name); in happy_meal_is_not_so_happy()
1841 hp->dev->name); in happy_meal_is_not_so_happy()
1847 printk(KERN_ERR "%s: Happy Meal MIF interrupt.\n", hp->dev->name); in happy_meal_is_not_so_happy()
1853 printk(KERN_ERR "%s: Happy Meal tx DMA errors [ ", hp->dev->name); in happy_meal_is_not_so_happy()
1871 hp->dev->name, in happy_meal_is_not_so_happy()
1877 printk(KERN_NOTICE "%s: Resetting...\n", hp->dev->name); in happy_meal_is_not_so_happy()
1878 happy_meal_init(hp); in happy_meal_is_not_so_happy()
1885 static void happy_meal_mif_interrupt(struct happy_meal *hp) in happy_meal_mif_interrupt() argument
1887 void __iomem *tregs = hp->tcvregs; in happy_meal_mif_interrupt()
1889 printk(KERN_INFO "%s: Link status change.\n", hp->dev->name); in happy_meal_mif_interrupt()
1890 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_mif_interrupt()
1891 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in happy_meal_mif_interrupt()
1894 if (hp->sw_lpa & LPA_100FULL) { in happy_meal_mif_interrupt()
1895 printk(KERN_INFO "%s: Switching to 100Mbps at full duplex.", hp->dev->name); in happy_meal_mif_interrupt()
1896 hp->sw_bmcr |= (BMCR_FULLDPLX | BMCR_SPEED100); in happy_meal_mif_interrupt()
1897 } else if (hp->sw_lpa & LPA_100HALF) { in happy_meal_mif_interrupt()
1898 printk(KERN_INFO "%s: Switching to 100MBps at half duplex.", hp->dev->name); in happy_meal_mif_interrupt()
1899 hp->sw_bmcr |= BMCR_SPEED100; in happy_meal_mif_interrupt()
1900 } else if (hp->sw_lpa & LPA_10FULL) { in happy_meal_mif_interrupt()
1901 printk(KERN_INFO "%s: Switching to 10MBps at full duplex.", hp->dev->name); in happy_meal_mif_interrupt()
1902 hp->sw_bmcr |= BMCR_FULLDPLX; in happy_meal_mif_interrupt()
1904 printk(KERN_INFO "%s: Using 10Mbps at half duplex.", hp->dev->name); in happy_meal_mif_interrupt()
1906 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_mif_interrupt()
1909 happy_meal_poll_stop(hp, tregs); in happy_meal_mif_interrupt()
1919 static void happy_meal_tx(struct happy_meal *hp) in happy_meal_tx() argument
1921 struct happy_meal_txd *txbase = &hp->happy_block->happy_meal_txd[0]; in happy_meal_tx()
1923 struct net_device *dev = hp->dev; in happy_meal_tx()
1926 elem = hp->tx_old; in happy_meal_tx()
1928 while (elem != hp->tx_new) { in happy_meal_tx()
1935 flags = hme_read_desc32(hp, &this->tx_flags); in happy_meal_tx()
1938 skb = hp->tx_skbs[elem]; in happy_meal_tx()
1944 flags = hme_read_desc32(hp, &txbase[last].tx_flags); in happy_meal_tx()
1948 hp->tx_skbs[elem] = NULL; in happy_meal_tx()
1949 hp->net_stats.tx_bytes += skb->len; in happy_meal_tx()
1952 dma_addr = hme_read_desc32(hp, &this->tx_addr); in happy_meal_tx()
1953 dma_len = hme_read_desc32(hp, &this->tx_flags); in happy_meal_tx()
1957 dma_unmap_single(hp->dma_dev, dma_addr, dma_len, DMA_TO_DEVICE); in happy_meal_tx()
1959 dma_unmap_page(hp->dma_dev, dma_addr, dma_len, DMA_TO_DEVICE); in happy_meal_tx()
1966 hp->net_stats.tx_packets++; in happy_meal_tx()
1968 hp->tx_old = elem; in happy_meal_tx()
1972 TX_BUFFS_AVAIL(hp) > (MAX_SKB_FRAGS + 1)) in happy_meal_tx()
1991 static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev) in happy_meal_rx() argument
1993 struct happy_meal_rxd *rxbase = &hp->happy_block->happy_meal_rxd[0]; in happy_meal_rx()
1995 int elem = hp->rx_new, drops = 0; in happy_meal_rx()
2000 while (!((flags = hme_read_desc32(hp, &this->rx_flags)) & RXFLAG_OWN)) { in happy_meal_rx()
2004 u32 dma_addr = hme_read_desc32(hp, &this->rx_addr); in happy_meal_rx()
2011 hp->net_stats.rx_errors++; in happy_meal_rx()
2013 hp->net_stats.rx_length_errors++; in happy_meal_rx()
2015 hp->net_stats.rx_over_errors++; in happy_meal_rx()
2016 hp->net_stats.rx_fifo_errors++; in happy_meal_rx()
2021 hp->net_stats.rx_dropped++; in happy_meal_rx()
2022 hme_write_rxd(hp, this, in happy_meal_rx()
2027 skb = hp->rx_skbs[elem]; in happy_meal_rx()
2039 mapping = dma_map_single(hp->dma_dev, new_skb->data, in happy_meal_rx()
2042 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) { in happy_meal_rx()
2048 dma_unmap_single(hp->dma_dev, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE); in happy_meal_rx()
2049 hp->rx_skbs[elem] = new_skb; in happy_meal_rx()
2050 hme_write_rxd(hp, this, in happy_meal_rx()
2067 dma_sync_single_for_cpu(hp->dma_dev, dma_addr, len, DMA_FROM_DEVICE); in happy_meal_rx()
2069 dma_sync_single_for_device(hp->dma_dev, dma_addr, len, DMA_FROM_DEVICE); in happy_meal_rx()
2071 hme_write_rxd(hp, this, in happy_meal_rx()
2086 hp->net_stats.rx_packets++; in happy_meal_rx()
2087 hp->net_stats.rx_bytes += len; in happy_meal_rx()
2092 hp->rx_new = elem; in happy_meal_rx()
2094 printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n", hp->dev->name); in happy_meal_rx()
2101 struct happy_meal *hp = netdev_priv(dev); in happy_meal_interrupt() local
2102 u32 happy_status = hme_read32(hp, hp->gregs + GREG_STAT); in happy_meal_interrupt()
2106 spin_lock(&hp->happy_lock); in happy_meal_interrupt()
2110 if (happy_meal_is_not_so_happy(hp, /* un- */ happy_status)) in happy_meal_interrupt()
2116 happy_meal_mif_interrupt(hp); in happy_meal_interrupt()
2121 happy_meal_tx(hp); in happy_meal_interrupt()
2126 happy_meal_rx(hp, dev); in happy_meal_interrupt()
2131 spin_unlock(&hp->happy_lock); in happy_meal_interrupt()
2144 struct happy_meal *hp = netdev_priv(dev); in quattro_sbus_interrupt() local
2145 u32 happy_status = hme_read32(hp, hp->gregs + GREG_STAT); in quattro_sbus_interrupt()
2155 spin_lock(&hp->happy_lock); in quattro_sbus_interrupt()
2159 if (happy_meal_is_not_so_happy(hp, happy_status)) in quattro_sbus_interrupt()
2165 happy_meal_mif_interrupt(hp); in quattro_sbus_interrupt()
2170 happy_meal_tx(hp); in quattro_sbus_interrupt()
2175 happy_meal_rx(hp, dev); in quattro_sbus_interrupt()
2179 spin_unlock(&hp->happy_lock); in quattro_sbus_interrupt()
2189 struct happy_meal *hp = netdev_priv(dev); in happy_meal_open() local
2197 if ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO) { in happy_meal_open()
2198 res = request_irq(hp->irq, happy_meal_interrupt, IRQF_SHARED, in happy_meal_open()
2203 hp->irq); in happy_meal_open()
2211 spin_lock_irq(&hp->happy_lock); in happy_meal_open()
2212 res = happy_meal_init(hp); in happy_meal_open()
2213 spin_unlock_irq(&hp->happy_lock); in happy_meal_open()
2215 if (res && ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO)) in happy_meal_open()
2216 free_irq(hp->irq, dev); in happy_meal_open()
2222 struct happy_meal *hp = netdev_priv(dev); in happy_meal_close() local
2224 spin_lock_irq(&hp->happy_lock); in happy_meal_close()
2225 happy_meal_stop(hp, hp->gregs); in happy_meal_close()
2226 happy_meal_clean_rings(hp); in happy_meal_close()
2229 del_timer(&hp->happy_timer); in happy_meal_close()
2231 spin_unlock_irq(&hp->happy_lock); in happy_meal_close()
2237 if ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO) in happy_meal_close()
2238 free_irq(hp->irq, dev); in happy_meal_close()
2251 struct happy_meal *hp = netdev_priv(dev); in happy_meal_tx_timeout() local
2256 hme_read32(hp, hp->gregs + GREG_STAT), in happy_meal_tx_timeout()
2257 hme_read32(hp, hp->etxregs + ETX_CFG), in happy_meal_tx_timeout()
2258 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG)); in happy_meal_tx_timeout()
2260 spin_lock_irq(&hp->happy_lock); in happy_meal_tx_timeout()
2261 happy_meal_init(hp); in happy_meal_tx_timeout()
2262 spin_unlock_irq(&hp->happy_lock); in happy_meal_tx_timeout()
2267 static void unmap_partial_tx_skb(struct happy_meal *hp, u32 first_mapping, in unmap_partial_tx_skb() argument
2270 struct happy_meal_txd *txbase = &hp->happy_block->happy_meal_txd[0]; in unmap_partial_tx_skb()
2272 dma_unmap_single(hp->dma_dev, first_mapping, first_len, DMA_TO_DEVICE); in unmap_partial_tx_skb()
2279 addr = hme_read_desc32(hp, &this->tx_addr); in unmap_partial_tx_skb()
2280 len = hme_read_desc32(hp, &this->tx_flags); in unmap_partial_tx_skb()
2282 dma_unmap_page(hp->dma_dev, addr, len, DMA_TO_DEVICE); in unmap_partial_tx_skb()
2289 struct happy_meal *hp = netdev_priv(dev); in happy_meal_start_xmit() local
2303 spin_lock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2305 if (TX_BUFFS_AVAIL(hp) <= (skb_shinfo(skb)->nr_frags + 1)) { in happy_meal_start_xmit()
2307 spin_unlock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2313 entry = hp->tx_new; in happy_meal_start_xmit()
2315 hp->tx_skbs[entry] = skb; in happy_meal_start_xmit()
2321 mapping = dma_map_single(hp->dma_dev, skb->data, len, DMA_TO_DEVICE); in happy_meal_start_xmit()
2322 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) in happy_meal_start_xmit()
2325 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], in happy_meal_start_xmit()
2337 first_mapping = dma_map_single(hp->dma_dev, skb->data, first_len, in happy_meal_start_xmit()
2339 if (unlikely(dma_mapping_error(hp->dma_dev, first_mapping))) in happy_meal_start_xmit()
2348 mapping = skb_frag_dma_map(hp->dma_dev, this_frag, in happy_meal_start_xmit()
2350 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) { in happy_meal_start_xmit()
2351 unmap_partial_tx_skb(hp, first_mapping, first_len, in happy_meal_start_xmit()
2358 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], in happy_meal_start_xmit()
2363 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[first_entry], in happy_meal_start_xmit()
2368 hp->tx_new = entry; in happy_meal_start_xmit()
2370 if (TX_BUFFS_AVAIL(hp) <= (MAX_SKB_FRAGS + 1)) in happy_meal_start_xmit()
2374 hme_write32(hp, hp->etxregs + ETX_PENDING, ETX_TP_DMAWAKEUP); in happy_meal_start_xmit()
2376 spin_unlock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2378 tx_add_log(hp, TXLOG_ACTION_TXMIT, 0); in happy_meal_start_xmit()
2382 hp->tx_skbs[hp->tx_new] = NULL; in happy_meal_start_xmit()
2383 spin_unlock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2392 struct happy_meal *hp = netdev_priv(dev); in happy_meal_get_stats() local
2394 spin_lock_irq(&hp->happy_lock); in happy_meal_get_stats()
2395 happy_meal_get_counters(hp, hp->bigmacregs); in happy_meal_get_stats()
2396 spin_unlock_irq(&hp->happy_lock); in happy_meal_get_stats()
2398 return &hp->net_stats; in happy_meal_get_stats()
2403 struct happy_meal *hp = netdev_priv(dev); in happy_meal_set_multicast() local
2404 void __iomem *bregs = hp->bigmacregs; in happy_meal_set_multicast()
2408 spin_lock_irq(&hp->happy_lock); in happy_meal_set_multicast()
2411 hme_write32(hp, bregs + BMAC_HTABLE0, 0xffff); in happy_meal_set_multicast()
2412 hme_write32(hp, bregs + BMAC_HTABLE1, 0xffff); in happy_meal_set_multicast()
2413 hme_write32(hp, bregs + BMAC_HTABLE2, 0xffff); in happy_meal_set_multicast()
2414 hme_write32(hp, bregs + BMAC_HTABLE3, 0xffff); in happy_meal_set_multicast()
2416 hme_write32(hp, bregs + BMAC_RXCFG, in happy_meal_set_multicast()
2417 hme_read32(hp, bregs + BMAC_RXCFG) | BIGMAC_RXCFG_PMISC); in happy_meal_set_multicast()
2427 hme_write32(hp, bregs + BMAC_HTABLE0, hash_table[0]); in happy_meal_set_multicast()
2428 hme_write32(hp, bregs + BMAC_HTABLE1, hash_table[1]); in happy_meal_set_multicast()
2429 hme_write32(hp, bregs + BMAC_HTABLE2, hash_table[2]); in happy_meal_set_multicast()
2430 hme_write32(hp, bregs + BMAC_HTABLE3, hash_table[3]); in happy_meal_set_multicast()
2433 spin_unlock_irq(&hp->happy_lock); in happy_meal_set_multicast()
2439 struct happy_meal *hp = netdev_priv(dev); in hme_get_settings() local
2453 spin_lock_irq(&hp->happy_lock); in hme_get_settings()
2454 hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR); in hme_get_settings()
2455 hp->sw_lpa = happy_meal_tcvr_read(hp, hp->tcvregs, MII_LPA); in hme_get_settings()
2456 spin_unlock_irq(&hp->happy_lock); in hme_get_settings()
2458 if (hp->sw_bmcr & BMCR_ANENABLE) { in hme_get_settings()
2460 speed = ((hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ? in hme_get_settings()
2464 (hp->sw_lpa & (LPA_100FULL)) ? in hme_get_settings()
2468 (hp->sw_lpa & (LPA_10FULL)) ? in hme_get_settings()
2472 speed = (hp->sw_bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10; in hme_get_settings()
2474 (hp->sw_bmcr & BMCR_FULLDPLX) ? in hme_get_settings()
2483 struct happy_meal *hp = netdev_priv(dev); in hme_set_settings() local
2497 spin_lock_irq(&hp->happy_lock); in hme_set_settings()
2498 del_timer(&hp->happy_timer); in hme_set_settings()
2499 happy_meal_begin_auto_negotiation(hp, hp->tcvregs, cmd); in hme_set_settings()
2500 spin_unlock_irq(&hp->happy_lock); in hme_set_settings()
2507 struct happy_meal *hp = netdev_priv(dev); in hme_get_drvinfo() local
2511 if (hp->happy_flags & HFLAG_PCI) { in hme_get_drvinfo()
2512 struct pci_dev *pdev = hp->happy_dev; in hme_get_drvinfo()
2518 struct platform_device *op = hp->happy_dev; in hme_get_drvinfo()
2530 struct happy_meal *hp = netdev_priv(dev); in hme_get_link() local
2532 spin_lock_irq(&hp->happy_lock); in hme_get_link()
2533 hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR); in hme_get_link()
2534 spin_unlock_irq(&hp->happy_lock); in hme_get_link()
2536 return hp->sw_bmsr & BMSR_LSTATUS; in hme_get_link()
2682 struct happy_meal *hp; in happy_meal_sbus_probe_one() local
2736 hp = netdev_priv(dev); in happy_meal_sbus_probe_one()
2738 hp->happy_dev = op; in happy_meal_sbus_probe_one()
2739 hp->dma_dev = &op->dev; in happy_meal_sbus_probe_one()
2741 spin_lock_init(&hp->happy_lock); in happy_meal_sbus_probe_one()
2745 hp->qfe_parent = qp; in happy_meal_sbus_probe_one()
2746 hp->qfe_ent = qfe_slot; in happy_meal_sbus_probe_one()
2750 hp->gregs = of_ioremap(&op->resource[0], 0, in happy_meal_sbus_probe_one()
2752 if (!hp->gregs) { in happy_meal_sbus_probe_one()
2757 hp->etxregs = of_ioremap(&op->resource[1], 0, in happy_meal_sbus_probe_one()
2759 if (!hp->etxregs) { in happy_meal_sbus_probe_one()
2764 hp->erxregs = of_ioremap(&op->resource[2], 0, in happy_meal_sbus_probe_one()
2766 if (!hp->erxregs) { in happy_meal_sbus_probe_one()
2771 hp->bigmacregs = of_ioremap(&op->resource[3], 0, in happy_meal_sbus_probe_one()
2773 if (!hp->bigmacregs) { in happy_meal_sbus_probe_one()
2778 hp->tcvregs = of_ioremap(&op->resource[4], 0, in happy_meal_sbus_probe_one()
2780 if (!hp->tcvregs) { in happy_meal_sbus_probe_one()
2785 hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); in happy_meal_sbus_probe_one()
2786 if (hp->hm_revision == 0xff) in happy_meal_sbus_probe_one()
2787 hp->hm_revision = 0xa0; in happy_meal_sbus_probe_one()
2790 if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21) in happy_meal_sbus_probe_one()
2791 hp->happy_flags = HFLAG_20_21; in happy_meal_sbus_probe_one()
2792 else if (hp->hm_revision != 0xa0) in happy_meal_sbus_probe_one()
2793 hp->happy_flags = HFLAG_NOT_A0; in happy_meal_sbus_probe_one()
2796 hp->happy_flags |= HFLAG_QUATTRO; in happy_meal_sbus_probe_one()
2799 hp->happy_bursts = of_getintprop_default(sbus_dp, in happy_meal_sbus_probe_one()
2802 hp->happy_block = dma_alloc_coherent(hp->dma_dev, in happy_meal_sbus_probe_one()
2804 &hp->hblock_dvma, in happy_meal_sbus_probe_one()
2807 if (!hp->happy_block) in happy_meal_sbus_probe_one()
2811 hp->linkcheck = 0; in happy_meal_sbus_probe_one()
2814 hp->timer_state = asleep; in happy_meal_sbus_probe_one()
2815 hp->timer_ticks = 0; in happy_meal_sbus_probe_one()
2817 init_timer(&hp->happy_timer); in happy_meal_sbus_probe_one()
2819 hp->dev = dev; in happy_meal_sbus_probe_one()
2828 hp->irq = op->archdata.irqs[0]; in happy_meal_sbus_probe_one()
2832 hp->read_desc32 = sbus_hme_read_desc32; in happy_meal_sbus_probe_one()
2833 hp->write_txd = sbus_hme_write_txd; in happy_meal_sbus_probe_one()
2834 hp->write_rxd = sbus_hme_write_rxd; in happy_meal_sbus_probe_one()
2835 hp->read32 = sbus_hme_read32; in happy_meal_sbus_probe_one()
2836 hp->write32 = sbus_hme_write32; in happy_meal_sbus_probe_one()
2842 spin_lock_irq(&hp->happy_lock); in happy_meal_sbus_probe_one()
2843 happy_meal_set_initial_advertisement(hp); in happy_meal_sbus_probe_one()
2844 spin_unlock_irq(&hp->happy_lock); in happy_meal_sbus_probe_one()
2846 err = register_netdev(hp->dev); in happy_meal_sbus_probe_one()
2853 platform_set_drvdata(op, hp); in happy_meal_sbus_probe_one()
2867 dma_free_coherent(hp->dma_dev, in happy_meal_sbus_probe_one()
2869 hp->happy_block, in happy_meal_sbus_probe_one()
2870 hp->hblock_dvma); in happy_meal_sbus_probe_one()
2873 if (hp->gregs) in happy_meal_sbus_probe_one()
2874 of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); in happy_meal_sbus_probe_one()
2875 if (hp->etxregs) in happy_meal_sbus_probe_one()
2876 of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); in happy_meal_sbus_probe_one()
2877 if (hp->erxregs) in happy_meal_sbus_probe_one()
2878 of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); in happy_meal_sbus_probe_one()
2879 if (hp->bigmacregs) in happy_meal_sbus_probe_one()
2880 of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); in happy_meal_sbus_probe_one()
2881 if (hp->tcvregs) in happy_meal_sbus_probe_one()
2882 of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); in happy_meal_sbus_probe_one()
2987 struct happy_meal *hp; in happy_meal_pci_probe() local
3032 hp = netdev_priv(dev); in happy_meal_pci_probe()
3034 hp->happy_dev = pdev; in happy_meal_pci_probe()
3035 hp->dma_dev = &pdev->dev; in happy_meal_pci_probe()
3037 spin_lock_init(&hp->happy_lock); in happy_meal_pci_probe()
3040 hp->qfe_parent = qp; in happy_meal_pci_probe()
3041 hp->qfe_ent = qfe_slot; in happy_meal_pci_probe()
3089 hp->gregs = (hpreg_base + 0x0000UL); in happy_meal_pci_probe()
3090 hp->etxregs = (hpreg_base + 0x2000UL); in happy_meal_pci_probe()
3091 hp->erxregs = (hpreg_base + 0x4000UL); in happy_meal_pci_probe()
3092 hp->bigmacregs = (hpreg_base + 0x6000UL); in happy_meal_pci_probe()
3093 hp->tcvregs = (hpreg_base + 0x7000UL); in happy_meal_pci_probe()
3096 hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); in happy_meal_pci_probe()
3097 if (hp->hm_revision == 0xff) in happy_meal_pci_probe()
3098 hp->hm_revision = 0xc0 | (pdev->revision & 0x0f); in happy_meal_pci_probe()
3101 hp->hm_revision = 0x20; in happy_meal_pci_probe()
3105 if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21) in happy_meal_pci_probe()
3106 hp->happy_flags = HFLAG_20_21; in happy_meal_pci_probe()
3107 else if (hp->hm_revision != 0xa0 && hp->hm_revision != 0xc0) in happy_meal_pci_probe()
3108 hp->happy_flags = HFLAG_NOT_A0; in happy_meal_pci_probe()
3111 hp->happy_flags |= HFLAG_QUATTRO; in happy_meal_pci_probe()
3114 hp->happy_flags |= HFLAG_PCI; in happy_meal_pci_probe()
3118 hp->happy_bursts = DMA_BURSTBITS; in happy_meal_pci_probe()
3121 hp->happy_block = dma_alloc_coherent(&pdev->dev, PAGE_SIZE, in happy_meal_pci_probe()
3122 &hp->hblock_dvma, GFP_KERNEL); in happy_meal_pci_probe()
3124 if (!hp->happy_block) in happy_meal_pci_probe()
3127 hp->linkcheck = 0; in happy_meal_pci_probe()
3128 hp->timer_state = asleep; in happy_meal_pci_probe()
3129 hp->timer_ticks = 0; in happy_meal_pci_probe()
3131 init_timer(&hp->happy_timer); in happy_meal_pci_probe()
3133 hp->irq = pdev->irq; in happy_meal_pci_probe()
3134 hp->dev = dev; in happy_meal_pci_probe()
3145 hp->read_desc32 = pci_hme_read_desc32; in happy_meal_pci_probe()
3146 hp->write_txd = pci_hme_write_txd; in happy_meal_pci_probe()
3147 hp->write_rxd = pci_hme_write_rxd; in happy_meal_pci_probe()
3148 hp->read32 = pci_hme_read32; in happy_meal_pci_probe()
3149 hp->write32 = pci_hme_write32; in happy_meal_pci_probe()
3155 spin_lock_irq(&hp->happy_lock); in happy_meal_pci_probe()
3156 happy_meal_set_initial_advertisement(hp); in happy_meal_pci_probe()
3157 spin_unlock_irq(&hp->happy_lock); in happy_meal_pci_probe()
3159 err = register_netdev(hp->dev); in happy_meal_pci_probe()
3166 pci_set_drvdata(pdev, hp); in happy_meal_pci_probe()
3197 iounmap(hp->gregs); in happy_meal_pci_probe()
3214 struct happy_meal *hp = pci_get_drvdata(pdev); in happy_meal_pci_remove() local
3215 struct net_device *net_dev = hp->dev; in happy_meal_pci_remove()
3219 dma_free_coherent(hp->dma_dev, PAGE_SIZE, in happy_meal_pci_remove()
3220 hp->happy_block, hp->hblock_dvma); in happy_meal_pci_remove()
3221 iounmap(hp->gregs); in happy_meal_pci_remove()
3222 pci_release_regions(hp->happy_dev); in happy_meal_pci_remove()
3284 struct happy_meal *hp = platform_get_drvdata(op); in hme_sbus_remove() local
3285 struct net_device *net_dev = hp->dev; in hme_sbus_remove()
3291 of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); in hme_sbus_remove()
3292 of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); in hme_sbus_remove()
3293 of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); in hme_sbus_remove()
3294 of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); in hme_sbus_remove()
3295 of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); in hme_sbus_remove()
3296 dma_free_coherent(hp->dma_dev, in hme_sbus_remove()
3298 hp->happy_block, in hme_sbus_remove()
3299 hp->hblock_dvma); in hme_sbus_remove()