gpio-cfg-helpers.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /* linux/arch/arm/plat-samsung/include/plat/gpio-cfg-helper.h
  2. *
  3. * Copyright 2008 Openmoko, Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * http://armlinux.simtec.co.uk/
  6. * Ben Dooks <ben@simtec.co.uk>
  7. *
  8. * Samsung Platform - GPIO pin configuration helper definitions
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. /* This is meant for core cpu support, machine or other driver files
  15. * should not be including this header.
  16. */
  17. #ifndef __PLAT_GPIO_CFG_HELPERS_H
  18. #define __PLAT_GPIO_CFG_HELPERS_H __FILE__
  19. /* As a note, all gpio configuration functions are entered exclusively, either
  20. * with the relevant lock held or the system prevented from doing anything else
  21. * by disabling interrupts.
  22. */
  23. static inline int samsung_gpio_do_setcfg(struct samsung_gpio_chip *chip,
  24. unsigned int off, unsigned int config)
  25. {
  26. return (chip->config->set_config)(chip, off, config);
  27. }
  28. static inline unsigned samsung_gpio_do_getcfg(struct samsung_gpio_chip *chip,
  29. unsigned int off)
  30. {
  31. return (chip->config->get_config)(chip, off);
  32. }
  33. static inline int samsung_gpio_do_setpull(struct samsung_gpio_chip *chip,
  34. unsigned int off, samsung_gpio_pull_t pull)
  35. {
  36. return (chip->config->set_pull)(chip, off, pull);
  37. }
  38. static inline samsung_gpio_pull_t samsung_gpio_do_getpull(struct samsung_gpio_chip *chip,
  39. unsigned int off)
  40. {
  41. return chip->config->get_pull(chip, off);
  42. }
  43. /* Pull-{up,down} resistor controls.
  44. *
  45. * S3C2410,S3C2440 = Pull-UP,
  46. * S3C2412,S3C2413 = Pull-Down
  47. * S3C6400,S3C6410 = Pull-Both [None,Down,Up,Undef]
  48. * S3C2443 = Pull-Both [not same as S3C6400]
  49. */
  50. /**
  51. * s3c24xx_gpio_setpull_1up() - Pull configuration for choice of up or none.
  52. * @chip: The gpio chip that is being configured.
  53. * @off: The offset for the GPIO being configured.
  54. * @param: pull: The pull mode being requested.
  55. *
  56. * This is a helper function for the case where we have GPIOs with one
  57. * bit configuring the presence of a pull-up resistor.
  58. */
  59. extern int s3c24xx_gpio_setpull_1up(struct samsung_gpio_chip *chip,
  60. unsigned int off, samsung_gpio_pull_t pull);
  61. /**
  62. * s3c24xx_gpio_setpull_1down() - Pull configuration for choice of down or none
  63. * @chip: The gpio chip that is being configured
  64. * @off: The offset for the GPIO being configured
  65. * @param: pull: The pull mode being requested
  66. *
  67. * This is a helper function for the case where we have GPIOs with one
  68. * bit configuring the presence of a pull-down resistor.
  69. */
  70. extern int s3c24xx_gpio_setpull_1down(struct samsung_gpio_chip *chip,
  71. unsigned int off, samsung_gpio_pull_t pull);
  72. /**
  73. * samsung_gpio_setpull_upown() - Pull configuration for choice of up,
  74. * down or none
  75. *
  76. * @chip: The gpio chip that is being configured.
  77. * @off: The offset for the GPIO being configured.
  78. * @param: pull: The pull mode being requested.
  79. *
  80. * This is a helper function for the case where we have GPIOs with two
  81. * bits configuring the presence of a pull resistor, in the following
  82. * order:
  83. * 00 = No pull resistor connected
  84. * 01 = Pull-up resistor connected
  85. * 10 = Pull-down resistor connected
  86. */
  87. extern int samsung_gpio_setpull_updown(struct samsung_gpio_chip *chip,
  88. unsigned int off, samsung_gpio_pull_t pull);
  89. /**
  90. * samsung_gpio_getpull_updown() - Get configuration for choice of up,
  91. * down or none
  92. *
  93. * @chip: The gpio chip that the GPIO pin belongs to
  94. * @off: The offset to the pin to get the configuration of.
  95. *
  96. * This helper function reads the state of the pull-{up,down} resistor
  97. * for the given GPIO in the same case as samsung_gpio_setpull_upown.
  98. */
  99. extern samsung_gpio_pull_t samsung_gpio_getpull_updown(struct samsung_gpio_chip *chip,
  100. unsigned int off);
  101. /**
  102. * s3c24xx_gpio_getpull_1up() - Get configuration for choice of up or none
  103. * @chip: The gpio chip that the GPIO pin belongs to
  104. * @off: The offset to the pin to get the configuration of.
  105. *
  106. * This helper function reads the state of the pull-up resistor for the
  107. * given GPIO in the same case as s3c24xx_gpio_setpull_1up.
  108. */
  109. extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1up(struct samsung_gpio_chip *chip,
  110. unsigned int off);
  111. /**
  112. * s3c24xx_gpio_getpull_1down() - Get configuration for choice of down or none
  113. * @chip: The gpio chip that the GPIO pin belongs to
  114. * @off: The offset to the pin to get the configuration of.
  115. *
  116. * This helper function reads the state of the pull-down resistor for the
  117. * given GPIO in the same case as s3c24xx_gpio_setpull_1down.
  118. */
  119. extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1down(struct samsung_gpio_chip *chip,
  120. unsigned int off);
  121. /**
  122. * s3c2443_gpio_setpull() - Pull configuration for s3c2443.
  123. * @chip: The gpio chip that is being configured.
  124. * @off: The offset for the GPIO being configured.
  125. * @param: pull: The pull mode being requested.
  126. *
  127. * This is a helper function for the case where we have GPIOs with two
  128. * bits configuring the presence of a pull resistor, in the following
  129. * order:
  130. * 00 = Pull-up resistor connected
  131. * 10 = Pull-down resistor connected
  132. * x1 = No pull up resistor
  133. */
  134. extern int s3c2443_gpio_setpull(struct samsung_gpio_chip *chip,
  135. unsigned int off, samsung_gpio_pull_t pull);
  136. /**
  137. * s3c2443_gpio_getpull() - Get configuration for s3c2443 pull resistors
  138. * @chip: The gpio chip that the GPIO pin belongs to.
  139. * @off: The offset to the pin to get the configuration of.
  140. *
  141. * This helper function reads the state of the pull-{up,down} resistor for the
  142. * given GPIO in the same case as samsung_gpio_setpull_upown.
  143. */
  144. extern samsung_gpio_pull_t s3c2443_gpio_getpull(struct samsung_gpio_chip *chip,
  145. unsigned int off);
  146. #endif /* __PLAT_GPIO_CFG_HELPERS_H */