Lines Matching +full:xps +full:- +full:ethernetlite +full:- +full:3
1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * Copyright (c) 2007 - 2013 Xilinx, Inc.
104 * struct net_local - Our private per device data
144 * xemaclite_enable_interrupts - Enable the interrupts for the EmacLite device
155 reg_data = xemaclite_readl(drvdata->base_addr + XEL_TSR_OFFSET); in xemaclite_enable_interrupts()
157 drvdata->base_addr + XEL_TSR_OFFSET); in xemaclite_enable_interrupts()
160 xemaclite_writel(XEL_RSR_RECV_IE_MASK, drvdata->base_addr + XEL_RSR_OFFSET); in xemaclite_enable_interrupts()
163 xemaclite_writel(XEL_GIER_GIE_MASK, drvdata->base_addr + XEL_GIER_OFFSET); in xemaclite_enable_interrupts()
167 * xemaclite_disable_interrupts - Disable the interrupts for the EmacLite device
178 xemaclite_writel(XEL_GIER_GIE_MASK, drvdata->base_addr + XEL_GIER_OFFSET); in xemaclite_disable_interrupts()
181 reg_data = xemaclite_readl(drvdata->base_addr + XEL_TSR_OFFSET); in xemaclite_disable_interrupts()
183 drvdata->base_addr + XEL_TSR_OFFSET); in xemaclite_disable_interrupts()
186 reg_data = xemaclite_readl(drvdata->base_addr + XEL_RSR_OFFSET); in xemaclite_disable_interrupts()
188 drvdata->base_addr + XEL_RSR_OFFSET); in xemaclite_disable_interrupts()
192 * xemaclite_aligned_write - Write from 16-bit aligned to 32-bit aligned address
193 * @src_ptr: Void pointer to the 16-bit aligned source address
194 * @dest_ptr: Pointer to the 32-bit aligned destination address
197 * This function writes data from a 16-bit aligned buffer to a 32-bit aligned
212 for (; length > 3; length -= 4) { in xemaclite_aligned_write()
236 for (; length > 0; length--) in xemaclite_aligned_write()
250 * xemaclite_aligned_read - Read from 32-bit aligned to 16-bit aligned buffer
251 * @src_ptr: Pointer to the 32-bit aligned source address
252 * @dest_ptr: Pointer to the 16-bit aligned destination address
255 * This function reads data from a 32-bit aligned address in the EmacLite device
256 * to a 16-bit aligned buffer.
268 for (; length > 3; length -= 4) { in xemaclite_aligned_read()
287 for (; length > 0; length--) in xemaclite_aligned_read()
293 * xemaclite_send_data - Send an Ethernet frame
302 * Return: 0 upon success or -1 if the buffer(s) are full.
314 addr = drvdata->base_addr + drvdata->next_tx_buf_to_use; in xemaclite_send_data()
325 if (drvdata->tx_ping_pong != 0) in xemaclite_send_data()
326 drvdata->next_tx_buf_to_use ^= XEL_BUFFER_OFFSET; in xemaclite_send_data()
327 } else if (drvdata->tx_ping_pong != 0) { in xemaclite_send_data()
338 return -1; /* Buffers were full, return failure */ in xemaclite_send_data()
340 return -1; /* Buffer was full, return failure */ in xemaclite_send_data()
362 * xemaclite_recv_data - Receive a frame
379 addr = (drvdata->base_addr + drvdata->next_rx_buf_to_use); in xemaclite_recv_data()
385 if (drvdata->rx_ping_pong != 0) in xemaclite_recv_data()
386 drvdata->next_rx_buf_to_use ^= XEL_BUFFER_OFFSET; in xemaclite_recv_data()
393 if (drvdata->rx_ping_pong != 0) in xemaclite_recv_data()
455 * xemaclite_update_address - Update the MAC address in the device
457 * @address_ptr:Pointer to the MAC address (MAC address is a 48-bit value)
472 addr = drvdata->base_addr + drvdata->next_tx_buf_to_use; in xemaclite_update_address()
489 * xemaclite_set_mac_address - Set the MAC address for this device
505 return -EBUSY; in xemaclite_set_mac_address()
507 eth_hw_addr_set(dev, addr->sa_data); in xemaclite_set_mac_address()
508 xemaclite_update_address(lp, dev->dev_addr); in xemaclite_set_mac_address()
513 * xemaclite_tx_timeout - Callback for Tx Timeout
524 dev_err(&lp->ndev->dev, "Exceeded transmit timeout of %lu ms\n", in xemaclite_tx_timeout()
527 dev->stats.tx_errors++; in xemaclite_tx_timeout()
530 spin_lock_irqsave(&lp->reset_lock, flags); in xemaclite_tx_timeout()
538 if (lp->deferred_skb) { in xemaclite_tx_timeout()
539 dev_kfree_skb(lp->deferred_skb); in xemaclite_tx_timeout()
540 lp->deferred_skb = NULL; in xemaclite_tx_timeout()
541 dev->stats.tx_errors++; in xemaclite_tx_timeout()
549 spin_unlock_irqrestore(&lp->reset_lock, flags); in xemaclite_tx_timeout()
557 * xemaclite_tx_handler - Interrupt handler for frames sent
567 dev->stats.tx_packets++; in xemaclite_tx_handler()
569 if (!lp->deferred_skb) in xemaclite_tx_handler()
572 if (xemaclite_send_data(lp, (u8 *)lp->deferred_skb->data, in xemaclite_tx_handler()
573 lp->deferred_skb->len)) in xemaclite_tx_handler()
576 dev->stats.tx_bytes += lp->deferred_skb->len; in xemaclite_tx_handler()
577 dev_consume_skb_irq(lp->deferred_skb); in xemaclite_tx_handler()
578 lp->deferred_skb = NULL; in xemaclite_tx_handler()
584 * xemaclite_rx_handler- Interrupt handler for frames received
600 dev->stats.rx_dropped++; in xemaclite_rx_handler()
601 dev_err(&lp->ndev->dev, "Could not allocate receive buffer\n"); in xemaclite_rx_handler()
607 len = xemaclite_recv_data(lp, (u8 *)skb->data, len); in xemaclite_rx_handler()
610 dev->stats.rx_errors++; in xemaclite_rx_handler()
617 skb->protocol = eth_type_trans(skb, dev); in xemaclite_rx_handler()
620 dev->stats.rx_packets++; in xemaclite_rx_handler()
621 dev->stats.rx_bytes += len; in xemaclite_rx_handler()
628 * xemaclite_interrupt - Interrupt handler for this driver
642 void __iomem *base_addr = lp->base_addr; in xemaclite_interrupt()
686 * xemaclite_mdio_wait - Wait for the MDIO to be ready to use
703 lp->base_addr + XEL_MDIOCTRL_OFFSET, in xemaclite_mdio_wait()
709 * xemaclite_mdio_read - Read from a given MII management register
722 struct net_local *lp = bus->priv; in xemaclite_mdio_read()
727 return -ETIMEDOUT; in xemaclite_mdio_read()
733 ctrl_reg = xemaclite_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET); in xemaclite_mdio_read()
736 lp->base_addr + XEL_MDIOADDR_OFFSET); in xemaclite_mdio_read()
738 lp->base_addr + XEL_MDIOCTRL_OFFSET); in xemaclite_mdio_read()
741 return -ETIMEDOUT; in xemaclite_mdio_read()
743 rc = xemaclite_readl(lp->base_addr + XEL_MDIORD_OFFSET); in xemaclite_mdio_read()
745 dev_dbg(&lp->ndev->dev, in xemaclite_mdio_read()
753 * xemaclite_mdio_write - Write to a given MII management register
767 struct net_local *lp = bus->priv; in xemaclite_mdio_write()
770 dev_dbg(&lp->ndev->dev, in xemaclite_mdio_write()
775 return -ETIMEDOUT; in xemaclite_mdio_write()
782 ctrl_reg = xemaclite_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET); in xemaclite_mdio_write()
785 lp->base_addr + XEL_MDIOADDR_OFFSET); in xemaclite_mdio_write()
786 xemaclite_writel(val, lp->base_addr + XEL_MDIOWR_OFFSET); in xemaclite_mdio_write()
788 lp->base_addr + XEL_MDIOCTRL_OFFSET); in xemaclite_mdio_write()
794 * xemaclite_mdio_setup - Register mii_bus for the Emaclite device
807 struct device_node *np = of_get_parent(lp->phy_node); in xemaclite_mdio_setup()
816 return -ENODEV; in xemaclite_mdio_setup()
823 dev->of_node->full_name); in xemaclite_mdio_setup()
827 if (lp->ndev->mem_start != res.start) { in xemaclite_mdio_setup()
830 phydev = of_phy_find_device(lp->phy_node); in xemaclite_mdio_setup()
835 put_device(&phydev->mdio.dev); in xemaclite_mdio_setup()
844 lp->base_addr + XEL_MDIOCTRL_OFFSET); in xemaclite_mdio_setup()
850 return -ENOMEM; in xemaclite_mdio_setup()
853 snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx", in xemaclite_mdio_setup()
855 bus->priv = lp; in xemaclite_mdio_setup()
856 bus->name = "Xilinx Emaclite MDIO"; in xemaclite_mdio_setup()
857 bus->read = xemaclite_mdio_read; in xemaclite_mdio_setup()
858 bus->write = xemaclite_mdio_write; in xemaclite_mdio_setup()
859 bus->parent = dev; in xemaclite_mdio_setup()
868 lp->mii_bus = bus; in xemaclite_mdio_setup()
878 * xemaclite_adjust_link - Link state callback for the Emaclite device
887 struct phy_device *phy = lp->phy_dev; in xemaclite_adjust_link()
891 link_state = phy->speed | (phy->duplex << 1) | phy->link; in xemaclite_adjust_link()
893 if (lp->last_link != link_state) { in xemaclite_adjust_link()
894 lp->last_link = link_state; in xemaclite_adjust_link()
900 * xemaclite_open - Open the network device
907 * Return: 0 on success. -ENODEV, if PHY cannot be connected.
908 * Non-zero error value on failure.
918 if (lp->phy_node) { in xemaclite_open()
919 lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node, in xemaclite_open()
922 if (!lp->phy_dev) { in xemaclite_open()
923 dev_err(&lp->ndev->dev, "of_phy_connect() failed\n"); in xemaclite_open()
924 return -ENODEV; in xemaclite_open()
927 /* EmacLite doesn't support giga-bit speeds */ in xemaclite_open()
928 phy_set_max_speed(lp->phy_dev, SPEED_100); in xemaclite_open()
929 phy_start(lp->phy_dev); in xemaclite_open()
933 xemaclite_update_address(lp, dev->dev_addr); in xemaclite_open()
936 retval = request_irq(dev->irq, xemaclite_interrupt, 0, dev->name, dev); in xemaclite_open()
938 dev_err(&lp->ndev->dev, "Could not allocate interrupt %d\n", in xemaclite_open()
939 dev->irq); in xemaclite_open()
940 if (lp->phy_dev) in xemaclite_open()
941 phy_disconnect(lp->phy_dev); in xemaclite_open()
942 lp->phy_dev = NULL; in xemaclite_open()
957 * xemaclite_close - Close the network device
972 free_irq(dev->irq, dev); in xemaclite_close()
974 if (lp->phy_dev) in xemaclite_close()
975 phy_disconnect(lp->phy_dev); in xemaclite_close()
976 lp->phy_dev = NULL; in xemaclite_close()
982 * xemaclite_send - Transmit a frame
1003 len = orig_skb->len; in xemaclite_send()
1007 spin_lock_irqsave(&lp->reset_lock, flags); in xemaclite_send()
1008 if (xemaclite_send_data(lp, (u8 *)new_skb->data, len) != 0) { in xemaclite_send()
1014 lp->deferred_skb = new_skb; in xemaclite_send()
1017 spin_unlock_irqrestore(&lp->reset_lock, flags); in xemaclite_send()
1020 spin_unlock_irqrestore(&lp->reset_lock, flags); in xemaclite_send()
1024 dev->stats.tx_bytes += len; in xemaclite_send()
1031 * get_bool - Get a parameter from the OF device
1042 u32 *p = (u32 *)of_get_property(ofdev->dev.of_node, s, NULL); in get_bool()
1045 dev_warn(&ofdev->dev, "Parameter %s not found, defaulting to false\n", s); in get_bool()
1053 * xemaclite_ethtools_get_drvinfo - Get various Axi Emac Lite driver info
1058 * Issue "ethtool -i ethX" under linux prompt to execute this function.
1063 strscpy(ed->driver, DRIVER_NAME, sizeof(ed->driver)); in xemaclite_ethtools_get_drvinfo()
1076 * xemaclite_of_probe - Probe method for the Emaclite device.
1093 struct device *dev = &ofdev->dev; in xemaclite_of_probe()
1102 return -ENOMEM; in xemaclite_of_probe()
1105 SET_NETDEV_DEV(ndev, &ofdev->dev); in xemaclite_of_probe()
1108 lp->ndev = ndev; in xemaclite_of_probe()
1115 ndev->irq = rc; in xemaclite_of_probe()
1118 lp->base_addr = devm_ioremap_resource(&ofdev->dev, res); in xemaclite_of_probe()
1119 if (IS_ERR(lp->base_addr)) { in xemaclite_of_probe()
1120 rc = PTR_ERR(lp->base_addr); in xemaclite_of_probe()
1124 ndev->mem_start = res->start; in xemaclite_of_probe()
1125 ndev->mem_end = res->end; in xemaclite_of_probe()
1127 spin_lock_init(&lp->reset_lock); in xemaclite_of_probe()
1128 lp->next_tx_buf_to_use = 0x0; in xemaclite_of_probe()
1129 lp->next_rx_buf_to_use = 0x0; in xemaclite_of_probe()
1130 lp->tx_ping_pong = get_bool(ofdev, "xlnx,tx-ping-pong"); in xemaclite_of_probe()
1131 lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong"); in xemaclite_of_probe()
1133 rc = of_get_ethdev_address(ofdev->dev.of_node, ndev); in xemaclite_of_probe()
1140 xemaclite_writel(0, lp->base_addr + XEL_TSR_OFFSET); in xemaclite_of_probe()
1141 xemaclite_writel(0, lp->base_addr + XEL_BUFFER_OFFSET + XEL_TSR_OFFSET); in xemaclite_of_probe()
1144 xemaclite_update_address(lp, ndev->dev_addr); in xemaclite_of_probe()
1146 lp->phy_node = of_parse_phandle(ofdev->dev.of_node, "phy-handle", 0); in xemaclite_of_probe()
1147 xemaclite_mdio_setup(lp, &ofdev->dev); in xemaclite_of_probe()
1149 dev_info(dev, "MAC address is now %pM\n", ndev->dev_addr); in xemaclite_of_probe()
1151 ndev->netdev_ops = &xemaclite_netdev_ops; in xemaclite_of_probe()
1152 ndev->ethtool_ops = &xemaclite_ethtool_ops; in xemaclite_of_probe()
1153 ndev->flags &= ~IFF_MULTICAST; in xemaclite_of_probe()
1154 ndev->watchdog_timeo = TX_TIMEOUT; in xemaclite_of_probe()
1166 (unsigned long __force)ndev->mem_start, lp->base_addr, ndev->irq); in xemaclite_of_probe()
1170 of_node_put(lp->phy_node); in xemaclite_of_probe()
1177 * xemaclite_of_remove - Unbind the driver from the Emaclite device.
1192 /* Un-register the mii_bus, if configured */ in xemaclite_of_remove()
1193 if (lp->mii_bus) { in xemaclite_of_remove()
1194 mdiobus_unregister(lp->mii_bus); in xemaclite_of_remove()
1195 mdiobus_free(lp->mii_bus); in xemaclite_of_remove()
1196 lp->mii_bus = NULL; in xemaclite_of_remove()
1201 of_node_put(lp->phy_node); in xemaclite_of_remove()
1202 lp->phy_node = NULL; in xemaclite_of_remove()
1213 disable_irq(ndev->irq); in xemaclite_poll_controller()
1214 xemaclite_interrupt(ndev->irq, ndev); in xemaclite_poll_controller()
1215 enable_irq(ndev->irq); in xemaclite_poll_controller()
1222 if (!dev->phydev || !netif_running(dev)) in xemaclite_ioctl()
1223 return -EINVAL; in xemaclite_ioctl()
1229 return phy_mii_ioctl(dev->phydev, rq, cmd); in xemaclite_ioctl()
1231 return -EOPNOTSUPP; in xemaclite_ioctl()
1249 { .compatible = "xlnx,opb-ethernetlite-1.01.a", },
1250 { .compatible = "xlnx,opb-ethernetlite-1.01.b", },
1251 { .compatible = "xlnx,xps-ethernetlite-1.00.a", },
1252 { .compatible = "xlnx,xps-ethernetlite-2.00.a", },
1253 { .compatible = "xlnx,xps-ethernetlite-2.01.a", },
1254 { .compatible = "xlnx,xps-ethernetlite-3.00.a", },