1 /* 2 // Copyright (C) 2022 Beken Corporation 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 typedef enum _pm_dev_state_ { 17 PM_UNUSABLE = 0, 18 PM_USABLE, 19 } PM_DEV_STATE; 20 21 enum DEV_PM_ID { 22 PM_ID_FLASH = 0, 23 PM_ID_UART, 24 PM_ID_TIMER, 25 PM_ID_USB, 26 PM_ID_CALENDAR, 27 PM_ID_AUDIO, 28 PM_ID_PWM, 29 PM_ID_GPIO, 30 PM_ID_RF, 31 PM_ID_BLE, 32 PM_ID_MAC, 33 PM_ID_MAX = 15, 34 }; 35 36 enum DEV_SLEEP_LEVEL { 37 IDLE_PS = 0, 38 NORMAL_PS, 39 LOWVOL_PS, 40 DEEP_PS, 41 }; 42 43 44 45 typedef union pm_status { 46 uint32_t value; 47 struct { 48 uint32_t normal_ps_remain_26m; 49 uint32_t resv: 15; 50 uint32_t unconditional_ps_support: 1; 51 uint32_t unconditional_ps_suspend_allow: 1; 52 uint32_t unconditional_ps_sleeped: 1; 53 uint32_t unconditional_ps_resume_allow: 1; 54 uint32_t normal_ps_support: 1; 55 uint32_t normal_ps_suspend_allow: 1; 56 uint32_t normal_ps_sleeped: 1; 57 uint32_t normal_ps_resume_allow: 1; 58 uint32_t lowvol_ps_support: 1; 59 uint32_t lowvol_ps_suspend_allow: 1; 60 uint32_t lowvol_ps_sleeped: 1; 61 uint32_t lowvol_ps_resume_allow: 1; 62 uint32_t deep_ps_support: 1; 63 uint32_t deep_ps_suspend_allow: 1; 64 uint32_t deep_ps_sleeped: 1; 65 uint32_t deep_ps_resume_allow: 1; 66 } bits; 67 } PM_STATUS; 68 69 typedef struct _pm_ops_ { 70 UINT32 ( *pm_init ) ( UINT32 op_flag ); 71 UINT32 ( *pm_deinit ) ( UINT32 op_flag ); 72 UINT32 ( *suspend ) ( UINT32 pm_level ); 73 UINT32 ( *resume ) ( UINT32 pm_level ); 74 PM_STATUS ( *status ) ( UINT32 op_flag ); 75 UINT32 ( *get_sleep_time ) ( void ); 76 } DEV_PM_OPS_S, *DEV_PM_OPS_PTR; 77 78 79 typedef struct _pm_ { 80 char *name; 81 UINT32 id; 82 UINT32 state; 83 DEV_PM_OPS_S *ops; 84 } DRV_PM_S, *DRV_PM_PTR; 85 86 extern UINT32 dev_pm_init ( void ); 87 extern int dev_pm_register ( UINT32 id, char *name, DEV_PM_OPS_PTR pmptr ); 88 extern UINT32 dev_pm_unregister ( UINT32 id ); 89 90 91