提交 6c323103 编写于 作者: F Francois Romieu 提交者: David S. Miller

r6040: remove virt_to_bus

Signed-off-by: NFrancois Romieu <romieu@fr.zoreil.com>
上级 5125a786
...@@ -126,8 +126,8 @@ ...@@ -126,8 +126,8 @@
#define TX_DCNT 0x80 /* TX descriptor count */ #define TX_DCNT 0x80 /* TX descriptor count */
#define RX_DCNT 0x80 /* RX descriptor count */ #define RX_DCNT 0x80 /* RX descriptor count */
#define MAX_BUF_SIZE 0x600 #define MAX_BUF_SIZE 0x600
#define ALLOC_DESC_SIZE ((TX_DCNT+RX_DCNT) * \ #define RX_DESC_SIZE (RX_DCNT * sizeof(struct r6040_descriptor))
sizeof(struct r6040_descriptor) + 0x10) #define TX_DESC_SIZE (TX_DCNT * sizeof(struct r6040_descriptor))
#define MBCR_DEFAULT 0x012A /* MAC Bus Control Register */ #define MBCR_DEFAULT 0x012A /* MAC Bus Control Register */
#define MCAST_MAX 4 /* Max number multicast addresses to filter */ #define MCAST_MAX 4 /* Max number multicast addresses to filter */
...@@ -164,10 +164,12 @@ struct r6040_private { ...@@ -164,10 +164,12 @@ struct r6040_private {
struct r6040_descriptor *rx_remove_ptr; struct r6040_descriptor *rx_remove_ptr;
struct r6040_descriptor *tx_insert_ptr; struct r6040_descriptor *tx_insert_ptr;
struct r6040_descriptor *tx_remove_ptr; struct r6040_descriptor *tx_remove_ptr;
struct r6040_descriptor *rx_ring;
struct r6040_descriptor *tx_ring;
dma_addr_t rx_ring_dma;
dma_addr_t tx_ring_dma;
u16 tx_free_desc, rx_free_desc, phy_addr, phy_mode; u16 tx_free_desc, rx_free_desc, phy_addr, phy_mode;
u16 mcr0, mcr1; u16 mcr0, mcr1;
dma_addr_t desc_dma;
char *desc_pool;
u16 switch_sig; u16 switch_sig;
struct net_device *dev; struct net_device *dev;
struct mii_if_info mii_if; struct mii_if_info mii_if;
...@@ -291,6 +293,7 @@ static void r6040_down(struct net_device *dev) ...@@ -291,6 +293,7 @@ static void r6040_down(struct net_device *dev)
{ {
struct r6040_private *lp = netdev_priv(dev); struct r6040_private *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->base; void __iomem *ioaddr = lp->base;
struct pci_dev *pdev = lp->pdev;
int i; int i;
int limit = 2048; int limit = 2048;
u16 *adrp; u16 *adrp;
...@@ -334,8 +337,8 @@ static void r6040_down(struct net_device *dev) ...@@ -334,8 +337,8 @@ static void r6040_down(struct net_device *dev)
} }
/* Free Descriptor memory */ /* Free Descriptor memory */
pci_free_consistent(lp->pdev, ALLOC_DESC_SIZE, pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
lp->desc_pool, lp->desc_dma); pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
} }
static int static int
...@@ -577,67 +580,53 @@ static void r6040_poll_controller(struct net_device *dev) ...@@ -577,67 +580,53 @@ static void r6040_poll_controller(struct net_device *dev)
#endif #endif
static void r6040_init_ring_desc(struct r6040_descriptor *desc_ring,
dma_addr_t desc_dma, int size)
{
struct r6040_descriptor *desc = desc_ring;
dma_addr_t mapping = desc_dma;
while (size-- > 0) {
mapping += sizeof(sizeof(*desc));
desc->ndesc = cpu_to_le32(mapping);
desc->vndescp = desc + 1;
desc++;
}
desc--;
desc->ndesc = cpu_to_le32(desc_dma);
desc->vndescp = desc_ring;
}
/* Init RDC MAC */ /* Init RDC MAC */
static void r6040_up(struct net_device *dev) static void r6040_up(struct net_device *dev)
{ {
struct r6040_private *lp = netdev_priv(dev); struct r6040_private *lp = netdev_priv(dev);
struct r6040_descriptor *descptr;
void __iomem *ioaddr = lp->base; void __iomem *ioaddr = lp->base;
int i;
__le32 tmp_addr;
dma_addr_t desc_dma, start_dma;
/* Initialize */ /* Initialize */
lp->tx_free_desc = TX_DCNT; lp->tx_free_desc = TX_DCNT;
lp->rx_free_desc = 0; lp->rx_free_desc = 0;
/* Init descriptor */ /* Init descriptor */
memset(lp->desc_pool, 0, ALLOC_DESC_SIZE); /* Let all descriptor = 0 */ lp->tx_remove_ptr = lp->tx_insert_ptr = lp->tx_ring;
lp->tx_insert_ptr = (struct r6040_descriptor *)lp->desc_pool; lp->rx_remove_ptr = lp->rx_insert_ptr = lp->rx_ring;
lp->tx_remove_ptr = lp->tx_insert_ptr;
lp->rx_insert_ptr = (struct r6040_descriptor *)lp->tx_insert_ptr +
TX_DCNT;
lp->rx_remove_ptr = lp->rx_insert_ptr;
/* Init TX descriptor */ /* Init TX descriptor */
descptr = lp->tx_insert_ptr; r6040_init_ring_desc(lp->tx_ring, lp->tx_ring_dma, TX_DCNT);
desc_dma = lp->desc_dma;
start_dma = desc_dma;
for (i = 0; i < TX_DCNT; i++) {
descptr->ndesc = cpu_to_le32(desc_dma +
sizeof(struct r6040_descriptor));
descptr->vndescp = (descptr + 1);
descptr = (descptr + 1);
desc_dma += sizeof(struct r6040_descriptor);
}
(descptr - 1)->ndesc = cpu_to_le32(start_dma);
(descptr - 1)->vndescp = lp->tx_insert_ptr;
/* Init RX descriptor */ /* Init RX descriptor */
start_dma = desc_dma; r6040_init_ring_desc(lp->rx_ring, lp->rx_ring_dma, RX_DCNT);
descptr = lp->rx_insert_ptr;
for (i = 0; i < RX_DCNT; i++) {
descptr->ndesc = cpu_to_le32(desc_dma +
sizeof(struct r6040_descriptor));
descptr->vndescp = (descptr + 1);
descptr = (descptr + 1);
desc_dma += sizeof(struct r6040_descriptor);
}
(descptr - 1)->ndesc = cpu_to_le32(start_dma);
(descptr - 1)->vndescp = lp->rx_insert_ptr;
/* Allocate buffer for RX descriptor */ /* Allocate buffer for RX descriptor */
rx_buf_alloc(lp, dev); rx_buf_alloc(lp, dev);
/* TX and RX descriptor start Register */ /*
tmp_addr = cpu_to_le32((u32)lp->tx_insert_ptr); * TX and RX descriptor start registers.
tmp_addr = virt_to_bus((volatile void *)tmp_addr); * Lower 16-bits to MxD_SA0. Higher 16-bits to MxD_SA1.
/* Lower 16-bits to MTD_SA0 */ */
iowrite16(tmp_addr, ioaddr + MTD_SA0); iowrite16(lp->tx_ring_dma, ioaddr + MTD_SA0);
/* Higher 16-bits to MTD_SA1 */ iowrite16(lp->tx_ring_dma >> 16, ioaddr + MTD_SA1);
iowrite16((u16)(tmp_addr >> 16), ioaddr + MTD_SA1);
tmp_addr = cpu_to_le32((u32)lp->rx_insert_ptr); iowrite16(lp->rx_ring_dma, ioaddr + MRD_SA0);
tmp_addr = virt_to_bus((volatile void *)tmp_addr); iowrite16(lp->rx_ring_dma >> 16, ioaddr + MRD_SA1);
iowrite16(tmp_addr, ioaddr + MRD_SA0);
iowrite16((u16)(tmp_addr >> 16), ioaddr + MRD_SA1);
/* Buffer Size Register */ /* Buffer Size Register */
iowrite16(MAX_BUF_SIZE, ioaddr + MR_BSR); iowrite16(MAX_BUF_SIZE, ioaddr + MR_BSR);
...@@ -743,10 +732,18 @@ r6040_open(struct net_device *dev) ...@@ -743,10 +732,18 @@ r6040_open(struct net_device *dev)
r6040_mac_address(dev); r6040_mac_address(dev);
/* Allocate Descriptor memory */ /* Allocate Descriptor memory */
lp->desc_pool = pci_alloc_consistent(lp->pdev, lp->rx_ring =
ALLOC_DESC_SIZE, &lp->desc_dma); pci_alloc_consistent(lp->pdev, RX_DESC_SIZE, &lp->rx_ring_dma);
if (!lp->desc_pool) if (!lp->rx_ring)
return -ENOMEM;
lp->tx_ring =
pci_alloc_consistent(lp->pdev, TX_DESC_SIZE, &lp->tx_ring_dma);
if (!lp->tx_ring) {
pci_free_consistent(lp->pdev, RX_DESC_SIZE, lp->rx_ring,
lp->rx_ring_dma);
return -ENOMEM; return -ENOMEM;
}
r6040_up(dev); r6040_up(dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册