From e455f83ca2e4ee7c39837309a422732167994cbf Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Tue, 12 Jul 2011 16:35:24 +0200 Subject: Separate NWL loopback code, provide DMA start/stop interfaces --- dma/nwl_loopback.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 dma/nwl_loopback.c (limited to 'dma/nwl_loopback.c') diff --git a/dma/nwl_loopback.c b/dma/nwl_loopback.c new file mode 100644 index 0000000..9c74b14 --- /dev/null +++ b/dma/nwl_loopback.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include + +#include "pci.h" +#include "pcilib.h" +#include "error.h" +#include "tools.h" +#include "nwl.h" + +#include "nwl_defines.h" + + +int dma_nwl_start_loopback(nwl_dma_t *ctx, pcilib_dma_direction_t direction, size_t packet_size) { + uint32_t val; + + // Re-initializing always + + val = packet_size; + nwl_write_register(val, ctx, ctx->base_addr, PKT_SIZE_ADDRESS); + + switch (direction) { + case PCILIB_DMA_BIDIRECTIONAL: + val = LOOPBACK; + break; + case PCILIB_DMA_TO_DEVICE: + return -1; + case PCILIB_DMA_FROM_DEVICE: + val = PKTGENR; + break; + } + + nwl_write_register(val, ctx, ctx->base_addr, TX_CONFIG_ADDRESS); + nwl_write_register(val, ctx, ctx->base_addr, RX_CONFIG_ADDRESS); + + ctx->loopback_started = 1; + + return 0; +} + +int dma_nwl_stop_loopback(nwl_dma_t *ctx) { + uint32_t val = 0; + + if (ctx->loopback_started) { + nwl_write_register(val, ctx, ctx->base_addr, TX_CONFIG_ADDRESS); + nwl_write_register(val, ctx, ctx->base_addr, RX_CONFIG_ADDRESS); + ctx->loopback_started = 0; + } + + return 0; +} -- cgit v1.2.3