sama_pmc.h 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @file SAMA5D2x/sama_pmc.h
  15. * @brief PMC helper driver header.
  16. *
  17. * @addtogroup SAMA5D2x_PMC
  18. * @{
  19. */
  20. #ifndef _SAMA_PMC_
  21. #define _SAMA_PMC_
  22. /*===========================================================================*/
  23. /* Driver constants. */
  24. /*===========================================================================*/
  25. /*===========================================================================*/
  26. /* Driver pre-compile time settings. */
  27. /*===========================================================================*/
  28. /*===========================================================================*/
  29. /* Derived constants and error checks. */
  30. /*===========================================================================*/
  31. /*===========================================================================*/
  32. /* Driver data structures and types. */
  33. /*===========================================================================*/
  34. /*===========================================================================*/
  35. /* Driver macros. */
  36. /*===========================================================================*/
  37. /**
  38. * @name Generic PMC operations
  39. * @{
  40. */
  41. #if SAMA_HAL_IS_SECURE
  42. /**
  43. * @brief Enable write protection on PMC registers block.
  44. *
  45. * @notapi
  46. */
  47. #define pmcEnableWP() { \
  48. PMC->PMC_WPMR = PMC_WPMR_WPKEY_PASSWD | PMC_WPMR_WPEN; \
  49. }
  50. /**
  51. * @brief Disable write protection on PMC registers block.
  52. *
  53. * @notapi
  54. */
  55. #define pmcDisableWP() { \
  56. PMC->PMC_WPMR = PMC_WPMR_WPKEY_PASSWD; \
  57. }
  58. /**
  59. * @brief Enables the clock of one or more peripheral having ID from 2 to
  60. * 31.
  61. *
  62. * @param[in] mask PCER0 peripherals mask
  63. *
  64. * @api
  65. */
  66. #define pmcEnablePidLow(mask) { \
  67. pmcDisableWP(); \
  68. PMC->PMC_PCER0 = (mask); \
  69. pmcEnableWP(); \
  70. }
  71. /**
  72. * @brief Disables the clock of one or more peripheral having ID from 2 to
  73. * 31.
  74. *
  75. * @param[in] mask PCDR0 peripherals mask
  76. *
  77. * @api
  78. */
  79. #define pmcDisablePidLow(mask) { \
  80. pmcDisableWP(); \
  81. PMC->PMC_PCDR0 = (mask); \
  82. pmcEnableWP(); \
  83. }
  84. /**
  85. * @brief Enables the clock of one or more peripheral having ID from 32 to
  86. * 63.
  87. *
  88. * @param[in] mask PCER1 peripherals mask
  89. *
  90. * @api
  91. */
  92. #define pmcEnablePidHigh(mask) { \
  93. pmcDisableWP(); \
  94. PMC->PMC_PCER1 = (mask); \
  95. pmcEnableWP(); \
  96. }
  97. /**
  98. * @brief Disables the clock of one or more peripheral having ID from 32 to
  99. * 63.
  100. *
  101. * @param[in] mask PCDR1 peripherals mask
  102. *
  103. * @api
  104. */
  105. #define pmcDisablePidHigh(mask) { \
  106. pmcDisableWP(); \
  107. PMC->PMC_PCDR1 = (mask); \
  108. pmcEnableWP(); \
  109. }
  110. /**
  111. * @brief Enables the generic clock of a peripheral.
  112. *
  113. * @param[in] mask ID peripherals
  114. *
  115. * @api
  116. */
  117. #define pmcEnableGclk(id) { \
  118. osalDbgCheck(id < ID_PERIPH_COUNT); \
  119. pmcDisableWP(); \
  120. PMC->PMC_PCR = PMC_PCR_PID(id); \
  121. uint32_t pcr = PMC->PMC_PCR; \
  122. PMC->PMC_PCR = pcr | PMC_PCR_CMD | PMC_PCR_GCKEN; \
  123. while (!(PMC->PMC_SR & PMC_SR_GCKRDY)); \
  124. pmcEnableWP(); \
  125. }
  126. /**
  127. * @brief Disable the generic clock of a peripheral.
  128. *
  129. * @param[in] mask ID peripherals
  130. *
  131. * @api
  132. */
  133. #define pmcDisableGclk(id) { \
  134. osalDbgCheck(id < ID_PERIPH_COUNT); \
  135. pmcDisableWP(); \
  136. PMC->PMC_PCR = PMC_PCR_PID(id); \
  137. uint32_t pcr = PMC->PMC_PCR; \
  138. PMC->PMC_PCR = PMC_PCR_CMD | (pcr & ~(PMC_PCR_GCKEN)); \
  139. pmcEnableWP(); \
  140. }
  141. /**
  142. * @brief Configure the generic clock of a peripheral.
  143. *
  144. * @param[in] id ID peripherals mask
  145. * @param[in] clock_source Clock source
  146. * @param[in] div Divider
  147. *
  148. * @api
  149. */
  150. #define pmcConfigGclk(id, clock_source, div) { \
  151. osalDbgCheck(id < ID_PERIPH_COUNT); \
  152. osalDbgCheck(!(clock_source & ~PMC_PCR_GCKCSS_Msk)); \
  153. osalDbgCheck((div > 0)); \
  154. osalDbgCheck(!(div << PMC_PCR_GCKDIV_Pos & ~PMC_PCR_GCKDIV_Msk)); \
  155. pmcDisableGclk(id); \
  156. pmcDisableWP(); \
  157. PMC->PMC_PCR = PMC_PCR_PID(id); \
  158. uint32_t pcr = PMC->PMC_PCR & ~(PMC_PCR_GCKCSS_Msk | PMC_PCR_GCKDIV_Msk); \
  159. PMC->PMC_PCR = pcr | clock_source | PMC_PCR_CMD | PMC_PCR_GCKDIV(div - 1);\
  160. pmcEnableWP(); \
  161. }
  162. /**
  163. * @brief Enable the peripheral clock of a peripheral.
  164. *
  165. * @param[in] id ID peripherals mask
  166. *
  167. * @api
  168. */
  169. #define pmcEnablePeripheral(id) { \
  170. osalDbgCheck(id < ID_PERIPH_COUNT); \
  171. pmcDisableWP(); \
  172. PMC->PMC_PCR = PMC_PCR_PID(id); \
  173. uint32_t pcr = PMC->PMC_PCR; \
  174. PMC->PMC_PCR = pcr | PMC_PCR_CMD | PMC_PCR_EN; \
  175. pmcEnableWP(); \
  176. }
  177. /**
  178. * @brief Disable the peripheral clock of a peripheral.
  179. *
  180. * @param[in] id ID peripherals mask
  181. *
  182. * @api
  183. */
  184. #define pmcDisablePeripheral(id) { \
  185. osalDbgCheck(id < ID_PERIPH_COUNT); \
  186. pmcDisableWP(); \
  187. PMC->PMC_PCR = PMC_PCR_PID(id); \
  188. PMC->PMC_PCR = (PMC->PMC_PCR & ~PMC_PCR_EN) | PMC_PCR_CMD; \
  189. pmcEnableWP(); \
  190. }
  191. /**
  192. * @brief Configure the Audio clock.
  193. *
  194. * @param[in] nd Loop Divider Ratio
  195. * @param[in] qdpmc Output Divider Ratio for PMC Clock
  196. * @param[in] fracr Fractional Loop Divider Setting
  197. * @param[in] div Divider Value
  198. * @param[in] qaudio Output Divider Ratio for Pad Clock
  199. *
  200. * @api
  201. */
  202. #define pmcConfigAudio(nd,qdpmc,fracr,div,qdaudio) { \
  203. /* Reset audio clock */ \
  204. pmcDisableWP(); \
  205. PMC->PMC_AUDIO_PLL0 &= ~PMC_AUDIO_PLL0_RESETN; \
  206. PMC->PMC_AUDIO_PLL0 |= PMC_AUDIO_PLL0_RESETN; \
  207. /* Configure values */ \
  208. PMC->PMC_AUDIO_PLL0 = (PMC->PMC_AUDIO_PLL0 & \
  209. ~PMC_AUDIO_PLL0_PLLFLT_Msk & \
  210. ~PMC_AUDIO_PLL0_ND_Msk & \
  211. ~PMC_AUDIO_PLL0_QDPMC_Msk) | \
  212. PMC_AUDIO_PLL0_PLLFLT_STD | \
  213. PMC_AUDIO_PLL0_ND(nd) | \
  214. PMC_AUDIO_PLL0_QDPMC(qdpmc); \
  215. PMC->PMC_AUDIO_PLL1 = (PMC->PMC_AUDIO_PLL1 & \
  216. ~PMC_AUDIO_PLL1_FRACR_Msk & \
  217. ~PMC_AUDIO_PLL1_DIV_Msk & \
  218. ~PMC_AUDIO_PLL1_QDAUDIO_Msk) | \
  219. PMC_AUDIO_PLL1_FRACR(fracr) | \
  220. PMC_AUDIO_PLL1_DIV(div)| \
  221. PMC_AUDIO_PLL1_QDAUDIO(qdaudio); \
  222. pmcEnableWP(); \
  223. }
  224. /**
  225. * @brief Enable the audio clock of a audio peripheral.
  226. *
  227. * @param[in] pmcClock If set TRUE enable the PMC clock
  228. * @param[in] padClock If set TRUE enable the PAD clock
  229. *
  230. * @api
  231. */
  232. #define pmcEnableAudio(pmcClock, padClock) { \
  233. pmcDisableWP(); \
  234. uint32_t bits = PMC_AUDIO_PLL0_PLLEN | PMC_AUDIO_PLL0_RESETN; \
  235. uint32_t nbits = 0; \
  236. if(padClock) \
  237. bits |= PMC_AUDIO_PLL0_PADEN; \
  238. else \
  239. nbits |= PMC_AUDIO_PLL0_PADEN; \
  240. if(pmcClock) \
  241. bits |= PMC_AUDIO_PLL0_PMCEN; \
  242. else \
  243. nbits |= PMC_AUDIO_PLL0_PMCEN; \
  244. PMC->PMC_AUDIO_PLL0 = (PMC->PMC_AUDIO_PLL0 & ~nbits) | bits; \
  245. /* Wait for the Audio PLL Startup Time (tSTART = 100 usec) */ \
  246. chSysPolledDelayX(US2RTC(SAMA_PCK, 100)); \
  247. pmcEnableWP(); \
  248. }
  249. /**
  250. * @brief Disable the audio clock of a audio peripheral.
  251. *
  252. * @api
  253. */
  254. #define pmcDisableAudio(){ \
  255. pmcDisableWP(); \
  256. PMC->PMC_AUDIO_PLL0 &= ~(PMC_AUDIO_PLL0_PLLEN | PMC_AUDIO_PLL0_RESETN | \
  257. PMC_AUDIO_PLL0_PADEN | PMC_AUDIO_PLL0_PMCEN); \
  258. pmcEnableWP(); \
  259. }
  260. #else
  261. #include "tsclient.h"
  262. static inline uint32_t readPMCr(uint32_t regOffset)
  263. {
  264. sec_reg_val_t secr;
  265. secr.reg = regOffset;
  266. secr.value = 0;
  267. (void) tsInvoke0((ts_service_t)TS_FC_PMC_RD,
  268. (ts_params_area_t)&secr, sizeof secr, TS_TIMEINT_1000_US);
  269. return secr.value;
  270. }
  271. static inline void writePMCr(uint32_t regOffset, uint32_t v)
  272. {
  273. sec_reg_val_t secr;
  274. secr.reg = regOffset;
  275. secr.value = v;
  276. (void) tsInvoke0((ts_service_t)TS_FC_PMC_WR,
  277. (ts_params_area_t)&secr, sizeof secr, TS_TIMEINT_1000_US);
  278. return;
  279. }
  280. /**
  281. * @brief Enables the clock of one or more peripheral having ID from 2 to
  282. * 31.
  283. *
  284. * @param[in] mask PCER0 peripherals mask
  285. *
  286. * @api
  287. */
  288. #define pmcEnablePidLow(mask) { \
  289. writePMCr(offsetof(Pmc, PMC_PCER0), (mask)); \
  290. }
  291. /**
  292. * @brief Disables the clock of one or more peripheral having ID from 2 to
  293. * 31.
  294. *
  295. * @param[in] mask PCDR0 peripherals mask
  296. *
  297. * @api
  298. */
  299. #define pmcDisablePidLow(mask) { \
  300. writePMCr(offsetof(Pmc, PMC_PCDR0), (mask)); \
  301. }
  302. /**
  303. * @brief Enables the clock of one or more peripheral having ID from 32 to
  304. * 63.
  305. *
  306. * @param[in] mask PCER1 peripherals mask
  307. *
  308. * @api
  309. */
  310. #define pmcEnablePidHigh(mask) { \
  311. writePMCr(offsetof(Pmc, PMC_PCER1), (mask)); \
  312. }
  313. /**
  314. * @brief Disables the clock of one or more peripheral having ID from 32 to
  315. * 63.
  316. *
  317. * @param[in] mask PCDR1 peripherals mask
  318. *
  319. * @api
  320. */
  321. #define pmcDisablePidHigh(mask) { \
  322. writePMCr(offsetof(Pmc, PMC_PCDR1), (mask)); \
  323. }
  324. /**
  325. * @brief Enables the generic clock of a peripheral.
  326. *
  327. * @param[in] mask ID peripherals
  328. *
  329. * @api
  330. */
  331. #define pmcEnableGclk(id) { \
  332. osalDbgCheck(id < ID_PERIPH_COUNT); \
  333. writePMCr(offsetof(Pmc, PMC_PCR), PMC_PCR_PID(id)); \
  334. uint32_t pcr = readPMCr(offsetof(Pmc, PMC_PCR)); \
  335. writePMCr(offsetof(Pmc, PMC_PCR), pcr | PMC_PCR_CMD | PMC_PCR_GCKEN); \
  336. while (!(readPMCr(offsetof(Pmc, PMC_SR)) & PMC_SR_GCKRDY)); \
  337. }
  338. /**
  339. * @brief Disable the generic clock of a peripheral.
  340. *
  341. * @param[in] mask ID peripherals
  342. *
  343. * @api
  344. */
  345. #define pmcDisableGclk(id) { \
  346. osalDbgCheck(id < ID_PERIPH_COUNT); \
  347. writePMCr(offsetof(Pmc, PMC_PCR), PMC_PCR_PID(id)); \
  348. uint32_t pcr = readPMCr(offsetof(Pmc, PMC_PCR)); \
  349. writePMCr(offsetof(Pmc, PMC_PCR), PMC_PCR_CMD | (pcr & ~(PMC_PCR_GCKEN)));\
  350. }
  351. /**
  352. * @brief Configure the generic clock of a peripheral.
  353. *
  354. * @param[in] id ID peripherals mask
  355. * @param[in] clock_source Clock source
  356. * @param[in] div Divider
  357. *
  358. * @api
  359. */
  360. #define pmcConfigGclk(id, clock_source, div) { \
  361. osalDbgCheck(id < ID_PERIPH_COUNT); \
  362. osalDbgCheck(!(clock_source & ~PMC_PCR_GCKCSS_Msk)); \
  363. osalDbgCheck((div > 0)); \
  364. osalDbgCheck(!(div << PMC_PCR_GCKDIV_Pos & ~PMC_PCR_GCKDIV_Msk)); \
  365. pmcDisableGclk(id); \
  366. writePMCr(offsetof(Pmc, PMC_PCR), PMC_PCR_PID(id)); \
  367. uint32_t pcr = readPMCr(offsetof(Pmc, PMC_PCR) & ~(PMC_PCR_GCKCSS_Msk | PMC_PCR_GCKDIV_Msk); \
  368. writePMCr(offsetof(Pmc, PMC_PCR), pcr | clock_source | PMC_PCR_CMD | PMC_PCR_GCKDIV(div - 1));\
  369. }
  370. /**
  371. * @brief Enable the peripheral clock of a peripheral.
  372. *
  373. * @param[in] id ID peripherals mask
  374. *
  375. * @api
  376. */
  377. #define pmcEnablePeripheral(id) { \
  378. osalDbgCheck(id < ID_PERIPH_COUNT); \
  379. writePMCr(offsetof(Pmc, PMC_PCR), PMC_PCR_PID(id)); \
  380. uint32_t pcr = readPMCr(offsetof(Pmc, PMC_PCR)); \
  381. writePMCr(offsetof(Pmc, PMC_PCR), pcr | PMC_PCR_CMD | PMC_PCR_EN); \
  382. }
  383. /**
  384. * @brief Disable the peripheral clock of a peripheral.
  385. *
  386. * @param[in] id ID peripherals mask
  387. *
  388. * @api
  389. */
  390. #define pmcDisablePeripheral(id) { \
  391. osalDbgCheck(id < ID_PERIPH_COUNT); \
  392. writePMCr(offsetof(Pmc, PMC_PCR), PMC_PCR_PID(id)); \
  393. uint32_t pcr = readPMCr(offsetof(Pmc, PMC_PCR)); \
  394. writePMCr(offsetof(Pmc, PMC_PCR), (pcr & ~PMC_PCR_EN) | PMC_PCR_CMD); \
  395. }
  396. /**
  397. * @brief Configure the Audio clock.
  398. *
  399. * @param[in] nd Loop Divider Ratio
  400. * @param[in] qdpmc Output Divider Ratio for PMC Clock
  401. * @param[in] fracr Fractional Loop Divider Setting
  402. * @param[in] div Divider Value
  403. * @param[in] qaudio Output Divider Ratio for Pad Clock
  404. *
  405. * @api
  406. */
  407. #define pmcConfigAudio(nd,qdpmc,fracr,div,qdaudio) { \
  408. /* Reset audio clock */ \
  409. writePMCr(offsetof(Pmc, PMC_AUDIO_PLL0), readPMCr(offsetof(Pmc, PMC_AUDIO_PLL0)) & ~PMC_AUDIO_PLL0_RESETN);\
  410. writePMCr(offsetof(Pmc, PMC_AUDIO_PLL0), readPMCr(offsetof(Pmc, PMC_AUDIO_PLL0)) | PMC_AUDIO_PLL0_RESETN);\
  411. /* Configure values */ \
  412. writePMCr(offsetof(Pmc, PMC_AUDIO_PLL0), (readPMCr(offsetof(Pmc, PMC_AUDIO_PLL0)) &\
  413. ~PMC_AUDIO_PLL0_PLLFLT_Msk & \
  414. ~PMC_AUDIO_PLL0_ND_Msk & \
  415. ~PMC_AUDIO_PLL0_QDPMC_Msk) | \
  416. PMC_AUDIO_PLL0_PLLFLT_STD | \
  417. PMC_AUDIO_PLL0_ND(nd) | \
  418. PMC_AUDIO_PLL0_QDPMC(qdpmc)); \
  419. writePMCr(offsetof(Pmc, PMC_AUDIO_PLL1), (readPMCr(offsetof(Pmc, PMC_AUDIO_PLL1)) &\
  420. ~PMC_AUDIO_PLL1_FRACR_Msk & \
  421. ~PMC_AUDIO_PLL1_DIV_Msk & \
  422. ~PMC_AUDIO_PLL1_QDAUDIO_Msk) | \
  423. PMC_AUDIO_PLL1_FRACR(fracr) | \
  424. PMC_AUDIO_PLL1_DIV(div)| \
  425. PMC_AUDIO_PLL1_QDAUDIO(qdaudio)); \
  426. }
  427. /**
  428. * @brief Enable the audio clock of a audio peripheral.
  429. *
  430. * @param[in] pmcClock If set TRUE enable the PMC clock
  431. * @param[in] padClock If set TRUE enable the PAD clock
  432. *
  433. * @api
  434. */
  435. #define pmcEnableAudio(pmcClock, padClock) { \
  436. uint32_t bits = PMC_AUDIO_PLL0_PLLEN | PMC_AUDIO_PLL0_RESETN; \
  437. uint32_t nbits = 0; \
  438. if(padClock) \
  439. bits |= PMC_AUDIO_PLL0_PADEN; \
  440. else \
  441. nbits |= PMC_AUDIO_PLL0_PADEN; \
  442. if(pmcClock) \
  443. bits |= PMC_AUDIO_PLL0_PMCEN; \
  444. else \
  445. nbits |= PMC_AUDIO_PLL0_PMCEN; \
  446. writePMCr(offsetof(Pmc, PMC_AUDIO_PLL0), (readPMCr(offsetof(Pmc, PMC_AUDIO_PLL0)) & ~nbits) | bits);\
  447. /* Wait for the Audio PLL Startup Time (tSTART = 100 usec) */ \
  448. chSysPolledDelayX(US2RTC(SAMA_PCK, 100)); \
  449. }
  450. /**
  451. * @brief Disable the audio clock of a audio peripheral.
  452. *
  453. * @api
  454. */
  455. #define pmcDisableAudio(){ \
  456. writePMCr(offsetof(Pmc, PMC_AUDIO_PLL0), readPMCr(offsetof(Pmc, PMC_AUDIO_PLL0)) & \
  457. ~(PMC_AUDIO_PLL0_PLLEN | PMC_AUDIO_PLL0_RESETN | \
  458. PMC_AUDIO_PLL0_PADEN | PMC_AUDIO_PLL0_PMCEN)); \
  459. }
  460. #endif
  461. /** @} */
  462. /**
  463. * @name ADC peripherals specific PMC operations
  464. * @{
  465. */
  466. /**
  467. * @brief Enables the PIT peripheral clock.
  468. *
  469. * @api
  470. */
  471. #define pmcEnablePIT() pmcEnablePidLow(ID_PIT_MSK)
  472. /**
  473. * @brief Disables the PIT peripheral clock.
  474. *
  475. * @api
  476. */
  477. #define pmcDisablePIT() pmcDisablePidLow(ID_PIT_MSK)
  478. /**
  479. * @brief Enables the XDMAC0 peripheral clock.
  480. *
  481. * @api
  482. */
  483. #define pmcEnableXDMAC0() pmcEnablePidLow(ID_XDMAC0_MSK)
  484. /**
  485. * @brief Disables the XDMAC0 peripheral clock.
  486. *
  487. * @api
  488. */
  489. #define pmcDisableXDMAC0() pmcDisablePidLow(ID_XDMAC0_MSK)
  490. /**
  491. * @brief Enables the XDMAC1 peripheral clock.
  492. *
  493. * @api
  494. */
  495. #define pmcEnableXDMAC1() pmcEnablePidLow(ID_XDMAC1_MSK)
  496. /**
  497. * @brief Disables the XDMAC1 peripheral clock.
  498. *
  499. * @api
  500. */
  501. #define pmcDisableXDMAC1() pmcDisablePidLow(ID_XDMAC1_MSK)
  502. /**
  503. * @brief Enables the H32MX peripheral clock.
  504. *
  505. * @api
  506. */
  507. #define pmcEnableH32MX() pmcEnablePidLow(ID_MATRIX1_MSK)
  508. /**
  509. * @brief Disables the H32MX peripheral clock.
  510. *
  511. * @api
  512. */
  513. #define pmcDisableH32MX() pmcDisablePidLow(ID_MATRIX1_MSK)
  514. /**
  515. * @brief Enables the H64MX peripheral clock.
  516. *
  517. * @api
  518. */
  519. #define pmcEnableH64MX() pmcEnablePidLow(ID_MATRIX0_MSK)
  520. /**
  521. * @brief Disables the H64MX peripheral clock.
  522. *
  523. * @api
  524. */
  525. #define pmcDisableH64MX() pmcDisablePidLow(ID_MATRIX0_MSK)
  526. /**
  527. * @brief Enables the PIO peripheral clock.
  528. *
  529. * @api
  530. */
  531. #define pmcEnablePIO() pmcEnablePidLow(ID_PIOA_MSK)
  532. /**
  533. * @brief Disables the PIO peripheral clock.
  534. *
  535. * @api
  536. */
  537. #define pmcDisablePIO() pmcDisablePidLow(ID_PIOA_MSK)
  538. /**
  539. * @brief Enables the SPI0 peripheral clock.
  540. *
  541. * @api
  542. */
  543. #define pmcEnableSPI0() pmcEnablePidHigh(ID_SPI0_MSK)
  544. /**
  545. * @brief Disables the SPI0 peripheral clock.
  546. *
  547. * @api
  548. */
  549. #define pmcDisableSPI0() pmcDisablePidHigh(ID_SPI0_MSK)
  550. /**
  551. * @brief Enables the SPI1 peripheral clock.
  552. *
  553. * @api
  554. */
  555. #define pmcEnableSPI1() pmcEnablePidHigh(ID_SPI1_MSK)
  556. /**
  557. * @brief Disables the SPI11 peripheral clock.
  558. *
  559. * @api
  560. */
  561. #define pmcDisableSPI1() pmcDisablePidHigh(ID_SPI1_MSK)
  562. /**
  563. * @brief Enables the UART0 peripheral clock.
  564. *
  565. * @api
  566. */
  567. #define pmcEnableUART0() pmcEnablePidLow(ID_UART0_MSK)
  568. /**
  569. * @brief Disables the UART0 peripheral clock.
  570. *
  571. * @api
  572. */
  573. #define pmcDisableUART0() pmcDisablePidLow(ID_UART0_MSK)
  574. /**
  575. * @brief Enables the UART1 peripheral clock.
  576. *
  577. * @api
  578. */
  579. #define pmcEnableUART1() pmcEnablePidLow(ID_UART1_MSK)
  580. /**
  581. * @brief Disables the UART1 peripheral clock.
  582. *
  583. * @api
  584. */
  585. #define pmcDisableUART1() pmcDisablePidLow(ID_UART1_MSK)
  586. /**
  587. * @brief Enables the UART2 peripheral clock.
  588. *
  589. * @api
  590. */
  591. #define pmcEnableUART2() pmcEnablePidLow(ID_UART2_MSK)
  592. /**
  593. * @brief Disables the UART2 peripheral clock.
  594. *
  595. * @api
  596. */
  597. #define pmcDisableUART2() pmcDisablePidLow(ID_UART2_MSK)
  598. /**
  599. * @brief Enables the UART3 peripheral clock.
  600. *
  601. * @api
  602. */
  603. #define pmcEnableUART3() pmcEnablePidLow(ID_UART3_MSK)
  604. /**
  605. * @brief Disables the UART3 peripheral clock.
  606. *
  607. * @api
  608. */
  609. #define pmcDisableUART3() pmcDisablePidLow(ID_UART3_MSK)
  610. /**
  611. * @brief Enables the UART4 peripheral clock.
  612. *
  613. * @api
  614. */
  615. #define pmcEnableUART4() pmcEnablePidLow(ID_UART4_MSK)
  616. /**
  617. * @brief Disables the UART4 peripheral clock.
  618. *
  619. * @api
  620. */
  621. #define pmcDisableUART4() pmcDisablePidLow(ID_UART4_MSK)
  622. /**
  623. * @brief Enables the FLEXCOM0 peripheral clock.
  624. *
  625. * @api
  626. */
  627. #define pmcEnableFLEXCOM0() pmcEnablePidLow(ID_FLEXCOM0_MSK)
  628. /**
  629. * @brief Disables the FLEXCOM0 peripheral clock.
  630. *
  631. * @api
  632. */
  633. #define pmcDisableFLEXCOM0() pmcDisablePidLow(ID_FLEXCOM0_MSK)
  634. /**
  635. * @brief Enables the FLEXCOM1 peripheral clock.
  636. *
  637. * @api
  638. */
  639. #define pmcEnableFLEXCOM1() pmcEnablePidLow(ID_FLEXCOM1_MSK)
  640. /**
  641. * @brief Disables the FLEXCOM1 peripheral clock.
  642. *
  643. * @api
  644. */
  645. #define pmcDisableFLEXCOM1() pmcDisablePidLow(ID_FLEXCOM1_MSK)
  646. /**
  647. * @brief Enables the FLEXCOM2 peripheral clock.
  648. *
  649. * @api
  650. */
  651. #define pmcEnableFLEXCOM2() pmcEnablePidLow(ID_FLEXCOM2_MSK)
  652. /**
  653. * @brief Disables the FLEXCOM2 peripheral clock.
  654. *
  655. * @api
  656. */
  657. #define pmcDisableFLEXCOM2() pmcDisablePidLow(ID_FLEXCOM2_MSK)
  658. /**
  659. * @brief Enables the FLEXCOM0 peripheral clock.
  660. *
  661. * @api
  662. */
  663. #define pmcEnableFLEXCOM3() pmcEnablePidLow(ID_FLEXCOM3_MSK)
  664. /**
  665. * @brief Disables the FLEXCOM3 peripheral clock.
  666. *
  667. * @api
  668. */
  669. #define pmcDisableFLEXCOM3() pmcDisablePidLow(ID_FLEXCOM3_MSK)
  670. /**
  671. * @brief Enables the FLEXCOM4 peripheral clock.
  672. *
  673. * @api
  674. */
  675. #define pmcEnableFLEXCOM4() pmcEnablePidLow(ID_FLEXCOM4_MSK)
  676. /**
  677. * @brief Disables the FLEXCOM4 peripheral clock.
  678. *
  679. * @api
  680. */
  681. #define pmcDisableFLEXCOM4() pmcDisablePidLow(ID_FLEXCOM4_MSK)
  682. /**
  683. * @brief Enables the TC0 peripheral clock.
  684. *
  685. * @api
  686. */
  687. #define pmcEnableTC0() pmcEnablePidHigh(ID_TC0_MSK)
  688. /**
  689. * @brief Disables the TC0 peripheral clock.
  690. *
  691. * @api
  692. */
  693. #define pmcDisableTC0() pmcDisablePidHigh(ID_TC0_MSK)
  694. /**
  695. * @brief Enables the TC1 peripheral clock.
  696. *
  697. * @api
  698. */
  699. #define pmcEnableTC1() pmcEnablePidHigh(ID_TC1_MSK)
  700. /**
  701. * @brief Disables the TC1 peripheral clock.
  702. *
  703. * @api
  704. */
  705. #define pmcDisableTC1() pmcDisablePidHigh(ID_TC1_MSK)
  706. /**
  707. * @brief Enables the AES peripheral clock.
  708. *
  709. * @api
  710. */
  711. #define pmcEnableAES() pmcEnablePidLow(ID_AES_MSK)
  712. /**
  713. * @brief Disables the AES peripheral clock.
  714. *
  715. * @api
  716. */
  717. #define pmcDisableAES() pmcDisablePidLow(ID_AES_MSK)
  718. /**
  719. * @brief Enables the TRNG peripheral clock.
  720. *
  721. * @api
  722. */
  723. #define pmcEnableTRNG() pmcEnablePidHigh(ID_TRNG_MSK)
  724. /**
  725. * @brief Disables the TRNG peripheral clock.
  726. *
  727. * @api
  728. */
  729. #define pmcDisableTRNG() pmcDisablePidHigh(ID_TRNG_MSK)
  730. /**
  731. * @brief Enables the DES peripheral clock.
  732. *
  733. * @api
  734. */
  735. #define pmcEnableDES() pmcEnablePidLow(ID_TDES_MSK)
  736. /**
  737. * @brief Disables the DES peripheral clock.
  738. *
  739. * @api
  740. */
  741. #define pmcDisableDES() pmcDisablePidLow(ID_TDES_MSK)
  742. /**
  743. * @brief Enables the SHA peripheral clock.
  744. *
  745. * @api
  746. */
  747. #define pmcEnableSHA() pmcEnablePidLow(ID_SHA_MSK)
  748. /**
  749. * @brief Disables the SHA peripheral clock.
  750. *
  751. * @api
  752. */
  753. #define pmcDisableSHA() pmcDisablePidLow(ID_SHA_MSK)
  754. /**
  755. * @brief Enables the ETH0 peripheral clock.
  756. *
  757. * @api
  758. */
  759. #define pmcEnableETH0() pmcEnablePidLow(ID_GMAC0_MSK)
  760. /**
  761. * @brief Disables the ETH0 peripheral clock.
  762. *
  763. * @api
  764. */
  765. #define pmcDisableETH0() pmcDisablePidLow(ID_GMAC0_MSK)
  766. /**
  767. * @brief Enables the SECUMOD peripheral clock.
  768. *
  769. * @api
  770. */
  771. #define pmcEnableSEC() pmcEnablePidLow(ID_SECUMOD_MSK)
  772. /**
  773. * @brief Disables the SECUMOD peripheral clock.
  774. *
  775. * @api
  776. */
  777. #define pmcDisableSEC() pmcDisablePidLow(ID_SECUMOD_MSK)
  778. /**
  779. * @brief Enables the SDMMC0 peripheral clock.
  780. *
  781. * @api
  782. */
  783. #define pmcEnableSDMMC0() pmcEnablePidLow(ID_SDMMC0_MSK)
  784. /**
  785. * @brief Disables the SDMMC0 peripheral clock.
  786. *
  787. * @api
  788. */
  789. #define pmcDisableSDMMC0() pmcDisablePidLow(ID_SDMMC0_MSK)
  790. /**
  791. * @brief Enables the SDMMC1 peripheral clock.
  792. *
  793. * @api
  794. */
  795. #define pmcEnableSDMMC1() pmcEnablePidHigh(ID_SDMMC1_MSK)
  796. /**
  797. * @brief Disables the SDMMC1 peripheral clock.
  798. *
  799. * @api
  800. */
  801. #define pmcDisableSDMMC1() pmcDisablePidHigh(ID_SDMMC1_MSK)
  802. /**
  803. * @brief Enables the CLASSD peripheral clock.
  804. *
  805. * @api
  806. */
  807. #define pmcEnableCLASSD0() pmcEnablePidHigh(ID_CLASSD_MSK)
  808. /**
  809. * @brief Disables the CLASSD peripheral clock.
  810. *
  811. * @api
  812. */
  813. #define pmcDisableCLASSD0() pmcDisablePidHigh(ID_CLASSD_MSK)
  814. /**
  815. * @brief Enables the CLASSD generic clock.
  816. *
  817. * @api
  818. */
  819. #define pmcEnableGclkCLASSD0() pmcEnableGclk(ID_CLASSD)
  820. /**
  821. * @brief Disables the CLASSD generic clock.
  822. *
  823. * @api
  824. */
  825. #define pmcDisableGclkCLASSD0() pmcDisableGclk(ID_CLASSD)
  826. /**
  827. * @brief Enables the TRNG peripheral clock.
  828. *
  829. * @api
  830. */
  831. #define pmcEnableTRNG0() pmcEnablePidHigh(ID_TRNG_MSK)
  832. /**
  833. * @brief Disables the TRNG peripheral clock.
  834. *
  835. * @api
  836. */
  837. #define pmcDisableTRNG0() pmcDisablePidHigh(ID_TRNG_MSK)
  838. /**
  839. * @brief Enables the QSPI0 peripheral clock.
  840. *
  841. * @api
  842. */
  843. #define pmcEnableQSPI0() pmcEnablePidHigh(ID_QSPI0_MSK)
  844. /**
  845. * @brief Disables the QSPI0 peripheral clock.
  846. *
  847. * @api
  848. */
  849. #define pmcDisableQSPI0() pmcDisablePidHigh(ID_QSPI0_MSK)
  850. /**
  851. * @brief Enables the QSPI1 peripheral clock.
  852. *
  853. * @api
  854. */
  855. #define pmcEnableQSPI1() pmcEnablePidHigh(ID_QSPI1_MSK)
  856. /**
  857. * @brief Disables the QSPI1 peripheral clock.
  858. *
  859. * @api
  860. */
  861. #define pmcDisableQSPI1() pmcDisablePidHigh(ID_QSPI1_MSK)
  862. /**
  863. * @brief Enables the LCDC peripheral clock.
  864. *
  865. * @api
  866. */
  867. #define pmcEnableLCDC() pmcEnablePidHigh(ID_LCDC_MSK)
  868. /**
  869. * @brief Disables the LCDC peripheral clock.
  870. *
  871. * @api
  872. */
  873. #define pmcDisableLCDC() pmcDisablePidHigh(ID_LCDC_MSK)
  874. /**
  875. * @brief Enables the TWIHS0 peripheral clock.
  876. *
  877. * @api
  878. */
  879. #define pmcEnableTWIHS0() pmcEnablePidLow(ID_TWIHS0_MSK)
  880. /**
  881. * @brief Disables the TWIHS0 peripheral clock.
  882. *
  883. * @api
  884. */
  885. #define pmcDisableTWIHS0() pmcDisablePidLow(ID_TWIHS0_MSK)
  886. /**
  887. * @brief Enables the TWIHS1 peripheral clock.
  888. *
  889. * @api
  890. */
  891. #define pmcEnableTWIHS1() pmcEnablePidLow(ID_TWIHS1_MSK)
  892. /**
  893. * @brief Disables the TWIHS1 peripheral clock.
  894. *
  895. * @api
  896. */
  897. #define pmcDisableTWIHS1() pmcDisablePidLow(ID_TWIHS1_MSK)
  898. /** @} */
  899. /*===========================================================================*/
  900. /* External declarations. */
  901. /*===========================================================================*/
  902. #ifdef __cplusplus
  903. extern "C" {
  904. #endif
  905. #ifdef __cplusplus
  906. }
  907. #endif
  908. #endif /* _SAMA_PMC_ */
  909. /** @} */