diff options
author | Markos Chandras <markos.chandras@imgtec.com> | 2015-03-19 06:28:14 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-20 12:56:40 -0400 |
commit | 87f966d97b89774162df04d2106c6350c8fe4cb3 (patch) | |
tree | 55713ee3440f8fbeaa3b362553182205d442b685 | |
parent | 8e199dfd82ee097b522b00344af6448715d8ee0c (diff) |
net: ethernet: pcnet32: Setup the SRAM and NOUFLO on Am79C97{3, 5}
On a MIPS Malta board, tons of fifo underflow errors have been observed
when using u-boot as bootloader instead of YAMON. The reason for that
is that YAMON used to set the pcnet device to SRAM mode but u-boot does
not. As a result, the default Tx threshold (64 bytes) is now too small to
keep the fifo relatively used and it can result to Tx fifo underflow errors.
As a result of which, it's best to setup the SRAM on supported controllers
so we can always use the NOUFLO bit.
Cc: <netdev@vger.kernel.org>
Cc: <stable@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Cc: Don Fry <pcnet32@frontier.com>
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/amd/pcnet32.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c index 11d6e6561df1..15a8190a6f75 100644 --- a/drivers/net/ethernet/amd/pcnet32.c +++ b/drivers/net/ethernet/amd/pcnet32.c | |||
@@ -1543,7 +1543,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1543 | { | 1543 | { |
1544 | struct pcnet32_private *lp; | 1544 | struct pcnet32_private *lp; |
1545 | int i, media; | 1545 | int i, media; |
1546 | int fdx, mii, fset, dxsuflo; | 1546 | int fdx, mii, fset, dxsuflo, sram; |
1547 | int chip_version; | 1547 | int chip_version; |
1548 | char *chipname; | 1548 | char *chipname; |
1549 | struct net_device *dev; | 1549 | struct net_device *dev; |
@@ -1580,7 +1580,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1580 | } | 1580 | } |
1581 | 1581 | ||
1582 | /* initialize variables */ | 1582 | /* initialize variables */ |
1583 | fdx = mii = fset = dxsuflo = 0; | 1583 | fdx = mii = fset = dxsuflo = sram = 0; |
1584 | chip_version = (chip_version >> 12) & 0xffff; | 1584 | chip_version = (chip_version >> 12) & 0xffff; |
1585 | 1585 | ||
1586 | switch (chip_version) { | 1586 | switch (chip_version) { |
@@ -1613,6 +1613,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1613 | chipname = "PCnet/FAST III 79C973"; /* PCI */ | 1613 | chipname = "PCnet/FAST III 79C973"; /* PCI */ |
1614 | fdx = 1; | 1614 | fdx = 1; |
1615 | mii = 1; | 1615 | mii = 1; |
1616 | sram = 1; | ||
1616 | break; | 1617 | break; |
1617 | case 0x2626: | 1618 | case 0x2626: |
1618 | chipname = "PCnet/Home 79C978"; /* PCI */ | 1619 | chipname = "PCnet/Home 79C978"; /* PCI */ |
@@ -1636,6 +1637,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1636 | chipname = "PCnet/FAST III 79C975"; /* PCI */ | 1637 | chipname = "PCnet/FAST III 79C975"; /* PCI */ |
1637 | fdx = 1; | 1638 | fdx = 1; |
1638 | mii = 1; | 1639 | mii = 1; |
1640 | sram = 1; | ||
1639 | break; | 1641 | break; |
1640 | case 0x2628: | 1642 | case 0x2628: |
1641 | chipname = "PCnet/PRO 79C976"; | 1643 | chipname = "PCnet/PRO 79C976"; |
@@ -1664,6 +1666,31 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) | |||
1664 | dxsuflo = 1; | 1666 | dxsuflo = 1; |
1665 | } | 1667 | } |
1666 | 1668 | ||
1669 | /* | ||
1670 | * The Am79C973/Am79C975 controllers come with 12K of SRAM | ||
1671 | * which we can use for the Tx/Rx buffers but most importantly, | ||
1672 | * the use of SRAM allow us to use the BCR18:NOUFLO bit to avoid | ||
1673 | * Tx fifo underflows. | ||
1674 | */ | ||
1675 | if (sram) { | ||
1676 | /* | ||
1677 | * The SRAM is being configured in two steps. First we | ||
1678 | * set the SRAM size in the BCR25:SRAM_SIZE bits. According | ||
1679 | * to the datasheet, each bit corresponds to a 512-byte | ||
1680 | * page so we can have at most 24 pages. The SRAM_SIZE | ||
1681 | * holds the value of the upper 8 bits of the 16-bit SRAM size. | ||
1682 | * The low 8-bits start at 0x00 and end at 0xff. So the | ||
1683 | * address range is from 0x0000 up to 0x17ff. Therefore, | ||
1684 | * the SRAM_SIZE is set to 0x17. The next step is to set | ||
1685 | * the BCR26:SRAM_BND midway through so the Tx and Rx | ||
1686 | * buffers can share the SRAM equally. | ||
1687 | */ | ||
1688 | a->write_bcr(ioaddr, 25, 0x17); | ||
1689 | a->write_bcr(ioaddr, 26, 0xc); | ||
1690 | /* And finally enable the NOUFLO bit */ | ||
1691 | a->write_bcr(ioaddr, 18, a->read_bcr(ioaddr, 18) | (1 << 11)); | ||
1692 | } | ||
1693 | |||
1667 | dev = alloc_etherdev(sizeof(*lp)); | 1694 | dev = alloc_etherdev(sizeof(*lp)); |
1668 | if (!dev) { | 1695 | if (!dev) { |
1669 | ret = -ENOMEM; | 1696 | ret = -ENOMEM; |