cy2239x.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #ifndef _DEV_CY2239X_H_
  2. #define _DEV_CY2239X_H_
  3. /*
  4. * Copyright (C) 2005 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*
  35. * $Log$
  36. * Revision 1.4 2009/01/17 11:26:47 haraldkipp
  37. * Getting rid of two remaining BSD types in favor of stdint.
  38. * Replaced 'u_int' by 'unsinged int' and 'uptr_t' by 'uintptr_t'.
  39. *
  40. * Revision 1.3 2008/08/11 06:59:59 haraldkipp
  41. * BSD types replaced by stdint types (feature request #1282721).
  42. *
  43. * Revision 1.2 2006/01/05 16:53:26 haraldkipp
  44. * Several new functions added to query and modify the clock settings.
  45. *
  46. * Revision 1.1 2005/10/24 11:41:39 haraldkipp
  47. * Initial check-in.
  48. *
  49. */
  50. /*!
  51. * \addtogroup xgCy2239x
  52. */
  53. /*@{*/
  54. #include <sys/types.h>
  55. /*! \brief Clock A output.
  56. *
  57. * On Ethernut 3 this is output drives the Ethernet Controller,
  58. * if R3 is mounted (default).
  59. */
  60. #define CY2239X_CLKA 0
  61. /*! \brief Clock B output.
  62. *
  63. * On Ethernut 3 this is output drives the GCK1 input of the CPLD,
  64. * if R6 is mounted (default).
  65. */
  66. #define CY2239X_CLKB 1
  67. /*! \brief Clock C output.
  68. *
  69. * On Ethernut 3 this is output drives the CPU, if R5 is mounted
  70. * (default).
  71. */
  72. #define CY2239X_CLKC 2
  73. /*! \brief Clock D output.
  74. *
  75. * On Ethernut 3 this is output drives the GCK3 input of the CPLD,
  76. * if R4 is mounted and R104 is not mounted (default).
  77. */
  78. #define CY2239X_CLKD 3
  79. /*! \brief Clock E output.
  80. *
  81. * On Ethernut 3 this is output drives the GCK3 input of the CPLD,
  82. * if R104 is mounted and R4 is not mounted. By default R104 is not
  83. * mounted, but R4 is.
  84. */
  85. #define CY2239X_CLKE 4
  86. /*! \brief Reference clock identifier. */
  87. #define CY2239X_REF 0
  88. /*! \brief PLL1 identifier.
  89. *
  90. * The output of PLL1 can be connected to any output divider.
  91. * Clock E output is fixed to PLL1.
  92. */
  93. #define CY2239X_PLL1 1
  94. /*! \brief PLL2 identifier.
  95. *
  96. * The output of PLL2 can be connected to the output divider
  97. * of clock A, B, C or D.
  98. */
  99. #define CY2239X_PLL2 2
  100. /*! \brief PLL3 identifier.
  101. *
  102. * The output of PLL3 can be connected to the output divider
  103. * of clock A, B, C or D.
  104. */
  105. #define CY2239X_PLL3 3
  106. /*@}*/
  107. extern uint32_t Cy2239xGetFreq(int clk, int fctrl);
  108. extern int Cy2239xGetPll(int clk);
  109. extern int Cy2239xSetPll(int clk, int pll);
  110. extern int Cy2239xGetDivider(int clk, int fctrl);
  111. extern int Cy2239xSetDivider(int clk, int sel, int val);
  112. extern int Cy2239xPllEnable(int pll, int fctrl, int ena);
  113. extern uint32_t Cy2239xPllGetFreq(int pll, int fctrl);
  114. extern int Cy2239xPllSetFreq(int pll, int fctrl, unsigned int pval, unsigned int poff, unsigned int qval, unsigned int fval);
  115. #endif