| 185 | } |
| 186 | |
| 187 | static void regulator_delay(rt_uint32_t delay) |
| 188 | { |
| 189 | rt_uint32_t ms = delay / 1000; |
| 190 | rt_uint32_t us = delay % 1000; |
| 191 | |
| 192 | if (ms > 0) |
| 193 | { |
| 194 | /* |
| 195 | * For small enough values, handle super-millisecond |
| 196 | * delays in the usleep_range() call below. |
| 197 | */ |
| 198 | if (ms < 20) |
| 199 | { |
| 200 | us += ms * 1000; |
| 201 | } |
| 202 | else if (rt_thread_self()) |
| 203 | { |
| 204 | rt_thread_mdelay(ms); |
| 205 | } |
| 206 | else |
| 207 | { |
| 208 | rt_hw_us_delay(ms * 1000); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | /* |
| 213 | * Give the scheduler some room to coalesce with any other |
| 214 | * wakeup sources. For delays shorter than 10 us, don't even |
| 215 | * bother setting up high-resolution timers and just busy-loop. |
| 216 | */ |
| 217 | if (us >= 10) |
| 218 | { |
| 219 | rt_hw_us_delay((us + 100) >> 1); |
| 220 | } |
| 221 | else |
| 222 | { |
| 223 | rt_hw_us_delay(us); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | static rt_err_t regulator_enable(struct rt_regulator_node *reg_np) |
| 228 | { |
no test coverage detected