blob: fe395ccb86b8bf849f1fd78c1b2bc90d1c78cd30 [file] [log] [blame]
Wolfgang Denk7521af12005-10-09 01:04:33 +02001/**
2 * @file powerspan.c Source file for PowerSpan II code.
3 */
4
5/*
6 * (C) Copyright 2005
7 * AMIRIX Systems Inc.
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27
28#include <common.h>
29#include <command.h>
30#include <asm/processor.h>
31#include "powerspan.h"
32#define tolower(x) x
33#include "ap1000.h"
34
35#ifdef INCLUDE_PCI
36
37/** Write one byte with byte swapping.
38 * @param addr [IN] the address to write to
39 * @param val [IN] the value to write
40 */
41void write1(unsigned long addr, unsigned char val) {
42 volatile unsigned char* p = (volatile unsigned char*)addr;
43#ifdef VERBOSITY
44 if(gVerbosityLevel > 1){
45 printf("write1: addr=%08x val=%02x\n", addr, val);
46 }
47#endif
48 *p = val;
49 PSII_SYNC();
50}
51
52/** Read one byte with byte swapping.
53 * @param addr [IN] the address to read from
54 * @return the value at addr
55 */
56unsigned char read1(unsigned long addr) {
57 unsigned char val;
58 volatile unsigned char* p = (volatile unsigned char*)addr;
59
60 val = *p;
61 PSII_SYNC();
62#ifdef VERBOSITY
63 if(gVerbosityLevel > 1){
64 printf("read1: addr=%08x val=%02x\n", addr, val);
65 }
66#endif
67 return val;
68}
69
70/** Write one 2-byte word with byte swapping.
71 * @param addr [IN] the address to write to
72 * @param val [IN] the value to write
73 */
74void write2(unsigned long addr, unsigned short val) {
75 volatile unsigned short* p = (volatile unsigned short*)addr;
76
77#ifdef VERBOSITY
78 if(gVerbosityLevel > 1){
79 printf("write2: addr=%08x val=%04x -> *p=%04x\n", addr, val,
80 ((val & 0xFF00) >> 8) | ((val & 0x00FF) << 8));
81 }
82#endif
83 *p = ((val & 0xFF00) >> 8) | ((val & 0x00FF) << 8);
84 PSII_SYNC();
85}
86
87/** Read one 2-byte word with byte swapping.
88 * @param addr [IN] the address to read from
89 * @return the value at addr
90 */
91unsigned short read2(unsigned long addr) {
92 unsigned short val;
93 volatile unsigned short* p = (volatile unsigned short*)addr;
94
95 val = *p;
96 val = ((val & 0xFF00) >> 8) | ((val & 0x00FF) << 8);
97 PSII_SYNC();
98#ifdef VERBOSITY
99 if(gVerbosityLevel > 1){
100 printf("read2: addr=%08x *p=%04x -> val=%04x\n", addr, *p, val);
101 }
102#endif
103 return val;
104}
105
106/** Write one 4-byte word with byte swapping.
107 * @param addr [IN] the address to write to
108 * @param val [IN] the value to write
109 */
110void write4(unsigned long addr, unsigned long val) {
111 volatile unsigned long* p = (volatile unsigned long*)addr;
112#ifdef VERBOSITY
113 if(gVerbosityLevel > 1){
114 printf("write4: addr=%08x val=%08x -> *p=%08x\n", addr, val,
115 ((val & 0xFF000000) >> 24) | ((val & 0x000000FF) << 24) |
116 ((val & 0x00FF0000) >> 8) | ((val & 0x0000FF00) << 8));
117 }
118#endif
119 *p = ((val & 0xFF000000) >> 24) | ((val & 0x000000FF) << 24) |
120 ((val & 0x00FF0000) >> 8) | ((val & 0x0000FF00) << 8);
121 PSII_SYNC();
122}
123
124/** Read one 4-byte word with byte swapping.
125 * @param addr [IN] the address to read from
126 * @return the value at addr
127 */
128unsigned long read4(unsigned long addr) {
129 unsigned long val;
130 volatile unsigned long* p = (volatile unsigned long*)addr;
131
132 val = *p;
133 val = ((val & 0xFF000000) >> 24) | ((val & 0x000000FF) << 24) |
134 ((val & 0x00FF0000) >> 8) | ((val & 0x0000FF00) << 8);
135 PSII_SYNC();
136#ifdef VERBOSITY
137 if(gVerbosityLevel > 1){
138 printf("read4: addr=%08x *p=%08x -> val=%08x\n", addr, *p, val);
139 }
140#endif
141 return val;
142}
143
144int PCIReadConfig(int bus, int dev, int fn, int reg, int width, unsigned long* val){
145 unsigned int conAdrVal;
146 unsigned int conDataReg = REG_CONFIG_DATA;
147 unsigned int status;
148 int ret_val = 0;
149
150
151 /* DEST bit hardcoded to 1: local pci is PCI-2 */
152 /* TYPE bit is hardcoded to 1: all config cycles are local */
153 conAdrVal = (1 << 24)
154 | ((bus & 0xFF) << 16)
155 | ((dev & 0xFF) << 11)
156 | ((fn & 0x07) << 8)
157 | (reg & 0xFC);
158
159 /* clear any pending master aborts */
160 write4(REG_P1_CSR, CLEAR_MASTER_ABORT);
161
162 /* Load the conAdrVal value first, then read from pb_conf_data */
163 write4(REG_CONFIG_ADDRESS, conAdrVal);
164 PSII_SYNC();
165
166
167 /* Note: documentation does not match the pspan library code */
168 /* Note: *pData comes back as -1 if device is not present */
169 switch (width){
170 case 4:{
171 *(unsigned int*)val = read4(conDataReg);
172 break;
173 }
174 case 2:{
175 *(unsigned short*)val = read2(conDataReg);
176 break;
177 }
178 case 1:{
179 *(unsigned char*)val = read1(conDataReg);
180 break;
181 }
182 default:{
183 ret_val = ILLEGAL_REG_OFFSET;
184 break;
185 }
186 }
187 PSII_SYNC();
188
189 /* clear any pending master aborts */
190 status = read4(REG_P1_CSR);
191 if(status & CLEAR_MASTER_ABORT){
192 ret_val = NO_DEVICE_FOUND;
193 write4(REG_P1_CSR, CLEAR_MASTER_ABORT);
194 }
195
196 return ret_val;
197}
198
199
200int PCIWriteConfig(int bus, int dev, int fn, int reg, int width, unsigned long val){
201 unsigned int conAdrVal;
202 unsigned int conDataReg = REG_CONFIG_DATA;
203 unsigned int status;
204 int ret_val = 0;
205
206
207 /* DEST bit hardcoded to 1: local pci is PCI-2 */
208 /* TYPE bit is hardcoded to 1: all config cycles are local */
209 conAdrVal = (1 << 24)
210 | ((bus & 0xFF) << 16)
211 | ((dev & 0xFF) << 11)
212 | ((fn & 0x07) << 8)
213 | (reg & 0xFC);
214
215 /* clear any pending master aborts */
216 write4(REG_P1_CSR, CLEAR_MASTER_ABORT);
217
218 /* Load the conAdrVal value first, then read from pb_conf_data */
219 write4(REG_CONFIG_ADDRESS, conAdrVal);
220 PSII_SYNC();
221
222
223 /* Note: documentation does not match the pspan library code */
224 /* Note: *pData comes back as -1 if device is not present */
225 switch (width){
226 case 4:{
227 write4(conDataReg, val);
228 break;
229 }
230 case 2:{
231 write2(conDataReg, val);
232 break;
233 }
234 case 1:{
235 write1(conDataReg, val);
236 break;
237 }
238 default:{
239 ret_val = ILLEGAL_REG_OFFSET;
240 break;
241 }
242 }
243 PSII_SYNC();
244
245 /* clear any pending master aborts */
246 status = read4(REG_P1_CSR);
247 if(status & CLEAR_MASTER_ABORT){
248 ret_val = NO_DEVICE_FOUND;
249 write4(REG_P1_CSR, CLEAR_MASTER_ABORT);
250 }
251
252 return ret_val;
253}
254
255
256int pci_read_config_byte(int bus, int dev, int fn, int reg, unsigned char* val){
257 unsigned long read_val;
258 int ret_val;
259
260 ret_val = PCIReadConfig(bus, dev, fn, reg, 1, &read_val);
261 *val = read_val & 0xFF;
262
263 return ret_val;
264}
265
266int pci_write_config_byte(int bus, int dev, int fn, int reg, unsigned char val){
267 return PCIWriteConfig(bus, dev, fn, reg, 1, val);
268}
269
270int pci_read_config_word(int bus, int dev, int fn, int reg, unsigned short* val){
271 unsigned long read_val;
272 int ret_val;
273
274 ret_val = PCIReadConfig(bus, dev, fn, reg, 2, &read_val);
275 *val = read_val & 0xFFFF;
276
277 return ret_val;
278}
279
280int pci_write_config_word(int bus, int dev, int fn, int reg, unsigned short val){
281 return PCIWriteConfig(bus, dev, fn, reg, 2, val);
282}
283
284int pci_read_config_dword(int bus, int dev, int fn, int reg, unsigned long* val){
285 return PCIReadConfig(bus, dev, fn, reg, 4, val);
286}
287
288int pci_write_config_dword(int bus, int dev, int fn, int reg, unsigned long val){
289 return PCIWriteConfig(bus, dev, fn, reg, 4, val);
290}
291
292#endif /* INCLUDE_PCI */
293
294int I2CAccess(unsigned char theI2CAddress, unsigned char theDevCode, unsigned char theChipSel, unsigned char* theValue, int RWFlag){
295 int ret_val = 0;
296 unsigned int reg_value;
297
298 reg_value = PowerSpanRead(REG_I2C_CSR);
299
300 if(reg_value & I2C_CSR_ACT){
301 printf("Error: I2C busy\n");
302 ret_val = I2C_BUSY;
303 }
304 else{
305 reg_value = ((theI2CAddress & 0xFF) << 24)
306 | ((theDevCode & 0x0F) << 12)
307 | ((theChipSel & 0x07) << 9)
308 | I2C_CSR_ERR;
309 if(RWFlag == I2C_WRITE){
310 reg_value |= I2C_CSR_RW | ((*theValue & 0xFF) << 16);
311 }
312
313 PowerSpanWrite(REG_I2C_CSR, reg_value);
314 udelay(1);
315
316 do{
317 reg_value = PowerSpanRead(REG_I2C_CSR);
318
319 if((reg_value & I2C_CSR_ACT) == 0){
320 if(reg_value & I2C_CSR_ERR){
321 ret_val = I2C_ERR;
322 }
323 else{
324 *theValue = (reg_value & I2C_CSR_DATA) >> 16;
325 }
326 }
327 } while(reg_value & I2C_CSR_ACT);
328 }
329
330 return ret_val;
331}
332
333int EEPROMRead(unsigned char theI2CAddress, unsigned char* theValue){
334 return I2CAccess(theI2CAddress, I2C_EEPROM_DEV, I2C_EEPROM_CHIP_SEL, theValue, I2C_READ);
335}
336
337int EEPROMWrite(unsigned char theI2CAddress, unsigned char theValue){
338 return I2CAccess(theI2CAddress, I2C_EEPROM_DEV, I2C_EEPROM_CHIP_SEL, &theValue, I2C_WRITE);
339}
340
341int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
342 char cmd;
343 int ret_val = 0;
344 unsigned int address = 0;
345 unsigned char value = 1;
346 unsigned char read_value;
347 int ii;
348 int error = 0;
349 unsigned char* mem_ptr;
350 unsigned char default_eeprom[] = EEPROM_DEFAULT;
351
352 if(argc < 2){
353 goto usage;
354 }
355
356 cmd = argv[1][0];
357 if(argc > 2){
358 address = simple_strtoul(argv[2], NULL, 16);
359 if(argc > 3){
360 value = simple_strtoul(argv[3], NULL, 16) & 0xFF;
361 }
362 }
363
364 switch (cmd){
365 case 'r':{
366 if(address > 256){
367 printf("Illegal Address\n");
368 goto usage;
369 }
370 printf("@0x%x: ", address);
371 for(ii = 0;ii < value;ii++){
372 if(EEPROMRead(address + ii, &read_value) != 0){
373 printf("Read Error\n");
374 }
375 else{
376 printf("0x%02x ", read_value);
377 }
378
379 if(((ii + 1) % 16) == 0){
380 printf("\n");
381 }
382 }
383 printf("\n");
384 break;
385 }
386 case 'w':{
387 if(address > 256){
388 printf("Illegal Address\n");
389 goto usage;
390 }
391 if(argc < 4){
392 goto usage;
393 }
394 if(EEPROMWrite(address, value) != 0){
395 printf("Write Error\n");
396 }
397 break;
398 }
399 case 'g':{
400 if(argc != 3){
401 goto usage;
402 }
403 mem_ptr = (unsigned char*)address;
404 for(ii = 0;((ii < EEPROM_LENGTH) && (error == 0));ii++){
405 if(EEPROMRead(ii, &read_value) != 0){
406 printf("Read Error\n");
407 error = 1;
408 }
409 else{
410 *mem_ptr = read_value;
411 mem_ptr++;
412 }
413 }
414 break;
415 }
416 case 'p':{
417 if(argc != 3){
418 goto usage;
419 }
420 mem_ptr = (unsigned char*)address;
421 for(ii = 0;((ii < EEPROM_LENGTH) && (error == 0));ii++){
422 if(EEPROMWrite(ii, *mem_ptr) != 0){
423 printf("Write Error\n");
424 error = 1;
425 }
426
427 mem_ptr++;
428 }
429 break;
430 }
431 case 'd':{
432 if(argc != 2){
433 goto usage;
434 }
435 for(ii = 0;((ii < EEPROM_LENGTH) && (error == 0));ii++){
436 if(EEPROMWrite(ii, default_eeprom[ii]) != 0){
437 printf("Write Error\n");
438 error = 1;
439 }
440 }
441 break;
442 }
443 default:{
444 goto usage;
445 }
446 }
447
448 goto done;
449 usage:
450 printf ("Usage:\n%s\n", cmdtp->help);
451
452 done:
453 return ret_val;
454
455}
456
457U_BOOT_CMD(
458 eeprom, 4, 0, do_eeprom,
459 "eeprom - read/write/copy to/from the PowerSpan II eeprom\n",
460 "eeprom r OFF [NUM]\n"
461 " - read NUM words starting at OFF\n"
462 "eeprom w OFF VAL\n"
463 " - write word VAL at offset OFF\n"
464 "eeprom g ADD\n"
465 " - store contents of eeprom at address ADD\n"
466 "eeprom p ADD\n"
467 " - put data stored at address ADD into the eeprom\n"
468 "eeprom d\n"
469 " - return eeprom to default contents\n"
470);
471
472unsigned int PowerSpanRead(unsigned int theOffset){
473 volatile unsigned int* ptr = (volatile unsigned int*)(PSPAN_BASEADDR + theOffset);
474 unsigned int ret_val;
475
476#ifdef VERBOSITY
477 if(gVerbosityLevel > 1){
478 printf("PowerSpanRead: offset=%08x ", theOffset);
479 }
480#endif
481 ret_val = *ptr;
482 PSII_SYNC();
483
484#ifdef VERBOSITY
485 if(gVerbosityLevel > 1){
486 printf("value=%08x\n", ret_val);
487 }
488#endif
489
490 return ret_val;
491}
492
493void PowerSpanWrite(unsigned int theOffset, unsigned int theValue){
494 volatile unsigned int* ptr = (volatile unsigned int*)(PSPAN_BASEADDR + theOffset);
495#ifdef VERBOSITY
496 if(gVerbosityLevel > 1){
497 printf("PowerSpanWrite: offset=%08x val=%02x\n", theOffset, theValue);
498 }
499#endif
500 *ptr = theValue;
501 PSII_SYNC();
502}
503
504/**
505 * Sets the indicated bits in the indicated register.
506 * @param theOffset [IN] the register to access.
507 * @param theMask [IN] bits set in theMask will be set in the register.
508 */
509void PowerSpanSetBits(unsigned int theOffset, unsigned int theMask){
510 volatile unsigned int* ptr = (volatile unsigned int*)(PSPAN_BASEADDR + theOffset);
511 unsigned int register_value;
512
513#ifdef VERBOSITY
514 if(gVerbosityLevel > 1){
515 printf("PowerSpanSetBits: offset=%08x mask=%02x\n", theOffset, theMask);
516 }
517#endif
518 register_value = *ptr;
519 PSII_SYNC();
520
521 register_value |= theMask;
522 *ptr = register_value;
523 PSII_SYNC();
524}
525
526/**
527 * Clears the indicated bits in the indicated register.
528 * @param theOffset [IN] the register to access.
529 * @param theMask [IN] bits set in theMask will be cleared in the register.
530 */
531void PowerSpanClearBits(unsigned int theOffset, unsigned int theMask){
532 volatile unsigned int* ptr = (volatile unsigned int*)(PSPAN_BASEADDR + theOffset);
533 unsigned int register_value;
534
535#ifdef VERBOSITY
536 if(gVerbosityLevel > 1){
537 printf("PowerSpanClearBits: offset=%08x mask=%02x\n", theOffset, theMask);
538 }
539#endif
540 register_value = *ptr;
541 PSII_SYNC();
542
543 register_value &= ~theMask;
544 *ptr = register_value;
545 PSII_SYNC();
546}
547
548/**
549 * Configures a slave image on the local bus, based on the parameters and some hardcoded system values.
550 * Slave Images are images that cause the PowerSpan II to be a master on the PCI bus. Thus, they
551 * are outgoing from the standpoint of the local bus.
552 * @param theImageIndex [IN] the PowerSpan II image to set (assumed to be 0-7).
553 * @param theBlockSize [IN] the block size of the image (as used by PowerSpan II: PB_SIx_CTL[BS]).
554 * @param theMemIOFlag [IN] if PX_TGT_USE_MEM_IO, this image will have the MEM_IO bit set.
555 * @param theEndianness [IN] the endian bits for the image (already shifted, use defines).
556 * @param theLocalBaseAddr [IN] the Local address for the image (assumed to be valid with provided block size).
557 * @param thePCIBaseAddr [IN] the PCI address for the image (assumed to be valid with provided block size).
558 */
559int SetSlaveImage(int theImageIndex, unsigned int theBlockSize, int theMemIOFlag, int theEndianness, unsigned int theLocalBaseAddr, unsigned int thePCIBaseAddr){
560 unsigned int reg_offset = theImageIndex * PB_SLAVE_IMAGE_OFF;
561 unsigned int reg_value = 0;
562
563 /* Make sure that the Slave Image is disabled */
564 PowerSpanClearBits((REGS_PB_SLAVE_CSR + reg_offset), PB_SLAVE_CSR_IMG_EN);
565
566 /* Setup the mask required for requested PB Slave Image configuration */
567 reg_value = PB_SLAVE_CSR_TA_EN | theEndianness | (theBlockSize << 24);
568 if(theMemIOFlag == PB_SLAVE_USE_MEM_IO){
569 reg_value |= PB_SLAVE_CSR_MEM_IO;
570 }
571
572 /* hardcoding the following:
573 TA_EN = 1
574 MD_EN = 0
575 MODE = 0
576 PRKEEP = 0
577 RD_AMT = 0
578 */
579 PowerSpanWrite((REGS_PB_SLAVE_CSR + reg_offset), reg_value);
580
581 /* these values are not checked by software */
582 PowerSpanWrite((REGS_PB_SLAVE_BADDR + reg_offset), theLocalBaseAddr);
583 PowerSpanWrite((REGS_PB_SLAVE_TADDR + reg_offset), thePCIBaseAddr);
584
585 /* Enable the Slave Image */
586 PowerSpanSetBits((REGS_PB_SLAVE_CSR + reg_offset), PB_SLAVE_CSR_IMG_EN);
587
588 return 0;
589}
590
591/**
592 * Configures a target image on the local bus, based on the parameters and some hardcoded system values.
593 * Target Images are used when the PowerSpan II is acting as a target for an access. Thus, they
594 * are incoming from the standpoint of the local bus.
595 * In order to behave better on the host PCI bus, if thePCIBaseAddr is NULL (0x00000000), then the PCI
596 * base address will not be updated; makes sense given that the hosts own memory should be mapped to
597 * PCI address 0x00000000.
598 * @param theImageIndex [IN] the PowerSpan II image to set.
599 * @param theBlockSize [IN] the block size of the image (as used by PowerSpan II: Px_TIx_CTL[BS]).
600 * @param theMemIOFlag [IN] if PX_TGT_USE_MEM_IO, this image will have the MEM_IO bit set.
601 * @param theEndianness [IN] the endian bits for the image (already shifted, use defines).
602 * @param theLocalBaseAddr [IN] the Local address for the image (assumed to be valid with provided block size).
603 * @param thePCIBaseAddr [IN] the PCI address for the image (assumed to be valid with provided block size).
604 */
605int SetTargetImage(int theImageIndex, unsigned int theBlockSize, int theMemIOFlag, int theEndianness, unsigned int theLocalBaseAddr, unsigned int thePCIBaseAddr){
606 unsigned int csr_reg_offset = theImageIndex * P1_TGT_IMAGE_OFF;
607 unsigned int pci_reg_offset = theImageIndex * P1_BST_OFF;
608 unsigned int reg_value = 0;
609
610 /* Make sure that the Slave Image is disabled */
611 PowerSpanClearBits((REGS_P1_TGT_CSR + csr_reg_offset), PB_SLAVE_CSR_IMG_EN);
612
613 /* Setup the mask required for requested PB Slave Image configuration */
614 reg_value = PX_TGT_CSR_TA_EN | PX_TGT_CSR_BAR_EN | (theBlockSize << 24) | PX_TGT_CSR_RTT_READ | PX_TGT_CSR_WTT_WFLUSH | theEndianness;
615 if(theMemIOFlag == PX_TGT_USE_MEM_IO){
616 reg_value |= PX_TGT_MEM_IO;
617 }
618
619 /* hardcoding the following:
620 TA_EN = 1
621 BAR_EN = 1
622 MD_EN = 0
623 MODE = 0
624 DEST = 0
625 RTT = 01010
626 GBL = 0
627 CI = 0
628 WTT = 00010
629 PRKEEP = 0
630 MRA = 0
631 RD_AMT = 0
632 */
633 PowerSpanWrite((REGS_P1_TGT_CSR + csr_reg_offset), reg_value);
634
635 PowerSpanWrite((REGS_P1_TGT_TADDR + csr_reg_offset), theLocalBaseAddr);
636
637 if(thePCIBaseAddr != (unsigned int)NULL){
638 PowerSpanWrite((REGS_P1_BST + pci_reg_offset), thePCIBaseAddr);
639 }
640
641 /* Enable the Slave Image */
642 PowerSpanSetBits((REGS_P1_TGT_CSR + csr_reg_offset), PB_SLAVE_CSR_IMG_EN);
643
644 return 0;
645}
646
647int do_bridge(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){
648 char cmd;
649 int ret_val = 1;
650 unsigned int image_index;
651 unsigned int block_size;
652 unsigned int mem_io;
653 unsigned int local_addr;
654 unsigned int pci_addr;
655 int endianness;
656
657 if(argc != 8){
658 goto usage;
659 }
660
661 cmd = argv[1][0];
662 image_index = simple_strtoul(argv[2], NULL, 16);
663 block_size = simple_strtoul(argv[3], NULL, 16);
664 mem_io = simple_strtoul(argv[4], NULL, 16);
665 endianness = argv[5][0];
666 local_addr = simple_strtoul(argv[6], NULL, 16);
667 pci_addr = simple_strtoul(argv[7], NULL, 16);
668
669
670 switch (cmd){
671 case 'i':{
672 if(tolower(endianness) == 'b'){
673 endianness = PX_TGT_CSR_BIG_END;
674 }
675 else if(tolower(endianness) == 'l'){
676 endianness = PX_TGT_CSR_TRUE_LEND;
677 }
678 else{
679 goto usage;
680 }
681 SetTargetImage(image_index, block_size, mem_io, endianness, local_addr, pci_addr);
682 break;
683 }
684 case 'o':{
685 if(tolower(endianness) == 'b'){
686 endianness = PB_SLAVE_CSR_BIG_END;
687 }
688 else if(tolower(endianness) == 'l'){
689 endianness = PB_SLAVE_CSR_TRUE_LEND;
690 }
691 else{
692 goto usage;
693 }
694 SetSlaveImage(image_index, block_size, mem_io, endianness, local_addr, pci_addr);
695 break;
696 }
697 default:{
698 goto usage;
699 }
700 }
701
702 goto done;
703 usage:
704 printf ("Usage:\n%s\n", cmdtp->help);
705
706 done:
707 return ret_val;
708
709}
710
711
712