21#if defined(LIBOPENCM3_PMC_H)
23#ifndef LIBOPENCM3_PMC_COMMON_ALL_H
24#define LIBOPENCM3_PMC_COMMON_ALL_H
31#define PMC_SCER MMIO32(PMC_BASE + 0x0000)
34#define PMC_SCDR MMIO32(PMC_BASE + 0x0004)
37#define PMC_SCSR MMIO32(PMC_BASE + 0x0008)
40#define CKGR_MOR MMIO32(PMC_BASE + 0x0020)
43#define CKGR_MCFR MMIO32(PMC_BASE + 0x0024)
46#define CKGR_PLLAR MMIO32(PMC_BASE + 0x0028)
49#define PMC_MCKR MMIO32(PMC_BASE + 0x0030)
52#define PMC_PCK0 MMIO32(PMC_BASE + 0x0040)
55#define PMC_PCK1 MMIO32(PMC_BASE + 0x0044)
58#define PMC_PCK2 MMIO32(PMC_BASE + 0x0048)
61#define PMC_IER MMIO32(PMC_BASE + 0x0060)
64#define PMC_IDR MMIO32(PMC_BASE + 0x0064)
67#define PMC_SR MMIO32(PMC_BASE + 0x0068)
70#define PMC_IMR MMIO32(PMC_BASE + 0x006C)
73#define PMC_FSMR MMIO32(PMC_BASE + 0x0070)
76#define PMC_FSPR MMIO32(PMC_BASE + 0x0074)
79#define PMC_FOCR MMIO32(PMC_BASE + 0x0078)
82#define PMC_WPMR MMIO32(PMC_BASE + 0x00E4)
85#define PMC_WPSR MMIO32(PMC_BASE + 0x00E8)
94#define PMC_SCER_PCK0 (0x01 << 8)
95#define PMC_SCER_PCK1 (0x01 << 9)
96#define PMC_SCER_PCK2 (0x01 << 10)
102#define PMC_SCDR_PCK0 (0x01 << 8)
103#define PMC_SCDR_PCK1 (0x01 << 9)
104#define PMC_SCDR_PCK2 (0x01 << 10)
110#define PMC_SCSR_PCK0 (0x01 << 8)
111#define PMC_SCSR_PCK1 (0x01 << 9)
112#define PMC_SCSR_PCK2 (0x01 << 10)
122#define CKGR_MOR_CFDEN (0x01 << 25)
125#define CKGR_MOR_MOSCSEL (0x01 << 24)
128#define CKGR_MOR_KEY (0x37 << 16)
131#define CKGR_MOR_MOSCXTST_SHIFT 8
132#define CKGR_MOR_MOSCXTST_MASK (0xFF << 8)
135#define CKGR_MOR_MOSCRCF_SHIFT 4
136#define CKGR_MOR_MOSCRCF_MASK (0x07 << CKGR_MOR_MOSCRCF_SHIFT)
139#define CKGR_MOR_MOSCRCF_4MHZ (0 << CKGR_MOR_MOSCRCF_SHIFT)
140#define CKGR_MOR_MOSCRCF_8MHZ (1 << CKGR_MOR_MOSCRCF_SHIFT)
141#define CKGR_MOR_MOSCRCF_12MHZ (2 << CKGR_MOR_MOSCRCF_SHIFT)
144#define CKGR_MOR_MOSCRCEN (0x01 << 3)
147#define CKGR_MOR_MOSCXTBY (0x01 << 1)
150#define CKGR_MOR_MOSCXTEN (0x01 << 0)
156#define CKGR_MCFR_MAINFRDY (0x01 << 16)
159#define CKGR_MCFR_MAINF_SHIFT 0
160#define CKGR_MCFR_MAINF_MASK (0xFFFF << CKGR_MCFR_MAINF_SHIFT)
166#define CKGR_PLLAR_ONE (0x01 << 29)
169#define CKGR_PLLAR_MULA_SHIFT 16
170#define CKGR_PLLAR_MULA_MASK (0x7FF << CKGR_PLLAR_MULA_SHIFT)
173#define CKGR_PLLAR_PLLACOUNT_SHIFT 8
174#define CKGR_PLLAR_PLLACOUNT_MASK (0x3F << CKGR_PLLAR_PLLACOUNT_SHIFT)
177#define CKGR_PLLAR_DIVA_SHIFT 0
178#define CKGR_PLLAR_DIVA_MASK (0xFF << CKGR_PLLAR_DIVA_SHIFT)
184#define PMC_MCKR_PRES_SHIFT 4
185#define PMC_MCKR_PRES_MASK (0x07 << PMC_MCKR_PRES_SHIFT)
186#define PMC_MCKR_PRES_CLK_1 (0 << PMC_MCKR_PRES_SHIFT)
187#define PMC_MCKR_PRES_CLK_2 (1 << PMC_MCKR_PRES_SHIFT)
188#define PMC_MCKR_PRES_CLK_4 (2 << PMC_MCKR_PRES_SHIFT)
189#define PMC_MCKR_PRES_CLK_8 (3 << PMC_MCKR_PRES_SHIFT)
190#define PMC_MCKR_PRES_CLK_16 (4 << PMC_MCKR_PRES_SHIFT)
191#define PMC_MCKR_PRES_CLK_32 (5 << PMC_MCKR_PRES_SHIFT)
192#define PMC_MCKR_PRES_CLK_64 (6 << PMC_MCKR_PRES_SHIFT)
193#define PMC_MCKR_PRES_CLK_3 (7 << PMC_MCKR_PRES_SHIFT)
196#define PMC_MCKR_CSS_SHIFT 0
197#define PMC_MCKR_CSS_MASK (0x03 << PMC_MCKR_CSS_SHIFT)
198#define PMC_MCKR_CSS_SLOW_CLK (0 << PMC_MCKR_CSS_SHIFT)
199#define PMC_MCKR_CSS_MAIN_CLK (1 << PMC_MCKR_CSS_SHIFT)
200#define PMC_MCKR_CSS_PLLA_CLK (2 << PMC_MCKR_CSS_SHIFT)
206#define PMC_PCK0_PRES_SHIFT 4
207#define PMC_PCK0_PRES_MASK (0x07 << PMC_PCK0_PRES_SHIFT)
208#define PMC_PCK0_PRES_CLK_1 (0 << PMC_PCK0_PRES_SHIFT)
209#define PMC_PCK0_PRES_CLK_2 (1 << PMC_PCK0_PRES_SHIFT)
210#define PMC_PCK0_PRES_CLK_4 (2 << PMC_PCK0_PRES_SHIFT)
211#define PMC_PCK0_PRES_CLK_8 (3 << PMC_PCK0_PRES_SHIFT)
212#define PMC_PCK0_PRES_CLK_16 (4 << PMC_PCK0_PRES_SHIFT)
213#define PMC_PCK0_PRES_CLK_32 (5 << PMC_PCK0_PRES_SHIFT)
214#define PMC_PCK0_PRES_CLK_64 (6 << PMC_PCK0_PRES_SHIFT)
217#define PMC_PCK0_CSS_SHIFT 0
218#define PMC_PCK0_CSS_MASK (0x07 << PMC_PCK0_CSS_SHIFT)
219#define PMC_PCK0_CSS_SLOW_CLK (0 << PMC_PCK0_CSS_SHIFT)
220#define PMC_PCK0_CSS_MAIN_CLK (1 << PMC_PCK0_CSS_SHIFT)
221#define PMC_PCK0_CSS_PLLA_CLK (2 << PMC_PCK0_CSS_SHIFT)
222#define PMC_PCK0_CSS_MCK (4 << PMC_PCK0_CSS_SHIFT)
228#define PMC_PCK1_PRES_SHIFT 4
229#define PMC_PCK1_PRES_MASK (0x07 << PMC_PCK1_PRES_SHIFT)
230#define PMC_PCK1_PRES_CLK_1 (0 << PMC_PCK1_PRES_SHIFT)
231#define PMC_PCK1_PRES_CLK_2 (1 << PMC_PCK1_PRES_SHIFT)
232#define PMC_PCK1_PRES_CLK_4 (2 << PMC_PCK1_PRES_SHIFT)
233#define PMC_PCK1_PRES_CLK_8 (3 << PMC_PCK1_PRES_SHIFT)
234#define PMC_PCK1_PRES_CLK_16 (4 << PMC_PCK1_PRES_SHIFT)
235#define PMC_PCK1_PRES_CLK_32 (5 << PMC_PCK1_PRES_SHIFT)
236#define PMC_PCK1_PRES_CLK_64 (6 << PMC_PCK1_PRES_SHIFT)
239#define PMC_PCK1_CSS_SHIFT 0
240#define PMC_PCK1_CSS_MASK (0x07 << PMC_PCK1_CSS_SHIFT)
241#define PMC_PCK1_CSS_SLOW_CLK (0 << PMC_PCK1_CSS_SHIFT)
242#define PMC_PCK1_CSS_MAIN_CLK (1 << PMC_PCK1_CSS_SHIFT)
243#define PMC_PCK1_CSS_PLLA_CLK (2 << PMC_PCK1_CSS_SHIFT)
244#define PMC_PCK1_CSS_MCK (4 << PMC_PCK1_CSS_SHIFT)
250#define PMC_PCK2_PRES_SHIFT 4
251#define PMC_PCK2_PRES_MASK (0x07 << PMC_PCK2_PRES_SHIFT)
252#define PMC_PCK2_PRES_CLK_1 (0 << PMC_PCK2_PRES_SHIFT)
253#define PMC_PCK2_PRES_CLK_2 (1 << PMC_PCK2_PRES_SHIFT)
254#define PMC_PCK2_PRES_CLK_4 (2 << PMC_PCK2_PRES_SHIFT)
255#define PMC_PCK2_PRES_CLK_8 (3 << PMC_PCK2_PRES_SHIFT)
256#define PMC_PCK2_PRES_CLK_16 (4 << PMC_PCK2_PRES_SHIFT)
257#define PMC_PCK2_PRES_CLK_32 (5 << PMC_PCK2_PRES_SHIFT)
258#define PMC_PCK2_PRES_CLK_64 (6 << PMC_PCK2_PRES_SHIFT)
261#define PMC_PCK2_CSS_SHIFT 0
262#define PMC_PCK2_CSS_MASK (0x07 << PMC_PCK2_CSS_SHIFT)
263#define PMC_PCK2_CSS_SLOW_CLK (0 << PMC_PCK2_CSS_SHIFT)
264#define PMC_PCK2_CSS_MAIN_CLK (1 << PMC_PCK2_CSS_SHIFT)
265#define PMC_PCK2_CSS_PLLA_CLK (2 << PMC_PCK2_CSS_SHIFT)
266#define PMC_PCK2_CSS_MCK (4 << PMC_PCK2_CSS_SHIFT)
272#define PMC_IER_CFDEV (0x01 << 18)
275#define PMC_IER_MOSCRCS (0x01 << 17)
278#define PMC_IER_MOSCSELS (0x01 << 16)
281#define PMC_IER_PCKRDY2 (0x01 << 10)
284#define PMC_IER_PCKRDY1 (0x01 << 9)
287#define PMC_IER_PCKRDY0 (0x01 << 8)
290#define PMC_IER_MCKRDY (0x01 << 3)
293#define PMC_IER_LOCKA (0x01 << 1)
296#define PMC_IER_MOSCXTS (0x01 << 0)
302#define PMC_IDR_CFDEV (0x01 << 18)
305#define PMC_IDR_MOSCRCS (0x01 << 17)
308#define PMC_IDR_MOSCSELS (0x01 << 16)
311#define PMC_IDR_PCKRDY2 (0x01 << 10)
314#define PMC_IDR_PCKRDY1 (0x01 << 9)
317#define PMC_IDR_PCKRDY0 (0x01 << 8)
320#define PMC_IDR_MCKRDY (0x01 << 3)
323#define PMC_IDR_LOCKA (0x01 << 1)
326#define PMC_IDR_MOSCXTS (0x01 << 0)
332#define PMC_SR_FOS (0x01 << 20)
335#define PMC_SR_CFDS (0x01 << 19)
338#define PMC_SR_CFDEV (0x01 << 18)
341#define PMC_SR_MOSCRCS (0x01 << 17)
344#define PMC_SR_MOSCSELS (0x01 << 16)
347#define PMC_SR_PCKRDY2 (0x01 << 10)
350#define PMC_SR_PCKRDY1 (0x01 << 9)
353#define PMC_SR_PCKRDY0 (0x01 << 8)
356#define PMC_SR_OSCSELS (0x01 << 7)
359#define PMC_SR_MCKRDY (0x01 << 3)
362#define PMC_SR_LOCKA (0x01 << 1)
365#define PMC_SR_MOSCXTS (0x01 << 0)
371#define PMC_IMR_CFDEV (0x01 << 18)
374#define PMC_IMR_MOSCRCS (0x01 << 17)
377#define PMC_IMR_MOSCSELS (0x01 << 16)
380#define PMC_IMR_PCKRDY2 (0x01 << 10)
383#define PMC_IMR_PCKRDY1 (0x01 << 9)
386#define PMC_IMR_PCKRDY0 (0x01 << 8)
389#define PMC_IMR_MCKRDY (0x01 << 3)
392#define PMC_IMR_LOCKA (0x01 << 1)
395#define PMC_IMR_MOSCXTS (0x01 << 0)
401#define PMC_FSMR_LPM (0x01 << 20)
404#define PMC_FSMR_USBAL (0x01 << 18)
407#define PMC_FSMR_RTCAL (0x01 << 17)
410#define PMC_FSMR_RTTAL (0x01 << 16)
413#define PMC_FSMR_FSTT15 (0x01 << 15)
414#define PMC_FSMR_FSTT14 (0x01 << 14)
415#define PMC_FSMR_FSTT13 (0x01 << 13)
416#define PMC_FSMR_FSTT12 (0x01 << 12)
417#define PMC_FSMR_FSTT11 (0x01 << 11)
418#define PMC_FSMR_FSTT10 (0x01 << 10)
419#define PMC_FSMR_FSTT9 (0x01 << 9)
420#define PMC_FSMR_FSTT8 (0x01 << 8)
421#define PMC_FSMR_FSTT7 (0x01 << 7)
422#define PMC_FSMR_FSTT6 (0x01 << 6)
423#define PMC_FSMR_FSTT5 (0x01 << 5)
424#define PMC_FSMR_FSTT4 (0x01 << 4)
425#define PMC_FSMR_FSTT3 (0x01 << 3)
426#define PMC_FSMR_FSTT2 (0x01 << 2)
427#define PMC_FSMR_FSTT1 (0x01 << 1)
428#define PMC_FSMR_FSTT0 (0x01 << 0)
434#define PMC_FSPR_FSTP15 (0x01 << 15)
435#define PMC_FSPR_FSTP14 (0x01 << 14)
436#define PMC_FSPR_FSTP13 (0x01 << 13)
437#define PMC_FSPR_FSTP12 (0x01 << 12)
438#define PMC_FSPR_FSTP11 (0x01 << 11)
439#define PMC_FSPR_FSTP10 (0x01 << 10)
440#define PMC_FSPR_FSTP9 (0x01 << 9)
441#define PMC_FSPR_FSTP8 (0x01 << 8)
442#define PMC_FSPR_FSTP7 (0x01 << 7)
443#define PMC_FSPR_FSTP6 (0x01 << 6)
444#define PMC_FSPR_FSTP5 (0x01 << 5)
445#define PMC_FSPR_FSTP4 (0x01 << 4)
446#define PMC_FSPR_FSTP3 (0x01 << 3)
447#define PMC_FSPR_FSTP2 (0x01 << 2)
448#define PMC_FSPR_FSTP1 (0x01 << 1)
449#define PMC_FSPR_FSTP0 (0x01 << 0)
455#define PMC_FOCR_FOCLR (0x01 << 0)
461#define PMC_WPMR_WPKEY_SHIFT 8
462#define PMC_WPMR_WPKEY (0x504D43 << PMC_WPMR_WPKEY_SHIFT)
465#define PMC_WPMR_WPEN (0x01 << 0)
471#define PMC_WPSR_WPVSRC_SHIFT 8
472#define PMC_WPSR_WPVSRC_MASK (0xFFFF << PMC_WPSR_WPVSRC_SHIFT)
475#define PMC_WPSR_WPVS (0x01 << 0)
500#warning "pmc_common_all.h should not be included explicitly, only via pmc.h"
void pmc_clock_setup_in_rc_4mhz_out_84mhz(void)
void pmc_xtal_enable(bool en, uint8_t startup_time)
void pmc_peripheral_clock_enable(uint8_t pid)
uint32_t pmc_mck_frequency
Default peripheral clock frequency after reset.
void pmc_clock_setup_in_xtal_12mhz_out_84mhz(void)
void pmc_peripheral_clock_disable(uint8_t pid)
void pmc_plla_config(uint8_t mul, uint8_t div)
void pmc_mck_set_source(enum mck_src src)