1 /** @file wifi-sdio.h 2 * 3 * @brief WLAN on SDIO 4 * 5 * Copyright 2008-2024 NXP 6 * 7 * SPDX-License-Identifier: BSD-3-Clause 8 * 9 */ 10 11 #ifndef __WIFI_SDIO_H__ 12 #define __WIFI_SDIO_H__ 13 14 #include <wifi.h> 15 #include "firmware_dnld.h" 16 17 #define wifi_io_e(...) wmlog_e("wifi_io", ##__VA_ARGS__) 18 #define wifi_io_w(...) wmlog_w("wifi_io", ##__VA_ARGS__) 19 20 #if CONFIG_WIFI_IO_DEBUG 21 #define wifi_io_d(...) wmlog("wifi_io", ##__VA_ARGS__) 22 #else 23 #define wifi_io_d(...) 24 #endif /* ! CONFIG_WIFI_IO_DEBUG */ 25 26 #define wifi_io_info_e(...) wmlog_e("wpkt", ##__VA_ARGS__) 27 #define wifi_io_info_w(...) wmlog_w("wpkt", ##__VA_ARGS__) 28 29 #if CONFIG_WIFI_IO_INFO_DUMP 30 #define wifi_io_info_d(...) wmlog("wpkt", ##__VA_ARGS__) 31 #else 32 #define wifi_io_info_d(...) 33 #endif 34 35 #define WLAN_MAGIC_NUM (('W' << 0) | ('L' << 8) | ('F' << 16) | ('W' << 24)) 36 37 #define WIFI_FW_CMDBUF_SIZE 2100U 38 39 #define WIFI_RESP_WAIT_TIME 10 40 41 #if CONFIG_ENABLE_AMSDU_RX 42 #define SDIO_INBUF_LEN (2048 * 2) 43 #else /* ! CONFIG_ENABLE_AMSDU_RX */ 44 #define SDIO_INBUF_LEN 2048 45 #endif /* CONFIG_ENABLE_AMSDU_RX */ 46 47 #define SDIO_OUTBUF_LEN 2048U 48 49 #if (SDIO_INBUF_LEN % MLAN_SDIO_BLOCK_SIZE) 50 #error "Please keep buffer length aligned to SDIO block size" 51 #endif /* Sanity check */ 52 53 #if (SDIO_OUTBUF_LEN % MLAN_SDIO_BLOCK_SIZE) 54 #error "Please keep buffer length aligned to SDIO block size" 55 #endif /* Sanity check */ 56 57 #define SDIO_PAYLOAD_SIZE 16 58 59 /*! @brief Data block count accessed in card */ 60 #define DATA_BLOCK_COUNT (4U) 61 /*! @brief Data buffer size. */ 62 #define DATA_BUFFER_SIZE (SDMMC_DEFAULT_BLOCK_SIZE * DATA_BLOCK_COUNT) 63 64 /* Duplicated in wlan.c. keep in sync till we can be included directly */ 65 typedef struct __nvram_backup_struct 66 { 67 t_u32 ioport; 68 t_u32 curr_wr_port; 69 t_u32 curr_rd_port; 70 t_u32 mp_end_port; 71 t_u32 bss_num; 72 t_u32 sta_mac_addr1; 73 t_u32 sta_mac_addr2; 74 t_u32 wifi_state; 75 } nvram_backup_t; 76 77 extern bool g_txrx_flag; 78 #ifdef WLAN_LOW_POWER_ENABLE 79 extern bool low_power_mode; 80 #endif 81 extern bool cal_data_valid; 82 extern bool mac_addr_valid; 83 84 mlan_status sd_wifi_init(enum wlan_type type, const uint8_t *fw_start_addr, const size_t size); 85 86 #if (CONFIG_WIFI_IND_DNLD) 87 mlan_status sd_wifi_reinit(enum wlan_type type, const uint8_t *fw_start_addr, const size_t size, uint8_t fw_reload); 88 #endif 89 90 mlan_status sd_wifi_post_init(enum wlan_type type); 91 92 void sd_wifi_reset_ports(); 93 94 void sd_wifi_deinit(void); 95 96 /* 97 * @internal 98 * 99 * 100 */ 101 int wlan_send_sdio_cmd(t_u8 *buf, t_u32 tx_blocks, t_u32 buflen); 102 103 /* 104 * @internal 105 * 106 * 107 */ 108 int wifi_send_cmdbuffer(t_u32 tx_blocks, t_u32 len); 109 110 /* 111 * @internal 112 * 113 * 114 */ 115 HostCmd_DS_COMMAND *wifi_get_command_buffer(void); 116 #if CONFIG_FW_VDLL 117 int wifi_send_vdllcmdbuffer(t_u32 tx_blocks, t_u32 len); 118 HostCmd_DS_COMMAND *wifi_get_vdllcommand_buffer(void); 119 int wlan_send_sdio_vdllcmd(t_u8 *buf, t_u32 tx_blocks, t_u32 buflen); 120 #endif 121 122 mlan_status wlan_process_int_status(mlan_adapter *pmadapter); 123 mlan_status wlan_xmit_pkt(t_u8 *buffer, t_u32 txlen, t_u8 interface, t_u32 tx_control); 124 int raw_process_pkt_hdrs(void *pbuf, t_u32 payloadlen, t_u8 interface); 125 uint32_t wifi_get_device_value1(void); 126 127 #if CONFIG_WMM 128 uint8_t *wifi_wmm_get_sdio_outbuf(uint32_t *outbuf_len, mlan_wmm_ac_e queue); 129 mlan_status wlan_xmit_wmm_pkt(t_u8 interface, t_u32 txlen, t_u8 *tx_buf); 130 mlan_status wlan_flush_wmm_pkt(t_u8 pkt_cnt); 131 mlan_status wlan_xmit_bypass_pkt(t_u8 *buffer, t_u32 txlen, t_u8 interface); 132 #if CONFIG_AMSDU_IN_AMPDU 133 uint8_t *wifi_get_amsdu_outbuf(uint32_t offset); 134 mlan_status wlan_xmit_wmm_amsdu_pkt(mlan_wmm_ac_e ac, t_u8 interface, t_u32 txlen, t_u8 *tx_buf, t_u8 amsdu_cnt); 135 #endif 136 #endif 137 138 void sdio_enable_interrupt(void); 139 140 void sdio_disable_interrupt(void); 141 142 void process_pkt_hdrs(void *pbuf, t_u32 payloadlen, t_u8 interface, t_u8 tid, t_u32 tx_control); 143 144 #if CONFIG_WIFI_FW_DEBUG 145 extern void wifi_dump_firmware_info(); 146 extern void wifi_sdio_reg_dbg(); 147 #endif /* CONFIG_WIFI_FW_DEBUG */ 148 149 #endif /* __WIFI_SDIO_H__ */ 150