blob: 80a9f866c03b3917b2b1e9ce0b43671b9603bb75 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001#ifndef __HMU_DRV_FUNC_H__
2#define __HMU_DRV_FUNC_H__
3#include "kal_general_types.h"
4#include "dcl.h"
5
6/*************************************************************************
7 * HMU Parameters Definition
8 *************************************************************************/
9 /*Maximum number of emulation devices managed by HMU in normal booting*/
10#define HMU_MAX_EMUDEVNUM 10
11 /*Maximum number of emulation devices managed by HMU in Host Detection booting*/
12#define HMU_MAX_HD_EMUDEVNUM 3
13/*Maximum length of the HIF core's extended information */
14#define HMU_MAX_HIF_EXTINFO_SIZE 512
15/*Maximum length of each emulation device's extended information */
16#define HMU_MAX_EMUDEV_EXTINFO_SIZE 64
17
18#define HMU_PREFIX "HMU"
19#define HMU_FAIL_PREFIX "HMU-FAIL"
20
21
22/* Port number for DHL debugging channel. */
23#define HMU_EXCEPT_COM_PORT uart_port_usb2
24
25/*************************************************************************
26 * Type Definitions
27 *************************************************************************/
28/*The definitions abouthe HIF event group */
29/* Name */
30#define HIF_DRV_EG_NAME "HIF_DRV_EG"
31
32/* Event */
33#define HIF_DRV_EG_HIF_TICK_EVENT 0x80000000 /* HIF tick to trigger USBCORE to check GPD. */
34#define HIF_DRV_EG_HIF_TICK_EVENT_SDIO 0x08000000 /* HIF tick to trigger SDIOCORE to check GPD. */
35#define HIF_DRV_EG_HIF_TICK_EVENT_UART 0x00800000 /* HIF tick to trigger UARTCORE to check GPD. */
36#define HIF_DRV_EG_HIF_TICK_EVENT_CLDMA 0x00080000 /* HIF tick to trigger CLDMACORE to check GPD. */
37#define HIF_DRV_EG_HIF_TICK_EVENT_CCB 0x00008000 /* HIF tick to trigger CCISMCCB. */
38#define HIF_DRV_EG_USBC_IND_EVENT 0x40000000 /* To allow USBCORE to indicate device events or setup packet up to USBCLASS in task context. */
39#define HIF_DRV_EG_UART_IND_EVENT 0x00400000 /* To allow UARTCORE to indicate port open in task context. */
40#define HIF_DRV_EG_HIF_TICK_EVENT_LHIF 0x0000800 /* HIF tick for LHIF polling UL data */
41#define HIF_DRV_EG_HIF_TICK_EVENT_LHIF_LOG 0x0000400 /* HIF tick for LHIF polling HW log */
42#define HIF_DRV_EG_ALL_EVENT 0xFFFFFFFF /* All events associated with the event group managed by HMU. */
43#define HIF_DRV_EG_HIF_RELOAD_EVNET 0x00000008 /* HIF Reload Event for HIF ON/OFF enhance, keep HMU for RGPD reload*/
44#define HIF_DRV_EG_HIF_TICK_EVENT_IPFC 0x00000001 /* HIF tick to trigger IPFCORE to check DL META or update */
45#define HIF_DRV_EG_HIF_IND_EVENT_IPFC 0x00000002 /* To allow IPFCORE to indicate internal ILM/event to itself */
46
47/* HIF tick to trigger HIFCORE to check GPD. Add HIF tick event must modify this mask*/
48#define HIF_DRV_EG_HIF_TICK_EVENT_GROUP ( HIF_DRV_EG_HIF_TICK_EVENT \
49 | HIF_DRV_EG_HIF_TICK_EVENT_SDIO \
50 | HIF_DRV_EG_HIF_TICK_EVENT_UART \
51 | HIF_DRV_EG_HIF_TICK_EVENT_CLDMA \
52 | HIF_DRV_EG_HIF_TICK_EVENT_LHIF \
53 | HIF_DRV_EG_HIF_TICK_EVENT_LHIF_LOG \
54 | HIF_DRV_EG_HIF_TICK_EVENT_CCB \
55 | HIF_DRV_EG_HIF_RELOAD_EVNET \
56 | HIF_DRV_EG_HIF_TICK_EVENT_IPFC \
57 )
58
59/**
60 * @brief enumeration for HMU Emulation Device types
61 */
62typedef enum
63{
64 HMU_USB_DEV_MIN = 0,
65 HMU_USB_DEV_ACM, hmu_usb_dev_cdcacm = HMU_USB_DEV_ACM,
66 HMU_USB_DEV_ECM, hmu_usb_dev_ecm = HMU_USB_DEV_ECM,
67 HMU_USB_DEV_MBIM, hmu_usb_dev_mbim = HMU_USB_DEV_MBIM,
68 HMU_USB_DEV_CDROM, hmu_usb_dev_cdrom = HMU_USB_DEV_CDROM,
69 HMU_USB_DEV_DISK, hmu_usb_dev_disk = HMU_USB_DEV_DISK,
70 HMU_USB_DEV_RNDIS, hmu_usb_dev_rndis = HMU_USB_DEV_RNDIS,
71#ifdef __USB_MSD_SUPPORT__
72 HMU_USB_DEV_MSD,hmu_usb_dev_msd = HMU_USB_DEV_MSD,
73#endif
74 HMU_USB_DEV_MAX,
75
76 HMU_MOBILE_DEV_MIN = 20,
77 HMU_MOBILE_DEV_COM ,
78 HMU_MOBILE_DEV_ETH ,
79 HMU_MOBILE_DEV_IP ,
80 HMU_MOBILE_DEV_IPC,
81 HMU_MOBILE_DEV_MB ,
82 HMU_MOBILE_DEV_MAX ,
83
84 HMU_EXT_DEV_MIN = 40 ,
85 HMU_EXT_DEV_UART ,
86 HMU_EXT_DEV_MAX ,
87
88 HMU_DEV_NONE = 0x7fffffff,
89}hmuEmuDeviceType_enum;
90
91/**
92 * @brief enumeration for HMU HIFCORE Init function types. Here we define both of init functions and post init functions
93 */
94typedef enum
95{
96// The declaration part for the type of init/deinit functions
97 HMU_HIFCORE_MIN = 0,
98 HMU_HIFCORE_USB ,
99 HMU_HIFCORE_SDIO ,
100 HMU_HIFCORE_CCIF ,
101 HMU_HIFCORE_CAIF ,
102 HMU_HIFCORE_CLDMA ,
103 HMU_HIFCORE_CCCI ,
104 HMU_HIFCORE_MAX ,
105
106 HMU_HIFCORE_TYPE_NONE = 0x7fffffff,
107}hmuHifCoreType_enum;
108
109#if 0
110/* under construction !*/
111/* under construction !*/
112/* under construction !*/
113/* under construction !*/
114/* under construction !*/
115/* under construction !*/
116/* under construction !*/
117/* under construction !*/
118/* under construction !*/
119/* under construction !*/
120/* under construction !*/
121/* under construction !*/
122/* under construction !*/
123#endif
124
125/*************************************************************************
126 * Struct Definitions
127 *************************************************************************/
128/**
129 * @name: HMU_EMUDEV_INFO_STRUCT
130 * @brief the hmu structure for emulation device
131 */
132typedef struct HMU_EMUDEV_INFO_STRUCT
133{
134 /* the emulation device type supported in LTE HIF */
135 hmuEmuDeviceType_enum dev_type;
136 /* the mapping between the emulation device and it's upper layer tunnel */
137 kal_uint32 dev_mapping;
138 /* reserve in NVRAM space. next pointer point to the next emulation device in device list. Null means no next device */
139 union {
140 void *reserve ;
141 struct HMU_EMUDEV_INFO_STRUCT *next ; // Not use in NVRAM
142 } u ;
143 /* the length of extra device-specific information */
144 kal_uint32 ext_devinfo_len;
145 /* the pointer to extra device-specific information */
146 kal_char ext_devinfo[HMU_MAX_EMUDEV_EXTINFO_SIZE];
147}hmu_emudev_info;
148
149/**
150 * @name: HMU_CONF_STRUCT_STRUCT
151 * @brief the hmu structure for HMU main structure in normal booting, and the configuration is loaded from NVRAM_EF_HMU_CONFIG_LID.
152 */
153typedef struct HMU_CONF_STRUCT_STRUCT
154{
155 /* total device number defined configuration files */
156 kal_uint32 dev_num;
157 /* the length of extra hif specific information*/
158 kal_uint32 ext_hifinfo_len;
159 /* the pointer to extra hif specific information*/
160 kal_char ext_hifinfo[HMU_MAX_HIF_EXTINFO_SIZE];
161 /* number of device info list to introduce the device information of the configured devices*/
162 hmu_emudev_info dev_info[HMU_MAX_EMUDEVNUM];
163}hmu_conf_struct;
164
165/**
166 * @name: HMU_HD_CONF_STRUCT_STRUCT
167 * @brief the hmu structure for HMU main structure in Host Detection booting, and the configuration is loaded from NVRAM_EF_HMU_HD_CONFIG_LID.
168 */
169typedef struct HMU_HD_CONF_STRUCT_STRUCT
170{
171 kal_uint32 dev_num;
172 kal_uint32 ext_hifinfo_len;
173 kal_char ext_hifinfo[HMU_MAX_HIF_EXTINFO_SIZE];
174 hmu_emudev_info dev_info[HMU_MAX_HD_EMUDEVNUM];
175}hmu_hd_conf_struct;
176
177/*
178 * @brief: upper layer device module exception mode initialization function
179 * it is used for the case that an exception happens before hmu_init() completed
180 *
181 * @return KAL_TRUE if caller is allowed to proceed the exception flow
182 * KAL_FALSE otherwise
183 */
184typedef kal_bool (*uldrv_except_init)(kal_uint32 dev_mapping, kal_uint32 ext_devinfo_len, kal_char *ext_devinfo);
185
186/**
187 * @name: _HMU_ULDRV_EXCEPT_INITFUNC_STRUCT
188 *
189 * @brief the structure is for upper layer device module to register its
190 * exception mode initialization callback function
191 */
192typedef struct _HMU_ULDRV_EXCEPT_INITFUNC_STRUCT {
193 kal_uint32 port_id;
194 uldrv_except_init except_init_func;
195} hmu_uldrv_except_initfunc ;
196
197typedef kal_int32 (*ul_drv_init)(kal_uint32 dev_mapping, kal_uint32 ext_devinfo_len, kal_char * ext_devinfo) ;
198
199/**
200 * @name: _HMU_HIFCORE_INITFUNC_STRUCT
201 * @brief the structure for Init function and hif emu device types registration table
202 */
203typedef struct _HMU_ULDRV_INITFUNC_STRUCT {
204 hmuEmuDeviceType_enum dev_type;
205 ul_drv_init init_func;
206} hmu_uldrv_initfunc ;
207
208typedef kal_int32 (*hif_core_init)(kal_uint32 dev_num, hmu_emudev_info *emudev_info, kal_uint32 ext_hifinfo_len, kal_char * ext_hifinfo) ;
209
210/**
211 * @name: _HMU_HIFCORE_INITFUNC_STRUCT
212 * @brief the structure for Init function and hif core types registration table
213 */
214typedef struct _HMU_HIFCORE_INITFUNC_STRUCT {
215 hmuHifCoreType_enum hifcore_type;
216 hif_core_init init_func;
217} hmu_hifcore_initfunc ;
218
219/**
220 * @name: _HMU_TICK_INTERVAL_STRUCT
221 * @brief the structure for set hif event trigger interval
222 */
223typedef struct _HMU_TICK_INTERVAL_STRUCT
224{
225 kal_uint32 hif_event;
226 kal_uint32 hif_event_tick_count;
227 kal_uint32 hif_current_tick;
228} hmu_tick_interval;
229
230
231/**
232 * @name: DECLARE_HMU_ULDRV_EXCEPT_INIT_FUNC
233 * @brief This macro is used to declare the upper layer device module exception initialization functions which will be linked in HMU registration table
234 */
235#define DECLARE_HMU_ULDRV_EXCEPT_INIT_FUNC(_funcName) \
236 extern kal_bool _funcName(kal_uint32 dev_mapping, kal_uint32 ext_devinfo_len, kal_char *ext_devinfo) ;
237
238#endif /*__HMU_DRV_FUNC_H__*/