clock.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. /*
  2. * linux/arch/arm/mach-at91rm9200/clock.c
  3. *
  4. * Copyright (C) 2005 David Brownell
  5. * Copyright (C) 2005 Ivan Kokshaysky
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/fs.h>
  16. #include <linux/debugfs.h>
  17. #include <linux/seq_file.h>
  18. #include <linux/list.h>
  19. #include <linux/errno.h>
  20. #include <linux/err.h>
  21. #include <linux/spinlock.h>
  22. #include <linux/delay.h>
  23. #include <linux/clk.h>
  24. #include <asm/semaphore.h>
  25. #include <asm/io.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/hardware.h>
  28. #include <asm/arch/at91_pmc.h>
  29. #include <asm/arch/cpu.h>
  30. #include "clock.h"
  31. /*
  32. * There's a lot more which can be done with clocks, including cpufreq
  33. * integration, slow clock mode support (for system suspend), letting
  34. * PLLB be used at other rates (on boards that don't need USB), etc.
  35. */
  36. #define clk_is_primary(x) ((x)->type & CLK_TYPE_PRIMARY)
  37. #define clk_is_programmable(x) ((x)->type & CLK_TYPE_PROGRAMMABLE)
  38. #define clk_is_peripheral(x) ((x)->type & CLK_TYPE_PERIPHERAL)
  39. #define clk_is_sys(x) ((x)->type & CLK_TYPE_SYSTEM)
  40. static LIST_HEAD(clocks);
  41. static DEFINE_SPINLOCK(clk_lock);
  42. static u32 at91_pllb_usb_init;
  43. /*
  44. * Four primary clock sources: two crystal oscillators (32K, main), and
  45. * two PLLs. PLLA usually runs the master clock; and PLLB must run at
  46. * 48 MHz (unless no USB function clocks are needed). The main clock and
  47. * both PLLs are turned off to run in "slow clock mode" (system suspend).
  48. */
  49. static struct clk clk32k = {
  50. .name = "clk32k",
  51. .rate_hz = AT91_SLOW_CLOCK,
  52. .users = 1, /* always on */
  53. .id = 0,
  54. .type = CLK_TYPE_PRIMARY,
  55. };
  56. static struct clk main_clk = {
  57. .name = "main",
  58. .pmc_mask = AT91_PMC_MOSCS, /* in PMC_SR */
  59. .id = 1,
  60. .type = CLK_TYPE_PRIMARY,
  61. };
  62. static struct clk plla = {
  63. .name = "plla",
  64. .parent = &main_clk,
  65. .pmc_mask = AT91_PMC_LOCKA, /* in PMC_SR */
  66. .id = 2,
  67. .type = CLK_TYPE_PRIMARY | CLK_TYPE_PLL,
  68. };
  69. static void pllb_mode(struct clk *clk, int is_on)
  70. {
  71. u32 value;
  72. if (is_on) {
  73. is_on = AT91_PMC_LOCKB;
  74. value = at91_pllb_usb_init;
  75. } else
  76. value = 0;
  77. // REVISIT: Add work-around for AT91RM9200 Errata #26 ?
  78. at91_sys_write(AT91_CKGR_PLLBR, value);
  79. do {
  80. cpu_relax();
  81. } while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKB) != is_on);
  82. }
  83. static struct clk pllb = {
  84. .name = "pllb",
  85. .parent = &main_clk,
  86. .pmc_mask = AT91_PMC_LOCKB, /* in PMC_SR */
  87. .mode = pllb_mode,
  88. .id = 3,
  89. .type = CLK_TYPE_PRIMARY | CLK_TYPE_PLL,
  90. };
  91. static void pmc_sys_mode(struct clk *clk, int is_on)
  92. {
  93. if (is_on)
  94. at91_sys_write(AT91_PMC_SCER, clk->pmc_mask);
  95. else
  96. at91_sys_write(AT91_PMC_SCDR, clk->pmc_mask);
  97. }
  98. /* USB function clocks (PLLB must be 48 MHz) */
  99. static struct clk udpck = {
  100. .name = "udpck",
  101. .parent = &pllb,
  102. .mode = pmc_sys_mode,
  103. };
  104. static struct clk uhpck = {
  105. .name = "uhpck",
  106. .parent = &pllb,
  107. .mode = pmc_sys_mode,
  108. };
  109. /*
  110. * The master clock is divided from the CPU clock (by 1-4). It's used for
  111. * memory, interfaces to on-chip peripherals, the AIC, and sometimes more
  112. * (e.g baud rate generation). It's sourced from one of the primary clocks.
  113. */
  114. static struct clk mck = {
  115. .name = "mck",
  116. .pmc_mask = AT91_PMC_MCKRDY, /* in PMC_SR */
  117. };
  118. static void pmc_periph_mode(struct clk *clk, int is_on)
  119. {
  120. if (is_on)
  121. at91_sys_write(AT91_PMC_PCER, clk->pmc_mask);
  122. else
  123. at91_sys_write(AT91_PMC_PCDR, clk->pmc_mask);
  124. }
  125. static struct clk __init *at91_css_to_clk(unsigned long css)
  126. {
  127. switch (css) {
  128. case AT91_PMC_CSS_SLOW:
  129. return &clk32k;
  130. case AT91_PMC_CSS_MAIN:
  131. return &main_clk;
  132. case AT91_PMC_CSS_PLLA:
  133. return &plla;
  134. case AT91_PMC_CSS_PLLB:
  135. return &pllb;
  136. }
  137. return NULL;
  138. }
  139. /*
  140. * Associate a particular clock with a function (eg, "uart") and device.
  141. * The drivers can then request the same 'function' with several different
  142. * devices and not care about which clock name to use.
  143. */
  144. void __init at91_clock_associate(const char *id, struct device *dev, const char *func)
  145. {
  146. struct clk *clk = clk_get(NULL, id);
  147. if (!dev || !clk || !IS_ERR(clk_get(dev, func)))
  148. return;
  149. clk->function = func;
  150. clk->dev = dev;
  151. }
  152. /* clocks cannot be de-registered no refcounting necessary */
  153. struct clk *clk_get(struct device *dev, const char *id)
  154. {
  155. struct clk *clk;
  156. list_for_each_entry(clk, &clocks, node) {
  157. if (strcmp(id, clk->name) == 0)
  158. return clk;
  159. if (clk->function && (dev == clk->dev) && strcmp(id, clk->function) == 0)
  160. return clk;
  161. }
  162. return ERR_PTR(-ENOENT);
  163. }
  164. EXPORT_SYMBOL(clk_get);
  165. void clk_put(struct clk *clk)
  166. {
  167. }
  168. EXPORT_SYMBOL(clk_put);
  169. static void __clk_enable(struct clk *clk)
  170. {
  171. if (clk->parent)
  172. __clk_enable(clk->parent);
  173. if (clk->users++ == 0 && clk->mode)
  174. clk->mode(clk, 1);
  175. }
  176. int clk_enable(struct clk *clk)
  177. {
  178. unsigned long flags;
  179. spin_lock_irqsave(&clk_lock, flags);
  180. __clk_enable(clk);
  181. spin_unlock_irqrestore(&clk_lock, flags);
  182. return 0;
  183. }
  184. EXPORT_SYMBOL(clk_enable);
  185. static void __clk_disable(struct clk *clk)
  186. {
  187. BUG_ON(clk->users == 0);
  188. if (--clk->users == 0 && clk->mode)
  189. clk->mode(clk, 0);
  190. if (clk->parent)
  191. __clk_disable(clk->parent);
  192. }
  193. void clk_disable(struct clk *clk)
  194. {
  195. unsigned long flags;
  196. spin_lock_irqsave(&clk_lock, flags);
  197. __clk_disable(clk);
  198. spin_unlock_irqrestore(&clk_lock, flags);
  199. }
  200. EXPORT_SYMBOL(clk_disable);
  201. unsigned long clk_get_rate(struct clk *clk)
  202. {
  203. unsigned long flags;
  204. unsigned long rate;
  205. spin_lock_irqsave(&clk_lock, flags);
  206. for (;;) {
  207. rate = clk->rate_hz;
  208. if (rate || !clk->parent)
  209. break;
  210. clk = clk->parent;
  211. }
  212. spin_unlock_irqrestore(&clk_lock, flags);
  213. return rate;
  214. }
  215. EXPORT_SYMBOL(clk_get_rate);
  216. /*------------------------------------------------------------------------*/
  217. #ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS
  218. /*
  219. * For now, only the programmable clocks support reparenting (MCK could
  220. * do this too, with care) or rate changing (the PLLs could do this too,
  221. * ditto MCK but that's more for cpufreq). Drivers may reparent to get
  222. * a better rate match; we don't.
  223. */
  224. long clk_round_rate(struct clk *clk, unsigned long rate)
  225. {
  226. unsigned long flags;
  227. unsigned prescale;
  228. unsigned long actual;
  229. if (!clk_is_programmable(clk))
  230. return -EINVAL;
  231. spin_lock_irqsave(&clk_lock, flags);
  232. actual = clk->parent->rate_hz;
  233. for (prescale = 0; prescale < 7; prescale++) {
  234. if (actual && actual <= rate)
  235. break;
  236. actual >>= 1;
  237. }
  238. spin_unlock_irqrestore(&clk_lock, flags);
  239. return (prescale < 7) ? actual : -ENOENT;
  240. }
  241. EXPORT_SYMBOL(clk_round_rate);
  242. int clk_set_rate(struct clk *clk, unsigned long rate)
  243. {
  244. unsigned long flags;
  245. unsigned prescale;
  246. unsigned long actual;
  247. if (!clk_is_programmable(clk))
  248. return -EINVAL;
  249. if (clk->users)
  250. return -EBUSY;
  251. spin_lock_irqsave(&clk_lock, flags);
  252. actual = clk->parent->rate_hz;
  253. for (prescale = 0; prescale < 7; prescale++) {
  254. if (actual && actual <= rate) {
  255. u32 pckr;
  256. pckr = at91_sys_read(AT91_PMC_PCKR(clk->id));
  257. pckr &= AT91_PMC_CSS_PLLB; /* clock selection */
  258. pckr |= prescale << 2;
  259. at91_sys_write(AT91_PMC_PCKR(clk->id), pckr);
  260. clk->rate_hz = actual;
  261. break;
  262. }
  263. actual >>= 1;
  264. }
  265. spin_unlock_irqrestore(&clk_lock, flags);
  266. return (prescale < 7) ? actual : -ENOENT;
  267. }
  268. EXPORT_SYMBOL(clk_set_rate);
  269. struct clk *clk_get_parent(struct clk *clk)
  270. {
  271. return clk->parent;
  272. }
  273. EXPORT_SYMBOL(clk_get_parent);
  274. int clk_set_parent(struct clk *clk, struct clk *parent)
  275. {
  276. unsigned long flags;
  277. if (clk->users)
  278. return -EBUSY;
  279. if (!clk_is_primary(parent) || !clk_is_programmable(clk))
  280. return -EINVAL;
  281. spin_lock_irqsave(&clk_lock, flags);
  282. clk->rate_hz = parent->rate_hz;
  283. clk->parent = parent;
  284. at91_sys_write(AT91_PMC_PCKR(clk->id), parent->id);
  285. spin_unlock_irqrestore(&clk_lock, flags);
  286. return 0;
  287. }
  288. EXPORT_SYMBOL(clk_set_parent);
  289. /* establish PCK0..PCK3 parentage and rate */
  290. static void init_programmable_clock(struct clk *clk)
  291. {
  292. struct clk *parent;
  293. u32 pckr;
  294. pckr = at91_sys_read(AT91_PMC_PCKR(clk->id));
  295. parent = at91_css_to_clk(pckr & AT91_PMC_CSS);
  296. clk->parent = parent;
  297. clk->rate_hz = parent->rate_hz / (1 << ((pckr >> 2) & 3));
  298. }
  299. #endif /* CONFIG_AT91_PROGRAMMABLE_CLOCKS */
  300. /*------------------------------------------------------------------------*/
  301. #ifdef CONFIG_DEBUG_FS
  302. static int at91_clk_show(struct seq_file *s, void *unused)
  303. {
  304. u32 scsr, pcsr, sr;
  305. struct clk *clk;
  306. unsigned i;
  307. seq_printf(s, "SCSR = %8x\n", scsr = at91_sys_read(AT91_PMC_SCSR));
  308. seq_printf(s, "PCSR = %8x\n", pcsr = at91_sys_read(AT91_PMC_PCSR));
  309. seq_printf(s, "MOR = %8x\n", at91_sys_read(AT91_CKGR_MOR));
  310. seq_printf(s, "MCFR = %8x\n", at91_sys_read(AT91_CKGR_MCFR));
  311. seq_printf(s, "PLLA = %8x\n", at91_sys_read(AT91_CKGR_PLLAR));
  312. seq_printf(s, "PLLB = %8x\n", at91_sys_read(AT91_CKGR_PLLBR));
  313. seq_printf(s, "MCKR = %8x\n", at91_sys_read(AT91_PMC_MCKR));
  314. for (i = 0; i < 4; i++)
  315. seq_printf(s, "PCK%d = %8x\n", i, at91_sys_read(AT91_PMC_PCKR(i)));
  316. seq_printf(s, "SR = %8x\n", sr = at91_sys_read(AT91_PMC_SR));
  317. seq_printf(s, "\n");
  318. list_for_each_entry(clk, &clocks, node) {
  319. char *state;
  320. if (clk->mode == pmc_sys_mode)
  321. state = (scsr & clk->pmc_mask) ? "on" : "off";
  322. else if (clk->mode == pmc_periph_mode)
  323. state = (pcsr & clk->pmc_mask) ? "on" : "off";
  324. else if (clk->pmc_mask)
  325. state = (sr & clk->pmc_mask) ? "on" : "off";
  326. else if (clk == &clk32k || clk == &main_clk)
  327. state = "on";
  328. else
  329. state = "";
  330. seq_printf(s, "%-10s users=%2d %-3s %9ld Hz %s\n",
  331. clk->name, clk->users, state, clk_get_rate(clk),
  332. clk->parent ? clk->parent->name : "");
  333. }
  334. return 0;
  335. }
  336. static int at91_clk_open(struct inode *inode, struct file *file)
  337. {
  338. return single_open(file, at91_clk_show, NULL);
  339. }
  340. static struct file_operations at91_clk_operations = {
  341. .open = at91_clk_open,
  342. .read = seq_read,
  343. .llseek = seq_lseek,
  344. .release = single_release,
  345. };
  346. static int __init at91_clk_debugfs_init(void)
  347. {
  348. /* /sys/kernel/debug/at91_clk */
  349. (void) debugfs_create_file("at91_clk", S_IFREG | S_IRUGO, NULL, NULL, &at91_clk_operations);
  350. return 0;
  351. }
  352. postcore_initcall(at91_clk_debugfs_init);
  353. #endif
  354. /*------------------------------------------------------------------------*/
  355. /* Register a new clock */
  356. int __init clk_register(struct clk *clk)
  357. {
  358. if (clk_is_peripheral(clk)) {
  359. clk->parent = &mck;
  360. clk->mode = pmc_periph_mode;
  361. list_add_tail(&clk->node, &clocks);
  362. }
  363. else if (clk_is_sys(clk)) {
  364. clk->parent = &mck;
  365. clk->mode = pmc_sys_mode;
  366. list_add_tail(&clk->node, &clocks);
  367. }
  368. #ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS
  369. else if (clk_is_programmable(clk)) {
  370. clk->mode = pmc_sys_mode;
  371. init_programmable_clock(clk);
  372. list_add_tail(&clk->node, &clocks);
  373. }
  374. #endif
  375. return 0;
  376. }
  377. /*------------------------------------------------------------------------*/
  378. static u32 __init at91_pll_rate(struct clk *pll, u32 freq, u32 reg)
  379. {
  380. unsigned mul, div;
  381. div = reg & 0xff;
  382. mul = (reg >> 16) & 0x7ff;
  383. if (div && mul) {
  384. freq /= div;
  385. freq *= mul + 1;
  386. } else
  387. freq = 0;
  388. return freq;
  389. }
  390. static u32 __init at91_usb_rate(struct clk *pll, u32 freq, u32 reg)
  391. {
  392. if (pll == &pllb && (reg & AT91_PMC_USB96M))
  393. return freq / 2;
  394. else
  395. return freq;
  396. }
  397. static unsigned __init at91_pll_calc(unsigned main_freq, unsigned out_freq)
  398. {
  399. unsigned i, div = 0, mul = 0, diff = 1 << 30;
  400. unsigned ret = (out_freq > 155000000) ? 0xbe00 : 0x3e00;
  401. /* PLL output max 240 MHz (or 180 MHz per errata) */
  402. if (out_freq > 240000000)
  403. goto fail;
  404. for (i = 1; i < 256; i++) {
  405. int diff1;
  406. unsigned input, mul1;
  407. /*
  408. * PLL input between 1MHz and 32MHz per spec, but lower
  409. * frequences seem necessary in some cases so allow 100K.
  410. */
  411. input = main_freq / i;
  412. if (input < 100000)
  413. continue;
  414. if (input > 32000000)
  415. continue;
  416. mul1 = out_freq / input;
  417. if (mul1 > 2048)
  418. continue;
  419. if (mul1 < 2)
  420. goto fail;
  421. diff1 = out_freq - input * mul1;
  422. if (diff1 < 0)
  423. diff1 = -diff1;
  424. if (diff > diff1) {
  425. diff = diff1;
  426. div = i;
  427. mul = mul1;
  428. if (diff == 0)
  429. break;
  430. }
  431. }
  432. if (i == 256 && diff > (out_freq >> 5))
  433. goto fail;
  434. return ret | ((mul - 1) << 16) | div;
  435. fail:
  436. return 0;
  437. }
  438. /*
  439. * Several unused clocks may be active. Turn them off.
  440. */
  441. static void __init at91_periphclk_reset(void)
  442. {
  443. unsigned long reg;
  444. struct clk *clk;
  445. reg = at91_sys_read(AT91_PMC_PCSR);
  446. list_for_each_entry(clk, &clocks, node) {
  447. if (clk->mode != pmc_periph_mode)
  448. continue;
  449. if (clk->users > 0)
  450. reg &= ~clk->pmc_mask;
  451. }
  452. at91_sys_write(AT91_PMC_PCDR, reg);
  453. }
  454. static struct clk *const standard_pmc_clocks[] __initdata = {
  455. /* four primary clocks */
  456. &clk32k,
  457. &main_clk,
  458. &plla,
  459. &pllb,
  460. /* PLLB children (USB) */
  461. &udpck,
  462. &uhpck,
  463. /* MCK */
  464. &mck
  465. };
  466. int __init at91_clock_init(unsigned long main_clock)
  467. {
  468. unsigned tmp, freq, mckr;
  469. int i;
  470. /*
  471. * When the bootloader initialized the main oscillator correctly,
  472. * there's no problem using the cycle counter. But if it didn't,
  473. * or when using oscillator bypass mode, we must be told the speed
  474. * of the main clock.
  475. */
  476. if (!main_clock) {
  477. do {
  478. tmp = at91_sys_read(AT91_CKGR_MCFR);
  479. } while (!(tmp & AT91_PMC_MAINRDY));
  480. main_clock = (tmp & AT91_PMC_MAINF) * (AT91_SLOW_CLOCK / 16);
  481. }
  482. main_clk.rate_hz = main_clock;
  483. /* report if PLLA is more than mildly overclocked */
  484. plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_sys_read(AT91_CKGR_PLLAR));
  485. if (plla.rate_hz > 209000000)
  486. pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000);
  487. /*
  488. * USB clock init: choose 48 MHz PLLB value, turn all clocks off,
  489. * disable 48MHz clock during usb peripheral suspend.
  490. *
  491. * REVISIT: assumes MCK doesn't derive from PLLB!
  492. */
  493. at91_pllb_usb_init = at91_pll_calc(main_clock, 48000000 * 2) | AT91_PMC_USB96M;
  494. pllb.rate_hz = at91_pll_rate(&pllb, main_clock, at91_pllb_usb_init);
  495. if (cpu_is_at91rm9200()) {
  496. uhpck.pmc_mask = AT91RM9200_PMC_UHP;
  497. udpck.pmc_mask = AT91RM9200_PMC_UDP;
  498. at91_sys_write(AT91_PMC_SCDR, AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP);
  499. at91_sys_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP);
  500. } else if (cpu_is_at91sam9260()) {
  501. uhpck.pmc_mask = AT91SAM926x_PMC_UHP;
  502. udpck.pmc_mask = AT91SAM926x_PMC_UDP;
  503. at91_sys_write(AT91_PMC_SCDR, AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP);
  504. } else if (cpu_is_at91sam9261()) {
  505. uhpck.pmc_mask = (AT91SAM926x_PMC_UHP | AT91_PMC_HCK0);
  506. udpck.pmc_mask = AT91SAM926x_PMC_UDP;
  507. at91_sys_write(AT91_PMC_SCDR, AT91SAM926x_PMC_UHP | AT91_PMC_HCK0 | AT91SAM926x_PMC_UDP);
  508. }
  509. at91_sys_write(AT91_CKGR_PLLBR, 0);
  510. udpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
  511. uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
  512. /*
  513. * MCK and CPU derive from one of those primary clocks.
  514. * For now, assume this parentage won't change.
  515. */
  516. mckr = at91_sys_read(AT91_PMC_MCKR);
  517. mck.parent = at91_css_to_clk(mckr & AT91_PMC_CSS);
  518. freq = mck.parent->rate_hz;
  519. freq /= (1 << ((mckr >> 2) & 3)); /* prescale */
  520. mck.rate_hz = freq / (1 + ((mckr >> 8) & 3)); /* mdiv */
  521. /* Register the PMC's standard clocks */
  522. for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++)
  523. list_add_tail(&standard_pmc_clocks[i]->node, &clocks);
  524. /* MCK and CPU clock are "always on" */
  525. clk_enable(&mck);
  526. printk("Clocks: CPU %u MHz, master %u MHz, main %u.%03u MHz\n",
  527. freq / 1000000, (unsigned) mck.rate_hz / 1000000,
  528. (unsigned) main_clock / 1000000,
  529. ((unsigned) main_clock % 1000000) / 1000);
  530. /* disable all programmable clocks */
  531. at91_sys_write(AT91_PMC_SCDR, AT91_PMC_PCK0 | AT91_PMC_PCK1 | AT91_PMC_PCK2 | AT91_PMC_PCK3);
  532. /* disable all other unused peripheral clocks */
  533. at91_periphclk_reset();
  534. return 0;
  535. }