Graeme Russ | a875dda | 2011-12-23 16:51:29 +1100 | [diff] [blame] | 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> |
Stefan Reinauer | 0065144 | 2012-11-03 11:41:29 +0000 | [diff] [blame] | 24 | #include <environment.h> |
Simon Glass | 347c05b | 2013-02-28 19:26:15 +0000 | [diff] [blame] | 25 | #include <fdtdec.h> |
Graeme Russ | a875dda | 2011-12-23 16:51:29 +1100 | [diff] [blame] | 26 | #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 | |
| 34 | int serial_initialize_r(void) |
| 35 | { |
| 36 | serial_initialize(); |
| 37 | |
| 38 | return 0; |
| 39 | } |
| 40 | |
Stefan Reinauer | 0065144 | 2012-11-03 11:41:29 +0000 | [diff] [blame] | 41 | /* |
| 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 | */ |
| 52 | static 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 Russ | a875dda | 2011-12-23 16:51:29 +1100 | [diff] [blame] | 63 | int env_relocate_r(void) |
| 64 | { |
| 65 | /* initialize environment */ |
Stefan Reinauer | 0065144 | 2012-11-03 11:41:29 +0000 | [diff] [blame] | 66 | if (should_load_env()) |
| 67 | env_relocate(); |
| 68 | else |
| 69 | set_default_env(NULL); |
Graeme Russ | a875dda | 2011-12-23 16:51:29 +1100 | [diff] [blame] | 70 | |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | |
| 75 | int pci_init_r(void) |
| 76 | { |
| 77 | /* Do pci configuration */ |
| 78 | pci_init(); |
| 79 | |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | int jumptable_init_r(void) |
| 84 | { |
| 85 | jumptable_init(); |
| 86 | |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | int pcmcia_init_r(void) |
| 91 | { |
| 92 | puts("PCMCIA:"); |
| 93 | pcmcia_init(); |
| 94 | |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | int kgdb_init_r(void) |
| 99 | { |
| 100 | puts("KGDB: "); |
| 101 | kgdb_init(); |
| 102 | |
| 103 | return 0; |
| 104 | } |
| 105 | |
| 106 | int enable_interrupts_r(void) |
| 107 | { |
| 108 | /* enable exceptions */ |
| 109 | enable_interrupts(); |
| 110 | |
| 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | int eth_initialize_r(void) |
| 115 | { |
| 116 | puts("Net: "); |
| 117 | eth_initialize(gd->bd); |
| 118 | |
| 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | int 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 | |
| 132 | int ide_init_r(void) |
| 133 | { |
| 134 | puts("IDE: "); |
| 135 | ide_init(); |
| 136 | |
| 137 | return 0; |
| 138 | } |
| 139 | |
| 140 | int scsi_init_r(void) |
| 141 | { |
| 142 | puts("SCSI: "); |
| 143 | scsi_init(); |
| 144 | |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | #ifdef CONFIG_BITBANGMII |
| 149 | int bb_miiphy_init_r(void) |
| 150 | { |
| 151 | bb_miiphy_init(); |
| 152 | |
| 153 | return 0; |
| 154 | } |
| 155 | #endif |
| 156 | |
| 157 | #ifdef CONFIG_POST |
| 158 | int post_run_r(void) |
| 159 | { |
| 160 | post_run(NULL, POST_RAM | post_bootmode_get(0)); |
| 161 | |
| 162 | return 0; |
| 163 | } |
| 164 | #endif |