xref: /openbmc/u-boot/board/micronas/vct/vct.c (revision 10980d4a)
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 <netdev.h>
25 #include <asm/mipsregs.h>
26 #include "vct.h"
27 
28 #if defined(CONFIG_VCT_PREMIUM)
29 #define BOARD_NAME	"PremiumD"
30 #elif defined(CONFIG_VCT_PLATINUM)
31 #define BOARD_NAME	"PlatinumD"
32 #elif defined(CONFIG_VCT_PLATINUMAVC)
33 #define BOARD_NAME	"PlatinumAVC"
34 #else
35 #error "vct: No board variant defined!"
36 #endif
37 
38 #if defined(CONFIG_VCT_ONENAND)
39 #define BOARD_NAME_ADD	" OneNAND"
40 #else
41 #define BOARD_NAME_ADD	" NOR"
42 #endif
43 
44 int board_early_init_f(void)
45 {
46 	/*
47 	 * First initialize the PIN mulitplexing
48 	 */
49 	vct_pin_mux_initialize();
50 
51 	/*
52 	 * Init the EBI very early so that FLASH can be accessed
53 	 */
54 	ebi_initialize();
55 
56 	return 0;
57 }
58 
59 void _machine_restart(void)
60 {
61 	reg_write(DCGU_EN_WDT_RESET(DCGU_BASE), DCGU_MAGIC_WDT);
62 	reg_write(WDT_TORR(WDT_BASE), 0x00);
63 	reg_write(WDT_CR(WDT_BASE), 0x1D);
64 
65 	/*
66 	 * Now wait for the watchdog to trigger the reset
67 	 */
68 	udelay(1000000);
69 }
70 
71 /*
72  * SDRAM is already configured by the bootstrap code, only return the
73  * auto-detected size here
74  */
75 phys_size_t initdram(int board_type)
76 {
77 	return get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
78 			    CONFIG_SYS_MBYTES_SDRAM << 20);
79 }
80 
81 int checkboard(void)
82 {
83 	char buf[64];
84 	int i = getenv_f("serial#", buf, sizeof(buf));
85 	u32 config0 = read_c0_prid();
86 
87 	if ((config0 & 0xff0000) == PRID_COMP_LEGACY
88 	    && (config0 & 0xff00) == PRID_IMP_LX4280) {
89 		puts("Board: MDED \n");
90 		printf("CPU:   LX4280 id: 0x%02x, rev: 0x%02x\n",
91 		       (config0 >> 8) & 0xFF, config0 & 0xFF);
92 	} else if ((config0 & 0xff0000) == PRID_COMP_MIPS
93 		   && (config0 & 0xff00) == PRID_IMP_VGC) {
94 		u32 jedec_id = *((u32 *) 0xBEBC71A0);
95 		if ((((jedec_id) >> 12) & 0xFF) == 0x40) {
96 			puts("Board: VGCA \n");
97 		} else if ((((jedec_id) >> 12) & 0xFF) == 0x48
98 			   || (((jedec_id) >> 12) & 0xFF) == 0x49) {
99 			puts("Board: VGCB \n");
100 		}
101 		printf("CPU:   MIPS 4K id: 0x%02x, rev: 0x%02x\n",
102 		       (config0 >> 8) & 0xFF, config0 & 0xFF);
103 	} else if (config0 == 0x19378) {
104 		printf("CPU:   MIPS 24K id: 0x%02x, rev: 0x%02x\n",
105 		       (config0 >> 8) & 0xFF, config0 & 0xFF);
106 	} else {
107 		printf("Unsupported cpu %d, proc_id=0x%x\n", config0 >> 24,
108 		       config0);
109 	}
110 
111 	printf("Board: Micronas VCT " BOARD_NAME BOARD_NAME_ADD);
112 	if (i > 0) {
113 		puts(", serial# ");
114 		puts(buf);
115 	}
116 	putc('\n');
117 
118 	return 0;
119 }
120 
121 int board_eth_init(bd_t *bis)
122 {
123 	int rc = 0;
124 #ifdef CONFIG_SMC911X
125 	rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
126 #endif
127 	return rc;
128 }
129