Lines Matching refs:tregs

261 static void BB_PUT_BIT(struct happy_meal *hp, void __iomem *tregs, int bit)  in BB_PUT_BIT()  argument
263 hme_write32(hp, tregs + TCVR_BBDATA, bit); in BB_PUT_BIT()
264 hme_write32(hp, tregs + TCVR_BBCLOCK, 0); in BB_PUT_BIT()
265 hme_write32(hp, tregs + TCVR_BBCLOCK, 1); in BB_PUT_BIT()
269 static u32 BB_GET_BIT(struct happy_meal *hp, void __iomem *tregs, int internal)
273 hme_write32(hp, tregs + TCVR_BBCLOCK, 0);
274 hme_write32(hp, tregs + TCVR_BBCLOCK, 1);
275 ret = hme_read32(hp, tregs + TCVR_CFG);
285 static u32 BB_GET_BIT2(struct happy_meal *hp, void __iomem *tregs, int internal) in BB_GET_BIT2() argument
289 hme_write32(hp, tregs + TCVR_BBCLOCK, 0); in BB_GET_BIT2()
291 retval = hme_read32(hp, tregs + TCVR_CFG); in BB_GET_BIT2()
296 hme_write32(hp, tregs + TCVR_BBCLOCK, 1); in BB_GET_BIT2()
304 void __iomem *tregs, int reg) in happy_meal_bb_read() argument
311 hme_write32(hp, tregs + TCVR_BBOENAB, 1); in happy_meal_bb_read()
315 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
318 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_read()
319 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
320 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_read()
321 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_read()
326 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_read()
331 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_read()
334 hme_write32(hp, tregs + TCVR_BBOENAB, 0); in happy_meal_bb_read()
337 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
339 retval |= BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
340 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
341 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
342 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
348 void __iomem *tregs, int reg, in happy_meal_bb_write() argument
357 hme_write32(hp, tregs + TCVR_BBOENAB, 1); in happy_meal_bb_write()
361 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
364 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
365 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
366 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
367 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
372 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_write()
377 BB_PUT_BIT(hp, tregs, ((tmp >> i) & 1)); in happy_meal_bb_write()
380 BB_PUT_BIT(hp, tregs, 1); in happy_meal_bb_write()
381 BB_PUT_BIT(hp, tregs, 0); in happy_meal_bb_write()
384 BB_PUT_BIT(hp, tregs, ((value >> i) & 1)); in happy_meal_bb_write()
387 hme_write32(hp, tregs + TCVR_BBOENAB, 0); in happy_meal_bb_write()
393 void __iomem *tregs, int reg) in happy_meal_tcvr_read() argument
405 return happy_meal_bb_read(hp, tregs, reg); in happy_meal_tcvr_read()
408 hme_write32(hp, tregs + TCVR_FRAME, in happy_meal_tcvr_read()
410 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries) in happy_meal_tcvr_read()
416 retval = hme_read32(hp, tregs + TCVR_FRAME) & 0xffff; in happy_meal_tcvr_read()
424 void __iomem *tregs, int reg, in happy_meal_tcvr_write() argument
433 happy_meal_bb_write(hp, tregs, reg, value); in happy_meal_tcvr_write()
438 hme_write32(hp, tregs + TCVR_FRAME, in happy_meal_tcvr_write()
441 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries) in happy_meal_tcvr_write()
483 static int try_next_permutation(struct happy_meal *hp, void __iomem *tregs) in try_next_permutation() argument
485 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in try_next_permutation()
492 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in try_next_permutation()
499 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in try_next_permutation()
507 static void display_link_mode(struct happy_meal *hp, void __iomem *tregs) in display_link_mode() argument
509 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in display_link_mode()
518 static void display_forced_link_mode(struct happy_meal *hp, void __iomem *tregs) in display_forced_link_mode() argument
520 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in display_forced_link_mode()
529 static int set_happy_link_modes(struct happy_meal *hp, void __iomem *tregs) in set_happy_link_modes() argument
537 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in set_happy_link_modes()
550 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in set_happy_link_modes()
591 void __iomem *tregs = hp->tcvregs; in is_lucent_phy() local
595 mr2 = happy_meal_tcvr_read(hp, tregs, 2); in is_lucent_phy()
596 mr3 = happy_meal_tcvr_read(hp, tregs, 3); in is_lucent_phy()
607 void __iomem *tregs, in happy_meal_begin_auto_negotiation() argument
613 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_begin_auto_negotiation()
614 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
615 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_begin_auto_negotiation()
616 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_begin_auto_negotiation()
620 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_begin_auto_negotiation()
640 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_begin_auto_negotiation()
656 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
660 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
666 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
701 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
708 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_begin_auto_negotiation()
711 happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, in happy_meal_begin_auto_negotiation()
725 void __iomem *tregs = hp->tcvregs; in happy_meal_timer() local
739 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_timer()
743 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_timer()
750 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, DP83840_CSCONFIG); in happy_meal_timer()
752 happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
759 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
764 ret = set_happy_link_modes(hp, tregs); in happy_meal_timer()
790 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
795 display_link_mode(hp, tregs); in happy_meal_timer()
816 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
817 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, DP83840_CSCONFIG); in happy_meal_timer()
824 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
833 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
841 display_forced_link_mode(hp, tregs); in happy_meal_timer()
842 set_happy_link_modes(hp, tregs); /* XXX error? then what? */ in happy_meal_timer()
849 ret = try_next_permutation(hp, tregs); in happy_meal_timer()
859 happy_meal_begin_auto_negotiation(hp, tregs, NULL); in happy_meal_timer()
863 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_timer()
866 happy_meal_tcvr_write(hp, tregs, in happy_meal_timer()
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()
1000 hme_write32(hp, tregs + TCVR_CFG, tconfig & ~(TCV_CFG_PSELECT)); in happy_meal_tcvr_reset()
1003 happy_meal_tcvr_write(hp, tregs, MII_BMCR, in happy_meal_tcvr_reset()
1005 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1011 hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT); in happy_meal_tcvr_reset()
1016 hme_write32(hp, tregs + TCVR_CFG, (tconfig | TCV_CFG_PSELECT)); in happy_meal_tcvr_reset()
1017 happy_meal_tcvr_write(hp, tregs, MII_BMCR, in happy_meal_tcvr_reset()
1019 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1025 hme_write32(hp, tregs + TCVR_CFG, (tconfig & ~(TCV_CFG_PSELECT))); in happy_meal_tcvr_reset()
1032 happy_meal_tcvr_write(hp, tregs, MII_BMCR, BMCR_RESET); in happy_meal_tcvr_reset()
1035 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1050 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_tcvr_reset()
1051 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_tcvr_reset()
1052 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_tcvr_reset()
1053 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_tcvr_reset()
1057 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_tcvr_reset()
1061 result = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_tcvr_reset()
1074 result = happy_meal_tcvr_read(hp, tregs, in happy_meal_tcvr_reset()
1076 happy_meal_tcvr_write(hp, tregs, in happy_meal_tcvr_reset()
1086 static void happy_meal_transceiver_check(struct happy_meal *hp, void __iomem *tregs) in happy_meal_transceiver_check() argument
1088 unsigned long tconfig = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_transceiver_check()
1089 u32 reread = hme_read32(hp, tregs + TCVR_CFG); in happy_meal_transceiver_check()
1093 hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT); in happy_meal_transceiver_check()
1099 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_transceiver_check()
1263 void __iomem *tregs = hp->tcvregs; in happy_meal_init() local
1288 hme_read32(hp, tregs + TCVR_CFG)); in happy_meal_init()
1289 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_init()
1290 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE)); in happy_meal_init()
1293 hme_read32(hp, tregs + TCVR_CFG)); in happy_meal_init()
1294 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_init()
1295 hme_read32(hp, tregs + TCVR_CFG) | TCV_CFG_BENABLE); in happy_meal_init()
1300 happy_meal_transceiver_check(hp, tregs); in happy_meal_init()
1322 if (happy_meal_tcvr_reset(hp, tregs)) in happy_meal_init()
1525 happy_meal_begin_auto_negotiation(hp, tregs, NULL); in happy_meal_init()
1534 void __iomem *tregs = hp->tcvregs; in happy_meal_set_initial_advertisement() local
1540 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_set_initial_advertisement()
1541 hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE)); in happy_meal_set_initial_advertisement()
1543 hme_write32(hp, tregs + TCVR_CFG, in happy_meal_set_initial_advertisement()
1544 hme_read32(hp, tregs + TCVR_CFG) | TCV_CFG_BENABLE); in happy_meal_set_initial_advertisement()
1545 happy_meal_transceiver_check(hp, tregs); in happy_meal_set_initial_advertisement()
1556 if (happy_meal_tcvr_reset(hp, tregs)) in happy_meal_set_initial_advertisement()
1560 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_set_initial_advertisement()
1561 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_set_initial_advertisement()
1583 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_set_initial_advertisement()