• Home
  • Raw
  • Download

Lines Matching refs:sc

137 static int axe_miibus_writereg(struct axe_softc *sc, int reg, int val);
138 static uint16_t axe_miibus_readreg(struct axe_softc *sc, int reg);
220 axe_cmd(struct axe_softc *sc, int cmd, int index, int val, void *buf) in axe_cmd() argument
225 AXE_LOCK_ASSERT(sc, MA_OWNED); in axe_cmd()
235 err = uether_do_request(&sc->sc_ue, &req, buf, 10000); in axe_cmd()
242 axe_miibus_readreg(struct axe_softc *sc, int reg) in axe_miibus_readreg() argument
246 axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL); in axe_miibus_readreg()
247 axe_cmd(sc, AXE_CMD_MII_READ_REG, reg, 0x10, &val); in axe_miibus_readreg()
248 axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL); in axe_miibus_readreg()
251 if (AXE_IS_772(sc) && reg == MII_BMSR) { in axe_miibus_readreg()
264 axe_miibus_writereg(struct axe_softc *sc, int reg, int val) in axe_miibus_writereg() argument
268 axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL); in axe_miibus_writereg()
269 axe_cmd(sc, AXE_CMD_MII_WRITE_REG, reg, 0x10, &val); in axe_miibus_writereg()
270 axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL); in axe_miibus_writereg()
275 axe_setmedium(struct axe_softc *sc) in axe_setmedium() argument
282 bmcr = axe_miibus_readreg(sc, 0); in axe_setmedium()
304 axe_cmd(sc, AXE_CMD_WRITE_MEDIA, 0, val, NULL); in axe_setmedium()
314 axe_get_phyno(struct axe_softc *sc, int sel) in axe_get_phyno() argument
318 switch (AXE_PHY_TYPE(sc->sc_phyaddrs[sel])) { in axe_get_phyno()
321 phyno = AXE_PHY_NO(sc->sc_phyaddrs[sel]); in axe_get_phyno()
344 axe_cmd(sc, AXE_CMD_WRITE_GPIO, 0, (x), NULL); \
349 axe_ax88178_init(struct axe_softc *sc) in axe_ax88178_init() argument
355 ue = &sc->sc_ue; in axe_ax88178_init()
356 axe_cmd(sc, AXE_CMD_SROM_WR_ENABLE, 0, 0, NULL); in axe_ax88178_init()
358 axe_cmd(sc, AXE_CMD_SROM_READ, 0, 0x0017, &eeprom); in axe_ax88178_init()
360 axe_cmd(sc, AXE_CMD_SROM_WR_DISABLE, 0, 0, NULL); in axe_ax88178_init()
430 (void) axe_miibus_writereg(sc, 0x1F, 0x0005); in axe_ax88178_init()
431 (void) axe_miibus_writereg(sc, 0x0C, 0x0000); in axe_ax88178_init()
432 val = axe_miibus_readreg(sc, 0x0001); in axe_ax88178_init()
433 (void) axe_miibus_writereg(sc, 0x01, val | 0x0080); in axe_ax88178_init()
434 (void) axe_miibus_writereg(sc, 0x1F, 0x0000); in axe_ax88178_init()
443 axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, AXE_SW_RESET_CLEAR, NULL); in axe_ax88178_init()
446 axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, in axe_ax88178_init()
450 axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0, 0, NULL); in axe_ax88178_init()
453 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, 0, NULL); in axe_ax88178_init()
457 axe_ax88772_init(struct axe_softc *sc) in axe_ax88772_init() argument
459 axe_cmd(sc, AXE_CMD_WRITE_GPIO, 0, 0x00b0, NULL); in axe_ax88772_init()
460 axe_uether_pause(&sc->sc_ue, hz / 16); in axe_ax88772_init()
462 if (sc->sc_phyno == AXE_772_PHY_NO_EPHY) { in axe_ax88772_init()
464 axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0, 0x01, NULL); in axe_ax88772_init()
465 axe_uether_pause(&sc->sc_ue, hz / 64); in axe_ax88772_init()
468 axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, in axe_ax88772_init()
470 axe_uether_pause(&sc->sc_ue, hz / 16); in axe_ax88772_init()
473 axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, in axe_ax88772_init()
475 axe_uether_pause(&sc->sc_ue, hz / 4); in axe_ax88772_init()
478 axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, AXE_SW_RESET_PRL, NULL); in axe_ax88772_init()
481 axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, in axe_ax88772_init()
485 axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0, 0x00, NULL); in axe_ax88772_init()
486 axe_uether_pause(&sc->sc_ue, hz / 64); in axe_ax88772_init()
489 axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, in axe_ax88772_init()
493 axe_uether_pause(&sc->sc_ue, hz / 4); in axe_ax88772_init()
494 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, 0, NULL); in axe_ax88772_init()
498 axe_ax88772_phywake(struct axe_softc *sc) in axe_ax88772_phywake() argument
500 if (sc->sc_phyno == AXE_772_PHY_NO_EPHY) { in axe_ax88772_phywake()
502 axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0, AXE_SW_PHY_SELECT_SS_ENB | in axe_ax88772_phywake()
505 axe_uether_pause(&sc->sc_ue, hz / 32); in axe_ax88772_phywake()
511 axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0, AXE_SW_PHY_SELECT_SS_ENB | in axe_ax88772_phywake()
513 axe_uether_pause(&sc->sc_ue, hz / 32); in axe_ax88772_phywake()
516 axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, AXE_SW_RESET_IPPD | in axe_ax88772_phywake()
518 axe_uether_pause(&sc->sc_ue, hz / 4); in axe_ax88772_phywake()
519 axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, AXE_SW_RESET_IPRL, NULL); in axe_ax88772_phywake()
520 axe_uether_pause(&sc->sc_ue, hz); in axe_ax88772_phywake()
521 axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, AXE_SW_RESET_CLEAR, NULL); in axe_ax88772_phywake()
522 axe_uether_pause(&sc->sc_ue, hz / 32); in axe_ax88772_phywake()
523 axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, AXE_SW_RESET_IPRL, NULL); in axe_ax88772_phywake()
524 axe_uether_pause(&sc->sc_ue, hz / 32); in axe_ax88772_phywake()
528 axe_ax88772b_init(struct axe_softc *sc) in axe_ax88772b_init() argument
530 struct usb_ether *ue = &sc->sc_ue; in axe_ax88772b_init()
543 axe_cmd(sc, AXE_CMD_SROM_READ, 0, AXE_EEPROM_772B_PHY_PWRCFG, &eeprom); in axe_ax88772b_init()
544 sc->sc_pwrcfg = le16toh(eeprom) & 0xFF00; in axe_ax88772b_init()
555 axe_cmd(sc, AXE_CMD_SROM_READ, 0, AXE_EEPROM_772B_NODE_ID + i, &eeprom); in axe_ax88772b_init()
562 axe_cmd(sc, AXE_178_CMD_WRITE_NODEID, 0, 0, ue->ue_eaddr); in axe_ax88772b_init()
567 axe_ax88772_phywake(sc); in axe_ax88772b_init()
569 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, 0, NULL); in axe_ax88772b_init()
574 sc->sc_flags &= ~AXE_FLAG_LINK; in axe_ax88772b_init()
576 usbd_transfer_start(sc->sc_xfer[AXE_BULK_DT_RD]); in axe_ax88772b_init()
582 axe_reset(struct axe_softc *sc) in axe_reset() argument
587 cd = usbd_get_config_descriptor(sc->sc_ue.ue_udev); in axe_reset()
588 err = usbd_req_set_config(sc->sc_ue.ue_udev, &sc->sc_mtx, in axe_reset()
594 axe_uether_pause(&sc->sc_ue, hz / 100); in axe_reset()
596 if (sc->sc_flags & AXE_FLAG_178) in axe_reset()
597 axe_ax88178_init(sc); in axe_reset()
598 else if (sc->sc_flags & AXE_FLAG_772) in axe_reset()
599 axe_ax88772_init(sc); in axe_reset()
600 else if (sc->sc_flags & AXE_FLAG_772A) in axe_reset()
601 axe_ax88772b_init(sc); in axe_reset()
602 else if (sc->sc_flags & AXE_FLAG_772B) in axe_reset()
603 axe_ax88772b_init(sc); in axe_reset()
605 axe_cmd(sc, AXE_CMD_WRITE_MEDIA, 0, in axe_reset()
613 struct axe_softc *sc = uether_getsc(ue); in axe_attach_post() local
617 axe_cmd(sc, AXE_CMD_READ_PHYID, 0, 0, sc->sc_phyaddrs); in axe_attach_post()
618 sc->sc_phyno = axe_get_phyno(sc, AXE_PHY_SEL_PRI); in axe_attach_post()
619 if (sc->sc_phyno == -1) in axe_attach_post()
620 sc->sc_phyno = axe_get_phyno(sc, AXE_PHY_SEL_SEC); in axe_attach_post()
621 if (sc->sc_phyno == -1) { in axe_attach_post()
622 device_printf(sc->sc_ue.ue_dev, in axe_attach_post()
624 sc->sc_phyno = 0; in axe_attach_post()
629 if (sc->sc_flags & (AXE_FLAG_772A | AXE_FLAG_772B)) { in axe_attach_post()
631 sc->sc_ipgs[0] = 0x15; in axe_attach_post()
632 sc->sc_ipgs[1] = 0x16; in axe_attach_post()
633 sc->sc_ipgs[2] = 0x1A; in axe_attach_post()
635 axe_cmd(sc, AXE_CMD_READ_IPG012, 0, 0, sc->sc_ipgs); in axe_attach_post()
655 axe_miibus_statchg(struct axe_softc *sc, uint16_t link_status) in axe_miibus_statchg() argument
657 struct usb_ether *ue = &sc->sc_ue; in axe_miibus_statchg()
663 if (sc->sc_flags & AXE_FLAG_772A) { in axe_miibus_statchg()
666 else if (sc->sc_flags & AXE_FLAG_772B) { in axe_miibus_statchg()
670 (void) axe_setmedium(sc); in axe_miibus_statchg()
676 if (sc->sc_flags & AXE_FLAG_772A) in axe_miibus_statchg()
678 else if (sc->sc_flags & AXE_FLAG_772B) in axe_miibus_statchg()
694 struct axe_softc *sc = device_get_softc(dev); in axe_attach() local
695 struct usb_ether *ue = &sc->sc_ue; in axe_attach()
698 sc->sc_flags = USB_GET_DRIVER_INFO(uaa); in axe_attach()
699 sc->sc_link_status = AXE_LINK_MASK; in axe_attach()
703 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_RECURSE); in axe_attach()
706 error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, in axe_attach()
707 axe_config, AXE_N_TRANSFER, sc, &sc->sc_mtx); in axe_attach()
713 ue->ue_sc = sc; in axe_attach()
716 ue->ue_mtx = &sc->sc_mtx; in axe_attach()
733 struct axe_softc *sc = device_get_softc(dev); in axe_detach() local
734 struct usb_ether *ue = &sc->sc_ue; in axe_detach()
736 usbd_transfer_unsetup(sc->sc_xfer, AXE_N_TRANSFER); in axe_detach()
738 mtx_destroy(&sc->sc_mtx); in axe_detach()
750 struct axe_softc *sc = usbd_xfer_softc(xfer); in axe_bulk_read_callback() local
751 struct usb_ether *ue = &sc->sc_ue; in axe_bulk_read_callback()
783 struct axe_softc *sc = ue->ue_sc; in axe_rx_frame() local
792 if ((sc->sc_flags & AXE_FLAG_STD_FRAME) != 0) { in axe_rx_frame()
801 if ((hdr.len ^ hdr.ilen) != sc->sc_lenmask) { in axe_rx_frame()
816 } else if ((sc->sc_flags & AXE_FLAG_CSUM_FRAME) != 0) { in axe_rx_frame()
830 sc->sc_lenmask) { in axe_rx_frame()
903 struct axe_softc *sc = usbd_xfer_softc(xfer); in axe_bulk_write_callback() local
905 struct usb_ether *ue = &(sc->sc_ue); in axe_bulk_write_callback()
939 if (AXE_IS_178_FAMILY(sc)) { in axe_bulk_write_callback()
987 struct axe_softc *sc = ue->ue_sc; in axe_start() local
992 usbd_transfer_start(sc->sc_xfer[AXE_BULK_DT_WR]); in axe_start()
993 usbd_transfer_start(sc->sc_xfer[AXE_BULK_DT_RD]); in axe_start()
1005 struct axe_softc *sc = uether_getsc(ue); in axe_init() local
1012 AXE_LOCK_ASSERT(sc, MA_OWNED); in axe_init()
1018 axe_reset(sc); in axe_init()
1021 if (AXE_IS_178_FAMILY(sc)) { in axe_init()
1022 axe_cmd(sc, AXE_178_CMD_READ_NODEID, 0, 0, ue->ue_eaddr); in axe_init()
1023 axe_cmd(sc, AXE_178_CMD_WRITE_IPG012, sc->sc_ipgs[2], in axe_init()
1024 (sc->sc_ipgs[1] << 8) | (sc->sc_ipgs[0]), NULL); in axe_init()
1026 axe_cmd(sc, AXE_178_CMD_READ_NODEID, 0, 0, ue->ue_eaddr); in axe_init()
1027 axe_cmd(sc, AXE_172_CMD_WRITE_IPG0, 0, sc->sc_ipgs[0], NULL); in axe_init()
1028 axe_cmd(sc, AXE_172_CMD_WRITE_IPG1, 0, sc->sc_ipgs[1], NULL); in axe_init()
1029 axe_cmd(sc, AXE_172_CMD_WRITE_IPG2, 0, sc->sc_ipgs[2], NULL); in axe_init()
1031 if (AXE_IS_178_FAMILY(sc)) { in axe_init()
1032 sc->sc_flags &= ~(AXE_FLAG_STD_FRAME | AXE_FLAG_CSUM_FRAME); in axe_init()
1033 sc->sc_lenmask = AXE_HDR_LEN_MASK; in axe_init()
1034 sc->sc_flags |= AXE_FLAG_STD_FRAME; in axe_init()
1038 if (sc->sc_flags & AXE_FLAG_772B) { in axe_init()
1040 axe_cmd(sc, AXE_772B_CMD_RXCTL_WRITE_CFG, in axe_init()
1047 if (AXE_IS_178_FAMILY(sc)) { in axe_init()
1048 if (sc->sc_flags & AXE_FLAG_772B) { in axe_init()
1065 if (sc->sc_flags & AXE_FLAG_772A) in axe_init()
1079 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL); in axe_init()
1084 usbd_xfer_set_stall(sc->sc_xfer[AXE_BULK_DT_WR]); in axe_init()
1085 usbd_xfer_set_stall(sc->sc_xfer[AXE_BULK_DT_RD]); in axe_init()
1094 struct axe_softc *sc = uether_getsc(ue); in axe_setpromisc() local
1099 axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, &rxmode); in axe_setpromisc()
1109 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL); in axe_setpromisc()
1116 struct axe_softc *sc = uether_getsc(ue); in axe_tick() local
1119 AXE_LOCK_ASSERT(sc, MA_OWNED); in axe_tick()
1121 link_status = axe_miibus_readreg(sc, MII_BMSR) & AXE_LINK_MASK; in axe_tick()
1122 if (sc->sc_link_status != link_status) { in axe_tick()
1123 axe_miibus_statchg(sc, link_status); in axe_tick()
1124 sc->sc_link_status = link_status; in axe_tick()
1131 struct axe_softc *sc = uether_getsc(ue); in axe_stop() local
1135 AXE_LOCK_ASSERT(sc, MA_OWNED); in axe_stop()
1137 sc->sc_flags &= ~AXE_FLAG_LINK; in axe_stop()
1141 usbd_transfer_stop(sc->sc_xfer[AXE_BULK_DT_WR]); in axe_stop()
1142 usbd_transfer_stop(sc->sc_xfer[AXE_BULK_DT_RD]); in axe_stop()