215-v6.3-pinctrl-add-mt7981-pinctrl-driver.patch 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  1. From 6c83b2d94fcca735cf7d8aa7a55a4957eb404a9d Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <[email protected]>
  3. Date: Thu, 26 Jan 2023 00:34:56 +0000
  4. Subject: [PATCH] pinctrl: add mt7981 pinctrl driver
  5. Add pinctrl driver for the MediaTek MT7981 SoC, based on the driver
  6. which can also be found the SDK.
  7. Signed-off-by: Daniel Golle <[email protected]>
  8. Reviewed-by: Rob Herring <[email protected]>
  9. Link: https://lore.kernel.org/r/ef5112946d16cacc67e65e439ba7b52a9950c1bb.1674693008.git.daniel@makrotopia.org
  10. Signed-off-by: Linus Walleij <[email protected]>
  11. ---
  12. drivers/pinctrl/mediatek/Kconfig | 5 +
  13. drivers/pinctrl/mediatek/Makefile | 1 +
  14. drivers/pinctrl/mediatek/pinctrl-mt7981.c | 1048 +++++++++++++++++++++
  15. 3 files changed, 1054 insertions(+)
  16. create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt7981.c
  17. --- a/drivers/pinctrl/mediatek/Kconfig
  18. +++ b/drivers/pinctrl/mediatek/Kconfig
  19. @@ -127,6 +127,11 @@ config PINCTRL_MT7622
  20. default ARM64 && ARCH_MEDIATEK
  21. select PINCTRL_MTK_MOORE
  22. +config PINCTRL_MT7981
  23. + bool "Mediatek MT7981 pin control"
  24. + depends on OF
  25. + select PINCTRL_MTK_MOORE
  26. +
  27. config PINCTRL_MT7986
  28. bool "Mediatek MT7986 pin control"
  29. depends on OF
  30. --- a/drivers/pinctrl/mediatek/Makefile
  31. +++ b/drivers/pinctrl/mediatek/Makefile
  32. @@ -18,6 +18,7 @@ obj-$(CONFIG_PINCTRL_MT6797) += pinctrl-
  33. obj-$(CONFIG_PINCTRL_MT7622) += pinctrl-mt7622.o
  34. obj-$(CONFIG_PINCTRL_MT7623) += pinctrl-mt7623.o
  35. obj-$(CONFIG_PINCTRL_MT7629) += pinctrl-mt7629.o
  36. +obj-$(CONFIG_PINCTRL_MT7981) += pinctrl-mt7981.o
  37. obj-$(CONFIG_PINCTRL_MT7986) += pinctrl-mt7986.o
  38. obj-$(CONFIG_PINCTRL_MT8167) += pinctrl-mt8167.o
  39. obj-$(CONFIG_PINCTRL_MT8173) += pinctrl-mt8173.o
  40. --- /dev/null
  41. +++ b/drivers/pinctrl/mediatek/pinctrl-mt7981.c
  42. @@ -0,0 +1,1048 @@
  43. +// SPDX-License-Identifier: GPL-2.0
  44. +/*
  45. + * The MT7981 driver based on Linux generic pinctrl binding.
  46. + *
  47. + * Copyright (C) 2020 MediaTek Inc.
  48. + * Author: Sam Shih <[email protected]>
  49. + */
  50. +
  51. +#include "pinctrl-moore.h"
  52. +
  53. +#define MT7981_PIN(_number, _name) \
  54. + MTK_PIN(_number, _name, 0, _number, DRV_GRP4)
  55. +
  56. +#define PIN_FIELD_BASE(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, _x_bits) \
  57. + PIN_FIELD_CALC(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, \
  58. + _x_bits, 32, 0)
  59. +
  60. +#define PINS_FIELD_BASE(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, _x_bits) \
  61. + PIN_FIELD_CALC(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, _s_bit, \
  62. + _x_bits, 32, 1)
  63. +
  64. +static const struct mtk_pin_field_calc mt7981_pin_mode_range[] = {
  65. + PIN_FIELD(0, 56, 0x300, 0x10, 0, 4),
  66. +};
  67. +
  68. +static const struct mtk_pin_field_calc mt7981_pin_dir_range[] = {
  69. + PIN_FIELD(0, 56, 0x0, 0x10, 0, 1),
  70. +};
  71. +
  72. +static const struct mtk_pin_field_calc mt7981_pin_di_range[] = {
  73. + PIN_FIELD(0, 56, 0x200, 0x10, 0, 1),
  74. +};
  75. +
  76. +static const struct mtk_pin_field_calc mt7981_pin_do_range[] = {
  77. + PIN_FIELD(0, 56, 0x100, 0x10, 0, 1),
  78. +};
  79. +
  80. +static const struct mtk_pin_field_calc mt7981_pin_ies_range[] = {
  81. + PIN_FIELD_BASE(0, 0, 1, 0x10, 0x10, 1, 1),
  82. + PIN_FIELD_BASE(1, 1, 1, 0x10, 0x10, 0, 1),
  83. + PIN_FIELD_BASE(2, 2, 5, 0x20, 0x10, 6, 1),
  84. + PIN_FIELD_BASE(3, 3, 4, 0x20, 0x10, 6, 1),
  85. + PIN_FIELD_BASE(4, 4, 4, 0x20, 0x10, 2, 1),
  86. + PIN_FIELD_BASE(5, 5, 4, 0x20, 0x10, 1, 1),
  87. + PIN_FIELD_BASE(6, 6, 4, 0x20, 0x10, 3, 1),
  88. + PIN_FIELD_BASE(7, 7, 4, 0x20, 0x10, 0, 1),
  89. + PIN_FIELD_BASE(8, 8, 4, 0x20, 0x10, 4, 1),
  90. +
  91. + PIN_FIELD_BASE(9, 9, 5, 0x20, 0x10, 9, 1),
  92. + PIN_FIELD_BASE(10, 10, 5, 0x20, 0x10, 8, 1),
  93. + PIN_FIELD_BASE(11, 11, 5, 0x40, 0x10, 10, 1),
  94. + PIN_FIELD_BASE(12, 12, 5, 0x20, 0x10, 7, 1),
  95. + PIN_FIELD_BASE(13, 13, 5, 0x20, 0x10, 11, 1),
  96. +
  97. + PIN_FIELD_BASE(14, 14, 4, 0x20, 0x10, 8, 1),
  98. +
  99. + PIN_FIELD_BASE(15, 15, 2, 0x20, 0x10, 0, 1),
  100. + PIN_FIELD_BASE(16, 16, 2, 0x20, 0x10, 1, 1),
  101. + PIN_FIELD_BASE(17, 17, 2, 0x20, 0x10, 5, 1),
  102. + PIN_FIELD_BASE(18, 18, 2, 0x20, 0x10, 4, 1),
  103. + PIN_FIELD_BASE(19, 19, 2, 0x20, 0x10, 2, 1),
  104. + PIN_FIELD_BASE(20, 20, 2, 0x20, 0x10, 3, 1),
  105. + PIN_FIELD_BASE(21, 21, 2, 0x20, 0x10, 6, 1),
  106. + PIN_FIELD_BASE(22, 22, 2, 0x20, 0x10, 7, 1),
  107. + PIN_FIELD_BASE(23, 23, 2, 0x20, 0x10, 10, 1),
  108. + PIN_FIELD_BASE(24, 24, 2, 0x20, 0x10, 9, 1),
  109. + PIN_FIELD_BASE(25, 25, 2, 0x20, 0x10, 8, 1),
  110. +
  111. + PIN_FIELD_BASE(26, 26, 5, 0x20, 0x10, 0, 1),
  112. + PIN_FIELD_BASE(27, 27, 5, 0x20, 0x10, 4, 1),
  113. + PIN_FIELD_BASE(28, 28, 5, 0x20, 0x10, 3, 1),
  114. + PIN_FIELD_BASE(29, 29, 5, 0x20, 0x10, 1, 1),
  115. + PIN_FIELD_BASE(30, 30, 5, 0x20, 0x10, 2, 1),
  116. + PIN_FIELD_BASE(31, 31, 5, 0x20, 0x10, 5, 1),
  117. +
  118. + PIN_FIELD_BASE(32, 32, 1, 0x10, 0x10, 2, 1),
  119. + PIN_FIELD_BASE(33, 33, 1, 0x10, 0x10, 3, 1),
  120. +
  121. + PIN_FIELD_BASE(34, 34, 4, 0x20, 0x10, 5, 1),
  122. + PIN_FIELD_BASE(35, 35, 4, 0x20, 0x10, 7, 1),
  123. +
  124. + PIN_FIELD_BASE(36, 36, 3, 0x10, 0x10, 2, 1),
  125. + PIN_FIELD_BASE(37, 37, 3, 0x10, 0x10, 3, 1),
  126. + PIN_FIELD_BASE(38, 38, 3, 0x10, 0x10, 0, 1),
  127. + PIN_FIELD_BASE(39, 39, 3, 0x10, 0x10, 1, 1),
  128. +
  129. + PIN_FIELD_BASE(40, 40, 7, 0x30, 0x10, 1, 1),
  130. + PIN_FIELD_BASE(41, 41, 7, 0x30, 0x10, 0, 1),
  131. + PIN_FIELD_BASE(42, 42, 7, 0x30, 0x10, 9, 1),
  132. + PIN_FIELD_BASE(43, 43, 7, 0x30, 0x10, 7, 1),
  133. + PIN_FIELD_BASE(44, 44, 7, 0x30, 0x10, 8, 1),
  134. + PIN_FIELD_BASE(45, 45, 7, 0x30, 0x10, 3, 1),
  135. + PIN_FIELD_BASE(46, 46, 7, 0x30, 0x10, 4, 1),
  136. + PIN_FIELD_BASE(47, 47, 7, 0x30, 0x10, 5, 1),
  137. + PIN_FIELD_BASE(48, 48, 7, 0x30, 0x10, 6, 1),
  138. + PIN_FIELD_BASE(49, 49, 7, 0x30, 0x10, 2, 1),
  139. +
  140. + PIN_FIELD_BASE(50, 50, 6, 0x10, 0x10, 0, 1),
  141. + PIN_FIELD_BASE(51, 51, 6, 0x10, 0x10, 2, 1),
  142. + PIN_FIELD_BASE(52, 52, 6, 0x10, 0x10, 3, 1),
  143. + PIN_FIELD_BASE(53, 53, 6, 0x10, 0x10, 4, 1),
  144. + PIN_FIELD_BASE(54, 54, 6, 0x10, 0x10, 5, 1),
  145. + PIN_FIELD_BASE(55, 55, 6, 0x10, 0x10, 6, 1),
  146. + PIN_FIELD_BASE(56, 56, 6, 0x10, 0x10, 1, 1),
  147. +};
  148. +
  149. +static const struct mtk_pin_field_calc mt7981_pin_smt_range[] = {
  150. + PIN_FIELD_BASE(0, 0, 1, 0x60, 0x10, 1, 1),
  151. + PIN_FIELD_BASE(1, 1, 1, 0x60, 0x10, 0, 1),
  152. + PIN_FIELD_BASE(2, 2, 5, 0x90, 0x10, 6, 1),
  153. + PIN_FIELD_BASE(3, 3, 4, 0x80, 0x10, 6, 1),
  154. + PIN_FIELD_BASE(4, 4, 4, 0x80, 0x10, 2, 1),
  155. + PIN_FIELD_BASE(5, 5, 4, 0x80, 0x10, 1, 1),
  156. + PIN_FIELD_BASE(6, 6, 4, 0x80, 0x10, 3, 1),
  157. + PIN_FIELD_BASE(7, 7, 4, 0x80, 0x10, 0, 1),
  158. + PIN_FIELD_BASE(8, 8, 4, 0x80, 0x10, 4, 1),
  159. +
  160. + PIN_FIELD_BASE(9, 9, 5, 0x90, 0x10, 9, 1),
  161. + PIN_FIELD_BASE(10, 10, 5, 0x90, 0x10, 8, 1),
  162. + PIN_FIELD_BASE(11, 11, 5, 0x90, 0x10, 10, 1),
  163. + PIN_FIELD_BASE(12, 12, 5, 0x90, 0x10, 7, 1),
  164. + PIN_FIELD_BASE(13, 13, 5, 0x90, 0x10, 11, 1),
  165. +
  166. + PIN_FIELD_BASE(14, 14, 4, 0x80, 0x10, 8, 1),
  167. +
  168. + PIN_FIELD_BASE(15, 15, 2, 0x90, 0x10, 0, 1),
  169. + PIN_FIELD_BASE(16, 16, 2, 0x90, 0x10, 1, 1),
  170. + PIN_FIELD_BASE(17, 17, 2, 0x90, 0x10, 5, 1),
  171. + PIN_FIELD_BASE(18, 18, 2, 0x90, 0x10, 4, 1),
  172. + PIN_FIELD_BASE(19, 19, 2, 0x90, 0x10, 2, 1),
  173. + PIN_FIELD_BASE(20, 20, 2, 0x90, 0x10, 3, 1),
  174. + PIN_FIELD_BASE(21, 21, 2, 0x90, 0x10, 6, 1),
  175. + PIN_FIELD_BASE(22, 22, 2, 0x90, 0x10, 7, 1),
  176. + PIN_FIELD_BASE(23, 23, 2, 0x90, 0x10, 10, 1),
  177. + PIN_FIELD_BASE(24, 24, 2, 0x90, 0x10, 9, 1),
  178. + PIN_FIELD_BASE(25, 25, 2, 0x90, 0x10, 8, 1),
  179. +
  180. + PIN_FIELD_BASE(26, 26, 5, 0x90, 0x10, 0, 1),
  181. + PIN_FIELD_BASE(27, 27, 5, 0x90, 0x10, 4, 1),
  182. + PIN_FIELD_BASE(28, 28, 5, 0x90, 0x10, 3, 1),
  183. + PIN_FIELD_BASE(29, 29, 5, 0x90, 0x10, 1, 1),
  184. + PIN_FIELD_BASE(30, 30, 5, 0x90, 0x10, 2, 1),
  185. + PIN_FIELD_BASE(31, 31, 5, 0x90, 0x10, 5, 1),
  186. +
  187. + PIN_FIELD_BASE(32, 32, 1, 0x60, 0x10, 2, 1),
  188. + PIN_FIELD_BASE(33, 33, 1, 0x60, 0x10, 3, 1),
  189. +
  190. + PIN_FIELD_BASE(34, 34, 4, 0x80, 0x10, 5, 1),
  191. + PIN_FIELD_BASE(35, 35, 4, 0x80, 0x10, 7, 1),
  192. +
  193. + PIN_FIELD_BASE(36, 36, 3, 0x60, 0x10, 2, 1),
  194. + PIN_FIELD_BASE(37, 37, 3, 0x60, 0x10, 3, 1),
  195. + PIN_FIELD_BASE(38, 38, 3, 0x60, 0x10, 0, 1),
  196. + PIN_FIELD_BASE(39, 39, 3, 0x60, 0x10, 1, 1),
  197. +
  198. + PIN_FIELD_BASE(40, 40, 7, 0x70, 0x10, 1, 1),
  199. + PIN_FIELD_BASE(41, 41, 7, 0x70, 0x10, 0, 1),
  200. + PIN_FIELD_BASE(42, 42, 7, 0x70, 0x10, 9, 1),
  201. + PIN_FIELD_BASE(43, 43, 7, 0x70, 0x10, 7, 1),
  202. + PIN_FIELD_BASE(44, 44, 7, 0x30, 0x10, 8, 1),
  203. + PIN_FIELD_BASE(45, 45, 7, 0x70, 0x10, 3, 1),
  204. + PIN_FIELD_BASE(46, 46, 7, 0x70, 0x10, 4, 1),
  205. + PIN_FIELD_BASE(47, 47, 7, 0x70, 0x10, 5, 1),
  206. + PIN_FIELD_BASE(48, 48, 7, 0x70, 0x10, 6, 1),
  207. + PIN_FIELD_BASE(49, 49, 7, 0x70, 0x10, 2, 1),
  208. +
  209. + PIN_FIELD_BASE(50, 50, 6, 0x50, 0x10, 0, 1),
  210. + PIN_FIELD_BASE(51, 51, 6, 0x50, 0x10, 2, 1),
  211. + PIN_FIELD_BASE(52, 52, 6, 0x50, 0x10, 3, 1),
  212. + PIN_FIELD_BASE(53, 53, 6, 0x50, 0x10, 4, 1),
  213. + PIN_FIELD_BASE(54, 54, 6, 0x50, 0x10, 5, 1),
  214. + PIN_FIELD_BASE(55, 55, 6, 0x50, 0x10, 6, 1),
  215. + PIN_FIELD_BASE(56, 56, 6, 0x50, 0x10, 1, 1),
  216. +};
  217. +
  218. +static const struct mtk_pin_field_calc mt7981_pin_pu_range[] = {
  219. + PIN_FIELD_BASE(40, 40, 7, 0x50, 0x10, 1, 1),
  220. + PIN_FIELD_BASE(41, 41, 7, 0x50, 0x10, 0, 1),
  221. + PIN_FIELD_BASE(42, 42, 7, 0x50, 0x10, 9, 1),
  222. + PIN_FIELD_BASE(43, 43, 7, 0x50, 0x10, 7, 1),
  223. + PIN_FIELD_BASE(44, 44, 7, 0x50, 0x10, 8, 1),
  224. + PIN_FIELD_BASE(45, 45, 7, 0x50, 0x10, 3, 1),
  225. + PIN_FIELD_BASE(46, 46, 7, 0x50, 0x10, 4, 1),
  226. + PIN_FIELD_BASE(47, 47, 7, 0x50, 0x10, 5, 1),
  227. + PIN_FIELD_BASE(48, 48, 7, 0x50, 0x10, 6, 1),
  228. + PIN_FIELD_BASE(49, 49, 7, 0x50, 0x10, 2, 1),
  229. +
  230. + PIN_FIELD_BASE(50, 50, 6, 0x30, 0x10, 0, 1),
  231. + PIN_FIELD_BASE(51, 51, 6, 0x30, 0x10, 2, 1),
  232. + PIN_FIELD_BASE(52, 52, 6, 0x30, 0x10, 3, 1),
  233. + PIN_FIELD_BASE(53, 53, 6, 0x30, 0x10, 4, 1),
  234. + PIN_FIELD_BASE(54, 54, 6, 0x30, 0x10, 5, 1),
  235. + PIN_FIELD_BASE(55, 55, 6, 0x30, 0x10, 6, 1),
  236. + PIN_FIELD_BASE(56, 56, 6, 0x30, 0x10, 1, 1),
  237. +};
  238. +
  239. +static const struct mtk_pin_field_calc mt7981_pin_pd_range[] = {
  240. + PIN_FIELD_BASE(40, 40, 7, 0x40, 0x10, 1, 1),
  241. + PIN_FIELD_BASE(41, 41, 7, 0x40, 0x10, 0, 1),
  242. + PIN_FIELD_BASE(42, 42, 7, 0x40, 0x10, 9, 1),
  243. + PIN_FIELD_BASE(43, 43, 7, 0x40, 0x10, 7, 1),
  244. + PIN_FIELD_BASE(44, 44, 7, 0x40, 0x10, 8, 1),
  245. + PIN_FIELD_BASE(45, 45, 7, 0x40, 0x10, 3, 1),
  246. + PIN_FIELD_BASE(46, 46, 7, 0x40, 0x10, 4, 1),
  247. + PIN_FIELD_BASE(47, 47, 7, 0x40, 0x10, 5, 1),
  248. + PIN_FIELD_BASE(48, 48, 7, 0x40, 0x10, 6, 1),
  249. + PIN_FIELD_BASE(49, 49, 7, 0x40, 0x10, 2, 1),
  250. +
  251. + PIN_FIELD_BASE(50, 50, 6, 0x20, 0x10, 0, 1),
  252. + PIN_FIELD_BASE(51, 51, 6, 0x20, 0x10, 2, 1),
  253. + PIN_FIELD_BASE(52, 52, 6, 0x20, 0x10, 3, 1),
  254. + PIN_FIELD_BASE(53, 53, 6, 0x20, 0x10, 4, 1),
  255. + PIN_FIELD_BASE(54, 54, 6, 0x20, 0x10, 5, 1),
  256. + PIN_FIELD_BASE(55, 55, 6, 0x20, 0x10, 6, 1),
  257. + PIN_FIELD_BASE(56, 56, 6, 0x20, 0x10, 1, 1),
  258. +};
  259. +
  260. +static const struct mtk_pin_field_calc mt7981_pin_drv_range[] = {
  261. + PIN_FIELD_BASE(0, 0, 1, 0x00, 0x10, 3, 3),
  262. + PIN_FIELD_BASE(1, 1, 1, 0x00, 0x10, 0, 3),
  263. +
  264. + PIN_FIELD_BASE(2, 2, 5, 0x00, 0x10, 18, 3),
  265. +
  266. + PIN_FIELD_BASE(3, 3, 4, 0x00, 0x10, 18, 1),
  267. + PIN_FIELD_BASE(4, 4, 4, 0x00, 0x10, 6, 1),
  268. + PIN_FIELD_BASE(5, 5, 4, 0x00, 0x10, 3, 3),
  269. + PIN_FIELD_BASE(6, 6, 4, 0x00, 0x10, 9, 3),
  270. + PIN_FIELD_BASE(7, 7, 4, 0x00, 0x10, 0, 3),
  271. + PIN_FIELD_BASE(8, 8, 4, 0x00, 0x10, 12, 3),
  272. +
  273. + PIN_FIELD_BASE(9, 9, 5, 0x00, 0x10, 27, 3),
  274. + PIN_FIELD_BASE(10, 10, 5, 0x00, 0x10, 24, 3),
  275. + PIN_FIELD_BASE(11, 11, 5, 0x00, 0x10, 0, 3),
  276. + PIN_FIELD_BASE(12, 12, 5, 0x00, 0x10, 21, 3),
  277. + PIN_FIELD_BASE(13, 13, 5, 0x00, 0x10, 3, 3),
  278. +
  279. + PIN_FIELD_BASE(14, 14, 4, 0x00, 0x10, 27, 3),
  280. +
  281. + PIN_FIELD_BASE(15, 15, 2, 0x00, 0x10, 0, 3),
  282. + PIN_FIELD_BASE(16, 16, 2, 0x00, 0x10, 3, 3),
  283. + PIN_FIELD_BASE(17, 17, 2, 0x00, 0x10, 15, 3),
  284. + PIN_FIELD_BASE(18, 18, 2, 0x00, 0x10, 12, 3),
  285. + PIN_FIELD_BASE(19, 19, 2, 0x00, 0x10, 6, 3),
  286. + PIN_FIELD_BASE(20, 20, 2, 0x00, 0x10, 9, 3),
  287. + PIN_FIELD_BASE(21, 21, 2, 0x00, 0x10, 18, 3),
  288. + PIN_FIELD_BASE(22, 22, 2, 0x00, 0x10, 21, 3),
  289. + PIN_FIELD_BASE(23, 23, 2, 0x00, 0x10, 0, 3),
  290. + PIN_FIELD_BASE(24, 24, 2, 0x00, 0x10, 27, 3),
  291. + PIN_FIELD_BASE(25, 25, 2, 0x00, 0x10, 24, 3),
  292. +
  293. + PIN_FIELD_BASE(26, 26, 5, 0x00, 0x10, 0, 3),
  294. + PIN_FIELD_BASE(27, 27, 5, 0x00, 0x10, 12, 3),
  295. + PIN_FIELD_BASE(28, 28, 5, 0x00, 0x10, 9, 3),
  296. + PIN_FIELD_BASE(29, 29, 5, 0x00, 0x10, 3, 3),
  297. + PIN_FIELD_BASE(30, 30, 5, 0x00, 0x10, 6, 3),
  298. + PIN_FIELD_BASE(31, 31, 5, 0x00, 0x10, 15, 3),
  299. +
  300. + PIN_FIELD_BASE(32, 32, 1, 0x00, 0x10, 9, 3),
  301. + PIN_FIELD_BASE(33, 33, 1, 0x00, 0x10, 12, 3),
  302. +
  303. + PIN_FIELD_BASE(34, 34, 4, 0x00, 0x10, 15, 3),
  304. + PIN_FIELD_BASE(35, 35, 4, 0x00, 0x10, 21, 3),
  305. +
  306. + PIN_FIELD_BASE(36, 36, 3, 0x00, 0x10, 6, 3),
  307. + PIN_FIELD_BASE(37, 37, 3, 0x00, 0x10, 9, 3),
  308. + PIN_FIELD_BASE(38, 38, 3, 0x00, 0x10, 0, 3),
  309. + PIN_FIELD_BASE(39, 39, 3, 0x00, 0x10, 3, 3),
  310. +
  311. + PIN_FIELD_BASE(40, 40, 7, 0x00, 0x10, 3, 3),
  312. + PIN_FIELD_BASE(41, 41, 7, 0x00, 0x10, 0, 3),
  313. + PIN_FIELD_BASE(42, 42, 7, 0x00, 0x10, 27, 3),
  314. + PIN_FIELD_BASE(43, 43, 7, 0x00, 0x10, 21, 3),
  315. + PIN_FIELD_BASE(44, 44, 7, 0x00, 0x10, 24, 3),
  316. + PIN_FIELD_BASE(45, 45, 7, 0x00, 0x10, 9, 3),
  317. + PIN_FIELD_BASE(46, 46, 7, 0x00, 0x10, 12, 3),
  318. + PIN_FIELD_BASE(47, 47, 7, 0x00, 0x10, 15, 3),
  319. + PIN_FIELD_BASE(48, 48, 7, 0x00, 0x10, 18, 3),
  320. + PIN_FIELD_BASE(49, 49, 7, 0x00, 0x10, 6, 3),
  321. +
  322. + PIN_FIELD_BASE(50, 50, 6, 0x00, 0x10, 0, 3),
  323. + PIN_FIELD_BASE(51, 51, 6, 0x00, 0x10, 6, 3),
  324. + PIN_FIELD_BASE(52, 52, 6, 0x00, 0x10, 9, 3),
  325. + PIN_FIELD_BASE(53, 53, 6, 0x00, 0x10, 12, 3),
  326. + PIN_FIELD_BASE(54, 54, 6, 0x00, 0x10, 15, 3),
  327. + PIN_FIELD_BASE(55, 55, 6, 0x00, 0x10, 18, 3),
  328. + PIN_FIELD_BASE(56, 56, 6, 0x00, 0x10, 3, 3),
  329. +};
  330. +
  331. +static const struct mtk_pin_field_calc mt7981_pin_pupd_range[] = {
  332. + PIN_FIELD_BASE(0, 0, 1, 0x20, 0x10, 1, 1),
  333. + PIN_FIELD_BASE(1, 1, 1, 0x20, 0x10, 0, 1),
  334. + PIN_FIELD_BASE(2, 2, 5, 0x30, 0x10, 6, 1),
  335. + PIN_FIELD_BASE(3, 3, 4, 0x30, 0x10, 6, 1),
  336. + PIN_FIELD_BASE(4, 4, 4, 0x30, 0x10, 2, 1),
  337. + PIN_FIELD_BASE(5, 5, 4, 0x30, 0x10, 1, 1),
  338. + PIN_FIELD_BASE(6, 6, 4, 0x30, 0x10, 3, 1),
  339. + PIN_FIELD_BASE(7, 7, 4, 0x30, 0x10, 0, 1),
  340. + PIN_FIELD_BASE(8, 8, 4, 0x30, 0x10, 4, 1),
  341. +
  342. + PIN_FIELD_BASE(9, 9, 5, 0x30, 0x10, 9, 1),
  343. + PIN_FIELD_BASE(10, 10, 5, 0x30, 0x10, 8, 1),
  344. + PIN_FIELD_BASE(11, 11, 5, 0x30, 0x10, 10, 1),
  345. + PIN_FIELD_BASE(12, 12, 5, 0x30, 0x10, 7, 1),
  346. + PIN_FIELD_BASE(13, 13, 5, 0x30, 0x10, 11, 1),
  347. +
  348. + PIN_FIELD_BASE(14, 14, 4, 0x30, 0x10, 8, 1),
  349. +
  350. + PIN_FIELD_BASE(15, 15, 2, 0x30, 0x10, 0, 1),
  351. + PIN_FIELD_BASE(16, 16, 2, 0x30, 0x10, 1, 1),
  352. + PIN_FIELD_BASE(17, 17, 2, 0x30, 0x10, 5, 1),
  353. + PIN_FIELD_BASE(18, 18, 2, 0x30, 0x10, 4, 1),
  354. + PIN_FIELD_BASE(19, 19, 2, 0x30, 0x10, 2, 1),
  355. + PIN_FIELD_BASE(20, 20, 2, 0x90, 0x10, 3, 1),
  356. + PIN_FIELD_BASE(21, 21, 2, 0x30, 0x10, 6, 1),
  357. + PIN_FIELD_BASE(22, 22, 2, 0x30, 0x10, 7, 1),
  358. + PIN_FIELD_BASE(23, 23, 2, 0x30, 0x10, 10, 1),
  359. + PIN_FIELD_BASE(24, 24, 2, 0x30, 0x10, 9, 1),
  360. + PIN_FIELD_BASE(25, 25, 2, 0x30, 0x10, 8, 1),
  361. +
  362. + PIN_FIELD_BASE(26, 26, 5, 0x30, 0x10, 0, 1),
  363. + PIN_FIELD_BASE(27, 27, 5, 0x30, 0x10, 4, 1),
  364. + PIN_FIELD_BASE(28, 28, 5, 0x30, 0x10, 3, 1),
  365. + PIN_FIELD_BASE(29, 29, 5, 0x30, 0x10, 1, 1),
  366. + PIN_FIELD_BASE(30, 30, 5, 0x30, 0x10, 2, 1),
  367. + PIN_FIELD_BASE(31, 31, 5, 0x30, 0x10, 5, 1),
  368. +
  369. + PIN_FIELD_BASE(32, 32, 1, 0x20, 0x10, 2, 1),
  370. + PIN_FIELD_BASE(33, 33, 1, 0x20, 0x10, 3, 1),
  371. +
  372. + PIN_FIELD_BASE(34, 34, 4, 0x30, 0x10, 5, 1),
  373. + PIN_FIELD_BASE(35, 35, 4, 0x30, 0x10, 7, 1),
  374. +
  375. + PIN_FIELD_BASE(36, 36, 3, 0x20, 0x10, 2, 1),
  376. + PIN_FIELD_BASE(37, 37, 3, 0x20, 0x10, 3, 1),
  377. + PIN_FIELD_BASE(38, 38, 3, 0x20, 0x10, 0, 1),
  378. + PIN_FIELD_BASE(39, 39, 3, 0x20, 0x10, 1, 1),
  379. +};
  380. +
  381. +static const struct mtk_pin_field_calc mt7981_pin_r0_range[] = {
  382. + PIN_FIELD_BASE(0, 0, 1, 0x30, 0x10, 1, 1),
  383. + PIN_FIELD_BASE(1, 1, 1, 0x30, 0x10, 0, 1),
  384. + PIN_FIELD_BASE(2, 2, 5, 0x40, 0x10, 6, 1),
  385. + PIN_FIELD_BASE(3, 3, 4, 0x40, 0x10, 6, 1),
  386. + PIN_FIELD_BASE(4, 4, 4, 0x40, 0x10, 2, 1),
  387. + PIN_FIELD_BASE(5, 5, 4, 0x40, 0x10, 1, 1),
  388. + PIN_FIELD_BASE(6, 6, 4, 0x40, 0x10, 3, 1),
  389. + PIN_FIELD_BASE(7, 7, 4, 0x40, 0x10, 0, 1),
  390. + PIN_FIELD_BASE(8, 8, 4, 0x40, 0x10, 4, 1),
  391. +
  392. + PIN_FIELD_BASE(9, 9, 5, 0x40, 0x10, 9, 1),
  393. + PIN_FIELD_BASE(10, 10, 5, 0x40, 0x10, 8, 1),
  394. + PIN_FIELD_BASE(11, 11, 5, 0x40, 0x10, 10, 1),
  395. + PIN_FIELD_BASE(12, 12, 5, 0x40, 0x10, 7, 1),
  396. + PIN_FIELD_BASE(13, 13, 5, 0x40, 0x10, 11, 1),
  397. +
  398. + PIN_FIELD_BASE(14, 14, 4, 0x40, 0x10, 8, 1),
  399. +
  400. + PIN_FIELD_BASE(15, 15, 2, 0x40, 0x10, 0, 1),
  401. + PIN_FIELD_BASE(16, 16, 2, 0x40, 0x10, 1, 1),
  402. + PIN_FIELD_BASE(17, 17, 2, 0x40, 0x10, 5, 1),
  403. + PIN_FIELD_BASE(18, 18, 2, 0x40, 0x10, 4, 1),
  404. + PIN_FIELD_BASE(19, 19, 2, 0x40, 0x10, 2, 1),
  405. + PIN_FIELD_BASE(20, 20, 2, 0x40, 0x10, 3, 1),
  406. + PIN_FIELD_BASE(21, 21, 2, 0x40, 0x10, 6, 1),
  407. + PIN_FIELD_BASE(22, 22, 2, 0x40, 0x10, 7, 1),
  408. + PIN_FIELD_BASE(23, 23, 2, 0x40, 0x10, 10, 1),
  409. + PIN_FIELD_BASE(24, 24, 2, 0x40, 0x10, 9, 1),
  410. + PIN_FIELD_BASE(25, 25, 2, 0x40, 0x10, 8, 1),
  411. +
  412. + PIN_FIELD_BASE(26, 26, 5, 0x40, 0x10, 0, 1),
  413. + PIN_FIELD_BASE(27, 27, 5, 0x40, 0x10, 4, 1),
  414. + PIN_FIELD_BASE(28, 28, 5, 0x40, 0x10, 3, 1),
  415. + PIN_FIELD_BASE(29, 29, 5, 0x40, 0x10, 1, 1),
  416. + PIN_FIELD_BASE(30, 30, 5, 0x40, 0x10, 2, 1),
  417. + PIN_FIELD_BASE(31, 31, 5, 0x40, 0x10, 5, 1),
  418. +
  419. + PIN_FIELD_BASE(32, 32, 1, 0x30, 0x10, 2, 1),
  420. + PIN_FIELD_BASE(33, 33, 1, 0x30, 0x10, 3, 1),
  421. +
  422. + PIN_FIELD_BASE(34, 34, 4, 0x40, 0x10, 5, 1),
  423. + PIN_FIELD_BASE(35, 35, 4, 0x40, 0x10, 7, 1),
  424. +
  425. + PIN_FIELD_BASE(36, 36, 3, 0x30, 0x10, 2, 1),
  426. + PIN_FIELD_BASE(37, 37, 3, 0x30, 0x10, 3, 1),
  427. + PIN_FIELD_BASE(38, 38, 3, 0x30, 0x10, 0, 1),
  428. + PIN_FIELD_BASE(39, 39, 3, 0x30, 0x10, 1, 1),
  429. +};
  430. +
  431. +static const struct mtk_pin_field_calc mt7981_pin_r1_range[] = {
  432. + PIN_FIELD_BASE(0, 0, 1, 0x40, 0x10, 1, 1),
  433. + PIN_FIELD_BASE(1, 1, 1, 0x40, 0x10, 0, 1),
  434. + PIN_FIELD_BASE(2, 2, 5, 0x50, 0x10, 6, 1),
  435. + PIN_FIELD_BASE(3, 3, 4, 0x50, 0x10, 6, 1),
  436. + PIN_FIELD_BASE(4, 4, 4, 0x50, 0x10, 2, 1),
  437. + PIN_FIELD_BASE(5, 5, 4, 0x50, 0x10, 1, 1),
  438. + PIN_FIELD_BASE(6, 6, 4, 0x50, 0x10, 3, 1),
  439. + PIN_FIELD_BASE(7, 7, 4, 0x50, 0x10, 0, 1),
  440. + PIN_FIELD_BASE(8, 8, 4, 0x50, 0x10, 4, 1),
  441. +
  442. + PIN_FIELD_BASE(9, 9, 5, 0x50, 0x10, 9, 1),
  443. + PIN_FIELD_BASE(10, 10, 5, 0x50, 0x10, 8, 1),
  444. + PIN_FIELD_BASE(11, 11, 5, 0x50, 0x10, 10, 1),
  445. + PIN_FIELD_BASE(12, 12, 5, 0x50, 0x10, 7, 1),
  446. + PIN_FIELD_BASE(13, 13, 5, 0x50, 0x10, 11, 1),
  447. +
  448. + PIN_FIELD_BASE(14, 14, 4, 0x50, 0x10, 8, 1),
  449. +
  450. + PIN_FIELD_BASE(15, 15, 2, 0x50, 0x10, 0, 1),
  451. + PIN_FIELD_BASE(16, 16, 2, 0x50, 0x10, 1, 1),
  452. + PIN_FIELD_BASE(17, 17, 2, 0x50, 0x10, 5, 1),
  453. + PIN_FIELD_BASE(18, 18, 2, 0x50, 0x10, 4, 1),
  454. + PIN_FIELD_BASE(19, 19, 2, 0x50, 0x10, 2, 1),
  455. + PIN_FIELD_BASE(20, 20, 2, 0x50, 0x10, 3, 1),
  456. + PIN_FIELD_BASE(21, 21, 2, 0x50, 0x10, 6, 1),
  457. + PIN_FIELD_BASE(22, 22, 2, 0x50, 0x10, 7, 1),
  458. + PIN_FIELD_BASE(23, 23, 2, 0x50, 0x10, 10, 1),
  459. + PIN_FIELD_BASE(24, 24, 2, 0x50, 0x10, 9, 1),
  460. + PIN_FIELD_BASE(25, 25, 2, 0x50, 0x10, 8, 1),
  461. +
  462. + PIN_FIELD_BASE(26, 26, 5, 0x50, 0x10, 0, 1),
  463. + PIN_FIELD_BASE(27, 27, 5, 0x50, 0x10, 4, 1),
  464. + PIN_FIELD_BASE(28, 28, 5, 0x50, 0x10, 3, 1),
  465. + PIN_FIELD_BASE(29, 29, 5, 0x50, 0x10, 1, 1),
  466. + PIN_FIELD_BASE(30, 30, 5, 0x50, 0x10, 2, 1),
  467. + PIN_FIELD_BASE(31, 31, 5, 0x50, 0x10, 5, 1),
  468. +
  469. + PIN_FIELD_BASE(32, 32, 1, 0x40, 0x10, 2, 1),
  470. + PIN_FIELD_BASE(33, 33, 1, 0x40, 0x10, 3, 1),
  471. +
  472. + PIN_FIELD_BASE(34, 34, 4, 0x50, 0x10, 5, 1),
  473. + PIN_FIELD_BASE(35, 35, 4, 0x50, 0x10, 7, 1),
  474. +
  475. + PIN_FIELD_BASE(36, 36, 3, 0x40, 0x10, 2, 1),
  476. + PIN_FIELD_BASE(37, 37, 3, 0x40, 0x10, 3, 1),
  477. + PIN_FIELD_BASE(38, 38, 3, 0x40, 0x10, 0, 1),
  478. + PIN_FIELD_BASE(39, 39, 3, 0x40, 0x10, 1, 1),
  479. +};
  480. +
  481. +static const unsigned int mt7981_pull_type[] = {
  482. + MTK_PULL_PUPD_R1R0_TYPE,/*0*/ MTK_PULL_PUPD_R1R0_TYPE,/*1*/
  483. + MTK_PULL_PUPD_R1R0_TYPE,/*2*/ MTK_PULL_PUPD_R1R0_TYPE,/*3*/
  484. + MTK_PULL_PUPD_R1R0_TYPE,/*4*/ MTK_PULL_PUPD_R1R0_TYPE,/*5*/
  485. + MTK_PULL_PUPD_R1R0_TYPE,/*6*/ MTK_PULL_PUPD_R1R0_TYPE,/*7*/
  486. + MTK_PULL_PUPD_R1R0_TYPE,/*8*/ MTK_PULL_PUPD_R1R0_TYPE,/*9*/
  487. + MTK_PULL_PUPD_R1R0_TYPE,/*10*/ MTK_PULL_PUPD_R1R0_TYPE,/*11*/
  488. + MTK_PULL_PUPD_R1R0_TYPE,/*12*/ MTK_PULL_PUPD_R1R0_TYPE,/*13*/
  489. + MTK_PULL_PUPD_R1R0_TYPE,/*14*/ MTK_PULL_PUPD_R1R0_TYPE,/*15*/
  490. + MTK_PULL_PUPD_R1R0_TYPE,/*16*/ MTK_PULL_PUPD_R1R0_TYPE,/*17*/
  491. + MTK_PULL_PUPD_R1R0_TYPE,/*18*/ MTK_PULL_PUPD_R1R0_TYPE,/*19*/
  492. + MTK_PULL_PUPD_R1R0_TYPE,/*20*/ MTK_PULL_PUPD_R1R0_TYPE,/*21*/
  493. + MTK_PULL_PUPD_R1R0_TYPE,/*22*/ MTK_PULL_PUPD_R1R0_TYPE,/*23*/
  494. + MTK_PULL_PUPD_R1R0_TYPE,/*24*/ MTK_PULL_PUPD_R1R0_TYPE,/*25*/
  495. + MTK_PULL_PUPD_R1R0_TYPE,/*26*/ MTK_PULL_PUPD_R1R0_TYPE,/*27*/
  496. + MTK_PULL_PUPD_R1R0_TYPE,/*28*/ MTK_PULL_PUPD_R1R0_TYPE,/*29*/
  497. + MTK_PULL_PUPD_R1R0_TYPE,/*30*/ MTK_PULL_PUPD_R1R0_TYPE,/*31*/
  498. + MTK_PULL_PUPD_R1R0_TYPE,/*32*/ MTK_PULL_PUPD_R1R0_TYPE,/*33*/
  499. + MTK_PULL_PUPD_R1R0_TYPE,/*34*/ MTK_PULL_PUPD_R1R0_TYPE,/*35*/
  500. + MTK_PULL_PUPD_R1R0_TYPE,/*36*/ MTK_PULL_PUPD_R1R0_TYPE,/*37*/
  501. + MTK_PULL_PUPD_R1R0_TYPE,/*38*/ MTK_PULL_PUPD_R1R0_TYPE,/*39*/
  502. + MTK_PULL_PUPD_R1R0_TYPE,/*40*/ MTK_PULL_PUPD_R1R0_TYPE,/*41*/
  503. + MTK_PULL_PUPD_R1R0_TYPE,/*42*/ MTK_PULL_PUPD_R1R0_TYPE,/*43*/
  504. + MTK_PULL_PUPD_R1R0_TYPE,/*44*/ MTK_PULL_PUPD_R1R0_TYPE,/*45*/
  505. + MTK_PULL_PUPD_R1R0_TYPE,/*46*/ MTK_PULL_PUPD_R1R0_TYPE,/*47*/
  506. + MTK_PULL_PUPD_R1R0_TYPE,/*48*/ MTK_PULL_PUPD_R1R0_TYPE,/*49*/
  507. + MTK_PULL_PUPD_R1R0_TYPE,/*50*/ MTK_PULL_PUPD_R1R0_TYPE,/*51*/
  508. + MTK_PULL_PUPD_R1R0_TYPE,/*52*/ MTK_PULL_PUPD_R1R0_TYPE,/*53*/
  509. + MTK_PULL_PUPD_R1R0_TYPE,/*54*/ MTK_PULL_PUPD_R1R0_TYPE,/*55*/
  510. + MTK_PULL_PUPD_R1R0_TYPE,/*56*/ MTK_PULL_PUPD_R1R0_TYPE,/*57*/
  511. + MTK_PULL_PUPD_R1R0_TYPE,/*58*/ MTK_PULL_PUPD_R1R0_TYPE,/*59*/
  512. + MTK_PULL_PUPD_R1R0_TYPE,/*60*/ MTK_PULL_PUPD_R1R0_TYPE,/*61*/
  513. + MTK_PULL_PUPD_R1R0_TYPE,/*62*/ MTK_PULL_PUPD_R1R0_TYPE,/*63*/
  514. + MTK_PULL_PUPD_R1R0_TYPE,/*64*/ MTK_PULL_PUPD_R1R0_TYPE,/*65*/
  515. + MTK_PULL_PUPD_R1R0_TYPE,/*66*/ MTK_PULL_PUPD_R1R0_TYPE,/*67*/
  516. + MTK_PULL_PUPD_R1R0_TYPE,/*68*/ MTK_PULL_PU_PD_TYPE,/*69*/
  517. + MTK_PULL_PU_PD_TYPE,/*70*/ MTK_PULL_PU_PD_TYPE,/*71*/
  518. + MTK_PULL_PU_PD_TYPE,/*72*/ MTK_PULL_PU_PD_TYPE,/*73*/
  519. + MTK_PULL_PU_PD_TYPE,/*74*/ MTK_PULL_PU_PD_TYPE,/*75*/
  520. + MTK_PULL_PU_PD_TYPE,/*76*/ MTK_PULL_PU_PD_TYPE,/*77*/
  521. + MTK_PULL_PU_PD_TYPE,/*78*/ MTK_PULL_PU_PD_TYPE,/*79*/
  522. + MTK_PULL_PU_PD_TYPE,/*80*/ MTK_PULL_PU_PD_TYPE,/*81*/
  523. + MTK_PULL_PU_PD_TYPE,/*82*/ MTK_PULL_PU_PD_TYPE,/*83*/
  524. + MTK_PULL_PU_PD_TYPE,/*84*/ MTK_PULL_PU_PD_TYPE,/*85*/
  525. + MTK_PULL_PU_PD_TYPE,/*86*/ MTK_PULL_PU_PD_TYPE,/*87*/
  526. + MTK_PULL_PU_PD_TYPE,/*88*/ MTK_PULL_PU_PD_TYPE,/*89*/
  527. + MTK_PULL_PU_PD_TYPE,/*90*/ MTK_PULL_PU_PD_TYPE,/*91*/
  528. + MTK_PULL_PU_PD_TYPE,/*92*/ MTK_PULL_PU_PD_TYPE,/*93*/
  529. + MTK_PULL_PU_PD_TYPE,/*94*/ MTK_PULL_PU_PD_TYPE,/*95*/
  530. + MTK_PULL_PU_PD_TYPE,/*96*/ MTK_PULL_PU_PD_TYPE,/*97*/
  531. + MTK_PULL_PU_PD_TYPE,/*98*/ MTK_PULL_PU_PD_TYPE,/*99*/
  532. + MTK_PULL_PU_PD_TYPE,/*100*/
  533. +};
  534. +
  535. +static const struct mtk_pin_reg_calc mt7981_reg_cals[] = {
  536. + [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7981_pin_mode_range),
  537. + [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7981_pin_dir_range),
  538. + [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7981_pin_di_range),
  539. + [PINCTRL_PIN_REG_DO] = MTK_RANGE(mt7981_pin_do_range),
  540. + [PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt7981_pin_smt_range),
  541. + [PINCTRL_PIN_REG_IES] = MTK_RANGE(mt7981_pin_ies_range),
  542. + [PINCTRL_PIN_REG_PU] = MTK_RANGE(mt7981_pin_pu_range),
  543. + [PINCTRL_PIN_REG_PD] = MTK_RANGE(mt7981_pin_pd_range),
  544. + [PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt7981_pin_drv_range),
  545. + [PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt7981_pin_pupd_range),
  546. + [PINCTRL_PIN_REG_R0] = MTK_RANGE(mt7981_pin_r0_range),
  547. + [PINCTRL_PIN_REG_R1] = MTK_RANGE(mt7981_pin_r1_range),
  548. +};
  549. +
  550. +static const struct mtk_pin_desc mt7981_pins[] = {
  551. + MT7981_PIN(0, "GPIO_WPS"),
  552. + MT7981_PIN(1, "GPIO_RESET"),
  553. + MT7981_PIN(2, "SYS_WATCHDOG"),
  554. + MT7981_PIN(3, "PCIE_PERESET_N"),
  555. + MT7981_PIN(4, "JTAG_JTDO"),
  556. + MT7981_PIN(5, "JTAG_JTDI"),
  557. + MT7981_PIN(6, "JTAG_JTMS"),
  558. + MT7981_PIN(7, "JTAG_JTCLK"),
  559. + MT7981_PIN(8, "JTAG_JTRST_N"),
  560. + MT7981_PIN(9, "WO_JTAG_JTDO"),
  561. + MT7981_PIN(10, "WO_JTAG_JTDI"),
  562. + MT7981_PIN(11, "WO_JTAG_JTMS"),
  563. + MT7981_PIN(12, "WO_JTAG_JTCLK"),
  564. + MT7981_PIN(13, "WO_JTAG_JTRST_N"),
  565. + MT7981_PIN(14, "USB_VBUS"),
  566. + MT7981_PIN(15, "PWM0"),
  567. + MT7981_PIN(16, "SPI0_CLK"),
  568. + MT7981_PIN(17, "SPI0_MOSI"),
  569. + MT7981_PIN(18, "SPI0_MISO"),
  570. + MT7981_PIN(19, "SPI0_CS"),
  571. + MT7981_PIN(20, "SPI0_HOLD"),
  572. + MT7981_PIN(21, "SPI0_WP"),
  573. + MT7981_PIN(22, "SPI1_CLK"),
  574. + MT7981_PIN(23, "SPI1_MOSI"),
  575. + MT7981_PIN(24, "SPI1_MISO"),
  576. + MT7981_PIN(25, "SPI1_CS"),
  577. + MT7981_PIN(26, "SPI2_CLK"),
  578. + MT7981_PIN(27, "SPI2_MOSI"),
  579. + MT7981_PIN(28, "SPI2_MISO"),
  580. + MT7981_PIN(29, "SPI2_CS"),
  581. + MT7981_PIN(30, "SPI2_HOLD"),
  582. + MT7981_PIN(31, "SPI2_WP"),
  583. + MT7981_PIN(32, "UART0_RXD"),
  584. + MT7981_PIN(33, "UART0_TXD"),
  585. + MT7981_PIN(34, "PCIE_CLK_REQ"),
  586. + MT7981_PIN(35, "PCIE_WAKE_N"),
  587. + MT7981_PIN(36, "SMI_MDC"),
  588. + MT7981_PIN(37, "SMI_MDIO"),
  589. + MT7981_PIN(38, "GBE_INT"),
  590. + MT7981_PIN(39, "GBE_RESET"),
  591. + MT7981_PIN(40, "WF_DIG_RESETB"),
  592. + MT7981_PIN(41, "WF_CBA_RESETB"),
  593. + MT7981_PIN(42, "WF_XO_REQ"),
  594. + MT7981_PIN(43, "WF_TOP_CLK"),
  595. + MT7981_PIN(44, "WF_TOP_DATA"),
  596. + MT7981_PIN(45, "WF_HB1"),
  597. + MT7981_PIN(46, "WF_HB2"),
  598. + MT7981_PIN(47, "WF_HB3"),
  599. + MT7981_PIN(48, "WF_HB4"),
  600. + MT7981_PIN(49, "WF_HB0"),
  601. + MT7981_PIN(50, "WF_HB0_B"),
  602. + MT7981_PIN(51, "WF_HB5"),
  603. + MT7981_PIN(52, "WF_HB6"),
  604. + MT7981_PIN(53, "WF_HB7"),
  605. + MT7981_PIN(54, "WF_HB8"),
  606. + MT7981_PIN(55, "WF_HB9"),
  607. + MT7981_PIN(56, "WF_HB10"),
  608. +};
  609. +
  610. +/* List all groups consisting of these pins dedicated to the enablement of
  611. + * certain hardware block and the corresponding mode for all of the pins.
  612. + * The hardware probably has multiple combinations of these pinouts.
  613. + */
  614. +
  615. +/* WA_AICE */
  616. +static int mt7981_wa_aice1_pins[] = { 0, 1, };
  617. +static int mt7981_wa_aice1_funcs[] = { 2, 2, };
  618. +
  619. +static int mt7981_wa_aice2_pins[] = { 0, 1, };
  620. +static int mt7981_wa_aice2_funcs[] = { 3, 3, };
  621. +
  622. +static int mt7981_wa_aice3_pins[] = { 28, 29, };
  623. +static int mt7981_wa_aice3_funcs[] = { 3, 3, };
  624. +
  625. +static int mt7981_wm_aice1_pins[] = { 9, 10, };
  626. +static int mt7981_wm_aice1_funcs[] = { 2, 2, };
  627. +
  628. +static int mt7981_wm_aice2_pins[] = { 30, 31, };
  629. +static int mt7981_wm_aice2_funcs[] = { 5, 5, };
  630. +
  631. +/* WM_UART */
  632. +static int mt7981_wm_uart_0_pins[] = { 0, 1, };
  633. +static int mt7981_wm_uart_0_funcs[] = { 5, 5, };
  634. +
  635. +static int mt7981_wm_uart_1_pins[] = { 20, 21, };
  636. +static int mt7981_wm_uart_1_funcs[] = { 4, 4, };
  637. +
  638. +static int mt7981_wm_uart_2_pins[] = { 30, 31, };
  639. +static int mt7981_wm_uart_2_funcs[] = { 3, 3, };
  640. +
  641. +/* DFD */
  642. +static int mt7981_dfd_pins[] = { 0, 1, 4, 5, };
  643. +static int mt7981_dfd_funcs[] = { 5, 5, 6, 6, };
  644. +
  645. +/* SYS_WATCHDOG */
  646. +static int mt7981_watchdog_pins[] = { 2, };
  647. +static int mt7981_watchdog_funcs[] = { 1, };
  648. +
  649. +static int mt7981_watchdog1_pins[] = { 13, };
  650. +static int mt7981_watchdog1_funcs[] = { 5, };
  651. +
  652. +/* PCIE_PERESET_N */
  653. +static int mt7981_pcie_pereset_pins[] = { 3, };
  654. +static int mt7981_pcie_pereset_funcs[] = { 1, };
  655. +
  656. +/* JTAG */
  657. +static int mt7981_jtag_pins[] = { 4, 5, 6, 7, 8, };
  658. +static int mt7981_jtag_funcs[] = { 1, 1, 1, 1, 1, };
  659. +
  660. +/* WM_JTAG */
  661. +static int mt7981_wm_jtag_0_pins[] = { 4, 5, 6, 7, 8, };
  662. +static int mt7981_wm_jtag_0_funcs[] = { 2, 2, 2, 2, 2, };
  663. +
  664. +static int mt7981_wm_jtag_1_pins[] = { 20, 21, 22, 23, 24, };
  665. +static int mt7981_wm_jtag_1_funcs[] = { 5, 5, 5, 5, 5, };
  666. +
  667. +/* WO0_JTAG */
  668. +static int mt7981_wo0_jtag_0_pins[] = { 9, 10, 11, 12, 13, };
  669. +static int mt7981_wo0_jtag_0_funcs[] = { 1, 1, 1, 1, 1, };
  670. +
  671. +static int mt7981_wo0_jtag_1_pins[] = { 25, 26, 27, 28, 29, };
  672. +static int mt7981_wo0_jtag_1_funcs[] = { 5, 5, 5, 5, 5, };
  673. +
  674. +/* UART2 */
  675. +static int mt7981_uart2_0_pins[] = { 4, 5, 6, 7, };
  676. +static int mt7981_uart2_0_funcs[] = { 3, 3, 3, 3, };
  677. +
  678. +/* GBE_LED0 */
  679. +static int mt7981_gbe_led0_pins[] = { 8, };
  680. +static int mt7981_gbe_led0_funcs[] = { 3, };
  681. +
  682. +/* PTA_EXT */
  683. +static int mt7981_pta_ext_0_pins[] = { 4, 5, 6, };
  684. +static int mt7981_pta_ext_0_funcs[] = { 4, 4, 4, };
  685. +
  686. +static int mt7981_pta_ext_1_pins[] = { 22, 23, 24, };
  687. +static int mt7981_pta_ext_1_funcs[] = { 4, 4, 4, };
  688. +
  689. +/* PWM2 */
  690. +static int mt7981_pwm2_pins[] = { 7, };
  691. +static int mt7981_pwm2_funcs[] = { 4, };
  692. +
  693. +/* NET_WO0_UART_TXD */
  694. +static int mt7981_net_wo0_uart_txd_0_pins[] = { 8, };
  695. +static int mt7981_net_wo0_uart_txd_0_funcs[] = { 4, };
  696. +
  697. +static int mt7981_net_wo0_uart_txd_1_pins[] = { 14, };
  698. +static int mt7981_net_wo0_uart_txd_1_funcs[] = { 3, };
  699. +
  700. +static int mt7981_net_wo0_uart_txd_2_pins[] = { 15, };
  701. +static int mt7981_net_wo0_uart_txd_2_funcs[] = { 4, };
  702. +
  703. +/* SPI1 */
  704. +static int mt7981_spi1_0_pins[] = { 4, 5, 6, 7, };
  705. +static int mt7981_spi1_0_funcs[] = { 5, 5, 5, 5, };
  706. +
  707. +/* I2C */
  708. +static int mt7981_i2c0_0_pins[] = { 6, 7, };
  709. +static int mt7981_i2c0_0_funcs[] = { 6, 6, };
  710. +
  711. +static int mt7981_i2c0_1_pins[] = { 30, 31, };
  712. +static int mt7981_i2c0_1_funcs[] = { 4, 4, };
  713. +
  714. +static int mt7981_i2c0_2_pins[] = { 36, 37, };
  715. +static int mt7981_i2c0_2_funcs[] = { 2, 2, };
  716. +
  717. +static int mt7981_u2_phy_i2c_pins[] = { 30, 31, };
  718. +static int mt7981_u2_phy_i2c_funcs[] = { 6, 6, };
  719. +
  720. +static int mt7981_u3_phy_i2c_pins[] = { 32, 33, };
  721. +static int mt7981_u3_phy_i2c_funcs[] = { 3, 3, };
  722. +
  723. +static int mt7981_sgmii1_phy_i2c_pins[] = { 32, 33, };
  724. +static int mt7981_sgmii1_phy_i2c_funcs[] = { 2, 2, };
  725. +
  726. +static int mt7981_sgmii0_phy_i2c_pins[] = { 32, 33, };
  727. +static int mt7981_sgmii0_phy_i2c_funcs[] = { 5, 5, };
  728. +
  729. +/* DFD_NTRST */
  730. +static int mt7981_dfd_ntrst_pins[] = { 8, };
  731. +static int mt7981_dfd_ntrst_funcs[] = { 6, };
  732. +
  733. +/* PWM0 */
  734. +static int mt7981_pwm0_0_pins[] = { 13, };
  735. +static int mt7981_pwm0_0_funcs[] = { 2, };
  736. +
  737. +static int mt7981_pwm0_1_pins[] = { 15, };
  738. +static int mt7981_pwm0_1_funcs[] = { 1, };
  739. +
  740. +/* PWM1 */
  741. +static int mt7981_pwm1_0_pins[] = { 14, };
  742. +static int mt7981_pwm1_0_funcs[] = { 2, };
  743. +
  744. +static int mt7981_pwm1_1_pins[] = { 15, };
  745. +static int mt7981_pwm1_1_funcs[] = { 3, };
  746. +
  747. +/* GBE_LED1 */
  748. +static int mt7981_gbe_led1_pins[] = { 13, };
  749. +static int mt7981_gbe_led1_funcs[] = { 3, };
  750. +
  751. +/* PCM */
  752. +static int mt7981_pcm_pins[] = { 9, 10, 11, 12, 13, 25 };
  753. +static int mt7981_pcm_funcs[] = { 4, 4, 4, 4, 4, 4, };
  754. +
  755. +/* UDI */
  756. +static int mt7981_udi_pins[] = { 9, 10, 11, 12, 13, };
  757. +static int mt7981_udi_funcs[] = { 6, 6, 6, 6, 6, };
  758. +
  759. +/* DRV_VBUS */
  760. +static int mt7981_drv_vbus_pins[] = { 14, };
  761. +static int mt7981_drv_vbus_funcs[] = { 1, };
  762. +
  763. +/* EMMC */
  764. +static int mt7981_emmc_45_pins[] = { 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, };
  765. +static int mt7981_emmc_45_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
  766. +
  767. +/* SNFI */
  768. +static int mt7981_snfi_pins[] = { 16, 17, 18, 19, 20, 21, };
  769. +static int mt7981_snfi_funcs[] = { 3, 3, 3, 3, 3, 3, };
  770. +
  771. +/* SPI0 */
  772. +static int mt7981_spi0_pins[] = { 16, 17, 18, 19, };
  773. +static int mt7981_spi0_funcs[] = { 1, 1, 1, 1, };
  774. +
  775. +/* SPI0 */
  776. +static int mt7981_spi0_wp_hold_pins[] = { 20, 21, };
  777. +static int mt7981_spi0_wp_hold_funcs[] = { 1, 1, };
  778. +
  779. +/* SPI1 */
  780. +static int mt7981_spi1_1_pins[] = { 22, 23, 24, 25, };
  781. +static int mt7981_spi1_1_funcs[] = { 1, 1, 1, 1, };
  782. +
  783. +/* SPI2 */
  784. +static int mt7981_spi2_pins[] = { 26, 27, 28, 29, };
  785. +static int mt7981_spi2_funcs[] = { 1, 1, 1, 1, };
  786. +
  787. +/* SPI2 */
  788. +static int mt7981_spi2_wp_hold_pins[] = { 30, 31, };
  789. +static int mt7981_spi2_wp_hold_funcs[] = { 1, 1, };
  790. +
  791. +/* UART1 */
  792. +static int mt7981_uart1_0_pins[] = { 16, 17, 18, 19, };
  793. +static int mt7981_uart1_0_funcs[] = { 4, 4, 4, 4, };
  794. +
  795. +static int mt7981_uart1_1_pins[] = { 26, 27, 28, 29, };
  796. +static int mt7981_uart1_1_funcs[] = { 2, 2, 2, 2, };
  797. +
  798. +/* UART2 */
  799. +static int mt7981_uart2_1_pins[] = { 22, 23, 24, 25, };
  800. +static int mt7981_uart2_1_funcs[] = { 3, 3, 3, 3, };
  801. +
  802. +/* UART0 */
  803. +static int mt7981_uart0_pins[] = { 32, 33, };
  804. +static int mt7981_uart0_funcs[] = { 1, 1, };
  805. +
  806. +/* PCIE_CLK_REQ */
  807. +static int mt7981_pcie_clk_pins[] = { 34, };
  808. +static int mt7981_pcie_clk_funcs[] = { 2, };
  809. +
  810. +/* PCIE_WAKE_N */
  811. +static int mt7981_pcie_wake_pins[] = { 35, };
  812. +static int mt7981_pcie_wake_funcs[] = { 2, };
  813. +
  814. +/* MDC_MDIO */
  815. +static int mt7981_smi_mdc_mdio_pins[] = { 36, 37, };
  816. +static int mt7981_smi_mdc_mdio_funcs[] = { 1, 1, };
  817. +
  818. +static int mt7981_gbe_ext_mdc_mdio_pins[] = { 36, 37, };
  819. +static int mt7981_gbe_ext_mdc_mdio_funcs[] = { 3, 3, };
  820. +
  821. +/* WF0_MODE1 */
  822. +static int mt7981_wf0_mode1_pins[] = { 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56 };
  823. +static int mt7981_wf0_mode1_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  824. +
  825. +/* WF0_MODE3 */
  826. +static int mt7981_wf0_mode3_pins[] = { 45, 46, 47, 48, 49, 51 };
  827. +static int mt7981_wf0_mode3_funcs[] = { 2, 2, 2, 2, 2, 2 };
  828. +
  829. +/* WF2G_LED */
  830. +static int mt7981_wf2g_led0_pins[] = { 30, };
  831. +static int mt7981_wf2g_led0_funcs[] = { 2, };
  832. +
  833. +static int mt7981_wf2g_led1_pins[] = { 34, };
  834. +static int mt7981_wf2g_led1_funcs[] = { 1, };
  835. +
  836. +/* WF5G_LED */
  837. +static int mt7981_wf5g_led0_pins[] = { 31, };
  838. +static int mt7981_wf5g_led0_funcs[] = { 2, };
  839. +
  840. +static int mt7981_wf5g_led1_pins[] = { 35, };
  841. +static int mt7981_wf5g_led1_funcs[] = { 1, };
  842. +
  843. +/* MT7531_INT */
  844. +static int mt7981_mt7531_int_pins[] = { 38, };
  845. +static int mt7981_mt7531_int_funcs[] = { 1, };
  846. +
  847. +/* ANT_SEL */
  848. +static int mt7981_ant_sel_pins[] = { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 34, 35 };
  849. +static int mt7981_ant_sel_funcs[] = { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 };
  850. +
  851. +static const struct group_desc mt7981_groups[] = {
  852. + /* @GPIO(0,1): WA_AICE(2) */
  853. + PINCTRL_PIN_GROUP("wa_aice1", mt7981_wa_aice1),
  854. + /* @GPIO(0,1): WA_AICE(3) */
  855. + PINCTRL_PIN_GROUP("wa_aice2", mt7981_wa_aice2),
  856. + /* @GPIO(0,1): WM_UART(5) */
  857. + PINCTRL_PIN_GROUP("wm_uart_0", mt7981_wm_uart_0),
  858. + /* @GPIO(0,1,4,5): DFD(6) */
  859. + PINCTRL_PIN_GROUP("dfd", mt7981_dfd),
  860. + /* @GPIO(2): SYS_WATCHDOG(1) */
  861. + PINCTRL_PIN_GROUP("watchdog", mt7981_watchdog),
  862. + /* @GPIO(3): PCIE_PERESET_N(1) */
  863. + PINCTRL_PIN_GROUP("pcie_pereset", mt7981_pcie_pereset),
  864. + /* @GPIO(4,8) JTAG(1) */
  865. + PINCTRL_PIN_GROUP("jtag", mt7981_jtag),
  866. + /* @GPIO(4,8) WM_JTAG(2) */
  867. + PINCTRL_PIN_GROUP("wm_jtag_0", mt7981_wm_jtag_0),
  868. + /* @GPIO(9,13) WO0_JTAG(1) */
  869. + PINCTRL_PIN_GROUP("wo0_jtag_0", mt7981_wo0_jtag_0),
  870. + /* @GPIO(4,7) WM_JTAG(3) */
  871. + PINCTRL_PIN_GROUP("uart2_0", mt7981_uart2_0),
  872. + /* @GPIO(8) GBE_LED0(3) */
  873. + PINCTRL_PIN_GROUP("gbe_led0", mt7981_gbe_led0),
  874. + /* @GPIO(4,6) PTA_EXT(4) */
  875. + PINCTRL_PIN_GROUP("pta_ext_0", mt7981_pta_ext_0),
  876. + /* @GPIO(7) PWM2(4) */
  877. + PINCTRL_PIN_GROUP("pwm2", mt7981_pwm2),
  878. + /* @GPIO(8) NET_WO0_UART_TXD(4) */
  879. + PINCTRL_PIN_GROUP("net_wo0_uart_txd_0", mt7981_net_wo0_uart_txd_0),
  880. + /* @GPIO(4,7) SPI1(5) */
  881. + PINCTRL_PIN_GROUP("spi1_0", mt7981_spi1_0),
  882. + /* @GPIO(6,7) I2C(5) */
  883. + PINCTRL_PIN_GROUP("i2c0_0", mt7981_i2c0_0),
  884. + /* @GPIO(0,1,4,5): DFD_NTRST(6) */
  885. + PINCTRL_PIN_GROUP("dfd_ntrst", mt7981_dfd_ntrst),
  886. + /* @GPIO(9,10): WM_AICE(2) */
  887. + PINCTRL_PIN_GROUP("wm_aice1", mt7981_wm_aice1),
  888. + /* @GPIO(13): PWM0(2) */
  889. + PINCTRL_PIN_GROUP("pwm0_0", mt7981_pwm0_0),
  890. + /* @GPIO(15): PWM0(1) */
  891. + PINCTRL_PIN_GROUP("pwm0_1", mt7981_pwm0_1),
  892. + /* @GPIO(14): PWM1(2) */
  893. + PINCTRL_PIN_GROUP("pwm1_0", mt7981_pwm1_0),
  894. + /* @GPIO(15): PWM1(3) */
  895. + PINCTRL_PIN_GROUP("pwm1_1", mt7981_pwm1_1),
  896. + /* @GPIO(14) NET_WO0_UART_TXD(3) */
  897. + PINCTRL_PIN_GROUP("net_wo0_uart_txd_1", mt7981_net_wo0_uart_txd_1),
  898. + /* @GPIO(15) NET_WO0_UART_TXD(4) */
  899. + PINCTRL_PIN_GROUP("net_wo0_uart_txd_2", mt7981_net_wo0_uart_txd_2),
  900. + /* @GPIO(13) GBE_LED0(3) */
  901. + PINCTRL_PIN_GROUP("gbe_led1", mt7981_gbe_led1),
  902. + /* @GPIO(9,13) PCM(4) */
  903. + PINCTRL_PIN_GROUP("pcm", mt7981_pcm),
  904. + /* @GPIO(13): SYS_WATCHDOG1(5) */
  905. + PINCTRL_PIN_GROUP("watchdog1", mt7981_watchdog1),
  906. + /* @GPIO(9,13) UDI(4) */
  907. + PINCTRL_PIN_GROUP("udi", mt7981_udi),
  908. + /* @GPIO(14) DRV_VBUS(1) */
  909. + PINCTRL_PIN_GROUP("drv_vbus", mt7981_drv_vbus),
  910. + /* @GPIO(15,25): EMMC(2) */
  911. + PINCTRL_PIN_GROUP("emmc_45", mt7981_emmc_45),
  912. + /* @GPIO(16,21): SNFI(3) */
  913. + PINCTRL_PIN_GROUP("snfi", mt7981_snfi),
  914. + /* @GPIO(16,19): SPI0(1) */
  915. + PINCTRL_PIN_GROUP("spi0", mt7981_spi0),
  916. + /* @GPIO(20,21): SPI0(1) */
  917. + PINCTRL_PIN_GROUP("spi0_wp_hold", mt7981_spi0_wp_hold),
  918. + /* @GPIO(22,25) SPI1(1) */
  919. + PINCTRL_PIN_GROUP("spi1_1", mt7981_spi1_1),
  920. + /* @GPIO(26,29): SPI2(1) */
  921. + PINCTRL_PIN_GROUP("spi2", mt7981_spi2),
  922. + /* @GPIO(30,31): SPI0(1) */
  923. + PINCTRL_PIN_GROUP("spi2_wp_hold", mt7981_spi2_wp_hold),
  924. + /* @GPIO(16,19): UART1(4) */
  925. + PINCTRL_PIN_GROUP("uart1_0", mt7981_uart1_0),
  926. + /* @GPIO(26,29): UART1(2) */
  927. + PINCTRL_PIN_GROUP("uart1_1", mt7981_uart1_1),
  928. + /* @GPIO(22,25): UART1(3) */
  929. + PINCTRL_PIN_GROUP("uart2_1", mt7981_uart2_1),
  930. + /* @GPIO(22,24) PTA_EXT(4) */
  931. + PINCTRL_PIN_GROUP("pta_ext_1", mt7981_pta_ext_1),
  932. + /* @GPIO(20,21): WM_UART(4) */
  933. + PINCTRL_PIN_GROUP("wm_aurt_1", mt7981_wm_uart_1),
  934. + /* @GPIO(30,31): WM_UART(3) */
  935. + PINCTRL_PIN_GROUP("wm_aurt_2", mt7981_wm_uart_2),
  936. + /* @GPIO(20,24) WM_JTAG(5) */
  937. + PINCTRL_PIN_GROUP("wm_jtag_1", mt7981_wm_jtag_1),
  938. + /* @GPIO(25,29) WO0_JTAG(5) */
  939. + PINCTRL_PIN_GROUP("wo0_jtag_1", mt7981_wo0_jtag_1),
  940. + /* @GPIO(28,29): WA_AICE(3) */
  941. + PINCTRL_PIN_GROUP("wa_aice3", mt7981_wa_aice3),
  942. + /* @GPIO(30,31): WM_AICE(5) */
  943. + PINCTRL_PIN_GROUP("wm_aice2", mt7981_wm_aice2),
  944. + /* @GPIO(30,31): I2C(4) */
  945. + PINCTRL_PIN_GROUP("i2c0_1", mt7981_i2c0_1),
  946. + /* @GPIO(30,31): I2C(6) */
  947. + PINCTRL_PIN_GROUP("u2_phy_i2c", mt7981_u2_phy_i2c),
  948. + /* @GPIO(32,33): I2C(1) */
  949. + PINCTRL_PIN_GROUP("uart0", mt7981_uart0),
  950. + /* @GPIO(32,33): I2C(2) */
  951. + PINCTRL_PIN_GROUP("sgmii1_phy_i2c", mt7981_sgmii1_phy_i2c),
  952. + /* @GPIO(32,33): I2C(3) */
  953. + PINCTRL_PIN_GROUP("u3_phy_i2c", mt7981_u3_phy_i2c),
  954. + /* @GPIO(32,33): I2C(5) */
  955. + PINCTRL_PIN_GROUP("sgmii0_phy_i2c", mt7981_sgmii0_phy_i2c),
  956. + /* @GPIO(34): PCIE_CLK_REQ(2) */
  957. + PINCTRL_PIN_GROUP("pcie_clk", mt7981_pcie_clk),
  958. + /* @GPIO(35): PCIE_WAKE_N(2) */
  959. + PINCTRL_PIN_GROUP("pcie_wake", mt7981_pcie_wake),
  960. + /* @GPIO(36,37): I2C(2) */
  961. + PINCTRL_PIN_GROUP("i2c0_2", mt7981_i2c0_2),
  962. + /* @GPIO(36,37): MDC_MDIO(1) */
  963. + PINCTRL_PIN_GROUP("smi_mdc_mdio", mt7981_smi_mdc_mdio),
  964. + /* @GPIO(36,37): MDC_MDIO(3) */
  965. + PINCTRL_PIN_GROUP("gbe_ext_mdc_mdio", mt7981_gbe_ext_mdc_mdio),
  966. + /* @GPIO(69,85): WF0_MODE1(1) */
  967. + PINCTRL_PIN_GROUP("wf0_mode1", mt7981_wf0_mode1),
  968. + /* @GPIO(74,80): WF0_MODE3(3) */
  969. + PINCTRL_PIN_GROUP("wf0_mode3", mt7981_wf0_mode3),
  970. + /* @GPIO(30): WF2G_LED(2) */
  971. + PINCTRL_PIN_GROUP("wf2g_led0", mt7981_wf2g_led0),
  972. + /* @GPIO(34): WF2G_LED(1) */
  973. + PINCTRL_PIN_GROUP("wf2g_led1", mt7981_wf2g_led1),
  974. + /* @GPIO(31): WF5G_LED(2) */
  975. + PINCTRL_PIN_GROUP("wf5g_led0", mt7981_wf5g_led0),
  976. + /* @GPIO(35): WF5G_LED(1) */
  977. + PINCTRL_PIN_GROUP("wf5g_led1", mt7981_wf5g_led1),
  978. + /* @GPIO(38): MT7531_INT(1) */
  979. + PINCTRL_PIN_GROUP("mt7531_int", mt7981_mt7531_int),
  980. + /* @GPIO(14,15,26,17,18,19,20,21,22,23,24,25,34,35): ANT_SEL(1) */
  981. + PINCTRL_PIN_GROUP("ant_sel", mt7981_ant_sel),
  982. +};
  983. +
  984. +/* Joint those groups owning the same capability in user point of view which
  985. + * allows that people tend to use through the device tree.
  986. + */
  987. +static const char *mt7981_wa_aice_groups[] = { "wa_aice1", "wa_aice2", "wm_aice1_1",
  988. + "wa_aice3", "wm_aice1_2", };
  989. +static const char *mt7981_uart_groups[] = { "wm_uart_0", "uart2_0",
  990. + "net_wo0_uart_txd_0", "net_wo0_uart_txd_1", "net_wo0_uart_txd_2",
  991. + "uart1_0", "uart1_1", "uart2_1", "wm_aurt_1", "wm_aurt_2", "uart0", };
  992. +static const char *mt7981_dfd_groups[] = { "dfd", "dfd_ntrst", };
  993. +static const char *mt7981_wdt_groups[] = { "watchdog", "watchdog1", };
  994. +static const char *mt7981_pcie_groups[] = { "pcie_pereset", "pcie_clk", "pcie_wake", };
  995. +static const char *mt7981_jtag_groups[] = { "jtag", "wm_jtag_0", "wo0_jtag_0",
  996. + "wo0_jtag_1", "wm_jtag_1", };
  997. +static const char *mt7981_led_groups[] = { "gbe_led0", "gbe_led1", "wf2g_led0",
  998. + "wf2g_led1", "wf5g_led0", "wf5g_led1", };
  999. +static const char *mt7981_pta_groups[] = { "pta_ext_0", "pta_ext_1", };
  1000. +static const char *mt7981_pwm_groups[] = { "pwm2", "pwm0_0", "pwm0_1",
  1001. + "pwm1_0", "pwm1_1", };
  1002. +static const char *mt7981_spi_groups[] = { "spi1_0", "spi0", "spi0_wp_hold", "spi1_1", "spi2",
  1003. + "spi2_wp_hold", };
  1004. +static const char *mt7981_i2c_groups[] = { "i2c0_0", "i2c0_1", "u2_phy_i2c",
  1005. + "sgmii1_phy_i2c", "u3_phy_i2c", "sgmii0_phy_i2c", "i2c0_2", };
  1006. +static const char *mt7981_pcm_groups[] = { "pcm", };
  1007. +static const char *mt7981_udi_groups[] = { "udi", };
  1008. +static const char *mt7981_usb_groups[] = { "drv_vbus", };
  1009. +static const char *mt7981_flash_groups[] = { "emmc_45", "snfi", };
  1010. +static const char *mt7981_ethernet_groups[] = { "smi_mdc_mdio", "gbe_ext_mdc_mdio",
  1011. + "wf0_mode1", "wf0_mode3", "mt7531_int", };
  1012. +static const char *mt7981_ant_groups[] = { "ant_sel", };
  1013. +
  1014. +static const struct function_desc mt7981_functions[] = {
  1015. + {"wa_aice", mt7981_wa_aice_groups, ARRAY_SIZE(mt7981_wa_aice_groups)},
  1016. + {"dfd", mt7981_dfd_groups, ARRAY_SIZE(mt7981_dfd_groups)},
  1017. + {"jtag", mt7981_jtag_groups, ARRAY_SIZE(mt7981_jtag_groups)},
  1018. + {"pta", mt7981_pta_groups, ARRAY_SIZE(mt7981_pta_groups)},
  1019. + {"pcm", mt7981_pcm_groups, ARRAY_SIZE(mt7981_pcm_groups)},
  1020. + {"udi", mt7981_udi_groups, ARRAY_SIZE(mt7981_udi_groups)},
  1021. + {"usb", mt7981_usb_groups, ARRAY_SIZE(mt7981_usb_groups)},
  1022. + {"ant", mt7981_ant_groups, ARRAY_SIZE(mt7981_ant_groups)},
  1023. + {"eth", mt7981_ethernet_groups, ARRAY_SIZE(mt7981_ethernet_groups)},
  1024. + {"i2c", mt7981_i2c_groups, ARRAY_SIZE(mt7981_i2c_groups)},
  1025. + {"led", mt7981_led_groups, ARRAY_SIZE(mt7981_led_groups)},
  1026. + {"pwm", mt7981_pwm_groups, ARRAY_SIZE(mt7981_pwm_groups)},
  1027. + {"spi", mt7981_spi_groups, ARRAY_SIZE(mt7981_spi_groups)},
  1028. + {"uart", mt7981_uart_groups, ARRAY_SIZE(mt7981_uart_groups)},
  1029. + {"watchdog", mt7981_wdt_groups, ARRAY_SIZE(mt7981_wdt_groups)},
  1030. + {"flash", mt7981_flash_groups, ARRAY_SIZE(mt7981_flash_groups)},
  1031. + {"pcie", mt7981_pcie_groups, ARRAY_SIZE(mt7981_pcie_groups)},
  1032. +};
  1033. +
  1034. +static const struct mtk_eint_hw mt7981_eint_hw = {
  1035. + .port_mask = 7,
  1036. + .ports = 7,
  1037. + .ap_num = ARRAY_SIZE(mt7981_pins),
  1038. + .db_cnt = 16,
  1039. +};
  1040. +
  1041. +static const char * const mt7981_pinctrl_register_base_names[] = {
  1042. + "gpio", "iocfg_rt", "iocfg_rm", "iocfg_rb",
  1043. + "iocfg_lb", "iocfg_bl", "iocfg_tm", "iocfg_tl",
  1044. +};
  1045. +
  1046. +static struct mtk_pin_soc mt7981_data = {
  1047. + .reg_cal = mt7981_reg_cals,
  1048. + .pins = mt7981_pins,
  1049. + .npins = ARRAY_SIZE(mt7981_pins),
  1050. + .grps = mt7981_groups,
  1051. + .ngrps = ARRAY_SIZE(mt7981_groups),
  1052. + .funcs = mt7981_functions,
  1053. + .nfuncs = ARRAY_SIZE(mt7981_functions),
  1054. + .eint_hw = &mt7981_eint_hw,
  1055. + .gpio_m = 0,
  1056. + .ies_present = false,
  1057. + .base_names = mt7981_pinctrl_register_base_names,
  1058. + .nbase_names = ARRAY_SIZE(mt7981_pinctrl_register_base_names),
  1059. + .pull_type = mt7981_pull_type,
  1060. + .bias_set_combo = mtk_pinconf_bias_set_combo,
  1061. + .bias_get_combo = mtk_pinconf_bias_get_combo,
  1062. + .drive_set = mtk_pinconf_drive_set_rev1,
  1063. + .drive_get = mtk_pinconf_drive_get_rev1,
  1064. + .adv_pull_get = mtk_pinconf_adv_pull_get,
  1065. + .adv_pull_set = mtk_pinconf_adv_pull_set,
  1066. +};
  1067. +
  1068. +static const struct of_device_id mt7981_pinctrl_of_match[] = {
  1069. + { .compatible = "mediatek,mt7981-pinctrl", },
  1070. + {}
  1071. +};
  1072. +
  1073. +static int mt7981_pinctrl_probe(struct platform_device *pdev)
  1074. +{
  1075. + return mtk_moore_pinctrl_probe(pdev, &mt7981_data);
  1076. +}
  1077. +
  1078. +static struct platform_driver mt7981_pinctrl_driver = {
  1079. + .driver = {
  1080. + .name = "mt7981-pinctrl",
  1081. + .of_match_table = mt7981_pinctrl_of_match,
  1082. + },
  1083. + .probe = mt7981_pinctrl_probe,
  1084. +};
  1085. +
  1086. +static int __init mt7981_pinctrl_init(void)
  1087. +{
  1088. + return platform_driver_register(&mt7981_pinctrl_driver);
  1089. +}
  1090. +arch_initcall(mt7981_pinctrl_init);