gpio_shell.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*
  2. * Copyright (c) 2018 Prevas A/S
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <shell/shell.h>
  7. #include <drivers/gpio.h>
  8. #include <board_cfg.h>
  9. #include "gpio_utils.h"
  10. #if defined(CONFIG_SOC_SERIES_LEOPARD)
  11. #define MAX_MFP_PINNUM 86
  12. #define MAX_GPIO_PINNUM 81
  13. #else
  14. #define MAX_MFP_PINNUM 69
  15. #define MAX_GPIO_PINNUM 65
  16. #endif
  17. #define WIO_CTL_MFP_MASK 0xf
  18. #if defined(CONFIG_SOC_SERIES_LEOPARD)
  19. enum {
  20. WIO0 = 81,
  21. WIO1,
  22. WIO2,
  23. WIO3,
  24. WIO4,
  25. };
  26. #else
  27. enum {
  28. WIO0 = 65,
  29. WIO1,
  30. WIO2,
  31. WIO3,
  32. };
  33. #endif
  34. enum {
  35. UART_TX,
  36. UART_RX,
  37. UART_CTS,
  38. UART_RTS,
  39. };
  40. enum {
  41. I2C_CLK,
  42. I2C_DAT,
  43. };
  44. enum {
  45. SPI_CS,
  46. SPI_CLK,
  47. SPI_MISO,
  48. SPI_MOSI,
  49. SPI_D2,
  50. SPI_D3,
  51. SPI_D4,
  52. SPI_D5,
  53. SPI_D6,
  54. SPI_D7,
  55. SPI_DM,
  56. SPI_DQS,
  57. SPI_CLK_POS,
  58. SPI_CLK_NEG,
  59. SPI_IO2,
  60. SPI_IO3,
  61. SPI_DQS0,
  62. SPI_DQS1,
  63. SPI_D8,
  64. SPI_D9,
  65. SPI_D10,
  66. SPI_D11,
  67. SPI_D12,
  68. SPI_D13,
  69. SPI_D14,
  70. SPI_D15,
  71. };
  72. enum {
  73. IICMT_CLK,
  74. IICMT_DAT,
  75. };
  76. enum {
  77. SPIMT_SS,
  78. SPIMT_SS0,
  79. SPIMT_SS1,
  80. SPIMT_CLK,
  81. SPIMT_MISO,
  82. SPIMT_MOSI,
  83. SPIMT_SS2,
  84. SPIMT_SS3,
  85. };
  86. enum {
  87. PPI_TRIG0,
  88. PPI_TRIG1,
  89. PPI_TRIG2,
  90. PPI_TRIG3,
  91. PPI_TRIG4,
  92. PPI_TRIG5,
  93. PPI_TRIG6,
  94. PPI_TRIG7,
  95. PPI_TRIG8,
  96. PPI_TRIG9,
  97. PPI_TRIG10,
  98. PPI_TRIG11,
  99. };
  100. enum {
  101. SD0_CMD,
  102. SD0_CLK0,
  103. SD0_D0,
  104. SD0_D1,
  105. SD0_D6,
  106. SD0_D7,
  107. SD0_D4,
  108. SD0_D5,
  109. SD0_D2,
  110. SD0_D3,
  111. SD0_CLK1,
  112. SD1_CMD,
  113. SD1_CLK0,
  114. SD1_D0,
  115. SD1_D1,
  116. SD1_D2,
  117. SD1_D3,
  118. SD1_D4,
  119. SD1_D5,
  120. SD1_D6,
  121. SD1_D7,
  122. SD1_CLK1,
  123. };
  124. enum {
  125. IIS_MCLK,
  126. IIS_LRCLK,
  127. IIS_BCLK,
  128. IIS_DOUT,
  129. IIS_DIN,
  130. };
  131. enum {
  132. SPDIF_TX,
  133. SPDIF_RX,
  134. SPDIF_RX_A,
  135. };
  136. enum {
  137. CEC,
  138. };
  139. enum {
  140. DMIC_CLK,
  141. DMIC_DAT,
  142. };
  143. enum {
  144. PWM0,
  145. PWM1,
  146. PWM2,
  147. PWM3,
  148. PWM4,
  149. PWM5,
  150. PWM6,
  151. PWM7,
  152. PWM8,
  153. };
  154. enum {
  155. LCD_D0,
  156. LCD_D1,
  157. LCD_D2,
  158. LCD_D3,
  159. LCD_D4,
  160. LCD_D5,
  161. LCD_D6,
  162. LCD_D7,
  163. LCD_D10,
  164. LCD_D11,
  165. LCD_D12,
  166. LCD_D13,
  167. LCD_D14,
  168. LCD_D15,
  169. LCD_CE0,
  170. LCD_CE1,
  171. LCD_RS,
  172. LCD_RDE,
  173. LCD_WR,
  174. LCD_TE,
  175. };
  176. enum {
  177. GIO14,
  178. GIO15,
  179. GIO16,
  180. GIO17,
  181. GIO30,
  182. GIO31,
  183. BT_UART_TX,
  184. BT_UART_RX,
  185. BT_REQ,
  186. BT_ACCESS,
  187. PTA_GRANT,
  188. ANT_SW0,
  189. ANT_SW1,
  190. ANT_SW2,
  191. ANT_SW3,
  192. ANT_SW4,
  193. ANT_SW5,
  194. ANT_SW6,
  195. ANT_SW7,
  196. };
  197. enum {
  198. LRADC4,
  199. LRADC5,
  200. LRADC2,
  201. LRADC3,
  202. LRADC6,
  203. LRADC7,
  204. LRADC1,
  205. };
  206. enum {
  207. TIMER2_CAP,
  208. TIMER3_CAP,
  209. };
  210. enum {
  211. CTK0_OUT,
  212. USBDM,
  213. USBDP,
  214. };
  215. enum {
  216. IOVCC1_OUT,
  217. IOVCC2_OUT,
  218. IOVCC4_OUT,
  219. WCI_TX,
  220. WCI_RX,
  221. VCC_OUT,
  222. };
  223. enum {
  224. HOSCOUT,
  225. LOSCOUT,
  226. };
  227. #if defined(CONFIG_SOC_SERIES_LEOPARD)
  228. static const uint8_t MFP_TABLE[MAX_GPIO_PINNUM][32] = {
  229. {0, SPI_CS, 0, 0, 0, 0, 0, 0, 0, 0, SD0_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SPI_MOSI},
  230. {0, SPI_MISO, 0, 0, 0, 0, 0, 0, 0, 0, SD0_CLK0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SPI_CLK},
  231. {0, SPI_CLK, 0, 0, 0, 0, 0, 0, 0, 0, SD0_D0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SPI_CS},
  232. {0, SPI_MOSI, 0, 0, 0, 0, 0, 0, 0, 0, SD0_D1, 0, 0, 0, 0, 0, 0, 0, PWM0, 0, 0, 0, SPI_MISO},
  233. {0, 0, 0, SPI_CS, 0, 0, UART_TX, 0, I2C_CLK, 0, SD0_D4, PPI_TRIG0, IIS_LRCLK, IIS_LRCLK, I2C_DAT, 0, 0, 0, PWM0, 0, SD1_D2, 0, 0, 0, 0, SPIMT_SS0, 0, 0, LRADC4},
  234. {0, 0, 0, SPI_CLK, 0, 0, UART_RX, 0, I2C_DAT, 0, SD0_D5, PPI_TRIG1, IIS_DOUT, IIS_DIN, I2C_CLK, 0, 0, 0, PWM1, 0, SD1_D3, 0, 0, 0, 0, SPIMT_CLK, 0, 0, LRADC5},
  235. {0, SPI_D2, 0, 0, 0, 0, UART_CTS, 0, 0, I2C_CLK, SD0_D2, 0, 0, 0, 0, 0, 0, DMIC_CLK, PWM2},
  236. {0, SPI_D3, 0, 0, 0, 0, UART_RTS, 0, 0, I2C_DAT, SD0_D3, 0, 0, 0, 0, 0, 0, DMIC_DAT, PWM3},
  237. {0, 0, 0, SPI_MISO, SPI_IO2, 0, 0, UART_TX, 0, 0, SD0_D2, PPI_TRIG2, IIS_LRCLK, IIS_LRCLK, I2C_DAT, I2C_CLK, 0, 0, PWM0, 0, SD1_CMD, 0, 0, 0, 0, SPIMT_MISO, 0, 0, LRADC2},
  238. {0, 0, 0, SPI_MOSI, SPI_IO3, 0, 0, UART_RX, 0, 0, SD0_D3, PPI_TRIG3, IIS_BCLK, IIS_BCLK, 0, I2C_DAT, 0, 0, PWM1, 0, SD1_CLK0, 0, 0, 0, 0, SPIMT_MOSI, 0, 0, LRADC3},
  239. {0, 0, 0, 0, SPI_CS, UART_RX, 0, UART_CTS, I2C_CLK, 0, SD0_CMD, 0, 0, 0, 0, 0, 0, 0, PWM2, 0, SD1_D2, IIS_DOUT, SPI_CS, GIO14, 0, SPIMT_SS1},
  240. // 11
  241. {0, 0, 0, 0, SPI_CLK, UART_RX, 0, UART_RTS, I2C_DAT, 0, SD0_D0, PPI_TRIG5, 0, 0, I2C_DAT, 0, 0, 0, PWM3, 0, SD1_CLK0, 0, SPI_CLK, GIO15, SPIMT_SS3, SPIMT_SS2},
  242. {0, 0, 0, 0, SPI_MISO, UART_CTS, UART_TX, 0, 0, I2C_CLK, SD0_CLK0, PPI_TRIG6, 0, 0, I2C_CLK, 0, 0, DMIC_CLK, PWM1, 0, SD1_D3, IIS_DOUT, SPI_MISO, GIO16, SPIMT_SS2, SPIMT_SS3},
  243. {0, 0, 0, 0, SPI_MOSI, UART_RTS, UART_RX, 0, 0, I2C_DAT, SD0_D1, PPI_TRIG7, 0, IIS_DIN, 0, I2C_CLK, 0, DMIC_DAT, 0, 0, SD1_D0, 0, SPI_MOSI, GIO17, SPIMT_SS1, 0, 0, 0, 0, 0, 0, WCI_TX},
  244. {0, 0, 0, 0, 0, UART_TX, 0, 0, I2C_CLK, 0, 0, PPI_TRIG0, IIS_DOUT, 0, 0, 0, 0, 0, PWM0, LCD_D0, 0, 0, 0, BT_UART_TX, SPIMT_SS3, SPIMT_MISO, IICMT_CLK},
  245. {0, 0, 0, 0, 0, UART_RX, 0, 0, I2C_DAT, 0, 0, PPI_TRIG1, 0, IIS_DIN, 0, 0, 0, 0, PWM1, LCD_D1, 0, 0, 0, BT_UART_RX, SPIMT_SS2, SPIMT_MOSI, IICMT_DAT},
  246. {0, 0, 0, SPI_CS, 0, 0, UART_TX, 0, 0, I2C_DAT, 0, PPI_TRIG2, IIS_MCLK, IIS_MCLK, 0, 0, 0, 0, PWM2, LCD_D2, 0, 0, 0, BT_REQ, 0, SPIMT_SS1, 0, IICMT_DAT},
  247. {0, 0, 0, SPI_CLK, 0, 0, UART_RX, 0, 0, I2C_CLK, 0, PPI_TRIG3, IIS_BCLK, IIS_BCLK, 0, I2C_CLK, 0, 0, PWM3, LCD_D3, 0, 0, 0, BT_ACCESS, 0, SPIMT_SS0, 0, IICMT_CLK},
  248. {0, 0, 0, SPI_MISO, SPI_MISO, 0, UART_CTS, 0, I2C_CLK, 0, SD0_D0, PPI_TRIG4, IIS_DOUT, IIS_DIN, 0, 0, 0, 0, PWM1, LCD_D4, SD1_D2, IIS_DOUT, 0, PTA_GRANT, SPIMT_MISO, SPIMT_MISO, IICMT_CLK, IICMT_CLK},
  249. {0, 0, 0, SPI_MOSI, SPI_MOSI, 0, UART_RTS, 0, I2C_DAT, 0, SD0_D1, PPI_TRIG5, IIS_MCLK, IIS_MCLK, 0, 0, 0, 0, PWM2, LCD_D5, SD1_D3, 0, 0, GIO14, SPIMT_MOSI, SPIMT_MOSI, IICMT_DAT, IICMT_DAT, 0, HOSCOUT, LOSCOUT},
  250. {0, 0, 0, SPI_CS, SPI_CS, 0, UART_TX, UART_TX, 0, I2C_CLK, SD0_D2, PPI_TRIG6, IIS_BCLK, IIS_BCLK, 0, 0, 0, 0, PWM3, LCD_D6, 0, 0, 0, GIO15, SPIMT_SS0, SPIMT_SS0, 0, IICMT_CLK, LRADC2},
  251. // 21
  252. {0, 0, 0, SPI_CLK, SPI_CLK, 0, UART_RX, UART_RX, I2C_CLK, I2C_DAT, SD0_D3, PPI_TRIG7, IIS_LRCLK, IIS_LRCLK, 0, 0, 0, 0, PWM0, LCD_D7, 0, 0, 0, GIO16, SPIMT_CLK, SPIMT_CLK, 0, IICMT_DAT, LRADC3},
  253. {0, 0, 0, 0, SPI_MISO, 0, 0, UART_CTS, I2C_DAT, 0, SD0_D6, PPI_TRIG8, 0, 0, I2C_CLK, 0, 0, 0, PWM1, 0, SD1_D0, IIS_DOUT, 0, GIO17, SPIMT_SS3, SPIMT_MISO, IICMT_CLK, 0, 0, HOSCOUT, LOSCOUT},
  254. {0, 0, 0, 0, SPI_MOSI, 0, 0, UART_RTS, 0, I2C_CLK, SD0_D7, PPI_TRIG9, IIS_DOUT, IIS_DIN, I2C_DAT, 0, 0, 0, 0, 0, SD1_D1, 0, 0, ANT_SW0, SPIMT_SS2, SPIMT_MOSI, IICMT_DAT, 0, LRADC2, 0, 0, WCI_TX},
  255. {0, 0, 0, 0, SPI_CLK, 0, UART_TX, 0, I2C_CLK, I2C_DAT, SD0_CLK0, PPI_TRIG10, IIS_MCLK, IIS_MCLK, 0, I2C_CLK, 0, 0, 0, LCD_D4, 0, 0, 0, ANT_SW1, SPIMT_SS1, SPIMT_SS0, IICMT_CLK, 0, 0, 0, 0, WCI_RX},
  256. {0, 0, 0, 0, SPI_IO2, 0, UART_RX, 0, I2C_DAT, 0, SD0_CMD, PPI_TRIG11, IIS_BCLK, IIS_BCLK, I2C_CLK, I2C_DAT, 0, 0, 0, LCD_D5, 0, 0, 0, ANT_SW2, 0, SPIMT_CLK, IICMT_DAT, 0, LRADC5, HOSCOUT, LOSCOUT, WCI_TX},
  257. {0, 0, 0, 0, SPI_CS, 0, 0, UART_TX, 0, I2C_CLK, SD0_D4, PPI_TRIG0, IIS_LRCLK, IIS_LRCLK, I2C_DAT, 0, 0, 0, 0, LCD_D6, SD1_CMD, 0, 0, ANT_SW3, 0, SPIMT_MISO, 0, IICMT_CLK, 0, 0, 0, VCC_OUT},
  258. {0, 0, 0, 0, SPI_IO3, 0, 0, UART_RX, 0, I2C_DAT, SD0_D5, PPI_TRIG1, IIS_DOUT, 0, 0, I2C_CLK, 0, 0, 0, LCD_D7, SD1_CLK0, 0, 0, ANT_SW4, 0, SPIMT_MOSI, 0, IICMT_DAT, LRADC6, 0, 0, VCC_OUT},
  259. {0, 0, 0, 0, SPI_IO2, UART_TX, 0, 0, I2C_CLK, 0, SD0_D6, PPI_TRIG2, IIS_DOUT, 0, I2C_CLK, 0, 0, 0, 0, 0, SD1_D1, 0, 0, BT_UART_TX, 0, SPIMT_SS0, IICMT_CLK},
  260. {0, 0, 0, SPI_CS, SPI_IO3, UART_RX, 0, 0, I2C_DAT, 0, SD0_D7, PPI_TRIG3, 0, IIS_DIN, I2C_DAT, 0, 0, 0, 0, 0, SD1_D0, IIS_DOUT, 0, BT_UART_RX, 0, SPIMT_SS1, IICMT_DAT},
  261. {0, 0, 0, SPI_CS, 0, 0, 0, 0, 0, 0, 0, PPI_TRIG0, IIS_LRCLK, IIS_LRCLK, I2C_DAT, I2C_DAT, 0, DMIC_CLK, 0, LCD_CE0, 0, 0, 0, ANT_SW7, 0, SPIMT_CLK},
  262. //31
  263. {0, 0, 0, SPI_CLK, SPI_CLK, 0, 0, 0, 0, 0, 0, PPI_TRIG4, IIS_MCLK, IIS_MCLK, 0, I2C_DAT, 0, DMIC_DAT, 0, 0, SD1_D2, 0, 0, ANT_SW5, 0, SPIMT_CLK, 0, 0, 0, HOSCOUT, LOSCOUT},
  264. {0, 0, 0, SPI_MISO, 0, 0, 0, 0, I2C_CLK, 0, 0, PPI_TRIG1, 0, 0, I2C_CLK, 0, 0, 0, 0, LCD_RS, 0, IIS_DOUT, 0, ANT_SW6, SPIMT_MISO, 0, IICMT_CLK, 0, 0, HOSCOUT, LOSCOUT},
  265. {0, 0, 0, SPI_MOSI, 0, 0, 0, 0, I2C_DAT, 0, 0, PPI_TRIG2, 0, 0, 0, 0, 0, 0, 0, LCD_RDE, 0, 0, 0, GIO30, SPIMT_MOSI, 0, IICMT_DAT, 0, 0, 0, 0, IOVCC2_OUT},
  266. {0, 0, 0, SPI_CLK, 0, 0, 0, 0, 0, I2C_CLK, 0, PPI_TRIG3, 0, 0, 0, 0, 0, DMIC_CLK, 0, LCD_WR, 0, 0, 0, BT_UART_TX, SPIMT_CLK, 0, 0, IICMT_CLK},
  267. {0, 0, 0, SPI_MISO, 0, 0, 0, 0, 0, I2C_DAT, 0, PPI_TRIG4, 0, 0, 0, I2C_CLK, 0, DMIC_DAT, 0, LCD_TE, 0, 0, 0, BT_UART_RX, SPIMT_SS1, 0, IICMT_CLK, IICMT_DAT, LRADC4},
  268. {0, 0, SPI_MOSI, 0, 0, 0, 0, 0, 0, 0, 0, PPI_TRIG0, IIS_MCLK, 0, 0, I2C_CLK, 0, 0, PWM0},
  269. {0, 0, SPI_MISO, 0, 0, UART_TX, 0, 0, 0, 0, 0, PPI_TRIG1, IIS_BCLK, 0, 0, I2C_DAT, 0, 0, PWM1},
  270. {0, 0, SPI_D2, 0, 0, UART_RX, 0, 0, 0, 0, 0, PPI_TRIG2, IIS_LRCLK, 0, 0, 0, 0, 0, PWM2},
  271. {0, 0, SPI_D3, 0, 0, 0, UART_TX, 0, I2C_CLK, 0, 0, PPI_TRIG3, IIS_DOUT, 0, 0, 0, 0, 0, PWM3, 0, 0, 0, 0, 0, 0, 0, IICMT_CLK, IICMT_CLK},
  272. {0, 0, SPI_CS, SPI_MISO, 0, 0, UART_RX, 0, I2C_DAT, 0, 0, PPI_TRIG4, 0, IIS_MCLK, 0, 0, 0, 0, PWM0, 0, 0, 0, 0, 0, 0, SPIMT_MISO, IICMT_DAT, IICMT_DAT},
  273. //41
  274. {0, 0, SPI_CLK_POS, SPI_MOSI, 0, 0, 0, UART_TX, 0, I2C_CLK, 0, PPI_TRIG5, 0, IIS_BCLK, 0, 0, 0, 0, PWM1, 0, SD1_D2, 0, 0, 0, 0, SPIMT_MOSI},
  275. {0, 0, SPI_CLK_NEG, SPI_CLK, 0, 0, 0, UART_RX, 0, I2C_DAT, 0, PPI_TRIG6, 0, IIS_LRCLK, 0, 0, 0, 0, PWM2, 0, SD1_D3, 0, 0, 0, 0, SPIMT_CLK},
  276. {0, 0, SPI_D4, SPI_CS, 0, UART_CTS, 0, 0, 0, 0, 0, PPI_TRIG7, 0, IIS_DIN, I2C_DAT, 0, 0, 0, PWM3, 0, SD1_CLK0, 0, 0, 0, 0, SPIMT_SS0},
  277. {0, 0, SPI_D5, 0, 0, UART_RTS, 0, 0, 0, 0, 0, PPI_TRIG8, 0, IIS_MCLK, I2C_CLK, 0, 0, 0, PWM1, 0, SD1_CMD, 0, 0, 0, 0, SPIMT_SS1},
  278. {0, 0, SPI_D6, 0, 0, 0, 0, 0, 0, 0, 0, PPI_TRIG9, 0, IIS_BCLK, 0, 0, 0, 0, PWM2, 0, SD1_D0, 0, 0, 0, 0, SPIMT_SS2},
  279. {0, 0, SPI_D7, 0, 0, 0, 0, 0, 0, 0, 0, PPI_TRIG10, 0, IIS_LRCLK, 0, 0, 0, 0, PWM3, 0, SD1_D1, 0, 0, 0, 0, SPIMT_SS3},
  280. {0, 0, SPI_DM, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, I2C_CLK, 0, 0, 0, 0, 0, IIS_DOUT, 0, 0, 0, 0, 0, 0, 0, HOSCOUT, LOSCOUT},
  281. {0, 0, SPI_DQS, 0, 0, 0, 0, 0, 0, 0, SD0_D7, PPI_TRIG11, 0, 0, 0, I2C_DAT, 0, 0, 0, 0, 0, 0, 0, 0, 0, SPIMT_CLK, 0, 0, 0, HOSCOUT, LOSCOUT},
  282. {0, 0, 0, SPI_CS, 0, 0, UART_TX, 0, I2C_CLK, 0, 0, PPI_TRIG0, 0, 0, I2C_CLK, 0, 0, 0, PWM0, 0, SD1_CMD, 0, 0, BT_REQ, SPIMT_SS0, 0, IICMT_CLK},
  283. {0, 0, 0, SPI_CLK, 0, 0, UART_RX, 0, I2C_DAT, 0, 0, PPI_TRIG1, 0, 0, I2C_DAT, 0, 0, 0, PWM1, 0, SD1_CLK0, 0, 0, BT_ACCESS, SPIMT_CLK, 0, IICMT_DAT},
  284. //51
  285. {0, 0, 0, SPI_MISO, 0, 0, UART_CTS, 0, 0, I2C_CLK, 0, PPI_TRIG2, 0, 0, 0, I2C_CLK, 0, 0, PWM2, 0, SD1_D1, 0, 0, PTA_GRANT, SPIMT_MISO, 0, 0, IICMT_CLK},
  286. {0, 0, 0, SPI_MOSI, 0, 0, UART_RTS, 0, I2C_CLK, I2C_DAT, 0, PPI_TRIG3, IIS_DOUT, 0, 0, I2C_DAT, 0, 0, PWM3, 0, SD1_D0, IIS_DOUT, 0, GIO14, SPIMT_MOSI, 0, 0, IICMT_DAT},
  287. {0, 0, 0, SPI_CS, SPI_CS, 0, 0, UART_TX, I2C_DAT, 0, SD0_D4, PPI_TRIG4, 0, IIS_MCLK, I2C_CLK, 0, 0, 0, PWM0, 0, SD1_D2, 0, 0, GIO15, 0, SPIMT_SS0, IICMT_CLK, 0, 0, HOSCOUT, LOSCOUT},
  288. {0, 0, 0, SPI_CLK, SPI_CLK, 0, 0, UART_RX, 0, I2C_CLK, SD0_D5, PPI_TRIG5, 0, IIS_BCLK, I2C_DAT, 0, 0, 0, PWM1, 0, SD1_D3, 0, 0, GIO16, 0, SPIMT_CLK, IICMT_DAT},
  289. {0, 0, 0, SPI_MISO, SPI_MISO, 0, 0, UART_CTS, 0, I2C_DAT, SD0_D6, PPI_TRIG6, 0, IIS_LRCLK, 0, I2C_CLK, 0, 0, PWM2, 0, SD1_CLK0, 0, 0, GIO17, 0, SPIMT_MISO, 0, IICMT_CLK},
  290. {0, 0, 0, SPI_MOSI, SPI_MOSI, 0, 0, UART_RTS, 0, 0, SD0_D7, PPI_TRIG7, IIS_DOUT, IIS_DIN, I2C_CLK, I2C_DAT, 0, 0, PWM3, 0, 0, 0, 0, ANT_SW0, 0, SPIMT_MOSI, 0, IICMT_DAT},
  291. {0, 0, 0, SPI_CS, 0, 0, 0, 0, I2C_CLK, 0, SD0_D2, PPI_TRIG8, 0, 0, I2C_DAT, 0, 0, 0, PWM1, 0, 0, IIS_DOUT, 0, ANT_SW1, SPIMT_SS2, 0, IICMT_CLK, 0, 0, HOSCOUT, LOSCOUT},
  292. {0, 0, 0, SPI_CLK, 0, 0, 0, 0, I2C_DAT, 0, SD0_D3, PPI_TRIG9, IIS_DOUT, 0, 0, I2C_CLK, 0, 0, 0, 0, 0, 0, 0, ANT_SW2, SPIMT_SS3, 0, IICMT_DAT, 0, 0, 0, 0, WCI_TX},
  293. {0, 0, 0, SPI_MISO, 0, 0, 0, 0, 0, I2C_CLK, SD0_CLK1, PPI_TRIG10, IIS_MCLK, IIS_MCLK, 0, I2C_DAT, 0, 0, 0, 0, 0, 0, 0, ANT_SW3, SPIMT_SS1, 0, 0, IICMT_CLK, 0, 0, 0, WCI_RX},
  294. {0, 0, 0, SPI_MOSI, 0, 0, 0, 0, 0, I2C_DAT, SD0_CLK0, PPI_TRIG11, IIS_BCLK, IIS_BCLK, 0, I2C_CLK, 0, 0, 0, 0, 0, 0, 0, ANT_SW4, 0, 0, 0, IICMT_DAT, 0, HOSCOUT, LOSCOUT},
  295. //61
  296. {0, 0, 0, 0, SPI_IO2, 0, 0, 0, 0, 0, SD0_D0, PPI_TRIG4, IIS_LRCLK, IIS_LRCLK, I2C_CLK, 0, 0, 0, 0, 0, 0, 0, 0, ANT_SW5, 0, SPIMT_SS3, 0, 0, LRADC5, HOSCOUT, LOSCOUT},
  297. {0, 0, 0, 0, SPI_IO3, UART_RX, UART_RX, UART_RX, 0, 0, SD0_D1, PPI_TRIG5, IIS_DOUT, IIS_DIN, I2C_DAT, 0, 0, 0, 0, 0, 0, 0, 0, ANT_SW6, 0, SPIMT_SS1, 0, 0, LRADC4},
  298. {0, 0, 0, SPI_MISO, SPI_MISO, UART_TX, UART_TX, UART_TX, 0, 0, SD0_CMD, PPI_TRIG6, IIS_MCLK, IIS_MCLK, 0, I2C_DAT, 0, 0, 0, 0, 0, IIS_DOUT, 0, ANT_SW7, 0, SPIMT_SS2, 0, 0, LRADC3, HOSCOUT, LOSCOUT, IOVCC4_OUT},
  299. {0, 0, 0, SPI_MISO, SPI_MISO, UART_TX, UART_TX, UART_TX, 0, 0, SD0_D7, PPI_TRIG11, IIS_MCLK, IIS_MCLK, I2C_CLK, I2C_DAT, 0, 0, PWM0, 0, SD1_D1, IIS_DOUT, 0, GIO31, SPIMT_SS0, 0, 0, IICMT_DAT, 0, HOSCOUT, LOSCOUT, IOVCC1_OUT},
  300. {0, 0, SPI_DQS1, SPI_MISO, 0, 0, UART_TX, 0, I2C_CLK, 0, SD0_CMD, 0, 0, IIS_DIN, 0, 0, 0, 0, PWM0, 0, 0, 0, 0, BT_REQ, SPIMT_SS0, 0, IICMT_CLK, 0, 0, 0, 0, WCI_TX},
  301. {0, 0, SPI_D8, SPI_MOSI, 0, 0, UART_RX, 0, I2C_DAT, 0, SD0_CLK0, PPI_TRIG0, IIS_MCLK, IIS_MCLK, 0, 0, 0, 0, PWM1, 0, 0, 0, 0, BT_ACCESS, SPIMT_CLK, 0, IICMT_DAT, 0, 0, 0, 0, WCI_RX},
  302. {0, 0, SPI_D9, SPI_CLK, 0, UART_TX, UART_CTS, 0, 0, I2C_CLK, SD0_D0, PPI_TRIG1, IIS_BCLK, IIS_BCLK, 0, 0, 0, 0, PWM2, 0, 0, 0, 0, PTA_GRANT, SPIMT_MISO, 0, 0, IICMT_CLK},
  303. {0, 0, SPI_D10, SPI_CS, 0, UART_RX, UART_RTS, 0, I2C_CLK, I2C_DAT, SD0_D1, PPI_TRIG2, IIS_LRCLK, IIS_LRCLK, 0, 0, 0, DMIC_CLK, PWM3, 0, 0, 0, 0, GIO14, SPIMT_MOSI, SPIMT_SS2, 0, IICMT_DAT},
  304. {0, 0, SPI_D11, 0, SPI_CS, 0, 0, UART_TX, I2C_DAT, 0, SD0_D2, PPI_TRIG3, IIS_DOUT, IIS_DIN, I2C_CLK, 0, 0, DMIC_DAT, PWM0, 0, 0, 0, 0, GIO15, SPIMT_SS1, SPIMT_SS3, IICMT_CLK},
  305. {0, 0, SPI_D12, 0, SPI_CLK, 0, 0, UART_RX, 0, I2C_CLK, SD0_D3, PPI_TRIG4, 0, 0, I2C_DAT, 0, 0, DMIC_CLK, PWM1, 0, 0, IIS_DOUT, 0, GIO16, SPIMT_SS2, SPIMT_SS1, IICMT_DAT, 0, 0, HOSCOUT, LOSCOUT},
  306. //71
  307. {0, 0, SPI_D13, 0, SPI_MISO, 0, 0, UART_CTS, 0, I2C_DAT, SD0_D4, PPI_TRIG5, IIS_MCLK, IIS_MCLK, 0, I2C_CLK, 0, 0, PWM2, 0, SD1_CMD, 0, 0, GIO17, SPIMT_SS3, SPIMT_CLK, 0, IICMT_CLK, 0, 0, 0, WCI_TX},
  308. {0, 0, SPI_D14, 0, SPI_MOSI, 0, 0, UART_RTS, 0, 0, SD0_D5, PPI_TRIG6, IIS_BCLK, IIS_BCLK, I2C_CLK, I2C_DAT, 0, 0, PWM3, 0, SD1_CLK0, 0, 0, ANT_SW0, 0, SPIMT_MISO, 0, IICMT_DAT, 0, HOSCOUT, LOSCOUT},
  309. {0, 0, SPI_D15, 0, SPI_IO2, 0, UART_TX, UART_RX, 0, 0, SD0_D6, PPI_TRIG7, IIS_LRCLK, IIS_LRCLK, I2C_DAT, I2C_CLK, 0, 0, PWM0, 0, SD1_D0, 0, 0, ANT_SW1, 0, SPIMT_MOSI, 0, 0, 0, 0, 0, WCI_RX},
  310. {0, 0, 0, SPI_MOSI, SPI_MOSI, UART_RX, 0, UART_RX, I2C_CLK, I2C_DAT, SD0_D6, PPI_TRIG4, IIS_BCLK, IIS_BCLK, I2C_DAT, I2C_CLK, 0, DMIC_CLK, PWM1, 0, SD1_D0, 0, 0, ANT_SW3, SPIMT_CLK, 0, 0, IICMT_CLK, LRADC6, HOSCOUT, LOSCOUT, WCI_RX},
  311. {0, 0, 0, SPI_MISO, SPI_MISO, UART_TX, 0, UART_RX, 0, 0, 0, 0, IIS_BCLK, IIS_BCLK, I2C_CLK, 0, USBDP, DMIC_CLK, PWM2, 0, SD1_D3, 0, 0, BT_UART_TX, 0, SPIMT_SS3, IICMT_CLK, IICMT_CLK, 0, 0, 0, WCI_TX},
  312. {0, 0, 0, SPI_MOSI, SPI_MOSI, UART_RX, 0, UART_TX, 0, 0, 0, 0, IIS_LRCLK, IIS_LRCLK, I2C_DAT, 0, USBDM, DMIC_DAT, PWM3, 0, SD1_CLK0, 0, 0, BT_UART_RX, 0, SPIMT_SS2, IICMT_DAT, IICMT_DAT, 0, 0, 0, WCI_RX},
  313. {0, 0, 0, SPI_MOSI, 0, 0, 0, 0, 0, 0, SD0_CLK0, PPI_TRIG4, IIS_DOUT, IIS_DIN, 0, I2C_DAT, 0, DMIC_DAT, 0, LCD_CE1, SD1_CLK0, IIS_DOUT, 0, ANT_SW6, SPIMT_SS0, 0, IICMT_DAT, 0, LRADC6, HOSCOUT, LOSCOUT},
  314. {0, 0, 0, SPI_CS, SPI_CS, 0, UART_TX, 0, I2C_DAT, 0, SD0_D4, PPI_TRIG8, IIS_BCLK, IIS_BCLK, I2C_CLK, I2C_CLK, 0, DMIC_DAT, PWM2, 0, SD1_CLK0, 0, 0, ANT_SW4, SPIMT_MISO, 0, IICMT_CLK, IICMT_DAT, 0, 0, 0, WCI_TX},
  315. {0, 0, 0, SPI_CLK, SPI_CLK, 0, UART_RX, UART_RX, I2C_CLK, I2C_CLK, SD0_D5, PPI_TRIG9, IIS_LRCLK, IIS_LRCLK, 0, I2C_CLK, 0, DMIC_CLK, PWM3, 0, SD1_CMD, 0, 0, ANT_SW5, SPIMT_MOSI, 0, IICMT_DAT, IICMT_CLK, 0, 0, 0, WCI_RX},
  316. {0, 0, 0, SPI_MOSI, SPI_MOSI, 0, UART_RX, UART_TX, 0, I2C_DAT, SD0_D7, PPI_TRIG8, IIS_DOUT, IIS_DIN, I2C_DAT, I2C_DAT, 0, DMIC_DAT, 0, 0, SD1_D0, IIS_DOUT, 0, ANT_SW2, 0, SPIMT_SS0, 0, 0, 0, HOSCOUT, LOSCOUT},
  317. };
  318. #else
  319. static const uint8_t MFP_TABLE[MAX_GPIO_PINNUM][32] = {
  320. {0, SPI_CS, 0, 0, 0, 0, 0, 0, 0, 0, SD0_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SPI_MOSI},
  321. {0, SPI_MISO, 0, 0, 0, 0, 0, 0, 0, 0, SD0_CLK0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SPI_CLK},
  322. {0, SPI_CLK, 0, 0, 0, 0, 0, 0, 0, 0, SD0_D0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SPI_CS},
  323. {0, SPI_MOSI, 0, 0, 0, 0, 0, 0, 0, 0, SD0_D1, 0, 0, IIS_MCLK, 0, 0, 0, 0, PWM0, 0, 0, 0, SPI_MISO},
  324. {0, 0, 0, SPI_CS, 0, 0, UART_TX, 0, I2C_CLK, 0, SD0_D6, PPI_TRIG0, IIS_LRCLK, IIS_LRCLK, 0, 0, DMIC_CLK, 0, PWM0, 0, 0, 0, 0, 0, 0, SPIMT_SS0, 0, 0, LRADC4, TIMER2_CAP},
  325. {0, 0, 0, SPI_CLK, 0, 0, UART_RX, 0, I2C_DAT, 0, SD0_D7, PPI_TRIG1, IIS_DOUT, IIS_DIN, SPDIF_TX, SPDIF_RX, DMIC_DAT, 0, PWM1, 0, 0, 0, 0, 0, 0, SPIMT_CLK, 0, 0, LRADC5, TIMER3_CAP},
  326. {0, SPI_D2, 0, 0, 0, 0, UART_CTS, 0, 0, I2C_CLK, SD0_D4, 0, IIS_MCLK, IIS_BCLK, 0, 0, 0, DMIC_CLK, PWM2},
  327. {0, SPI_D3, 0, 0, 0, 0, UART_RTS, 0, 0, I2C_DAT, SD0_D5, 0, IIS_BCLK, IIS_LRCLK, 0, 0, 0, DMIC_DAT, PWM3},
  328. {0, 0, 0, SPI_MISO, SPI_IO2, 0, 0, UART_TX, 0, 0, SD0_D2, PPI_TRIG2, IIS_LRCLK, IIS_LRCLK, 0, 0, DMIC_CLK, 0, PWM4, 0, 0, 0, 0, 0, 0, SPIMT_MISO, 0, 0, LRADC2},
  329. {0, 0, 0, SPI_MOSI, SPI_IO3, 0, 0, UART_RX, 0, 0, SD0_D3, PPI_TRIG3, IIS_DOUT, IIS_DIN, SPDIF_TX, SPDIF_RX, DMIC_DAT, 0, PWM5, 0, 0, CEC, 0, 0, 0, SPIMT_MOSI, 0, 0, LRADC3},
  330. {0, 0, 0, 0, SPI_CS, UART_RX, 0, UART_CTS, I2C_CLK, 0, SD0_CLK1, 0, 0, 0, 0, 0, 0, 0, PWM6, 0, 0, 0, SPI_CS, GIO14, SPIMT_SS0},
  331. {0, 0, 0, 0, SPI_CLK, UART_RX, 0, UART_RTS, I2C_DAT, 0, SD0_CMD, PPI_TRIG5, 0, 0, 0, 0, 0, 0, PWM7, 0, 0, 0, SPI_CLK, GIO15, SPIMT_CLK},
  332. //12
  333. {0, 0, 0, 0, SPI_MISO, UART_CTS, UART_TX, 0, 0, I2C_CLK, SD0_D0, PPI_TRIG6, 0, 0, 0, 0, 0, DMIC_CLK, PWM8, 0, 0, 0, SPI_MISO, GIO16, SPIMT_MISO},
  334. {0, 0, 0, 0, SPI_MOSI, UART_RTS, UART_RX, 0, 0, I2C_DAT, SD0_D1, PPI_TRIG7, 0, IIS_DIN, 0, SPDIF_RX, 0, DMIC_DAT, 0, 0, 0, 0, SPI_MOSI, GIO17, SPIMT_MOSI, 0, 0, 0, 0, 0, 0, IOVCC1_OUT},
  335. {0, 0, 0, 0, 0, UART_TX, 0, 0, I2C_CLK, 0, 0, PPI_TRIG0, IIS_DOUT, 0, SPDIF_TX, 0, 0, 0, PWM0, LCD_D0, 0, CEC, 0, BT_UART_TX, 0, 0, IICMT_CLK},
  336. {0, 0, 0, 0, 0, UART_RX, 0, 0, I2C_DAT, 0, 0, PPI_TRIG1, 0, IIS_DIN, 0, SPDIF_RX, 0, 0, PWM1, LCD_D1, 0, 0, 0, BT_UART_RX, 0, 0, IICMT_DAT, 0, 0, 0, 0, IOVCC2_OUT},
  337. {0, 0, 0, SPI_CS, 0, 0, UART_TX, 0, I2C_CLK, 0, 0, PPI_TRIG2, IIS_MCLK, IIS_MCLK, 0, SPDIF_RX_A, 0, 0, PWM2, LCD_D2, 0, CEC, 0, BT_REQ, SPIMT_SS, 0, IICMT_CLK},
  338. {0, 0, 0, SPI_CLK, 0, 0, UART_RX, 0, I2C_DAT, 0, 0, PPI_TRIG3, IIS_BCLK, IIS_BCLK, 0, 0, 0, 0, PWM3, LCD_D3, 0, 0, 0, BT_ACCESS, SPIMT_CLK, 0, IICMT_DAT},
  339. //18
  340. {0, 0, 0, SPI_MISO, SPI_MISO, 0, UART_CTS, 0, I2C_CLK, I2C_CLK, SD1_CMD, PPI_TRIG4, IIS_LRCLK, IIS_DIN, 0, 0, 0, 0, PWM4, LCD_D4, 0, 0, 0, PTA_GRANT, SPIMT_MISO, SPIMT_MISO, IICMT_CLK, IICMT_CLK},
  341. {0, 0, 0, SPI_MOSI, SPI_MOSI, 0, UART_RTS, 0, I2C_DAT, I2C_DAT, SD1_CLK0, PPI_TRIG5, 0, IIS_MCLK, 0, 0, 0, 0, PWM5, LCD_D5, 0, 0, 0, GIO14, SPIMT_MOSI, SPIMT_MOSI, IICMT_DAT, IICMT_DAT},
  342. {0, 0, 0, SPI_CS, SPI_CS, 0, UART_TX, UART_TX, 0, I2C_CLK, SD1_D0, PPI_TRIG6, 0, IIS_BCLK, 0, 0, 0, 0, PWM6, LCD_D6, 0, 0, 0, GIO15, SPIMT_SS, SPIMT_SS, 0, IICMT_CLK, LRADC2},
  343. //21
  344. {0, 0, 0, SPI_CLK, SPI_CLK, 0, UART_RX, UART_RX, 0, I2C_DAT, SD1_D1, PPI_TRIG7, 0, IIS_LRCLK, 0, 0, 0, 0, PWM7, LCD_D7, 0, 0, 0, GIO16, SPIMT_CLK, SPIMT_CLK, 0, IICMT_DAT, LRADC3},
  345. {0, 0, 0, 0, SPI_MISO, 0, 0, UART_CTS, I2C_CLK, 0, SD1_D2, PPI_TRIG8, IIS_DOUT, 0, SPDIF_TX, 0, DMIC_CLK, 0, PWM8, 0, 0, CEC, 0, GIO17, 0, SPIMT_MISO, IICMT_CLK, 0, LRADC6, TIMER2_CAP},
  346. {0, 0, 0, 0, SPI_MOSI, 0, 0, UART_RTS, I2C_DAT, 0, SD1_D3, PPI_TRIG9, 0, IIS_DIN, 0, SPDIF_RX, DMIC_DAT, 0, 0, 0, 0, 0, 0, ANT_SW0, 0, SPIMT_MOSI, IICMT_DAT, 0, LRADC7, TIMER3_CAP},
  347. {0, 0, SPI_CS, 0, 0, 0, UART_TX, 0, I2C_CLK, 0, SD1_D4, PPI_TRIG10, IIS_MCLK, IIS_MCLK, 0, SPDIF_RX_A, 0, 0, 0, LCD_D10, 0, CEC, 0, ANT_SW1, SPIMT_SS, 0, IICMT_CLK},
  348. {0, 0, SPI_CLK, 0, 0, 0, UART_RX, 0, I2C_DAT, 0, SD1_D5, PPI_TRIG11, IIS_BCLK, IIS_BCLK, 0, 0, 0, 0, 0, LCD_D11, 0, CEC, 0, ANT_SW2, SPIMT_CLK, 0, IICMT_DAT},
  349. {0, 0, SPI_MISO, 0, 0, 0, 0, UART_TX, 0, I2C_CLK, SD1_D6, PPI_TRIG0, IIS_LRCLK, IIS_LRCLK, 0, 0, 0, 0, 0, LCD_D12, 0, 0, 0, ANT_SW3, SPIMT_MISO, 0, 0, IICMT_CLK},
  350. {0, 0, SPI_MOSI, 0, 0, 0, 0, UART_RX, 0, I2C_DAT, SD1_D7, PPI_TRIG1, 0, IIS_MCLK, 0, 0, 0, 0, 0, LCD_D13, 0, 0, 0, ANT_SW4, SPIMT_MOSI, 0, 0, IICMT_DAT},
  351. {0, 0, 0, 0, SPI_IO2, UART_TX, 0, 0, I2C_CLK, 0, SD1_CLK1, PPI_TRIG2, 0, IIS_BCLK, 0, 0, 0, 0, 0, LCD_D14, 0, 0, 0, BT_UART_TX, SPIMT_SS1, 0, IICMT_CLK},
  352. {0, 0, 0, 0, SPI_IO3, UART_RX, 0, 0, I2C_DAT, 0, 0, PPI_TRIG3, 0, IIS_LRCLK, 0, 0, 0, 0, 0, LCD_D15, 0, 0, 0, BT_UART_RX, 0, SPIMT_SS1, IICMT_DAT},
  353. {0, 0, 0, SPI_CS, 0, 0, 0, 0, 0, 0, 0, PPI_TRIG0, 0, 0, 0, 0, 0, DMIC_CLK, 0, LCD_CE0, 0, 0, 0, ANT_SW7},
  354. //31
  355. {0, 0, 0, SPI_CLK, 0, 0, 0, 0, 0, 0, 0, PPI_TRIG4, 0, 0, 0, 0, 0, DMIC_DAT, 0, LCD_CE1, 0, 0, 0, ANT_SW5},
  356. {0, 0, 0, SPI_MISO, 0, 0, 0, 0, I2C_CLK, 0, 0, PPI_TRIG1, 0, 0, 0, 0, 0, 0, 0, LCD_RS, 0, 0, 0, ANT_SW6, SPIMT_MISO, 0, IICMT_CLK},
  357. {0, 0, 0, SPI_MOSI, 0, 0, 0, 0, I2C_DAT, 0, 0, PPI_TRIG2, 0, 0, 0, 0, 0, 0, 0, LCD_RDE, 0, 0, 0, GIO30, SPIMT_MOSI, 0, IICMT_DAT},
  358. {0, 0, 0, SPI_CLK, 0, 0, 0, 0, 0, I2C_CLK, 0, PPI_TRIG3, 0, 0, 0, 0, 0, DMIC_CLK, 0, LCD_WR, 0, 0, 0, BT_UART_TX, SPIMT_CLK, 0, 0, IICMT_CLK},
  359. {0, 0, 0, SPI_CS, 0, 0, 0, 0, 0, I2C_DAT, 0, PPI_TRIG4, 0, 0, 0, 0, 0, DMIC_DAT, 0, LCD_TE, 0, 0, 0, BT_UART_RX, SPIMT_SS, 0, 0, IICMT_DAT, LRADC4},
  360. {0, 0, SPI_MOSI, 0, 0, 0, 0, 0, 0, 0, SD1_CLK1, PPI_TRIG0, IIS_MCLK, 0, 0, 0, 0, 0, PWM0},
  361. {0, 0, SPI_MISO, 0, 0, UART_TX, 0, 0, 0, 0, SD1_D4, PPI_TRIG1, IIS_BCLK, 0, 0, 0, 0, 0, PWM1},
  362. {0, 0, SPI_D2, 0, 0, UART_RX, 0, 0, 0, 0, SD1_D5, PPI_TRIG2, IIS_LRCLK, 0, 0, 0, 0, 0, PWM2},
  363. {0, 0, SPI_D3, 0, 0, 0, UART_TX, 0, I2C_CLK, I2C_CLK, SD1_D6, PPI_TRIG3, IIS_DOUT, 0, 0, 0, 0, 0, PWM3, 0, 0, 0, 0, 0, 0, 0, IICMT_CLK, IICMT_CLK},
  364. {0, 0, SPI_CS, SPI_MISO, 0, 0, UART_RX, 0, I2C_DAT, I2C_DAT, SD1_D7, PPI_TRIG4, 0, IIS_MCLK, 0, 0, DMIC_CLK, 0, PWM4, 0, 0, 0, 0, 0, 0, SPIMT_MISO, IICMT_DAT, IICMT_DAT},
  365. //41
  366. {0, 0, SPI_CLK_POS, SPI_MOSI, 0, 0, 0, UART_TX, 0, 0, SD1_D2, PPI_TRIG5, 0, IIS_BCLK, 0, 0, DMIC_DAT, 0, PWM5, 0, 0, 0, 0, 0, 0, SPIMT_MOSI},
  367. {0, 0, SPI_CLK_NEG, SPI_CLK, 0, 0, 0, UART_RX, 0, 0, SD1_D3, PPI_TRIG6, 0, IIS_LRCLK, 0, 0, DMIC_DAT, 0, PWM6, 0, 0, 0, 0, 0, 0, SPIMT_CLK, 0, 0, 0, TIMER2_CAP},
  368. {0, 0, SPI_D4, SPI_CS, 0, UART_CTS, 0, 0, 0, 0, SD1_CLK0, PPI_TRIG7, 0, IIS_DIN, 0, 0, 0, 0, PWM7, 0, 0, 0, 0, 0, 0, SPIMT_SS0},
  369. {0, 0, SPI_D5, 0, 0, UART_RTS, 0, 0, 0, 0, SD1_CMD, PPI_TRIG8, 0, IIS_MCLK, 0, 0, DMIC_CLK, 0, PWM8},
  370. {0, 0, SPI_D6, 0, 0, 0, 0, 0, 0, 0, SD1_D0, PPI_TRIG9, 0, IIS_BCLK, 0, 0, 0, 0, PWM7},
  371. {0, 0, SPI_D7, 0, 0, 0, 0, 0, 0, 0, SD1_D1, PPI_TRIG10, 0, IIS_LRCLK, 0, 0, 0, 0, PWM8},
  372. {0, 0, SPI_DM, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TIMER3_CAP},
  373. {0, 0, SPI_DQS, 0, 0, 0, 0, 0, 0, 0, 0, PPI_TRIG11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TIMER2_CAP},
  374. {0, 0, 0, SPI_CS, 0, 0, UART_TX, 0, 0, 0, 0, PPI_TRIG0, IIS_MCLK, 0, 0, 0, 0, 0, PWM0, 0, 0, 0, 0, BT_REQ, SPIMT_SS0, 0, IICMT_CLK},
  375. {0, 0, 0, SPI_CLK, 0, 0, UART_RX, 0, I2C_DAT, 0, 0, PPI_TRIG1, IIS_BCLK, 0, 0, 0, 0, 0, PWM1, 0, 0, 0, 0, BT_ACCESS, SPIMT_CLK, 0, IICMT_DAT},
  376. //51
  377. {0, 0, 0, SPI_MISO, 0, 0, UART_CTS, 0, 0, I2C_CLK, 0, PPI_TRIG2, IIS_LRCLK, 0, 0, 0, 0, 0, PWM2, 0, 0, 0, 0, PTA_GRANT, SPIMT_MISO, 0, 0, IICMT_CLK},
  378. {0, 0, 0, SPI_MOSI, 0, 0, UART_RTS, 0, 0, I2C_DAT, 0, PPI_TRIG3, IIS_DOUT, 0, 0, 0, 0, 0, PWM3, 0, 0, 0, 0, GIO14, SPIMT_MOSI, 0, 0, IICMT_DAT},
  379. {0, 0, 0, 0, SPI_CS, 0, 0, UART_TX, I2C_CLK, 0, 0, PPI_TRIG4, 0, IIS_MCLK, 0, 0, DMIC_CLK, 0, PWM4, 0, 0, 0, 0, GIO15, 0, SPIMT_SS0, IICMT_CLK},
  380. {0, 0, 0, 0, SPI_CLK, 0, 0, UART_RX, I2C_DAT, 0, 0, PPI_TRIG5, 0, IIS_BCLK, 0, 0, DMIC_DAT, 0, PWM5, 0, 0, 0, 0, GIO16, 0, SPIMT_CLK, IICMT_DAT},
  381. {0, 0, 0, 0, SPI_MISO, 0, 0, UART_CTS, 0, I2C_CLK, 0, PPI_TRIG6, 0, IIS_LRCLK, 0, 0, DMIC_DAT, 0, PWM6, 0, 0, 0, 0, GIO17, 0, SPIMT_MISO, 0, IICMT_CLK},
  382. {0, 0, 0, 0, SPI_MOSI, 0, 0, UART_RTS, 0, I2C_DAT, 0, PPI_TRIG7, 0, IIS_DIN, 0, SPDIF_RX_A, 0, 0, PWM7, 0, 0, 0, 0, ANT_SW0, 0, SPIMT_MOSI, 0, IICMT_DAT},
  383. {0, 0, 0, SPI_CS, 0, 0, 0, 0, I2C_CLK, 0, 0, PPI_TRIG8, 0, IIS_MCLK, 0, 0, DMIC_CLK, 0, PWM8, 0, 0, 0, 0, ANT_SW1, SPIMT_SS, 0, IICMT_CLK, 0, 0, 0, CTK0_OUT},
  384. {0, 0, 0, SPI_CLK, 0, 0, 0, 0, I2C_DAT, 0, 0, PPI_TRIG9, 0, IIS_BCLK, 0, 0, 0, 0, 0, 0, 0, 0, 0, ANT_SW2, SPIMT_CLK, 0, IICMT_DAT},
  385. {0, 0, 0, SPI_MISO, 0, 0, 0, 0, 0, I2C_CLK, 0, PPI_TRIG10, 0, IIS_LRCLK, 0, 0, 0, 0, 0, 0, 0, 0, 0, ANT_SW3, SPIMT_MISO, 0, 0, IICMT_CLK},
  386. {0, 0, 0, SPI_MOSI, 0, 0, 0, 0, 0, I2C_DAT, 0, PPI_TRIG11, 0, IIS_DIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, ANT_SW4, SPIMT_MOSI, 0, 0, IICMT_DAT},
  387. //61
  388. {0, 0, 0, 0, SPI_IO2, 0, 0, 0, 0, 0, 0, PPI_TRIG4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ANT_SW5, SPIMT_SS1, 0, 0, 0, LRADC5, TIMER2_CAP},
  389. {0, 0, 0, 0, SPI_IO3, UART_RX, UART_RX, UART_RX, 0, 0, 0, PPI_TRIG5, 0, 0, SPDIF_TX, SPDIF_RX, 0, 0, 0, 0, 0, CEC, 0, ANT_SW6, 0, SPIMT_SS1, 0, 0, LRADC6, TIMER3_CAP},
  390. {0, 0, 0, 0, 0, UART_TX, UART_TX, UART_TX, 0, 0, 0, PPI_TRIG6, 0, 0, SPDIF_TX, SPDIF_RX, 0, 0, 0, 0, 0, CEC, 0, ANT_SW7, 0, SPIMT_SS1, 0, 0, LRADC7, 0, 0, IOVCC4_OUT},
  391. {0, 0, 0, 0, 0, UART_TX, UART_TX, UART_TX, 0, 0, 0, PPI_TRIG11, 0, 0, SPDIF_TX, SPDIF_RX, 0, 0, PWM0, 0, 0, CEC, 0, GIO31},
  392. };
  393. #endif
  394. static int cmd_gpio_check(const struct shell *shell, size_t argc, char **argv)
  395. {
  396. uint8_t i;
  397. uint8_t j;
  398. uint32_t regval;
  399. uint32_t v_mfp;
  400. uint16_t pinmux[MAX_MFP_PINNUM];
  401. uint16_t pinmux_high;
  402. uint16_t pinmux_low;
  403. bool warning_flag;
  404. for (i=0; i<MAX_MFP_PINNUM; i++)
  405. {
  406. #if defined(CONFIG_SOC_SERIES_LEOPARD)
  407. if (i < WIO0)
  408. {
  409. regval = sys_read32(GPIO_REG_BASE + 4 * i);
  410. v_mfp = regval & GPIO_CTL_MFP_MASK;
  411. }
  412. else
  413. {
  414. regval = sys_read32(GPIO_REG_BASE + 444 + 4 * i);
  415. v_mfp = regval & WIO_CTL_MFP_MASK;
  416. }
  417. #else
  418. if (i < WIO0)
  419. {
  420. regval = sys_read32(GPIO_REG_BASE + 4 + 4 * i);
  421. v_mfp = regval & GPIO_CTL_MFP_MASK;
  422. }
  423. else
  424. {
  425. regval = sys_read32(GPIO_REG_BASE + 508 + 4 * i);
  426. v_mfp = regval & WIO_CTL_MFP_MASK;
  427. }
  428. #endif
  429. if (v_mfp != 0)
  430. {
  431. if (i < WIO0)
  432. {
  433. pinmux_high = (uint16_t)(v_mfp << 8);
  434. pinmux_low = MFP_TABLE[i][v_mfp];
  435. pinmux[i] = pinmux_high + pinmux_low;
  436. }
  437. else if (i == WIO0)
  438. {
  439. if(v_mfp == 2)
  440. {
  441. pinmux_high = (uint16_t)(MFP1_I2C << 8);
  442. pinmux_low = I2C_CLK;
  443. pinmux[i] = pinmux_high + pinmux_low;
  444. }
  445. else if (v_mfp == 3)
  446. {
  447. pinmux_high = (uint16_t)(ADCKEY_MFP_SEL << 8);
  448. pinmux_low = LRADC1;
  449. pinmux[i] = pinmux_high + pinmux_low;
  450. }
  451. else
  452. pinmux[i] = 0;
  453. }
  454. else if (i == WIO1)
  455. {
  456. if(v_mfp == 2)
  457. {
  458. pinmux_high = (uint16_t)(MFP1_I2C << 8);
  459. pinmux_low = I2C_DAT;
  460. pinmux[i] = pinmux_high + pinmux_low;
  461. }
  462. else if (v_mfp == 1)
  463. {
  464. pinmux_high = (uint16_t)(ADCKEY_MFP_SEL << 8);
  465. pinmux_low = LRADC1;
  466. pinmux[i] = pinmux_high + pinmux_low;
  467. }
  468. else if (v_mfp == 3)
  469. {
  470. pinmux_high = (uint16_t)(ADCKEY_MFP_SEL << 8);
  471. pinmux_low = LRADC1;
  472. pinmux[i] = pinmux_high + pinmux_low;
  473. }
  474. else if (v_mfp == 6)
  475. {
  476. pinmux_high = (uint16_t)(30 << 8);
  477. pinmux_low = LOSCOUT;
  478. pinmux[i] = pinmux_high + pinmux_low;
  479. }
  480. else
  481. pinmux[i] = 0;
  482. }
  483. else if (i == WIO2)
  484. {
  485. if(v_mfp == 2)
  486. {
  487. pinmux_high = (uint16_t)(MFP0_I2C << 8);
  488. pinmux_low = I2C_CLK;
  489. pinmux[i] = pinmux_high + pinmux_low;
  490. }
  491. else
  492. pinmux[i] = 0;
  493. }
  494. else if (i == WIO3)
  495. {
  496. if(v_mfp == 2)
  497. {
  498. pinmux_high = (uint16_t)(MFP0_I2C << 8);
  499. pinmux_low = I2C_DAT;
  500. pinmux[i] = pinmux_high + pinmux_low;
  501. }
  502. else if (v_mfp == 6)
  503. {
  504. pinmux_high = (uint16_t)(30 << 8);
  505. pinmux_low = LOSCOUT;
  506. pinmux[i] = pinmux_high + pinmux_low;
  507. }
  508. else
  509. pinmux[i] = 0;
  510. }
  511. else if (i == WIO4)
  512. {
  513. if(v_mfp == 2)
  514. {
  515. pinmux_high = (uint16_t)(MFP1_I2C << 8);
  516. pinmux_low = I2C_CLK;
  517. pinmux[i] = pinmux_high + pinmux_low;
  518. }
  519. else if (v_mfp == 6)
  520. {
  521. pinmux_high = (uint16_t)(30 << 8);
  522. pinmux_low = LOSCOUT;
  523. pinmux[i] = pinmux_high + pinmux_low;
  524. }
  525. else
  526. pinmux[i] = 0;
  527. }
  528. }
  529. else
  530. pinmux[i] = 0;
  531. }
  532. for (i=0; i<MAX_MFP_PINNUM; i++)
  533. {
  534. warning_flag = true;
  535. if (pinmux[i] != 0)
  536. {
  537. for (j=i+1; j<MAX_MFP_PINNUM; j++)
  538. {
  539. if (pinmux[j] == pinmux[i])
  540. {
  541. pinmux[j] = 0;
  542. if (warning_flag)
  543. {
  544. if (i < WIO0)
  545. printk("warning: GPIO_%d ", i);
  546. else
  547. printk("warning: WIO_%d ", i);
  548. warning_flag = false;
  549. }
  550. if (j < WIO0)
  551. printk("GPIO_%d ", j);
  552. else
  553. printk("WIO_%d ", j);
  554. }
  555. if (j == MAX_MFP_PINNUM-1 && !warning_flag)
  556. {
  557. printk("have the same function of 0x%x\n", pinmux[i] >> 8);
  558. }
  559. }
  560. }
  561. }
  562. return 0;
  563. }
  564. SHELL_CMD_REGISTER(gpio_check, NULL, "gpio_check commands", cmd_gpio_check);