Lines Matching refs:tregs

297 static void BB_PUT_BIT(struct happy_meal *hp, void __iomem *tregs, int bit)  in BB_PUT_BIT()  argument
299 hme_write32(hp, tregs + TCVR_BBDATA, bit); in BB_PUT_BIT()
300 hme_write32(hp, tregs + TCVR_BBCLOCK, 0); in BB_PUT_BIT()
301 hme_write32(hp, tregs + TCVR_BBCLOCK, 1); in BB_PUT_BIT()
305 static u32 BB_GET_BIT(struct happy_meal *hp, void __iomem *tregs, int internal)
309 hme_write32(hp, tregs + TCVR_BBCLOCK, 0);
310 hme_write32(hp, tregs + TCVR_BBCLOCK, 1);
311 ret = hme_read32(hp, tregs + TCVR_CFG);
321 static u32 BB_GET_BIT2(struct happy_meal *hp, void __iomem *tregs, int internal) in BB_GET_BIT2() argument
325 hme_write32(hp, tregs + TCVR_BBCLOCK, 0); in BB_GET_BIT2()
327 retval = hme_read32(hp, tregs + TCVR_CFG); in BB_GET_BIT2()
332 hme_write32(hp, tregs + TCVR_BBCLOCK, 1); in BB_GET_BIT2()
340 void __iomem *tregs, int reg) in happy_meal_bb_read() argument
349 hme_write32(hp, tregs + TCVR_BBOENAB, 1); in happy_meal_bb_read()
353 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
356 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_read()
357 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
358 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
359 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_read()
364 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_read()
369 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_read()
372 hme_write32(hp, tregs + TCVR_BBOENAB, 0); in happy_meal_bb_read()
375 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
377 retval |= BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
378 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
379 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
380 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
386 void __iomem *tregs, int reg, in happy_meal_bb_write() argument
395 hme_write32(hp, tregs + TCVR_BBOENAB, 1); in happy_meal_bb_write()
399 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
402 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
403 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
404 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
405 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
410 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_write()
415 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_write()
418 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
419 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
422 BB_PUT_BIT(hp, tregs, ((value >> i) & 1)); in happy_meal_bb_write()
425 hme_write32(hp, tregs + TCVR_BBOENAB, 0); in happy_meal_bb_write()
431 void __iomem *tregs, int reg) in happy_meal_tcvr_read() argument
444 return happy_meal_bb_read(hp, tregs, reg); in happy_meal_tcvr_read()
447 hme_write32(hp, tregs + TCVR_FRAME, in happy_meal_tcvr_read()
449 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries) in happy_meal_tcvr_read()
455 retval = hme_read32(hp, tregs + TCVR_FRAME) & 0xffff; in happy_meal_tcvr_read()
463 void __iomem *tregs, int reg, in happy_meal_tcvr_write() argument
472 happy_meal_bb_write(hp, tregs, reg, value); in happy_meal_tcvr_write()
477 hme_write32(hp, tregs + TCVR_FRAME, in happy_meal_tcvr_write()
480 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries) in happy_meal_tcvr_write()
522 static int try_next_permutation(struct happy_meal *hp, void __iomem *tregs) in try_next_permutation() argument
524 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in try_next_permutation()
531 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in try_next_permutation()
538 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in try_next_permutation()
546 static void display_link_mode(struct happy_meal *hp, void __iomem *tregs) in display_link_mode() argument
554 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in display_link_mode()
568 static void display_forced_link_mode(struct happy_meal *hp, void __iomem *tregs) in display_forced_link_mode() argument
576 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in display_forced_link_mode()
587 static int set_happy_link_modes(struct happy_meal *hp, void __iomem *tregs) in set_happy_link_modes() argument
595 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in set_happy_link_modes()
608 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in set_happy_link_modes()
651 void __iomem *tregs = hp->tcvregs; in is_lucent_phy() local
655 mr2 = happy_meal_tcvr_read(hp, tregs, 2); in is_lucent_phy()
656 mr3 = happy_meal_tcvr_read(hp, tregs, 3); in is_lucent_phy()
667 void __iomem *tregs = hp->tcvregs; in happy_meal_timer() local
681 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_timer()
685 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_timer()
692 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, DP83840_CSCONFIG); in happy_meal_timer()
694 happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
701 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
706 ret = set_happy_link_modes(hp, tregs); in happy_meal_timer()
732 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
737 display_link_mode(hp, tregs); in happy_meal_timer()
758 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
759 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, DP83840_CSCONFIG); in happy_meal_timer()
766 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
775 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
783 display_forced_link_mode(hp, tregs); in happy_meal_timer()
784 set_happy_link_modes(hp, tregs); /* XXX error? then what? */ in happy_meal_timer()
791 ret = try_next_permutation(hp, tregs); in happy_meal_timer()
810 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_timer()
813 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
933 static void happy_meal_poll_stop(struct happy_meal *hp, void __iomem *tregs) in happy_meal_poll_stop() argument
946 hme_write32(hp, tregs + TCVR_IMASK, 0xffff); in happy_meal_poll_stop()
950 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_poll_stop()
951 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_PENABLE)); in happy_meal_poll_stop()
968 static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs) in happy_meal_tcvr_reset() argument
973 tconfig = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_tcvr_reset()
977 hme_write32(hp, tregs + TCVR_CFG, tconfig & ~(TCV_CFG_PSELECT)); in happy_meal_tcvr_reset()
981 happy_meal_tcvr_write(hp, tregs, MII_BMCR, in happy_meal_tcvr_reset()
983 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
989 hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT); in happy_meal_tcvr_reset()
995 hme_write32(hp, tregs + TCVR_CFG, (tconfig | TCV_CFG_PSELECT)); in happy_meal_tcvr_reset()
997 happy_meal_tcvr_write(hp, tregs, MII_BMCR, in happy_meal_tcvr_reset()
999 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1005 hme_write32(hp, tregs + TCVR_CFG, (tconfig & ~(TCV_CFG_PSELECT))); in happy_meal_tcvr_reset()
1012 happy_meal_tcvr_write(hp, tregs, MII_BMCR, BMCR_RESET); in happy_meal_tcvr_reset()
1015 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1030 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_tcvr_reset()
1031 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_tcvr_reset()
1032 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_tcvr_reset()
1033 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_tcvr_reset()
1037 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_tcvr_reset()
1041 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1054 result = happy_meal_tcvr_read(hp, tregs, in happy_meal_tcvr_reset()
1056 happy_meal_tcvr_write(hp, tregs, in happy_meal_tcvr_reset()
1066 static void happy_meal_transceiver_check(struct happy_meal *hp, void __iomem *tregs) in happy_meal_transceiver_check() argument
1068 unsigned long tconfig = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_transceiver_check()
1077 happy_meal_poll_stop(hp, tregs); in happy_meal_transceiver_check()
1083 hme_write32(hp, tregs + TCVR_CFG, tconfig); in happy_meal_transceiver_check()
1088 if (!(hme_read32(hp, tregs + TCVR_STATUS) >> 16)) { in happy_meal_transceiver_check()
1090 happy_meal_poll_stop(hp, tregs); in happy_meal_transceiver_check()
1094 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_transceiver_check()
1095 hme_read32(hp, tregs + TCVR_CFG) & in happy_meal_transceiver_check()
1104 u32 reread = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_transceiver_check()
1109 hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT); in happy_meal_transceiver_check()
1115 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_transceiver_check()
1275 void __iomem *tregs, in happy_meal_begin_auto_negotiation() argument
1281 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_begin_auto_negotiation()
1282 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
1283 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_begin_auto_negotiation()
1284 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_begin_auto_negotiation()
1288 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_begin_auto_negotiation()
1308 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_begin_auto_negotiation()
1330 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1334 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1340 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
1374 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1381 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_begin_auto_negotiation()
1384 happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, in happy_meal_begin_auto_negotiation()
1403 void __iomem *tregs = hp->tcvregs; in happy_meal_init() local
1419 happy_meal_poll_stop(hp, tregs); in happy_meal_init()
1431 hme_read32(hp, tregs + TCVR_IMASK))); in happy_meal_init()
1432 hme_write32(hp, tregs + TCVR_IMASK, 0xffff); in happy_meal_init()
1437 hme_read32(hp, tregs + TCVR_CFG))); in happy_meal_init()
1438 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_init()
1439 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE)); in happy_meal_init()
1442 hme_read32(hp, tregs + TCVR_CFG))); in happy_meal_init()
1443 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_init()
1444 hme_read32(hp, tregs + TCVR_CFG) | TCV_CFG_BENABLE); in happy_meal_init()
1449 happy_meal_transceiver_check(hp, tregs); in happy_meal_init()
1472 if (happy_meal_tcvr_reset(hp, tregs)) in happy_meal_init()
1679 happy_meal_begin_auto_negotiation(hp, tregs, NULL); in happy_meal_init()
1688 void __iomem *tregs = hp->tcvregs; in happy_meal_set_initial_advertisement() local
1693 hme_write32(hp, tregs + TCVR_IMASK, 0xffff); in happy_meal_set_initial_advertisement()
1695 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_set_initial_advertisement()
1696 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE)); in happy_meal_set_initial_advertisement()
1698 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_set_initial_advertisement()
1699 hme_read32(hp, tregs + TCVR_CFG) | TCV_CFG_BENABLE); in happy_meal_set_initial_advertisement()
1700 happy_meal_transceiver_check(hp, tregs); in happy_meal_set_initial_advertisement()
1711 if (happy_meal_tcvr_reset(hp, tregs)) in happy_meal_set_initial_advertisement()
1715 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_set_initial_advertisement()
1716 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_set_initial_advertisement()
1738 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_set_initial_advertisement()
1862 void __iomem *tregs = hp->tcvregs; in happy_meal_mif_interrupt() local
1865 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_mif_interrupt()
1866 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in happy_meal_mif_interrupt()
1881 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_mif_interrupt()
1884 happy_meal_poll_stop(hp, tregs); in happy_meal_mif_interrupt()