002-0020-pinctrl-mediatek-add-pinctrl-driver-for-MT7981-SoC.patch 40 KB

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