Lines Matching refs:dev
61 static int dm_read(struct usbnet *dev, u8 reg, u16 length, void *data) in dm_read() argument
64 err = usbnet_read_cmd(dev, DM_READ_REGS, in dm_read()
72 static int dm_read_reg(struct usbnet *dev, u8 reg, u8 *value) in dm_read_reg() argument
74 return dm_read(dev, reg, 1, value); in dm_read_reg()
77 static int dm_write(struct usbnet *dev, u8 reg, u16 length, void *data) in dm_write() argument
80 err = usbnet_write_cmd(dev, DM_WRITE_REGS, in dm_write()
89 static int dm_write_reg(struct usbnet *dev, u8 reg, u8 value) in dm_write_reg() argument
91 return usbnet_write_cmd(dev, DM_WRITE_REG, in dm_write_reg()
96 static void dm_write_async(struct usbnet *dev, u8 reg, u16 length, in dm_write_async() argument
99 usbnet_write_cmd_async(dev, DM_WRITE_REGS, in dm_write_async()
104 static void dm_write_reg_async(struct usbnet *dev, u8 reg, u8 value) in dm_write_reg_async() argument
106 usbnet_write_cmd_async(dev, DM_WRITE_REG, in dm_write_reg_async()
111 static int dm_read_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 *value) in dm_read_shared_word() argument
115 mutex_lock(&dev->phy_mutex); in dm_read_shared_word()
117 dm_write_reg(dev, DM_SHARED_ADDR, phy ? (reg | 0x40) : reg); in dm_read_shared_word()
118 dm_write_reg(dev, DM_SHARED_CTRL, phy ? 0xc : 0x4); in dm_read_shared_word()
124 ret = dm_read_reg(dev, DM_SHARED_CTRL, &tmp); in dm_read_shared_word()
134 netdev_err(dev->net, "%s read timed out!\n", phy ? "phy" : "eeprom"); in dm_read_shared_word()
139 dm_write_reg(dev, DM_SHARED_CTRL, 0x0); in dm_read_shared_word()
140 ret = dm_read(dev, DM_SHARED_DATA, 2, value); in dm_read_shared_word()
142 netdev_dbg(dev->net, "read shared %d 0x%02x returned 0x%04x, %d\n", in dm_read_shared_word()
146 mutex_unlock(&dev->phy_mutex); in dm_read_shared_word()
150 static int dm_write_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 value) in dm_write_shared_word() argument
154 mutex_lock(&dev->phy_mutex); in dm_write_shared_word()
156 ret = dm_write(dev, DM_SHARED_DATA, 2, &value); in dm_write_shared_word()
160 dm_write_reg(dev, DM_SHARED_ADDR, phy ? (reg | 0x40) : reg); in dm_write_shared_word()
161 dm_write_reg(dev, DM_SHARED_CTRL, phy ? 0x1a : 0x12); in dm_write_shared_word()
167 ret = dm_read_reg(dev, DM_SHARED_CTRL, &tmp); in dm_write_shared_word()
177 netdev_err(dev->net, "%s write timed out!\n", phy ? "phy" : "eeprom"); in dm_write_shared_word()
182 dm_write_reg(dev, DM_SHARED_CTRL, 0x0); in dm_write_shared_word()
185 mutex_unlock(&dev->phy_mutex); in dm_write_shared_word()
189 static int dm_read_eeprom_word(struct usbnet *dev, u8 offset, void *value) in dm_read_eeprom_word() argument
191 return dm_read_shared_word(dev, 0, offset, value); in dm_read_eeprom_word()
196 static int dm9601_get_eeprom_len(struct net_device *dev) in dm9601_get_eeprom_len() argument
204 struct usbnet *dev = netdev_priv(net); in dm9601_get_eeprom() local
213 if (dm_read_eeprom_word(dev, eeprom->offset / 2 + i, in dm9601_get_eeprom()
222 struct usbnet *dev = netdev_priv(netdev); in dm9601_mdio_read() local
228 netdev_dbg(dev->net, "Only internal phy supported\n"); in dm9601_mdio_read()
232 err = dm_read_shared_word(dev, 1, loc, &res); in dm9601_mdio_read()
234 netdev_err(dev->net, "MDIO read error: %d\n", err); in dm9601_mdio_read()
238 netdev_dbg(dev->net, in dm9601_mdio_read()
248 struct usbnet *dev = netdev_priv(netdev); in dm9601_mdio_write() local
252 netdev_dbg(dev->net, "Only internal phy supported\n"); in dm9601_mdio_write()
256 netdev_dbg(dev->net, "dm9601_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", in dm9601_mdio_write()
259 dm_write_shared_word(dev, 1, loc, res); in dm9601_mdio_write()
271 struct usbnet *dev = netdev_priv(net); in dm9601_get_link() local
273 return mii_link_ok(&dev->mii); in dm9601_get_link()
278 struct usbnet *dev = netdev_priv(net); in dm9601_ioctl() local
280 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); in dm9601_ioctl()
297 struct usbnet *dev = netdev_priv(net); in dm9601_set_multicast() local
300 u8 *hashes = (u8 *) & dev->data; in dm9601_set_multicast()
320 dm_write_async(dev, DM_MCAST_ADDR, DM_MCAST_SIZE, hashes); in dm9601_set_multicast()
321 dm_write_reg_async(dev, DM_RX_CTRL, rx_ctl); in dm9601_set_multicast()
324 static void __dm9601_set_mac_address(struct usbnet *dev) in __dm9601_set_mac_address() argument
326 dm_write_async(dev, DM_PHY_ADDR, ETH_ALEN, dev->net->dev_addr); in __dm9601_set_mac_address()
332 struct usbnet *dev = netdev_priv(net); in dm9601_set_mac_address() local
335 dev_err(&net->dev, "not setting invalid mac address %pM\n", in dm9601_set_mac_address()
341 __dm9601_set_mac_address(dev); in dm9601_set_mac_address()
359 static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf) in dm9601_bind() argument
364 ret = usbnet_get_endpoints(dev, intf); in dm9601_bind()
368 dev->net->netdev_ops = &dm9601_netdev_ops; in dm9601_bind()
369 dev->net->ethtool_ops = &dm9601_ethtool_ops; in dm9601_bind()
370 dev->net->hard_header_len += DM_TX_OVERHEAD; in dm9601_bind()
371 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; in dm9601_bind()
377 dev->rx_urb_size = dev->net->mtu + ETH_HLEN + DM_RX_OVERHEAD + 1; in dm9601_bind()
379 dev->mii.dev = dev->net; in dm9601_bind()
380 dev->mii.mdio_read = dm9601_mdio_read; in dm9601_bind()
381 dev->mii.mdio_write = dm9601_mdio_write; in dm9601_bind()
382 dev->mii.phy_id_mask = 0x1f; in dm9601_bind()
383 dev->mii.reg_num_mask = 0x1f; in dm9601_bind()
386 dm_write_reg(dev, DM_NET_CTRL, 1); in dm9601_bind()
390 if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, mac) < 0) { in dm9601_bind()
400 eth_hw_addr_set(dev->net, mac); in dm9601_bind()
404 dev->net->dev_addr); in dm9601_bind()
405 __dm9601_set_mac_address(dev); in dm9601_bind()
408 if (dm_read_reg(dev, DM_CHIP_ID, &id) < 0) { in dm9601_bind()
409 netdev_err(dev->net, "Error reading chip ID\n"); in dm9601_bind()
418 if (dm_read_reg(dev, DM_MODE_CTRL, &mode) < 0) { in dm9601_bind()
419 netdev_err(dev->net, "Error reading MODE_CTRL\n"); in dm9601_bind()
423 dm_write_reg(dev, DM_MODE_CTRL, mode & 0x7f); in dm9601_bind()
427 dm_write_reg(dev, DM_GPR_CTRL, 1); in dm9601_bind()
428 dm_write_reg(dev, DM_GPR_DATA, 0); in dm9601_bind()
431 dm9601_set_multicast(dev->net); in dm9601_bind()
433 dm9601_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); in dm9601_bind()
434 dm9601_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, in dm9601_bind()
436 mii_nway_restart(&dev->mii); in dm9601_bind()
442 static int dm9601_rx_fixup(struct usbnet *dev, struct sk_buff *skb) in dm9601_rx_fixup() argument
456 dev_err(&dev->udev->dev, "unexpected tiny rx frame\n"); in dm9601_rx_fixup()
464 if (status & 0x01) dev->net->stats.rx_fifo_errors++; in dm9601_rx_fixup()
465 if (status & 0x02) dev->net->stats.rx_crc_errors++; in dm9601_rx_fixup()
466 if (status & 0x04) dev->net->stats.rx_frame_errors++; in dm9601_rx_fixup()
467 if (status & 0x20) dev->net->stats.rx_missed_errors++; in dm9601_rx_fixup()
468 if (status & 0x90) dev->net->stats.rx_length_errors++; in dm9601_rx_fixup()
478 static struct sk_buff *dm9601_tx_fixup(struct usbnet *dev, struct sk_buff *skb, in dm9601_tx_fixup() argument
496 while ((len & 1) || !(len % dev->maxpacket)) in dm9601_tx_fixup()
525 static void dm9601_status(struct usbnet *dev, struct urb *urb) in dm9601_status() argument
547 if (netif_carrier_ok(dev->net) != link) { in dm9601_status()
548 usbnet_link_change(dev, link, 1); in dm9601_status()
549 netdev_dbg(dev->net, "Link Status is: %d\n", link); in dm9601_status()
553 static int dm9601_link_reset(struct usbnet *dev) in dm9601_link_reset() argument
557 mii_check_media(&dev->mii, 1, 1); in dm9601_link_reset()
558 mii_ethtool_gset(&dev->mii, &ecmd); in dm9601_link_reset()
560 netdev_dbg(dev->net, "link_reset() speed: %u duplex: %d\n", in dm9601_link_reset()