Skip to content

Commit

Permalink
pasemi_mac: Move RX/TX section enablement to dma_lib
Browse files Browse the repository at this point in the history
Also stop both rx and tx sections before changing the configuration of
the dma device during init.

Signed-off-by: Olof Johansson <olof@lixom.net>
Acked-by: Jeff Garzik <jgarzik@pobox.com>
  • Loading branch information
Olof Johansson committed Mar 5, 2008
1 parent 6a2d322 commit afea327
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
30 changes: 30 additions & 0 deletions arch/powerpc/platforms/pasemi/dma_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/pci.h>
Expand Down Expand Up @@ -410,6 +411,7 @@ int pasemi_dma_init(void)
struct resource res;
struct device_node *dn;
int i, intf, err = 0;
unsigned long timeout;
u32 tmp;

if (!machine_is(pasemi))
Expand Down Expand Up @@ -478,6 +480,34 @@ int pasemi_dma_init(void)
for (i = 0; i < MAX_RXCH; i++)
__set_bit(i, rxch_free);

timeout = jiffies + HZ;
pasemi_write_dma_reg(PAS_DMA_COM_RXCMD, 0);
while (pasemi_read_dma_reg(PAS_DMA_COM_RXSTA) & 1) {
if (time_after(jiffies, timeout)) {
pr_warning("Warning: Could not disable RX section\n");
break;
}
}

timeout = jiffies + HZ;
pasemi_write_dma_reg(PAS_DMA_COM_TXCMD, 0);
while (pasemi_read_dma_reg(PAS_DMA_COM_TXSTA) & 1) {
if (time_after(jiffies, timeout)) {
pr_warning("Warning: Could not disable TX section\n");
break;
}
}

/* setup resource allocations for the different DMA sections */
tmp = pasemi_read_dma_reg(PAS_DMA_COM_CFG);
pasemi_write_dma_reg(PAS_DMA_COM_CFG, tmp | 0x18000000);

/* enable tx section */
pasemi_write_dma_reg(PAS_DMA_COM_TXCMD, PAS_DMA_COM_TXCMD_EN);

/* enable rx section */
pasemi_write_dma_reg(PAS_DMA_COM_RXCMD, PAS_DMA_COM_RXCMD_EN);

printk(KERN_INFO "PA Semi PWRficient DMA library initialized "
"(%d tx, %d rx channels)\n", num_txch, num_rxch);

Expand Down
6 changes: 0 additions & 6 deletions drivers/net/pasemi_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,12 +1043,6 @@ static int pasemi_mac_open(struct net_device *dev)
unsigned int flags;
int ret;

/* enable rx section */
write_dma_reg(PAS_DMA_COM_RXCMD, PAS_DMA_COM_RXCMD_EN);

/* enable tx section */
write_dma_reg(PAS_DMA_COM_TXCMD, PAS_DMA_COM_TXCMD_EN);

flags = PAS_MAC_CFG_TXP_FCE | PAS_MAC_CFG_TXP_FPC(3) |
PAS_MAC_CFG_TXP_SL(3) | PAS_MAC_CFG_TXP_COB(0xf) |
PAS_MAC_CFG_TXP_TIFT(8) | PAS_MAC_CFG_TXP_TIFG(12);
Expand Down
7 changes: 6 additions & 1 deletion include/asm-powerpc/pasemi_dma.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2006 PA Semi, Inc
* Copyright (C) 2006-2008 PA Semi, Inc
*
* Hardware register layout and descriptor formats for the on-board
* DMA engine on PA Semi PWRficient. Used by ethernet, function and security
Expand Down Expand Up @@ -40,6 +40,11 @@ enum {
PAS_DMA_COM_TXSTA = 0x104, /* Transmit Status Register */
PAS_DMA_COM_RXCMD = 0x108, /* Receive Command Register */
PAS_DMA_COM_RXSTA = 0x10c, /* Receive Status Register */
PAS_DMA_COM_CFG = 0x114, /* Common config reg */
PAS_DMA_TXF_SFLG0 = 0x140, /* Set flags */
PAS_DMA_TXF_SFLG1 = 0x144, /* Set flags */
PAS_DMA_TXF_CFLG0 = 0x148, /* Set flags */
PAS_DMA_TXF_CFLG1 = 0x14c, /* Set flags */
};


Expand Down

0 comments on commit afea327

Please sign in to comment.