Lines Matching +full:inter +full:- +full:chip
1 // SPDX-License-Identifier: GPL-2.0+
77 } debug = { -1 };
86 struct device *dev = &priv->spi->dev; in spi_read_buf()
87 u8 *rx_buf = priv->spi_transfer_buf + 4; in spi_read_buf()
88 u8 *tx_buf = priv->spi_transfer_buf; in spi_read_buf()
106 ret = spi_sync(priv->spi, &msg); in spi_read_buf()
123 struct device *dev = &priv->spi->dev; in spi_write_buf()
126 if (len > SPI_TRANSFER_BUF_LEN - 1 || len <= 0) in spi_write_buf()
127 ret = -EINVAL; in spi_write_buf()
129 priv->spi_transfer_buf[0] = ENC28J60_WRITE_BUF_MEM; in spi_write_buf()
130 memcpy(&priv->spi_transfer_buf[1], data, len); in spi_write_buf()
131 ret = spi_write(priv->spi, priv->spi_transfer_buf, len + 1); in spi_write_buf()
144 struct device *dev = &priv->spi->dev; in spi_read_op()
156 ret = spi_write_then_read(priv->spi, tx_buf, 1, rx_buf, slen); in spi_read_op()
161 val = rx_buf[slen - 1]; in spi_read_op()
171 struct device *dev = &priv->spi->dev; in spi_write_op()
174 priv->spi_transfer_buf[0] = op | (addr & ADDR_MASK); in spi_write_op()
175 priv->spi_transfer_buf[1] = val; in spi_write_op()
176 ret = spi_write(priv->spi, priv->spi_transfer_buf, 2); in spi_write_op()
205 if ((b & ECON1_BSEL0) != (priv->bank & ECON1_BSEL0)) { in enc28j60_set_bank()
213 if ((b & ECON1_BSEL1) != (priv->bank & ECON1_BSEL1)) { in enc28j60_set_bank()
221 priv->bank = b; in enc28j60_set_bank()
227 * - nolock_xxx: caller needs to invoke mutex_lock, usually to access
229 * - locked_xxx: caller doesn't need to invoke mutex_lock, single access
246 mutex_lock(&priv->lock); in locked_reg_bfset()
248 mutex_unlock(&priv->lock); in locked_reg_bfset()
262 mutex_lock(&priv->lock); in locked_reg_bfclr()
264 mutex_unlock(&priv->lock); in locked_reg_bfclr()
280 mutex_lock(&priv->lock); in locked_regb_read()
282 mutex_unlock(&priv->lock); in locked_regb_read()
305 mutex_lock(&priv->lock); in locked_regw_read()
307 mutex_unlock(&priv->lock); in locked_regw_read()
323 mutex_lock(&priv->lock); in locked_regb_write()
325 mutex_unlock(&priv->lock); in locked_regb_write()
341 mutex_lock(&priv->lock); in locked_regw_write()
343 mutex_unlock(&priv->lock); in locked_regw_write()
353 mutex_lock(&priv->lock); in enc28j60_mem_read()
357 struct device *dev = &priv->spi->dev; in enc28j60_mem_read()
363 "%s() error writing ERDPT (0x%04x - 0x%04x)\n", in enc28j60_mem_read()
368 mutex_unlock(&priv->lock); in enc28j60_mem_read()
377 struct device *dev = &priv->spi->dev; in enc28j60_packet_write()
379 mutex_lock(&priv->lock); in enc28j60_packet_write()
394 /* write per-packet control byte */ in enc28j60_packet_write()
406 mutex_unlock(&priv->lock); in enc28j60_packet_write()
411 struct device *dev = &priv->spi->dev; in poll_ready()
419 return -ETIMEDOUT; in poll_ready()
442 mutex_lock(&priv->lock); in enc28j60_phy_read()
453 mutex_unlock(&priv->lock); in enc28j60_phy_read()
462 mutex_lock(&priv->lock); in enc28j60_phy_write()
469 mutex_unlock(&priv->lock); in enc28j60_phy_write()
475 * Program the hardware MAC address from dev->dev_addr.
481 struct device *dev = &priv->spi->dev; in enc28j60_set_hw_macaddr()
483 mutex_lock(&priv->lock); in enc28j60_set_hw_macaddr()
484 if (!priv->hw_enable) { in enc28j60_set_hw_macaddr()
487 ndev->name, ndev->dev_addr); in enc28j60_set_hw_macaddr()
488 /* NOTE: MAC address in ENC28J60 is byte-backward */ in enc28j60_set_hw_macaddr()
489 nolock_regb_write(priv, MAADR5, ndev->dev_addr[0]); in enc28j60_set_hw_macaddr()
490 nolock_regb_write(priv, MAADR4, ndev->dev_addr[1]); in enc28j60_set_hw_macaddr()
491 nolock_regb_write(priv, MAADR3, ndev->dev_addr[2]); in enc28j60_set_hw_macaddr()
492 nolock_regb_write(priv, MAADR2, ndev->dev_addr[3]); in enc28j60_set_hw_macaddr()
493 nolock_regb_write(priv, MAADR1, ndev->dev_addr[4]); in enc28j60_set_hw_macaddr()
494 nolock_regb_write(priv, MAADR0, ndev->dev_addr[5]); in enc28j60_set_hw_macaddr()
501 ret = -EBUSY; in enc28j60_set_hw_macaddr()
503 mutex_unlock(&priv->lock); in enc28j60_set_hw_macaddr()
508 * Store the new hardware address in dev->dev_addr, and update the MAC.
515 return -EBUSY; in enc28j60_set_mac_address()
516 if (!is_valid_ether_addr(address->sa_data)) in enc28j60_set_mac_address()
517 return -EADDRNOTAVAIL; in enc28j60_set_mac_address()
519 eth_hw_addr_set(dev, address->sa_data); in enc28j60_set_mac_address()
528 struct device *dev = &priv->spi->dev; in enc28j60_dump_regs()
530 mutex_lock(&priv->lock); in enc28j60_dump_regs()
558 mutex_unlock(&priv->lock); in enc28j60_dump_regs()
568 if ((next_packet_ptr - 1 < start) || (next_packet_ptr - 1 > end)) in erxrdpt_workaround()
571 erxrdpt = next_packet_ptr - 1; in erxrdpt_workaround()
582 return (ptr + RSV_SIZE) - (RXEND_INIT - RXSTART_INIT + 1); in rx_packet_start()
589 struct device *dev = &priv->spi->dev; in nolock_rxfifo_init()
599 priv->next_pk_ptr = start; in nolock_rxfifo_init()
601 erxrdpt = erxrdpt_workaround(priv->next_pk_ptr, start, end); in nolock_rxfifo_init()
608 struct device *dev = &priv->spi->dev; in nolock_txfifo_init()
623 * the chip to be in that mode whenever it's inactive. (However, we
628 struct device *dev = &priv->spi->dev; in enc28j60_lowpower()
633 mutex_lock(&priv->lock); in enc28j60_lowpower()
645 mutex_unlock(&priv->lock); in enc28j60_lowpower()
650 struct device *dev = &priv->spi->dev; in enc28j60_hw_init()
654 dev_printk(KERN_DEBUG, dev, "%s() - %s\n", __func__, in enc28j60_hw_init()
655 priv->full_duplex ? "FullDuplex" : "HalfDuplex"); in enc28j60_hw_init()
657 mutex_lock(&priv->lock); in enc28j60_hw_init()
658 /* first reset the chip */ in enc28j60_hw_init()
662 priv->bank = 0; in enc28j60_hw_init()
663 priv->hw_enable = false; in enc28j60_hw_init()
664 priv->tx_retry_count = 0; in enc28j60_hw_init()
665 priv->max_pk_counter = 0; in enc28j60_hw_init()
666 priv->rxfilter = RXFILTER_NORMAL; in enc28j60_hw_init()
672 mutex_unlock(&priv->lock); in enc28j60_hw_init()
681 dev_info(dev, "chip RevID: 0x%02x\n", reg); in enc28j60_hw_init()
697 if (priv->full_duplex) { in enc28j60_hw_init()
701 /* set inter-frame gap (non-back-to-back) */ in enc28j60_hw_init()
703 /* set inter-frame gap (back-to-back) */ in enc28j60_hw_init()
710 /* set inter-frame gap (non-back-to-back) */ in enc28j60_hw_init()
712 /* set inter-frame gap (back-to-back) */ in enc28j60_hw_init()
726 if (priv->full_duplex) { in enc28j60_hw_init()
745 struct device *dev = &priv->spi->dev; in enc28j60_hw_enable()
754 mutex_lock(&priv->lock); in enc28j60_hw_enable()
762 priv->hw_enable = true; in enc28j60_hw_enable()
763 mutex_unlock(&priv->lock); in enc28j60_hw_enable()
768 mutex_lock(&priv->lock); in enc28j60_hw_disable()
772 priv->hw_enable = false; in enc28j60_hw_disable()
773 mutex_unlock(&priv->lock); in enc28j60_hw_disable()
782 if (!priv->hw_enable) { in enc28j60_setlink()
787 priv->full_duplex = (duplex == DUPLEX_FULL); in enc28j60_setlink()
791 ret = -EOPNOTSUPP; in enc28j60_setlink()
796 ret = -EBUSY; in enc28j60_setlink()
806 struct device *dev = &priv->spi->dev; in enc28j60_read_tsv()
819 struct device *dev = &priv->spi->dev; in enc28j60_dump_tsv()
822 dev_printk(KERN_DEBUG, dev, "%s - TSV:\n", msg); in enc28j60_dump_tsv()
865 struct device *dev = &priv->spi->dev; in enc28j60_dump_rsv()
867 dev_printk(KERN_DEBUG, dev, "%s - NextPk: 0x%04x - RSV:\n", msg, pk_ptr); in enc28j60_dump_rsv()
892 printk(KERN_DEBUG DRV_NAME ": %s - packet len:%d\n", msg, len); in dump_packet()
905 struct device *dev = &priv->spi->dev; in enc28j60_hw_rx()
913 priv->next_pk_ptr); in enc28j60_hw_rx()
915 if (unlikely(priv->next_pk_ptr > RXEND_INIT)) { in enc28j60_hw_rx()
918 __func__, priv->next_pk_ptr); in enc28j60_hw_rx()
920 mutex_lock(&priv->lock); in enc28j60_hw_rx()
927 mutex_unlock(&priv->lock); in enc28j60_hw_rx()
928 ndev->stats.rx_errors++; in enc28j60_hw_rx()
932 enc28j60_mem_read(priv, priv->next_pk_ptr, sizeof(rsv), rsv); in enc28j60_hw_rx()
952 ndev->stats.rx_errors++; in enc28j60_hw_rx()
954 ndev->stats.rx_crc_errors++; in enc28j60_hw_rx()
956 ndev->stats.rx_frame_errors++; in enc28j60_hw_rx()
958 ndev->stats.rx_over_errors++; in enc28j60_hw_rx()
964 ndev->stats.rx_dropped++; in enc28j60_hw_rx()
969 rx_packet_start(priv->next_pk_ptr), in enc28j60_hw_rx()
972 dump_packet(__func__, skb->len, skb->data); in enc28j60_hw_rx()
973 skb->protocol = eth_type_trans(skb, ndev); in enc28j60_hw_rx()
975 ndev->stats.rx_packets++; in enc28j60_hw_rx()
976 ndev->stats.rx_bytes += len; in enc28j60_hw_rx()
990 mutex_lock(&priv->lock); in enc28j60_hw_rx()
998 "%s() ERXRDPT verify error (0x%04x - 0x%04x)\n", in enc28j60_hw_rx()
1002 priv->next_pk_ptr = next_packet; in enc28j60_hw_rx()
1005 mutex_unlock(&priv->lock); in enc28j60_hw_rx()
1013 struct net_device *ndev = priv->netdev; in enc28j60_get_free_rxfifo()
1017 mutex_lock(&priv->lock); in enc28j60_get_free_rxfifo()
1020 free_space = -1; in enc28j60_get_free_rxfifo()
1028 free_space = (erxnd - erxst) - (erxwr - erxrd); in enc28j60_get_free_rxfifo()
1030 free_space = (erxnd - erxst); in enc28j60_get_free_rxfifo()
1032 free_space = erxrd - erxwr - 1; in enc28j60_get_free_rxfifo()
1034 mutex_unlock(&priv->lock); in enc28j60_get_free_rxfifo()
1047 struct device *dev = &priv->spi->dev; in enc28j60_check_link_status()
1061 netdev_info(ndev, "link up - %s\n", in enc28j60_check_link_status()
1075 ndev->stats.tx_errors++; in enc28j60_tx_clear()
1077 ndev->stats.tx_packets++; in enc28j60_tx_clear()
1079 if (priv->tx_skb) { in enc28j60_tx_clear()
1081 ndev->stats.tx_bytes += priv->tx_skb->len; in enc28j60_tx_clear()
1082 dev_kfree_skb(priv->tx_skb); in enc28j60_tx_clear()
1083 priv->tx_skb = NULL; in enc28j60_tx_clear()
1106 if (pk_counter > priv->max_pk_counter) { in enc28j60_rx_interrupt()
1108 priv->max_pk_counter = pk_counter; in enc28j60_rx_interrupt()
1109 if (netif_msg_rx_status(priv) && priv->max_pk_counter > 1) in enc28j60_rx_interrupt()
1111 priv->max_pk_counter); in enc28j60_rx_interrupt()
1114 while (pk_counter-- > 0) in enc28j60_rx_interrupt()
1123 struct net_device *ndev = priv->netdev; in enc28j60_irq()
1158 priv->tx_retry_count = 0; in enc28j60_irq()
1185 mutex_lock(&priv->lock); in enc28j60_irq()
1189 mutex_unlock(&priv->lock); in enc28j60_irq()
1195 priv->tx_retry_count); in enc28j60_irq()
1196 if (priv->tx_retry_count++ < MAX_TX_RETRYCOUNT) in enc28j60_irq()
1215 ndev->stats.rx_dropped++; in enc28j60_irq()
1224 /* re-enable interrupts */ in enc28j60_irq()
1237 struct net_device *ndev = priv->netdev; in enc28j60_hw_tx()
1239 BUG_ON(!priv->tx_skb); in enc28j60_hw_tx()
1243 priv->tx_skb->len); in enc28j60_hw_tx()
1247 priv->tx_skb->len, priv->tx_skb->data); in enc28j60_hw_tx()
1248 enc28j60_packet_write(priv, priv->tx_skb->len, priv->tx_skb->data); in enc28j60_hw_tx()
1253 struct device *dev = &priv->spi->dev; in enc28j60_hw_tx()
1258 test_len = priv->tx_skb->len; in enc28j60_hw_tx()
1266 if (priv->tx_skb->data[k] != test_buf[k]) { in enc28j60_hw_tx()
1268 "Error, %d location differ: 0x%02x-0x%02x\n", in enc28j60_hw_tx()
1269 k, priv->tx_skb->data[k], test_buf[k]); in enc28j60_hw_tx()
1297 priv->tx_skb = skb; in enc28j60_send_packet()
1298 schedule_work(&priv->tx_work); in enc28j60_send_packet()
1319 ndev->stats.tx_errors++; in enc28j60_tx_timeout()
1321 schedule_work(&priv->restart_work); in enc28j60_tx_timeout()
1330 * there is non-reboot way to recover if something goes wrong.
1336 if (!is_valid_ether_addr(dev->dev_addr)) { in enc28j60_net_open()
1338 netdev_err(dev, "invalid MAC address %pM\n", dev->dev_addr); in enc28j60_net_open()
1339 return -EADDRNOTAVAIL; in enc28j60_net_open()
1347 return -EINVAL; in enc28j60_net_open()
1377 * num_addrs == -1 Promiscuous mode, receive all packets
1384 int oldfilter = priv->rxfilter; in enc28j60_set_multicast_list()
1386 if (dev->flags & IFF_PROMISC) { in enc28j60_set_multicast_list()
1389 priv->rxfilter = RXFILTER_PROMISC; in enc28j60_set_multicast_list()
1390 } else if ((dev->flags & IFF_ALLMULTI) || !netdev_mc_empty(dev)) { in enc28j60_set_multicast_list()
1393 (dev->flags & IFF_ALLMULTI) ? "all-" : ""); in enc28j60_set_multicast_list()
1394 priv->rxfilter = RXFILTER_MULTI; in enc28j60_set_multicast_list()
1398 priv->rxfilter = RXFILTER_NORMAL; in enc28j60_set_multicast_list()
1401 if (oldfilter != priv->rxfilter) in enc28j60_set_multicast_list()
1402 schedule_work(&priv->setrx_work); in enc28j60_set_multicast_list()
1409 struct device *dev = &priv->spi->dev; in enc28j60_setrx_work_handler()
1411 if (priv->rxfilter == RXFILTER_PROMISC) { in enc28j60_setrx_work_handler()
1415 } else if (priv->rxfilter == RXFILTER_MULTI) { in enc28j60_setrx_work_handler()
1434 struct net_device *ndev = priv->netdev; in enc28j60_restart_work_handler()
1454 strscpy(info->driver, DRV_NAME, sizeof(info->driver)); in enc28j60_get_drvinfo()
1455 strscpy(info->version, DRV_VERSION, sizeof(info->version)); in enc28j60_get_drvinfo()
1456 strscpy(info->bus_info, in enc28j60_get_drvinfo()
1457 dev_name(dev->dev.parent), sizeof(info->bus_info)); in enc28j60_get_drvinfo()
1471 cmd->base.speed = SPEED_10; in enc28j60_get_link_ksettings()
1472 cmd->base.duplex = priv->full_duplex ? DUPLEX_FULL : DUPLEX_HALF; in enc28j60_get_link_ksettings()
1473 cmd->base.port = PORT_TP; in enc28j60_get_link_ksettings()
1474 cmd->base.autoneg = AUTONEG_DISABLE; in enc28j60_get_link_ksettings()
1483 return enc28j60_setlink(dev, cmd->base.autoneg, in enc28j60_set_link_ksettings()
1484 cmd->base.speed, cmd->base.duplex); in enc28j60_set_link_ksettings()
1490 return priv->msg_enable; in enc28j60_get_msglevel()
1496 priv->msg_enable = val; in enc28j60_set_msglevel()
1531 dev_info(&spi->dev, "Ethernet driver %s loaded\n", DRV_VERSION); in enc28j60_probe()
1535 ret = -ENOMEM; in enc28j60_probe()
1540 priv->netdev = dev; /* priv to netdev reference */ in enc28j60_probe()
1541 priv->spi = spi; /* priv to spi reference */ in enc28j60_probe()
1542 priv->msg_enable = netif_msg_init(debug.msg_enable, ENC28J60_MSG_DEFAULT); in enc28j60_probe()
1543 mutex_init(&priv->lock); in enc28j60_probe()
1544 INIT_WORK(&priv->tx_work, enc28j60_tx_work_handler); in enc28j60_probe()
1545 INIT_WORK(&priv->setrx_work, enc28j60_setrx_work_handler); in enc28j60_probe()
1546 INIT_WORK(&priv->restart_work, enc28j60_restart_work_handler); in enc28j60_probe()
1548 SET_NETDEV_DEV(dev, &spi->dev); in enc28j60_probe()
1552 dev_info(&spi->dev, "chip not found\n"); in enc28j60_probe()
1553 ret = -EIO; in enc28j60_probe()
1557 if (device_get_ethdev_address(&spi->dev, dev)) in enc28j60_probe()
1564 ret = request_threaded_irq(spi->irq, NULL, enc28j60_irq, IRQF_ONESHOT, in enc28j60_probe()
1568 dev_err(&spi->dev, "request irq %d failed (ret = %d)\n", in enc28j60_probe()
1569 spi->irq, ret); in enc28j60_probe()
1573 dev->if_port = IF_PORT_10BASET; in enc28j60_probe()
1574 dev->irq = spi->irq; in enc28j60_probe()
1575 dev->netdev_ops = &enc28j60_netdev_ops; in enc28j60_probe()
1576 dev->watchdog_timeo = TX_TIMEOUT; in enc28j60_probe()
1577 dev->ethtool_ops = &enc28j60_ethtool_ops; in enc28j60_probe()
1584 dev_err(&spi->dev, "register netdev failed (ret = %d)\n", in enc28j60_probe()
1592 free_irq(spi->irq, priv); in enc28j60_probe()
1603 unregister_netdev(priv->netdev); in enc28j60_remove()
1604 free_irq(spi->irq, priv); in enc28j60_remove()
1605 free_netdev(priv->netdev); in enc28j60_remove()