diff options
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/3c59x.c | 5 | ||||
-rw-r--r-- | drivers/net/8139cp.c | 179 | ||||
-rw-r--r-- | drivers/net/8390.c | 10 | ||||
-rw-r--r-- | drivers/net/Kconfig | 15 | ||||
-rw-r--r-- | drivers/net/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/acenic.c | 6 | ||||
-rw-r--r-- | drivers/net/arm/at91_ether.c | 156 | ||||
-rw-r--r-- | drivers/net/arm/at91_ether.h | 1 | ||||
-rw-r--r-- | drivers/net/b44.c | 277 | ||||
-rw-r--r-- | drivers/net/b44.h | 7 | ||||
-rw-r--r-- | drivers/net/forcedeth.c | 22 | ||||
-rw-r--r-- | drivers/net/ioc3-eth.c | 2 | ||||
-rw-r--r-- | drivers/net/myri10ge/myri10ge.c | 2 | ||||
-rw-r--r-- | drivers/net/netx-eth.c | 516 | ||||
-rw-r--r-- | drivers/net/pcmcia/xirc2ps_cs.c | 2 | ||||
-rw-r--r-- | drivers/net/smc91x.h | 44 | ||||
-rw-r--r-- | drivers/net/sunhme.c | 5 | ||||
-rw-r--r-- | drivers/net/sunlance.c | 2 | ||||
-rw-r--r-- | drivers/net/tokenring/olympic.c | 4 | ||||
-rw-r--r-- | drivers/net/wan/c101.c | 6 | ||||
-rw-r--r-- | drivers/net/wan/hdlc_generic.c | 24 | ||||
-rw-r--r-- | drivers/net/wan/n2.c | 5 | ||||
-rw-r--r-- | drivers/net/wan/pci200syn.c | 1 | ||||
-rw-r--r-- | drivers/net/wan/wanxl.c | 12 | ||||
-rw-r--r-- | drivers/net/wireless/wavelan.c | 18 |
25 files changed, 1153 insertions, 169 deletions
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index 274b0138d442..e27778926eba 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c | |||
@@ -1382,17 +1382,12 @@ static int __devinit vortex_probe1(struct device *gendev, | |||
1382 | for (i = 0; i < 6; i++) | 1382 | for (i = 0; i < 6; i++) |
1383 | iowrite8(dev->dev_addr[i], ioaddr + i); | 1383 | iowrite8(dev->dev_addr[i], ioaddr + i); |
1384 | 1384 | ||
1385 | #ifdef __sparc__ | ||
1386 | if (print_info) | ||
1387 | printk(", IRQ %s\n", __irq_itoa(dev->irq)); | ||
1388 | #else | ||
1389 | if (print_info) | 1385 | if (print_info) |
1390 | printk(", IRQ %d\n", dev->irq); | 1386 | printk(", IRQ %d\n", dev->irq); |
1391 | /* Tell them about an invalid IRQ. */ | 1387 | /* Tell them about an invalid IRQ. */ |
1392 | if (dev->irq <= 0 || dev->irq >= NR_IRQS) | 1388 | if (dev->irq <= 0 || dev->irq >= NR_IRQS) |
1393 | printk(KERN_WARNING " *** Warning: IRQ %d is unlikely to work! ***\n", | 1389 | printk(KERN_WARNING " *** Warning: IRQ %d is unlikely to work! ***\n", |
1394 | dev->irq); | 1390 | dev->irq); |
1395 | #endif | ||
1396 | 1391 | ||
1397 | EL3WINDOW(4); | 1392 | EL3WINDOW(4); |
1398 | step = (ioread8(ioaddr + Wn4_NetDiag) & 0x1e) >> 1; | 1393 | step = (ioread8(ioaddr + Wn4_NetDiag) & 0x1e) >> 1; |
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c index 46d8c01437e9..a26077a175ad 100644 --- a/drivers/net/8139cp.c +++ b/drivers/net/8139cp.c | |||
@@ -401,6 +401,11 @@ static void cp_clean_rings (struct cp_private *cp); | |||
401 | #ifdef CONFIG_NET_POLL_CONTROLLER | 401 | #ifdef CONFIG_NET_POLL_CONTROLLER |
402 | static void cp_poll_controller(struct net_device *dev); | 402 | static void cp_poll_controller(struct net_device *dev); |
403 | #endif | 403 | #endif |
404 | static int cp_get_eeprom_len(struct net_device *dev); | ||
405 | static int cp_get_eeprom(struct net_device *dev, | ||
406 | struct ethtool_eeprom *eeprom, u8 *data); | ||
407 | static int cp_set_eeprom(struct net_device *dev, | ||
408 | struct ethtool_eeprom *eeprom, u8 *data); | ||
404 | 409 | ||
405 | static struct pci_device_id cp_pci_tbl[] = { | 410 | static struct pci_device_id cp_pci_tbl[] = { |
406 | { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139, | 411 | { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139, |
@@ -1577,6 +1582,9 @@ static struct ethtool_ops cp_ethtool_ops = { | |||
1577 | .get_strings = cp_get_strings, | 1582 | .get_strings = cp_get_strings, |
1578 | .get_ethtool_stats = cp_get_ethtool_stats, | 1583 | .get_ethtool_stats = cp_get_ethtool_stats, |
1579 | .get_perm_addr = ethtool_op_get_perm_addr, | 1584 | .get_perm_addr = ethtool_op_get_perm_addr, |
1585 | .get_eeprom_len = cp_get_eeprom_len, | ||
1586 | .get_eeprom = cp_get_eeprom, | ||
1587 | .set_eeprom = cp_set_eeprom, | ||
1580 | }; | 1588 | }; |
1581 | 1589 | ||
1582 | static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) | 1590 | static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) |
@@ -1612,24 +1620,32 @@ static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) | |||
1612 | #define eeprom_delay() readl(ee_addr) | 1620 | #define eeprom_delay() readl(ee_addr) |
1613 | 1621 | ||
1614 | /* The EEPROM commands include the alway-set leading bit. */ | 1622 | /* The EEPROM commands include the alway-set leading bit. */ |
1623 | #define EE_EXTEND_CMD (4) | ||
1615 | #define EE_WRITE_CMD (5) | 1624 | #define EE_WRITE_CMD (5) |
1616 | #define EE_READ_CMD (6) | 1625 | #define EE_READ_CMD (6) |
1617 | #define EE_ERASE_CMD (7) | 1626 | #define EE_ERASE_CMD (7) |
1618 | 1627 | ||
1619 | static int read_eeprom (void __iomem *ioaddr, int location, int addr_len) | 1628 | #define EE_EWDS_ADDR (0) |
1620 | { | 1629 | #define EE_WRAL_ADDR (1) |
1621 | int i; | 1630 | #define EE_ERAL_ADDR (2) |
1622 | unsigned retval = 0; | 1631 | #define EE_EWEN_ADDR (3) |
1623 | void __iomem *ee_addr = ioaddr + Cfg9346; | 1632 | |
1624 | int read_cmd = location | (EE_READ_CMD << addr_len); | 1633 | #define CP_EEPROM_MAGIC PCI_DEVICE_ID_REALTEK_8139 |
1625 | 1634 | ||
1635 | static void eeprom_cmd_start(void __iomem *ee_addr) | ||
1636 | { | ||
1626 | writeb (EE_ENB & ~EE_CS, ee_addr); | 1637 | writeb (EE_ENB & ~EE_CS, ee_addr); |
1627 | writeb (EE_ENB, ee_addr); | 1638 | writeb (EE_ENB, ee_addr); |
1628 | eeprom_delay (); | 1639 | eeprom_delay (); |
1640 | } | ||
1629 | 1641 | ||
1630 | /* Shift the read command bits out. */ | 1642 | static void eeprom_cmd(void __iomem *ee_addr, int cmd, int cmd_len) |
1631 | for (i = 4 + addr_len; i >= 0; i--) { | 1643 | { |
1632 | int dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0; | 1644 | int i; |
1645 | |||
1646 | /* Shift the command bits out. */ | ||
1647 | for (i = cmd_len - 1; i >= 0; i--) { | ||
1648 | int dataval = (cmd & (1 << i)) ? EE_DATA_WRITE : 0; | ||
1633 | writeb (EE_ENB | dataval, ee_addr); | 1649 | writeb (EE_ENB | dataval, ee_addr); |
1634 | eeprom_delay (); | 1650 | eeprom_delay (); |
1635 | writeb (EE_ENB | dataval | EE_SHIFT_CLK, ee_addr); | 1651 | writeb (EE_ENB | dataval | EE_SHIFT_CLK, ee_addr); |
@@ -1637,6 +1653,33 @@ static int read_eeprom (void __iomem *ioaddr, int location, int addr_len) | |||
1637 | } | 1653 | } |
1638 | writeb (EE_ENB, ee_addr); | 1654 | writeb (EE_ENB, ee_addr); |
1639 | eeprom_delay (); | 1655 | eeprom_delay (); |
1656 | } | ||
1657 | |||
1658 | static void eeprom_cmd_end(void __iomem *ee_addr) | ||
1659 | { | ||
1660 | writeb (~EE_CS, ee_addr); | ||
1661 | eeprom_delay (); | ||
1662 | } | ||
1663 | |||
1664 | static void eeprom_extend_cmd(void __iomem *ee_addr, int extend_cmd, | ||
1665 | int addr_len) | ||
1666 | { | ||
1667 | int cmd = (EE_EXTEND_CMD << addr_len) | (extend_cmd << (addr_len - 2)); | ||
1668 | |||
1669 | eeprom_cmd_start(ee_addr); | ||
1670 | eeprom_cmd(ee_addr, cmd, 3 + addr_len); | ||
1671 | eeprom_cmd_end(ee_addr); | ||
1672 | } | ||
1673 | |||
1674 | static u16 read_eeprom (void __iomem *ioaddr, int location, int addr_len) | ||
1675 | { | ||
1676 | int i; | ||
1677 | u16 retval = 0; | ||
1678 | void __iomem *ee_addr = ioaddr + Cfg9346; | ||
1679 | int read_cmd = location | (EE_READ_CMD << addr_len); | ||
1680 | |||
1681 | eeprom_cmd_start(ee_addr); | ||
1682 | eeprom_cmd(ee_addr, read_cmd, 3 + addr_len); | ||
1640 | 1683 | ||
1641 | for (i = 16; i > 0; i--) { | 1684 | for (i = 16; i > 0; i--) { |
1642 | writeb (EE_ENB | EE_SHIFT_CLK, ee_addr); | 1685 | writeb (EE_ENB | EE_SHIFT_CLK, ee_addr); |
@@ -1648,13 +1691,125 @@ static int read_eeprom (void __iomem *ioaddr, int location, int addr_len) | |||
1648 | eeprom_delay (); | 1691 | eeprom_delay (); |
1649 | } | 1692 | } |
1650 | 1693 | ||
1651 | /* Terminate the EEPROM access. */ | 1694 | eeprom_cmd_end(ee_addr); |
1652 | writeb (~EE_CS, ee_addr); | ||
1653 | eeprom_delay (); | ||
1654 | 1695 | ||
1655 | return retval; | 1696 | return retval; |
1656 | } | 1697 | } |
1657 | 1698 | ||
1699 | static void write_eeprom(void __iomem *ioaddr, int location, u16 val, | ||
1700 | int addr_len) | ||
1701 | { | ||
1702 | int i; | ||
1703 | void __iomem *ee_addr = ioaddr + Cfg9346; | ||
1704 | int write_cmd = location | (EE_WRITE_CMD << addr_len); | ||
1705 | |||
1706 | eeprom_extend_cmd(ee_addr, EE_EWEN_ADDR, addr_len); | ||
1707 | |||
1708 | eeprom_cmd_start(ee_addr); | ||
1709 | eeprom_cmd(ee_addr, write_cmd, 3 + addr_len); | ||
1710 | eeprom_cmd(ee_addr, val, 16); | ||
1711 | eeprom_cmd_end(ee_addr); | ||
1712 | |||
1713 | eeprom_cmd_start(ee_addr); | ||
1714 | for (i = 0; i < 20000; i++) | ||
1715 | if (readb(ee_addr) & EE_DATA_READ) | ||
1716 | break; | ||
1717 | eeprom_cmd_end(ee_addr); | ||
1718 | |||
1719 | eeprom_extend_cmd(ee_addr, EE_EWDS_ADDR, addr_len); | ||
1720 | } | ||
1721 | |||
1722 | static int cp_get_eeprom_len(struct net_device *dev) | ||
1723 | { | ||
1724 | struct cp_private *cp = netdev_priv(dev); | ||
1725 | int size; | ||
1726 | |||
1727 | spin_lock_irq(&cp->lock); | ||
1728 | size = read_eeprom(cp->regs, 0, 8) == 0x8129 ? 256 : 128; | ||
1729 | spin_unlock_irq(&cp->lock); | ||
1730 | |||
1731 | return size; | ||
1732 | } | ||
1733 | |||
1734 | static int cp_get_eeprom(struct net_device *dev, | ||
1735 | struct ethtool_eeprom *eeprom, u8 *data) | ||
1736 | { | ||
1737 | struct cp_private *cp = netdev_priv(dev); | ||
1738 | unsigned int addr_len; | ||
1739 | u16 val; | ||
1740 | u32 offset = eeprom->offset >> 1; | ||
1741 | u32 len = eeprom->len; | ||
1742 | u32 i = 0; | ||
1743 | |||
1744 | eeprom->magic = CP_EEPROM_MAGIC; | ||
1745 | |||
1746 | spin_lock_irq(&cp->lock); | ||
1747 | |||
1748 | addr_len = read_eeprom(cp->regs, 0, 8) == 0x8129 ? 8 : 6; | ||
1749 | |||
1750 | if (eeprom->offset & 1) { | ||
1751 | val = read_eeprom(cp->regs, offset, addr_len); | ||
1752 | data[i++] = (u8)(val >> 8); | ||
1753 | offset++; | ||
1754 | } | ||
1755 | |||
1756 | while (i < len - 1) { | ||
1757 | val = read_eeprom(cp->regs, offset, addr_len); | ||
1758 | data[i++] = (u8)val; | ||
1759 | data[i++] = (u8)(val >> 8); | ||
1760 | offset++; | ||
1761 | } | ||
1762 | |||
1763 | if (i < len) { | ||
1764 | val = read_eeprom(cp->regs, offset, addr_len); | ||
1765 | data[i] = (u8)val; | ||
1766 | } | ||
1767 | |||
1768 | spin_unlock_irq(&cp->lock); | ||
1769 | return 0; | ||
1770 | } | ||
1771 | |||
1772 | static int cp_set_eeprom(struct net_device *dev, | ||
1773 | struct ethtool_eeprom *eeprom, u8 *data) | ||
1774 | { | ||
1775 | struct cp_private *cp = netdev_priv(dev); | ||
1776 | unsigned int addr_len; | ||
1777 | u16 val; | ||
1778 | u32 offset = eeprom->offset >> 1; | ||
1779 | u32 len = eeprom->len; | ||
1780 | u32 i = 0; | ||
1781 | |||
1782 | if (eeprom->magic != CP_EEPROM_MAGIC) | ||
1783 | return -EINVAL; | ||
1784 | |||
1785 | spin_lock_irq(&cp->lock); | ||
1786 | |||
1787 | addr_len = read_eeprom(cp->regs, 0, 8) == 0x8129 ? 8 : 6; | ||
1788 | |||
1789 | if (eeprom->offset & 1) { | ||
1790 | val = read_eeprom(cp->regs, offset, addr_len) & 0xff; | ||
1791 | val |= (u16)data[i++] << 8; | ||
1792 | write_eeprom(cp->regs, offset, val, addr_len); | ||
1793 | offset++; | ||
1794 | } | ||
1795 | |||
1796 | while (i < len - 1) { | ||
1797 | val = (u16)data[i++]; | ||
1798 | val |= (u16)data[i++] << 8; | ||
1799 | write_eeprom(cp->regs, offset, val, addr_len); | ||
1800 | offset++; | ||
1801 | } | ||
1802 | |||
1803 | if (i < len) { | ||
1804 | val = read_eeprom(cp->regs, offset, addr_len) & 0xff00; | ||
1805 | val |= (u16)data[i]; | ||
1806 | write_eeprom(cp->regs, offset, val, addr_len); | ||
1807 | } | ||
1808 | |||
1809 | spin_unlock_irq(&cp->lock); | ||
1810 | return 0; | ||
1811 | } | ||
1812 | |||
1658 | /* Put the board into D3cold state and wait for WakeUp signal */ | 1813 | /* Put the board into D3cold state and wait for WakeUp signal */ |
1659 | static void cp_set_d3_state (struct cp_private *cp) | 1814 | static void cp_set_d3_state (struct cp_private *cp) |
1660 | { | 1815 | { |
diff --git a/drivers/net/8390.c b/drivers/net/8390.c index f87027420081..86be96af9c8f 100644 --- a/drivers/net/8390.c +++ b/drivers/net/8390.c | |||
@@ -275,12 +275,14 @@ static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
275 | struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); | 275 | struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); |
276 | int send_length = skb->len, output_page; | 276 | int send_length = skb->len, output_page; |
277 | unsigned long flags; | 277 | unsigned long flags; |
278 | char buf[ETH_ZLEN]; | ||
279 | char *data = skb->data; | ||
278 | 280 | ||
279 | if (skb->len < ETH_ZLEN) { | 281 | if (skb->len < ETH_ZLEN) { |
280 | skb = skb_padto(skb, ETH_ZLEN); | 282 | memset(buf, 0, ETH_ZLEN); /* more efficient than doing just the needed bits */ |
281 | if (skb == NULL) | 283 | memcpy(buf, data, skb->len); |
282 | return 0; | ||
283 | send_length = ETH_ZLEN; | 284 | send_length = ETH_ZLEN; |
285 | data = buf; | ||
284 | } | 286 | } |
285 | 287 | ||
286 | /* Mask interrupts from the ethercard. | 288 | /* Mask interrupts from the ethercard. |
@@ -347,7 +349,7 @@ static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
347 | * trigger the send later, upon receiving a Tx done interrupt. | 349 | * trigger the send later, upon receiving a Tx done interrupt. |
348 | */ | 350 | */ |
349 | 351 | ||
350 | ei_block_output(dev, send_length, skb->data, output_page); | 352 | ei_block_output(dev, send_length, data, output_page); |
351 | 353 | ||
352 | if (! ei_local->txing) | 354 | if (! ei_local->txing) |
353 | { | 355 | { |
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 0c6b45a11d15..7fa24c51e40b 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -854,6 +854,17 @@ config SMC9194 | |||
854 | <file:Documentation/networking/net-modules.txt>. The module | 854 | <file:Documentation/networking/net-modules.txt>. The module |
855 | will be called smc9194. | 855 | will be called smc9194. |
856 | 856 | ||
857 | config NET_NETX | ||
858 | tristate "NetX Ethernet support" | ||
859 | select MII | ||
860 | depends on NET_ETHERNET && ARCH_NETX | ||
861 | help | ||
862 | This is support for the Hilscher netX builtin Ethernet ports | ||
863 | |||
864 | To compile this driver as a module, choose M here and read | ||
865 | <file:Documentation/networking/net-modules.txt>. The module | ||
866 | will be called netx-eth. | ||
867 | |||
857 | config DM9000 | 868 | config DM9000 |
858 | tristate "DM9000 support" | 869 | tristate "DM9000 support" |
859 | depends on (ARM || MIPS) && NET_ETHERNET | 870 | depends on (ARM || MIPS) && NET_ETHERNET |
@@ -1376,8 +1387,8 @@ config APRICOT | |||
1376 | called apricot. | 1387 | called apricot. |
1377 | 1388 | ||
1378 | config B44 | 1389 | config B44 |
1379 | tristate "Broadcom 4400 ethernet support (EXPERIMENTAL)" | 1390 | tristate "Broadcom 4400 ethernet support" |
1380 | depends on NET_PCI && PCI && EXPERIMENTAL | 1391 | depends on NET_PCI && PCI |
1381 | select MII | 1392 | select MII |
1382 | help | 1393 | help |
1383 | If you have a network (Ethernet) controller of this type, say Y and | 1394 | If you have a network (Ethernet) controller of this type, say Y and |
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 1eced3287507..c91e95126f78 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile | |||
@@ -187,6 +187,7 @@ obj-$(CONFIG_MACSONIC) += macsonic.o | |||
187 | obj-$(CONFIG_MACMACE) += macmace.o | 187 | obj-$(CONFIG_MACMACE) += macmace.o |
188 | obj-$(CONFIG_MAC89x0) += mac89x0.o | 188 | obj-$(CONFIG_MAC89x0) += mac89x0.o |
189 | obj-$(CONFIG_TUN) += tun.o | 189 | obj-$(CONFIG_TUN) += tun.o |
190 | obj-$(CONFIG_NET_NETX) += netx-eth.o | ||
190 | obj-$(CONFIG_DL2K) += dl2k.o | 191 | obj-$(CONFIG_DL2K) += dl2k.o |
191 | obj-$(CONFIG_R8169) += r8169.o | 192 | obj-$(CONFIG_R8169) += r8169.o |
192 | obj-$(CONFIG_AMD8111_ETH) += amd8111e.o | 193 | obj-$(CONFIG_AMD8111_ETH) += amd8111e.o |
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c index b508812e97ac..23ff22ba5d31 100644 --- a/drivers/net/acenic.c +++ b/drivers/net/acenic.c | |||
@@ -579,11 +579,7 @@ static int __devinit acenic_probe_one(struct pci_dev *pdev, | |||
579 | } | 579 | } |
580 | 580 | ||
581 | printk("Gigabit Ethernet at 0x%08lx, ", dev->base_addr); | 581 | printk("Gigabit Ethernet at 0x%08lx, ", dev->base_addr); |
582 | #ifdef __sparc__ | 582 | printk("irq %d\n", pdev->irq); |
583 | printk("irq %s\n", __irq_itoa(pdev->irq)); | ||
584 | #else | ||
585 | printk("irq %i\n", pdev->irq); | ||
586 | #endif | ||
587 | 583 | ||
588 | #ifdef CONFIG_ACENIC_OMIT_TIGON_I | 584 | #ifdef CONFIG_ACENIC_OMIT_TIGON_I |
589 | if ((readl(&ap->regs->HostCtrl) >> 28) == 4) { | 585 | if ((readl(&ap->regs->HostCtrl) >> 28) == 4) { |
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c index 5503dc8a66e4..613005a0285d 100644 --- a/drivers/net/arm/at91_ether.c +++ b/drivers/net/arm/at91_ether.c | |||
@@ -43,7 +43,9 @@ | |||
43 | #define DRV_VERSION "1.0" | 43 | #define DRV_VERSION "1.0" |
44 | 44 | ||
45 | static struct net_device *at91_dev; | 45 | static struct net_device *at91_dev; |
46 | static struct clk *ether_clk; | 46 | |
47 | static struct timer_list check_timer; | ||
48 | #define LINK_POLL_INTERVAL (HZ) | ||
47 | 49 | ||
48 | /* ..................................................................... */ | 50 | /* ..................................................................... */ |
49 | 51 | ||
@@ -143,7 +145,7 @@ static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int | |||
143 | * MAC accordingly. | 145 | * MAC accordingly. |
144 | * If no link or auto-negotiation is busy, then no changes are made. | 146 | * If no link or auto-negotiation is busy, then no changes are made. |
145 | */ | 147 | */ |
146 | static void update_linkspeed(struct net_device *dev) | 148 | static void update_linkspeed(struct net_device *dev, int silent) |
147 | { | 149 | { |
148 | struct at91_private *lp = (struct at91_private *) dev->priv; | 150 | struct at91_private *lp = (struct at91_private *) dev->priv; |
149 | unsigned int bmsr, bmcr, lpa, mac_cfg; | 151 | unsigned int bmsr, bmcr, lpa, mac_cfg; |
@@ -151,7 +153,8 @@ static void update_linkspeed(struct net_device *dev) | |||
151 | 153 | ||
152 | if (!mii_link_ok(&lp->mii)) { /* no link */ | 154 | if (!mii_link_ok(&lp->mii)) { /* no link */ |
153 | netif_carrier_off(dev); | 155 | netif_carrier_off(dev); |
154 | printk(KERN_INFO "%s: Link down.\n", dev->name); | 156 | if (!silent) |
157 | printk(KERN_INFO "%s: Link down.\n", dev->name); | ||
155 | return; | 158 | return; |
156 | } | 159 | } |
157 | 160 | ||
@@ -186,7 +189,8 @@ static void update_linkspeed(struct net_device *dev) | |||
186 | } | 189 | } |
187 | at91_emac_write(AT91_EMAC_CFG, mac_cfg); | 190 | at91_emac_write(AT91_EMAC_CFG, mac_cfg); |
188 | 191 | ||
189 | printk(KERN_INFO "%s: Link now %i-%s\n", dev->name, speed, (duplex == DUPLEX_FULL) ? "FullDuplex" : "HalfDuplex"); | 192 | if (!silent) |
193 | printk(KERN_INFO "%s: Link now %i-%s\n", dev->name, speed, (duplex == DUPLEX_FULL) ? "FullDuplex" : "HalfDuplex"); | ||
190 | netif_carrier_on(dev); | 194 | netif_carrier_on(dev); |
191 | } | 195 | } |
192 | 196 | ||
@@ -226,7 +230,7 @@ static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id, struct pt_regs | |||
226 | goto done; | 230 | goto done; |
227 | } | 231 | } |
228 | 232 | ||
229 | update_linkspeed(dev); | 233 | update_linkspeed(dev, 0); |
230 | 234 | ||
231 | done: | 235 | done: |
232 | disable_mdi(); | 236 | disable_mdi(); |
@@ -243,14 +247,17 @@ static void enable_phyirq(struct net_device *dev) | |||
243 | unsigned int dsintr, irq_number; | 247 | unsigned int dsintr, irq_number; |
244 | int status; | 248 | int status; |
245 | 249 | ||
246 | if (lp->phy_type == MII_RTL8201_ID) /* RTL8201 does not have an interrupt */ | 250 | irq_number = lp->board_data.phy_irq_pin; |
247 | return; | 251 | if (!irq_number) { |
248 | if (lp->phy_type == MII_DP83847_ID) /* DP83847 does not have an interrupt */ | 252 | /* |
249 | return; | 253 | * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L), |
250 | if (lp->phy_type == MII_AC101L_ID) /* AC101L interrupt not supported yet */ | 254 | * or board does not have it connected. |
255 | */ | ||
256 | check_timer.expires = jiffies + LINK_POLL_INTERVAL; | ||
257 | add_timer(&check_timer); | ||
251 | return; | 258 | return; |
259 | } | ||
252 | 260 | ||
253 | irq_number = lp->board_data.phy_irq_pin; | ||
254 | status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev); | 261 | status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev); |
255 | if (status) { | 262 | if (status) { |
256 | printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status); | 263 | printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status); |
@@ -292,12 +299,11 @@ static void disable_phyirq(struct net_device *dev) | |||
292 | unsigned int dsintr; | 299 | unsigned int dsintr; |
293 | unsigned int irq_number; | 300 | unsigned int irq_number; |
294 | 301 | ||
295 | if (lp->phy_type == MII_RTL8201_ID) /* RTL8201 does not have an interrupt */ | 302 | irq_number = lp->board_data.phy_irq_pin; |
296 | return; | 303 | if (!irq_number) { |
297 | if (lp->phy_type == MII_DP83847_ID) /* DP83847 does not have an interrupt */ | 304 | del_timer_sync(&check_timer); |
298 | return; | ||
299 | if (lp->phy_type == MII_AC101L_ID) /* AC101L interrupt not supported yet */ | ||
300 | return; | 305 | return; |
306 | } | ||
301 | 307 | ||
302 | spin_lock_irq(&lp->lock); | 308 | spin_lock_irq(&lp->lock); |
303 | enable_mdi(); | 309 | enable_mdi(); |
@@ -326,7 +332,6 @@ static void disable_phyirq(struct net_device *dev) | |||
326 | disable_mdi(); | 332 | disable_mdi(); |
327 | spin_unlock_irq(&lp->lock); | 333 | spin_unlock_irq(&lp->lock); |
328 | 334 | ||
329 | irq_number = lp->board_data.phy_irq_pin; | ||
330 | free_irq(irq_number, dev); /* Free interrupt handler */ | 335 | free_irq(irq_number, dev); /* Free interrupt handler */ |
331 | } | 336 | } |
332 | 337 | ||
@@ -355,6 +360,18 @@ static void reset_phy(struct net_device *dev) | |||
355 | } | 360 | } |
356 | #endif | 361 | #endif |
357 | 362 | ||
363 | static void at91ether_check_link(unsigned long dev_id) | ||
364 | { | ||
365 | struct net_device *dev = (struct net_device *) dev_id; | ||
366 | |||
367 | enable_mdi(); | ||
368 | update_linkspeed(dev, 1); | ||
369 | disable_mdi(); | ||
370 | |||
371 | check_timer.expires = jiffies + LINK_POLL_INTERVAL; | ||
372 | add_timer(&check_timer); | ||
373 | } | ||
374 | |||
358 | /* ......................... ADDRESS MANAGEMENT ........................ */ | 375 | /* ......................... ADDRESS MANAGEMENT ........................ */ |
359 | 376 | ||
360 | /* | 377 | /* |
@@ -501,7 +518,7 @@ static int hash_get_index(__u8 *addr) | |||
501 | hash_index |= (bitval << j); | 518 | hash_index |= (bitval << j); |
502 | } | 519 | } |
503 | 520 | ||
504 | return hash_index; | 521 | return hash_index; |
505 | } | 522 | } |
506 | 523 | ||
507 | /* | 524 | /* |
@@ -557,10 +574,8 @@ static void at91ether_set_rx_mode(struct net_device *dev) | |||
557 | at91_emac_write(AT91_EMAC_CFG, cfg); | 574 | at91_emac_write(AT91_EMAC_CFG, cfg); |
558 | } | 575 | } |
559 | 576 | ||
560 | |||
561 | /* ......................... ETHTOOL SUPPORT ........................... */ | 577 | /* ......................... ETHTOOL SUPPORT ........................... */ |
562 | 578 | ||
563 | |||
564 | static int mdio_read(struct net_device *dev, int phy_id, int location) | 579 | static int mdio_read(struct net_device *dev, int phy_id, int location) |
565 | { | 580 | { |
566 | unsigned int value; | 581 | unsigned int value; |
@@ -642,6 +657,22 @@ static struct ethtool_ops at91ether_ethtool_ops = { | |||
642 | .get_link = ethtool_op_get_link, | 657 | .get_link = ethtool_op_get_link, |
643 | }; | 658 | }; |
644 | 659 | ||
660 | static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | ||
661 | { | ||
662 | struct at91_private *lp = (struct at91_private *) dev->priv; | ||
663 | int res; | ||
664 | |||
665 | if (!netif_running(dev)) | ||
666 | return -EINVAL; | ||
667 | |||
668 | spin_lock_irq(&lp->lock); | ||
669 | enable_mdi(); | ||
670 | res = generic_mii_ioctl(&lp->mii, if_mii(rq), cmd, NULL); | ||
671 | disable_mdi(); | ||
672 | spin_unlock_irq(&lp->lock); | ||
673 | |||
674 | return res; | ||
675 | } | ||
645 | 676 | ||
646 | /* ................................ MAC ................................ */ | 677 | /* ................................ MAC ................................ */ |
647 | 678 | ||
@@ -685,10 +716,10 @@ static int at91ether_open(struct net_device *dev) | |||
685 | struct at91_private *lp = (struct at91_private *) dev->priv; | 716 | struct at91_private *lp = (struct at91_private *) dev->priv; |
686 | unsigned long ctl; | 717 | unsigned long ctl; |
687 | 718 | ||
688 | if (!is_valid_ether_addr(dev->dev_addr)) | 719 | if (!is_valid_ether_addr(dev->dev_addr)) |
689 | return -EADDRNOTAVAIL; | 720 | return -EADDRNOTAVAIL; |
690 | 721 | ||
691 | clk_enable(ether_clk); /* Re-enable Peripheral clock */ | 722 | clk_enable(lp->ether_clk); /* Re-enable Peripheral clock */ |
692 | 723 | ||
693 | /* Clear internal statistics */ | 724 | /* Clear internal statistics */ |
694 | ctl = at91_emac_read(AT91_EMAC_CTL); | 725 | ctl = at91_emac_read(AT91_EMAC_CTL); |
@@ -708,7 +739,7 @@ static int at91ether_open(struct net_device *dev) | |||
708 | /* Determine current link speed */ | 739 | /* Determine current link speed */ |
709 | spin_lock_irq(&lp->lock); | 740 | spin_lock_irq(&lp->lock); |
710 | enable_mdi(); | 741 | enable_mdi(); |
711 | update_linkspeed(dev); | 742 | update_linkspeed(dev, 0); |
712 | disable_mdi(); | 743 | disable_mdi(); |
713 | spin_unlock_irq(&lp->lock); | 744 | spin_unlock_irq(&lp->lock); |
714 | 745 | ||
@@ -722,6 +753,7 @@ static int at91ether_open(struct net_device *dev) | |||
722 | */ | 753 | */ |
723 | static int at91ether_close(struct net_device *dev) | 754 | static int at91ether_close(struct net_device *dev) |
724 | { | 755 | { |
756 | struct at91_private *lp = (struct at91_private *) dev->priv; | ||
725 | unsigned long ctl; | 757 | unsigned long ctl; |
726 | 758 | ||
727 | /* Disable Receiver and Transmitter */ | 759 | /* Disable Receiver and Transmitter */ |
@@ -738,7 +770,7 @@ static int at91ether_close(struct net_device *dev) | |||
738 | 770 | ||
739 | netif_stop_queue(dev); | 771 | netif_stop_queue(dev); |
740 | 772 | ||
741 | clk_disable(ether_clk); /* Disable Peripheral clock */ | 773 | clk_disable(lp->ether_clk); /* Disable Peripheral clock */ |
742 | 774 | ||
743 | return 0; | 775 | return 0; |
744 | } | 776 | } |
@@ -870,7 +902,7 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id, struct pt_regs *re | |||
870 | if (intstatus & AT91_EMAC_RCOM) /* Receive complete */ | 902 | if (intstatus & AT91_EMAC_RCOM) /* Receive complete */ |
871 | at91ether_rx(dev); | 903 | at91ether_rx(dev); |
872 | 904 | ||
873 | if (intstatus & AT91_EMAC_TCOM) { /* Transmit complete */ | 905 | if (intstatus & AT91_EMAC_TCOM) { /* Transmit complete */ |
874 | /* The TCOM bit is set even if the transmission failed. */ | 906 | /* The TCOM bit is set even if the transmission failed. */ |
875 | if (intstatus & (AT91_EMAC_TUND | AT91_EMAC_RTRY)) | 907 | if (intstatus & (AT91_EMAC_TUND | AT91_EMAC_RTRY)) |
876 | lp->stats.tx_errors += 1; | 908 | lp->stats.tx_errors += 1; |
@@ -899,7 +931,8 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id, struct pt_regs *re | |||
899 | /* | 931 | /* |
900 | * Initialize the ethernet interface | 932 | * Initialize the ethernet interface |
901 | */ | 933 | */ |
902 | static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address, struct platform_device *pdev) | 934 | static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address, |
935 | struct platform_device *pdev, struct clk *ether_clk) | ||
903 | { | 936 | { |
904 | struct at91_eth_data *board_data = pdev->dev.platform_data; | 937 | struct at91_eth_data *board_data = pdev->dev.platform_data; |
905 | struct net_device *dev; | 938 | struct net_device *dev; |
@@ -933,6 +966,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add | |||
933 | return -ENOMEM; | 966 | return -ENOMEM; |
934 | } | 967 | } |
935 | lp->board_data = *board_data; | 968 | lp->board_data = *board_data; |
969 | lp->ether_clk = ether_clk; | ||
936 | platform_set_drvdata(pdev, dev); | 970 | platform_set_drvdata(pdev, dev); |
937 | 971 | ||
938 | spin_lock_init(&lp->lock); | 972 | spin_lock_init(&lp->lock); |
@@ -945,6 +979,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add | |||
945 | dev->set_multicast_list = at91ether_set_rx_mode; | 979 | dev->set_multicast_list = at91ether_set_rx_mode; |
946 | dev->set_mac_address = set_mac_address; | 980 | dev->set_mac_address = set_mac_address; |
947 | dev->ethtool_ops = &at91ether_ethtool_ops; | 981 | dev->ethtool_ops = &at91ether_ethtool_ops; |
982 | dev->do_ioctl = at91ether_ioctl; | ||
948 | 983 | ||
949 | SET_NETDEV_DEV(dev, &pdev->dev); | 984 | SET_NETDEV_DEV(dev, &pdev->dev); |
950 | 985 | ||
@@ -975,6 +1010,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add | |||
975 | lp->mii.dev = dev; /* Support for ethtool */ | 1010 | lp->mii.dev = dev; /* Support for ethtool */ |
976 | lp->mii.mdio_read = mdio_read; | 1011 | lp->mii.mdio_read = mdio_read; |
977 | lp->mii.mdio_write = mdio_write; | 1012 | lp->mii.mdio_write = mdio_write; |
1013 | lp->mii.phy_id = phy_address; | ||
1014 | lp->mii.phy_id_mask = 0x1f; | ||
1015 | lp->mii.reg_num_mask = 0x1f; | ||
978 | 1016 | ||
979 | lp->phy_type = phy_type; /* Type of PHY connected */ | 1017 | lp->phy_type = phy_type; /* Type of PHY connected */ |
980 | lp->phy_address = phy_address; /* MDI address of PHY */ | 1018 | lp->phy_address = phy_address; /* MDI address of PHY */ |
@@ -992,11 +1030,18 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add | |||
992 | /* Determine current link speed */ | 1030 | /* Determine current link speed */ |
993 | spin_lock_irq(&lp->lock); | 1031 | spin_lock_irq(&lp->lock); |
994 | enable_mdi(); | 1032 | enable_mdi(); |
995 | update_linkspeed(dev); | 1033 | update_linkspeed(dev, 0); |
996 | disable_mdi(); | 1034 | disable_mdi(); |
997 | spin_unlock_irq(&lp->lock); | 1035 | spin_unlock_irq(&lp->lock); |
998 | netif_carrier_off(dev); /* will be enabled in open() */ | 1036 | netif_carrier_off(dev); /* will be enabled in open() */ |
999 | 1037 | ||
1038 | /* If board has no PHY IRQ, use a timer to poll the PHY */ | ||
1039 | if (!lp->board_data.phy_irq_pin) { | ||
1040 | init_timer(&check_timer); | ||
1041 | check_timer.data = (unsigned long)dev; | ||
1042 | check_timer.function = at91ether_check_link; | ||
1043 | } | ||
1044 | |||
1000 | /* Display ethernet banner */ | 1045 | /* Display ethernet banner */ |
1001 | printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%02x:%02x:%02x:%02x:%02x:%02x)\n", | 1046 | printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%02x:%02x:%02x:%02x:%02x:%02x)\n", |
1002 | dev->name, (uint) dev->base_addr, dev->irq, | 1047 | dev->name, (uint) dev->base_addr, dev->irq, |
@@ -1005,7 +1050,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add | |||
1005 | dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], | 1050 | dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], |
1006 | dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); | 1051 | dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); |
1007 | if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) | 1052 | if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) |
1008 | printk(KERN_INFO "%s: Davicom 9196 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)"); | 1053 | printk(KERN_INFO "%s: Davicom 9161 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)"); |
1009 | else if (phy_type == MII_LXT971A_ID) | 1054 | else if (phy_type == MII_LXT971A_ID) |
1010 | printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name); | 1055 | printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name); |
1011 | else if (phy_type == MII_RTL8201_ID) | 1056 | else if (phy_type == MII_RTL8201_ID) |
@@ -1031,9 +1076,10 @@ static int __init at91ether_probe(struct platform_device *pdev) | |||
1031 | int detected = -1; | 1076 | int detected = -1; |
1032 | unsigned long phy_id; | 1077 | unsigned long phy_id; |
1033 | unsigned short phy_address = 0; | 1078 | unsigned short phy_address = 0; |
1079 | struct clk *ether_clk; | ||
1034 | 1080 | ||
1035 | ether_clk = clk_get(&pdev->dev, "ether_clk"); | 1081 | ether_clk = clk_get(&pdev->dev, "ether_clk"); |
1036 | if (!ether_clk) { | 1082 | if (IS_ERR(ether_clk)) { |
1037 | printk(KERN_ERR "at91_ether: no clock defined\n"); | 1083 | printk(KERN_ERR "at91_ether: no clock defined\n"); |
1038 | return -ENODEV; | 1084 | return -ENODEV; |
1039 | } | 1085 | } |
@@ -1056,7 +1102,7 @@ static int __init at91ether_probe(struct platform_device *pdev) | |||
1056 | case MII_DP83847_ID: /* National Semiconductor DP83847: */ | 1102 | case MII_DP83847_ID: /* National Semiconductor DP83847: */ |
1057 | case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */ | 1103 | case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */ |
1058 | case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */ | 1104 | case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */ |
1059 | detected = at91ether_setup(phy_id, phy_address, pdev); | 1105 | detected = at91ether_setup(phy_id, phy_address, pdev, ether_clk); |
1060 | break; | 1106 | break; |
1061 | } | 1107 | } |
1062 | 1108 | ||
@@ -1075,17 +1121,61 @@ static int __devexit at91ether_remove(struct platform_device *pdev) | |||
1075 | unregister_netdev(at91_dev); | 1121 | unregister_netdev(at91_dev); |
1076 | free_irq(at91_dev->irq, at91_dev); | 1122 | free_irq(at91_dev->irq, at91_dev); |
1077 | dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); | 1123 | dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); |
1078 | clk_put(ether_clk); | 1124 | clk_put(lp->ether_clk); |
1079 | 1125 | ||
1080 | free_netdev(at91_dev); | 1126 | free_netdev(at91_dev); |
1081 | at91_dev = NULL; | 1127 | at91_dev = NULL; |
1082 | return 0; | 1128 | return 0; |
1083 | } | 1129 | } |
1084 | 1130 | ||
1131 | #ifdef CONFIG_PM | ||
1132 | |||
1133 | static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg) | ||
1134 | { | ||
1135 | struct at91_private *lp = (struct at91_private *) at91_dev->priv; | ||
1136 | struct net_device *net_dev = platform_get_drvdata(pdev); | ||
1137 | int phy_irq = lp->board_data.phy_irq_pin; | ||
1138 | |||
1139 | if (netif_running(net_dev)) { | ||
1140 | if (phy_irq) | ||
1141 | disable_irq(phy_irq); | ||
1142 | |||
1143 | netif_stop_queue(net_dev); | ||
1144 | netif_device_detach(net_dev); | ||
1145 | |||
1146 | clk_disable(lp->ether_clk); | ||
1147 | } | ||
1148 | return 0; | ||
1149 | } | ||
1150 | |||
1151 | static int at91ether_resume(struct platform_device *pdev) | ||
1152 | { | ||
1153 | struct at91_private *lp = (struct at91_private *) at91_dev->priv; | ||
1154 | struct net_device *net_dev = platform_get_drvdata(pdev); | ||
1155 | int phy_irq = lp->board_data.phy_irq_pin; | ||
1156 | |||
1157 | if (netif_running(net_dev)) { | ||
1158 | clk_enable(lp->ether_clk); | ||
1159 | |||
1160 | netif_device_attach(net_dev); | ||
1161 | netif_start_queue(net_dev); | ||
1162 | |||
1163 | if (phy_irq) | ||
1164 | enable_irq(phy_irq); | ||
1165 | } | ||
1166 | return 0; | ||
1167 | } | ||
1168 | |||
1169 | #else | ||
1170 | #define at91ether_suspend NULL | ||
1171 | #define at91ether_resume NULL | ||
1172 | #endif | ||
1173 | |||
1085 | static struct platform_driver at91ether_driver = { | 1174 | static struct platform_driver at91ether_driver = { |
1086 | .probe = at91ether_probe, | 1175 | .probe = at91ether_probe, |
1087 | .remove = __devexit_p(at91ether_remove), | 1176 | .remove = __devexit_p(at91ether_remove), |
1088 | /* FIXME: support suspend and resume */ | 1177 | .suspend = at91ether_suspend, |
1178 | .resume = at91ether_resume, | ||
1089 | .driver = { | 1179 | .driver = { |
1090 | .name = DRV_NAME, | 1180 | .name = DRV_NAME, |
1091 | .owner = THIS_MODULE, | 1181 | .owner = THIS_MODULE, |
diff --git a/drivers/net/arm/at91_ether.h b/drivers/net/arm/at91_ether.h index 9885735c9c8a..d1e72e02be3a 100644 --- a/drivers/net/arm/at91_ether.h +++ b/drivers/net/arm/at91_ether.h | |||
@@ -80,6 +80,7 @@ struct at91_private | |||
80 | struct net_device_stats stats; | 80 | struct net_device_stats stats; |
81 | struct mii_if_info mii; /* ethtool support */ | 81 | struct mii_if_info mii; /* ethtool support */ |
82 | struct at91_eth_data board_data; /* board-specific configuration */ | 82 | struct at91_eth_data board_data; /* board-specific configuration */ |
83 | struct clk *ether_clk; /* clock */ | ||
83 | 84 | ||
84 | /* PHY */ | 85 | /* PHY */ |
85 | unsigned long phy_type; /* type of PHY (PHY_ID) */ | 86 | unsigned long phy_type; /* type of PHY (PHY_ID) */ |
diff --git a/drivers/net/b44.c b/drivers/net/b44.c index d8233e0b7899..a7e4ba5a580f 100644 --- a/drivers/net/b44.c +++ b/drivers/net/b44.c | |||
@@ -29,8 +29,8 @@ | |||
29 | 29 | ||
30 | #define DRV_MODULE_NAME "b44" | 30 | #define DRV_MODULE_NAME "b44" |
31 | #define PFX DRV_MODULE_NAME ": " | 31 | #define PFX DRV_MODULE_NAME ": " |
32 | #define DRV_MODULE_VERSION "1.00" | 32 | #define DRV_MODULE_VERSION "1.01" |
33 | #define DRV_MODULE_RELDATE "Apr 7, 2006" | 33 | #define DRV_MODULE_RELDATE "Jun 16, 2006" |
34 | 34 | ||
35 | #define B44_DEF_MSG_ENABLE \ | 35 | #define B44_DEF_MSG_ENABLE \ |
36 | (NETIF_MSG_DRV | \ | 36 | (NETIF_MSG_DRV | \ |
@@ -75,6 +75,15 @@ | |||
75 | /* minimum number of free TX descriptors required to wake up TX process */ | 75 | /* minimum number of free TX descriptors required to wake up TX process */ |
76 | #define B44_TX_WAKEUP_THRESH (B44_TX_RING_SIZE / 4) | 76 | #define B44_TX_WAKEUP_THRESH (B44_TX_RING_SIZE / 4) |
77 | 77 | ||
78 | /* b44 internal pattern match filter info */ | ||
79 | #define B44_PATTERN_BASE 0x400 | ||
80 | #define B44_PATTERN_SIZE 0x80 | ||
81 | #define B44_PMASK_BASE 0x600 | ||
82 | #define B44_PMASK_SIZE 0x10 | ||
83 | #define B44_MAX_PATTERNS 16 | ||
84 | #define B44_ETHIPV6UDP_HLEN 62 | ||
85 | #define B44_ETHIPV4UDP_HLEN 42 | ||
86 | |||
78 | static char version[] __devinitdata = | 87 | static char version[] __devinitdata = |
79 | DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; | 88 | DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; |
80 | 89 | ||
@@ -101,7 +110,7 @@ MODULE_DEVICE_TABLE(pci, b44_pci_tbl); | |||
101 | 110 | ||
102 | static void b44_halt(struct b44 *); | 111 | static void b44_halt(struct b44 *); |
103 | static void b44_init_rings(struct b44 *); | 112 | static void b44_init_rings(struct b44 *); |
104 | static void b44_init_hw(struct b44 *); | 113 | static void b44_init_hw(struct b44 *, int); |
105 | 114 | ||
106 | static int dma_desc_align_mask; | 115 | static int dma_desc_align_mask; |
107 | static int dma_desc_sync_size; | 116 | static int dma_desc_sync_size; |
@@ -873,7 +882,7 @@ static int b44_poll(struct net_device *netdev, int *budget) | |||
873 | spin_lock_irq(&bp->lock); | 882 | spin_lock_irq(&bp->lock); |
874 | b44_halt(bp); | 883 | b44_halt(bp); |
875 | b44_init_rings(bp); | 884 | b44_init_rings(bp); |
876 | b44_init_hw(bp); | 885 | b44_init_hw(bp, 1); |
877 | netif_wake_queue(bp->dev); | 886 | netif_wake_queue(bp->dev); |
878 | spin_unlock_irq(&bp->lock); | 887 | spin_unlock_irq(&bp->lock); |
879 | done = 1; | 888 | done = 1; |
@@ -942,7 +951,7 @@ static void b44_tx_timeout(struct net_device *dev) | |||
942 | 951 | ||
943 | b44_halt(bp); | 952 | b44_halt(bp); |
944 | b44_init_rings(bp); | 953 | b44_init_rings(bp); |
945 | b44_init_hw(bp); | 954 | b44_init_hw(bp, 1); |
946 | 955 | ||
947 | spin_unlock_irq(&bp->lock); | 956 | spin_unlock_irq(&bp->lock); |
948 | 957 | ||
@@ -1059,7 +1068,7 @@ static int b44_change_mtu(struct net_device *dev, int new_mtu) | |||
1059 | b44_halt(bp); | 1068 | b44_halt(bp); |
1060 | dev->mtu = new_mtu; | 1069 | dev->mtu = new_mtu; |
1061 | b44_init_rings(bp); | 1070 | b44_init_rings(bp); |
1062 | b44_init_hw(bp); | 1071 | b44_init_hw(bp, 1); |
1063 | spin_unlock_irq(&bp->lock); | 1072 | spin_unlock_irq(&bp->lock); |
1064 | 1073 | ||
1065 | b44_enable_ints(bp); | 1074 | b44_enable_ints(bp); |
@@ -1356,13 +1365,15 @@ static int b44_set_mac_addr(struct net_device *dev, void *p) | |||
1356 | * packet processing. Invoked with bp->lock held. | 1365 | * packet processing. Invoked with bp->lock held. |
1357 | */ | 1366 | */ |
1358 | static void __b44_set_rx_mode(struct net_device *); | 1367 | static void __b44_set_rx_mode(struct net_device *); |
1359 | static void b44_init_hw(struct b44 *bp) | 1368 | static void b44_init_hw(struct b44 *bp, int full_reset) |
1360 | { | 1369 | { |
1361 | u32 val; | 1370 | u32 val; |
1362 | 1371 | ||
1363 | b44_chip_reset(bp); | 1372 | b44_chip_reset(bp); |
1364 | b44_phy_reset(bp); | 1373 | if (full_reset) { |
1365 | b44_setup_phy(bp); | 1374 | b44_phy_reset(bp); |
1375 | b44_setup_phy(bp); | ||
1376 | } | ||
1366 | 1377 | ||
1367 | /* Enable CRC32, set proper LED modes and power on PHY */ | 1378 | /* Enable CRC32, set proper LED modes and power on PHY */ |
1368 | bw32(bp, B44_MAC_CTRL, MAC_CTRL_CRC32_ENAB | MAC_CTRL_PHY_LEDCTRL); | 1379 | bw32(bp, B44_MAC_CTRL, MAC_CTRL_CRC32_ENAB | MAC_CTRL_PHY_LEDCTRL); |
@@ -1376,16 +1387,21 @@ static void b44_init_hw(struct b44 *bp) | |||
1376 | bw32(bp, B44_TXMAXLEN, bp->dev->mtu + ETH_HLEN + 8 + RX_HEADER_LEN); | 1387 | bw32(bp, B44_TXMAXLEN, bp->dev->mtu + ETH_HLEN + 8 + RX_HEADER_LEN); |
1377 | 1388 | ||
1378 | bw32(bp, B44_TX_WMARK, 56); /* XXX magic */ | 1389 | bw32(bp, B44_TX_WMARK, 56); /* XXX magic */ |
1379 | bw32(bp, B44_DMATX_CTRL, DMATX_CTRL_ENABLE); | 1390 | if (full_reset) { |
1380 | bw32(bp, B44_DMATX_ADDR, bp->tx_ring_dma + bp->dma_offset); | 1391 | bw32(bp, B44_DMATX_CTRL, DMATX_CTRL_ENABLE); |
1381 | bw32(bp, B44_DMARX_CTRL, (DMARX_CTRL_ENABLE | | 1392 | bw32(bp, B44_DMATX_ADDR, bp->tx_ring_dma + bp->dma_offset); |
1382 | (bp->rx_offset << DMARX_CTRL_ROSHIFT))); | 1393 | bw32(bp, B44_DMARX_CTRL, (DMARX_CTRL_ENABLE | |
1383 | bw32(bp, B44_DMARX_ADDR, bp->rx_ring_dma + bp->dma_offset); | 1394 | (bp->rx_offset << DMARX_CTRL_ROSHIFT))); |
1395 | bw32(bp, B44_DMARX_ADDR, bp->rx_ring_dma + bp->dma_offset); | ||
1384 | 1396 | ||
1385 | bw32(bp, B44_DMARX_PTR, bp->rx_pending); | 1397 | bw32(bp, B44_DMARX_PTR, bp->rx_pending); |
1386 | bp->rx_prod = bp->rx_pending; | 1398 | bp->rx_prod = bp->rx_pending; |
1387 | 1399 | ||
1388 | bw32(bp, B44_MIB_CTRL, MIB_CTRL_CLR_ON_READ); | 1400 | bw32(bp, B44_MIB_CTRL, MIB_CTRL_CLR_ON_READ); |
1401 | } else { | ||
1402 | bw32(bp, B44_DMARX_CTRL, (DMARX_CTRL_ENABLE | | ||
1403 | (bp->rx_offset << DMARX_CTRL_ROSHIFT))); | ||
1404 | } | ||
1389 | 1405 | ||
1390 | val = br32(bp, B44_ENET_CTRL); | 1406 | val = br32(bp, B44_ENET_CTRL); |
1391 | bw32(bp, B44_ENET_CTRL, (val | ENET_CTRL_ENABLE)); | 1407 | bw32(bp, B44_ENET_CTRL, (val | ENET_CTRL_ENABLE)); |
@@ -1401,7 +1417,7 @@ static int b44_open(struct net_device *dev) | |||
1401 | goto out; | 1417 | goto out; |
1402 | 1418 | ||
1403 | b44_init_rings(bp); | 1419 | b44_init_rings(bp); |
1404 | b44_init_hw(bp); | 1420 | b44_init_hw(bp, 1); |
1405 | 1421 | ||
1406 | b44_check_phy(bp); | 1422 | b44_check_phy(bp); |
1407 | 1423 | ||
@@ -1450,6 +1466,140 @@ static void b44_poll_controller(struct net_device *dev) | |||
1450 | } | 1466 | } |
1451 | #endif | 1467 | #endif |
1452 | 1468 | ||
1469 | static void bwfilter_table(struct b44 *bp, u8 *pp, u32 bytes, u32 table_offset) | ||
1470 | { | ||
1471 | u32 i; | ||
1472 | u32 *pattern = (u32 *) pp; | ||
1473 | |||
1474 | for (i = 0; i < bytes; i += sizeof(u32)) { | ||
1475 | bw32(bp, B44_FILT_ADDR, table_offset + i); | ||
1476 | bw32(bp, B44_FILT_DATA, pattern[i / sizeof(u32)]); | ||
1477 | } | ||
1478 | } | ||
1479 | |||
1480 | static int b44_magic_pattern(u8 *macaddr, u8 *ppattern, u8 *pmask, int offset) | ||
1481 | { | ||
1482 | int magicsync = 6; | ||
1483 | int k, j, len = offset; | ||
1484 | int ethaddr_bytes = ETH_ALEN; | ||
1485 | |||
1486 | memset(ppattern + offset, 0xff, magicsync); | ||
1487 | for (j = 0; j < magicsync; j++) | ||
1488 | set_bit(len++, (unsigned long *) pmask); | ||
1489 | |||
1490 | for (j = 0; j < B44_MAX_PATTERNS; j++) { | ||
1491 | if ((B44_PATTERN_SIZE - len) >= ETH_ALEN) | ||
1492 | ethaddr_bytes = ETH_ALEN; | ||
1493 | else | ||
1494 | ethaddr_bytes = B44_PATTERN_SIZE - len; | ||
1495 | if (ethaddr_bytes <=0) | ||
1496 | break; | ||
1497 | for (k = 0; k< ethaddr_bytes; k++) { | ||
1498 | ppattern[offset + magicsync + | ||
1499 | (j * ETH_ALEN) + k] = macaddr[k]; | ||
1500 | len++; | ||
1501 | set_bit(len, (unsigned long *) pmask); | ||
1502 | } | ||
1503 | } | ||
1504 | return len - 1; | ||
1505 | } | ||
1506 | |||
1507 | /* Setup magic packet patterns in the b44 WOL | ||
1508 | * pattern matching filter. | ||
1509 | */ | ||
1510 | static void b44_setup_pseudo_magicp(struct b44 *bp) | ||
1511 | { | ||
1512 | |||
1513 | u32 val; | ||
1514 | int plen0, plen1, plen2; | ||
1515 | u8 *pwol_pattern; | ||
1516 | u8 pwol_mask[B44_PMASK_SIZE]; | ||
1517 | |||
1518 | pwol_pattern = kmalloc(B44_PATTERN_SIZE, GFP_KERNEL); | ||
1519 | if (!pwol_pattern) { | ||
1520 | printk(KERN_ERR PFX "Memory not available for WOL\n"); | ||
1521 | return; | ||
1522 | } | ||
1523 | |||
1524 | /* Ipv4 magic packet pattern - pattern 0.*/ | ||
1525 | memset(pwol_pattern, 0, B44_PATTERN_SIZE); | ||
1526 | memset(pwol_mask, 0, B44_PMASK_SIZE); | ||
1527 | plen0 = b44_magic_pattern(bp->dev->dev_addr, pwol_pattern, pwol_mask, | ||
1528 | B44_ETHIPV4UDP_HLEN); | ||
1529 | |||
1530 | bwfilter_table(bp, pwol_pattern, B44_PATTERN_SIZE, B44_PATTERN_BASE); | ||
1531 | bwfilter_table(bp, pwol_mask, B44_PMASK_SIZE, B44_PMASK_BASE); | ||
1532 | |||
1533 | /* Raw ethernet II magic packet pattern - pattern 1 */ | ||
1534 | memset(pwol_pattern, 0, B44_PATTERN_SIZE); | ||
1535 | memset(pwol_mask, 0, B44_PMASK_SIZE); | ||
1536 | plen1 = b44_magic_pattern(bp->dev->dev_addr, pwol_pattern, pwol_mask, | ||
1537 | ETH_HLEN); | ||
1538 | |||
1539 | bwfilter_table(bp, pwol_pattern, B44_PATTERN_SIZE, | ||
1540 | B44_PATTERN_BASE + B44_PATTERN_SIZE); | ||
1541 | bwfilter_table(bp, pwol_mask, B44_PMASK_SIZE, | ||
1542 | B44_PMASK_BASE + B44_PMASK_SIZE); | ||
1543 | |||
1544 | /* Ipv6 magic packet pattern - pattern 2 */ | ||
1545 | memset(pwol_pattern, 0, B44_PATTERN_SIZE); | ||
1546 | memset(pwol_mask, 0, B44_PMASK_SIZE); | ||
1547 | plen2 = b44_magic_pattern(bp->dev->dev_addr, pwol_pattern, pwol_mask, | ||
1548 | B44_ETHIPV6UDP_HLEN); | ||
1549 | |||
1550 | bwfilter_table(bp, pwol_pattern, B44_PATTERN_SIZE, | ||
1551 | B44_PATTERN_BASE + B44_PATTERN_SIZE + B44_PATTERN_SIZE); | ||
1552 | bwfilter_table(bp, pwol_mask, B44_PMASK_SIZE, | ||
1553 | B44_PMASK_BASE + B44_PMASK_SIZE + B44_PMASK_SIZE); | ||
1554 | |||
1555 | kfree(pwol_pattern); | ||
1556 | |||
1557 | /* set these pattern's lengths: one less than each real length */ | ||
1558 | val = plen0 | (plen1 << 8) | (plen2 << 16) | WKUP_LEN_ENABLE_THREE; | ||
1559 | bw32(bp, B44_WKUP_LEN, val); | ||
1560 | |||
1561 | /* enable wakeup pattern matching */ | ||
1562 | val = br32(bp, B44_DEVCTRL); | ||
1563 | bw32(bp, B44_DEVCTRL, val | DEVCTRL_PFE); | ||
1564 | |||
1565 | } | ||
1566 | |||
1567 | static void b44_setup_wol(struct b44 *bp) | ||
1568 | { | ||
1569 | u32 val; | ||
1570 | u16 pmval; | ||
1571 | |||
1572 | bw32(bp, B44_RXCONFIG, RXCONFIG_ALLMULTI); | ||
1573 | |||
1574 | if (bp->flags & B44_FLAG_B0_ANDLATER) { | ||
1575 | |||
1576 | bw32(bp, B44_WKUP_LEN, WKUP_LEN_DISABLE); | ||
1577 | |||
1578 | val = bp->dev->dev_addr[2] << 24 | | ||
1579 | bp->dev->dev_addr[3] << 16 | | ||
1580 | bp->dev->dev_addr[4] << 8 | | ||
1581 | bp->dev->dev_addr[5]; | ||
1582 | bw32(bp, B44_ADDR_LO, val); | ||
1583 | |||
1584 | val = bp->dev->dev_addr[0] << 8 | | ||
1585 | bp->dev->dev_addr[1]; | ||
1586 | bw32(bp, B44_ADDR_HI, val); | ||
1587 | |||
1588 | val = br32(bp, B44_DEVCTRL); | ||
1589 | bw32(bp, B44_DEVCTRL, val | DEVCTRL_MPM | DEVCTRL_PFE); | ||
1590 | |||
1591 | } else { | ||
1592 | b44_setup_pseudo_magicp(bp); | ||
1593 | } | ||
1594 | |||
1595 | val = br32(bp, B44_SBTMSLOW); | ||
1596 | bw32(bp, B44_SBTMSLOW, val | SBTMSLOW_PE); | ||
1597 | |||
1598 | pci_read_config_word(bp->pdev, SSB_PMCSR, &pmval); | ||
1599 | pci_write_config_word(bp->pdev, SSB_PMCSR, pmval | SSB_PE); | ||
1600 | |||
1601 | } | ||
1602 | |||
1453 | static int b44_close(struct net_device *dev) | 1603 | static int b44_close(struct net_device *dev) |
1454 | { | 1604 | { |
1455 | struct b44 *bp = netdev_priv(dev); | 1605 | struct b44 *bp = netdev_priv(dev); |
@@ -1475,6 +1625,11 @@ static int b44_close(struct net_device *dev) | |||
1475 | 1625 | ||
1476 | netif_poll_enable(dev); | 1626 | netif_poll_enable(dev); |
1477 | 1627 | ||
1628 | if (bp->flags & B44_FLAG_WOL_ENABLE) { | ||
1629 | b44_init_hw(bp, 0); | ||
1630 | b44_setup_wol(bp); | ||
1631 | } | ||
1632 | |||
1478 | b44_free_consistent(bp); | 1633 | b44_free_consistent(bp); |
1479 | 1634 | ||
1480 | return 0; | 1635 | return 0; |
@@ -1620,8 +1775,6 @@ static int b44_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1620 | { | 1775 | { |
1621 | struct b44 *bp = netdev_priv(dev); | 1776 | struct b44 *bp = netdev_priv(dev); |
1622 | 1777 | ||
1623 | if (!netif_running(dev)) | ||
1624 | return -EAGAIN; | ||
1625 | cmd->supported = (SUPPORTED_Autoneg); | 1778 | cmd->supported = (SUPPORTED_Autoneg); |
1626 | cmd->supported |= (SUPPORTED_100baseT_Half | | 1779 | cmd->supported |= (SUPPORTED_100baseT_Half | |
1627 | SUPPORTED_100baseT_Full | | 1780 | SUPPORTED_100baseT_Full | |
@@ -1649,6 +1802,12 @@ static int b44_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1649 | XCVR_INTERNAL : XCVR_EXTERNAL; | 1802 | XCVR_INTERNAL : XCVR_EXTERNAL; |
1650 | cmd->autoneg = (bp->flags & B44_FLAG_FORCE_LINK) ? | 1803 | cmd->autoneg = (bp->flags & B44_FLAG_FORCE_LINK) ? |
1651 | AUTONEG_DISABLE : AUTONEG_ENABLE; | 1804 | AUTONEG_DISABLE : AUTONEG_ENABLE; |
1805 | if (cmd->autoneg == AUTONEG_ENABLE) | ||
1806 | cmd->advertising |= ADVERTISED_Autoneg; | ||
1807 | if (!netif_running(dev)){ | ||
1808 | cmd->speed = 0; | ||
1809 | cmd->duplex = 0xff; | ||
1810 | } | ||
1652 | cmd->maxtxpkt = 0; | 1811 | cmd->maxtxpkt = 0; |
1653 | cmd->maxrxpkt = 0; | 1812 | cmd->maxrxpkt = 0; |
1654 | return 0; | 1813 | return 0; |
@@ -1658,9 +1817,6 @@ static int b44_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1658 | { | 1817 | { |
1659 | struct b44 *bp = netdev_priv(dev); | 1818 | struct b44 *bp = netdev_priv(dev); |
1660 | 1819 | ||
1661 | if (!netif_running(dev)) | ||
1662 | return -EAGAIN; | ||
1663 | |||
1664 | /* We do not support gigabit. */ | 1820 | /* We do not support gigabit. */ |
1665 | if (cmd->autoneg == AUTONEG_ENABLE) { | 1821 | if (cmd->autoneg == AUTONEG_ENABLE) { |
1666 | if (cmd->advertising & | 1822 | if (cmd->advertising & |
@@ -1677,28 +1833,39 @@ static int b44_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1677 | spin_lock_irq(&bp->lock); | 1833 | spin_lock_irq(&bp->lock); |
1678 | 1834 | ||
1679 | if (cmd->autoneg == AUTONEG_ENABLE) { | 1835 | if (cmd->autoneg == AUTONEG_ENABLE) { |
1680 | bp->flags &= ~B44_FLAG_FORCE_LINK; | 1836 | bp->flags &= ~(B44_FLAG_FORCE_LINK | |
1681 | bp->flags &= ~(B44_FLAG_ADV_10HALF | | 1837 | B44_FLAG_100_BASE_T | |
1838 | B44_FLAG_FULL_DUPLEX | | ||
1839 | B44_FLAG_ADV_10HALF | | ||
1682 | B44_FLAG_ADV_10FULL | | 1840 | B44_FLAG_ADV_10FULL | |
1683 | B44_FLAG_ADV_100HALF | | 1841 | B44_FLAG_ADV_100HALF | |
1684 | B44_FLAG_ADV_100FULL); | 1842 | B44_FLAG_ADV_100FULL); |
1685 | if (cmd->advertising & ADVERTISE_10HALF) | 1843 | if (cmd->advertising == 0) { |
1686 | bp->flags |= B44_FLAG_ADV_10HALF; | 1844 | bp->flags |= (B44_FLAG_ADV_10HALF | |
1687 | if (cmd->advertising & ADVERTISE_10FULL) | 1845 | B44_FLAG_ADV_10FULL | |
1688 | bp->flags |= B44_FLAG_ADV_10FULL; | 1846 | B44_FLAG_ADV_100HALF | |
1689 | if (cmd->advertising & ADVERTISE_100HALF) | 1847 | B44_FLAG_ADV_100FULL); |
1690 | bp->flags |= B44_FLAG_ADV_100HALF; | 1848 | } else { |
1691 | if (cmd->advertising & ADVERTISE_100FULL) | 1849 | if (cmd->advertising & ADVERTISED_10baseT_Half) |
1692 | bp->flags |= B44_FLAG_ADV_100FULL; | 1850 | bp->flags |= B44_FLAG_ADV_10HALF; |
1851 | if (cmd->advertising & ADVERTISED_10baseT_Full) | ||
1852 | bp->flags |= B44_FLAG_ADV_10FULL; | ||
1853 | if (cmd->advertising & ADVERTISED_100baseT_Half) | ||
1854 | bp->flags |= B44_FLAG_ADV_100HALF; | ||
1855 | if (cmd->advertising & ADVERTISED_100baseT_Full) | ||
1856 | bp->flags |= B44_FLAG_ADV_100FULL; | ||
1857 | } | ||
1693 | } else { | 1858 | } else { |
1694 | bp->flags |= B44_FLAG_FORCE_LINK; | 1859 | bp->flags |= B44_FLAG_FORCE_LINK; |
1860 | bp->flags &= ~(B44_FLAG_100_BASE_T | B44_FLAG_FULL_DUPLEX); | ||
1695 | if (cmd->speed == SPEED_100) | 1861 | if (cmd->speed == SPEED_100) |
1696 | bp->flags |= B44_FLAG_100_BASE_T; | 1862 | bp->flags |= B44_FLAG_100_BASE_T; |
1697 | if (cmd->duplex == DUPLEX_FULL) | 1863 | if (cmd->duplex == DUPLEX_FULL) |
1698 | bp->flags |= B44_FLAG_FULL_DUPLEX; | 1864 | bp->flags |= B44_FLAG_FULL_DUPLEX; |
1699 | } | 1865 | } |
1700 | 1866 | ||
1701 | b44_setup_phy(bp); | 1867 | if (netif_running(dev)) |
1868 | b44_setup_phy(bp); | ||
1702 | 1869 | ||
1703 | spin_unlock_irq(&bp->lock); | 1870 | spin_unlock_irq(&bp->lock); |
1704 | 1871 | ||
@@ -1734,7 +1901,7 @@ static int b44_set_ringparam(struct net_device *dev, | |||
1734 | 1901 | ||
1735 | b44_halt(bp); | 1902 | b44_halt(bp); |
1736 | b44_init_rings(bp); | 1903 | b44_init_rings(bp); |
1737 | b44_init_hw(bp); | 1904 | b44_init_hw(bp, 1); |
1738 | netif_wake_queue(bp->dev); | 1905 | netif_wake_queue(bp->dev); |
1739 | spin_unlock_irq(&bp->lock); | 1906 | spin_unlock_irq(&bp->lock); |
1740 | 1907 | ||
@@ -1777,7 +1944,7 @@ static int b44_set_pauseparam(struct net_device *dev, | |||
1777 | if (bp->flags & B44_FLAG_PAUSE_AUTO) { | 1944 | if (bp->flags & B44_FLAG_PAUSE_AUTO) { |
1778 | b44_halt(bp); | 1945 | b44_halt(bp); |
1779 | b44_init_rings(bp); | 1946 | b44_init_rings(bp); |
1780 | b44_init_hw(bp); | 1947 | b44_init_hw(bp, 1); |
1781 | } else { | 1948 | } else { |
1782 | __b44_set_flow_ctrl(bp, bp->flags); | 1949 | __b44_set_flow_ctrl(bp, bp->flags); |
1783 | } | 1950 | } |
@@ -1819,12 +1986,40 @@ static void b44_get_ethtool_stats(struct net_device *dev, | |||
1819 | spin_unlock_irq(&bp->lock); | 1986 | spin_unlock_irq(&bp->lock); |
1820 | } | 1987 | } |
1821 | 1988 | ||
1989 | static void b44_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | ||
1990 | { | ||
1991 | struct b44 *bp = netdev_priv(dev); | ||
1992 | |||
1993 | wol->supported = WAKE_MAGIC; | ||
1994 | if (bp->flags & B44_FLAG_WOL_ENABLE) | ||
1995 | wol->wolopts = WAKE_MAGIC; | ||
1996 | else | ||
1997 | wol->wolopts = 0; | ||
1998 | memset(&wol->sopass, 0, sizeof(wol->sopass)); | ||
1999 | } | ||
2000 | |||
2001 | static int b44_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | ||
2002 | { | ||
2003 | struct b44 *bp = netdev_priv(dev); | ||
2004 | |||
2005 | spin_lock_irq(&bp->lock); | ||
2006 | if (wol->wolopts & WAKE_MAGIC) | ||
2007 | bp->flags |= B44_FLAG_WOL_ENABLE; | ||
2008 | else | ||
2009 | bp->flags &= ~B44_FLAG_WOL_ENABLE; | ||
2010 | spin_unlock_irq(&bp->lock); | ||
2011 | |||
2012 | return 0; | ||
2013 | } | ||
2014 | |||
1822 | static struct ethtool_ops b44_ethtool_ops = { | 2015 | static struct ethtool_ops b44_ethtool_ops = { |
1823 | .get_drvinfo = b44_get_drvinfo, | 2016 | .get_drvinfo = b44_get_drvinfo, |
1824 | .get_settings = b44_get_settings, | 2017 | .get_settings = b44_get_settings, |
1825 | .set_settings = b44_set_settings, | 2018 | .set_settings = b44_set_settings, |
1826 | .nway_reset = b44_nway_reset, | 2019 | .nway_reset = b44_nway_reset, |
1827 | .get_link = ethtool_op_get_link, | 2020 | .get_link = ethtool_op_get_link, |
2021 | .get_wol = b44_get_wol, | ||
2022 | .set_wol = b44_set_wol, | ||
1828 | .get_ringparam = b44_get_ringparam, | 2023 | .get_ringparam = b44_get_ringparam, |
1829 | .set_ringparam = b44_set_ringparam, | 2024 | .set_ringparam = b44_set_ringparam, |
1830 | .get_pauseparam = b44_get_pauseparam, | 2025 | .get_pauseparam = b44_get_pauseparam, |
@@ -1903,6 +2098,10 @@ static int __devinit b44_get_invariants(struct b44 *bp) | |||
1903 | /* XXX - really required? | 2098 | /* XXX - really required? |
1904 | bp->flags |= B44_FLAG_BUGGY_TXPTR; | 2099 | bp->flags |= B44_FLAG_BUGGY_TXPTR; |
1905 | */ | 2100 | */ |
2101 | |||
2102 | if (ssb_get_core_rev(bp) >= 7) | ||
2103 | bp->flags |= B44_FLAG_B0_ANDLATER; | ||
2104 | |||
1906 | out: | 2105 | out: |
1907 | return err; | 2106 | return err; |
1908 | } | 2107 | } |
@@ -2103,6 +2302,10 @@ static int b44_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2103 | spin_unlock_irq(&bp->lock); | 2302 | spin_unlock_irq(&bp->lock); |
2104 | 2303 | ||
2105 | free_irq(dev->irq, dev); | 2304 | free_irq(dev->irq, dev); |
2305 | if (bp->flags & B44_FLAG_WOL_ENABLE) { | ||
2306 | b44_init_hw(bp, 0); | ||
2307 | b44_setup_wol(bp); | ||
2308 | } | ||
2106 | pci_disable_device(pdev); | 2309 | pci_disable_device(pdev); |
2107 | return 0; | 2310 | return 0; |
2108 | } | 2311 | } |
@@ -2125,7 +2328,7 @@ static int b44_resume(struct pci_dev *pdev) | |||
2125 | spin_lock_irq(&bp->lock); | 2328 | spin_lock_irq(&bp->lock); |
2126 | 2329 | ||
2127 | b44_init_rings(bp); | 2330 | b44_init_rings(bp); |
2128 | b44_init_hw(bp); | 2331 | b44_init_hw(bp, 1); |
2129 | netif_device_attach(bp->dev); | 2332 | netif_device_attach(bp->dev); |
2130 | spin_unlock_irq(&bp->lock); | 2333 | spin_unlock_irq(&bp->lock); |
2131 | 2334 | ||
diff --git a/drivers/net/b44.h b/drivers/net/b44.h index b178662978f3..4944507fad23 100644 --- a/drivers/net/b44.h +++ b/drivers/net/b44.h | |||
@@ -24,6 +24,9 @@ | |||
24 | #define WKUP_LEN_P3_MASK 0x7f000000 /* Pattern 3 */ | 24 | #define WKUP_LEN_P3_MASK 0x7f000000 /* Pattern 3 */ |
25 | #define WKUP_LEN_P3_SHIFT 24 | 25 | #define WKUP_LEN_P3_SHIFT 24 |
26 | #define WKUP_LEN_D3 0x80000000 | 26 | #define WKUP_LEN_D3 0x80000000 |
27 | #define WKUP_LEN_DISABLE 0x80808080 | ||
28 | #define WKUP_LEN_ENABLE_TWO 0x80800000 | ||
29 | #define WKUP_LEN_ENABLE_THREE 0x80000000 | ||
27 | #define B44_ISTAT 0x0020UL /* Interrupt Status */ | 30 | #define B44_ISTAT 0x0020UL /* Interrupt Status */ |
28 | #define ISTAT_LS 0x00000020 /* Link Change (B0 only) */ | 31 | #define ISTAT_LS 0x00000020 /* Link Change (B0 only) */ |
29 | #define ISTAT_PME 0x00000040 /* Power Management Event */ | 32 | #define ISTAT_PME 0x00000040 /* Power Management Event */ |
@@ -264,6 +267,8 @@ | |||
264 | #define SBIDHIGH_VC_SHIFT 16 | 267 | #define SBIDHIGH_VC_SHIFT 16 |
265 | 268 | ||
266 | /* SSB PCI config space registers. */ | 269 | /* SSB PCI config space registers. */ |
270 | #define SSB_PMCSR 0x44 | ||
271 | #define SSB_PE 0x100 | ||
267 | #define SSB_BAR0_WIN 0x80 | 272 | #define SSB_BAR0_WIN 0x80 |
268 | #define SSB_BAR1_WIN 0x84 | 273 | #define SSB_BAR1_WIN 0x84 |
269 | #define SSB_SPROM_CONTROL 0x88 | 274 | #define SSB_SPROM_CONTROL 0x88 |
@@ -420,6 +425,7 @@ struct b44 { | |||
420 | 425 | ||
421 | u32 dma_offset; | 426 | u32 dma_offset; |
422 | u32 flags; | 427 | u32 flags; |
428 | #define B44_FLAG_B0_ANDLATER 0x00000001 | ||
423 | #define B44_FLAG_BUGGY_TXPTR 0x00000002 | 429 | #define B44_FLAG_BUGGY_TXPTR 0x00000002 |
424 | #define B44_FLAG_REORDER_BUG 0x00000004 | 430 | #define B44_FLAG_REORDER_BUG 0x00000004 |
425 | #define B44_FLAG_PAUSE_AUTO 0x00008000 | 431 | #define B44_FLAG_PAUSE_AUTO 0x00008000 |
@@ -435,6 +441,7 @@ struct b44 { | |||
435 | #define B44_FLAG_INTERNAL_PHY 0x10000000 | 441 | #define B44_FLAG_INTERNAL_PHY 0x10000000 |
436 | #define B44_FLAG_RX_RING_HACK 0x20000000 | 442 | #define B44_FLAG_RX_RING_HACK 0x20000000 |
437 | #define B44_FLAG_TX_RING_HACK 0x40000000 | 443 | #define B44_FLAG_TX_RING_HACK 0x40000000 |
444 | #define B44_FLAG_WOL_ENABLE 0x80000000 | ||
438 | 445 | ||
439 | u32 rx_offset; | 446 | u32 rx_offset; |
440 | 447 | ||
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 04a53f1dfdbd..191383d461d7 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c | |||
@@ -2076,7 +2076,7 @@ static void nv_set_multicast(struct net_device *dev) | |||
2076 | spin_unlock_irq(&np->lock); | 2076 | spin_unlock_irq(&np->lock); |
2077 | } | 2077 | } |
2078 | 2078 | ||
2079 | void nv_update_pause(struct net_device *dev, u32 pause_flags) | 2079 | static void nv_update_pause(struct net_device *dev, u32 pause_flags) |
2080 | { | 2080 | { |
2081 | struct fe_priv *np = netdev_priv(dev); | 2081 | struct fe_priv *np = netdev_priv(dev); |
2082 | u8 __iomem *base = get_hwbase(dev); | 2082 | u8 __iomem *base = get_hwbase(dev); |
@@ -2991,13 +2991,13 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
2991 | netif_carrier_off(dev); | 2991 | netif_carrier_off(dev); |
2992 | if (netif_running(dev)) { | 2992 | if (netif_running(dev)) { |
2993 | nv_disable_irq(dev); | 2993 | nv_disable_irq(dev); |
2994 | spin_lock_bh(&dev->xmit_lock); | 2994 | netif_tx_lock_bh(dev); |
2995 | spin_lock(&np->lock); | 2995 | spin_lock(&np->lock); |
2996 | /* stop engines */ | 2996 | /* stop engines */ |
2997 | nv_stop_rx(dev); | 2997 | nv_stop_rx(dev); |
2998 | nv_stop_tx(dev); | 2998 | nv_stop_tx(dev); |
2999 | spin_unlock(&np->lock); | 2999 | spin_unlock(&np->lock); |
3000 | spin_unlock_bh(&dev->xmit_lock); | 3000 | netif_tx_unlock_bh(dev); |
3001 | } | 3001 | } |
3002 | 3002 | ||
3003 | if (ecmd->autoneg == AUTONEG_ENABLE) { | 3003 | if (ecmd->autoneg == AUTONEG_ENABLE) { |
@@ -3131,13 +3131,13 @@ static int nv_nway_reset(struct net_device *dev) | |||
3131 | netif_carrier_off(dev); | 3131 | netif_carrier_off(dev); |
3132 | if (netif_running(dev)) { | 3132 | if (netif_running(dev)) { |
3133 | nv_disable_irq(dev); | 3133 | nv_disable_irq(dev); |
3134 | spin_lock_bh(&dev->xmit_lock); | 3134 | netif_tx_lock_bh(dev); |
3135 | spin_lock(&np->lock); | 3135 | spin_lock(&np->lock); |
3136 | /* stop engines */ | 3136 | /* stop engines */ |
3137 | nv_stop_rx(dev); | 3137 | nv_stop_rx(dev); |
3138 | nv_stop_tx(dev); | 3138 | nv_stop_tx(dev); |
3139 | spin_unlock(&np->lock); | 3139 | spin_unlock(&np->lock); |
3140 | spin_unlock_bh(&dev->xmit_lock); | 3140 | netif_tx_unlock_bh(dev); |
3141 | printk(KERN_INFO "%s: link down.\n", dev->name); | 3141 | printk(KERN_INFO "%s: link down.\n", dev->name); |
3142 | } | 3142 | } |
3143 | 3143 | ||
@@ -3244,7 +3244,7 @@ static int nv_set_ringparam(struct net_device *dev, struct ethtool_ringparam* ri | |||
3244 | 3244 | ||
3245 | if (netif_running(dev)) { | 3245 | if (netif_running(dev)) { |
3246 | nv_disable_irq(dev); | 3246 | nv_disable_irq(dev); |
3247 | spin_lock_bh(&dev->xmit_lock); | 3247 | netif_tx_lock_bh(dev); |
3248 | spin_lock(&np->lock); | 3248 | spin_lock(&np->lock); |
3249 | /* stop engines */ | 3249 | /* stop engines */ |
3250 | nv_stop_rx(dev); | 3250 | nv_stop_rx(dev); |
@@ -3303,7 +3303,7 @@ static int nv_set_ringparam(struct net_device *dev, struct ethtool_ringparam* ri | |||
3303 | nv_start_rx(dev); | 3303 | nv_start_rx(dev); |
3304 | nv_start_tx(dev); | 3304 | nv_start_tx(dev); |
3305 | spin_unlock(&np->lock); | 3305 | spin_unlock(&np->lock); |
3306 | spin_unlock_bh(&dev->xmit_lock); | 3306 | netif_tx_unlock_bh(dev); |
3307 | nv_enable_irq(dev); | 3307 | nv_enable_irq(dev); |
3308 | } | 3308 | } |
3309 | return 0; | 3309 | return 0; |
@@ -3339,13 +3339,13 @@ static int nv_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam* | |||
3339 | netif_carrier_off(dev); | 3339 | netif_carrier_off(dev); |
3340 | if (netif_running(dev)) { | 3340 | if (netif_running(dev)) { |
3341 | nv_disable_irq(dev); | 3341 | nv_disable_irq(dev); |
3342 | spin_lock_bh(&dev->xmit_lock); | 3342 | netif_tx_lock_bh(dev); |
3343 | spin_lock(&np->lock); | 3343 | spin_lock(&np->lock); |
3344 | /* stop engines */ | 3344 | /* stop engines */ |
3345 | nv_stop_rx(dev); | 3345 | nv_stop_rx(dev); |
3346 | nv_stop_tx(dev); | 3346 | nv_stop_tx(dev); |
3347 | spin_unlock(&np->lock); | 3347 | spin_unlock(&np->lock); |
3348 | spin_unlock_bh(&dev->xmit_lock); | 3348 | netif_tx_unlock_bh(dev); |
3349 | } | 3349 | } |
3350 | 3350 | ||
3351 | np->pause_flags &= ~(NV_PAUSEFRAME_RX_REQ|NV_PAUSEFRAME_TX_REQ); | 3351 | np->pause_flags &= ~(NV_PAUSEFRAME_RX_REQ|NV_PAUSEFRAME_TX_REQ); |
@@ -3729,7 +3729,7 @@ static void nv_self_test(struct net_device *dev, struct ethtool_test *test, u64 | |||
3729 | if (test->flags & ETH_TEST_FL_OFFLINE) { | 3729 | if (test->flags & ETH_TEST_FL_OFFLINE) { |
3730 | if (netif_running(dev)) { | 3730 | if (netif_running(dev)) { |
3731 | netif_stop_queue(dev); | 3731 | netif_stop_queue(dev); |
3732 | spin_lock_bh(&dev->xmit_lock); | 3732 | netif_tx_lock_bh(dev); |
3733 | spin_lock_irq(&np->lock); | 3733 | spin_lock_irq(&np->lock); |
3734 | nv_disable_hw_interrupts(dev, np->irqmask); | 3734 | nv_disable_hw_interrupts(dev, np->irqmask); |
3735 | if (!(np->msi_flags & NV_MSI_X_ENABLED)) { | 3735 | if (!(np->msi_flags & NV_MSI_X_ENABLED)) { |
@@ -3745,7 +3745,7 @@ static void nv_self_test(struct net_device *dev, struct ethtool_test *test, u64 | |||
3745 | nv_drain_rx(dev); | 3745 | nv_drain_rx(dev); |
3746 | nv_drain_tx(dev); | 3746 | nv_drain_tx(dev); |
3747 | spin_unlock_irq(&np->lock); | 3747 | spin_unlock_irq(&np->lock); |
3748 | spin_unlock_bh(&dev->xmit_lock); | 3748 | netif_tx_unlock_bh(dev); |
3749 | } | 3749 | } |
3750 | 3750 | ||
3751 | if (!nv_register_test(dev)) { | 3751 | if (!nv_register_test(dev)) { |
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c index ae71ed57c12d..e76e6e7be0b1 100644 --- a/drivers/net/ioc3-eth.c +++ b/drivers/net/ioc3-eth.c | |||
@@ -145,7 +145,7 @@ static inline struct sk_buff * ioc3_alloc_skb(unsigned long length, | |||
145 | static inline unsigned long ioc3_map(void *ptr, unsigned long vdev) | 145 | static inline unsigned long ioc3_map(void *ptr, unsigned long vdev) |
146 | { | 146 | { |
147 | #ifdef CONFIG_SGI_IP27 | 147 | #ifdef CONFIG_SGI_IP27 |
148 | vdev <<= 58; /* Shift to PCI64_ATTR_VIRTUAL */ | 148 | vdev <<= 57; /* Shift to PCI64_ATTR_VIRTUAL */ |
149 | 149 | ||
150 | return vdev | (0xaUL << PCI64_ATTR_TARG_SHFT) | PCI64_ATTR_PREF | | 150 | return vdev | (0xaUL << PCI64_ATTR_TARG_SHFT) | PCI64_ATTR_PREF | |
151 | ((unsigned long)ptr & TO_PHYS_MASK); | 151 | ((unsigned long)ptr & TO_PHYS_MASK); |
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index e1feb58bd661..1a2b9785e998 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -2120,7 +2120,7 @@ abort_linearize: | |||
2120 | goto drop; | 2120 | goto drop; |
2121 | } | 2121 | } |
2122 | 2122 | ||
2123 | if (skb_linearize(skb, GFP_ATOMIC)) | 2123 | if (skb_linearize(skb)) |
2124 | goto drop; | 2124 | goto drop; |
2125 | 2125 | ||
2126 | mgp->tx_linearized++; | 2126 | mgp->tx_linearized++; |
diff --git a/drivers/net/netx-eth.c b/drivers/net/netx-eth.c new file mode 100644 index 000000000000..b92430c4e3ac --- /dev/null +++ b/drivers/net/netx-eth.c | |||
@@ -0,0 +1,516 @@ | |||
1 | /* | ||
2 | * drivers/net/netx-eth.c | ||
3 | * | ||
4 | * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/config.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/delay.h> | ||
25 | |||
26 | #include <linux/netdevice.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/etherdevice.h> | ||
29 | #include <linux/skbuff.h> | ||
30 | #include <linux/mii.h> | ||
31 | |||
32 | #include <asm/io.h> | ||
33 | #include <asm/hardware.h> | ||
34 | #include <asm/arch/hardware.h> | ||
35 | #include <asm/arch/netx-regs.h> | ||
36 | #include <asm/arch/pfifo.h> | ||
37 | #include <asm/arch/xc.h> | ||
38 | #include <asm/arch/eth.h> | ||
39 | |||
40 | /* XC Fifo Offsets */ | ||
41 | #define EMPTY_PTR_FIFO(xcno) (0 + ((xcno) << 3)) /* Index of the empty pointer FIFO */ | ||
42 | #define IND_FIFO_PORT_HI(xcno) (1 + ((xcno) << 3)) /* Index of the FIFO where received */ | ||
43 | /* Data packages are indicated by XC */ | ||
44 | #define IND_FIFO_PORT_LO(xcno) (2 + ((xcno) << 3)) /* Index of the FIFO where received */ | ||
45 | /* Data packages are indicated by XC */ | ||
46 | #define REQ_FIFO_PORT_HI(xcno) (3 + ((xcno) << 3)) /* Index of the FIFO where Data packages */ | ||
47 | /* have to be indicated by ARM which */ | ||
48 | /* shall be sent */ | ||
49 | #define REQ_FIFO_PORT_LO(xcno) (4 + ((xcno) << 3)) /* Index of the FIFO where Data packages */ | ||
50 | /* have to be indicated by ARM which shall */ | ||
51 | /* be sent */ | ||
52 | #define CON_FIFO_PORT_HI(xcno) (5 + ((xcno) << 3)) /* Index of the FIFO where sent Data packages */ | ||
53 | /* are confirmed */ | ||
54 | #define CON_FIFO_PORT_LO(xcno) (6 + ((xcno) << 3)) /* Index of the FIFO where sent Data */ | ||
55 | /* packages are confirmed */ | ||
56 | #define PFIFO_MASK(xcno) (0x7f << (xcno*8)) | ||
57 | |||
58 | #define FIFO_PTR_FRAMELEN_SHIFT 0 | ||
59 | #define FIFO_PTR_FRAMELEN_MASK (0x7ff << 0) | ||
60 | #define FIFO_PTR_FRAMELEN(len) (((len) << 0) & FIFO_PTR_FRAMELEN_MASK) | ||
61 | #define FIFO_PTR_TIMETRIG (1<<11) | ||
62 | #define FIFO_PTR_MULTI_REQ | ||
63 | #define FIFO_PTR_ORIGIN (1<<14) | ||
64 | #define FIFO_PTR_VLAN (1<<15) | ||
65 | #define FIFO_PTR_FRAMENO_SHIFT 16 | ||
66 | #define FIFO_PTR_FRAMENO_MASK (0x3f << 16) | ||
67 | #define FIFO_PTR_FRAMENO(no) (((no) << 16) & FIFO_PTR_FRAMENO_MASK) | ||
68 | #define FIFO_PTR_SEGMENT_SHIFT 22 | ||
69 | #define FIFO_PTR_SEGMENT_MASK (0xf << 22) | ||
70 | #define FIFO_PTR_SEGMENT(seg) (((seg) & 0xf) << 22) | ||
71 | #define FIFO_PTR_ERROR_SHIFT 28 | ||
72 | #define FIFO_PTR_ERROR_MASK (0xf << 28) | ||
73 | |||
74 | #define ISR_LINK_STATUS_CHANGE (1<<4) | ||
75 | #define ISR_IND_LO (1<<3) | ||
76 | #define ISR_CON_LO (1<<2) | ||
77 | #define ISR_IND_HI (1<<1) | ||
78 | #define ISR_CON_HI (1<<0) | ||
79 | |||
80 | #define ETH_MAC_LOCAL_CONFIG 0x1560 | ||
81 | #define ETH_MAC_4321 0x1564 | ||
82 | #define ETH_MAC_65 0x1568 | ||
83 | |||
84 | #define MAC_TRAFFIC_CLASS_ARRANGEMENT_SHIFT 16 | ||
85 | #define MAC_TRAFFIC_CLASS_ARRANGEMENT_MASK (0xf<<MAC_TRAFFIC_CLASS_ARRANGEMENT_SHIFT) | ||
86 | #define MAC_TRAFFIC_CLASS_ARRANGEMENT(x) (((x)<<MAC_TRAFFIC_CLASS_ARRANGEMENT_SHIFT) & MAC_TRAFFIC_CLASS_ARRANGEMENT_MASK) | ||
87 | #define LOCAL_CONFIG_LINK_STATUS_IRQ_EN (1<<24) | ||
88 | #define LOCAL_CONFIG_CON_LO_IRQ_EN (1<<23) | ||
89 | #define LOCAL_CONFIG_CON_HI_IRQ_EN (1<<22) | ||
90 | #define LOCAL_CONFIG_IND_LO_IRQ_EN (1<<21) | ||
91 | #define LOCAL_CONFIG_IND_HI_IRQ_EN (1<<20) | ||
92 | |||
93 | #define CARDNAME "netx-eth" | ||
94 | |||
95 | /* LSB must be zero */ | ||
96 | #define INTERNAL_PHY_ADR 0x1c | ||
97 | |||
98 | struct netx_eth_priv { | ||
99 | void __iomem *sram_base, *xpec_base, *xmac_base; | ||
100 | int id; | ||
101 | struct net_device_stats stats; | ||
102 | struct mii_if_info mii; | ||
103 | u32 msg_enable; | ||
104 | struct xc *xc; | ||
105 | spinlock_t lock; | ||
106 | }; | ||
107 | |||
108 | static void netx_eth_set_multicast_list(struct net_device *ndev) | ||
109 | { | ||
110 | /* implement me */ | ||
111 | } | ||
112 | |||
113 | static int | ||
114 | netx_eth_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev) | ||
115 | { | ||
116 | struct netx_eth_priv *priv = netdev_priv(ndev); | ||
117 | unsigned char *buf = skb->data; | ||
118 | unsigned int len = skb->len; | ||
119 | |||
120 | spin_lock_irq(&priv->lock); | ||
121 | memcpy_toio(priv->sram_base + 1560, (void *)buf, len); | ||
122 | if (len < 60) { | ||
123 | memset_io(priv->sram_base + 1560 + len, 0, 60 - len); | ||
124 | len = 60; | ||
125 | } | ||
126 | |||
127 | pfifo_push(REQ_FIFO_PORT_LO(priv->id), | ||
128 | FIFO_PTR_SEGMENT(priv->id) | | ||
129 | FIFO_PTR_FRAMENO(1) | | ||
130 | FIFO_PTR_FRAMELEN(len)); | ||
131 | |||
132 | ndev->trans_start = jiffies; | ||
133 | priv->stats.tx_packets++; | ||
134 | priv->stats.tx_bytes += skb->len; | ||
135 | |||
136 | netif_stop_queue(ndev); | ||
137 | spin_unlock_irq(&priv->lock); | ||
138 | dev_kfree_skb(skb); | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | static void netx_eth_receive(struct net_device *ndev) | ||
144 | { | ||
145 | struct netx_eth_priv *priv = netdev_priv(ndev); | ||
146 | unsigned int val, frameno, seg, len; | ||
147 | unsigned char *data; | ||
148 | struct sk_buff *skb; | ||
149 | |||
150 | val = pfifo_pop(IND_FIFO_PORT_LO(priv->id)); | ||
151 | |||
152 | frameno = (val & FIFO_PTR_FRAMENO_MASK) >> FIFO_PTR_FRAMENO_SHIFT; | ||
153 | seg = (val & FIFO_PTR_SEGMENT_MASK) >> FIFO_PTR_SEGMENT_SHIFT; | ||
154 | len = (val & FIFO_PTR_FRAMELEN_MASK) >> FIFO_PTR_FRAMELEN_SHIFT; | ||
155 | |||
156 | skb = dev_alloc_skb(len); | ||
157 | if (unlikely(skb == NULL)) { | ||
158 | printk(KERN_NOTICE "%s: Low memory, packet dropped.\n", | ||
159 | ndev->name); | ||
160 | priv->stats.rx_dropped++; | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | data = skb_put(skb, len); | ||
165 | |||
166 | memcpy_fromio(data, priv->sram_base + frameno * 1560, len); | ||
167 | |||
168 | pfifo_push(EMPTY_PTR_FIFO(priv->id), | ||
169 | FIFO_PTR_SEGMENT(seg) | FIFO_PTR_FRAMENO(frameno)); | ||
170 | |||
171 | ndev->last_rx = jiffies; | ||
172 | skb->dev = ndev; | ||
173 | skb->protocol = eth_type_trans(skb, ndev); | ||
174 | netif_rx(skb); | ||
175 | priv->stats.rx_packets++; | ||
176 | priv->stats.rx_bytes += len; | ||
177 | } | ||
178 | |||
179 | static irqreturn_t | ||
180 | netx_eth_interrupt(int irq, void *dev_id, struct pt_regs *regs) | ||
181 | { | ||
182 | struct net_device *ndev = dev_id; | ||
183 | struct netx_eth_priv *priv = netdev_priv(ndev); | ||
184 | int status; | ||
185 | unsigned long flags; | ||
186 | |||
187 | spin_lock_irqsave(&priv->lock, flags); | ||
188 | |||
189 | status = readl(NETX_PFIFO_XPEC_ISR(priv->id)); | ||
190 | while (status) { | ||
191 | int fill_level; | ||
192 | writel(status, NETX_PFIFO_XPEC_ISR(priv->id)); | ||
193 | |||
194 | if ((status & ISR_CON_HI) || (status & ISR_IND_HI)) | ||
195 | printk("%s: unexpected status: 0x%08x\n", | ||
196 | __FUNCTION__, status); | ||
197 | |||
198 | fill_level = | ||
199 | readl(NETX_PFIFO_FILL_LEVEL(IND_FIFO_PORT_LO(priv->id))); | ||
200 | while (fill_level--) | ||
201 | netx_eth_receive(ndev); | ||
202 | |||
203 | if (status & ISR_CON_LO) | ||
204 | netif_wake_queue(ndev); | ||
205 | |||
206 | if (status & ISR_LINK_STATUS_CHANGE) | ||
207 | mii_check_media(&priv->mii, netif_msg_link(priv), 1); | ||
208 | |||
209 | status = readl(NETX_PFIFO_XPEC_ISR(priv->id)); | ||
210 | } | ||
211 | spin_unlock_irqrestore(&priv->lock, flags); | ||
212 | return IRQ_HANDLED; | ||
213 | } | ||
214 | |||
215 | static struct net_device_stats *netx_eth_query_statistics(struct net_device *ndev) | ||
216 | { | ||
217 | struct netx_eth_priv *priv = netdev_priv(ndev); | ||
218 | return &priv->stats; | ||
219 | } | ||
220 | |||
221 | static int netx_eth_open(struct net_device *ndev) | ||
222 | { | ||
223 | struct netx_eth_priv *priv = netdev_priv(ndev); | ||
224 | |||
225 | if (request_irq | ||
226 | (ndev->irq, &netx_eth_interrupt, SA_SHIRQ, ndev->name, ndev)) | ||
227 | return -EAGAIN; | ||
228 | |||
229 | writel(ndev->dev_addr[0] | | ||
230 | ndev->dev_addr[1]<<8 | | ||
231 | ndev->dev_addr[2]<<16 | | ||
232 | ndev->dev_addr[3]<<24, | ||
233 | priv->xpec_base + NETX_XPEC_RAM_START_OFS + ETH_MAC_4321); | ||
234 | writel(ndev->dev_addr[4] | | ||
235 | ndev->dev_addr[5]<<8, | ||
236 | priv->xpec_base + NETX_XPEC_RAM_START_OFS + ETH_MAC_65); | ||
237 | |||
238 | writel(LOCAL_CONFIG_LINK_STATUS_IRQ_EN | | ||
239 | LOCAL_CONFIG_CON_LO_IRQ_EN | | ||
240 | LOCAL_CONFIG_CON_HI_IRQ_EN | | ||
241 | LOCAL_CONFIG_IND_LO_IRQ_EN | | ||
242 | LOCAL_CONFIG_IND_HI_IRQ_EN, | ||
243 | priv->xpec_base + NETX_XPEC_RAM_START_OFS + | ||
244 | ETH_MAC_LOCAL_CONFIG); | ||
245 | |||
246 | mii_check_media(&priv->mii, netif_msg_link(priv), 1); | ||
247 | netif_start_queue(ndev); | ||
248 | |||
249 | return 0; | ||
250 | } | ||
251 | |||
252 | static int netx_eth_close(struct net_device *ndev) | ||
253 | { | ||
254 | struct netx_eth_priv *priv = netdev_priv(ndev); | ||
255 | |||
256 | netif_stop_queue(ndev); | ||
257 | |||
258 | writel(0, | ||
259 | priv->xpec_base + NETX_XPEC_RAM_START_OFS + ETH_MAC_LOCAL_CONFIG); | ||
260 | |||
261 | free_irq(ndev->irq, ndev); | ||
262 | |||
263 | return 0; | ||
264 | } | ||
265 | |||
266 | static void netx_eth_timeout(struct net_device *ndev) | ||
267 | { | ||
268 | struct netx_eth_priv *priv = netdev_priv(ndev); | ||
269 | int i; | ||
270 | |||
271 | printk(KERN_ERR "%s: transmit timed out, resetting\n", ndev->name); | ||
272 | |||
273 | spin_lock_irq(&priv->lock); | ||
274 | |||
275 | xc_reset(priv->xc); | ||
276 | xc_start(priv->xc); | ||
277 | |||
278 | for (i=2; i<=18; i++) | ||
279 | pfifo_push(EMPTY_PTR_FIFO(priv->id), | ||
280 | FIFO_PTR_FRAMENO(i) | FIFO_PTR_SEGMENT(priv->id)); | ||
281 | |||
282 | spin_unlock_irq(&priv->lock); | ||
283 | |||
284 | netif_wake_queue(ndev); | ||
285 | } | ||
286 | |||
287 | static int | ||
288 | netx_eth_phy_read(struct net_device *ndev, int phy_id, int reg) | ||
289 | { | ||
290 | unsigned int val; | ||
291 | |||
292 | val = MIIMU_SNRDY | MIIMU_PREAMBLE | MIIMU_PHYADDR(phy_id) | | ||
293 | MIIMU_REGADDR(reg) | MIIMU_PHY_NRES; | ||
294 | |||
295 | writel(val, NETX_MIIMU); | ||
296 | while (readl(NETX_MIIMU) & MIIMU_SNRDY); | ||
297 | |||
298 | return readl(NETX_MIIMU) >> 16; | ||
299 | |||
300 | } | ||
301 | |||
302 | static void | ||
303 | netx_eth_phy_write(struct net_device *ndev, int phy_id, int reg, int value) | ||
304 | { | ||
305 | unsigned int val; | ||
306 | |||
307 | val = MIIMU_SNRDY | MIIMU_PREAMBLE | MIIMU_PHYADDR(phy_id) | | ||
308 | MIIMU_REGADDR(reg) | MIIMU_PHY_NRES | MIIMU_OPMODE_WRITE | | ||
309 | MIIMU_DATA(value); | ||
310 | |||
311 | writel(val, NETX_MIIMU); | ||
312 | while (readl(NETX_MIIMU) & MIIMU_SNRDY); | ||
313 | } | ||
314 | |||
315 | static int netx_eth_enable(struct net_device *ndev) | ||
316 | { | ||
317 | struct netx_eth_priv *priv = netdev_priv(ndev); | ||
318 | unsigned int mac4321, mac65; | ||
319 | int running, i; | ||
320 | |||
321 | ether_setup(ndev); | ||
322 | |||
323 | ndev->open = netx_eth_open; | ||
324 | ndev->stop = netx_eth_close; | ||
325 | ndev->hard_start_xmit = netx_eth_hard_start_xmit; | ||
326 | ndev->tx_timeout = netx_eth_timeout; | ||
327 | ndev->watchdog_timeo = msecs_to_jiffies(5000); | ||
328 | ndev->get_stats = netx_eth_query_statistics; | ||
329 | ndev->set_multicast_list = netx_eth_set_multicast_list; | ||
330 | |||
331 | priv->msg_enable = NETIF_MSG_LINK; | ||
332 | priv->mii.phy_id_mask = 0x1f; | ||
333 | priv->mii.reg_num_mask = 0x1f; | ||
334 | priv->mii.force_media = 0; | ||
335 | priv->mii.full_duplex = 0; | ||
336 | priv->mii.dev = ndev; | ||
337 | priv->mii.mdio_read = netx_eth_phy_read; | ||
338 | priv->mii.mdio_write = netx_eth_phy_write; | ||
339 | priv->mii.phy_id = INTERNAL_PHY_ADR + priv->id; | ||
340 | |||
341 | running = xc_running(priv->xc); | ||
342 | xc_stop(priv->xc); | ||
343 | |||
344 | /* if the xc engine is already running, assume the bootloader has | ||
345 | * loaded the firmware for us | ||
346 | */ | ||
347 | if (running) { | ||
348 | /* get Node Address from hardware */ | ||
349 | mac4321 = readl(priv->xpec_base + | ||
350 | NETX_XPEC_RAM_START_OFS + ETH_MAC_4321); | ||
351 | mac65 = readl(priv->xpec_base + | ||
352 | NETX_XPEC_RAM_START_OFS + ETH_MAC_65); | ||
353 | |||
354 | ndev->dev_addr[0] = mac4321 & 0xff; | ||
355 | ndev->dev_addr[1] = (mac4321 >> 8) & 0xff; | ||
356 | ndev->dev_addr[2] = (mac4321 >> 16) & 0xff; | ||
357 | ndev->dev_addr[3] = (mac4321 >> 24) & 0xff; | ||
358 | ndev->dev_addr[4] = mac65 & 0xff; | ||
359 | ndev->dev_addr[5] = (mac65 >> 8) & 0xff; | ||
360 | } else { | ||
361 | if (xc_request_firmware(priv->xc)) { | ||
362 | printk(CARDNAME ": requesting firmware failed\n"); | ||
363 | return -ENODEV; | ||
364 | } | ||
365 | } | ||
366 | |||
367 | xc_reset(priv->xc); | ||
368 | xc_start(priv->xc); | ||
369 | |||
370 | if (!is_valid_ether_addr(ndev->dev_addr)) | ||
371 | printk("%s: Invalid ethernet MAC address. Please " | ||
372 | "set using ifconfig\n", ndev->name); | ||
373 | |||
374 | for (i=2; i<=18; i++) | ||
375 | pfifo_push(EMPTY_PTR_FIFO(priv->id), | ||
376 | FIFO_PTR_FRAMENO(i) | FIFO_PTR_SEGMENT(priv->id)); | ||
377 | |||
378 | return register_netdev(ndev); | ||
379 | |||
380 | } | ||
381 | |||
382 | static int netx_eth_drv_probe(struct platform_device *pdev) | ||
383 | { | ||
384 | struct netx_eth_priv *priv; | ||
385 | struct net_device *ndev; | ||
386 | struct netxeth_platform_data *pdata; | ||
387 | int ret; | ||
388 | |||
389 | ndev = alloc_etherdev(sizeof (struct netx_eth_priv)); | ||
390 | if (!ndev) { | ||
391 | printk("%s: could not allocate device.\n", CARDNAME); | ||
392 | ret = -ENOMEM; | ||
393 | goto exit; | ||
394 | } | ||
395 | SET_MODULE_OWNER(ndev); | ||
396 | SET_NETDEV_DEV(ndev, &pdev->dev); | ||
397 | |||
398 | platform_set_drvdata(pdev, ndev); | ||
399 | |||
400 | priv = netdev_priv(ndev); | ||
401 | |||
402 | pdata = (struct netxeth_platform_data *)pdev->dev.platform_data; | ||
403 | priv->xc = request_xc(pdata->xcno, &pdev->dev); | ||
404 | if (!priv->xc) { | ||
405 | dev_err(&pdev->dev, "unable to request xc engine\n"); | ||
406 | ret = -ENODEV; | ||
407 | goto exit_free_netdev; | ||
408 | } | ||
409 | |||
410 | ndev->irq = priv->xc->irq; | ||
411 | priv->id = pdev->id; | ||
412 | priv->xpec_base = priv->xc->xpec_base; | ||
413 | priv->xmac_base = priv->xc->xmac_base; | ||
414 | priv->sram_base = priv->xc->sram_base; | ||
415 | |||
416 | ret = pfifo_request(PFIFO_MASK(priv->id)); | ||
417 | if (ret) { | ||
418 | printk("unable to request PFIFO\n"); | ||
419 | goto exit_free_xc; | ||
420 | } | ||
421 | |||
422 | ret = netx_eth_enable(ndev); | ||
423 | if (ret) | ||
424 | goto exit_free_pfifo; | ||
425 | |||
426 | return 0; | ||
427 | exit_free_pfifo: | ||
428 | pfifo_free(PFIFO_MASK(priv->id)); | ||
429 | exit_free_xc: | ||
430 | free_xc(priv->xc); | ||
431 | exit_free_netdev: | ||
432 | platform_set_drvdata(pdev, NULL); | ||
433 | free_netdev(ndev); | ||
434 | exit: | ||
435 | return ret; | ||
436 | } | ||
437 | |||
438 | static int netx_eth_drv_remove(struct platform_device *pdev) | ||
439 | { | ||
440 | struct net_device *ndev = dev_get_drvdata(&pdev->dev); | ||
441 | struct netx_eth_priv *priv = netdev_priv(ndev); | ||
442 | |||
443 | platform_set_drvdata(pdev, NULL); | ||
444 | |||
445 | unregister_netdev(ndev); | ||
446 | xc_stop(priv->xc); | ||
447 | free_xc(priv->xc); | ||
448 | free_netdev(ndev); | ||
449 | pfifo_free(PFIFO_MASK(priv->id)); | ||
450 | |||
451 | return 0; | ||
452 | } | ||
453 | |||
454 | static int netx_eth_drv_suspend(struct platform_device *pdev, pm_message_t state) | ||
455 | { | ||
456 | dev_err(&pdev->dev, "suspend not implemented\n"); | ||
457 | return 0; | ||
458 | } | ||
459 | |||
460 | static int netx_eth_drv_resume(struct platform_device *pdev) | ||
461 | { | ||
462 | dev_err(&pdev->dev, "resume not implemented\n"); | ||
463 | return 0; | ||
464 | } | ||
465 | |||
466 | static struct platform_driver netx_eth_driver = { | ||
467 | .probe = netx_eth_drv_probe, | ||
468 | .remove = netx_eth_drv_remove, | ||
469 | .suspend = netx_eth_drv_suspend, | ||
470 | .resume = netx_eth_drv_resume, | ||
471 | .driver = { | ||
472 | .name = CARDNAME, | ||
473 | .owner = THIS_MODULE, | ||
474 | }, | ||
475 | }; | ||
476 | |||
477 | static int __init netx_eth_init(void) | ||
478 | { | ||
479 | unsigned int phy_control, val; | ||
480 | |||
481 | printk("NetX Ethernet driver\n"); | ||
482 | |||
483 | phy_control = PHY_CONTROL_PHY_ADDRESS(INTERNAL_PHY_ADR>>1) | | ||
484 | PHY_CONTROL_PHY1_MODE(PHY_MODE_ALL) | | ||
485 | PHY_CONTROL_PHY1_AUTOMDIX | | ||
486 | PHY_CONTROL_PHY1_EN | | ||
487 | PHY_CONTROL_PHY0_MODE(PHY_MODE_ALL) | | ||
488 | PHY_CONTROL_PHY0_AUTOMDIX | | ||
489 | PHY_CONTROL_PHY0_EN | | ||
490 | PHY_CONTROL_CLK_XLATIN; | ||
491 | |||
492 | val = readl(NETX_SYSTEM_IOC_ACCESS_KEY); | ||
493 | writel(val, NETX_SYSTEM_IOC_ACCESS_KEY); | ||
494 | |||
495 | writel(phy_control | PHY_CONTROL_RESET, NETX_SYSTEM_PHY_CONTROL); | ||
496 | udelay(100); | ||
497 | |||
498 | val = readl(NETX_SYSTEM_IOC_ACCESS_KEY); | ||
499 | writel(val, NETX_SYSTEM_IOC_ACCESS_KEY); | ||
500 | |||
501 | writel(phy_control, NETX_SYSTEM_PHY_CONTROL); | ||
502 | |||
503 | return platform_driver_register(&netx_eth_driver); | ||
504 | } | ||
505 | |||
506 | static void __exit netx_eth_cleanup(void) | ||
507 | { | ||
508 | platform_driver_unregister(&netx_eth_driver); | ||
509 | } | ||
510 | |||
511 | module_init(netx_eth_init); | ||
512 | module_exit(netx_eth_cleanup); | ||
513 | |||
514 | MODULE_AUTHOR("Sascha Hauer, Pengutronix"); | ||
515 | MODULE_LICENSE("GPL"); | ||
516 | |||
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index 71f45056a70c..e80d1e3aec68 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c | |||
@@ -1359,7 +1359,7 @@ do_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1359 | kio_addr_t ioaddr = dev->base_addr; | 1359 | kio_addr_t ioaddr = dev->base_addr; |
1360 | int okay; | 1360 | int okay; |
1361 | unsigned freespace; | 1361 | unsigned freespace; |
1362 | unsigned pktlen = skb? skb->len : 0; | 1362 | unsigned pktlen = skb->len; |
1363 | 1363 | ||
1364 | DEBUG(1, "do_start_xmit(skb=%p, dev=%p) len=%u\n", | 1364 | DEBUG(1, "do_start_xmit(skb=%p, dev=%p) len=%u\n", |
1365 | skb, dev, pktlen); | 1365 | skb, dev, pktlen); |
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h index f72a4f57905a..bf776125ca38 100644 --- a/drivers/net/smc91x.h +++ b/drivers/net/smc91x.h | |||
@@ -260,15 +260,17 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg) | |||
260 | #define RPC_LSA_DEFAULT RPC_LED_TX_RX | 260 | #define RPC_LSA_DEFAULT RPC_LED_TX_RX |
261 | #define RPC_LSB_DEFAULT RPC_LED_100_10 | 261 | #define RPC_LSB_DEFAULT RPC_LED_100_10 |
262 | 262 | ||
263 | #elif defined(CONFIG_MACH_LPD7A400) || defined(CONFIG_MACH_LPD7A404) | 263 | #elif defined(CONFIG_MACH_LPD79520) \ |
264 | || defined(CONFIG_MACH_LPD7A400) \ | ||
265 | || defined(CONFIG_MACH_LPD7A404) | ||
264 | 266 | ||
265 | /* The LPD7A40X_IOBARRIER is necessary to overcome a mismatch between | 267 | /* The LPD7X_IOBARRIER is necessary to overcome a mismatch between the |
266 | * the way that the CPU handles chip selects and the way that the SMC | 268 | * way that the CPU handles chip selects and the way that the SMC chip |
267 | * chip expects the chip select to operate. Refer to | 269 | * expects the chip select to operate. Refer to |
268 | * Documentation/arm/Sharp-LH/IOBarrier for details. The read from | 270 | * Documentation/arm/Sharp-LH/IOBarrier for details. The read from |
269 | * IOBARRIER is a byte as a least-common denominator of possible | 271 | * IOBARRIER is a byte, in order that we read the least-common |
270 | * regions to use as the barrier. It would be wasteful to read 32 | 272 | * denominator. It would be wasteful to read 32 bits from an 8-bit |
271 | * bits from a byte oriented region. | 273 | * accessible region. |
272 | * | 274 | * |
273 | * There is no explicit protection against interrupts intervening | 275 | * There is no explicit protection against interrupts intervening |
274 | * between the writew and the IOBARRIER. In SMC ISR there is a | 276 | * between the writew and the IOBARRIER. In SMC ISR there is a |
@@ -287,25 +289,35 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg) | |||
287 | #define SMC_CAN_USE_16BIT 1 | 289 | #define SMC_CAN_USE_16BIT 1 |
288 | #define SMC_CAN_USE_32BIT 0 | 290 | #define SMC_CAN_USE_32BIT 0 |
289 | #define SMC_NOWAIT 0 | 291 | #define SMC_NOWAIT 0 |
290 | #define LPD7A40X_IOBARRIER readb (IOBARRIER_VIRT) | 292 | #define LPD7X_IOBARRIER readb (IOBARRIER_VIRT) |
291 | 293 | ||
292 | #define SMC_inw(a,r) readw ((void*) ((a) + (r))) | 294 | #define SMC_inw(a,r)\ |
293 | #define SMC_insw(a,r,p,l) readsw ((void*) ((a) + (r)), p, l) | 295 | ({ unsigned short v = readw ((void*) ((a) + (r))); LPD7X_IOBARRIER; v; }) |
294 | #define SMC_outw(v,a,r) ({ writew ((v), (a) + (r)); LPD7A40X_IOBARRIER; }) | 296 | #define SMC_outw(v,a,r) ({ writew ((v), (a) + (r)); LPD7X_IOBARRIER; }) |
295 | 297 | ||
296 | #define SMC_outsw LPD7A40X_SMC_outsw | 298 | #define SMC_insw LPD7_SMC_insw |
299 | static inline void LPD7_SMC_insw (unsigned char* a, int r, | ||
300 | unsigned char* p, int l) | ||
301 | { | ||
302 | unsigned short* ps = (unsigned short*) p; | ||
303 | while (l-- > 0) { | ||
304 | *ps++ = readw (a + r); | ||
305 | LPD7X_IOBARRIER; | ||
306 | } | ||
307 | } | ||
297 | 308 | ||
298 | static inline void LPD7A40X_SMC_outsw(unsigned long a, int r, | 309 | #define SMC_outsw LPD7_SMC_outsw |
299 | unsigned char* p, int l) | 310 | static inline void LPD7_SMC_outsw (unsigned char* a, int r, |
311 | unsigned char* p, int l) | ||
300 | { | 312 | { |
301 | unsigned short* ps = (unsigned short*) p; | 313 | unsigned short* ps = (unsigned short*) p; |
302 | while (l-- > 0) { | 314 | while (l-- > 0) { |
303 | writew (*ps++, a + r); | 315 | writew (*ps++, a + r); |
304 | LPD7A40X_IOBARRIER; | 316 | LPD7X_IOBARRIER; |
305 | } | 317 | } |
306 | } | 318 | } |
307 | 319 | ||
308 | #define SMC_INTERRUPT_PREAMBLE LPD7A40X_IOBARRIER | 320 | #define SMC_INTERRUPT_PREAMBLE LPD7X_IOBARRIER |
309 | 321 | ||
310 | #define RPC_LSA_DEFAULT RPC_LED_TX_RX | 322 | #define RPC_LSA_DEFAULT RPC_LED_TX_RX |
311 | #define RPC_LSB_DEFAULT RPC_LED_100_10 | 323 | #define RPC_LSB_DEFAULT RPC_LED_100_10 |
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index 9f046cae2f71..bd5d2668a362 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c | |||
@@ -2221,13 +2221,8 @@ static int happy_meal_open(struct net_device *dev) | |||
2221 | if (request_irq(dev->irq, &happy_meal_interrupt, | 2221 | if (request_irq(dev->irq, &happy_meal_interrupt, |
2222 | SA_SHIRQ, dev->name, (void *)dev)) { | 2222 | SA_SHIRQ, dev->name, (void *)dev)) { |
2223 | HMD(("EAGAIN\n")); | 2223 | HMD(("EAGAIN\n")); |
2224 | #ifdef __sparc__ | ||
2225 | printk(KERN_ERR "happy_meal(SBUS): Can't order irq %s to go.\n", | ||
2226 | __irq_itoa(dev->irq)); | ||
2227 | #else | ||
2228 | printk(KERN_ERR "happy_meal(SBUS): Can't order irq %d to go.\n", | 2224 | printk(KERN_ERR "happy_meal(SBUS): Can't order irq %d to go.\n", |
2229 | dev->irq); | 2225 | dev->irq); |
2230 | #endif | ||
2231 | 2226 | ||
2232 | return -EAGAIN; | 2227 | return -EAGAIN; |
2233 | } | 2228 | } |
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c index b7d87d4690b4..6381243d8d00 100644 --- a/drivers/net/sunlance.c +++ b/drivers/net/sunlance.c | |||
@@ -936,7 +936,7 @@ static int lance_open(struct net_device *dev) | |||
936 | 936 | ||
937 | if (request_irq(dev->irq, &lance_interrupt, SA_SHIRQ, | 937 | if (request_irq(dev->irq, &lance_interrupt, SA_SHIRQ, |
938 | lancestr, (void *) dev)) { | 938 | lancestr, (void *) dev)) { |
939 | printk(KERN_ERR "Lance: Can't get irq %s\n", __irq_itoa(dev->irq)); | 939 | printk(KERN_ERR "Lance: Can't get irq %d\n", dev->irq); |
940 | return -EAGAIN; | 940 | return -EAGAIN; |
941 | } | 941 | } |
942 | 942 | ||
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c index 23032a7bc0a9..c3cb8d26cfe3 100644 --- a/drivers/net/tokenring/olympic.c +++ b/drivers/net/tokenring/olympic.c | |||
@@ -217,7 +217,7 @@ static int __devinit olympic_probe(struct pci_dev *pdev, const struct pci_device | |||
217 | dev = alloc_trdev(sizeof(struct olympic_private)) ; | 217 | dev = alloc_trdev(sizeof(struct olympic_private)) ; |
218 | if (!dev) { | 218 | if (!dev) { |
219 | i = -ENOMEM; | 219 | i = -ENOMEM; |
220 | goto op_free_dev; | 220 | goto op_release_dev; |
221 | } | 221 | } |
222 | 222 | ||
223 | olympic_priv = dev->priv ; | 223 | olympic_priv = dev->priv ; |
@@ -282,8 +282,8 @@ op_free_iomap: | |||
282 | if (olympic_priv->olympic_lap) | 282 | if (olympic_priv->olympic_lap) |
283 | iounmap(olympic_priv->olympic_lap); | 283 | iounmap(olympic_priv->olympic_lap); |
284 | 284 | ||
285 | op_free_dev: | ||
286 | free_netdev(dev); | 285 | free_netdev(dev); |
286 | op_release_dev: | ||
287 | pci_release_regions(pdev); | 287 | pci_release_regions(pdev); |
288 | 288 | ||
289 | op_disable_dev: | 289 | op_disable_dev: |
diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c index 43d854ace233..b60ef02db7b0 100644 --- a/drivers/net/wan/c101.c +++ b/drivers/net/wan/c101.c | |||
@@ -326,21 +326,21 @@ static int __init c101_run(unsigned long irq, unsigned long winbase) | |||
326 | if (request_irq(irq, sca_intr, 0, devname, card)) { | 326 | if (request_irq(irq, sca_intr, 0, devname, card)) { |
327 | printk(KERN_ERR "c101: could not allocate IRQ\n"); | 327 | printk(KERN_ERR "c101: could not allocate IRQ\n"); |
328 | c101_destroy_card(card); | 328 | c101_destroy_card(card); |
329 | return(-EBUSY); | 329 | return -EBUSY; |
330 | } | 330 | } |
331 | card->irq = irq; | 331 | card->irq = irq; |
332 | 332 | ||
333 | if (!request_mem_region(winbase, C101_MAPPED_RAM_SIZE, devname)) { | 333 | if (!request_mem_region(winbase, C101_MAPPED_RAM_SIZE, devname)) { |
334 | printk(KERN_ERR "c101: could not request RAM window\n"); | 334 | printk(KERN_ERR "c101: could not request RAM window\n"); |
335 | c101_destroy_card(card); | 335 | c101_destroy_card(card); |
336 | return(-EBUSY); | 336 | return -EBUSY; |
337 | } | 337 | } |
338 | card->phy_winbase = winbase; | 338 | card->phy_winbase = winbase; |
339 | card->win0base = ioremap(winbase, C101_MAPPED_RAM_SIZE); | 339 | card->win0base = ioremap(winbase, C101_MAPPED_RAM_SIZE); |
340 | if (!card->win0base) { | 340 | if (!card->win0base) { |
341 | printk(KERN_ERR "c101: could not map I/O address\n"); | 341 | printk(KERN_ERR "c101: could not map I/O address\n"); |
342 | c101_destroy_card(card); | 342 | c101_destroy_card(card); |
343 | return -EBUSY; | 343 | return -EFAULT; |
344 | } | 344 | } |
345 | 345 | ||
346 | card->tx_ring_buffers = TX_RING_BUFFERS; | 346 | card->tx_ring_buffers = TX_RING_BUFFERS; |
diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index 46cef8f92133..57f9538b8fb5 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c | |||
@@ -259,7 +259,7 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | static void hdlc_setup(struct net_device *dev) | 262 | void hdlc_setup(struct net_device *dev) |
263 | { | 263 | { |
264 | hdlc_device *hdlc = dev_to_hdlc(dev); | 264 | hdlc_device *hdlc = dev_to_hdlc(dev); |
265 | 265 | ||
@@ -288,26 +288,6 @@ struct net_device *alloc_hdlcdev(void *priv) | |||
288 | return dev; | 288 | return dev; |
289 | } | 289 | } |
290 | 290 | ||
291 | int register_hdlc_device(struct net_device *dev) | ||
292 | { | ||
293 | int result = dev_alloc_name(dev, "hdlc%d"); | ||
294 | if (result < 0) | ||
295 | return result; | ||
296 | |||
297 | result = register_netdev(dev); | ||
298 | if (result != 0) | ||
299 | return -EIO; | ||
300 | |||
301 | #if 0 | ||
302 | if (netif_carrier_ok(dev)) | ||
303 | netif_carrier_off(dev); /* no carrier until DCD goes up */ | ||
304 | #endif | ||
305 | |||
306 | return 0; | ||
307 | } | ||
308 | |||
309 | |||
310 | |||
311 | void unregister_hdlc_device(struct net_device *dev) | 291 | void unregister_hdlc_device(struct net_device *dev) |
312 | { | 292 | { |
313 | rtnl_lock(); | 293 | rtnl_lock(); |
@@ -326,8 +306,8 @@ EXPORT_SYMBOL(hdlc_open); | |||
326 | EXPORT_SYMBOL(hdlc_close); | 306 | EXPORT_SYMBOL(hdlc_close); |
327 | EXPORT_SYMBOL(hdlc_set_carrier); | 307 | EXPORT_SYMBOL(hdlc_set_carrier); |
328 | EXPORT_SYMBOL(hdlc_ioctl); | 308 | EXPORT_SYMBOL(hdlc_ioctl); |
309 | EXPORT_SYMBOL(hdlc_setup); | ||
329 | EXPORT_SYMBOL(alloc_hdlcdev); | 310 | EXPORT_SYMBOL(alloc_hdlcdev); |
330 | EXPORT_SYMBOL(register_hdlc_device); | ||
331 | EXPORT_SYMBOL(unregister_hdlc_device); | 311 | EXPORT_SYMBOL(unregister_hdlc_device); |
332 | 312 | ||
333 | static struct packet_type hdlc_packet_type = { | 313 | static struct packet_type hdlc_packet_type = { |
diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c index cd32751b64eb..b7d88db89a5c 100644 --- a/drivers/net/wan/n2.c +++ b/drivers/net/wan/n2.c | |||
@@ -387,6 +387,11 @@ static int __init n2_run(unsigned long io, unsigned long irq, | |||
387 | } | 387 | } |
388 | card->phy_winbase = winbase; | 388 | card->phy_winbase = winbase; |
389 | card->winbase = ioremap(winbase, USE_WINDOWSIZE); | 389 | card->winbase = ioremap(winbase, USE_WINDOWSIZE); |
390 | if (!card->winbase) { | ||
391 | printk(KERN_ERR "n2: ioremap() failed\n"); | ||
392 | n2_destroy_card(card); | ||
393 | return -EFAULT; | ||
394 | } | ||
390 | 395 | ||
391 | outb(0, io + N2_PCR); | 396 | outb(0, io + N2_PCR); |
392 | outb(winbase >> 12, io + N2_BAR); | 397 | outb(winbase >> 12, io + N2_BAR); |
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c index f485a97844cc..670e8bd2245c 100644 --- a/drivers/net/wan/pci200syn.c +++ b/drivers/net/wan/pci200syn.c | |||
@@ -354,6 +354,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev, | |||
354 | card->rambase == NULL) { | 354 | card->rambase == NULL) { |
355 | printk(KERN_ERR "pci200syn: ioremap() failed\n"); | 355 | printk(KERN_ERR "pci200syn: ioremap() failed\n"); |
356 | pci200_pci_remove_one(pdev); | 356 | pci200_pci_remove_one(pdev); |
357 | return -EFAULT; | ||
357 | } | 358 | } |
358 | 359 | ||
359 | /* Reset PLX */ | 360 | /* Reset PLX */ |
diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c index 29a756dd979b..437e0e938e38 100644 --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c | |||
@@ -634,7 +634,13 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, | |||
634 | 634 | ||
635 | /* set up PLX mapping */ | 635 | /* set up PLX mapping */ |
636 | plx_phy = pci_resource_start(pdev, 0); | 636 | plx_phy = pci_resource_start(pdev, 0); |
637 | |||
637 | card->plx = ioremap_nocache(plx_phy, 0x70); | 638 | card->plx = ioremap_nocache(plx_phy, 0x70); |
639 | if (!card->plx) { | ||
640 | printk(KERN_ERR "wanxl: ioremap() failed\n"); | ||
641 | wanxl_pci_remove_one(pdev); | ||
642 | return -EFAULT; | ||
643 | } | ||
638 | 644 | ||
639 | #if RESET_WHILE_LOADING | 645 | #if RESET_WHILE_LOADING |
640 | wanxl_reset(card); | 646 | wanxl_reset(card); |
@@ -700,6 +706,12 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, | |||
700 | } | 706 | } |
701 | 707 | ||
702 | mem = ioremap_nocache(mem_phy, PDM_OFFSET + sizeof(firmware)); | 708 | mem = ioremap_nocache(mem_phy, PDM_OFFSET + sizeof(firmware)); |
709 | if (!mem) { | ||
710 | printk(KERN_ERR "wanxl: ioremap() failed\n"); | ||
711 | wanxl_pci_remove_one(pdev); | ||
712 | return -EFAULT; | ||
713 | } | ||
714 | |||
703 | for (i = 0; i < sizeof(firmware); i += 4) | 715 | for (i = 0; i < sizeof(firmware); i += 4) |
704 | writel(htonl(*(u32*)(firmware + i)), mem + PDM_OFFSET + i); | 716 | writel(htonl(*(u32*)(firmware + i)), mem + PDM_OFFSET + i); |
705 | 717 | ||
diff --git a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c index dade4b903579..5b69befdab74 100644 --- a/drivers/net/wireless/wavelan.c +++ b/drivers/net/wireless/wavelan.c | |||
@@ -1695,8 +1695,8 @@ static int wv_frequency_list(unsigned long ioaddr, /* I/O port of the card */ | |||
1695 | /* Look in the table if the frequency is allowed */ | 1695 | /* Look in the table if the frequency is allowed */ |
1696 | if (table[9 - (freq / 16)] & (1 << (freq % 16))) { | 1696 | if (table[9 - (freq / 16)] & (1 << (freq % 16))) { |
1697 | /* Compute approximate channel number */ | 1697 | /* Compute approximate channel number */ |
1698 | while ((((channel_bands[c] >> 1) - 24) < freq) && | 1698 | while ((c < NELS(channel_bands)) && |
1699 | (c < NELS(channel_bands))) | 1699 | (((channel_bands[c] >> 1) - 24) < freq)) |
1700 | c++; | 1700 | c++; |
1701 | list[i].i = c; /* Set the list index */ | 1701 | list[i].i = c; /* Set the list index */ |
1702 | 1702 | ||
@@ -2903,6 +2903,7 @@ static int wavelan_packet_xmit(struct sk_buff *skb, struct net_device * dev) | |||
2903 | { | 2903 | { |
2904 | net_local *lp = (net_local *) dev->priv; | 2904 | net_local *lp = (net_local *) dev->priv; |
2905 | unsigned long flags; | 2905 | unsigned long flags; |
2906 | char data[ETH_ZLEN]; | ||
2906 | 2907 | ||
2907 | #ifdef DEBUG_TX_TRACE | 2908 | #ifdef DEBUG_TX_TRACE |
2908 | printk(KERN_DEBUG "%s: ->wavelan_packet_xmit(0x%X)\n", dev->name, | 2909 | printk(KERN_DEBUG "%s: ->wavelan_packet_xmit(0x%X)\n", dev->name, |
@@ -2937,15 +2938,16 @@ static int wavelan_packet_xmit(struct sk_buff *skb, struct net_device * dev) | |||
2937 | * able to detect collisions, therefore in theory we don't really | 2938 | * able to detect collisions, therefore in theory we don't really |
2938 | * need to pad. Jean II */ | 2939 | * need to pad. Jean II */ |
2939 | if (skb->len < ETH_ZLEN) { | 2940 | if (skb->len < ETH_ZLEN) { |
2940 | skb = skb_padto(skb, ETH_ZLEN); | 2941 | memset(data, 0, ETH_ZLEN); |
2941 | if (skb == NULL) | 2942 | memcpy(data, skb->data, skb->len); |
2942 | return 0; | 2943 | /* Write packet on the card */ |
2944 | if(wv_packet_write(dev, data, ETH_ZLEN)) | ||
2945 | return 1; /* We failed */ | ||
2943 | } | 2946 | } |
2944 | 2947 | else if(wv_packet_write(dev, skb->data, skb->len)) | |
2945 | /* Write packet on the card */ | ||
2946 | if(wv_packet_write(dev, skb->data, skb->len)) | ||
2947 | return 1; /* We failed */ | 2948 | return 1; /* We failed */ |
2948 | 2949 | ||
2950 | |||
2949 | dev_kfree_skb(skb); | 2951 | dev_kfree_skb(skb); |
2950 | 2952 | ||
2951 | #ifdef DEBUG_TX_TRACE | 2953 | #ifdef DEBUG_TX_TRACE |