1 /*
2  * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 #ifndef __MT76_DMA_H
17 #define __MT76_DMA_H
18 
19 #define MT_RING_SIZE			0x10
20 
21 #define MT_DMA_CTL_SD_LEN1		GENMASK(13, 0)
22 #define MT_DMA_CTL_LAST_SEC1		BIT(14)
23 #define MT_DMA_CTL_BURST		BIT(15)
24 #define MT_DMA_CTL_SD_LEN0		GENMASK(29, 16)
25 #define MT_DMA_CTL_LAST_SEC0		BIT(30)
26 #define MT_DMA_CTL_DMA_DONE		BIT(31)
27 
28 #define MT_DMA_HDR_LEN			4
29 #define MT_RX_INFO_LEN			4
30 #define MT_FCE_INFO_LEN			4
31 #define MT_RX_RXWI_LEN			32
32 
33 struct mt76_desc {
34 	__le32 buf0;
35 	__le32 ctrl;
36 	__le32 buf1;
37 	__le32 info;
38 } __packed __aligned(4);
39 
40 enum mt76_qsel {
41 	MT_QSEL_MGMT,
42 	MT_QSEL_HCCA,
43 	MT_QSEL_EDCA,
44 	MT_QSEL_EDCA_2,
45 };
46 
47 enum mt76_mcu_evt_type {
48 	EVT_CMD_DONE,
49 	EVT_CMD_ERROR,
50 	EVT_CMD_RETRY,
51 	EVT_EVENT_PWR_RSP,
52 	EVT_EVENT_WOW_RSP,
53 	EVT_EVENT_CARRIER_DETECT_RSP,
54 	EVT_EVENT_DFS_DETECT_RSP,
55 };
56 
57 void mt76_dma_attach(struct mt76_dev *dev);
58 void mt76_dma_cleanup(struct mt76_dev *dev);
59 
60 #endif
61