d21d599fa70ecaa8b6cff4ba2a30b452e287250b
[platform/kernel/u-boot.git] / board / gdsys / neo / neo.c
1 /*
2  * (C) Copyright 2007-2008
3  * Dirk Eibach,  Guntermann & Drunck GmbH, eibach@gdsys.de
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 <command.h>
26 #include <asm/processor.h>
27 #include <asm/io.h>
28
29 #define HWTYPE_CCX16    1
30 #define HWREV_300       3
31
32 int board_early_init_f(void)
33 {
34         mtdcr(UIC0SR, 0xFFFFFFFF);      /* clear all ints */
35         mtdcr(UIC0ER, 0x00000000);      /* disable all ints */
36         mtdcr(UIC0CR, 0x00000000);      /* set all to be non-critical */
37         mtdcr(UIC0PR, 0xFFFFFF80);      /* set int polarities */
38         mtdcr(UIC0TR, 0x10000000);      /* set int trigger levels */
39         mtdcr(UIC0VCR, 0x00000001);     /* set vect base=0,INT0 highest prio */
40         mtdcr(UIC0SR, 0xFFFFFFFF);      /* clear all ints */
41
42         /*
43          * EBC Configuration Register: set ready timeout to 512 ebc-clks
44          * -> ca. 15 us
45          */
46         mtebc(EBC0_CFG, 0xa8400000);    /* ebc always driven */
47
48         return 0;
49 }
50
51 /*
52  * Check Board Identity:
53  */
54 int checkboard(void)
55 {
56         char buf[64];
57         int i = getenv_f("serial#", buf, sizeof(buf));
58         u16 val = in_le16((void *)CONFIG_FPGA_BASE + 2);
59         u8 unit_type;
60         u8 hardware_cpu_ports;
61         u8 hardware_con_ports;
62         u8 hardware_version;
63
64         printf("Board: CATCenter Neo");
65
66         if (i > 0) {
67                 puts(", serial# ");
68                 puts(buf);
69         }
70         puts("\n       ");
71
72         unit_type = (val & 0xf000) >> 12;
73         hardware_cpu_ports = ((val & 0x0f00) >> 8) * 8;
74         hardware_con_ports = ((val & 0x00f0) >> 4) * 2;
75         hardware_version = val & 0x000f;
76
77         switch (unit_type) {
78         case HWTYPE_CCX16:
79                 printf("CCX16-FPGA (80 UARTs)");
80                 break;
81
82         default:
83                 printf("UnitType %d, unsupported", unit_type);
84                 break;
85         }
86
87         printf(", %d cpu ports, %d console ports,",
88                hardware_cpu_ports, hardware_con_ports);
89
90         switch (hardware_version) {
91         case HWREV_300:
92                 printf(" HW-Ver 3.00\n");
93                 break;
94
95         default:
96                 printf(" HW-Ver %d, unsupported\n",
97                        hardware_version);
98                 break;
99         }
100
101         return 0;
102 }