yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2012 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /***************************************************************************** |
| 37 | * |
| 38 | * Filename: |
| 39 | * --------- |
| 40 | * hmu.c |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * MOLY |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * This file is the header file of Host Interface Management Unit. |
| 49 | * |
| 50 | * Author: |
| 51 | * ------- |
| 52 | * ------- |
| 53 | * |
| 54 | * |
| 55 | * ========================================================================== |
| 56 | * $Log$ |
| 57 | * |
| 58 | * 08 07 2017 cs.huang |
| 59 | * [MOLY00268551] Task batch scheduling for LTE Low power |
| 60 | * HMU for TG change |
| 61 | * |
| 62 | * 08 07 2017 cs.huang |
| 63 | * [MOLY00268551] Task batch scheduling for LTE Low power |
| 64 | * HMU for TG change |
| 65 | * |
| 66 | * 02 06 2017 steve.kao |
| 67 | * [MOLY00195563] [6293][EL2][UPCM][RATDM][EPDCP] Initial feature integrations |
| 68 | * |
| 69 | * [UMOLYA][TRUNK][HMU] Set HMU_GPTIMER_PRIODIC_INTERVAL as 1 ms for UESIM only |
| 70 | * |
| 71 | * 09 26 2016 cammie.yang |
| 72 | * [MOLY00195563] [6293][EL2][UPCM][RATDM][EPDCP] Initial feature integrations |
| 73 | * [TRUNK] UPCM/RATDM/EPDCP feature integrations from PS.DEV |
| 74 | * |
| 75 | * 09 19 2016 cammie.yang |
| 76 | * [MOLY00195563] [6293][EL2][UPCM][RATDM][EPDCP] Initial feature integrations |
| 77 | * [PS.DEV][HMU] modify tick uint of HMU_GPTIMER_PRIODIC_INTERVAL in modis environment for NWSIM TC_7_3_6_1 |
| 78 | * |
| 79 | * 11 11 2015 ap.wang |
| 80 | * [MOLY00148947] [HMU] Change PALLADIUM GPT timer to 1ms |
| 81 | * . |
| 82 | * |
| 83 | * 11 10 2015 ap.wang |
| 84 | * [MOLY00148746] [HMU] Check timer feature |
| 85 | * . |
| 86 | * |
| 87 | * 11 10 2015 ap.wang |
| 88 | * [MOLY00148746] [HMU] Check timer feature |
| 89 | * |
| 90 | * 03 02 2015 ap.wang |
| 91 | * [MOLY00097320] [HMU] Rollback HMU 10ms patch for FPGA to 1ms |
| 92 | * Rollback HMU 10ms patch for FPGA |
| 93 | * |
| 94 | * 12 31 2014 ap.wang |
| 95 | * [MOLY00089916] [HMU] HIF ON/OFF for power saving |
| 96 | * . |
| 97 | * |
| 98 | * 11 13 2014 cs.huang |
| 99 | * [MOLY00071215] [HMU] Modify HMU tick to 10ms for 6291 FPGA freqency too slow |
| 100 | * Merging |
| 101 | * |
| 102 | * //UMOLY/DEV/MT6291_DEV/mcu/pcore/interface/service/hif/hmu.h |
| 103 | * |
| 104 | * to //UMOLY/TRUNK/UMOLY/mcu/pcore/interface/service/hif/hmu.h |
| 105 | * |
| 106 | * 07 04 2014 ap.wang |
| 107 | * [MOLY00071481] [HMU] Add HIF boot init to Application init |
| 108 | * . |
| 109 | * |
| 110 | * |
| 111 | * 06 10 2014 ap.wang |
| 112 | * [MOLY00067367] [HMU] Modify GPT timer to MS callback for R8 on MOLY |
| 113 | * . |
| 114 | * |
| 115 | * 04 28 2014 ap.wang |
| 116 | * [MOLY00063912] [HMU] HMU temp solution for K2 MD2 |
| 117 | * HMU temp solution for K2 MD2 |
| 118 | * |
| 119 | * 03 11 2013 ap.wang |
| 120 | * [MOLY00011696] [HMU] HMU code refine and compile warning fix |
| 121 | * [HMU] Add copyright header and change ipc_reload condition |
| 122 | ****************************************************************************/ |
| 123 | |
| 124 | /******************************************************************************* |
| 125 | * Include header files |
| 126 | *******************************************************************************/ |
| 127 | |
| 128 | #ifndef __HMU_H__ |
| 129 | #define __HMU_H__ |
| 130 | |
| 131 | #include "hmu_conf_data.h" |
| 132 | /************************************************************************* |
| 133 | * Type Definitions |
| 134 | *************************************************************************/ |
| 135 | |
| 136 | //#if defined(__MTK_TARGET__) |
| 137 | //#define hmu_printf dbg_print |
| 138 | //#else |
| 139 | //#define hmu_printf kal_printf |
| 140 | //#endif |
| 141 | #define hmu_printf |
| 142 | |
| 143 | #define HMU_GPTIMER_INIT_INTERVAL (100U) //100 ms |
| 144 | |
| 145 | #if defined(__MTK_TARGET__) |
| 146 | #if defined(__PALLADIUM__) |
| 147 | #define HMU_GPTIMER_PRIODIC_INTERVAL (1U) // 1ms |
| 148 | #elif defined(__FPGA__) |
| 149 | #define HMU_GPTIMER_PRIODIC_INTERVAL (10U) // 10ms |
| 150 | #else |
| 151 | #define HMU_GPTIMER_PRIODIC_INTERVAL (1U) // 1ms |
| 152 | #endif |
| 153 | #elif defined(__U4G_ADAPTOR__) |
| 154 | #define HMU_GPTIMER_PRIODIC_INTERVAL (1U) // 1ms. to ensure that GCF TC_7_3_6_1 will pass in NWSIM |
| 155 | #else |
| 156 | #define HMU_GPTIMER_PRIODIC_INTERVAL (10U) // 10ms |
| 157 | #endif |
| 158 | |
| 159 | /** |
| 160 | * @brief enumeration for HMU API return codes |
| 161 | */ |
| 162 | typedef enum |
| 163 | { |
| 164 | HMU_OK = 0, |
| 165 | |
| 166 | HMU_INIT_NOFUNC = (-1), |
| 167 | HMU_NOT_INIT = (-2), |
| 168 | HMU_ALREADY_INIT = (-3), |
| 169 | |
| 170 | HMU_QUERY_FAIL = (-10), |
| 171 | HMU_QUERY_OUTOFBUF = (-11), |
| 172 | HMU_QUERY_NVRAMFAIL = (-12), |
| 173 | HMU_QUERY_NOMATCHING = (-13), |
| 174 | |
| 175 | }hmuReturnCode_enum; |
| 176 | |
| 177 | typedef enum |
| 178 | { |
| 179 | HMU_PRE_FUNC = 0, |
| 180 | HMU_MAIN_FUNC = 1, |
| 181 | HMU_POST_FUNC = 2, |
| 182 | }hmuFuncType_enum; |
| 183 | |
| 184 | /** |
| 185 | * @brief hmu_check_timer() return value |
| 186 | */ |
| 187 | typedef enum |
| 188 | { |
| 189 | HMU_CHECK_TIMER_SUCCESS = 0, |
| 190 | HMU_CHECK_TIMER_WARNING = 1, |
| 191 | HMU_CHECK_TIMER_ERROR = 2, |
| 192 | }HMU_CHECK_TIMER_ENUM; |
| 193 | |
| 194 | /** |
| 195 | * @brief enumeration for HMU Boot method, |
| 196 | * Currently, we have |
| 197 | * (1) HMU_BOOT_NORMAL : this setting is for normal booting with USB,SDIO,CCIF .... |
| 198 | * When you select HMU_BOOT_NORMAL in hmu_init, the HMU configuration file will be loaded from NVRAM_EF_HMU_CONFIG_LID |
| 199 | * (2) HMU_BOOT_HD L this setting is for USB Host detection booting |
| 200 | * When you select HMU_BOOT_HD in hmu_init, the HMU configuration file will be loaded from NVRAM_EF_HMU_HD_CONFIG_LID |
| 201 | */ |
| 202 | typedef enum |
| 203 | { |
| 204 | HMU_BOOT_NORMAL = 0, |
| 205 | HMU_BOOT_HD , |
| 206 | }hmuBootType_enum; |
| 207 | |
| 208 | typedef enum |
| 209 | { |
| 210 | HMU_TIMER_SOURCE_DSP = 0, |
| 211 | HMU_TIMER_SOURCE_SYS , |
| 212 | }hmuTimerSource_enum; |
| 213 | /** |
| 214 | * @name: _HMU_INTERNAL_STRUCT |
| 215 | * @brief the structure for Init function and hif emu device types registration table |
| 216 | */ |
| 217 | typedef struct _HMU_INTERNAL_STATE_STRUCT { |
| 218 | kal_bool hmuBootInit; |
| 219 | kal_bool hmuInit ; |
| 220 | kal_eventgrpid hmuHifEgId ; |
| 221 | } hmu_internal_state_struct ; |
| 222 | |
| 223 | /***************************************************************************** |
| 224 | * FUNCTION |
| 225 | * hmu_boot_init |
| 226 | * DESCRIPTION |
| 227 | * HMU 1st boot Init function to init global mutex and gptimer |
| 228 | * PARAMETERS |
| 229 | * |
| 230 | * RETURNS |
| 231 | * success or fail |
| 232 | *****************************************************************************/ |
| 233 | kal_int32 hmu_boot_init(void) ; |
| 234 | |
| 235 | /***************************************************************************** |
| 236 | * FUNCTION |
| 237 | * hmu_hifeg_set |
| 238 | * DESCRIPTION |
| 239 | * Set one or more the events to resume the HIF task. |
| 240 | * PARAMETERS |
| 241 | * events - events to set. |
| 242 | * See also HIF_DRV_EG_XXX defined in hmu_conf_data.h for more information. |
| 243 | * RETURNS |
| 244 | * the eg set result, success or fail |
| 245 | *****************************************************************************/ |
| 246 | kal_status hmu_hifeg_set(kal_uint32 events); |
| 247 | |
| 248 | /***************************************************************************** |
| 249 | * FUNCTION |
| 250 | * hmu_hifeg_wait |
| 251 | * DESCRIPTION |
| 252 | * Wait and clear the one or more HIF events. |
| 253 | * PARAMETERS |
| 254 | * events - events to wait. |
| 255 | * See also HIF_DRV_EG_XXX defined in hmu_conf_data.h for more information. |
| 256 | * RETURNS |
| 257 | * The event happened. |
| 258 | *****************************************************************************/ |
| 259 | kal_uint32 hmu_hifeg_wait(kal_uint32 events); |
| 260 | |
| 261 | /***************************************************************************** |
| 262 | * FUNCTION |
| 263 | * hmu_start_hif_sys_timer |
| 264 | * DESCRIPTION |
| 265 | * start the sys timer for HIF tasking. This API should be called from PWSV module to restart |
| 266 | * the timer after wake up from PWSV |
| 267 | * PARAMETERS |
| 268 | * void |
| 269 | * RETURNS |
| 270 | * void |
| 271 | *****************************************************************************/ |
| 272 | void hmu_start_hif_sys_timer(void) ; |
| 273 | |
| 274 | /***************************************************************************** |
| 275 | * FUNCTION |
| 276 | * hmu_stop_hif_sys_timer |
| 277 | * DESCRIPTION |
| 278 | * stop the sys timer to pause HIF tasking. This API should be called at the beginning of |
| 279 | * PWSV procedure |
| 280 | * PARAMETERS |
| 281 | * void |
| 282 | * RETURNS |
| 283 | * void |
| 284 | *****************************************************************************/ |
| 285 | void hmu_stop_hif_sys_timer(void) ; |
| 286 | |
| 287 | |
| 288 | /***************************************************************************** |
| 289 | * FUNCTION |
| 290 | * hmu_dsp_timer_kick |
| 291 | * DESCRIPTION |
| 292 | * The dsp periodical timer should kick this API to schedul the HIF tasking when the dsp |
| 293 | * timer exists. |
| 294 | * PARAMETERS |
| 295 | * void |
| 296 | * RETURNS |
| 297 | * void |
| 298 | *****************************************************************************/ |
| 299 | void hmu_dsp_timer_kick(void) ; |
| 300 | |
| 301 | /***************************************************************************** |
| 302 | * FUNCTION |
| 303 | * hmu_switch_hif_timer |
| 304 | * DESCRIPTION |
| 305 | * The dsp periodical timer should kick this API to schedul the HIF tasking when the dsp |
| 306 | * timer exists. |
| 307 | * PARAMETERS |
| 308 | * source - (1) HMU_TIMER_SOURCE_DSP |
| 309 | * (2) HMU_TIMER_SOURCE_SYS |
| 310 | * RETURNS |
| 311 | * void |
| 312 | *****************************************************************************/ |
| 313 | void hmu_switch_hif_timer(hmuTimerSource_enum source) ; |
| 314 | |
| 315 | /***************************************************************************** |
| 316 | * FUNCTION |
| 317 | * hmu_except_init |
| 318 | * |
| 319 | * DESCRIPTION |
| 320 | * Trigger an upper layer device module to hook with TTYCORE and then proceed |
| 321 | * exception flow if an exception happens before hmu_init() completes. |
| 322 | * |
| 323 | * PARAMETERS |
| 324 | * N/A |
| 325 | * |
| 326 | * RETURNS |
| 327 | * KAL_TRUE if caller is allowed to proceed the exception flow; |
| 328 | * KAL_FALSE if there's no proper callback function registered by |
| 329 | * upper layer device modules or something wrong while executing |
| 330 | * the callback function. |
| 331 | *****************************************************************************/ |
| 332 | kal_bool hmu_except_init(void); |
| 333 | |
| 334 | /***************************************************************************** |
| 335 | * FUNCTION |
| 336 | * hif_boot_init |
| 337 | * DESCRIPTION |
| 338 | * HIF boot init function to initial HIF module without task. |
| 339 | * PARAMETERS |
| 340 | * |
| 341 | * RETURNS |
| 342 | * success or fail |
| 343 | *****************************************************************************/ |
| 344 | kal_int32 hif_boot_init(void) ; |
| 345 | |
| 346 | /***************************************************************************** |
| 347 | * FUNCTION |
| 348 | * hmu_hifeg_stop |
| 349 | * DESCRIPTION |
| 350 | * stop one or more HIF events. |
| 351 | * PARAMETERS |
| 352 | * events - events to wait. |
| 353 | * See also HIF_DRV_EG_XXX defined in hmu_conf_data.h for more information. |
| 354 | * RETURNS |
| 355 | * The enabled events. |
| 356 | *****************************************************************************/ |
| 357 | kal_uint32 hmu_hifeg_stop(kal_uint32 events); |
| 358 | |
| 359 | /***************************************************************************** |
| 360 | * FUNCTION |
| 361 | * hmu_hifeg_start |
| 362 | * DESCRIPTION |
| 363 | * start one or more HIF events. |
| 364 | * PARAMETERS |
| 365 | * events - events to wait. |
| 366 | * See also HIF_DRV_EG_XXX defined in hmu_conf_data.h for more information. |
| 367 | * RETURNS |
| 368 | * The enabled events. |
| 369 | *****************************************************************************/ |
| 370 | kal_uint32 hmu_hifeg_start(kal_uint32 events); |
| 371 | |
| 372 | /***************************************************************************** |
| 373 | * FUNCTION |
| 374 | * hmu_check_timer |
| 375 | * DESCRIPTION |
| 376 | * Check HMU timer source whether is normal |
| 377 | * PARAMETERS |
| 378 | * |
| 379 | * RETURNS |
| 380 | * HMU_CHECK_TIMER_ENUM : return checking result |
| 381 | *****************************************************************************/ |
| 382 | kal_uint32 hmu_check_timer(kal_uint32 events); |
| 383 | |
| 384 | /***************************************************************************** |
| 385 | * FUNCTION |
| 386 | * hmu_check_timer_start / hmu_check_timer_stop |
| 387 | * DESCRIPTION |
| 388 | * Start / Stop HMU checking timer |
| 389 | * PARAMETERS |
| 390 | * |
| 391 | * RETURNS |
| 392 | *****************************************************************************/ |
| 393 | void hmu_check_timer_start(); |
| 394 | void hmu_check_timer_stop(); |
| 395 | |
| 396 | /***************************************************************************** |
| 397 | * FUNCTION |
| 398 | * hmu_tg_callback |
| 399 | * DESCRIPTION |
| 400 | * Callback from task group hisr |
| 401 | * PARAMETERS |
| 402 | * |
| 403 | * RETURNS |
| 404 | *****************************************************************************/ |
| 405 | #if defined(__LP_SCHEDULE_ENABLE__) && defined(__LP_SCHEDULE_HMU_RESCHEDULE__) |
| 406 | #define __HMU_TG_TIMER_SUPPORT__ |
| 407 | #endif |
| 408 | void hmu_tg_timer_callback(); |
| 409 | |
| 410 | #endif /*__HMU_H__*/ |