18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Definitions for RTL818x hardware
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright 2007 Michael Wu <flamingice@sourmilk.net>
68c2ecf20Sopenharmony_ci * Copyright 2007 Andrea Merello <andrea.merello@gmail.com>
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Based on the r8187 driver, which is:
98c2ecf20Sopenharmony_ci * Copyright 2005 Andrea Merello <andrea.merello@gmail.com>, et al.
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef RTL818X_H
138c2ecf20Sopenharmony_ci#define RTL818X_H
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistruct rtl818x_csr {
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci	u8	MAC[6];
188c2ecf20Sopenharmony_ci	u8	reserved_0[2];
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci	union {
218c2ecf20Sopenharmony_ci		__le32	MAR[2];  /* 0x8 */
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci		struct{ /* rtl8187se */
248c2ecf20Sopenharmony_ci			u8 rf_sw_config; /* 0x8 */
258c2ecf20Sopenharmony_ci			u8 reserved_01[3];
268c2ecf20Sopenharmony_ci			__le32 TMGDA; /* 0xc */
278c2ecf20Sopenharmony_ci		} __packed;
288c2ecf20Sopenharmony_ci	} __packed;
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	union { /*  0x10  */
318c2ecf20Sopenharmony_ci		struct {
328c2ecf20Sopenharmony_ci			u8	RX_FIFO_COUNT;
338c2ecf20Sopenharmony_ci			u8	reserved_1;
348c2ecf20Sopenharmony_ci			u8	TX_FIFO_COUNT;
358c2ecf20Sopenharmony_ci			u8	BQREQ;
368c2ecf20Sopenharmony_ci		} __packed;
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci		__le32 TBKDA; /* for 8187se */
398c2ecf20Sopenharmony_ci	} __packed;
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci	__le32 TBEDA; /* 0x14 - for rtl8187se */
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	__le32	TSFT[2];
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	union { /* 0x20 */
468c2ecf20Sopenharmony_ci		__le32	TLPDA;
478c2ecf20Sopenharmony_ci		__le32  TVIDA; /* for 8187se */
488c2ecf20Sopenharmony_ci	} __packed;
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci	union { /* 0x24 */
518c2ecf20Sopenharmony_ci		__le32	TNPDA;
528c2ecf20Sopenharmony_ci		__le32  TVODA; /* for 8187se */
538c2ecf20Sopenharmony_ci	} __packed;
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci	/* hi pri ring for all cards */
568c2ecf20Sopenharmony_ci	__le32	THPDA; /* 0x28 */
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci	union { /* 0x2c */
598c2ecf20Sopenharmony_ci		struct {
608c2ecf20Sopenharmony_ci			u8 reserved_2a;
618c2ecf20Sopenharmony_ci			u8 EIFS_8187SE;
628c2ecf20Sopenharmony_ci		} __packed;
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci		__le16	BRSR;
658c2ecf20Sopenharmony_ci	} __packed;
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci	u8	BSSID[6]; /* 0x2e */
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	union { /* 0x34 */
708c2ecf20Sopenharmony_ci		struct {
718c2ecf20Sopenharmony_ci			u8 RESP_RATE;
728c2ecf20Sopenharmony_ci			u8 EIFS;
738c2ecf20Sopenharmony_ci		} __packed;
748c2ecf20Sopenharmony_ci		__le16 BRSR_8187SE;
758c2ecf20Sopenharmony_ci	} __packed;
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	u8	reserved_3[1]; /* 0x36 */
788c2ecf20Sopenharmony_ci	u8	CMD; /* 0x37 */
798c2ecf20Sopenharmony_ci#define RTL818X_CMD_TX_ENABLE		(1 << 2)
808c2ecf20Sopenharmony_ci#define RTL818X_CMD_RX_ENABLE		(1 << 3)
818c2ecf20Sopenharmony_ci#define RTL818X_CMD_RESET		(1 << 4)
828c2ecf20Sopenharmony_ci	u8	reserved_4[4]; /* 0x38 */
838c2ecf20Sopenharmony_ci	union {
848c2ecf20Sopenharmony_ci		struct {
858c2ecf20Sopenharmony_ci			__le16	INT_MASK;
868c2ecf20Sopenharmony_ci			__le16	INT_STATUS;
878c2ecf20Sopenharmony_ci		} __packed;
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci		__le32	INT_STATUS_SE; /* 0x3c */
908c2ecf20Sopenharmony_ci	} __packed;
918c2ecf20Sopenharmony_ci/* status bits for rtl8187 and rtl8180/8185 */
928c2ecf20Sopenharmony_ci#define RTL818X_INT_RX_OK		(1 <<  0)
938c2ecf20Sopenharmony_ci#define RTL818X_INT_RX_ERR		(1 <<  1)
948c2ecf20Sopenharmony_ci#define RTL818X_INT_TXL_OK		(1 <<  2)
958c2ecf20Sopenharmony_ci#define RTL818X_INT_TXL_ERR		(1 <<  3)
968c2ecf20Sopenharmony_ci#define RTL818X_INT_RX_DU		(1 <<  4)
978c2ecf20Sopenharmony_ci#define RTL818X_INT_RX_FO		(1 <<  5)
988c2ecf20Sopenharmony_ci#define RTL818X_INT_TXN_OK		(1 <<  6)
998c2ecf20Sopenharmony_ci#define RTL818X_INT_TXN_ERR		(1 <<  7)
1008c2ecf20Sopenharmony_ci#define RTL818X_INT_TXH_OK		(1 <<  8)
1018c2ecf20Sopenharmony_ci#define RTL818X_INT_TXH_ERR		(1 <<  9)
1028c2ecf20Sopenharmony_ci#define RTL818X_INT_TXB_OK		(1 << 10)
1038c2ecf20Sopenharmony_ci#define RTL818X_INT_TXB_ERR		(1 << 11)
1048c2ecf20Sopenharmony_ci#define RTL818X_INT_ATIM		(1 << 12)
1058c2ecf20Sopenharmony_ci#define RTL818X_INT_BEACON		(1 << 13)
1068c2ecf20Sopenharmony_ci#define RTL818X_INT_TIME_OUT		(1 << 14)
1078c2ecf20Sopenharmony_ci#define RTL818X_INT_TX_FO		(1 << 15)
1088c2ecf20Sopenharmony_ci/* status bits for rtl8187se */
1098c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TIMER3		(1 <<  0)
1108c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TIMER2		(1 <<  1)
1118c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_RQ0SOR		(1 <<  2)
1128c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TXBED_OK		(1 <<  3)
1138c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TXBED_ERR	(1 <<  4)
1148c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TXBE_OK		(1 <<  5)
1158c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TXBE_ERR		(1 <<  6)
1168c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_RX_OK		(1 <<  7)
1178c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_RX_ERR		(1 <<  8)
1188c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TXL_OK		(1 <<  9)
1198c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TXL_ERR		(1 << 10)
1208c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_RX_DU		(1 << 11)
1218c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_RX_FIFO		(1 << 12)
1228c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TXN_OK		(1 << 13)
1238c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TXN_ERR		(1 << 14)
1248c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TXH_OK		(1 << 15)
1258c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TXH_ERR		(1 << 16)
1268c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TXB_OK		(1 << 17)
1278c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TXB_ERR		(1 << 18)
1288c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_ATIM_TO		(1 << 19)
1298c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_BK_TO		(1 << 20)
1308c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TIMER1		(1 << 21)
1318c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TX_FIFO		(1 << 22)
1328c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_WAKEUP		(1 << 23)
1338c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_BK_DMA		(1 << 24)
1348c2ecf20Sopenharmony_ci#define RTL818X_INT_SE_TMGD_OK		(1 << 30)
1358c2ecf20Sopenharmony_ci	__le32	TX_CONF; /* 0x40 */
1368c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_LOOPBACK_MAC	(1 << 17)
1378c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_LOOPBACK_CONT	(3 << 17)
1388c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_NO_ICV		(1 << 19)
1398c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_DISCW		(1 << 20)
1408c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_SAT_HWPLCP	(1 << 24)
1418c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_R8180_ABCD	(2 << 25)
1428c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_R8180_F		(3 << 25)
1438c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_R8185_ABC	(4 << 25)
1448c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_R8185_D		(5 << 25)
1458c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_R8187vD		(5 << 25)
1468c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_R8187vD_B	(6 << 25)
1478c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_RTL8187SE	(6 << 25)
1488c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_HWVER_MASK	(7 << 25)
1498c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_DISREQQSIZE	(1 << 28)
1508c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_PROBE_DTS	(1 << 29)
1518c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_HW_SEQNUM	(1 << 30)
1528c2ecf20Sopenharmony_ci#define RTL818X_TX_CONF_CW_MIN		(1 << 31)
1538c2ecf20Sopenharmony_ci	__le32	RX_CONF;
1548c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_MONITOR		(1 <<  0)
1558c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_NICMAC		(1 <<  1)
1568c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_MULTICAST	(1 <<  2)
1578c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_BROADCAST	(1 <<  3)
1588c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_FCS		(1 <<  5)
1598c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_DATA		(1 << 18)
1608c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_CTRL		(1 << 19)
1618c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_MGMT		(1 << 20)
1628c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_ADDR3		(1 << 21)
1638c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_PM		(1 << 22)
1648c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_BSSID		(1 << 23)
1658c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_RX_AUTORESETPHY	(1 << 28)
1668c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_CSDM1		(1 << 29)
1678c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_CSDM2		(1 << 30)
1688c2ecf20Sopenharmony_ci#define RTL818X_RX_CONF_ONLYERLPKT	(1 << 31)
1698c2ecf20Sopenharmony_ci	__le32	INT_TIMEOUT;
1708c2ecf20Sopenharmony_ci	__le32	TBDA;
1718c2ecf20Sopenharmony_ci	u8	EEPROM_CMD;
1728c2ecf20Sopenharmony_ci#define RTL818X_EEPROM_CMD_READ		(1 << 0)
1738c2ecf20Sopenharmony_ci#define RTL818X_EEPROM_CMD_WRITE	(1 << 1)
1748c2ecf20Sopenharmony_ci#define RTL818X_EEPROM_CMD_CK		(1 << 2)
1758c2ecf20Sopenharmony_ci#define RTL818X_EEPROM_CMD_CS		(1 << 3)
1768c2ecf20Sopenharmony_ci#define RTL818X_EEPROM_CMD_NORMAL	(0 << 6)
1778c2ecf20Sopenharmony_ci#define RTL818X_EEPROM_CMD_LOAD		(1 << 6)
1788c2ecf20Sopenharmony_ci#define RTL818X_EEPROM_CMD_PROGRAM	(2 << 6)
1798c2ecf20Sopenharmony_ci#define RTL818X_EEPROM_CMD_CONFIG	(3 << 6)
1808c2ecf20Sopenharmony_ci	u8	CONFIG0;
1818c2ecf20Sopenharmony_ci	u8	CONFIG1;
1828c2ecf20Sopenharmony_ci	u8	CONFIG2;
1838c2ecf20Sopenharmony_ci#define RTL818X_CONFIG2_ANTENNA_DIV	(1 << 6)
1848c2ecf20Sopenharmony_ci	__le32	ANAPARAM;
1858c2ecf20Sopenharmony_ci	u8	MSR;
1868c2ecf20Sopenharmony_ci#define RTL818X_MSR_NO_LINK		(0 << 2)
1878c2ecf20Sopenharmony_ci#define RTL818X_MSR_ADHOC		(1 << 2)
1888c2ecf20Sopenharmony_ci#define RTL818X_MSR_INFRA		(2 << 2)
1898c2ecf20Sopenharmony_ci#define RTL818X_MSR_MASTER		(3 << 2)
1908c2ecf20Sopenharmony_ci#define RTL818X_MSR_ENEDCA		(4 << 2)
1918c2ecf20Sopenharmony_ci	u8	CONFIG3;
1928c2ecf20Sopenharmony_ci#define RTL818X_CONFIG3_ANAPARAM_WRITE	(1 << 6)
1938c2ecf20Sopenharmony_ci#define RTL818X_CONFIG3_GNT_SELECT	(1 << 7)
1948c2ecf20Sopenharmony_ci	u8	CONFIG4;
1958c2ecf20Sopenharmony_ci#define RTL818X_CONFIG4_POWEROFF	(1 << 6)
1968c2ecf20Sopenharmony_ci#define RTL818X_CONFIG4_VCOOFF		(1 << 7)
1978c2ecf20Sopenharmony_ci	u8	TESTR;
1988c2ecf20Sopenharmony_ci	u8	reserved_9[2];
1998c2ecf20Sopenharmony_ci	u8	PGSELECT;
2008c2ecf20Sopenharmony_ci	u8	SECURITY;
2018c2ecf20Sopenharmony_ci	__le32	ANAPARAM2;
2028c2ecf20Sopenharmony_ci	u8	reserved_10[8];
2038c2ecf20Sopenharmony_ci	__le32  IMR;		/* 0x6c	- Interrupt mask reg for 8187se */
2048c2ecf20Sopenharmony_ci#define IMR_TMGDOK      ((1 << 30))
2058c2ecf20Sopenharmony_ci#define IMR_DOT11HINT	((1 << 25))	/* 802.11h Measurement Interrupt */
2068c2ecf20Sopenharmony_ci#define IMR_BCNDMAINT	((1 << 24))	/* Beacon DMA Interrupt */
2078c2ecf20Sopenharmony_ci#define IMR_WAKEINT	((1 << 23))	/* Wake Up Interrupt */
2088c2ecf20Sopenharmony_ci#define IMR_TXFOVW	((1 << 22))	/* Tx FIFO Overflow */
2098c2ecf20Sopenharmony_ci#define IMR_TIMEOUT1	((1 << 21))	/* Time Out Interrupt 1 */
2108c2ecf20Sopenharmony_ci#define IMR_BCNINT	((1 << 20))	/* Beacon Time out */
2118c2ecf20Sopenharmony_ci#define IMR_ATIMINT	((1 << 19))	/* ATIM Time Out */
2128c2ecf20Sopenharmony_ci#define IMR_TBDER	((1 << 18))	/* Tx Beacon Descriptor Error */
2138c2ecf20Sopenharmony_ci#define IMR_TBDOK	((1 << 17))	/* Tx Beacon Descriptor OK */
2148c2ecf20Sopenharmony_ci#define IMR_THPDER	((1 << 16))	/* Tx High Priority Descriptor Error */
2158c2ecf20Sopenharmony_ci#define IMR_THPDOK	((1 << 15))	/* Tx High Priority Descriptor OK */
2168c2ecf20Sopenharmony_ci#define IMR_TVODER	((1 << 14))	/* Tx AC_VO Descriptor Error Int */
2178c2ecf20Sopenharmony_ci#define IMR_TVODOK	((1 << 13))	/* Tx AC_VO Descriptor OK Interrupt */
2188c2ecf20Sopenharmony_ci#define IMR_FOVW	((1 << 12))	/* Rx FIFO Overflow Interrupt */
2198c2ecf20Sopenharmony_ci#define IMR_RDU		((1 << 11))	/* Rx Descriptor Unavailable */
2208c2ecf20Sopenharmony_ci#define IMR_TVIDER	((1 << 10))	/* Tx AC_VI Descriptor Error */
2218c2ecf20Sopenharmony_ci#define IMR_TVIDOK	((1 << 9))	/* Tx AC_VI Descriptor OK Interrupt */
2228c2ecf20Sopenharmony_ci#define IMR_RER		((1 << 8))	/* Rx Error Interrupt */
2238c2ecf20Sopenharmony_ci#define IMR_ROK		((1 << 7))	/* Receive OK Interrupt */
2248c2ecf20Sopenharmony_ci#define IMR_TBEDER	((1 << 6))	/* Tx AC_BE Descriptor Error */
2258c2ecf20Sopenharmony_ci#define IMR_TBEDOK	((1 << 5))	/* Tx AC_BE Descriptor OK */
2268c2ecf20Sopenharmony_ci#define IMR_TBKDER	((1 << 4))	/* Tx AC_BK Descriptor Error */
2278c2ecf20Sopenharmony_ci#define IMR_TBKDOK	((1 << 3))	/* Tx AC_BK Descriptor OK */
2288c2ecf20Sopenharmony_ci#define IMR_RQOSOK	((1 << 2))	/* Rx QoS OK Interrupt */
2298c2ecf20Sopenharmony_ci#define IMR_TIMEOUT2	((1 << 1))	/* Time Out Interrupt 2 */
2308c2ecf20Sopenharmony_ci#define IMR_TIMEOUT3	((1 << 0))	/* Time Out Interrupt 3 */
2318c2ecf20Sopenharmony_ci	__le16	BEACON_INTERVAL; /* 0x70 */
2328c2ecf20Sopenharmony_ci	__le16	ATIM_WND; /*  0x72 */
2338c2ecf20Sopenharmony_ci	__le16	BEACON_INTERVAL_TIME; /*  0x74 */
2348c2ecf20Sopenharmony_ci	__le16	ATIMTR_INTERVAL; /*  0x76 */
2358c2ecf20Sopenharmony_ci	u8	PHY_DELAY; /*  0x78 */
2368c2ecf20Sopenharmony_ci	u8	CARRIER_SENSE_COUNTER; /* 0x79 */
2378c2ecf20Sopenharmony_ci	u8	reserved_11[2]; /* 0x7a */
2388c2ecf20Sopenharmony_ci	u8	PHY[4]; /* 0x7c  */
2398c2ecf20Sopenharmony_ci	__le16	RFPinsOutput; /* 0x80 */
2408c2ecf20Sopenharmony_ci	__le16	RFPinsEnable; /* 0x82 */
2418c2ecf20Sopenharmony_ci	__le16	RFPinsSelect; /* 0x84 */
2428c2ecf20Sopenharmony_ci	__le16	RFPinsInput;  /* 0x86 */
2438c2ecf20Sopenharmony_ci	__le32	RF_PARA; /*  0x88 */
2448c2ecf20Sopenharmony_ci	__le32	RF_TIMING; /*  0x8c */
2458c2ecf20Sopenharmony_ci	u8	GP_ENABLE; /*  0x90 */
2468c2ecf20Sopenharmony_ci	u8	GPIO0; /*  0x91 */
2478c2ecf20Sopenharmony_ci	u8	GPIO1; /*  0x92 */
2488c2ecf20Sopenharmony_ci	u8	TPPOLL_STOP; /*  0x93 - rtl8187se only */
2498c2ecf20Sopenharmony_ci#define RTL818x_TPPOLL_STOP_BQ			(1 << 7)
2508c2ecf20Sopenharmony_ci#define RTL818x_TPPOLL_STOP_VI			(1 << 4)
2518c2ecf20Sopenharmony_ci#define RTL818x_TPPOLL_STOP_VO			(1 << 5)
2528c2ecf20Sopenharmony_ci#define RTL818x_TPPOLL_STOP_BE			(1 << 3)
2538c2ecf20Sopenharmony_ci#define RTL818x_TPPOLL_STOP_BK			(1 << 2)
2548c2ecf20Sopenharmony_ci#define RTL818x_TPPOLL_STOP_MG			(1 << 1)
2558c2ecf20Sopenharmony_ci#define RTL818x_TPPOLL_STOP_HI			(1 << 6)
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci	__le32	HSSI_PARA; /*  0x94 */
2588c2ecf20Sopenharmony_ci	u8	reserved_13[4]; /* 0x98 */
2598c2ecf20Sopenharmony_ci	u8	TX_AGC_CTL; /*  0x9c */
2608c2ecf20Sopenharmony_ci#define RTL818X_TX_AGC_CTL_PERPACKET_GAIN	(1 << 0)
2618c2ecf20Sopenharmony_ci#define RTL818X_TX_AGC_CTL_PERPACKET_ANTSEL	(1 << 1)
2628c2ecf20Sopenharmony_ci#define RTL818X_TX_AGC_CTL_FEEDBACK_ANT		(1 << 2)
2638c2ecf20Sopenharmony_ci	u8	TX_GAIN_CCK;
2648c2ecf20Sopenharmony_ci	u8	TX_GAIN_OFDM;
2658c2ecf20Sopenharmony_ci	u8	TX_ANTENNA;
2668c2ecf20Sopenharmony_ci	u8	reserved_14[16];
2678c2ecf20Sopenharmony_ci	u8	WPA_CONF;
2688c2ecf20Sopenharmony_ci	u8	reserved_15[3];
2698c2ecf20Sopenharmony_ci	u8	SIFS;
2708c2ecf20Sopenharmony_ci	u8	DIFS;
2718c2ecf20Sopenharmony_ci	u8	SLOT;
2728c2ecf20Sopenharmony_ci	u8	reserved_16[5];
2738c2ecf20Sopenharmony_ci	u8	CW_CONF;
2748c2ecf20Sopenharmony_ci#define RTL818X_CW_CONF_PERPACKET_CW	(1 << 0)
2758c2ecf20Sopenharmony_ci#define RTL818X_CW_CONF_PERPACKET_RETRY	(1 << 1)
2768c2ecf20Sopenharmony_ci	u8	CW_VAL;
2778c2ecf20Sopenharmony_ci	u8	RATE_FALLBACK;
2788c2ecf20Sopenharmony_ci#define RTL818X_RATE_FALLBACK_ENABLE	(1 << 7)
2798c2ecf20Sopenharmony_ci	u8	ACM_CONTROL;
2808c2ecf20Sopenharmony_ci	u8	reserved_17[24];
2818c2ecf20Sopenharmony_ci	u8	CONFIG5;
2828c2ecf20Sopenharmony_ci	u8	TX_DMA_POLLING;
2838c2ecf20Sopenharmony_ci	u8	PHY_PR;
2848c2ecf20Sopenharmony_ci	u8	reserved_18;
2858c2ecf20Sopenharmony_ci	__le16	CWR;
2868c2ecf20Sopenharmony_ci	u8	RETRY_CTR;
2878c2ecf20Sopenharmony_ci	u8	reserved_19[3];
2888c2ecf20Sopenharmony_ci	__le16	INT_MIG;
2898c2ecf20Sopenharmony_ci/* RTL818X_R8187B_*: magic numbers from ioregisters */
2908c2ecf20Sopenharmony_ci#define RTL818X_R8187B_B	0
2918c2ecf20Sopenharmony_ci#define RTL818X_R8187B_D	1
2928c2ecf20Sopenharmony_ci#define RTL818X_R8187B_E	2
2938c2ecf20Sopenharmony_ci	__le32	RDSAR;
2948c2ecf20Sopenharmony_ci	__le16	TID_AC_MAP;
2958c2ecf20Sopenharmony_ci	u8	reserved_20[4];
2968c2ecf20Sopenharmony_ci	union {
2978c2ecf20Sopenharmony_ci		__le16	ANAPARAM3; /* 0xee */
2988c2ecf20Sopenharmony_ci		u8	ANAPARAM3A; /* for rtl8187 */
2998c2ecf20Sopenharmony_ci	};
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci#define AC_PARAM_TXOP_LIMIT_SHIFT	16
3028c2ecf20Sopenharmony_ci#define AC_PARAM_ECW_MAX_SHIFT		12
3038c2ecf20Sopenharmony_ci#define AC_PARAM_ECW_MIN_SHIFT		8
3048c2ecf20Sopenharmony_ci#define AC_PARAM_AIFS_SHIFT		0
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci	__le32 AC_VO_PARAM; /* 0xf0 */
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci	union { /* 0xf4 */
3098c2ecf20Sopenharmony_ci		__le32 AC_VI_PARAM;
3108c2ecf20Sopenharmony_ci		__le16 FEMR;
3118c2ecf20Sopenharmony_ci	} __packed;
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	union{ /* 0xf8 */
3148c2ecf20Sopenharmony_ci		__le32  AC_BE_PARAM; /* rtl8187se */
3158c2ecf20Sopenharmony_ci		struct{
3168c2ecf20Sopenharmony_ci			u8      reserved_21[2];
3178c2ecf20Sopenharmony_ci			__le16	TALLY_CNT; /* 0xfa */
3188c2ecf20Sopenharmony_ci		} __packed;
3198c2ecf20Sopenharmony_ci	} __packed;
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci	union {
3228c2ecf20Sopenharmony_ci		u8	TALLY_SEL; /* 0xfc */
3238c2ecf20Sopenharmony_ci		__le32  AC_BK_PARAM;
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci	} __packed;
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci} __packed;
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci/* These are addresses with NON-standard usage.
3308c2ecf20Sopenharmony_ci * They have offsets very far from this struct.
3318c2ecf20Sopenharmony_ci * I don't like to introduce a ton of "reserved"..
3328c2ecf20Sopenharmony_ci * They are for RTL8187SE
3338c2ecf20Sopenharmony_ci */
3348c2ecf20Sopenharmony_ci#define REG_ADDR1(addr)	((u8 __iomem *)priv->map + (addr))
3358c2ecf20Sopenharmony_ci#define REG_ADDR2(addr)	((__le16 __iomem *)priv->map + ((addr) >> 1))
3368c2ecf20Sopenharmony_ci#define REG_ADDR4(addr)	((__le32 __iomem *)priv->map + ((addr) >> 2))
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_ci#define FEMR_SE		REG_ADDR2(0x1D4)
3398c2ecf20Sopenharmony_ci#define ARFR		REG_ADDR2(0x1E0)
3408c2ecf20Sopenharmony_ci#define RFSW_CTRL	REG_ADDR2(0x272)
3418c2ecf20Sopenharmony_ci#define SW_3W_DB0	REG_ADDR2(0x274)
3428c2ecf20Sopenharmony_ci#define SW_3W_DB0_4	REG_ADDR4(0x274)
3438c2ecf20Sopenharmony_ci#define SW_3W_DB1	REG_ADDR2(0x278)
3448c2ecf20Sopenharmony_ci#define SW_3W_DB1_4	REG_ADDR4(0x278)
3458c2ecf20Sopenharmony_ci#define SW_3W_CMD1	REG_ADDR1(0x27D)
3468c2ecf20Sopenharmony_ci#define PI_DATA_REG	REG_ADDR2(0x360)
3478c2ecf20Sopenharmony_ci#define SI_DATA_REG     REG_ADDR2(0x362)
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_cistruct rtl818x_rf_ops {
3508c2ecf20Sopenharmony_ci	char *name;
3518c2ecf20Sopenharmony_ci	void (*init)(struct ieee80211_hw *);
3528c2ecf20Sopenharmony_ci	void (*stop)(struct ieee80211_hw *);
3538c2ecf20Sopenharmony_ci	void (*set_chan)(struct ieee80211_hw *, struct ieee80211_conf *);
3548c2ecf20Sopenharmony_ci	u8 (*calc_rssi)(u8 agc, u8 sq);
3558c2ecf20Sopenharmony_ci};
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ci/**
3588c2ecf20Sopenharmony_ci * enum rtl818x_tx_desc_flags - Tx/Rx flags are common between RTL818X chips
3598c2ecf20Sopenharmony_ci *
3608c2ecf20Sopenharmony_ci * @RTL818X_TX_DESC_FLAG_NO_ENC: Disable hardware based encryption.
3618c2ecf20Sopenharmony_ci * @RTL818X_TX_DESC_FLAG_TX_OK: TX frame was ACKed.
3628c2ecf20Sopenharmony_ci * @RTL818X_TX_DESC_FLAG_SPLCP: Use short preamble.
3638c2ecf20Sopenharmony_ci * @RTL818X_TX_DESC_FLAG_MOREFRAG: More fragments follow.
3648c2ecf20Sopenharmony_ci * @RTL818X_TX_DESC_FLAG_CTS: Use CTS-to-self protection.
3658c2ecf20Sopenharmony_ci * @RTL818X_TX_DESC_FLAG_RTS: Use RTS/CTS protection.
3668c2ecf20Sopenharmony_ci * @RTL818X_TX_DESC_FLAG_LS: Last segment of the frame.
3678c2ecf20Sopenharmony_ci * @RTL818X_TX_DESC_FLAG_FS: First segment of the frame.
3688c2ecf20Sopenharmony_ci */
3698c2ecf20Sopenharmony_cienum rtl818x_tx_desc_flags {
3708c2ecf20Sopenharmony_ci	RTL818X_TX_DESC_FLAG_NO_ENC	= (1 << 15),
3718c2ecf20Sopenharmony_ci	RTL818X_TX_DESC_FLAG_TX_OK	= (1 << 15),
3728c2ecf20Sopenharmony_ci	RTL818X_TX_DESC_FLAG_SPLCP	= (1 << 16),
3738c2ecf20Sopenharmony_ci	RTL818X_TX_DESC_FLAG_RX_UNDER	= (1 << 16),
3748c2ecf20Sopenharmony_ci	RTL818X_TX_DESC_FLAG_MOREFRAG	= (1 << 17),
3758c2ecf20Sopenharmony_ci	RTL818X_TX_DESC_FLAG_CTS	= (1 << 18),
3768c2ecf20Sopenharmony_ci	RTL818X_TX_DESC_FLAG_RTS	= (1 << 23),
3778c2ecf20Sopenharmony_ci	RTL818X_TX_DESC_FLAG_LS		= (1 << 28),
3788c2ecf20Sopenharmony_ci	RTL818X_TX_DESC_FLAG_FS		= (1 << 29),
3798c2ecf20Sopenharmony_ci	RTL818X_TX_DESC_FLAG_DMA	= (1 << 30),
3808c2ecf20Sopenharmony_ci	RTL818X_TX_DESC_FLAG_OWN	= (1 << 31)
3818c2ecf20Sopenharmony_ci};
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_cienum rtl818x_rx_desc_flags {
3848c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_ICV_ERR	= (1 << 12),
3858c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_CRC32_ERR	= (1 << 13),
3868c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_PM		= (1 << 14),
3878c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_RX_ERR	= (1 << 15),
3888c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_BCAST	= (1 << 16),
3898c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_PAM	= (1 << 17),
3908c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_MCAST	= (1 << 18),
3918c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_QOS	= (1 << 19), /* RTL8187(B) only */
3928c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_TRSW	= (1 << 24), /* RTL8187(B) only */
3938c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_SPLCP	= (1 << 25),
3948c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_FOF	= (1 << 26),
3958c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_DMA_FAIL	= (1 << 27),
3968c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_LS		= (1 << 28),
3978c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_FS		= (1 << 29),
3988c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_EOR	= (1 << 30),
3998c2ecf20Sopenharmony_ci	RTL818X_RX_DESC_FLAG_OWN	= (1 << 31)
4008c2ecf20Sopenharmony_ci};
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_ci#endif /* RTL818X_H */
403