rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | #ifndef __DRV_LITEGPT_H__ |
| 2 | #define __DRV_LITEGPT_H__ |
| 3 | #include "intrCtrl.h" |
| 4 | |
| 5 | #if defined(__CR4__) || defined(__MIPS_IA__) || defined(__MIPS_I7200__) |
| 6 | #define BASE_ADDR_LITEMDGPTM 0xA0170000 |
| 7 | #define MD_IRQID_MDGPTM_LITE_EVENT1 255 //(IRQ_MDLITE_GPTM_CODE) for build pass |
| 8 | #endif |
| 9 | |
| 10 | /* Register Address Definition */ |
| 11 | #if defined(__CR4__) || defined(__MIPS_IA__) || defined(__MIPS_I7200__) /* end of defined(CORTEXA9)||defined(CORTEXA7) */ |
| 12 | #define LITE_GPT_BASE (BASE_ADDR_LITEMDGPTM) |
| 13 | #define LITE_GPT_TOTAL_COUNTER (4U) |
| 14 | #define LITE_GPT_INTR_ID 255// (MD_IRQID_MDGPTM_LITE_EVENT1) for build pass |
| 15 | #endif /* end of else if */ |
| 16 | |
| 17 | #define LITE_GPT_CON_REG(i) (LITE_GPT_BASE + ((i - 1)<<3)) |
| 18 | #define LITE_GPT_DAT_REG(i) (LITE_GPT_BASE + 0x38 + ((i - 1)<<2)) |
| 19 | #define LITE_GPT_PSR_REG(i) (LITE_GPT_BASE + 0x14 + ((i - 1)<<2)) |
| 20 | |
| 21 | #define LITEGPT_MAX_PRESCALE (7U) |
| 22 | #define LITEGPT_MIN_PRESCALE (0U) |
| 23 | #define LITEGPT_DEFAULT_PRESCALE (4U) |
| 24 | #define LITEGPT_MAX_CNT_BIT (16U) |
| 25 | #define LITEGPT_CNT_MAX (0xFFFDU) |
| 26 | #define TOPSM_TEST_LITEGPT_WAKEUP 3 |
| 27 | |
| 28 | #define LITEGPT_CTRL_MODE_ENABLE (1U<<15) |
| 29 | #define LITEGPT_CTRL_MODE_ONESHOT (0U<<14) |
| 30 | #define LITEGPT_CTRL_MODE_REPEAT (1U<<14) |
| 31 | |
| 32 | #define LITEGPT_PSR_PRESCALE(n) (n&0x7) |
| 33 | |
| 34 | extern void drv_litegpt_stop_timer(kal_uint32 num); |
| 35 | extern void drv_litegpt_start_timer(kal_uint32 num); |
| 36 | extern void drv_litegpt_set_timer(kal_uint32 num, kal_uint32 time, kal_uint32 mode, kal_uint32 prescaler); |
| 37 | extern kal_uint32 drv_litegpt_time_remaining(kal_uint32 num); |
| 38 | |
| 39 | extern void drv_litegpt_set_wakeup_gpt(kal_uint32 time_tick);//the duration is about 1/32K*time_tick us |
| 40 | extern void drv_litegpt_clr_wakeup_event(void); |
| 41 | |
| 42 | #endif /* end of __DRV_LITEGPT_H__ */ |
| 43 | |