Lines 96-111
Link Here
|
96 |
*/ |
96 |
*/ |
97 |
static const STRUCT_USB_HOST_ID ure_devs[] = { |
97 |
static const STRUCT_USB_HOST_ID ure_devs[] = { |
98 |
#define URE_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } |
98 |
#define URE_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } |
99 |
URE_DEV(LENOVO, RTL8153, 0), |
99 |
URE_DEV(LENOVO, RTL8153, URE_FLAG_8153), |
100 |
URE_DEV(LENOVO, TBT3LAN, 0), |
100 |
URE_DEV(LENOVO, TBT3LAN, 0), |
101 |
URE_DEV(LENOVO, TBT3LANGEN2, 0), |
101 |
URE_DEV(LENOVO, TBT3LANGEN2, 0), |
102 |
URE_DEV(LENOVO, ONELINK, 0), |
102 |
URE_DEV(LENOVO, ONELINK, 0), |
103 |
URE_DEV(LENOVO, USBCLAN, 0), |
103 |
URE_DEV(LENOVO, USBCLAN, 0), |
104 |
URE_DEV(LENOVO, USBCLANGEN2, 0), |
104 |
URE_DEV(LENOVO, USBCLANGEN2, 0), |
105 |
URE_DEV(NVIDIA, RTL8153, 0), |
105 |
URE_DEV(NVIDIA, RTL8153, URE_FLAG_8153), |
106 |
URE_DEV(REALTEK, RTL8152, URE_FLAG_8152), |
106 |
URE_DEV(REALTEK, RTL8152, URE_FLAG_8152), |
107 |
URE_DEV(REALTEK, RTL8153, 0), |
107 |
URE_DEV(REALTEK, RTL8153, URE_FLAG_8153), |
108 |
URE_DEV(TPLINK, RTL8153, 0), |
108 |
URE_DEV(TPLINK, RTL8153, URE_FLAG_8153), |
|
|
109 |
URE_DEV(REALTEK, RTL8156, URE_FLAG_8156), |
109 |
#undef URE_DEV |
110 |
#undef URE_DEV |
110 |
}; |
111 |
}; |
111 |
|
112 |
|
Lines 141-146
Link Here
|
141 |
static int ure_write_4(struct ure_softc *, uint16_t, uint16_t, uint32_t); |
142 |
static int ure_write_4(struct ure_softc *, uint16_t, uint16_t, uint32_t); |
142 |
static uint16_t ure_ocp_reg_read(struct ure_softc *, uint16_t); |
143 |
static uint16_t ure_ocp_reg_read(struct ure_softc *, uint16_t); |
143 |
static void ure_ocp_reg_write(struct ure_softc *, uint16_t, uint16_t); |
144 |
static void ure_ocp_reg_write(struct ure_softc *, uint16_t, uint16_t); |
|
|
145 |
static void ure_sram_write(struct ure_softc *, uint16_t, uint16_t); |
144 |
|
146 |
|
145 |
static int ure_sysctl_chipver(SYSCTL_HANDLER_ARGS); |
147 |
static int ure_sysctl_chipver(SYSCTL_HANDLER_ARGS); |
146 |
|
148 |
|
Lines 149-244
Link Here
|
149 |
static void ure_reset(struct ure_softc *); |
151 |
static void ure_reset(struct ure_softc *); |
150 |
static int ure_ifmedia_upd(struct ifnet *); |
152 |
static int ure_ifmedia_upd(struct ifnet *); |
151 |
static void ure_ifmedia_sts(struct ifnet *, struct ifmediareq *); |
153 |
static void ure_ifmedia_sts(struct ifnet *, struct ifmediareq *); |
|
|
154 |
static void ure_add_media_types(struct ure_softc *); |
155 |
static void ure_link_state(struct ure_softc *sc); |
156 |
static int ure_get_link_status(struct ure_softc *); |
152 |
static int ure_ioctl(struct ifnet *, u_long, caddr_t); |
157 |
static int ure_ioctl(struct ifnet *, u_long, caddr_t); |
153 |
static void ure_rtl8152_init(struct ure_softc *); |
158 |
static void ure_rtl8152_init(struct ure_softc *); |
|
|
159 |
static void ure_rtl8152_nic_reset(struct ure_softc *); |
154 |
static void ure_rtl8153_init(struct ure_softc *); |
160 |
static void ure_rtl8153_init(struct ure_softc *); |
|
|
161 |
static void ure_rtl8153b_init(struct ure_softc *); |
162 |
static void ure_rtl8153b_nic_reset(struct ure_softc *); |
155 |
static void ure_disable_teredo(struct ure_softc *); |
163 |
static void ure_disable_teredo(struct ure_softc *); |
156 |
static void ure_init_fifo(struct ure_softc *); |
164 |
static void ure_enable_aldps(struct ure_softc *, bool); |
|
|
165 |
static uint16_t ure_phy_status(struct ure_softc *, uint16_t); |
157 |
static void ure_rxcsum(int capenb, struct ure_rxpkt *rp, struct mbuf *m); |
166 |
static void ure_rxcsum(int capenb, struct ure_rxpkt *rp, struct mbuf *m); |
158 |
static int ure_txcsum(struct mbuf *m, int caps, uint32_t *regout); |
167 |
static int ure_txcsum(struct mbuf *m, int caps, uint32_t *regout); |
159 |
|
168 |
|
160 |
static const struct usb_config ure_config_rx[URE_N_TRANSFER] = { |
|
|
161 |
{ |
162 |
.type = UE_BULK, |
163 |
.endpoint = UE_ADDR_ANY, |
164 |
.direction = UE_DIR_IN, |
165 |
.bufsize = URE_TRANSFER_SIZE, |
166 |
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, |
167 |
.callback = ure_bulk_read_callback, |
168 |
.timeout = 0, /* no timeout */ |
169 |
}, |
170 |
{ |
171 |
.type = UE_BULK, |
172 |
.endpoint = UE_ADDR_ANY, |
173 |
.direction = UE_DIR_IN, |
174 |
.bufsize = URE_TRANSFER_SIZE, |
175 |
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, |
176 |
.callback = ure_bulk_read_callback, |
177 |
.timeout = 0, /* no timeout */ |
178 |
}, |
179 |
#if URE_N_TRANSFER == 4 |
180 |
{ |
181 |
.type = UE_BULK, |
182 |
.endpoint = UE_ADDR_ANY, |
183 |
.direction = UE_DIR_IN, |
184 |
.bufsize = URE_TRANSFER_SIZE, |
185 |
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, |
186 |
.callback = ure_bulk_read_callback, |
187 |
.timeout = 0, /* no timeout */ |
188 |
}, |
189 |
{ |
190 |
.type = UE_BULK, |
191 |
.endpoint = UE_ADDR_ANY, |
192 |
.direction = UE_DIR_IN, |
193 |
.bufsize = URE_TRANSFER_SIZE, |
194 |
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, |
195 |
.callback = ure_bulk_read_callback, |
196 |
.timeout = 0, /* no timeout */ |
197 |
}, |
198 |
#endif |
199 |
}; |
200 |
|
201 |
static const struct usb_config ure_config_tx[URE_N_TRANSFER] = { |
202 |
{ |
203 |
.type = UE_BULK, |
204 |
.endpoint = UE_ADDR_ANY, |
205 |
.direction = UE_DIR_OUT, |
206 |
.bufsize = URE_TRANSFER_SIZE, |
207 |
.flags = {.pipe_bof = 1,.force_short_xfer = 1,}, |
208 |
.callback = ure_bulk_write_callback, |
209 |
.timeout = 10000, /* 10 seconds */ |
210 |
}, |
211 |
{ |
212 |
.type = UE_BULK, |
213 |
.endpoint = UE_ADDR_ANY, |
214 |
.direction = UE_DIR_OUT, |
215 |
.bufsize = URE_TRANSFER_SIZE, |
216 |
.flags = {.pipe_bof = 1,.force_short_xfer = 1,}, |
217 |
.callback = ure_bulk_write_callback, |
218 |
.timeout = 10000, /* 10 seconds */ |
219 |
}, |
220 |
#if URE_N_TRANSFER == 4 |
221 |
{ |
222 |
.type = UE_BULK, |
223 |
.endpoint = UE_ADDR_ANY, |
224 |
.direction = UE_DIR_OUT, |
225 |
.bufsize = URE_TRANSFER_SIZE, |
226 |
.flags = {.pipe_bof = 1,.force_short_xfer = 1,}, |
227 |
.callback = ure_bulk_write_callback, |
228 |
.timeout = 10000, /* 10 seconds */ |
229 |
}, |
230 |
{ |
231 |
.type = UE_BULK, |
232 |
.endpoint = UE_ADDR_ANY, |
233 |
.direction = UE_DIR_OUT, |
234 |
.bufsize = URE_TRANSFER_SIZE, |
235 |
.flags = {.pipe_bof = 1,.force_short_xfer = 1,}, |
236 |
.callback = ure_bulk_write_callback, |
237 |
.timeout = 10000, /* 10 seconds */ |
238 |
}, |
239 |
#endif |
240 |
}; |
241 |
|
242 |
static device_method_t ure_methods[] = { |
169 |
static device_method_t ure_methods[] = { |
243 |
/* Device interface. */ |
170 |
/* Device interface. */ |
244 |
DEVMETHOD(device_probe, ure_probe), |
171 |
DEVMETHOD(device_probe, ure_probe), |
Lines 283-288
Link Here
|
283 |
.ue_mii_sts = ure_ifmedia_sts, |
210 |
.ue_mii_sts = ure_ifmedia_sts, |
284 |
}; |
211 |
}; |
285 |
|
212 |
|
|
|
213 |
#define URE_SETBIT_1(sc, reg, index, x) \ |
214 |
ure_write_1(sc, reg, index, ure_read_1(sc, reg, index) | (x)) |
215 |
#define URE_SETBIT_2(sc, reg, index, x) \ |
216 |
ure_write_2(sc, reg, index, ure_read_2(sc, reg, index) | (x)) |
217 |
#define URE_SETBIT_4(sc, reg, index, x) \ |
218 |
ure_write_4(sc, reg, index, ure_read_4(sc, reg, index) | (x)) |
219 |
|
220 |
#define URE_CLRBIT_1(sc, reg, index, x) \ |
221 |
ure_write_1(sc, reg, index, ure_read_1(sc, reg, index) & ~(x)) |
222 |
#define URE_CLRBIT_2(sc, reg, index, x) \ |
223 |
ure_write_2(sc, reg, index, ure_read_2(sc, reg, index) & ~(x)) |
224 |
#define URE_CLRBIT_4(sc, reg, index, x) \ |
225 |
ure_write_4(sc, reg, index, ure_read_4(sc, reg, index) & ~(x)) |
226 |
|
286 |
static int |
227 |
static int |
287 |
ure_ctl(struct ure_softc *sc, uint8_t rw, uint16_t val, uint16_t index, |
228 |
ure_ctl(struct ure_softc *sc, uint8_t rw, uint16_t val, uint16_t index, |
288 |
void *buf, int len) |
229 |
void *buf, int len) |
Lines 435-440
Link Here
|
435 |
ure_write_2(sc, reg, URE_MCU_TYPE_PLA, data); |
376 |
ure_write_2(sc, reg, URE_MCU_TYPE_PLA, data); |
436 |
} |
377 |
} |
437 |
|
378 |
|
|
|
379 |
static void |
380 |
ure_sram_write(struct ure_softc *sc, uint16_t addr, uint16_t data) |
381 |
{ |
382 |
|
383 |
ure_ocp_reg_write(sc, URE_OCP_SRAM_ADDR, addr); |
384 |
ure_ocp_reg_write(sc, URE_OCP_SRAM_DATA, data); |
385 |
} |
386 |
|
438 |
static int |
387 |
static int |
439 |
ure_miibus_readreg(device_t dev, int phy, int reg) |
388 |
ure_miibus_readreg(device_t dev, int phy, int reg) |
440 |
{ |
389 |
{ |
Lines 558-582
Link Here
|
558 |
struct usb_attach_arg *uaa = device_get_ivars(dev); |
507 |
struct usb_attach_arg *uaa = device_get_ivars(dev); |
559 |
struct ure_softc *sc = device_get_softc(dev); |
508 |
struct ure_softc *sc = device_get_softc(dev); |
560 |
struct usb_ether *ue = &sc->sc_ue; |
509 |
struct usb_ether *ue = &sc->sc_ue; |
|
|
510 |
struct usb_config ure_config_rx[URE_MAX_RX]; |
511 |
struct usb_config ure_config_tx[URE_MAX_TX]; |
561 |
uint8_t iface_index; |
512 |
uint8_t iface_index; |
562 |
int error; |
513 |
int i, error; |
563 |
|
514 |
|
564 |
sc->sc_flags = USB_GET_DRIVER_INFO(uaa); |
515 |
sc->sc_flags = USB_GET_DRIVER_INFO(uaa); |
565 |
device_set_usb_desc(dev); |
516 |
device_set_usb_desc(dev); |
566 |
mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); |
517 |
mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); |
567 |
|
518 |
|
568 |
iface_index = URE_IFACE_IDX; |
519 |
iface_index = URE_IFACE_IDX; |
|
|
520 |
|
521 |
if (sc->sc_flags & (URE_FLAG_8153 | URE_FLAG_8153B)) |
522 |
sc->sc_rxbufsz = URE_8153_RX_BUFSZ; |
523 |
else if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) |
524 |
sc->sc_rxbufsz = URE_8156_RX_BUFSZ; |
525 |
else |
526 |
sc->sc_rxbufsz = URE_8152_RX_BUFSZ; |
527 |
|
528 |
for (i = 0; i < URE_MAX_RX; i++) { |
529 |
ure_config_rx[i] = (struct usb_config) { |
530 |
.type = UE_BULK, |
531 |
.endpoint = UE_ADDR_ANY, |
532 |
.direction = UE_DIR_IN, |
533 |
.bufsize = sc->sc_rxbufsz, |
534 |
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, |
535 |
.callback = ure_bulk_read_callback, |
536 |
.timeout = 0, /* no timeout */ |
537 |
}; |
538 |
} |
569 |
error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_rx_xfer, |
539 |
error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_rx_xfer, |
570 |
ure_config_rx, URE_N_TRANSFER, sc, &sc->sc_mtx); |
540 |
ure_config_rx, URE_MAX_RX, sc, &sc->sc_mtx); |
571 |
if (error != 0) { |
541 |
if (error != 0) { |
572 |
device_printf(dev, "allocating USB RX transfers failed\n"); |
542 |
device_printf(dev, "allocating USB RX transfers failed\n"); |
573 |
goto detach; |
543 |
goto detach; |
574 |
} |
544 |
} |
575 |
|
545 |
|
|
|
546 |
for (i = 0; i < URE_MAX_TX; i++) { |
547 |
ure_config_tx[i] = (struct usb_config) { |
548 |
.type = UE_BULK, |
549 |
.endpoint = UE_ADDR_ANY, |
550 |
.direction = UE_DIR_OUT, |
551 |
.bufsize = URE_TX_BUFSZ, |
552 |
.flags = {.pipe_bof = 1,.force_short_xfer = 1,}, |
553 |
.callback = ure_bulk_write_callback, |
554 |
.timeout = 10000, /* 10 seconds */ |
555 |
}; |
556 |
} |
576 |
error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_tx_xfer, |
557 |
error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_tx_xfer, |
577 |
ure_config_tx, URE_N_TRANSFER, sc, &sc->sc_mtx); |
558 |
ure_config_tx, URE_MAX_TX, sc, &sc->sc_mtx); |
578 |
if (error != 0) { |
559 |
if (error != 0) { |
579 |
usbd_transfer_unsetup(sc->sc_rx_xfer, URE_N_TRANSFER); |
560 |
usbd_transfer_unsetup(sc->sc_rx_xfer, URE_MAX_RX); |
580 |
device_printf(dev, "allocating USB TX transfers failed\n"); |
561 |
device_printf(dev, "allocating USB TX transfers failed\n"); |
581 |
goto detach; |
562 |
goto detach; |
582 |
} |
563 |
} |
Lines 592-597
Link Here
|
592 |
device_printf(dev, "could not attach interface\n"); |
573 |
device_printf(dev, "could not attach interface\n"); |
593 |
goto detach; |
574 |
goto detach; |
594 |
} |
575 |
} |
|
|
576 |
|
595 |
return (0); /* success */ |
577 |
return (0); /* success */ |
596 |
|
578 |
|
597 |
detach: |
579 |
detach: |
Lines 605-612
Link Here
|
605 |
struct ure_softc *sc = device_get_softc(dev); |
587 |
struct ure_softc *sc = device_get_softc(dev); |
606 |
struct usb_ether *ue = &sc->sc_ue; |
588 |
struct usb_ether *ue = &sc->sc_ue; |
607 |
|
589 |
|
608 |
usbd_transfer_unsetup(sc->sc_tx_xfer, URE_N_TRANSFER); |
590 |
usbd_transfer_unsetup(sc->sc_tx_xfer, URE_MAX_TX); |
609 |
usbd_transfer_unsetup(sc->sc_rx_xfer, URE_N_TRANSFER); |
591 |
usbd_transfer_unsetup(sc->sc_rx_xfer, URE_MAX_RX); |
610 |
uether_ifdetach(ue); |
592 |
uether_ifdetach(ue); |
611 |
mtx_destroy(&sc->sc_mtx); |
593 |
mtx_destroy(&sc->sc_mtx); |
612 |
|
594 |
|
Lines 785-791
Link Here
|
785 |
caps = if_getcapenable(ifp); |
767 |
caps = if_getcapenable(ifp); |
786 |
|
768 |
|
787 |
pos = 0; |
769 |
pos = 0; |
788 |
rem = URE_TRANSFER_SIZE; |
770 |
rem = URE_TX_BUFSZ; |
789 |
while (rem > sizeof(txpkt)) { |
771 |
while (rem > sizeof(txpkt)) { |
790 |
IFQ_DRV_DEQUEUE(&ifp->if_snd, m); |
772 |
IFQ_DRV_DEQUEUE(&ifp->if_snd, m); |
791 |
if (m == NULL) |
773 |
if (m == NULL) |
Lines 895-916
Link Here
|
895 |
switch (ver) { |
877 |
switch (ver) { |
896 |
case 0x4c00: |
878 |
case 0x4c00: |
897 |
sc->sc_chip |= URE_CHIP_VER_4C00; |
879 |
sc->sc_chip |= URE_CHIP_VER_4C00; |
|
|
880 |
sc->sc_flags = URE_FLAG_8152; |
898 |
break; |
881 |
break; |
899 |
case 0x4c10: |
882 |
case 0x4c10: |
900 |
sc->sc_chip |= URE_CHIP_VER_4C10; |
883 |
sc->sc_chip |= URE_CHIP_VER_4C10; |
|
|
884 |
sc->sc_flags = URE_FLAG_8152; |
901 |
break; |
885 |
break; |
902 |
case 0x5c00: |
886 |
case 0x5c00: |
903 |
sc->sc_chip |= URE_CHIP_VER_5C00; |
887 |
sc->sc_chip |= URE_CHIP_VER_5C00; |
|
|
888 |
sc->sc_flags = URE_FLAG_8153; |
904 |
break; |
889 |
break; |
905 |
case 0x5c10: |
890 |
case 0x5c10: |
906 |
sc->sc_chip |= URE_CHIP_VER_5C10; |
891 |
sc->sc_chip |= URE_CHIP_VER_5C10; |
|
|
892 |
sc->sc_flags = URE_FLAG_8153; |
907 |
break; |
893 |
break; |
908 |
case 0x5c20: |
894 |
case 0x5c20: |
909 |
sc->sc_chip |= URE_CHIP_VER_5C20; |
895 |
sc->sc_chip |= URE_CHIP_VER_5C20; |
|
|
896 |
sc->sc_flags = URE_FLAG_8153; |
910 |
break; |
897 |
break; |
911 |
case 0x5c30: |
898 |
case 0x5c30: |
912 |
sc->sc_chip |= URE_CHIP_VER_5C30; |
899 |
sc->sc_chip |= URE_CHIP_VER_5C30; |
|
|
900 |
sc->sc_flags = URE_FLAG_8153; |
913 |
break; |
901 |
break; |
|
|
902 |
case 0x6000: |
903 |
sc->sc_flags = URE_FLAG_8153B; |
904 |
sc->sc_chip |= URE_CHIP_VER_6000; |
905 |
break; |
906 |
case 0x6010: |
907 |
sc->sc_flags = URE_FLAG_8153B; |
908 |
sc->sc_chip |= URE_CHIP_VER_6010; |
909 |
break; |
910 |
case 0x7020: |
911 |
sc->sc_flags = URE_FLAG_8156; |
912 |
sc->sc_chip |= URE_CHIP_VER_7020; |
913 |
break; |
914 |
case 0x7030: |
915 |
sc->sc_flags = URE_FLAG_8156; |
916 |
sc->sc_chip |= URE_CHIP_VER_7030; |
917 |
break; |
918 |
case 0x7400: |
919 |
sc->sc_flags = URE_FLAG_8156B; |
920 |
sc->sc_chip |= URE_CHIP_VER_7400; |
921 |
break; |
922 |
case 0x7410: |
923 |
sc->sc_flags = URE_FLAG_8156B; |
924 |
sc->sc_chip |= URE_CHIP_VER_7410; |
925 |
break; |
914 |
default: |
926 |
default: |
915 |
device_printf(sc->sc_ue.ue_dev, |
927 |
device_printf(sc->sc_ue.ue_dev, |
916 |
"unknown version 0x%04x\n", ver); |
928 |
"unknown version 0x%04x\n", ver); |
Lines 949-954
Link Here
|
949 |
/* Initialize controller and get station address. */ |
961 |
/* Initialize controller and get station address. */ |
950 |
if (sc->sc_flags & URE_FLAG_8152) |
962 |
if (sc->sc_flags & URE_FLAG_8152) |
951 |
ure_rtl8152_init(sc); |
963 |
ure_rtl8152_init(sc); |
|
|
964 |
else if (sc->sc_flags & (URE_FLAG_8153B | URE_FLAG_8156 | URE_FLAG_8156B)) |
965 |
ure_rtl8153b_init(sc); |
952 |
else |
966 |
else |
953 |
ure_rtl8153_init(sc); |
967 |
ure_rtl8153_init(sc); |
954 |
|
968 |
|
Lines 972-984
Link Here
|
972 |
ure_attach_post_sub(struct usb_ether *ue) |
986 |
ure_attach_post_sub(struct usb_ether *ue) |
973 |
{ |
987 |
{ |
974 |
struct sysctl_ctx_list *sctx; |
988 |
struct sysctl_ctx_list *sctx; |
975 |
struct sysctl_oid *soid; |
989 |
struct sysctl_oid *soid; |
976 |
struct ure_softc *sc; |
990 |
struct ure_softc *sc = uether_getsc(ue); |
977 |
struct ifnet *ifp; |
991 |
struct ifnet *ifp = ue->ue_ifp; |
978 |
int error; |
992 |
int error = 0; |
979 |
|
993 |
|
980 |
sc = uether_getsc(ue); |
|
|
981 |
ifp = ue->ue_ifp; |
982 |
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; |
994 |
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; |
983 |
ifp->if_start = uether_start; |
995 |
ifp->if_start = uether_start; |
984 |
ifp->if_ioctl = ure_ioctl; |
996 |
ifp->if_ioctl = ure_ioctl; |
Lines 1001-1009
Link Here
|
1001 |
if_setcapenable(ifp, if_getcapabilities(ifp)); |
1013 |
if_setcapenable(ifp, if_getcapabilities(ifp)); |
1002 |
|
1014 |
|
1003 |
mtx_lock(&Giant); |
1015 |
mtx_lock(&Giant); |
1004 |
error = mii_attach(ue->ue_dev, &ue->ue_miibus, ifp, |
1016 |
if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { |
1005 |
uether_ifmedia_upd, ue->ue_methods->ue_mii_sts, |
1017 |
ifmedia_init(&sc->sc_ifmedia, IFM_IMASK, ure_ifmedia_upd, |
1006 |
BMSR_DEFCAPMASK, sc->sc_phyno, MII_OFFSET_ANY, 0); |
1018 |
ure_ifmedia_sts); |
|
|
1019 |
ure_add_media_types(sc); |
1020 |
ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_AUTO, 0, NULL); |
1021 |
ifmedia_set(&sc->sc_ifmedia, IFM_ETHER | IFM_AUTO); |
1022 |
sc->sc_ifmedia.ifm_media = IFM_ETHER | IFM_AUTO; |
1023 |
} else { |
1024 |
error = mii_attach(ue->ue_dev, &ue->ue_miibus, ifp, |
1025 |
uether_ifmedia_upd, ue->ue_methods->ue_mii_sts, |
1026 |
BMSR_DEFCAPMASK, sc->sc_phyno, MII_OFFSET_ANY, 0); |
1027 |
} |
1007 |
mtx_unlock(&Giant); |
1028 |
mtx_unlock(&Giant); |
1008 |
|
1029 |
|
1009 |
sctx = device_get_sysctl_ctx(sc->sc_ue.ue_dev); |
1030 |
sctx = device_get_sysctl_ctx(sc->sc_ue.ue_dev); |
Lines 1022-1027
Link Here
|
1022 |
struct ure_softc *sc = uether_getsc(ue); |
1043 |
struct ure_softc *sc = uether_getsc(ue); |
1023 |
struct ifnet *ifp = uether_getifp(ue); |
1044 |
struct ifnet *ifp = uether_getifp(ue); |
1024 |
uint16_t cpcr; |
1045 |
uint16_t cpcr; |
|
|
1046 |
uint32_t reg; |
1025 |
|
1047 |
|
1026 |
URE_LOCK_ASSERT(sc, MA_OWNED); |
1048 |
URE_LOCK_ASSERT(sc, MA_OWNED); |
1027 |
|
1049 |
|
Lines 1031-1037
Link Here
|
1031 |
/* Cancel pending I/O. */ |
1053 |
/* Cancel pending I/O. */ |
1032 |
ure_stop(ue); |
1054 |
ure_stop(ue); |
1033 |
|
1055 |
|
1034 |
ure_reset(sc); |
1056 |
if (sc->sc_flags & (URE_FLAG_8153B | URE_FLAG_8156 | URE_FLAG_8156B)) |
|
|
1057 |
ure_rtl8153b_nic_reset(sc); |
1058 |
else |
1059 |
ure_reset(sc); |
1035 |
|
1060 |
|
1036 |
/* Set MAC address. */ |
1061 |
/* Set MAC address. */ |
1037 |
ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_CONFIG); |
1062 |
ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_CONFIG); |
Lines 1039-1051
Link Here
|
1039 |
IF_LLADDR(ifp), 8); |
1064 |
IF_LLADDR(ifp), 8); |
1040 |
ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_NORAML); |
1065 |
ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_NORAML); |
1041 |
|
1066 |
|
|
|
1067 |
/* Set RX EARLY timeout and size */ |
1068 |
if (sc->sc_flags & URE_FLAG_8153) { |
1069 |
switch (usbd_get_speed(sc->sc_ue.ue_udev)) { |
1070 |
case USB_SPEED_SUPER: |
1071 |
reg = URE_COALESCE_SUPER / 8; |
1072 |
break; |
1073 |
case USB_SPEED_HIGH: |
1074 |
reg = URE_COALESCE_HIGH / 8; |
1075 |
break; |
1076 |
default: |
1077 |
reg = URE_COALESCE_SLOW / 8; |
1078 |
break; |
1079 |
} |
1080 |
ure_write_2(sc, URE_USB_RX_EARLY_AGG, URE_MCU_TYPE_USB, reg); |
1081 |
reg = URE_8153_RX_BUFSZ - (URE_FRAMELEN(if_getmtu(ifp)) + |
1082 |
sizeof(struct ure_rxpkt) + URE_RXPKT_ALIGN); |
1083 |
ure_write_2(sc, URE_USB_RX_EARLY_SIZE, URE_MCU_TYPE_USB, reg / 4); |
1084 |
} else if (sc->sc_flags & URE_FLAG_8153B) { |
1085 |
ure_write_2(sc, URE_USB_RX_EARLY_AGG, URE_MCU_TYPE_USB, 158); |
1086 |
ure_write_2(sc, URE_USB_RX_EXTRA_AGG_TMR, URE_MCU_TYPE_USB, 1875); |
1087 |
reg = URE_8153_RX_BUFSZ - (URE_FRAMELEN(if_getmtu(ifp)) + |
1088 |
sizeof(struct ure_rxpkt) + URE_RXPKT_ALIGN); |
1089 |
ure_write_2(sc, URE_USB_RX_EARLY_SIZE, URE_MCU_TYPE_USB, reg / 8); |
1090 |
ure_write_1(sc, URE_USB_UPT_RXDMA_OWN, URE_MCU_TYPE_USB, |
1091 |
URE_OWN_UPDATE | URE_OWN_CLEAR); |
1092 |
} else if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { |
1093 |
ure_write_2(sc, URE_USB_RX_EARLY_AGG, URE_MCU_TYPE_USB, 80); |
1094 |
ure_write_2(sc, URE_USB_RX_EXTRA_AGG_TMR, URE_MCU_TYPE_USB, 1875); |
1095 |
reg = URE_8156_RX_BUFSZ - (URE_FRAMELEN(if_getmtu(ifp)) + |
1096 |
sizeof(struct ure_rxpkt) + URE_RXPKT_ALIGN); |
1097 |
ure_write_2(sc, URE_USB_RX_EARLY_SIZE, URE_MCU_TYPE_USB, reg / 8); |
1098 |
ure_write_1(sc, URE_USB_UPT_RXDMA_OWN, URE_MCU_TYPE_USB, |
1099 |
URE_OWN_UPDATE | URE_OWN_CLEAR); |
1100 |
} |
1101 |
|
1102 |
if (sc->sc_flags & URE_FLAG_8156B) { |
1103 |
URE_CLRBIT_2(sc, URE_USB_FW_TASK, URE_MCU_TYPE_USB, URE_FC_PATCH_TASK); |
1104 |
uether_pause(&sc->sc_ue, hz / 500); |
1105 |
URE_SETBIT_2(sc, URE_USB_FW_TASK, URE_MCU_TYPE_USB, URE_FC_PATCH_TASK); |
1106 |
} |
1107 |
|
1042 |
/* Reset the packet filter. */ |
1108 |
/* Reset the packet filter. */ |
1043 |
ure_write_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA, |
1109 |
URE_CLRBIT_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA, URE_FMC_FCR_MCU_EN); |
1044 |
ure_read_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA) & |
1110 |
URE_SETBIT_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA, URE_FMC_FCR_MCU_EN); |
1045 |
~URE_FMC_FCR_MCU_EN); |
|
|
1046 |
ure_write_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA, |
1047 |
ure_read_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA) | |
1048 |
URE_FMC_FCR_MCU_EN); |
1049 |
|
1111 |
|
1050 |
/* Enable RX VLANs if enabled */ |
1112 |
/* Enable RX VLANs if enabled */ |
1051 |
cpcr = ure_read_2(sc, URE_PLA_CPCR, URE_MCU_TYPE_PLA); |
1113 |
cpcr = ure_read_2(sc, URE_PLA_CPCR, URE_MCU_TYPE_PLA); |
Lines 1059-1071
Link Here
|
1059 |
ure_write_2(sc, URE_PLA_CPCR, URE_MCU_TYPE_PLA, cpcr); |
1121 |
ure_write_2(sc, URE_PLA_CPCR, URE_MCU_TYPE_PLA, cpcr); |
1060 |
|
1122 |
|
1061 |
/* Enable transmit and receive. */ |
1123 |
/* Enable transmit and receive. */ |
1062 |
ure_write_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA, |
1124 |
URE_SETBIT_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA, URE_CR_RE | URE_CR_TE); |
1063 |
ure_read_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA) | URE_CR_RE | |
|
|
1064 |
URE_CR_TE); |
1065 |
|
1125 |
|
1066 |
ure_write_2(sc, URE_PLA_MISC_1, URE_MCU_TYPE_PLA, |
1126 |
URE_CLRBIT_2(sc, URE_PLA_MISC_1, URE_MCU_TYPE_PLA, URE_RXDY_GATED_EN); |
1067 |
ure_read_2(sc, URE_PLA_MISC_1, URE_MCU_TYPE_PLA) & |
|
|
1068 |
~URE_RXDY_GATED_EN); |
1069 |
|
1127 |
|
1070 |
/* Configure RX filters. */ |
1128 |
/* Configure RX filters. */ |
1071 |
ure_rxfilter(ue); |
1129 |
ure_rxfilter(ue); |
Lines 1084-1109
Link Here
|
1084 |
{ |
1142 |
{ |
1085 |
struct ure_softc *sc = uether_getsc(ue); |
1143 |
struct ure_softc *sc = uether_getsc(ue); |
1086 |
struct ifnet *ifp = uether_getifp(ue); |
1144 |
struct ifnet *ifp = uether_getifp(ue); |
1087 |
struct mii_data *mii = GET_MII(sc); |
1145 |
struct mii_data *mii; |
1088 |
|
1146 |
|
1089 |
URE_LOCK_ASSERT(sc, MA_OWNED); |
1147 |
URE_LOCK_ASSERT(sc, MA_OWNED); |
1090 |
|
1148 |
|
1091 |
(void)ifp; |
1149 |
(void)ifp; |
1092 |
for (int i = 0; i < URE_N_TRANSFER; i++) |
1150 |
for (int i = 0; i < URE_MAX_RX; i++) |
1093 |
DEVPRINTFN(13, sc->sc_ue.ue_dev, |
1151 |
DEVPRINTFN(13, sc->sc_ue.ue_dev, |
1094 |
"rx[%d] = %d\n", i, USB_GET_STATE(sc->sc_rx_xfer[i])); |
1152 |
"rx[%d] = %d\n", i, USB_GET_STATE(sc->sc_rx_xfer[i])); |
1095 |
|
1153 |
|
1096 |
for (int i = 0; i < URE_N_TRANSFER; i++) |
1154 |
for (int i = 0; i < URE_MAX_TX; i++) |
1097 |
DEVPRINTFN(13, sc->sc_ue.ue_dev, |
1155 |
DEVPRINTFN(13, sc->sc_ue.ue_dev, |
1098 |
"tx[%d] = %d\n", i, USB_GET_STATE(sc->sc_tx_xfer[i])); |
1156 |
"tx[%d] = %d\n", i, USB_GET_STATE(sc->sc_tx_xfer[i])); |
1099 |
|
1157 |
|
1100 |
mii_tick(mii); |
1158 |
if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) |
1101 |
if ((sc->sc_flags & URE_FLAG_LINK) == 0 |
1159 |
ure_link_state(sc); |
1102 |
&& mii->mii_media_status & IFM_ACTIVE && |
1160 |
else { |
1103 |
IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { |
1161 |
mii = GET_MII(sc); |
1104 |
sc->sc_flags |= URE_FLAG_LINK; |
1162 |
mii_tick(mii); |
1105 |
sc->sc_rxstarted = 0; |
1163 |
if ((sc->sc_flags & URE_FLAG_LINK) == 0 |
1106 |
ure_start(ue); |
1164 |
&& mii->mii_media_status & IFM_ACTIVE && |
|
|
1165 |
IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { |
1166 |
sc->sc_flags |= URE_FLAG_LINK; |
1167 |
sc->sc_rxstarted = 0; |
1168 |
ure_start(ue); |
1169 |
} |
1107 |
} |
1170 |
} |
1108 |
} |
1171 |
} |
1109 |
|
1172 |
|
Lines 1171-1181
Link Here
|
1171 |
|
1234 |
|
1172 |
if (!sc->sc_rxstarted) { |
1235 |
if (!sc->sc_rxstarted) { |
1173 |
sc->sc_rxstarted = 1; |
1236 |
sc->sc_rxstarted = 1; |
1174 |
for (i = 0; i != URE_N_TRANSFER; i++) |
1237 |
for (i = 0; i != URE_MAX_RX; i++) |
1175 |
usbd_transfer_start(sc->sc_rx_xfer[i]); |
1238 |
usbd_transfer_start(sc->sc_rx_xfer[i]); |
1176 |
} |
1239 |
} |
1177 |
|
1240 |
|
1178 |
for (i = 0; i != URE_N_TRANSFER; i++) |
1241 |
for (i = 0; i != URE_MAX_TX; i++) |
1179 |
usbd_transfer_start(sc->sc_tx_xfer[i]); |
1242 |
usbd_transfer_start(sc->sc_tx_xfer[i]); |
1180 |
} |
1243 |
} |
1181 |
|
1244 |
|
Lines 1203-1214
Link Here
|
1203 |
ure_ifmedia_upd(struct ifnet *ifp) |
1266 |
ure_ifmedia_upd(struct ifnet *ifp) |
1204 |
{ |
1267 |
{ |
1205 |
struct ure_softc *sc = ifp->if_softc; |
1268 |
struct ure_softc *sc = ifp->if_softc; |
1206 |
struct mii_data *mii = GET_MII(sc); |
1269 |
struct ifmedia *ifm = &sc->sc_ifmedia; |
|
|
1270 |
struct mii_data *mii; |
1207 |
struct mii_softc *miisc; |
1271 |
struct mii_softc *miisc; |
1208 |
int error; |
1272 |
int anar, gig, reg, locked, error; |
1209 |
|
1273 |
|
1210 |
URE_LOCK_ASSERT(sc, MA_OWNED); |
1274 |
if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { |
|
|
1275 |
if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) |
1276 |
return (EINVAL); |
1211 |
|
1277 |
|
|
|
1278 |
locked = mtx_owned(&sc->sc_mtx); |
1279 |
if (!locked) |
1280 |
URE_LOCK(sc); |
1281 |
reg = ure_ocp_reg_read(sc, 0xa5d4); |
1282 |
reg &= ~URE_ADV_2500TFDX; |
1283 |
|
1284 |
anar = gig = 0; |
1285 |
switch (IFM_SUBTYPE(ifm->ifm_media)) { |
1286 |
case IFM_AUTO: |
1287 |
anar |= ANAR_TX_FD | ANAR_TX | ANAR_10_FD | ANAR_10; |
1288 |
gig |= GTCR_ADV_1000TFDX | GTCR_ADV_1000THDX; |
1289 |
reg |= URE_ADV_2500TFDX; |
1290 |
break; |
1291 |
case IFM_2500_T: |
1292 |
anar |= ANAR_TX_FD | ANAR_TX | ANAR_10_FD | ANAR_10; |
1293 |
gig |= GTCR_ADV_1000TFDX | GTCR_ADV_1000THDX; |
1294 |
reg |= URE_ADV_2500TFDX; |
1295 |
ifp->if_baudrate = IF_Mbps(2500); |
1296 |
break; |
1297 |
case IFM_1000_T: |
1298 |
anar |= ANAR_TX_FD | ANAR_TX | ANAR_10_FD | ANAR_10; |
1299 |
gig |= GTCR_ADV_1000TFDX | GTCR_ADV_1000THDX; |
1300 |
ifp->if_baudrate = IF_Gbps(1); |
1301 |
break; |
1302 |
case IFM_100_TX: |
1303 |
anar |= ANAR_TX | ANAR_TX_FD; |
1304 |
ifp->if_baudrate = IF_Mbps(100); |
1305 |
break; |
1306 |
case IFM_10_T: |
1307 |
anar |= ANAR_10 | ANAR_10_FD; |
1308 |
ifp->if_baudrate = IF_Mbps(10); |
1309 |
break; |
1310 |
default: |
1311 |
device_printf(sc->sc_ue.ue_dev, "unsupported media type\n"); |
1312 |
if (!locked) |
1313 |
URE_UNLOCK(sc); |
1314 |
return (EINVAL); |
1315 |
} |
1316 |
|
1317 |
ure_ocp_reg_write(sc, URE_OCP_BASE_MII + MII_ANAR * 2, |
1318 |
anar | ANAR_PAUSE_ASYM | ANAR_FC); |
1319 |
ure_ocp_reg_write(sc, URE_OCP_BASE_MII + MII_100T2CR * 2, gig); |
1320 |
ure_ocp_reg_write(sc, 0xa5d4, reg); |
1321 |
ure_ocp_reg_write(sc, URE_OCP_BASE_MII + MII_BMCR, |
1322 |
BMCR_AUTOEN | BMCR_STARTNEG); |
1323 |
if (!locked) |
1324 |
URE_UNLOCK(sc); |
1325 |
return (0); |
1326 |
} |
1327 |
|
1328 |
mii = GET_MII(sc); |
1329 |
|
1330 |
URE_LOCK_ASSERT(sc, MA_OWNED); |
1212 |
LIST_FOREACH(miisc, &mii->mii_phys, mii_list) |
1331 |
LIST_FOREACH(miisc, &mii->mii_phys, mii_list) |
1213 |
PHY_RESET(miisc); |
1332 |
PHY_RESET(miisc); |
1214 |
error = mii_mediachg(mii); |
1333 |
error = mii_mediachg(mii); |
Lines 1223-1230
Link Here
|
1223 |
{ |
1342 |
{ |
1224 |
struct ure_softc *sc; |
1343 |
struct ure_softc *sc; |
1225 |
struct mii_data *mii; |
1344 |
struct mii_data *mii; |
|
|
1345 |
uint16_t status=0; |
1226 |
|
1346 |
|
1227 |
sc = ifp->if_softc; |
1347 |
sc = ifp->if_softc; |
|
|
1348 |
if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { |
1349 |
URE_LOCK(sc); |
1350 |
ifmr->ifm_status = IFM_AVALID; |
1351 |
if (ure_get_link_status(sc)) { |
1352 |
ifmr->ifm_status |= IFM_ACTIVE; |
1353 |
status = ure_read_2(sc, URE_PLA_PHYSTATUS, |
1354 |
URE_MCU_TYPE_PLA); |
1355 |
if ((status & URE_PHYSTATUS_FDX) || |
1356 |
(status & URE_PHYSTATUS_2500MBPS)) |
1357 |
ifmr->ifm_active |= IFM_FDX; |
1358 |
else |
1359 |
ifmr->ifm_active |= IFM_HDX; |
1360 |
if (status & URE_PHYSTATUS_10MBPS) |
1361 |
ifmr->ifm_active |= IFM_10_T; |
1362 |
else if (status & URE_PHYSTATUS_100MBPS) |
1363 |
ifmr->ifm_active |= IFM_100_TX; |
1364 |
else if (status & URE_PHYSTATUS_1000MBPS) |
1365 |
ifmr->ifm_active |= IFM_1000_T; |
1366 |
else if (status & URE_PHYSTATUS_2500MBPS) |
1367 |
ifmr->ifm_active |= IFM_2500_T; |
1368 |
} |
1369 |
URE_UNLOCK(sc); |
1370 |
return; |
1371 |
} |
1372 |
|
1228 |
mii = GET_MII(sc); |
1373 |
mii = GET_MII(sc); |
1229 |
|
1374 |
|
1230 |
URE_LOCK(sc); |
1375 |
URE_LOCK(sc); |
Lines 1234-1248
Link Here
|
1234 |
URE_UNLOCK(sc); |
1379 |
URE_UNLOCK(sc); |
1235 |
} |
1380 |
} |
1236 |
|
1381 |
|
|
|
1382 |
static void |
1383 |
ure_add_media_types(struct ure_softc *sc) |
1384 |
{ |
1385 |
|
1386 |
ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_10_T, 0, NULL); |
1387 |
ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_10_T | IFM_FDX, 0, NULL); |
1388 |
ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_100_TX, 0, NULL); |
1389 |
ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_100_TX | IFM_FDX, 0, NULL); |
1390 |
ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL); |
1391 |
ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_2500_T | IFM_FDX, 0, NULL); |
1392 |
} |
1393 |
|
1394 |
static void |
1395 |
ure_link_state(struct ure_softc *sc) |
1396 |
{ |
1397 |
struct ifnet *ifp = uether_getifp(&sc->sc_ue); |
1398 |
|
1399 |
if (ure_get_link_status(sc)) { |
1400 |
if (ifp->if_link_state != LINK_STATE_UP) { |
1401 |
if_link_state_change(ifp, LINK_STATE_UP); |
1402 |
/* Enable transmit and receive. */ |
1403 |
URE_SETBIT_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA, URE_CR_RE | URE_CR_TE); |
1404 |
|
1405 |
if (ure_read_2(sc, URE_PLA_PHYSTATUS, URE_MCU_TYPE_PLA) & |
1406 |
URE_PHYSTATUS_2500MBPS) |
1407 |
URE_CLRBIT_2(sc, URE_PLA_MAC_PWR_CTRL4, URE_MCU_TYPE_PLA, 0x40); |
1408 |
else |
1409 |
URE_SETBIT_2(sc, URE_PLA_MAC_PWR_CTRL4, URE_MCU_TYPE_PLA, 0x40); |
1410 |
} |
1411 |
} else { |
1412 |
if (ifp->if_link_state != LINK_STATE_DOWN) { |
1413 |
if_link_state_change(ifp, LINK_STATE_DOWN); |
1414 |
} |
1415 |
} |
1416 |
} |
1417 |
|
1237 |
static int |
1418 |
static int |
|
|
1419 |
ure_get_link_status(struct ure_softc *sc) |
1420 |
{ |
1421 |
|
1422 |
if (ure_read_2(sc, URE_PLA_PHYSTATUS, URE_MCU_TYPE_PLA) & |
1423 |
URE_PHYSTATUS_LINK) { |
1424 |
sc->sc_flags |= URE_FLAG_LINK; |
1425 |
return (1); |
1426 |
} else { |
1427 |
|
1428 |
sc->sc_flags &= ~URE_FLAG_LINK; |
1429 |
return (0); |
1430 |
} |
1431 |
} |
1432 |
|
1433 |
static int |
1238 |
ure_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) |
1434 |
ure_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) |
1239 |
{ |
1435 |
{ |
1240 |
struct usb_ether *ue = ifp->if_softc; |
1436 |
struct usb_ether *ue = ifp->if_softc; |
1241 |
struct ure_softc *sc; |
1437 |
struct ure_softc *sc = uether_getsc(ue);; |
1242 |
struct ifreq *ifr; |
1438 |
struct ifreq *ifr; |
1243 |
int error, mask, reinit; |
1439 |
int error, mask, reinit; |
1244 |
|
1440 |
|
1245 |
sc = uether_getsc(ue); |
|
|
1246 |
ifr = (struct ifreq *)data; |
1441 |
ifr = (struct ifreq *)data; |
1247 |
error = 0; |
1442 |
error = 0; |
1248 |
reinit = 0; |
1443 |
reinit = 0; |
Lines 1297-1302
Link Here
|
1297 |
if_setmtu(ifp, ifr->ifr_mtu); |
1492 |
if_setmtu(ifp, ifr->ifr_mtu); |
1298 |
URE_UNLOCK(sc); |
1493 |
URE_UNLOCK(sc); |
1299 |
break; |
1494 |
break; |
|
|
1495 |
|
1496 |
case SIOCGIFMEDIA: |
1497 |
case SIOCSIFMEDIA: |
1498 |
if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) |
1499 |
error = ifmedia_ioctl(ifp, ifr, &sc->sc_ifmedia, cmd); |
1500 |
else |
1501 |
error = uether_ioctl(ifp, cmd, data); |
1502 |
break; |
1300 |
|
1503 |
|
1301 |
default: |
1504 |
default: |
1302 |
error = uether_ioctl(ifp, cmd, data); |
1505 |
error = uether_ioctl(ifp, cmd, data); |
Lines 1310-1336
Link Here
|
1310 |
{ |
1513 |
{ |
1311 |
uint32_t pwrctrl; |
1514 |
uint32_t pwrctrl; |
1312 |
|
1515 |
|
1313 |
/* Disable ALDPS. */ |
1516 |
ure_enable_aldps(sc, false); |
1314 |
ure_ocp_reg_write(sc, URE_OCP_ALDPS_CONFIG, URE_ENPDNPS | URE_LINKENA | |
|
|
1315 |
URE_DIS_SDSAVE); |
1316 |
uether_pause(&sc->sc_ue, hz / 50); |
1317 |
|
1517 |
|
1318 |
if (sc->sc_chip & URE_CHIP_VER_4C00) { |
1518 |
if (sc->sc_chip & URE_CHIP_VER_4C00) { |
1319 |
ure_write_2(sc, URE_PLA_LED_FEATURE, URE_MCU_TYPE_PLA, |
1519 |
URE_CLRBIT_2(sc, URE_PLA_LED_FEATURE, URE_MCU_TYPE_PLA, URE_LED_MODE_MASK); |
1320 |
ure_read_2(sc, URE_PLA_LED_FEATURE, URE_MCU_TYPE_PLA) & |
|
|
1321 |
~URE_LED_MODE_MASK); |
1322 |
} |
1520 |
} |
1323 |
|
1521 |
|
1324 |
ure_write_2(sc, URE_USB_UPS_CTRL, URE_MCU_TYPE_USB, |
1522 |
URE_CLRBIT_2(sc, URE_USB_UPS_CTRL, URE_MCU_TYPE_USB, URE_POWER_CUT); |
1325 |
ure_read_2(sc, URE_USB_UPS_CTRL, URE_MCU_TYPE_USB) & |
|
|
1326 |
~URE_POWER_CUT); |
1327 |
ure_write_2(sc, URE_USB_PM_CTRL_STATUS, URE_MCU_TYPE_USB, |
1328 |
ure_read_2(sc, URE_USB_PM_CTRL_STATUS, URE_MCU_TYPE_USB) & |
1329 |
~URE_RESUME_INDICATE); |
1330 |
|
1523 |
|
1331 |
ure_write_2(sc, URE_PLA_PHY_PWR, URE_MCU_TYPE_PLA, |
1524 |
URE_CLRBIT_2(sc, URE_USB_PM_CTRL_STATUS, URE_MCU_TYPE_USB, URE_RESUME_INDICATE); |
1332 |
ure_read_2(sc, URE_PLA_PHY_PWR, URE_MCU_TYPE_PLA) | |
1525 |
|
1333 |
URE_TX_10M_IDLE_EN | URE_PFM_PWM_SWITCH); |
1526 |
URE_SETBIT_2(sc, URE_PLA_PHY_PWR, URE_MCU_TYPE_PLA, URE_TX_10M_IDLE_EN | URE_PFM_PWM_SWITCH); |
|
|
1527 |
|
1334 |
pwrctrl = ure_read_4(sc, URE_PLA_MAC_PWR_CTRL, URE_MCU_TYPE_PLA); |
1528 |
pwrctrl = ure_read_4(sc, URE_PLA_MAC_PWR_CTRL, URE_MCU_TYPE_PLA); |
1335 |
pwrctrl &= ~URE_MCU_CLK_RATIO_MASK; |
1529 |
pwrctrl &= ~URE_MCU_CLK_RATIO_MASK; |
1336 |
pwrctrl |= URE_MCU_CLK_RATIO | URE_D3_CLK_GATED_EN; |
1530 |
pwrctrl |= URE_MCU_CLK_RATIO | URE_D3_CLK_GATED_EN; |
Lines 1340-1355
Link Here
|
1340 |
URE_SPDWN_LINKCHG_MSK); |
1534 |
URE_SPDWN_LINKCHG_MSK); |
1341 |
|
1535 |
|
1342 |
/* Enable Rx aggregation. */ |
1536 |
/* Enable Rx aggregation. */ |
1343 |
ure_write_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB, |
1537 |
URE_CLRBIT_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB, URE_RX_AGG_DISABLE | URE_RX_ZERO_EN); |
1344 |
ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) & |
|
|
1345 |
~URE_RX_AGG_DISABLE); |
1346 |
|
1538 |
|
1347 |
/* Disable ALDPS. */ |
1539 |
ure_enable_aldps(sc, false); |
1348 |
ure_ocp_reg_write(sc, URE_OCP_ALDPS_CONFIG, URE_ENPDNPS | URE_LINKENA | |
|
|
1349 |
URE_DIS_SDSAVE); |
1350 |
uether_pause(&sc->sc_ue, hz / 50); |
1351 |
|
1540 |
|
1352 |
ure_init_fifo(sc); |
1541 |
ure_rtl8152_nic_reset(sc); |
1353 |
|
1542 |
|
1354 |
ure_write_1(sc, URE_USB_TX_AGG, URE_MCU_TYPE_USB, |
1543 |
ure_write_1(sc, URE_USB_TX_AGG, URE_MCU_TYPE_USB, |
1355 |
URE_TX_AGG_MAX_THRESHOLD); |
1544 |
URE_TX_AGG_MAX_THRESHOLD); |
Lines 1365-1374
Link Here
|
1365 |
uint8_t u1u2[8]; |
1554 |
uint8_t u1u2[8]; |
1366 |
int i; |
1555 |
int i; |
1367 |
|
1556 |
|
1368 |
/* Disable ALDPS. */ |
1557 |
ure_enable_aldps(sc, false); |
1369 |
ure_ocp_reg_write(sc, URE_OCP_POWER_CFG, |
|
|
1370 |
ure_ocp_reg_read(sc, URE_OCP_POWER_CFG) & ~URE_EN_ALDPS); |
1371 |
uether_pause(&sc->sc_ue, hz / 50); |
1372 |
|
1558 |
|
1373 |
memset(u1u2, 0x00, sizeof(u1u2)); |
1559 |
memset(u1u2, 0x00, sizeof(u1u2)); |
1374 |
ure_write_mem(sc, URE_USB_TOLERANCE, |
1560 |
ure_write_mem(sc, URE_USB_TOLERANCE, |
Lines 1395-1403
Link Here
|
1395 |
device_printf(sc->sc_ue.ue_dev, |
1581 |
device_printf(sc->sc_ue.ue_dev, |
1396 |
"timeout waiting for phy to stabilize\n"); |
1582 |
"timeout waiting for phy to stabilize\n"); |
1397 |
|
1583 |
|
1398 |
ure_write_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB, |
1584 |
URE_CLRBIT_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB, URE_U2P3_ENABLE); |
1399 |
ure_read_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB) & |
|
|
1400 |
~URE_U2P3_ENABLE); |
1401 |
|
1585 |
|
1402 |
if (sc->sc_chip & URE_CHIP_VER_5C10) { |
1586 |
if (sc->sc_chip & URE_CHIP_VER_5C10) { |
1403 |
val = ure_read_2(sc, URE_USB_SSPHYLINK2, URE_MCU_TYPE_USB); |
1587 |
val = ure_read_2(sc, URE_USB_SSPHYLINK2, URE_MCU_TYPE_USB); |
Lines 1405-1418
Link Here
|
1405 |
val |= URE_PWD_DN_SCALE(96); |
1589 |
val |= URE_PWD_DN_SCALE(96); |
1406 |
ure_write_2(sc, URE_USB_SSPHYLINK2, URE_MCU_TYPE_USB, val); |
1590 |
ure_write_2(sc, URE_USB_SSPHYLINK2, URE_MCU_TYPE_USB, val); |
1407 |
|
1591 |
|
1408 |
ure_write_1(sc, URE_USB_USB2PHY, URE_MCU_TYPE_USB, |
1592 |
URE_SETBIT_1(sc, URE_USB_USB2PHY, URE_MCU_TYPE_USB, URE_USB2PHY_L1 | URE_USB2PHY_SUSPEND); |
1409 |
ure_read_1(sc, URE_USB_USB2PHY, URE_MCU_TYPE_USB) | |
1593 |
} else if (sc->sc_chip & URE_CHIP_VER_5C20) |
1410 |
URE_USB2PHY_L1 | URE_USB2PHY_SUSPEND); |
1594 |
URE_CLRBIT_1(sc, URE_PLA_DMY_REG0, URE_MCU_TYPE_PLA, URE_ECM_ALDPS); |
1411 |
} else if (sc->sc_chip & URE_CHIP_VER_5C20) { |
1595 |
|
1412 |
ure_write_1(sc, URE_PLA_DMY_REG0, URE_MCU_TYPE_PLA, |
|
|
1413 |
ure_read_1(sc, URE_PLA_DMY_REG0, URE_MCU_TYPE_PLA) & |
1414 |
~URE_ECM_ALDPS); |
1415 |
} |
1416 |
if (sc->sc_chip & (URE_CHIP_VER_5C20 | URE_CHIP_VER_5C30)) { |
1596 |
if (sc->sc_chip & (URE_CHIP_VER_5C20 | URE_CHIP_VER_5C30)) { |
1417 |
val = ure_read_1(sc, URE_USB_CSR_DUMMY1, URE_MCU_TYPE_USB); |
1597 |
val = ure_read_1(sc, URE_USB_CSR_DUMMY1, URE_MCU_TYPE_USB); |
1418 |
if (ure_read_2(sc, URE_USB_BURST_SIZE, URE_MCU_TYPE_USB) == |
1598 |
if (ure_read_2(sc, URE_USB_BURST_SIZE, URE_MCU_TYPE_USB) == |
Lines 1423-1439
Link Here
|
1423 |
ure_write_1(sc, URE_USB_CSR_DUMMY1, URE_MCU_TYPE_USB, val); |
1603 |
ure_write_1(sc, URE_USB_CSR_DUMMY1, URE_MCU_TYPE_USB, val); |
1424 |
} |
1604 |
} |
1425 |
|
1605 |
|
1426 |
ure_write_1(sc, URE_USB_CSR_DUMMY2, URE_MCU_TYPE_USB, |
1606 |
URE_SETBIT_1(sc, URE_USB_CSR_DUMMY2, URE_MCU_TYPE_USB, URE_EP4_FULL_FC); |
1427 |
ure_read_1(sc, URE_USB_CSR_DUMMY2, URE_MCU_TYPE_USB) | |
|
|
1428 |
URE_EP4_FULL_FC); |
1429 |
|
1607 |
|
1430 |
ure_write_2(sc, URE_USB_WDT11_CTRL, URE_MCU_TYPE_USB, |
1608 |
URE_CLRBIT_2(sc, URE_USB_WDT11_CTRL, URE_MCU_TYPE_USB, URE_TIMER11_EN); |
1431 |
ure_read_2(sc, URE_USB_WDT11_CTRL, URE_MCU_TYPE_USB) & |
|
|
1432 |
~URE_TIMER11_EN); |
1433 |
|
1609 |
|
1434 |
ure_write_2(sc, URE_PLA_LED_FEATURE, URE_MCU_TYPE_PLA, |
1610 |
URE_CLRBIT_2(sc, URE_PLA_LED_FEATURE, URE_MCU_TYPE_PLA, URE_LED_MODE_MASK); |
1435 |
ure_read_2(sc, URE_PLA_LED_FEATURE, URE_MCU_TYPE_PLA) & |
|
|
1436 |
~URE_LED_MODE_MASK); |
1437 |
|
1611 |
|
1438 |
if ((sc->sc_chip & URE_CHIP_VER_5C10) && |
1612 |
if ((sc->sc_chip & URE_CHIP_VER_5C10) && |
1439 |
usbd_get_speed(sc->sc_ue.ue_udev) != USB_SPEED_SUPER) |
1613 |
usbd_get_speed(sc->sc_ue.ue_udev) != USB_SPEED_SUPER) |
Lines 1450-1462
Link Here
|
1450 |
|
1624 |
|
1451 |
ure_write_2(sc, URE_USB_CONNECT_TIMER, URE_MCU_TYPE_USB, 0x0001); |
1625 |
ure_write_2(sc, URE_USB_CONNECT_TIMER, URE_MCU_TYPE_USB, 0x0001); |
1452 |
|
1626 |
|
1453 |
ure_write_2(sc, URE_USB_POWER_CUT, URE_MCU_TYPE_USB, |
1627 |
URE_CLRBIT_2(sc, URE_USB_POWER_CUT, URE_MCU_TYPE_USB, URE_PWR_EN | URE_PHASE2_EN); |
1454 |
ure_read_2(sc, URE_USB_POWER_CUT, URE_MCU_TYPE_USB) & |
|
|
1455 |
~(URE_PWR_EN | URE_PHASE2_EN)); |
1456 |
ure_write_2(sc, URE_USB_MISC_0, URE_MCU_TYPE_USB, |
1457 |
ure_read_2(sc, URE_USB_MISC_0, URE_MCU_TYPE_USB) & |
1458 |
~URE_PCUT_STATUS); |
1459 |
|
1628 |
|
|
|
1629 |
URE_CLRBIT_2(sc, URE_USB_MISC_0, URE_MCU_TYPE_USB, URE_PCUT_STATUS); |
1630 |
|
1460 |
memset(u1u2, 0xff, sizeof(u1u2)); |
1631 |
memset(u1u2, 0xff, sizeof(u1u2)); |
1461 |
ure_write_mem(sc, URE_USB_TOLERANCE, |
1632 |
ure_write_mem(sc, URE_USB_TOLERANCE, |
1462 |
URE_MCU_TYPE_USB | URE_BYTE_EN_SIX_BYTES, u1u2, sizeof(u1u2)); |
1633 |
URE_MCU_TYPE_USB | URE_BYTE_EN_SIX_BYTES, u1u2, sizeof(u1u2)); |
Lines 1484-1500
Link Here
|
1484 |
ure_write_mem(sc, URE_USB_TOLERANCE, |
1655 |
ure_write_mem(sc, URE_USB_TOLERANCE, |
1485 |
URE_MCU_TYPE_USB | URE_BYTE_EN_SIX_BYTES, u1u2, sizeof(u1u2)); |
1656 |
URE_MCU_TYPE_USB | URE_BYTE_EN_SIX_BYTES, u1u2, sizeof(u1u2)); |
1486 |
|
1657 |
|
1487 |
/* Disable ALDPS. */ |
1658 |
ure_enable_aldps(sc, false); |
|
|
1659 |
|
1660 |
if (sc->sc_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10 | |
1661 |
URE_CHIP_VER_5C20)) { |
1662 |
ure_ocp_reg_write(sc, URE_OCP_ADC_CFG, |
1663 |
URE_CKADSEL_L | URE_ADC_EN | URE_EN_EMI_L); |
1664 |
} |
1665 |
if (sc->sc_chip & URE_CHIP_VER_5C00) { |
1666 |
ure_ocp_reg_write(sc, URE_OCP_EEE_CFG, |
1667 |
ure_ocp_reg_read(sc, URE_OCP_EEE_CFG) & |
1668 |
~URE_CTAP_SHORT_EN); |
1669 |
} |
1488 |
ure_ocp_reg_write(sc, URE_OCP_POWER_CFG, |
1670 |
ure_ocp_reg_write(sc, URE_OCP_POWER_CFG, |
1489 |
ure_ocp_reg_read(sc, URE_OCP_POWER_CFG) & ~URE_EN_ALDPS); |
1671 |
ure_ocp_reg_read(sc, URE_OCP_POWER_CFG) | |
1490 |
uether_pause(&sc->sc_ue, hz / 50); |
1672 |
URE_EEE_CLKDIV_EN); |
|
|
1673 |
ure_ocp_reg_write(sc, URE_OCP_DOWN_SPEED, |
1674 |
ure_ocp_reg_read(sc, URE_OCP_DOWN_SPEED) | |
1675 |
URE_EN_10M_BGOFF); |
1676 |
ure_ocp_reg_write(sc, URE_OCP_POWER_CFG, |
1677 |
ure_ocp_reg_read(sc, URE_OCP_POWER_CFG) | |
1678 |
URE_EN_10M_PLLOFF); |
1679 |
ure_sram_write(sc, URE_SRAM_IMPEDANCE, 0x0b13); |
1680 |
URE_SETBIT_2(sc, URE_PLA_PHY_PWR, URE_MCU_TYPE_PLA, URE_PFM_PWM_SWITCH); |
1491 |
|
1681 |
|
1492 |
ure_init_fifo(sc); |
1682 |
/* Enable LPF corner auto tune. */ |
|
|
1683 |
ure_sram_write(sc, URE_SRAM_LPF_CFG, 0xf70f); |
1493 |
|
1684 |
|
|
|
1685 |
/* Adjust 10M amplitude. */ |
1686 |
ure_sram_write(sc, URE_SRAM_10M_AMP1, 0x00af); |
1687 |
ure_sram_write(sc, URE_SRAM_10M_AMP2, 0x0208); |
1688 |
|
1689 |
ure_rtl8152_nic_reset(sc); |
1690 |
|
1494 |
/* Enable Rx aggregation. */ |
1691 |
/* Enable Rx aggregation. */ |
1495 |
ure_write_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB, |
1692 |
URE_CLRBIT_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB, URE_RX_AGG_DISABLE | URE_RX_ZERO_EN); |
1496 |
ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) & |
|
|
1497 |
~URE_RX_AGG_DISABLE); |
1498 |
|
1693 |
|
1499 |
val = ure_read_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB); |
1694 |
val = ure_read_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB); |
1500 |
if (!(sc->sc_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10))) |
1695 |
if (!(sc->sc_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10))) |
Lines 1509-1514
Link Here
|
1509 |
} |
1704 |
} |
1510 |
|
1705 |
|
1511 |
static void |
1706 |
static void |
|
|
1707 |
ure_rtl8153b_init(struct ure_softc *sc) |
1708 |
{ |
1709 |
uint16_t val; |
1710 |
int i; |
1711 |
|
1712 |
if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { |
1713 |
URE_CLRBIT_1(sc, 0xd26b, URE_MCU_TYPE_USB, 0x01); |
1714 |
ure_write_2(sc, 0xd32a, URE_MCU_TYPE_USB, 0); |
1715 |
URE_SETBIT_2(sc, 0xcfee, URE_MCU_TYPE_USB, 0x0020); |
1716 |
} |
1717 |
|
1718 |
if (sc->sc_flags & URE_FLAG_8156B) { |
1719 |
URE_SETBIT_2(sc, 0xb460, URE_MCU_TYPE_USB, 0x08); |
1720 |
} |
1721 |
|
1722 |
ure_enable_aldps(sc, false); |
1723 |
|
1724 |
/* Disable U1U2 */ |
1725 |
URE_CLRBIT_2(sc, URE_USB_LPM_CONFIG, URE_MCU_TYPE_USB, URE_LPM_U1U2_EN); |
1726 |
|
1727 |
/* Wait loading flash */ |
1728 |
if (sc->sc_chip == URE_CHIP_VER_7410) |
1729 |
if ((ure_read_2(sc, 0xd3ae, URE_MCU_TYPE_PLA) & 0x0002) && |
1730 |
!(ure_read_2(sc, 0xd284, URE_MCU_TYPE_USB) & 0x0020)) { |
1731 |
for (i=0; i < 100; i++) { |
1732 |
if (ure_read_2(sc, 0xd284, URE_MCU_TYPE_USB) & 0x0004) |
1733 |
break; |
1734 |
uether_pause(&sc->sc_ue, hz / 1000); |
1735 |
} |
1736 |
} |
1737 |
|
1738 |
for (i = 0; i < URE_TIMEOUT; i++) { |
1739 |
if (ure_read_2(sc, URE_PLA_BOOT_CTRL, URE_MCU_TYPE_PLA) & |
1740 |
URE_AUTOLOAD_DONE) |
1741 |
break; |
1742 |
uether_pause(&sc->sc_ue, hz / 100); |
1743 |
} |
1744 |
if (i == URE_TIMEOUT) |
1745 |
device_printf(sc->sc_ue.ue_dev, |
1746 |
"timeout waiting for chip autoload\n"); |
1747 |
|
1748 |
val = ure_phy_status(sc, 0); |
1749 |
if ((val == URE_PHY_STAT_EXT_INIT) & |
1750 |
(sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B))) { |
1751 |
ure_ocp_reg_write(sc, 0xa468, |
1752 |
ure_ocp_reg_read(sc, 0xa468) & ~0x0a); |
1753 |
if (sc->sc_flags & URE_FLAG_8156B) |
1754 |
ure_ocp_reg_write(sc, 0xa466, |
1755 |
ure_ocp_reg_read(sc, 0xa466) & ~0x01); |
1756 |
} |
1757 |
|
1758 |
val = ure_ocp_reg_read(sc, URE_OCP_BASE_MII + MII_BMCR); |
1759 |
if (val & BMCR_PDOWN) { |
1760 |
val &= ~BMCR_PDOWN; |
1761 |
ure_ocp_reg_write(sc, URE_OCP_BASE_MII + MII_BMCR, val); |
1762 |
} |
1763 |
|
1764 |
ure_phy_status(sc, URE_PHY_STAT_LAN_ON); |
1765 |
|
1766 |
/* Disable U2P3 */ |
1767 |
URE_CLRBIT_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB, URE_U2P3_ENABLE); |
1768 |
|
1769 |
/* MSC timer, 32760 ms. */ |
1770 |
ure_write_2(sc, URE_USB_MSC_TIMER, URE_MCU_TYPE_USB, 0x0fff); |
1771 |
|
1772 |
/* U1/U2/L1 idle timer, 500 us. */ |
1773 |
ure_write_2(sc, URE_USB_U1U2_TIMER, URE_MCU_TYPE_USB, 500); |
1774 |
|
1775 |
/* Disable power cut */ |
1776 |
URE_CLRBIT_2(sc, URE_USB_POWER_CUT, URE_MCU_TYPE_USB, URE_PWR_EN); |
1777 |
URE_CLRBIT_2(sc, URE_USB_MISC_0, URE_MCU_TYPE_USB, URE_PCUT_STATUS); |
1778 |
|
1779 |
/* Disable ups */ |
1780 |
URE_CLRBIT_1(sc, URE_USB_POWER_CUT, URE_MCU_TYPE_USB, URE_UPS_EN | URE_USP_PREWAKE); |
1781 |
URE_CLRBIT_1(sc, 0xcfff, URE_MCU_TYPE_USB, 0x01); |
1782 |
|
1783 |
/* Disable queue wake */ |
1784 |
URE_CLRBIT_1(sc, URE_PLA_INDICATE_FALG, URE_MCU_TYPE_USB, URE_UPCOMING_RUNTIME_D3); |
1785 |
URE_CLRBIT_1(sc, URE_PLA_SUSPEND_FLAG, URE_MCU_TYPE_USB, URE_LINK_CHG_EVENT); |
1786 |
URE_CLRBIT_2(sc, URE_PLA_EXTRA_STATUS, URE_MCU_TYPE_USB, URE_LINK_CHANGE_FLAG); |
1787 |
|
1788 |
/* Disable runtime suspend */ |
1789 |
ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_CONFIG); |
1790 |
URE_CLRBIT_2(sc, URE_PLA_CONFIG34, URE_MCU_TYPE_USB, URE_LINK_OFF_WAKE_EN); |
1791 |
ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_NORAML); |
1792 |
|
1793 |
/* Enable U1U2 */ |
1794 |
if (usbd_get_speed(sc->sc_ue.ue_udev) == USB_SPEED_SUPER) |
1795 |
URE_SETBIT_2(sc, URE_USB_LPM_CONFIG, URE_MCU_TYPE_USB, URE_LPM_U1U2_EN); |
1796 |
|
1797 |
if (sc->sc_flags & URE_FLAG_8156B) { |
1798 |
URE_CLRBIT_2(sc, 0xc010, URE_MCU_TYPE_PLA, 0x0800); |
1799 |
URE_SETBIT_2(sc, 0xe854, URE_MCU_TYPE_PLA, 0x0001); |
1800 |
|
1801 |
/* enable fc timer and set timer to 600 ms. */ |
1802 |
ure_write_2(sc, URE_USB_FC_TIMER, URE_MCU_TYPE_USB, URE_CTRL_TIMER_EN | (600 / 8)); |
1803 |
|
1804 |
if (!(ure_read_1(sc, 0xdc6b, URE_MCU_TYPE_PLA) & 0x80)) { |
1805 |
val = ure_read_2(sc, URE_USB_FW_CTRL, URE_MCU_TYPE_USB); |
1806 |
val |= URE_FLOW_CTRL_PATCH_OPT | 0x0100; |
1807 |
val &= ~0x08; |
1808 |
ure_write_2(sc, URE_USB_FW_CTRL, URE_MCU_TYPE_USB, val); |
1809 |
} |
1810 |
|
1811 |
URE_SETBIT_2(sc, URE_USB_FW_TASK, URE_MCU_TYPE_USB, URE_FC_PATCH_TASK); |
1812 |
} |
1813 |
|
1814 |
val = ure_read_2(sc, URE_PLA_EXTRA_STATUS, URE_MCU_TYPE_PLA); |
1815 |
if (ure_get_link_status(sc)) |
1816 |
val |= URE_CUR_LINK_OK; |
1817 |
else |
1818 |
val &= ~URE_CUR_LINK_OK; |
1819 |
val |= URE_POLL_LINK_CHG; |
1820 |
ure_write_2(sc, URE_PLA_EXTRA_STATUS, URE_MCU_TYPE_PLA, val); |
1821 |
|
1822 |
/* MAC clock speed down */ |
1823 |
if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { |
1824 |
ure_write_2(sc, URE_PLA_MAC_PWR_CTRL, URE_MCU_TYPE_PLA, 0x0403); |
1825 |
val = ure_read_2(sc, URE_PLA_MAC_PWR_CTRL2, URE_MCU_TYPE_PLA); |
1826 |
val &= ~0xff; |
1827 |
val |= URE_MAC_CLK_SPDWN_EN | 0x03; |
1828 |
ure_write_2(sc, URE_PLA_MAC_PWR_CTRL2, URE_MCU_TYPE_PLA, val); |
1829 |
} else { |
1830 |
URE_SETBIT_2(sc, URE_PLA_MAC_PWR_CTRL2, URE_MCU_TYPE_USB, URE_MAC_CLK_SPDWN_EN); |
1831 |
} |
1832 |
URE_CLRBIT_2(sc, URE_PLA_MAC_PWR_CTRL3, URE_MCU_TYPE_PLA, URE_PLA_MCU_SPDWN_EN); |
1833 |
|
1834 |
/* Enable Rx aggregation. */ |
1835 |
URE_CLRBIT_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB, URE_RX_AGG_DISABLE | URE_RX_ZERO_EN); |
1836 |
|
1837 |
if (sc->sc_flags & URE_FLAG_8156) |
1838 |
URE_SETBIT_1(sc, 0xd4b4, URE_MCU_TYPE_USB, 0x02); |
1839 |
|
1840 |
/* Reset tally */ |
1841 |
URE_SETBIT_2(sc, URE_PLA_RSTTALLY, URE_MCU_TYPE_USB, URE_TALLY_RESET); |
1842 |
} |
1843 |
|
1844 |
static void |
1845 |
ure_rtl8153b_nic_reset(struct ure_softc *sc) |
1846 |
{ |
1847 |
struct ifnet *ifp = uether_getifp(&sc->sc_ue); |
1848 |
uint16_t val; |
1849 |
int i; |
1850 |
|
1851 |
/* Disable U1U2 */ |
1852 |
URE_CLRBIT_2(sc, URE_USB_LPM_CONFIG, URE_MCU_TYPE_USB, URE_LPM_U1U2_EN); |
1853 |
|
1854 |
/* Disable U2P3 */ |
1855 |
URE_CLRBIT_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB, URE_U2P3_ENABLE); |
1856 |
|
1857 |
ure_enable_aldps(sc, false); |
1858 |
|
1859 |
/* Enable rxdy_gated */ |
1860 |
URE_SETBIT_2(sc, URE_PLA_MISC_1, URE_MCU_TYPE_PLA, URE_RXDY_GATED_EN); |
1861 |
|
1862 |
/* Disable teredo */ |
1863 |
ure_disable_teredo(sc); |
1864 |
|
1865 |
DEVPRINTFN(14, sc->sc_ue.ue_dev, "rtl8153b_nic_reset: RCR: %#x\n", ure_read_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA)); |
1866 |
URE_CLRBIT_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA, URE_RCR_ACPT_ALL); |
1867 |
|
1868 |
ure_reset(sc); |
1869 |
|
1870 |
/* Reset BMU */ |
1871 |
URE_CLRBIT_1(sc, URE_USB_BMU_RESET, URE_MCU_TYPE_USB, URE_BMU_RESET_EP_IN | URE_BMU_RESET_EP_OUT); |
1872 |
URE_SETBIT_1(sc, URE_USB_BMU_RESET, URE_MCU_TYPE_USB, URE_BMU_RESET_EP_IN | URE_BMU_RESET_EP_OUT); |
1873 |
|
1874 |
URE_CLRBIT_1(sc, URE_PLA_OOB_CTRL, URE_MCU_TYPE_PLA, URE_NOW_IS_OOB); |
1875 |
URE_CLRBIT_2(sc, URE_PLA_SFF_STS_7, URE_MCU_TYPE_PLA, URE_MCU_BORW_EN); |
1876 |
if (sc->sc_flags & URE_FLAG_8153B) { |
1877 |
for (i = 0; i < URE_TIMEOUT; i++) { |
1878 |
if (ure_read_1(sc, URE_PLA_OOB_CTRL, URE_MCU_TYPE_PLA) & |
1879 |
URE_LINK_LIST_READY) |
1880 |
break; |
1881 |
uether_pause(&sc->sc_ue, hz / 100); |
1882 |
} |
1883 |
if (i == URE_TIMEOUT) |
1884 |
device_printf(sc->sc_ue.ue_dev, |
1885 |
"timeout waiting for OOB control\n"); |
1886 |
|
1887 |
URE_SETBIT_2(sc, URE_PLA_SFF_STS_7, URE_MCU_TYPE_PLA, URE_RE_INIT_LL); |
1888 |
for (i = 0; i < URE_TIMEOUT; i++) { |
1889 |
if (ure_read_1(sc, URE_PLA_OOB_CTRL, URE_MCU_TYPE_PLA) & |
1890 |
URE_LINK_LIST_READY) |
1891 |
break; |
1892 |
uether_pause(&sc->sc_ue, hz / 100); |
1893 |
} |
1894 |
if (i == URE_TIMEOUT) |
1895 |
device_printf(sc->sc_ue.ue_dev, |
1896 |
"timeout waiting for OOB control\n"); |
1897 |
} |
1898 |
|
1899 |
/* Configure rxvlan */ |
1900 |
val = ure_read_2(sc, 0xc012, URE_MCU_TYPE_PLA); |
1901 |
val &= ~0x00c0; |
1902 |
if (ifp->if_capabilities & IFCAP_VLAN_HWTAGGING) |
1903 |
val |= 0x00c0; |
1904 |
ure_write_2(sc, 0xc012, URE_MCU_TYPE_PLA, val); |
1905 |
|
1906 |
val = if_getmtu(ifp); |
1907 |
ure_write_2(sc, URE_PLA_RMS, URE_MCU_TYPE_PLA, URE_FRAMELEN(val)); |
1908 |
ure_write_1(sc, URE_PLA_MTPS, URE_MCU_TYPE_PLA, URE_MTPS_JUMBO); |
1909 |
|
1910 |
if (sc->sc_flags & URE_FLAG_8153B) { |
1911 |
URE_SETBIT_2(sc, URE_PLA_TCR0, URE_MCU_TYPE_PLA, URE_TCR0_AUTO_FIFO); |
1912 |
ure_reset(sc); |
1913 |
} |
1914 |
|
1915 |
/* Configure fc parameter */ |
1916 |
if (sc->sc_flags & URE_FLAG_8156) { |
1917 |
ure_write_2(sc, 0xc0a6, URE_MCU_TYPE_PLA, 0x0400); |
1918 |
ure_write_2(sc, 0xc0aa, URE_MCU_TYPE_PLA, 0x0800); |
1919 |
} else if (sc->sc_flags & URE_FLAG_8156B) { |
1920 |
ure_write_2(sc, 0xc0a6, URE_MCU_TYPE_PLA, 0x0200); |
1921 |
ure_write_2(sc, 0xc0aa, URE_MCU_TYPE_PLA, 0x0400); |
1922 |
} |
1923 |
|
1924 |
/* Configure Rx FIFO threshold. */ |
1925 |
if (sc->sc_flags & URE_FLAG_8153B) { |
1926 |
ure_write_4(sc, URE_PLA_RXFIFO_CTRL0, URE_MCU_TYPE_PLA, URE_RXFIFO_THR1_NORMAL); |
1927 |
ure_write_2(sc, URE_PLA_RXFIFO_CTRL1, URE_MCU_TYPE_PLA, URE_RXFIFO_THR2_NORMAL); |
1928 |
ure_write_2(sc, URE_PLA_RXFIFO_CTRL2, URE_MCU_TYPE_PLA, URE_RXFIFO_THR3_NORMAL); |
1929 |
ure_write_4(sc, URE_USB_RX_BUF_TH, URE_MCU_TYPE_USB, URE_RX_THR_B); |
1930 |
} else { |
1931 |
ure_write_2(sc, 0xc0a2, URE_MCU_TYPE_PLA, |
1932 |
(ure_read_2(sc, 0xc0a2, URE_MCU_TYPE_PLA) & ~0xfff) | 0x08); |
1933 |
ure_write_4(sc, URE_USB_RX_BUF_TH, URE_MCU_TYPE_USB, 0x00600400); |
1934 |
} |
1935 |
|
1936 |
/* Configure Tx FIFO threshold. */ |
1937 |
if (sc->sc_flags & URE_FLAG_8153B) { |
1938 |
ure_write_4(sc, URE_PLA_TXFIFO_CTRL, URE_MCU_TYPE_PLA, URE_TXFIFO_THR_NORMAL2); |
1939 |
} else if (sc->sc_flags & URE_FLAG_8156) { |
1940 |
ure_write_2(sc, URE_PLA_TXFIFO_CTRL, URE_MCU_TYPE_PLA, URE_TXFIFO_THR_NORMAL2); |
1941 |
URE_SETBIT_2(sc, 0xd4b4, URE_MCU_TYPE_USB, 0x0002); |
1942 |
} else if (sc->sc_flags & URE_FLAG_8156B) { |
1943 |
ure_write_2(sc, URE_PLA_TXFIFO_CTRL, URE_MCU_TYPE_PLA, 0x0008); |
1944 |
ure_write_2(sc, 0xe61a, URE_MCU_TYPE_PLA, |
1945 |
(URE_FRAMELEN(val) + 0x100) / 16 ); |
1946 |
} |
1947 |
|
1948 |
URE_CLRBIT_2(sc, URE_PLA_MAC_PWR_CTRL3, URE_MCU_TYPE_PLA, URE_PLA_MCU_SPDWN_EN); |
1949 |
|
1950 |
if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) |
1951 |
URE_CLRBIT_2(sc, 0xd32a, URE_MCU_TYPE_USB, 0x300); |
1952 |
|
1953 |
ure_enable_aldps(sc, true); |
1954 |
|
1955 |
if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { |
1956 |
/* Enable U2P3 */ |
1957 |
URE_SETBIT_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB, URE_U2P3_ENABLE); |
1958 |
} |
1959 |
|
1960 |
/* Enable U1U2 */ |
1961 |
if (usbd_get_speed(sc->sc_ue.ue_udev) == USB_SPEED_SUPER) |
1962 |
URE_SETBIT_2(sc, URE_USB_LPM_CONFIG, URE_MCU_TYPE_USB, URE_LPM_U1U2_EN); |
1963 |
} |
1964 |
|
1965 |
static void |
1512 |
ure_stop(struct usb_ether *ue) |
1966 |
ure_stop(struct usb_ether *ue) |
1513 |
{ |
1967 |
{ |
1514 |
struct ure_softc *sc = uether_getsc(ue); |
1968 |
struct ure_softc *sc = uether_getsc(ue); |
Lines 1523-1530
Link Here
|
1523 |
/* |
1977 |
/* |
1524 |
* stop all the transfers, if not already stopped: |
1978 |
* stop all the transfers, if not already stopped: |
1525 |
*/ |
1979 |
*/ |
1526 |
for (int i = 0; i < URE_N_TRANSFER; i++) { |
1980 |
for (int i = 0; i < URE_MAX_RX; i++) { |
1527 |
usbd_transfer_stop(sc->sc_rx_xfer[i]); |
1981 |
usbd_transfer_stop(sc->sc_rx_xfer[i]); |
|
|
1982 |
} |
1983 |
for (int i = 0; i < URE_MAX_TX; i++) { |
1528 |
usbd_transfer_stop(sc->sc_tx_xfer[i]); |
1984 |
usbd_transfer_stop(sc->sc_tx_xfer[i]); |
1529 |
} |
1985 |
} |
1530 |
} |
1986 |
} |
Lines 1533-1612
Link Here
|
1533 |
ure_disable_teredo(struct ure_softc *sc) |
1989 |
ure_disable_teredo(struct ure_softc *sc) |
1534 |
{ |
1990 |
{ |
1535 |
|
1991 |
|
1536 |
ure_write_4(sc, URE_PLA_TEREDO_CFG, URE_MCU_TYPE_PLA, |
1992 |
if (sc->sc_flags & (URE_FLAG_8153B | URE_FLAG_8156 | URE_FLAG_8156B)) |
1537 |
ure_read_4(sc, URE_PLA_TEREDO_CFG, URE_MCU_TYPE_PLA) & |
1993 |
ure_write_1(sc, URE_PLA_TEREDO_CFG, URE_MCU_TYPE_PLA, 0xff); |
1538 |
~(URE_TEREDO_SEL | URE_TEREDO_RS_EVENT_MASK | URE_OOB_TEREDO_EN)); |
1994 |
else { |
1539 |
ure_write_2(sc, URE_PLA_WDT6_CTRL, URE_MCU_TYPE_PLA, |
1995 |
URE_CLRBIT_2(sc, URE_PLA_TEREDO_CFG, URE_MCU_TYPE_PLA, |
1540 |
URE_WDT6_SET_MODE); |
1996 |
(URE_TEREDO_SEL | URE_TEREDO_RS_EVENT_MASK | URE_OOB_TEREDO_EN)); |
|
|
1997 |
} |
1998 |
ure_write_2(sc, URE_PLA_WDT6_CTRL, URE_MCU_TYPE_PLA, URE_WDT6_SET_MODE); |
1541 |
ure_write_2(sc, URE_PLA_REALWOW_TIMER, URE_MCU_TYPE_PLA, 0); |
1999 |
ure_write_2(sc, URE_PLA_REALWOW_TIMER, URE_MCU_TYPE_PLA, 0); |
1542 |
ure_write_4(sc, URE_PLA_TEREDO_TIMER, URE_MCU_TYPE_PLA, 0); |
2000 |
ure_write_4(sc, URE_PLA_TEREDO_TIMER, URE_MCU_TYPE_PLA, 0); |
1543 |
} |
2001 |
} |
1544 |
|
2002 |
|
1545 |
static void |
2003 |
static void |
1546 |
ure_init_fifo(struct ure_softc *sc) |
2004 |
ure_enable_aldps(struct ure_softc *sc, bool enable) |
1547 |
{ |
2005 |
{ |
1548 |
uint32_t rx_fifo1, rx_fifo2; |
|
|
1549 |
int i; |
2006 |
int i; |
1550 |
|
2007 |
|
1551 |
ure_write_2(sc, URE_PLA_MISC_1, URE_MCU_TYPE_PLA, |
2008 |
if (enable) |
1552 |
ure_read_2(sc, URE_PLA_MISC_1, URE_MCU_TYPE_PLA) | |
2009 |
ure_ocp_reg_write(sc, URE_OCP_POWER_CFG, |
1553 |
URE_RXDY_GATED_EN); |
2010 |
ure_ocp_reg_read(sc, URE_OCP_POWER_CFG) | URE_EN_ALDPS); |
|
|
2011 |
else { |
2012 |
ure_ocp_reg_write(sc, URE_OCP_ALDPS_CONFIG, URE_ENPDNPS | URE_LINKENA | |
2013 |
URE_DIS_SDSAVE); |
2014 |
for (i = 0; i < 20; i++) { |
2015 |
uether_pause(&sc->sc_ue, hz / 1000); |
2016 |
if (ure_ocp_reg_read(sc, 0xe000) & 0x0100) |
2017 |
break; |
2018 |
} |
2019 |
} |
2020 |
} |
1554 |
|
2021 |
|
1555 |
ure_disable_teredo(sc); |
2022 |
static uint16_t |
|
|
2023 |
ure_phy_status(struct ure_softc *sc, uint16_t desired) |
2024 |
{ |
2025 |
uint16_t val; |
2026 |
int i; |
2027 |
|
2028 |
for (i = 0; i < URE_TIMEOUT; i++) { |
2029 |
val = ure_ocp_reg_read(sc, URE_OCP_PHY_STATUS) & |
2030 |
URE_PHY_STAT_MASK; |
2031 |
if (desired) { |
2032 |
if (val == desired) |
2033 |
break; |
2034 |
} else { |
2035 |
if (val == URE_PHY_STAT_LAN_ON || |
2036 |
val == URE_PHY_STAT_PWRDN || |
2037 |
val == URE_PHY_STAT_EXT_INIT) |
2038 |
break; |
2039 |
} |
2040 |
uether_pause(&sc->sc_ue, hz / 100); |
2041 |
} |
2042 |
if (i == URE_TIMEOUT) |
2043 |
device_printf(sc->sc_ue.ue_dev, |
2044 |
"timeout waiting for phy to stabilize\n"); |
1556 |
|
2045 |
|
1557 |
DEVPRINTFN(14, sc->sc_ue.ue_dev, "init_fifo: RCR: %#x\n", ure_read_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA)); |
2046 |
return val; |
1558 |
ure_write_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA, |
2047 |
} |
1559 |
ure_read_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA) & |
|
|
1560 |
~URE_RCR_ACPT_ALL); |
1561 |
|
2048 |
|
1562 |
if (!(sc->sc_flags & URE_FLAG_8152)) { |
2049 |
static void |
1563 |
if (sc->sc_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10 | |
2050 |
ure_rtl8152_nic_reset(struct ure_softc *sc) |
1564 |
URE_CHIP_VER_5C20)) { |
2051 |
{ |
1565 |
ure_ocp_reg_write(sc, URE_OCP_ADC_CFG, |
2052 |
uint32_t rx_fifo1, rx_fifo2; |
1566 |
URE_CKADSEL_L | URE_ADC_EN | URE_EN_EMI_L); |
2053 |
int i; |
1567 |
} |
|
|
1568 |
if (sc->sc_chip & URE_CHIP_VER_5C00) { |
1569 |
ure_ocp_reg_write(sc, URE_OCP_EEE_CFG, |
1570 |
ure_ocp_reg_read(sc, URE_OCP_EEE_CFG) & |
1571 |
~URE_CTAP_SHORT_EN); |
1572 |
} |
1573 |
ure_ocp_reg_write(sc, URE_OCP_POWER_CFG, |
1574 |
ure_ocp_reg_read(sc, URE_OCP_POWER_CFG) | |
1575 |
URE_EEE_CLKDIV_EN); |
1576 |
ure_ocp_reg_write(sc, URE_OCP_DOWN_SPEED, |
1577 |
ure_ocp_reg_read(sc, URE_OCP_DOWN_SPEED) | |
1578 |
URE_EN_10M_BGOFF); |
1579 |
ure_ocp_reg_write(sc, URE_OCP_POWER_CFG, |
1580 |
ure_ocp_reg_read(sc, URE_OCP_POWER_CFG) | |
1581 |
URE_EN_10M_PLLOFF); |
1582 |
ure_ocp_reg_write(sc, URE_OCP_SRAM_ADDR, URE_SRAM_IMPEDANCE); |
1583 |
ure_ocp_reg_write(sc, URE_OCP_SRAM_DATA, 0x0b13); |
1584 |
ure_write_2(sc, URE_PLA_PHY_PWR, URE_MCU_TYPE_PLA, |
1585 |
ure_read_2(sc, URE_PLA_PHY_PWR, URE_MCU_TYPE_PLA) | |
1586 |
URE_PFM_PWM_SWITCH); |
1587 |
|
2054 |
|
1588 |
/* Enable LPF corner auto tune. */ |
2055 |
URE_SETBIT_2(sc, URE_PLA_MISC_1, URE_MCU_TYPE_PLA, URE_RXDY_GATED_EN); |
1589 |
ure_ocp_reg_write(sc, URE_OCP_SRAM_ADDR, URE_SRAM_LPF_CFG); |
|
|
1590 |
ure_ocp_reg_write(sc, URE_OCP_SRAM_DATA, 0xf70f); |
1591 |
|
2056 |
|
1592 |
/* Adjust 10M amplitude. */ |
2057 |
ure_disable_teredo(sc); |
1593 |
ure_ocp_reg_write(sc, URE_OCP_SRAM_ADDR, URE_SRAM_10M_AMP1); |
|
|
1594 |
ure_ocp_reg_write(sc, URE_OCP_SRAM_DATA, 0x00af); |
1595 |
ure_ocp_reg_write(sc, URE_OCP_SRAM_ADDR, URE_SRAM_10M_AMP2); |
1596 |
ure_ocp_reg_write(sc, URE_OCP_SRAM_DATA, 0x0208); |
1597 |
} |
1598 |
|
2058 |
|
|
|
2059 |
DEVPRINTFN(14, sc->sc_ue.ue_dev, "rtl8152_nic_reset: RCR: %#x\n", ure_read_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA)); |
2060 |
URE_CLRBIT_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA, URE_RCR_ACPT_ALL); |
2061 |
|
1599 |
ure_reset(sc); |
2062 |
ure_reset(sc); |
1600 |
|
2063 |
|
1601 |
ure_write_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA, 0); |
2064 |
ure_write_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA, 0); |
1602 |
|
2065 |
|
1603 |
ure_write_1(sc, URE_PLA_OOB_CTRL, URE_MCU_TYPE_PLA, |
2066 |
URE_CLRBIT_1(sc, URE_PLA_OOB_CTRL, URE_MCU_TYPE_PLA, URE_NOW_IS_OOB); |
1604 |
ure_read_1(sc, URE_PLA_OOB_CTRL, URE_MCU_TYPE_PLA) & |
|
|
1605 |
~URE_NOW_IS_OOB); |
1606 |
|
2067 |
|
1607 |
ure_write_2(sc, URE_PLA_SFF_STS_7, URE_MCU_TYPE_PLA, |
2068 |
URE_CLRBIT_2(sc, URE_PLA_SFF_STS_7, URE_MCU_TYPE_PLA, URE_MCU_BORW_EN); |
1608 |
ure_read_2(sc, URE_PLA_SFF_STS_7, URE_MCU_TYPE_PLA) & |
|
|
1609 |
~URE_MCU_BORW_EN); |
1610 |
for (i = 0; i < URE_TIMEOUT; i++) { |
2069 |
for (i = 0; i < URE_TIMEOUT; i++) { |
1611 |
if (ure_read_1(sc, URE_PLA_OOB_CTRL, URE_MCU_TYPE_PLA) & |
2070 |
if (ure_read_1(sc, URE_PLA_OOB_CTRL, URE_MCU_TYPE_PLA) & |
1612 |
URE_LINK_LIST_READY) |
2071 |
URE_LINK_LIST_READY) |
Lines 1616-1624
Link Here
|
1616 |
if (i == URE_TIMEOUT) |
2075 |
if (i == URE_TIMEOUT) |
1617 |
device_printf(sc->sc_ue.ue_dev, |
2076 |
device_printf(sc->sc_ue.ue_dev, |
1618 |
"timeout waiting for OOB control\n"); |
2077 |
"timeout waiting for OOB control\n"); |
1619 |
ure_write_2(sc, URE_PLA_SFF_STS_7, URE_MCU_TYPE_PLA, |
2078 |
URE_SETBIT_2(sc, URE_PLA_SFF_STS_7, URE_MCU_TYPE_PLA, URE_RE_INIT_LL); |
1620 |
ure_read_2(sc, URE_PLA_SFF_STS_7, URE_MCU_TYPE_PLA) | |
|
|
1621 |
URE_RE_INIT_LL); |
1622 |
for (i = 0; i < URE_TIMEOUT; i++) { |
2079 |
for (i = 0; i < URE_TIMEOUT; i++) { |
1623 |
if (ure_read_1(sc, URE_PLA_OOB_CTRL, URE_MCU_TYPE_PLA) & |
2080 |
if (ure_read_1(sc, URE_PLA_OOB_CTRL, URE_MCU_TYPE_PLA) & |
1624 |
URE_LINK_LIST_READY) |
2081 |
URE_LINK_LIST_READY) |
Lines 1629-1640
Link Here
|
1629 |
device_printf(sc->sc_ue.ue_dev, |
2086 |
device_printf(sc->sc_ue.ue_dev, |
1630 |
"timeout waiting for OOB control\n"); |
2087 |
"timeout waiting for OOB control\n"); |
1631 |
|
2088 |
|
1632 |
ure_write_2(sc, URE_PLA_CPCR, URE_MCU_TYPE_PLA, |
2089 |
URE_CLRBIT_2(sc, URE_PLA_CPCR, URE_MCU_TYPE_PLA, URE_CPCR_RX_VLAN); |
1633 |
ure_read_2(sc, URE_PLA_CPCR, URE_MCU_TYPE_PLA) & |
2090 |
|
1634 |
~URE_CPCR_RX_VLAN); |
2091 |
URE_SETBIT_2(sc, URE_PLA_TCR0, URE_MCU_TYPE_PLA, URE_TCR0_AUTO_FIFO); |
1635 |
ure_write_2(sc, URE_PLA_TCR0, URE_MCU_TYPE_PLA, |
|
|
1636 |
ure_read_2(sc, URE_PLA_TCR0, URE_MCU_TYPE_PLA) | |
1637 |
URE_TCR0_AUTO_FIFO); |
1638 |
|
2092 |
|
1639 |
/* Configure Rx FIFO threshold. */ |
2093 |
/* Configure Rx FIFO threshold. */ |
1640 |
ure_write_4(sc, URE_PLA_RXFIFO_CTRL0, URE_MCU_TYPE_PLA, |
2094 |
ure_write_4(sc, URE_PLA_RXFIFO_CTRL0, URE_MCU_TYPE_PLA, |