18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: ISC
28c2ecf20Sopenharmony_ci/* Copyright (C) 2020 MediaTek Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Author: Sean Wang <sean.wang@mediatek.com>
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef __MT76S_H
88c2ecf20Sopenharmony_ci#define __MT76S_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#define MT_PSE_PAGE_SZ			128
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define MCR_WCIR			0x0000
138c2ecf20Sopenharmony_ci#define MCR_WHLPCR			0x0004
148c2ecf20Sopenharmony_ci#define WHLPCR_FW_OWN_REQ_CLR		BIT(9)
158c2ecf20Sopenharmony_ci#define WHLPCR_FW_OWN_REQ_SET		BIT(8)
168c2ecf20Sopenharmony_ci#define WHLPCR_IS_DRIVER_OWN		BIT(8)
178c2ecf20Sopenharmony_ci#define WHLPCR_INT_EN_CLR		BIT(1)
188c2ecf20Sopenharmony_ci#define WHLPCR_INT_EN_SET		BIT(0)
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define MCR_WSDIOCSR			0x0008
218c2ecf20Sopenharmony_ci#define MCR_WHCR			0x000C
228c2ecf20Sopenharmony_ci#define W_INT_CLR_CTRL			BIT(1)
238c2ecf20Sopenharmony_ci#define RECV_MAILBOX_RD_CLR_EN		BIT(2)
248c2ecf20Sopenharmony_ci#define MAX_HIF_RX_LEN_NUM		GENMASK(13, 8)
258c2ecf20Sopenharmony_ci#define RX_ENHANCE_MODE			BIT(16)
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define MCR_WHISR			0x0010
288c2ecf20Sopenharmony_ci#define MCR_WHIER			0x0014
298c2ecf20Sopenharmony_ci#define WHIER_D2H_SW_INT		GENMASK(31, 8)
308c2ecf20Sopenharmony_ci#define WHIER_FW_OWN_BACK_INT_EN	BIT(7)
318c2ecf20Sopenharmony_ci#define WHIER_ABNORMAL_INT_EN		BIT(6)
328c2ecf20Sopenharmony_ci#define WHIER_RX1_DONE_INT_EN		BIT(2)
338c2ecf20Sopenharmony_ci#define WHIER_RX0_DONE_INT_EN		BIT(1)
348c2ecf20Sopenharmony_ci#define WHIER_TX_DONE_INT_EN		BIT(0)
358c2ecf20Sopenharmony_ci#define WHIER_DEFAULT			(WHIER_RX0_DONE_INT_EN	| \
368c2ecf20Sopenharmony_ci					 WHIER_RX1_DONE_INT_EN	| \
378c2ecf20Sopenharmony_ci					 WHIER_TX_DONE_INT_EN	| \
388c2ecf20Sopenharmony_ci					 WHIER_ABNORMAL_INT_EN	| \
398c2ecf20Sopenharmony_ci					 WHIER_D2H_SW_INT)
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define MCR_WASR			0x0020
428c2ecf20Sopenharmony_ci#define MCR_WSICR			0x0024
438c2ecf20Sopenharmony_ci#define MCR_WTSR0			0x0028
448c2ecf20Sopenharmony_ci#define TQ0_CNT				GENMASK(7, 0)
458c2ecf20Sopenharmony_ci#define TQ1_CNT				GENMASK(15, 8)
468c2ecf20Sopenharmony_ci#define TQ2_CNT				GENMASK(23, 16)
478c2ecf20Sopenharmony_ci#define TQ3_CNT				GENMASK(31, 24)
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#define MCR_WTSR1			0x002c
508c2ecf20Sopenharmony_ci#define TQ4_CNT				GENMASK(7, 0)
518c2ecf20Sopenharmony_ci#define TQ5_CNT				GENMASK(15, 8)
528c2ecf20Sopenharmony_ci#define TQ6_CNT				GENMASK(23, 16)
538c2ecf20Sopenharmony_ci#define TQ7_CNT				GENMASK(31, 24)
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#define MCR_WTDR1			0x0034
568c2ecf20Sopenharmony_ci#define MCR_WRDR0			0x0050
578c2ecf20Sopenharmony_ci#define MCR_WRDR1			0x0054
588c2ecf20Sopenharmony_ci#define MCR_WRDR(p)			(0x0050 + 4 * (p))
598c2ecf20Sopenharmony_ci#define MCR_H2DSM0R			0x0070
608c2ecf20Sopenharmony_ci#define H2D_SW_INT_READ			BIT(16)
618c2ecf20Sopenharmony_ci#define H2D_SW_INT_WRITE		BIT(17)
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#define MCR_H2DSM1R			0x0074
648c2ecf20Sopenharmony_ci#define MCR_D2HRM0R			0x0078
658c2ecf20Sopenharmony_ci#define MCR_D2HRM1R			0x007c
668c2ecf20Sopenharmony_ci#define MCR_D2HRM2R			0x0080
678c2ecf20Sopenharmony_ci#define MCR_WRPLR			0x0090
688c2ecf20Sopenharmony_ci#define RX0_PACKET_LENGTH		GENMASK(15, 0)
698c2ecf20Sopenharmony_ci#define RX1_PACKET_LENGTH		GENMASK(31, 16)
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define MCR_WTMDR			0x00b0
728c2ecf20Sopenharmony_ci#define MCR_WTMCR			0x00b4
738c2ecf20Sopenharmony_ci#define MCR_WTMDPCR0			0x00b8
748c2ecf20Sopenharmony_ci#define MCR_WTMDPCR1			0x00bc
758c2ecf20Sopenharmony_ci#define MCR_WPLRCR			0x00d4
768c2ecf20Sopenharmony_ci#define MCR_WSR				0x00D8
778c2ecf20Sopenharmony_ci#define MCR_CLKIOCR			0x0100
788c2ecf20Sopenharmony_ci#define MCR_CMDIOCR			0x0104
798c2ecf20Sopenharmony_ci#define MCR_DAT0IOCR			0x0108
808c2ecf20Sopenharmony_ci#define MCR_DAT1IOCR			0x010C
818c2ecf20Sopenharmony_ci#define MCR_DAT2IOCR			0x0110
828c2ecf20Sopenharmony_ci#define MCR_DAT3IOCR			0x0114
838c2ecf20Sopenharmony_ci#define MCR_CLKDLYCR			0x0118
848c2ecf20Sopenharmony_ci#define MCR_CMDDLYCR			0x011C
858c2ecf20Sopenharmony_ci#define MCR_ODATDLYCR			0x0120
868c2ecf20Sopenharmony_ci#define MCR_IDATDLYCR1			0x0124
878c2ecf20Sopenharmony_ci#define MCR_IDATDLYCR2			0x0128
888c2ecf20Sopenharmony_ci#define MCR_ILCHCR			0x012C
898c2ecf20Sopenharmony_ci#define MCR_WTQCR0			0x0130
908c2ecf20Sopenharmony_ci#define MCR_WTQCR1			0x0134
918c2ecf20Sopenharmony_ci#define MCR_WTQCR2			0x0138
928c2ecf20Sopenharmony_ci#define MCR_WTQCR3			0x013C
938c2ecf20Sopenharmony_ci#define MCR_WTQCR4			0x0140
948c2ecf20Sopenharmony_ci#define MCR_WTQCR5			0x0144
958c2ecf20Sopenharmony_ci#define MCR_WTQCR6			0x0148
968c2ecf20Sopenharmony_ci#define MCR_WTQCR7			0x014C
978c2ecf20Sopenharmony_ci#define MCR_WTQCR(x)                   (0x130 + 4 * (x))
988c2ecf20Sopenharmony_ci#define TXQ_CNT_L			GENMASK(15, 0)
998c2ecf20Sopenharmony_ci#define TXQ_CNT_H			GENMASK(31, 16)
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#define MCR_SWPCDBGR			0x0154
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_cistruct mt76s_intr {
1048c2ecf20Sopenharmony_ci	u32 isr;
1058c2ecf20Sopenharmony_ci	struct {
1068c2ecf20Sopenharmony_ci		u32 wtqcr[8];
1078c2ecf20Sopenharmony_ci	} tx;
1088c2ecf20Sopenharmony_ci	struct {
1098c2ecf20Sopenharmony_ci		u16 num[2];
1108c2ecf20Sopenharmony_ci		u16 len[2][16];
1118c2ecf20Sopenharmony_ci	} rx;
1128c2ecf20Sopenharmony_ci	u32 rec_mb[2];
1138c2ecf20Sopenharmony_ci} __packed;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#endif
116