pinconf-generic.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Interface the generic pinconfig portions of the pinctrl subsystem
  3. *
  4. * Copyright (C) 2011 ST-Ericsson SA
  5. * Written on behalf of Linaro for ST-Ericsson
  6. * This interface is used in the core to keep track of pins.
  7. *
  8. * Author: Linus Walleij <linus.walleij@linaro.org>
  9. *
  10. * License terms: GNU General Public License (GPL) version 2
  11. */
  12. #ifndef __LINUX_PINCTRL_PINCONF_GENERIC_H
  13. #define __LINUX_PINCTRL_PINCONF_GENERIC_H
  14. /*
  15. * You shouldn't even be able to compile with these enums etc unless you're
  16. * using generic pin config. That is why this is defined out.
  17. */
  18. #ifdef CONFIG_GENERIC_PINCONF
  19. /**
  20. * enum pin_config_param - possible pin configuration parameters
  21. * @PIN_CONFIG_BIAS_DISABLE: disable any pin bias on the pin, a
  22. * transition from say pull-up to pull-down implies that you disable
  23. * pull-up in the process, this setting disables all biasing.
  24. * @PIN_CONFIG_BIAS_HIGH_IMPEDANCE: the pin will be set to a high impedance
  25. * mode, also know as "third-state" (tristate) or "high-Z" or "floating".
  26. * On output pins this effectively disconnects the pin, which is useful
  27. * if for example some other pin is going to drive the signal connected
  28. * to it for a while. Pins used for input are usually always high
  29. * impedance.
  30. * @PIN_CONFIG_BIAS_PULL_UP: the pin will be pulled up (usually with high
  31. * impedance to VDD). If the argument is != 0 pull-up is enabled,
  32. * if it is 0, pull-up is disabled.
  33. * @PIN_CONFIG_BIAS_PULL_DOWN: the pin will be pulled down (usually with high
  34. * impedance to GROUND). If the argument is != 0 pull-down is enabled,
  35. * if it is 0, pull-down is disabled.
  36. * @PIN_CONFIG_DRIVE_PUSH_PULL: the pin will be driven actively high and
  37. * low, this is the most typical case and is typically achieved with two
  38. * active transistors on the output. Sending this config will enabale
  39. * push-pull mode, the argument is ignored.
  40. * @PIN_CONFIG_DRIVE_OPEN_DRAIN: the pin will be driven with open drain (open
  41. * collector) which means it is usually wired with other output ports
  42. * which are then pulled up with an external resistor. Sending this
  43. * config will enabale open drain mode, the argument is ignored.
  44. * @PIN_CONFIG_DRIVE_OPEN_SOURCE: the pin will be driven with open source
  45. * (open emitter). Sending this config will enabale open drain mode, the
  46. * argument is ignored.
  47. * @PIN_CONFIG_DRIVE_STRENGTH: the pin will output the current passed as
  48. * argument. The argument is in mA.
  49. * @PIN_CONFIG_INPUT_SCHMITT_ENABLE: control schmitt-trigger mode on the pin.
  50. * If the argument != 0, schmitt-trigger mode is enabled. If it's 0,
  51. * schmitt-trigger mode is disabled.
  52. * @PIN_CONFIG_INPUT_SCHMITT: this will configure an input pin to run in
  53. * schmitt-trigger mode. If the schmitt-trigger has adjustable hysteresis,
  54. * the threshold value is given on a custom format as argument when
  55. * setting pins to this mode.
  56. * @PIN_CONFIG_INPUT_DEBOUNCE: this will configure the pin to debounce mode,
  57. * which means it will wait for signals to settle when reading inputs. The
  58. * argument gives the debounce time on a custom format. Setting the
  59. * argument to zero turns debouncing off.
  60. * @PIN_CONFIG_POWER_SOURCE: if the pin can select between different power
  61. * supplies, the argument to this parameter (on a custom format) tells
  62. * the driver which alternative power source to use.
  63. * @PIN_CONFIG_SLEW_RATE: if the pin can select slew rate, the argument to
  64. * this parameter (on a custom format) tells the driver which alternative
  65. * slew rate to use.
  66. * @PIN_CONFIG_LOW_POWER_MODE: this will configure the pin for low power
  67. * operation, if several modes of operation are supported these can be
  68. * passed in the argument on a custom form, else just use argument 1
  69. * to indicate low power mode, argument 0 turns low power mode off.
  70. * @PIN_CONFIG_OUTPUT: this will configure the pin in output, use argument
  71. * 1 to indicate high level, argument 0 to indicate low level.
  72. * @PIN_CONFIG_END: this is the last enumerator for pin configurations, if
  73. * you need to pass in custom configurations to the pin controller, use
  74. * PIN_CONFIG_END+1 as the base offset.
  75. */
  76. enum pin_config_param {
  77. PIN_CONFIG_BIAS_DISABLE,
  78. PIN_CONFIG_BIAS_HIGH_IMPEDANCE,
  79. PIN_CONFIG_BIAS_PULL_UP,
  80. PIN_CONFIG_BIAS_PULL_DOWN,
  81. PIN_CONFIG_DRIVE_PUSH_PULL,
  82. PIN_CONFIG_DRIVE_OPEN_DRAIN,
  83. PIN_CONFIG_DRIVE_OPEN_SOURCE,
  84. PIN_CONFIG_DRIVE_STRENGTH,
  85. PIN_CONFIG_INPUT_SCHMITT_ENABLE,
  86. PIN_CONFIG_INPUT_SCHMITT,
  87. PIN_CONFIG_INPUT_DEBOUNCE,
  88. PIN_CONFIG_POWER_SOURCE,
  89. PIN_CONFIG_SLEW_RATE,
  90. PIN_CONFIG_LOW_POWER_MODE,
  91. PIN_CONFIG_OUTPUT,
  92. PIN_CONFIG_END = 0x7FFF,
  93. };
  94. /*
  95. * Helpful configuration macro to be used in tables etc.
  96. */
  97. #define PIN_CONF_PACKED(p, a) ((a << 16) | ((unsigned long) p & 0xffffUL))
  98. /*
  99. * The following inlines stuffs a configuration parameter and data value
  100. * into and out of an unsigned long argument, as used by the generic pin config
  101. * system. We put the parameter in the lower 16 bits and the argument in the
  102. * upper 16 bits.
  103. */
  104. static inline enum pin_config_param pinconf_to_config_param(unsigned long config)
  105. {
  106. return (enum pin_config_param) (config & 0xffffUL);
  107. }
  108. static inline u16 pinconf_to_config_argument(unsigned long config)
  109. {
  110. return (enum pin_config_param) ((config >> 16) & 0xffffUL);
  111. }
  112. static inline unsigned long pinconf_to_config_packed(enum pin_config_param param,
  113. u16 argument)
  114. {
  115. return PIN_CONF_PACKED(param, argument);
  116. }
  117. #endif /* CONFIG_GENERIC_PINCONF */
  118. #endif /* __LINUX_PINCTRL_PINCONF_GENERIC_H */