pinctrl-amd.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. * GPIO driver for AMD
  3. *
  4. * Copyright (c) 2014,2015 Ken Xue <Ken.Xue@amd.com>
  5. * Jeff Wu <Jeff.Wu@amd.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms and conditions of the GNU General Public License,
  9. * version 2, as published by the Free Software Foundation.
  10. *
  11. */
  12. #ifndef _PINCTRL_AMD_H
  13. #define _PINCTRL_AMD_H
  14. #define AMD_GPIO_PINS_PER_BANK 64
  15. #define AMD_GPIO_PINS_BANK0 63
  16. #define AMD_GPIO_PINS_BANK1 64
  17. #define AMD_GPIO_PINS_BANK2 56
  18. #define AMD_GPIO_PINS_BANK3 32
  19. #define WAKE_INT_MASTER_REG 0xfc
  20. #define EOI_MASK (1 << 29)
  21. #define WAKE_INT_STATUS_REG0 0x2f8
  22. #define WAKE_INT_STATUS_REG1 0x2fc
  23. #define DB_TMR_OUT_OFF 0
  24. #define DB_TMR_OUT_UNIT_OFF 4
  25. #define DB_CNTRL_OFF 5
  26. #define DB_TMR_LARGE_OFF 7
  27. #define LEVEL_TRIG_OFF 8
  28. #define ACTIVE_LEVEL_OFF 9
  29. #define INTERRUPT_ENABLE_OFF 11
  30. #define INTERRUPT_MASK_OFF 12
  31. #define WAKE_CNTRL_OFF_S0I3 13
  32. #define WAKE_CNTRL_OFF_S3 14
  33. #define WAKE_CNTRL_OFF_S4 15
  34. #define PIN_STS_OFF 16
  35. #define DRV_STRENGTH_SEL_OFF 17
  36. #define PULL_UP_SEL_OFF 19
  37. #define PULL_UP_ENABLE_OFF 20
  38. #define PULL_DOWN_ENABLE_OFF 21
  39. #define OUTPUT_VALUE_OFF 22
  40. #define OUTPUT_ENABLE_OFF 23
  41. #define SW_CNTRL_IN_OFF 24
  42. #define SW_CNTRL_EN_OFF 25
  43. #define INTERRUPT_STS_OFF 28
  44. #define WAKE_STS_OFF 29
  45. #define DB_TMR_OUT_MASK 0xFUL
  46. #define DB_CNTRl_MASK 0x3UL
  47. #define ACTIVE_LEVEL_MASK 0x3UL
  48. #define DRV_STRENGTH_SEL_MASK 0x3UL
  49. #define DB_TYPE_NO_DEBOUNCE 0x0UL
  50. #define DB_TYPE_PRESERVE_LOW_GLITCH 0x1UL
  51. #define DB_TYPE_PRESERVE_HIGH_GLITCH 0x2UL
  52. #define DB_TYPE_REMOVE_GLITCH 0x3UL
  53. #define EDGE_TRAGGER 0x0UL
  54. #define LEVEL_TRIGGER 0x1UL
  55. #define ACTIVE_HIGH 0x0UL
  56. #define ACTIVE_LOW 0x1UL
  57. #define BOTH_EADGE 0x2UL
  58. #define ENABLE_INTERRUPT 0x1UL
  59. #define DISABLE_INTERRUPT 0x0UL
  60. #define ENABLE_INTERRUPT_MASK 0x0UL
  61. #define DISABLE_INTERRUPT_MASK 0x1UL
  62. #define CLR_INTR_STAT 0x1UL
  63. struct amd_pingroup {
  64. const char *name;
  65. const unsigned *pins;
  66. unsigned npins;
  67. };
  68. struct amd_function {
  69. const char *name;
  70. const char * const *groups;
  71. unsigned ngroups;
  72. };
  73. struct amd_gpio {
  74. raw_spinlock_t lock;
  75. void __iomem *base;
  76. const struct amd_pingroup *groups;
  77. u32 ngroups;
  78. struct pinctrl_dev *pctrl;
  79. struct gpio_chip gc;
  80. unsigned int hwbank_num;
  81. struct resource *res;
  82. struct platform_device *pdev;
  83. u32 *saved_regs;
  84. };
  85. /* KERNCZ configuration*/
  86. static const struct pinctrl_pin_desc kerncz_pins[] = {
  87. PINCTRL_PIN(0, "GPIO_0"),
  88. PINCTRL_PIN(1, "GPIO_1"),
  89. PINCTRL_PIN(2, "GPIO_2"),
  90. PINCTRL_PIN(3, "GPIO_3"),
  91. PINCTRL_PIN(4, "GPIO_4"),
  92. PINCTRL_PIN(5, "GPIO_5"),
  93. PINCTRL_PIN(6, "GPIO_6"),
  94. PINCTRL_PIN(7, "GPIO_7"),
  95. PINCTRL_PIN(8, "GPIO_8"),
  96. PINCTRL_PIN(9, "GPIO_9"),
  97. PINCTRL_PIN(10, "GPIO_10"),
  98. PINCTRL_PIN(11, "GPIO_11"),
  99. PINCTRL_PIN(12, "GPIO_12"),
  100. PINCTRL_PIN(13, "GPIO_13"),
  101. PINCTRL_PIN(14, "GPIO_14"),
  102. PINCTRL_PIN(15, "GPIO_15"),
  103. PINCTRL_PIN(16, "GPIO_16"),
  104. PINCTRL_PIN(17, "GPIO_17"),
  105. PINCTRL_PIN(18, "GPIO_18"),
  106. PINCTRL_PIN(19, "GPIO_19"),
  107. PINCTRL_PIN(20, "GPIO_20"),
  108. PINCTRL_PIN(23, "GPIO_23"),
  109. PINCTRL_PIN(24, "GPIO_24"),
  110. PINCTRL_PIN(25, "GPIO_25"),
  111. PINCTRL_PIN(26, "GPIO_26"),
  112. PINCTRL_PIN(39, "GPIO_39"),
  113. PINCTRL_PIN(40, "GPIO_40"),
  114. PINCTRL_PIN(43, "GPIO_42"),
  115. PINCTRL_PIN(46, "GPIO_46"),
  116. PINCTRL_PIN(47, "GPIO_47"),
  117. PINCTRL_PIN(48, "GPIO_48"),
  118. PINCTRL_PIN(49, "GPIO_49"),
  119. PINCTRL_PIN(50, "GPIO_50"),
  120. PINCTRL_PIN(51, "GPIO_51"),
  121. PINCTRL_PIN(52, "GPIO_52"),
  122. PINCTRL_PIN(53, "GPIO_53"),
  123. PINCTRL_PIN(54, "GPIO_54"),
  124. PINCTRL_PIN(55, "GPIO_55"),
  125. PINCTRL_PIN(56, "GPIO_56"),
  126. PINCTRL_PIN(57, "GPIO_57"),
  127. PINCTRL_PIN(58, "GPIO_58"),
  128. PINCTRL_PIN(59, "GPIO_59"),
  129. PINCTRL_PIN(60, "GPIO_60"),
  130. PINCTRL_PIN(61, "GPIO_61"),
  131. PINCTRL_PIN(62, "GPIO_62"),
  132. PINCTRL_PIN(64, "GPIO_64"),
  133. PINCTRL_PIN(65, "GPIO_65"),
  134. PINCTRL_PIN(66, "GPIO_66"),
  135. PINCTRL_PIN(68, "GPIO_68"),
  136. PINCTRL_PIN(69, "GPIO_69"),
  137. PINCTRL_PIN(70, "GPIO_70"),
  138. PINCTRL_PIN(71, "GPIO_71"),
  139. PINCTRL_PIN(72, "GPIO_72"),
  140. PINCTRL_PIN(74, "GPIO_74"),
  141. PINCTRL_PIN(75, "GPIO_75"),
  142. PINCTRL_PIN(76, "GPIO_76"),
  143. PINCTRL_PIN(84, "GPIO_84"),
  144. PINCTRL_PIN(85, "GPIO_85"),
  145. PINCTRL_PIN(86, "GPIO_86"),
  146. PINCTRL_PIN(87, "GPIO_87"),
  147. PINCTRL_PIN(88, "GPIO_88"),
  148. PINCTRL_PIN(89, "GPIO_89"),
  149. PINCTRL_PIN(90, "GPIO_90"),
  150. PINCTRL_PIN(91, "GPIO_91"),
  151. PINCTRL_PIN(92, "GPIO_92"),
  152. PINCTRL_PIN(93, "GPIO_93"),
  153. PINCTRL_PIN(95, "GPIO_95"),
  154. PINCTRL_PIN(96, "GPIO_96"),
  155. PINCTRL_PIN(97, "GPIO_97"),
  156. PINCTRL_PIN(98, "GPIO_98"),
  157. PINCTRL_PIN(99, "GPIO_99"),
  158. PINCTRL_PIN(100, "GPIO_100"),
  159. PINCTRL_PIN(101, "GPIO_101"),
  160. PINCTRL_PIN(102, "GPIO_102"),
  161. PINCTRL_PIN(113, "GPIO_113"),
  162. PINCTRL_PIN(114, "GPIO_114"),
  163. PINCTRL_PIN(115, "GPIO_115"),
  164. PINCTRL_PIN(116, "GPIO_116"),
  165. PINCTRL_PIN(117, "GPIO_117"),
  166. PINCTRL_PIN(118, "GPIO_118"),
  167. PINCTRL_PIN(119, "GPIO_119"),
  168. PINCTRL_PIN(120, "GPIO_120"),
  169. PINCTRL_PIN(121, "GPIO_121"),
  170. PINCTRL_PIN(122, "GPIO_122"),
  171. PINCTRL_PIN(126, "GPIO_126"),
  172. PINCTRL_PIN(129, "GPIO_129"),
  173. PINCTRL_PIN(130, "GPIO_130"),
  174. PINCTRL_PIN(131, "GPIO_131"),
  175. PINCTRL_PIN(132, "GPIO_132"),
  176. PINCTRL_PIN(133, "GPIO_133"),
  177. PINCTRL_PIN(135, "GPIO_135"),
  178. PINCTRL_PIN(136, "GPIO_136"),
  179. PINCTRL_PIN(137, "GPIO_137"),
  180. PINCTRL_PIN(138, "GPIO_138"),
  181. PINCTRL_PIN(139, "GPIO_139"),
  182. PINCTRL_PIN(140, "GPIO_140"),
  183. PINCTRL_PIN(141, "GPIO_141"),
  184. PINCTRL_PIN(142, "GPIO_142"),
  185. PINCTRL_PIN(143, "GPIO_143"),
  186. PINCTRL_PIN(144, "GPIO_144"),
  187. PINCTRL_PIN(145, "GPIO_145"),
  188. PINCTRL_PIN(146, "GPIO_146"),
  189. PINCTRL_PIN(147, "GPIO_147"),
  190. PINCTRL_PIN(148, "GPIO_148"),
  191. PINCTRL_PIN(166, "GPIO_166"),
  192. PINCTRL_PIN(167, "GPIO_167"),
  193. PINCTRL_PIN(168, "GPIO_168"),
  194. PINCTRL_PIN(169, "GPIO_169"),
  195. PINCTRL_PIN(170, "GPIO_170"),
  196. PINCTRL_PIN(171, "GPIO_171"),
  197. PINCTRL_PIN(172, "GPIO_172"),
  198. PINCTRL_PIN(173, "GPIO_173"),
  199. PINCTRL_PIN(174, "GPIO_174"),
  200. PINCTRL_PIN(175, "GPIO_175"),
  201. PINCTRL_PIN(176, "GPIO_176"),
  202. PINCTRL_PIN(177, "GPIO_177"),
  203. };
  204. static const unsigned i2c0_pins[] = {145, 146};
  205. static const unsigned i2c1_pins[] = {147, 148};
  206. static const unsigned i2c2_pins[] = {113, 114};
  207. static const unsigned i2c3_pins[] = {19, 20};
  208. static const unsigned uart0_pins[] = {135, 136, 137, 138, 139};
  209. static const unsigned uart1_pins[] = {140, 141, 142, 143, 144};
  210. static const struct amd_pingroup kerncz_groups[] = {
  211. {
  212. .name = "i2c0",
  213. .pins = i2c0_pins,
  214. .npins = 2,
  215. },
  216. {
  217. .name = "i2c1",
  218. .pins = i2c1_pins,
  219. .npins = 2,
  220. },
  221. {
  222. .name = "i2c2",
  223. .pins = i2c2_pins,
  224. .npins = 2,
  225. },
  226. {
  227. .name = "i2c3",
  228. .pins = i2c3_pins,
  229. .npins = 2,
  230. },
  231. {
  232. .name = "uart0",
  233. .pins = uart0_pins,
  234. .npins = 5,
  235. },
  236. {
  237. .name = "uart1",
  238. .pins = uart1_pins,
  239. .npins = 5,
  240. },
  241. };
  242. #endif