forked from openwrt/mt76
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mt76: add mt76x02_dma_enable/mt76x02_dma_disable utility routines
Introduce mt76x02_dma_enable and mt76x02_dma_disable utility routines in order to be reused in mt76x0 mac configuration and remove duplicated code Signed-off-by: Lorenzo Bianconi <[email protected]>
- Loading branch information
1 parent
3a3554a
commit 0527feb
Showing
4 changed files
with
57 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2016 Felix Fietkau <[email protected]> | ||
* Copyright (C) 2018 Lorenzo Bianconi <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#include <linux/kernel.h> | ||
|
||
#include "mt76.h" | ||
#include "mt76x02_dma.h" | ||
#include "mt76x02_regs.h" | ||
|
||
void mt76x02_dma_enable(struct mt76_dev *dev) | ||
{ | ||
u32 val; | ||
|
||
__mt76_wr(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_ENABLE_TX); | ||
mt76x02_wait_for_wpdma(dev, 1000); | ||
usleep_range(50, 100); | ||
|
||
val = FIELD_PREP(MT_WPDMA_GLO_CFG_DMA_BURST_SIZE, 3) | | ||
MT_WPDMA_GLO_CFG_TX_DMA_EN | | ||
MT_WPDMA_GLO_CFG_RX_DMA_EN; | ||
__mt76_set(dev, MT_WPDMA_GLO_CFG, val); | ||
__mt76_clear(dev, MT_WPDMA_GLO_CFG, | ||
MT_WPDMA_GLO_CFG_TX_WRITEBACK_DONE); | ||
} | ||
EXPORT_SYMBOL_GPL(mt76x02_dma_enable); | ||
|
||
void mt76x02_dma_disable(struct mt76_dev *dev) | ||
{ | ||
u32 val = __mt76_rr(dev, MT_WPDMA_GLO_CFG); | ||
|
||
val &= MT_WPDMA_GLO_CFG_DMA_BURST_SIZE | | ||
MT_WPDMA_GLO_CFG_BIG_ENDIAN | | ||
MT_WPDMA_GLO_CFG_HDR_SEG_LEN; | ||
val |= MT_WPDMA_GLO_CFG_TX_WRITEBACK_DONE; | ||
__mt76_wr(dev, MT_WPDMA_GLO_CFG, val); | ||
} | ||
EXPORT_SYMBOL_GPL(mt76x02_dma_disable); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters