gpio_v2.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /**
  2. * \file gpio_v2.h
  3. *
  4. * \brief This file contains the prototypes of the APIs present in the
  5. * device abstraction layer file of GPIO belonging to AM335X SoC.
  6. * This also contains some related macros.
  7. */
  8. /*
  9. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
  10. */
  11. /*
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions
  14. * are met:
  15. *
  16. * Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. *
  19. * Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in the
  21. * documentation and/or other materials provided with the
  22. * distribution.
  23. *
  24. * Neither the name of Texas Instruments Incorporated nor the names of
  25. * its contributors may be used to endorse or promote products derived
  26. * from this software without specific prior written permission.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  29. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  30. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  31. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  32. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  33. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  34. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  35. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  36. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  37. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  38. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. */
  41. #ifndef _GPIO_V2_H_
  42. #define _GPIO_V2_H_
  43. #include "hw_gpio_v2.h"
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. /*****************************************************************************
  48. ** MACRO DEFINITIONS
  49. *****************************************************************************/
  50. /* Values used to configure the direction of GPIO pins. */
  51. #define GPIO_DIR_INPUT (GPIO_OE_OUTPUTEN_DISABLED)
  52. #define GPIO_DIR_OUTPUT (GPIO_OE_OUTPUTEN_ENABLED)
  53. /* Values helping to decide the value on a GPIO pin. */
  54. #define GPIO_PIN_LOW (0x0)
  55. #define GPIO_PIN_HIGH (0x1)
  56. /* Values denoting the Interrupt Line number to be used. */
  57. #define GPIO_INT_LINE_1 (0x0)
  58. #define GPIO_INT_LINE_2 (0x1)
  59. /* Values denoting the Smart Wakeup Interrupt Line to be used. */
  60. #define GPIO_INT_SWAKEUP_LINE_1 (0x0)
  61. #define GPIO_INT_SWAKEUP_LINE_2 (0x1)
  62. /*
  63. ** Values used to enable/disable interrupt generation due to level
  64. ** detection on an input GPIO pin.
  65. */
  66. #define GPIO_INT_TYPE_NO_LEVEL (0x01)
  67. #define GPIO_INT_TYPE_LEVEL_LOW (0x04)
  68. #define GPIO_INT_TYPE_LEVEL_HIGH (0x08)
  69. #define GPIO_INT_TYPE_BOTH_LEVEL (0x0C)
  70. /*
  71. ** Values used to enable/disable interrupt generation due to edge
  72. ** detection on an input GPIO pin.
  73. */
  74. #define GPIO_INT_TYPE_NO_EDGE (0x80)
  75. #define GPIO_INT_TYPE_RISE_EDGE (0x10)
  76. #define GPIO_INT_TYPE_FALL_EDGE (0x20)
  77. #define GPIO_INT_TYPE_BOTH_EDGE (0x30)
  78. /* Values used for Idle Mode configurations. */
  79. #define GPIO_IDLE_MODE_FORCE_IDLE (GPIO_SYSCONFIG_IDLEMODE_FORCEIDLE << \
  80. GPIO_SYSCONFIG_IDLEMODE_SHIFT)
  81. #define GPIO_IDLE_MODE_NO_IDLE (GPIO_SYSCONFIG_IDLEMODE_NOIDLE << \
  82. GPIO_SYSCONFIG_IDLEMODE_SHIFT)
  83. #define GPIO_IDLE_MODE_SMART_IDLE (GPIO_SYSCONFIG_IDLEMODE_SMARTIDLE << \
  84. GPIO_SYSCONFIG_IDLEMODE_SHIFT)
  85. #define GPIO_IDLE_MODE_SMART_IDLE_WAKEUP (GPIO_SYSCONFIG_IDLEMODE_SMARTIDLEWAKEUP << \
  86. GPIO_SYSCONFIG_IDLEMODE_SHIFT)
  87. /* Values used to enable/disable Auto-Idle mode. */
  88. #define GPIO_AUTO_IDLE_MODE_ENABLE (GPIO_SYSCONFIG_AUTOIDLE_AUTOMATIC)
  89. #define GPIO_AUTO_IDLE_MODE_DISABLE (GPIO_SYSCONFIG_AUTOIDLE_FREERUN)
  90. /* Values used to configure the Gating Ratio. */
  91. #define GPIO_GR_FUNC_CLK_INTER_CLK_BY_1 (GPIO_CTRL_GATINGRATIO_N_1 << \
  92. GPIO_CTRL_GATINGRATIO_SHIFT)
  93. #define GPIO_GR_FUNC_CLK_INTER_CLK_BY_2 (GPIO_CTRL_GATINGRATIO_N_2 << \
  94. GPIO_CTRL_GATINGRATIO_SHIFT)
  95. #define GPIO_GR_FUNC_CLK_INTER_CLK_BY_4 (GPIO_CTRL_GATINGRATIO_N_4 << \
  96. GPIO_CTRL_GATINGRATIO_SHIFT)
  97. #define GPIO_GR_FUNC_CLK_INTER_CLK_BY_8 (GPIO_CTRL_GATINGRATIO_N_8 << \
  98. GPIO_CTRL_GATINGRATIO_SHIFT)
  99. /* Values used to enable/disable Debouncing feature for an input pin. */
  100. #define GPIO_DEBOUNCE_FUNC_ENABLE (GPIO_DEBOUNCENABLE_DEBOUNCEENABLE_DEBOUNCE)
  101. #define GPIO_DEBOUNCE_FUNC_DISABLE (GPIO_DEBOUNCENABLE_DEBOUNCEENABLE_NODEBOUNCE)
  102. /*
  103. ** Structure to store the GPIO context
  104. */
  105. typedef struct gpioContext{
  106. unsigned int ctrl;
  107. unsigned int dir;
  108. unsigned int data;
  109. }GPIOCONTEXT;
  110. /*****************************************************************************
  111. ** FUNCTION PROTOTYPES
  112. *****************************************************************************/
  113. extern void GPIOModuleReset(unsigned int baseAdd);
  114. extern void GPIOModuleEnable(unsigned int baseAdd);
  115. extern void GPIOModuleDisable(unsigned int baseAdd);
  116. extern void GPIODirModeSet(unsigned int baseAdd,
  117. unsigned int pinNumber,
  118. unsigned int pinDirection);
  119. extern unsigned int GPIODirModeGet(unsigned int baseAdd,
  120. unsigned int pinNumber);
  121. extern void GPIOPinWrite(unsigned int baseAdd,
  122. unsigned int pinNumber,
  123. unsigned int pinValue);
  124. extern unsigned int GPIOPinRead(unsigned int baseAdd,
  125. unsigned int pinNumber);
  126. extern void GPIOMultiplePinsWrite(unsigned int baseAdd,
  127. unsigned int setMask,
  128. unsigned int clrMask);
  129. extern unsigned int GPIOMultiplePinsRead(unsigned int baseAdd,
  130. unsigned int readMask);
  131. extern void GPIOPinIntEnable(unsigned int baseAdd,
  132. unsigned int intLine,
  133. unsigned int pinNumber);
  134. extern void GPIOPinIntDisable(unsigned int baseAdd,
  135. unsigned int intLine,
  136. unsigned int pinNumber);
  137. extern void GPIOIntTypeSet(unsigned int baseAdd,
  138. unsigned int pinNumber,
  139. unsigned int eventType);
  140. extern unsigned int GPIOIntTypeGet(unsigned int baseAdd,
  141. unsigned int pinNumber);
  142. extern unsigned int GPIOPinIntStatus(unsigned int baseAdd,
  143. unsigned int intLine,
  144. unsigned int pinNumber);
  145. extern void GPIOPinIntClear(unsigned int baseAdd,
  146. unsigned int intLine,
  147. unsigned int pinNumber);
  148. extern unsigned int GPIORawIntStatus(unsigned int baseAdd,
  149. unsigned int intLine,
  150. unsigned int readMask);
  151. extern void GPIOTriggerPinInt(unsigned int baseAdd,
  152. unsigned int intLine,
  153. unsigned int pinNumber);
  154. extern void GPIOWakeupGlobalEnable(unsigned int baseAdd);
  155. extern void GPIOWakeupGlobalDisable(unsigned int baseAdd);
  156. extern void GPIOPinIntWakeUpEnable(unsigned int baseAdd,
  157. unsigned int intLine,
  158. unsigned int pinNumber);
  159. extern void GPIOPinIntWakeUpDisable(unsigned int baseAdd,
  160. unsigned int intLine,
  161. unsigned int pinNumber);
  162. extern void GPIOAutoIdleModeControl(unsigned int baseAdd,
  163. unsigned int modeFlag);
  164. extern void GPIOIdleModeConfigure(unsigned int baseAdd,
  165. unsigned int modeFlag);
  166. extern void GPIOGatingRatioConfigure(unsigned int baseAdd,
  167. unsigned int configFlag);
  168. extern void GPIODebounceFuncControl(unsigned int baseAdd,
  169. unsigned int pinNumber,
  170. unsigned int controlFlag);
  171. extern void GPIODebounceTimeConfig(unsigned int baseAdd,
  172. unsigned int debounceTime);
  173. extern unsigned int GPIORevisionInfoGet(unsigned int baseAdd);
  174. extern void gpioContextSave(unsigned int baseAdd, GPIOCONTEXT *contextPtr);
  175. extern void gpioContextRestore(unsigned int baseAdd, GPIOCONTEXT *contextPtr);
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179. #endif
  180. /********************************* End Of File ******************************/