xref: /rk3399_rockchip-uboot/board/micronas/vct/vct.c (revision 00caae6d47645e68d6e5277aceb69592b49381a6)
1ae691e57SStefan Roese /*
2ae691e57SStefan Roese  * (C) Copyright 2008 Stefan Roese <sr@denx.de>, DENX Software Engineering
3ae691e57SStefan Roese  *
4ae691e57SStefan Roese  * Copyright (C) 2006 Micronas GmbH
5ae691e57SStefan Roese  *
61a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
7ae691e57SStefan Roese  */
8ae691e57SStefan Roese 
9ae691e57SStefan Roese #include <common.h>
10ae691e57SStefan Roese #include <command.h>
11736fead8SBen Warren #include <netdev.h>
12ae691e57SStefan Roese #include <asm/mipsregs.h>
13ae691e57SStefan Roese #include "vct.h"
14ae691e57SStefan Roese 
15ae691e57SStefan Roese #if defined(CONFIG_VCT_PREMIUM)
16ae691e57SStefan Roese #define BOARD_NAME	"PremiumD"
17ae691e57SStefan Roese #elif defined(CONFIG_VCT_PLATINUM)
18ae691e57SStefan Roese #define BOARD_NAME	"PlatinumD"
19ae691e57SStefan Roese #elif defined(CONFIG_VCT_PLATINUMAVC)
20ae691e57SStefan Roese #define BOARD_NAME	"PlatinumAVC"
21ae691e57SStefan Roese #else
22ae691e57SStefan Roese #error "vct: No board variant defined!"
23ae691e57SStefan Roese #endif
24ae691e57SStefan Roese 
25ae691e57SStefan Roese #if defined(CONFIG_VCT_ONENAND)
26ae691e57SStefan Roese #define BOARD_NAME_ADD	" OneNAND"
27ae691e57SStefan Roese #else
28ae691e57SStefan Roese #define BOARD_NAME_ADD	" NOR"
29ae691e57SStefan Roese #endif
30ae691e57SStefan Roese 
31088454cdSSimon Glass DECLARE_GLOBAL_DATA_PTR;
32088454cdSSimon Glass 
board_early_init_f(void)33ae691e57SStefan Roese int board_early_init_f(void)
34ae691e57SStefan Roese {
35ae691e57SStefan Roese 	/*
36ae691e57SStefan Roese 	 * First initialize the PIN mulitplexing
37ae691e57SStefan Roese 	 */
38ae691e57SStefan Roese 	vct_pin_mux_initialize();
39ae691e57SStefan Roese 
40ae691e57SStefan Roese 	/*
41ae691e57SStefan Roese 	 * Init the EBI very early so that FLASH can be accessed
42ae691e57SStefan Roese 	 */
43ae691e57SStefan Roese 	ebi_initialize();
44ae691e57SStefan Roese 
45ae691e57SStefan Roese 	return 0;
46ae691e57SStefan Roese }
47ae691e57SStefan Roese 
_machine_restart(void)48ae691e57SStefan Roese void _machine_restart(void)
49ae691e57SStefan Roese {
50ae691e57SStefan Roese 	reg_write(DCGU_EN_WDT_RESET(DCGU_BASE), DCGU_MAGIC_WDT);
51ae691e57SStefan Roese 	reg_write(WDT_TORR(WDT_BASE), 0x00);
52ae691e57SStefan Roese 	reg_write(WDT_CR(WDT_BASE), 0x1D);
53ae691e57SStefan Roese 
54ae691e57SStefan Roese 	/*
55ae691e57SStefan Roese 	 * Now wait for the watchdog to trigger the reset
56ae691e57SStefan Roese 	 */
57ae691e57SStefan Roese 	udelay(1000000);
58ae691e57SStefan Roese }
59ae691e57SStefan Roese 
60ae691e57SStefan Roese /*
61ae691e57SStefan Roese  * SDRAM is already configured by the bootstrap code, only return the
62ae691e57SStefan Roese  * auto-detected size here
63ae691e57SStefan Roese  */
dram_init(void)64f1683aa7SSimon Glass int dram_init(void)
65ae691e57SStefan Roese {
66088454cdSSimon Glass 	gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
67ae691e57SStefan Roese 			    CONFIG_SYS_MBYTES_SDRAM << 20);
68088454cdSSimon Glass 
69088454cdSSimon Glass 	return 0;
70ae691e57SStefan Roese }
71ae691e57SStefan Roese 
checkboard(void)72ae691e57SStefan Roese int checkboard(void)
73ae691e57SStefan Roese {
74f0c0b3a9SWolfgang Denk 	char buf[64];
75*00caae6dSSimon Glass 	int i = env_get_f("serial#", buf, sizeof(buf));
76ae691e57SStefan Roese 	u32 config0 = read_c0_prid();
77ae691e57SStefan Roese 
78ae691e57SStefan Roese 	if ((config0 & 0xff0000) == PRID_COMP_LEGACY
79ae691e57SStefan Roese 	    && (config0 & 0xff00) == PRID_IMP_LX4280) {
80ae691e57SStefan Roese 		puts("Board: MDED \n");
81ae691e57SStefan Roese 		printf("CPU:   LX4280 id: 0x%02x, rev: 0x%02x\n",
82ae691e57SStefan Roese 		       (config0 >> 8) & 0xFF, config0 & 0xFF);
83ae691e57SStefan Roese 	} else if ((config0 & 0xff0000) == PRID_COMP_MIPS
84ae691e57SStefan Roese 		   && (config0 & 0xff00) == PRID_IMP_VGC) {
85ae691e57SStefan Roese 		u32 jedec_id = *((u32 *) 0xBEBC71A0);
86ae691e57SStefan Roese 		if ((((jedec_id) >> 12) & 0xFF) == 0x40) {
87ae691e57SStefan Roese 			puts("Board: VGCA \n");
88ae691e57SStefan Roese 		} else if ((((jedec_id) >> 12) & 0xFF) == 0x48
89ae691e57SStefan Roese 			   || (((jedec_id) >> 12) & 0xFF) == 0x49) {
90ae691e57SStefan Roese 			puts("Board: VGCB \n");
91ae691e57SStefan Roese 		}
92ae691e57SStefan Roese 		printf("CPU:   MIPS 4K id: 0x%02x, rev: 0x%02x\n",
93ae691e57SStefan Roese 		       (config0 >> 8) & 0xFF, config0 & 0xFF);
94ae691e57SStefan Roese 	} else if (config0 == 0x19378) {
95ae691e57SStefan Roese 		printf("CPU:   MIPS 24K id: 0x%02x, rev: 0x%02x\n",
96ae691e57SStefan Roese 		       (config0 >> 8) & 0xFF, config0 & 0xFF);
97ae691e57SStefan Roese 	} else {
98ae691e57SStefan Roese 		printf("Unsupported cpu %d, proc_id=0x%x\n", config0 >> 24,
99ae691e57SStefan Roese 		       config0);
100ae691e57SStefan Roese 	}
101ae691e57SStefan Roese 
102ae691e57SStefan Roese 	printf("Board: Micronas VCT " BOARD_NAME BOARD_NAME_ADD);
103f0c0b3a9SWolfgang Denk 	if (i > 0) {
104ae691e57SStefan Roese 		puts(", serial# ");
105f0c0b3a9SWolfgang Denk 		puts(buf);
106ae691e57SStefan Roese 	}
107ae691e57SStefan Roese 	putc('\n');
108ae691e57SStefan Roese 
109ae691e57SStefan Roese 	return 0;
110ae691e57SStefan Roese }
111736fead8SBen Warren 
board_eth_init(bd_t * bis)112736fead8SBen Warren int board_eth_init(bd_t *bis)
113736fead8SBen Warren {
114736fead8SBen Warren 	int rc = 0;
115736fead8SBen Warren #ifdef CONFIG_SMC911X
116736fead8SBen Warren 	rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
117736fead8SBen Warren #endif
118736fead8SBen Warren 	return rc;
119736fead8SBen Warren }
120