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 <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
5f1fa4cdb7
commit
208856493e
@ -16,7 +16,7 @@ CFLAGS_trace.o := -I$(src)
|
||||
CFLAGS_usb_trace.o := -I$(src)
|
||||
|
||||
mt76x02-lib-y := mt76x02_util.o mt76x02_mac.o mt76x02_mcu.o \
|
||||
mt76x02_eeprom.o mt76x02_phy.o
|
||||
mt76x02_eeprom.o mt76x02_phy.o mt76x02_mmio.o
|
||||
|
||||
mt76x02-usb-y := mt76x02_usb_mcu.o mt76x02_usb_core.o
|
||||
|
||||
|
@ -67,4 +67,7 @@ mt76x02_wait_for_wpdma(struct mt76_dev *dev, int timeout)
|
||||
0, timeout);
|
||||
}
|
||||
|
||||
void mt76x02_dma_enable(struct mt76_dev *dev);
|
||||
void mt76x02_dma_disable(struct mt76_dev *dev);
|
||||
|
||||
#endif /* __MT76x02_DMA_H */
|
||||
|
51
drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c
Normal file
51
drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
|
||||
* Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
|
||||
*
|
||||
* 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);
|
@ -206,16 +206,7 @@ int mt76x2_mac_start(struct mt76x2_dev *dev)
|
||||
|
||||
memset(dev->aggr_stats, 0, sizeof(dev->aggr_stats));
|
||||
|
||||
mt76_wr(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_ENABLE_TX);
|
||||
mt76x02_wait_for_wpdma(&dev->mt76, 1000);
|
||||
usleep_range(50, 100);
|
||||
|
||||
mt76_set(dev, MT_WPDMA_GLO_CFG,
|
||||
MT_WPDMA_GLO_CFG_TX_DMA_EN |
|
||||
MT_WPDMA_GLO_CFG_RX_DMA_EN);
|
||||
|
||||
mt76_clear(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_TX_WRITEBACK_DONE);
|
||||
|
||||
mt76x02_dma_enable(&dev->mt76);
|
||||
mt76_wr(dev, MT_RX_FILTR_CFG, dev->mt76.rxfilter);
|
||||
|
||||
mt76_wr(dev, MT_MAC_SYS_CTRL,
|
||||
@ -354,20 +345,13 @@ int mt76x2_init_hardware(struct mt76x2_dev *dev)
|
||||
0xc000,
|
||||
0xc000,
|
||||
};
|
||||
u32 val;
|
||||
int ret;
|
||||
|
||||
dev->beacon_offsets = beacon_offsets;
|
||||
tasklet_init(&dev->pre_tbtt_tasklet, mt76x2_pre_tbtt_tasklet,
|
||||
(unsigned long) dev);
|
||||
|
||||
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);
|
||||
|
||||
mt76x02_dma_disable(&dev->mt76);
|
||||
mt76x2_reset_wlan(dev, true);
|
||||
mt76x2_power_on(dev);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user