pfc_init_g2e.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. /*
  2. * Copyright (c) 2021, Renesas Electronics Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stdint.h>
  7. #include <lib/mmio.h>
  8. #include "pfc_init_g2e.h"
  9. #include "rcar_def.h"
  10. #include "../pfc_regs.h"
  11. /* PFC */
  12. #define GPSR0_SDA4 BIT(17)
  13. #define GPSR0_SCL4 BIT(16)
  14. #define GPSR0_D15 BIT(15)
  15. #define GPSR0_D14 BIT(14)
  16. #define GPSR0_D13 BIT(13)
  17. #define GPSR0_D12 BIT(12)
  18. #define GPSR0_D11 BIT(11)
  19. #define GPSR0_D10 BIT(10)
  20. #define GPSR0_D9 BIT(9)
  21. #define GPSR0_D8 BIT(8)
  22. #define GPSR0_D7 BIT(7)
  23. #define GPSR0_D6 BIT(6)
  24. #define GPSR0_D5 BIT(5)
  25. #define GPSR0_D4 BIT(4)
  26. #define GPSR0_D3 BIT(3)
  27. #define GPSR0_D2 BIT(2)
  28. #define GPSR0_D1 BIT(1)
  29. #define GPSR0_D0 BIT(0)
  30. #define GPSR1_WE0 BIT(22)
  31. #define GPSR1_CS0 BIT(21)
  32. #define GPSR1_CLKOUT BIT(20)
  33. #define GPSR1_A19 BIT(19)
  34. #define GPSR1_A18 BIT(18)
  35. #define GPSR1_A17 BIT(17)
  36. #define GPSR1_A16 BIT(16)
  37. #define GPSR1_A15 BIT(15)
  38. #define GPSR1_A14 BIT(14)
  39. #define GPSR1_A13 BIT(13)
  40. #define GPSR1_A12 BIT(12)
  41. #define GPSR1_A11 BIT(11)
  42. #define GPSR1_A10 BIT(10)
  43. #define GPSR1_A9 BIT(9)
  44. #define GPSR1_A8 BIT(8)
  45. #define GPSR1_A7 BIT(7)
  46. #define GPSR1_A6 BIT(6)
  47. #define GPSR1_A5 BIT(5)
  48. #define GPSR1_A4 BIT(4)
  49. #define GPSR1_A3 BIT(3)
  50. #define GPSR1_A2 BIT(2)
  51. #define GPSR1_A1 BIT(1)
  52. #define GPSR1_A0 BIT(0)
  53. #define GPSR2_BIT27_REVERSED BIT(27)
  54. #define GPSR2_BIT26_REVERSED BIT(26)
  55. #define GPSR2_EX_WAIT0 BIT(25)
  56. #define GPSR2_RD_WR BIT(24)
  57. #define GPSR2_RD BIT(23)
  58. #define GPSR2_BS BIT(22)
  59. #define GPSR2_AVB_PHY_INT BIT(21)
  60. #define GPSR2_AVB_TXCREFCLK BIT(20)
  61. #define GPSR2_AVB_RD3 BIT(19)
  62. #define GPSR2_AVB_RD2 BIT(18)
  63. #define GPSR2_AVB_RD1 BIT(17)
  64. #define GPSR2_AVB_RD0 BIT(16)
  65. #define GPSR2_AVB_RXC BIT(15)
  66. #define GPSR2_AVB_RX_CTL BIT(14)
  67. #define GPSR2_RPC_RESET BIT(13)
  68. #define GPSR2_RPC_RPC_INT BIT(12)
  69. #define GPSR2_QSPI1_SSL BIT(11)
  70. #define GPSR2_QSPI1_IO3 BIT(10)
  71. #define GPSR2_QSPI1_IO2 BIT(9)
  72. #define GPSR2_QSPI1_MISO_IO1 BIT(8)
  73. #define GPSR2_QSPI1_MOSI_IO0 BIT(7)
  74. #define GPSR2_QSPI1_SPCLK BIT(6)
  75. #define GPSR2_QSPI0_SSL BIT(5)
  76. #define GPSR2_QSPI0_IO3 BIT(4)
  77. #define GPSR2_QSPI0_IO2 BIT(3)
  78. #define GPSR2_QSPI0_MISO_IO1 BIT(2)
  79. #define GPSR2_QSPI0_MOSI_IO0 BIT(1)
  80. #define GPSR2_QSPI0_SPCLK BIT(0)
  81. #define GPSR3_SD1_WP BIT(15)
  82. #define GPSR3_SD1_CD BIT(14)
  83. #define GPSR3_SD0_WP BIT(13)
  84. #define GPSR3_SD0_CD BIT(12)
  85. #define GPSR3_SD1_DAT3 BIT(11)
  86. #define GPSR3_SD1_DAT2 BIT(10)
  87. #define GPSR3_SD1_DAT1 BIT(9)
  88. #define GPSR3_SD1_DAT0 BIT(8)
  89. #define GPSR3_SD1_CMD BIT(7)
  90. #define GPSR3_SD1_CLK BIT(6)
  91. #define GPSR3_SD0_DAT3 BIT(5)
  92. #define GPSR3_SD0_DAT2 BIT(4)
  93. #define GPSR3_SD0_DAT1 BIT(3)
  94. #define GPSR3_SD0_DAT0 BIT(2)
  95. #define GPSR3_SD0_CMD BIT(1)
  96. #define GPSR3_SD0_CLK BIT(0)
  97. #define GPSR4_SD3_DS BIT(10)
  98. #define GPSR4_SD3_DAT7 BIT(9)
  99. #define GPSR4_SD3_DAT6 BIT(8)
  100. #define GPSR4_SD3_DAT5 BIT(7)
  101. #define GPSR4_SD3_DAT4 BIT(6)
  102. #define GPSR4_SD3_DAT3 BIT(5)
  103. #define GPSR4_SD3_DAT2 BIT(4)
  104. #define GPSR4_SD3_DAT1 BIT(3)
  105. #define GPSR4_SD3_DAT0 BIT(2)
  106. #define GPSR4_SD3_CMD BIT(1)
  107. #define GPSR4_SD3_CLK BIT(0)
  108. #define GPSR5_MLB_DAT BIT(19)
  109. #define GPSR5_MLB_SIG BIT(18)
  110. #define GPSR5_MLB_CLK BIT(17)
  111. #define GPSR5_SSI_SDATA9 BIT(16)
  112. #define GPSR5_MSIOF0_SS2 BIT(15)
  113. #define GPSR5_MSIOF0_SS1 BIT(14)
  114. #define GPSR5_MSIOF0_SYNC BIT(13)
  115. #define GPSR5_MSIOF0_TXD BIT(12)
  116. #define GPSR5_MSIOF0_RXD BIT(11)
  117. #define GPSR5_MSIOF0_SCK BIT(10)
  118. #define GPSR5_RX2_A BIT(9)
  119. #define GPSR5_TX2_A BIT(8)
  120. #define GPSR5_SCK2_A BIT(7)
  121. #define GPSR5_TX1 BIT(6)
  122. #define GPSR5_RX1 BIT(5)
  123. #define GPSR5_RTS0_A BIT(4)
  124. #define GPSR5_CTS0_A BIT(3)
  125. #define GPSR5_TX0_A BIT(2)
  126. #define GPSR5_RX0_A BIT(1)
  127. #define GPSR5_SCK0_A BIT(0)
  128. #define GPSR6_USB30_PWEN BIT(17)
  129. #define GPSR6_SSI_SDATA6 BIT(16)
  130. #define GPSR6_SSI_WS6 BIT(15)
  131. #define GPSR6_SSI_SCK6 BIT(14)
  132. #define GPSR6_SSI_SDATA5 BIT(13)
  133. #define GPSR6_SSI_WS5 BIT(12)
  134. #define GPSR6_SSI_SCK5 BIT(11)
  135. #define GPSR6_SSI_SDATA4 BIT(10)
  136. #define GPSR6_USB30_OVC BIT(9)
  137. #define GPSR6_AUDIO_CLKA BIT(8)
  138. #define GPSR6_SSI_SDATA3 BIT(7)
  139. #define GPSR6_SSI_WS349 BIT(6)
  140. #define GPSR6_SSI_SCK349 BIT(5)
  141. #define GPSR6_SSI_SDATA2 BIT(4)
  142. #define GPSR6_SSI_SDATA1 BIT(3)
  143. #define GPSR6_SSI_SDATA0 BIT(2)
  144. #define GPSR6_SSI_WS01239 BIT(1)
  145. #define GPSR6_SSI_SCK01239 BIT(0)
  146. #define IPSR_28_FUNC(x) ((uint32_t)(x) << 28U)
  147. #define IPSR_24_FUNC(x) ((uint32_t)(x) << 24U)
  148. #define IPSR_20_FUNC(x) ((uint32_t)(x) << 20U)
  149. #define IPSR_16_FUNC(x) ((uint32_t)(x) << 16U)
  150. #define IPSR_12_FUNC(x) ((uint32_t)(x) << 12U)
  151. #define IPSR_8_FUNC(x) ((uint32_t)(x) << 8U)
  152. #define IPSR_4_FUNC(x) ((uint32_t)(x) << 4U)
  153. #define IPSR_0_FUNC(x) ((uint32_t)(x) << 0U)
  154. #define POCCTRL0_MASK (0x0007F000U)
  155. #define POC_SD3_DS_33V BIT(29)
  156. #define POC_SD3_DAT7_33V BIT(28)
  157. #define POC_SD3_DAT6_33V BIT(27)
  158. #define POC_SD3_DAT5_33V BIT(26)
  159. #define POC_SD3_DAT4_33V BIT(25)
  160. #define POC_SD3_DAT3_33V BIT(24)
  161. #define POC_SD3_DAT2_33V BIT(23)
  162. #define POC_SD3_DAT1_33V BIT(22)
  163. #define POC_SD3_DAT0_33V BIT(21)
  164. #define POC_SD3_CMD_33V BIT(20)
  165. #define POC_SD3_CLK_33V BIT(19)
  166. #define POC_SD1_DAT3_33V BIT(11)
  167. #define POC_SD1_DAT2_33V BIT(10)
  168. #define POC_SD1_DAT1_33V BIT(9)
  169. #define POC_SD1_DAT0_33V BIT(8)
  170. #define POC_SD1_CMD_33V BIT(7)
  171. #define POC_SD1_CLK_33V BIT(6)
  172. #define POC_SD0_DAT3_33V BIT(5)
  173. #define POC_SD0_DAT2_33V BIT(4)
  174. #define POC_SD0_DAT1_33V BIT(3)
  175. #define POC_SD0_DAT0_33V BIT(2)
  176. #define POC_SD0_CMD_33V BIT(1)
  177. #define POC_SD0_CLK_33V BIT(0)
  178. #define POCCTRL2_MASK (0xFFFFFFFEU)
  179. #define POC2_VREF_33V BIT(0)
  180. #define MOD_SEL0_ADGB_A ((uint32_t)0U << 29U)
  181. #define MOD_SEL0_ADGB_B ((uint32_t)1U << 29U)
  182. #define MOD_SEL0_ADGB_C ((uint32_t)2U << 29U)
  183. #define MOD_SEL0_DRIF0_A ((uint32_t)0U << 28U)
  184. #define MOD_SEL0_DRIF0_B ((uint32_t)1U << 28U)
  185. #define MOD_SEL0_FM_A ((uint32_t)0U << 26U)
  186. #define MOD_SEL0_FM_B ((uint32_t)1U << 26U)
  187. #define MOD_SEL0_FM_C ((uint32_t)2U << 26U)
  188. #define MOD_SEL0_FSO_A ((uint32_t)0U << 25U)
  189. #define MOD_SEL0_FSO_B ((uint32_t)1U << 25U)
  190. #define MOD_SEL0_HSCIF0_A ((uint32_t)0U << 24U)
  191. #define MOD_SEL0_HSCIF0_B ((uint32_t)1U << 24U)
  192. #define MOD_SEL0_HSCIF1_A ((uint32_t)0U << 23U)
  193. #define MOD_SEL0_HSCIF1_B ((uint32_t)1U << 23U)
  194. #define MOD_SEL0_HSCIF2_A ((uint32_t)0U << 22U)
  195. #define MOD_SEL0_HSCIF2_B ((uint32_t)1U << 22U)
  196. #define MOD_SEL0_I2C1_A ((uint32_t)0U << 20U)
  197. #define MOD_SEL0_I2C1_B ((uint32_t)1U << 20U)
  198. #define MOD_SEL0_I2C1_C ((uint32_t)2U << 20U)
  199. #define MOD_SEL0_I2C1_D ((uint32_t)3U << 20U)
  200. #define MOD_SEL0_I2C2_A ((uint32_t)0U << 17U)
  201. #define MOD_SEL0_I2C2_B ((uint32_t)1U << 17U)
  202. #define MOD_SEL0_I2C2_C ((uint32_t)2U << 17U)
  203. #define MOD_SEL0_I2C2_D ((uint32_t)3U << 17U)
  204. #define MOD_SEL0_I2C2_E ((uint32_t)4U << 17U)
  205. #define MOD_SEL0_NDFC_A ((uint32_t)0U << 16U)
  206. #define MOD_SEL0_NDFC_B ((uint32_t)1U << 16U)
  207. #define MOD_SEL0_PWM0_A ((uint32_t)0U << 15U)
  208. #define MOD_SEL0_PWM0_B ((uint32_t)1U << 15U)
  209. #define MOD_SEL0_PWM1_A ((uint32_t)0U << 14U)
  210. #define MOD_SEL0_PWM1_B ((uint32_t)1U << 14U)
  211. #define MOD_SEL0_PWM2_A ((uint32_t)0U << 12U)
  212. #define MOD_SEL0_PWM2_B ((uint32_t)1U << 12U)
  213. #define MOD_SEL0_PWM2_C ((uint32_t)2U << 12U)
  214. #define MOD_SEL0_PWM3_A ((uint32_t)0U << 10U)
  215. #define MOD_SEL0_PWM3_B ((uint32_t)1U << 10U)
  216. #define MOD_SEL0_PWM3_C ((uint32_t)2U << 10U)
  217. #define MOD_SEL0_PWM4_A ((uint32_t)0U << 9U)
  218. #define MOD_SEL0_PWM4_B ((uint32_t)1U << 9U)
  219. #define MOD_SEL0_PWM5_A ((uint32_t)0U << 8U)
  220. #define MOD_SEL0_PWM5_B ((uint32_t)1U << 8U)
  221. #define MOD_SEL0_PWM6_A ((uint32_t)0U << 7U)
  222. #define MOD_SEL0_PWM6_B ((uint32_t)1U << 7U)
  223. #define MOD_SEL0_REMOCON_A ((uint32_t)0U << 5U)
  224. #define MOD_SEL0_REMOCON_B ((uint32_t)1U << 5U)
  225. #define MOD_SEL0_REMOCON_C ((uint32_t)2U << 5U)
  226. #define MOD_SEL0_SCIF_A ((uint32_t)0U << 4U)
  227. #define MOD_SEL0_SCIF_B ((uint32_t)1U << 4U)
  228. #define MOD_SEL0_SCIF0_A ((uint32_t)0U << 3U)
  229. #define MOD_SEL0_SCIF0_B ((uint32_t)1U << 3U)
  230. #define MOD_SEL0_SCIF2_A ((uint32_t)0U << 2U)
  231. #define MOD_SEL0_SCIF2_B ((uint32_t)1U << 2U)
  232. #define MOD_SEL0_SPEED_PULSE_IF_A ((uint32_t)0U << 0U)
  233. #define MOD_SEL0_SPEED_PULSE_IF_B ((uint32_t)1U << 0U)
  234. #define MOD_SEL0_SPEED_PULSE_IF_C ((uint32_t)2U << 0U)
  235. #define MOD_SEL1_SIMCARD_A ((uint32_t)0U << 31U)
  236. #define MOD_SEL1_SIMCARD_B ((uint32_t)1U << 31U)
  237. #define MOD_SEL1_SSI2_A ((uint32_t)0U << 30U)
  238. #define MOD_SEL1_SSI2_B ((uint32_t)1U << 30U)
  239. #define MOD_SEL1_TIMER_TMU_A ((uint32_t)0U << 29U)
  240. #define MOD_SEL1_TIMER_TMU_B ((uint32_t)1U << 29U)
  241. #define MOD_SEL1_USB20_CH0_A ((uint32_t)0U << 28U)
  242. #define MOD_SEL1_USB20_CH0_B ((uint32_t)1U << 28U)
  243. #define MOD_SEL1_DRIF2_A ((uint32_t)0U << 26U)
  244. #define MOD_SEL1_DRIF2_B ((uint32_t)1U << 26U)
  245. #define MOD_SEL1_DRIF3_A ((uint32_t)0U << 25U)
  246. #define MOD_SEL1_DRIF3_B ((uint32_t)1U << 25U)
  247. #define MOD_SEL1_HSCIF3_A ((uint32_t)0U << 22U)
  248. #define MOD_SEL1_HSCIF3_B ((uint32_t)1U << 22U)
  249. #define MOD_SEL1_HSCIF3_C ((uint32_t)2U << 22U)
  250. #define MOD_SEL1_HSCIF3_D ((uint32_t)3U << 22U)
  251. #define MOD_SEL1_HSCIF3_E ((uint32_t)4U << 22U)
  252. #define MOD_SEL1_HSCIF4_A ((uint32_t)0U << 19U)
  253. #define MOD_SEL1_HSCIF4_B ((uint32_t)1U << 19U)
  254. #define MOD_SEL1_HSCIF4_C ((uint32_t)2U << 19U)
  255. #define MOD_SEL1_HSCIF4_D ((uint32_t)3U << 19U)
  256. #define MOD_SEL1_HSCIF4_E ((uint32_t)4U << 19U)
  257. #define MOD_SEL1_I2C6_A ((uint32_t)0U << 18U)
  258. #define MOD_SEL1_I2C6_B ((uint32_t)1U << 18U)
  259. #define MOD_SEL1_I2C7_A ((uint32_t)0U << 17U)
  260. #define MOD_SEL1_I2C7_B ((uint32_t)1U << 17U)
  261. #define MOD_SEL1_MSIOF2_A ((uint32_t)0U << 16U)
  262. #define MOD_SEL1_MSIOF2_B ((uint32_t)1U << 16U)
  263. #define MOD_SEL1_MSIOF3_A ((uint32_t)0U << 15U)
  264. #define MOD_SEL1_MSIOF3_B ((uint32_t)1U << 15U)
  265. #define MOD_SEL1_SCIF3_A ((uint32_t)0U << 13U)
  266. #define MOD_SEL1_SCIF3_B ((uint32_t)1U << 13U)
  267. #define MOD_SEL1_SCIF3_C ((uint32_t)2U << 13U)
  268. #define MOD_SEL1_SCIF4_A ((uint32_t)0U << 11U)
  269. #define MOD_SEL1_SCIF4_B ((uint32_t)1U << 11U)
  270. #define MOD_SEL1_SCIF4_C ((uint32_t)2U << 11U)
  271. #define MOD_SEL1_SCIF5_A ((uint32_t)0U << 9U)
  272. #define MOD_SEL1_SCIF5_B ((uint32_t)1U << 9U)
  273. #define MOD_SEL1_SCIF5_C ((uint32_t)2U << 9U)
  274. #define MOD_SEL1_VIN4_A ((uint32_t)0U << 8U)
  275. #define MOD_SEL1_VIN4_B ((uint32_t)1U << 8U)
  276. #define MOD_SEL1_VIN5_A ((uint32_t)0U << 7U)
  277. #define MOD_SEL1_VIN5_B ((uint32_t)1U << 7U)
  278. #define MOD_SEL1_ADGC_A ((uint32_t)0U << 5U)
  279. #define MOD_SEL1_ADGC_B ((uint32_t)1U << 5U)
  280. #define MOD_SEL1_ADGC_C ((uint32_t)2U << 5U)
  281. #define MOD_SEL1_SSI9_A ((uint32_t)0U << 4U)
  282. #define MOD_SEL1_SSI9_B ((uint32_t)1U << 4U)
  283. static void pfc_reg_write(uint32_t addr, uint32_t data)
  284. {
  285. mmio_write_32(PFC_PMMR, ~data);
  286. mmio_write_32((uintptr_t)addr, data);
  287. }
  288. void pfc_init_g2e(void)
  289. {
  290. uint32_t reg;
  291. /* initialize module select */
  292. pfc_reg_write(PFC_MOD_SEL0,
  293. MOD_SEL0_ADGB_A |
  294. MOD_SEL0_DRIF0_A |
  295. MOD_SEL0_FM_A |
  296. MOD_SEL0_FSO_A |
  297. MOD_SEL0_HSCIF0_A |
  298. MOD_SEL0_HSCIF1_A |
  299. MOD_SEL0_HSCIF2_A |
  300. MOD_SEL0_I2C1_A |
  301. MOD_SEL0_I2C2_A |
  302. MOD_SEL0_NDFC_A |
  303. MOD_SEL0_PWM0_A |
  304. MOD_SEL0_PWM1_A |
  305. MOD_SEL0_PWM2_A |
  306. MOD_SEL0_PWM3_A |
  307. MOD_SEL0_PWM4_A |
  308. MOD_SEL0_PWM5_A |
  309. MOD_SEL0_PWM6_A |
  310. MOD_SEL0_REMOCON_A |
  311. MOD_SEL0_SCIF_A |
  312. MOD_SEL0_SCIF0_A |
  313. MOD_SEL0_SCIF2_A |
  314. MOD_SEL0_SPEED_PULSE_IF_A);
  315. pfc_reg_write(PFC_MOD_SEL1,
  316. MOD_SEL1_SIMCARD_A |
  317. MOD_SEL1_SSI2_A |
  318. MOD_SEL1_TIMER_TMU_A |
  319. MOD_SEL1_USB20_CH0_B |
  320. MOD_SEL1_DRIF2_A |
  321. MOD_SEL1_DRIF3_A |
  322. MOD_SEL1_HSCIF3_C |
  323. MOD_SEL1_HSCIF4_B |
  324. MOD_SEL1_I2C6_A |
  325. MOD_SEL1_I2C7_A |
  326. MOD_SEL1_MSIOF2_A |
  327. MOD_SEL1_MSIOF3_A |
  328. MOD_SEL1_SCIF3_A |
  329. MOD_SEL1_SCIF4_A |
  330. MOD_SEL1_SCIF5_A |
  331. MOD_SEL1_VIN4_A |
  332. MOD_SEL1_VIN5_A |
  333. MOD_SEL1_ADGC_A |
  334. MOD_SEL1_SSI9_A);
  335. /* initialize peripheral function select */
  336. pfc_reg_write(PFC_IPSR0,
  337. IPSR_28_FUNC(2) | /* HRX4_B */
  338. IPSR_24_FUNC(2) | /* HTX4_B */
  339. IPSR_20_FUNC(0) | /* QSPI1_SPCLK */
  340. IPSR_16_FUNC(0) | /* QSPI0_IO3 */
  341. IPSR_12_FUNC(0) | /* QSPI0_IO2 */
  342. IPSR_8_FUNC(0) | /* QSPI0_MISO/IO1 */
  343. IPSR_4_FUNC(0) | /* QSPI0_MOSI/IO0 */
  344. IPSR_0_FUNC(0)); /* QSPI0_SPCLK */
  345. pfc_reg_write(PFC_IPSR1,
  346. IPSR_28_FUNC(0) | /* AVB_RD2 */
  347. IPSR_24_FUNC(0) | /* AVB_RD1 */
  348. IPSR_20_FUNC(0) | /* AVB_RD0 */
  349. IPSR_16_FUNC(0) | /* RPC_RESET# */
  350. IPSR_12_FUNC(0) | /* RPC_INT# */
  351. IPSR_8_FUNC(0) | /* QSPI1_SSL */
  352. IPSR_4_FUNC(2) | /* HRX3_C */
  353. IPSR_0_FUNC(2)); /* HTX3_C */
  354. pfc_reg_write(PFC_IPSR2,
  355. IPSR_28_FUNC(1) | /* IRQ0 */
  356. IPSR_24_FUNC(0) |
  357. IPSR_20_FUNC(0) |
  358. IPSR_16_FUNC(2) | /* AVB_LINK */
  359. IPSR_12_FUNC(0) |
  360. IPSR_8_FUNC(0) | /* AVB_MDC */
  361. IPSR_4_FUNC(0) | /* AVB_MDIO */
  362. IPSR_0_FUNC(0)); /* AVB_TXCREFCLK */
  363. pfc_reg_write(PFC_IPSR3,
  364. IPSR_28_FUNC(5) | /* DU_HSYNC */
  365. IPSR_24_FUNC(0) |
  366. IPSR_20_FUNC(0) |
  367. IPSR_16_FUNC(0) |
  368. IPSR_12_FUNC(5) | /* DU_DG4 */
  369. IPSR_8_FUNC(5) | /* DU_DOTCLKOUT0 */
  370. IPSR_4_FUNC(5) | /* DU_DISP */
  371. IPSR_0_FUNC(1)); /* IRQ1 */
  372. pfc_reg_write(PFC_IPSR4,
  373. IPSR_28_FUNC(5) | /* DU_DB5 */
  374. IPSR_24_FUNC(5) | /* DU_DB4 */
  375. IPSR_20_FUNC(5) | /* DU_DB3 */
  376. IPSR_16_FUNC(5) | /* DU_DB2 */
  377. IPSR_12_FUNC(5) | /* DU_DG6 */
  378. IPSR_8_FUNC(5) | /* DU_VSYNC */
  379. IPSR_4_FUNC(5) | /* DU_DG5 */
  380. IPSR_0_FUNC(5)); /* DU_DG7 */
  381. pfc_reg_write(PFC_IPSR5,
  382. IPSR_28_FUNC(5) | /* DU_DR3 */
  383. IPSR_24_FUNC(5) | /* DU_DB7 */
  384. IPSR_20_FUNC(5) | /* DU_DR2 */
  385. IPSR_16_FUNC(5) | /* DU_DR1 */
  386. IPSR_12_FUNC(5) | /* DU_DR0 */
  387. IPSR_8_FUNC(5) | /* DU_DB1 */
  388. IPSR_4_FUNC(5) | /* DU_DB0 */
  389. IPSR_0_FUNC(5)); /* DU_DB6 */
  390. pfc_reg_write(PFC_IPSR6,
  391. IPSR_28_FUNC(5) | /* DU_DG1 */
  392. IPSR_24_FUNC(5) | /* DU_DG0 */
  393. IPSR_20_FUNC(5) | /* DU_DR7 */
  394. IPSR_16_FUNC(1) | /* CANFD1_RX */
  395. IPSR_12_FUNC(5) | /* DU_DR6 */
  396. IPSR_8_FUNC(5) | /* DU_DR5 */
  397. IPSR_4_FUNC(1) | /* CANFD1_TX */
  398. IPSR_0_FUNC(5)); /* DU_DR4 */
  399. pfc_reg_write(PFC_IPSR7,
  400. IPSR_28_FUNC(0) | /* SD0_CLK */
  401. IPSR_24_FUNC(0) |
  402. IPSR_20_FUNC(5) | /* DU_DOTCLKIN0 */
  403. IPSR_16_FUNC(5) | /* DU_DG3 */
  404. IPSR_12_FUNC(1) | /* CAN_CLK */
  405. IPSR_8_FUNC(1) | /* CANFD0_RX */
  406. IPSR_4_FUNC(1) | /* CANFD0_TX */
  407. IPSR_0_FUNC(5)); /* DU_DG2 */
  408. pfc_reg_write(PFC_IPSR8,
  409. IPSR_28_FUNC(0) | /* SD1_DAT0 */
  410. IPSR_24_FUNC(0) | /* SD1_CMD */
  411. IPSR_20_FUNC(0) | /* SD1_CLK */
  412. IPSR_16_FUNC(0) | /* SD0_DAT3 */
  413. IPSR_12_FUNC(0) | /* SD0_DAT2 */
  414. IPSR_8_FUNC(0) | /* SD0_DAT1 */
  415. IPSR_4_FUNC(0) | /* SD0_DAT0 */
  416. IPSR_0_FUNC(0)); /* SD0_CMD */
  417. pfc_reg_write(PFC_IPSR9,
  418. IPSR_28_FUNC(0) | /* SD3_DAT2 */
  419. IPSR_24_FUNC(0) | /* SD3_DAT1 */
  420. IPSR_20_FUNC(0) | /* SD3_DAT0 */
  421. IPSR_16_FUNC(0) | /* SD3_CMD */
  422. IPSR_12_FUNC(0) | /* SD3_CLK */
  423. IPSR_8_FUNC(0) | /* SD1_DAT3 */
  424. IPSR_4_FUNC(0) | /* SD1_DAT2 */
  425. IPSR_0_FUNC(0)); /* SD1_DAT1 */
  426. pfc_reg_write(PFC_IPSR10,
  427. IPSR_24_FUNC(0) | /* SD0_CD */
  428. IPSR_20_FUNC(0) | /* SD3_DS */
  429. IPSR_16_FUNC(0) | /* SD3_DAT7 */
  430. IPSR_12_FUNC(0) | /* SD3_DAT6 */
  431. IPSR_8_FUNC(0) | /* SD3_DAT5 */
  432. IPSR_4_FUNC(0) | /* SD3_DAT4 */
  433. IPSR_0_FUNC(0)); /* SD3_DAT3 */
  434. pfc_reg_write(PFC_IPSR11,
  435. IPSR_28_FUNC(0) |
  436. IPSR_24_FUNC(8) | /* USB0_ID */
  437. IPSR_20_FUNC(2) | /* AUDIO_CLKOUT1_A */
  438. IPSR_16_FUNC(0) | /* CTS0#_A */
  439. IPSR_12_FUNC(0) |
  440. IPSR_8_FUNC(0) |
  441. IPSR_4_FUNC(0) | /* SD1_WP */
  442. IPSR_0_FUNC(0)); /* SD1_CD */
  443. pfc_reg_write(PFC_IPSR12,
  444. IPSR_28_FUNC(0) |
  445. IPSR_24_FUNC(0) |
  446. IPSR_20_FUNC(0) |
  447. IPSR_16_FUNC(0) |
  448. IPSR_12_FUNC(0) | /* RX2_A */
  449. IPSR_8_FUNC(0) | /* TX2_A */
  450. IPSR_4_FUNC(0) | /* SCK2_A */
  451. IPSR_0_FUNC(0));
  452. pfc_reg_write(PFC_IPSR13,
  453. IPSR_28_FUNC(0) |
  454. IPSR_24_FUNC(0) |
  455. IPSR_20_FUNC(0) |
  456. IPSR_16_FUNC(4) | /* SDA1_B */
  457. IPSR_12_FUNC(4) | /* SCL1_B */
  458. IPSR_8_FUNC(0) | /* SSI_SDATA9 */
  459. IPSR_4_FUNC(1) | /* HTX2_A */
  460. IPSR_0_FUNC(1)); /* HRX2_A */
  461. pfc_reg_write(PFC_IPSR14,
  462. IPSR_28_FUNC(0) | /* SSI_SCK5 */
  463. IPSR_24_FUNC(0) | /* SSI_SDATA4 */
  464. IPSR_20_FUNC(0) | /* SSI_SDATA3 */
  465. IPSR_16_FUNC(0) | /* SSI_WS349 */
  466. IPSR_12_FUNC(0) | /* SSI_SCK349 */
  467. IPSR_8_FUNC(0) |
  468. IPSR_4_FUNC(0) | /* SSI_SDATA1 */
  469. IPSR_0_FUNC(0));/* SSI_SDATA0 */
  470. pfc_reg_write(PFC_IPSR15,
  471. IPSR_28_FUNC(0) | /* USB30_OVC */
  472. IPSR_24_FUNC(0) | /* USB30_PWEN */
  473. IPSR_20_FUNC(0) | /* AUDIO_CLKA */
  474. IPSR_16_FUNC(1) | /* HRTS2#_A */
  475. IPSR_12_FUNC(1) | /* HCTS2#_A */
  476. IPSR_8_FUNC(3) | /* TPU0TO1 */
  477. IPSR_4_FUNC(3) | /* TPU0TO0 */
  478. IPSR_0_FUNC(0)); /* SSI_WS5 */
  479. /* initialize GPIO/peripheral function select */
  480. pfc_reg_write(PFC_GPSR0,
  481. GPSR0_SCL4 |
  482. GPSR0_D15 |
  483. GPSR0_D14 |
  484. GPSR0_D13 |
  485. GPSR0_D12 |
  486. GPSR0_D11 |
  487. GPSR0_D10 |
  488. GPSR0_D9 |
  489. GPSR0_D8 |
  490. GPSR0_D7 |
  491. GPSR0_D6 |
  492. GPSR0_D5 |
  493. GPSR0_D4 |
  494. GPSR0_D3 |
  495. GPSR0_D2 |
  496. GPSR0_D1 |
  497. GPSR0_D0);
  498. pfc_reg_write(PFC_GPSR1,
  499. GPSR1_WE0 |
  500. GPSR1_CS0 |
  501. GPSR1_A19 |
  502. GPSR1_A18 |
  503. GPSR1_A17 |
  504. GPSR1_A16 |
  505. GPSR1_A15 |
  506. GPSR1_A14 |
  507. GPSR1_A13 |
  508. GPSR1_A12 |
  509. GPSR1_A11 |
  510. GPSR1_A10 |
  511. GPSR1_A9 |
  512. GPSR1_A8 |
  513. GPSR1_A4 |
  514. GPSR1_A3 |
  515. GPSR1_A2 |
  516. GPSR1_A1 |
  517. GPSR1_A0);
  518. pfc_reg_write(PFC_GPSR2,
  519. GPSR2_BIT27_REVERSED |
  520. GPSR2_BIT26_REVERSED |
  521. GPSR2_AVB_PHY_INT |
  522. GPSR2_AVB_TXCREFCLK |
  523. GPSR2_AVB_RD3 |
  524. GPSR2_AVB_RD2 |
  525. GPSR2_AVB_RD1 |
  526. GPSR2_AVB_RD0 |
  527. GPSR2_AVB_RXC |
  528. GPSR2_AVB_RX_CTL |
  529. GPSR2_RPC_RESET |
  530. GPSR2_RPC_RPC_INT |
  531. GPSR2_QSPI1_IO3 |
  532. GPSR2_QSPI1_IO2 |
  533. GPSR2_QSPI1_MISO_IO1 |
  534. GPSR2_QSPI1_MOSI_IO0 |
  535. GPSR2_QSPI0_SSL |
  536. GPSR2_QSPI0_IO3 |
  537. GPSR2_QSPI0_IO2 |
  538. GPSR2_QSPI0_MISO_IO1 |
  539. GPSR2_QSPI0_MOSI_IO0 |
  540. GPSR2_QSPI0_SPCLK);
  541. pfc_reg_write(PFC_GPSR3,
  542. GPSR3_SD0_CD |
  543. GPSR3_SD1_DAT3 |
  544. GPSR3_SD1_DAT2 |
  545. GPSR3_SD1_DAT1 |
  546. GPSR3_SD1_DAT0 |
  547. GPSR3_SD1_CMD |
  548. GPSR3_SD1_CLK |
  549. GPSR3_SD0_DAT3 |
  550. GPSR3_SD0_DAT2 |
  551. GPSR3_SD0_DAT1 |
  552. GPSR3_SD0_DAT0 |
  553. GPSR3_SD0_CMD |
  554. GPSR3_SD0_CLK);
  555. pfc_reg_write(PFC_GPSR4,
  556. GPSR4_SD3_DAT3 |
  557. GPSR4_SD3_DAT2 |
  558. GPSR4_SD3_DAT1 |
  559. GPSR4_SD3_DAT0 |
  560. GPSR4_SD3_CMD |
  561. GPSR4_SD3_CLK);
  562. pfc_reg_write(PFC_GPSR5,
  563. GPSR5_MLB_SIG |
  564. GPSR5_MLB_CLK |
  565. GPSR5_SSI_SDATA9 |
  566. GPSR5_MSIOF0_SS2 |
  567. GPSR5_MSIOF0_SS1 |
  568. GPSR5_MSIOF0_SYNC |
  569. GPSR5_MSIOF0_TXD |
  570. GPSR5_MSIOF0_RXD |
  571. GPSR5_MSIOF0_SCK |
  572. GPSR5_RX2_A |
  573. GPSR5_TX2_A |
  574. GPSR5_RTS0_A |
  575. GPSR5_SCK0_A);
  576. pfc_reg_write(PFC_GPSR6,
  577. GPSR6_USB30_PWEN |
  578. GPSR6_SSI_SDATA6 |
  579. GPSR6_SSI_WS6 |
  580. GPSR6_SSI_SCK6 |
  581. GPSR6_SSI_SDATA5 |
  582. GPSR6_SSI_SCK5 |
  583. GPSR6_SSI_SDATA4 |
  584. GPSR6_USB30_OVC |
  585. GPSR6_AUDIO_CLKA |
  586. GPSR6_SSI_SDATA3 |
  587. GPSR6_SSI_WS349 |
  588. GPSR6_SSI_SCK349 |
  589. GPSR6_SSI_SDATA0 |
  590. GPSR6_SSI_WS01239 |
  591. GPSR6_SSI_SCK01239);
  592. /* initialize POC control */
  593. reg = mmio_read_32(PFC_POCCTRL0);
  594. reg = (reg & POCCTRL0_MASK) |
  595. POC_SD1_DAT3_33V |
  596. POC_SD1_DAT2_33V |
  597. POC_SD1_DAT1_33V |
  598. POC_SD1_DAT0_33V |
  599. POC_SD1_CMD_33V |
  600. POC_SD1_CLK_33V |
  601. POC_SD0_DAT3_33V |
  602. POC_SD0_DAT2_33V |
  603. POC_SD0_DAT1_33V |
  604. POC_SD0_DAT0_33V |
  605. POC_SD0_CMD_33V |
  606. POC_SD0_CLK_33V;
  607. pfc_reg_write(PFC_POCCTRL0, reg);
  608. reg = mmio_read_32(PFC_POCCTRL2);
  609. reg = ((reg & POCCTRL2_MASK) & ~POC2_VREF_33V);
  610. pfc_reg_write(PFC_POCCTRL2, reg);
  611. /* initialize LSI pin pull-up/down control */
  612. pfc_reg_write(PFC_PUD0, 0x00080000U);
  613. pfc_reg_write(PFC_PUD1, 0xCE398464U);
  614. pfc_reg_write(PFC_PUD2, 0xA4C380F4U);
  615. pfc_reg_write(PFC_PUD3, 0x0000079FU);
  616. pfc_reg_write(PFC_PUD4, 0xFFF0FFFFU);
  617. pfc_reg_write(PFC_PUD5, 0x40000000U);
  618. /* initialize LSI pin pull-enable register */
  619. pfc_reg_write(PFC_PUEN0, 0x00000000U);
  620. pfc_reg_write(PFC_PUEN1, 0x00300000U);
  621. pfc_reg_write(PFC_PUEN2, 0x00400074U);
  622. pfc_reg_write(PFC_PUEN3, 0x00000000U);
  623. pfc_reg_write(PFC_PUEN4, 0x07900600U);
  624. pfc_reg_write(PFC_PUEN5, 0x00000000U);
  625. /* initialize positive/negative logic select */
  626. mmio_write_32(GPIO_POSNEG0, 0x00000000U);
  627. mmio_write_32(GPIO_POSNEG1, 0x00000000U);
  628. mmio_write_32(GPIO_POSNEG2, 0x00000000U);
  629. mmio_write_32(GPIO_POSNEG3, 0x00000000U);
  630. mmio_write_32(GPIO_POSNEG4, 0x00000000U);
  631. mmio_write_32(GPIO_POSNEG5, 0x00000000U);
  632. mmio_write_32(GPIO_POSNEG6, 0x00000000U);
  633. /* initialize general IO/interrupt switching */
  634. mmio_write_32(GPIO_IOINTSEL0, 0x00000000U);
  635. mmio_write_32(GPIO_IOINTSEL1, 0x00000000U);
  636. mmio_write_32(GPIO_IOINTSEL2, 0x00000000U);
  637. mmio_write_32(GPIO_IOINTSEL3, 0x00000000U);
  638. mmio_write_32(GPIO_IOINTSEL4, 0x00000000U);
  639. mmio_write_32(GPIO_IOINTSEL5, 0x00000000U);
  640. mmio_write_32(GPIO_IOINTSEL6, 0x00000000U);
  641. /* initialize general output register */
  642. mmio_write_32(GPIO_OUTDT0, 0x00000000U);
  643. mmio_write_32(GPIO_OUTDT1, 0x00000000U);
  644. mmio_write_32(GPIO_OUTDT2, 0x00000000U);
  645. mmio_write_32(GPIO_OUTDT3, 0x00006000U);
  646. mmio_write_32(GPIO_OUTDT5, 0x00000000U);
  647. mmio_write_32(GPIO_OUTDT6, 0x00000000U);
  648. /* initialize general input/output switching */
  649. mmio_write_32(GPIO_INOUTSEL0, 0x00020000U);
  650. mmio_write_32(GPIO_INOUTSEL1, 0x00100000U);
  651. mmio_write_32(GPIO_INOUTSEL2, 0x03000000U);
  652. mmio_write_32(GPIO_INOUTSEL3, 0x0000E000U);
  653. mmio_write_32(GPIO_INOUTSEL4, 0x00000440U);
  654. mmio_write_32(GPIO_INOUTSEL5, 0x00080000U);
  655. mmio_write_32(GPIO_INOUTSEL6, 0x00000010U);
  656. }