blob: dd58d0124ea641f820613d032f2f9b1253a2a114 [file] [log] [blame]
stroese071d8972003-05-23 11:35:47 +00001/*
2 * (C) Copyright 2001-2003
Stefan Roese2076d0a2006-01-18 20:03:15 +01003 * Stefan Roese, DENX Software Engineering, sr@denx.de.
4 *
5 * (C) Copyright 2005
6 * Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com
stroese071d8972003-05-23 11:35:47 +00007 *
8 * See file CREDITS for list of people who contributed to this
9 * project.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA
25 */
26
27#include <common.h>
28#include <asm/processor.h>
29#include <command.h>
stroese071d8972003-05-23 11:35:47 +000030#include <malloc.h>
31
Wolfgang Denkd87080b2006-03-31 18:32:53 +020032DECLARE_GLOBAL_DATA_PTR;
stroese071d8972003-05-23 11:35:47 +000033
stroese4510a7b2004-12-16 18:40:02 +000034extern void lxt971_no_sleep(void);
35
stroeseef9e8682003-09-12 08:46:58 +000036/* fpga configuration data - not compressed, generated by bin2c */
37const unsigned char fpgadata[] =
38{
39#include "fpgadata.c"
40};
41int filesize = sizeof(fpgadata);
stroese071d8972003-05-23 11:35:47 +000042
wdenkc837dcb2004-01-20 23:12:12 +000043int board_early_init_f (void)
stroese071d8972003-05-23 11:35:47 +000044{
45 /*
46 * IRQ 0-15 405GP internally generated; active high; level sensitive
47 * IRQ 16 405GP internally generated; active low; level sensitive
48 * IRQ 17-24 RESERVED
49 * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
50 * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
51 * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
52 * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
53 * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
54 * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
55 * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
56 */
Matthias Fuchsc553b5f2009-02-15 22:26:54 +010057 mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
58 mtdcr(uicer, 0x00000000); /* disable all ints */
59 mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
60 mtdcr(uicpr, 0xFFFFFF81); /* set int polarities */
61 mtdcr(uictr, 0x10000000); /* set int trigger levels */
62 mtdcr(uicvcr, 0x00000001); /* set vect base=0, INT0 highest priority */
63 mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
stroese071d8972003-05-23 11:35:47 +000064
65 /*
Matthias Fuchsc553b5f2009-02-15 22:26:54 +010066 * EBC Configuration Register:
67 * set ready timeout to 512 ebc-clks -> ca. 15 us
stroese071d8972003-05-23 11:35:47 +000068 */
69 mtebc (epcr, 0xa8400000);
70
stroese4510a7b2004-12-16 18:40:02 +000071 /*
Stefan Roese2076d0a2006-01-18 20:03:15 +010072 * Setup GPIO pins
stroese4510a7b2004-12-16 18:40:02 +000073 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020074 mtdcr(cntrl0, mfdcr(cntrl0) | ((CONFIG_SYS_FPGA_INIT | \
75 CONFIG_SYS_FPGA_DONE | \
76 CONFIG_SYS_XEREADY | \
77 CONFIG_SYS_NONMONARCH | \
78 CONFIG_SYS_REV1_2) << 5));
Stefan Roese2076d0a2006-01-18 20:03:15 +010079
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020080 if (!(in32(GPIO0_IR) & CONFIG_SYS_REV1_2)) {
Stefan Roese2076d0a2006-01-18 20:03:15 +010081 /* rev 1.2 boards */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020082 mtdcr(cntrl0, mfdcr(cntrl0) | ((CONFIG_SYS_INTA_FAKE | \
83 CONFIG_SYS_SELF_RST) << 5));
Stefan Roese2076d0a2006-01-18 20:03:15 +010084 }
85
86 out32(GPIO0_OR, 0);
Matthias Fuchsc553b5f2009-02-15 22:26:54 +010087 /* setup for output */
88 out32(GPIO0_TCR, CONFIG_SYS_FPGA_PRG | CONFIG_SYS_FPGA_CLK | \
89 CONFIG_SYS_FPGA_DATA | CONFIG_SYS_XEREADY);
Stefan Roese2076d0a2006-01-18 20:03:15 +010090
Matthias Fuchsc553b5f2009-02-15 22:26:54 +010091 /*
92 * - check if rev1_2 is low, then:
93 * - set/reset CONFIG_SYS_INTA_FAKE/CONFIG_SYS_SELF_RST
94 * in TCR to assert INTA# or SELFRST#
stroese4510a7b2004-12-16 18:40:02 +000095 */
stroese071d8972003-05-23 11:35:47 +000096 return 0;
97}
98
stroese071d8972003-05-23 11:35:47 +000099int misc_init_r (void)
100{
stroese4510a7b2004-12-16 18:40:02 +0000101 /* adjust flash start and offset */
102 gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
103 gd->bd->bi_flashoffset = 0;
104
Matthias Fuchsc553b5f2009-02-15 22:26:54 +0100105 /* deassert EREADY# */
106 out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_XEREADY);
stroese071d8972003-05-23 11:35:47 +0000107 return (0);
108}
109
Stefan Roese2076d0a2006-01-18 20:03:15 +0100110ushort pmc405_pci_subsys_deviceid(void)
111{
112 ulong val;
113 val = in32(GPIO0_IR);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200114 if (!(val & CONFIG_SYS_REV1_2)) { /* low=rev1.2 */
Matthias Fuchsc553b5f2009-02-15 22:26:54 +0100115 /* check monarch# signal */
116 if (val & CONFIG_SYS_NONMONARCH)
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200117 return CONFIG_SYS_PCI_SUBSYS_DEVICEID_NONMONARCH;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200118 return CONFIG_SYS_PCI_SUBSYS_DEVICEID_MONARCH;
Stefan Roese2076d0a2006-01-18 20:03:15 +0100119 }
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200120 return CONFIG_SYS_PCI_SUBSYS_DEVICEID_NONMONARCH;
Stefan Roese2076d0a2006-01-18 20:03:15 +0100121}
stroese071d8972003-05-23 11:35:47 +0000122
123/*
Matthias Fuchsc553b5f2009-02-15 22:26:54 +0100124 * Check Board Identity
stroese071d8972003-05-23 11:35:47 +0000125 */
stroese071d8972003-05-23 11:35:47 +0000126int checkboard (void)
127{
Stefan Roese2076d0a2006-01-18 20:03:15 +0100128 ulong val;
129
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200130 char str[64];
stroese071d8972003-05-23 11:35:47 +0000131 int i = getenv_r ("serial#", str, sizeof(str));
132
133 puts ("Board: ");
134
Matthias Fuchsc553b5f2009-02-15 22:26:54 +0100135 if (i == -1)
stroeseef9e8682003-09-12 08:46:58 +0000136 puts ("### No HW ID - assuming PMC405");
Matthias Fuchsc553b5f2009-02-15 22:26:54 +0100137 else
stroese071d8972003-05-23 11:35:47 +0000138 puts(str);
stroese071d8972003-05-23 11:35:47 +0000139
Stefan Roese2076d0a2006-01-18 20:03:15 +0100140 val = in32(GPIO0_IR);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200141 if (!(val & CONFIG_SYS_REV1_2)) { /* low=rev1.2 */
Stefan Roese2076d0a2006-01-18 20:03:15 +0100142 puts(" rev1.2 (");
Matthias Fuchsc553b5f2009-02-15 22:26:54 +0100143 if (val & CONFIG_SYS_NONMONARCH) /* monarch# signal */
Stefan Roese2076d0a2006-01-18 20:03:15 +0100144 puts("non-");
Stefan Roese2076d0a2006-01-18 20:03:15 +0100145 puts("monarch)");
Matthias Fuchsc553b5f2009-02-15 22:26:54 +0100146 } else
Stefan Roese2076d0a2006-01-18 20:03:15 +0100147 puts(" <=rev1.1");
stroese071d8972003-05-23 11:35:47 +0000148
Stefan Roese2076d0a2006-01-18 20:03:15 +0100149 putc ('\n');
stroese4510a7b2004-12-16 18:40:02 +0000150
stroese071d8972003-05-23 11:35:47 +0000151 return 0;
152}
153
Stefan Roese2076d0a2006-01-18 20:03:15 +0100154void reset_phy(void)
stroese071d8972003-05-23 11:35:47 +0000155{
Stefan Roese2076d0a2006-01-18 20:03:15 +0100156#ifdef CONFIG_LXT971_NO_SLEEP
stroese071d8972003-05-23 11:35:47 +0000157
Stefan Roese2076d0a2006-01-18 20:03:15 +0100158 /*
159 * Disable sleep mode in LXT971
160 */
161 lxt971_no_sleep();
162#endif
stroese071d8972003-05-23 11:35:47 +0000163}