18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
48c2ecf20Sopenharmony_ci * All rights reserved.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef WILC_WLAN_H
88c2ecf20Sopenharmony_ci#define WILC_WLAN_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/types.h>
118c2ecf20Sopenharmony_ci#include <linux/bitfield.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/********************************************
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci *      Mac eth header length
168c2ecf20Sopenharmony_ci *
178c2ecf20Sopenharmony_ci ********************************************/
188c2ecf20Sopenharmony_ci#define MAX_MAC_HDR_LEN			26 /* QOS_MAC_HDR_LEN */
198c2ecf20Sopenharmony_ci#define SUB_MSDU_HEADER_LENGTH		14
208c2ecf20Sopenharmony_ci#define SNAP_HDR_LEN			8
218c2ecf20Sopenharmony_ci#define ETHERNET_HDR_LEN		14
228c2ecf20Sopenharmony_ci#define WORD_ALIGNMENT_PAD		0
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define ETH_ETHERNET_HDR_OFFSET		(MAX_MAC_HDR_LEN + \
258c2ecf20Sopenharmony_ci					 SUB_MSDU_HEADER_LENGTH + \
268c2ecf20Sopenharmony_ci					 SNAP_HDR_LEN - \
278c2ecf20Sopenharmony_ci					 ETHERNET_HDR_LEN + \
288c2ecf20Sopenharmony_ci					 WORD_ALIGNMENT_PAD)
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define HOST_HDR_OFFSET			4
318c2ecf20Sopenharmony_ci#define ETHERNET_HDR_LEN		14
328c2ecf20Sopenharmony_ci#define IP_HDR_LEN			20
338c2ecf20Sopenharmony_ci#define IP_HDR_OFFSET			ETHERNET_HDR_LEN
348c2ecf20Sopenharmony_ci#define UDP_HDR_OFFSET			(IP_HDR_LEN + IP_HDR_OFFSET)
358c2ecf20Sopenharmony_ci#define UDP_HDR_LEN			8
368c2ecf20Sopenharmony_ci#define UDP_DATA_OFFSET			(UDP_HDR_OFFSET + UDP_HDR_LEN)
378c2ecf20Sopenharmony_ci#define ETH_CONFIG_PKT_HDR_LEN		UDP_DATA_OFFSET
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define ETH_CONFIG_PKT_HDR_OFFSET	(ETH_ETHERNET_HDR_OFFSET + \
408c2ecf20Sopenharmony_ci					 ETH_CONFIG_PKT_HDR_LEN)
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/********************************************
438c2ecf20Sopenharmony_ci *
448c2ecf20Sopenharmony_ci *      Register Defines
458c2ecf20Sopenharmony_ci *
468c2ecf20Sopenharmony_ci ********************************************/
478c2ecf20Sopenharmony_ci#define WILC_PERIPH_REG_BASE		0x1000
488c2ecf20Sopenharmony_ci#define WILC_CHANGING_VIR_IF		0x108c
498c2ecf20Sopenharmony_ci#define WILC_CHIPID			WILC_PERIPH_REG_BASE
508c2ecf20Sopenharmony_ci#define WILC_GLB_RESET_0		(WILC_PERIPH_REG_BASE + 0x400)
518c2ecf20Sopenharmony_ci#define WILC_PIN_MUX_0			(WILC_PERIPH_REG_BASE + 0x408)
528c2ecf20Sopenharmony_ci#define WILC_HOST_TX_CTRL		(WILC_PERIPH_REG_BASE + 0x6c)
538c2ecf20Sopenharmony_ci#define WILC_HOST_RX_CTRL_0		(WILC_PERIPH_REG_BASE + 0x70)
548c2ecf20Sopenharmony_ci#define WILC_HOST_RX_CTRL_1		(WILC_PERIPH_REG_BASE + 0x74)
558c2ecf20Sopenharmony_ci#define WILC_HOST_VMM_CTL		(WILC_PERIPH_REG_BASE + 0x78)
568c2ecf20Sopenharmony_ci#define WILC_HOST_RX_CTRL		(WILC_PERIPH_REG_BASE + 0x80)
578c2ecf20Sopenharmony_ci#define WILC_HOST_RX_EXTRA_SIZE		(WILC_PERIPH_REG_BASE + 0x84)
588c2ecf20Sopenharmony_ci#define WILC_HOST_TX_CTRL_1		(WILC_PERIPH_REG_BASE + 0x88)
598c2ecf20Sopenharmony_ci#define WILC_MISC			(WILC_PERIPH_REG_BASE + 0x428)
608c2ecf20Sopenharmony_ci#define WILC_INTR_REG_BASE		(WILC_PERIPH_REG_BASE + 0xa00)
618c2ecf20Sopenharmony_ci#define WILC_INTR_ENABLE		WILC_INTR_REG_BASE
628c2ecf20Sopenharmony_ci#define WILC_INTR2_ENABLE		(WILC_INTR_REG_BASE + 4)
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci#define WILC_INTR_POLARITY		(WILC_INTR_REG_BASE + 0x10)
658c2ecf20Sopenharmony_ci#define WILC_INTR_TYPE			(WILC_INTR_REG_BASE + 0x20)
668c2ecf20Sopenharmony_ci#define WILC_INTR_CLEAR			(WILC_INTR_REG_BASE + 0x30)
678c2ecf20Sopenharmony_ci#define WILC_INTR_STATUS		(WILC_INTR_REG_BASE + 0x40)
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#define WILC_RF_REVISION_ID		0x13f4
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define WILC_VMM_TBL_SIZE		64
728c2ecf20Sopenharmony_ci#define WILC_VMM_TX_TBL_BASE		0x150400
738c2ecf20Sopenharmony_ci#define WILC_VMM_RX_TBL_BASE		0x150500
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#define WILC_VMM_BASE			0x150000
768c2ecf20Sopenharmony_ci#define WILC_VMM_CORE_CTL		WILC_VMM_BASE
778c2ecf20Sopenharmony_ci#define WILC_VMM_TBL_CTL		(WILC_VMM_BASE + 0x4)
788c2ecf20Sopenharmony_ci#define WILC_VMM_TBL_ENTRY		(WILC_VMM_BASE + 0x8)
798c2ecf20Sopenharmony_ci#define WILC_VMM_TBL0_SIZE		(WILC_VMM_BASE + 0xc)
808c2ecf20Sopenharmony_ci#define WILC_VMM_TO_HOST_SIZE		(WILC_VMM_BASE + 0x10)
818c2ecf20Sopenharmony_ci#define WILC_VMM_CORE_CFG		(WILC_VMM_BASE + 0x14)
828c2ecf20Sopenharmony_ci#define WILC_VMM_TBL_ACTIVE		(WILC_VMM_BASE + 040)
838c2ecf20Sopenharmony_ci#define WILC_VMM_TBL_STATUS		(WILC_VMM_BASE + 0x44)
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define WILC_SPI_REG_BASE		0xe800
868c2ecf20Sopenharmony_ci#define WILC_SPI_CTL			WILC_SPI_REG_BASE
878c2ecf20Sopenharmony_ci#define WILC_SPI_MASTER_DMA_ADDR	(WILC_SPI_REG_BASE + 0x4)
888c2ecf20Sopenharmony_ci#define WILC_SPI_MASTER_DMA_COUNT	(WILC_SPI_REG_BASE + 0x8)
898c2ecf20Sopenharmony_ci#define WILC_SPI_SLAVE_DMA_ADDR		(WILC_SPI_REG_BASE + 0xc)
908c2ecf20Sopenharmony_ci#define WILC_SPI_SLAVE_DMA_COUNT	(WILC_SPI_REG_BASE + 0x10)
918c2ecf20Sopenharmony_ci#define WILC_SPI_TX_MODE		(WILC_SPI_REG_BASE + 0x20)
928c2ecf20Sopenharmony_ci#define WILC_SPI_PROTOCOL_CONFIG	(WILC_SPI_REG_BASE + 0x24)
938c2ecf20Sopenharmony_ci#define WILC_SPI_INTR_CTL		(WILC_SPI_REG_BASE + 0x2c)
948c2ecf20Sopenharmony_ci#define WILC_SPI_INT_STATUS		(WILC_SPI_REG_BASE + 0x40)
958c2ecf20Sopenharmony_ci#define WILC_SPI_INT_CLEAR		(WILC_SPI_REG_BASE + 0x44)
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#define WILC_SPI_WAKEUP_REG		0x1
988c2ecf20Sopenharmony_ci#define WILC_SPI_WAKEUP_BIT		BIT(1)
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#define WILC_SPI_PROTOCOL_OFFSET	(WILC_SPI_PROTOCOL_CONFIG - \
1018c2ecf20Sopenharmony_ci					 WILC_SPI_REG_BASE)
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci#define WILC_SPI_CLOCKLESS_ADDR_LIMIT	0x30
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci/* Functions IO enables bits */
1068c2ecf20Sopenharmony_ci#define WILC_SDIO_CCCR_IO_EN_FUNC1	BIT(1)
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci/* Function/Interrupt enables bits */
1098c2ecf20Sopenharmony_ci#define WILC_SDIO_CCCR_IEN_MASTER	BIT(0)
1108c2ecf20Sopenharmony_ci#define WILC_SDIO_CCCR_IEN_FUNC1	BIT(1)
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci/* Abort CCCR register bits */
1138c2ecf20Sopenharmony_ci#define WILC_SDIO_CCCR_ABORT_RESET	BIT(3)
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci/* Vendor specific CCCR registers */
1168c2ecf20Sopenharmony_ci#define WILC_SDIO_WAKEUP_REG		0xf0
1178c2ecf20Sopenharmony_ci#define WILC_SDIO_WAKEUP_BIT		BIT(0)
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci#define WILC_SDIO_CLK_STATUS_REG	0xf1
1208c2ecf20Sopenharmony_ci#define WILC_SDIO_CLK_STATUS_BIT	BIT(0)
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci#define WILC_SDIO_INTERRUPT_DATA_SZ_REG	0xf2 /* Read size (2 bytes) */
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define WILC_SDIO_VMM_TBL_CTRL_REG	0xf6
1258c2ecf20Sopenharmony_ci#define WILC_SDIO_IRQ_FLAG_REG		0xf7
1268c2ecf20Sopenharmony_ci#define WILC_SDIO_IRQ_CLEAR_FLAG_REG	0xf8
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci#define WILC_SDIO_HOST_TO_FW_REG	0xfa
1298c2ecf20Sopenharmony_ci#define WILC_SDIO_HOST_TO_FW_BIT	BIT(0)
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci#define WILC_SDIO_FW_TO_HOST_REG	0xfc
1328c2ecf20Sopenharmony_ci#define WILC_SDIO_FW_TO_HOST_BIT	BIT(0)
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci/* Function 1 specific FBR register */
1358c2ecf20Sopenharmony_ci#define WILC_SDIO_FBR_CSA_REG		0x10C /* CSA pointer (3 bytes) */
1368c2ecf20Sopenharmony_ci#define WILC_SDIO_FBR_DATA_REG		0x10F
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci#define WILC_SDIO_F1_DATA_REG		0x0
1398c2ecf20Sopenharmony_ci#define WILC_SDIO_EXT_IRQ_FLAG_REG	0x4
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci#define WILC_AHB_DATA_MEM_BASE		0x30000
1428c2ecf20Sopenharmony_ci#define WILC_AHB_SHARE_MEM_BASE		0xd0000
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci#define WILC_VMM_TBL_RX_SHADOW_BASE	WILC_AHB_SHARE_MEM_BASE
1458c2ecf20Sopenharmony_ci#define WILC_VMM_TBL_RX_SHADOW_SIZE	256
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci#define WILC_FW_HOST_COMM		0x13c0
1488c2ecf20Sopenharmony_ci#define WILC_GP_REG_0			0x149c
1498c2ecf20Sopenharmony_ci#define WILC_GP_REG_1			0x14a0
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci#define WILC_HAVE_SDIO_IRQ_GPIO		BIT(0)
1528c2ecf20Sopenharmony_ci#define WILC_HAVE_USE_PMU		BIT(1)
1538c2ecf20Sopenharmony_ci#define WILC_HAVE_SLEEP_CLK_SRC_RTC	BIT(2)
1548c2ecf20Sopenharmony_ci#define WILC_HAVE_SLEEP_CLK_SRC_XO	BIT(3)
1558c2ecf20Sopenharmony_ci#define WILC_HAVE_EXT_PA_INV_TX_RX	BIT(4)
1568c2ecf20Sopenharmony_ci#define WILC_HAVE_LEGACY_RF_SETTINGS	BIT(5)
1578c2ecf20Sopenharmony_ci#define WILC_HAVE_XTAL_24		BIT(6)
1588c2ecf20Sopenharmony_ci#define WILC_HAVE_DISABLE_WILC_UART	BIT(7)
1598c2ecf20Sopenharmony_ci#define WILC_HAVE_USE_IRQ_AS_HOST_WAKE	BIT(8)
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci#define WILC_CORTUS_INTERRUPT_BASE	0x10A8
1628c2ecf20Sopenharmony_ci#define WILC_CORTUS_INTERRUPT_1		(WILC_CORTUS_INTERRUPT_BASE + 0x4)
1638c2ecf20Sopenharmony_ci#define WILC_CORTUS_INTERRUPT_2		(WILC_CORTUS_INTERRUPT_BASE + 0x8)
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci/* tx control register 1 to 4 for RX */
1668c2ecf20Sopenharmony_ci#define WILC_REG_4_TO_1_RX		0x1e1c
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci/* tx control register 1 to 4 for TX Bank_0 */
1698c2ecf20Sopenharmony_ci#define WILC_REG_4_TO_1_TX_BANK0	0x1e9c
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci#define WILC_CORTUS_RESET_MUX_SEL	0x1118
1728c2ecf20Sopenharmony_ci#define WILC_CORTUS_BOOT_REGISTER	0xc0000
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci#define WILC_CORTUS_BOOT_FROM_IRAM	0x71
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci#define WILC_1000_BASE_ID		0x100000
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci#define WILC_1000_BASE_ID_2A		0x1002A0
1798c2ecf20Sopenharmony_ci#define WILC_1000_BASE_ID_2A_REV1	(WILC_1000_BASE_ID_2A + 1)
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci#define WILC_1000_BASE_ID_2B		0x1002B0
1828c2ecf20Sopenharmony_ci#define WILC_1000_BASE_ID_2B_REV1	(WILC_1000_BASE_ID_2B + 1)
1838c2ecf20Sopenharmony_ci#define WILC_1000_BASE_ID_2B_REV2	(WILC_1000_BASE_ID_2B + 2)
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci#define WILC_CHIP_REV_FIELD		GENMASK(11, 0)
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci/********************************************
1888c2ecf20Sopenharmony_ci *
1898c2ecf20Sopenharmony_ci *      Wlan Defines
1908c2ecf20Sopenharmony_ci *
1918c2ecf20Sopenharmony_ci ********************************************/
1928c2ecf20Sopenharmony_ci#define WILC_CFG_PKT		1
1938c2ecf20Sopenharmony_ci#define WILC_NET_PKT		0
1948c2ecf20Sopenharmony_ci#define WILC_MGMT_PKT		2
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci#define WILC_CFG_SET		1
1978c2ecf20Sopenharmony_ci#define WILC_CFG_QUERY		0
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci#define WILC_CFG_RSP		1
2008c2ecf20Sopenharmony_ci#define WILC_CFG_RSP_STATUS	2
2018c2ecf20Sopenharmony_ci#define WILC_CFG_RSP_SCAN	3
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci#define WILC_ABORT_REQ_BIT		BIT(31)
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci#define WILC_RX_BUFF_SIZE	(96 * 1024)
2068c2ecf20Sopenharmony_ci#define WILC_TX_BUFF_SIZE	(64 * 1024)
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci#define MODALIAS		"WILC_SPI"
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci#define WILC_PKT_HDR_CONFIG_FIELD	BIT(31)
2118c2ecf20Sopenharmony_ci#define WILC_PKT_HDR_OFFSET_FIELD	GENMASK(30, 22)
2128c2ecf20Sopenharmony_ci#define WILC_PKT_HDR_TOTAL_LEN_FIELD	GENMASK(21, 11)
2138c2ecf20Sopenharmony_ci#define WILC_PKT_HDR_LEN_FIELD		GENMASK(10, 0)
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci#define WILC_INTERRUPT_DATA_SIZE	GENMASK(14, 0)
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci#define WILC_VMM_BUFFER_SIZE		GENMASK(9, 0)
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci#define WILC_VMM_HDR_TYPE		BIT(31)
2208c2ecf20Sopenharmony_ci#define WILC_VMM_HDR_MGMT_FIELD		BIT(30)
2218c2ecf20Sopenharmony_ci#define WILC_VMM_HDR_PKT_SIZE		GENMASK(29, 15)
2228c2ecf20Sopenharmony_ci#define WILC_VMM_HDR_BUFF_SIZE		GENMASK(14, 0)
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci#define WILC_VMM_ENTRY_COUNT		GENMASK(8, 3)
2258c2ecf20Sopenharmony_ci#define WILC_VMM_ENTRY_AVAILABLE	BIT(2)
2268c2ecf20Sopenharmony_ci/*******************************************/
2278c2ecf20Sopenharmony_ci/*        E0 and later Interrupt flags.    */
2288c2ecf20Sopenharmony_ci/*******************************************/
2298c2ecf20Sopenharmony_ci/*******************************************/
2308c2ecf20Sopenharmony_ci/*        E0 and later Interrupt flags.    */
2318c2ecf20Sopenharmony_ci/*           IRQ Status word               */
2328c2ecf20Sopenharmony_ci/* 15:0 = DMA count in words.              */
2338c2ecf20Sopenharmony_ci/* 16: INT0 flag                           */
2348c2ecf20Sopenharmony_ci/* 17: INT1 flag                           */
2358c2ecf20Sopenharmony_ci/* 18: INT2 flag                           */
2368c2ecf20Sopenharmony_ci/* 19: INT3 flag                           */
2378c2ecf20Sopenharmony_ci/* 20: INT4 flag                           */
2388c2ecf20Sopenharmony_ci/* 21: INT5 flag                           */
2398c2ecf20Sopenharmony_ci/*******************************************/
2408c2ecf20Sopenharmony_ci#define IRG_FLAGS_OFFSET	16
2418c2ecf20Sopenharmony_ci#define IRQ_DMA_WD_CNT_MASK	GENMASK(IRG_FLAGS_OFFSET - 1, 0)
2428c2ecf20Sopenharmony_ci#define INT_0			BIT(IRG_FLAGS_OFFSET)
2438c2ecf20Sopenharmony_ci#define INT_1			BIT(IRG_FLAGS_OFFSET + 1)
2448c2ecf20Sopenharmony_ci#define INT_2			BIT(IRG_FLAGS_OFFSET + 2)
2458c2ecf20Sopenharmony_ci#define INT_3			BIT(IRG_FLAGS_OFFSET + 3)
2468c2ecf20Sopenharmony_ci#define INT_4			BIT(IRG_FLAGS_OFFSET + 4)
2478c2ecf20Sopenharmony_ci#define INT_5			BIT(IRG_FLAGS_OFFSET + 5)
2488c2ecf20Sopenharmony_ci#define MAX_NUM_INT		5
2498c2ecf20Sopenharmony_ci#define IRG_FLAGS_MASK		GENMASK(IRG_FLAGS_OFFSET + MAX_NUM_INT, \
2508c2ecf20Sopenharmony_ci					IRG_FLAGS_OFFSET)
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci/*******************************************/
2538c2ecf20Sopenharmony_ci/*        E0 and later Interrupt flags.    */
2548c2ecf20Sopenharmony_ci/*           IRQ Clear word                */
2558c2ecf20Sopenharmony_ci/* 0: Clear INT0                           */
2568c2ecf20Sopenharmony_ci/* 1: Clear INT1                           */
2578c2ecf20Sopenharmony_ci/* 2: Clear INT2                           */
2588c2ecf20Sopenharmony_ci/* 3: Clear INT3                           */
2598c2ecf20Sopenharmony_ci/* 4: Clear INT4                           */
2608c2ecf20Sopenharmony_ci/* 5: Clear INT5                           */
2618c2ecf20Sopenharmony_ci/* 6: Select VMM table 1                   */
2628c2ecf20Sopenharmony_ci/* 7: Select VMM table 2                   */
2638c2ecf20Sopenharmony_ci/* 8: Enable VMM                           */
2648c2ecf20Sopenharmony_ci/*******************************************/
2658c2ecf20Sopenharmony_ci#define CLR_INT0		BIT(0)
2668c2ecf20Sopenharmony_ci#define CLR_INT1		BIT(1)
2678c2ecf20Sopenharmony_ci#define CLR_INT2		BIT(2)
2688c2ecf20Sopenharmony_ci#define CLR_INT3		BIT(3)
2698c2ecf20Sopenharmony_ci#define CLR_INT4		BIT(4)
2708c2ecf20Sopenharmony_ci#define CLR_INT5		BIT(5)
2718c2ecf20Sopenharmony_ci#define SEL_VMM_TBL0		BIT(6)
2728c2ecf20Sopenharmony_ci#define SEL_VMM_TBL1		BIT(7)
2738c2ecf20Sopenharmony_ci#define EN_VMM			BIT(8)
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci#define DATA_INT_EXT		INT_0
2768c2ecf20Sopenharmony_ci#define ALL_INT_EXT		DATA_INT_EXT
2778c2ecf20Sopenharmony_ci#define NUM_INT_EXT		1
2788c2ecf20Sopenharmony_ci#define UNHANDLED_IRQ_MASK	GENMASK(MAX_NUM_INT - 1, NUM_INT_EXT)
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci#define DATA_INT_CLR		CLR_INT0
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci#define ENABLE_RX_VMM		(SEL_VMM_TBL1 | EN_VMM)
2838c2ecf20Sopenharmony_ci#define ENABLE_TX_VMM		(SEL_VMM_TBL0 | EN_VMM)
2848c2ecf20Sopenharmony_ci/* time for expiring the completion of cfg packets */
2858c2ecf20Sopenharmony_ci#define WILC_CFG_PKTS_TIMEOUT	msecs_to_jiffies(2000)
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci#define IS_MANAGMEMENT		0x100
2888c2ecf20Sopenharmony_ci#define IS_MANAGMEMENT_CALLBACK	0x080
2898c2ecf20Sopenharmony_ci#define IS_MGMT_STATUS_SUCCES	0x040
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci#define WILC_WID_TYPE		GENMASK(15, 12)
2928c2ecf20Sopenharmony_ci#define WILC_VMM_ENTRY_FULL_RETRY	1
2938c2ecf20Sopenharmony_ci/********************************************
2948c2ecf20Sopenharmony_ci *
2958c2ecf20Sopenharmony_ci *      Tx/Rx Queue Structure
2968c2ecf20Sopenharmony_ci *
2978c2ecf20Sopenharmony_ci ********************************************/
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_cistruct txq_entry_t {
3008c2ecf20Sopenharmony_ci	struct list_head list;
3018c2ecf20Sopenharmony_ci	int type;
3028c2ecf20Sopenharmony_ci	int ack_idx;
3038c2ecf20Sopenharmony_ci	u8 *buffer;
3048c2ecf20Sopenharmony_ci	int buffer_size;
3058c2ecf20Sopenharmony_ci	void *priv;
3068c2ecf20Sopenharmony_ci	int status;
3078c2ecf20Sopenharmony_ci	struct wilc_vif *vif;
3088c2ecf20Sopenharmony_ci	void (*tx_complete_func)(void *priv, int status);
3098c2ecf20Sopenharmony_ci};
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_cistruct rxq_entry_t {
3128c2ecf20Sopenharmony_ci	struct list_head list;
3138c2ecf20Sopenharmony_ci	u8 *buffer;
3148c2ecf20Sopenharmony_ci	int buffer_size;
3158c2ecf20Sopenharmony_ci};
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci/********************************************
3188c2ecf20Sopenharmony_ci *
3198c2ecf20Sopenharmony_ci *      Host IF Structure
3208c2ecf20Sopenharmony_ci *
3218c2ecf20Sopenharmony_ci ********************************************/
3228c2ecf20Sopenharmony_cistruct wilc;
3238c2ecf20Sopenharmony_cistruct wilc_hif_func {
3248c2ecf20Sopenharmony_ci	int (*hif_init)(struct wilc *wilc, bool resume);
3258c2ecf20Sopenharmony_ci	int (*hif_deinit)(struct wilc *wilc);
3268c2ecf20Sopenharmony_ci	int (*hif_read_reg)(struct wilc *wilc, u32 addr, u32 *data);
3278c2ecf20Sopenharmony_ci	int (*hif_write_reg)(struct wilc *wilc, u32 addr, u32 data);
3288c2ecf20Sopenharmony_ci	int (*hif_block_rx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
3298c2ecf20Sopenharmony_ci	int (*hif_block_tx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
3308c2ecf20Sopenharmony_ci	int (*hif_read_int)(struct wilc *wilc, u32 *int_status);
3318c2ecf20Sopenharmony_ci	int (*hif_clear_int_ext)(struct wilc *wilc, u32 val);
3328c2ecf20Sopenharmony_ci	int (*hif_read_size)(struct wilc *wilc, u32 *size);
3338c2ecf20Sopenharmony_ci	int (*hif_block_tx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
3348c2ecf20Sopenharmony_ci	int (*hif_block_rx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
3358c2ecf20Sopenharmony_ci	int (*hif_sync_ext)(struct wilc *wilc, int nint);
3368c2ecf20Sopenharmony_ci	int (*enable_interrupt)(struct wilc *nic);
3378c2ecf20Sopenharmony_ci	void (*disable_interrupt)(struct wilc *nic);
3388c2ecf20Sopenharmony_ci};
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci#define WILC_MAX_CFG_FRAME_SIZE		1468
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_cistruct tx_complete_data {
3438c2ecf20Sopenharmony_ci	int size;
3448c2ecf20Sopenharmony_ci	void *buff;
3458c2ecf20Sopenharmony_ci	struct sk_buff *skb;
3468c2ecf20Sopenharmony_ci};
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_cistruct wilc_cfg_cmd_hdr {
3498c2ecf20Sopenharmony_ci	u8 cmd_type;
3508c2ecf20Sopenharmony_ci	u8 seq_no;
3518c2ecf20Sopenharmony_ci	__le16 total_len;
3528c2ecf20Sopenharmony_ci	__le32 driver_handler;
3538c2ecf20Sopenharmony_ci};
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_cistruct wilc_cfg_frame {
3568c2ecf20Sopenharmony_ci	struct wilc_cfg_cmd_hdr hdr;
3578c2ecf20Sopenharmony_ci	u8 frame[WILC_MAX_CFG_FRAME_SIZE];
3588c2ecf20Sopenharmony_ci};
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_cistruct wilc_cfg_rsp {
3618c2ecf20Sopenharmony_ci	u8 type;
3628c2ecf20Sopenharmony_ci	u8 seq_no;
3638c2ecf20Sopenharmony_ci};
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_cistruct wilc;
3668c2ecf20Sopenharmony_cistruct wilc_vif;
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ciint wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
3698c2ecf20Sopenharmony_ci				u32 buffer_size);
3708c2ecf20Sopenharmony_ciint wilc_wlan_start(struct wilc *wilc);
3718c2ecf20Sopenharmony_ciint wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif);
3728c2ecf20Sopenharmony_ciint wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
3738c2ecf20Sopenharmony_ci			      u32 buffer_size,
3748c2ecf20Sopenharmony_ci			      void (*tx_complete_fn)(void *, int));
3758c2ecf20Sopenharmony_ciint wilc_wlan_handle_txq(struct wilc *wl, u32 *txq_count);
3768c2ecf20Sopenharmony_civoid wilc_handle_isr(struct wilc *wilc);
3778c2ecf20Sopenharmony_civoid wilc_wlan_cleanup(struct net_device *dev);
3788c2ecf20Sopenharmony_ciint wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer,
3798c2ecf20Sopenharmony_ci		      u32 buffer_size, int commit, u32 drv_handler);
3808c2ecf20Sopenharmony_ciint wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit,
3818c2ecf20Sopenharmony_ci		      u32 drv_handler);
3828c2ecf20Sopenharmony_ciint wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
3838c2ecf20Sopenharmony_ci			       u32 buffer_size, void (*func)(void *, int));
3848c2ecf20Sopenharmony_civoid wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value);
3858c2ecf20Sopenharmony_ciint wilc_wlan_get_num_conn_ifcs(struct wilc *wilc);
3868c2ecf20Sopenharmony_cinetdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev);
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_civoid wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size);
3898c2ecf20Sopenharmony_civoid host_wakeup_notify(struct wilc *wilc);
3908c2ecf20Sopenharmony_civoid host_sleep_notify(struct wilc *wilc);
3918c2ecf20Sopenharmony_civoid chip_allow_sleep(struct wilc *wilc);
3928c2ecf20Sopenharmony_civoid chip_wakeup(struct wilc *wilc);
3938c2ecf20Sopenharmony_ciint wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids,
3948c2ecf20Sopenharmony_ci			 u32 count);
3958c2ecf20Sopenharmony_ciint wilc_wlan_init(struct net_device *dev);
3968c2ecf20Sopenharmony_ciu32 wilc_get_chipid(struct wilc *wilc, bool update);
3978c2ecf20Sopenharmony_ci#endif
398