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