wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 2 | * (C) Copyright 2001-2003 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3 | * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.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 | |
| 24 | #include <common.h> |
| 25 | #include <asm/processor.h> |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 26 | #include <asm/io.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 27 | #include <command.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 28 | #include <malloc.h> |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 29 | #include <net.h> |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 30 | #include <pci.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 31 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 34 | extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); /*cmd_boot.c*/ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 35 | #if 0 |
| 36 | #define FPGA_DEBUG |
| 37 | #endif |
| 38 | |
| 39 | /* fpga configuration data - generated by bin2cc */ |
| 40 | const unsigned char fpgadata[] = |
| 41 | { |
| 42 | #ifdef CONFIG_CPCI405_VER2 |
stroese | d253d4b | 2003-05-23 11:30:39 +0000 | [diff] [blame] | 43 | # ifdef CONFIG_CPCI405AB |
| 44 | # include "fpgadata_cpci405ab.c" |
| 45 | # else |
| 46 | # include "fpgadata_cpci4052.c" |
| 47 | # endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 48 | #else |
| 49 | # include "fpgadata_cpci405.c" |
| 50 | #endif |
| 51 | }; |
| 52 | |
| 53 | /* |
| 54 | * include common fpga code (for esd boards) |
| 55 | */ |
| 56 | #include "../common/fpga.c" |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 57 | #include "../common/auto_update.h" |
| 58 | |
| 59 | #ifdef CONFIG_CPCI405AB |
| 60 | au_image_t au_image[] = { |
| 61 | {"cpci405ab/preinst.img", 0, -1, AU_SCRIPT}, |
| 62 | {"cpci405ab/pImage", 0xffc00000, 0x000c0000, AU_NOR}, |
| 63 | {"cpci405ab/pImage.initrd", 0xffcc0000, 0x00300000, AU_NOR}, |
| 64 | {"cpci405ab/u-boot.img", 0xfffc0000, 0x00040000, AU_FIRMWARE}, |
| 65 | {"cpci405ab/postinst.img", 0, 0, AU_SCRIPT}, |
| 66 | }; |
| 67 | #else |
| 68 | #ifdef CONFIG_CPCI405_VER2 |
| 69 | au_image_t au_image[] = { |
| 70 | {"cpci4052/preinst.img", 0, -1, AU_SCRIPT}, |
| 71 | {"cpci4052/pImage", 0xffc00000, 0x000c0000, AU_NOR}, |
| 72 | {"cpci4052/pImage.initrd", 0xffcc0000, 0x00300000, AU_NOR}, |
| 73 | {"cpci4052/u-boot.img", 0xfffc0000, 0x00040000, AU_FIRMWARE}, |
| 74 | {"cpci4052/postinst.img", 0, 0, AU_SCRIPT}, |
| 75 | }; |
| 76 | #else |
| 77 | au_image_t au_image[] = { |
| 78 | {"cpci405/preinst.img", 0, -1, AU_SCRIPT}, |
| 79 | {"cpci405/pImage", 0xffc00000, 0x000c0000, AU_NOR}, |
| 80 | {"cpci405/pImage.initrd", 0xffcc0000, 0x00310000, AU_NOR}, |
| 81 | {"cpci405/u-boot.img", 0xfffd0000, 0x00030000, AU_FIRMWARE}, |
| 82 | {"cpci405/postinst.img", 0, 0, AU_SCRIPT}, |
| 83 | }; |
| 84 | #endif |
| 85 | #endif |
| 86 | |
| 87 | int N_AU_IMAGES = (sizeof(au_image) / sizeof(au_image[0])); |
| 88 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 89 | /* Prototypes */ |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 90 | int cpci405_version(void); |
wdenk | a0ebde5 | 2004-09-08 22:03:11 +0000 | [diff] [blame] | 91 | int gunzip(void *, int, unsigned char *, unsigned long *); |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 92 | void lxt971_no_sleep(void); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 93 | |
wdenk | da55c6e | 2004-01-20 23:12:12 +0000 | [diff] [blame] | 94 | int board_early_init_f (void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 95 | { |
| 96 | #ifndef CONFIG_CPCI405_VER2 |
| 97 | int index, len, i; |
| 98 | int status; |
| 99 | #endif |
| 100 | |
| 101 | #ifdef FPGA_DEBUG |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 102 | /* set up serial port with default baudrate */ |
| 103 | (void) get_clocks (); |
| 104 | gd->baudrate = CONFIG_BAUDRATE; |
| 105 | serial_init (); |
| 106 | console_init_f(); |
| 107 | #endif |
| 108 | |
| 109 | /* |
| 110 | * First pull fpga-prg pin low, to disable fpga logic (on version 2 board) |
| 111 | */ |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 112 | out32(GPIO0_ODR, 0x00000000); /* no open drain pins */ |
| 113 | out32(GPIO0_TCR, CFG_FPGA_PRG); /* setup for output */ |
stroese | d253d4b | 2003-05-23 11:30:39 +0000 | [diff] [blame] | 114 | out32(GPIO0_OR, CFG_FPGA_PRG); /* set output pins to high */ |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 115 | out32(GPIO0_OR, 0); /* pull prg low */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 116 | |
| 117 | /* |
| 118 | * Boot onboard FPGA |
| 119 | */ |
| 120 | #ifndef CONFIG_CPCI405_VER2 |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 121 | if (cpci405_version() == 1) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 122 | status = fpga_boot((unsigned char *)fpgadata, sizeof(fpgadata)); |
| 123 | if (status != 0) { |
| 124 | /* booting FPGA failed */ |
| 125 | #ifndef FPGA_DEBUG |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 126 | /* set up serial port with default baudrate */ |
| 127 | (void) get_clocks (); |
| 128 | gd->baudrate = CONFIG_BAUDRATE; |
| 129 | serial_init (); |
| 130 | console_init_f(); |
| 131 | #endif |
| 132 | printf("\nFPGA: Booting failed "); |
| 133 | switch (status) { |
| 134 | case ERROR_FPGA_PRG_INIT_LOW: |
| 135 | printf("(Timeout: INIT not low after asserting PROGRAM*)\n "); |
| 136 | break; |
| 137 | case ERROR_FPGA_PRG_INIT_HIGH: |
| 138 | printf("(Timeout: INIT not high after deasserting PROGRAM*)\n "); |
| 139 | break; |
| 140 | case ERROR_FPGA_PRG_DONE: |
| 141 | printf("(Timeout: DONE not high after programming FPGA)\n "); |
| 142 | break; |
| 143 | } |
| 144 | |
| 145 | /* display infos on fpgaimage */ |
| 146 | index = 15; |
| 147 | for (i=0; i<4; i++) { |
| 148 | len = fpgadata[index]; |
| 149 | printf("FPGA: %s\n", &(fpgadata[index+1])); |
| 150 | index += len+3; |
| 151 | } |
| 152 | putc ('\n'); |
| 153 | /* delayed reboot */ |
| 154 | for (i=20; i>0; i--) { |
| 155 | printf("Rebooting in %2d seconds \r",i); |
| 156 | for (index=0;index<1000;index++) |
| 157 | udelay(1000); |
| 158 | } |
| 159 | putc ('\n'); |
| 160 | do_reset(NULL, 0, 0, NULL); |
| 161 | } |
| 162 | } |
| 163 | #endif /* !CONFIG_CPCI405_VER2 */ |
| 164 | |
| 165 | /* |
| 166 | * IRQ 0-15 405GP internally generated; active high; level sensitive |
| 167 | * IRQ 16 405GP internally generated; active low; level sensitive |
| 168 | * IRQ 17-24 RESERVED |
| 169 | * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive |
| 170 | * IRQ 26 (EXT IRQ 1) CAN1 (+FPGA on CPCI4052) ; active low; level sensitive |
| 171 | * IRQ 27 (EXT IRQ 2) PCI SLOT 0; active low; level sensitive |
| 172 | * IRQ 28 (EXT IRQ 3) PCI SLOT 1; active low; level sensitive |
| 173 | * IRQ 29 (EXT IRQ 4) PCI SLOT 2; active low; level sensitive |
| 174 | * IRQ 30 (EXT IRQ 5) PCI SLOT 3; active low; level sensitive |
| 175 | * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive |
| 176 | */ |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 177 | mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */ |
| 178 | mtdcr(uicer, 0x00000000); /* disable all ints */ |
| 179 | mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/ |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 180 | #ifdef CONFIG_CPCI405_6U |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 181 | if (cpci405_version() == 3) { |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 182 | mtdcr(uicpr, 0xFFFFFF99); /* set int polarities */ |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 183 | } else { |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 184 | mtdcr(uicpr, 0xFFFFFF81); /* set int polarities */ |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 185 | } |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 186 | #else |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 187 | mtdcr(uicpr, 0xFFFFFF81); /* set int polarities */ |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 188 | #endif |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 189 | mtdcr(uictr, 0x10000000); /* set int trigger levels */ |
| 190 | mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/ |
| 191 | mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 192 | |
| 193 | return 0; |
| 194 | } |
| 195 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 196 | /* ------------------------------------------------------------------------- */ |
| 197 | |
| 198 | int ctermm2(void) |
| 199 | { |
| 200 | #ifdef CONFIG_CPCI405_VER2 |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 201 | return 0; /* no, board is cpci405 */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 202 | #else |
| 203 | if ((*(unsigned char *)0xf0000400 == 0x00) && |
| 204 | (*(unsigned char *)0xf0000401 == 0x01)) |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 205 | return 0; /* no, board is cpci405 */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 206 | else |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 207 | return -1; /* yes, board is cterm-m2 */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 208 | #endif |
| 209 | } |
| 210 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 211 | int cpci405_host(void) |
| 212 | { |
| 213 | if (mfdcr(strap) & PSR_PCI_ARBIT_EN) |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 214 | return -1; /* yes, board is cpci405 host */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 215 | else |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 216 | return 0; /* no, board is cpci405 adapter */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 217 | } |
| 218 | |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 219 | int cpci405_version(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 220 | { |
| 221 | unsigned long cntrl0Reg; |
| 222 | unsigned long value; |
| 223 | |
| 224 | /* |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 225 | * Setup GPIO pins (CS2/GPIO11 and CS3/GPIO12 as GPIO) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 226 | */ |
| 227 | cntrl0Reg = mfdcr(cntrl0); |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 228 | mtdcr(cntrl0, cntrl0Reg | 0x03000000); |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 229 | out_be32((void*)GPIO0_ODR, in_be32((void*)GPIO0_ODR) & ~0x00180000); |
| 230 | out_be32((void*)GPIO0_TCR, in_be32((void*)GPIO0_TCR) & ~0x00180000); |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 231 | udelay(1000); /* wait some time before reading input */ |
| 232 | value = in_be32((void*)GPIO0_IR) & 0x00180000; /* get config bits */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 233 | |
| 234 | /* |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 235 | * Restore GPIO settings |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 236 | */ |
| 237 | mtdcr(cntrl0, cntrl0Reg); |
| 238 | |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 239 | switch (value) { |
| 240 | case 0x00180000: |
| 241 | /* CS2==1 && CS3==1 -> version 1 */ |
| 242 | return 1; |
| 243 | case 0x00080000: |
| 244 | /* CS2==0 && CS3==1 -> version 2 */ |
| 245 | return 2; |
| 246 | case 0x00100000: |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 247 | /* CS2==1 && CS3==0 -> version 3 or 6U board */ |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 248 | return 3; |
| 249 | case 0x00000000: |
| 250 | /* CS2==0 && CS3==0 -> version 4 */ |
| 251 | return 4; |
| 252 | default: |
| 253 | /* should not be reached! */ |
| 254 | return 2; |
| 255 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 256 | } |
| 257 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 258 | int misc_init_f (void) |
| 259 | { |
| 260 | return 0; /* dummy implementation */ |
| 261 | } |
| 262 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 263 | int misc_init_r (void) |
| 264 | { |
stroese | 67cb27d | 2003-04-04 16:52:57 +0000 | [diff] [blame] | 265 | unsigned long cntrl0Reg; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 266 | |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 267 | /* adjust flash start and offset */ |
| 268 | gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize; |
| 269 | gd->bd->bi_flashoffset = 0; |
| 270 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 271 | #ifdef CONFIG_CPCI405_VER2 |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 272 | { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 273 | unsigned char *dst; |
| 274 | ulong len = sizeof(fpgadata); |
| 275 | int status; |
| 276 | int index; |
| 277 | int i; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 278 | |
| 279 | /* |
| 280 | * On CPCI-405 version 2 the environment is saved in eeprom! |
| 281 | * FPGA can be gzip compressed (malloc) and booted this late. |
| 282 | */ |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 283 | if (cpci405_version() >= 2) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 284 | /* |
| 285 | * Setup GPIO pins (CS6+CS7 as GPIO) |
| 286 | */ |
| 287 | cntrl0Reg = mfdcr(cntrl0); |
| 288 | mtdcr(cntrl0, cntrl0Reg | 0x00300000); |
| 289 | |
| 290 | dst = malloc(CFG_FPGA_MAX_SIZE); |
wdenk | a0ebde5 | 2004-09-08 22:03:11 +0000 | [diff] [blame] | 291 | if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 292 | printf ("GUNZIP ERROR - must RESET board to recover\n"); |
| 293 | do_reset (NULL, 0, 0, NULL); |
| 294 | } |
| 295 | |
| 296 | status = fpga_boot(dst, len); |
| 297 | if (status != 0) { |
| 298 | printf("\nFPGA: Booting failed "); |
| 299 | switch (status) { |
| 300 | case ERROR_FPGA_PRG_INIT_LOW: |
| 301 | printf("(Timeout: INIT not low after asserting PROGRAM*)\n "); |
| 302 | break; |
| 303 | case ERROR_FPGA_PRG_INIT_HIGH: |
| 304 | printf("(Timeout: INIT not high after deasserting PROGRAM*)\n "); |
| 305 | break; |
| 306 | case ERROR_FPGA_PRG_DONE: |
| 307 | printf("(Timeout: DONE not high after programming FPGA)\n "); |
| 308 | break; |
| 309 | } |
| 310 | |
| 311 | /* display infos on fpgaimage */ |
| 312 | index = 15; |
| 313 | for (i=0; i<4; i++) { |
| 314 | len = dst[index]; |
| 315 | printf("FPGA: %s\n", &(dst[index+1])); |
| 316 | index += len+3; |
| 317 | } |
| 318 | putc ('\n'); |
| 319 | /* delayed reboot */ |
| 320 | for (i=20; i>0; i--) { |
| 321 | printf("Rebooting in %2d seconds \r",i); |
| 322 | for (index=0;index<1000;index++) |
| 323 | udelay(1000); |
| 324 | } |
| 325 | putc ('\n'); |
| 326 | do_reset(NULL, 0, 0, NULL); |
| 327 | } |
| 328 | |
| 329 | /* restore gpio/cs settings */ |
| 330 | mtdcr(cntrl0, cntrl0Reg); |
| 331 | |
| 332 | puts("FPGA: "); |
| 333 | |
| 334 | /* display infos on fpgaimage */ |
| 335 | index = 15; |
| 336 | for (i=0; i<4; i++) { |
| 337 | len = dst[index]; |
| 338 | printf("%s ", &(dst[index+1])); |
| 339 | index += len+3; |
| 340 | } |
| 341 | putc ('\n'); |
| 342 | |
| 343 | free(dst); |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 344 | |
| 345 | /* |
| 346 | * Reset FPGA via FPGA_DATA pin |
| 347 | */ |
| 348 | SET_FPGA(FPGA_PRG | FPGA_CLK); |
| 349 | udelay(1000); /* wait 1ms */ |
| 350 | SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA); |
| 351 | udelay(1000); /* wait 1ms */ |
| 352 | |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 353 | #ifdef CONFIG_CPCI405_6U |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 354 | if (cpci405_version() == 3) { |
| 355 | volatile unsigned short *fpga_mode = (unsigned short *)CFG_FPGA_BASE_ADDR; |
| 356 | volatile unsigned char *leds = (unsigned char *)CFG_LED_ADDR; |
| 357 | |
| 358 | /* |
| 359 | * Enable outputs in fpga on version 3 board |
| 360 | */ |
| 361 | *fpga_mode |= CFG_FPGA_MODE_ENABLE_OUTPUT; |
| 362 | |
| 363 | /* |
| 364 | * Set outputs to 0 |
| 365 | */ |
| 366 | *leds = 0x00; |
| 367 | |
| 368 | /* |
| 369 | * Reset external DUART |
| 370 | */ |
| 371 | *fpga_mode |= CFG_FPGA_MODE_DUART_RESET; |
| 372 | udelay(100); |
| 373 | *fpga_mode &= ~(CFG_FPGA_MODE_DUART_RESET); |
| 374 | } |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 375 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 376 | } |
| 377 | else { |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 378 | puts("\n*** U-Boot Version does not match Board Version!\n"); |
| 379 | puts("*** CPCI-405 Version 1.x detected!\n"); |
| 380 | puts("*** Please use correct U-Boot version (CPCI405 instead of CPCI4052)!\n\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 381 | } |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 382 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 383 | |
| 384 | #else /* CONFIG_CPCI405_VER2 */ |
| 385 | |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 386 | #if 0 /* test-only: code-plug now not relavant for ip-address any more */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 387 | /* |
| 388 | * Generate last byte of ip-addr from code-plug @ 0xf0000400 |
| 389 | */ |
| 390 | if (ctermm2()) { |
| 391 | char str[32]; |
| 392 | unsigned char ipbyte = *(unsigned char *)0xf0000400; |
| 393 | |
| 394 | /* |
| 395 | * Only overwrite ip-addr with allowed values |
| 396 | */ |
| 397 | if ((ipbyte != 0x00) && (ipbyte != 0xff)) { |
| 398 | bd->bi_ip_addr = (bd->bi_ip_addr & 0xffffff00) | ipbyte; |
| 399 | sprintf(str, "%ld.%ld.%ld.%ld", |
| 400 | (bd->bi_ip_addr & 0xff000000) >> 24, |
| 401 | (bd->bi_ip_addr & 0x00ff0000) >> 16, |
| 402 | (bd->bi_ip_addr & 0x0000ff00) >> 8, |
| 403 | (bd->bi_ip_addr & 0x000000ff)); |
| 404 | setenv("ipaddr", str); |
| 405 | } |
| 406 | } |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 407 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 408 | |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 409 | if (cpci405_version() >= 2) { |
| 410 | puts("\n*** U-Boot Version does not match Board Version!\n"); |
| 411 | puts("*** CPCI-405 Board Version 2.x detected!\n"); |
| 412 | puts("*** Please use correct U-Boot version (CPCI4052 instead of CPCI405)!\n\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | #endif /* CONFIG_CPCI405_VER2 */ |
| 416 | |
| 417 | /* |
stroese | 67cb27d | 2003-04-04 16:52:57 +0000 | [diff] [blame] | 418 | * Select cts (and not dsr) on uart1 |
| 419 | */ |
| 420 | cntrl0Reg = mfdcr(cntrl0); |
| 421 | mtdcr(cntrl0, cntrl0Reg | 0x00001000); |
| 422 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 423 | return (0); |
| 424 | } |
| 425 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 426 | /* |
| 427 | * Check Board Identity: |
| 428 | */ |
| 429 | |
| 430 | int checkboard (void) |
| 431 | { |
| 432 | #ifndef CONFIG_CPCI405_VER2 |
| 433 | int index; |
| 434 | int len; |
| 435 | #endif |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 436 | char str[64]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 437 | int i = getenv_r ("serial#", str, sizeof(str)); |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 438 | unsigned short ver; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 439 | |
| 440 | puts ("Board: "); |
| 441 | |
| 442 | if (i == -1) { |
| 443 | puts ("### No HW ID - assuming CPCI405"); |
| 444 | } else { |
| 445 | puts(str); |
| 446 | } |
| 447 | |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 448 | ver = cpci405_version(); |
| 449 | printf(" (Ver %d.x, ", ver); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 450 | |
stroese | 768eb2d | 2003-03-20 15:31:19 +0000 | [diff] [blame] | 451 | #if 0 /* test-only */ |
| 452 | if (ver >= 2) { |
| 453 | volatile u16 *fpga_status = (u16 *)CFG_FPGA_BASE_ADDR + 1; |
| 454 | |
| 455 | if (*fpga_status & CFG_FPGA_STATUS_FLASH) { |
| 456 | puts ("FLASH Bank B, "); |
| 457 | } else { |
| 458 | puts ("FLASH Bank A, "); |
| 459 | } |
| 460 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 461 | #endif |
| 462 | |
| 463 | if (ctermm2()) { |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 464 | char str[4]; |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 465 | |
| 466 | /* |
| 467 | * Read board-id and save in env-variable |
| 468 | */ |
| 469 | sprintf(str, "%d", *(unsigned char *)0xf0000400); |
| 470 | setenv("boardid", str); |
| 471 | printf("CTERM-M2 - Id=%s)", str); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 472 | } else { |
| 473 | if (cpci405_host()) { |
| 474 | puts ("PCI Host Version)"); |
| 475 | } else { |
| 476 | puts ("PCI Adapter Version)"); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | #ifndef CONFIG_CPCI405_VER2 |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 481 | puts ("\nFPGA: "); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 482 | |
| 483 | /* display infos on fpgaimage */ |
| 484 | index = 15; |
| 485 | for (i=0; i<4; i++) { |
| 486 | len = fpgadata[index]; |
| 487 | printf("%s ", &(fpgadata[index+1])); |
| 488 | index += len+3; |
| 489 | } |
| 490 | #endif |
| 491 | |
| 492 | putc ('\n'); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 493 | return 0; |
| 494 | } |
| 495 | |
| 496 | /* ------------------------------------------------------------------------- */ |
| 497 | |
| 498 | long int initdram (int board_type) |
| 499 | { |
| 500 | unsigned long val; |
| 501 | |
| 502 | mtdcr(memcfga, mem_mb0cf); |
| 503 | val = mfdcr(memcfgd); |
| 504 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 505 | return (4*1024*1024 << ((val & 0x000e0000) >> 17)); |
| 506 | } |
| 507 | |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 508 | void reset_phy(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 509 | { |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 510 | #ifdef CONFIG_LXT971_NO_SLEEP |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 511 | |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 512 | /* |
| 513 | * Disable sleep mode in LXT971 |
| 514 | */ |
| 515 | lxt971_no_sleep(); |
| 516 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | /* ------------------------------------------------------------------------- */ |
| 520 | |
| 521 | #ifdef CONFIG_CPCI405_VER2 |
| 522 | #ifdef CONFIG_IDE_RESET |
| 523 | |
| 524 | void ide_set_reset(int on) |
| 525 | { |
| 526 | volatile unsigned short *fpga_mode = (unsigned short *)CFG_FPGA_BASE_ADDR; |
| 527 | |
| 528 | /* |
| 529 | * Assert or deassert CompactFlash Reset Pin |
| 530 | */ |
| 531 | if (on) { /* assert RESET */ |
| 532 | *fpga_mode &= ~(CFG_FPGA_MODE_CF_RESET); |
| 533 | } else { /* release RESET */ |
| 534 | *fpga_mode |= CFG_FPGA_MODE_CF_RESET; |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | #endif /* CONFIG_IDE_RESET */ |
| 539 | #endif /* CONFIG_CPCI405_VER2 */ |
| 540 | |
Stefan Roese | 54ef7fd | 2007-06-25 15:57:39 +0200 | [diff] [blame] | 541 | #if defined(CONFIG_PCI) |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 542 | void cpci405_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev) |
| 543 | { |
| 544 | unsigned char int_line = 0xff; |
| 545 | |
| 546 | /* |
| 547 | * Write pci interrupt line register (cpci405 specific) |
| 548 | */ |
| 549 | switch (PCI_DEV(dev) & 0x03) { |
| 550 | case 0: |
| 551 | int_line = 27 + 2; |
| 552 | break; |
| 553 | case 1: |
| 554 | int_line = 27 + 3; |
| 555 | break; |
| 556 | case 2: |
| 557 | int_line = 27 + 0; |
| 558 | break; |
| 559 | case 3: |
| 560 | int_line = 27 + 1; |
| 561 | break; |
| 562 | } |
| 563 | |
| 564 | pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line); |
| 565 | } |
| 566 | |
| 567 | int pci_pre_init(struct pci_controller *hose) |
| 568 | { |
| 569 | hose->fixup_irq = cpci405_pci_fixup_irq; |
| 570 | return 1; |
| 571 | } |
Stefan Roese | 54ef7fd | 2007-06-25 15:57:39 +0200 | [diff] [blame] | 572 | #endif /* defined(CONFIG_PCI) */ |
Matthias Fuchs | 196088b | 2007-06-24 17:41:21 +0200 | [diff] [blame] | 573 | |
| 574 | |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 575 | #ifdef CONFIG_CPCI405AB |
stroese | d253d4b | 2003-05-23 11:30:39 +0000 | [diff] [blame] | 576 | |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 577 | #define ONE_WIRE_CLEAR (*(volatile unsigned short *)(CFG_FPGA_BASE_ADDR + CFG_FPGA_MODE) \ |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 578 | |= CFG_FPGA_MODE_1WIRE_DIR) |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 579 | #define ONE_WIRE_SET (*(volatile unsigned short *)(CFG_FPGA_BASE_ADDR + CFG_FPGA_MODE) \ |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 580 | &= ~CFG_FPGA_MODE_1WIRE_DIR) |
Wolfgang Denk | a0453aa | 2007-07-10 00:01:28 +0200 | [diff] [blame] | 581 | #define ONE_WIRE_GET (*(volatile unsigned short *)(CFG_FPGA_BASE_ADDR + CFG_FPGA_STATUS) \ |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 582 | & CFG_FPGA_MODE_1WIRE) |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 583 | |
| 584 | /* |
| 585 | * Generate a 1-wire reset, return 1 if no presence detect was found, |
| 586 | * return 0 otherwise. |
| 587 | * (NOTE: Does not handle alarm presence from DS2404/DS1994) |
| 588 | */ |
| 589 | int OWTouchReset(void) |
stroese | d253d4b | 2003-05-23 11:30:39 +0000 | [diff] [blame] | 590 | { |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 591 | int result; |
stroese | d253d4b | 2003-05-23 11:30:39 +0000 | [diff] [blame] | 592 | |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 593 | ONE_WIRE_CLEAR; |
| 594 | udelay(480); |
| 595 | ONE_WIRE_SET; |
| 596 | udelay(70); |
| 597 | |
| 598 | result = ONE_WIRE_GET; |
| 599 | |
| 600 | udelay(410); |
| 601 | return result; |
| 602 | } |
| 603 | |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 604 | /* |
| 605 | * Send 1 a 1-wire write bit. |
| 606 | * Provide 10us recovery time. |
| 607 | */ |
| 608 | void OWWriteBit(int bit) |
| 609 | { |
| 610 | if (bit) { |
| 611 | /* |
| 612 | * write '1' bit |
| 613 | */ |
| 614 | ONE_WIRE_CLEAR; |
| 615 | udelay(6); |
| 616 | ONE_WIRE_SET; |
| 617 | udelay(64); |
| 618 | } else { |
| 619 | /* |
| 620 | * write '0' bit |
| 621 | */ |
| 622 | ONE_WIRE_CLEAR; |
| 623 | udelay(60); |
| 624 | ONE_WIRE_SET; |
| 625 | udelay(10); |
stroese | d253d4b | 2003-05-23 11:30:39 +0000 | [diff] [blame] | 626 | } |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 627 | } |
| 628 | |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 629 | /* |
| 630 | * Read a bit from the 1-wire bus and return it. |
| 631 | * Provide 10us recovery time. |
| 632 | */ |
| 633 | int OWReadBit(void) |
| 634 | { |
| 635 | int result; |
stroese | d253d4b | 2003-05-23 11:30:39 +0000 | [diff] [blame] | 636 | |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 637 | ONE_WIRE_CLEAR; |
| 638 | udelay(6); |
| 639 | ONE_WIRE_SET; |
| 640 | udelay(9); |
| 641 | |
| 642 | result = ONE_WIRE_GET; |
| 643 | |
| 644 | udelay(55); |
| 645 | return result; |
stroese | d253d4b | 2003-05-23 11:30:39 +0000 | [diff] [blame] | 646 | } |
| 647 | |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 648 | void OWWriteByte(int data) |
| 649 | { |
| 650 | int loop; |
| 651 | |
| 652 | for (loop=0; loop<8; loop++) { |
| 653 | OWWriteBit(data & 0x01); |
| 654 | data >>= 1; |
| 655 | } |
| 656 | } |
| 657 | |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 658 | int OWReadByte(void) |
stroese | d253d4b | 2003-05-23 11:30:39 +0000 | [diff] [blame] | 659 | { |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 660 | int loop, result = 0; |
| 661 | |
| 662 | for (loop=0; loop<8; loop++) { |
| 663 | result >>= 1; |
| 664 | if (OWReadBit()) { |
| 665 | result |= 0x80; |
| 666 | } |
stroese | d253d4b | 2003-05-23 11:30:39 +0000 | [diff] [blame] | 667 | } |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 668 | |
| 669 | return result; |
stroese | d253d4b | 2003-05-23 11:30:39 +0000 | [diff] [blame] | 670 | } |
| 671 | |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 672 | int do_onewire(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 673 | { |
| 674 | volatile unsigned short val; |
| 675 | int result; |
| 676 | int i; |
| 677 | unsigned char ow_id[6]; |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 678 | char str[32]; |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 679 | unsigned char ow_crc; |
| 680 | |
| 681 | /* |
| 682 | * Clear 1-wire bit (open drain with pull-up) |
| 683 | */ |
| 684 | val = *(volatile unsigned short *)0xf0400000; |
| 685 | val &= ~0x1000; /* clear 1-wire bit */ |
| 686 | *(volatile unsigned short *)0xf0400000 = val; |
| 687 | |
| 688 | result = OWTouchReset(); |
| 689 | if (result != 0) { |
| 690 | puts("No 1-wire device detected!\n"); |
| 691 | } |
| 692 | |
| 693 | OWWriteByte(0x33); /* send read rom command */ |
| 694 | OWReadByte(); /* skip family code ( == 0x01) */ |
| 695 | for (i=0; i<6; i++) { |
| 696 | ow_id[i] = OWReadByte(); |
| 697 | } |
| 698 | ow_crc = OWReadByte(); /* read crc */ |
| 699 | |
| 700 | sprintf(str, "%08X%04X", *(unsigned int *)&ow_id[0], *(unsigned short *)&ow_id[4]); |
| 701 | printf("Setting environment variable 'ow_id' to %s\n", str); |
| 702 | setenv("ow_id", str); |
| 703 | |
| 704 | return 0; |
| 705 | } |
| 706 | U_BOOT_CMD( |
| 707 | onewire, 1, 1, do_onewire, |
| 708 | "onewire - Read 1-write ID\n", |
| 709 | NULL |
| 710 | ); |
| 711 | |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 712 | #define CFG_I2C_EEPROM_ADDR_2 0x51 /* EEPROM CAT28WC32 */ |
| 713 | #define CFG_ENV_SIZE_2 0x800 /* 2048 bytes may be used for env vars*/ |
| 714 | |
| 715 | /* |
| 716 | * Write backplane ip-address... |
| 717 | */ |
| 718 | int do_get_bpip(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 719 | { |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 720 | bd_t *bd = gd->bd; |
| 721 | char *buf; |
| 722 | ulong crc; |
| 723 | char str[32]; |
| 724 | char *ptr; |
| 725 | IPaddr_t ipaddr; |
| 726 | |
| 727 | buf = malloc(CFG_ENV_SIZE_2); |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 728 | if (eeprom_read(CFG_I2C_EEPROM_ADDR_2, 0, (uchar *)buf, CFG_ENV_SIZE_2)) { |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 729 | puts("\nError reading backplane EEPROM!\n"); |
| 730 | } else { |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 731 | crc = crc32(0, (uchar *)(buf+4), CFG_ENV_SIZE_2-4); |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 732 | if (crc != *(ulong *)buf) { |
| 733 | printf("ERROR: crc mismatch %08lx %08lx\n", crc, *(ulong *)buf); |
| 734 | return -1; |
| 735 | } |
| 736 | |
| 737 | /* |
| 738 | * Find bp_ip |
| 739 | */ |
| 740 | ptr = strstr(buf+4, "bp_ip="); |
| 741 | if (ptr == NULL) { |
| 742 | printf("ERROR: bp_ip not found!\n"); |
| 743 | return -1; |
| 744 | } |
| 745 | ptr += 6; |
| 746 | ipaddr = string_to_ip(ptr); |
| 747 | |
| 748 | /* |
| 749 | * Update whole ip-addr |
| 750 | */ |
| 751 | bd->bi_ip_addr = ipaddr; |
| 752 | sprintf(str, "%ld.%ld.%ld.%ld", |
| 753 | (bd->bi_ip_addr & 0xff000000) >> 24, |
| 754 | (bd->bi_ip_addr & 0x00ff0000) >> 16, |
| 755 | (bd->bi_ip_addr & 0x0000ff00) >> 8, |
| 756 | (bd->bi_ip_addr & 0x000000ff)); |
| 757 | setenv("ipaddr", str); |
| 758 | printf("Updated ip_addr from bp_eeprom to %s!\n", str); |
| 759 | } |
| 760 | |
| 761 | free(buf); |
| 762 | |
| 763 | return 0; |
| 764 | } |
| 765 | U_BOOT_CMD( |
| 766 | getbpip, 1, 1, do_get_bpip, |
| 767 | "getbpip - Update IP-Address with Backplane IP-Address\n", |
| 768 | NULL |
| 769 | ); |
| 770 | |
| 771 | /* |
| 772 | * Set and print backplane ip... |
| 773 | */ |
| 774 | int do_set_bpip(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 775 | { |
| 776 | char *buf; |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 777 | char str[32]; |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 778 | ulong crc; |
| 779 | |
| 780 | if (argc < 2) { |
| 781 | puts("ERROR!\n"); |
| 782 | return -1; |
| 783 | } |
| 784 | |
| 785 | printf("Setting bp_ip to %s\n", argv[1]); |
| 786 | buf = malloc(CFG_ENV_SIZE_2); |
| 787 | memset(buf, 0, CFG_ENV_SIZE_2); |
| 788 | sprintf(str, "bp_ip=%s", argv[1]); |
| 789 | strcpy(buf+4, str); |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 790 | crc = crc32(0, (uchar *)(buf+4), CFG_ENV_SIZE_2-4); |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 791 | *(ulong *)buf = crc; |
| 792 | |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 793 | if (eeprom_write(CFG_I2C_EEPROM_ADDR_2, 0, (uchar *)buf, CFG_ENV_SIZE_2)) { |
stroese | 9b115e9 | 2004-12-16 18:27:05 +0000 | [diff] [blame] | 794 | puts("\nError writing backplane EEPROM!\n"); |
| 795 | } |
| 796 | |
| 797 | free(buf); |
| 798 | |
| 799 | return 0; |
| 800 | } |
| 801 | U_BOOT_CMD( |
| 802 | setbpip, 2, 1, do_set_bpip, |
| 803 | "setbpip - Write Backplane IP-Address\n", |
| 804 | NULL |
| 805 | ); |
| 806 | |
stroese | c8065c9 | 2003-09-12 08:44:46 +0000 | [diff] [blame] | 807 | #endif /* CONFIG_CPCI405AB */ |