blob: e67ff309dffb6838c7b82aae19d9c4146728f0b7 [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 *
Matthias Fuchs2f6eb912009-02-15 22:27:47 +01005 * (C) Copyright 2005-2009
Stefan Roese2076d0a2006-01-18 20:03:15 +01006 * Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com
stroese071d8972003-05-23 11:35:47 +00007 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
stroese071d8972003-05-23 11:35:47 +00009 */
10
11#include <common.h>
12#include <asm/processor.h>
Matthias Fuchs2f6eb912009-02-15 22:27:47 +010013#include <asm/io.h>
stroese071d8972003-05-23 11:35:47 +000014#include <command.h>
stroese071d8972003-05-23 11:35:47 +000015#include <malloc.h>
16
Wolfgang Denkd87080b2006-03-31 18:32:53 +020017DECLARE_GLOBAL_DATA_PTR;
stroese071d8972003-05-23 11:35:47 +000018
stroese4510a7b2004-12-16 18:40:02 +000019extern void lxt971_no_sleep(void);
20
wdenkc837dcb2004-01-20 23:12:12 +000021int board_early_init_f (void)
stroese071d8972003-05-23 11:35:47 +000022{
23 /*
24 * IRQ 0-15 405GP internally generated; active high; level sensitive
25 * IRQ 16 405GP internally generated; active low; level sensitive
26 * IRQ 17-24 RESERVED
27 * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
28 * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
29 * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
30 * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
31 * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
32 * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
33 * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
34 */
Stefan Roese952e7762009-09-24 09:55:50 +020035 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
36 mtdcr(UIC0ER, 0x00000000); /* disable all ints */
37 mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/
38 mtdcr(UIC0PR, 0xFFFFFF81); /* set int polarities */
39 mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */
40 mtdcr(UIC0VCR, 0x00000001); /* set vect base=0, INT0 highest priority */
41 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
stroese071d8972003-05-23 11:35:47 +000042
43 /*
Matthias Fuchsc553b5f2009-02-15 22:26:54 +010044 * EBC Configuration Register:
45 * set ready timeout to 512 ebc-clks -> ca. 15 us
stroese071d8972003-05-23 11:35:47 +000046 */
Stefan Roesed1c3b272009-09-09 16:25:29 +020047 mtebc (EBC0_CFG, 0xa8400000);
stroese071d8972003-05-23 11:35:47 +000048
stroese4510a7b2004-12-16 18:40:02 +000049 /*
Stefan Roese2076d0a2006-01-18 20:03:15 +010050 * Setup GPIO pins
stroese4510a7b2004-12-16 18:40:02 +000051 */
Stefan Roesed1c3b272009-09-09 16:25:29 +020052 mtdcr(CPC0_CR0, mfdcr(CPC0_CR0) | ((CONFIG_SYS_FPGA_INIT |
Stefan Roesef50fe4b2009-02-18 14:05:37 +010053 CONFIG_SYS_FPGA_DONE |
54 CONFIG_SYS_XEREADY |
55 CONFIG_SYS_NONMONARCH |
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020056 CONFIG_SYS_REV1_2) << 5));
Stefan Roese2076d0a2006-01-18 20:03:15 +010057
Stefan Roesef50fe4b2009-02-18 14:05:37 +010058 if (!(in_be32((void *)GPIO0_IR) & CONFIG_SYS_REV1_2)) {
Stefan Roese2076d0a2006-01-18 20:03:15 +010059 /* rev 1.2 boards */
Stefan Roesed1c3b272009-09-09 16:25:29 +020060 mtdcr(CPC0_CR0, mfdcr(CPC0_CR0) | ((CONFIG_SYS_INTA_FAKE |
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020061 CONFIG_SYS_SELF_RST) << 5));
Stefan Roese2076d0a2006-01-18 20:03:15 +010062 }
63
Stefan Roesef50fe4b2009-02-18 14:05:37 +010064 out_be32((void *)GPIO0_OR, CONFIG_SYS_VPEN);
Matthias Fuchsc553b5f2009-02-15 22:26:54 +010065 /* setup for output */
Stefan Roesef50fe4b2009-02-18 14:05:37 +010066 out_be32((void *)GPIO0_TCR, CONFIG_SYS_FPGA_PRG | CONFIG_SYS_FPGA_CLK |
67 CONFIG_SYS_FPGA_DATA | CONFIG_SYS_XEREADY | CONFIG_SYS_VPEN);
Stefan Roese2076d0a2006-01-18 20:03:15 +010068
Matthias Fuchsc553b5f2009-02-15 22:26:54 +010069 /*
70 * - check if rev1_2 is low, then:
71 * - set/reset CONFIG_SYS_INTA_FAKE/CONFIG_SYS_SELF_RST
72 * in TCR to assert INTA# or SELFRST#
stroese4510a7b2004-12-16 18:40:02 +000073 */
stroese071d8972003-05-23 11:35:47 +000074 return 0;
75}
76
stroese071d8972003-05-23 11:35:47 +000077int misc_init_r (void)
78{
stroese4510a7b2004-12-16 18:40:02 +000079 /* adjust flash start and offset */
80 gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
81 gd->bd->bi_flashoffset = 0;
82
Matthias Fuchsc553b5f2009-02-15 22:26:54 +010083 /* deassert EREADY# */
Stefan Roesef50fe4b2009-02-18 14:05:37 +010084 out_be32((void *)GPIO0_OR,
85 in_be32((void *)GPIO0_OR) | CONFIG_SYS_XEREADY);
stroese071d8972003-05-23 11:35:47 +000086 return (0);
87}
88
Stefan Roese2076d0a2006-01-18 20:03:15 +010089ushort pmc405_pci_subsys_deviceid(void)
90{
91 ulong val;
Stefan Roesef50fe4b2009-02-18 14:05:37 +010092
93 val = in_be32((void *)GPIO0_IR);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020094 if (!(val & CONFIG_SYS_REV1_2)) { /* low=rev1.2 */
Matthias Fuchsc553b5f2009-02-15 22:26:54 +010095 /* check monarch# signal */
96 if (val & CONFIG_SYS_NONMONARCH)
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020097 return CONFIG_SYS_PCI_SUBSYS_DEVICEID_NONMONARCH;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020098 return CONFIG_SYS_PCI_SUBSYS_DEVICEID_MONARCH;
Stefan Roese2076d0a2006-01-18 20:03:15 +010099 }
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200100 return CONFIG_SYS_PCI_SUBSYS_DEVICEID_NONMONARCH;
Stefan Roese2076d0a2006-01-18 20:03:15 +0100101}
stroese071d8972003-05-23 11:35:47 +0000102
103/*
Matthias Fuchsc553b5f2009-02-15 22:26:54 +0100104 * Check Board Identity
stroese071d8972003-05-23 11:35:47 +0000105 */
stroese071d8972003-05-23 11:35:47 +0000106int checkboard (void)
107{
Stefan Roese2076d0a2006-01-18 20:03:15 +0100108 ulong val;
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200109 char str[64];
Wolfgang Denkcdb74972010-07-24 21:55:43 +0200110 int i = getenv_f("serial#", str, sizeof(str));
stroese071d8972003-05-23 11:35:47 +0000111
112 puts ("Board: ");
113
Matthias Fuchsc553b5f2009-02-15 22:26:54 +0100114 if (i == -1)
stroeseef9e8682003-09-12 08:46:58 +0000115 puts ("### No HW ID - assuming PMC405");
Matthias Fuchsc553b5f2009-02-15 22:26:54 +0100116 else
stroese071d8972003-05-23 11:35:47 +0000117 puts(str);
stroese071d8972003-05-23 11:35:47 +0000118
Stefan Roesef50fe4b2009-02-18 14:05:37 +0100119 val = in_be32((void *)GPIO0_IR);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200120 if (!(val & CONFIG_SYS_REV1_2)) { /* low=rev1.2 */
Stefan Roese2076d0a2006-01-18 20:03:15 +0100121 puts(" rev1.2 (");
Matthias Fuchsc553b5f2009-02-15 22:26:54 +0100122 if (val & CONFIG_SYS_NONMONARCH) /* monarch# signal */
Stefan Roese2076d0a2006-01-18 20:03:15 +0100123 puts("non-");
Stefan Roese2076d0a2006-01-18 20:03:15 +0100124 puts("monarch)");
Matthias Fuchsc553b5f2009-02-15 22:26:54 +0100125 } else
Stefan Roese2076d0a2006-01-18 20:03:15 +0100126 puts(" <=rev1.1");
stroese071d8972003-05-23 11:35:47 +0000127
Stefan Roese2076d0a2006-01-18 20:03:15 +0100128 putc ('\n');
stroese4510a7b2004-12-16 18:40:02 +0000129
stroese071d8972003-05-23 11:35:47 +0000130 return 0;
131}
132
Stefan Roese2076d0a2006-01-18 20:03:15 +0100133void reset_phy(void)
stroese071d8972003-05-23 11:35:47 +0000134{
Stefan Roese2076d0a2006-01-18 20:03:15 +0100135#ifdef CONFIG_LXT971_NO_SLEEP
stroese071d8972003-05-23 11:35:47 +0000136
Stefan Roese2076d0a2006-01-18 20:03:15 +0100137 /*
138 * Disable sleep mode in LXT971
139 */
140 lxt971_no_sleep();
141#endif
stroese071d8972003-05-23 11:35:47 +0000142}