wm_cpu.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. * @file wm_cpu.h
  3. *
  4. * @brief cpu driver module
  5. *
  6. * @author dave
  7. *
  8. * @copyright (c) 2014 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef WM_CPU_H
  11. #define WM_CPU_H
  12. #include <stdint.h>
  13. /**XT806 BASE PLL CLOCK*/
  14. #define XT806_PLL_CLK_MHZ (480)
  15. enum CPU_CLK{
  16. CPU_CLK_240M = 2,
  17. CPU_CLK_160M = 3,
  18. CPU_CLK_80M = 6,
  19. CPU_CLK_40M = 12,
  20. CPU_CLK_2M = 240,
  21. };
  22. typedef union {
  23. struct {
  24. uint32_t CPU: 8; /*!< bit: 0.. 7 cpu clock divider */
  25. uint32_t WLAN: 8; /*!< bit: 8.. 15 Wlan clock divider */
  26. uint32_t BUS2: 8; /*!< bit: 16.. 23 clock dividing ratio of bus2 & bus1 */
  27. uint32_t PD: 4; /*!< bit: 24.. 27 peripheral divider */
  28. uint32_t RSV: 3; /*!< bit: 28.. 30 Reserved */
  29. uint32_t DIV_EN: 1; /*!< bit: 31 divide frequency enable */
  30. } b;
  31. uint32_t w;
  32. } clk_div_reg;
  33. #define UNIT_MHZ (1000000)
  34. typedef struct{
  35. u32 apbclk;
  36. u32 cpuclk;
  37. u32 wlanclk;
  38. }tls_sys_clk;
  39. /**
  40. * @defgroup Driver_APIs Driver APIs
  41. * @brief Driver APIs
  42. */
  43. /**
  44. * @addtogroup Driver_APIs
  45. * @{
  46. */
  47. /**
  48. * @defgroup CPUCLK_Driver_APIs CPU CLOCK Driver APIs
  49. * @brief CPU CLOCK driver APIs
  50. */
  51. /**
  52. * @addtogroup CPUCLK_Driver_APIs
  53. * @{
  54. */
  55. /**
  56. * @brief This function is used to set cpu clock
  57. *
  58. * @param[in] clk select cpu clock
  59. * clk == CPU_CLK_80M 80M
  60. * clk == CPU_CLK_40M 40M
  61. *
  62. * @return None
  63. *
  64. * @note None
  65. */
  66. void tls_sys_clk_set(u32 clk);
  67. /**
  68. * @brief This function is used to get cpu clock
  69. *
  70. * @param[out] *sysclk point to the addr for system clk output
  71. *
  72. * @return None
  73. *
  74. * @note None
  75. */
  76. void tls_sys_clk_get(tls_sys_clk *sysclk);
  77. /**
  78. * @}
  79. */
  80. /**
  81. * @}
  82. */
  83. #endif /* WM_CPU_H */