xref: /linux/drivers/net/wireless/rsi/rsi_hal.h (revision 898b255339310944965309a465309317ed5538ae)
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 
20*898b2553SPrameela Rani Garnepudi /* Device Operating modes */
21*898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_WIFI_ALONE		1
22*898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_BT_ALONE		4
23*898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_BT_LE_ALONE		8
24*898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_BT_DUAL		12
25*898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_STA_BT		5
26*898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_STA_BT_LE		9
27*898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_STA_BT_DUAL		13
28*898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_AP_BT		6
29*898b2553SPrameela Rani Garnepudi #define DEV_OPMODE_AP_BT_DUAL		14
30*898b2553SPrameela 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
116192524a4SPavani Muthyala #define LMAC_VER_OFFSET			(FW_FLASH_OFFSET + 0x200)
117192524a4SPavani Muthyala 
118b78e91bcSPrameela Rani Garnepudi struct bl_header {
119b78e91bcSPrameela Rani Garnepudi 	__le32 flags;
120b78e91bcSPrameela Rani Garnepudi 	__le32 image_no;
121b78e91bcSPrameela Rani Garnepudi 	__le32 check_sum;
122b78e91bcSPrameela Rani Garnepudi 	__le32 flash_start_address;
123b78e91bcSPrameela Rani Garnepudi 	__le32 flash_len;
124b78e91bcSPrameela Rani Garnepudi } __packed;
125b78e91bcSPrameela Rani Garnepudi 
126b78e91bcSPrameela Rani Garnepudi struct ta_metadata {
127b78e91bcSPrameela Rani Garnepudi 	char *name;
128b78e91bcSPrameela Rani Garnepudi 	unsigned int address;
129b78e91bcSPrameela Rani Garnepudi };
130b78e91bcSPrameela Rani Garnepudi 
131de2dea16SPavani Muthyala struct rsi_mgmt_desc {
132de2dea16SPavani Muthyala 	__le16 len_qno;
133de2dea16SPavani Muthyala 	u8 frame_type;
134de2dea16SPavani Muthyala 	u8 misc_flags;
1356507de6dSPrameela Rani Garnepudi 	u8 xtend_desc_size;
136de2dea16SPavani Muthyala 	u8 header_len;
1376507de6dSPrameela Rani Garnepudi 	__le16 frame_info;
1384671c209SPrameela Rani Garnepudi 	__le16 rate_info;
1396507de6dSPrameela Rani Garnepudi 	__le16 bbp_info;
140de2dea16SPavani Muthyala 	__le16 seq_ctrl;
1416507de6dSPrameela Rani Garnepudi 	u8 reserved2;
14219844c0aSPrameela Rani Garnepudi 	u8 sta_id;
143de2dea16SPavani Muthyala } __packed;
144de2dea16SPavani Muthyala 
145af193097SPavani Muthyala struct rsi_data_desc {
146af193097SPavani Muthyala 	__le16 len_qno;
1470eb42586SPavani Muthyala 	u8 cfm_frame_type;
1480eb42586SPavani Muthyala 	u8 misc_flags;
149af193097SPavani Muthyala 	u8 xtend_desc_size;
150af193097SPavani Muthyala 	u8 header_len;
151af193097SPavani Muthyala 	__le16 frame_info;
152af193097SPavani Muthyala 	__le16 rate_info;
153af193097SPavani Muthyala 	__le16 bbp_info;
154af193097SPavani Muthyala 	__le16 mac_flags;
155af193097SPavani Muthyala 	u8 qid_tid;
156af193097SPavani Muthyala 	u8 sta_id;
157af193097SPavani Muthyala } __packed;
158af193097SPavani Muthyala 
159716b840cSSiva Rebbagondla struct rsi_bt_desc {
160716b840cSSiva Rebbagondla 	__le16 len_qno;
161716b840cSSiva Rebbagondla 	__le16 reserved1;
162716b840cSSiva Rebbagondla 	__le32 reserved2;
163716b840cSSiva Rebbagondla 	__le32 reserved3;
164716b840cSSiva Rebbagondla 	__le16 reserved4;
165716b840cSSiva Rebbagondla 	__le16 bt_pkt_type;
166716b840cSSiva Rebbagondla } __packed;
167716b840cSSiva Rebbagondla 
168b78e91bcSPrameela Rani Garnepudi int rsi_hal_device_init(struct rsi_hw *adapter);
169d26a9559SPrameela Rani Garnepudi int rsi_prepare_beacon(struct rsi_common *common, struct sk_buff *skb);
170d26a9559SPrameela Rani Garnepudi int rsi_send_pkt_to_bus(struct rsi_common *common, struct sk_buff *skb);
171716b840cSSiva Rebbagondla int rsi_send_bt_pkt(struct rsi_common *common, struct sk_buff *skb);
172b78e91bcSPrameela Rani Garnepudi 
173b78e91bcSPrameela Rani Garnepudi #endif
174