pinctrl-mt7986.c 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * The MT7986 driver based on Linux generic pinctrl binding.
  4. *
  5. * Copyright (C) 2021 MediaTek Inc.
  6. * Author: Sam Shih <[email protected]>
  7. */
  8. #include "pinctrl-moore.h"
  9. #define MT7986_PIN(_number, _name) MTK_PIN(_number, _name, 0, _number, DRV_GRP4)
  10. #define MT7986_NOT_BALLOUT_PIN(_number) { .number = _number, .name = NULL }
  11. #define PIN_FIELD_BASE(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, \
  12. _x_bits) \
  13. PIN_FIELD_CALC(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, \
  14. _x_bits, 32, 0)
  15. /**
  16. * enum - Locking variants of the iocfg bases
  17. *
  18. * MT7986 have multiple bases to program pin configuration listed as the below:
  19. * iocfg_rt:0x11c30000, iocfg_rb:0x11c40000, iocfg_lt:0x11e20000,
  20. * iocfg_lb:0x11e30000, iocfg_tr:0x11f00000, iocfg_tl:0x11f10000,
  21. * _i_based could be used to indicate what base the pin should be mapped into.
  22. *
  23. * Each iocfg register base control different group of pads on the SoC
  24. *
  25. *
  26. * chip carrier
  27. *
  28. * A B C D E F G H
  29. * +------------------------+
  30. * 8 | o o o o o o o o |
  31. * 7 | o o o o o o o o |
  32. * 6 | o o o o o o o o |
  33. * 5 | o o o o o o o o |
  34. * 4 | o o o o o o o o |
  35. * 3 | o o o o o o o o |
  36. * 2 | o o o o o o o o |
  37. * 1 | o o o o o o o o |
  38. * +------------------------+
  39. *
  40. * inside Chip carrier
  41. *
  42. * A B C D E F G H
  43. * +------------------------+
  44. * 8 | |
  45. * 7 | TL TR |
  46. * 6 | +---------+ |
  47. * 5 | LT | | RT |
  48. * 4 | | | |
  49. * 3 | LB | | RB |
  50. * 2 | +---------+ |
  51. * 1 | |
  52. * +------------------------+
  53. *
  54. */
  55. enum {
  56. GPIO_BASE,
  57. IOCFG_RT_BASE,
  58. IOCFG_RB_BASE,
  59. IOCFG_LT_BASE,
  60. IOCFG_LB_BASE,
  61. IOCFG_TR_BASE,
  62. IOCFG_TL_BASE,
  63. };
  64. static const char *const mt7986_pinctrl_register_base_names[] = {
  65. "gpio", "iocfg_rt", "iocfg_rb", "iocfg_lt", "iocfg_lb", "iocfg_tr",
  66. "iocfg_tl",
  67. };
  68. static const struct mtk_pin_field_calc mt7986_pin_mode_range[] = {
  69. PIN_FIELD(0, 100, 0x300, 0x10, 0, 4),
  70. };
  71. static const struct mtk_pin_field_calc mt7986_pin_dir_range[] = {
  72. PIN_FIELD(0, 100, 0x0, 0x10, 0, 1),
  73. };
  74. static const struct mtk_pin_field_calc mt7986_pin_di_range[] = {
  75. PIN_FIELD(0, 100, 0x200, 0x10, 0, 1),
  76. };
  77. static const struct mtk_pin_field_calc mt7986_pin_do_range[] = {
  78. PIN_FIELD(0, 100, 0x100, 0x10, 0, 1),
  79. };
  80. static const struct mtk_pin_field_calc mt7986_pin_ies_range[] = {
  81. PIN_FIELD_BASE(0, 0, IOCFG_RB_BASE, 0x40, 0x10, 17, 1),
  82. PIN_FIELD_BASE(1, 2, IOCFG_LT_BASE, 0x20, 0x10, 10, 1),
  83. PIN_FIELD_BASE(3, 4, IOCFG_LB_BASE, 0x20, 0x10, 0, 1),
  84. PIN_FIELD_BASE(5, 6, IOCFG_RB_BASE, 0x40, 0x10, 0, 1),
  85. PIN_FIELD_BASE(7, 10, IOCFG_LT_BASE, 0x20, 0x10, 0, 1),
  86. PIN_FIELD_BASE(11, 14, IOCFG_RB_BASE, 0x40, 0x10, 8, 1),
  87. PIN_FIELD_BASE(15, 20, IOCFG_RB_BASE, 0x40, 0x10, 2, 1),
  88. PIN_FIELD_BASE(21, 23, IOCFG_RT_BASE, 0x30, 0x10, 12, 1),
  89. PIN_FIELD_BASE(24, 24, IOCFG_RT_BASE, 0x30, 0x10, 18, 1),
  90. PIN_FIELD_BASE(25, 25, IOCFG_RT_BASE, 0x30, 0x10, 17, 1),
  91. PIN_FIELD_BASE(26, 27, IOCFG_RT_BASE, 0x30, 0x10, 15, 1),
  92. PIN_FIELD_BASE(28, 29, IOCFG_RT_BASE, 0x30, 0x10, 19, 1),
  93. PIN_FIELD_BASE(30, 30, IOCFG_RT_BASE, 0x30, 0x10, 23, 1),
  94. PIN_FIELD_BASE(31, 31, IOCFG_RT_BASE, 0x30, 0x10, 22, 1),
  95. PIN_FIELD_BASE(32, 32, IOCFG_RT_BASE, 0x30, 0x10, 21, 1),
  96. PIN_FIELD_BASE(33, 33, IOCFG_LT_BASE, 0x20, 0x10, 4, 1),
  97. PIN_FIELD_BASE(34, 34, IOCFG_LT_BASE, 0x20, 0x10, 8, 1),
  98. PIN_FIELD_BASE(35, 35, IOCFG_LT_BASE, 0x20, 0x10, 7, 1),
  99. PIN_FIELD_BASE(36, 37, IOCFG_LT_BASE, 0x20, 0x10, 5, 1),
  100. PIN_FIELD_BASE(38, 38, IOCFG_LT_BASE, 0x20, 0x10, 9, 1),
  101. PIN_FIELD_BASE(39, 40, IOCFG_RB_BASE, 0x40, 0x10, 18, 1),
  102. PIN_FIELD_BASE(41, 41, IOCFG_RB_BASE, 0x40, 0x10, 12, 1),
  103. PIN_FIELD_BASE(42, 43, IOCFG_RB_BASE, 0x40, 0x10, 22, 1),
  104. PIN_FIELD_BASE(44, 45, IOCFG_RB_BASE, 0x40, 0x10, 20, 1),
  105. PIN_FIELD_BASE(46, 47, IOCFG_RB_BASE, 0x40, 0x10, 26, 1),
  106. PIN_FIELD_BASE(48, 49, IOCFG_RB_BASE, 0x40, 0x10, 24, 1),
  107. PIN_FIELD_BASE(50, 57, IOCFG_RT_BASE, 0x30, 0x10, 2, 1),
  108. PIN_FIELD_BASE(58, 58, IOCFG_RT_BASE, 0x30, 0x10, 1, 1),
  109. PIN_FIELD_BASE(59, 59, IOCFG_RT_BASE, 0x30, 0x10, 0, 1),
  110. PIN_FIELD_BASE(60, 61, IOCFG_RT_BASE, 0x30, 0x10, 10, 1),
  111. PIN_FIELD_BASE(62, 62, IOCFG_RB_BASE, 0x40, 0x10, 15, 1),
  112. PIN_FIELD_BASE(63, 63, IOCFG_RB_BASE, 0x40, 0x10, 14, 1),
  113. PIN_FIELD_BASE(64, 64, IOCFG_RB_BASE, 0x40, 0x10, 13, 1),
  114. PIN_FIELD_BASE(65, 65, IOCFG_RB_BASE, 0x40, 0x10, 16, 1),
  115. PIN_FIELD_BASE(66, 68, IOCFG_LB_BASE, 0x20, 0x10, 2, 1),
  116. PIN_FIELD_BASE(69, 69, IOCFG_TR_BASE, 0x30, 0x10, 1, 1),
  117. PIN_FIELD_BASE(70, 70, IOCFG_TR_BASE, 0x30, 0x10, 0, 1),
  118. PIN_FIELD_BASE(71, 71, IOCFG_TR_BASE, 0x30, 0x10, 16, 1),
  119. PIN_FIELD_BASE(72, 73, IOCFG_TR_BASE, 0x30, 0x10, 14, 1),
  120. PIN_FIELD_BASE(74, 74, IOCFG_TR_BASE, 0x30, 0x10, 4, 1),
  121. PIN_FIELD_BASE(75, 77, IOCFG_TR_BASE, 0x30, 0x10, 6, 1),
  122. PIN_FIELD_BASE(78, 79, IOCFG_TR_BASE, 0x30, 0x10, 2, 1),
  123. PIN_FIELD_BASE(80, 84, IOCFG_TR_BASE, 0x30, 0x10, 9, 1),
  124. PIN_FIELD_BASE(85, 85, IOCFG_TR_BASE, 0x30, 0x10, 5, 1),
  125. PIN_FIELD_BASE(86, 86, IOCFG_TL_BASE, 0x30, 0x10, 1, 1),
  126. PIN_FIELD_BASE(87, 87, IOCFG_TL_BASE, 0x30, 0x10, 0, 1),
  127. PIN_FIELD_BASE(88, 88, IOCFG_TL_BASE, 0x30, 0x10, 14, 1),
  128. PIN_FIELD_BASE(89, 90, IOCFG_TL_BASE, 0x30, 0x10, 12, 1),
  129. PIN_FIELD_BASE(91, 94, IOCFG_TL_BASE, 0x30, 0x10, 4, 1),
  130. PIN_FIELD_BASE(95, 96, IOCFG_TL_BASE, 0x30, 0x10, 2, 1),
  131. PIN_FIELD_BASE(97, 100, IOCFG_TL_BASE, 0x30, 0x10, 8, 1),
  132. };
  133. static const struct mtk_pin_field_calc mt7986_pin_smt_range[] = {
  134. PIN_FIELD_BASE(0, 0, IOCFG_RB_BASE, 0xf0, 0x10, 17, 1),
  135. PIN_FIELD_BASE(1, 2, IOCFG_LT_BASE, 0x90, 0x10, 10, 1),
  136. PIN_FIELD_BASE(3, 4, IOCFG_LB_BASE, 0x90, 0x10, 0, 1),
  137. PIN_FIELD_BASE(5, 6, IOCFG_RB_BASE, 0xf0, 0x10, 0, 1),
  138. PIN_FIELD_BASE(7, 10, IOCFG_LT_BASE, 0x90, 0x10, 0, 1),
  139. PIN_FIELD_BASE(11, 14, IOCFG_RB_BASE, 0xf0, 0x10, 8, 1),
  140. PIN_FIELD_BASE(15, 20, IOCFG_RB_BASE, 0xf0, 0x10, 2, 1),
  141. PIN_FIELD_BASE(21, 23, IOCFG_RT_BASE, 0xc0, 0x10, 12, 1),
  142. PIN_FIELD_BASE(24, 24, IOCFG_RT_BASE, 0xc0, 0x10, 18, 1),
  143. PIN_FIELD_BASE(25, 25, IOCFG_RT_BASE, 0xc0, 0x10, 17, 1),
  144. PIN_FIELD_BASE(26, 27, IOCFG_RT_BASE, 0xc0, 0x10, 15, 1),
  145. PIN_FIELD_BASE(28, 29, IOCFG_RT_BASE, 0xc0, 0x10, 19, 1),
  146. PIN_FIELD_BASE(30, 30, IOCFG_RT_BASE, 0xc0, 0x10, 23, 1),
  147. PIN_FIELD_BASE(31, 31, IOCFG_RT_BASE, 0xc0, 0x10, 22, 1),
  148. PIN_FIELD_BASE(32, 32, IOCFG_RT_BASE, 0xc0, 0x10, 21, 1),
  149. PIN_FIELD_BASE(33, 33, IOCFG_LT_BASE, 0x90, 0x10, 4, 1),
  150. PIN_FIELD_BASE(34, 34, IOCFG_LT_BASE, 0x90, 0x10, 8, 1),
  151. PIN_FIELD_BASE(35, 35, IOCFG_LT_BASE, 0x90, 0x10, 7, 1),
  152. PIN_FIELD_BASE(36, 37, IOCFG_LT_BASE, 0x90, 0x10, 5, 1),
  153. PIN_FIELD_BASE(38, 38, IOCFG_LT_BASE, 0x90, 0x10, 9, 1),
  154. PIN_FIELD_BASE(39, 40, IOCFG_RB_BASE, 0xf0, 0x10, 18, 1),
  155. PIN_FIELD_BASE(41, 41, IOCFG_RB_BASE, 0xf0, 0x10, 12, 1),
  156. PIN_FIELD_BASE(42, 43, IOCFG_RB_BASE, 0xf0, 0x10, 22, 1),
  157. PIN_FIELD_BASE(44, 45, IOCFG_RB_BASE, 0xf0, 0x10, 20, 1),
  158. PIN_FIELD_BASE(46, 47, IOCFG_RB_BASE, 0xf0, 0x10, 26, 1),
  159. PIN_FIELD_BASE(48, 49, IOCFG_RB_BASE, 0xf0, 0x10, 24, 1),
  160. PIN_FIELD_BASE(50, 57, IOCFG_RT_BASE, 0xc0, 0x10, 2, 1),
  161. PIN_FIELD_BASE(58, 58, IOCFG_RT_BASE, 0xc0, 0x10, 1, 1),
  162. PIN_FIELD_BASE(59, 59, IOCFG_RT_BASE, 0xc0, 0x10, 0, 1),
  163. PIN_FIELD_BASE(60, 61, IOCFG_RT_BASE, 0xc0, 0x10, 10, 1),
  164. PIN_FIELD_BASE(62, 62, IOCFG_RB_BASE, 0xf0, 0x10, 15, 1),
  165. PIN_FIELD_BASE(63, 63, IOCFG_RB_BASE, 0xf0, 0x10, 14, 1),
  166. PIN_FIELD_BASE(64, 64, IOCFG_RB_BASE, 0xf0, 0x10, 13, 1),
  167. PIN_FIELD_BASE(65, 65, IOCFG_RB_BASE, 0xf0, 0x10, 16, 1),
  168. PIN_FIELD_BASE(66, 68, IOCFG_LB_BASE, 0x90, 0x10, 2, 1),
  169. PIN_FIELD_BASE(69, 69, IOCFG_TR_BASE, 0x80, 0x10, 1, 1),
  170. PIN_FIELD_BASE(70, 70, IOCFG_TR_BASE, 0x80, 0x10, 0, 1),
  171. PIN_FIELD_BASE(71, 71, IOCFG_TR_BASE, 0x80, 0x10, 16, 1),
  172. PIN_FIELD_BASE(72, 73, IOCFG_TR_BASE, 0x80, 0x10, 14, 1),
  173. PIN_FIELD_BASE(74, 74, IOCFG_TR_BASE, 0x80, 0x10, 4, 1),
  174. PIN_FIELD_BASE(75, 77, IOCFG_TR_BASE, 0x80, 0x10, 6, 1),
  175. PIN_FIELD_BASE(78, 79, IOCFG_TR_BASE, 0x80, 0x10, 2, 1),
  176. PIN_FIELD_BASE(80, 84, IOCFG_TR_BASE, 0x80, 0x10, 9, 1),
  177. PIN_FIELD_BASE(85, 85, IOCFG_TR_BASE, 0x80, 0x10, 5, 1),
  178. PIN_FIELD_BASE(86, 86, IOCFG_TL_BASE, 0x70, 0x10, 1, 1),
  179. PIN_FIELD_BASE(87, 87, IOCFG_TL_BASE, 0x70, 0x10, 0, 1),
  180. PIN_FIELD_BASE(88, 88, IOCFG_TL_BASE, 0x70, 0x10, 14, 1),
  181. PIN_FIELD_BASE(89, 90, IOCFG_TL_BASE, 0x70, 0x10, 12, 1),
  182. PIN_FIELD_BASE(91, 94, IOCFG_TL_BASE, 0x70, 0x10, 4, 1),
  183. PIN_FIELD_BASE(95, 96, IOCFG_TL_BASE, 0x70, 0x10, 2, 1),
  184. PIN_FIELD_BASE(97, 100, IOCFG_TL_BASE, 0x70, 0x10, 8, 1),
  185. };
  186. static const struct mtk_pin_field_calc mt7986_pin_pu_range[] = {
  187. PIN_FIELD_BASE(69, 69, IOCFG_TR_BASE, 0x50, 0x10, 1, 1),
  188. PIN_FIELD_BASE(70, 70, IOCFG_TR_BASE, 0x50, 0x10, 0, 1),
  189. PIN_FIELD_BASE(71, 71, IOCFG_TR_BASE, 0x50, 0x10, 16, 1),
  190. PIN_FIELD_BASE(72, 73, IOCFG_TR_BASE, 0x50, 0x10, 14, 1),
  191. PIN_FIELD_BASE(74, 74, IOCFG_TR_BASE, 0x50, 0x10, 4, 1),
  192. PIN_FIELD_BASE(75, 77, IOCFG_TR_BASE, 0x50, 0x10, 6, 1),
  193. PIN_FIELD_BASE(78, 79, IOCFG_TR_BASE, 0x50, 0x10, 2, 1),
  194. PIN_FIELD_BASE(80, 84, IOCFG_TR_BASE, 0x50, 0x10, 9, 1),
  195. PIN_FIELD_BASE(85, 85, IOCFG_TR_BASE, 0x50, 0x10, 5, 1),
  196. PIN_FIELD_BASE(86, 86, IOCFG_TL_BASE, 0x50, 0x10, 1, 1),
  197. PIN_FIELD_BASE(87, 87, IOCFG_TL_BASE, 0x50, 0x10, 0, 1),
  198. PIN_FIELD_BASE(88, 88, IOCFG_TL_BASE, 0x50, 0x10, 14, 1),
  199. PIN_FIELD_BASE(89, 90, IOCFG_TL_BASE, 0x50, 0x10, 12, 1),
  200. PIN_FIELD_BASE(91, 94, IOCFG_TL_BASE, 0x50, 0x10, 4, 1),
  201. PIN_FIELD_BASE(95, 96, IOCFG_TL_BASE, 0x50, 0x10, 2, 1),
  202. PIN_FIELD_BASE(97, 100, IOCFG_TL_BASE, 0x50, 0x10, 8, 1),
  203. };
  204. static const struct mtk_pin_field_calc mt7986_pin_pd_range[] = {
  205. PIN_FIELD_BASE(69, 69, IOCFG_TR_BASE, 0x40, 0x10, 1, 1),
  206. PIN_FIELD_BASE(70, 70, IOCFG_TR_BASE, 0x40, 0x10, 0, 1),
  207. PIN_FIELD_BASE(71, 71, IOCFG_TR_BASE, 0x40, 0x10, 16, 1),
  208. PIN_FIELD_BASE(72, 73, IOCFG_TR_BASE, 0x40, 0x10, 14, 1),
  209. PIN_FIELD_BASE(74, 74, IOCFG_TR_BASE, 0x40, 0x10, 4, 1),
  210. PIN_FIELD_BASE(75, 77, IOCFG_TR_BASE, 0x40, 0x10, 6, 1),
  211. PIN_FIELD_BASE(78, 79, IOCFG_TR_BASE, 0x40, 0x10, 2, 1),
  212. PIN_FIELD_BASE(80, 84, IOCFG_TR_BASE, 0x40, 0x10, 9, 1),
  213. PIN_FIELD_BASE(85, 85, IOCFG_TR_BASE, 0x40, 0x10, 5, 1),
  214. PIN_FIELD_BASE(86, 86, IOCFG_TL_BASE, 0x40, 0x10, 1, 1),
  215. PIN_FIELD_BASE(87, 87, IOCFG_TL_BASE, 0x40, 0x10, 0, 1),
  216. PIN_FIELD_BASE(88, 88, IOCFG_TL_BASE, 0x40, 0x10, 14, 1),
  217. PIN_FIELD_BASE(89, 90, IOCFG_TL_BASE, 0x40, 0x10, 12, 1),
  218. PIN_FIELD_BASE(91, 94, IOCFG_TL_BASE, 0x40, 0x10, 4, 1),
  219. PIN_FIELD_BASE(95, 96, IOCFG_TL_BASE, 0x40, 0x10, 2, 1),
  220. PIN_FIELD_BASE(97, 100, IOCFG_TL_BASE, 0x40, 0x10, 8, 1),
  221. };
  222. static const struct mtk_pin_field_calc mt7986_pin_drv_range[] = {
  223. PIN_FIELD_BASE(0, 0, IOCFG_RB_BASE, 0x10, 0x10, 21, 3),
  224. PIN_FIELD_BASE(1, 2, IOCFG_LT_BASE, 0x10, 0x10, 0, 3),
  225. PIN_FIELD_BASE(3, 4, IOCFG_LB_BASE, 0x00, 0x10, 0, 1),
  226. PIN_FIELD_BASE(5, 5, IOCFG_RB_BASE, 0x00, 0x10, 0, 3),
  227. PIN_FIELD_BASE(6, 6, IOCFG_RB_BASE, 0x00, 0x10, 21, 3),
  228. PIN_FIELD_BASE(7, 10, IOCFG_LT_BASE, 0x00, 0x10, 0, 3),
  229. PIN_FIELD_BASE(11, 12, IOCFG_RB_BASE, 0x00, 0x10, 24, 3),
  230. PIN_FIELD_BASE(13, 14, IOCFG_RB_BASE, 0x10, 0x10, 0, 3),
  231. PIN_FIELD_BASE(15, 20, IOCFG_RB_BASE, 0x00, 0x10, 3, 3),
  232. PIN_FIELD_BASE(21, 23, IOCFG_RT_BASE, 0x10, 0x10, 6, 3),
  233. PIN_FIELD_BASE(24, 24, IOCFG_RT_BASE, 0x10, 0x10, 24, 3),
  234. PIN_FIELD_BASE(25, 25, IOCFG_RT_BASE, 0x10, 0x10, 21, 3),
  235. PIN_FIELD_BASE(26, 27, IOCFG_RT_BASE, 0x10, 0x10, 15, 3),
  236. PIN_FIELD_BASE(28, 28, IOCFG_RT_BASE, 0x10, 0x10, 27, 3),
  237. PIN_FIELD_BASE(29, 29, IOCFG_RT_BASE, 0x20, 0x10, 0, 3),
  238. PIN_FIELD_BASE(30, 30, IOCFG_RT_BASE, 0x20, 0x10, 9, 3),
  239. PIN_FIELD_BASE(31, 31, IOCFG_RT_BASE, 0x20, 0x10, 6, 3),
  240. PIN_FIELD_BASE(32, 32, IOCFG_RT_BASE, 0x20, 0x10, 3, 3),
  241. PIN_FIELD_BASE(33, 33, IOCFG_LT_BASE, 0x00, 0x10, 12, 3),
  242. PIN_FIELD_BASE(34, 34, IOCFG_LT_BASE, 0x00, 0x10, 24, 3),
  243. PIN_FIELD_BASE(35, 35, IOCFG_LT_BASE, 0x00, 0x10, 21, 3),
  244. PIN_FIELD_BASE(36, 37, IOCFG_LT_BASE, 0x00, 0x10, 15, 3),
  245. PIN_FIELD_BASE(38, 38, IOCFG_LT_BASE, 0x00, 0x10, 27, 3),
  246. PIN_FIELD_BASE(39, 39, IOCFG_RB_BASE, 0x10, 0x10, 27, 3),
  247. PIN_FIELD_BASE(40, 40, IOCFG_RB_BASE, 0x20, 0x10, 0, 3),
  248. PIN_FIELD_BASE(41, 41, IOCFG_RB_BASE, 0x10, 0x10, 6, 3),
  249. PIN_FIELD_BASE(42, 43, IOCFG_RB_BASE, 0x20, 0x10, 9, 3),
  250. PIN_FIELD_BASE(44, 45, IOCFG_RB_BASE, 0x20, 0x10, 3, 3),
  251. PIN_FIELD_BASE(46, 47, IOCFG_RB_BASE, 0x20, 0x10, 21, 3),
  252. PIN_FIELD_BASE(48, 49, IOCFG_RB_BASE, 0x20, 0x10, 15, 3),
  253. PIN_FIELD_BASE(50, 57, IOCFG_RT_BASE, 0x00, 0x10, 6, 3),
  254. PIN_FIELD_BASE(58, 58, IOCFG_RT_BASE, 0x00, 0x10, 3, 3),
  255. PIN_FIELD_BASE(59, 59, IOCFG_RT_BASE, 0x00, 0x10, 0, 3),
  256. PIN_FIELD_BASE(60, 61, IOCFG_RT_BASE, 0x10, 0x10, 0, 3),
  257. PIN_FIELD_BASE(62, 62, IOCFG_RB_BASE, 0x10, 0x10, 15, 3),
  258. PIN_FIELD_BASE(63, 63, IOCFG_RB_BASE, 0x10, 0x10, 12, 3),
  259. PIN_FIELD_BASE(64, 64, IOCFG_RB_BASE, 0x10, 0x10, 9, 3),
  260. PIN_FIELD_BASE(65, 65, IOCFG_RB_BASE, 0x10, 0x10, 18, 3),
  261. PIN_FIELD_BASE(66, 68, IOCFG_LB_BASE, 0x00, 0x10, 2, 3),
  262. PIN_FIELD_BASE(69, 69, IOCFG_TR_BASE, 0x00, 0x10, 3, 3),
  263. PIN_FIELD_BASE(70, 70, IOCFG_TR_BASE, 0x00, 0x10, 0, 3),
  264. PIN_FIELD_BASE(71, 71, IOCFG_TR_BASE, 0x10, 0x10, 18, 3),
  265. PIN_FIELD_BASE(72, 73, IOCFG_TR_BASE, 0x10, 0x10, 12, 3),
  266. PIN_FIELD_BASE(74, 77, IOCFG_TR_BASE, 0x00, 0x10, 15, 3),
  267. PIN_FIELD_BASE(78, 79, IOCFG_TR_BASE, 0x00, 0x10, 6, 3),
  268. PIN_FIELD_BASE(80, 80, IOCFG_TR_BASE, 0x00, 0x10, 27, 3),
  269. PIN_FIELD_BASE(81, 84, IOCFG_TR_BASE, 0x10, 0x10, 0, 3),
  270. PIN_FIELD_BASE(85, 85, IOCFG_TR_BASE, 0x00, 0x10, 12, 3),
  271. PIN_FIELD_BASE(86, 86, IOCFG_TL_BASE, 0x00, 0x10, 3, 3),
  272. PIN_FIELD_BASE(87, 87, IOCFG_TL_BASE, 0x00, 0x10, 0, 3),
  273. PIN_FIELD_BASE(88, 88, IOCFG_TL_BASE, 0x10, 0x10, 12, 3),
  274. PIN_FIELD_BASE(89, 90, IOCFG_TL_BASE, 0x10, 0x10, 6, 3),
  275. PIN_FIELD_BASE(91, 94, IOCFG_TL_BASE, 0x00, 0x10, 12, 3),
  276. PIN_FIELD_BASE(95, 96, IOCFG_TL_BASE, 0x00, 0x10, 6, 3),
  277. PIN_FIELD_BASE(97, 98, IOCFG_TL_BASE, 0x00, 0x10, 24, 3),
  278. PIN_FIELD_BASE(99, 100, IOCFG_TL_BASE, 0x10, 0x10, 2, 3),
  279. };
  280. static const struct mtk_pin_field_calc mt7986_pin_pupd_range[] = {
  281. PIN_FIELD_BASE(0, 0, IOCFG_RB_BASE, 0x60, 0x10, 17, 1),
  282. PIN_FIELD_BASE(1, 2, IOCFG_LT_BASE, 0x30, 0x10, 10, 1),
  283. PIN_FIELD_BASE(3, 4, IOCFG_LB_BASE, 0x40, 0x10, 0, 1),
  284. PIN_FIELD_BASE(5, 6, IOCFG_RB_BASE, 0x60, 0x10, 0, 1),
  285. PIN_FIELD_BASE(7, 10, IOCFG_LT_BASE, 0x30, 0x10, 0, 1),
  286. PIN_FIELD_BASE(11, 14, IOCFG_RB_BASE, 0x60, 0x10, 8, 1),
  287. PIN_FIELD_BASE(15, 20, IOCFG_RB_BASE, 0x60, 0x10, 2, 1),
  288. PIN_FIELD_BASE(21, 23, IOCFG_RT_BASE, 0x40, 0x10, 12, 1),
  289. PIN_FIELD_BASE(24, 24, IOCFG_RT_BASE, 0x40, 0x10, 18, 1),
  290. PIN_FIELD_BASE(25, 25, IOCFG_RT_BASE, 0x40, 0x10, 17, 1),
  291. PIN_FIELD_BASE(26, 27, IOCFG_RT_BASE, 0x40, 0x10, 15, 1),
  292. PIN_FIELD_BASE(28, 29, IOCFG_RT_BASE, 0x40, 0x10, 19, 1),
  293. PIN_FIELD_BASE(30, 30, IOCFG_RT_BASE, 0x40, 0x10, 23, 1),
  294. PIN_FIELD_BASE(31, 31, IOCFG_RT_BASE, 0x40, 0x10, 22, 1),
  295. PIN_FIELD_BASE(32, 32, IOCFG_RT_BASE, 0x40, 0x10, 21, 1),
  296. PIN_FIELD_BASE(33, 33, IOCFG_LT_BASE, 0x30, 0x10, 4, 1),
  297. PIN_FIELD_BASE(34, 34, IOCFG_LT_BASE, 0x30, 0x10, 8, 1),
  298. PIN_FIELD_BASE(35, 35, IOCFG_LT_BASE, 0x30, 0x10, 7, 1),
  299. PIN_FIELD_BASE(36, 37, IOCFG_LT_BASE, 0x30, 0x10, 5, 1),
  300. PIN_FIELD_BASE(38, 38, IOCFG_LT_BASE, 0x30, 0x10, 9, 1),
  301. PIN_FIELD_BASE(39, 40, IOCFG_RB_BASE, 0x60, 0x10, 18, 1),
  302. PIN_FIELD_BASE(41, 41, IOCFG_RB_BASE, 0x60, 0x10, 12, 1),
  303. PIN_FIELD_BASE(42, 43, IOCFG_RB_BASE, 0x60, 0x10, 23, 1),
  304. PIN_FIELD_BASE(44, 45, IOCFG_RB_BASE, 0x60, 0x10, 21, 1),
  305. PIN_FIELD_BASE(46, 47, IOCFG_RB_BASE, 0x60, 0x10, 27, 1),
  306. PIN_FIELD_BASE(48, 49, IOCFG_RB_BASE, 0x60, 0x10, 25, 1),
  307. PIN_FIELD_BASE(50, 57, IOCFG_RT_BASE, 0x40, 0x10, 2, 1),
  308. PIN_FIELD_BASE(58, 58, IOCFG_RT_BASE, 0x40, 0x10, 1, 1),
  309. PIN_FIELD_BASE(59, 59, IOCFG_RT_BASE, 0x40, 0x10, 0, 1),
  310. PIN_FIELD_BASE(60, 61, IOCFG_RT_BASE, 0x40, 0x10, 10, 1),
  311. PIN_FIELD_BASE(62, 62, IOCFG_RB_BASE, 0x60, 0x10, 15, 1),
  312. PIN_FIELD_BASE(63, 63, IOCFG_RB_BASE, 0x60, 0x10, 14, 1),
  313. PIN_FIELD_BASE(64, 64, IOCFG_RB_BASE, 0x60, 0x10, 13, 1),
  314. PIN_FIELD_BASE(65, 65, IOCFG_RB_BASE, 0x60, 0x10, 16, 1),
  315. PIN_FIELD_BASE(66, 68, IOCFG_LB_BASE, 0x40, 0x10, 2, 1),
  316. };
  317. static const struct mtk_pin_field_calc mt7986_pin_r0_range[] = {
  318. PIN_FIELD_BASE(0, 0, IOCFG_RB_BASE, 0x70, 0x10, 17, 1),
  319. PIN_FIELD_BASE(1, 2, IOCFG_LT_BASE, 0x40, 0x10, 10, 1),
  320. PIN_FIELD_BASE(3, 4, IOCFG_LB_BASE, 0x50, 0x10, 0, 1),
  321. PIN_FIELD_BASE(5, 6, IOCFG_RB_BASE, 0x70, 0x10, 0, 1),
  322. PIN_FIELD_BASE(7, 10, IOCFG_LT_BASE, 0x40, 0x10, 0, 1),
  323. PIN_FIELD_BASE(11, 14, IOCFG_RB_BASE, 0x70, 0x10, 8, 1),
  324. PIN_FIELD_BASE(15, 20, IOCFG_RB_BASE, 0x70, 0x10, 2, 1),
  325. PIN_FIELD_BASE(21, 23, IOCFG_RT_BASE, 0x50, 0x10, 12, 1),
  326. PIN_FIELD_BASE(24, 24, IOCFG_RT_BASE, 0x50, 0x10, 18, 1),
  327. PIN_FIELD_BASE(25, 25, IOCFG_RT_BASE, 0x50, 0x10, 17, 1),
  328. PIN_FIELD_BASE(26, 27, IOCFG_RT_BASE, 0x50, 0x10, 15, 1),
  329. PIN_FIELD_BASE(28, 29, IOCFG_RT_BASE, 0x50, 0x10, 19, 1),
  330. PIN_FIELD_BASE(30, 30, IOCFG_RT_BASE, 0x50, 0x10, 23, 1),
  331. PIN_FIELD_BASE(31, 31, IOCFG_RT_BASE, 0x50, 0x10, 22, 1),
  332. PIN_FIELD_BASE(32, 32, IOCFG_RT_BASE, 0x50, 0x10, 21, 1),
  333. PIN_FIELD_BASE(33, 33, IOCFG_LT_BASE, 0x40, 0x10, 4, 1),
  334. PIN_FIELD_BASE(34, 34, IOCFG_LT_BASE, 0x40, 0x10, 8, 1),
  335. PIN_FIELD_BASE(35, 35, IOCFG_LT_BASE, 0x40, 0x10, 7, 1),
  336. PIN_FIELD_BASE(36, 37, IOCFG_LT_BASE, 0x40, 0x10, 5, 1),
  337. PIN_FIELD_BASE(38, 38, IOCFG_LT_BASE, 0x40, 0x10, 9, 1),
  338. PIN_FIELD_BASE(39, 40, IOCFG_RB_BASE, 0x70, 0x10, 18, 1),
  339. PIN_FIELD_BASE(41, 41, IOCFG_RB_BASE, 0x70, 0x10, 12, 1),
  340. PIN_FIELD_BASE(42, 43, IOCFG_RB_BASE, 0x70, 0x10, 23, 1),
  341. PIN_FIELD_BASE(44, 45, IOCFG_RB_BASE, 0x70, 0x10, 21, 1),
  342. PIN_FIELD_BASE(46, 47, IOCFG_RB_BASE, 0x70, 0x10, 27, 1),
  343. PIN_FIELD_BASE(48, 49, IOCFG_RB_BASE, 0x70, 0x10, 25, 1),
  344. PIN_FIELD_BASE(50, 57, IOCFG_RT_BASE, 0x50, 0x10, 2, 1),
  345. PIN_FIELD_BASE(58, 58, IOCFG_RT_BASE, 0x50, 0x10, 1, 1),
  346. PIN_FIELD_BASE(59, 59, IOCFG_RT_BASE, 0x50, 0x10, 0, 1),
  347. PIN_FIELD_BASE(60, 61, IOCFG_RT_BASE, 0x50, 0x10, 10, 1),
  348. PIN_FIELD_BASE(62, 62, IOCFG_RB_BASE, 0x70, 0x10, 15, 1),
  349. PIN_FIELD_BASE(63, 63, IOCFG_RB_BASE, 0x70, 0x10, 14, 1),
  350. PIN_FIELD_BASE(64, 64, IOCFG_RB_BASE, 0x70, 0x10, 13, 1),
  351. PIN_FIELD_BASE(65, 65, IOCFG_RB_BASE, 0x70, 0x10, 16, 1),
  352. PIN_FIELD_BASE(66, 68, IOCFG_LB_BASE, 0x50, 0x10, 2, 1),
  353. };
  354. static const struct mtk_pin_field_calc mt7986_pin_r1_range[] = {
  355. PIN_FIELD_BASE(0, 0, IOCFG_RB_BASE, 0x80, 0x10, 17, 1),
  356. PIN_FIELD_BASE(1, 2, IOCFG_LT_BASE, 0x50, 0x10, 10, 1),
  357. PIN_FIELD_BASE(3, 4, IOCFG_LB_BASE, 0x60, 0x10, 0, 1),
  358. PIN_FIELD_BASE(5, 6, IOCFG_RB_BASE, 0x80, 0x10, 0, 1),
  359. PIN_FIELD_BASE(7, 10, IOCFG_LT_BASE, 0x50, 0x10, 0, 1),
  360. PIN_FIELD_BASE(11, 14, IOCFG_RB_BASE, 0x80, 0x10, 8, 1),
  361. PIN_FIELD_BASE(15, 20, IOCFG_RB_BASE, 0x80, 0x10, 2, 1),
  362. PIN_FIELD_BASE(21, 23, IOCFG_RT_BASE, 0x60, 0x10, 12, 1),
  363. PIN_FIELD_BASE(24, 24, IOCFG_RT_BASE, 0x60, 0x10, 18, 1),
  364. PIN_FIELD_BASE(25, 25, IOCFG_RT_BASE, 0x60, 0x10, 17, 1),
  365. PIN_FIELD_BASE(26, 27, IOCFG_RT_BASE, 0x60, 0x10, 15, 1),
  366. PIN_FIELD_BASE(28, 29, IOCFG_RT_BASE, 0x60, 0x10, 19, 1),
  367. PIN_FIELD_BASE(30, 30, IOCFG_RT_BASE, 0x60, 0x10, 23, 1),
  368. PIN_FIELD_BASE(31, 31, IOCFG_RT_BASE, 0x60, 0x10, 22, 1),
  369. PIN_FIELD_BASE(32, 32, IOCFG_RT_BASE, 0x60, 0x10, 21, 1),
  370. PIN_FIELD_BASE(33, 33, IOCFG_LT_BASE, 0x50, 0x10, 4, 1),
  371. PIN_FIELD_BASE(34, 34, IOCFG_LT_BASE, 0x50, 0x10, 8, 1),
  372. PIN_FIELD_BASE(35, 35, IOCFG_LT_BASE, 0x50, 0x10, 7, 1),
  373. PIN_FIELD_BASE(36, 37, IOCFG_LT_BASE, 0x50, 0x10, 5, 1),
  374. PIN_FIELD_BASE(38, 38, IOCFG_LT_BASE, 0x50, 0x10, 9, 1),
  375. PIN_FIELD_BASE(39, 40, IOCFG_RB_BASE, 0x80, 0x10, 18, 1),
  376. PIN_FIELD_BASE(41, 41, IOCFG_RB_BASE, 0x80, 0x10, 12, 1),
  377. PIN_FIELD_BASE(42, 43, IOCFG_RB_BASE, 0x80, 0x10, 23, 1),
  378. PIN_FIELD_BASE(44, 45, IOCFG_RB_BASE, 0x80, 0x10, 21, 1),
  379. PIN_FIELD_BASE(46, 47, IOCFG_RB_BASE, 0x80, 0x10, 27, 1),
  380. PIN_FIELD_BASE(48, 49, IOCFG_RB_BASE, 0x80, 0x10, 25, 1),
  381. PIN_FIELD_BASE(50, 57, IOCFG_RT_BASE, 0x60, 0x10, 2, 1),
  382. PIN_FIELD_BASE(58, 58, IOCFG_RT_BASE, 0x60, 0x10, 1, 1),
  383. PIN_FIELD_BASE(59, 59, IOCFG_RT_BASE, 0x60, 0x10, 0, 1),
  384. PIN_FIELD_BASE(60, 61, IOCFG_RT_BASE, 0x60, 0x10, 10, 1),
  385. PIN_FIELD_BASE(62, 62, IOCFG_RB_BASE, 0x80, 0x10, 15, 1),
  386. PIN_FIELD_BASE(63, 63, IOCFG_RB_BASE, 0x80, 0x10, 14, 1),
  387. PIN_FIELD_BASE(64, 64, IOCFG_RB_BASE, 0x80, 0x10, 13, 1),
  388. PIN_FIELD_BASE(65, 65, IOCFG_RB_BASE, 0x80, 0x10, 16, 1),
  389. PIN_FIELD_BASE(66, 68, IOCFG_LB_BASE, 0x60, 0x10, 2, 1),
  390. };
  391. static const struct mtk_pin_reg_calc mt7986_reg_cals[] = {
  392. [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7986_pin_mode_range),
  393. [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7986_pin_dir_range),
  394. [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7986_pin_di_range),
  395. [PINCTRL_PIN_REG_DO] = MTK_RANGE(mt7986_pin_do_range),
  396. [PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt7986_pin_smt_range),
  397. [PINCTRL_PIN_REG_IES] = MTK_RANGE(mt7986_pin_ies_range),
  398. [PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt7986_pin_drv_range),
  399. [PINCTRL_PIN_REG_PU] = MTK_RANGE(mt7986_pin_pu_range),
  400. [PINCTRL_PIN_REG_PD] = MTK_RANGE(mt7986_pin_pd_range),
  401. [PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt7986_pin_pupd_range),
  402. [PINCTRL_PIN_REG_R0] = MTK_RANGE(mt7986_pin_r0_range),
  403. [PINCTRL_PIN_REG_R1] = MTK_RANGE(mt7986_pin_r1_range),
  404. };
  405. static const struct mtk_pin_desc mt7986a_pins[] = {
  406. MT7986_PIN(0, "SYS_WATCHDOG"),
  407. MT7986_PIN(1, "WF2G_LED"),
  408. MT7986_PIN(2, "WF5G_LED"),
  409. MT7986_PIN(3, "I2C_SCL"),
  410. MT7986_PIN(4, "I2C_SDA"),
  411. MT7986_PIN(5, "GPIO_0"),
  412. MT7986_PIN(6, "GPIO_1"),
  413. MT7986_PIN(7, "GPIO_2"),
  414. MT7986_PIN(8, "GPIO_3"),
  415. MT7986_PIN(9, "GPIO_4"),
  416. MT7986_PIN(10, "GPIO_5"),
  417. MT7986_PIN(11, "GPIO_6"),
  418. MT7986_PIN(12, "GPIO_7"),
  419. MT7986_PIN(13, "GPIO_8"),
  420. MT7986_PIN(14, "GPIO_9"),
  421. MT7986_PIN(15, "GPIO_10"),
  422. MT7986_PIN(16, "GPIO_11"),
  423. MT7986_PIN(17, "GPIO_12"),
  424. MT7986_PIN(18, "GPIO_13"),
  425. MT7986_PIN(19, "GPIO_14"),
  426. MT7986_PIN(20, "GPIO_15"),
  427. MT7986_PIN(21, "PWM0"),
  428. MT7986_PIN(22, "PWM1"),
  429. MT7986_PIN(23, "SPI0_CLK"),
  430. MT7986_PIN(24, "SPI0_MOSI"),
  431. MT7986_PIN(25, "SPI0_MISO"),
  432. MT7986_PIN(26, "SPI0_CS"),
  433. MT7986_PIN(27, "SPI0_HOLD"),
  434. MT7986_PIN(28, "SPI0_WP"),
  435. MT7986_PIN(29, "SPI1_CLK"),
  436. MT7986_PIN(30, "SPI1_MOSI"),
  437. MT7986_PIN(31, "SPI1_MISO"),
  438. MT7986_PIN(32, "SPI1_CS"),
  439. MT7986_PIN(33, "SPI2_CLK"),
  440. MT7986_PIN(34, "SPI2_MOSI"),
  441. MT7986_PIN(35, "SPI2_MISO"),
  442. MT7986_PIN(36, "SPI2_CS"),
  443. MT7986_PIN(37, "SPI2_HOLD"),
  444. MT7986_PIN(38, "SPI2_WP"),
  445. MT7986_PIN(39, "UART0_RXD"),
  446. MT7986_PIN(40, "UART0_TXD"),
  447. MT7986_PIN(41, "PCIE_PERESET_N"),
  448. MT7986_PIN(42, "UART1_RXD"),
  449. MT7986_PIN(43, "UART1_TXD"),
  450. MT7986_PIN(44, "UART1_CTS"),
  451. MT7986_PIN(45, "UART1_RTS"),
  452. MT7986_PIN(46, "UART2_RXD"),
  453. MT7986_PIN(47, "UART2_TXD"),
  454. MT7986_PIN(48, "UART2_CTS"),
  455. MT7986_PIN(49, "UART2_RTS"),
  456. MT7986_PIN(50, "EMMC_DATA_0"),
  457. MT7986_PIN(51, "EMMC_DATA_1"),
  458. MT7986_PIN(52, "EMMC_DATA_2"),
  459. MT7986_PIN(53, "EMMC_DATA_3"),
  460. MT7986_PIN(54, "EMMC_DATA_4"),
  461. MT7986_PIN(55, "EMMC_DATA_5"),
  462. MT7986_PIN(56, "EMMC_DATA_6"),
  463. MT7986_PIN(57, "EMMC_DATA_7"),
  464. MT7986_PIN(58, "EMMC_CMD"),
  465. MT7986_PIN(59, "EMMC_CK"),
  466. MT7986_PIN(60, "EMMC_DSL"),
  467. MT7986_PIN(61, "EMMC_RSTB"),
  468. MT7986_PIN(62, "PCM_DTX"),
  469. MT7986_PIN(63, "PCM_DRX"),
  470. MT7986_PIN(64, "PCM_CLK"),
  471. MT7986_PIN(65, "PCM_FS"),
  472. MT7986_PIN(66, "MT7531_INT"),
  473. MT7986_PIN(67, "SMI_MDC"),
  474. MT7986_PIN(68, "SMI_MDIO"),
  475. MT7986_PIN(69, "WF0_DIG_RESETB"),
  476. MT7986_PIN(70, "WF0_CBA_RESETB"),
  477. MT7986_PIN(71, "WF0_XO_REQ"),
  478. MT7986_PIN(72, "WF0_TOP_CLK"),
  479. MT7986_PIN(73, "WF0_TOP_DATA"),
  480. MT7986_PIN(74, "WF0_HB1"),
  481. MT7986_PIN(75, "WF0_HB2"),
  482. MT7986_PIN(76, "WF0_HB3"),
  483. MT7986_PIN(77, "WF0_HB4"),
  484. MT7986_PIN(78, "WF0_HB0"),
  485. MT7986_PIN(79, "WF0_HB0_B"),
  486. MT7986_PIN(80, "WF0_HB5"),
  487. MT7986_PIN(81, "WF0_HB6"),
  488. MT7986_PIN(82, "WF0_HB7"),
  489. MT7986_PIN(83, "WF0_HB8"),
  490. MT7986_PIN(84, "WF0_HB9"),
  491. MT7986_PIN(85, "WF0_HB10"),
  492. MT7986_PIN(86, "WF1_DIG_RESETB"),
  493. MT7986_PIN(87, "WF1_CBA_RESETB"),
  494. MT7986_PIN(88, "WF1_XO_REQ"),
  495. MT7986_PIN(89, "WF1_TOP_CLK"),
  496. MT7986_PIN(90, "WF1_TOP_DATA"),
  497. MT7986_PIN(91, "WF1_HB1"),
  498. MT7986_PIN(92, "WF1_HB2"),
  499. MT7986_PIN(93, "WF1_HB3"),
  500. MT7986_PIN(94, "WF1_HB4"),
  501. MT7986_PIN(95, "WF1_HB0"),
  502. MT7986_PIN(96, "WF1_HB0_B"),
  503. MT7986_PIN(97, "WF1_HB5"),
  504. MT7986_PIN(98, "WF1_HB6"),
  505. MT7986_PIN(99, "WF1_HB7"),
  506. MT7986_PIN(100, "WF1_HB8"),
  507. };
  508. static const struct mtk_pin_desc mt7986b_pins[] = {
  509. MT7986_PIN(0, "SYS_WATCHDOG"),
  510. MT7986_PIN(1, "WF2G_LED"),
  511. MT7986_PIN(2, "WF5G_LED"),
  512. MT7986_PIN(3, "I2C_SCL"),
  513. MT7986_PIN(4, "I2C_SDA"),
  514. MT7986_PIN(5, "GPIO_0"),
  515. MT7986_PIN(6, "GPIO_1"),
  516. MT7986_PIN(7, "GPIO_2"),
  517. MT7986_PIN(8, "GPIO_3"),
  518. MT7986_PIN(9, "GPIO_4"),
  519. MT7986_PIN(10, "GPIO_5"),
  520. MT7986_PIN(11, "GPIO_6"),
  521. MT7986_PIN(12, "GPIO_7"),
  522. MT7986_PIN(13, "GPIO_8"),
  523. MT7986_PIN(14, "GPIO_9"),
  524. MT7986_PIN(15, "GPIO_10"),
  525. MT7986_PIN(16, "GPIO_11"),
  526. MT7986_PIN(17, "GPIO_12"),
  527. MT7986_PIN(18, "GPIO_13"),
  528. MT7986_PIN(19, "GPIO_14"),
  529. MT7986_PIN(20, "GPIO_15"),
  530. MT7986_PIN(21, "PWM0"),
  531. MT7986_PIN(22, "PWM1"),
  532. MT7986_PIN(23, "SPI0_CLK"),
  533. MT7986_PIN(24, "SPI0_MOSI"),
  534. MT7986_PIN(25, "SPI0_MISO"),
  535. MT7986_PIN(26, "SPI0_CS"),
  536. MT7986_PIN(27, "SPI0_HOLD"),
  537. MT7986_PIN(28, "SPI0_WP"),
  538. MT7986_PIN(29, "SPI1_CLK"),
  539. MT7986_PIN(30, "SPI1_MOSI"),
  540. MT7986_PIN(31, "SPI1_MISO"),
  541. MT7986_PIN(32, "SPI1_CS"),
  542. MT7986_PIN(33, "SPI2_CLK"),
  543. MT7986_PIN(34, "SPI2_MOSI"),
  544. MT7986_PIN(35, "SPI2_MISO"),
  545. MT7986_PIN(36, "SPI2_CS"),
  546. MT7986_PIN(37, "SPI2_HOLD"),
  547. MT7986_PIN(38, "SPI2_WP"),
  548. MT7986_PIN(39, "UART0_RXD"),
  549. MT7986_PIN(40, "UART0_TXD"),
  550. MT7986_NOT_BALLOUT_PIN(41),
  551. MT7986_NOT_BALLOUT_PIN(42),
  552. MT7986_NOT_BALLOUT_PIN(43),
  553. MT7986_NOT_BALLOUT_PIN(44),
  554. MT7986_NOT_BALLOUT_PIN(45),
  555. MT7986_NOT_BALLOUT_PIN(46),
  556. MT7986_NOT_BALLOUT_PIN(47),
  557. MT7986_NOT_BALLOUT_PIN(48),
  558. MT7986_NOT_BALLOUT_PIN(49),
  559. MT7986_NOT_BALLOUT_PIN(50),
  560. MT7986_NOT_BALLOUT_PIN(51),
  561. MT7986_NOT_BALLOUT_PIN(52),
  562. MT7986_NOT_BALLOUT_PIN(53),
  563. MT7986_NOT_BALLOUT_PIN(54),
  564. MT7986_NOT_BALLOUT_PIN(55),
  565. MT7986_NOT_BALLOUT_PIN(56),
  566. MT7986_NOT_BALLOUT_PIN(57),
  567. MT7986_NOT_BALLOUT_PIN(58),
  568. MT7986_NOT_BALLOUT_PIN(59),
  569. MT7986_NOT_BALLOUT_PIN(60),
  570. MT7986_NOT_BALLOUT_PIN(61),
  571. MT7986_NOT_BALLOUT_PIN(62),
  572. MT7986_NOT_BALLOUT_PIN(63),
  573. MT7986_NOT_BALLOUT_PIN(64),
  574. MT7986_NOT_BALLOUT_PIN(65),
  575. MT7986_PIN(66, "MT7531_INT"),
  576. MT7986_PIN(67, "SMI_MDC"),
  577. MT7986_PIN(68, "SMI_MDIO"),
  578. MT7986_PIN(69, "WF0_DIG_RESETB"),
  579. MT7986_PIN(70, "WF0_CBA_RESETB"),
  580. MT7986_PIN(71, "WF0_XO_REQ"),
  581. MT7986_PIN(72, "WF0_TOP_CLK"),
  582. MT7986_PIN(73, "WF0_TOP_DATA"),
  583. MT7986_PIN(74, "WF0_HB1"),
  584. MT7986_PIN(75, "WF0_HB2"),
  585. MT7986_PIN(76, "WF0_HB3"),
  586. MT7986_PIN(77, "WF0_HB4"),
  587. MT7986_PIN(78, "WF0_HB0"),
  588. MT7986_PIN(79, "WF0_HB0_B"),
  589. MT7986_PIN(80, "WF0_HB5"),
  590. MT7986_PIN(81, "WF0_HB6"),
  591. MT7986_PIN(82, "WF0_HB7"),
  592. MT7986_PIN(83, "WF0_HB8"),
  593. MT7986_PIN(84, "WF0_HB9"),
  594. MT7986_PIN(85, "WF0_HB10"),
  595. MT7986_PIN(86, "WF1_DIG_RESETB"),
  596. MT7986_PIN(87, "WF1_CBA_RESETB"),
  597. MT7986_PIN(88, "WF1_XO_REQ"),
  598. MT7986_PIN(89, "WF1_TOP_CLK"),
  599. MT7986_PIN(90, "WF1_TOP_DATA"),
  600. MT7986_PIN(91, "WF1_HB1"),
  601. MT7986_PIN(92, "WF1_HB2"),
  602. MT7986_PIN(93, "WF1_HB3"),
  603. MT7986_PIN(94, "WF1_HB4"),
  604. MT7986_PIN(95, "WF1_HB0"),
  605. MT7986_PIN(96, "WF1_HB0_B"),
  606. MT7986_PIN(97, "WF1_HB5"),
  607. MT7986_PIN(98, "WF1_HB6"),
  608. MT7986_PIN(99, "WF1_HB7"),
  609. MT7986_PIN(100, "WF1_HB8"),
  610. };
  611. /* List all groups consisting of these pins dedicated to the enablement of
  612. * certain hardware block and the corresponding mode for all of the pins.
  613. * The hardware probably has multiple combinations of these pinouts.
  614. */
  615. static int mt7986_watchdog_pins[] = { 0, };
  616. static int mt7986_watchdog_funcs[] = { 1, };
  617. static int mt7986_wifi_led_pins[] = { 1, 2, };
  618. static int mt7986_wifi_led_funcs[] = { 1, 1, };
  619. static int mt7986_i2c_pins[] = { 3, 4, };
  620. static int mt7986_i2c_funcs[] = { 1, 1, };
  621. static int mt7986_uart1_0_pins[] = { 7, 8, 9, 10, };
  622. static int mt7986_uart1_0_funcs[] = { 3, 3, 3, 3, };
  623. static int mt7986_spi1_0_pins[] = { 11, 12, 13, 14, };
  624. static int mt7986_spi1_0_funcs[] = { 3, 3, 3, 3, };
  625. static int mt7986_pwm1_1_pins[] = { 20, };
  626. static int mt7986_pwm1_1_funcs[] = { 2, };
  627. static int mt7986_pwm0_pins[] = { 21, };
  628. static int mt7986_pwm0_funcs[] = { 1, };
  629. static int mt7986_pwm1_0_pins[] = { 22, };
  630. static int mt7986_pwm1_0_funcs[] = { 1, };
  631. static int mt7986_emmc_45_pins[] = {
  632. 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, };
  633. static int mt7986_emmc_45_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
  634. static int mt7986_snfi_pins[] = { 23, 24, 25, 26, 27, 28, };
  635. static int mt7986_snfi_funcs[] = { 1, 1, 1, 1, 1, 1, };
  636. static int mt7986_spi1_1_pins[] = { 23, 24, 25, 26, };
  637. static int mt7986_spi1_1_funcs[] = { 3, 3, 3, 3, };
  638. static int mt7986_uart1_1_pins[] = { 23, 24, 25, 26, };
  639. static int mt7986_uart1_1_funcs[] = { 4, 4, 4, 4, };
  640. static int mt7986_spi1_2_pins[] = { 29, 30, 31, 32, };
  641. static int mt7986_spi1_2_funcs[] = { 1, 1, 1, 1, };
  642. static int mt7986_uart1_2_pins[] = { 29, 30, 31, 32, };
  643. static int mt7986_uart1_2_funcs[] = { 3, 3, 3, 3, };
  644. static int mt7986_uart2_0_pins[] = { 29, 30, 31, 32, };
  645. static int mt7986_uart2_0_funcs[] = { 4, 4, 4, 4, };
  646. static int mt7986_spi0_pins[] = { 33, 34, 35, 36, };
  647. static int mt7986_spi0_funcs[] = { 1, 1, 1, 1, };
  648. static int mt7986_spi0_wp_hold_pins[] = { 37, 38, };
  649. static int mt7986_spi0_wp_hold_funcs[] = { 1, 1, };
  650. static int mt7986_uart2_1_pins[] = { 33, 34, 35, 36, };
  651. static int mt7986_uart2_1_funcs[] = { 3, 3, 3, 3, };
  652. static int mt7986_uart1_3_rx_tx_pins[] = { 35, 36, };
  653. static int mt7986_uart1_3_rx_tx_funcs[] = { 2, 2, };
  654. static int mt7986_uart1_3_cts_rts_pins[] = { 37, 38, };
  655. static int mt7986_uart1_3_cts_rts_funcs[] = { 2, 2, };
  656. static int mt7986_spi1_3_pins[] = { 33, 34, 35, 36, };
  657. static int mt7986_spi1_3_funcs[] = { 4, 4, 4, 4, };
  658. static int mt7986_uart0_pins[] = { 39, 40, };
  659. static int mt7986_uart0_funcs[] = { 1, 1, };
  660. static int mt7986_pcie_reset_pins[] = { 41, };
  661. static int mt7986_pcie_reset_funcs[] = { 1, };
  662. static int mt7986_uart1_pins[] = { 42, 43, 44, 45, };
  663. static int mt7986_uart1_funcs[] = { 1, 1, 1, 1, };
  664. static int mt7986_uart2_pins[] = { 46, 47, 48, 49, };
  665. static int mt7986_uart2_funcs[] = { 1, 1, 1, 1, };
  666. static int mt7986_emmc_51_pins[] = {
  667. 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, };
  668. static int mt7986_emmc_51_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
  669. static int mt7986_pcm_pins[] = { 62, 63, 64, 65, };
  670. static int mt7986_pcm_funcs[] = { 1, 1, 1, 1, };
  671. static int mt7986_i2s_pins[] = { 62, 63, 64, 65, };
  672. static int mt7986_i2s_funcs[] = { 1, 1, 1, 1, };
  673. static int mt7986_switch_int_pins[] = { 66, };
  674. static int mt7986_switch_int_funcs[] = { 1, };
  675. static int mt7986_mdc_mdio_pins[] = { 67, 68, };
  676. static int mt7986_mdc_mdio_funcs[] = { 1, 1, };
  677. static int mt7986_wf_2g_pins[] = {74, 75, 76, 77, 78, 79, 80, 81, 82, 83, };
  678. static int mt7986_wf_2g_funcs[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
  679. static int mt7986_wf_5g_pins[] = {91, 92, 93, 94, 95, 96, 97, 98, 99, 100, };
  680. static int mt7986_wf_5g_funcs[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
  681. static int mt7986_wf_dbdc_pins[] = {
  682. 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, };
  683. static int mt7986_wf_dbdc_funcs[] = {
  684. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
  685. static int mt7986_pcie_clk_pins[] = { 9, };
  686. static int mt7986_pcie_clk_funcs[] = { 1, };
  687. static int mt7986_pcie_wake_pins[] = { 10, };
  688. static int mt7986_pcie_wake_funcs[] = { 1, };
  689. static const struct group_desc mt7986_groups[] = {
  690. PINCTRL_PIN_GROUP("watchdog", mt7986_watchdog),
  691. PINCTRL_PIN_GROUP("wifi_led", mt7986_wifi_led),
  692. PINCTRL_PIN_GROUP("i2c", mt7986_i2c),
  693. PINCTRL_PIN_GROUP("uart1_0", mt7986_uart1_0),
  694. PINCTRL_PIN_GROUP("pcie_clk", mt7986_pcie_clk),
  695. PINCTRL_PIN_GROUP("pcie_wake", mt7986_pcie_wake),
  696. PINCTRL_PIN_GROUP("spi1_0", mt7986_spi1_0),
  697. PINCTRL_PIN_GROUP("pwm1_1", mt7986_pwm1_1),
  698. PINCTRL_PIN_GROUP("pwm0", mt7986_pwm0),
  699. PINCTRL_PIN_GROUP("pwm1_0", mt7986_pwm1_0),
  700. PINCTRL_PIN_GROUP("emmc_45", mt7986_emmc_45),
  701. PINCTRL_PIN_GROUP("snfi", mt7986_snfi),
  702. PINCTRL_PIN_GROUP("spi1_1", mt7986_spi1_1),
  703. PINCTRL_PIN_GROUP("uart1_1", mt7986_uart1_1),
  704. PINCTRL_PIN_GROUP("spi1_2", mt7986_spi1_2),
  705. PINCTRL_PIN_GROUP("uart1_2", mt7986_uart1_2),
  706. PINCTRL_PIN_GROUP("uart2_0", mt7986_uart2_0),
  707. PINCTRL_PIN_GROUP("spi0", mt7986_spi0),
  708. PINCTRL_PIN_GROUP("spi0_wp_hold", mt7986_spi0_wp_hold),
  709. PINCTRL_PIN_GROUP("uart2_1", mt7986_uart2_1),
  710. PINCTRL_PIN_GROUP("uart1_3_rx_tx", mt7986_uart1_3_rx_tx),
  711. PINCTRL_PIN_GROUP("uart1_3_cts_rts", mt7986_uart1_3_cts_rts),
  712. PINCTRL_PIN_GROUP("spi1_3", mt7986_spi1_3),
  713. PINCTRL_PIN_GROUP("uart0", mt7986_uart0),
  714. PINCTRL_PIN_GROUP("switch_int", mt7986_switch_int),
  715. PINCTRL_PIN_GROUP("mdc_mdio", mt7986_mdc_mdio),
  716. PINCTRL_PIN_GROUP("pcie_pereset", mt7986_pcie_reset),
  717. PINCTRL_PIN_GROUP("uart1", mt7986_uart1),
  718. PINCTRL_PIN_GROUP("uart2", mt7986_uart2),
  719. PINCTRL_PIN_GROUP("emmc_51", mt7986_emmc_51),
  720. PINCTRL_PIN_GROUP("pcm", mt7986_pcm),
  721. PINCTRL_PIN_GROUP("i2s", mt7986_i2s),
  722. PINCTRL_PIN_GROUP("wf_2g", mt7986_wf_2g),
  723. PINCTRL_PIN_GROUP("wf_5g", mt7986_wf_5g),
  724. PINCTRL_PIN_GROUP("wf_dbdc", mt7986_wf_dbdc),
  725. };
  726. /* Joint those groups owning the same capability in user point of view which
  727. * allows that people tend to use through the device tree.
  728. */
  729. static const char *mt7986_audio_groups[] = { "pcm", "i2s" };
  730. static const char *mt7986_emmc_groups[] = {
  731. "emmc_45", "emmc_51", };
  732. static const char *mt7986_ethernet_groups[] = {
  733. "switch_int", "mdc_mdio", };
  734. static const char *mt7986_i2c_groups[] = { "i2c", };
  735. static const char *mt7986_led_groups[] = { "wifi_led", };
  736. static const char *mt7986_flash_groups[] = { "snfi", };
  737. static const char *mt7986_pcie_groups[] = {
  738. "pcie_clk", "pcie_wake", "pcie_pereset" };
  739. static const char *mt7986_pwm_groups[] = { "pwm0", "pwm1_0", "pwm1_1", };
  740. static const char *mt7986_spi_groups[] = {
  741. "spi0", "spi0_wp_hold", "spi1_0", "spi1_1", "spi1_2", "spi1_3", };
  742. static const char *mt7986_uart_groups[] = {
  743. "uart1_0", "uart1_1", "uart1_2", "uart1_3_rx_tx", "uart1_3_cts_rts",
  744. "uart2_0", "uart2_1", "uart0", "uart1", "uart2",
  745. };
  746. static const char *mt7986_wdt_groups[] = { "watchdog", };
  747. static const char *mt7986_wf_groups[] = { "wf_2g", "wf_5g", "wf_dbdc", };
  748. static const struct function_desc mt7986_functions[] = {
  749. {"audio", mt7986_audio_groups, ARRAY_SIZE(mt7986_audio_groups)},
  750. {"emmc", mt7986_emmc_groups, ARRAY_SIZE(mt7986_emmc_groups)},
  751. {"eth", mt7986_ethernet_groups, ARRAY_SIZE(mt7986_ethernet_groups)},
  752. {"i2c", mt7986_i2c_groups, ARRAY_SIZE(mt7986_i2c_groups)},
  753. {"led", mt7986_led_groups, ARRAY_SIZE(mt7986_led_groups)},
  754. {"flash", mt7986_flash_groups, ARRAY_SIZE(mt7986_flash_groups)},
  755. {"pcie", mt7986_pcie_groups, ARRAY_SIZE(mt7986_pcie_groups)},
  756. {"pwm", mt7986_pwm_groups, ARRAY_SIZE(mt7986_pwm_groups)},
  757. {"spi", mt7986_spi_groups, ARRAY_SIZE(mt7986_spi_groups)},
  758. {"uart", mt7986_uart_groups, ARRAY_SIZE(mt7986_uart_groups)},
  759. {"watchdog", mt7986_wdt_groups, ARRAY_SIZE(mt7986_wdt_groups)},
  760. {"wifi", mt7986_wf_groups, ARRAY_SIZE(mt7986_wf_groups)},
  761. };
  762. static const struct mtk_eint_hw mt7986a_eint_hw = {
  763. .port_mask = 7,
  764. .ports = 7,
  765. .ap_num = ARRAY_SIZE(mt7986a_pins),
  766. .db_cnt = 16,
  767. .db_time = debounce_time_mt6765,
  768. };
  769. static const struct mtk_eint_hw mt7986b_eint_hw = {
  770. .port_mask = 7,
  771. .ports = 7,
  772. .ap_num = ARRAY_SIZE(mt7986b_pins),
  773. .db_cnt = 16,
  774. .db_time = debounce_time_mt6765,
  775. };
  776. static struct mtk_pin_soc mt7986a_data = {
  777. .reg_cal = mt7986_reg_cals,
  778. .pins = mt7986a_pins,
  779. .npins = ARRAY_SIZE(mt7986a_pins),
  780. .grps = mt7986_groups,
  781. .ngrps = ARRAY_SIZE(mt7986_groups),
  782. .funcs = mt7986_functions,
  783. .nfuncs = ARRAY_SIZE(mt7986_functions),
  784. .eint_hw = &mt7986a_eint_hw,
  785. .gpio_m = 0,
  786. .ies_present = false,
  787. .base_names = mt7986_pinctrl_register_base_names,
  788. .nbase_names = ARRAY_SIZE(mt7986_pinctrl_register_base_names),
  789. .bias_set_combo = mtk_pinconf_bias_set_combo,
  790. .bias_get_combo = mtk_pinconf_bias_get_combo,
  791. .drive_set = mtk_pinconf_drive_set_rev1,
  792. .drive_get = mtk_pinconf_drive_get_rev1,
  793. .adv_pull_get = mtk_pinconf_adv_pull_get,
  794. .adv_pull_set = mtk_pinconf_adv_pull_set,
  795. };
  796. static struct mtk_pin_soc mt7986b_data = {
  797. .reg_cal = mt7986_reg_cals,
  798. .pins = mt7986b_pins,
  799. .npins = ARRAY_SIZE(mt7986b_pins),
  800. .grps = mt7986_groups,
  801. .ngrps = ARRAY_SIZE(mt7986_groups),
  802. .funcs = mt7986_functions,
  803. .nfuncs = ARRAY_SIZE(mt7986_functions),
  804. .eint_hw = &mt7986b_eint_hw,
  805. .gpio_m = 0,
  806. .ies_present = false,
  807. .base_names = mt7986_pinctrl_register_base_names,
  808. .nbase_names = ARRAY_SIZE(mt7986_pinctrl_register_base_names),
  809. .bias_set_combo = mtk_pinconf_bias_set_combo,
  810. .bias_get_combo = mtk_pinconf_bias_get_combo,
  811. .drive_set = mtk_pinconf_drive_set_rev1,
  812. .drive_get = mtk_pinconf_drive_get_rev1,
  813. .adv_pull_get = mtk_pinconf_adv_pull_get,
  814. .adv_pull_set = mtk_pinconf_adv_pull_set,
  815. };
  816. static const struct of_device_id mt7986a_pinctrl_of_match[] = {
  817. {.compatible = "mediatek,mt7986a-pinctrl",},
  818. {}
  819. };
  820. static const struct of_device_id mt7986b_pinctrl_of_match[] = {
  821. {.compatible = "mediatek,mt7986b-pinctrl",},
  822. {}
  823. };
  824. static int mt7986a_pinctrl_probe(struct platform_device *pdev)
  825. {
  826. return mtk_moore_pinctrl_probe(pdev, &mt7986a_data);
  827. }
  828. static int mt7986b_pinctrl_probe(struct platform_device *pdev)
  829. {
  830. return mtk_moore_pinctrl_probe(pdev, &mt7986b_data);
  831. }
  832. static struct platform_driver mt7986a_pinctrl_driver = {
  833. .driver = {
  834. .name = "mt7986a-pinctrl",
  835. .of_match_table = mt7986a_pinctrl_of_match,
  836. },
  837. .probe = mt7986a_pinctrl_probe,
  838. };
  839. static struct platform_driver mt7986b_pinctrl_driver = {
  840. .driver = {
  841. .name = "mt7986b-pinctrl",
  842. .of_match_table = mt7986b_pinctrl_of_match,
  843. },
  844. .probe = mt7986b_pinctrl_probe,
  845. };
  846. static int __init mt7986a_pinctrl_init(void)
  847. {
  848. return platform_driver_register(&mt7986a_pinctrl_driver);
  849. }
  850. static int __init mt7986b_pinctrl_init(void)
  851. {
  852. return platform_driver_register(&mt7986b_pinctrl_driver);
  853. }
  854. arch_initcall(mt7986a_pinctrl_init);
  855. arch_initcall(mt7986b_pinctrl_init);