18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: ISC */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef __MT76x02_DMA_H 78c2ecf20Sopenharmony_ci#define __MT76x02_DMA_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include "mt76x02.h" 108c2ecf20Sopenharmony_ci#include "dma.h" 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#define MT_TXD_INFO_LEN GENMASK(15, 0) 138c2ecf20Sopenharmony_ci#define MT_TXD_INFO_NEXT_VLD BIT(16) 148c2ecf20Sopenharmony_ci#define MT_TXD_INFO_TX_BURST BIT(17) 158c2ecf20Sopenharmony_ci#define MT_TXD_INFO_80211 BIT(19) 168c2ecf20Sopenharmony_ci#define MT_TXD_INFO_TSO BIT(20) 178c2ecf20Sopenharmony_ci#define MT_TXD_INFO_CSO BIT(21) 188c2ecf20Sopenharmony_ci#define MT_TXD_INFO_WIV BIT(24) 198c2ecf20Sopenharmony_ci#define MT_TXD_INFO_QSEL GENMASK(26, 25) 208c2ecf20Sopenharmony_ci#define MT_TXD_INFO_DPORT GENMASK(29, 27) 218c2ecf20Sopenharmony_ci#define MT_TXD_INFO_TYPE GENMASK(31, 30) 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define MT_RX_FCE_INFO_LEN GENMASK(13, 0) 248c2ecf20Sopenharmony_ci#define MT_RX_FCE_INFO_SELF_GEN BIT(15) 258c2ecf20Sopenharmony_ci#define MT_RX_FCE_INFO_CMD_SEQ GENMASK(19, 16) 268c2ecf20Sopenharmony_ci#define MT_RX_FCE_INFO_EVT_TYPE GENMASK(23, 20) 278c2ecf20Sopenharmony_ci#define MT_RX_FCE_INFO_PCIE_INTR BIT(24) 288c2ecf20Sopenharmony_ci#define MT_RX_FCE_INFO_QSEL GENMASK(26, 25) 298c2ecf20Sopenharmony_ci#define MT_RX_FCE_INFO_D_PORT GENMASK(29, 27) 308c2ecf20Sopenharmony_ci#define MT_RX_FCE_INFO_TYPE GENMASK(31, 30) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* MCU request message header */ 338c2ecf20Sopenharmony_ci#define MT_MCU_MSG_LEN GENMASK(15, 0) 348c2ecf20Sopenharmony_ci#define MT_MCU_MSG_CMD_SEQ GENMASK(19, 16) 358c2ecf20Sopenharmony_ci#define MT_MCU_MSG_CMD_TYPE GENMASK(26, 20) 368c2ecf20Sopenharmony_ci#define MT_MCU_MSG_PORT GENMASK(29, 27) 378c2ecf20Sopenharmony_ci#define MT_MCU_MSG_TYPE GENMASK(31, 30) 388c2ecf20Sopenharmony_ci#define MT_MCU_MSG_TYPE_CMD BIT(30) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define MT_RX_HEADROOM 32 418c2ecf20Sopenharmony_ci#define MT76X02_RX_RING_SIZE 256 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cienum dma_msg_port { 448c2ecf20Sopenharmony_ci WLAN_PORT, 458c2ecf20Sopenharmony_ci CPU_RX_PORT, 468c2ecf20Sopenharmony_ci CPU_TX_PORT, 478c2ecf20Sopenharmony_ci HOST_PORT, 488c2ecf20Sopenharmony_ci VIRTUAL_CPU_RX_PORT, 498c2ecf20Sopenharmony_ci VIRTUAL_CPU_TX_PORT, 508c2ecf20Sopenharmony_ci DISCARD, 518c2ecf20Sopenharmony_ci}; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic inline bool 548c2ecf20Sopenharmony_cimt76x02_wait_for_wpdma(struct mt76_dev *dev, int timeout) 558c2ecf20Sopenharmony_ci{ 568c2ecf20Sopenharmony_ci return __mt76_poll(dev, MT_WPDMA_GLO_CFG, 578c2ecf20Sopenharmony_ci MT_WPDMA_GLO_CFG_TX_DMA_BUSY | 588c2ecf20Sopenharmony_ci MT_WPDMA_GLO_CFG_RX_DMA_BUSY, 598c2ecf20Sopenharmony_ci 0, timeout); 608c2ecf20Sopenharmony_ci} 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciint mt76x02_dma_init(struct mt76x02_dev *dev); 638c2ecf20Sopenharmony_civoid mt76x02_dma_disable(struct mt76x02_dev *dev); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#endif /* __MT76x02_DMA_H */ 66