gpiomux.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. * 02110-1301, USA.
  16. */
  17. #ifndef __ARCH_ARM_MACH_MSM_GPIOMUX_H
  18. #define __ARCH_ARM_MACH_MSM_GPIOMUX_H
  19. #include <linux/bitops.h>
  20. #include <linux/errno.h>
  21. #include <mach/msm_gpiomux.h>
  22. #if defined(CONFIG_MSM_V2_TLMM)
  23. #include "gpiomux-v2.h"
  24. #else
  25. #include "gpiomux-v1.h"
  26. #endif
  27. /**
  28. * struct msm_gpiomux_config: gpiomux settings for one gpio line.
  29. *
  30. * A complete gpiomux config is the bitwise-or of a drive-strength,
  31. * function, and pull. For functions other than GPIO, the OE
  32. * is hard-wired according to the function. For GPIO mode,
  33. * OE is controlled by gpiolib.
  34. *
  35. * Available settings differ by target; see the gpiomux header
  36. * specific to your target arch for available configurations.
  37. *
  38. * @active: The configuration to be installed when the line is
  39. * active, or its reference count is > 0.
  40. * @suspended: The configuration to be installed when the line
  41. * is suspended, or its reference count is 0.
  42. * @ref: The reference count of the line. For internal use of
  43. * the gpiomux framework only.
  44. */
  45. struct msm_gpiomux_config {
  46. gpiomux_config_t active;
  47. gpiomux_config_t suspended;
  48. unsigned ref;
  49. };
  50. /**
  51. * @GPIOMUX_VALID: If set, the config field contains 'good data'.
  52. * The absence of this bit will prevent the gpiomux
  53. * system from applying the configuration under all
  54. * circumstances.
  55. */
  56. enum {
  57. GPIOMUX_VALID = BIT(sizeof(gpiomux_config_t) * BITS_PER_BYTE - 1),
  58. GPIOMUX_CTL_MASK = GPIOMUX_VALID,
  59. };
  60. #ifdef CONFIG_MSM_GPIOMUX
  61. /* Each architecture must provide its own instance of this table.
  62. * To avoid having gpiomux manage any given gpio, one or both of
  63. * the entries can avoid setting GPIOMUX_VALID - the absence
  64. * of that flag will prevent the configuration from being applied
  65. * during state transitions.
  66. */
  67. extern struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS];
  68. /* Install a new configuration to the gpio line. To avoid overwriting
  69. * a configuration, leave the VALID bit out.
  70. */
  71. int msm_gpiomux_write(unsigned gpio,
  72. gpiomux_config_t active,
  73. gpiomux_config_t suspended);
  74. /* Architecture-internal function for use by the framework only.
  75. * This function can assume the following:
  76. * - the gpio value has passed a bounds-check
  77. * - the gpiomux spinlock has been obtained
  78. *
  79. * This function is not for public consumption. External users
  80. * should use msm_gpiomux_write.
  81. */
  82. void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val);
  83. #else
  84. static inline int msm_gpiomux_write(unsigned gpio,
  85. gpiomux_config_t active,
  86. gpiomux_config_t suspended)
  87. {
  88. return -ENOSYS;
  89. }
  90. #endif
  91. #endif