xref: /rk3399_rockchip-uboot/arch/x86/lib/init_helpers.c (revision d47ab0ecde1c9a66acbaf421ddd92c888d2ef344)
1 /*
2  * (C) Copyright 2011
3  * Graeme Russ, <graeme.russ@gmail.com>
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 #include <common.h>
24 #include <command.h>
25 #include <stdio_dev.h>
26 #include <version.h>
27 #include <malloc.h>
28 #include <net.h>
29 #include <ide.h>
30 #include <serial.h>
31 #include <status_led.h>
32 #include <asm/u-boot-x86.h>
33 
34 #include <asm/init_helpers.h>
35 
36 DECLARE_GLOBAL_DATA_PTR;
37 
38 /************************************************************************
39  * Init Utilities							*
40  ************************************************************************
41  * Some of this code should be moved into the core functions,
42  * or dropped completely,
43  * but let's get it working (again) first...
44  */
45 
46 int display_banner(void)
47 {
48 	printf("\n\n%s\n\n", version_string);
49 
50 	return 0;
51 }
52 
53 int display_dram_config(void)
54 {
55 	int i;
56 
57 	puts("DRAM Configuration:\n");
58 
59 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
60 		printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
61 		print_size(gd->bd->bi_dram[i].size, "\n");
62 	}
63 
64 	return 0;
65 }
66 
67 int init_baudrate_f(void)
68 {
69 	gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
70 	return 0;
71 }
72 
73 int mem_malloc_init_r(void)
74 {
75 	mem_malloc_init(((gd->relocaddr - CONFIG_SYS_MALLOC_LEN)+3)&~3,
76 			CONFIG_SYS_MALLOC_LEN);
77 
78 	return 0;
79 }
80 
81 bd_t bd_data;
82 
83 int init_bd_struct_r(void)
84 {
85 	gd->bd = &bd_data;
86 	memset(gd->bd, 0, sizeof(bd_t));
87 
88 	return 0;
89 }
90 
91 #ifndef CONFIG_SYS_NO_FLASH
92 int flash_init_r(void)
93 {
94 	ulong size;
95 
96 	puts("Flash: ");
97 
98 	/* configure available FLASH banks */
99 	size = flash_init();
100 
101 	print_size(size, "\n");
102 
103 	return 0;
104 }
105 #endif
106 
107 int init_ip_address_r(void)
108 {
109 	/* IP Address */
110 	bd_data.bi_ip_addr = getenv_IPaddr("ipaddr");
111 
112 	return 0;
113 }
114 
115 #ifdef CONFIG_STATUS_LED
116 int status_led_set_r(void)
117 {
118 	status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
119 
120 	return 0;
121 }
122 #endif
123 
124 int set_bootfile_r(void)
125 {
126 	char *s;
127 
128 	s = getenv("bootfile");
129 
130 	if (s != NULL)
131 		copy_filename(BootFile, s, sizeof(BootFile));
132 
133 	return 0;
134 }
135 
136 int set_load_addr_r(void)
137 {
138 	/* Initialize from environment */
139 	load_addr = getenv_ulong("loadaddr", 16, load_addr);
140 
141 	return 0;
142 }
143