Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2005 |
| 3 | * Travis B. Sawyer, Sandburst Corporation, tsawyer@sandburst.com |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 6 | */ |
| 7 | #include <config.h> |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 10 | #include "metrobox.h" |
| 11 | #include "metrobox_version.h" |
Peter Tyser | 561858e | 2008-11-03 09:30:59 -0600 | [diff] [blame] | 12 | #include <timestamp.h> |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 13 | #include <asm/processor.h> |
| 14 | #include <asm/io.h> |
| 15 | #include <spd_sdram.h> |
| 16 | #include <i2c.h> |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 17 | #include "../common/sb_common.h" |
Wolfgang Denk | d2567be | 2009-03-28 20:16:16 +0100 | [diff] [blame] | 18 | #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) || \ |
| 19 | defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3) |
| 20 | #include <net.h> |
| 21 | #endif |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 22 | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 23 | void fpga_init (void); |
| 24 | |
| 25 | METROBOX_BOARD_ID_ST board_id_as[] = |
| 26 | { {"Undefined"}, /* Not specified */ |
| 27 | {"2x10Gb"}, /* 2 ports, 10 GbE */ |
| 28 | {"20x1Gb"}, /* 20 ports, 1 GbE */ |
| 29 | {"Reserved"}, /* Reserved for future use */ |
| 30 | }; |
| 31 | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 32 | /************************************************************************* |
| 33 | * board_early_init_f |
| 34 | * |
| 35 | * Setup chip selects, initialize the Opto-FPGA, initialize |
| 36 | * interrupt polarity and triggers. |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 37 | ************************************************************************/ |
| 38 | int board_early_init_f (void) |
| 39 | { |
| 40 | ppc440_gpio_regs_t *gpio_regs; |
| 41 | |
| 42 | /* Enable GPIO interrupts */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 43 | mtsdr(SDR0_PFC0, 0x00103E00); |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 44 | |
| 45 | /* Setup access for LEDs, and system topology info */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 46 | gpio_regs = (ppc440_gpio_regs_t *)CONFIG_SYS_GPIO_BASE; |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 47 | gpio_regs->open_drain = SBCOMMON_GPIO_SYS_LEDS; |
| 48 | gpio_regs->tri_state = SBCOMMON_GPIO_DBGLEDS; |
| 49 | |
| 50 | /* Turn on all the leds for now */ |
| 51 | gpio_regs->out = SBCOMMON_GPIO_LEDS; |
| 52 | |
| 53 | /*--------------------------------------------------------------------+ |
| 54 | | Initialize EBC CONFIG |
| 55 | +-------------------------------------------------------------------*/ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 56 | mtebc(EBC0_CFG, |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 57 | EBC_CFG_LE_UNLOCK | EBC_CFG_PTD_ENABLE | |
| 58 | EBC_CFG_RTC_64PERCLK | EBC_CFG_ATC_PREVIOUS | |
| 59 | EBC_CFG_DTC_PREVIOUS | EBC_CFG_CTC_PREVIOUS | |
| 60 | EBC_CFG_EMC_DEFAULT | EBC_CFG_PME_DISABLE | |
| 61 | EBC_CFG_PR_32); |
| 62 | |
| 63 | /*--------------------------------------------------------------------+ |
| 64 | | 1/2 MB FLASH. Initialize bank 0 with default values. |
| 65 | +-------------------------------------------------------------------*/ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 66 | mtebc(PB0AP, |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 67 | EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(8) | |
| 68 | EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) | |
| 69 | EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) | |
| 70 | EBC_BXAP_WBF_ENCODE(1)| EBC_BXAP_TH_ENCODE(1) | |
| 71 | EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY | |
| 72 | EBC_BXAP_PEN_DISABLED); |
| 73 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 74 | mtebc(PB0CR, EBC_BXCR_BAS_ENCODE(CONFIG_SYS_FLASH_BASE) | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 75 | EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_8BIT); |
| 76 | /*--------------------------------------------------------------------+ |
| 77 | | 8KB NVRAM/RTC. Initialize bank 1 with default values. |
| 78 | +-------------------------------------------------------------------*/ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 79 | mtebc(PB1AP, |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 80 | EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(10) | |
| 81 | EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) | |
| 82 | EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) | |
| 83 | EBC_BXAP_WBF_ENCODE(1)| EBC_BXAP_TH_ENCODE(1) | |
| 84 | EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY | |
| 85 | EBC_BXAP_PEN_DISABLED); |
| 86 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 87 | mtebc(PB1CR, EBC_BXCR_BAS_ENCODE(0x48000000) | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 88 | EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_8BIT); |
| 89 | |
| 90 | /*--------------------------------------------------------------------+ |
| 91 | | Compact Flash, uses 2 Chip Selects (2 & 6) |
| 92 | +-------------------------------------------------------------------*/ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 93 | mtebc(PB2AP, |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 94 | EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(8) | |
| 95 | EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) | |
| 96 | EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) | |
| 97 | EBC_BXAP_WBF_ENCODE(0)| EBC_BXAP_TH_ENCODE(1) | |
| 98 | EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY | |
| 99 | EBC_BXAP_PEN_DISABLED); |
| 100 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 101 | mtebc(PB2CR, EBC_BXCR_BAS_ENCODE(0xF0000000) | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 102 | EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_16BIT); |
| 103 | |
| 104 | /*--------------------------------------------------------------------+ |
| 105 | | OPTO & OFEM FPGA. Initialize bank 3 with default values. |
| 106 | +-------------------------------------------------------------------*/ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 107 | mtebc(PB3AP, |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 108 | EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED | |
| 109 | EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) | |
| 110 | EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) | |
| 111 | EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED | |
| 112 | EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW); |
| 113 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 114 | mtebc(PB3CR, EBC_BXCR_BAS_ENCODE(0x48200000) | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 115 | EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT); |
| 116 | |
| 117 | /*--------------------------------------------------------------------+ |
| 118 | | MAC A for metrobox |
| 119 | | MAC A & B for Kamino. OFEM FPGA decodes the addresses |
| 120 | | Initialize bank 4 with default values. |
| 121 | +-------------------------------------------------------------------*/ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 122 | mtebc(PB4AP, |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 123 | EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED | |
| 124 | EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) | |
| 125 | EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) | |
| 126 | EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED | |
| 127 | EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW); |
| 128 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 129 | mtebc(PB4CR, EBC_BXCR_BAS_ENCODE(0x48600000) | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 130 | EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT); |
| 131 | |
| 132 | /*--------------------------------------------------------------------+ |
| 133 | | Metrobox MAC B Initialize bank 5 with default values. |
| 134 | | KA REF FPGA Initialize bank 5 with default values. |
| 135 | +-------------------------------------------------------------------*/ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 136 | mtebc(PB5AP, |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 137 | EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED | |
| 138 | EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) | |
| 139 | EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) | |
| 140 | EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED | |
| 141 | EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW); |
| 142 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 143 | mtebc(PB5CR, EBC_BXCR_BAS_ENCODE(0x48700000) | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 144 | EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT); |
| 145 | |
| 146 | /*--------------------------------------------------------------------+ |
| 147 | | Compact Flash, uses 2 Chip Selects (2 & 6) |
| 148 | +-------------------------------------------------------------------*/ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 149 | mtebc(PB6AP, |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 150 | EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(8) | |
| 151 | EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) | |
| 152 | EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) | |
| 153 | EBC_BXAP_WBF_ENCODE(0)| EBC_BXAP_TH_ENCODE(1) | |
| 154 | EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY | |
| 155 | EBC_BXAP_PEN_DISABLED); |
| 156 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 157 | mtebc(PB6CR, EBC_BXCR_BAS_ENCODE(0xF0100000) | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 158 | EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_16BIT); |
| 159 | |
| 160 | /*--------------------------------------------------------------------+ |
| 161 | | BME-32. Initialize bank 7 with default values. |
| 162 | +-------------------------------------------------------------------*/ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 163 | mtebc(PB7AP, |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 164 | EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED | |
| 165 | EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) | |
| 166 | EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) | |
| 167 | EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED | |
| 168 | EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW); |
| 169 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 170 | mtebc(PB7CR, EBC_BXCR_BAS_ENCODE(0x48500000) | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 171 | EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT); |
| 172 | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 173 | /*--------------------------------------------------------------------+ |
| 174 | * Setup the interrupt controller polarities, triggers, etc. |
| 175 | +-------------------------------------------------------------------*/ |
Stefan Roese | 5de8514 | 2008-06-26 17:36:39 +0200 | [diff] [blame] | 176 | /* |
| 177 | * Because of the interrupt handling rework to handle 440GX interrupts |
| 178 | * with the common code, we needed to change names of the UIC registers. |
| 179 | * Here the new relationship: |
| 180 | * |
| 181 | * U-Boot name 440GX name |
| 182 | * ----------------------- |
| 183 | * UIC0 UICB0 |
| 184 | * UIC1 UIC0 |
| 185 | * UIC2 UIC1 |
| 186 | * UIC3 UIC2 |
| 187 | */ |
Stefan Roese | 952e776 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 188 | mtdcr (UIC1SR, 0xffffffff); /* clear all */ |
| 189 | mtdcr (UIC1ER, 0x00000000); /* disable all */ |
| 190 | mtdcr (UIC1CR, 0x00000000); /* all non- critical */ |
| 191 | mtdcr (UIC1PR, 0xfffffe03); /* polarity */ |
| 192 | mtdcr (UIC1TR, 0x01c00000); /* trigger edge vs level */ |
| 193 | mtdcr (UIC1VR, 0x00000001); /* int31 highest, base=0x000 */ |
| 194 | mtdcr (UIC1SR, 0xffffffff); /* clear all */ |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 195 | |
Stefan Roese | 952e776 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 196 | mtdcr (UIC2SR, 0xffffffff); /* clear all */ |
| 197 | mtdcr (UIC2ER, 0x00000000); /* disable all */ |
| 198 | mtdcr (UIC2CR, 0x00000000); /* all non-critical */ |
| 199 | mtdcr (UIC2PR, 0xffffc8ff); /* polarity */ |
| 200 | mtdcr (UIC2TR, 0x00ff0000); /* trigger edge vs level */ |
| 201 | mtdcr (UIC2VR, 0x00000001); /* int31 highest, base=0x000 */ |
| 202 | mtdcr (UIC2SR, 0xffffffff); /* clear all */ |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 203 | |
Stefan Roese | 952e776 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 204 | mtdcr (UIC3SR, 0xffffffff); /* clear all */ |
| 205 | mtdcr (UIC3ER, 0x00000000); /* disable all */ |
| 206 | mtdcr (UIC3CR, 0x00000000); /* all non-critical */ |
| 207 | mtdcr (UIC3PR, 0xffff83ff); /* polarity */ |
| 208 | mtdcr (UIC3TR, 0x00ff8c0f); /* trigger edge vs level */ |
| 209 | mtdcr (UIC3VR, 0x00000001); /* int31 highest, base=0x000 */ |
| 210 | mtdcr (UIC3SR, 0xffffffff); /* clear all */ |
Stefan Roese | 5de8514 | 2008-06-26 17:36:39 +0200 | [diff] [blame] | 211 | |
Stefan Roese | 952e776 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 212 | mtdcr (UIC0SR, 0xfc000000); /* clear all */ |
| 213 | mtdcr (UIC0ER, 0x00000000); /* disable all */ |
| 214 | mtdcr (UIC0CR, 0x00000000); /* all non-critical */ |
| 215 | mtdcr (UIC0PR, 0xfc000000); |
| 216 | mtdcr (UIC0TR, 0x00000000); |
| 217 | mtdcr (UIC0VR, 0x00000001); |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 218 | |
| 219 | fpga_init(); |
| 220 | |
| 221 | return 0; |
| 222 | } |
| 223 | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 224 | /************************************************************************* |
| 225 | * checkboard |
| 226 | * |
| 227 | * Dump pertinent info to the console |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 228 | ************************************************************************/ |
| 229 | int checkboard (void) |
| 230 | { |
| 231 | sys_info_t sysinfo; |
| 232 | unsigned char brd_rev, brd_id; |
| 233 | unsigned short sernum; |
| 234 | unsigned char opto_rev, opto_id; |
| 235 | OPTO_FPGA_REGS_ST *opto_ps; |
| 236 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 237 | opto_ps = (OPTO_FPGA_REGS_ST *)CONFIG_SYS_FPGA_BASE; |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 238 | |
| 239 | opto_rev = (unsigned char)((opto_ps->revision_ul & |
| 240 | SAND_HAL_XC_XCVR_CNTL_REVISION_REVISION_MASK) |
| 241 | >> SAND_HAL_XC_XCVR_CNTL_REVISION_REVISION_SHIFT); |
| 242 | |
| 243 | opto_id = (unsigned char)((opto_ps->revision_ul & |
| 244 | SAND_HAL_XC_XCVR_CNTL_REVISION_IDENTIFICATION_MASK) |
| 245 | >> SAND_HAL_XC_XCVR_CNTL_REVISION_IDENTIFICATION_SHIFT); |
| 246 | |
| 247 | brd_rev = (unsigned char)((opto_ps->boardinfo_ul & |
| 248 | SAND_HAL_XC_XCVR_CNTL_BRD_INFO_BRD_REV_MASK) |
| 249 | >> SAND_HAL_XC_XCVR_CNTL_BRD_INFO_BRD_REV_SHIFT); |
| 250 | |
| 251 | brd_id = (unsigned char)((opto_ps->boardinfo_ul & |
| 252 | SAND_HAL_XC_XCVR_CNTL_BRD_INFO_BRD_ID_MASK) |
| 253 | >> SAND_HAL_XC_XCVR_CNTL_BRD_INFO_BRD_ID_SHIFT); |
| 254 | |
| 255 | get_sys_info (&sysinfo); |
| 256 | |
| 257 | sernum = sbcommon_get_serial_number(); |
| 258 | printf ("Board: Sandburst Corporation MetroBox Serial Number: %d\n", sernum); |
| 259 | printf ("%s\n", METROBOX_U_BOOT_REL_STR); |
| 260 | |
Peter Tyser | 561858e | 2008-11-03 09:30:59 -0600 | [diff] [blame] | 261 | printf ("Built %s %s by %s\n", U_BOOT_DATE, U_BOOT_TIME, BUILDUSER); |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 262 | if (sbcommon_get_master()) { |
| 263 | printf("Slot 0 - Master\nSlave board"); |
| 264 | if (sbcommon_secondary_present()) |
| 265 | printf(" present\n"); |
| 266 | else |
| 267 | printf(" not detected\n"); |
| 268 | } else { |
| 269 | printf("Slot 1 - Slave\n\n"); |
| 270 | } |
| 271 | |
| 272 | printf ("OptoFPGA ID:\t0x%02X\tRev: 0x%02X\n", opto_id, opto_rev); |
Wolfgang Denk | bde6358 | 2008-07-11 22:56:11 +0200 | [diff] [blame] | 273 | printf ("Board Rev:\t0x%02X\tID: %s\n", brd_rev, board_id_as[brd_id].name); |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 274 | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 275 | /* Fix the ack in the bme 32 */ |
| 276 | udelay(5000); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 277 | out32(CONFIG_SYS_BME32_BASE + 0x0000000C, 0x00000001); |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 278 | asm("eieio"); |
| 279 | |
| 280 | |
| 281 | return (0); |
| 282 | } |
| 283 | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 284 | /************************************************************************* |
| 285 | * misc_init_f |
| 286 | * |
| 287 | * Initialize I2C bus one to gain access to the fans |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 288 | ************************************************************************/ |
| 289 | int misc_init_f (void) |
| 290 | { |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 291 | /* Turn on fans */ |
| 292 | sbcommon_fans(); |
| 293 | |
| 294 | return (0); |
| 295 | } |
Wolfgang Denk | 3d078ce | 2005-08-15 16:03:56 +0200 | [diff] [blame] | 296 | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 297 | /************************************************************************* |
| 298 | * misc_init_r |
| 299 | * |
| 300 | * Do nothing. |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 301 | ************************************************************************/ |
| 302 | int misc_init_r (void) |
| 303 | { |
| 304 | unsigned short sernum; |
| 305 | char envstr[255]; |
Mike Frysinger | d8d21e6 | 2009-02-16 18:03:14 -0500 | [diff] [blame] | 306 | uchar enetaddr[6]; |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 307 | unsigned char opto_rev; |
| 308 | OPTO_FPGA_REGS_ST *opto_ps; |
| 309 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 310 | opto_ps = (OPTO_FPGA_REGS_ST *)CONFIG_SYS_FPGA_BASE; |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 311 | |
| 312 | if(NULL != getenv("secondserial")) { |
| 313 | puts("secondserial is set, switching to second serial port\n"); |
| 314 | setenv("stderr", "serial1"); |
| 315 | setenv("stdout", "serial1"); |
| 316 | setenv("stdin", "serial1"); |
| 317 | } |
| 318 | |
| 319 | setenv("ubrelver", METROBOX_U_BOOT_REL_STR); |
| 320 | |
| 321 | memset(envstr, 0, 255); |
Peter Tyser | 561858e | 2008-11-03 09:30:59 -0600 | [diff] [blame] | 322 | sprintf (envstr, "Built %s %s by %s", |
| 323 | U_BOOT_DATE, U_BOOT_TIME, BUILDUSER); |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 324 | setenv("bldstr", envstr); |
| 325 | saveenv(); |
| 326 | |
| 327 | if( getenv("autorecover")) { |
| 328 | setenv("autorecover", NULL); |
| 329 | saveenv(); |
| 330 | sernum = sbcommon_get_serial_number(); |
| 331 | |
| 332 | printf("\nSetting up environment for automatic filesystem recovery\n"); |
| 333 | /* |
| 334 | * Setup default bootargs |
| 335 | */ |
| 336 | memset(envstr, 0, 255); |
| 337 | sprintf(envstr, "console=ttyS0,9600 root=/dev/ram0 " |
| 338 | "rw ip=10.100.60.%d:::255.255.0.0:metrobox%d:eth0:none idebus=33", |
| 339 | sernum, sernum); |
| 340 | setenv("bootargs", envstr); |
| 341 | |
| 342 | /* |
| 343 | * Setup Default boot command |
| 344 | */ |
| 345 | setenv("bootcmd", "fatload ide 0 8000000 pimage.metrobox;" |
| 346 | "fatload ide 0 8100000 pramdisk;" |
| 347 | "bootm 8000000 8100000"); |
| 348 | |
| 349 | printf("Done. Please type allow the system to continue to boot\n"); |
| 350 | } |
| 351 | |
| 352 | if( getenv("fakeled")) { |
| 353 | setenv("bootdelay", "-1"); |
| 354 | saveenv(); |
| 355 | printf("fakeled is set. use 'setenv fakeled ; setenv bootdelay 5 ; saveenv' to recover\n"); |
| 356 | opto_rev = (unsigned char)((opto_ps->revision_ul & |
| 357 | SAND_HAL_XC_XCVR_CNTL_REVISION_REVISION_MASK) |
| 358 | >> SAND_HAL_XC_XCVR_CNTL_REVISION_REVISION_SHIFT); |
| 359 | |
| 360 | if(0x12 <= opto_rev) { |
| 361 | opto_ps->control_ul &= ~ SAND_HAL_XC_XCVR_CNTL_CNTL_ERROR_LED_MASK; |
| 362 | } |
| 363 | } |
| 364 | |
Mike Frysinger | d8d21e6 | 2009-02-16 18:03:14 -0500 | [diff] [blame] | 365 | #ifdef CONFIG_HAS_ETH0 |
| 366 | if (!eth_getenv_enetaddr("ethaddr", enetaddr)) { |
| 367 | board_get_enetaddr(0, enetaddr); |
Mike Frysinger | 0baeca4 | 2009-03-26 11:17:41 -0400 | [diff] [blame] | 368 | eth_setenv_enetaddr("ethaddr", enetaddr); |
Mike Frysinger | d8d21e6 | 2009-02-16 18:03:14 -0500 | [diff] [blame] | 369 | } |
| 370 | #endif |
| 371 | |
| 372 | #ifdef CONFIG_HAS_ETH1 |
| 373 | if (!eth_getenv_enetaddr("eth1addr", enetaddr)) { |
| 374 | board_get_enetaddr(1, enetaddr); |
Mike Frysinger | 0baeca4 | 2009-03-26 11:17:41 -0400 | [diff] [blame] | 375 | eth_setenv_enetaddr("eth1addr", enetaddr); |
Mike Frysinger | d8d21e6 | 2009-02-16 18:03:14 -0500 | [diff] [blame] | 376 | } |
| 377 | #endif |
| 378 | |
| 379 | #ifdef CONFIG_HAS_ETH2 |
| 380 | if (!eth_getenv_enetaddr("eth2addr", enetaddr)) { |
| 381 | board_get_enetaddr(2, enetaddr); |
Mike Frysinger | 0baeca4 | 2009-03-26 11:17:41 -0400 | [diff] [blame] | 382 | eth_setenv_enetaddr("eth2addr", enetaddr); |
Mike Frysinger | d8d21e6 | 2009-02-16 18:03:14 -0500 | [diff] [blame] | 383 | } |
| 384 | #endif |
| 385 | |
| 386 | #ifdef CONFIG_HAS_ETH3 |
| 387 | if (!eth_getenv_enetaddr("eth3addr", enetaddr)) { |
| 388 | board_get_enetaddr(3, enetaddr); |
Mike Frysinger | 0baeca4 | 2009-03-26 11:17:41 -0400 | [diff] [blame] | 389 | eth_setenv_enetaddr("eth3addr", enetaddr); |
Mike Frysinger | d8d21e6 | 2009-02-16 18:03:14 -0500 | [diff] [blame] | 390 | } |
| 391 | #endif |
| 392 | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 393 | return (0); |
| 394 | } |
| 395 | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 396 | /************************************************************************* |
| 397 | * ide_set_reset |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 398 | ************************************************************************/ |
| 399 | #ifdef CONFIG_IDE_RESET |
| 400 | void ide_set_reset(int on) |
| 401 | { |
| 402 | OPTO_FPGA_REGS_ST *opto_ps; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 403 | opto_ps = (OPTO_FPGA_REGS_ST *)CONFIG_SYS_FPGA_BASE; |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 404 | |
| 405 | if (on) { /* assert RESET */ |
| 406 | opto_ps->reset_ul &= ~SAND_HAL_XC_XCVR_CNTL_RESET_CF_RESET_N_MASK; |
| 407 | } else { /* release RESET */ |
| 408 | opto_ps->reset_ul |= SAND_HAL_XC_XCVR_CNTL_RESET_CF_RESET_N_MASK; |
| 409 | } |
| 410 | } |
| 411 | #endif /* CONFIG_IDE_RESET */ |
| 412 | |
| 413 | /************************************************************************* |
| 414 | * fpga_init |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 415 | ************************************************************************/ |
| 416 | void fpga_init(void) |
| 417 | { |
| 418 | OPTO_FPGA_REGS_ST *opto_ps; |
| 419 | unsigned char opto_rev; |
| 420 | unsigned long tmp; |
| 421 | |
| 422 | /* Ensure we have power all around */ |
| 423 | udelay(500); |
| 424 | |
| 425 | /* |
| 426 | * Take appropriate hw bits out of reset |
| 427 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 428 | opto_ps = (OPTO_FPGA_REGS_ST *)CONFIG_SYS_FPGA_BASE; |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 429 | |
| 430 | tmp = |
| 431 | SAND_HAL_XC_XCVR_CNTL_RESET_MAC1_RESET_N_MASK | |
| 432 | SAND_HAL_XC_XCVR_CNTL_RESET_MAC0_RESET_N_MASK | |
| 433 | SAND_HAL_XC_XCVR_CNTL_RESET_BME_RESET_N_MASK | |
| 434 | SAND_HAL_XC_XCVR_CNTL_RESET_ACE_RESET_N_MASK | |
| 435 | SAND_HAL_XC_XCVR_CNTL_RESET_CF_RESET_N_MASK | |
| 436 | SAND_HAL_XC_XCVR_CNTL_RESET_QE_A_RESET_N_MASK | |
| 437 | SAND_HAL_XC_XCVR_CNTL_RESET_IFE_A_RESET_N_MASK | |
| 438 | SAND_HAL_XC_XCVR_CNTL_RESET_EFE_A_RESET_N_MASK | |
| 439 | SAND_HAL_XC_XCVR_CNTL_RESET_QE_B_RESET_N_MASK | |
| 440 | SAND_HAL_XC_XCVR_CNTL_RESET_IFE_B_RESET_N_MASK | |
| 441 | SAND_HAL_XC_XCVR_CNTL_RESET_EFE_B_RESET_N_MASK | |
| 442 | SAND_HAL_XC_XCVR_CNTL_RESET_LOCK1_RESET_N_MASK | |
| 443 | SAND_HAL_XC_XCVR_CNTL_RESET_LOCK0_RESET_N_MASK | |
| 444 | SAND_HAL_XC_XCVR_CNTL_RESET_I2C_MUX1_RESET_N_MASK | |
| 445 | SAND_HAL_XC_XCVR_CNTL_RESET_I2C_MUX0_RESET_N_MASK | |
| 446 | SAND_HAL_XC_XCVR_CNTL_RESET_PHY0_RESET_N_MASK | |
| 447 | SAND_HAL_XC_XCVR_CNTL_RESET_PHY1_RESET_N_MASK | |
| 448 | SAND_HAL_XC_XCVR_CNTL_RESET_SLAVE_RESET_N_MASK; |
| 449 | opto_ps->reset_ul = tmp; |
| 450 | /* |
| 451 | * Turn on the 'Slow Blink' for the System Error Led. |
| 452 | * Ensure FPGA rev is up to at least rev 0x12 |
| 453 | */ |
| 454 | opto_rev = (unsigned char)((opto_ps->revision_ul & |
| 455 | SAND_HAL_XC_XCVR_CNTL_REVISION_REVISION_MASK) |
| 456 | >> SAND_HAL_XC_XCVR_CNTL_REVISION_REVISION_SHIFT); |
| 457 | if(0x12 <= opto_rev) { |
| 458 | opto_ps->control_ul |= 1 << SAND_HAL_XC_XCVR_CNTL_CNTL_ERROR_LED_SHIFT; |
| 459 | } |
| 460 | |
| 461 | asm("eieio"); |
| 462 | |
| 463 | return; |
| 464 | } |
| 465 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 466 | int metroboxSetupVars(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 467 | { |
| 468 | unsigned short sernum; |
| 469 | char envstr[255]; |
| 470 | |
| 471 | sernum = sbcommon_get_serial_number(); |
| 472 | |
| 473 | memset(envstr, 0, 255); |
| 474 | /* |
| 475 | * Setup our ip address |
| 476 | */ |
| 477 | sprintf(envstr, "10.100.60.%d", sernum); |
| 478 | |
| 479 | setenv("ipaddr", envstr); |
| 480 | /* |
| 481 | * Setup the host ip address |
| 482 | */ |
| 483 | setenv("serverip", "10.100.17.10"); |
| 484 | |
| 485 | /* |
| 486 | * Setup default bootargs |
| 487 | */ |
| 488 | memset(envstr, 0, 255); |
| 489 | |
| 490 | sprintf(envstr, "console=ttyS0,9600 root=/dev/nfs " |
| 491 | "rw nfsroot=10.100.17.10:/home/metrobox/mbc%d " |
| 492 | "nfsaddrs=10.100.60.%d:10.100.17.10:10.100.1.1" |
| 493 | ":255.255.0.0:metrobox%d.sandburst.com:eth0:none idebus=33", |
| 494 | sernum, sernum, sernum); |
| 495 | |
| 496 | setenv("bootargs_nfs", envstr); |
| 497 | setenv("bootargs", envstr); |
| 498 | |
| 499 | /* |
| 500 | * Setup CF bootargs |
| 501 | */ |
| 502 | memset(envstr, 0, 255); |
| 503 | sprintf(envstr, "console=ttyS0,9600 root=/dev/hda2 " |
| 504 | "rw ip=10.100.60.%d:::255.255.0.0:metrobox%d:eth0:none idebus=33", |
| 505 | sernum, sernum); |
| 506 | |
| 507 | setenv("bootargs_cf", envstr); |
| 508 | |
| 509 | /* |
| 510 | * Setup Default boot command |
| 511 | */ |
| 512 | setenv("bootcmd_tftp", "tftp 8000000 pImage.metrobox;bootm 8000000"); |
| 513 | setenv("bootcmd", "tftp 8000000 pImage.metrobox;bootm 8000000"); |
| 514 | |
| 515 | /* |
| 516 | * Setup compact flash boot command |
| 517 | */ |
| 518 | setenv("bootcmd_cf", "fatload ide 0 8000000 pimage.metrobox;bootm 8000000"); |
| 519 | |
| 520 | saveenv(); |
| 521 | |
| 522 | |
| 523 | return(1); |
| 524 | } |
| 525 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 526 | int metroboxRecover(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 527 | { |
| 528 | unsigned short sernum; |
| 529 | char envstr[255]; |
| 530 | |
| 531 | sernum = sbcommon_get_serial_number(); |
| 532 | |
| 533 | printf("\nSetting up environment for filesystem recovery\n"); |
| 534 | /* |
| 535 | * Setup default bootargs |
| 536 | */ |
| 537 | memset(envstr, 0, 255); |
| 538 | sprintf(envstr, "console=ttyS0,9600 root=/dev/ram0 " |
| 539 | "rw ip=10.100.60.%d:::255.255.0.0:metrobox%d:eth0:none", |
| 540 | sernum, sernum); |
| 541 | |
| 542 | setenv("bootargs", envstr); |
| 543 | |
| 544 | /* |
| 545 | * Setup Default boot command |
| 546 | */ |
| 547 | setenv("bootcmd", "fatload ide 0 8000000 pimage.metrobox;" |
| 548 | "fatload ide 0 8100000 pramdisk;" |
| 549 | "bootm 8000000 8100000"); |
| 550 | |
| 551 | printf("Done. Please type boot<cr>.\nWhen the kernel has booted" |
| 552 | " please type fsrecover.sh<cr>\n"); |
| 553 | |
| 554 | return(1); |
| 555 | } |
| 556 | |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 557 | U_BOOT_CMD(mbsetup, 1, 1, metroboxSetupVars, |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 558 | "Set environment to factory defaults", ""); |
Stefan Roese | b79316f | 2005-08-15 12:31:23 +0200 | [diff] [blame] | 559 | |
| 560 | U_BOOT_CMD(mbrecover, 1, 1, metroboxRecover, |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 561 | "Set environment to allow for fs recovery", ""); |