stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2001-2003 |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 3 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
| 4 | * |
Matthias Fuchs | 2f6eb91 | 2009-02-15 22:27:47 +0100 | [diff] [blame] | 5 | * (C) Copyright 2005-2009 |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 6 | * Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 7 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <common.h> |
| 12 | #include <asm/processor.h> |
Matthias Fuchs | 2f6eb91 | 2009-02-15 22:27:47 +0100 | [diff] [blame] | 13 | #include <asm/io.h> |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 14 | #include <command.h> |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 15 | #include <malloc.h> |
| 16 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 17 | DECLARE_GLOBAL_DATA_PTR; |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 18 | |
stroese | 4510a7b | 2004-12-16 18:40:02 +0000 | [diff] [blame] | 19 | extern void lxt971_no_sleep(void); |
| 20 | |
wdenk | c837dcb | 2004-01-20 23:12:12 +0000 | [diff] [blame] | 21 | int board_early_init_f (void) |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 22 | { |
| 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 Roese | 952e776 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 35 | 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 */ |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 42 | |
| 43 | /* |
Matthias Fuchs | c553b5f | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 44 | * EBC Configuration Register: |
| 45 | * set ready timeout to 512 ebc-clks -> ca. 15 us |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 46 | */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 47 | mtebc (EBC0_CFG, 0xa8400000); |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 48 | |
stroese | 4510a7b | 2004-12-16 18:40:02 +0000 | [diff] [blame] | 49 | /* |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 50 | * Setup GPIO pins |
stroese | 4510a7b | 2004-12-16 18:40:02 +0000 | [diff] [blame] | 51 | */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 52 | mtdcr(CPC0_CR0, mfdcr(CPC0_CR0) | ((CONFIG_SYS_FPGA_INIT | |
Stefan Roese | f50fe4b | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 53 | CONFIG_SYS_FPGA_DONE | |
| 54 | CONFIG_SYS_XEREADY | |
| 55 | CONFIG_SYS_NONMONARCH | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 56 | CONFIG_SYS_REV1_2) << 5)); |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 57 | |
Stefan Roese | f50fe4b | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 58 | if (!(in_be32((void *)GPIO0_IR) & CONFIG_SYS_REV1_2)) { |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 59 | /* rev 1.2 boards */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 60 | mtdcr(CPC0_CR0, mfdcr(CPC0_CR0) | ((CONFIG_SYS_INTA_FAKE | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 61 | CONFIG_SYS_SELF_RST) << 5)); |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 62 | } |
| 63 | |
Stefan Roese | f50fe4b | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 64 | out_be32((void *)GPIO0_OR, CONFIG_SYS_VPEN); |
Matthias Fuchs | c553b5f | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 65 | /* setup for output */ |
Stefan Roese | f50fe4b | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 66 | 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 Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 68 | |
Matthias Fuchs | c553b5f | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 69 | /* |
| 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# |
stroese | 4510a7b | 2004-12-16 18:40:02 +0000 | [diff] [blame] | 73 | */ |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 74 | return 0; |
| 75 | } |
| 76 | |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 77 | int misc_init_r (void) |
| 78 | { |
stroese | 4510a7b | 2004-12-16 18:40:02 +0000 | [diff] [blame] | 79 | /* adjust flash start and offset */ |
| 80 | gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize; |
| 81 | gd->bd->bi_flashoffset = 0; |
| 82 | |
Matthias Fuchs | c553b5f | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 83 | /* deassert EREADY# */ |
Stefan Roese | f50fe4b | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 84 | out_be32((void *)GPIO0_OR, |
| 85 | in_be32((void *)GPIO0_OR) | CONFIG_SYS_XEREADY); |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 86 | return (0); |
| 87 | } |
| 88 | |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 89 | ushort pmc405_pci_subsys_deviceid(void) |
| 90 | { |
| 91 | ulong val; |
Stefan Roese | f50fe4b | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 92 | |
| 93 | val = in_be32((void *)GPIO0_IR); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 94 | if (!(val & CONFIG_SYS_REV1_2)) { /* low=rev1.2 */ |
Matthias Fuchs | c553b5f | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 95 | /* check monarch# signal */ |
| 96 | if (val & CONFIG_SYS_NONMONARCH) |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 97 | return CONFIG_SYS_PCI_SUBSYS_DEVICEID_NONMONARCH; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 98 | return CONFIG_SYS_PCI_SUBSYS_DEVICEID_MONARCH; |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 99 | } |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 100 | return CONFIG_SYS_PCI_SUBSYS_DEVICEID_NONMONARCH; |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 101 | } |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 102 | |
| 103 | /* |
Matthias Fuchs | c553b5f | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 104 | * Check Board Identity |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 105 | */ |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 106 | int checkboard (void) |
| 107 | { |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 108 | ulong val; |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 109 | char str[64]; |
Wolfgang Denk | cdb7497 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 110 | int i = getenv_f("serial#", str, sizeof(str)); |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 111 | |
| 112 | puts ("Board: "); |
| 113 | |
Matthias Fuchs | c553b5f | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 114 | if (i == -1) |
stroese | ef9e868 | 2003-09-12 08:46:58 +0000 | [diff] [blame] | 115 | puts ("### No HW ID - assuming PMC405"); |
Matthias Fuchs | c553b5f | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 116 | else |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 117 | puts(str); |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 118 | |
Stefan Roese | f50fe4b | 2009-02-18 14:05:37 +0100 | [diff] [blame] | 119 | val = in_be32((void *)GPIO0_IR); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 120 | if (!(val & CONFIG_SYS_REV1_2)) { /* low=rev1.2 */ |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 121 | puts(" rev1.2 ("); |
Matthias Fuchs | c553b5f | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 122 | if (val & CONFIG_SYS_NONMONARCH) /* monarch# signal */ |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 123 | puts("non-"); |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 124 | puts("monarch)"); |
Matthias Fuchs | c553b5f | 2009-02-15 22:26:54 +0100 | [diff] [blame] | 125 | } else |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 126 | puts(" <=rev1.1"); |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 127 | |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 128 | putc ('\n'); |
stroese | 4510a7b | 2004-12-16 18:40:02 +0000 | [diff] [blame] | 129 | |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 130 | return 0; |
| 131 | } |
| 132 | |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 133 | void reset_phy(void) |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 134 | { |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 135 | #ifdef CONFIG_LXT971_NO_SLEEP |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 136 | |
Stefan Roese | 2076d0a | 2006-01-18 20:03:15 +0100 | [diff] [blame] | 137 | /* |
| 138 | * Disable sleep mode in LXT971 |
| 139 | */ |
| 140 | lxt971_no_sleep(); |
| 141 | #endif |
stroese | 071d897 | 2003-05-23 11:35:47 +0000 | [diff] [blame] | 142 | } |