1 /** @file fwdnld_inf_abs.h 2 * 3 * @brief This file provides interface abstraction APIs 4 * 5 * Copyright 2023-2024 NXP 6 * 7 * SPDX-License-Identifier: BSD-3-Clause 8 * 9 */ 10 11 #ifndef _FWDNLD_INTF_ABS_H_ 12 #define _FWDNLD_INTF_ABS_H_ 13 14 #include <wifi_config_default.h> 15 16 #include <stddef.h> 17 #include <stdint.h> 18 19 /* Return type defines */ 20 typedef enum 21 { 22 /* Please add interface specific return types with the values 23 * APIs just return interface returned return types*/ 24 FWDNLD_INTF_FAIL = 0xffffffff, 25 FWDNLD_INTF_SUCCESS = 0, 26 FWDNLD_INTF_SKIP, 27 FWDNLD_INTF_PART_WRITE, 28 FWDNLD_INTF_PART_READ, 29 FWDNLD_INTF_WAIT, 30 FWDNLD_INTF_EPARAM 31 } fwdnld_intf_ret_t; 32 33 /*Interface type defines*/ 34 35 typedef enum 36 { 37 FWDNLD_INTF_IMU, 38 FWDNLD_INTF_SDIO, 39 FWDNLD_INTF_SPI, 40 FWDNLD_INTF_UART 41 } fwdnld_intf_type_t; 42 43 struct fwdnldintf; 44 45 typedef struct intf_elems 46 { 47 /* Functions for the interface */ 48 fwdnld_intf_ret_t (*fwdnld_intf_send)(struct fwdnldintf *intf, 49 const uint8_t *buff, 50 uint32_t transfer_len, 51 uint32_t *transferred_len); 52 fwdnld_intf_ret_t (*fwdnld_intf_prepare)(struct fwdnldintf *intf, void *params); 53 fwdnld_intf_ret_t (*fwdnld_intf_check_ready)(struct fwdnldintf *intf, void *params); 54 #if (CONFIG_WIFI_IND_DNLD) 55 fwdnld_intf_ret_t (*fwdnld_intf_check_reload)(struct fwdnldintf *intf, uint8_t fw_reload); 56 #endif 57 /* interface values to be stored */ 58 uint8_t *outbuf; /* For Tx */ 59 uint32_t outbuf_len; 60 uint8_t *inbuf; /* For Rx */ 61 uint32_t inbuf_len; 62 void *intf_specific; /*Place holder to store interface specific struct */ 63 } intf_t; 64 65 typedef struct fwdnldintf 66 { 67 fwdnld_intf_type_t intf_type; 68 intf_t intf_s; /*returned by interface init */ 69 } fwdnld_intf_t; 70 71 #define GET_INTF_TYPE(x) ((x)->intf_type) 72 #define GET_INTF_OUTBUF(x) ((x)->intf_s.outbuf) 73 #define GET_INTF_OUTBUFLEN(x) ((x)->intf_s.outbuf_len) 74 75 #if CONFIG_WIFI_IND_DNLD 76 /** driver initial the fw reset */ 77 #define FW_RELOAD_SDIO_INBAND_RESET 1 78 /** out band reset trigger reset, no interface re-emulation */ 79 #define FW_RELOAD_NO_EMULATION 2 80 /** out band reset with interface re-emulation */ 81 #define FW_RELOAD_WITH_EMULATION 3 82 /** sdio hw reset */ 83 #define FW_RELOAD_SDIO_HW_RESET 5 84 #endif 85 86 /** API to init the interface 87 * 88 * This function calls internally the interface specific init 89 * 90 * \param[in] intf_type Its of type fwdnld_intf_type_t 91 * \param[in] intf_specific Initialisation sequence related any setting that 92 * the specific interface needs. 93 * \note intf_specific is to be interpretted and defined by each interface 94 * 95 * \return fwdnld_intf* Success, a pointer to interface is returned. To be used in 96 * further API calls to this inited interface. 97 * \return In case init fails, NULL is returned. 98 */ 99 fwdnld_intf_t *fwdnld_intf_init(fwdnld_intf_type_t intf_type, void *intf_specific); 100 101 #endif /*_FWDNLD_INTF_ABS_H_*/ 102