xref: /linux/drivers/net/wireless/rsi/rsi_hal.h (revision e5a1ecc97e5f717934685bf62a4d398df331459e)
1b78e91bcSPrameela Rani Garnepudi /**
2b78e91bcSPrameela Rani Garnepudi  * Copyright (c) 2017 Redpine Signals Inc.
3b78e91bcSPrameela Rani Garnepudi  *
4b78e91bcSPrameela Rani Garnepudi  * Permission to use, copy, modify, and/or distribute this software for any
5b78e91bcSPrameela Rani Garnepudi  * purpose with or without fee is hereby granted, provided that the above
6b78e91bcSPrameela Rani Garnepudi  * copyright notice and this permission notice appear in all copies.
7b78e91bcSPrameela Rani Garnepudi  *
8b78e91bcSPrameela Rani Garnepudi  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9b78e91bcSPrameela Rani Garnepudi  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10b78e91bcSPrameela Rani Garnepudi  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11b78e91bcSPrameela Rani Garnepudi  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12b78e91bcSPrameela Rani Garnepudi  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13b78e91bcSPrameela Rani Garnepudi  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14b78e91bcSPrameela Rani Garnepudi  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15b78e91bcSPrameela Rani Garnepudi  */
16b78e91bcSPrameela Rani Garnepudi 
17b78e91bcSPrameela Rani Garnepudi #ifndef __RSI_HAL_H__
18b78e91bcSPrameela Rani Garnepudi #define __RSI_HAL_H__
19b78e91bcSPrameela Rani Garnepudi 
20898b2553SPrameela Rani Garnepudi /* Device Operating modes */
21898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_WIFI_ALONE		1
22898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_BT_ALONE		4
23898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_BT_LE_ALONE		8
24898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_BT_DUAL		12
25898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_STA_BT		5
26898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_STA_BT_LE		9
27898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_STA_BT_DUAL		13
28898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_AP_BT		6
29898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_AP_BT_DUAL		14
30898b2553SPrameela Rani Garnepudi 
31b78e91bcSPrameela Rani Garnepudi #define FLASH_WRITE_CHUNK_SIZE		(4 * 1024)
32b78e91bcSPrameela Rani Garnepudi #define FLASH_SECTOR_SIZE		(4 * 1024)
33b78e91bcSPrameela Rani Garnepudi 
34b78e91bcSPrameela Rani Garnepudi #define FLASH_SIZE_ADDR			0x04000016
35b78e91bcSPrameela Rani Garnepudi #define PING_BUFFER_ADDRESS		0x19000
36b78e91bcSPrameela Rani Garnepudi #define PONG_BUFFER_ADDRESS		0x1a000
37b78e91bcSPrameela Rani Garnepudi #define SWBL_REGIN			0x41050034
38b78e91bcSPrameela Rani Garnepudi #define SWBL_REGOUT			0x4105003c
39b78e91bcSPrameela Rani Garnepudi #define PING_WRITE			0x1
40b78e91bcSPrameela Rani Garnepudi #define PONG_WRITE			0x2
41b78e91bcSPrameela Rani Garnepudi 
42b78e91bcSPrameela Rani Garnepudi #define BL_CMD_TIMEOUT			2000
43b78e91bcSPrameela Rani Garnepudi #define BL_BURN_TIMEOUT			(50 * 1000)
44b78e91bcSPrameela Rani Garnepudi 
45b78e91bcSPrameela Rani Garnepudi #define REGIN_VALID			0xA
46b78e91bcSPrameela Rani Garnepudi #define REGIN_INPUT			0xA0
47b78e91bcSPrameela Rani Garnepudi #define REGOUT_VALID			0xAB
48b78e91bcSPrameela Rani Garnepudi #define REGOUT_INVALID			(~0xAB)
49b78e91bcSPrameela Rani Garnepudi #define CMD_PASS			0xAA
50b78e91bcSPrameela Rani Garnepudi #define CMD_FAIL			0xCC
51b78e91bcSPrameela Rani Garnepudi 
52b78e91bcSPrameela Rani Garnepudi #define LOAD_HOSTED_FW			'A'
53b78e91bcSPrameela Rani Garnepudi #define BURN_HOSTED_FW			'B'
54b78e91bcSPrameela Rani Garnepudi #define PING_VALID			'I'
55b78e91bcSPrameela Rani Garnepudi #define PONG_VALID			'O'
56b78e91bcSPrameela Rani Garnepudi #define PING_AVAIL			'I'
57b78e91bcSPrameela Rani Garnepudi #define PONG_AVAIL			'O'
58b78e91bcSPrameela Rani Garnepudi #define EOF_REACHED			'E'
59b78e91bcSPrameela Rani Garnepudi #define CHECK_CRC			'K'
60b78e91bcSPrameela Rani Garnepudi #define POLLING_MODE			'P'
61b78e91bcSPrameela Rani Garnepudi #define CONFIG_AUTO_READ_MODE		'R'
62b78e91bcSPrameela Rani Garnepudi #define JUMP_TO_ZERO_PC			'J'
63b78e91bcSPrameela Rani Garnepudi #define FW_LOADING_SUCCESSFUL		'S'
64b78e91bcSPrameela Rani Garnepudi #define LOADING_INITIATED		'1'
65b78e91bcSPrameela Rani Garnepudi 
6649ddac0dSKarun Eagalapati #define RSI_ULP_RESET_REG		0x161
6749ddac0dSKarun Eagalapati #define RSI_WATCH_DOG_TIMER_1		0x16c
6849ddac0dSKarun Eagalapati #define RSI_WATCH_DOG_TIMER_2		0x16d
6949ddac0dSKarun Eagalapati #define RSI_WATCH_DOG_DELAY_TIMER_1		0x16e
7049ddac0dSKarun Eagalapati #define RSI_WATCH_DOG_DELAY_TIMER_2		0x16f
7149ddac0dSKarun Eagalapati #define RSI_WATCH_DOG_TIMER_ENABLE		0x170
7249ddac0dSKarun Eagalapati 
7349ddac0dSKarun Eagalapati #define RSI_ULP_WRITE_0			00
7449ddac0dSKarun Eagalapati #define RSI_ULP_WRITE_2			02
7549ddac0dSKarun Eagalapati #define RSI_ULP_WRITE_50		50
7649ddac0dSKarun Eagalapati 
7749ddac0dSKarun Eagalapati #define RSI_RESTART_WDT			BIT(11)
7849ddac0dSKarun Eagalapati #define RSI_BYPASS_ULP_ON_WDT		BIT(1)
7949ddac0dSKarun Eagalapati 
8049ddac0dSKarun Eagalapati #define RSI_ULP_TIMER_ENABLE		((0xaa000) | RSI_RESTART_WDT |	\
8149ddac0dSKarun Eagalapati 					 RSI_BYPASS_ULP_ON_WDT)
8249ddac0dSKarun Eagalapati #define RSI_RF_SPI_PROG_REG_BASE_ADDR	0x40080000
8349ddac0dSKarun Eagalapati 
8449ddac0dSKarun Eagalapati #define RSI_GSPI_CTRL_REG0		(RSI_RF_SPI_PROG_REG_BASE_ADDR)
8549ddac0dSKarun Eagalapati #define RSI_GSPI_CTRL_REG1		(RSI_RF_SPI_PROG_REG_BASE_ADDR + 0x2)
8649ddac0dSKarun Eagalapati #define RSI_GSPI_DATA_REG0		(RSI_RF_SPI_PROG_REG_BASE_ADDR + 0x4)
8749ddac0dSKarun Eagalapati #define RSI_GSPI_DATA_REG1		(RSI_RF_SPI_PROG_REG_BASE_ADDR + 0x6)
8849ddac0dSKarun Eagalapati #define RSI_GSPI_DATA_REG2		(RSI_RF_SPI_PROG_REG_BASE_ADDR + 0x8)
8949ddac0dSKarun Eagalapati 
9049ddac0dSKarun Eagalapati #define RSI_GSPI_CTRL_REG0_VALUE		0x340
9149ddac0dSKarun Eagalapati 
9249ddac0dSKarun Eagalapati #define RSI_GSPI_DMA_MODE			BIT(13)
9349ddac0dSKarun Eagalapati 
9449ddac0dSKarun Eagalapati #define RSI_GSPI_2_ULP			BIT(12)
9549ddac0dSKarun Eagalapati #define RSI_GSPI_TRIG			BIT(7)
9649ddac0dSKarun Eagalapati #define RSI_GSPI_READ			BIT(6)
9749ddac0dSKarun Eagalapati #define RSI_GSPI_RF_SPI_ACTIVE		BIT(8)
9849ddac0dSKarun Eagalapati 
99b78e91bcSPrameela Rani Garnepudi /* Boot loader commands */
100b78e91bcSPrameela Rani Garnepudi #define SEND_RPS_FILE			'2'
101b78e91bcSPrameela Rani Garnepudi 
102b78e91bcSPrameela Rani Garnepudi #define FW_IMAGE_MIN_ADDRESS		(68 * 1024)
103b78e91bcSPrameela Rani Garnepudi #define MAX_FLASH_FILE_SIZE		(400 * 1024) //400K
104b78e91bcSPrameela Rani Garnepudi #define FLASH_START_ADDRESS		16
105b78e91bcSPrameela Rani Garnepudi 
106b78e91bcSPrameela Rani Garnepudi #define COMMON_HAL_CARD_READY_IND	0x0
107b78e91bcSPrameela Rani Garnepudi 
108b78e91bcSPrameela Rani Garnepudi #define COMMAN_HAL_WAIT_FOR_CARD_READY	1
109b78e91bcSPrameela Rani Garnepudi 
1109920322cSPrameela Rani Garnepudi #define RSI_DEV_OPMODE_WIFI_ALONE	1
1119920322cSPrameela Rani Garnepudi #define RSI_DEV_COEX_MODE_WIFI_ALONE	1
1129920322cSPrameela Rani Garnepudi 
113de2dea16SPavani Muthyala #define BBP_INFO_40MHZ 0x6
114de2dea16SPavani Muthyala 
115192524a4SPavani Muthyala #define FW_FLASH_OFFSET			0x820
1163ac61578SSiva Rebbagondla #define LMAC_VER_OFFSET_9113		(FW_FLASH_OFFSET + 0x200)
117*e5a1ecc9SSiva Rebbagondla #define LMAC_VER_OFFSET_9116		0x22C2
118a1854faeSPrameela Rani Garnepudi #define MAX_DWORD_ALIGN_BYTES		64
11916d3bb7bSAmitkumar Karwar #define RSI_COMMON_REG_SIZE		2
120*e5a1ecc9SSiva Rebbagondla #define RSI_9116_REG_SIZE		4
121*e5a1ecc9SSiva Rebbagondla #define FW_ALIGN_SIZE			4
122*e5a1ecc9SSiva Rebbagondla #define RSI_9116_FW_MAGIC_WORD		0x5aa5
123*e5a1ecc9SSiva Rebbagondla 
124*e5a1ecc9SSiva Rebbagondla #define MEM_ACCESS_CTRL_FROM_HOST	0x41300000
125*e5a1ecc9SSiva Rebbagondla #define RAM_384K_ACCESS_FROM_TA		(BIT(2) | BIT(3) | BIT(4) | BIT(5) | \
126*e5a1ecc9SSiva Rebbagondla 					 BIT(20) | BIT(21) | BIT(22) | \
127*e5a1ecc9SSiva Rebbagondla 					 BIT(23) | BIT(24) | BIT(25))
128192524a4SPavani Muthyala 
129b78e91bcSPrameela Rani Garnepudi struct bl_header {
130b78e91bcSPrameela Rani Garnepudi 	__le32 flags;
131b78e91bcSPrameela Rani Garnepudi 	__le32 image_no;
132b78e91bcSPrameela Rani Garnepudi 	__le32 check_sum;
133b78e91bcSPrameela Rani Garnepudi 	__le32 flash_start_address;
134b78e91bcSPrameela Rani Garnepudi 	__le32 flash_len;
135b78e91bcSPrameela Rani Garnepudi } __packed;
136b78e91bcSPrameela Rani Garnepudi 
137b78e91bcSPrameela Rani Garnepudi struct ta_metadata {
138b78e91bcSPrameela Rani Garnepudi 	char *name;
139b78e91bcSPrameela Rani Garnepudi 	unsigned int address;
140b78e91bcSPrameela Rani Garnepudi };
141b78e91bcSPrameela Rani Garnepudi 
142*e5a1ecc9SSiva Rebbagondla #define RSI_BL_CTRL_LEN_MASK			0xFFFFFF
143*e5a1ecc9SSiva Rebbagondla #define RSI_BL_CTRL_SPI_32BIT_MODE		BIT(27)
144*e5a1ecc9SSiva Rebbagondla #define RSI_BL_CTRL_REL_TA_SOFTRESET		BIT(28)
145*e5a1ecc9SSiva Rebbagondla #define RSI_BL_CTRL_START_FROM_ROM_PC		BIT(29)
146*e5a1ecc9SSiva Rebbagondla #define RSI_BL_CTRL_SPI_8BIT_MODE		BIT(30)
147*e5a1ecc9SSiva Rebbagondla #define RSI_BL_CTRL_LAST_ENTRY			BIT(31)
148*e5a1ecc9SSiva Rebbagondla struct bootload_entry {
149*e5a1ecc9SSiva Rebbagondla 	__le32 control;
150*e5a1ecc9SSiva Rebbagondla 	__le32 dst_addr;
151*e5a1ecc9SSiva Rebbagondla } __packed;
152*e5a1ecc9SSiva Rebbagondla 
153*e5a1ecc9SSiva Rebbagondla struct bootload_ds {
154*e5a1ecc9SSiva Rebbagondla 	__le16 fixed_pattern;
155*e5a1ecc9SSiva Rebbagondla 	__le16 offset;
156*e5a1ecc9SSiva Rebbagondla 	__le32 reserved;
157*e5a1ecc9SSiva Rebbagondla 	struct bootload_entry bl_entry[7];
158*e5a1ecc9SSiva Rebbagondla } __packed;
159*e5a1ecc9SSiva Rebbagondla 
160de2dea16SPavani Muthyala struct rsi_mgmt_desc {
161de2dea16SPavani Muthyala 	__le16 len_qno;
162de2dea16SPavani Muthyala 	u8 frame_type;
163de2dea16SPavani Muthyala 	u8 misc_flags;
1646507de6dSPrameela Rani Garnepudi 	u8 xtend_desc_size;
165de2dea16SPavani Muthyala 	u8 header_len;
1666507de6dSPrameela Rani Garnepudi 	__le16 frame_info;
1674671c209SPrameela Rani Garnepudi 	__le16 rate_info;
1686507de6dSPrameela Rani Garnepudi 	__le16 bbp_info;
169de2dea16SPavani Muthyala 	__le16 seq_ctrl;
1706507de6dSPrameela Rani Garnepudi 	u8 reserved2;
17119844c0aSPrameela Rani Garnepudi 	u8 sta_id;
172de2dea16SPavani Muthyala } __packed;
173de2dea16SPavani Muthyala 
174af193097SPavani Muthyala struct rsi_data_desc {
175af193097SPavani Muthyala 	__le16 len_qno;
1760eb42586SPavani Muthyala 	u8 cfm_frame_type;
1770eb42586SPavani Muthyala 	u8 misc_flags;
178af193097SPavani Muthyala 	u8 xtend_desc_size;
179af193097SPavani Muthyala 	u8 header_len;
180af193097SPavani Muthyala 	__le16 frame_info;
181af193097SPavani Muthyala 	__le16 rate_info;
182af193097SPavani Muthyala 	__le16 bbp_info;
183af193097SPavani Muthyala 	__le16 mac_flags;
184af193097SPavani Muthyala 	u8 qid_tid;
185af193097SPavani Muthyala 	u8 sta_id;
186af193097SPavani Muthyala } __packed;
187af193097SPavani Muthyala 
188716b840cSSiva Rebbagondla struct rsi_bt_desc {
189716b840cSSiva Rebbagondla 	__le16 len_qno;
190716b840cSSiva Rebbagondla 	__le16 reserved1;
191716b840cSSiva Rebbagondla 	__le32 reserved2;
192716b840cSSiva Rebbagondla 	__le32 reserved3;
193716b840cSSiva Rebbagondla 	__le16 reserved4;
194716b840cSSiva Rebbagondla 	__le16 bt_pkt_type;
195716b840cSSiva Rebbagondla } __packed;
196716b840cSSiva Rebbagondla 
197b78e91bcSPrameela Rani Garnepudi int rsi_hal_device_init(struct rsi_hw *adapter);
1981be05eb5SPrameela Rani Garnepudi int rsi_prepare_mgmt_desc(struct rsi_common *common, struct sk_buff *skb);
1991be05eb5SPrameela Rani Garnepudi int rsi_prepare_data_desc(struct rsi_common *common, struct sk_buff *skb);
200d26a9559SPrameela Rani Garnepudi int rsi_prepare_beacon(struct rsi_common *common, struct sk_buff *skb);
201d26a9559SPrameela Rani Garnepudi int rsi_send_pkt_to_bus(struct rsi_common *common, struct sk_buff *skb);
202716b840cSSiva Rebbagondla int rsi_send_bt_pkt(struct rsi_common *common, struct sk_buff *skb);
203b78e91bcSPrameela Rani Garnepudi 
204b78e91bcSPrameela Rani Garnepudi #endif
205