Lines Matching full:hp
111 static __inline__ void tx_add_log(struct happy_meal *hp, unsigned int a, unsigned int s) in tx_add_log() argument
119 tlp->tx_new = hp->tx_new; in tx_add_log()
120 tlp->tx_old = hp->tx_old; in tx_add_log()
139 static __inline__ void tx_dump_ring(struct happy_meal *hp) in tx_dump_ring() argument
141 struct hmeal_init_block *hb = hp->happy_block; in tx_dump_ring()
155 #define tx_add_log(hp, a, s) do { } while(0) argument
157 #define tx_dump_ring(hp) do { } while(0) argument
305 static inline u32 hme_read_desc32(struct happy_meal *hp, hme32 *p) in hme_read_desc32() argument
322 static void BB_PUT_BIT(struct happy_meal *hp, void __iomem *tregs, int bit) in BB_PUT_BIT() argument
324 hme_write32(hp, tregs + TCVR_BBDATA, bit); in BB_PUT_BIT()
325 hme_write32(hp, tregs + TCVR_BBCLOCK, 0); in BB_PUT_BIT()
326 hme_write32(hp, tregs + TCVR_BBCLOCK, 1); in BB_PUT_BIT()
330 static u32 BB_GET_BIT(struct happy_meal *hp, void __iomem *tregs, int internal)
334 hme_write32(hp, tregs + TCVR_BBCLOCK, 0);
335 hme_write32(hp, tregs + TCVR_BBCLOCK, 1);
336 ret = hme_read32(hp, tregs + TCVR_CFG);
346 static u32 BB_GET_BIT2(struct happy_meal *hp, void __iomem *tregs, int internal) in BB_GET_BIT2() argument
350 hme_write32(hp, tregs + TCVR_BBCLOCK, 0); in BB_GET_BIT2()
352 retval = hme_read32(hp, tregs + TCVR_CFG); in BB_GET_BIT2()
357 hme_write32(hp, tregs + TCVR_BBCLOCK, 1); in BB_GET_BIT2()
364 static int happy_meal_bb_read(struct happy_meal *hp, in happy_meal_bb_read() argument
374 hme_write32(hp, tregs + TCVR_BBOENAB, 1); in happy_meal_bb_read()
378 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
381 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_read()
382 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
383 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
384 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_read()
387 tmp = hp->paddr & 0xff; in happy_meal_bb_read()
389 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_read()
394 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_read()
397 hme_write32(hp, tregs + TCVR_BBOENAB, 0); in happy_meal_bb_read()
400 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
402 retval |= 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()
405 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
410 static void happy_meal_bb_write(struct happy_meal *hp, in happy_meal_bb_write() argument
420 hme_write32(hp, tregs + TCVR_BBOENAB, 1); in happy_meal_bb_write()
424 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
427 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
428 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
429 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
430 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
433 tmp = (hp->paddr & 0xff); in happy_meal_bb_write()
435 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_write()
440 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_write()
443 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
444 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
447 BB_PUT_BIT(hp, tregs, ((value >> i) & 1)); in happy_meal_bb_write()
450 hme_write32(hp, tregs + TCVR_BBOENAB, 0); in happy_meal_bb_write()
455 static int happy_meal_tcvr_read(struct happy_meal *hp, in happy_meal_tcvr_read() argument
462 if (hp->tcvr_type == none) { in happy_meal_tcvr_read()
467 if (!(hp->happy_flags & HFLAG_FENABLE)) { in happy_meal_tcvr_read()
469 return happy_meal_bb_read(hp, tregs, reg); in happy_meal_tcvr_read()
472 hme_write32(hp, tregs + TCVR_FRAME, in happy_meal_tcvr_read()
473 (FRAME_READ | (hp->paddr << 23) | ((reg & 0xff) << 18))); in happy_meal_tcvr_read()
474 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries) in happy_meal_tcvr_read()
480 retval = hme_read32(hp, tregs + TCVR_FRAME) & 0xffff; in happy_meal_tcvr_read()
487 static void happy_meal_tcvr_write(struct happy_meal *hp, in happy_meal_tcvr_write() argument
496 if (!(hp->happy_flags & HFLAG_FENABLE)) { in happy_meal_tcvr_write()
497 happy_meal_bb_write(hp, tregs, reg, value); in happy_meal_tcvr_write()
502 hme_write32(hp, tregs + TCVR_FRAME, in happy_meal_tcvr_write()
503 (FRAME_WRITE | (hp->paddr << 23) | in happy_meal_tcvr_write()
505 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries) in happy_meal_tcvr_write()
547 static int try_next_permutation(struct happy_meal *hp, void __iomem *tregs) in try_next_permutation() argument
549 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in try_next_permutation()
554 if (hp->sw_bmcr & BMCR_FULLDPLX) { in try_next_permutation()
555 hp->sw_bmcr &= ~(BMCR_FULLDPLX); in try_next_permutation()
556 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in try_next_permutation()
561 if (hp->sw_bmcr & BMCR_SPEED100) { in try_next_permutation()
562 hp->sw_bmcr &= ~(BMCR_SPEED100); in try_next_permutation()
563 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in try_next_permutation()
571 static void display_link_mode(struct happy_meal *hp, void __iomem *tregs) in display_link_mode() argument
573 printk(KERN_INFO "%s: Link is up using ", hp->dev->name); in display_link_mode()
574 if (hp->tcvr_type == external) in display_link_mode()
579 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in display_link_mode()
580 if (hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) { in display_link_mode()
581 if (hp->sw_lpa & LPA_100FULL) in display_link_mode()
586 if (hp->sw_lpa & LPA_10FULL) in display_link_mode()
593 static void display_forced_link_mode(struct happy_meal *hp, void __iomem *tregs) in display_forced_link_mode() argument
595 printk(KERN_INFO "%s: Link has been forced up using ", hp->dev->name); in display_forced_link_mode()
596 if (hp->tcvr_type == external) in display_forced_link_mode()
601 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in display_forced_link_mode()
602 if (hp->sw_bmcr & BMCR_SPEED100) in display_forced_link_mode()
606 if (hp->sw_bmcr & BMCR_FULLDPLX) in display_forced_link_mode()
612 static int set_happy_link_modes(struct happy_meal *hp, void __iomem *tregs) in set_happy_link_modes() argument
619 if (hp->timer_state == arbwait) { in set_happy_link_modes()
620 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in set_happy_link_modes()
621 if (!(hp->sw_lpa & (LPA_10HALF | LPA_10FULL | LPA_100HALF | LPA_100FULL))) in set_happy_link_modes()
623 if (hp->sw_lpa & LPA_100FULL) in set_happy_link_modes()
625 else if (hp->sw_lpa & LPA_100HALF) in set_happy_link_modes()
627 else if (hp->sw_lpa & LPA_10FULL) in set_happy_link_modes()
633 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in set_happy_link_modes()
634 if (hp->sw_bmcr & BMCR_FULLDPLX) in set_happy_link_modes()
648 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
649 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) & in set_happy_link_modes()
651 while (hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) & BIGMAC_TXCFG_ENABLE) in set_happy_link_modes()
654 hp->happy_flags |= HFLAG_FULL; in set_happy_link_modes()
655 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
656 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) | in set_happy_link_modes()
659 hp->happy_flags &= ~(HFLAG_FULL); in set_happy_link_modes()
660 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
661 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) & in set_happy_link_modes()
664 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
665 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) | in set_happy_link_modes()
672 static int happy_meal_init(struct happy_meal *hp);
674 static int is_lucent_phy(struct happy_meal *hp) in is_lucent_phy() argument
676 void __iomem *tregs = hp->tcvregs; in is_lucent_phy()
680 mr2 = happy_meal_tcvr_read(hp, tregs, 2); in is_lucent_phy()
681 mr3 = happy_meal_tcvr_read(hp, tregs, 3); in is_lucent_phy()
691 struct happy_meal *hp = from_timer(hp, t, happy_timer); in happy_meal_timer() local
692 void __iomem *tregs = hp->tcvregs; in happy_meal_timer()
695 spin_lock_irq(&hp->happy_lock); in happy_meal_timer()
697 hp->timer_ticks++; in happy_meal_timer()
698 switch(hp->timer_state) { in happy_meal_timer()
703 if (hp->timer_ticks >= 10) { in happy_meal_timer()
706 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_timer()
708 hp->dev->name); in happy_meal_timer()
709 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_timer()
710 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_timer()
712 if (!is_lucent_phy(hp)) { in happy_meal_timer()
717 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, DP83840_CSCONFIG); in happy_meal_timer()
718 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_timer()
719 happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
721 hp->timer_state = ltrywait; in happy_meal_timer()
722 hp->timer_ticks = 0; in happy_meal_timer()
726 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
727 if (hp->sw_bmsr & BMSR_ANEGCOMPLETE) { in happy_meal_timer()
731 ret = set_happy_link_modes(hp, tregs); in happy_meal_timer()
743 hp->timer_state = lupwait; in happy_meal_timer()
757 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
758 if (hp->sw_bmsr & BMSR_LSTATUS) { in happy_meal_timer()
762 display_link_mode(hp, tregs); in happy_meal_timer()
763 hp->timer_state = asleep; in happy_meal_timer()
766 if (hp->timer_ticks >= 10) { in happy_meal_timer()
768 "not completely up.\n", hp->dev->name); in happy_meal_timer()
769 hp->timer_ticks = 0; in happy_meal_timer()
783 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
784 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, DP83840_CSCONFIG); in happy_meal_timer()
785 if (hp->timer_ticks == 1) { in happy_meal_timer()
786 if (!is_lucent_phy(hp)) { in happy_meal_timer()
790 hp->sw_csconfig |= CSCONFIG_TCVDISAB; in happy_meal_timer()
791 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
792 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
797 if (hp->timer_ticks == 2) { in happy_meal_timer()
798 if (!is_lucent_phy(hp)) { in happy_meal_timer()
799 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_timer()
800 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
801 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
806 if (hp->sw_bmsr & BMSR_LSTATUS) { in happy_meal_timer()
808 display_forced_link_mode(hp, tregs); in happy_meal_timer()
809 set_happy_link_modes(hp, tregs); /* XXX error? then what? */ in happy_meal_timer()
810 hp->timer_state = asleep; in happy_meal_timer()
813 if (hp->timer_ticks >= 4) { /* 6 seconds or so... */ in happy_meal_timer()
816 ret = try_next_permutation(hp, tregs); in happy_meal_timer()
824 hp->dev->name); in happy_meal_timer()
826 ret = happy_meal_init(hp); in happy_meal_timer()
830 "Happy Meal.\n", hp->dev->name); in happy_meal_timer()
834 if (!is_lucent_phy(hp)) { in happy_meal_timer()
835 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_timer()
837 hp->sw_csconfig |= CSCONFIG_TCVDISAB; in happy_meal_timer()
838 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
839 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
841 hp->timer_ticks = 0; in happy_meal_timer()
853 hp->dev->name); in happy_meal_timer()
855 hp->timer_ticks = 0; in happy_meal_timer()
856 hp->timer_state = asleep; /* foo on you */ in happy_meal_timer()
861 hp->happy_timer.expires = jiffies + ((12 * HZ)/10); /* 1.2 sec. */ in happy_meal_timer()
862 add_timer(&hp->happy_timer); in happy_meal_timer()
866 spin_unlock_irq(&hp->happy_lock); in happy_meal_timer()
872 /* hp->happy_lock must be held */
873 static void happy_meal_tx_reset(struct happy_meal *hp, void __iomem *bregs) in happy_meal_tx_reset() argument
880 hme_write32(hp, bregs + BMAC_TXSWRESET, 0); in happy_meal_tx_reset()
881 while ((hme_read32(hp, bregs + BMAC_TXSWRESET) & 1) && --tries) in happy_meal_tx_reset()
892 /* hp->happy_lock must be held */
893 static void happy_meal_rx_reset(struct happy_meal *hp, void __iomem *bregs) in happy_meal_rx_reset() argument
900 hme_write32(hp, bregs + BMAC_RXSWRESET, 0); in happy_meal_rx_reset()
901 while ((hme_read32(hp, bregs + BMAC_RXSWRESET) & 1) && --tries) in happy_meal_rx_reset()
914 /* hp->happy_lock must be held */
915 static void happy_meal_stop(struct happy_meal *hp, void __iomem *gregs) in happy_meal_stop() argument
922 hme_write32(hp, gregs + GREG_SWRESET, GREG_RESET_ALL); in happy_meal_stop()
923 while (hme_read32(hp, gregs + GREG_SWRESET) && --tries) in happy_meal_stop()
934 /* hp->happy_lock must be held */
935 static void happy_meal_get_counters(struct happy_meal *hp, void __iomem *bregs) in happy_meal_get_counters() argument
937 struct net_device_stats *stats = &hp->dev->stats; in happy_meal_get_counters()
939 stats->rx_crc_errors += hme_read32(hp, bregs + BMAC_RCRCECTR); in happy_meal_get_counters()
940 hme_write32(hp, bregs + BMAC_RCRCECTR, 0); in happy_meal_get_counters()
942 stats->rx_frame_errors += hme_read32(hp, bregs + BMAC_UNALECTR); in happy_meal_get_counters()
943 hme_write32(hp, bregs + BMAC_UNALECTR, 0); in happy_meal_get_counters()
945 stats->rx_length_errors += hme_read32(hp, bregs + BMAC_GLECTR); in happy_meal_get_counters()
946 hme_write32(hp, bregs + BMAC_GLECTR, 0); in happy_meal_get_counters()
948 stats->tx_aborted_errors += hme_read32(hp, bregs + BMAC_EXCTR); in happy_meal_get_counters()
951 (hme_read32(hp, bregs + BMAC_EXCTR) + in happy_meal_get_counters()
952 hme_read32(hp, bregs + BMAC_LTCTR)); in happy_meal_get_counters()
953 hme_write32(hp, bregs + BMAC_EXCTR, 0); in happy_meal_get_counters()
954 hme_write32(hp, bregs + BMAC_LTCTR, 0); in happy_meal_get_counters()
957 /* hp->happy_lock must be held */
958 static void happy_meal_poll_stop(struct happy_meal *hp, void __iomem *tregs) in happy_meal_poll_stop() argument
963 if ((hp->happy_flags & (HFLAG_POLLENABLE | HFLAG_POLL)) != in happy_meal_poll_stop()
971 hme_write32(hp, tregs + TCVR_IMASK, 0xffff); in happy_meal_poll_stop()
975 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_poll_stop()
976 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_PENABLE)); in happy_meal_poll_stop()
979 hp->happy_flags &= ~(HFLAG_POLL); in happy_meal_poll_stop()
992 /* hp->happy_lock must be held */
993 static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs) in happy_meal_tcvr_reset() argument
998 tconfig = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_tcvr_reset()
1000 if (hp->tcvr_type == external) { in happy_meal_tcvr_reset()
1002 hme_write32(hp, tregs + TCVR_CFG, tconfig & ~(TCV_CFG_PSELECT)); in happy_meal_tcvr_reset()
1003 hp->tcvr_type = internal; in happy_meal_tcvr_reset()
1004 hp->paddr = TCV_PADDR_ITX; in happy_meal_tcvr_reset()
1006 happy_meal_tcvr_write(hp, tregs, MII_BMCR, in happy_meal_tcvr_reset()
1008 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1014 hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT); in happy_meal_tcvr_reset()
1015 hp->tcvr_type = external; in happy_meal_tcvr_reset()
1016 hp->paddr = TCV_PADDR_ETX; in happy_meal_tcvr_reset()
1020 hme_write32(hp, tregs + TCVR_CFG, (tconfig | TCV_CFG_PSELECT)); in happy_meal_tcvr_reset()
1022 happy_meal_tcvr_write(hp, tregs, MII_BMCR, in happy_meal_tcvr_reset()
1024 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1030 hme_write32(hp, tregs + TCVR_CFG, (tconfig & ~(TCV_CFG_PSELECT))); in happy_meal_tcvr_reset()
1031 hp->tcvr_type = internal; in happy_meal_tcvr_reset()
1032 hp->paddr = TCV_PADDR_ITX; in happy_meal_tcvr_reset()
1037 happy_meal_tcvr_write(hp, tregs, MII_BMCR, BMCR_RESET); in happy_meal_tcvr_reset()
1040 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1043 hp->sw_bmcr = result; in happy_meal_tcvr_reset()
1055 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_tcvr_reset()
1056 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_tcvr_reset()
1057 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_tcvr_reset()
1058 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_tcvr_reset()
1061 hp->sw_bmcr &= ~(BMCR_ISOLATE); in happy_meal_tcvr_reset()
1062 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_tcvr_reset()
1066 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1078 if (!is_lucent_phy(hp)) { in happy_meal_tcvr_reset()
1079 result = happy_meal_tcvr_read(hp, tregs, in happy_meal_tcvr_reset()
1081 happy_meal_tcvr_write(hp, tregs, in happy_meal_tcvr_reset()
1089 * hp->happy_lock must be held
1091 static void happy_meal_transceiver_check(struct happy_meal *hp, void __iomem *tregs) in happy_meal_transceiver_check() argument
1093 unsigned long tconfig = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_transceiver_check()
1096 if (hp->happy_flags & HFLAG_POLL) { in happy_meal_transceiver_check()
1099 if (hp->tcvr_type == internal) { in happy_meal_transceiver_check()
1102 happy_meal_poll_stop(hp, tregs); in happy_meal_transceiver_check()
1103 hp->paddr = TCV_PADDR_ETX; in happy_meal_transceiver_check()
1104 hp->tcvr_type = external; in happy_meal_transceiver_check()
1108 hme_write32(hp, tregs + TCVR_CFG, tconfig); in happy_meal_transceiver_check()
1111 if (hp->tcvr_type == external) { in happy_meal_transceiver_check()
1113 if (!(hme_read32(hp, tregs + TCVR_STATUS) >> 16)) { in happy_meal_transceiver_check()
1115 happy_meal_poll_stop(hp, tregs); in happy_meal_transceiver_check()
1116 hp->paddr = TCV_PADDR_ITX; in happy_meal_transceiver_check()
1117 hp->tcvr_type = internal; in happy_meal_transceiver_check()
1119 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_transceiver_check()
1120 hme_read32(hp, tregs + TCVR_CFG) & in happy_meal_transceiver_check()
1129 u32 reread = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_transceiver_check()
1134 hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT); in happy_meal_transceiver_check()
1135 hp->paddr = TCV_PADDR_ETX; in happy_meal_transceiver_check()
1136 hp->tcvr_type = external; in happy_meal_transceiver_check()
1140 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_transceiver_check()
1142 hp->paddr = TCV_PADDR_ITX; in happy_meal_transceiver_check()
1143 hp->tcvr_type = internal; in happy_meal_transceiver_check()
1147 hp->tcvr_type = none; /* Grrr... */ in happy_meal_transceiver_check()
1198 static void happy_meal_clean_rings(struct happy_meal *hp) in happy_meal_clean_rings() argument
1203 if (hp->rx_skbs[i] != NULL) { in happy_meal_clean_rings()
1204 struct sk_buff *skb = hp->rx_skbs[i]; in happy_meal_clean_rings()
1208 rxd = &hp->happy_block->happy_meal_rxd[i]; in happy_meal_clean_rings()
1209 dma_addr = hme_read_desc32(hp, &rxd->rx_addr); in happy_meal_clean_rings()
1210 dma_unmap_single(hp->dma_dev, dma_addr, in happy_meal_clean_rings()
1213 hp->rx_skbs[i] = NULL; in happy_meal_clean_rings()
1218 if (hp->tx_skbs[i] != NULL) { in happy_meal_clean_rings()
1219 struct sk_buff *skb = hp->tx_skbs[i]; in happy_meal_clean_rings()
1224 hp->tx_skbs[i] = NULL; in happy_meal_clean_rings()
1227 txd = &hp->happy_block->happy_meal_txd[i]; in happy_meal_clean_rings()
1228 dma_addr = hme_read_desc32(hp, &txd->tx_addr); in happy_meal_clean_rings()
1230 dma_unmap_single(hp->dma_dev, dma_addr, in happy_meal_clean_rings()
1231 (hme_read_desc32(hp, &txd->tx_flags) in happy_meal_clean_rings()
1235 dma_unmap_page(hp->dma_dev, dma_addr, in happy_meal_clean_rings()
1236 (hme_read_desc32(hp, &txd->tx_flags) in happy_meal_clean_rings()
1249 /* hp->happy_lock must be held */
1250 static void happy_meal_init_rings(struct happy_meal *hp) in happy_meal_init_rings() argument
1252 struct hmeal_init_block *hb = hp->happy_block; in happy_meal_init_rings()
1256 hp->rx_new = hp->rx_old = hp->tx_new = hp->tx_old = 0; in happy_meal_init_rings()
1260 happy_meal_clean_rings(hp); in happy_meal_init_rings()
1270 hme_write_rxd(hp, &hb->happy_meal_rxd[i], 0, 0); in happy_meal_init_rings()
1273 hp->rx_skbs[i] = skb; in happy_meal_init_rings()
1277 mapping = dma_map_single(hp->dma_dev, skb->data, RX_BUF_ALLOC_SIZE, in happy_meal_init_rings()
1279 if (dma_mapping_error(hp->dma_dev, mapping)) { in happy_meal_init_rings()
1281 hme_write_rxd(hp, &hb->happy_meal_rxd[i], 0, 0); in happy_meal_init_rings()
1284 hme_write_rxd(hp, &hb->happy_meal_rxd[i], in happy_meal_init_rings()
1292 hme_write_txd(hp, &hb->happy_meal_txd[i], 0, 0); in happy_meal_init_rings()
1297 /* hp->happy_lock must be held */
1299 happy_meal_begin_auto_negotiation(struct happy_meal *hp, in happy_meal_begin_auto_negotiation() argument
1306 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_begin_auto_negotiation()
1307 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
1308 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_begin_auto_negotiation()
1309 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_begin_auto_negotiation()
1313 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_begin_auto_negotiation()
1316 if (hp->sw_bmsr & BMSR_10HALF) in happy_meal_begin_auto_negotiation()
1317 hp->sw_advertise |= (ADVERTISE_10HALF); in happy_meal_begin_auto_negotiation()
1319 hp->sw_advertise &= ~(ADVERTISE_10HALF); in happy_meal_begin_auto_negotiation()
1321 if (hp->sw_bmsr & BMSR_10FULL) in happy_meal_begin_auto_negotiation()
1322 hp->sw_advertise |= (ADVERTISE_10FULL); in happy_meal_begin_auto_negotiation()
1324 hp->sw_advertise &= ~(ADVERTISE_10FULL); in happy_meal_begin_auto_negotiation()
1325 if (hp->sw_bmsr & BMSR_100HALF) in happy_meal_begin_auto_negotiation()
1326 hp->sw_advertise |= (ADVERTISE_100HALF); in happy_meal_begin_auto_negotiation()
1328 hp->sw_advertise &= ~(ADVERTISE_100HALF); in happy_meal_begin_auto_negotiation()
1329 if (hp->sw_bmsr & BMSR_100FULL) in happy_meal_begin_auto_negotiation()
1330 hp->sw_advertise |= (ADVERTISE_100FULL); in happy_meal_begin_auto_negotiation()
1332 hp->sw_advertise &= ~(ADVERTISE_100FULL); in happy_meal_begin_auto_negotiation()
1333 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_begin_auto_negotiation()
1342 ASD(("%s: Advertising [ ", hp->dev->name)); in happy_meal_begin_auto_negotiation()
1343 if (hp->sw_advertise & ADVERTISE_10HALF) in happy_meal_begin_auto_negotiation()
1345 if (hp->sw_advertise & ADVERTISE_10FULL) in happy_meal_begin_auto_negotiation()
1347 if (hp->sw_advertise & ADVERTISE_100HALF) in happy_meal_begin_auto_negotiation()
1349 if (hp->sw_advertise & ADVERTISE_100FULL) in happy_meal_begin_auto_negotiation()
1354 hp->sw_bmcr |= BMCR_ANENABLE; in happy_meal_begin_auto_negotiation()
1355 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1358 hp->sw_bmcr |= BMCR_ANRESTART; in happy_meal_begin_auto_negotiation()
1359 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1365 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
1366 if (!(hp->sw_bmcr & BMCR_ANRESTART)) in happy_meal_begin_auto_negotiation()
1372 "BMCR=0x%04x\n", hp->dev->name, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1374 hp->dev->name); in happy_meal_begin_auto_negotiation()
1377 hp->timer_state = arbwait; in happy_meal_begin_auto_negotiation()
1390 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_begin_auto_negotiation()
1393 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_begin_auto_negotiation()
1395 hp->sw_bmcr = 0; in happy_meal_begin_auto_negotiation()
1397 hp->sw_bmcr |= BMCR_FULLDPLX; in happy_meal_begin_auto_negotiation()
1399 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1401 if (!is_lucent_phy(hp)) { in happy_meal_begin_auto_negotiation()
1406 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_begin_auto_negotiation()
1408 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_begin_auto_negotiation()
1409 happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, in happy_meal_begin_auto_negotiation()
1410 hp->sw_csconfig); in happy_meal_begin_auto_negotiation()
1412 hp->timer_state = ltrywait; in happy_meal_begin_auto_negotiation()
1415 hp->timer_ticks = 0; in happy_meal_begin_auto_negotiation()
1416 hp->happy_timer.expires = jiffies + (12 * HZ)/10; /* 1.2 sec. */ in happy_meal_begin_auto_negotiation()
1417 add_timer(&hp->happy_timer); in happy_meal_begin_auto_negotiation()
1420 /* hp->happy_lock must be held */
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()
1710 /* hp->happy_lock must be held */
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()
1769 * hp->happy_lock must be held
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()
1884 /* hp->happy_lock must be held */
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()
1918 /* hp->happy_lock must be held */
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()
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()
1968 hp->tx_old = elem; in happy_meal_tx()
1972 TX_BUFFS_AVAIL(hp) > (MAX_SKB_FRAGS + 1)) in happy_meal_tx()
1989 * hp->happy_lock must be held
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()
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()
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()
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()
2440 struct happy_meal *hp = netdev_priv(dev); in hme_get_link_ksettings() local
2454 spin_lock_irq(&hp->happy_lock); in hme_get_link_ksettings()
2455 hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR); in hme_get_link_ksettings()
2456 hp->sw_lpa = happy_meal_tcvr_read(hp, hp->tcvregs, MII_LPA); in hme_get_link_ksettings()
2457 spin_unlock_irq(&hp->happy_lock); in hme_get_link_ksettings()
2459 if (hp->sw_bmcr & BMCR_ANENABLE) { in hme_get_link_ksettings()
2461 speed = ((hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ? in hme_get_link_ksettings()
2465 (hp->sw_lpa & (LPA_100FULL)) ? in hme_get_link_ksettings()
2469 (hp->sw_lpa & (LPA_10FULL)) ? in hme_get_link_ksettings()
2473 speed = (hp->sw_bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10; in hme_get_link_ksettings()
2475 (hp->sw_bmcr & BMCR_FULLDPLX) ? in hme_get_link_ksettings()
2488 struct happy_meal *hp = netdev_priv(dev); in hme_set_link_ksettings() local
2502 spin_lock_irq(&hp->happy_lock); in hme_set_link_ksettings()
2503 del_timer(&hp->happy_timer); in hme_set_link_ksettings()
2504 happy_meal_begin_auto_negotiation(hp, hp->tcvregs, cmd); in hme_set_link_ksettings()
2505 spin_unlock_irq(&hp->happy_lock); in hme_set_link_ksettings()
2512 struct happy_meal *hp = netdev_priv(dev); in hme_get_drvinfo() local
2516 if (hp->happy_flags & HFLAG_PCI) { in hme_get_drvinfo()
2517 struct pci_dev *pdev = hp->happy_dev; in hme_get_drvinfo()
2523 struct platform_device *op = hp->happy_dev; in hme_get_drvinfo()
2535 struct happy_meal *hp = netdev_priv(dev); in hme_get_link() local
2537 spin_lock_irq(&hp->happy_lock); in hme_get_link()
2538 hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR); in hme_get_link()
2539 spin_unlock_irq(&hp->happy_lock); in hme_get_link()
2541 return hp->sw_bmsr & BMSR_LSTATUS; in hme_get_link()
2686 struct happy_meal *hp; in happy_meal_sbus_probe_one() local
2740 hp = netdev_priv(dev); in happy_meal_sbus_probe_one()
2742 hp->happy_dev = op; in happy_meal_sbus_probe_one()
2743 hp->dma_dev = &op->dev; in happy_meal_sbus_probe_one()
2745 spin_lock_init(&hp->happy_lock); in happy_meal_sbus_probe_one()
2749 hp->qfe_parent = qp; in happy_meal_sbus_probe_one()
2750 hp->qfe_ent = qfe_slot; in happy_meal_sbus_probe_one()
2754 hp->gregs = of_ioremap(&op->resource[0], 0, in happy_meal_sbus_probe_one()
2756 if (!hp->gregs) { in happy_meal_sbus_probe_one()
2761 hp->etxregs = of_ioremap(&op->resource[1], 0, in happy_meal_sbus_probe_one()
2763 if (!hp->etxregs) { in happy_meal_sbus_probe_one()
2768 hp->erxregs = of_ioremap(&op->resource[2], 0, in happy_meal_sbus_probe_one()
2770 if (!hp->erxregs) { in happy_meal_sbus_probe_one()
2775 hp->bigmacregs = of_ioremap(&op->resource[3], 0, in happy_meal_sbus_probe_one()
2777 if (!hp->bigmacregs) { in happy_meal_sbus_probe_one()
2782 hp->tcvregs = of_ioremap(&op->resource[4], 0, in happy_meal_sbus_probe_one()
2784 if (!hp->tcvregs) { in happy_meal_sbus_probe_one()
2789 hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); in happy_meal_sbus_probe_one()
2790 if (hp->hm_revision == 0xff) in happy_meal_sbus_probe_one()
2791 hp->hm_revision = 0xa0; in happy_meal_sbus_probe_one()
2794 if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21) in happy_meal_sbus_probe_one()
2795 hp->happy_flags = HFLAG_20_21; in happy_meal_sbus_probe_one()
2796 else if (hp->hm_revision != 0xa0) in happy_meal_sbus_probe_one()
2797 hp->happy_flags = HFLAG_NOT_A0; in happy_meal_sbus_probe_one()
2800 hp->happy_flags |= HFLAG_QUATTRO; in happy_meal_sbus_probe_one()
2803 hp->happy_bursts = of_getintprop_default(sbus_dp, in happy_meal_sbus_probe_one()
2806 hp->happy_block = dma_alloc_coherent(hp->dma_dev, in happy_meal_sbus_probe_one()
2808 &hp->hblock_dvma, in happy_meal_sbus_probe_one()
2811 if (!hp->happy_block) in happy_meal_sbus_probe_one()
2815 hp->linkcheck = 0; in happy_meal_sbus_probe_one()
2818 hp->timer_state = asleep; in happy_meal_sbus_probe_one()
2819 hp->timer_ticks = 0; in happy_meal_sbus_probe_one()
2821 timer_setup(&hp->happy_timer, happy_meal_timer, 0); in happy_meal_sbus_probe_one()
2823 hp->dev = dev; in happy_meal_sbus_probe_one()
2832 hp->irq = op->archdata.irqs[0]; in happy_meal_sbus_probe_one()
2836 hp->read_desc32 = sbus_hme_read_desc32; in happy_meal_sbus_probe_one()
2837 hp->write_txd = sbus_hme_write_txd; in happy_meal_sbus_probe_one()
2838 hp->write_rxd = sbus_hme_write_rxd; in happy_meal_sbus_probe_one()
2839 hp->read32 = sbus_hme_read32; in happy_meal_sbus_probe_one()
2840 hp->write32 = sbus_hme_write32; in happy_meal_sbus_probe_one()
2846 spin_lock_irq(&hp->happy_lock); in happy_meal_sbus_probe_one()
2847 happy_meal_set_initial_advertisement(hp); in happy_meal_sbus_probe_one()
2848 spin_unlock_irq(&hp->happy_lock); in happy_meal_sbus_probe_one()
2850 err = register_netdev(hp->dev); in happy_meal_sbus_probe_one()
2857 platform_set_drvdata(op, hp); in happy_meal_sbus_probe_one()
2871 dma_free_coherent(hp->dma_dev, in happy_meal_sbus_probe_one()
2873 hp->happy_block, in happy_meal_sbus_probe_one()
2874 hp->hblock_dvma); in happy_meal_sbus_probe_one()
2877 if (hp->gregs) in happy_meal_sbus_probe_one()
2878 of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); in happy_meal_sbus_probe_one()
2879 if (hp->etxregs) in happy_meal_sbus_probe_one()
2880 of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); in happy_meal_sbus_probe_one()
2881 if (hp->erxregs) in happy_meal_sbus_probe_one()
2882 of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); in happy_meal_sbus_probe_one()
2883 if (hp->bigmacregs) in happy_meal_sbus_probe_one()
2884 of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); in happy_meal_sbus_probe_one()
2885 if (hp->tcvregs) in happy_meal_sbus_probe_one()
2886 of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); in happy_meal_sbus_probe_one()
2991 struct happy_meal *hp; in happy_meal_pci_probe() local
3036 hp = netdev_priv(dev); in happy_meal_pci_probe()
3038 hp->happy_dev = pdev; in happy_meal_pci_probe()
3039 hp->dma_dev = &pdev->dev; in happy_meal_pci_probe()
3041 spin_lock_init(&hp->happy_lock); in happy_meal_pci_probe()
3044 hp->qfe_parent = qp; in happy_meal_pci_probe()
3045 hp->qfe_ent = qfe_slot; in happy_meal_pci_probe()
3093 hp->gregs = (hpreg_base + 0x0000UL); in happy_meal_pci_probe()
3094 hp->etxregs = (hpreg_base + 0x2000UL); in happy_meal_pci_probe()
3095 hp->erxregs = (hpreg_base + 0x4000UL); in happy_meal_pci_probe()
3096 hp->bigmacregs = (hpreg_base + 0x6000UL); in happy_meal_pci_probe()
3097 hp->tcvregs = (hpreg_base + 0x7000UL); in happy_meal_pci_probe()
3100 hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); in happy_meal_pci_probe()
3101 if (hp->hm_revision == 0xff) in happy_meal_pci_probe()
3102 hp->hm_revision = 0xc0 | (pdev->revision & 0x0f); in happy_meal_pci_probe()
3105 hp->hm_revision = 0x20; in happy_meal_pci_probe()
3109 if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21) in happy_meal_pci_probe()
3110 hp->happy_flags = HFLAG_20_21; in happy_meal_pci_probe()
3111 else if (hp->hm_revision != 0xa0 && hp->hm_revision != 0xc0) in happy_meal_pci_probe()
3112 hp->happy_flags = HFLAG_NOT_A0; in happy_meal_pci_probe()
3115 hp->happy_flags |= HFLAG_QUATTRO; in happy_meal_pci_probe()
3118 hp->happy_flags |= HFLAG_PCI; in happy_meal_pci_probe()
3122 hp->happy_bursts = DMA_BURSTBITS; in happy_meal_pci_probe()
3125 hp->happy_block = dma_alloc_coherent(&pdev->dev, PAGE_SIZE, in happy_meal_pci_probe()
3126 &hp->hblock_dvma, GFP_KERNEL); in happy_meal_pci_probe()
3128 if (!hp->happy_block) in happy_meal_pci_probe()
3131 hp->linkcheck = 0; in happy_meal_pci_probe()
3132 hp->timer_state = asleep; in happy_meal_pci_probe()
3133 hp->timer_ticks = 0; in happy_meal_pci_probe()
3135 timer_setup(&hp->happy_timer, happy_meal_timer, 0); in happy_meal_pci_probe()
3137 hp->irq = pdev->irq; in happy_meal_pci_probe()
3138 hp->dev = dev; in happy_meal_pci_probe()
3149 hp->read_desc32 = pci_hme_read_desc32; in happy_meal_pci_probe()
3150 hp->write_txd = pci_hme_write_txd; in happy_meal_pci_probe()
3151 hp->write_rxd = pci_hme_write_rxd; in happy_meal_pci_probe()
3152 hp->read32 = pci_hme_read32; in happy_meal_pci_probe()
3153 hp->write32 = pci_hme_write32; in happy_meal_pci_probe()
3159 spin_lock_irq(&hp->happy_lock); in happy_meal_pci_probe()
3160 happy_meal_set_initial_advertisement(hp); in happy_meal_pci_probe()
3161 spin_unlock_irq(&hp->happy_lock); in happy_meal_pci_probe()
3163 err = register_netdev(hp->dev); in happy_meal_pci_probe()
3170 pci_set_drvdata(pdev, hp); in happy_meal_pci_probe()
3201 iounmap(hp->gregs); in happy_meal_pci_probe()
3218 struct happy_meal *hp = pci_get_drvdata(pdev); in happy_meal_pci_remove() local
3219 struct net_device *net_dev = hp->dev; in happy_meal_pci_remove()
3223 dma_free_coherent(hp->dma_dev, PAGE_SIZE, in happy_meal_pci_remove()
3224 hp->happy_block, hp->hblock_dvma); in happy_meal_pci_remove()
3225 iounmap(hp->gregs); in happy_meal_pci_remove()
3226 pci_release_regions(hp->happy_dev); in happy_meal_pci_remove()
3288 struct happy_meal *hp = platform_get_drvdata(op); in hme_sbus_remove() local
3289 struct net_device *net_dev = hp->dev; in hme_sbus_remove()
3295 of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); in hme_sbus_remove()
3296 of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); in hme_sbus_remove()
3297 of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); in hme_sbus_remove()
3298 of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); in hme_sbus_remove()
3299 of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); in hme_sbus_remove()
3300 dma_free_coherent(hp->dma_dev, in hme_sbus_remove()
3302 hp->happy_block, in hme_sbus_remove()
3303 hp->hblock_dvma); in hme_sbus_remove()