blob: 40128f170a280e285c7c825aaf394b14a82a40aa [file] [log] [blame]
Christophe Leroydac3c6f2022-10-14 12:54:50 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2010-2020 CS Group
4 * Charles Frey <charles.frey@c-s.fr>
5 * Florent Trinh Thai <florent.trinh-thai@c-s.fr>
6 * Christophe Leroy <christophe.leroy@c-s.fr>
7 *
8 * Board specific routines for the CMPC885 board
9 */
10
11#include <env.h>
12#include <common.h>
13#include <mpc8xx.h>
14#include <asm/io.h>
15#include <dm.h>
16#include <stdio.h>
17#include <stdarg.h>
18#include <watchdog.h>
19#include <serial.h>
20#include <hang.h>
21#include <flash.h>
22#include <init.h>
23#include <fdt_support.h>
24#include <linux/delay.h>
Christophe Leroydac3c6f2022-10-14 12:54:50 +020025#include <spi.h>
26
Christophe Leroy3155b0a2023-04-04 12:42:15 +020027#include "../common/common.h"
28
Christophe Leroydac3c6f2022-10-14 12:54:50 +020029DECLARE_GLOBAL_DATA_PTR;
30
Christophe Leroydac3c6f2022-10-14 12:54:50 +020031#define ADDR_CPLD_R_RESET ((unsigned short __iomem *)CONFIG_CPLD_BASE)
32#define ADDR_CPLD_R_ETAT ((unsigned short __iomem *)(CONFIG_CPLD_BASE + 2))
33#define ADDR_CPLD_R_TYPE ((unsigned char __iomem *)(CONFIG_CPLD_BASE + 3))
34
Christophe Leroy6a8c36b2023-01-30 09:07:38 +010035#define PATH_PHY2 "/soc@ff000000/mdio@e00/ethernet-phy@2"
36#define PATH_PHY3 "/soc@ff000000/mdio@e00/ethernet-phy@3"
37#define PATH_ETH1 "/soc@ff000000/ethernet@1e00"
38#define FIBER_PHY PATH_PHY2
Christophe Leroydac3c6f2022-10-14 12:54:50 +020039
Christophe Leroydac3c6f2022-10-14 12:54:50 +020040#define R_ETAT_PRES_BASE 0x0040
41
42#define R_RESET_STATUS 0x0400
43#define R_RST_STATUS 0x0004
44
45int ft_board_setup(void *blob, struct bd_info *bd)
46{
47 const char *sync = "receive";
48
49 ft_cpu_setup(blob, bd);
50
51 /* BRG */
Christophe Leroy6a8c36b2023-01-30 09:07:38 +010052 do_fixup_by_path_u32(blob, "/soc/cpm", "brg-frequency", bd->bi_busfreq, 1);
53
Christophe Leroydac3c6f2022-10-14 12:54:50 +020054 /* MAC addr */
55 fdt_fixup_ethernet(blob);
56
57 /* Bus Frequency for CPM */
58 do_fixup_by_path_u32(blob, "/soc", "bus-frequency", bd->bi_busfreq, 1);
59
60 /* E1 interface - Set data rate */
61 do_fixup_by_path_u32(blob, "/localbus/e1", "data-rate", 2, 1);
62
63 /* E1 interface - Set channel phase to 0 */
64 do_fixup_by_path_u32(blob, "/localbus/e1", "channel-phase", 0, 1);
65
66 /* E1 interface - rising edge sync pulse transmit */
Christophe Leroy6a8c36b2023-01-30 09:07:38 +010067 do_fixup_by_path(blob, "/localbus/e1", "rising-edge-sync-pulse", sync, strlen(sync), 1);
68
69 /* MIAE only */
Christophe Leroy78ba7b62023-04-05 18:50:23 +020070 if (!(in_be16(ADDR_CPLD_R_ETAT) & R_ETAT_PRES_BASE))
Christophe Leroy6a8c36b2023-01-30 09:07:38 +010071 return 0;
72
Christophe Leroy78ba7b62023-04-05 18:50:23 +020073 return ft_board_setup_common(blob);
74}
Christophe Leroy6a8c36b2023-01-30 09:07:38 +010075
Christophe Leroy78ba7b62023-04-05 18:50:23 +020076void ft_board_setup_phy3(void)
77{
78 /* switch to phy3 with gpio, we'll only use phy3 */
79 immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR;
80 cpm8xx_t __iomem *cp = (cpm8xx_t __iomem *)&immr->im_cpm;
Christophe Leroy6a8c36b2023-01-30 09:07:38 +010081
Christophe Leroy78ba7b62023-04-05 18:50:23 +020082 setbits_be32(&cp->cp_pedat, 0x00002000);
Christophe Leroydac3c6f2022-10-14 12:54:50 +020083}
84
85int checkboard(void)
86{
87 serial_puts("Board: ");
88
89 /* Is a motherboard present ? */
Christophe Leroy78ba7b62023-04-05 18:50:23 +020090 if (in_be16(ADDR_CPLD_R_ETAT) & R_ETAT_PRES_BASE)
91 return checkboard_common();
Christophe Leroy6a8c36b2023-01-30 09:07:38 +010092
Christophe Leroy78ba7b62023-04-05 18:50:23 +020093 printf("CMPC885 (CS GROUP)\n");
Christophe Leroy6a8c36b2023-01-30 09:07:38 +010094
Christophe Leroydac3c6f2022-10-14 12:54:50 +020095 return 0;
96}
97
Christophe Leroydac3c6f2022-10-14 12:54:50 +020098#define MAX_SPI_BYTES 0x20
99
Christophe Leroy4b6a5382023-04-05 16:05:36 +0200100#define EE_OFF_MAC1 0x10
101#define EE_OFF_MAC2 0x16
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200102
103/* Reads MAC addresses from SPI EEPROM */
104static int setup_mac(void)
105{
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200106 uchar din[MAX_SPI_BYTES];
Christophe Leroy4b6a5382023-04-05 16:05:36 +0200107 int ret;
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200108 unsigned long ident = 0x08005120;
109
Christophe Leroy4b6a5382023-04-05 16:05:36 +0200110 ret = read_eeprom(din, sizeof(din));
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200111 if (ret)
112 return ret;
113
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200114 if (memcmp(din + EE_OFF_MAC1, &ident, sizeof(ident)) == 0)
115 eth_env_set_enetaddr("ethaddr", din + EE_OFF_MAC1);
116
117 if (memcmp(din + EE_OFF_MAC2, &ident, sizeof(ident)) == 0)
118 eth_env_set_enetaddr("eth1addr", din + EE_OFF_MAC2);
119
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200120 return 0;
121}
122
123int misc_init_r(void)
124{
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200125 /* Verify mother board presence */
126 if (in_be16(ADDR_CPLD_R_ETAT) & R_ETAT_PRES_BASE) {
Christophe Leroy78ba7b62023-04-05 18:50:23 +0200127 misc_init_r_common();
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200128 } else {
Christophe Leroy78ba7b62023-04-05 18:50:23 +0200129 env_set("config", CFG_BOARD_CMPCXXX);
130 env_set("hostname", CFG_BOARD_CMPCXXX);
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200131 }
132
133 if (setup_mac())
134 printf("Error retrieving mac addresses\n");
135
136 /* Protection ON by default */
137 flash_protect(FLAG_PROTECT_SET, CFG_SYS_FLASH_BASE, 0xffffffff, &flash_info[0]);
138
139 return 0;
140}
141
Christophe Leroy78ba7b62023-04-05 18:50:23 +0200142void iop_setup_mcr(void)
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200143{
144 immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR;
145 iop8xx_t __iomem *iop = &immr->im_ioport;
146 cpm8xx_t __iomem *cp = &immr->im_cpm;
147
148 /* Wait reset on FPGA_F */
149 udelay(100);
150
151 /* We must initialize data before changing direction */
152 setbits_be16(&iop->iop_pcdat, 0x088E);
153 setbits_be16(&iop->iop_pddat, 0x0001);
154 setbits_be32(&cp->cp_pbdat, 0x00029510);
155 setbits_be32(&cp->cp_pedat, 0x00000002);
156
157 /*
158 * PAPAR[13] = 0 [0x0004] -> GPIO: ()
159 * PAPAR[12] = 0 [0x0008] -> GPIO: ()
160 * PAPAR[9] = 1 [0x0040] -> GPIO: (PCM_IN_12_MPC)
161 * PAPAR[8] = 1 [0x0080] -> GPIO: (PCM_OUT_12_MPC)
162 * PAPAR[7] = 1 [0x0100] -> GPIO: (TDM_BCLK_MPC)
163 * PAPAR[6] = 1 [0x0200] -> GPIO: (CLK2)
164 */
165 clrsetbits_be16(&iop->iop_papar, 0x03CC, 0x03C0);
166
167 /*
168 * PBODR[16] = 1 [0x00008000] -> GPIO: (PROG_FPGA_MEZZ)
169 */
170 setbits_be16(&cp->cp_pbodr, 0x00008000);
171
172 /*
173 * PBDIR[27] = 1 [0x00000010] -> GPIO: (WR_TEMP2)
174 * PBDIR[26] = 1 [0x00000020] -> GPIO: (BRG02)
175 * PBDIR[23] = 1 [0x00000100] -> GPIO: (CS_TEMP2)
176 * PBDIR[18] = 1 [0x00002000] -> GPIO: (RTS2)
177 * PBDIR[16] = 1 [0x00008000] -> GPIO: (PROG_FPGA_MEZZ)
178 * PBDIR[15] = 1 [0x00010000] -> GPIO: (BRG03)
179 * PBDIR[14] = 1 [0x00020000] -> GPIO: (CS_TEMP)
180 */
181 setbits_be32(&cp->cp_pbdir, 0x0003A130);
182
183 /*
184 * PBPAR[20] = 1 [0x00000800] -> GPIO: (SMRXD2)
185 * PBPAR[17] = 0 [0x00004000] -> GPIO: (DONE_FPGA_MEZZ)
186 * PBPAR[16] = 0 [0x00008000] -> GPIO: (PROG_FPGA_MEZZ)
187 */
188 clrsetbits_be32(&cp->cp_pbpar, 0x0000C800, 0x00000800);
189
190 /*
191 * PCPAR[14] = 0 [0x0002] -> GPIO: (CS_POT2)
192 */
193 clrbits_be16(&iop->iop_pcpar, 0x0002);
194
195 /*
196 * PDPAR[14] = 1 [0x0002] -> GPIO: (TDM_FS_MPC)
197 * PDPAR[11] = 1 [0x0010] -> GPIO: (RXD3)
198 * PDPAR[10] = 1 [0x0020] -> GPIO: (TXD3)
199 * PDPAR[9] = 1 [0x0040] -> GPIO: (TXD4)
200 * PDPAR[7] = 1 [0x0100] -> GPIO: (RTS3)
201 * PDPAR[5] = 1 [0x0400] -> GPIO: (CLK8)
202 * PDPAR[3] = 1 [0x1000] -> GPIO: (CLK7)
203 */
204 setbits_be16(&iop->iop_pdpar, 0x1572);
205
206 /*
207 * PEPAR[27] = 1 [0x00000010] -> GPIO: (R2_RXER)
208 * PEPAR[26] = 1 [0x00000020] -> GPIO: (R2_CRS_DV)
209 * PEPAR[25] = 1 [0x00000040] -> GPIO: (RXD4)
210 * PEPAR[24] = 1 [0x00000080] -> GPIO: (BRG01)
211 * PEPAR[23] = 0 [0x00000100] -> GPIO: (DONE_FPGA_RADIO)
212 * PEPAR[22] = 1 [0x00000200] -> GPIO: (R2_RXD1)
213 * PEPAR[21] = 1 [0x00000400] -> GPIO: (R2_RXD0)
214 * PEPAR[20] = 1 [0x00000800] -> GPIO: (SMTXD2)
215 * PEPAR[19] = 1 [0x00001000] -> GPIO: (R2_TXEN)
216 * PEPAR[17] = 1 [0x00004000] -> GPIO: (CLK5)
217 * PEPAR[16] = 1 [0x00008000] -> GPIO: (R2_REF_CLK)
218 * PEPAR[15] = 1 [0x00010000] -> GPIO: (R2_TXD1)
219 * PEPAR[14] = 1 [0x00020000] -> GPIO: (R2_TXD0)
220 */
221 clrsetbits_be32(&cp->cp_pepar, 0x0003DFF0, 0x0003DEF0);
222
223 /*
224 * PADIR[9] = 1 [0x0040] -> GPIO: (PCM_IN_12_MPC)
225 * PADIR[8] = 1 [0x0080] -> GPIO: (PCM_OUT_12_MPC)
226 * PADIR[5] = 1 [0x0400] -> GPIO: ()
227 */
228 setbits_be16(&iop->iop_padir, 0x04C0);
229
230 /*
231 * PCDIR[15] = 1 [0x0001] -> GPIO: (WP_EEPROM2)
232 * PCDIR[14] = 1 [0x0002] -> GPIO: (CS_POT2)
233 * PCDIR[13] = 1 [0x0004] -> GPIO: (CS_POT1)
234 * PCDIR[12] = 1 [0x0008] -> GPIO: (CS_EEPROM2)
235 * PCDIR[8] = 1 [0x0080] -> GPIO: (CS_CODEC_FAV)
236 * PCDIR[4] = 1 [0x0800] -> GPIO: (CS_CODEC_RADIO)
237 */
238 setbits_be16(&iop->iop_pcdir, 0x088F);
239
240 /*
241 * PDDIR[9] = 1 [0x0040] -> GPIO: (TXD4)
242 * PDDIR[6] = 0 [0x0200] -> GPIO: (INIT_FPGA_RADIO)
243 * PDDIR[2] = x [0x2000] -> Reserved
244 * PDDIR[1] = 0 [0x4000] -> ODR for PD10 : (TXD3)
245 * PDDIR[0] = 0 [0x8000] -> ODR for PD8 : (R_MDC)
246 */
247 clrsetbits_be16(&iop->iop_pddir, 0xC240, 0x0040);
248
249 /*
250 * PEDIR[30] = 1 [0x00000002] -> GPIO: (FPGA_FIRMWARE)
251 * PEDIR[27] = 1 [0x00000010] -> GPIO: (R2_RXER)
252 * PEDIR[26] = 1 [0x00000020] -> GPIO: (R2_CRS_DV)
253 * PEDIR[23] = 0 [0x00000100] -> GPIO: (DONE_FPGA_RADIO)
254 * PEDIR[22] = 1 [0x00000200] -> GPIO: (R2_RXD1)
255 * PEDIR[21] = 1 [0x00000400] -> GPIO: (R2_RXD0)
256 * PEDIR[19] = 1 [0x00001000] -> GPIO: (R2_TXEN)
257 * PEDIR[18] = 1 [0x00002000] -> GPIO: (PROG_FPGA_RADIO)
258 * PEDIR[16] = 1 [0x00008000] -> GPIO: (R2_REF_CLK)
259 * PEDIR[15] = 1 [0x00010000] -> GPIO: (R2_TXD1)
260 * PEDIR[14] = 1 [0x00020000] -> GPIO: (R2_TXD0)
261 */
262 clrsetbits_be32(&cp->cp_pedir, 0x0003B732, 0x0003B632);
263
264 /*
265 * PAODR[10] = 1 [0x0020] -> GPIO: (INIT_FPGA_F)
266 */
267 setbits_be16(&iop->iop_paodr, 0x0020); // set_bit
268
269 /*
270 * PEODR[30] = 1 [0x00000002] -> GPIO: (FPGA_FIRMWARE)
271 * PEODR[18] = 1 [0x00002000] -> GPIO: (FPGA_RADIO)
272 */
273 setbits_be32(&cp->cp_peodr, 0x00002002);
274
275 /*
276 * PESO[24] = 1 [0x00000080] -> GPIO: (BRG01)
277 * PESO[23] = 0 [0x00000100] -> GPIO: (DONE_FPGA_RADIO)
278 * PESO[20] = 1 [0x00000800] -> GPIO: (SMTXD2)
279 * PESO[19] = 1 [0x00001000] -> GPIO: (R2_TXEN)
280 * PESO[15] = 1 [0x00010000] -> GPIO: (R2_TXD1)
281 * PESO[14] = 1 [0x00020000] -> GPIO: (R2_TXD0)
282 */
283 clrsetbits_be32(&cp->cp_peso, 0x00031980, 0x00031880);
284
285 /* Disable CS for device */
286 /* PROGFPGA down */
287 clrbits_be32(&cp->cp_pbdat, 0x00008000);
288
289 /* PROGFPGA down */
290 clrbits_be32(&cp->cp_pedat, 0x00002000);
291 udelay(1); /* Wait more than 300ns */
292
293 /*
294 * We do not set the PROG signal of the C4E1 because
295 * there is a conflic with the CS of the EEPROM.
296 * I don't know why there is not the same problem
297 * with the FPGA_R
298 */
299
300 /* PROGFPGA up */
301 setbits_be32(&cp->cp_pedat, 0x00002000);
302}
303
304static void iop_setup_cmpc885(void)
305{
306 immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR;
307 iop8xx_t __iomem *iop = &immr->im_ioport;
308 cpm8xx_t __iomem *cp = &immr->im_cpm;
309
310 /* We must initialize data before changing direction */
311 out_be16(&iop->iop_pcdat, 0x0000);
312 out_be16(&iop->iop_pddat, 0x0001);
313
314 out_be32(&cp->cp_pbdat, 0x00021400);
315 out_be32(&cp->cp_pedat, 0x00000000);
316
317 /*
318 * PAPAR[13] = 0 [0x0004] -> GPIO: ()
319 * PAPAR[12] = 0 [0x0008] -> GPIO: ()
320 * PAPAR[9] = 0 [0x0040] -> GPIO: ()
321 * PAPAR[8] = 0 [0x0080] -> GPIO: ()
322 * PAPAR[7] = 0 [0x0100] -> GPIO: ()
323 * PAPAR[6] = 0 [0x0200] -> GPIO: ()
324 */
325 clrbits_be16(&iop->iop_papar, 0x03CC);
326
327 /*
328 * PBPAR[20] = 0 [0x00000800] -> GPIO: ()
329 * PBPAR[17] = 0 [0x00004000] -> GPIO: ()
330 * PBPAR[16] = 0 [0x00008000] -> GPIO: ()
331 */
332 clrbits_be32(&cp->cp_pbpar, 0x0000C800);
333
334 /*
335 * PCPAR[14] = 0 [0x0002] -> GPIO: ()
336 */
337 clrbits_be16(&iop->iop_pcpar, 0x0002);
338
339 /*
340 * PDPAR[14] = 0 [0x0002] -> GPIO: ()
341 * PDPAR[11] = 0 [0x0010] -> GPIO: ()
342 * PDPAR[10] = 0 [0x0020] -> GPIO: ()
343 * PDPAR[9] = 0 [0x0040] -> GPIO: ()
344 * PDPAR[7] = 0 [0x0100] -> GPIO: ()
345 * PDPAR[5] = 0 [0x0400] -> GPIO: ()
346 * PDPAR[3] = 0 [0x1000] -> GPIO: ()
347 */
348 clrbits_be16(&iop->iop_pdpar, 0x1572);
349
350 /*
351 * PEPAR[27] = 0 [0x00000010] -> GPIO: ()
352 * PEPAR[26] = 0 [0x00000020] -> GPIO: ()
353 * PEPAR[25] = 0 [0x00000040] -> GPIO: ()
354 * PEPAR[24] = 0 [0x00000080] -> GPIO: ()
355 * PEPAR[23] = 0 [0x00000100] -> GPIO: ()
356 * PEPAR[22] = 0 [0x00000200] -> GPIO: ()
357 * PEPAR[21] = 0 [0x00000400] -> GPIO: ()
358 * PEPAR[20] = 0 [0x00000800] -> GPIO: ()
359 * PEPAR[19] = 0 [0x00001000] -> GPIO: ()
360 * PEPAR[17] = 0 [0x00004000] -> GPIO: ()
361 * PEPAR[16] = 0 [0x00008000] -> GPIO: ()
362 * PEPAR[15] = 0 [0x00010000] -> GPIO: ()
363 * PEPAR[14] = 0 [0x00020000] -> GPIO: ()
364 */
365 clrbits_be32(&cp->cp_pepar, 0x0003DFF0);
366
367 /*
368 * PADIR[9] = 0 [0x0040] -> GPIO: ()
369 * PADIR[8] = 0 [0x0080] -> GPIO: ()
370 * PADIR[5] = 0 [0x0400] -> GPIO: ()
371 */
372 clrbits_be16(&iop->iop_padir, 0x04C0);
373
374 /*
375 * In/Out or per. Function 0/1
376 * PBDIR[27] = 0 [0x00000010] -> GPIO: ()
377 * PBDIR[26] = 0 [0x00000020] -> GPIO: ()
378 * PBDIR[23] = 0 [0x00000100] -> GPIO: ()
379 * PBDIR[17] = 0 [0x00004000] -> GPIO: ()
380 * PBDIR[16] = 0 [0x00008000] -> GPIO: ()
381 */
382 clrbits_be32(&cp->cp_pbdir, 0x0000C130);
383
384 /*
385 * PCDIR[15] = 0 [0x0001] -> GPIO: ()
386 * PCDIR[14] = 0 [0x0002] -> GPIO: ()
387 * PCDIR[13] = 0 [0x0004] -> GPIO: ()
388 * PCDIR[12] = 0 [0x0008] -> GPIO: ()
389 * PCDIR[8] = 0 [0x0080] -> GPIO: ()
390 * PCDIR[4] = 0 [0x0800] -> GPIO: ()
391 */
392 clrbits_be16(&iop->iop_pcdir, 0x088F);
393
394 /*
395 * PDDIR[9] = 0 [0x0040] -> GPIO: ()
396 * PDDIR[6] = 0 [0x0200] -> GPIO: ()
397 * PDDIR[2] = x [0x2000] -> Reserved
398 * PDDIR[1] = 0 [0x4000] -> ODR for PD10 : ()
399 * PDDIR[0] = 0 [0x8000] -> ODR for PD8 : (R_MDC)
400 */
401 clrbits_be16(&iop->iop_pddir, 0xC240);
402
403 /*
404 * PEDIR[30] = 0 [0x00000002] -> GPIO: ()
405 * PEDIR[27] = 0 [0x00000010] -> GPIO: ()
406 * PEDIR[26] = 0 [0x00000020] -> GPIO: ()
407 * PEDIR[23] = 0 [0x00000100] -> GPIO: ()
408 * PEDIR[22] = 0 [0x00000200] -> GPIO: ()
409 * PEDIR[21] = 0 [0x00000400] -> GPIO: ()
410 * PEDIR[19] = 0 [0x00001000] -> GPIO: ()
411 * PEDIR[18] = 0 [0x00002000] -> GPIO: ()
412 * PEDIR[16] = 0 [0x00008000] -> GPIO: ()
413 * PEDIR[15] = 0 [0x00010000] -> GPIO: ()
414 * PEDIR[14] = 0 [0x00020000] -> GPIO: ()
415 */
416 clrbits_be32(&cp->cp_pedir, 0x0003B732);
417
418 /*
419 * PAODR[10] = 0 [0x0020] -> GPIO: ()
420 */
421 clrbits_be16(&iop->iop_paodr, 0x0020);
422
423 /*
424 * PBODR[16] = 0 [0x00008000] -> GPIO: ()
425 */
426 clrbits_be16(&cp->cp_pbodr, 0x00008000);
427
428 /*
429 * PEODR[30] = 0 [0x00000002] -> GPIO: ()
430 * PEODR[18] = 0 [0x00002000] -> GPIO: ()
431 */
432 clrbits_be32(&cp->cp_peodr, 0x00002002);
433
434 /*
435 * PESO[24] = 0 [0x00000080] -> GPIO: ()
436 * PESO[23] = 0 [0x00000100] -> GPIO: ()
437 * PESO[20] = 0 [0x00000800] -> GPIO: ()
438 * PESO[19] = 0 [0x00001000] -> GPIO: ()
439 * PESO[15] = 0 [0x00010000] -> GPIO: ()
440 * PESO[14] = 0 [0x00020000] -> GPIO: ()
441 */
442 clrbits_be32(&cp->cp_peso, 0x00031980);
443}
444
Christophe Leroy78ba7b62023-04-05 18:50:23 +0200445void iop_setup_miae(void)
Christophe Leroy6a8c36b2023-01-30 09:07:38 +0100446{
447 immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR;
448 iop8xx_t __iomem *iop = &immr->im_ioport;
449 cpm8xx_t __iomem *cp = &immr->im_cpm;
450
451 /* Wait reset on FPGA_F */
452 udelay(100);
453
454 /* Set the front panel LED color to red */
Christophe Leroy78ba7b62023-04-05 18:50:23 +0200455 clrbits_8((unsigned char __iomem *)CONFIG_FPGA_BASE + 0x44, 0x02);
Christophe Leroy6a8c36b2023-01-30 09:07:38 +0100456
457 /* We must initialize data before changing direction */
458 setbits_be16(&iop->iop_pcdat, 0x0888);
459 setbits_be16(&iop->iop_pddat, 0x0201);
460 setbits_be32(&cp->cp_pbdat, 0x00021510);
461 setbits_be32(&cp->cp_pedat, 0x00000002);
462
463 /*
464 * PAPAR[13] = 1 [0x0004] -> GPIO: (RXD2)
465 * PAPAR[12] = 1 [0x0008] -> GPIO: (TXD2)
466 * PAPAR[9] = 1 [0x0040] -> GPIO: (TDM1O)
467 * PAPAR[8] = 1 [0x0080] -> GPIO: (TDM1I)
468 * PAPAR[7] = 1 [0x0100] -> GPIO: (TDM_BCLK_MPC)
469 * PAPAR[6] = 1 [0x0200] -> GPIO: (CLK2)
470 */
471 setbits_be16(&iop->iop_papar, 0x03CC);
472
473 /*
474 * PBODR[16] = 0 [0x00008000] -> GPIO: (L1ST4)
475 */
476 clrbits_be16(&cp->cp_pbodr, 0x00008000);
477
478 /*
479 * PBDIR[27] = 1 [0x00000010] -> GPIO: (WR_TEMP2)
480 * PBDIR[26] = 1 [0x00000020] -> GPIO: (BRG02)
481 * PBDIR[23] = 1 [0x00000100] -> GPIO: (CS_TEMP2)
482 * PBDIR[18] = 1 [0x00002000] -> GPIO: (RTS2)
483 * PBDIR[16] = 0 [0x00008000] -> GPIO: (L1ST4)
484 * PBDIR[15] = 1 [0x00010000] -> GPIO: (BRG03)
485 * PBDIR[14] = 1 [0x00020000] -> GPIO: (CS_TEMP)
486 */
487 clrsetbits_be32(&cp->cp_pbdir, 0x0003A130, 0x00032130);
488
489 /*
490 * PBPAR[20] = 1 [0x00000800] -> GPIO: (SMRXD2)
491 * PBPAR[17] = 1 [0x00004000] -> GPIO: (L1ST3)
492 * PBPAR[16] = 1 [0x00008000] -> GPIO: (L1ST4)
493 */
494 setbits_be32(&cp->cp_pbpar, 0x0000C800);
495
496 /*
497 * PCPAR[14] = 1 [0x0002] -> GPIO: (L1ST2)
498 */
499 setbits_be16(&iop->iop_pcpar, 0x0002);
500
501 /*
502 * PDPAR[14] = 1 [0x0002] -> GPIO: (TDM_FS_MPC)
503 * PDPAR[11] = 1 [0x0010] -> GPIO: (RXD3)
504 * PDPAR[10] = 1 [0x0020] -> GPIO: (TXD3)
505 * PDPAR[9] = 1 [0x0040] -> GPIO: (TXD4)
506 * PDPAR[7] = 1 [0x0100] -> GPIO: (RTS3)
507 * PDPAR[5] = 1 [0x0400] -> GPIO: (CLK8)
508 * PDPAR[3] = 1 [0x1000] -> GPIO: (CLK7)
509 */
510 setbits_be16(&iop->iop_pdpar, 0x1572);
511
512 /*
513 * PEPAR[27] = 1 [0x00000010] -> GPIO: (R2_RXER)
514 * PEPAR[26] = 1 [0x00000020] -> GPIO: (R2_CRS_DV)
515 * PEPAR[25] = 1 [0x00000040] -> GPIO: (RXD4)
516 * PEPAR[24] = 1 [0x00000080] -> GPIO: (BRG01)
517 * PEPAR[23] = 1 [0x00000100] -> GPIO: (L1ST1)
518 * PEPAR[22] = 1 [0x00000200] -> GPIO: (R2_RXD1)
519 * PEPAR[21] = 1 [0x00000400] -> GPIO: (R2_RXD0)
520 * PEPAR[20] = 1 [0x00000800] -> GPIO: (SMTXD2)
521 * PEPAR[19] = 1 [0x00001000] -> GPIO: (R2_TXEN)
522 * PEPAR[17] = 1 [0x00004000] -> GPIO: (CLK5)
523 * PEPAR[16] = 1 [0x00008000] -> GPIO: (R2_REF_CLK)
524 * PEPAR[15] = 1 [0x00010000] -> GPIO: (R2_TXD1)
525 * PEPAR[14] = 1 [0x00020000] -> GPIO: (R2_TXD0)
526 */
527 setbits_be32(&cp->cp_pepar, 0x0003DFF0);
528
529 /*
530 * PADIR[9] = 1 [0x0040] -> GPIO: (TDM1O)
531 * PADIR[8] = 1 [0x0080] -> GPIO: (TDM1I)
532 * PADIR[5] = 0 [0x0400] -> GPIO: ()
533 */
534 clrsetbits_be16(&iop->iop_padir, 0x04C0, 0x00C0);
535
536 /*
537 * PCDIR[15] = 1 [0x0001] -> GPIO: (WP_EEPROM2)
538 * PCDIR[14] = 1 [0x0002] -> GPIO: (L1ST2)
539 * PCDIR[13] = 0 [0x0004] -> GPIO: ()
540 * PCDIR[12] = 1 [0x0008] -> GPIO: (CS_EEPROM2)
541 * PCDIR[8] = 1 [0x0080] -> GPIO: (CS_CODEC_2)
542 * PCDIR[4] = 1 [0x0800] -> GPIO: (CS_CODEC_1)
543 */
544 clrsetbits_be16(&iop->iop_pcdir, 0x088F, 0x088B);
545
546 /*
547 * PDDIR[9] = 1 [0x0040] -> GPIO: (TXD4)
548 * PDDIR[6] = 1 [0x0200] -> GPIO: (CS_CODEC_3)
549 */
550 setbits_be16(&iop->iop_pddir, 0x0240);
551
552 /*
553 * PEDIR[30] = 1 [0x00000002] -> GPIO: (FPGA_FIRMWARE)
554 * PEDIR[27] = 1 [0x00000010] -> GPIO: (R2_RXER)
555 * PEDIR[26] = 1 [0x00000020] -> GPIO: (R2_CRS_DV)
556 * PEDIR[23] = 1 [0x00000100] -> GPIO: (L1ST1)
557 * PEDIR[22] = 1 [0x00000200] -> GPIO: (R2_RXD1)
558 * PEDIR[21] = 1 [0x00000400] -> GPIO: (R2_RXD0)
559 * PEDIR[19] = 1 [0x00001000] -> GPIO: (R2_TXEN)
560 * PEDIR[18] = 1 [0x00002000] -> GPIO: (PE18)
561 * PEDIR[16] = 1 [0x00008000] -> GPIO: (R2_REF_CLK)
562 * PEDIR[15] = 1 [0x00010000] -> GPIO: (R2_TXD1)
563 * PEDIR[14] = 1 [0x00020000] -> GPIO: (R2_TXD0)
564 */
565 setbits_be32(&cp->cp_pedir, 0x0003B732);
566
567 /*
568 * PAODR[10] = 1 [0x0020] -> GPIO: (INIT_FPGA_F)
569 */
570 setbits_be16(&iop->iop_paodr, 0x0020);
571
572 /*
573 * PEODR[30] = 1 [0x00000002] -> GPIO: (FPGA_FIRMWARE)
574 * PEODR[18] = 0 [0x00002000] -> GPIO: (PE18)
575 */
576 clrsetbits_be32(&cp->cp_peodr, 0x00002002, 0x00000002);
577
578 /*
579 * PESO[24] = 1 [0x00000080] -> GPIO: (BRG01)
580 * PESO[23] = 1 [0x00000100] -> GPIO: (L1ST1)
581 * PESO[20] = 1 [0x00000800] -> GPIO: (SMTXD2)
582 * PESO[19] = 1 [0x00001000] -> GPIO: (R2_TXEN)
583 * PESO[15] = 1 [0x00010000] -> GPIO: (R2_TXD1)
584 * PESO[14] = 1 [0x00020000] -> GPIO: (R2_TXD0)
585 */
586 setbits_be32(&cp->cp_peso, 0x00031980);
587}
588
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200589/* Specific board initialization */
Christophe Leroy019b39b2023-05-03 08:38:16 +0200590int board_early_init_f(void)
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200591{
592 immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR;
593 iop8xx_t __iomem *iop = &immr->im_ioport;
594 cpm8xx_t __iomem *cp = &immr->im_cpm;
595
596 /* MPC885 Port settings common to all boards */
597 setbits_be16(&iop->iop_padat, 0x0000);
598
599 /* Port A (MPC885 reference manual - 34.2) */
600 /*
601 * In/Out or per. Function 0/1
602 * PADIR[15] = 0 [0x0001] -> GPIO: (USB_RXD)
603 * PADIR[14] = 0 [0x0002] -> GPIO: (USB_OE)
604 * PADIR[13] = 0 [0x0004] -> GPIO: ()
605 * PADIR[12] = 0 [0x0008] -> GPIO: ()
606 * PADIR[11] = 1 [0x0010] -> GPIO: (R1_TXD0)
607 * PADIR[10] = 0 [0x0020] -> GPIO: ()
608 * PADIR[7] = 0 [0x0100] -> GPIO: ()
609 * PADIR[6] = 0 [0x0200] -> GPIO: ()
610 * PADIR[4] = 1 [0x0800] -> GPIO: (R1_TXD1)
611 * PADIR[3] = 0 [0x1000] -> GPIO: (R1_RXER)
612 * PADIR[2] = 0 [0x2000] -> GPIO: (R1_CRS_DV)
613 * PADIR[1] = 0 [0x4000] -> GPIO: (R1_RXD0)
614 * PADIR[0] = 0 [0x8000] -> GPIO: (R1_RXD1)
615 */
616 clrsetbits_be16(&iop->iop_padir, 0xFB3F, 0x0810);
617
618 /*
619 * Open drain or active output
620 * PAODR[15] = x [0x0001]
621 * PAODR[14] = 0 [0x0002]
622 * PAODR[13] = x [0x0004]
623 * PAODR[12] = 0 [0x0008]
624 * PAODR[11] = 0 [0x0010]
625 * PAODR[9] = 0 [0x0040]
626 * PAODR[8] = 0 [0x0080]
627 * PAODR[7] = 0 [0x0100]
628 */
629 clrbits_be16(&iop->iop_paodr, 0x01DF);
630
631 /*
632 * GPIO or per. Function
633 * PAPAR[15] = 1 [0x0001] -> GPIO: (USB_RXD)
634 * PAPAR[14] = 1 [0x0002] -> GPIO: (USB_OE)
635 * PAPAR[11] = 1 [0x0010] -> GPIO: (R1_TXD0)
636 * PAPAR[10] = 0 [0x0020] -> GPIO: (INIT_FPGA_F)
637 * PAPAR[5] = 0 [0x0400] -> GPIO: ()
638 * PAPAR[4] = 1 [0x0800] -> GPIO: (R1_TXD1)
639 * PAPAR[3] = 1 [0x1000] -> GPIO: (R1_RXER)
640 * PAPAR[2] = 1 [0x2000] -> GPIO: (R1_CRS_DV)
641 * PAPAR[1] = 1 [0x4000] -> GPIO: (R1_RXD0)
642 * PAPAR[0] = 1 [0x8000] -> GPIO: (R1_RXD1)
643 */
644 clrsetbits_be16(&iop->iop_papar, 0xFC33, 0xF813);
645
646 /* Port B (MPC885 reference manual - 34.3) */
647 /*
648 * In/Out or per. Function 0/1
649 * PBDIR[31] = 0 [0x00000001] -> GPIO: (R1_REF_CLK)
650 * PBDIR[30] = 1 [0x00000002] -> GPIO: (CLK)
651 * PBDIR[29] = 1 [0x00000004] -> GPIO: (MOSI)
652 * PBDIR[28] = 1 [0x00000008] -> GPIO: (MISO)
653 * PBDIR[25] = 0 [0x00000040] -> GPIO: (SMTXD1)
654 * PBDIR[24] = 0 [0x00000080] -> GPIO: (SMRXD1)
655 * PBDIR[22] = 0 [0x00000200] -> GPIO: (INIT_FPGA_MEZZ)
656 * PBDIR[21] = 1 [0x00000400] -> GPIO: (CS_EEPROM)
657 * PBDIR[20] = 0 [0x00000800] -> GPIO: (SMRXD2)
658 * PBDIR[19] = 1 [0x00001000] -> GPIO: (WR_TEMP)
659 * PBDIR[17] = 0 [0x00004000] -> GPIO: (DONE_FPGA_MEZZ)
660 */
661 clrsetbits_be32(&cp->cp_pbdir, 0x00005ECF, 0x0000140E);
662
663 /*
664 * Open drain or active output
665 * PBODR[31] = 0 [0x00000001] -> GPIO: (R1_REF_CLK)
666 * PBODR[30] = 0 [0x00000002] -> GPIO: (CLK)
667 * PBODR[29] = 0 [0x00000004] -> GPIO: (MOSI)
668 * PBODR[28] = 0 [0x00000008] -> GPIO: (MISO)
669 * PBODR[27] = 0 [0x00000010] -> GPIO: (WR_TEMP2)
670 * PBODR[26] = 0 [0x00000020] -> GPIO: (BRG02)
671 * PBODR[25] = 0 [0x00000040] -> GPIO: (SMTXD1)
672 * PBODR[24] = 0 [0x00000080] -> GPIO: (SMRXD1)
673 * PBODR[23] = 0 [0x00000100] -> GPIO: (CS_TEMP2)
674 * PBODR[22] = 0 [0x00000200] -> GPIO: (INIT_FPGA_MEZZ)
675 * PBODR[21] = 0 [0x00000400] -> GPIO: (CS_EEPROM)
676 * PBODR[20] = 0 [0x00000800] -> GPIO: (SMRXD2)
677 * PBODR[19] = 0 [0x00001000] -> GPIO: (WR_TEMP)
678 * PBODR[18] = 0 [0x00002000] -> GPIO: (RTS2)
679 * PBODR[17] = 0 [0x00004000] -> GPIO: (DONE_FPGA_MEZZ)
680 */
681 clrbits_be16(&cp->cp_pbodr, 0x00007FFF);
682
683 /*
684 * GPIO or per. Function
685 * PBPAR[31] = 1 [0x00000001] -> GPIO: (R1_REF_CLK)
686 * PBPAR[30] = 1 [0x00000002] -> GPIO: (CLK)
687 * PBPAR[29] = 1 [0x00000004] -> GPIO: (MOSI)
688 * PBPAR[28] = 1 [0x00000008] -> GPIO: (MISO)
689 * PBPAR[27] = 0 [0x00000010] -> GPIO: (WR_TEMP2)
690 * PBPAR[26] = 0 [0x00000020] -> GPIO: (BRG02)
691 * PBPAR[25] = 1 [0x00000040] -> GPIO: (SMTXD1)
692 * PBPAR[24] = 1 [0x00000080] -> GPIO: (SMRXD1)
693 * PBPAR[23] = 0 [0x00000100] -> GPIO: (CS_TEMP2)
694 * PBPAR[22] = 0 [0x00000200] -> GPIO: (INIT_FPGA_MEZZ)
695 * PBPAR[21] = 0 [0x00000400] -> GPIO: (CS_EEPROM)
696 * PBPAR[19] = 0 [0x00001000] -> GPIO: (WR_TEMP)
697 * PBPAR[18] = 0 [0x00002000] -> GPIO: (RTS2)
698 * PBPAR[15] = 0 [0x00010000] -> GPIO: (BRG03)
699 * PBPAR[14] = 0 [0x00020000] -> GPIO: (CS_TEMP)
700 */
701 clrsetbits_be32(&cp->cp_pbpar, 0x000337FF, 0x000000CF);
702
703 /* Port C (MPC885 Reference Manual - 34.4) */
704 /*
705 * In/Out or per. Function 0/1
706 * PCDIR[11] = 0 [0x0010] -> GPIO: (USB_RXP)
707 * PCDIR[10] = 0 [0x0020] -> GPIO: (USB_RXN)
708 * PCDIR[9] = 0 [0x0040] -> GPIO: (CTS2)
709 * PCDIR[7] = 1 [0x0100] -> GPIO: (USB_TXP)
710 * PCDIR[6] = 1 [0x0200] -> GPIO: (USB_TXN)
711 * PCDIR[5] = 0 [0x0400] -> GPIO: (CTS3)
712 */
713 clrsetbits_be16(&iop->iop_pcdir, 0x0770, 0x0300);
714
715 /*
716 * GPIO or per. Function
717 * PCPAR[15] = 0 [0x0001] -> GPIO: (WP_EEPROM2)
718 * PCPAR[13] = 0 [0x0004] -> GPIO: (CS_POT1)
719 * PCPAR[12] = 0 [0x0008] -> GPIO: (CS_EEPROM2)
720 * PCPAR[11] = 0 [0x0010] -> GPIO: (USB_RXP)
721 * PCPAR[10] = 0 [0x0020] -> GPIO: (USB_RXN)
722 * PCPAR[9] = 0 [0x0040] -> GPIO: (CTS2)
723 * PCPAR[8] = 0 [0x0080] -> GPIO: (CS_CODEC_FAV)
724 * PCPAR[7] = 1 [0x0100] -> GPIO: (USB_TXP)
725 * PCPAR[6] = 1 [0x0200] -> GPIO: (USB_TXN)
726 * PCPAR[5] = 0 [0x0400] -> GPIO: (CTS3)
727 * PCPAR[4] = 0 [0x0800] -> GPIO: (CS_CODEC_RADIO)
728 */
729 clrsetbits_be16(&iop->iop_pcpar, 0x0FFD, 0x0300);
730
731 /*
732 * Special Option register
733 * PCSO[15] = 0 [0x0001] -> GPIO: (WP_EEPROM2)
734 * PCSO[14] = 0 [0x0002] -> GPIO: (CS_POT2)
735 * PCSO[13] = x [0x0004] -> Reserved
736 * PCSO[12] = x [0x0008] -> Reserved
737 * PCSO[11] = 1 [0x0010] -> GPIO: (USB_RXP)
738 * PCSO[10] = 1 [0x0020] -> GPIO: (USB_RXN)
739 * PCSO[9] = 1 [0x0040] -> GPIO: (CTS2)
740 * PCSO[8] = 0 [0x0080] -> GPIO: (CS_CODEC_FAV)
741 * PCSO[7] = 0 [0x0100] -> GPIO: (USB_TXP)
742 * PCSO[6] = 0 [0x0200] -> GPIO: (USB_TXN)
743 * PCSO[5] = 1 [0x0400] -> GPIO: (CTS3)
744 * PCSO[4] = 0 [0x0800] -> GPIO: (CS_CODEC_RADIO)
745 */
746 clrsetbits_be16(&iop->iop_pcso, 0x0FF3, 0x0470);
747
748 /*
749 * Interrupt or IO
750 * PCINT[15] = 0 [0x0001] -> GPIO: ()
751 * PCINT[14] = 0 [0x0002] -> GPIO: ()
752 * PCINT[13] = 0 [0x0004] -> GPIO: ()
753 * PCINT[12] = 0 [0x0008] -> GPIO: ()
754 * PCINT[11] = 0 [0x0010] -> GPIO: (USB_RXP)
755 * PCINT[10] = 0 [0x0020] -> GPIO: (USB_RXN)
756 * PCINT[9] = 0 [0x0040] -> GPIO: ()
757 * PCINT[8] = 0 [0x0080] -> GPIO: ()
758 * PCINT[7] = 0 [0x0100] -> GPIO: (USB_TXP)
759 * PCINT[6] = 0 [0x0200] -> GPIO: (USB_TXN)
760 * PCINT[5] = 0 [0x0400] -> GPIO: ()
761 * PCINT[4] = 0 [0x0800] -> GPIO: ()
762 */
763 clrbits_be16(&iop->iop_pcint, 0x0FFF);
764
765 /* Port D (MPC885 Reference Manual - 34.5) */
766 /*
767 * In/Out or per. Function 0/1
768 * PDDIR[15] = 1 [0x0001] -> GPIO: (CS_NAND)
769 * PDDIR[14] = 0 [0x0002] -> GPIO: (TDM_FS_MPC)
770 * PDDIR[13] = 1 [0x0004] -> GPIO: (ALE_NAND)
771 * PDDIR[12] = 1 [0x0008] -> GPIO: (CLE_NAND)
772 * PDDIR[11] = 0 [0x0010] -> GPIO: (RXD3)
773 * PDDIR[10] = 0 [0x0020] -> GPIO: (TXD3)
774 * PDDIR[9] = 1 [0x0040] -> GPIO: (TXD4)
775 * PDDIR[8] = 0 [0x0080] -> GPIO: (R_MDC)
776 * PDDIR[7] = 0 [0x0100] -> GPIO: (RTS3)
777 * PDDIR[5] = 0 [0x0400] -> GPIO: (CLK8)
778 * PDDIR[4] = 0 [0x0800] -> GPIO: (CLK4)
779 * PDDIR[3] = 0 [0x1000] -> GPIO: (CLK7)
780 */
781 clrsetbits_be16(&iop->iop_pddir, 0x1DFF, 0x004D);
782
783 /*
784 * GPIO or per. Function
785 * PDPAR[15] = 0 [0x0001] -> GPIO: (CS_NAND)
786 * PDPAR[13] = 0 [0x0004] -> GPIO: (ALE_NAND)
787 * PDPAR[12] = 0 [0x0008] -> GPIO: (CLE_NAND)
788 * PDPAR[8] = 1 [0x0080] -> GPIO: (R_MDC)
789 * PDPAR[6] = 0 [0x0200] -> GPIO: (INIT_FPGA_RADIO)
790 * PDPAR[4] = 1 [0x0800] -> GPIO: (CLK4)
791 */
792 clrsetbits_be16(&iop->iop_pdpar, 0x0A8D, 0x0880);
793
794 /* Port E (MPC885 Reference Manual - 34.6) */
795 /*
796 * In/Out or per. Function 0/1
797 * PEDIR[31] = 0 [0x00000001] -> GPIO: (DONE_FPGA_FIRMWARE)
798 * PEDIR[29] = 1 [0x00000004] -> GPIO: (USB_SPEED)
799 * PEDIR[28] = 1 [0x00000008] -> GPIO: (USB_SUSPEND)
800 * PEDIR[25] = 0 [0x00000040] -> GPIO: (RXD4)
801 * PEDIR[24] = 0 [0x00000080] -> GPIO: (BRG01)
802 * PEDIR[20] = 0 [0x00000800] -> GPIO: (SMTXD2)
803 * PEDIR[17] = 0 [0x00004000] -> GPIO: (CLK5)
804 */
805 clrsetbits_be32(&cp->cp_pedir, 0x000048CD, 0x0000000C);
806
807 /*
808 * open drain or active output
809 * PEODR[31] = 0 [0x00000001] -> GPIO: (DONE_FPGA_FIRMWARE)
810 * PEODR[29] = 0 [0x00000004] -> GPIO: (USB_SPEED)
811 * PEODR[28] = 1 [0x00000008] -> GPIO: (USB_SUSPEND)
812 * PEODR[27] = 0 [0x00000010] -> GPIO: (R2_RXER)
813 * PEODR[26] = 0 [0x00000020] -> GPIO: (R2_CRS_DV)
814 * PEODR[25] = 0 [0x00000040] -> GPIO: (RXD4)
815 * PEODR[24] = 0 [0x00000080] -> GPIO: (BRG01)
816 * PEODR[23] = 0 [0x00000100] -> GPIO: (DONE_FPGA_RADIO)
817 * PEODR[22] = 0 [0x00000200] -> GPIO: (R2_RXD1)
818 * PEODR[21] = 0 [0x00000400] -> GPIO: (R2_RXD0)
819 * PEODR[20] = 0 [0x00000800] -> GPIO: (SMTXD2)
820 * PEODR[19] = 0 [0x00001000] -> GPIO: (R2_TXEN)
821 * PEODR[17] = 0 [0x00004000] -> GPIO: (CLK5)
822 * PEODR[16] = 0 [0x00008000] -> GPIO: (R2_REF_CLK)
823 */
824 clrsetbits_be32(&cp->cp_peodr, 0x0000DFFD, 0x00000008);
825
826 /*
827 * GPIO or per. Function
828 * PEPAR[31] = 0 [0x00000001] -> GPIO: (DONE_FPGA_FIRMWARE)
829 * PEPAR[30] = 0 [0x00000002] -> GPIO: (PROG_FPGA_FIRMWARE)
830 * PEPAR[29] = 0 [0x00000004] -> GPIO: (USB_SPEED)
831 * PEPAR[28] = 0 [0x00000008] -> GPIO: (USB_SUSPEND)
832 * PEPAR[18] = 0 [0x00002000] -> GPIO: (PROG_FPGA_RADIO)
833 */
834 clrbits_be32(&cp->cp_pepar, 0x0000200F);
835
836 /*
837 * Special Option register
838 * PESO[31] = 0 [0x00000001] -> GPIO: (DONE_FPGA_FIRMWARE)
839 * PESO[30] = 0 [0x00000002] -> GPIO: (PROG_FPGA_FIRMWARE)
840 * PESO[29] = 0 [0x00000004] -> GPIO: (USB_SPEED)
841 * PESO[28] = 0 [0x00000008] -> GPIO: (USB_SUSPEND)
842 * PESO[27] = 0 [0x00000010] -> GPIO: (R2_RXER)
843 * PESO[26] = 0 [0x00000020] -> GPIO: (R2_CRS_DV)
844 * PESO[25] = 0 [0x00000040] -> GPIO: (RXD4)
845 * PESO[22] = 0 [0x00000200] -> GPIO: (R2_RXD1)
846 * PESO[21] = 0 [0x00000400] -> GPIO: (R2_RXD0)
847 * PESO[18] = 0 [0x00002000] -> GPIO: (PROG_FPGA_RADIO)
848 * PESO[17] = 0 [0x00004000] -> GPIO: (CLK5)
849 * PESO[16] = 0 [0x00008000] -> GPIO: (R2_REF_CLK)
850 */
851 clrbits_be32(&cp->cp_peso, 0x0000E67F);
852
853 /* Is a motherboard present ? */
854 if (in_be16(ADDR_CPLD_R_ETAT) & R_ETAT_PRES_BASE) {
855 /* Initialize signal PROG_FPGA_FIRMWARE */
856 out_be32(&cp->cp_pedat, 0x00000002);
857 out_be32(&cp->cp_peodr, 0x00000002);
858 out_be32(&cp->cp_pedir, 0x00000002);
859
860 /* Check if fpga firmware is loaded */
861 if (!(in_be32(&cp->cp_pedat) & 0x00000001)) {
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200862 /* Load fpga firmware */
863 /* Activate PROG_FPGA_FIRMWARE for 1 usec */
864 clrbits_be32(&cp->cp_pedat, 0x00000002);
865 udelay(1);
866 setbits_be32(&cp->cp_pedat, 0x00000002);
867
868 /* Wait 200 msec and check DONE_FPGA_FIRMWARE */
869 mdelay(200);
Christophe Leroy019b39b2023-05-03 08:38:16 +0200870 if (!(in_be32(&cp->cp_pedat) & 0x00000001))
871 hang();
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200872
873 /* Send a reset signal and wait for 20 msec */
874 clrbits_be16(ADDR_CPLD_R_RESET, R_RST_STATUS);
875 mdelay(20);
876 setbits_be16(ADDR_CPLD_R_RESET, R_RST_STATUS);
877 }
878
879 /* Wait 300 msec and check the reset state */
880 mdelay(300);
Christophe Leroy019b39b2023-05-03 08:38:16 +0200881 if (!(in_be16(ADDR_CPLD_R_RESET) & R_RESET_STATUS))
882 hang();
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200883
Christophe Leroy78ba7b62023-04-05 18:50:23 +0200884 iop_setup_common();
Christophe Leroydac3c6f2022-10-14 12:54:50 +0200885 } else {
886 iop_setup_cmpc885();
887 }
888
889 return 0;
890}