27 #ifndef LPC17XX_CLKPWR_H_
28 #define LPC17XX_CLKPWR_H_
48 #define CLKPWR_PCLKSEL_WDT ((uint32_t)(0))
50 #define CLKPWR_PCLKSEL_TIMER0 ((uint32_t)(2))
52 #define CLKPWR_PCLKSEL_TIMER1 ((uint32_t)(4))
54 #define CLKPWR_PCLKSEL_UART0 ((uint32_t)(6))
56 #define CLKPWR_PCLKSEL_UART1 ((uint32_t)(8))
58 #define CLKPWR_PCLKSEL_PWM1 ((uint32_t)(12))
60 #define CLKPWR_PCLKSEL_I2C0 ((uint32_t)(14))
62 #define CLKPWR_PCLKSEL_SPI ((uint32_t)(16))
64 #define CLKPWR_PCLKSEL_SSP1 ((uint32_t)(20))
66 #define CLKPWR_PCLKSEL_DAC ((uint32_t)(22))
68 #define CLKPWR_PCLKSEL_ADC ((uint32_t)(24))
70 #define CLKPWR_PCLKSEL_CAN1 ((uint32_t)(26))
72 #define CLKPWR_PCLKSEL_CAN2 ((uint32_t)(28))
74 #define CLKPWR_PCLKSEL_ACF ((uint32_t)(30))
76 #define CLKPWR_PCLKSEL_QEI ((uint32_t)(32))
78 #define CLKPWR_PCLKSEL_PCB ((uint32_t)(36))
80 #define CLKPWR_PCLKSEL_I2C1 ((uint32_t)(38))
82 #define CLKPWR_PCLKSEL_SSP0 ((uint32_t)(42))
84 #define CLKPWR_PCLKSEL_TIMER2 ((uint32_t)(44))
86 #define CLKPWR_PCLKSEL_TIMER3 ((uint32_t)(46))
88 #define CLKPWR_PCLKSEL_UART2 ((uint32_t)(48))
90 #define CLKPWR_PCLKSEL_UART3 ((uint32_t)(50))
92 #define CLKPWR_PCLKSEL_I2C2 ((uint32_t)(52))
94 #define CLKPWR_PCLKSEL_I2S ((uint32_t)(54))
96 #define CLKPWR_PCLKSEL_RIT ((uint32_t)(58))
98 #define CLKPWR_PCLKSEL_SYSCON ((uint32_t)(60))
100 #define CLKPWR_PCLKSEL_MC ((uint32_t)(62))
107 #define CLKPWR_PCLKSEL_CCLK_DIV_4 ((uint32_t)(0))
109 #define CLKPWR_PCLKSEL_CCLK_DIV_1 ((uint32_t)(1))
111 #define CLKPWR_PCLKSEL_CCLK_DIV_2 ((uint32_t)(2))
118 #define CLKPWR_PCONP_PCTIM0 ((uint32_t)(1<<1))
120 #define CLKPWR_PCONP_PCTIM1 ((uint32_t)(1<<2))
122 #define CLKPWR_PCONP_PCUART0 ((uint32_t)(1<<3))
124 #define CLKPWR_PCONP_PCUART1 ((uint32_t)(1<<4))
126 #define CLKPWR_PCONP_PCPWM1 ((uint32_t)(1<<6))
128 #define CLKPWR_PCONP_PCI2C0 ((uint32_t)(1<<7))
130 #define CLKPWR_PCONP_PCSPI ((uint32_t)(1<<8))
132 #define CLKPWR_PCONP_PCRTC ((uint32_t)(1<<9))
134 #define CLKPWR_PCONP_PCSSP1 ((uint32_t)(1<<10))
136 #define CLKPWR_PCONP_PCAD ((uint32_t)(1<<12))
138 #define CLKPWR_PCONP_PCAN1 ((uint32_t)(1<<13))
140 #define CLKPWR_PCONP_PCAN2 ((uint32_t)(1<<14))
142 #define CLKPWR_PCONP_PCGPIO ((uint32_t)(1<<15))
144 #define CLKPWR_PCONP_PCRIT ((uint32_t)(1<<16))
146 #define CLKPWR_PCONP_PCMC ((uint32_t)(1<<17))
148 #define CLKPWR_PCONP_PCQEI ((uint32_t)(1<<18))
150 #define CLKPWR_PCONP_PCI2C1 ((uint32_t)(1<<19))
152 #define CLKPWR_PCONP_PCSSP0 ((uint32_t)(1<<21))
154 #define CLKPWR_PCONP_PCTIM2 ((uint32_t)(1<<22))
156 #define CLKPWR_PCONP_PCTIM3 ((uint32_t)(1<<23))
158 #define CLKPWR_PCONP_PCUART2 ((uint32_t)(1<<24))
160 #define CLKPWR_PCONP_PCUART3 ((uint32_t)(1<<25))
162 #define CLKPWR_PCONP_PCI2C2 ((uint32_t)(1<<26))
164 #define CLKPWR_PCONP_PCI2S ((uint32_t)(1<<27))
166 #define CLKPWR_PCONP_PCGPDMA ((uint32_t)(1<<29))
168 #define CLKPWR_PCONP_PCENET ((uint32_t)(1<<30))
170 #define CLKPWR_PCONP_PCUSB ((uint32_t)(1<<31))
186 #define CLKPWR_CLKSRCSEL_CLKSRC_IRC ((uint32_t)(0x00))
188 #define CLKPWR_CLKSRCSEL_CLKSRC_MAINOSC ((uint32_t)(0x01))
190 #define CLKPWR_CLKSRCSEL_CLKSRC_RTC ((uint32_t)(0x02))
192 #define CLKPWR_CLKSRCSEL_BITMASK ((uint32_t)(0x03))
199 #define CLKPWR_CLKOUTCFG_CLKOUTSEL_CPU ((uint32_t)(0x00))
201 #define CLKPWR_CLKOUTCFG_CLKOUTSEL_MAINOSC ((uint32_t)(0x01))
203 #define CLKPWR_CLKOUTCFG_CLKOUTSEL_RC ((uint32_t)(0x02))
205 #define CLKPWR_CLKOUTCFG_CLKOUTSEL_USB ((uint32_t)(0x03))
207 #define CLKPWR_CLKOUTCFG_CLKOUTSEL_RTC ((uint32_t)(0x04))
209 #define CLKPWR_CLKOUTCFG_CLKOUTDIV(n) ((uint32_t)((n&0x0F)<<4))
211 #define CLKPWR_CLKOUTCFG_CLKOUT_EN ((uint32_t)(1<<8))
213 #define CLKPWR_CLKOUTCFG_CLKOUT_ACT ((uint32_t)(1<<9))
215 #define CLKPWR_CLKOUTCFG_BITMASK ((uint32_t)(0x3FF))
221 #define CLKPWR_PLL0CON_ENABLE ((uint32_t)(0x01))
223 #define CLKPWR_PLL0CON_CONNECT ((uint32_t)(0x02))
225 #define CLKPWR_PLL0CON_BITMASK ((uint32_t)(0x03))
231 #define CLKPWR_PLL0CFG_MSEL(n) ((uint32_t)(n&0x7FFF))
233 #define CLKPWR_PLL0CFG_NSEL(n) ((uint32_t)((n<<16)&0xFF0000))
235 #define CLKPWR_PLL0CFG_BITMASK ((uint32_t)(0xFF7FFF))
242 #define CLKPWR_PLL0STAT_MSEL(n) ((uint32_t)(n&0x7FFF))
244 #define CLKPWR_PLL0STAT_NSEL(n) ((uint32_t)((n>>16)&0xFF))
246 #define CLKPWR_PLL0STAT_PLLE ((uint32_t)(1<<24))
248 #define CLKPWR_PLL0STAT_PLLC ((uint32_t)(1<<25))
250 #define CLKPWR_PLL0STAT_PLOCK ((uint32_t)(1<<26))
256 #define CLKPWR_PLL0FEED_BITMASK ((uint32_t)0xFF)
262 #define CLKPWR_PLL1CON_ENABLE ((uint32_t)(0x01))
264 #define CLKPWR_PLL1CON_CONNECT ((uint32_t)(0x02))
266 #define CLKPWR_PLL1CON_BITMASK ((uint32_t)(0x03))
272 #define CLKPWR_PLL1CFG_MSEL(n) ((uint32_t)(n&0x1F))
274 #define CLKPWR_PLL1CFG_PSEL(n) ((uint32_t)((n&0x03)<<5))
276 #define CLKPWR_PLL1CFG_BITMASK ((uint32_t)(0x7F))
282 #define CLKPWR_PLL1STAT_MSEL(n) ((uint32_t)(n&0x1F))
284 #define CLKPWR_PLL1STAT_PSEL(n) ((uint32_t)((n>>5)&0x03))
286 #define CLKPWR_PLL1STAT_PLLE ((uint32_t)(1<<8))
288 #define CLKPWR_PLL1STAT_PLLC ((uint32_t)(1<<9))
290 #define CLKPWR_PLL1STAT_PLOCK ((uint32_t)(1<<10))
296 #define CLKPWR_PLL1FEED_BITMASK ((uint32_t)0xFF)
302 #define CLKPWR_CCLKCFG_BITMASK ((uint32_t)(0xFF))
308 #define CLKPWR_USBCLKCFG_BITMASK ((uint32_t)(0x0F))
314 #define CLKPWR_IRCTRIM_BITMASK ((uint32_t)(0x0F))
320 #define CLKPWR_PCLKSEL0_BITMASK ((uint32_t)(0xFFF3F3FF))
322 #define CLKPWR_PCLKSEL1_BITMASK ((uint32_t)(0xFCF3F0F3))
326 #define CLKPWR_PCLKSEL_SET(p,n) _SBF(p,n)
328 #define CLKPWR_PCLKSEL_BITMASK(p) _SBF(p,0x03)
330 #define CLKPWR_PCLKSEL_GET(p, n) ((uint32_t)((n>>p)&0x03))
336 #define CLKPWR_PCON_PM0 ((uint32_t)(1<<0))
338 #define CLKPWR_PCON_PM1 ((uint32_t)(1<<1))
340 #define CLKPWR_PCON_BODPDM ((uint32_t)(1<<2))
342 #define CLKPWR_PCON_BOGD ((uint32_t)(1<<3))
344 #define CLKPWR_PCON_BORD ((uint32_t)(1<<4))
346 #define CLKPWR_PCON_SMFLAG ((uint32_t)(1<<8))
348 #define CLKPWR_PCON_DSFLAG ((uint32_t)(1<<9))
350 #define CLKPWR_PCON_PDFLAG ((uint32_t)(1<<10))
352 #define CLKPWR_PCON_DPDFLAG ((uint32_t)(1<<11))
358 #define CLKPWR_PCONP_BITMASK 0xEFEFF7DE