aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Romieu <romieu@fr.zoreil.com>2007-11-28 16:31:00 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:04:15 -0500
commit6c3231035d7ec31b3830daebd4c742e0b7471661 (patch)
tree6da44de741ca77e09f752777630350cf5be8a8e9
parent5125a786680df0d6d31aad53bc23e19f51a30509 (diff)
r6040: remove virt_to_bus
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
-rw-r--r--drivers/net/r6040.c103
1 files changed, 50 insertions, 53 deletions
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index 6a6329e64123..a106add09fee 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -126,8 +126,8 @@
126#define TX_DCNT 0x80 /* TX descriptor count */ 126#define TX_DCNT 0x80 /* TX descriptor count */
127#define RX_DCNT 0x80 /* RX descriptor count */ 127#define RX_DCNT 0x80 /* RX descriptor count */
128#define MAX_BUF_SIZE 0x600 128#define MAX_BUF_SIZE 0x600
129#define ALLOC_DESC_SIZE ((TX_DCNT+RX_DCNT) * \ 129#define RX_DESC_SIZE (RX_DCNT * sizeof(struct r6040_descriptor))
130 sizeof(struct r6040_descriptor) + 0x10) 130#define TX_DESC_SIZE (TX_DCNT * sizeof(struct r6040_descriptor))
131#define MBCR_DEFAULT 0x012A /* MAC Bus Control Register */ 131#define MBCR_DEFAULT 0x012A /* MAC Bus Control Register */
132#define MCAST_MAX 4 /* Max number multicast addresses to filter */ 132#define MCAST_MAX 4 /* Max number multicast addresses to filter */
133 133
@@ -164,10 +164,12 @@ struct r6040_private {
164 struct r6040_descriptor *rx_remove_ptr; 164 struct r6040_descriptor *rx_remove_ptr;
165 struct r6040_descriptor *tx_insert_ptr; 165 struct r6040_descriptor *tx_insert_ptr;
166 struct r6040_descriptor *tx_remove_ptr; 166 struct r6040_descriptor *tx_remove_ptr;
167 struct r6040_descriptor *rx_ring;
168 struct r6040_descriptor *tx_ring;
169 dma_addr_t rx_ring_dma;
170 dma_addr_t tx_ring_dma;
167 u16 tx_free_desc, rx_free_desc, phy_addr, phy_mode; 171 u16 tx_free_desc, rx_free_desc, phy_addr, phy_mode;
168 u16 mcr0, mcr1; 172 u16 mcr0, mcr1;
169 dma_addr_t desc_dma;
170 char *desc_pool;
171 u16 switch_sig; 173 u16 switch_sig;
172 struct net_device *dev; 174 struct net_device *dev;
173 struct mii_if_info mii_if; 175 struct mii_if_info mii_if;
@@ -291,6 +293,7 @@ static void r6040_down(struct net_device *dev)
291{ 293{
292 struct r6040_private *lp = netdev_priv(dev); 294 struct r6040_private *lp = netdev_priv(dev);
293 void __iomem *ioaddr = lp->base; 295 void __iomem *ioaddr = lp->base;
296 struct pci_dev *pdev = lp->pdev;
294 int i; 297 int i;
295 int limit = 2048; 298 int limit = 2048;
296 u16 *adrp; 299 u16 *adrp;
@@ -334,8 +337,8 @@ static void r6040_down(struct net_device *dev)
334 } 337 }
335 338
336 /* Free Descriptor memory */ 339 /* Free Descriptor memory */
337 pci_free_consistent(lp->pdev, ALLOC_DESC_SIZE, 340 pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
338 lp->desc_pool, lp->desc_dma); 341 pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
339} 342}
340 343
341static int 344static int
@@ -577,67 +580,53 @@ static void r6040_poll_controller(struct net_device *dev)
577#endif 580#endif
578 581
579 582
583static void r6040_init_ring_desc(struct r6040_descriptor *desc_ring,
584 dma_addr_t desc_dma, int size)
585{
586 struct r6040_descriptor *desc = desc_ring;
587 dma_addr_t mapping = desc_dma;
588
589 while (size-- > 0) {
590 mapping += sizeof(sizeof(*desc));
591 desc->ndesc = cpu_to_le32(mapping);
592 desc->vndescp = desc + 1;
593 desc++;
594 }
595 desc--;
596 desc->ndesc = cpu_to_le32(desc_dma);
597 desc->vndescp = desc_ring;
598}
599
580/* Init RDC MAC */ 600/* Init RDC MAC */
581static void r6040_up(struct net_device *dev) 601static void r6040_up(struct net_device *dev)
582{ 602{
583 struct r6040_private *lp = netdev_priv(dev); 603 struct r6040_private *lp = netdev_priv(dev);
584 struct r6040_descriptor *descptr;
585 void __iomem *ioaddr = lp->base; 604 void __iomem *ioaddr = lp->base;
586 int i;
587 __le32 tmp_addr;
588 dma_addr_t desc_dma, start_dma;
589 605
590 /* Initialize */ 606 /* Initialize */
591 lp->tx_free_desc = TX_DCNT; 607 lp->tx_free_desc = TX_DCNT;
592 lp->rx_free_desc = 0; 608 lp->rx_free_desc = 0;
593 /* Init descriptor */ 609 /* Init descriptor */
594 memset(lp->desc_pool, 0, ALLOC_DESC_SIZE); /* Let all descriptor = 0 */ 610 lp->tx_remove_ptr = lp->tx_insert_ptr = lp->tx_ring;
595 lp->tx_insert_ptr = (struct r6040_descriptor *)lp->desc_pool; 611 lp->rx_remove_ptr = lp->rx_insert_ptr = lp->rx_ring;
596 lp->tx_remove_ptr = lp->tx_insert_ptr;
597 lp->rx_insert_ptr = (struct r6040_descriptor *)lp->tx_insert_ptr +
598 TX_DCNT;
599 lp->rx_remove_ptr = lp->rx_insert_ptr;
600 /* Init TX descriptor */ 612 /* Init TX descriptor */
601 descptr = lp->tx_insert_ptr; 613 r6040_init_ring_desc(lp->tx_ring, lp->tx_ring_dma, TX_DCNT);
602 desc_dma = lp->desc_dma;
603 start_dma = desc_dma;
604 for (i = 0; i < TX_DCNT; i++) {
605 descptr->ndesc = cpu_to_le32(desc_dma +
606 sizeof(struct r6040_descriptor));
607 descptr->vndescp = (descptr + 1);
608 descptr = (descptr + 1);
609 desc_dma += sizeof(struct r6040_descriptor);
610 }
611 (descptr - 1)->ndesc = cpu_to_le32(start_dma);
612 (descptr - 1)->vndescp = lp->tx_insert_ptr;
613 614
614 /* Init RX descriptor */ 615 /* Init RX descriptor */
615 start_dma = desc_dma; 616 r6040_init_ring_desc(lp->rx_ring, lp->rx_ring_dma, RX_DCNT);
616 descptr = lp->rx_insert_ptr;
617 for (i = 0; i < RX_DCNT; i++) {
618 descptr->ndesc = cpu_to_le32(desc_dma +
619 sizeof(struct r6040_descriptor));
620 descptr->vndescp = (descptr + 1);
621 descptr = (descptr + 1);
622 desc_dma += sizeof(struct r6040_descriptor);
623 }
624 (descptr - 1)->ndesc = cpu_to_le32(start_dma);
625 (descptr - 1)->vndescp = lp->rx_insert_ptr;
626 617
627 /* Allocate buffer for RX descriptor */ 618 /* Allocate buffer for RX descriptor */
628 rx_buf_alloc(lp, dev); 619 rx_buf_alloc(lp, dev);
629 620
630 /* TX and RX descriptor start Register */ 621 /*
631 tmp_addr = cpu_to_le32((u32)lp->tx_insert_ptr); 622 * TX and RX descriptor start registers.
632 tmp_addr = virt_to_bus((volatile void *)tmp_addr); 623 * Lower 16-bits to MxD_SA0. Higher 16-bits to MxD_SA1.
633 /* Lower 16-bits to MTD_SA0 */ 624 */
634 iowrite16(tmp_addr, ioaddr + MTD_SA0); 625 iowrite16(lp->tx_ring_dma, ioaddr + MTD_SA0);
635 /* Higher 16-bits to MTD_SA1 */ 626 iowrite16(lp->tx_ring_dma >> 16, ioaddr + MTD_SA1);
636 iowrite16((u16)(tmp_addr >> 16), ioaddr + MTD_SA1); 627
637 tmp_addr = cpu_to_le32((u32)lp->rx_insert_ptr); 628 iowrite16(lp->rx_ring_dma, ioaddr + MRD_SA0);
638 tmp_addr = virt_to_bus((volatile void *)tmp_addr); 629 iowrite16(lp->rx_ring_dma >> 16, ioaddr + MRD_SA1);
639 iowrite16(tmp_addr, ioaddr + MRD_SA0);
640 iowrite16((u16)(tmp_addr >> 16), ioaddr + MRD_SA1);
641 630
642 /* Buffer Size Register */ 631 /* Buffer Size Register */
643 iowrite16(MAX_BUF_SIZE, ioaddr + MR_BSR); 632 iowrite16(MAX_BUF_SIZE, ioaddr + MR_BSR);
@@ -743,10 +732,18 @@ r6040_open(struct net_device *dev)
743 r6040_mac_address(dev); 732 r6040_mac_address(dev);
744 733
745 /* Allocate Descriptor memory */ 734 /* Allocate Descriptor memory */
746 lp->desc_pool = pci_alloc_consistent(lp->pdev, 735 lp->rx_ring =
747 ALLOC_DESC_SIZE, &lp->desc_dma); 736 pci_alloc_consistent(lp->pdev, RX_DESC_SIZE, &lp->rx_ring_dma);
748 if (!lp->desc_pool) 737 if (!lp->rx_ring)
738 return -ENOMEM;
739
740 lp->tx_ring =
741 pci_alloc_consistent(lp->pdev, TX_DESC_SIZE, &lp->tx_ring_dma);
742 if (!lp->tx_ring) {
743 pci_free_consistent(lp->pdev, RX_DESC_SIZE, lp->rx_ring,
744 lp->rx_ring_dma);
749 return -ENOMEM; 745 return -ENOMEM;
746 }
750 747
751 r6040_up(dev); 748 r6040_up(dev);
752 749