gpio.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * Coldfire generic GPIO support
  3. *
  4. * (C) Copyright 2009, Steven King <sfking@fdwdc.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  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. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <asm/coldfire.h>
  18. #include <asm/mcfsim.h>
  19. #include <asm/mcfgpio.h>
  20. static struct mcf_gpio_chip mcf_gpio_chips[] = {
  21. {
  22. .gpio_chip = {
  23. .label = "PIRQ",
  24. .request = mcf_gpio_request,
  25. .free = mcf_gpio_free,
  26. .direction_input = mcf_gpio_direction_input,
  27. .direction_output = mcf_gpio_direction_output,
  28. .get = mcf_gpio_get_value,
  29. .set = mcf_gpio_set_value,
  30. .ngpio = 8,
  31. },
  32. .pddr = MCFEPORT_EPDDR,
  33. .podr = MCFEPORT_EPDR,
  34. .ppdr = MCFEPORT_EPPDR,
  35. },
  36. {
  37. .gpio_chip = {
  38. .label = "BUSCTL",
  39. .request = mcf_gpio_request,
  40. .free = mcf_gpio_free,
  41. .direction_input = mcf_gpio_direction_input,
  42. .direction_output = mcf_gpio_direction_output,
  43. .get = mcf_gpio_get_value,
  44. .set = mcf_gpio_set_value_fast,
  45. .base = 8,
  46. .ngpio = 4,
  47. },
  48. .pddr = MCFGPIO_PDDR_BUSCTL,
  49. .podr = MCFGPIO_PODR_BUSCTL,
  50. .ppdr = MCFGPIO_PPDSDR_BUSCTL,
  51. .setr = MCFGPIO_PPDSDR_BUSCTL,
  52. .clrr = MCFGPIO_PCLRR_BUSCTL,
  53. },
  54. {
  55. .gpio_chip = {
  56. .label = "BE",
  57. .request = mcf_gpio_request,
  58. .free = mcf_gpio_free,
  59. .direction_input = mcf_gpio_direction_input,
  60. .direction_output = mcf_gpio_direction_output,
  61. .get = mcf_gpio_get_value,
  62. .set = mcf_gpio_set_value_fast,
  63. .base = 16,
  64. .ngpio = 4,
  65. },
  66. .pddr = MCFGPIO_PDDR_BE,
  67. .podr = MCFGPIO_PODR_BE,
  68. .ppdr = MCFGPIO_PPDSDR_BE,
  69. .setr = MCFGPIO_PPDSDR_BE,
  70. .clrr = MCFGPIO_PCLRR_BE,
  71. },
  72. {
  73. .gpio_chip = {
  74. .label = "CS",
  75. .request = mcf_gpio_request,
  76. .free = mcf_gpio_free,
  77. .direction_input = mcf_gpio_direction_input,
  78. .direction_output = mcf_gpio_direction_output,
  79. .get = mcf_gpio_get_value,
  80. .set = mcf_gpio_set_value_fast,
  81. .base = 25,
  82. .ngpio = 3,
  83. },
  84. .pddr = MCFGPIO_PDDR_CS,
  85. .podr = MCFGPIO_PODR_CS,
  86. .ppdr = MCFGPIO_PPDSDR_CS,
  87. .setr = MCFGPIO_PPDSDR_CS,
  88. .clrr = MCFGPIO_PCLRR_CS,
  89. },
  90. {
  91. .gpio_chip = {
  92. .label = "FECI2C",
  93. .request = mcf_gpio_request,
  94. .free = mcf_gpio_free,
  95. .direction_input = mcf_gpio_direction_input,
  96. .direction_output = mcf_gpio_direction_output,
  97. .get = mcf_gpio_get_value,
  98. .set = mcf_gpio_set_value_fast,
  99. .base = 32,
  100. .ngpio = 4,
  101. },
  102. .pddr = MCFGPIO_PDDR_FECI2C,
  103. .podr = MCFGPIO_PODR_FECI2C,
  104. .ppdr = MCFGPIO_PPDSDR_FECI2C,
  105. .setr = MCFGPIO_PPDSDR_FECI2C,
  106. .clrr = MCFGPIO_PCLRR_FECI2C,
  107. },
  108. {
  109. .gpio_chip = {
  110. .label = "QSPI",
  111. .request = mcf_gpio_request,
  112. .free = mcf_gpio_free,
  113. .direction_input = mcf_gpio_direction_input,
  114. .direction_output = mcf_gpio_direction_output,
  115. .get = mcf_gpio_get_value,
  116. .set = mcf_gpio_set_value_fast,
  117. .base = 40,
  118. .ngpio = 4,
  119. },
  120. .pddr = MCFGPIO_PDDR_QSPI,
  121. .podr = MCFGPIO_PODR_QSPI,
  122. .ppdr = MCFGPIO_PPDSDR_QSPI,
  123. .setr = MCFGPIO_PPDSDR_QSPI,
  124. .clrr = MCFGPIO_PCLRR_QSPI,
  125. },
  126. {
  127. .gpio_chip = {
  128. .label = "TIMER",
  129. .request = mcf_gpio_request,
  130. .free = mcf_gpio_free,
  131. .direction_input = mcf_gpio_direction_input,
  132. .direction_output = mcf_gpio_direction_output,
  133. .get = mcf_gpio_get_value,
  134. .set = mcf_gpio_set_value_fast,
  135. .base = 48,
  136. .ngpio = 4,
  137. },
  138. .pddr = MCFGPIO_PDDR_TIMER,
  139. .podr = MCFGPIO_PODR_TIMER,
  140. .ppdr = MCFGPIO_PPDSDR_TIMER,
  141. .setr = MCFGPIO_PPDSDR_TIMER,
  142. .clrr = MCFGPIO_PCLRR_TIMER,
  143. },
  144. {
  145. .gpio_chip = {
  146. .label = "UART",
  147. .request = mcf_gpio_request,
  148. .free = mcf_gpio_free,
  149. .direction_input = mcf_gpio_direction_input,
  150. .direction_output = mcf_gpio_direction_output,
  151. .get = mcf_gpio_get_value,
  152. .set = mcf_gpio_set_value_fast,
  153. .base = 56,
  154. .ngpio = 8,
  155. },
  156. .pddr = MCFGPIO_PDDR_UART,
  157. .podr = MCFGPIO_PODR_UART,
  158. .ppdr = MCFGPIO_PPDSDR_UART,
  159. .setr = MCFGPIO_PPDSDR_UART,
  160. .clrr = MCFGPIO_PCLRR_UART,
  161. },
  162. {
  163. .gpio_chip = {
  164. .label = "FECH",
  165. .request = mcf_gpio_request,
  166. .free = mcf_gpio_free,
  167. .direction_input = mcf_gpio_direction_input,
  168. .direction_output = mcf_gpio_direction_output,
  169. .get = mcf_gpio_get_value,
  170. .set = mcf_gpio_set_value_fast,
  171. .base = 64,
  172. .ngpio = 8,
  173. },
  174. .pddr = MCFGPIO_PDDR_FECH,
  175. .podr = MCFGPIO_PODR_FECH,
  176. .ppdr = MCFGPIO_PPDSDR_FECH,
  177. .setr = MCFGPIO_PPDSDR_FECH,
  178. .clrr = MCFGPIO_PCLRR_FECH,
  179. },
  180. {
  181. .gpio_chip = {
  182. .label = "FECL",
  183. .request = mcf_gpio_request,
  184. .free = mcf_gpio_free,
  185. .direction_input = mcf_gpio_direction_input,
  186. .direction_output = mcf_gpio_direction_output,
  187. .get = mcf_gpio_get_value,
  188. .set = mcf_gpio_set_value_fast,
  189. .base = 72,
  190. .ngpio = 8,
  191. },
  192. .pddr = MCFGPIO_PDDR_FECL,
  193. .podr = MCFGPIO_PODR_FECL,
  194. .ppdr = MCFGPIO_PPDSDR_FECL,
  195. .setr = MCFGPIO_PPDSDR_FECL,
  196. .clrr = MCFGPIO_PCLRR_FECL,
  197. },
  198. };
  199. static int __init mcf_gpio_init(void)
  200. {
  201. unsigned i = 0;
  202. while (i < ARRAY_SIZE(mcf_gpio_chips))
  203. (void)gpiochip_add((struct gpio_chip *)&mcf_gpio_chips[i++]);
  204. return 0;
  205. }
  206. core_initcall(mcf_gpio_init);