Thu Mar 3 05:54:11 2022 UTC ()
axen(4): Use axen mii read/write reg routines, not usbnet ones.

The usbnet wrappers don't add anything important.  We already test
usbnet_isdying in axen_cmd, and that's already a best-effort thing
(which should probably be done better by having usbd_do_request fail
promptly if detaching anyway).


(riastradh)
diff -r1.86 -r1.87 src/sys/dev/usb/if_axen.c

cvs diff -r1.86 -r1.87 src/sys/dev/usb/if_axen.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_axen.c 2022/03/03 05:54:03 1.86
+++ src/sys/dev/usb/if_axen.c 2022/03/03 05:54:11 1.87
@@ -1,39 +1,39 @@ @@ -1,39 +1,39 @@
1/* $NetBSD: if_axen.c,v 1.86 2022/03/03 05:54:03 riastradh Exp $ */ 1/* $NetBSD: if_axen.c,v 1.87 2022/03/03 05:54:11 riastradh Exp $ */
2/* $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */ 2/* $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2013 Yojiro UO <yuo@openbsd.org> 5 * Copyright (c) 2013 Yojiro UO <yuo@openbsd.org>
6 * 6 *
7 * Permission to use, copy, modify, and distribute this software for any 7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above 8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies. 9 * copyright notice and this permission notice appear in all copies.
10 * 10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */ 18 */
19 19
20/* 20/*
21 * ASIX Electronics AX88178a USB 2.0 ethernet and AX88179 USB 3.0 Ethernet 21 * ASIX Electronics AX88178a USB 2.0 ethernet and AX88179 USB 3.0 Ethernet
22 * driver. 22 * driver.
23 */ 23 */
24 24
25#include <sys/cdefs.h> 25#include <sys/cdefs.h>
26__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.86 2022/03/03 05:54:03 riastradh Exp $"); 26__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.87 2022/03/03 05:54:11 riastradh Exp $");
27 27
28#ifdef _KERNEL_OPT 28#ifdef _KERNEL_OPT
29#include "opt_usb.h" 29#include "opt_usb.h"
30#endif 30#endif
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33 33
34#include <netinet/in.h> /* XXX for netinet/ip.h */ 34#include <netinet/in.h> /* XXX for netinet/ip.h */
35#include <netinet/ip.h> /* XXX for IP_MAXPACKET */ 35#include <netinet/ip.h> /* XXX for IP_MAXPACKET */
36 36
37#include <dev/usb/usbnet.h> 37#include <dev/usb/usbnet.h>
38 38
39#include <dev/usb/if_axenreg.h> 39#include <dev/usb/if_axenreg.h>
@@ -482,38 +482,38 @@ axen_ax88179_init(struct usbnet *un) @@ -482,38 +482,38 @@ axen_ax88179_init(struct usbnet *un)
482 wval = htole16(ctl); 482 wval = htole16(ctl);
483 DPRINTF(("axen: set to medium mode: 0x%04x\n", ctl)); 483 DPRINTF(("axen: set to medium mode: 0x%04x\n", ctl));
484 axen_cmd(un, AXEN_CMD_MAC_WRITE2, 2, AXEN_MEDIUM_STATUS, &wval); 484 axen_cmd(un, AXEN_CMD_MAC_WRITE2, 2, AXEN_MEDIUM_STATUS, &wval);
485 usbd_delay_ms(un->un_udev, 100); 485 usbd_delay_ms(un->un_udev, 100);
486 486
487 axen_cmd(un, AXEN_CMD_MAC_READ2, 2, AXEN_MEDIUM_STATUS, &wval); 487 axen_cmd(un, AXEN_CMD_MAC_READ2, 2, AXEN_MEDIUM_STATUS, &wval);
488 DPRINTF(("axen: current medium mode: 0x%04x\n", le16toh(wval))); 488 DPRINTF(("axen: current medium mode: 0x%04x\n", le16toh(wval)));
489 489
490#if 0 /* XXX: TBD.... */ 490#if 0 /* XXX: TBD.... */
491#define GMII_LED_ACTIVE 0x1a 491#define GMII_LED_ACTIVE 0x1a
492#define GMII_PHY_PAGE_SEL 0x1e 492#define GMII_PHY_PAGE_SEL 0x1e
493#define GMII_PHY_PAGE_SEL 0x1f 493#define GMII_PHY_PAGE_SEL 0x1f
494#define GMII_PAGE_EXT 0x0007 494#define GMII_PAGE_EXT 0x0007
495 usbnet_mii_writereg(un->un_dev, un->un_phyno, GMII_PHY_PAGE_SEL, 495 axen_uno_mii_write_reg(un, un->un_phyno, GMII_PHY_PAGE_SEL,
496 GMII_PAGE_EXT); 496 GMII_PAGE_EXT);
497 usbnet_mii_writereg(un->un_dev, un->un_phyno, GMII_PHY_PAGE, 497 axen_uno_mii_write_reg(un, un->un_phyno, GMII_PHY_PAGE,
498 0x002c); 498 0x002c);
499#endif 499#endif
500 500
501#if 1 /* XXX: phy hack ? */ 501#if 1 /* XXX: phy hack ? */
502 usbnet_mii_writereg(un->un_dev, un->un_phyno, 0x1F, 0x0005); 502 axen_uno_mii_write_reg(un, un->un_phyno, 0x1F, 0x0005);
503 usbnet_mii_writereg(un->un_dev, un->un_phyno, 0x0C, 0x0000); 503 axen_uno_mii_write_reg(un, un->un_phyno, 0x0C, 0x0000);
504 usbnet_mii_readreg(un->un_dev, un->un_phyno, 0x0001, &wval); 504 axen_uno_mii_read_reg(un, un->un_phyno, 0x0001, &wval);
505 usbnet_mii_writereg(un->un_dev, un->un_phyno, 0x01, wval | 0x0080); 505 axen_uno_mii_write_reg(un, un->un_phyno, 0x01, wval | 0x0080);
506 usbnet_mii_writereg(un->un_dev, un->un_phyno, 0x1F, 0x0000); 506 axen_uno_mii_write_reg(un, un->un_phyno, 0x1F, 0x0000);
507#endif 507#endif
508 508
509 usbnet_unlock_core(un); 509 usbnet_unlock_core(un);
510} 510}
511 511
512static void 512static void
513axen_setoe_locked(struct usbnet *un) 513axen_setoe_locked(struct usbnet *un)
514{ 514{
515 struct ifnet * const ifp = usbnet_ifp(un); 515 struct ifnet * const ifp = usbnet_ifp(un);
516 uint64_t enabled = ifp->if_capenable; 516 uint64_t enabled = ifp->if_capenable;
517 uint8_t val; 517 uint8_t val;
518 518
519 KASSERT(IFNET_LOCKED(ifp)); 519 KASSERT(IFNET_LOCKED(ifp));