blob: c32d333ddfab897d8053fa4d3ea08872631e71d9 [file] [log] [blame]
wdenk153d5112002-08-30 11:07:04 +00001/*
2 * (C) Copyright 2000, 2001
3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include "du405.h"
26#include <asm/processor.h>
Stefan Roeseb36df562010-09-09 19:18:00 +020027#include <asm/ppc4xx.h>
28#include <asm/ppc4xx-i2c.h>
wdenk153d5112002-08-30 11:07:04 +000029#include <command.h>
wdenk8bde7f72003-06-27 21:31:46 +000030
Wolfgang Denkd87080b2006-03-31 18:32:53 +020031DECLARE_GLOBAL_DATA_PTR;
32
stroeseab379df2004-12-16 18:36:28 +000033extern void lxt971_no_sleep(void);
wdenk153d5112002-08-30 11:07:04 +000034
wdenk153d5112002-08-30 11:07:04 +000035
36#if 0
37#define FPGA_DEBUG
38#endif
39
40#if 0
41#define FPGA_DEBUG2
42#endif
43
44/* fpga configuration data - generated by bin2cc */
45const unsigned char fpgadata[] = {
46#include "fpgadata.c"
47};
48
49/*
50 * include common fpga code (for esd boards)
51 */
52#include "../common/fpga.c"
53
54
wdenkc837dcb2004-01-20 23:12:12 +000055int board_early_init_f (void)
wdenk153d5112002-08-30 11:07:04 +000056{
wdenk153d5112002-08-30 11:07:04 +000057 int index, len, i;
58 int status;
59
60#ifdef FPGA_DEBUG
61 /* set up serial port with default baudrate */
62 (void) get_clocks ();
63 gd->baudrate = CONFIG_BAUDRATE;
64 serial_init ();
65 console_init_f ();
66#endif
67
68 /*
69 * Boot onboard FPGA
70 */
71 status = fpga_boot ((unsigned char *) fpgadata, sizeof (fpgadata));
72 if (status != 0) {
73 /* booting FPGA failed */
74#ifndef FPGA_DEBUG
75 /* set up serial port with default baudrate */
76 (void) get_clocks ();
77 gd->baudrate = CONFIG_BAUDRATE;
78 serial_init ();
79 console_init_f ();
80#endif
81 printf ("\nFPGA: Booting failed ");
82 switch (status) {
83 case ERROR_FPGA_PRG_INIT_LOW:
84 printf ("(Timeout: INIT not low after asserting PROGRAM*)\n ");
85 break;
86 case ERROR_FPGA_PRG_INIT_HIGH:
87 printf ("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
88 break;
89 case ERROR_FPGA_PRG_DONE:
90 printf ("(Timeout: DONE not high after programming FPGA)\n ");
91 break;
92 }
93
94 /* display infos on fpgaimage */
95 index = 15;
96 for (i = 0; i < 4; i++) {
97 len = fpgadata[index];
98 printf ("FPGA: %s\n", &(fpgadata[index + 1]));
99 index += len + 3;
100 }
101 putc ('\n');
102 /* delayed reboot */
103 for (i = 20; i > 0; i--) {
104 printf ("Rebooting in %2d seconds \r", i);
105 for (index = 0; index < 1000; index++)
106 udelay (1000);
107 }
108 putc ('\n');
109 do_reset (NULL, 0, 0, NULL);
110 }
111
112 /*
113 * IRQ 0-15 405GP internally generated; active high; level sensitive
114 * IRQ 16 405GP internally generated; active low; level sensitive
115 * IRQ 17-24 RESERVED
116 * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
117 * IRQ 26 (EXT IRQ 1) DUART_A; active high; level sensitive
118 * IRQ 27 (EXT IRQ 2) DUART_B; active high; level sensitive
119 * IRQ 28 (EXT IRQ 3) unused; active low; level sensitive
120 * IRQ 29 (EXT IRQ 4) unused; active low; level sensitive
121 * IRQ 30 (EXT IRQ 5) unused; active low; level sensitive
122 * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
123 */
Stefan Roese952e7762009-09-24 09:55:50 +0200124 mtdcr (UIC0SR, 0xFFFFFFFF); /* clear all ints */
125 mtdcr (UIC0ER, 0x00000000); /* disable all ints */
126 mtdcr (UIC0CR, 0x00000000); /* set all to be non-critical */
127 mtdcr (UIC0PR, 0xFFFFFFB1); /* set int polarities */
128 mtdcr (UIC0TR, 0x10000000); /* set int trigger levels */
129 mtdcr (UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest priority */
130 mtdcr (UIC0SR, 0xFFFFFFFF); /* clear all ints */
wdenk153d5112002-08-30 11:07:04 +0000131
132 /*
133 * EBC Configuration Register: set ready timeout to 100 us
134 */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200135 mtebc (EBC0_CFG, 0xb8400000);
wdenk153d5112002-08-30 11:07:04 +0000136
137 return 0;
138}
139
140
Stefan Roese82f4c6a2005-08-12 16:52:47 +0200141int misc_init_r (void)
142{
Stefan Roesed1c3b272009-09-09 16:25:29 +0200143 unsigned long CPC0_CR0Reg;
Stefan Roese82f4c6a2005-08-12 16:52:47 +0200144
145 /*
146 * Setup UART1 handshaking: use CTS instead of DSR
147 */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200148 CPC0_CR0Reg = mfdcr(CPC0_CR0);
149 mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x00001000);
Stefan Roese82f4c6a2005-08-12 16:52:47 +0200150
151 return (0);
152}
153
154
wdenk153d5112002-08-30 11:07:04 +0000155/*
156 * Check Board Identity:
157 */
wdenk153d5112002-08-30 11:07:04 +0000158int checkboard (void)
159{
160 int index;
161 int len;
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200162 char str[64];
Wolfgang Denkcdb74972010-07-24 21:55:43 +0200163 int i = getenv_f("serial#", str, sizeof (str));
wdenk153d5112002-08-30 11:07:04 +0000164
165 puts ("Board: ");
166
167 if (i == -1) {
168 puts ("### No HW ID - assuming DU405");
169 } else {
170 puts (str);
171 }
172
173 puts ("\nFPGA: ");
174
175 /* display infos on fpgaimage */
176 index = 15;
177 for (i = 0; i < 4; i++) {
178 len = fpgadata[index];
179 printf ("%s ", &(fpgadata[index + 1]));
180 index += len + 3;
181 }
182
183 putc ('\n');
184
185 /*
186 * Reset external DUART via FPGA
187 */
Matthias Fuchsbb57ad42009-02-20 10:19:19 +0100188 out_8((void *)FPGA_MODE_REG, 0xff); /* reset high active */
189 out_8((void *)FPGA_MODE_REG, 0x00); /* low again */
wdenk153d5112002-08-30 11:07:04 +0000190
Matthias Fuchs09db8f42009-02-20 10:19:15 +0100191 return 0;
192}
193
194void reset_phy(void)
195{
196#if defined(CONFIG_LXT971_NO_SLEEP)
197
stroeseab379df2004-12-16 18:36:28 +0000198 /*
199 * Disable sleep mode in LXT971
200 */
201 lxt971_no_sleep();
Matthias Fuchs09db8f42009-02-20 10:19:15 +0100202#endif
wdenk153d5112002-08-30 11:07:04 +0000203}