xref: /openbmc/u-boot/board/micronas/vct/vct.c (revision f62fb999)
1 /*
2  * (C) Copyright 2008 Stefan Roese <sr@denx.de>, DENX Software Engineering
3  *
4  * Copyright (C) 2006 Micronas GmbH
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19  * MA 02111-1307 USA
20  */
21 
22 #include <common.h>
23 #include <command.h>
24 #include <asm/mipsregs.h>
25 #include "vct.h"
26 
27 #if defined(CONFIG_VCT_PREMIUM)
28 #define BOARD_NAME	"PremiumD"
29 #elif defined(CONFIG_VCT_PLATINUM)
30 #define BOARD_NAME	"PlatinumD"
31 #elif defined(CONFIG_VCT_PLATINUMAVC)
32 #define BOARD_NAME	"PlatinumAVC"
33 #else
34 #error "vct: No board variant defined!"
35 #endif
36 
37 #if defined(CONFIG_VCT_ONENAND)
38 #define BOARD_NAME_ADD	" OneNAND"
39 #else
40 #define BOARD_NAME_ADD	" NOR"
41 #endif
42 
43 int board_early_init_f(void)
44 {
45 	/*
46 	 * First initialize the PIN mulitplexing
47 	 */
48 	vct_pin_mux_initialize();
49 
50 	/*
51 	 * Init the EBI very early so that FLASH can be accessed
52 	 */
53 	ebi_initialize();
54 
55 	return 0;
56 }
57 
58 void _machine_restart(void)
59 {
60 	reg_write(DCGU_EN_WDT_RESET(DCGU_BASE), DCGU_MAGIC_WDT);
61 	reg_write(WDT_TORR(WDT_BASE), 0x00);
62 	reg_write(WDT_CR(WDT_BASE), 0x1D);
63 
64 	/*
65 	 * Now wait for the watchdog to trigger the reset
66 	 */
67 	udelay(1000000);
68 }
69 
70 /*
71  * SDRAM is already configured by the bootstrap code, only return the
72  * auto-detected size here
73  */
74 phys_size_t initdram(int board_type)
75 {
76 	return get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
77 			    CONFIG_SYS_MBYTES_SDRAM << 20);
78 }
79 
80 int checkboard(void)
81 {
82 	u32 config0 = read_c0_prid();
83 	char *s = getenv("serial#");
84 
85 	if ((config0 & 0xff0000) == PRID_COMP_LEGACY
86 	    && (config0 & 0xff00) == PRID_IMP_LX4280) {
87 		puts("Board: MDED \n");
88 		printf("CPU:   LX4280 id: 0x%02x, rev: 0x%02x\n",
89 		       (config0 >> 8) & 0xFF, config0 & 0xFF);
90 	} else if ((config0 & 0xff0000) == PRID_COMP_MIPS
91 		   && (config0 & 0xff00) == PRID_IMP_VGC) {
92 		u32 jedec_id = *((u32 *) 0xBEBC71A0);
93 		if ((((jedec_id) >> 12) & 0xFF) == 0x40) {
94 			puts("Board: VGCA \n");
95 		} else if ((((jedec_id) >> 12) & 0xFF) == 0x48
96 			   || (((jedec_id) >> 12) & 0xFF) == 0x49) {
97 			puts("Board: VGCB \n");
98 		}
99 		printf("CPU:   MIPS 4K id: 0x%02x, rev: 0x%02x\n",
100 		       (config0 >> 8) & 0xFF, config0 & 0xFF);
101 	} else if (config0 == 0x19378) {
102 		printf("CPU:   MIPS 24K id: 0x%02x, rev: 0x%02x\n",
103 		       (config0 >> 8) & 0xFF, config0 & 0xFF);
104 	} else {
105 		printf("Unsupported cpu %d, proc_id=0x%x\n", config0 >> 24,
106 		       config0);
107 	}
108 
109 	printf("Board: Micronas VCT " BOARD_NAME BOARD_NAME_ADD);
110 	if (s != NULL) {
111 		puts(", serial# ");
112 		puts(s);
113 	}
114 	putc('\n');
115 
116 	return 0;
117 }
118