pinctrl-bm1880.c 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Bitmain BM1880 SoC Pinctrl driver
  4. *
  5. * Copyright (c) 2019 Linaro Ltd.
  6. * Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
  7. */
  8. #include <linux/io.h>
  9. #include <linux/of.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/slab.h>
  12. #include <linux/pinctrl/pinconf-generic.h>
  13. #include <linux/pinctrl/pinconf.h>
  14. #include <linux/pinctrl/pinctrl.h>
  15. #include <linux/pinctrl/pinmux.h>
  16. #include "core.h"
  17. #include "pinctrl-utils.h"
  18. #define BM1880_REG_MUX 0x20
  19. /**
  20. * struct bm1880_pinctrl - driver data
  21. * @base: Pinctrl base address
  22. * @pctrldev: Pinctrl device
  23. * @groups: Pingroups
  24. * @ngroups: Number of @groups
  25. * @funcs: Pinmux functions
  26. * @nfuncs: Number of @funcs
  27. * @pinconf: Pinconf data
  28. */
  29. struct bm1880_pinctrl {
  30. void __iomem *base;
  31. struct pinctrl_dev *pctrldev;
  32. const struct bm1880_pctrl_group *groups;
  33. unsigned int ngroups;
  34. const struct bm1880_pinmux_function *funcs;
  35. unsigned int nfuncs;
  36. const struct bm1880_pinconf_data *pinconf;
  37. };
  38. /**
  39. * struct bm1880_pctrl_group - pinctrl group
  40. * @name: Name of the group
  41. * @pins: Array of pins belonging to this group
  42. * @npins: Number of @pins
  43. */
  44. struct bm1880_pctrl_group {
  45. const char *name;
  46. const unsigned int *pins;
  47. const unsigned int npins;
  48. };
  49. /**
  50. * struct bm1880_pinmux_function - a pinmux function
  51. * @name: Name of the pinmux function.
  52. * @groups: List of pingroups for this function.
  53. * @ngroups: Number of entries in @groups.
  54. * @mux_val: Selector for this function
  55. * @mux: Offset of function specific mux
  56. * @mux_shift: Shift for function specific selector
  57. */
  58. struct bm1880_pinmux_function {
  59. const char *name;
  60. const char * const *groups;
  61. unsigned int ngroups;
  62. u32 mux_val;
  63. u32 mux;
  64. u8 mux_shift;
  65. };
  66. /**
  67. * struct bm1880_pinconf_data - pinconf data
  68. * @drv_bits: Drive strength bit width
  69. */
  70. struct bm1880_pinconf_data {
  71. u32 drv_bits;
  72. };
  73. static const struct pinctrl_pin_desc bm1880_pins[] = {
  74. PINCTRL_PIN(0, "MIO0"),
  75. PINCTRL_PIN(1, "MIO1"),
  76. PINCTRL_PIN(2, "MIO2"),
  77. PINCTRL_PIN(3, "MIO3"),
  78. PINCTRL_PIN(4, "MIO4"),
  79. PINCTRL_PIN(5, "MIO5"),
  80. PINCTRL_PIN(6, "MIO6"),
  81. PINCTRL_PIN(7, "MIO7"),
  82. PINCTRL_PIN(8, "MIO8"),
  83. PINCTRL_PIN(9, "MIO9"),
  84. PINCTRL_PIN(10, "MIO10"),
  85. PINCTRL_PIN(11, "MIO11"),
  86. PINCTRL_PIN(12, "MIO12"),
  87. PINCTRL_PIN(13, "MIO13"),
  88. PINCTRL_PIN(14, "MIO14"),
  89. PINCTRL_PIN(15, "MIO15"),
  90. PINCTRL_PIN(16, "MIO16"),
  91. PINCTRL_PIN(17, "MIO17"),
  92. PINCTRL_PIN(18, "MIO18"),
  93. PINCTRL_PIN(19, "MIO19"),
  94. PINCTRL_PIN(20, "MIO20"),
  95. PINCTRL_PIN(21, "MIO21"),
  96. PINCTRL_PIN(22, "MIO22"),
  97. PINCTRL_PIN(23, "MIO23"),
  98. PINCTRL_PIN(24, "MIO24"),
  99. PINCTRL_PIN(25, "MIO25"),
  100. PINCTRL_PIN(26, "MIO26"),
  101. PINCTRL_PIN(27, "MIO27"),
  102. PINCTRL_PIN(28, "MIO28"),
  103. PINCTRL_PIN(29, "MIO29"),
  104. PINCTRL_PIN(30, "MIO30"),
  105. PINCTRL_PIN(31, "MIO31"),
  106. PINCTRL_PIN(32, "MIO32"),
  107. PINCTRL_PIN(33, "MIO33"),
  108. PINCTRL_PIN(34, "MIO34"),
  109. PINCTRL_PIN(35, "MIO35"),
  110. PINCTRL_PIN(36, "MIO36"),
  111. PINCTRL_PIN(37, "MIO37"),
  112. PINCTRL_PIN(38, "MIO38"),
  113. PINCTRL_PIN(39, "MIO39"),
  114. PINCTRL_PIN(40, "MIO40"),
  115. PINCTRL_PIN(41, "MIO41"),
  116. PINCTRL_PIN(42, "MIO42"),
  117. PINCTRL_PIN(43, "MIO43"),
  118. PINCTRL_PIN(44, "MIO44"),
  119. PINCTRL_PIN(45, "MIO45"),
  120. PINCTRL_PIN(46, "MIO46"),
  121. PINCTRL_PIN(47, "MIO47"),
  122. PINCTRL_PIN(48, "MIO48"),
  123. PINCTRL_PIN(49, "MIO49"),
  124. PINCTRL_PIN(50, "MIO50"),
  125. PINCTRL_PIN(51, "MIO51"),
  126. PINCTRL_PIN(52, "MIO52"),
  127. PINCTRL_PIN(53, "MIO53"),
  128. PINCTRL_PIN(54, "MIO54"),
  129. PINCTRL_PIN(55, "MIO55"),
  130. PINCTRL_PIN(56, "MIO56"),
  131. PINCTRL_PIN(57, "MIO57"),
  132. PINCTRL_PIN(58, "MIO58"),
  133. PINCTRL_PIN(59, "MIO59"),
  134. PINCTRL_PIN(60, "MIO60"),
  135. PINCTRL_PIN(61, "MIO61"),
  136. PINCTRL_PIN(62, "MIO62"),
  137. PINCTRL_PIN(63, "MIO63"),
  138. PINCTRL_PIN(64, "MIO64"),
  139. PINCTRL_PIN(65, "MIO65"),
  140. PINCTRL_PIN(66, "MIO66"),
  141. PINCTRL_PIN(67, "MIO67"),
  142. PINCTRL_PIN(68, "MIO68"),
  143. PINCTRL_PIN(69, "MIO69"),
  144. PINCTRL_PIN(70, "MIO70"),
  145. PINCTRL_PIN(71, "MIO71"),
  146. PINCTRL_PIN(72, "MIO72"),
  147. PINCTRL_PIN(73, "MIO73"),
  148. PINCTRL_PIN(74, "MIO74"),
  149. PINCTRL_PIN(75, "MIO75"),
  150. PINCTRL_PIN(76, "MIO76"),
  151. PINCTRL_PIN(77, "MIO77"),
  152. PINCTRL_PIN(78, "MIO78"),
  153. PINCTRL_PIN(79, "MIO79"),
  154. PINCTRL_PIN(80, "MIO80"),
  155. PINCTRL_PIN(81, "MIO81"),
  156. PINCTRL_PIN(82, "MIO82"),
  157. PINCTRL_PIN(83, "MIO83"),
  158. PINCTRL_PIN(84, "MIO84"),
  159. PINCTRL_PIN(85, "MIO85"),
  160. PINCTRL_PIN(86, "MIO86"),
  161. PINCTRL_PIN(87, "MIO87"),
  162. PINCTRL_PIN(88, "MIO88"),
  163. PINCTRL_PIN(89, "MIO89"),
  164. PINCTRL_PIN(90, "MIO90"),
  165. PINCTRL_PIN(91, "MIO91"),
  166. PINCTRL_PIN(92, "MIO92"),
  167. PINCTRL_PIN(93, "MIO93"),
  168. PINCTRL_PIN(94, "MIO94"),
  169. PINCTRL_PIN(95, "MIO95"),
  170. PINCTRL_PIN(96, "MIO96"),
  171. PINCTRL_PIN(97, "MIO97"),
  172. PINCTRL_PIN(98, "MIO98"),
  173. PINCTRL_PIN(99, "MIO99"),
  174. PINCTRL_PIN(100, "MIO100"),
  175. PINCTRL_PIN(101, "MIO101"),
  176. PINCTRL_PIN(102, "MIO102"),
  177. PINCTRL_PIN(103, "MIO103"),
  178. PINCTRL_PIN(104, "MIO104"),
  179. PINCTRL_PIN(105, "MIO105"),
  180. PINCTRL_PIN(106, "MIO106"),
  181. PINCTRL_PIN(107, "MIO107"),
  182. PINCTRL_PIN(108, "MIO108"),
  183. PINCTRL_PIN(109, "MIO109"),
  184. PINCTRL_PIN(110, "MIO110"),
  185. PINCTRL_PIN(111, "MIO111"),
  186. };
  187. enum bm1880_pinmux_functions {
  188. F_nand, F_spi, F_emmc, F_sdio, F_eth0, F_pwm0, F_pwm1, F_pwm2,
  189. F_pwm3, F_pwm4, F_pwm5, F_pwm6, F_pwm7, F_pwm8, F_pwm9, F_pwm10,
  190. F_pwm11, F_pwm12, F_pwm13, F_pwm14, F_pwm15, F_pwm16, F_pwm17,
  191. F_pwm18, F_pwm19, F_pwm20, F_pwm21, F_pwm22, F_pwm23, F_pwm24,
  192. F_pwm25, F_pwm26, F_pwm27, F_pwm28, F_pwm29, F_pwm30, F_pwm31,
  193. F_pwm32, F_pwm33, F_pwm34, F_pwm35, F_pwm36, F_pwm37, F_i2c0, F_i2c1,
  194. F_i2c2, F_i2c3, F_i2c4, F_uart0, F_uart1, F_uart2, F_uart3, F_uart4,
  195. F_uart5, F_uart6, F_uart7, F_uart8, F_uart9, F_uart10, F_uart11,
  196. F_uart12, F_uart13, F_uart14, F_uart15, F_gpio0, F_gpio1, F_gpio2,
  197. F_gpio3, F_gpio4, F_gpio5, F_gpio6, F_gpio7, F_gpio8, F_gpio9, F_gpio10,
  198. F_gpio11, F_gpio12, F_gpio13, F_gpio14, F_gpio15, F_gpio16, F_gpio17,
  199. F_gpio18, F_gpio19, F_gpio20, F_gpio21, F_gpio22, F_gpio23, F_gpio24,
  200. F_gpio25, F_gpio26, F_gpio27, F_gpio28, F_gpio29, F_gpio30, F_gpio31,
  201. F_gpio32, F_gpio33, F_gpio34, F_gpio35, F_gpio36, F_gpio37, F_gpio38,
  202. F_gpio39, F_gpio40, F_gpio41, F_gpio42, F_gpio43, F_gpio44, F_gpio45,
  203. F_gpio46, F_gpio47, F_gpio48, F_gpio49, F_gpio50, F_gpio51, F_gpio52,
  204. F_gpio53, F_gpio54, F_gpio55, F_gpio56, F_gpio57, F_gpio58, F_gpio59,
  205. F_gpio60, F_gpio61, F_gpio62, F_gpio63, F_gpio64, F_gpio65, F_gpio66,
  206. F_gpio67, F_eth1, F_i2s0, F_i2s0_mclkin, F_i2s1, F_i2s1_mclkin, F_spi0,
  207. F_max
  208. };
  209. static const unsigned int nand_pins[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
  210. 10, 11, 12, 13, 14, 15, 16 };
  211. static const unsigned int spi_pins[] = { 0, 1, 8, 10, 11, 12, 13 };
  212. static const unsigned int emmc_pins[] = { 2, 3, 4, 5, 6, 7, 9, 14, 15, 16 };
  213. static const unsigned int sdio_pins[] = { 17, 18, 19, 20, 21, 22, 23, 24,
  214. 25, 26 };
  215. static const unsigned int eth0_pins[] = { 27, 28, 29, 30, 31, 32, 33, 34, 35,
  216. 36, 37, 38, 39, 40, 41, 42 };
  217. static const unsigned int pwm0_pins[] = { 29 };
  218. static const unsigned int pwm1_pins[] = { 30 };
  219. static const unsigned int pwm2_pins[] = { 34 };
  220. static const unsigned int pwm3_pins[] = { 35 };
  221. static const unsigned int pwm4_pins[] = { 43 };
  222. static const unsigned int pwm5_pins[] = { 44 };
  223. static const unsigned int pwm6_pins[] = { 45 };
  224. static const unsigned int pwm7_pins[] = { 46 };
  225. static const unsigned int pwm8_pins[] = { 47 };
  226. static const unsigned int pwm9_pins[] = { 48 };
  227. static const unsigned int pwm10_pins[] = { 49 };
  228. static const unsigned int pwm11_pins[] = { 50 };
  229. static const unsigned int pwm12_pins[] = { 51 };
  230. static const unsigned int pwm13_pins[] = { 52 };
  231. static const unsigned int pwm14_pins[] = { 53 };
  232. static const unsigned int pwm15_pins[] = { 54 };
  233. static const unsigned int pwm16_pins[] = { 55 };
  234. static const unsigned int pwm17_pins[] = { 56 };
  235. static const unsigned int pwm18_pins[] = { 57 };
  236. static const unsigned int pwm19_pins[] = { 58 };
  237. static const unsigned int pwm20_pins[] = { 59 };
  238. static const unsigned int pwm21_pins[] = { 60 };
  239. static const unsigned int pwm22_pins[] = { 61 };
  240. static const unsigned int pwm23_pins[] = { 62 };
  241. static const unsigned int pwm24_pins[] = { 97 };
  242. static const unsigned int pwm25_pins[] = { 98 };
  243. static const unsigned int pwm26_pins[] = { 99 };
  244. static const unsigned int pwm27_pins[] = { 100 };
  245. static const unsigned int pwm28_pins[] = { 101 };
  246. static const unsigned int pwm29_pins[] = { 102 };
  247. static const unsigned int pwm30_pins[] = { 103 };
  248. static const unsigned int pwm31_pins[] = { 104 };
  249. static const unsigned int pwm32_pins[] = { 105 };
  250. static const unsigned int pwm33_pins[] = { 106 };
  251. static const unsigned int pwm34_pins[] = { 107 };
  252. static const unsigned int pwm35_pins[] = { 108 };
  253. static const unsigned int pwm36_pins[] = { 109 };
  254. static const unsigned int pwm37_pins[] = { 110 };
  255. static const unsigned int i2c0_pins[] = { 63, 64 };
  256. static const unsigned int i2c1_pins[] = { 65, 66 };
  257. static const unsigned int i2c2_pins[] = { 67, 68 };
  258. static const unsigned int i2c3_pins[] = { 69, 70 };
  259. static const unsigned int i2c4_pins[] = { 71, 72 };
  260. static const unsigned int uart0_pins[] = { 73, 74 };
  261. static const unsigned int uart1_pins[] = { 75, 76 };
  262. static const unsigned int uart2_pins[] = { 77, 78 };
  263. static const unsigned int uart3_pins[] = { 79, 80 };
  264. static const unsigned int uart4_pins[] = { 81, 82 };
  265. static const unsigned int uart5_pins[] = { 83, 84 };
  266. static const unsigned int uart6_pins[] = { 85, 86 };
  267. static const unsigned int uart7_pins[] = { 87, 88 };
  268. static const unsigned int uart8_pins[] = { 89, 90 };
  269. static const unsigned int uart9_pins[] = { 91, 92 };
  270. static const unsigned int uart10_pins[] = { 93, 94 };
  271. static const unsigned int uart11_pins[] = { 95, 96 };
  272. static const unsigned int uart12_pins[] = { 73, 74, 75, 76 };
  273. static const unsigned int uart13_pins[] = { 77, 78, 83, 84 };
  274. static const unsigned int uart14_pins[] = { 79, 80, 85, 86 };
  275. static const unsigned int uart15_pins[] = { 81, 82, 87, 88 };
  276. static const unsigned int gpio0_pins[] = { 97 };
  277. static const unsigned int gpio1_pins[] = { 98 };
  278. static const unsigned int gpio2_pins[] = { 99 };
  279. static const unsigned int gpio3_pins[] = { 100 };
  280. static const unsigned int gpio4_pins[] = { 101 };
  281. static const unsigned int gpio5_pins[] = { 102 };
  282. static const unsigned int gpio6_pins[] = { 103 };
  283. static const unsigned int gpio7_pins[] = { 104 };
  284. static const unsigned int gpio8_pins[] = { 105 };
  285. static const unsigned int gpio9_pins[] = { 106 };
  286. static const unsigned int gpio10_pins[] = { 107 };
  287. static const unsigned int gpio11_pins[] = { 108 };
  288. static const unsigned int gpio12_pins[] = { 109 };
  289. static const unsigned int gpio13_pins[] = { 110 };
  290. static const unsigned int gpio14_pins[] = { 43 };
  291. static const unsigned int gpio15_pins[] = { 44 };
  292. static const unsigned int gpio16_pins[] = { 45 };
  293. static const unsigned int gpio17_pins[] = { 46 };
  294. static const unsigned int gpio18_pins[] = { 47 };
  295. static const unsigned int gpio19_pins[] = { 48 };
  296. static const unsigned int gpio20_pins[] = { 49 };
  297. static const unsigned int gpio21_pins[] = { 50 };
  298. static const unsigned int gpio22_pins[] = { 51 };
  299. static const unsigned int gpio23_pins[] = { 52 };
  300. static const unsigned int gpio24_pins[] = { 53 };
  301. static const unsigned int gpio25_pins[] = { 54 };
  302. static const unsigned int gpio26_pins[] = { 55 };
  303. static const unsigned int gpio27_pins[] = { 56 };
  304. static const unsigned int gpio28_pins[] = { 57 };
  305. static const unsigned int gpio29_pins[] = { 58 };
  306. static const unsigned int gpio30_pins[] = { 59 };
  307. static const unsigned int gpio31_pins[] = { 60 };
  308. static const unsigned int gpio32_pins[] = { 61 };
  309. static const unsigned int gpio33_pins[] = { 62 };
  310. static const unsigned int gpio34_pins[] = { 63 };
  311. static const unsigned int gpio35_pins[] = { 64 };
  312. static const unsigned int gpio36_pins[] = { 65 };
  313. static const unsigned int gpio37_pins[] = { 66 };
  314. static const unsigned int gpio38_pins[] = { 67 };
  315. static const unsigned int gpio39_pins[] = { 68 };
  316. static const unsigned int gpio40_pins[] = { 69 };
  317. static const unsigned int gpio41_pins[] = { 70 };
  318. static const unsigned int gpio42_pins[] = { 71 };
  319. static const unsigned int gpio43_pins[] = { 72 };
  320. static const unsigned int gpio44_pins[] = { 73 };
  321. static const unsigned int gpio45_pins[] = { 74 };
  322. static const unsigned int gpio46_pins[] = { 75 };
  323. static const unsigned int gpio47_pins[] = { 76 };
  324. static const unsigned int gpio48_pins[] = { 77 };
  325. static const unsigned int gpio49_pins[] = { 78 };
  326. static const unsigned int gpio50_pins[] = { 79 };
  327. static const unsigned int gpio51_pins[] = { 80 };
  328. static const unsigned int gpio52_pins[] = { 81 };
  329. static const unsigned int gpio53_pins[] = { 82 };
  330. static const unsigned int gpio54_pins[] = { 83 };
  331. static const unsigned int gpio55_pins[] = { 84 };
  332. static const unsigned int gpio56_pins[] = { 85 };
  333. static const unsigned int gpio57_pins[] = { 86 };
  334. static const unsigned int gpio58_pins[] = { 87 };
  335. static const unsigned int gpio59_pins[] = { 88 };
  336. static const unsigned int gpio60_pins[] = { 89 };
  337. static const unsigned int gpio61_pins[] = { 90 };
  338. static const unsigned int gpio62_pins[] = { 91 };
  339. static const unsigned int gpio63_pins[] = { 92 };
  340. static const unsigned int gpio64_pins[] = { 93 };
  341. static const unsigned int gpio65_pins[] = { 94 };
  342. static const unsigned int gpio66_pins[] = { 95 };
  343. static const unsigned int gpio67_pins[] = { 96 };
  344. static const unsigned int eth1_pins[] = { 43, 44, 45, 46, 47, 48, 49, 50, 51,
  345. 52, 53, 54, 55, 56, 57, 58 };
  346. static const unsigned int i2s0_pins[] = { 87, 88, 89, 90, 91 };
  347. static const unsigned int i2s0_mclkin_pins[] = { 97 };
  348. static const unsigned int i2s1_pins[] = { 92, 93, 94, 95, 96 };
  349. static const unsigned int i2s1_mclkin_pins[] = { 98 };
  350. static const unsigned int spi0_pins[] = { 59, 60, 61, 62 };
  351. #define BM1880_PINCTRL_GRP(nm) \
  352. { \
  353. .name = #nm "_grp", \
  354. .pins = nm ## _pins, \
  355. .npins = ARRAY_SIZE(nm ## _pins), \
  356. }
  357. static const struct bm1880_pctrl_group bm1880_pctrl_groups[] = {
  358. BM1880_PINCTRL_GRP(nand),
  359. BM1880_PINCTRL_GRP(spi),
  360. BM1880_PINCTRL_GRP(emmc),
  361. BM1880_PINCTRL_GRP(sdio),
  362. BM1880_PINCTRL_GRP(eth0),
  363. BM1880_PINCTRL_GRP(pwm0),
  364. BM1880_PINCTRL_GRP(pwm1),
  365. BM1880_PINCTRL_GRP(pwm2),
  366. BM1880_PINCTRL_GRP(pwm3),
  367. BM1880_PINCTRL_GRP(pwm4),
  368. BM1880_PINCTRL_GRP(pwm5),
  369. BM1880_PINCTRL_GRP(pwm6),
  370. BM1880_PINCTRL_GRP(pwm7),
  371. BM1880_PINCTRL_GRP(pwm8),
  372. BM1880_PINCTRL_GRP(pwm9),
  373. BM1880_PINCTRL_GRP(pwm10),
  374. BM1880_PINCTRL_GRP(pwm11),
  375. BM1880_PINCTRL_GRP(pwm12),
  376. BM1880_PINCTRL_GRP(pwm13),
  377. BM1880_PINCTRL_GRP(pwm14),
  378. BM1880_PINCTRL_GRP(pwm15),
  379. BM1880_PINCTRL_GRP(pwm16),
  380. BM1880_PINCTRL_GRP(pwm17),
  381. BM1880_PINCTRL_GRP(pwm18),
  382. BM1880_PINCTRL_GRP(pwm19),
  383. BM1880_PINCTRL_GRP(pwm20),
  384. BM1880_PINCTRL_GRP(pwm21),
  385. BM1880_PINCTRL_GRP(pwm22),
  386. BM1880_PINCTRL_GRP(pwm23),
  387. BM1880_PINCTRL_GRP(pwm24),
  388. BM1880_PINCTRL_GRP(pwm25),
  389. BM1880_PINCTRL_GRP(pwm26),
  390. BM1880_PINCTRL_GRP(pwm27),
  391. BM1880_PINCTRL_GRP(pwm28),
  392. BM1880_PINCTRL_GRP(pwm29),
  393. BM1880_PINCTRL_GRP(pwm30),
  394. BM1880_PINCTRL_GRP(pwm31),
  395. BM1880_PINCTRL_GRP(pwm32),
  396. BM1880_PINCTRL_GRP(pwm33),
  397. BM1880_PINCTRL_GRP(pwm34),
  398. BM1880_PINCTRL_GRP(pwm35),
  399. BM1880_PINCTRL_GRP(pwm36),
  400. BM1880_PINCTRL_GRP(pwm37),
  401. BM1880_PINCTRL_GRP(i2c0),
  402. BM1880_PINCTRL_GRP(i2c1),
  403. BM1880_PINCTRL_GRP(i2c2),
  404. BM1880_PINCTRL_GRP(i2c3),
  405. BM1880_PINCTRL_GRP(i2c4),
  406. BM1880_PINCTRL_GRP(uart0),
  407. BM1880_PINCTRL_GRP(uart1),
  408. BM1880_PINCTRL_GRP(uart2),
  409. BM1880_PINCTRL_GRP(uart3),
  410. BM1880_PINCTRL_GRP(uart4),
  411. BM1880_PINCTRL_GRP(uart5),
  412. BM1880_PINCTRL_GRP(uart6),
  413. BM1880_PINCTRL_GRP(uart7),
  414. BM1880_PINCTRL_GRP(uart8),
  415. BM1880_PINCTRL_GRP(uart9),
  416. BM1880_PINCTRL_GRP(uart10),
  417. BM1880_PINCTRL_GRP(uart11),
  418. BM1880_PINCTRL_GRP(uart12),
  419. BM1880_PINCTRL_GRP(uart13),
  420. BM1880_PINCTRL_GRP(uart14),
  421. BM1880_PINCTRL_GRP(uart15),
  422. BM1880_PINCTRL_GRP(gpio0),
  423. BM1880_PINCTRL_GRP(gpio1),
  424. BM1880_PINCTRL_GRP(gpio2),
  425. BM1880_PINCTRL_GRP(gpio3),
  426. BM1880_PINCTRL_GRP(gpio4),
  427. BM1880_PINCTRL_GRP(gpio5),
  428. BM1880_PINCTRL_GRP(gpio6),
  429. BM1880_PINCTRL_GRP(gpio7),
  430. BM1880_PINCTRL_GRP(gpio8),
  431. BM1880_PINCTRL_GRP(gpio9),
  432. BM1880_PINCTRL_GRP(gpio10),
  433. BM1880_PINCTRL_GRP(gpio11),
  434. BM1880_PINCTRL_GRP(gpio12),
  435. BM1880_PINCTRL_GRP(gpio13),
  436. BM1880_PINCTRL_GRP(gpio14),
  437. BM1880_PINCTRL_GRP(gpio15),
  438. BM1880_PINCTRL_GRP(gpio16),
  439. BM1880_PINCTRL_GRP(gpio17),
  440. BM1880_PINCTRL_GRP(gpio18),
  441. BM1880_PINCTRL_GRP(gpio19),
  442. BM1880_PINCTRL_GRP(gpio20),
  443. BM1880_PINCTRL_GRP(gpio21),
  444. BM1880_PINCTRL_GRP(gpio22),
  445. BM1880_PINCTRL_GRP(gpio23),
  446. BM1880_PINCTRL_GRP(gpio24),
  447. BM1880_PINCTRL_GRP(gpio25),
  448. BM1880_PINCTRL_GRP(gpio26),
  449. BM1880_PINCTRL_GRP(gpio27),
  450. BM1880_PINCTRL_GRP(gpio28),
  451. BM1880_PINCTRL_GRP(gpio29),
  452. BM1880_PINCTRL_GRP(gpio30),
  453. BM1880_PINCTRL_GRP(gpio31),
  454. BM1880_PINCTRL_GRP(gpio32),
  455. BM1880_PINCTRL_GRP(gpio33),
  456. BM1880_PINCTRL_GRP(gpio34),
  457. BM1880_PINCTRL_GRP(gpio35),
  458. BM1880_PINCTRL_GRP(gpio36),
  459. BM1880_PINCTRL_GRP(gpio37),
  460. BM1880_PINCTRL_GRP(gpio38),
  461. BM1880_PINCTRL_GRP(gpio39),
  462. BM1880_PINCTRL_GRP(gpio40),
  463. BM1880_PINCTRL_GRP(gpio41),
  464. BM1880_PINCTRL_GRP(gpio42),
  465. BM1880_PINCTRL_GRP(gpio43),
  466. BM1880_PINCTRL_GRP(gpio44),
  467. BM1880_PINCTRL_GRP(gpio45),
  468. BM1880_PINCTRL_GRP(gpio46),
  469. BM1880_PINCTRL_GRP(gpio47),
  470. BM1880_PINCTRL_GRP(gpio48),
  471. BM1880_PINCTRL_GRP(gpio49),
  472. BM1880_PINCTRL_GRP(gpio50),
  473. BM1880_PINCTRL_GRP(gpio51),
  474. BM1880_PINCTRL_GRP(gpio52),
  475. BM1880_PINCTRL_GRP(gpio53),
  476. BM1880_PINCTRL_GRP(gpio54),
  477. BM1880_PINCTRL_GRP(gpio55),
  478. BM1880_PINCTRL_GRP(gpio56),
  479. BM1880_PINCTRL_GRP(gpio57),
  480. BM1880_PINCTRL_GRP(gpio58),
  481. BM1880_PINCTRL_GRP(gpio59),
  482. BM1880_PINCTRL_GRP(gpio60),
  483. BM1880_PINCTRL_GRP(gpio61),
  484. BM1880_PINCTRL_GRP(gpio62),
  485. BM1880_PINCTRL_GRP(gpio63),
  486. BM1880_PINCTRL_GRP(gpio64),
  487. BM1880_PINCTRL_GRP(gpio65),
  488. BM1880_PINCTRL_GRP(gpio66),
  489. BM1880_PINCTRL_GRP(gpio67),
  490. BM1880_PINCTRL_GRP(eth1),
  491. BM1880_PINCTRL_GRP(i2s0),
  492. BM1880_PINCTRL_GRP(i2s0_mclkin),
  493. BM1880_PINCTRL_GRP(i2s1),
  494. BM1880_PINCTRL_GRP(i2s1_mclkin),
  495. BM1880_PINCTRL_GRP(spi0),
  496. };
  497. static const char * const nand_group[] = { "nand_grp" };
  498. static const char * const spi_group[] = { "spi_grp" };
  499. static const char * const emmc_group[] = { "emmc_grp" };
  500. static const char * const sdio_group[] = { "sdio_grp" };
  501. static const char * const eth0_group[] = { "eth0_grp" };
  502. static const char * const pwm0_group[] = { "pwm0_grp" };
  503. static const char * const pwm1_group[] = { "pwm1_grp" };
  504. static const char * const pwm2_group[] = { "pwm2_grp" };
  505. static const char * const pwm3_group[] = { "pwm3_grp" };
  506. static const char * const pwm4_group[] = { "pwm4_grp" };
  507. static const char * const pwm5_group[] = { "pwm5_grp" };
  508. static const char * const pwm6_group[] = { "pwm6_grp" };
  509. static const char * const pwm7_group[] = { "pwm7_grp" };
  510. static const char * const pwm8_group[] = { "pwm8_grp" };
  511. static const char * const pwm9_group[] = { "pwm9_grp" };
  512. static const char * const pwm10_group[] = { "pwm10_grp" };
  513. static const char * const pwm11_group[] = { "pwm11_grp" };
  514. static const char * const pwm12_group[] = { "pwm12_grp" };
  515. static const char * const pwm13_group[] = { "pwm13_grp" };
  516. static const char * const pwm14_group[] = { "pwm14_grp" };
  517. static const char * const pwm15_group[] = { "pwm15_grp" };
  518. static const char * const pwm16_group[] = { "pwm16_grp" };
  519. static const char * const pwm17_group[] = { "pwm17_grp" };
  520. static const char * const pwm18_group[] = { "pwm18_grp" };
  521. static const char * const pwm19_group[] = { "pwm19_grp" };
  522. static const char * const pwm20_group[] = { "pwm20_grp" };
  523. static const char * const pwm21_group[] = { "pwm21_grp" };
  524. static const char * const pwm22_group[] = { "pwm22_grp" };
  525. static const char * const pwm23_group[] = { "pwm23_grp" };
  526. static const char * const pwm24_group[] = { "pwm24_grp" };
  527. static const char * const pwm25_group[] = { "pwm25_grp" };
  528. static const char * const pwm26_group[] = { "pwm26_grp" };
  529. static const char * const pwm27_group[] = { "pwm27_grp" };
  530. static const char * const pwm28_group[] = { "pwm28_grp" };
  531. static const char * const pwm29_group[] = { "pwm29_grp" };
  532. static const char * const pwm30_group[] = { "pwm30_grp" };
  533. static const char * const pwm31_group[] = { "pwm31_grp" };
  534. static const char * const pwm32_group[] = { "pwm32_grp" };
  535. static const char * const pwm33_group[] = { "pwm33_grp" };
  536. static const char * const pwm34_group[] = { "pwm34_grp" };
  537. static const char * const pwm35_group[] = { "pwm35_grp" };
  538. static const char * const pwm36_group[] = { "pwm36_grp" };
  539. static const char * const pwm37_group[] = { "pwm37_grp" };
  540. static const char * const i2c0_group[] = { "i2c0_grp" };
  541. static const char * const i2c1_group[] = { "i2c1_grp" };
  542. static const char * const i2c2_group[] = { "i2c2_grp" };
  543. static const char * const i2c3_group[] = { "i2c3_grp" };
  544. static const char * const i2c4_group[] = { "i2c4_grp" };
  545. static const char * const uart0_group[] = { "uart0_grp" };
  546. static const char * const uart1_group[] = { "uart1_grp" };
  547. static const char * const uart2_group[] = { "uart2_grp" };
  548. static const char * const uart3_group[] = { "uart3_grp" };
  549. static const char * const uart4_group[] = { "uart4_grp" };
  550. static const char * const uart5_group[] = { "uart5_grp" };
  551. static const char * const uart6_group[] = { "uart6_grp" };
  552. static const char * const uart7_group[] = { "uart7_grp" };
  553. static const char * const uart8_group[] = { "uart8_grp" };
  554. static const char * const uart9_group[] = { "uart9_grp" };
  555. static const char * const uart10_group[] = { "uart10_grp" };
  556. static const char * const uart11_group[] = { "uart11_grp" };
  557. static const char * const uart12_group[] = { "uart12_grp" };
  558. static const char * const uart13_group[] = { "uart13_grp" };
  559. static const char * const uart14_group[] = { "uart14_grp" };
  560. static const char * const uart15_group[] = { "uart15_grp" };
  561. static const char * const gpio0_group[] = { "gpio0_grp" };
  562. static const char * const gpio1_group[] = { "gpio1_grp" };
  563. static const char * const gpio2_group[] = { "gpio2_grp" };
  564. static const char * const gpio3_group[] = { "gpio3_grp" };
  565. static const char * const gpio4_group[] = { "gpio4_grp" };
  566. static const char * const gpio5_group[] = { "gpio5_grp" };
  567. static const char * const gpio6_group[] = { "gpio6_grp" };
  568. static const char * const gpio7_group[] = { "gpio7_grp" };
  569. static const char * const gpio8_group[] = { "gpio8_grp" };
  570. static const char * const gpio9_group[] = { "gpio9_grp" };
  571. static const char * const gpio10_group[] = { "gpio10_grp" };
  572. static const char * const gpio11_group[] = { "gpio11_grp" };
  573. static const char * const gpio12_group[] = { "gpio12_grp" };
  574. static const char * const gpio13_group[] = { "gpio13_grp" };
  575. static const char * const gpio14_group[] = { "gpio14_grp" };
  576. static const char * const gpio15_group[] = { "gpio15_grp" };
  577. static const char * const gpio16_group[] = { "gpio16_grp" };
  578. static const char * const gpio17_group[] = { "gpio17_grp" };
  579. static const char * const gpio18_group[] = { "gpio18_grp" };
  580. static const char * const gpio19_group[] = { "gpio19_grp" };
  581. static const char * const gpio20_group[] = { "gpio20_grp" };
  582. static const char * const gpio21_group[] = { "gpio21_grp" };
  583. static const char * const gpio22_group[] = { "gpio22_grp" };
  584. static const char * const gpio23_group[] = { "gpio23_grp" };
  585. static const char * const gpio24_group[] = { "gpio24_grp" };
  586. static const char * const gpio25_group[] = { "gpio25_grp" };
  587. static const char * const gpio26_group[] = { "gpio26_grp" };
  588. static const char * const gpio27_group[] = { "gpio27_grp" };
  589. static const char * const gpio28_group[] = { "gpio28_grp" };
  590. static const char * const gpio29_group[] = { "gpio29_grp" };
  591. static const char * const gpio30_group[] = { "gpio30_grp" };
  592. static const char * const gpio31_group[] = { "gpio31_grp" };
  593. static const char * const gpio32_group[] = { "gpio32_grp" };
  594. static const char * const gpio33_group[] = { "gpio33_grp" };
  595. static const char * const gpio34_group[] = { "gpio34_grp" };
  596. static const char * const gpio35_group[] = { "gpio35_grp" };
  597. static const char * const gpio36_group[] = { "gpio36_grp" };
  598. static const char * const gpio37_group[] = { "gpio37_grp" };
  599. static const char * const gpio38_group[] = { "gpio38_grp" };
  600. static const char * const gpio39_group[] = { "gpio39_grp" };
  601. static const char * const gpio40_group[] = { "gpio40_grp" };
  602. static const char * const gpio41_group[] = { "gpio41_grp" };
  603. static const char * const gpio42_group[] = { "gpio42_grp" };
  604. static const char * const gpio43_group[] = { "gpio43_grp" };
  605. static const char * const gpio44_group[] = { "gpio44_grp" };
  606. static const char * const gpio45_group[] = { "gpio45_grp" };
  607. static const char * const gpio46_group[] = { "gpio46_grp" };
  608. static const char * const gpio47_group[] = { "gpio47_grp" };
  609. static const char * const gpio48_group[] = { "gpio48_grp" };
  610. static const char * const gpio49_group[] = { "gpio49_grp" };
  611. static const char * const gpio50_group[] = { "gpio50_grp" };
  612. static const char * const gpio51_group[] = { "gpio51_grp" };
  613. static const char * const gpio52_group[] = { "gpio52_grp" };
  614. static const char * const gpio53_group[] = { "gpio53_grp" };
  615. static const char * const gpio54_group[] = { "gpio54_grp" };
  616. static const char * const gpio55_group[] = { "gpio55_grp" };
  617. static const char * const gpio56_group[] = { "gpio56_grp" };
  618. static const char * const gpio57_group[] = { "gpio57_grp" };
  619. static const char * const gpio58_group[] = { "gpio58_grp" };
  620. static const char * const gpio59_group[] = { "gpio59_grp" };
  621. static const char * const gpio60_group[] = { "gpio60_grp" };
  622. static const char * const gpio61_group[] = { "gpio61_grp" };
  623. static const char * const gpio62_group[] = { "gpio62_grp" };
  624. static const char * const gpio63_group[] = { "gpio63_grp" };
  625. static const char * const gpio64_group[] = { "gpio64_grp" };
  626. static const char * const gpio65_group[] = { "gpio65_grp" };
  627. static const char * const gpio66_group[] = { "gpio66_grp" };
  628. static const char * const gpio67_group[] = { "gpio67_grp" };
  629. static const char * const eth1_group[] = { "eth1_grp" };
  630. static const char * const i2s0_group[] = { "i2s0_grp" };
  631. static const char * const i2s0_mclkin_group[] = { "i2s0_mclkin_grp" };
  632. static const char * const i2s1_group[] = { "i2s1_grp" };
  633. static const char * const i2s1_mclkin_group[] = { "i2s1_mclkin_grp" };
  634. static const char * const spi0_group[] = { "spi0_grp" };
  635. #define BM1880_PINMUX_FUNCTION(fname, mval) \
  636. [F_##fname] = { \
  637. .name = #fname, \
  638. .groups = fname##_group, \
  639. .ngroups = ARRAY_SIZE(fname##_group), \
  640. .mux_val = mval, \
  641. }
  642. static const struct bm1880_pinmux_function bm1880_pmux_functions[] = {
  643. BM1880_PINMUX_FUNCTION(nand, 2),
  644. BM1880_PINMUX_FUNCTION(spi, 0),
  645. BM1880_PINMUX_FUNCTION(emmc, 1),
  646. BM1880_PINMUX_FUNCTION(sdio, 0),
  647. BM1880_PINMUX_FUNCTION(eth0, 0),
  648. BM1880_PINMUX_FUNCTION(pwm0, 2),
  649. BM1880_PINMUX_FUNCTION(pwm1, 2),
  650. BM1880_PINMUX_FUNCTION(pwm2, 2),
  651. BM1880_PINMUX_FUNCTION(pwm3, 2),
  652. BM1880_PINMUX_FUNCTION(pwm4, 2),
  653. BM1880_PINMUX_FUNCTION(pwm5, 2),
  654. BM1880_PINMUX_FUNCTION(pwm6, 2),
  655. BM1880_PINMUX_FUNCTION(pwm7, 2),
  656. BM1880_PINMUX_FUNCTION(pwm8, 2),
  657. BM1880_PINMUX_FUNCTION(pwm9, 2),
  658. BM1880_PINMUX_FUNCTION(pwm10, 2),
  659. BM1880_PINMUX_FUNCTION(pwm11, 2),
  660. BM1880_PINMUX_FUNCTION(pwm12, 2),
  661. BM1880_PINMUX_FUNCTION(pwm13, 2),
  662. BM1880_PINMUX_FUNCTION(pwm14, 2),
  663. BM1880_PINMUX_FUNCTION(pwm15, 2),
  664. BM1880_PINMUX_FUNCTION(pwm16, 2),
  665. BM1880_PINMUX_FUNCTION(pwm17, 2),
  666. BM1880_PINMUX_FUNCTION(pwm18, 2),
  667. BM1880_PINMUX_FUNCTION(pwm19, 2),
  668. BM1880_PINMUX_FUNCTION(pwm20, 2),
  669. BM1880_PINMUX_FUNCTION(pwm21, 2),
  670. BM1880_PINMUX_FUNCTION(pwm22, 2),
  671. BM1880_PINMUX_FUNCTION(pwm23, 2),
  672. BM1880_PINMUX_FUNCTION(pwm24, 2),
  673. BM1880_PINMUX_FUNCTION(pwm25, 2),
  674. BM1880_PINMUX_FUNCTION(pwm26, 2),
  675. BM1880_PINMUX_FUNCTION(pwm27, 2),
  676. BM1880_PINMUX_FUNCTION(pwm28, 2),
  677. BM1880_PINMUX_FUNCTION(pwm29, 2),
  678. BM1880_PINMUX_FUNCTION(pwm30, 2),
  679. BM1880_PINMUX_FUNCTION(pwm31, 2),
  680. BM1880_PINMUX_FUNCTION(pwm32, 2),
  681. BM1880_PINMUX_FUNCTION(pwm33, 2),
  682. BM1880_PINMUX_FUNCTION(pwm34, 2),
  683. BM1880_PINMUX_FUNCTION(pwm35, 2),
  684. BM1880_PINMUX_FUNCTION(pwm36, 2),
  685. BM1880_PINMUX_FUNCTION(pwm37, 2),
  686. BM1880_PINMUX_FUNCTION(i2c0, 1),
  687. BM1880_PINMUX_FUNCTION(i2c1, 1),
  688. BM1880_PINMUX_FUNCTION(i2c2, 1),
  689. BM1880_PINMUX_FUNCTION(i2c3, 1),
  690. BM1880_PINMUX_FUNCTION(i2c4, 1),
  691. BM1880_PINMUX_FUNCTION(uart0, 3),
  692. BM1880_PINMUX_FUNCTION(uart1, 3),
  693. BM1880_PINMUX_FUNCTION(uart2, 3),
  694. BM1880_PINMUX_FUNCTION(uart3, 3),
  695. BM1880_PINMUX_FUNCTION(uart4, 1),
  696. BM1880_PINMUX_FUNCTION(uart5, 1),
  697. BM1880_PINMUX_FUNCTION(uart6, 1),
  698. BM1880_PINMUX_FUNCTION(uart7, 1),
  699. BM1880_PINMUX_FUNCTION(uart8, 1),
  700. BM1880_PINMUX_FUNCTION(uart9, 1),
  701. BM1880_PINMUX_FUNCTION(uart10, 1),
  702. BM1880_PINMUX_FUNCTION(uart11, 1),
  703. BM1880_PINMUX_FUNCTION(uart12, 3),
  704. BM1880_PINMUX_FUNCTION(uart13, 3),
  705. BM1880_PINMUX_FUNCTION(uart14, 3),
  706. BM1880_PINMUX_FUNCTION(uart15, 3),
  707. BM1880_PINMUX_FUNCTION(gpio0, 0),
  708. BM1880_PINMUX_FUNCTION(gpio1, 0),
  709. BM1880_PINMUX_FUNCTION(gpio2, 0),
  710. BM1880_PINMUX_FUNCTION(gpio3, 0),
  711. BM1880_PINMUX_FUNCTION(gpio4, 0),
  712. BM1880_PINMUX_FUNCTION(gpio5, 0),
  713. BM1880_PINMUX_FUNCTION(gpio6, 0),
  714. BM1880_PINMUX_FUNCTION(gpio7, 0),
  715. BM1880_PINMUX_FUNCTION(gpio8, 0),
  716. BM1880_PINMUX_FUNCTION(gpio9, 0),
  717. BM1880_PINMUX_FUNCTION(gpio10, 0),
  718. BM1880_PINMUX_FUNCTION(gpio11, 0),
  719. BM1880_PINMUX_FUNCTION(gpio12, 1),
  720. BM1880_PINMUX_FUNCTION(gpio13, 1),
  721. BM1880_PINMUX_FUNCTION(gpio14, 0),
  722. BM1880_PINMUX_FUNCTION(gpio15, 0),
  723. BM1880_PINMUX_FUNCTION(gpio16, 0),
  724. BM1880_PINMUX_FUNCTION(gpio17, 0),
  725. BM1880_PINMUX_FUNCTION(gpio18, 0),
  726. BM1880_PINMUX_FUNCTION(gpio19, 0),
  727. BM1880_PINMUX_FUNCTION(gpio20, 0),
  728. BM1880_PINMUX_FUNCTION(gpio21, 0),
  729. BM1880_PINMUX_FUNCTION(gpio22, 0),
  730. BM1880_PINMUX_FUNCTION(gpio23, 0),
  731. BM1880_PINMUX_FUNCTION(gpio24, 0),
  732. BM1880_PINMUX_FUNCTION(gpio25, 0),
  733. BM1880_PINMUX_FUNCTION(gpio26, 0),
  734. BM1880_PINMUX_FUNCTION(gpio27, 0),
  735. BM1880_PINMUX_FUNCTION(gpio28, 0),
  736. BM1880_PINMUX_FUNCTION(gpio29, 0),
  737. BM1880_PINMUX_FUNCTION(gpio30, 0),
  738. BM1880_PINMUX_FUNCTION(gpio31, 0),
  739. BM1880_PINMUX_FUNCTION(gpio32, 0),
  740. BM1880_PINMUX_FUNCTION(gpio33, 0),
  741. BM1880_PINMUX_FUNCTION(gpio34, 0),
  742. BM1880_PINMUX_FUNCTION(gpio35, 0),
  743. BM1880_PINMUX_FUNCTION(gpio36, 0),
  744. BM1880_PINMUX_FUNCTION(gpio37, 0),
  745. BM1880_PINMUX_FUNCTION(gpio38, 0),
  746. BM1880_PINMUX_FUNCTION(gpio39, 0),
  747. BM1880_PINMUX_FUNCTION(gpio40, 0),
  748. BM1880_PINMUX_FUNCTION(gpio41, 0),
  749. BM1880_PINMUX_FUNCTION(gpio42, 0),
  750. BM1880_PINMUX_FUNCTION(gpio43, 0),
  751. BM1880_PINMUX_FUNCTION(gpio44, 0),
  752. BM1880_PINMUX_FUNCTION(gpio45, 0),
  753. BM1880_PINMUX_FUNCTION(gpio46, 0),
  754. BM1880_PINMUX_FUNCTION(gpio47, 0),
  755. BM1880_PINMUX_FUNCTION(gpio48, 0),
  756. BM1880_PINMUX_FUNCTION(gpio49, 0),
  757. BM1880_PINMUX_FUNCTION(gpio50, 0),
  758. BM1880_PINMUX_FUNCTION(gpio51, 0),
  759. BM1880_PINMUX_FUNCTION(gpio52, 0),
  760. BM1880_PINMUX_FUNCTION(gpio53, 0),
  761. BM1880_PINMUX_FUNCTION(gpio54, 0),
  762. BM1880_PINMUX_FUNCTION(gpio55, 0),
  763. BM1880_PINMUX_FUNCTION(gpio56, 0),
  764. BM1880_PINMUX_FUNCTION(gpio57, 0),
  765. BM1880_PINMUX_FUNCTION(gpio58, 0),
  766. BM1880_PINMUX_FUNCTION(gpio59, 0),
  767. BM1880_PINMUX_FUNCTION(gpio60, 0),
  768. BM1880_PINMUX_FUNCTION(gpio61, 0),
  769. BM1880_PINMUX_FUNCTION(gpio62, 0),
  770. BM1880_PINMUX_FUNCTION(gpio63, 0),
  771. BM1880_PINMUX_FUNCTION(gpio64, 0),
  772. BM1880_PINMUX_FUNCTION(gpio65, 0),
  773. BM1880_PINMUX_FUNCTION(gpio66, 0),
  774. BM1880_PINMUX_FUNCTION(gpio67, 0),
  775. BM1880_PINMUX_FUNCTION(eth1, 1),
  776. BM1880_PINMUX_FUNCTION(i2s0, 2),
  777. BM1880_PINMUX_FUNCTION(i2s0_mclkin, 1),
  778. BM1880_PINMUX_FUNCTION(i2s1, 2),
  779. BM1880_PINMUX_FUNCTION(i2s1_mclkin, 1),
  780. BM1880_PINMUX_FUNCTION(spi0, 1),
  781. };
  782. #define BM1880_PINCONF_DAT(_width) \
  783. { \
  784. .drv_bits = _width, \
  785. }
  786. static const struct bm1880_pinconf_data bm1880_pinconf[] = {
  787. BM1880_PINCONF_DAT(0x03),
  788. BM1880_PINCONF_DAT(0x03),
  789. BM1880_PINCONF_DAT(0x03),
  790. BM1880_PINCONF_DAT(0x03),
  791. BM1880_PINCONF_DAT(0x03),
  792. BM1880_PINCONF_DAT(0x03),
  793. BM1880_PINCONF_DAT(0x03),
  794. BM1880_PINCONF_DAT(0x03),
  795. BM1880_PINCONF_DAT(0x03),
  796. BM1880_PINCONF_DAT(0x03),
  797. BM1880_PINCONF_DAT(0x03),
  798. BM1880_PINCONF_DAT(0x03),
  799. BM1880_PINCONF_DAT(0x03),
  800. BM1880_PINCONF_DAT(0x03),
  801. BM1880_PINCONF_DAT(0x03),
  802. BM1880_PINCONF_DAT(0x03),
  803. BM1880_PINCONF_DAT(0x03),
  804. BM1880_PINCONF_DAT(0x03),
  805. BM1880_PINCONF_DAT(0x03),
  806. BM1880_PINCONF_DAT(0x03),
  807. BM1880_PINCONF_DAT(0x03),
  808. BM1880_PINCONF_DAT(0x03),
  809. BM1880_PINCONF_DAT(0x03),
  810. BM1880_PINCONF_DAT(0x03),
  811. BM1880_PINCONF_DAT(0x03),
  812. BM1880_PINCONF_DAT(0x03),
  813. BM1880_PINCONF_DAT(0x03),
  814. BM1880_PINCONF_DAT(0x03),
  815. BM1880_PINCONF_DAT(0x03),
  816. BM1880_PINCONF_DAT(0x03),
  817. BM1880_PINCONF_DAT(0x03),
  818. BM1880_PINCONF_DAT(0x03),
  819. BM1880_PINCONF_DAT(0x03),
  820. BM1880_PINCONF_DAT(0x03),
  821. BM1880_PINCONF_DAT(0x03),
  822. BM1880_PINCONF_DAT(0x03),
  823. BM1880_PINCONF_DAT(0x03),
  824. BM1880_PINCONF_DAT(0x03),
  825. BM1880_PINCONF_DAT(0x03),
  826. BM1880_PINCONF_DAT(0x03),
  827. BM1880_PINCONF_DAT(0x03),
  828. BM1880_PINCONF_DAT(0x03),
  829. BM1880_PINCONF_DAT(0x03),
  830. BM1880_PINCONF_DAT(0x03),
  831. BM1880_PINCONF_DAT(0x03),
  832. BM1880_PINCONF_DAT(0x03),
  833. BM1880_PINCONF_DAT(0x03),
  834. BM1880_PINCONF_DAT(0x03),
  835. BM1880_PINCONF_DAT(0x03),
  836. BM1880_PINCONF_DAT(0x03),
  837. BM1880_PINCONF_DAT(0x03),
  838. BM1880_PINCONF_DAT(0x03),
  839. BM1880_PINCONF_DAT(0x03),
  840. BM1880_PINCONF_DAT(0x03),
  841. BM1880_PINCONF_DAT(0x03),
  842. BM1880_PINCONF_DAT(0x03),
  843. BM1880_PINCONF_DAT(0x03),
  844. BM1880_PINCONF_DAT(0x03),
  845. BM1880_PINCONF_DAT(0x03),
  846. BM1880_PINCONF_DAT(0x03),
  847. BM1880_PINCONF_DAT(0x02),
  848. BM1880_PINCONF_DAT(0x02),
  849. BM1880_PINCONF_DAT(0x02),
  850. BM1880_PINCONF_DAT(0x02),
  851. BM1880_PINCONF_DAT(0x02),
  852. BM1880_PINCONF_DAT(0x02),
  853. BM1880_PINCONF_DAT(0x02),
  854. BM1880_PINCONF_DAT(0x02),
  855. BM1880_PINCONF_DAT(0x02),
  856. BM1880_PINCONF_DAT(0x02),
  857. BM1880_PINCONF_DAT(0x02),
  858. BM1880_PINCONF_DAT(0x02),
  859. BM1880_PINCONF_DAT(0x02),
  860. BM1880_PINCONF_DAT(0x02),
  861. BM1880_PINCONF_DAT(0x02),
  862. BM1880_PINCONF_DAT(0x02),
  863. BM1880_PINCONF_DAT(0x02),
  864. BM1880_PINCONF_DAT(0x02),
  865. BM1880_PINCONF_DAT(0x02),
  866. BM1880_PINCONF_DAT(0x02),
  867. BM1880_PINCONF_DAT(0x02),
  868. BM1880_PINCONF_DAT(0x02),
  869. BM1880_PINCONF_DAT(0x02),
  870. BM1880_PINCONF_DAT(0x02),
  871. BM1880_PINCONF_DAT(0x02),
  872. BM1880_PINCONF_DAT(0x02),
  873. BM1880_PINCONF_DAT(0x02),
  874. BM1880_PINCONF_DAT(0x02),
  875. BM1880_PINCONF_DAT(0x02),
  876. BM1880_PINCONF_DAT(0x02),
  877. BM1880_PINCONF_DAT(0x02),
  878. BM1880_PINCONF_DAT(0x02),
  879. BM1880_PINCONF_DAT(0x02),
  880. BM1880_PINCONF_DAT(0x02),
  881. BM1880_PINCONF_DAT(0x02),
  882. BM1880_PINCONF_DAT(0x02),
  883. BM1880_PINCONF_DAT(0x02),
  884. BM1880_PINCONF_DAT(0x02),
  885. BM1880_PINCONF_DAT(0x02),
  886. BM1880_PINCONF_DAT(0x02),
  887. BM1880_PINCONF_DAT(0x02),
  888. BM1880_PINCONF_DAT(0x02),
  889. BM1880_PINCONF_DAT(0x02),
  890. BM1880_PINCONF_DAT(0x02),
  891. BM1880_PINCONF_DAT(0x02),
  892. BM1880_PINCONF_DAT(0x02),
  893. BM1880_PINCONF_DAT(0x02),
  894. BM1880_PINCONF_DAT(0x02),
  895. BM1880_PINCONF_DAT(0x02),
  896. BM1880_PINCONF_DAT(0x02),
  897. BM1880_PINCONF_DAT(0x02),
  898. BM1880_PINCONF_DAT(0x02),
  899. };
  900. static int bm1880_pctrl_get_groups_count(struct pinctrl_dev *pctldev)
  901. {
  902. struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  903. return pctrl->ngroups;
  904. }
  905. static const char *bm1880_pctrl_get_group_name(struct pinctrl_dev *pctldev,
  906. unsigned int selector)
  907. {
  908. struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  909. return pctrl->groups[selector].name;
  910. }
  911. static int bm1880_pctrl_get_group_pins(struct pinctrl_dev *pctldev,
  912. unsigned int selector,
  913. const unsigned int **pins,
  914. unsigned int *num_pins)
  915. {
  916. struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  917. *pins = pctrl->groups[selector].pins;
  918. *num_pins = pctrl->groups[selector].npins;
  919. return 0;
  920. }
  921. static const struct pinctrl_ops bm1880_pctrl_ops = {
  922. .get_groups_count = bm1880_pctrl_get_groups_count,
  923. .get_group_name = bm1880_pctrl_get_group_name,
  924. .get_group_pins = bm1880_pctrl_get_group_pins,
  925. .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
  926. .dt_free_map = pinctrl_utils_free_map,
  927. };
  928. /* pinmux */
  929. static int bm1880_pmux_get_functions_count(struct pinctrl_dev *pctldev)
  930. {
  931. struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  932. return pctrl->nfuncs;
  933. }
  934. static const char *bm1880_pmux_get_function_name(struct pinctrl_dev *pctldev,
  935. unsigned int selector)
  936. {
  937. struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  938. return pctrl->funcs[selector].name;
  939. }
  940. static int bm1880_pmux_get_function_groups(struct pinctrl_dev *pctldev,
  941. unsigned int selector,
  942. const char * const **groups,
  943. unsigned * const num_groups)
  944. {
  945. struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  946. *groups = pctrl->funcs[selector].groups;
  947. *num_groups = pctrl->funcs[selector].ngroups;
  948. return 0;
  949. }
  950. static int bm1880_pinmux_set_mux(struct pinctrl_dev *pctldev,
  951. unsigned int function,
  952. unsigned int group)
  953. {
  954. struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  955. const struct bm1880_pctrl_group *pgrp = &pctrl->groups[group];
  956. const struct bm1880_pinmux_function *func = &pctrl->funcs[function];
  957. int i;
  958. for (i = 0; i < pgrp->npins; i++) {
  959. unsigned int pin = pgrp->pins[i];
  960. u32 offset = (pin >> 1) << 2;
  961. u32 mux_offset = ((!((pin + 1) & 1) << 4) + 4);
  962. u32 regval = readl_relaxed(pctrl->base + BM1880_REG_MUX +
  963. offset);
  964. regval &= ~(0x03 << mux_offset);
  965. regval |= func->mux_val << mux_offset;
  966. writel_relaxed(regval, pctrl->base + BM1880_REG_MUX + offset);
  967. }
  968. return 0;
  969. }
  970. #define BM1880_PINCONF(pin, idx) ((!((pin + 1) & 1) << 4) + idx)
  971. #define BM1880_PINCONF_PULLCTRL(pin) BM1880_PINCONF(pin, 0)
  972. #define BM1880_PINCONF_PULLUP(pin) BM1880_PINCONF(pin, 1)
  973. #define BM1880_PINCONF_PULLDOWN(pin) BM1880_PINCONF(pin, 2)
  974. #define BM1880_PINCONF_DRV(pin) BM1880_PINCONF(pin, 6)
  975. #define BM1880_PINCONF_SCHMITT(pin) BM1880_PINCONF(pin, 9)
  976. #define BM1880_PINCONF_SLEW(pin) BM1880_PINCONF(pin, 10)
  977. static int bm1880_pinconf_drv_set(unsigned int mA, u32 width,
  978. u32 *regval, u32 bit_offset)
  979. {
  980. u32 _regval;
  981. _regval = *regval;
  982. /*
  983. * There are two sets of drive strength bit width exposed by the
  984. * SoC at 4mA step, hence we need to handle them separately.
  985. */
  986. if (width == 0x03) {
  987. switch (mA) {
  988. case 4:
  989. _regval &= ~(width << bit_offset);
  990. _regval |= (0 << bit_offset);
  991. break;
  992. case 8:
  993. _regval &= ~(width << bit_offset);
  994. _regval |= (1 << bit_offset);
  995. break;
  996. case 12:
  997. _regval &= ~(width << bit_offset);
  998. _regval |= (2 << bit_offset);
  999. break;
  1000. case 16:
  1001. _regval &= ~(width << bit_offset);
  1002. _regval |= (3 << bit_offset);
  1003. break;
  1004. case 20:
  1005. _regval &= ~(width << bit_offset);
  1006. _regval |= (4 << bit_offset);
  1007. break;
  1008. case 24:
  1009. _regval &= ~(width << bit_offset);
  1010. _regval |= (5 << bit_offset);
  1011. break;
  1012. case 28:
  1013. _regval &= ~(width << bit_offset);
  1014. _regval |= (6 << bit_offset);
  1015. break;
  1016. case 32:
  1017. _regval &= ~(width << bit_offset);
  1018. _regval |= (7 << bit_offset);
  1019. break;
  1020. default:
  1021. return -EINVAL;
  1022. }
  1023. } else {
  1024. switch (mA) {
  1025. case 4:
  1026. _regval &= ~(width << bit_offset);
  1027. _regval |= (0 << bit_offset);
  1028. break;
  1029. case 8:
  1030. _regval &= ~(width << bit_offset);
  1031. _regval |= (1 << bit_offset);
  1032. break;
  1033. case 12:
  1034. _regval &= ~(width << bit_offset);
  1035. _regval |= (2 << bit_offset);
  1036. break;
  1037. case 16:
  1038. _regval &= ~(width << bit_offset);
  1039. _regval |= (3 << bit_offset);
  1040. break;
  1041. default:
  1042. return -EINVAL;
  1043. }
  1044. }
  1045. *regval = _regval;
  1046. return 0;
  1047. }
  1048. static int bm1880_pinconf_drv_get(u32 width, u32 drv)
  1049. {
  1050. int ret = -ENOTSUPP;
  1051. /*
  1052. * There are two sets of drive strength bit width exposed by the
  1053. * SoC at 4mA step, hence we need to handle them separately.
  1054. */
  1055. if (width == 0x03) {
  1056. switch (drv) {
  1057. case 0:
  1058. ret = 4;
  1059. break;
  1060. case 1:
  1061. ret = 8;
  1062. break;
  1063. case 2:
  1064. ret = 12;
  1065. break;
  1066. case 3:
  1067. ret = 16;
  1068. break;
  1069. case 4:
  1070. ret = 20;
  1071. break;
  1072. case 5:
  1073. ret = 24;
  1074. break;
  1075. case 6:
  1076. ret = 28;
  1077. break;
  1078. case 7:
  1079. ret = 32;
  1080. break;
  1081. default:
  1082. break;
  1083. }
  1084. } else {
  1085. switch (drv) {
  1086. case 0:
  1087. ret = 4;
  1088. break;
  1089. case 1:
  1090. ret = 8;
  1091. break;
  1092. case 2:
  1093. ret = 12;
  1094. break;
  1095. case 3:
  1096. ret = 16;
  1097. break;
  1098. default:
  1099. break;
  1100. }
  1101. }
  1102. return ret;
  1103. }
  1104. static int bm1880_pinconf_cfg_get(struct pinctrl_dev *pctldev,
  1105. unsigned int pin,
  1106. unsigned long *config)
  1107. {
  1108. struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  1109. unsigned int param = pinconf_to_config_param(*config);
  1110. unsigned int arg = 0;
  1111. u32 regval, offset, bit_offset;
  1112. int ret;
  1113. offset = (pin >> 1) << 2;
  1114. regval = readl_relaxed(pctrl->base + BM1880_REG_MUX + offset);
  1115. switch (param) {
  1116. case PIN_CONFIG_BIAS_PULL_UP:
  1117. bit_offset = BM1880_PINCONF_PULLUP(pin);
  1118. arg = !!(regval & BIT(bit_offset));
  1119. break;
  1120. case PIN_CONFIG_BIAS_PULL_DOWN:
  1121. bit_offset = BM1880_PINCONF_PULLDOWN(pin);
  1122. arg = !!(regval & BIT(bit_offset));
  1123. break;
  1124. case PIN_CONFIG_BIAS_DISABLE:
  1125. bit_offset = BM1880_PINCONF_PULLCTRL(pin);
  1126. arg = !!(regval & BIT(bit_offset));
  1127. break;
  1128. case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
  1129. bit_offset = BM1880_PINCONF_SCHMITT(pin);
  1130. arg = !!(regval & BIT(bit_offset));
  1131. break;
  1132. case PIN_CONFIG_SLEW_RATE:
  1133. bit_offset = BM1880_PINCONF_SLEW(pin);
  1134. arg = !!(regval & BIT(bit_offset));
  1135. break;
  1136. case PIN_CONFIG_DRIVE_STRENGTH:
  1137. bit_offset = BM1880_PINCONF_DRV(pin);
  1138. ret = bm1880_pinconf_drv_get(pctrl->pinconf[pin].drv_bits,
  1139. !!(regval & BIT(bit_offset)));
  1140. if (ret < 0)
  1141. return ret;
  1142. arg = ret;
  1143. break;
  1144. default:
  1145. return -ENOTSUPP;
  1146. }
  1147. *config = pinconf_to_config_packed(param, arg);
  1148. return 0;
  1149. }
  1150. static int bm1880_pinconf_cfg_set(struct pinctrl_dev *pctldev,
  1151. unsigned int pin,
  1152. unsigned long *configs,
  1153. unsigned int num_configs)
  1154. {
  1155. struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  1156. u32 regval, offset, bit_offset;
  1157. int i, ret;
  1158. offset = (pin >> 1) << 2;
  1159. regval = readl_relaxed(pctrl->base + BM1880_REG_MUX + offset);
  1160. for (i = 0; i < num_configs; i++) {
  1161. unsigned int param = pinconf_to_config_param(configs[i]);
  1162. unsigned int arg = pinconf_to_config_argument(configs[i]);
  1163. switch (param) {
  1164. case PIN_CONFIG_BIAS_PULL_UP:
  1165. bit_offset = BM1880_PINCONF_PULLUP(pin);
  1166. regval |= BIT(bit_offset);
  1167. break;
  1168. case PIN_CONFIG_BIAS_PULL_DOWN:
  1169. bit_offset = BM1880_PINCONF_PULLDOWN(pin);
  1170. regval |= BIT(bit_offset);
  1171. break;
  1172. case PIN_CONFIG_BIAS_DISABLE:
  1173. bit_offset = BM1880_PINCONF_PULLCTRL(pin);
  1174. regval |= BIT(bit_offset);
  1175. break;
  1176. case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
  1177. bit_offset = BM1880_PINCONF_SCHMITT(pin);
  1178. if (arg)
  1179. regval |= BIT(bit_offset);
  1180. else
  1181. regval &= ~BIT(bit_offset);
  1182. break;
  1183. case PIN_CONFIG_SLEW_RATE:
  1184. bit_offset = BM1880_PINCONF_SLEW(pin);
  1185. if (arg)
  1186. regval |= BIT(bit_offset);
  1187. else
  1188. regval &= ~BIT(bit_offset);
  1189. break;
  1190. case PIN_CONFIG_DRIVE_STRENGTH:
  1191. bit_offset = BM1880_PINCONF_DRV(pin);
  1192. ret = bm1880_pinconf_drv_set(arg,
  1193. pctrl->pinconf[pin].drv_bits,
  1194. &regval, bit_offset);
  1195. if (ret < 0)
  1196. return ret;
  1197. break;
  1198. default:
  1199. dev_warn(pctldev->dev,
  1200. "unsupported configuration parameter '%u'\n",
  1201. param);
  1202. continue;
  1203. }
  1204. writel_relaxed(regval, pctrl->base + BM1880_REG_MUX + offset);
  1205. }
  1206. return 0;
  1207. }
  1208. static int bm1880_pinconf_group_set(struct pinctrl_dev *pctldev,
  1209. unsigned int selector,
  1210. unsigned long *configs,
  1211. unsigned int num_configs)
  1212. {
  1213. int i, ret;
  1214. struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
  1215. const struct bm1880_pctrl_group *pgrp = &pctrl->groups[selector];
  1216. for (i = 0; i < pgrp->npins; i++) {
  1217. ret = bm1880_pinconf_cfg_set(pctldev, pgrp->pins[i], configs,
  1218. num_configs);
  1219. if (ret)
  1220. return ret;
  1221. }
  1222. return 0;
  1223. }
  1224. static const struct pinconf_ops bm1880_pinconf_ops = {
  1225. .is_generic = true,
  1226. .pin_config_get = bm1880_pinconf_cfg_get,
  1227. .pin_config_set = bm1880_pinconf_cfg_set,
  1228. .pin_config_group_set = bm1880_pinconf_group_set,
  1229. };
  1230. static const struct pinmux_ops bm1880_pinmux_ops = {
  1231. .get_functions_count = bm1880_pmux_get_functions_count,
  1232. .get_function_name = bm1880_pmux_get_function_name,
  1233. .get_function_groups = bm1880_pmux_get_function_groups,
  1234. .set_mux = bm1880_pinmux_set_mux,
  1235. };
  1236. static const struct pinctrl_desc bm1880_desc = {
  1237. .name = "bm1880_pinctrl",
  1238. .pins = bm1880_pins,
  1239. .npins = ARRAY_SIZE(bm1880_pins),
  1240. .pctlops = &bm1880_pctrl_ops,
  1241. .pmxops = &bm1880_pinmux_ops,
  1242. .confops = &bm1880_pinconf_ops,
  1243. .owner = THIS_MODULE,
  1244. };
  1245. static int bm1880_pinctrl_probe(struct platform_device *pdev)
  1246. {
  1247. struct bm1880_pinctrl *pctrl;
  1248. pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
  1249. if (!pctrl)
  1250. return -ENOMEM;
  1251. pctrl->base = devm_platform_ioremap_resource(pdev, 0);
  1252. if (IS_ERR(pctrl->base))
  1253. return PTR_ERR(pctrl->base);
  1254. pctrl->groups = bm1880_pctrl_groups;
  1255. pctrl->ngroups = ARRAY_SIZE(bm1880_pctrl_groups);
  1256. pctrl->funcs = bm1880_pmux_functions;
  1257. pctrl->nfuncs = ARRAY_SIZE(bm1880_pmux_functions);
  1258. pctrl->pinconf = bm1880_pinconf;
  1259. pctrl->pctrldev = devm_pinctrl_register(&pdev->dev, &bm1880_desc,
  1260. pctrl);
  1261. if (IS_ERR(pctrl->pctrldev))
  1262. return PTR_ERR(pctrl->pctrldev);
  1263. platform_set_drvdata(pdev, pctrl);
  1264. dev_info(&pdev->dev, "BM1880 pinctrl driver initialized\n");
  1265. return 0;
  1266. }
  1267. static const struct of_device_id bm1880_pinctrl_of_match[] = {
  1268. { .compatible = "bitmain,bm1880-pinctrl" },
  1269. { }
  1270. };
  1271. static struct platform_driver bm1880_pinctrl_driver = {
  1272. .driver = {
  1273. .name = "pinctrl-bm1880",
  1274. .of_match_table = of_match_ptr(bm1880_pinctrl_of_match),
  1275. },
  1276. .probe = bm1880_pinctrl_probe,
  1277. };
  1278. static int __init bm1880_pinctrl_init(void)
  1279. {
  1280. return platform_driver_register(&bm1880_pinctrl_driver);
  1281. }
  1282. arch_initcall(bm1880_pinctrl_init);