rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [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) 2001 |
| 8 | * |
| 9 | *****************************************************************************/ |
| 10 | |
| 11 | /***************************************************************************** |
| 12 | * |
| 13 | * Filename: |
| 14 | * --------- |
| 15 | * dcl_gpt.h |
| 16 | * |
| 17 | * Project: |
| 18 | * -------- |
| 19 | * Maui |
| 20 | * |
| 21 | * Description: |
| 22 | * ------------ |
| 23 | * Header file of DCL (Driver Common Layer) for GPT. |
| 24 | * |
| 25 | * Author: |
| 26 | * ------- |
| 27 | * ------- |
| 28 | * |
| 29 | *============================================================================ |
| 30 | * HISTORY |
| 31 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 32 | *------------------------------------------------------------------------------ |
| 33 | * removed! |
| 34 | * removed! |
| 35 | * removed! |
| 36 | * |
| 37 | * removed! |
| 38 | * removed! |
| 39 | * removed! |
| 40 | * |
| 41 | * removed! |
| 42 | * removed! |
| 43 | * removed! |
| 44 | * |
| 45 | * removed! |
| 46 | * removed! |
| 47 | * removed! |
| 48 | * |
| 49 | * removed! |
| 50 | * removed! |
| 51 | * removed! |
| 52 | * |
| 53 | * removed! |
| 54 | * removed! |
| 55 | * removed! |
| 56 | * |
| 57 | * removed! |
| 58 | * removed! |
| 59 | * removed! |
| 60 | * |
| 61 | * removed! |
| 62 | * removed! |
| 63 | * removed! |
| 64 | * |
| 65 | * removed! |
| 66 | * removed! |
| 67 | * removed! |
| 68 | * |
| 69 | *------------------------------------------------------------------------------ |
| 70 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 71 | *============================================================================ |
| 72 | ****************************************************************************/ |
| 73 | |
| 74 | /******************************************************************************* |
| 75 | * DCL_CTRL_CMD |
| 76 | *******************************************************************************/ |
| 77 | #ifndef DCL_GPT_HW_H_ |
| 78 | #define DCL_GPT_HW_H_ |
| 79 | #include "kal_general_types.h" |
| 80 | #include "drv_comm.h" |
| 81 | #include "dcl.h" |
| 82 | |
| 83 | typedef DCL_UINT16 GPT_DEV; |
| 84 | typedef enum |
| 85 | { |
| 86 | GPT1 = 1, |
| 87 | GPT2 = 2, |
| 88 | GPT3 = 3, |
| 89 | GPT4 = 4 |
| 90 | } GPT_DEV_T; |
| 91 | |
| 92 | typedef enum |
| 93 | { |
| 94 | clk_16k, |
| 95 | clk_8k, |
| 96 | clk_4k, |
| 97 | clk_2k, |
| 98 | clk_1k, |
| 99 | clk_500, |
| 100 | clk_250, |
| 101 | clk_125, |
| 102 | clk_invalid=0xFF |
| 103 | }gpt_clock; |
| 104 | |
| 105 | typedef DCL_UINT32 HGPT_CMD; |
| 106 | typedef enum |
| 107 | { |
| 108 | |
| 109 | HGPT_CMD_CLK, |
| 110 | HGPT_CMD_RESET, |
| 111 | HGPT_CMD_START, |
| 112 | HGPT_CMD_STOP, |
| 113 | HGPT_CMD_BUSYWAIT, |
| 114 | // HGPT_CMD_GPT_STATUS, |
| 115 | FHGPT_CMD_START, |
| 116 | FHGPT_CMD_STOP, |
| 117 | FHGPT_CMD_RETURN_COUNT, |
| 118 | FHGPT_CMD_LOCK |
| 119 | } HGPT_CMD_T; |
| 120 | |
| 121 | /* For HGPT_CMD_CLK command. */ |
| 122 | typedef enum |
| 123 | { |
| 124 | CLK_16K, |
| 125 | CLK_8K, |
| 126 | CLK_4K, |
| 127 | CLK_2K, |
| 128 | CLK_1K, |
| 129 | CLK_500, |
| 130 | CLK_250, |
| 131 | CLK_125 |
| 132 | } HGPT_CLK_T; |
| 133 | |
| 134 | typedef struct |
| 135 | { |
| 136 | DCL_UINT32 u4Clock; // for HGPT_CLK_T enum |
| 137 | } HGPT_CTRL_CLK_T; |
| 138 | |
| 139 | /* For HGPT_CMD_RESET command. */ |
| 140 | typedef struct |
| 141 | { |
| 142 | DCL_UINT16 u2CountValue; |
| 143 | DCL_BOOL fgAutoReload; |
| 144 | } HGPT_CTRL_RESET_T; |
| 145 | |
| 146 | /* For HGPT_CMD_RESET command. */ |
| 147 | typedef DCL_UINT16 FGPT_CTRL_RETURN_COUNT_T; |
| 148 | typedef DCL_UINT32 FGPT_CTRL_RETURN_COUNT_T_32bit; |
| 149 | typedef DCL_UINT16 BUSY_WAIT_COUNT_T; |
| 150 | typedef DCL_BOOL FGPT_CTRL_LOCK_T; |
| 151 | //typedef DCL_UINT8 GPT_STATUS_T; |
| 152 | typedef union |
| 153 | { |
| 154 | HGPT_CTRL_CLK_T rHGPTClk; |
| 155 | HGPT_CTRL_RESET_T rHGPTReset; |
| 156 | FGPT_CTRL_RETURN_COUNT_T u2RetCount; |
| 157 | FGPT_CTRL_RETURN_COUNT_T_32bit u2RetCount_32bit; |
| 158 | BUSY_WAIT_COUNT_T uBusyWaitCount; |
| 159 | FGPT_CTRL_LOCK_T ulock; |
| 160 | // GPT_STATUS_T gpt_status; |
| 161 | } HGPT_CTRL; |
| 162 | |
| 163 | //void GPTI_BusyWait(kal_uint16 len);//modified by dongming for build error about GPTI_BuisyWait follow non_static declaration |
| 164 | /* DCL for HW GPT */ |
| 165 | /************************************************************************* |
| 166 | * FUNCTION |
| 167 | * DclHGPT_Initialize |
| 168 | * |
| 169 | * DESCRIPTION |
| 170 | * This function is to initialize HW GPT module. |
| 171 | * |
| 172 | * PARAMETERS |
| 173 | * None |
| 174 | * |
| 175 | * RETURNS |
| 176 | * DCL_STATUS_OK |
| 177 | * |
| 178 | *************************************************************************/ |
| 179 | extern DCL_STATUS DclHGPT_Initialize(void); |
| 180 | |
| 181 | /************************************************************************* |
| 182 | * FUNCTION |
| 183 | * DclHGPT_Open |
| 184 | * |
| 185 | * DESCRIPTION |
| 186 | * This function is to open a HW GPT module. Note that HW GPT only supports |
| 187 | * single open for each valid eDev and if DCL_GPT1 is chosen SGPT may be |
| 188 | * influenced and work abnormally. |
| 189 | * |
| 190 | * PARAMETERS |
| 191 | * eDev - only valid for DCL_GPT1 and DCL_GPT2 |
| 192 | * flags - no sepcial flags is needed. Please use FLAGS_NONE |
| 193 | * |
| 194 | * RETURNS |
| 195 | * DCL_HANDLE_INVALID - Open failed. |
| 196 | * other value - a valid handle |
| 197 | * |
| 198 | *************************************************************************/ |
| 199 | extern DCL_HANDLE DclHGPT_Open(DCL_DEV dev, DCL_FLAGS flags); |
| 200 | |
| 201 | /************************************************************************* |
| 202 | * FUNCTION |
| 203 | * DclHGPT_ReadData |
| 204 | * |
| 205 | * DESCRIPTION |
| 206 | * This function is not supported for the HW GPT module now. |
| 207 | * |
| 208 | * PARAMETERS |
| 209 | * N/A |
| 210 | * |
| 211 | * RETURNS |
| 212 | * STATUS_UNSUPPORTED |
| 213 | * |
| 214 | *************************************************************************/ |
| 215 | extern DCL_STATUS DclHGPT_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN *buf_len, DCL_OPTIONS options); |
| 216 | |
| 217 | /************************************************************************* |
| 218 | * FUNCTION |
| 219 | * DclHGPT_WriteData |
| 220 | * |
| 221 | * DESCRIPTION |
| 222 | * This function is not supported for the HW GPT module now. |
| 223 | * |
| 224 | * PARAMETERS |
| 225 | * N/A |
| 226 | * |
| 227 | * RETURNS |
| 228 | * STATUS_UNSUPPORTED |
| 229 | * |
| 230 | *************************************************************************/ |
| 231 | extern DCL_STATUS DclHGPT_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN *buf_len, DCL_OPTIONS options); |
| 232 | |
| 233 | /************************************************************************* |
| 234 | * FUNCTION |
| 235 | * DclHGPT_Configure |
| 236 | * |
| 237 | * DESCRIPTION |
| 238 | * This function is not supported for the HW GPT module now. |
| 239 | * |
| 240 | * PARAMETERS |
| 241 | * N/A |
| 242 | * |
| 243 | * RETURNS |
| 244 | * STATUS_UNSUPPORTED |
| 245 | * |
| 246 | *************************************************************************/ |
| 247 | extern DCL_STATUS DclHGPT_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure); |
| 248 | |
| 249 | /************************************************************************* |
| 250 | * FUNCTION |
| 251 | * DclHGPT_RegisterCallback |
| 252 | * |
| 253 | * DESCRIPTION |
| 254 | * This function is to set callback function for the HW GPT module. |
| 255 | * |
| 256 | * PARAMETERS |
| 257 | * handle - hanlde previous got from DclHGPT_Open(). |
| 258 | * event - only support EVENT_HGPT_TIMEOUT event. |
| 259 | * callback - the callback function when HW GPT is timeout. |
| 260 | * |
| 261 | * RETURNS |
| 262 | * STATUS_OK - successfully register the callback function. |
| 263 | * STATUS_INVALID_HANDLE - It's a invalid handle. |
| 264 | * STATUS_NOT_OPENED - The module has not been opened. |
| 265 | * STATUS_INVALID_EVENT - The event parameter is invalid. |
| 266 | * |
| 267 | *************************************************************************/ |
| 268 | extern DCL_STATUS DclHGPT_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback); |
| 269 | |
| 270 | /************************************************************************* |
| 271 | * FUNCTION |
| 272 | * DclHGPT_Control |
| 273 | * |
| 274 | * DESCRIPTION |
| 275 | * This function is to send command to control the HW GPT module. |
| 276 | * |
| 277 | * PARAMETERS |
| 278 | * handle - a valid handle return by DclHGPT_Open() |
| 279 | * cmd - a control command for HW GPT module |
| 280 | * 1. HGPT_CMD_CLK: to set clock for a HW GPT timer |
| 281 | * 2. HGPT_CMD_RESET: to reset a HWGPT timer |
| 282 | * 3. HGPT_CMD_START: to start a HW GPT timer |
| 283 | * 4. HGPT_CMD_STOP: to stop a HWGPT timer |
| 284 | * data - for 1. HGPT_CMD_CLK: pointer to a HGPT_CTRL_CLK_T structure |
| 285 | * 2. HGPT_CMD_RESET: pointer to a HGPT_CTRL_RESET_T structure |
| 286 | * 3. HGPT_CMD_START: a NULL pointer |
| 287 | * 4. HGPT_CMD_STOP: a NULL pointer |
| 288 | * |
| 289 | * RETURNS |
| 290 | * STATUS_OK - command is executed successfully. |
| 291 | * STATUS_FAIL - command is failed. |
| 292 | * STATUS_INVALID_CMD - The command is invalid. |
| 293 | * STATUS_INVALID_HANDLE - The handle is invalid. |
| 294 | * STATUS_INVALID_CTRL_DATA - The ctrl data is not valid. |
| 295 | * |
| 296 | *************************************************************************/ |
| 297 | extern DCL_STATUS DclHGPT_Control(DCL_HANDLE handle, HGPT_CMD cmd, HGPT_CTRL *data); |
| 298 | |
| 299 | /************************************************************************* |
| 300 | * FUNCTION |
| 301 | * DclHGPT_Close |
| 302 | * |
| 303 | * DESCRIPTION |
| 304 | * This function is to close a HW GPT module by a handle previous opened. |
| 305 | * |
| 306 | * PARAMETERS |
| 307 | * handle - hanlde previous got from DclHGPT_Open(). |
| 308 | * |
| 309 | * RETURNS |
| 310 | * STATUS_OK - successful. |
| 311 | * DCL_HANDLE_INVALID - it's a invalid handle. |
| 312 | * |
| 313 | *************************************************************************/ |
| 314 | extern DCL_STATUS DclHGPT_Close(DCL_HANDLE handle); |
| 315 | |
| 316 | /* DCL for Free Run HW GPT */ |
| 317 | /************************************************************************* |
| 318 | * FUNCTION |
| 319 | * DclFHGPT_Initialize |
| 320 | * |
| 321 | * DESCRIPTION |
| 322 | * This function is to initialize the free run GPT module. |
| 323 | * |
| 324 | * PARAMETERS |
| 325 | * None |
| 326 | * |
| 327 | * RETURNS |
| 328 | * DCL_STATUS_OK |
| 329 | * |
| 330 | *************************************************************************/ |
| 331 | extern DCL_STATUS DclFHGPT_Initialize(void); |
| 332 | |
| 333 | /************************************************************************* |
| 334 | * FUNCTION |
| 335 | * DclFHGPT_Open |
| 336 | * |
| 337 | * DESCRIPTION |
| 338 | * This function is to open a free run GPT module if it exists. Note |
| 339 | * that it supports multiple opens and no need to close it. |
| 340 | * |
| 341 | * PARAMETERS |
| 342 | * eDev - only valid for DCL_GPT3 |
| 343 | * flags - no sepcial flags is needed. Please use FLAGS_NONE |
| 344 | * |
| 345 | * RETURNS |
| 346 | * DCL_HANDLE_INVALID - Open failed. It means no free run GPT exists or |
| 347 | * open a wrong device. |
| 348 | * other value - a valid handle |
| 349 | * |
| 350 | *************************************************************************/ |
| 351 | extern DCL_HANDLE DclFHGPT_Open(DCL_DEV dev, DCL_FLAGS flags); |
| 352 | |
| 353 | /************************************************************************* |
| 354 | * FUNCTION |
| 355 | * DclFHGPT_ReadData |
| 356 | * |
| 357 | * DESCRIPTION |
| 358 | * This function is not supported for the free run GPT module now. |
| 359 | * |
| 360 | * PARAMETERS |
| 361 | * N/A |
| 362 | * |
| 363 | * RETURNS |
| 364 | * STATUS_UNSUPPORTED |
| 365 | * |
| 366 | *************************************************************************/ |
| 367 | extern DCL_STATUS DclFHGPT_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN *buf_len, DCL_OPTIONS options); |
| 368 | |
| 369 | /************************************************************************* |
| 370 | * FUNCTION |
| 371 | * DclFHGPT_WriteData |
| 372 | * |
| 373 | * DESCRIPTION |
| 374 | * This function is not supported for the free run GPT module now. |
| 375 | * |
| 376 | * PARAMETERS |
| 377 | * N/A |
| 378 | * |
| 379 | * RETURNS |
| 380 | * STATUS_UNSUPPORTED |
| 381 | * |
| 382 | *************************************************************************/ |
| 383 | extern DCL_STATUS DclFHGPT_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN *buf_len, DCL_OPTIONS options); |
| 384 | |
| 385 | /************************************************************************* |
| 386 | * FUNCTION |
| 387 | * DclFHGPT_Configure |
| 388 | * |
| 389 | * DESCRIPTION |
| 390 | * This function is not supported for the free run GPT module now. |
| 391 | * |
| 392 | * PARAMETERS |
| 393 | * N/A |
| 394 | * |
| 395 | * RETURNS |
| 396 | * STATUS_UNSUPPORTED |
| 397 | * |
| 398 | *************************************************************************/ |
| 399 | extern DCL_STATUS DclFHGPT_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure); |
| 400 | |
| 401 | /************************************************************************* |
| 402 | * FUNCTION |
| 403 | * DclFHGPT_RegisterCallback |
| 404 | * |
| 405 | * DESCRIPTION |
| 406 | * This function is not supported for the free run GPT module now. |
| 407 | * |
| 408 | * PARAMETERS |
| 409 | * N/A |
| 410 | * |
| 411 | * RETURNS |
| 412 | * STATUS_UNSUPPORTED |
| 413 | * |
| 414 | *************************************************************************/ |
| 415 | extern DCL_STATUS DclFHGPT_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback); |
| 416 | |
| 417 | /************************************************************************* |
| 418 | * FUNCTION |
| 419 | * DclFHGPT_Control |
| 420 | * |
| 421 | * DESCRIPTION |
| 422 | * This function is to send command to control the free run GPT module. |
| 423 | * |
| 424 | * PARAMETERS |
| 425 | * handle - a valid handle return by DclFHGPT_Open() |
| 426 | * cmd - a control command for free ryb GPT module |
| 427 | * FGPT_CMD_RETURN_COUNT: to get the timer count |
| 428 | * data - for FGPT_CMD_RETURN_COUNT: pointer to a FGPT_CTRL_RETURN_COUNT_T type |
| 429 | * |
| 430 | * RETURNS |
| 431 | * STATUS_OK - command is executed successfully. |
| 432 | * STATUS_FAIL - command is failed. No free run GPT is supported. |
| 433 | * STATUS_INVALID_CMD - The command is invalid. |
| 434 | * STATUS_INVALID_HANDLE - The handle is invalid. |
| 435 | * |
| 436 | *************************************************************************/ |
| 437 | extern DCL_STATUS DclFHGPT_Control(DCL_HANDLE handle, HGPT_CMD cmd, HGPT_CTRL *data); |
| 438 | |
| 439 | /************************************************************************* |
| 440 | * FUNCTION |
| 441 | * DclFHGPT_Close |
| 442 | * |
| 443 | * DESCRIPTION |
| 444 | * This function is not supported for the free run GPT module now. |
| 445 | * |
| 446 | * PARAMETERS |
| 447 | * N/A |
| 448 | * |
| 449 | * RETURNS |
| 450 | * STATUS_UNSUPPORTED |
| 451 | * |
| 452 | *************************************************************************/ |
| 453 | extern DCL_STATUS DclFHGPT_Close(DCL_HANDLE handle); |
| 454 | |
| 455 | kal_bool GPT_IsStop(void); |
| 456 | |
| 457 | |
| 458 | #if defined(__DRV_COMM_REG_DBG__) && defined(__DRV_GPT_REG_DBG__) |
| 459 | #define DRV_GPT_WriteReg(addr,data) DRV_DBG_WriteReg(addr,data) |
| 460 | #define DRV_GPT_Reg(addr) DRV_DBG_Reg(addr) |
| 461 | #define DRV_GPT_WriteReg32(addr,data) DRV_DBG_WriteReg32(addr,data) |
| 462 | #define DRV_GPT_Reg32(addr) DRV_DBG_Reg32(addr) |
| 463 | #define DRV_GPT_WriteReg8(addr,data) DRV_DBG_WriteReg8(addr,data) |
| 464 | #define DRV_GPT_Reg8(addr) DRV_DBG_Reg8(addr) |
| 465 | #define DRV_GPT_ClearBits(addr,data) DRV_DBG_ClearBits(addr,data) |
| 466 | #define DRV_GPT_SetBits(addr,data) DRV_DBG_SetBits(addr,data) |
| 467 | #define DRV_GPT_SetData(addr, bitmask, value) DRV_DBG_SetData(addr, bitmask, value) |
| 468 | #define DRV_GPT_ClearBits32(addr,data) DRV_DBG_ClearBits32(addr,data) |
| 469 | #define DRV_GPT_SetBits32(addr,data) DRV_DBG_SetBits32(addr,data) |
| 470 | #define DRV_GPT_SetData32(addr, bitmask, value) DRV_DBG_SetData32(addr, bitmask, value) |
| 471 | #define DRV_GPT_ClearBits8(addr,data) DRV_DBG_ClearBits8(addr,data) |
| 472 | #define DRV_GPT_SetBits8(addr,data) DRV_DBG_SetBits8(addr,data) |
| 473 | #define DRV_GPT_SetData8(addr, bitmask, value) DRV_DBG_SetData8(addr, bitmask, value) |
| 474 | #else |
| 475 | #define DRV_GPT_WriteReg(addr,data) DRV_WriteReg(addr,data) |
| 476 | #define DRV_GPT_Reg(addr) DRV_Reg(addr) |
| 477 | #define DRV_GPT_WriteReg32(addr,data) DRV_WriteReg32(addr,data) |
| 478 | #define DRV_GPT_Reg32(addr) DRV_Reg32(addr) |
| 479 | #define DRV_GPT_WriteReg8(addr,data) DRV_WriteReg8(addr,data) |
| 480 | #define DRV_GPT_Reg8(addr) DRV_Reg8(addr) |
| 481 | #define DRV_GPT_ClearBits(addr,data) DRV_ClearBits(addr,data) |
| 482 | #define DRV_GPT_SetBits(addr,data) DRV_SetBits(addr,data) |
| 483 | #define DRV_GPT_SetData(addr, bitmask, value) DRV_SetData(addr, bitmask, value) |
| 484 | #define DRV_GPT_ClearBits32(addr,data) DRV_ClearBits32(addr,data) |
| 485 | #define DRV_GPT_SetBits32(addr,data) DRV_SetBits32(addr,data) |
| 486 | #define DRV_GPT_SetData32(addr, bitmask, value) DRV_SetData32(addr, bitmask, value) |
| 487 | #define DRV_GPT_ClearBits8(addr,data) DRV_ClearBits8(addr,data) |
| 488 | #define DRV_GPT_SetBits8(addr,data) DRV_SetBits8(addr,data) |
| 489 | #define DRV_GPT_SetData8(addr, bitmask, value) DRV_SetData8(addr, bitmask, value) |
| 490 | #endif //#if defined(__DRV_COMM_REG_DBG__) && defined(__DRV_GPT_REG_DBG__) |
| 491 | |
| 492 | |
| 493 | #endif |