blob: 19af875c0e0ee4951966615e0ad8ac103f4a7700 [file] [log] [blame]
Graeme Russa875dda2011-12-23 16:51:29 +11001/*
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>
Stefan Reinauer00651442012-11-03 11:41:29 +000024#include <environment.h>
Simon Glass347c05b2013-02-28 19:26:15 +000025#include <fdtdec.h>
Graeme Russa875dda2011-12-23 16:51:29 +110026#include <serial.h>
27#include <kgdb.h>
28#include <scsi.h>
29#include <post.h>
30#include <miiphy.h>
31
32#include <asm/init_wrappers.h>
33
34int serial_initialize_r(void)
35{
36 serial_initialize();
37
38 return 0;
39}
40
Stefan Reinauer00651442012-11-03 11:41:29 +000041/*
42 * Tell if it's OK to load the environment early in boot.
43 *
44 * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see
45 * if this is OK (defaulting to saying it's not OK).
46 *
47 * NOTE: Loading the environment early can be a bad idea if security is
48 * important, since no verification is done on the environment.
49 *
50 * @return 0 if environment should not be loaded, !=0 if it is ok to load
51 */
52static int should_load_env(void)
53{
54#ifdef CONFIG_OF_CONTROL
55 return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 0);
56#elif defined CONFIG_DELAY_ENVIRONMENT
57 return 0;
58#else
59 return 1;
60#endif
61}
62
Graeme Russa875dda2011-12-23 16:51:29 +110063int env_relocate_r(void)
64{
65 /* initialize environment */
Stefan Reinauer00651442012-11-03 11:41:29 +000066 if (should_load_env())
67 env_relocate();
68 else
69 set_default_env(NULL);
Graeme Russa875dda2011-12-23 16:51:29 +110070
71 return 0;
72}
73
74
75int pci_init_r(void)
76{
77 /* Do pci configuration */
78 pci_init();
79
80 return 0;
81}
82
83int jumptable_init_r(void)
84{
85 jumptable_init();
86
87 return 0;
88}
89
90int pcmcia_init_r(void)
91{
92 puts("PCMCIA:");
93 pcmcia_init();
94
95 return 0;
96}
97
98int kgdb_init_r(void)
99{
100 puts("KGDB: ");
101 kgdb_init();
102
103 return 0;
104}
105
106int enable_interrupts_r(void)
107{
108 /* enable exceptions */
109 enable_interrupts();
110
111 return 0;
112}
113
114int eth_initialize_r(void)
115{
116 puts("Net: ");
117 eth_initialize(gd->bd);
118
119 return 0;
120}
121
122int reset_phy_r(void)
123{
124#ifdef DEBUG
125 puts("Reset Ethernet PHY\n");
126#endif
127 reset_phy();
128
129 return 0;
130}
131
132int ide_init_r(void)
133{
134 puts("IDE: ");
135 ide_init();
136
137 return 0;
138}
139
140int scsi_init_r(void)
141{
142 puts("SCSI: ");
143 scsi_init();
144
145 return 0;
146}
147
148#ifdef CONFIG_BITBANGMII
149int bb_miiphy_init_r(void)
150{
151 bb_miiphy_init();
152
153 return 0;
154}
155#endif
156
157#ifdef CONFIG_POST
158int post_run_r(void)
159{
160 post_run(NULL, POST_RAM | post_bootmode_get(0));
161
162 return 0;
163}
164#endif