162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. 462306a36Sopenharmony_ci * All rights reserved. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#ifndef WILC_WLAN_H 862306a36Sopenharmony_ci#define WILC_WLAN_H 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include <linux/types.h> 1162306a36Sopenharmony_ci#include <linux/bitfield.h> 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/******************************************** 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * Mac eth header length 1662306a36Sopenharmony_ci * 1762306a36Sopenharmony_ci ********************************************/ 1862306a36Sopenharmony_ci#define MAX_MAC_HDR_LEN 26 /* QOS_MAC_HDR_LEN */ 1962306a36Sopenharmony_ci#define SUB_MSDU_HEADER_LENGTH 14 2062306a36Sopenharmony_ci#define SNAP_HDR_LEN 8 2162306a36Sopenharmony_ci#define ETHERNET_HDR_LEN 14 2262306a36Sopenharmony_ci#define WORD_ALIGNMENT_PAD 0 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#define ETH_ETHERNET_HDR_OFFSET (MAX_MAC_HDR_LEN + \ 2562306a36Sopenharmony_ci SUB_MSDU_HEADER_LENGTH + \ 2662306a36Sopenharmony_ci SNAP_HDR_LEN - \ 2762306a36Sopenharmony_ci ETHERNET_HDR_LEN + \ 2862306a36Sopenharmony_ci WORD_ALIGNMENT_PAD) 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define HOST_HDR_OFFSET 4 3162306a36Sopenharmony_ci#define ETHERNET_HDR_LEN 14 3262306a36Sopenharmony_ci#define IP_HDR_LEN 20 3362306a36Sopenharmony_ci#define IP_HDR_OFFSET ETHERNET_HDR_LEN 3462306a36Sopenharmony_ci#define UDP_HDR_OFFSET (IP_HDR_LEN + IP_HDR_OFFSET) 3562306a36Sopenharmony_ci#define UDP_HDR_LEN 8 3662306a36Sopenharmony_ci#define UDP_DATA_OFFSET (UDP_HDR_OFFSET + UDP_HDR_LEN) 3762306a36Sopenharmony_ci#define ETH_CONFIG_PKT_HDR_LEN UDP_DATA_OFFSET 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci#define ETH_CONFIG_PKT_HDR_OFFSET (ETH_ETHERNET_HDR_OFFSET + \ 4062306a36Sopenharmony_ci ETH_CONFIG_PKT_HDR_LEN) 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/******************************************** 4362306a36Sopenharmony_ci * 4462306a36Sopenharmony_ci * Register Defines 4562306a36Sopenharmony_ci * 4662306a36Sopenharmony_ci ********************************************/ 4762306a36Sopenharmony_ci#define WILC_PERIPH_REG_BASE 0x1000 4862306a36Sopenharmony_ci#define WILC_CHANGING_VIR_IF 0x108c 4962306a36Sopenharmony_ci#define WILC_CHIPID WILC_PERIPH_REG_BASE 5062306a36Sopenharmony_ci#define WILC_GLB_RESET_0 (WILC_PERIPH_REG_BASE + 0x400) 5162306a36Sopenharmony_ci#define WILC_PIN_MUX_0 (WILC_PERIPH_REG_BASE + 0x408) 5262306a36Sopenharmony_ci#define WILC_HOST_TX_CTRL (WILC_PERIPH_REG_BASE + 0x6c) 5362306a36Sopenharmony_ci#define WILC_HOST_RX_CTRL_0 (WILC_PERIPH_REG_BASE + 0x70) 5462306a36Sopenharmony_ci#define WILC_HOST_RX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x74) 5562306a36Sopenharmony_ci#define WILC_HOST_VMM_CTL (WILC_PERIPH_REG_BASE + 0x78) 5662306a36Sopenharmony_ci#define WILC_HOST_RX_CTRL (WILC_PERIPH_REG_BASE + 0x80) 5762306a36Sopenharmony_ci#define WILC_HOST_RX_EXTRA_SIZE (WILC_PERIPH_REG_BASE + 0x84) 5862306a36Sopenharmony_ci#define WILC_HOST_TX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x88) 5962306a36Sopenharmony_ci#define WILC_MISC (WILC_PERIPH_REG_BASE + 0x428) 6062306a36Sopenharmony_ci#define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00) 6162306a36Sopenharmony_ci#define WILC_INTR_ENABLE WILC_INTR_REG_BASE 6262306a36Sopenharmony_ci#define WILC_INTR2_ENABLE (WILC_INTR_REG_BASE + 4) 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci#define WILC_INTR_POLARITY (WILC_INTR_REG_BASE + 0x10) 6562306a36Sopenharmony_ci#define WILC_INTR_TYPE (WILC_INTR_REG_BASE + 0x20) 6662306a36Sopenharmony_ci#define WILC_INTR_CLEAR (WILC_INTR_REG_BASE + 0x30) 6762306a36Sopenharmony_ci#define WILC_INTR_STATUS (WILC_INTR_REG_BASE + 0x40) 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#define WILC_RF_REVISION_ID 0x13f4 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci#define WILC_VMM_TBL_SIZE 64 7262306a36Sopenharmony_ci#define WILC_VMM_TX_TBL_BASE 0x150400 7362306a36Sopenharmony_ci#define WILC_VMM_RX_TBL_BASE 0x150500 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci#define WILC_VMM_BASE 0x150000 7662306a36Sopenharmony_ci#define WILC_VMM_CORE_CTL WILC_VMM_BASE 7762306a36Sopenharmony_ci#define WILC_VMM_TBL_CTL (WILC_VMM_BASE + 0x4) 7862306a36Sopenharmony_ci#define WILC_VMM_TBL_ENTRY (WILC_VMM_BASE + 0x8) 7962306a36Sopenharmony_ci#define WILC_VMM_TBL0_SIZE (WILC_VMM_BASE + 0xc) 8062306a36Sopenharmony_ci#define WILC_VMM_TO_HOST_SIZE (WILC_VMM_BASE + 0x10) 8162306a36Sopenharmony_ci#define WILC_VMM_CORE_CFG (WILC_VMM_BASE + 0x14) 8262306a36Sopenharmony_ci#define WILC_VMM_TBL_ACTIVE (WILC_VMM_BASE + 040) 8362306a36Sopenharmony_ci#define WILC_VMM_TBL_STATUS (WILC_VMM_BASE + 0x44) 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci#define WILC_SPI_REG_BASE 0xe800 8662306a36Sopenharmony_ci#define WILC_SPI_CTL WILC_SPI_REG_BASE 8762306a36Sopenharmony_ci#define WILC_SPI_MASTER_DMA_ADDR (WILC_SPI_REG_BASE + 0x4) 8862306a36Sopenharmony_ci#define WILC_SPI_MASTER_DMA_COUNT (WILC_SPI_REG_BASE + 0x8) 8962306a36Sopenharmony_ci#define WILC_SPI_SLAVE_DMA_ADDR (WILC_SPI_REG_BASE + 0xc) 9062306a36Sopenharmony_ci#define WILC_SPI_SLAVE_DMA_COUNT (WILC_SPI_REG_BASE + 0x10) 9162306a36Sopenharmony_ci#define WILC_SPI_TX_MODE (WILC_SPI_REG_BASE + 0x20) 9262306a36Sopenharmony_ci#define WILC_SPI_PROTOCOL_CONFIG (WILC_SPI_REG_BASE + 0x24) 9362306a36Sopenharmony_ci#define WILC_SPI_INTR_CTL (WILC_SPI_REG_BASE + 0x2c) 9462306a36Sopenharmony_ci#define WILC_SPI_INT_STATUS (WILC_SPI_REG_BASE + 0x40) 9562306a36Sopenharmony_ci#define WILC_SPI_INT_CLEAR (WILC_SPI_REG_BASE + 0x44) 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci#define WILC_SPI_WAKEUP_REG 0x1 9862306a36Sopenharmony_ci#define WILC_SPI_WAKEUP_BIT BIT(1) 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci#define WILC_SPI_CLK_STATUS_REG 0x0f 10162306a36Sopenharmony_ci#define WILC_SPI_CLK_STATUS_BIT BIT(2) 10262306a36Sopenharmony_ci#define WILC_SPI_HOST_TO_FW_REG 0x0b 10362306a36Sopenharmony_ci#define WILC_SPI_HOST_TO_FW_BIT BIT(0) 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci#define WILC_SPI_FW_TO_HOST_REG 0x10 10662306a36Sopenharmony_ci#define WILC_SPI_FW_TO_HOST_BIT BIT(0) 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci#define WILC_SPI_PROTOCOL_OFFSET (WILC_SPI_PROTOCOL_CONFIG - \ 10962306a36Sopenharmony_ci WILC_SPI_REG_BASE) 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci#define WILC_SPI_CLOCKLESS_ADDR_LIMIT 0x30 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci/* Functions IO enables bits */ 11462306a36Sopenharmony_ci#define WILC_SDIO_CCCR_IO_EN_FUNC1 BIT(1) 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci/* Function/Interrupt enables bits */ 11762306a36Sopenharmony_ci#define WILC_SDIO_CCCR_IEN_MASTER BIT(0) 11862306a36Sopenharmony_ci#define WILC_SDIO_CCCR_IEN_FUNC1 BIT(1) 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci/* Abort CCCR register bits */ 12162306a36Sopenharmony_ci#define WILC_SDIO_CCCR_ABORT_RESET BIT(3) 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci/* Vendor specific CCCR registers */ 12462306a36Sopenharmony_ci#define WILC_SDIO_WAKEUP_REG 0xf0 12562306a36Sopenharmony_ci#define WILC_SDIO_WAKEUP_BIT BIT(0) 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci#define WILC_SDIO_CLK_STATUS_REG 0xf1 12862306a36Sopenharmony_ci#define WILC_SDIO_CLK_STATUS_BIT BIT(0) 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci#define WILC_SDIO_INTERRUPT_DATA_SZ_REG 0xf2 /* Read size (2 bytes) */ 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci#define WILC_SDIO_VMM_TBL_CTRL_REG 0xf6 13362306a36Sopenharmony_ci#define WILC_SDIO_IRQ_FLAG_REG 0xf7 13462306a36Sopenharmony_ci#define WILC_SDIO_IRQ_CLEAR_FLAG_REG 0xf8 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci#define WILC_SDIO_HOST_TO_FW_REG 0xfa 13762306a36Sopenharmony_ci#define WILC_SDIO_HOST_TO_FW_BIT BIT(0) 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci#define WILC_SDIO_FW_TO_HOST_REG 0xfc 14062306a36Sopenharmony_ci#define WILC_SDIO_FW_TO_HOST_BIT BIT(0) 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci/* Function 1 specific FBR register */ 14362306a36Sopenharmony_ci#define WILC_SDIO_FBR_CSA_REG 0x10C /* CSA pointer (3 bytes) */ 14462306a36Sopenharmony_ci#define WILC_SDIO_FBR_DATA_REG 0x10F 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci#define WILC_SDIO_F1_DATA_REG 0x0 14762306a36Sopenharmony_ci#define WILC_SDIO_EXT_IRQ_FLAG_REG 0x4 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci#define WILC_AHB_DATA_MEM_BASE 0x30000 15062306a36Sopenharmony_ci#define WILC_AHB_SHARE_MEM_BASE 0xd0000 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci#define WILC_VMM_TBL_RX_SHADOW_BASE WILC_AHB_SHARE_MEM_BASE 15362306a36Sopenharmony_ci#define WILC_VMM_TBL_RX_SHADOW_SIZE 256 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci#define WILC_FW_HOST_COMM 0x13c0 15662306a36Sopenharmony_ci#define WILC_GP_REG_0 0x149c 15762306a36Sopenharmony_ci#define WILC_GP_REG_1 0x14a0 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci#define WILC_HAVE_SDIO_IRQ_GPIO BIT(0) 16062306a36Sopenharmony_ci#define WILC_HAVE_USE_PMU BIT(1) 16162306a36Sopenharmony_ci#define WILC_HAVE_SLEEP_CLK_SRC_RTC BIT(2) 16262306a36Sopenharmony_ci#define WILC_HAVE_SLEEP_CLK_SRC_XO BIT(3) 16362306a36Sopenharmony_ci#define WILC_HAVE_EXT_PA_INV_TX_RX BIT(4) 16462306a36Sopenharmony_ci#define WILC_HAVE_LEGACY_RF_SETTINGS BIT(5) 16562306a36Sopenharmony_ci#define WILC_HAVE_XTAL_24 BIT(6) 16662306a36Sopenharmony_ci#define WILC_HAVE_DISABLE_WILC_UART BIT(7) 16762306a36Sopenharmony_ci#define WILC_HAVE_USE_IRQ_AS_HOST_WAKE BIT(8) 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci#define WILC_CORTUS_INTERRUPT_BASE 0x10A8 17062306a36Sopenharmony_ci#define WILC_CORTUS_INTERRUPT_1 (WILC_CORTUS_INTERRUPT_BASE + 0x4) 17162306a36Sopenharmony_ci#define WILC_CORTUS_INTERRUPT_2 (WILC_CORTUS_INTERRUPT_BASE + 0x8) 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci/* tx control register 1 to 4 for RX */ 17462306a36Sopenharmony_ci#define WILC_REG_4_TO_1_RX 0x1e1c 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci/* tx control register 1 to 4 for TX Bank_0 */ 17762306a36Sopenharmony_ci#define WILC_REG_4_TO_1_TX_BANK0 0x1e9c 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci#define WILC_CORTUS_RESET_MUX_SEL 0x1118 18062306a36Sopenharmony_ci#define WILC_CORTUS_BOOT_REGISTER 0xc0000 18162306a36Sopenharmony_ci 18262306a36Sopenharmony_ci#define WILC_CORTUS_BOOT_FROM_IRAM 0x71 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci#define WILC_1000_BASE_ID 0x100000 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_ci#define WILC_1000_BASE_ID_2A 0x1002A0 18762306a36Sopenharmony_ci#define WILC_1000_BASE_ID_2A_REV1 (WILC_1000_BASE_ID_2A + 1) 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_ci#define WILC_1000_BASE_ID_2B 0x1002B0 19062306a36Sopenharmony_ci#define WILC_1000_BASE_ID_2B_REV1 (WILC_1000_BASE_ID_2B + 1) 19162306a36Sopenharmony_ci#define WILC_1000_BASE_ID_2B_REV2 (WILC_1000_BASE_ID_2B + 2) 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci#define WILC_CHIP_REV_FIELD GENMASK(11, 0) 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci/******************************************** 19662306a36Sopenharmony_ci * 19762306a36Sopenharmony_ci * Wlan Defines 19862306a36Sopenharmony_ci * 19962306a36Sopenharmony_ci ********************************************/ 20062306a36Sopenharmony_ci#define WILC_CFG_PKT 1 20162306a36Sopenharmony_ci#define WILC_NET_PKT 0 20262306a36Sopenharmony_ci#define WILC_MGMT_PKT 2 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci#define WILC_CFG_SET 1 20562306a36Sopenharmony_ci#define WILC_CFG_QUERY 0 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_ci#define WILC_CFG_RSP 1 20862306a36Sopenharmony_ci#define WILC_CFG_RSP_STATUS 2 20962306a36Sopenharmony_ci#define WILC_CFG_RSP_SCAN 3 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ci#define WILC_ABORT_REQ_BIT BIT(31) 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci#define WILC_RX_BUFF_SIZE (96 * 1024) 21462306a36Sopenharmony_ci#define WILC_TX_BUFF_SIZE (64 * 1024) 21562306a36Sopenharmony_ci 21662306a36Sopenharmony_ci#define NQUEUES 4 21762306a36Sopenharmony_ci#define AC_BUFFER_SIZE 1000 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ci#define VO_AC_COUNT_FIELD GENMASK(31, 25) 22062306a36Sopenharmony_ci#define VO_AC_ACM_STAT_FIELD BIT(24) 22162306a36Sopenharmony_ci#define VI_AC_COUNT_FIELD GENMASK(23, 17) 22262306a36Sopenharmony_ci#define VI_AC_ACM_STAT_FIELD BIT(16) 22362306a36Sopenharmony_ci#define BE_AC_COUNT_FIELD GENMASK(15, 9) 22462306a36Sopenharmony_ci#define BE_AC_ACM_STAT_FIELD BIT(8) 22562306a36Sopenharmony_ci#define BK_AC_COUNT_FIELD GENMASK(7, 3) 22662306a36Sopenharmony_ci#define BK_AC_ACM_STAT_FIELD BIT(1) 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_ci#define WILC_PKT_HDR_CONFIG_FIELD BIT(31) 22962306a36Sopenharmony_ci#define WILC_PKT_HDR_OFFSET_FIELD GENMASK(30, 22) 23062306a36Sopenharmony_ci#define WILC_PKT_HDR_TOTAL_LEN_FIELD GENMASK(21, 11) 23162306a36Sopenharmony_ci#define WILC_PKT_HDR_LEN_FIELD GENMASK(10, 0) 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ci#define WILC_INTERRUPT_DATA_SIZE GENMASK(14, 0) 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci#define WILC_VMM_BUFFER_SIZE GENMASK(9, 0) 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ci#define WILC_VMM_HDR_TYPE BIT(31) 23862306a36Sopenharmony_ci#define WILC_VMM_HDR_MGMT_FIELD BIT(30) 23962306a36Sopenharmony_ci#define WILC_VMM_HDR_PKT_SIZE GENMASK(29, 15) 24062306a36Sopenharmony_ci#define WILC_VMM_HDR_BUFF_SIZE GENMASK(14, 0) 24162306a36Sopenharmony_ci 24262306a36Sopenharmony_ci#define WILC_VMM_ENTRY_COUNT GENMASK(8, 3) 24362306a36Sopenharmony_ci#define WILC_VMM_ENTRY_AVAILABLE BIT(2) 24462306a36Sopenharmony_ci/*******************************************/ 24562306a36Sopenharmony_ci/* E0 and later Interrupt flags. */ 24662306a36Sopenharmony_ci/*******************************************/ 24762306a36Sopenharmony_ci/*******************************************/ 24862306a36Sopenharmony_ci/* E0 and later Interrupt flags. */ 24962306a36Sopenharmony_ci/* IRQ Status word */ 25062306a36Sopenharmony_ci/* 15:0 = DMA count in words. */ 25162306a36Sopenharmony_ci/* 16: INT0 flag */ 25262306a36Sopenharmony_ci/* 17: INT1 flag */ 25362306a36Sopenharmony_ci/* 18: INT2 flag */ 25462306a36Sopenharmony_ci/* 19: INT3 flag */ 25562306a36Sopenharmony_ci/* 20: INT4 flag */ 25662306a36Sopenharmony_ci/* 21: INT5 flag */ 25762306a36Sopenharmony_ci/*******************************************/ 25862306a36Sopenharmony_ci#define IRG_FLAGS_OFFSET 16 25962306a36Sopenharmony_ci#define IRQ_DMA_WD_CNT_MASK GENMASK(IRG_FLAGS_OFFSET - 1, 0) 26062306a36Sopenharmony_ci#define INT_0 BIT(IRG_FLAGS_OFFSET) 26162306a36Sopenharmony_ci#define INT_1 BIT(IRG_FLAGS_OFFSET + 1) 26262306a36Sopenharmony_ci#define INT_2 BIT(IRG_FLAGS_OFFSET + 2) 26362306a36Sopenharmony_ci#define INT_3 BIT(IRG_FLAGS_OFFSET + 3) 26462306a36Sopenharmony_ci#define INT_4 BIT(IRG_FLAGS_OFFSET + 4) 26562306a36Sopenharmony_ci#define INT_5 BIT(IRG_FLAGS_OFFSET + 5) 26662306a36Sopenharmony_ci#define MAX_NUM_INT 5 26762306a36Sopenharmony_ci#define IRG_FLAGS_MASK GENMASK(IRG_FLAGS_OFFSET + MAX_NUM_INT, \ 26862306a36Sopenharmony_ci IRG_FLAGS_OFFSET) 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci/*******************************************/ 27162306a36Sopenharmony_ci/* E0 and later Interrupt flags. */ 27262306a36Sopenharmony_ci/* IRQ Clear word */ 27362306a36Sopenharmony_ci/* 0: Clear INT0 */ 27462306a36Sopenharmony_ci/* 1: Clear INT1 */ 27562306a36Sopenharmony_ci/* 2: Clear INT2 */ 27662306a36Sopenharmony_ci/* 3: Clear INT3 */ 27762306a36Sopenharmony_ci/* 4: Clear INT4 */ 27862306a36Sopenharmony_ci/* 5: Clear INT5 */ 27962306a36Sopenharmony_ci/* 6: Select VMM table 1 */ 28062306a36Sopenharmony_ci/* 7: Select VMM table 2 */ 28162306a36Sopenharmony_ci/* 8: Enable VMM */ 28262306a36Sopenharmony_ci/*******************************************/ 28362306a36Sopenharmony_ci#define CLR_INT0 BIT(0) 28462306a36Sopenharmony_ci#define CLR_INT1 BIT(1) 28562306a36Sopenharmony_ci#define CLR_INT2 BIT(2) 28662306a36Sopenharmony_ci#define CLR_INT3 BIT(3) 28762306a36Sopenharmony_ci#define CLR_INT4 BIT(4) 28862306a36Sopenharmony_ci#define CLR_INT5 BIT(5) 28962306a36Sopenharmony_ci#define SEL_VMM_TBL0 BIT(6) 29062306a36Sopenharmony_ci#define SEL_VMM_TBL1 BIT(7) 29162306a36Sopenharmony_ci#define EN_VMM BIT(8) 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_ci#define DATA_INT_EXT INT_0 29462306a36Sopenharmony_ci#define ALL_INT_EXT DATA_INT_EXT 29562306a36Sopenharmony_ci#define NUM_INT_EXT 1 29662306a36Sopenharmony_ci#define UNHANDLED_IRQ_MASK GENMASK(MAX_NUM_INT - 1, NUM_INT_EXT) 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ci#define DATA_INT_CLR CLR_INT0 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ci#define ENABLE_RX_VMM (SEL_VMM_TBL1 | EN_VMM) 30162306a36Sopenharmony_ci#define ENABLE_TX_VMM (SEL_VMM_TBL0 | EN_VMM) 30262306a36Sopenharmony_ci/* time for expiring the completion of cfg packets */ 30362306a36Sopenharmony_ci#define WILC_CFG_PKTS_TIMEOUT msecs_to_jiffies(3000) 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_ci#define IS_MANAGMEMENT 0x100 30662306a36Sopenharmony_ci#define IS_MANAGMEMENT_CALLBACK 0x080 30762306a36Sopenharmony_ci#define IS_MGMT_STATUS_SUCCES 0x040 30862306a36Sopenharmony_ci#define IS_MGMT_AUTH_PKT 0x010 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_ci#define WILC_WID_TYPE GENMASK(15, 12) 31162306a36Sopenharmony_ci#define WILC_VMM_ENTRY_FULL_RETRY 1 31262306a36Sopenharmony_ci/******************************************** 31362306a36Sopenharmony_ci * 31462306a36Sopenharmony_ci * Tx/Rx Queue Structure 31562306a36Sopenharmony_ci * 31662306a36Sopenharmony_ci ********************************************/ 31762306a36Sopenharmony_cienum ip_pkt_priority { 31862306a36Sopenharmony_ci AC_VO_Q = 0, 31962306a36Sopenharmony_ci AC_VI_Q = 1, 32062306a36Sopenharmony_ci AC_BE_Q = 2, 32162306a36Sopenharmony_ci AC_BK_Q = 3 32262306a36Sopenharmony_ci}; 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_cistruct txq_entry_t { 32562306a36Sopenharmony_ci struct list_head list; 32662306a36Sopenharmony_ci int type; 32762306a36Sopenharmony_ci u8 q_num; 32862306a36Sopenharmony_ci int ack_idx; 32962306a36Sopenharmony_ci u8 *buffer; 33062306a36Sopenharmony_ci int buffer_size; 33162306a36Sopenharmony_ci void *priv; 33262306a36Sopenharmony_ci int status; 33362306a36Sopenharmony_ci struct wilc_vif *vif; 33462306a36Sopenharmony_ci void (*tx_complete_func)(void *priv, int status); 33562306a36Sopenharmony_ci}; 33662306a36Sopenharmony_ci 33762306a36Sopenharmony_cistruct txq_fw_recv_queue_stat { 33862306a36Sopenharmony_ci u8 acm; 33962306a36Sopenharmony_ci u8 count; 34062306a36Sopenharmony_ci}; 34162306a36Sopenharmony_ci 34262306a36Sopenharmony_cistruct txq_handle { 34362306a36Sopenharmony_ci struct txq_entry_t txq_head; 34462306a36Sopenharmony_ci u16 count; 34562306a36Sopenharmony_ci struct txq_fw_recv_queue_stat fw; 34662306a36Sopenharmony_ci}; 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_cistruct rxq_entry_t { 34962306a36Sopenharmony_ci struct list_head list; 35062306a36Sopenharmony_ci u8 *buffer; 35162306a36Sopenharmony_ci int buffer_size; 35262306a36Sopenharmony_ci}; 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_ci/******************************************** 35562306a36Sopenharmony_ci * 35662306a36Sopenharmony_ci * Host IF Structure 35762306a36Sopenharmony_ci * 35862306a36Sopenharmony_ci ********************************************/ 35962306a36Sopenharmony_cistruct wilc; 36062306a36Sopenharmony_cistruct wilc_hif_func { 36162306a36Sopenharmony_ci int (*hif_init)(struct wilc *wilc, bool resume); 36262306a36Sopenharmony_ci int (*hif_deinit)(struct wilc *wilc); 36362306a36Sopenharmony_ci int (*hif_read_reg)(struct wilc *wilc, u32 addr, u32 *data); 36462306a36Sopenharmony_ci int (*hif_write_reg)(struct wilc *wilc, u32 addr, u32 data); 36562306a36Sopenharmony_ci int (*hif_block_rx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); 36662306a36Sopenharmony_ci int (*hif_block_tx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); 36762306a36Sopenharmony_ci int (*hif_read_int)(struct wilc *wilc, u32 *int_status); 36862306a36Sopenharmony_ci int (*hif_clear_int_ext)(struct wilc *wilc, u32 val); 36962306a36Sopenharmony_ci int (*hif_read_size)(struct wilc *wilc, u32 *size); 37062306a36Sopenharmony_ci int (*hif_block_tx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); 37162306a36Sopenharmony_ci int (*hif_block_rx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); 37262306a36Sopenharmony_ci int (*hif_sync_ext)(struct wilc *wilc, int nint); 37362306a36Sopenharmony_ci int (*enable_interrupt)(struct wilc *nic); 37462306a36Sopenharmony_ci void (*disable_interrupt)(struct wilc *nic); 37562306a36Sopenharmony_ci int (*hif_reset)(struct wilc *wilc); 37662306a36Sopenharmony_ci bool (*hif_is_init)(struct wilc *wilc); 37762306a36Sopenharmony_ci}; 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_ci#define WILC_MAX_CFG_FRAME_SIZE 1468 38062306a36Sopenharmony_ci 38162306a36Sopenharmony_cistruct tx_complete_data { 38262306a36Sopenharmony_ci int size; 38362306a36Sopenharmony_ci void *buff; 38462306a36Sopenharmony_ci struct sk_buff *skb; 38562306a36Sopenharmony_ci}; 38662306a36Sopenharmony_ci 38762306a36Sopenharmony_cistruct wilc_cfg_cmd_hdr { 38862306a36Sopenharmony_ci u8 cmd_type; 38962306a36Sopenharmony_ci u8 seq_no; 39062306a36Sopenharmony_ci __le16 total_len; 39162306a36Sopenharmony_ci __le32 driver_handler; 39262306a36Sopenharmony_ci}; 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_cistruct wilc_cfg_frame { 39562306a36Sopenharmony_ci struct wilc_cfg_cmd_hdr hdr; 39662306a36Sopenharmony_ci u8 frame[WILC_MAX_CFG_FRAME_SIZE]; 39762306a36Sopenharmony_ci}; 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_cistruct wilc_cfg_rsp { 40062306a36Sopenharmony_ci u8 type; 40162306a36Sopenharmony_ci u8 seq_no; 40262306a36Sopenharmony_ci}; 40362306a36Sopenharmony_ci 40462306a36Sopenharmony_cistruct wilc_vif; 40562306a36Sopenharmony_ci 40662306a36Sopenharmony_ciint wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, 40762306a36Sopenharmony_ci u32 buffer_size); 40862306a36Sopenharmony_ciint wilc_wlan_start(struct wilc *wilc); 40962306a36Sopenharmony_ciint wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif); 41062306a36Sopenharmony_ciint wilc_wlan_txq_add_net_pkt(struct net_device *dev, 41162306a36Sopenharmony_ci struct tx_complete_data *tx_data, u8 *buffer, 41262306a36Sopenharmony_ci u32 buffer_size, 41362306a36Sopenharmony_ci void (*tx_complete_fn)(void *, int)); 41462306a36Sopenharmony_ciint wilc_wlan_handle_txq(struct wilc *wl, u32 *txq_count); 41562306a36Sopenharmony_civoid wilc_handle_isr(struct wilc *wilc); 41662306a36Sopenharmony_civoid wilc_wlan_cleanup(struct net_device *dev); 41762306a36Sopenharmony_ciint wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, 41862306a36Sopenharmony_ci u32 buffer_size, int commit, u32 drv_handler); 41962306a36Sopenharmony_ciint wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, 42062306a36Sopenharmony_ci u32 drv_handler); 42162306a36Sopenharmony_ciint wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, 42262306a36Sopenharmony_ci u32 buffer_size, void (*func)(void *, int)); 42362306a36Sopenharmony_civoid wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value); 42462306a36Sopenharmony_ciint wilc_wlan_get_num_conn_ifcs(struct wilc *wilc); 42562306a36Sopenharmony_cinetdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev); 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_civoid wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size); 42862306a36Sopenharmony_cibool wilc_wfi_mgmt_frame_rx(struct wilc_vif *vif, u8 *buff, u32 size); 42962306a36Sopenharmony_civoid host_wakeup_notify(struct wilc *wilc); 43062306a36Sopenharmony_civoid host_sleep_notify(struct wilc *wilc); 43162306a36Sopenharmony_civoid chip_allow_sleep(struct wilc *wilc); 43262306a36Sopenharmony_civoid chip_wakeup(struct wilc *wilc); 43362306a36Sopenharmony_ciint wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, 43462306a36Sopenharmony_ci u32 count); 43562306a36Sopenharmony_ciint wilc_wlan_init(struct net_device *dev); 43662306a36Sopenharmony_ciu32 wilc_get_chipid(struct wilc *wilc, bool update); 43762306a36Sopenharmony_ci#endif 438