56 if (!netif_running(net))
66 static void ax88172a_adjust_link(
struct net_device *netdev)
86 netdev_dbg(netdev,
"speed %u duplex %d, setting mode to 0x%04x\n",
92 static void ax88172a_status(
struct usbnet *dev,
struct urb *
urb)
98 static int ax88172a_init_mdio(
struct usbnet *dev)
103 priv->
mdio = mdiobus_alloc();
105 netdev_err(dev->
net,
"Could not allocate MDIO bus\n");
109 priv->
mdio->priv = (
void *)dev;
110 priv->
mdio->read = &asix_mdio_bus_read;
111 priv->
mdio->write = &asix_mdio_bus_write;
112 priv->
mdio->name =
"Asix MDIO Bus";
115 dev->
udev->bus->busnum, dev->
udev->devnum);
118 if (!priv->
mdio->irq) {
119 netdev_err(dev->
net,
"Could not allocate mdio->irq\n");
128 netdev_err(dev->
net,
"Could not register MDIO bus\n");
132 netdev_info(dev->
net,
"registered mdio bus %s\n", priv->
mdio->id);
142 static void ax88172a_remove_mdio(
struct usbnet *dev)
146 netdev_info(dev->
net,
"deregistering mdio bus %s\n", priv->
mdio->id);
160 .ndo_do_ioctl = ax88172a_ioctl,
188 static const struct ethtool_ops ax88172a_ethtool_ops = {
203 static int ax88172a_reset_phy(
struct usbnet *dev,
int embd_phy)
239 netdev_err(dev->
net,
"Could not allocate memory for private data\n");
247 netdev_err(dev->
net,
"Failed to read MAC address: %d\n", ret);
252 dev->
net->netdev_ops = &ax88172a_netdev_ops;
253 dev->
net->ethtool_ops = &ax88172a_ethtool_ops;
258 netdev_err(dev->
net,
"Failed to read software interface selection register: %d\n",
263 netdev_dbg(dev->
net,
"AX_CMD_SW_PHY_STATUS = 0x%02x\n", buf[0]);
274 netdev_err(dev->
net,
"Interface mode not supported by driver\n");
290 ret = ax88172a_init_mdio(dev);
301 static int ax88172a_stop(
struct usbnet *dev)
308 netdev_info(dev->
net,
"Disconnecting from phy %s\n",
321 ax88172a_remove_mdio(dev);
325 static int ax88172a_reset(
struct usbnet *dev)
350 netdev_err(dev->
net,
"Write IPG,IPG1,IPG2 failed: %d\n", ret);
367 netdev_dbg(dev->
net,
"RX_CTL is 0x%04x after all initializations\n",
371 netdev_dbg(dev->
net,
"Medium Status is 0x%04x after all initializations\n",
379 &ax88172a_adjust_link,
381 if (IS_ERR(priv->
phydev)) {
382 netdev_err(dev->
net,
"Could not connect to PHY device %s\n",
384 ret = PTR_ERR(priv->
phydev);
388 netdev_info(dev->
net,
"Connected to phy %s\n", priv->
phy_name);
404 .description =
"ASIX AX88172A USB 2.0 Ethernet",
405 .bind = ax88172a_bind,
406 .reset = ax88172a_reset,
407 .stop = ax88172a_stop,
408 .unbind = ax88172a_unbind,
409 .status = ax88172a_status,