1 /* 2 * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved. 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 /** 17 * @file wm_pmu.h 18 * 19 * @brief pmu driver module 20 * 21 * @author dave 22 * 23 * Copyright (c) 2014 Winner Microelectronics Co., Ltd. 24 */ 25 #ifndef WM_PMU_H 26 #define WM_PMU_H 27 28 #include "wm_type_def.h" 29 30 /** peripheral type */ 31 typedef enum { 32 TLS_PERIPHERAL_TYPE_I2C = (1 << 0), /**< peripheral type : I2C */ 33 TLS_PERIPHERAL_TYPE_UART0 = (1 << 1), /**< peripheral type : UART0 */ 34 TLS_PERIPHERAL_TYPE_UART1 = (1 << 2), /**< peripheral type : UART1 */ 35 TLS_PERIPHERAL_TYPE_UART2 = (1 << 3), /**< peripheral type : UART2 */ 36 TLS_PERIPHERAL_TYPE_UART3 = (1 << 4), /**< peripheral type : UART3 */ 37 TLS_PERIPHERAL_TYPE_UART4 = (1 << 5), /**< peripheral type : UART4 */ 38 39 TLS_PERIPHERAL_TYPE_UART5 = (1 << 6), /**< peripheral type : UART4 */ 40 41 TLS_PERIPHERAL_TYPE_LSPI = (1 << 7), /**< peripheral type : LSPI */ 42 TLS_PERIPHERAL_TYPE_DMA = (1 << 8), /**< peripheral type : DMA */ 43 44 TLS_PERIPHERAL_TYPE_TIMER = (1 << 10), /**< peripheral type : TIMER */ 45 TLS_PERIPHERAL_TYPE_GPIO = (1 << 11), /**< peripheral type : GPIO */ 46 TLS_PERIPHERAL_TYPE_SDADC = (1 << 12), /**< peripheral type : SDADC */ 47 TLS_PERIPHERAL_TYPE_PWM = (1 << 13), /**< peripheral type : PWM */ 48 TLS_PERIPHERAL_TYPE_LCD = (1 << 14), /**< peripheral type : LCD */ 49 TLS_PERIPHERAL_TYPE_I2S = (1 << 15), /**< peripheral type : I2S */ 50 TLS_PERIPHERAL_TYPE_RSA = (1 << 16), /**< peripheral type : RSA */ 51 TLS_PERIPHERAL_TYPE_GPSEC = (1 << 17), /**< peripheral type : GPSEC */ 52 53 TLS_PERIPHERAL_TYPE_SDIO_MASTER = (1<<18), /**< peripheral type : SDIO */ 54 TLS_PERIPHERAL_TYPE_PSRAM = (1<<19), /**< peripheral type : PSRAM */ 55 TLS_PERIPHERAL_TYPE_BT = (1<<20), /**< peripheral type : BT */ 56 TLS_PERIPHERAL_TYPE_TOUCH_SENSOR = (1 << 21) /**< peripheral type : TOUCH */ 57 }tls_peripheral_type_s; 58 59 /** callback function of PMU interrupt */ 60 typedef void (*tls_pmu_irq_callback)(void *arg); 61 62 /** 63 * @defgroup Driver_APIs Driver APIs 64 * @brief Driver APIs 65 */ 66 67 /** 68 * @addtogroup Driver_APIs 69 * @{ 70 */ 71 72 /** 73 * @defgroup PMU_Driver_APIs PMU Driver APIs 74 * @brief PMU driver APIs 75 */ 76 77 /** 78 * @addtogroup PMU_Driver_APIs 79 * @{ 80 */ 81 82 /** 83 * @brief This function is used to register pmu timer1 interrupt 84 * 85 * @param[in] callback the pmu timer1 interrupt call back function 86 * @param[in] arg parameter of call back function 87 * 88 * @return None 89 * 90 * @note 91 * user not need clear interrupt flag. 92 * pmu timer1 callback function is called in interrupt, 93 * so can not operate the critical data in the callback fuuction, 94 * recommendation to send messages to other tasks to operate it. 95 */ 96 void tls_pmu_timer1_isr_register(tls_pmu_irq_callback callback, void *arg); 97 98 /** 99 * @brief This function is used to register pmu timer0 interrupt 100 * 101 * @param[in] callback the pmu timer0 interrupt call back function 102 * @param[in] arg parameter of call back function 103 * 104 * @return None 105 * 106 * @note 107 * user not need clear interrupt flag. 108 * pmu timer0 callback function is called in interrupt, 109 * so can not operate the critical data in the callback fuuction, 110 * recommendation to send messages to other tasks to operate it. 111 */ 112 void tls_pmu_timer0_isr_register(tls_pmu_irq_callback callback, void *arg); 113 114 /** 115 * @brief This function is used to register pmu gpio interrupt 116 * 117 * @param[in] callback the pmu gpio interrupt call back function 118 * @param[in] arg parameter of call back function 119 * 120 * @return None 121 * 122 * @note 123 * user not need clear interrupt flag. 124 * pmu gpio callback function is called in interrupt, 125 * so can not operate the critical data in the callback fuuction, 126 * recommendation to send messages to other tasks to operate it. 127 */ 128 void tls_pmu_gpio_isr_register(tls_pmu_irq_callback callback, void *arg); 129 130 /** 131 * @brief This function is used to register pmu sdio interrupt 132 * 133 * @param[in] callback the pmu sdio interrupt call back function 134 * @param[in] arg parameter of call back function 135 * 136 * @return None 137 * 138 * @note 139 * user not need clear interrupt flag. 140 * pmu sdio callback function is called in interrupt, 141 * so can not operate the critical data in the callback fuuction, 142 * recommendation to send messages to other tasks to operate it. 143 */ 144 void tls_pmu_sdio_isr_register(tls_pmu_irq_callback callback, void *arg); 145 146 /** 147 * @brief This function is used to select pmu clk 148 * 149 * @param[in] bypass pmu clk whether or not use bypass mode 150 * 1 pmu clk use 32K by 40MHZ 151 * other pmu clk 32K by calibration circuit 152 * 153 * @return None 154 * 155 * @note None 156 */ 157 void tls_pmu_clk_select(u8 bypass); 158 159 /** 160 * @brief This function is used to start pmu timer0 161 * 162 * @param[in] second vlaue of timer0 count[s] 163 * 164 * @return None 165 * 166 * @note None 167 */ 168 void tls_pmu_timer0_start(u16 second); 169 170 /** 171 * @brief This function is used to stop pmu timer0 172 * 173 * @param None 174 * 175 * @return None 176 * 177 * @note None 178 */ 179 void tls_pmu_timer0_stop(void); 180 181 /** 182 * @brief This function is used to start pmu timer1 183 * 184 * @param[in] second vlaue of timer1 count[ms] 185 * 186 * @return None 187 * 188 * @note None 189 */ 190 void tls_pmu_timer1_start(u16 msec); 191 192 /** 193 * @brief This function is used to stop pmu timer1 194 * 195 * @param None 196 * 197 * @return None 198 * 199 * @note None 200 */ 201 void tls_pmu_timer1_stop(void); 202 203 /** 204 * @brief This function is used to start pmu goto standby 205 * 206 * @param None 207 * 208 * @return None 209 * 210 * @note None 211 */ 212 void tls_pmu_standby_start(void); 213 214 /** 215 * @brief This function is used to start pmu goto sleep 216 * 217 * @param None 218 * 219 * @return None 220 * 221 * @note None 222 */ 223 void tls_pmu_sleep_start(void); 224 225 /** 226 * @brief This function is used to close peripheral's clock 227 * 228 * @param[in] devices peripherals 229 * 230 * @return None 231 * 232 * @note None 233 */ 234 void tls_close_peripheral_clock(tls_peripheral_type_s devices); 235 236 /** 237 * @brief This function is used to open peripheral's clock 238 * 239 * @param[in] devices peripherals 240 * 241 * @return None 242 * 243 * @note None 244 */ 245 void tls_open_peripheral_clock(tls_peripheral_type_s devices); 246 /** 247 * @} 248 */ 249 250 /** 251 * @} 252 */ 253 254 #endif 255 256