Lines Matching +full:mac +full:- +full:clk +full:- +full:rx
1 // SPDX-License-Identifier: GPL-2.0-or-later
13 #include <linux/clk.h>
23 #include <linux/soc/nxp/lpc32xx-misc.h>
25 #define MODNAME "lpc-eth"
35 * Ethernet MAC controller Register offsets
317 if (dev && dev->of_node) { in lpc_phy_interface_mode()
318 const char *mode = of_get_property(dev->of_node, in lpc_phy_interface_mode()
319 "phy-mode", NULL); in lpc_phy_interface_mode()
328 if (dev && dev->of_node) in use_iram_for_net()
329 return of_property_read_bool(dev->of_node, "use-iram"); in use_iram_for_net()
378 * Structure of a TX/RX descriptors and RX status
403 struct clk *clk; member
420 * MAC support functions
422 static void __lpc_set_mac(struct netdata_local *pldat, const u8 *mac) in __lpc_set_mac() argument
427 tmp = mac[0] | ((u32)mac[1] << 8); in __lpc_set_mac()
428 writel(tmp, LPC_ENET_SA2(pldat->net_base)); in __lpc_set_mac()
429 tmp = mac[2] | ((u32)mac[3] << 8); in __lpc_set_mac()
430 writel(tmp, LPC_ENET_SA1(pldat->net_base)); in __lpc_set_mac()
431 tmp = mac[4] | ((u32)mac[5] << 8); in __lpc_set_mac()
432 writel(tmp, LPC_ENET_SA0(pldat->net_base)); in __lpc_set_mac()
434 netdev_dbg(pldat->ndev, "Ethernet MAC address %pM\n", mac); in __lpc_set_mac()
437 static void __lpc_get_mac(struct netdata_local *pldat, u8 *mac) in __lpc_get_mac() argument
442 tmp = readl(LPC_ENET_SA2(pldat->net_base)); in __lpc_get_mac()
443 mac[0] = tmp & 0xFF; in __lpc_get_mac()
444 mac[1] = tmp >> 8; in __lpc_get_mac()
445 tmp = readl(LPC_ENET_SA1(pldat->net_base)); in __lpc_get_mac()
446 mac[2] = tmp & 0xFF; in __lpc_get_mac()
447 mac[3] = tmp >> 8; in __lpc_get_mac()
448 tmp = readl(LPC_ENET_SA0(pldat->net_base)); in __lpc_get_mac()
449 mac[4] = tmp & 0xFF; in __lpc_get_mac()
450 mac[5] = tmp >> 8; in __lpc_get_mac()
457 if (pldat->duplex == DUPLEX_FULL) { in __lpc_params_setup()
458 tmp = readl(LPC_ENET_MAC2(pldat->net_base)); in __lpc_params_setup()
460 writel(tmp, LPC_ENET_MAC2(pldat->net_base)); in __lpc_params_setup()
461 tmp = readl(LPC_ENET_COMMAND(pldat->net_base)); in __lpc_params_setup()
463 writel(tmp, LPC_ENET_COMMAND(pldat->net_base)); in __lpc_params_setup()
464 writel(LPC_IPGT_LOAD(0x15), LPC_ENET_IPGT(pldat->net_base)); in __lpc_params_setup()
466 tmp = readl(LPC_ENET_MAC2(pldat->net_base)); in __lpc_params_setup()
468 writel(tmp, LPC_ENET_MAC2(pldat->net_base)); in __lpc_params_setup()
469 tmp = readl(LPC_ENET_COMMAND(pldat->net_base)); in __lpc_params_setup()
471 writel(tmp, LPC_ENET_COMMAND(pldat->net_base)); in __lpc_params_setup()
472 writel(LPC_IPGT_LOAD(0x12), LPC_ENET_IPGT(pldat->net_base)); in __lpc_params_setup()
475 if (pldat->speed == SPEED_100) in __lpc_params_setup()
476 writel(LPC_SUPP_SPEED, LPC_ENET_SUPP(pldat->net_base)); in __lpc_params_setup()
478 writel(0, LPC_ENET_SUPP(pldat->net_base)); in __lpc_params_setup()
483 /* Reset all MAC logic */ in __lpc_eth_reset()
486 LPC_MAC1_SOFT_RESET), LPC_ENET_MAC1(pldat->net_base)); in __lpc_eth_reset()
488 LPC_COMMAND_RXRESET), LPC_ENET_COMMAND(pldat->net_base)); in __lpc_eth_reset()
494 writel(LPC_MCFG_RESET_MII_MGMT, LPC_ENET_MCFG(pldat->net_base)); in __lpc_mii_mngt_reset()
498 LPC_ENET_MCFG(pldat->net_base)); in __lpc_mii_mngt_reset()
507 phaddr = addr - pldat->dma_buff_base_v; in __va_to_pa()
508 phaddr += pldat->dma_buff_base_p; in __va_to_pa()
524 /* Setup TX/RX descriptors */
533 tbuff = PTR_ALIGN(pldat->dma_buff_base_v, 16); in __lpc_txrx_desc_setup()
536 pldat->tx_desc_v = tbuff; in __lpc_txrx_desc_setup()
539 pldat->tx_stat_v = tbuff; in __lpc_txrx_desc_setup()
543 pldat->tx_buff_v = tbuff; in __lpc_txrx_desc_setup()
546 /* Setup RX descriptors, status, and buffers */ in __lpc_txrx_desc_setup()
547 pldat->rx_desc_v = tbuff; in __lpc_txrx_desc_setup()
551 pldat->rx_stat_v = tbuff; in __lpc_txrx_desc_setup()
555 pldat->rx_buff_v = tbuff; in __lpc_txrx_desc_setup()
560 ptxstat = &pldat->tx_stat_v[i]; in __lpc_txrx_desc_setup()
561 ptxrxdesc = &pldat->tx_desc_v[i]; in __lpc_txrx_desc_setup()
563 ptxrxdesc->packet = __va_to_pa( in __lpc_txrx_desc_setup()
564 pldat->tx_buff_v + i * ENET_MAXF_SIZE, pldat); in __lpc_txrx_desc_setup()
565 ptxrxdesc->control = 0; in __lpc_txrx_desc_setup()
569 /* Map the RX descriptors to the RX buffers in hardware */ in __lpc_txrx_desc_setup()
571 prxstat = &pldat->rx_stat_v[i]; in __lpc_txrx_desc_setup()
572 ptxrxdesc = &pldat->rx_desc_v[i]; in __lpc_txrx_desc_setup()
574 ptxrxdesc->packet = __va_to_pa( in __lpc_txrx_desc_setup()
575 pldat->rx_buff_v + i * ENET_MAXF_SIZE, pldat); in __lpc_txrx_desc_setup()
576 ptxrxdesc->control = RXDESC_CONTROL_INT | (ENET_MAXF_SIZE - 1); in __lpc_txrx_desc_setup()
577 prxstat->statusinfo = 0; in __lpc_txrx_desc_setup()
578 prxstat->statushashcrc = 0; in __lpc_txrx_desc_setup()
584 writel((ENET_TX_DESC - 1), in __lpc_txrx_desc_setup()
585 LPC_ENET_TXDESCRIPTORNUMBER(pldat->net_base)); in __lpc_txrx_desc_setup()
586 writel(__va_to_pa(pldat->tx_desc_v, pldat), in __lpc_txrx_desc_setup()
587 LPC_ENET_TXDESCRIPTOR(pldat->net_base)); in __lpc_txrx_desc_setup()
588 writel(__va_to_pa(pldat->tx_stat_v, pldat), in __lpc_txrx_desc_setup()
589 LPC_ENET_TXSTATUS(pldat->net_base)); in __lpc_txrx_desc_setup()
590 writel((ENET_RX_DESC - 1), in __lpc_txrx_desc_setup()
591 LPC_ENET_RXDESCRIPTORNUMBER(pldat->net_base)); in __lpc_txrx_desc_setup()
592 writel(__va_to_pa(pldat->rx_desc_v, pldat), in __lpc_txrx_desc_setup()
593 LPC_ENET_RXDESCRIPTOR(pldat->net_base)); in __lpc_txrx_desc_setup()
594 writel(__va_to_pa(pldat->rx_stat_v, pldat), in __lpc_txrx_desc_setup()
595 LPC_ENET_RXSTATUS(pldat->net_base)); in __lpc_txrx_desc_setup()
603 tmp = readl(LPC_ENET_COMMAND(pldat->net_base)); in __lpc_eth_init()
605 writel(tmp, LPC_ENET_COMMAND(pldat->net_base)); in __lpc_eth_init()
606 tmp = readl(LPC_ENET_MAC1(pldat->net_base)); in __lpc_eth_init()
608 writel(tmp, LPC_ENET_MAC1(pldat->net_base)); in __lpc_eth_init()
610 /* Initial MAC setup */ in __lpc_eth_init()
611 writel(LPC_MAC1_PASS_ALL_RX_FRAMES, LPC_ENET_MAC1(pldat->net_base)); in __lpc_eth_init()
613 LPC_ENET_MAC2(pldat->net_base)); in __lpc_eth_init()
614 writel(ENET_MAXF_SIZE, LPC_ENET_MAXF(pldat->net_base)); in __lpc_eth_init()
619 LPC_ENET_CLRT(pldat->net_base)); in __lpc_eth_init()
620 writel(LPC_IPGR_LOAD_PART2(0x12), LPC_ENET_IPGR(pldat->net_base)); in __lpc_eth_init()
622 if (lpc_phy_interface_mode(&pldat->pdev->dev) == PHY_INTERFACE_MODE_MII) in __lpc_eth_init()
624 LPC_ENET_COMMAND(pldat->net_base)); in __lpc_eth_init()
627 LPC_ENET_COMMAND(pldat->net_base)); in __lpc_eth_init()
628 writel(LPC_SUPP_RESET_RMII, LPC_ENET_SUPP(pldat->net_base)); in __lpc_eth_init()
633 /* Setup TX and RX descriptors */ in __lpc_eth_init()
638 LPC_ENET_RXFILTER_CTRL(pldat->net_base)); in __lpc_eth_init()
641 pldat->num_used_tx_buffs = 0; in __lpc_eth_init()
642 pldat->last_tx_idx = in __lpc_eth_init()
643 readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base)); in __lpc_eth_init()
646 writel(0xFFFF, LPC_ENET_INTCLEAR(pldat->net_base)); in __lpc_eth_init()
648 lpc_eth_enable_int(pldat->net_base); in __lpc_eth_init()
651 tmp = readl(LPC_ENET_COMMAND(pldat->net_base)); in __lpc_eth_init()
653 writel(tmp, LPC_ENET_COMMAND(pldat->net_base)); in __lpc_eth_init()
654 tmp = readl(LPC_ENET_MAC1(pldat->net_base)); in __lpc_eth_init()
656 writel(tmp, LPC_ENET_MAC1(pldat->net_base)); in __lpc_eth_init()
663 writel(0, LPC_ENET_MAC1(pldat->net_base)); in __lpc_eth_shutdown()
664 writel(0, LPC_ENET_MAC2(pldat->net_base)); in __lpc_eth_shutdown()
668 * MAC<--->PHY support functions
672 struct netdata_local *pldat = bus->priv; in lpc_mdio_read()
676 writel(((phy_id << 8) | phyreg), LPC_ENET_MADR(pldat->net_base)); in lpc_mdio_read()
677 writel(LPC_MCMD_READ, LPC_ENET_MCMD(pldat->net_base)); in lpc_mdio_read()
680 while (readl(LPC_ENET_MIND(pldat->net_base)) & LPC_MIND_BUSY) { in lpc_mdio_read()
682 return -EIO; in lpc_mdio_read()
686 lps = readl(LPC_ENET_MRDD(pldat->net_base)); in lpc_mdio_read()
687 writel(0, LPC_ENET_MCMD(pldat->net_base)); in lpc_mdio_read()
695 struct netdata_local *pldat = bus->priv; in lpc_mdio_write()
698 writel(((phy_id << 8) | phyreg), LPC_ENET_MADR(pldat->net_base)); in lpc_mdio_write()
699 writel(phydata, LPC_ENET_MWTD(pldat->net_base)); in lpc_mdio_write()
702 while (readl(LPC_ENET_MIND(pldat->net_base)) & LPC_MIND_BUSY) { in lpc_mdio_write()
704 return -EIO; in lpc_mdio_write()
713 return __lpc_mii_mngt_reset((struct netdata_local *)bus->priv); in lpc_mdio_reset()
719 struct phy_device *phydev = ndev->phydev; in lpc_handle_link_change()
724 spin_lock_irqsave(&pldat->lock, flags); in lpc_handle_link_change()
726 if (phydev->link) { in lpc_handle_link_change()
727 if ((pldat->speed != phydev->speed) || in lpc_handle_link_change()
728 (pldat->duplex != phydev->duplex)) { in lpc_handle_link_change()
729 pldat->speed = phydev->speed; in lpc_handle_link_change()
730 pldat->duplex = phydev->duplex; in lpc_handle_link_change()
735 if (phydev->link != pldat->link) { in lpc_handle_link_change()
736 if (!phydev->link) { in lpc_handle_link_change()
737 pldat->speed = 0; in lpc_handle_link_change()
738 pldat->duplex = -1; in lpc_handle_link_change()
740 pldat->link = phydev->link; in lpc_handle_link_change()
745 spin_unlock_irqrestore(&pldat->lock, flags); in lpc_handle_link_change()
757 if (lpc_phy_interface_mode(&pldat->pdev->dev) == PHY_INTERFACE_MODE_MII) in lpc_mii_probe()
762 if (pldat->phy_node) in lpc_mii_probe()
763 phydev = of_phy_find_device(pldat->phy_node); in lpc_mii_probe()
765 phydev = phy_find_first(pldat->mii_bus); in lpc_mii_probe()
768 return -ENODEV; in lpc_mii_probe()
773 lpc_phy_interface_mode(&pldat->pdev->dev)); in lpc_mii_probe()
781 pldat->link = 0; in lpc_mii_probe()
782 pldat->speed = 0; in lpc_mii_probe()
783 pldat->duplex = -1; in lpc_mii_probe()
793 int err = -ENXIO; in lpc_mii_init()
795 pldat->mii_bus = mdiobus_alloc(); in lpc_mii_init()
796 if (!pldat->mii_bus) { in lpc_mii_init()
797 err = -ENOMEM; in lpc_mii_init()
802 if (lpc_phy_interface_mode(&pldat->pdev->dev) == PHY_INTERFACE_MODE_MII) in lpc_mii_init()
804 LPC_ENET_COMMAND(pldat->net_base)); in lpc_mii_init()
807 LPC_ENET_COMMAND(pldat->net_base)); in lpc_mii_init()
808 writel(LPC_SUPP_RESET_RMII, LPC_ENET_SUPP(pldat->net_base)); in lpc_mii_init()
811 pldat->mii_bus->name = "lpc_mii_bus"; in lpc_mii_init()
812 pldat->mii_bus->read = &lpc_mdio_read; in lpc_mii_init()
813 pldat->mii_bus->write = &lpc_mdio_write; in lpc_mii_init()
814 pldat->mii_bus->reset = &lpc_mdio_reset; in lpc_mii_init()
815 snprintf(pldat->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", in lpc_mii_init()
816 pldat->pdev->name, pldat->pdev->id); in lpc_mii_init()
817 pldat->mii_bus->priv = pldat; in lpc_mii_init()
818 pldat->mii_bus->parent = &pldat->pdev->dev; in lpc_mii_init()
820 node = of_get_child_by_name(pldat->pdev->dev.of_node, "mdio"); in lpc_mii_init()
821 err = of_mdiobus_register(pldat->mii_bus, node); in lpc_mii_init()
826 err = lpc_mii_probe(pldat->ndev); in lpc_mii_init()
833 mdiobus_unregister(pldat->mii_bus); in lpc_mii_init()
834 mdiobus_free(pldat->mii_bus); in lpc_mii_init()
844 txcidx = readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base)); in __lpc_handle_xmit()
845 while (pldat->last_tx_idx != txcidx) { in __lpc_handle_xmit()
846 unsigned int skblen = pldat->skblen[pldat->last_tx_idx]; in __lpc_handle_xmit()
849 ptxstat = &pldat->tx_stat_v[pldat->last_tx_idx]; in __lpc_handle_xmit()
853 pldat->num_used_tx_buffs--; in __lpc_handle_xmit()
854 pldat->last_tx_idx++; in __lpc_handle_xmit()
855 if (pldat->last_tx_idx >= ENET_TX_DESC) in __lpc_handle_xmit()
856 pldat->last_tx_idx = 0; in __lpc_handle_xmit()
859 ndev->stats.collisions += TXSTATUS_COLLISIONS_GET(txstat); in __lpc_handle_xmit()
865 ndev->stats.tx_fifo_errors++; in __lpc_handle_xmit()
869 ndev->stats.tx_aborted_errors++; in __lpc_handle_xmit()
873 ndev->stats.tx_aborted_errors++; in __lpc_handle_xmit()
877 ndev->stats.tx_aborted_errors++; in __lpc_handle_xmit()
879 ndev->stats.tx_errors++; in __lpc_handle_xmit()
882 ndev->stats.tx_packets++; in __lpc_handle_xmit()
883 ndev->stats.tx_bytes += skblen; in __lpc_handle_xmit()
886 txcidx = readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base)); in __lpc_handle_xmit()
889 if (pldat->num_used_tx_buffs <= ENET_TX_DESC/2) { in __lpc_handle_xmit()
903 /* Get the current RX buffer indexes */ in __lpc_handle_recv()
904 rxconsidx = readl(LPC_ENET_RXCONSUMEINDEX(pldat->net_base)); in __lpc_handle_recv()
906 readl(LPC_ENET_RXPRODUCEINDEX(pldat->net_base))) { in __lpc_handle_recv()
908 prxstat = &pldat->rx_stat_v[rxconsidx]; in __lpc_handle_recv()
909 len = (prxstat->statusinfo & RXSTATUS_SIZE) + 1; in __lpc_handle_recv()
912 ethst = prxstat->statusinfo; in __lpc_handle_recv()
918 int si = prxstat->statusinfo; in __lpc_handle_recv()
922 ndev->stats.rx_fifo_errors++; in __lpc_handle_recv()
925 ndev->stats.rx_crc_errors++; in __lpc_handle_recv()
928 ndev->stats.rx_length_errors++; in __lpc_handle_recv()
931 ndev->stats.rx_length_errors++; in __lpc_handle_recv()
933 ndev->stats.rx_errors++; in __lpc_handle_recv()
938 ndev->stats.rx_dropped++; in __lpc_handle_recv()
942 pldat->rx_buff_v + rxconsidx * ENET_MAXF_SIZE, in __lpc_handle_recv()
946 skb->protocol = eth_type_trans(skb, ndev); in __lpc_handle_recv()
948 ndev->stats.rx_packets++; in __lpc_handle_recv()
949 ndev->stats.rx_bytes += len; in __lpc_handle_recv()
958 LPC_ENET_RXCONSUMEINDEX(pldat->net_base)); in __lpc_handle_recv()
969 struct net_device *ndev = pldat->ndev; in lpc_eth_poll()
980 lpc_eth_enable_int(pldat->net_base); in lpc_eth_poll()
992 spin_lock(&pldat->lock); in __lpc_eth_interrupt()
994 tmp = readl(LPC_ENET_INTSTATUS(pldat->net_base)); in __lpc_eth_interrupt()
996 writel(tmp, LPC_ENET_INTCLEAR(pldat->net_base)); in __lpc_eth_interrupt()
998 lpc_eth_disable_int(pldat->net_base); in __lpc_eth_interrupt()
999 if (likely(napi_schedule_prep(&pldat->napi))) in __lpc_eth_interrupt()
1000 __napi_schedule(&pldat->napi); in __lpc_eth_interrupt()
1002 spin_unlock(&pldat->lock); in __lpc_eth_interrupt()
1013 dev_dbg(&pldat->pdev->dev, "shutting down %s\n", ndev->name); in lpc_eth_close()
1015 napi_disable(&pldat->napi); in lpc_eth_close()
1018 spin_lock_irqsave(&pldat->lock, flags); in lpc_eth_close()
1021 writel(0, LPC_ENET_MAC1(pldat->net_base)); in lpc_eth_close()
1022 writel(0, LPC_ENET_MAC2(pldat->net_base)); in lpc_eth_close()
1023 spin_unlock_irqrestore(&pldat->lock, flags); in lpc_eth_close()
1025 if (ndev->phydev) in lpc_eth_close()
1026 phy_stop(ndev->phydev); in lpc_eth_close()
1027 clk_disable_unprepare(pldat->clk); in lpc_eth_close()
1040 len = skb->len; in lpc_eth_hard_start_xmit()
1042 spin_lock_irq(&pldat->lock); in lpc_eth_hard_start_xmit()
1044 if (pldat->num_used_tx_buffs >= (ENET_TX_DESC - 1)) { in lpc_eth_hard_start_xmit()
1049 spin_unlock_irq(&pldat->lock); in lpc_eth_hard_start_xmit()
1055 txidx = readl(LPC_ENET_TXPRODUCEINDEX(pldat->net_base)); in lpc_eth_hard_start_xmit()
1058 ptxstat = &pldat->tx_stat_v[txidx]; in lpc_eth_hard_start_xmit()
1060 ptxrxdesc = &pldat->tx_desc_v[txidx]; in lpc_eth_hard_start_xmit()
1061 ptxrxdesc->control = in lpc_eth_hard_start_xmit()
1062 (len - 1) | TXDESC_CONTROL_LAST | TXDESC_CONTROL_INT; in lpc_eth_hard_start_xmit()
1065 memcpy(pldat->tx_buff_v + txidx * ENET_MAXF_SIZE, skb->data, len); in lpc_eth_hard_start_xmit()
1068 pldat->skblen[txidx] = len; in lpc_eth_hard_start_xmit()
1069 pldat->num_used_tx_buffs++; in lpc_eth_hard_start_xmit()
1075 writel(txidx, LPC_ENET_TXPRODUCEINDEX(pldat->net_base)); in lpc_eth_hard_start_xmit()
1078 if (pldat->num_used_tx_buffs >= (ENET_TX_DESC - 1)) in lpc_eth_hard_start_xmit()
1081 spin_unlock_irq(&pldat->lock); in lpc_eth_hard_start_xmit()
1093 if (!is_valid_ether_addr(addr->sa_data)) in lpc_set_mac_address()
1094 return -EADDRNOTAVAIL; in lpc_set_mac_address()
1095 eth_hw_addr_set(ndev, addr->sa_data); in lpc_set_mac_address()
1097 spin_lock_irqsave(&pldat->lock, flags); in lpc_set_mac_address()
1100 __lpc_set_mac(pldat, ndev->dev_addr); in lpc_set_mac_address()
1102 spin_unlock_irqrestore(&pldat->lock, flags); in lpc_set_mac_address()
1110 struct netdev_hw_addr_list *mcptr = &ndev->mc; in lpc_eth_set_multicast_list()
1115 spin_lock_irqsave(&pldat->lock, flags); in lpc_eth_set_multicast_list()
1118 __lpc_set_mac(pldat, ndev->dev_addr); in lpc_eth_set_multicast_list()
1122 if (ndev->flags & IFF_PROMISC) in lpc_eth_set_multicast_list()
1125 if (ndev->flags & IFF_ALLMULTI) in lpc_eth_set_multicast_list()
1131 writel(tmp32, LPC_ENET_RXFILTER_CTRL(pldat->net_base)); in lpc_eth_set_multicast_list()
1140 hash_val = (ether_crc(6, ha->addr) >> 23) & 0x3F; in lpc_eth_set_multicast_list()
1143 hashhi |= 1 << (hash_val - 32); in lpc_eth_set_multicast_list()
1148 writel(hashlo, LPC_ENET_HASHFILTERL(pldat->net_base)); in lpc_eth_set_multicast_list()
1149 writel(hashhi, LPC_ENET_HASHFILTERH(pldat->net_base)); in lpc_eth_set_multicast_list()
1151 spin_unlock_irqrestore(&pldat->lock, flags); in lpc_eth_set_multicast_list()
1160 dev_dbg(&pldat->pdev->dev, "enabling %s\n", ndev->name); in lpc_eth_open()
1162 ret = clk_prepare_enable(pldat->clk); in lpc_eth_open()
1167 phy_resume(ndev->phydev); in lpc_eth_open()
1174 phy_start(ndev->phydev); in lpc_eth_open()
1176 napi_enable(&pldat->napi); in lpc_eth_open()
1187 strscpy(info->driver, MODNAME, sizeof(info->driver)); in lpc_eth_ethtool_getdrvinfo()
1188 strscpy(info->version, DRV_VERSION, sizeof(info->version)); in lpc_eth_ethtool_getdrvinfo()
1189 strscpy(info->bus_info, dev_name(ndev->dev.parent), in lpc_eth_ethtool_getdrvinfo()
1190 sizeof(info->bus_info)); in lpc_eth_ethtool_getdrvinfo()
1197 return pldat->msg_enable; in lpc_eth_ethtool_getmsglevel()
1204 pldat->msg_enable = level; in lpc_eth_ethtool_setmsglevel()
1228 struct device *dev = &pdev->dev; in lpc_eth_drv_probe()
1229 struct device_node *np = dev->of_node; in lpc_eth_drv_probe()
1245 ret = -ENXIO; in lpc_eth_drv_probe()
1253 ret = -ENOMEM; in lpc_eth_drv_probe()
1260 pldat->pdev = pdev; in lpc_eth_drv_probe()
1261 pldat->ndev = ndev; in lpc_eth_drv_probe()
1263 spin_lock_init(&pldat->lock); in lpc_eth_drv_probe()
1266 ndev->irq = irq; in lpc_eth_drv_probe()
1269 pldat->clk = clk_get(dev, NULL); in lpc_eth_drv_probe()
1270 if (IS_ERR(pldat->clk)) { in lpc_eth_drv_probe()
1272 ret = PTR_ERR(pldat->clk); in lpc_eth_drv_probe()
1277 ret = clk_prepare_enable(pldat->clk); in lpc_eth_drv_probe()
1282 pldat->net_base = ioremap(res->start, resource_size(res)); in lpc_eth_drv_probe()
1283 if (!pldat->net_base) { in lpc_eth_drv_probe()
1285 ret = -ENOMEM; in lpc_eth_drv_probe()
1288 ret = request_irq(ndev->irq, __lpc_eth_interrupt, 0, in lpc_eth_drv_probe()
1289 ndev->name, ndev); in lpc_eth_drv_probe()
1296 ndev->netdev_ops = &lpc_netdev_ops; in lpc_eth_drv_probe()
1297 ndev->ethtool_ops = &lpc_eth_ethtool_ops; in lpc_eth_drv_probe()
1298 ndev->watchdog_timeo = msecs_to_jiffies(2500); in lpc_eth_drv_probe()
1301 pldat->dma_buff_size = (ENET_TX_DESC + ENET_RX_DESC) * (ENET_MAXF_SIZE + in lpc_eth_drv_probe()
1305 if (pldat->dma_buff_size > in lpc_eth_drv_probe()
1306 lpc32xx_return_iram(&pldat->dma_buff_base_v, &dma_handle)) { in lpc_eth_drv_probe()
1307 pldat->dma_buff_base_v = NULL; in lpc_eth_drv_probe()
1308 pldat->dma_buff_size = 0; in lpc_eth_drv_probe()
1314 if (pldat->dma_buff_base_v == NULL) { in lpc_eth_drv_probe()
1319 pldat->dma_buff_size = PAGE_ALIGN(pldat->dma_buff_size); in lpc_eth_drv_probe()
1324 pldat->dma_buff_base_v = in lpc_eth_drv_probe()
1326 pldat->dma_buff_size, &dma_handle, in lpc_eth_drv_probe()
1328 if (pldat->dma_buff_base_v == NULL) { in lpc_eth_drv_probe()
1329 ret = -ENOMEM; in lpc_eth_drv_probe()
1333 pldat->dma_buff_base_p = dma_handle; in lpc_eth_drv_probe()
1339 pldat->net_base); in lpc_eth_drv_probe()
1340 netdev_dbg(ndev, "IRQ number :%d\n", ndev->irq); in lpc_eth_drv_probe()
1341 netdev_dbg(ndev, "DMA buffer size :%zd\n", pldat->dma_buff_size); in lpc_eth_drv_probe()
1343 &pldat->dma_buff_base_p); in lpc_eth_drv_probe()
1345 pldat->dma_buff_base_v); in lpc_eth_drv_probe()
1347 pldat->phy_node = of_parse_phandle(np, "phy-handle", 0); in lpc_eth_drv_probe()
1349 /* Get MAC address from current HW setting (POR state is all zeros) */ in lpc_eth_drv_probe()
1353 if (!is_valid_ether_addr(ndev->dev_addr)) { in lpc_eth_drv_probe()
1356 if (!is_valid_ether_addr(ndev->dev_addr)) in lpc_eth_drv_probe()
1363 pldat->msg_enable = NETIF_MSG_LINK; in lpc_eth_drv_probe()
1371 pldat->link = 0; in lpc_eth_drv_probe()
1372 pldat->speed = 100; in lpc_eth_drv_probe()
1373 pldat->duplex = DUPLEX_FULL; in lpc_eth_drv_probe()
1376 netif_napi_add_weight(ndev, &pldat->napi, lpc_eth_poll, NAPI_WEIGHT); in lpc_eth_drv_probe()
1389 netdev_info(ndev, "LPC mac at 0x%08lx irq %d\n", in lpc_eth_drv_probe()
1390 (unsigned long)res->start, ndev->irq); in lpc_eth_drv_probe()
1401 pldat->dma_buff_size > lpc32xx_return_iram(NULL, NULL)) in lpc_eth_drv_probe()
1402 dma_free_coherent(dev, pldat->dma_buff_size, in lpc_eth_drv_probe()
1403 pldat->dma_buff_base_v, in lpc_eth_drv_probe()
1404 pldat->dma_buff_base_p); in lpc_eth_drv_probe()
1406 free_irq(ndev->irq, ndev); in lpc_eth_drv_probe()
1408 iounmap(pldat->net_base); in lpc_eth_drv_probe()
1410 clk_disable_unprepare(pldat->clk); in lpc_eth_drv_probe()
1412 clk_put(pldat->clk); in lpc_eth_drv_probe()
1427 if (!use_iram_for_net(&pldat->pdev->dev) || in lpc_eth_drv_remove()
1428 pldat->dma_buff_size > lpc32xx_return_iram(NULL, NULL)) in lpc_eth_drv_remove()
1429 dma_free_coherent(&pldat->pdev->dev, pldat->dma_buff_size, in lpc_eth_drv_remove()
1430 pldat->dma_buff_base_v, in lpc_eth_drv_remove()
1431 pldat->dma_buff_base_p); in lpc_eth_drv_remove()
1432 free_irq(ndev->irq, ndev); in lpc_eth_drv_remove()
1433 iounmap(pldat->net_base); in lpc_eth_drv_remove()
1434 mdiobus_unregister(pldat->mii_bus); in lpc_eth_drv_remove()
1435 mdiobus_free(pldat->mii_bus); in lpc_eth_drv_remove()
1436 clk_disable_unprepare(pldat->clk); in lpc_eth_drv_remove()
1437 clk_put(pldat->clk); in lpc_eth_drv_remove()
1448 if (device_may_wakeup(&pdev->dev)) in lpc_eth_drv_suspend()
1449 enable_irq_wake(ndev->irq); in lpc_eth_drv_suspend()
1455 clk_disable_unprepare(pldat->clk); in lpc_eth_drv_suspend()
1474 if (device_may_wakeup(&pdev->dev)) in lpc_eth_drv_resume()
1475 disable_irq_wake(ndev->irq); in lpc_eth_drv_resume()
1482 ret = clk_enable(pldat->clk); in lpc_eth_drv_resume()
1499 { .compatible = "nxp,lpc-eth" },