gpio.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * (C) Copyright 2009 Samsung Electronics
  3. * Minkyu Kang <mk7.kang@samsung.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  18. * MA 02111-1307 USA
  19. */
  20. #ifndef __ASM_ARCH_GPIO_H
  21. #define __ASM_ARCH_GPIO_H
  22. #ifndef __ASSEMBLY__
  23. struct s5p_gpio_bank {
  24. unsigned int con;
  25. unsigned int dat;
  26. unsigned int pull;
  27. unsigned int drv;
  28. unsigned int pdn_con;
  29. unsigned int pdn_pull;
  30. unsigned char res1[8];
  31. };
  32. struct s5pc100_gpio {
  33. struct s5p_gpio_bank a0;
  34. struct s5p_gpio_bank a1;
  35. struct s5p_gpio_bank b;
  36. struct s5p_gpio_bank c;
  37. struct s5p_gpio_bank d;
  38. struct s5p_gpio_bank e0;
  39. struct s5p_gpio_bank e1;
  40. struct s5p_gpio_bank f0;
  41. struct s5p_gpio_bank f1;
  42. struct s5p_gpio_bank f2;
  43. struct s5p_gpio_bank f3;
  44. struct s5p_gpio_bank g0;
  45. struct s5p_gpio_bank g1;
  46. struct s5p_gpio_bank g2;
  47. struct s5p_gpio_bank g3;
  48. struct s5p_gpio_bank i;
  49. struct s5p_gpio_bank j0;
  50. struct s5p_gpio_bank j1;
  51. struct s5p_gpio_bank j2;
  52. struct s5p_gpio_bank j3;
  53. struct s5p_gpio_bank j4;
  54. struct s5p_gpio_bank k0;
  55. struct s5p_gpio_bank k1;
  56. struct s5p_gpio_bank k2;
  57. struct s5p_gpio_bank k3;
  58. struct s5p_gpio_bank l0;
  59. struct s5p_gpio_bank l1;
  60. struct s5p_gpio_bank l2;
  61. struct s5p_gpio_bank l3;
  62. struct s5p_gpio_bank l4;
  63. struct s5p_gpio_bank h0;
  64. struct s5p_gpio_bank h1;
  65. struct s5p_gpio_bank h2;
  66. struct s5p_gpio_bank h3;
  67. };
  68. struct s5pc110_gpio {
  69. struct s5p_gpio_bank a0;
  70. struct s5p_gpio_bank a1;
  71. struct s5p_gpio_bank b;
  72. struct s5p_gpio_bank c0;
  73. struct s5p_gpio_bank c1;
  74. struct s5p_gpio_bank d0;
  75. struct s5p_gpio_bank d1;
  76. struct s5p_gpio_bank e0;
  77. struct s5p_gpio_bank e1;
  78. struct s5p_gpio_bank f0;
  79. struct s5p_gpio_bank f1;
  80. struct s5p_gpio_bank f2;
  81. struct s5p_gpio_bank f3;
  82. struct s5p_gpio_bank g0;
  83. struct s5p_gpio_bank g1;
  84. struct s5p_gpio_bank g2;
  85. struct s5p_gpio_bank g3;
  86. struct s5p_gpio_bank i;
  87. struct s5p_gpio_bank j0;
  88. struct s5p_gpio_bank j1;
  89. struct s5p_gpio_bank j2;
  90. struct s5p_gpio_bank j3;
  91. struct s5p_gpio_bank j4;
  92. struct s5p_gpio_bank mp0_1;
  93. struct s5p_gpio_bank mp0_2;
  94. struct s5p_gpio_bank mp0_3;
  95. struct s5p_gpio_bank mp0_4;
  96. struct s5p_gpio_bank mp0_5;
  97. struct s5p_gpio_bank mp0_6;
  98. struct s5p_gpio_bank mp0_7;
  99. struct s5p_gpio_bank mp1_0;
  100. struct s5p_gpio_bank mp1_1;
  101. struct s5p_gpio_bank mp1_2;
  102. struct s5p_gpio_bank mp1_3;
  103. struct s5p_gpio_bank mp1_4;
  104. struct s5p_gpio_bank mp1_5;
  105. struct s5p_gpio_bank mp1_6;
  106. struct s5p_gpio_bank mp1_7;
  107. struct s5p_gpio_bank mp1_8;
  108. struct s5p_gpio_bank mp2_0;
  109. struct s5p_gpio_bank mp2_1;
  110. struct s5p_gpio_bank mp2_2;
  111. struct s5p_gpio_bank mp2_3;
  112. struct s5p_gpio_bank mp2_4;
  113. struct s5p_gpio_bank mp2_5;
  114. struct s5p_gpio_bank mp2_6;
  115. struct s5p_gpio_bank mp2_7;
  116. struct s5p_gpio_bank mp2_8;
  117. struct s5p_gpio_bank res1[48];
  118. struct s5p_gpio_bank h0;
  119. struct s5p_gpio_bank h1;
  120. struct s5p_gpio_bank h2;
  121. struct s5p_gpio_bank h3;
  122. };
  123. /* functions */
  124. void gpio_cfg_pin(struct s5p_gpio_bank *bank, int gpio, int cfg);
  125. void gpio_direction_output(struct s5p_gpio_bank *bank, int gpio, int en);
  126. void gpio_direction_input(struct s5p_gpio_bank *bank, int gpio);
  127. void gpio_set_value(struct s5p_gpio_bank *bank, int gpio, int en);
  128. unsigned int gpio_get_value(struct s5p_gpio_bank *bank, int gpio);
  129. void gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode);
  130. void gpio_set_drv(struct s5p_gpio_bank *bank, int gpio, int mode);
  131. void gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode);
  132. #endif
  133. /* Pin configurations */
  134. #define GPIO_INPUT 0x0
  135. #define GPIO_OUTPUT 0x1
  136. #define GPIO_IRQ 0xf
  137. #define GPIO_FUNC(x) (x)
  138. /* Pull mode */
  139. #define GPIO_PULL_NONE 0x0
  140. #define GPIO_PULL_DOWN 0x1
  141. #define GPIO_PULL_UP 0x2
  142. /* Drive Strength level */
  143. #define GPIO_DRV_1X 0x0
  144. #define GPIO_DRV_2X 0x1
  145. #define GPIO_DRV_3X 0x2
  146. #define GPIO_DRV_4X 0x3
  147. #define GPIO_DRV_FAST 0x0
  148. #define GPIO_DRV_SLOW 0x1
  149. #endif