26 #include "in_compile.h" 136 #if defined (__CC_ARM) 139 #elif defined (__GNUC__) 140 #pragma GCC push_options 141 #pragma GCC optimize ("O0") 143 static INLINE
void clk_delay(uint32_t us)
145 uint32_t reg = RD_WORD(D2_REG_CLK_CTRL);
146 if (!(reg & D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_XOX2_OR_XO)) {
149 reg = (RD_WORD(GLOBAL_REG_CLK_CTRL_1) >> GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D2_CLK_SHIFT) & GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D2_CLK_MASK;
159 for (uint32_t k = 0; k < (us * 6); k++)
162 #if defined (__CC_ARM) 164 #elif defined (__GNUC__) 165 #pragma GCC pop_options 167 static INLINE
void clk_xo_ps_opt(uint32_t stable_time)
169 WR_WORD(AON_PS_REGS_DCDC_EN_DELAY_CTRL, 0x4);
170 WR_WORD(AON_PS_REGS_ON_DELAY_0_CTRL, stable_time);
171 WR_WORD(AON_PS_REGS_ON_DELAY_1_CTRL, 0x14020018);
172 WR_WORD(AON_PS_REGS_XO_EN_DELAY_CTRL, 0x402);
173 WR_WORD(AON_PS_REGS_OFF_DELAY_0_CTRL, 0x2010000);
174 WR_WORD(AON_PS_REGS_OFF_DELAY_1_CTRL, 0x3040002);
177 static INLINE
void clk_xo_stage_delay(uint32_t stage0_delay, uint32_t stage1_delay)
179 uint32_t reg = RD_WORD(AON_REG_XO_EN_STAGE_CTRL);
180 reg &= ~(AON_REG_XO_EN_STAGE_CTRL_CTL_XO_STAGE0_DURATION|AON_REG_XO_EN_STAGE_CTRL_CTL_XO_STAGE1_DURATION);
181 reg |= (stage0_delay & AON_REG_XO_EN_STAGE_CTRL_CTL_XO_STAGE0_DURATION_MASK) << AON_REG_XO_EN_STAGE_CTRL_CTL_XO_STAGE0_DURATION_SHIFT;
182 reg |= (stage1_delay & AON_REG_XO_EN_STAGE_CTRL_CTL_XO_STAGE1_DURATION_MASK) << AON_REG_XO_EN_STAGE_CTRL_CTL_XO_STAGE1_DURATION_SHIFT;
183 WR_WORD(AON_REG_XO_EN_STAGE_CTRL, reg);
186 static INLINE
void clk_xo_delay(uint32_t cycles)
188 WR_WORD(AON_PS_REGS_ON_DELAY_0_CTRL, (cycles & AON_PS_REGS_ON_DELAY_0_CTRL_CLOCK_EN_EARLY_PD_DOO_MASK));
191 static INLINE
void clk_xo_cap(uint32_t cap)
193 uint32_t reg = RD_WORD(AON_REG_XO_STAGE_1_REG);
195 reg |= (cap & 0xF) | ((cap & 0xF) << 4);
196 WR_WORD(AON_REG_XO_STAGE_1_REG, reg);
199 static INLINE
void clk_xo_gm(uint32_t gm)
201 uint32_t reg = RD_WORD(AON_REG_XO_STAGE_1_REG);
203 reg |= (gm & 0x1F) << 8;
204 WR_WORD(AON_REG_XO_STAGE_1_REG, reg);
207 static INLINE
void clk_xo_x2(
int en)
210 uint32_t reg2 = RD_WORD(AON_REG_XO_STAGE_1_REG);
219 WR_WORD(AON_REG_XO_STAGE_1_REG, reg2);
222 static INLINE
void clk_xo_2x_current(
int en)
224 uint32_t reg = RD_WORD(AON_REG_XO_STAGE_1_REG);
230 WR_WORD(AON_REG_XO_STAGE_1_REG, reg);
233 static INLINE
void clk_xo_amp(uint32_t target)
235 uint32_t reg = RD_WORD(AON_REG_XO_STAGE_1_REG);
237 reg |= (target & 0x7) << 19;
238 WR_WORD(AON_REG_XO_STAGE_1_REG, reg);
241 static INLINE
void clk_xo_peak_det(
int en)
243 uint32_t reg = RD_WORD(AON_REG_XO_STAGE_1_REG);
249 WR_WORD(AON_REG_XO_STAGE_1_REG, reg);
252 static INLINE uint32_t clk_xo_status(
void)
254 return (RD_WORD(RFTRX_REG_XO_STATUS));
257 static INLINE
void clk_root_rc_32mhz(
void)
260 uint32_t clk_enable_2, rc_clk_sel, rftrx;
262 clk_enable_2 = RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
264 clk_enable_2 |= GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_32M_RC_EN;
265 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
266 RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
270 rc_clk_sel = RD_WORD(D2_REG_RC_CLOCK_SEL);
272 rc_clk_sel &= ~D2_REG_RC_CLOCK_SEL_CTL_CLK_CTRL_D2REG_SEL_XOCPLL_OR_32MRC;
273 WR_WORD(D2_REG_RC_CLOCK_SEL, rc_clk_sel);
274 RD_WORD(D2_REG_RC_CLOCK_SEL);
277 clk_enable_2 &= ~(GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_XO_TO_DIGI_CLK_EN|
278 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_64MXO_EN|
279 GLOBAL_REG_CLK_ENABLE_2_CTL_TRX_CPLL_TO_DIGI_EN|
280 GLOBAL_REG_CLK_ENABLE_2_CTL_TRX_CPLL_TO_DIGI_DIV2_EN);
281 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
283 rftrx=RD_WORD(RFTRX_REG_RFTRX_MISC_CTRL);
285 rftrx &=~(RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_X2_TO_DIGI_EN|RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_TO_DIGI_EN);
286 WR_WORD(RFTRX_REG_RFTRX_MISC_CTRL,rftrx);
291 static INLINE
void clk_root_xo_64mhz(
void)
293 uint32_t rftrx_misc_ctrl, clk_enable_2, clk_ctrl, rc_clk_sel;
296 clk_enable_2 = RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
297 clk_enable_2 |= GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_64MXO_EN;
298 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
301 rftrx_misc_ctrl = RD_WORD(RFTRX_REG_RFTRX_MISC_CTRL);
302 rftrx_misc_ctrl |= RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_X2_TO_DIGI_EN;
303 WR_WORD(RFTRX_REG_RFTRX_MISC_CTRL, rftrx_misc_ctrl);
304 RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
308 clk_ctrl = RD_WORD(D2_REG_CLK_CTRL);
309 clk_ctrl &= ~D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_XOX2_OR_XO;
310 WR_WORD(D2_REG_CLK_CTRL, clk_ctrl);
313 rc_clk_sel = RD_WORD(D2_REG_RC_CLOCK_SEL);
314 rc_clk_sel |= D2_REG_RC_CLOCK_SEL_CTL_CLK_CTRL_D2REG_SEL_XOCPLL_OR_32MRC;
315 WR_WORD(D2_REG_RC_CLOCK_SEL, rc_clk_sel);
318 clk_ctrl &= ~D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_XO_OR_CPLL;
319 WR_WORD(D2_REG_CLK_CTRL, clk_ctrl);
322 clk_enable_2 &= ~(GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_32M_RC_EN|
323 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_XO_TO_DIGI_CLK_EN|
324 GLOBAL_REG_CLK_ENABLE_2_CTL_TRX_CPLL_TO_DIGI_EN|
325 GLOBAL_REG_CLK_ENABLE_2_CTL_TRX_CPLL_TO_DIGI_DIV2_EN);
326 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
329 rftrx_misc_ctrl &= ~RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_TO_DIGI_EN;
330 WR_WORD(RFTRX_REG_RFTRX_MISC_CTRL, rftrx_misc_ctrl);
334 static INLINE
void clk_root_xo_32mhz(
int cold)
336 uint32_t rftrx_misc_ctrl, clk_enable_2, clk_ctrl, rc_clk_sel ;
339 clk_enable_2 = RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
341 clk_enable_2 |= GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_XO_TO_DIGI_CLK_EN;
342 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
346 rftrx_misc_ctrl = RD_WORD(RFTRX_REG_RFTRX_MISC_CTRL);
348 rftrx_misc_ctrl |= RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_TO_DIGI_EN;
349 WR_WORD(RFTRX_REG_RFTRX_MISC_CTRL, rftrx_misc_ctrl);
350 RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
355 clk_ctrl = RD_WORD(D2_REG_CLK_CTRL);
356 clk_ctrl |= D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_XOX2_OR_XO;
357 WR_WORD(D2_REG_CLK_CTRL, clk_ctrl);
361 rc_clk_sel = RD_WORD(D2_REG_RC_CLOCK_SEL);
362 rc_clk_sel |= D2_REG_RC_CLOCK_SEL_CTL_CLK_CTRL_D2REG_SEL_XOCPLL_OR_32MRC;
363 WR_WORD(D2_REG_RC_CLOCK_SEL, rc_clk_sel);
367 clk_ctrl &= ~D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_XO_OR_CPLL;
368 WR_WORD(D2_REG_CLK_CTRL, clk_ctrl);
372 clk_enable_2 &= ~(GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_32M_RC_EN|
373 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_64MXO_EN);
374 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
377 rftrx_misc_ctrl &= ~RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_X2_TO_DIGI_EN;
378 WR_WORD(RFTRX_REG_RFTRX_MISC_CTRL, rftrx_misc_ctrl);
382 static INLINE
void clk_root_cpll_32mhz(
void)
385 uint32_t rftrx_misc_ctrl, clk_enable_2, clk_ctrl, cpll_ctrl;
388 rftrx_misc_ctrl = RD_WORD(RFTRX_REG_RFTRX_MISC_CTRL);
389 rftrx_misc_ctrl |= RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_CPLL_TO_DIGI_EN;
390 WR_WORD(RFTRX_REG_RFTRX_MISC_CTRL, rftrx_misc_ctrl);
393 cpll_ctrl = RD_WORD(AON_REG_CPLL_CTRL);
394 cpll_ctrl &= ~AON_REG_CPLL_CTRL_CTL_CPLL_FREQ_SEL;
395 cpll_ctrl |= AON_REG_CPLL_CTRL_CTL_CPLL_EN|AON_REG_CPLL_CTRL_CTL_BGR_EN;
396 WR_WORD(AON_REG_CPLL_CTRL, cpll_ctrl);
399 while (!(RD_WORD(GLOBAL_REG_CPLL_CTRL_XO_DETECT_STATUS) & GLOBAL_REG_CPLL_CTRL_XO_DETECT_STATUS_STS_CPLL_CTRL_CPLL_LOCKED));
402 clk_enable_2 = RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
403 clk_enable_2 |= GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_CPLL_DIV2_CLK_EN;
404 clk_enable_2 &= ~GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_CPLL_CLK_EN;
405 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
408 clk_ctrl = D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_CPLL_OR_CPLL_DIV2;
409 clk_ctrl |= D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_XO_OR_CPLL;
410 WR_WORD(D2_REG_CLK_CTRL, clk_ctrl);
411 WR_WORD(D2_REG_RC_CLOCK_SEL, D2_REG_RC_CLOCK_SEL_CTL_CLK_CTRL_D2REG_SEL_XOCPLL_OR_32MRC);
414 rftrx_misc_ctrl &= ~(RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_X2_TO_DIGI_EN|RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_TO_DIGI_EN);
415 WR_WORD(RFTRX_REG_RFTRX_MISC_CTRL, rftrx_misc_ctrl);
418 clk_enable_2 &= ~(GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_32M_RC_EN|
419 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_64MXO_EN|
420 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_XO_TO_DIGI_CLK_EN);
421 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
425 static INLINE
void clk_root_cpll_64mhz(
void)
428 uint32_t rftrx_misc_ctrl, clk_enable_2, clk_ctrl, cpll_ctrl;
431 rftrx_misc_ctrl = RD_WORD(RFTRX_REG_RFTRX_MISC_CTRL);
432 rftrx_misc_ctrl |= RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_CPLL_TO_DIGI_EN;
433 WR_WORD(RFTRX_REG_RFTRX_MISC_CTRL, rftrx_misc_ctrl);
436 cpll_ctrl = RD_WORD(AON_REG_CPLL_CTRL);
437 cpll_ctrl &= ~AON_REG_CPLL_CTRL_CTL_CPLL_FREQ_SEL;
438 cpll_ctrl |= AON_REG_CPLL_CTRL_CTL_CPLL_EN|AON_REG_CPLL_CTRL_CTL_BGR_EN;
439 WR_WORD(AON_REG_CPLL_CTRL, cpll_ctrl);
442 while (!(RD_WORD(GLOBAL_REG_CPLL_CTRL_XO_DETECT_STATUS) & GLOBAL_REG_CPLL_CTRL_XO_DETECT_STATUS_STS_CPLL_CTRL_CPLL_LOCKED));
445 clk_enable_2 = RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
446 clk_enable_2 &= ~GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_CPLL_DIV2_CLK_EN;
447 clk_enable_2 |= GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_CPLL_CLK_EN;
448 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
451 clk_ctrl |= D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_XO_OR_CPLL;
452 WR_WORD(D2_REG_CLK_CTRL, clk_ctrl);
453 WR_WORD(D2_REG_RC_CLOCK_SEL, D2_REG_RC_CLOCK_SEL_CTL_CLK_CTRL_D2REG_SEL_XOCPLL_OR_32MRC);
456 rftrx_misc_ctrl &= ~(RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_X2_TO_DIGI_EN|RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_TO_DIGI_EN);
457 WR_WORD(RFTRX_REG_RFTRX_MISC_CTRL, rftrx_misc_ctrl);
460 clk_enable_2 &= ~(GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_32M_RC_EN|
461 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_64MXO_EN|
462 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_XO_TO_DIGI_CLK_EN);
463 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
467 static INLINE
void clk_root_cpll_128mhz(
void)
470 uint32_t rftrx_misc_ctrl, clk_enable_2, clk_ctrl, cpll_ctrl;
473 rftrx_misc_ctrl = RD_WORD(RFTRX_REG_RFTRX_MISC_CTRL);
474 rftrx_misc_ctrl |= RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_CPLL_TO_DIGI_EN;
475 WR_WORD(RFTRX_REG_RFTRX_MISC_CTRL, rftrx_misc_ctrl);
478 cpll_ctrl = RD_WORD(AON_REG_CPLL_CTRL);
479 cpll_ctrl |= AON_REG_CPLL_CTRL_CTL_CPLL_EN|AON_REG_CPLL_CTRL_CTL_BGR_EN|AON_REG_CPLL_CTRL_CTL_CPLL_FREQ_SEL;
480 WR_WORD(AON_REG_CPLL_CTRL, cpll_ctrl);
483 while (!(RD_WORD(GLOBAL_REG_CPLL_CTRL_XO_DETECT_STATUS) & GLOBAL_REG_CPLL_CTRL_XO_DETECT_STATUS_STS_CPLL_CTRL_CPLL_LOCKED));
486 clk_enable_2 = RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
487 clk_enable_2 &= ~GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_CPLL_CLK_EN;
488 clk_enable_2 |= GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_CPLL_DIV2_CLK_EN;
489 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
492 clk_ctrl = D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_CPLL_OR_CPLL_DIV2;
493 clk_ctrl |= D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_XO_OR_CPLL;
494 WR_WORD(D2_REG_CLK_CTRL, clk_ctrl);
495 WR_WORD(D2_REG_RC_CLOCK_SEL, D2_REG_RC_CLOCK_SEL_CTL_CLK_CTRL_D2REG_SEL_XOCPLL_OR_32MRC);
498 rftrx_misc_ctrl &= ~(RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_X2_TO_DIGI_EN|RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_TO_DIGI_EN);
499 WR_WORD(RFTRX_REG_RFTRX_MISC_CTRL, rftrx_misc_ctrl);
502 clk_enable_2 &= ~(GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_32M_RC_EN|
503 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_64MXO_EN|
504 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_XO_TO_DIGI_CLK_EN);
505 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
509 static INLINE
void clk_root_cpll_resume(
int freq_64mhz)
511 uint32_t clk_enable_2, clk_ctrl ;
517 while (!(RD_WORD(GLOBAL_REG_CPLL_CTRL_XO_DETECT_STATUS) & GLOBAL_REG_CPLL_CTRL_XO_DETECT_STATUS_STS_CPLL_CTRL_CPLL_LOCKED));
520 clk_enable_2 &= ~GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_ANA_CLK_32M_RC_EN;
522 clk_enable_2 |= GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_CPLL_CLK_EN;
523 clk_enable_2 &= ~GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_CPLL_DIV2_CLK_EN;
525 clk_enable_2 |= GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_CPLL_DIV2_CLK_EN;
526 clk_enable_2 &= ~GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_CPLL_CLK_EN;
528 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, clk_enable_2);
532 clk_ctrl = D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_CPLL_OR_CPLL_DIV2;
534 clk_ctrl |= D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_XO_OR_CPLL;
535 WR_WORD(D2_REG_CLK_CTRL, clk_ctrl);
536 WR_WORD(D2_REG_RC_CLOCK_SEL, D2_REG_RC_CLOCK_SEL_CTL_CLK_CTRL_D2REG_SEL_XOCPLL_OR_32MRC);
539 static INLINE
void clk_xo_to_digi_en(
int en)
541 uint32_t reg_EN2 = RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
544 reg_EN2 |= GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_XO_TO_DIGI_CLK_EN;
546 reg_EN2 &= ~GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_XO_TO_DIGI_CLK_EN;
548 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, reg_EN2);
551 uint32_t rftrx_misc_ctrl = RD_WORD(RFTRX_REG_RFTRX_MISC_CTRL);
553 rftrx_misc_ctrl |= RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_TO_DIGI_EN;
555 rftrx_misc_ctrl &= ~RFTRX_REG_RFTRX_MISC_CTRL_CTL_CLK_XO_TO_DIGI_EN;
557 WR_WORD(RFTRX_REG_RFTRX_MISC_CTRL, rftrx_misc_ctrl);
560 static INLINE
void clk_xo_on(
int xo_32, uint8_t capacitor, uint8_t drive_strength)
566 uint32_t reg_xo = RD_WORD(AON_REG_XO_STAGE_1_REG);
568 reg_xo |= capacitor | (capacitor << 4) | (drive_strength << 8);
569 WR_WORD(AON_REG_XO_STAGE_1_REG, reg_xo);
573 reg_xo = RD_WORD(AON_REG_XO_STAGE_1_REG);
574 reg_xo &= ~(1 << 16);
575 WR_WORD(AON_REG_XO_STAGE_1_REG, reg_xo);
582 clk_root_xo_32mhz(1);
588 static INLINE
void clk_rc_bypass(
int bypass)
590 uint32_t reg = RD_WORD(AON_PS_REGS_MISC_BYPASS_0_CTRL);
592 reg |= AON_PS_REGS_MISC_BYPASS_0_CTRL_CLK_32MHZ_RC_EN_EN;
593 reg &= ~AON_PS_REGS_MISC_BYPASS_0_CTRL_CLK_32MHZ_RC_EN_VAL;
595 reg &= ~AON_PS_REGS_MISC_BYPASS_0_CTRL_CLK_32MHZ_RC_EN_EN;
596 reg |= AON_PS_REGS_MISC_BYPASS_0_CTRL_CLK_32MHZ_RC_EN_VAL;
598 WR_WORD(AON_PS_REGS_MISC_BYPASS_0_CTRL, reg);
601 static INLINE
void clk_rc_bypass_en(
void)
603 uint32_t reg = RD_WORD(AON_PS_REGS_MISC_BYPASS_0_CTRL);
604 reg |= AON_PS_REGS_MISC_BYPASS_0_CTRL_CLK_32MHZ_RC_EN_EN;
605 reg &= ~AON_PS_REGS_MISC_BYPASS_0_CTRL_CLK_32MHZ_RC_EN_VAL;
606 WR_WORD(AON_PS_REGS_MISC_BYPASS_0_CTRL, reg);
609 static INLINE
void clk_rc_bypass_dis(
void)
611 uint32_t reg = RD_WORD(AON_PS_REGS_MISC_BYPASS_0_CTRL);
612 reg &= ~AON_PS_REGS_MISC_BYPASS_0_CTRL_CLK_32MHZ_RC_EN_EN;
613 reg |= AON_PS_REGS_MISC_BYPASS_0_CTRL_CLK_32MHZ_RC_EN_VAL;
614 WR_WORD(AON_PS_REGS_MISC_BYPASS_0_CTRL, reg);
617 static INLINE
void clk_gated_hclk_en(
void)
619 WR_WORD(GLOBAL_REG_CLK_CTRL_2, (RD_WORD(GLOBAL_REG_CLK_CTRL_2)|GLOBAL_REG_CLK_CTRL_2_CTL_CLK_CTRL_2_ALLOW_CM4_TO_GATE_HCLK));
622 static INLINE
void clk_gated_hclk_dis(
void)
624 WR_WORD(GLOBAL_REG_CLK_CTRL_2, (RD_WORD(GLOBAL_REG_CLK_CTRL_2)&~GLOBAL_REG_CLK_CTRL_2_CTL_CLK_CTRL_2_ALLOW_CM4_TO_GATE_HCLK));
627 static INLINE
void clk_mux_set(
int d0_mux,
int d1_mux,
int d2_mux)
629 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_CTRL_1);
631 reg &= ~GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D2_CLK;
632 reg |= ((d2_mux & GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D2_CLK_MASK) << GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D2_CLK_SHIFT);
633 reg &= ~GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D1_DIV2_4_8_CLKS;
634 reg |= ((d1_mux & GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D1_DIV2_4_8_CLKS_MASK) << GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D1_DIV2_4_8_CLKS_SHIFT);
635 WR_WORD(GLOBAL_REG_CLK_CTRL_1, reg);
637 reg = RD_WORD(D2_REG_CLK_CTRL);
639 reg |= D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_D0_CLK;
641 reg &= ~D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_D0_CLK;
642 WR_WORD(D2_REG_CLK_CTRL, reg);
645 static INLINE
int clk_root_get(
void)
648 uint32_t reg = RD_WORD(D2_REG_RC_CLOCK_SEL);
650 if (reg & D2_REG_RC_CLOCK_SEL_CTL_CLK_CTRL_D2REG_SEL_XOCPLL_OR_32MRC) {
651 reg = RD_WORD(D2_REG_CLK_CTRL);
652 if (reg & D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_XO_OR_CPLL) {
654 uint32_t reg1 = RD_WORD(AON_REG_CPLL_CTRL);
655 if (reg & D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_CPLL_OR_CPLL_DIV2) {
656 if (reg1& AON_REG_CPLL_CTRL_CTL_CPLL_FREQ_SEL) {
660 if (reg1 & AON_REG_CPLL_CTRL_CTL_CPLL_FREQ_SEL) {
668 if (!(reg & D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_XOX2_OR_XO)) {
680 static INLINE
void clk_d0_mux(uint32_t mux)
682 uint32_t reg = RD_WORD(D2_REG_CLK_CTRL);
685 reg |= D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_D0_CLK;
687 reg &= ~D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_D0_CLK;
689 WR_WORD(D2_REG_CLK_CTRL, reg);
692 static INLINE uint32_t clk_d0_mux_get(
void)
694 uint32_t reg = RD_WORD(D2_REG_CLK_CTRL);
696 if (reg & D2_REG_CLK_CTRL_CTL_CLK_CTRL_D2REG_SEL_D0_CLK)
702 static INLINE
void clk_d1_mux(uint32_t clk_div)
704 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_CTRL_1);
706 reg &= ~GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D1_DIV2_4_8_CLKS;
707 reg |= ((clk_div & GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D1_DIV2_4_8_CLKS_MASK) << GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D1_DIV2_4_8_CLKS_SHIFT);
709 WR_WORD(GLOBAL_REG_CLK_CTRL_1, reg);
712 static INLINE uint32_t clk_d1_mux_get(
void)
714 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_CTRL_1);
716 return ((reg & GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D1_DIV2_4_8_CLKS) >> GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D1_DIV2_4_8_CLKS_SHIFT);
719 static INLINE
void clk_d2_mux(uint32_t clk_div)
721 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_CTRL_1);
723 reg &= ~GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D2_CLK;
724 reg |= ((clk_div & GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D2_CLK_MASK) << GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D2_CLK_SHIFT);
726 WR_WORD(GLOBAL_REG_CLK_CTRL_1, reg);
729 static INLINE uint32_t clk_d2_mux_get(
void)
731 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_CTRL_1);
733 return ((reg & GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D2_CLK) >> GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D2_CLK_SHIFT);
736 static INLINE uint32_t clk_d0_enable_1_get(
void)
738 return (RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1));
741 static INLINE
void clk_d0_enable_1_set(uint32_t val)
743 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, val);
746 static INLINE uint32_t clk_d0_enable_2_get(
void)
748 return (RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2));
751 static INLINE
void clk_d0_enable_2_set(uint32_t val)
753 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, val);
756 static INLINE uint32_t clk_enable_1_get(
void)
758 return (RD_WORD(GLOBAL_REG_CLK_ENABLE_1));
761 static INLINE
void clk_enable_1_set(uint32_t val)
763 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, val);
766 static INLINE uint32_t clk_enable_2_get(
void)
768 return (RD_WORD(GLOBAL_REG_CLK_ENABLE_2));
771 static INLINE
void clk_enable_2_set(uint32_t val)
773 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, val);
776 static INLINE uint32_t clk_ctl_1_get(
void)
778 return (RD_WORD(GLOBAL_REG_CLK_CTRL_1));
781 static INLINE
void clk_ctl_1_set(uint32_t val)
783 WR_WORD(GLOBAL_REG_CLK_CTRL_1, val);
786 static INLINE uint32_t clk_ctl_2_get(
void)
788 return (RD_WORD(GLOBAL_REG_CLK_CTRL_2));
791 static INLINE
void clk_ctl_2_set(uint32_t val)
793 WR_WORD(GLOBAL_REG_CLK_CTRL_2, val);
796 static INLINE
void clk_tmr0_mux(
int mux)
798 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
799 reg &= ~(GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_SEL_MASK << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_SEL_SHIFT);
800 reg |= (mux & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_SEL_SHIFT;
801 reg &= ~(GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_EMIT_SHM_IF_CLK_SEL | GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_CAP_SHM_IF_CLK_SEL);
802 reg |= (mux & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_EMIT_SHM_IF_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_EMIT_SHM_IF_CLK_SEL_SHIFT;
803 reg |= (mux & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_CAP_SHM_IF_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_CAP_SHM_IF_CLK_SEL_SHIFT;
804 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, reg);
807 static INLINE
void clk_tmr1_mux(
int mux)
809 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
810 reg &= ~(GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_SEL_MASK << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_SEL_SHIFT);
811 reg |= (mux & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_SEL_SHIFT;
812 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, reg);
815 static INLINE
void clk_tmr2_mux(
int mux)
817 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
818 reg &= ~(GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_2_CLK_SEL_MASK << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_2_CLK_SEL_SHIFT);
819 reg |= (mux & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_2_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_2_CLK_SEL_SHIFT;
820 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, reg);
823 static INLINE
void clk_tmr3_mux(
int mux)
825 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
826 reg &= ~(GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_3_CLK_SEL_MASK << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_3_CLK_SEL_SHIFT);
827 reg |= (mux & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_3_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_3_CLK_SEL_SHIFT;
828 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, reg);
831 static INLINE
void clk_tmr4_mux(
int mux)
833 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
834 reg &= ~(GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_4_CLK_SEL_MASK << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_4_CLK_SEL_SHIFT);
835 reg |= (mux & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_4_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_4_CLK_SEL_SHIFT;
836 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, reg);
839 static INLINE
void clk_tmr5_mux(
int mux)
841 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
842 reg &= ~(GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_5_CLK_SEL_MASK << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_5_CLK_SEL_SHIFT);
843 reg |= (mux & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_5_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_5_CLK_SEL_SHIFT;
844 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, reg);
846 static INLINE
void clk_tmr6_mux(
int mux)
848 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL);
849 reg &= ~(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_0_CLK_SEL_MASK << GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_0_CLK_SEL_SHIFT);
850 reg |= (mux & GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_0_CLK_SEL_MASK) << GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_0_CLK_SEL_SHIFT;
851 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, reg);
853 static INLINE
void clk_tmr7_mux(
int mux)
855 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL);
856 reg &= ~(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_1_CLK_SEL_MASK << GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_1_CLK_SEL_SHIFT);
857 reg |= (mux & GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_1_CLK_SEL_MASK) << GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_1_CLK_SEL_SHIFT;
858 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, reg);
860 static INLINE
void clk_tmr8_mux(
int mux)
862 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL);
863 reg &= ~(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_2_CLK_SEL_MASK << GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_2_CLK_SEL_SHIFT);
864 reg |= (mux & GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_2_CLK_SEL_MASK) << GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_2_CLK_SEL_SHIFT;
865 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, reg);
867 static INLINE
void clk_tmr9_mux(
int mux)
869 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL);
870 reg &= ~(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_3_CLK_SEL_MASK << GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_3_CLK_SEL_SHIFT);
871 reg |= (mux & GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_3_CLK_SEL_MASK) << GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_3_CLK_SEL_SHIFT;
872 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, reg);
874 static INLINE
void clk_tmr_mux(
int mux0,
int mux1,
int mux2,
int mux3,
int mux4,
int mux5)
876 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
877 reg |= ((mux0 & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_SEL_SHIFT)|
878 ((mux1 & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_SEL_SHIFT)|
879 ((mux2 & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_2_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_2_CLK_SEL_SHIFT)|
880 ((mux3 & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_3_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_3_CLK_SEL_SHIFT)|
881 ((mux4 & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_4_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_4_CLK_SEL_SHIFT)|
882 ((mux5 & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_5_CLK_SEL_MASK) << GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_5_CLK_SEL_SHIFT);
883 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, reg);
886 static INLINE
int clk_tmr0_mux_get(
void)
888 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
889 int mux = (reg >> GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_SEL_SHIFT) & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_SEL_MASK;
893 static INLINE
int clk_tmr1_mux_get(
void)
895 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
896 int mux = (reg >> GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_SEL_SHIFT) & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_SEL_MASK;
900 static INLINE
int clk_tmr2_mux_get(
void)
902 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
903 int mux = (reg >> GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_2_CLK_SEL_SHIFT) & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_2_CLK_SEL_MASK;
907 static INLINE
int clk_tmr3_mux_get(
void)
909 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
910 int mux = (reg >> GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_3_CLK_SEL_SHIFT) & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_3_CLK_SEL_MASK;
914 static INLINE
int clk_tmr4_mux_get(
void)
916 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
917 int mux = (reg >> GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_4_CLK_SEL_SHIFT) & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_4_CLK_SEL_MASK;
921 static INLINE
int clk_tmr5_mux_get(
void)
923 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL);
924 int mux = (reg >> GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_5_CLK_SEL_SHIFT) & GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_5_CLK_SEL_MASK;
928 static INLINE
int clk_tmr6_mux_get(
void)
930 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL);
931 int mux = (reg >> GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_0_CLK_SEL_SHIFT) & GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_0_CLK_SEL_MASK;
935 static INLINE
int clk_tmr7_mux_get(
void)
937 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL);
938 int mux = (reg >> GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_1_CLK_SEL_SHIFT) & GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_1_CLK_SEL_MASK;
942 static INLINE
int clk_tmr8_mux_get(
void)
944 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL);
945 int mux = (reg >> GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_2_CLK_SEL_SHIFT) & GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_2_CLK_SEL_MASK;
949 static INLINE
int clk_tmr9_mux_get(
void)
951 uint32_t reg = RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL);
952 int mux = (reg >> GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_3_CLK_SEL_SHIFT) & GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_3_CLK_SEL_MASK;
956 static INLINE uint32_t clk_tmr_mux_get(
void)
958 return (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL) & 0xFFF);
961 static INLINE
void clk_tmr_mux_set(uint32_t mux)
963 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, mux);
966 static INLINE
void clk_slv_i2s_mux(
int from_pad)
968 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_CTRL_1);
971 reg |= GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D0_I2S_SLAVE_SCLK_FROM_PAD;
973 reg &= ~GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D0_I2S_SLAVE_SCLK_FROM_PAD;
976 WR_WORD(GLOBAL_REG_CLK_CTRL_1, reg);
979 static INLINE
void clk_smem_mux(uint32_t clk_div)
981 WR_WORD(GLOBAL_REG_CLK_CTRL_1, ((RD_WORD(GLOBAL_REG_CLK_CTRL_1) & ~GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_SHM_CLK) | ((clk_div & GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_SHM_CLK_MASK) << GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_SHM_CLK_SHIFT) ));
984 static INLINE uint32_t clk_smem_mux_get(
void)
986 return ((RD_WORD(GLOBAL_REG_CLK_CTRL_1) & GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_SHM_CLK) >> GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_SHM_CLK_SHIFT);
989 static INLINE
void clk_mi2s_divider(
int en)
991 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
993 reg |= GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ENABLE_I2S_INT_DIV_INPUT_CLK;
995 reg &= ~GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ENABLE_I2S_INT_DIV_INPUT_CLK;
997 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, reg);
1000 static INLINE
void clk_mi2s(uint32_t div)
1002 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_CTRL_2);
1004 reg &= ~GLOBAL_REG_CLK_CTRL_2_CTL_CLK_CTRL_2_INT_DIV_VALUE;
1005 reg |= ((div & GLOBAL_REG_CLK_CTRL_2_CTL_CLK_CTRL_2_INT_DIV_VALUE_MASK) << GLOBAL_REG_CLK_CTRL_2_CTL_CLK_CTRL_2_INT_DIV_VALUE_SHIFT);
1007 WR_WORD(GLOBAL_REG_CLK_CTRL_2, reg);
1010 static INLINE
void clk_qspi_mux(uint32_t div)
1013 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_CTRL_2);
1015 reg &= ~GLOBAL_REG_CLK_CTRL_2_CTL_CLK_CTRL_2_SEL_SSIMAS0_CLK;
1016 reg |= ((div & GLOBAL_REG_CLK_CTRL_2_CTL_CLK_CTRL_2_SEL_SSIMAS0_CLK_MASK) << GLOBAL_REG_CLK_CTRL_2_CTL_CLK_CTRL_2_SEL_SSIMAS0_CLK_SHIFT);
1018 WR_WORD(GLOBAL_REG_CLK_CTRL_2, reg);
1022 static INLINE uint32_t clk_qspi_mux_get(
void)
1024 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_CTRL_2);
1026 return ((reg & GLOBAL_REG_CLK_CTRL_2_CTL_CLK_CTRL_2_SEL_SSIMAS0_CLK) >> GLOBAL_REG_CLK_CTRL_2_CTL_CLK_CTRL_2_SEL_SSIMAS0_CLK_SHIFT);
1029 static INLINE
void clk_efuse_mux(uint32_t div)
1031 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_CTRL_1);
1034 reg &= ~GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_EFUSE_CLK;
1036 reg |= GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_EFUSE_CLK;
1039 WR_WORD(GLOBAL_REG_CLK_CTRL_1, reg);
1042 static INLINE uint32_t clk_efuse_mux_get(
void)
1044 return ((RD_WORD(GLOBAL_REG_CLK_CTRL_1) & GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_EFUSE_CLK) ? 1 : 0 );
1047 static INLINE
void clk_kb_en(
int en)
1049 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1050 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1053 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_KEYBOARD_CLK_FREE|GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_KEYBOARD_CLK_GATED;
1054 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_KEYBOARD_TOP_PCLK;
1056 reg &= ~(GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_KEYBOARD_CLK_FREE|GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_KEYBOARD_CLK_GATED);
1057 reg1 &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_KEYBOARD_TOP_PCLK;
1059 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1060 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1063 static INLINE
void clk_hash_en(
int en)
1065 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1068 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_SECURITY_CORE_PCLK;
1070 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_SECURITY_CORE_PCLK;
1072 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1075 static INLINE
void clk_ecc_en(
int en)
1077 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1078 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1081 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_SECURITY_CORE_PCLK;
1082 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_FW_RAM_CLK|GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_A_CLK|
1083 GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_B_CLK|GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_C_CLK|
1084 GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_D_CLK;
1086 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_SECURITY_CORE_PCLK;
1087 reg1 &= ~(GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_FW_RAM_CLK|GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_A_CLK|
1088 GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_B_CLK|GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_C_CLK|
1089 GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_D_CLK);
1091 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1092 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1095 static INLINE
void clk_aes_en(
int en)
1097 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1098 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1101 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_SECURITY_CORE_PCLK;
1102 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_FW_RAM_CLK|GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_A_CLK|
1103 GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_B_CLK|GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_C_CLK|
1104 GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_D_CLK;
1106 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_SECURITY_CORE_PCLK;
1107 reg1 &= ~(GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_FW_RAM_CLK|GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_A_CLK|
1108 GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_B_CLK|GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_C_CLK|
1109 GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_ECC_MEM_D_CLK);
1111 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1112 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1115 static INLINE
void clk_mspi_en(
int en)
1117 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1118 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1121 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_SSI_MASTER1_SSI_CLK;
1122 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SSI_MASTER1_PCLK;
1124 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_SSI_MASTER1_SSI_CLK;
1125 reg1 &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SSI_MASTER1_PCLK;
1127 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1128 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1131 static INLINE
void clk_sspi0_en(
int en)
1133 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1134 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1137 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_SSI_SLAVE0_SSI_CLK;
1138 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SSI_SLAVE0_PCLK;
1140 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_SSI_SLAVE0_SSI_CLK;
1141 reg1 &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SSI_SLAVE0_PCLK;
1143 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1144 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1147 static INLINE
void clk_sspi1_en(
int en)
1149 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1150 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1153 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_SSI_SLAVE1_SSI_CLK;
1154 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SSI_SLAVE1_PCLK;
1156 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_SSI_SLAVE1_SSI_CLK;
1157 reg1 &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SSI_SLAVE1_PCLK;
1159 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1160 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1163 static INLINE
void clk_intr_ctl_en(
int en)
1165 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1168 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_INTRCTRL_CLK;
1170 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_INTRCTRL_CLK;
1172 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1175 static INLINE
void clk_wdt_en(
int en)
1177 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1178 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1181 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_WDT_TCLK;
1182 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_WDT_PCLK;
1184 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_WDT_TCLK;
1185 reg1 &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_WDT_PCLK;
1187 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1188 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1191 static INLINE
void clk_i2c0_en(
int en)
1193 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1194 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1197 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_I2C_0_IC_CLK;
1198 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_I2C_0_PCLK;
1200 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_I2C_0_IC_CLK;
1201 reg1 &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_I2C_0_PCLK;
1203 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1204 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1207 static INLINE
void clk_i2c1_en(
int en)
1209 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1210 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1213 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_I2C_1_IC_CLK;
1214 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_I2C_1_PCLK;
1216 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_I2C_1_IC_CLK;
1217 reg1 &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_I2C_1_PCLK;
1219 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1220 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1223 static INLINE
void clk_efuse_en(
int en)
1225 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1226 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1229 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_EFUSE_CLK;
1230 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_EFUSECTRL_TOP_PCLK;
1232 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_EFUSE_CLK;
1233 reg1 &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_EFUSECTRL_TOP_PCLK;
1235 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1236 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1239 static INLINE
void clk_tmr_pclk_en(
void)
1241 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, (RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2)|GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_TIMERS_0_PCLK));
1243 static INLINE
void clk_tmr_pclk_dis(
void)
1245 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, (RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2)&(~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_TIMERS_0_PCLK)));
1247 static INLINE
void clk_tmr0_en(
void)
1249 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)|GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_ENABLE));
1252 static INLINE
void clk_tmr0_dis(
void)
1254 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)&~GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_ENABLE));
1257 static INLINE
void clk_tmr0_emit_en(
void)
1259 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)|GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_EMIT_ENABLE));
1262 static INLINE
void clk_tmr0_emit_dis(
void)
1264 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)&~GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_EMIT_ENABLE));
1267 static INLINE
void clk_tmr0_capture_en(
void)
1269 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)|GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_CAP_ENABLE));
1272 static INLINE
void clk_tmr0_capture_dis(
void)
1274 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)&~GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_0_CLK_CAP_ENABLE));
1277 static INLINE
void clk_tmr0_smem_emit_en(
void)
1279 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)|GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_EMIT_SHM_IF_ENABLE));
1282 static INLINE
void clk_tmr0_smem_emit_dis(
void)
1284 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)&~GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_EMIT_SHM_IF_ENABLE));
1287 static INLINE
void clk_tmr0_smem_capture_en(
void)
1289 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)|GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_CAP_SHM_IF_ENABLE));
1292 static INLINE
void clk_tmr0_smem_capture_dis(
void)
1294 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)&~GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_CAP_SHM_IF_ENABLE));
1297 static INLINE
void clk_tmr1_en(
void)
1299 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)|GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_ENABLE));
1302 static INLINE
void clk_tmr1_dis(
void)
1304 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)&~GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_ENABLE));
1307 static INLINE
void clk_tmr1_emit_en(
void)
1309 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)|GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_EMIT_ENABLE));
1312 static INLINE
void clk_tmr1_emit_dis(
void)
1314 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)&~GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_EMIT_ENABLE));
1317 static INLINE
void clk_tmr1_capture_en(
void)
1319 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)|GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_CAP_ENABLE));
1322 static INLINE
void clk_tmr1_capture_dis(
void)
1324 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)&~GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_1_CLK_CAP_ENABLE));
1327 static INLINE
void clk_tmr2_en(
void)
1329 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)|GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_2_CLK_ENABLE));
1332 static INLINE
void clk_tmr2_dis(
void)
1334 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)&~GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_2_CLK_ENABLE));
1337 static INLINE
void clk_tmr3_en(
void)
1339 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)|GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_3_CLK_ENABLE));
1342 static INLINE
void clk_tmr3_dis(
void)
1344 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)&~GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_3_CLK_ENABLE));
1347 static INLINE
void clk_tmr4_en(
void)
1349 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)|GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_4_CLK_ENABLE));
1352 static INLINE
void clk_tmr4_dis(
void)
1354 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)&~GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_4_CLK_ENABLE));
1357 static INLINE
void clk_tmr5_en(
void)
1359 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)|GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_5_CLK_ENABLE));
1362 static INLINE
void clk_tmr5_dis(
void)
1364 WR_WORD(GLOBAL_REG_TIMER_CLK_CTRL, (RD_WORD(GLOBAL_REG_TIMER_CLK_CTRL)&~GLOBAL_REG_TIMER_CLK_CTRL_CTL_PD1_TIMER_5_CLK_ENABLE));
1367 static INLINE
void clk_tmr6_en(
void)
1369 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, (RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL)|GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_0_CLK_ENABLE));
1372 static INLINE
void clk_tmr6_dis(
void)
1374 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, (RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL)&~GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_0_CLK_ENABLE));
1377 static INLINE
void clk_tmr6_emit_en(
void)
1379 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, (RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL)|GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_0_CLK_EMIT_ENABLE));
1382 static INLINE
void clk_tmr6_emit_dis(
void)
1384 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, (RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL)&~GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_0_CLK_EMIT_ENABLE));
1387 static INLINE
void clk_tmr6_capture_en(
void)
1389 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, (RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL)|GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_0_CLK_CAP_ENABLE));
1392 static INLINE
void clk_tmr6_capture_dis(
void)
1394 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, (RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL)&~GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_0_CLK_CAP_ENABLE));
1397 static INLINE
void clk_tmr7_en(
void)
1399 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, (RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL)|GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_1_CLK_ENABLE));
1402 static INLINE
void clk_tmr7_dis(
void)
1404 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, (RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL)&~GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_1_CLK_ENABLE));
1407 static INLINE
void clk_tmr8_en(
void)
1409 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, (RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL)|GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_2_CLK_ENABLE));
1412 static INLINE
void clk_tmr8_dis(
void)
1414 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, (RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL)&~GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_2_CLK_ENABLE));
1417 static INLINE
void clk_tmr9_en(
void)
1419 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, (RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL)|GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_3_CLK_ENABLE));
1422 static INLINE
void clk_tmr9_dis(
void)
1424 WR_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL, (RD_WORD(GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL)&~GLOBAL_REG_TIMER_ADDITIONAL_CLK_RST_CTRL_CTL_PD1_TIMER_ADD_3_CLK_ENABLE));
1426 static INLINE
void clk_pwm_en(
int en)
1428 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1431 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_PWM0_PCLK;
1433 reg &= ~ GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_PWM0_PCLK;
1436 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1439 static INLINE
void clk_counter_en(
int en)
1441 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1442 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
1444 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_COUNTER_TOP_PCLK;
1445 reg1 |= GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ENABLE_COUNTER_CLKRSTGEN_32M_CLK|
1446 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ENABLE_COUNTER_CLKRSTGEN_16M_CLK|
1447 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ENABLE_COUNTER_CLKRSTGEN_8M_CLK;
1449 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_COUNTER_TOP_PCLK;
1450 reg1 &= ~(GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ENABLE_COUNTER_CLKRSTGEN_32M_CLK|
1451 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ENABLE_COUNTER_CLKRSTGEN_16M_CLK|
1452 GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ENABLE_COUNTER_CLKRSTGEN_8M_CLK);
1455 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1456 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, reg1);
1459 static INLINE
void clk_audio_en(
int en)
1461 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1462 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1465 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_AUDIO_64M_CLK;
1466 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_AUDIO_TOP_PCLK;
1468 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_AUDIO_64M_CLK;
1469 reg1 &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_AUDIO_TOP_PCLK;
1472 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1473 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1476 static INLINE
void clk_audio_enc_en(
int en)
1478 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1481 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_AUDIO_AURX_CLK;
1483 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_AUDIO_AURX_CLK;
1485 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1488 static INLINE
void clk_audio_dec_en(
int en)
1490 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1493 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_AUDIO_AUTX_CLK|
1494 GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_AUDIO_SPK_CLK|
1495 GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_AUDIO_SD_CLK;
1497 reg &= ~(GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_AUDIO_AUTX_CLK|
1498 GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_AUDIO_SPK_CLK |
1499 GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_AUDIO_SD_CLK);
1502 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1505 static INLINE
void clk_audio_resample(
int en)
1507 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1510 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_AUDIO_AUTX_CLK;
1512 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_AUDIO_AUTX_CLK;
1515 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1519 static INLINE
void clk_audio_sdm_mux(uint32_t mux)
1521 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_CTRL_1);
1523 reg &= ~GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D0_AUDIO_SPK_SD_CLK;
1524 reg |= ((mux & GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D0_AUDIO_SPK_SD_CLK_MASK) << GLOBAL_REG_CLK_CTRL_1_CTL_CLK_CTRL_1_SEL_D0_AUDIO_SPK_SD_CLK_SHIFT);
1526 WR_WORD(GLOBAL_REG_CLK_CTRL_1, reg);
1529 static INLINE
void clk_sadc_en(
int en)
1531 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1532 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1535 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_SADC_CLK;
1536 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SADCCTRL_TOP_PCLK;
1538 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_SADC_CLK;
1539 reg1 &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SADCCTRL_TOP_PCLK;
1542 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1543 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1546 static INLINE
void clk_mi2s_en(
int en)
1548 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1549 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1552 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_I2S_MASTER_SCLK;
1553 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_I2S_MASTER_PCLK;
1555 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_I2S_MASTER_SCLK;
1556 reg1 &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_I2S_MASTER_PCLK;
1559 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1560 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1563 static INLINE
void clk_si2s_en(
int en)
1565 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1566 uint32_t reg1 = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1569 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_I2S_SLAVE_SCLK;
1570 reg1 |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_I2S_SLAVE_PCLK;
1572 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_CPU_I_I2S_SLAVE_SCLK;
1573 reg1 &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_I2S_SLAVE_PCLK;
1576 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1577 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg1);
1580 static INLINE
void clk_quaddec_en(
int en)
1582 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1585 reg |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_CLK_QUADDEC|GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_QUADDEC_TOP_PCLK;
1587 reg &= ~(GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_CLK_QUADDEC|GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_QUADDEC_TOP_PCLK);
1590 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg);
1593 static INLINE
void clk_dma_en(
int en)
1595 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1598 reg |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_DMAC_REQ_MUX_PCLK;
1600 reg &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_DMAC_REQ_MUX_PCLK;
1603 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg);
1606 static INLINE
void clk_uart0_en(
int en)
1608 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1611 reg |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_UART_0_PCLK;
1613 reg &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_UART_0_PCLK;
1616 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg);
1619 static INLINE
void clk_uart1_en(
int en)
1621 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1624 reg |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_UART_1_PCLK;
1626 reg &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_UART_1_PCLK;
1629 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg);
1632 static INLINE
void clk_sm_0_en(
int en)
1634 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1637 reg |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SHM_MEM_0_CLK;
1639 reg &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SHM_MEM_0_CLK;
1641 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg);
1644 static INLINE
void clk_sm_1_en(
int en)
1646 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1649 reg |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SHM_MEM_1_CLK;
1651 reg &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SHM_MEM_1_CLK;
1653 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg);
1656 static INLINE
void clk_sm_2_en(
int en)
1658 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1661 reg |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SHM_MEM_2_CLK;
1663 reg &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SHM_MEM_2_CLK;
1665 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg);
1668 static INLINE
void clk_sm_3_en(
int en)
1670 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1673 reg |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SHM_MEM_3_CLK;
1675 reg &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SHM_MEM_3_CLK;
1677 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg);
1680 static INLINE
void clk_sm_4_en(
int en)
1682 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1685 reg |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SHM_MEM_4_CLK;
1687 reg &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_SHM_MEM_4_CLK;
1689 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg);
1692 static INLINE
void clk_sm_en(
int en)
1694 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_1);
1697 reg |= GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_SHAREDMEM_TOP_CLK|GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_AHB2SHM_HCLK;
1699 reg &= ~(GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_SHAREDMEM_TOP_CLK|GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_AHB2SHM_HCLK);
1702 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, reg);
1705 static INLINE
void clk_ble_en(
int en)
1708 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
1710 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_RXTX_SEQ_REGS_CLK;
1712 reg &= ~GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_RXTX_SEQ_REGS_CLK;
1714 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
1716 reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_2);
1718 reg |= GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_CLK_EM;
1720 reg &= ~GLOBAL_REG_CLKD0_ENABLE_2_CTL_CLKD0_ENABLE_2_CLK_EM;
1722 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_2, reg);
1725 reg = RD_WORD(GLOBAL_REG_CLKD1_ENABLE_1);
1727 reg |= GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_1_AHBTRG_TOP_PCLK|
1728 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_1_BLE_I_MDM_CORE_CLK|GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_1_BLE_I_MDM_PCLK|
1729 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_1_BLE_I_CLK_ANT|
1730 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_1_BLE_I_BB_MASTER1_GCLK|
1731 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_CLK_PLLTRIG_MEM|GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_PCLK_PLLTRIG|GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_PLLTRIG|
1732 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_CPU_I_CLK_AHBTRG|
1733 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_TRXSEQ_I_MAIN_CLK|
1734 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_TRXSEQ_I_MAIN_CLK_FREE|GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_TRXSEQ_I_CNTR_CLK|
1735 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_BLE_FE_PCLK;
1737 reg &= ~(GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_1_AHBTRG_TOP_PCLK|
1738 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_1_BLE_I_MDM_CORE_CLK|GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_1_BLE_I_MDM_PCLK|
1739 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_1_BLE_I_CLK_ANT|
1740 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_1_BLE_I_BB_MASTER1_GCLK|
1741 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_CLK_PLLTRIG_MEM|GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_PCLK_PLLTRIG|GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_PLLTRIG|
1742 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_CPU_I_CLK_AHBTRG|
1743 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_TRXSEQ_I_MAIN_CLK|
1744 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_TRXSEQ_I_MAIN_CLK_FREE|GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_TRXSEQ_I_CNTR_CLK|
1745 GLOBAL_REG_CLKD1_ENABLE_1_CTL_CLKD1_ENABLE_BLE_FE_PCLK);
1747 WR_WORD(GLOBAL_REG_CLKD1_ENABLE_1, reg);
1749 reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_1);
1751 reg |= GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_CLK_EM2SHM;
1753 reg &= ~GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_CLK_EM2SHM;
1754 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, reg);
1758 static INLINE
void clk_calib_en(
int en)
1760 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_2);
1762 reg |= GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_XO_TO_DIGI_CLK_EN_FOR_CALIB;
1764 reg &= ~GLOBAL_REG_CLK_ENABLE_2_CTL_CLK_ENABLE_2_ROOT_XO_TO_DIGI_CLK_EN_FOR_CALIB;
1766 WR_WORD(GLOBAL_REG_CLK_ENABLE_2, reg);
1769 static INLINE
void clk_ipm_en(
int en)
1771 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_1);
1774 reg |= GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_IPM_FREE;
1776 reg &= ~GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_IPM_FREE;
1779 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, reg);
1782 static INLINE
void clk_trig_en(
int en)
1784 uint32_t reg = RD_WORD(GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL);
1785 uint32_t reg2 = RD_WORD(GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_2);
1786 uint32_t reg_clk_ctrl4 = RD_WORD(GLOBAL_REG_CLK_CTRL_4);
1788 reg |= GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_TRIGHDLR_PCLK_EN|GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_TRIGHDLR_CLK_FREE_EN;
1791 reg &= ~(GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_CLK_FREE|GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_SHM_CLK|
1792 GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_MEM_CLK|GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_HP_CLK|
1793 GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_MP_CLK|GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_LP_CLK|
1794 GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_HP_TIMER_CLK|GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_MP_TIMER_CLK|
1795 GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_LP_TIMER_CLK|GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_HCLK);
1796 reg2 &= ~GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_2_CTL_WFI_GATE_TRIGHDLR_APB_MSTR_PCLK;
1797 reg_clk_ctrl4 &= ~(GLOBAL_REG_CLK_CTRL_4_CTL_CLK_CTRL_4_DIS_CLK_WFI_APB_D0_1_HCLK|GLOBAL_REG_CLK_CTRL_4_CTL_CLK_CTRL_4_DIS_CLK_WFI_APB_D0_2_HCLK);
1799 reg &= ~(GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_TRIGHDLR_PCLK_EN|GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_TRIGHDLR_CLK_FREE_EN);
1801 reg |= (GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_CLK_FREE|GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_SHM_CLK|
1802 GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_MEM_CLK|GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_HP_CLK|
1803 GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_MP_CLK|GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_LP_CLK|
1804 GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_HP_TIMER_CLK|GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_MP_TIMER_CLK|
1805 GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_LP_TIMER_CLK|GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_CTL_WFI_GATE_TRIGHDLR_HCLK);
1806 reg2 |= GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_2_CTL_WFI_GATE_TRIGHDLR_APB_MSTR_PCLK;
1807 reg_clk_ctrl4 |= (GLOBAL_REG_CLK_CTRL_4_CTL_CLK_CTRL_4_DIS_CLK_WFI_APB_D0_1_HCLK|GLOBAL_REG_CLK_CTRL_4_CTL_CLK_CTRL_4_DIS_CLK_WFI_APB_D0_2_HCLK);
1810 WR_WORD(GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL, reg);
1811 WR_WORD(GLOBAL_REG_TRIGHDLR_CLK_RST_CTRL_2, reg2);
1812 WR_WORD(GLOBAL_REG_CLK_CTRL_4, reg_clk_ctrl4);
1815 static INLINE
void clk_wfi_clean(
void)
1817 uint32_t reg_clk_ctrl4 = RD_WORD(GLOBAL_REG_CLK_CTRL_4);
1819 reg_clk_ctrl4 &= ~(GLOBAL_REG_CLK_CTRL_4_CTL_CLK_CTRL_4_DIS_CLK_WFI_CALIB_REG_CLK);
1821 WR_WORD(GLOBAL_REG_CLK_CTRL_4, reg_clk_ctrl4);
1824 static INLINE
void clk_gpio_0_intr_en(
int en)
1826 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_1);
1829 reg |= GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_GPIO_0_INTR_CLK;
1831 reg &= ~GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_GPIO_0_INTR_CLK;
1834 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, reg);
1837 static INLINE
void clk_gpio_1_intr_en(
int en)
1839 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_1);
1842 reg |= GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_GPIO_1_INTR_CLK;
1844 reg &= ~GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_GPIO_1_INTR_CLK;
1847 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, reg);
1850 static INLINE
void clk_gpio_2_intr_en(
int en)
1852 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_1);
1855 reg |= GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_GPIO_2_INTR_CLK;
1857 reg &= ~GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_GPIO_2_INTR_CLK;
1860 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, reg);
1863 static INLINE
void clk_gpio_3_intr_en(
int en)
1865 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_1);
1868 reg |= GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_GPIO_3_INTR_CLK;
1870 reg &= ~GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_GPIO_3_INTR_CLK;
1873 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, reg);
1876 static INLINE
void clk_gpio_4_intr_en(
int en)
1878 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_1);
1881 reg |= GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_GPIO_4_INTR_CLK;
1883 reg &= ~GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_GPIO_4_INTR_CLK;
1886 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, reg);
1889 static INLINE
void clk_wdt_intr_en(
int en)
1891 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_1);
1894 reg |= GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_WDT_INTR_CLK;
1896 reg &= ~GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_WDT_INTR_CLK;
1899 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, reg);
1902 static INLINE
void clk_sw_intr_en(
int en)
1904 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_1);
1907 reg |= GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_SW_INTR_CLK;
1909 reg &= ~GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_SW_INTR_CLK;
1912 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, reg);
1915 static INLINE
void clk_nmi_intr_en(
int en)
1917 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_ENABLE_1);
1920 reg |= GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_NMI_CLK;
1922 reg &= ~GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_NMI_CLK;
1925 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, reg);
1929 static INLINE
void clk_rtc_cap(uint8_t cap)
1933 WR_WORD(AON_REG_PMU_AONPD_REG_5TO6, (cap << 4) | (cap << 9) | 0xF);
1936 static FORCEINLINE
void clk_rtc_en(
void)
1938 WR_WORD(AON_REG_PMU_MISC_CTRL, (RD_WORD(AON_REG_PMU_MISC_CTRL)|AON_REG_PMU_MISC_CTRL_CTL_CLK_32K_RTC_EN));
1941 static FORCEINLINE
void clk_rtc_dis(
void)
1943 WR_WORD(AON_REG_PMU_MISC_CTRL, (RD_WORD(AON_REG_PMU_MISC_CTRL)&~AON_REG_PMU_MISC_CTRL_CTL_CLK_32K_RTC_EN));
1946 static FORCEINLINE
void clk_32k_rtc(
void)
1948 WR_WORD(AON_REG_AON_MISC_CTRL, (RD_WORD(AON_REG_AON_MISC_CTRL)|AON_REG_AON_MISC_CTRL_AON_MISC_CTRL_SEL_AON_32K_CLK));
1951 static FORCEINLINE
void clk_32k_rc(
void)
1953 WR_WORD(AON_REG_AON_MISC_CTRL, (RD_WORD(AON_REG_AON_MISC_CTRL)&~AON_REG_AON_MISC_CTRL_AON_MISC_CTRL_SEL_AON_32K_CLK));
1956 static FORCEINLINE
void clk_wdt_rtc(
void)
1958 WR_WORD(AON_REG_AON_MISC_CTRL, (RD_WORD(AON_REG_AON_MISC_CTRL)|(AON_REG_AON_MISC_CTRL_CTL_SEL_TIMER_WDT_32K_CLK|AON_REG_AON_MISC_CTRL_CTL_WDT_RST_SWITCH_RC_CLK)));
1961 static FORCEINLINE
void clk_wdt_rc(
void)
1963 WR_WORD(AON_REG_AON_MISC_CTRL, (RD_WORD(AON_REG_AON_MISC_CTRL)&~AON_REG_AON_MISC_CTRL_CTL_SEL_TIMER_WDT_32K_CLK));
1966 static INLINE
void clk_force_spiflash_ctl_clk(
void)
1968 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_FORCE_ON_1);
1969 reg |= GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_SPIFLASH_CTRL_CLK;
1970 WR_WORD(GLOBAL_REG_CLK_FORCE_ON_1, reg);
1973 static INLINE
void clk_force_dma_ctl_clks(
int force_on)
1976 uint32_t reg = RD_WORD(GLOBAL_REG_CLK_FORCE_ON_1);
1978 reg |= GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_AHB_D0_HCLK|
1979 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_APB_D0_1_HCLK|
1980 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_APB_D0_2_HCLK|
1981 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_APB_D0_3_HCLK|
1982 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_ICM_DATA_CODE_RAM_CLK|
1983 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_DATA_CODE_SRAM_A_CLK|
1984 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_DATA_CODE_SRAM_B_CLK|
1985 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_DMAC_REQ_MUX_CLK;
1986 WR_WORD(GLOBAL_REG_CLK_FORCE_ON_1, reg);
1987 reg = RD_WORD(GLOBAL_REG_CLK_FORCE_ON_2);
1988 reg |= GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DC_RAM_0_CLK|
1989 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DC_RAM_1_CLK|
1990 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DC_RAM_2_CLK|
1991 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DC_RAM_3_CLK|
1992 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DC_RAM_4_CLK|
1993 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DMAC_0_CLK|
1994 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DMAC_1_CLK|
1995 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_D2_M2_AHB_HCLK;
1996 WR_WORD(GLOBAL_REG_CLK_FORCE_ON_2, reg);
1997 reg = RD_WORD(GLOBAL_REG_CLK_FORCE_ON_3);
1998 reg |= GLOBAL_REG_CLK_FORCE_ON_3_CTL_CLK_FORCE_ON_3_DC_RAM_64_80K_CLK;
1999 WR_WORD(GLOBAL_REG_CLK_FORCE_ON_3, reg);
2001 reg &= ~(GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_AHB_D0_HCLK|
2002 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_APB_D0_1_HCLK|
2003 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_APB_D0_2_HCLK|
2004 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_APB_D0_3_HCLK|
2005 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_ICM_DATA_CODE_RAM_CLK|
2006 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_DATA_CODE_SRAM_A_CLK|
2007 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_DATA_CODE_SRAM_B_CLK|
2008 GLOBAL_REG_CLK_FORCE_ON_1_CTL_CLK_FORCE_ON_1_DMAC_REQ_MUX_CLK);
2009 WR_WORD(GLOBAL_REG_CLK_FORCE_ON_1, reg);
2010 reg = RD_WORD(GLOBAL_REG_CLK_FORCE_ON_2);
2011 reg &= ~(GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DC_RAM_0_CLK|
2012 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DC_RAM_1_CLK|
2013 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DC_RAM_2_CLK|
2014 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DC_RAM_3_CLK|
2015 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DC_RAM_4_CLK|
2016 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DMAC_0_CLK|
2017 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_DMAC_1_CLK|
2018 GLOBAL_REG_CLK_FORCE_ON_2_CTL_CLK_FORCE_ON_2_D2_M2_AHB_HCLK);
2019 WR_WORD(GLOBAL_REG_CLK_FORCE_ON_2, reg);
2020 reg = RD_WORD(GLOBAL_REG_CLK_FORCE_ON_3);
2021 reg &= ~GLOBAL_REG_CLK_FORCE_ON_3_CTL_CLK_FORCE_ON_3_DC_RAM_64_80K_CLK;
2022 WR_WORD(GLOBAL_REG_CLK_FORCE_ON_3, reg);
2027 static INLINE
void clk_reset_ble_sleep_clk(
void)
2030 WR_WORD(AON_REG_AON_RESET_CTRL, 0x1d);
2031 WR_WORD(AON_REG_AON_RESET_CTRL, 0x1f);
2035 static FORCEINLINE
void clk_ble_time_snap_shot(
void)
2037 WR_WORD(GLOBAL2_REG_SNAPSHOT_CTRL, GLOBAL2_REG_SNAPSHOT_CTRL_CTL_SNAPSHOT_BLE_BB_CNTR);
2038 RD_WORD(GLOBAL2_REG_SNAPSHOT_CTRL);
2041 static FORCEINLINE uint32_t clk_ble_time_clkn(
void)
2043 return RD_WORD(GLOBAL2_REG_SNAPSHOT_VAL_BLE_CLKN);
2046 static FORCEINLINE uint32_t clk_ble_time_fine(
void)
2048 return RD_WORD(GLOBAL2_REG_SNAPSHOT_VAL_BLE_FINE);
2051 static INLINE
void clk_32k_calib(uint8_t cycles)
2054 reg = ((cycles & GLOBAL_REG_CALIBRATION_MISC_CTRL_CTL_CAL_CNT_LMT_LOG2_MASK) << GLOBAL_REG_CALIBRATION_MISC_CTRL_CTL_CAL_CNT_LMT_LOG2_SHIFT);
2055 reg |= GLOBAL_REG_CALIBRATION_MISC_CTRL_CTL_CAL_START;
2057 WR_WORD(GLOBAL_REG_CALIBRATION_MISC_CTRL, reg);
2060 static INLINE uint32_t clk_32k_calib_get(
void)
2062 return (RD_WORD(GLOBAL_REG_CALIBRATION_MISC_STATUS) & (GLOBAL_REG_CALIBRATION_MISC_STATUS_STS_CALIB_COUNT_INT|GLOBAL_REG_CALIBRATION_MISC_STATUS_STS_CALIB_COUNT_FRAC));
2065 static INLINE uint32_t clk_32k_calib_get_frac(
void)
2067 return ((RD_WORD(GLOBAL_REG_CALIBRATION_MISC_STATUS) & GLOBAL_REG_CALIBRATION_MISC_STATUS_STS_CALIB_COUNT_FRAC) >> GLOBAL_REG_CALIBRATION_MISC_STATUS_STS_CALIB_COUNT_FRAC_SHIFT);
2070 static INLINE uint32_t clk_32k_calib_get_int(
void)
2072 return ((RD_WORD(GLOBAL_REG_CALIBRATION_MISC_STATUS) & GLOBAL_REG_CALIBRATION_MISC_STATUS_STS_CALIB_COUNT_INT) >> GLOBAL_REG_CALIBRATION_MISC_STATUS_STS_CALIB_COUNT_INT_SHIFT);
2075 static INLINE
int clk_32k_calib_done(
void)
2077 return ((RD_WORD(GLOBAL_REG_CALIBRATION_MISC_STATUS) & GLOBAL_REG_CALIBRATION_MISC_STATUS_STS_CALIB_COUNT_DONE) ? 1 : 0);
2080 static INLINE
void clk_32k_calib_done_clear(
void)
2082 WR_WORD(GLOBAL_REG_CALIBRATION_MISC_STATUS, GLOBAL_REG_CALIBRATION_MISC_STATUS_STS_CALIB_COUNT_DONE);
2085 static INLINE
void clk_32k_hw_timing_corr(uint32_t corr)
2087 WR_WORD(GLOBAL2_REG_HW_TIMING_CORR_CTRL, corr);
2090 static INLINE
void clk_ble_phase_match_reset(
void)
2092 uint32_t reg = RD_WORD(GLOBAL_REG_BLE_ADDITIONAL_CONTROL);
2094 reg |= GLOBAL_REG_BLE_ADDITIONAL_CONTROL_CTL_BLE_PHASE_MATCH_SOFT_RESET;
2095 WR_WORD(GLOBAL_REG_BLE_ADDITIONAL_CONTROL, reg);
2098 reg &= ~GLOBAL_REG_BLE_ADDITIONAL_CONTROL_CTL_BLE_PHASE_MATCH_SOFT_RESET;
2099 WR_WORD(GLOBAL_REG_BLE_ADDITIONAL_CONTROL, reg);
2102 static FORCEINLINE
void clk_systick_mux(
int mux)
2104 WR_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL, ((RD_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL) & ~GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CLK_SEL)|((mux & GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CLK_SEL_MASK) << GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CLK_SEL_SHIFT)));
2107 static INLINE
int clk_systick_mux_get(
void)
2109 return ((RD_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL) >> GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CLK_SEL_SHIFT) & GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CLK_SEL_MASK) ;
2112 static FORCEINLINE
void clk_systick_en(
void)
2114 WR_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL, (RD_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL)|GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CLK_ENABLE));
2117 static FORCEINLINE
void clk_systick_dis(
void)
2119 WR_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL, (RD_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL)&~GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CLK_ENABLE));
2122 static INLINE
void clk_systick_emit_en(
int en)
2124 uint32_t reg = RD_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL);
2127 reg |= GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CLK_EMIT_ENABLE;
2129 reg &= ~GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CLK_EMIT_ENABLE;
2132 WR_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL, reg);
2135 static INLINE
void clk_systick_capture_en(
int en)
2137 uint32_t reg = RD_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL);
2140 reg |= GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CLK_CAP_ENABLE;
2142 reg &= ~GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CLK_CAP_ENABLE;
2145 WR_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL, reg);
2148 static INLINE
void clk_systick_force(
int on)
2150 uint32_t reg = RD_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL);
2153 reg |= GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CNT_CLK_FORCE_ON;
2155 reg |= GLOBAL_REG_SYSTICK_CLK_CTRL_CTL_SYSTICK_CNT_CLK_FORCE_OFF;
2157 WR_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL, reg);
2160 static INLINE uint32_t clk_systick_get(
void)
2162 return (RD_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL));
2165 static INLINE
void clk_systick_set(uint32_t val)
2167 WR_WORD(GLOBAL_REG_SYSTICK_CLK_CTRL, val);
2170 static INLINE
void clk_reset_ipmac_clk(
void)
2172 uint32_t reg = RD_WORD(GLOBAL_REG_RESET_CTRL_2);
2174 reg &= ~(GLOBAL_REG_RESET_CTRL_2_CTL_RESET_2_D1_BLE_IPM_REG|GLOBAL_REG_RESET_CTRL_2_CTL_RESET_2_D1_BLE_IPMAC_REG);
2175 WR_WORD(GLOBAL_REG_RESET_CTRL_2, reg);
2176 reg |= GLOBAL_REG_RESET_CTRL_2_CTL_RESET_2_D1_BLE_IPM_REG|GLOBAL_REG_RESET_CTRL_2_CTL_RESET_2_D1_BLE_IPMAC_REG;
2177 WR_WORD(GLOBAL_REG_RESET_CTRL_2, reg);
2180 static INLINE
void clk_reset_adc(
void)
2183 val = RD_WORD(GLOBAL_REG_RESET_CTRL_1);
2184 val &= ~GLOBAL_REG_RESET_CTRL_1_CTL_RESET_1_D0_SADC_RSTN_REG;
2185 WR_WORD(GLOBAL_REG_RESET_CTRL_1, val);
2186 val |= GLOBAL_REG_RESET_CTRL_1_CTL_RESET_1_D0_SADC_RSTN_REG;
2187 WR_WORD(GLOBAL_REG_RESET_CTRL_1, val);
2190 static INLINE
void clk_spiflash_en(
int en)
2192 uint32_t reg = RD_WORD(GLOBAL_REG_CLKD0_ENABLE_1);
2195 reg |= GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_SSI_MAS0_CLK;
2197 reg &= ~(GLOBAL_REG_CLKD0_ENABLE_1_CTL_CLKD0_ENABLE_1_SSI_MAS0_CLK);
2199 WR_WORD(GLOBAL_REG_CLKD0_ENABLE_1, reg);
2202 static INLINE
void clk_osc_xo_intr_clk_en(
void)
2204 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, (RD_WORD(GLOBAL_REG_CLK_ENABLE_1)|GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_OSC_XO_INTR_CLK));
2207 static INLINE
void clk_osc_xo_intr_clk_dis(
void)
2209 WR_WORD(GLOBAL_REG_CLK_ENABLE_1, (RD_WORD(GLOBAL_REG_CLK_ENABLE_1)&~GLOBAL_REG_CLK_ENABLE_1_CTL_CLK_ENABLE_1_OSC_XO_INTR_CLK));
2721 void hal_clk_cap_en(
int tmr_id,
int en);
2722 void hal_clk_emit_en(
int tmr_id,
int en);
2723 void hal_clk_aon_tmr_intr(
int en);
uint32_t hal_clk_32k_get(void)
Get slow clock (low power clock) rate.
Divided by 4 of XO/32MRC.
Definition: hal_clk.h:84
void hal_clk_i2c_en(int id, int on)
Enable or disable I2c clock.
void hal_clk_sm_en(int on)
Enable or disable share memory clock.
void hal_clk_audio_en(int en)
Enable or disable shared audio clock.
uint32_t hal_clk_root_get(void)
Get Root clock.
void hal_clk_counter_en(int on)
Enable or disable counter clock.
Divided by 8 of XO/32MRC.
Definition: hal_clk.h:110
void hal_clk_systick_en(int en)
Enable or disable Inplay's systick clock.
Divided by 1 of 32MXO/32MRC. This is default.
Definition: hal_clk.h:36
int hal_clk_smem_mux(int mux)
Set Shared memory clock.
void hal_clk_tmr_en(int tim_id, int en)
Enable or disable Timer clock.
void hal_clk_audio_dec_en(int en)
Enable or disable audio decoder related clock.
void hal_clk_gpio_intr(int port, int on)
Enable or disable GPIO interrupt controller clock.
Divided by 2 of XO/32MRC.
Definition: hal_clk.h:68
void hal_clk_wdt_en(int on)
Enable or disable Watch Dog Timer clock.
int hal_clk_efuse_mux(int mux)
Set Efuse clock.
uint32_t hal_clk_d0_get(void)
Get D0 domanin clock.
uint32_t hal_clk_cpu_get(void)
Get CPU clock.
void hal_clk_calib_xo(void)
Calibrate XO.
void hal_clk_kb_en(int on)
Enable or disable keyboard clock.
Divided by 2 of XO/32MRC. This is default.
Definition: hal_clk.h:56
void hal_clk_audio_sdm_mux(int mux)
Audio sigma delta modulator clock source mux.
Divided by 2 of XO/32MRC. This is default.
Definition: hal_clk.h:106
clk_sdm_mux
Audio speaker and SD clock mux.
Definition: hal_clk.h:72
clk_error
Error return code.
Definition: hal_clk.h:125
Divided by 1 of XO/32MRC.
Definition: hal_clk.h:104
void hal_clk_pwm_en(int on)
Enable or disable PWM clock.
clk_smem_div
share memory clock divider
Definition: hal_clk.h:90
void hal_clk_mi2s_set(uint32_t bit_clk)
Set Master I2S bit clock.
int hal_clk_tmr_mux(int tmr_id, int mux)
Set Timer clock.
Divided by 2 of XOX2/XO/32MRC. This is default.
Definition: hal_clk.h:44
void hal_clk_quaddec_en(int on)
Enable or disable QD clock.
tmr_id
Timer Id.
Definition: hal_timer.h:46
int hal_clk_sadc_mux(int mux)
Set Sensor ADC clock.
clk_systick_div
systick clock divider
Definition: hal_clk.h:114
void hal_clk_sadc_en(int on)
Enable or disable sensor ADC clock.
Divided by 8 of XOX2/XO/32MRC.
Definition: hal_clk.h:48
uint32_t hal_clk_systick_get(void)
Get Inplay systick clock.
I2S master clock generated from integer divider.
Definition: hal_clk.h:74
Divided by 2 of 32MXO/32MRC.
Definition: hal_clk.h:38
Divided by 1 of XO/32MRC.
Definition: hal_clk.h:92
void hal_clk_ecc_en(int on)
Enable or disable ECC clock.
Divided by 16 of XO/32MRC.
Definition: hal_clk.h:120
void hal_clk_dma_en(int on)
Enable or disable DMA clock.
Divided by 4 of XO/32MRC.
Definition: hal_clk.h:108
int hal_clk_d2_mux(int mux)
Set D2 domain clock.
void hal_clk_sspi_en(int id, int on)
Enable or disable slave SPI clock.
void hal_clk_calib_32k(int cycles)
Calibrate Low Power Clock (RC/RTC) timer.
void hal_clk_aes_en(int on)
Enable or disable AES clock.
uint32_t hal_clk_tmr_get(int tmr_id)
Get Timer clock.
Divided by 8 of XO/32MRC.
Definition: hal_clk.h:66
Divided by 4 of XOX2/XO/32MRC.
Definition: hal_clk.h:46
int hal_clk_cpu_set(uint32_t cpu_clk)
Set CPU clock.
Divided by 8 of XO/32MRC. This is default.
Definition: hal_clk.h:86
Divided by 2 of XO/32MRC. This is default.
Definition: hal_clk.h:94
Divided by 4 of XO/32MRC.
Definition: hal_clk.h:64
uint32_t hal_clk_qspi_get(void)
Get QSPI clock.
No error.
Definition: hal_clk.h:127
void hal_clk_uart_en(int id, int on)
Enable or disable Uart clock.
void hal_clk_mspi_en(int on)
Enable or disable master SPI clock.
int hal_clk_qspi_mux(int mux)
Set QSPI speed clock.
int hal_clk_d0_mux(int mux)
Set D0 domain clock.
I2S slave clock from PAD.
Definition: hal_clk.h:76
Divided by 1 of XO/32MRC.
Definition: hal_clk.h:54
int hal_clk_32k_ready(void)
Check if RTC is ready.
Divided by 4 of XO/32MRC.
Definition: hal_clk.h:96
Invalid input paramters.
Definition: hal_clk.h:129
Divided by 4 of XO/32MRC.
Definition: hal_clk.h:58
void hal_clk_i2s_en(int id, int on)
Enable or disable I2S clock.
void hal_clk_audio_enc_en(int en)
Enable or disable audio encoder related clock.
Divided by 8 of XO/32MRC.
Definition: hal_clk.h:98
int hal_clk_d1_mux(int mux)
Set D1 domain clock.
void hal_clk_hash_en(int on)
Enable or disable hash clock.
Divided by 4 of XO/32MRC. This is default.
Definition: hal_clk.h:116
void hal_clk_efuse_en(int en)
Enable or disable Efuse clock.
void hal_clk_audio_resample_en(int en)
Enable or disable audio reampling related clock.
clk_d0_div
Clock D0 domain divider.
Definition: hal_clk.h:34
void hal_clk_si2s_set(int ext_clk)
Set Slave I2S clock source.
PDM clock.
Definition: hal_clk.h:78
uint32_t hal_clk_sadc_get(void)
Get SADC clock.
uint32_t hal_clk_d2_get(void)
Get D2 domanin clock.
void hal_clk_32k(int clk_src)
Select 32k clock source.
clk_d1_div
Clock D1 domain divider.
Definition: hal_clk.h:42
clk_efuse_div
Efuse clock divider.
Definition: hal_clk.h:82
clk_qspi_div
QSPI serial clock divider.
Definition: hal_clk.h:102
clk_d2_div
Clock D2 domain divider.
Definition: hal_clk.h:52
int hal_clk_systick_mux(int mux)
Set Inplay's Systick clock.
Divided by 8 of XO/32MRC.
Definition: hal_clk.h:118
void hal_clk_ble_en(int on)
Enable or disable BLE clock.
uint32_t hal_clk_d1_get(void)
Get D1 domanin clock.
clk_tim_div
Timer clock 1 divider.
Definition: hal_clk.h:62
void hal_clk_audio_output(int mux)
Set audio output (Speaker/Sigma Delta) clock mux.