clock.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * TNETV107X: Clock APIs
  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 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. * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #ifndef __ASM_ARCH_CLOCK_H
  22. #define __ASM_ARCH_CLOCK_H
  23. #define PSC_MDCTL_NEXT_SWRSTDISABLE 0x0
  24. #define PSC_MDCTL_NEXT_SYNCRST 0x1
  25. #define PSC_MDCTL_NEXT_DISABLE 0x2
  26. #define PSC_MDCTL_NEXT_ENABLE 0x3
  27. #define CONFIG_SYS_INT_OSC_FREQ 24000000
  28. #ifndef __ASSEMBLY__
  29. /* PLL identifiers */
  30. enum pll_type_e {
  31. SYS_PLL,
  32. TDM_PLL,
  33. ETH_PLL
  34. };
  35. /* PLL configuration data */
  36. struct pll_init_data {
  37. int pll;
  38. int internal_osc;
  39. unsigned long pll_freq;
  40. unsigned long div_freq[10];
  41. };
  42. void init_plls(int num_pll, struct pll_init_data *config);
  43. int lpsc_status(unsigned int mod);
  44. void lpsc_control(int mod, unsigned long state, int lrstz);
  45. unsigned long clk_get_rate(unsigned int clk);
  46. unsigned long clk_round_rate(unsigned int clk, unsigned long hz);
  47. int clk_set_rate(unsigned int clk, unsigned long hz);
  48. static inline void clk_enable(unsigned int mod)
  49. {
  50. lpsc_control(mod, PSC_MDCTL_NEXT_ENABLE, -1);
  51. }
  52. static inline void clk_disable(unsigned int mod)
  53. {
  54. lpsc_control(mod, PSC_MDCTL_NEXT_DISABLE, -1);
  55. }
  56. #endif
  57. #endif