gpio.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (c) 2008 Simtec Electronics
  3. * http://armlinux.simtec.co.uk/
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * S3C2410 - GPIO lib support
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. /* some boards require extra gpio capacity to support external
  13. * devices that need GPIO.
  14. */
  15. #ifndef __MACH_GPIO_H
  16. #define __MACH_GPIO_H __FILE__
  17. #ifdef CONFIG_CPU_S3C244X
  18. #define ARCH_NR_GPIOS (32 * 9 + CONFIG_S3C24XX_GPIO_EXTRA)
  19. #elif defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2416)
  20. #define ARCH_NR_GPIOS (32 * 12 + CONFIG_S3C24XX_GPIO_EXTRA)
  21. #else
  22. #define ARCH_NR_GPIOS (256 + CONFIG_S3C24XX_GPIO_EXTRA)
  23. #endif
  24. /*
  25. * GPIO sizes for various SoCs:
  26. *
  27. * 2410 2412 2440 2443 2416
  28. * 2442
  29. * ---- ---- ---- ---- ----
  30. * A 23 22 25 16 25
  31. * B 11 11 11 11 9
  32. * C 16 15 16 16 16
  33. * D 16 16 16 16 16
  34. * E 16 16 16 16 16
  35. * F 8 8 8 8 8
  36. * G 16 16 16 16 8
  37. * H 11 11 9 15 15
  38. * J -- -- 13 16 --
  39. * K -- -- -- -- 16
  40. * L -- -- -- 15 7
  41. * M -- -- -- 2 2
  42. */
  43. /* GPIO bank sizes */
  44. #define S3C2410_GPIO_A_NR (32)
  45. #define S3C2410_GPIO_B_NR (32)
  46. #define S3C2410_GPIO_C_NR (32)
  47. #define S3C2410_GPIO_D_NR (32)
  48. #define S3C2410_GPIO_E_NR (32)
  49. #define S3C2410_GPIO_F_NR (32)
  50. #define S3C2410_GPIO_G_NR (32)
  51. #define S3C2410_GPIO_H_NR (32)
  52. #define S3C2410_GPIO_J_NR (32) /* technically 16. */
  53. #define S3C2410_GPIO_K_NR (32) /* technically 16. */
  54. #define S3C2410_GPIO_L_NR (32) /* technically 15. */
  55. #define S3C2410_GPIO_M_NR (32) /* technically 2. */
  56. #if CONFIG_S3C_GPIO_SPACE != 0
  57. #error CONFIG_S3C_GPIO_SPACE cannot be nonzero at the moment
  58. #endif
  59. #define S3C2410_GPIO_NEXT(__gpio) \
  60. ((__gpio##_START) + (__gpio##_NR) + CONFIG_S3C_GPIO_SPACE + 0)
  61. #ifndef __ASSEMBLY__
  62. enum s3c_gpio_number {
  63. S3C2410_GPIO_A_START = 0,
  64. S3C2410_GPIO_B_START = S3C2410_GPIO_NEXT(S3C2410_GPIO_A),
  65. S3C2410_GPIO_C_START = S3C2410_GPIO_NEXT(S3C2410_GPIO_B),
  66. S3C2410_GPIO_D_START = S3C2410_GPIO_NEXT(S3C2410_GPIO_C),
  67. S3C2410_GPIO_E_START = S3C2410_GPIO_NEXT(S3C2410_GPIO_D),
  68. S3C2410_GPIO_F_START = S3C2410_GPIO_NEXT(S3C2410_GPIO_E),
  69. S3C2410_GPIO_G_START = S3C2410_GPIO_NEXT(S3C2410_GPIO_F),
  70. S3C2410_GPIO_H_START = S3C2410_GPIO_NEXT(S3C2410_GPIO_G),
  71. S3C2410_GPIO_J_START = S3C2410_GPIO_NEXT(S3C2410_GPIO_H),
  72. S3C2410_GPIO_K_START = S3C2410_GPIO_NEXT(S3C2410_GPIO_J),
  73. S3C2410_GPIO_L_START = S3C2410_GPIO_NEXT(S3C2410_GPIO_K),
  74. S3C2410_GPIO_M_START = S3C2410_GPIO_NEXT(S3C2410_GPIO_L),
  75. };
  76. #endif /* __ASSEMBLY__ */
  77. /* S3C2410 GPIO number definitions. */
  78. #define S3C2410_GPA(_nr) (S3C2410_GPIO_A_START + (_nr))
  79. #define S3C2410_GPB(_nr) (S3C2410_GPIO_B_START + (_nr))
  80. #define S3C2410_GPC(_nr) (S3C2410_GPIO_C_START + (_nr))
  81. #define S3C2410_GPD(_nr) (S3C2410_GPIO_D_START + (_nr))
  82. #define S3C2410_GPE(_nr) (S3C2410_GPIO_E_START + (_nr))
  83. #define S3C2410_GPF(_nr) (S3C2410_GPIO_F_START + (_nr))
  84. #define S3C2410_GPG(_nr) (S3C2410_GPIO_G_START + (_nr))
  85. #define S3C2410_GPH(_nr) (S3C2410_GPIO_H_START + (_nr))
  86. #define S3C2410_GPJ(_nr) (S3C2410_GPIO_J_START + (_nr))
  87. #define S3C2410_GPK(_nr) (S3C2410_GPIO_K_START + (_nr))
  88. #define S3C2410_GPL(_nr) (S3C2410_GPIO_L_START + (_nr))
  89. #define S3C2410_GPM(_nr) (S3C2410_GPIO_M_START + (_nr))
  90. #include <plat/gpio-cfg.h>
  91. #ifdef CONFIG_CPU_S3C244X
  92. #define S3C_GPIO_END (S3C2410_GPJ(0) + 32)
  93. #elif defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2416)
  94. #define S3C_GPIO_END (S3C2410_GPM(0) + 32)
  95. #else
  96. #define S3C_GPIO_END (S3C2410_GPH(0) + 32)
  97. #endif
  98. #endif /* __MACH_GPIO_H */