clk.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (C) 2006 Atmel Corporation
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #ifndef __ASM_AVR32_ARCH_CLK_H__
  23. #define __ASM_AVR32_ARCH_CLK_H__
  24. #ifdef CONFIG_PLL
  25. #define MAIN_CLK_RATE ((CFG_OSC0_HZ / CFG_PLL0_DIV) * CFG_PLL0_MUL)
  26. #else
  27. #define MAIN_CLK_RATE (CFG_OSC0_HZ)
  28. #endif
  29. static inline unsigned long get_cpu_clk_rate(void)
  30. {
  31. return MAIN_CLK_RATE >> CFG_CLKDIV_CPU;
  32. }
  33. static inline unsigned long get_hsb_clk_rate(void)
  34. {
  35. return MAIN_CLK_RATE >> CFG_CLKDIV_HSB;
  36. }
  37. static inline unsigned long get_pba_clk_rate(void)
  38. {
  39. return MAIN_CLK_RATE >> CFG_CLKDIV_PBA;
  40. }
  41. static inline unsigned long get_pbb_clk_rate(void)
  42. {
  43. return MAIN_CLK_RATE >> CFG_CLKDIV_PBB;
  44. }
  45. /* Accessors for specific devices. More will be added as needed. */
  46. static inline unsigned long get_sdram_clk_rate(void)
  47. {
  48. return get_hsb_clk_rate();
  49. }
  50. static inline unsigned long get_usart_clk_rate(unsigned int dev_id)
  51. {
  52. return get_pba_clk_rate();
  53. }
  54. static inline unsigned long get_macb_pclk_rate(unsigned int dev_id)
  55. {
  56. return get_pbb_clk_rate();
  57. }
  58. static inline unsigned long get_macb_hclk_rate(unsigned int dev_id)
  59. {
  60. return get_hsb_clk_rate();
  61. }
  62. static inline unsigned long get_mci_clk_rate(void)
  63. {
  64. return get_pbb_clk_rate();
  65. }
  66. #endif /* __ASM_AVR32_ARCH_CLK_H__ */