stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2001-2003 |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 3 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
| 4 | * |
Matthias Fuchs | 21f9d87 | 2009-02-15 22:27:47 +0100 | [diff] [blame] | 5 | * (C) Copyright 2005-2009 |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 6 | * Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 7 | * |
| 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> |
Matthias Fuchs | 21f9d87 | 2009-02-15 22:27:47 +0100 | [diff] [blame] | 29 | #include <asm/io.h> |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 30 | #include <command.h> |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 31 | #include <malloc.h> |
| 32 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 34 | |
stroese | 631ccae | 2004-12-16 18:40:02 +0000 | [diff] [blame] | 35 | extern void lxt971_no_sleep(void); |
| 36 | |
wdenk | da55c6e | 2004-01-20 23:12:12 +0000 | [diff] [blame] | 37 | int board_early_init_f (void) |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 38 | { |
| 39 | /* |
| 40 | * IRQ 0-15 405GP internally generated; active high; level sensitive |
| 41 | * IRQ 16 405GP internally generated; active low; level sensitive |
| 42 | * IRQ 17-24 RESERVED |
| 43 | * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive |
| 44 | * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive |
| 45 | * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive |
| 46 | * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive |
| 47 | * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive |
| 48 | * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive |
| 49 | * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive |
| 50 | */ |
Stefan Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 51 | mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */ |
| 52 | mtdcr(UIC0ER, 0x00000000); /* disable all ints */ |
| 53 | mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/ |
| 54 | mtdcr(UIC0PR, 0xFFFFFF81); /* set int polarities */ |
| 55 | mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */ |
| 56 | mtdcr(UIC0VCR, 0x00000001); /* set vect base=0, INT0 highest priority */ |
| 57 | mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */ |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 58 | |
| 59 | /* |
Matthias Fuchs | f742242 | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 60 | * EBC Configuration Register: |
| 61 | * set ready timeout to 512 ebc-clks -> ca. 15 us |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 62 | */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 63 | mtebc (EBC0_CFG, 0xa8400000); |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 64 | |
stroese | 631ccae | 2004-12-16 18:40:02 +0000 | [diff] [blame] | 65 | /* |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 66 | * Setup GPIO pins |
stroese | 631ccae | 2004-12-16 18:40:02 +0000 | [diff] [blame] | 67 | */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 68 | mtdcr(CPC0_CR0, mfdcr(CPC0_CR0) | ((CONFIG_SYS_FPGA_INIT | |
Stefan Roese | a1edf84 | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 69 | CONFIG_SYS_FPGA_DONE | |
| 70 | CONFIG_SYS_XEREADY | |
| 71 | CONFIG_SYS_NONMONARCH | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 72 | CONFIG_SYS_REV1_2) << 5)); |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 73 | |
Stefan Roese | a1edf84 | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 74 | if (!(in_be32((void *)GPIO0_IR) & CONFIG_SYS_REV1_2)) { |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 75 | /* rev 1.2 boards */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 76 | mtdcr(CPC0_CR0, mfdcr(CPC0_CR0) | ((CONFIG_SYS_INTA_FAKE | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 77 | CONFIG_SYS_SELF_RST) << 5)); |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 78 | } |
| 79 | |
Stefan Roese | a1edf84 | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 80 | out_be32((void *)GPIO0_OR, CONFIG_SYS_VPEN); |
Matthias Fuchs | f742242 | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 81 | /* setup for output */ |
Stefan Roese | a1edf84 | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 82 | out_be32((void *)GPIO0_TCR, CONFIG_SYS_FPGA_PRG | CONFIG_SYS_FPGA_CLK | |
| 83 | CONFIG_SYS_FPGA_DATA | CONFIG_SYS_XEREADY | CONFIG_SYS_VPEN); |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 84 | |
Matthias Fuchs | f742242 | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 85 | /* |
| 86 | * - check if rev1_2 is low, then: |
| 87 | * - set/reset CONFIG_SYS_INTA_FAKE/CONFIG_SYS_SELF_RST |
| 88 | * in TCR to assert INTA# or SELFRST# |
stroese | 631ccae | 2004-12-16 18:40:02 +0000 | [diff] [blame] | 89 | */ |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 90 | return 0; |
| 91 | } |
| 92 | |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 93 | int misc_init_r (void) |
| 94 | { |
stroese | 631ccae | 2004-12-16 18:40:02 +0000 | [diff] [blame] | 95 | /* adjust flash start and offset */ |
| 96 | gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize; |
| 97 | gd->bd->bi_flashoffset = 0; |
| 98 | |
Matthias Fuchs | f742242 | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 99 | /* deassert EREADY# */ |
Stefan Roese | a1edf84 | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 100 | out_be32((void *)GPIO0_OR, |
| 101 | in_be32((void *)GPIO0_OR) | CONFIG_SYS_XEREADY); |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 102 | return (0); |
| 103 | } |
| 104 | |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 105 | ushort pmc405_pci_subsys_deviceid(void) |
| 106 | { |
| 107 | ulong val; |
Stefan Roese | a1edf84 | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 108 | |
| 109 | val = in_be32((void *)GPIO0_IR); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 110 | if (!(val & CONFIG_SYS_REV1_2)) { /* low=rev1.2 */ |
Matthias Fuchs | f742242 | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 111 | /* check monarch# signal */ |
| 112 | if (val & CONFIG_SYS_NONMONARCH) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 113 | return CONFIG_SYS_PCI_SUBSYS_DEVICEID_NONMONARCH; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 114 | return CONFIG_SYS_PCI_SUBSYS_DEVICEID_MONARCH; |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 115 | } |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 116 | return CONFIG_SYS_PCI_SUBSYS_DEVICEID_NONMONARCH; |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 117 | } |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 118 | |
| 119 | /* |
Matthias Fuchs | f742242 | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 120 | * Check Board Identity |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 121 | */ |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 122 | int checkboard (void) |
| 123 | { |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 124 | ulong val; |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 125 | char str[64]; |
Stefan Roese | a1edf84 | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 126 | int i = getenv_r("serial#", str, sizeof(str)); |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 127 | |
| 128 | puts ("Board: "); |
| 129 | |
Matthias Fuchs | f742242 | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 130 | if (i == -1) |
stroese | 93d6508 | 2003-09-12 08:46:58 +0000 | [diff] [blame] | 131 | puts ("### No HW ID - assuming PMC405"); |
Matthias Fuchs | f742242 | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 132 | else |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 133 | puts(str); |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 134 | |
Stefan Roese | a1edf84 | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 135 | val = in_be32((void *)GPIO0_IR); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 136 | if (!(val & CONFIG_SYS_REV1_2)) { /* low=rev1.2 */ |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 137 | puts(" rev1.2 ("); |
Matthias Fuchs | f742242 | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 138 | if (val & CONFIG_SYS_NONMONARCH) /* monarch# signal */ |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 139 | puts("non-"); |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 140 | puts("monarch)"); |
Matthias Fuchs | f742242 | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 141 | } else |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 142 | puts(" <=rev1.1"); |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 143 | |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 144 | putc ('\n'); |
stroese | 631ccae | 2004-12-16 18:40:02 +0000 | [diff] [blame] | 145 | |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 146 | return 0; |
| 147 | } |
| 148 | |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 149 | void reset_phy(void) |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 150 | { |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 151 | #ifdef CONFIG_LXT971_NO_SLEEP |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 152 | |
Stefan Roese | 1c671a9 | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 153 | /* |
| 154 | * Disable sleep mode in LXT971 |
| 155 | */ |
| 156 | lxt971_no_sleep(); |
| 157 | #endif |
stroese | 9f53bf3 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 158 | } |