Blame view

common/cmd_pci.c 14.8 KB
c609719b8   wdenk   Initial revision
1
2
3
4
5
6
7
8
  /*
   * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
   * Andreas Heppel <aheppel@sysgo.de>
   *
   * (C) Copyright 2002
   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
   * Wolfgang Grandegger, DENX Software Engineering, wg@denx.de.
   *
1a4596601   Wolfgang Denk   Add GPL-2.0+ SPDX...
9
   * SPDX-License-Identifier:	GPL-2.0+
c609719b8   wdenk   Initial revision
10
11
12
13
14
15
16
   */
  
  /*
   * PCI routines
   */
  
  #include <common.h>
0098e179e   Simon Glass   Move bootretry co...
17
  #include <bootretry.h>
18d66533a   Simon Glass   move CLI prototyp...
18
  #include <cli.h>
c609719b8   wdenk   Initial revision
19
  #include <command.h>
c609719b8   wdenk   Initial revision
20
21
  #include <asm/processor.h>
  #include <asm/io.h>
c609719b8   wdenk   Initial revision
22
  #include <pci.h>
c609719b8   wdenk   Initial revision
23
24
25
26
27
28
29
30
31
32
33
  /*
   * Follows routines for the output of infos about devices on PCI bus.
   */
  
  void pci_header_show(pci_dev_t dev);
  void pci_header_show_brief(pci_dev_t dev);
  
  /*
   * Subroutine:  pciinfo
   *
   * Description: Show information about devices on PCI bus.
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
34
   *				Depending on the define CONFIG_SYS_SHORT_PCI_LISTING
c609719b8   wdenk   Initial revision
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
   *				the output will be more or less exhaustive.
   *
   * Inputs:	bus_no		the number of the bus to be scanned.
   *
   * Return:      None
   *
   */
  void pciinfo(int BusNum, int ShortPCIListing)
  {
  	int Device;
  	int Function;
  	unsigned char HeaderType;
  	unsigned short VendorID;
  	pci_dev_t dev;
  
  	printf("Scanning PCI devices on bus %d
  ", BusNum);
  
  	if (ShortPCIListing) {
  		printf("BusDevFun  VendorId   DeviceId   Device Class       Sub-Class
  ");
  		printf("_____________________________________________________________
  ");
  	}
  
  	for (Device = 0; Device < PCI_MAX_PCI_DEVICES; Device++) {
  		HeaderType = 0;
  		VendorID = 0;
  		for (Function = 0; Function < PCI_MAX_PCI_FUNCTIONS; Function++) {
  			/*
  			 * If this is not a multi-function device, we skip the rest.
  			 */
  			if (Function && !(HeaderType & 0x80))
  				break;
  
  			dev = PCI_BDF(BusNum, Device, Function);
  
  			pci_read_config_word(dev, PCI_VENDOR_ID, &VendorID);
  			if ((VendorID == 0xFFFF) || (VendorID == 0x0000))
  				continue;
c7de829c7   wdenk   * Patch by Thomas...
75
  			if (!Function) pci_read_config_byte(dev, PCI_HEADER_TYPE, &HeaderType);
c609719b8   wdenk   Initial revision
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
  
  			if (ShortPCIListing)
  			{
  				printf("%02x.%02x.%02x   ", BusNum, Device, Function);
  				pci_header_show_brief(dev);
  			}
  			else
  			{
  				printf("
  Found PCI device %02x.%02x.%02x:
  ",
  				       BusNum, Device, Function);
  				pci_header_show(dev);
  			}
  	    }
      }
  }
c609719b8   wdenk   Initial revision
93
94
95
96
97
  
  /*
   * Subroutine:  pci_header_show_brief
   *
   * Description: Reads and prints the header of the
53677ef18   Wolfgang Denk   Big white-space c...
98
   *		specified PCI device in short form.
c609719b8   wdenk   Initial revision
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
   *
   * Inputs:	dev      Bus+Device+Function number
   *
   * Return:      None
   *
   */
  void pci_header_show_brief(pci_dev_t dev)
  {
  	u16 vendor, device;
  	u8 class, subclass;
  
  	pci_read_config_word(dev, PCI_VENDOR_ID, &vendor);
  	pci_read_config_word(dev, PCI_DEVICE_ID, &device);
  	pci_read_config_byte(dev, PCI_CLASS_CODE, &class);
  	pci_read_config_byte(dev, PCI_CLASS_SUB_CODE, &subclass);
5d232d0e7   wdenk   * Patch by Dave E...
114
115
  	printf("0x%.4x     0x%.4x     %-23s 0x%.2x
  ",
c609719b8   wdenk   Initial revision
116
  	       vendor, device,
983eb9d16   Peter Tyser   pci: Clean up PCI...
117
  	       pci_class_str(class), subclass);
c609719b8   wdenk   Initial revision
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
  }
  
  /*
   * Subroutine:  PCI_Header_Show
   *
   * Description: Reads the header of the specified PCI device.
   *
   * Inputs:		BusDevFunc      Bus+Device+Function number
   *
   * Return:      None
   *
   */
  void pci_header_show(pci_dev_t dev)
  {
  	u8 _byte, header_type;
  	u16 _word;
  	u32 _dword;
  
  #define PRINT(msg, type, reg) \
  	pci_read_config_##type(dev, reg, &_##type); \
  	printf(msg, _##type)
  
  #define PRINT2(msg, type, reg, func) \
  	pci_read_config_##type(dev, reg, &_##type); \
  	printf(msg, _##type, func(_##type))
  
  	pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
  
  	PRINT ("  vendor ID =                   0x%.4x
  ", word, PCI_VENDOR_ID);
  	PRINT ("  device ID =                   0x%.4x
  ", word, PCI_DEVICE_ID);
  	PRINT ("  command register =            0x%.4x
  ", word, PCI_COMMAND);
  	PRINT ("  status register =             0x%.4x
  ", word, PCI_STATUS);
  	PRINT ("  revision ID =                 0x%.2x
  ", byte, PCI_REVISION_ID);
  	PRINT2("  class code =                  0x%.2x (%s)
  ", byte, PCI_CLASS_CODE,
983eb9d16   Peter Tyser   pci: Clean up PCI...
158
  								pci_class_str);
c609719b8   wdenk   Initial revision
159
160
161
162
163
164
165
166
167
168
169
170
171
172
  	PRINT ("  sub class code =              0x%.2x
  ", byte, PCI_CLASS_SUB_CODE);
  	PRINT ("  programming interface =       0x%.2x
  ", byte, PCI_CLASS_PROG);
  	PRINT ("  cache line =                  0x%.2x
  ", byte, PCI_CACHE_LINE_SIZE);
  	PRINT ("  latency time =                0x%.2x
  ", byte, PCI_LATENCY_TIMER);
  	PRINT ("  header type =                 0x%.2x
  ", byte, PCI_HEADER_TYPE);
  	PRINT ("  BIST =                        0x%.2x
  ", byte, PCI_BIST);
  	PRINT ("  base address 0 =              0x%.8x
  ", dword, PCI_BASE_ADDRESS_0);
c609719b8   wdenk   Initial revision
173

7c7a23bd5   wdenk   * Patch by Hans-J...
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
  	switch (header_type & 0x03) {
  	case PCI_HEADER_TYPE_NORMAL:	/* "normal" PCI device */
  		PRINT ("  base address 1 =              0x%.8x
  ", dword, PCI_BASE_ADDRESS_1);
  		PRINT ("  base address 2 =              0x%.8x
  ", dword, PCI_BASE_ADDRESS_2);
  		PRINT ("  base address 3 =              0x%.8x
  ", dword, PCI_BASE_ADDRESS_3);
  		PRINT ("  base address 4 =              0x%.8x
  ", dword, PCI_BASE_ADDRESS_4);
  		PRINT ("  base address 5 =              0x%.8x
  ", dword, PCI_BASE_ADDRESS_5);
  		PRINT ("  cardBus CIS pointer =         0x%.8x
  ", dword, PCI_CARDBUS_CIS);
  		PRINT ("  sub system vendor ID =        0x%.4x
  ", word, PCI_SUBSYSTEM_VENDOR_ID);
  		PRINT ("  sub system ID =               0x%.4x
  ", word, PCI_SUBSYSTEM_ID);
  		PRINT ("  expansion ROM base address =  0x%.8x
  ", dword, PCI_ROM_ADDRESS);
  		PRINT ("  interrupt line =              0x%.2x
  ", byte, PCI_INTERRUPT_LINE);
  		PRINT ("  interrupt pin =               0x%.2x
  ", byte, PCI_INTERRUPT_PIN);
  		PRINT ("  min Grant =                   0x%.2x
  ", byte, PCI_MIN_GNT);
  		PRINT ("  max Latency =                 0x%.2x
  ", byte, PCI_MAX_LAT);
  		break;
8bde7f776   wdenk   * Code cleanup:
203

7c7a23bd5   wdenk   * Patch by Hans-J...
204
205
206
207
  	case PCI_HEADER_TYPE_BRIDGE:	/* PCI-to-PCI bridge */
  
  		PRINT ("  base address 1 =              0x%.8x
  ", dword, PCI_BASE_ADDRESS_1);
c609719b8   wdenk   Initial revision
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
  		PRINT ("  primary bus number =          0x%.2x
  ", byte, PCI_PRIMARY_BUS);
  		PRINT ("  secondary bus number =        0x%.2x
  ", byte, PCI_SECONDARY_BUS);
  		PRINT ("  subordinate bus number =      0x%.2x
  ", byte, PCI_SUBORDINATE_BUS);
  		PRINT ("  secondary latency timer =     0x%.2x
  ", byte, PCI_SEC_LATENCY_TIMER);
  		PRINT ("  IO base =                     0x%.2x
  ", byte, PCI_IO_BASE);
  		PRINT ("  IO limit =                    0x%.2x
  ", byte, PCI_IO_LIMIT);
  		PRINT ("  secondary status =            0x%.4x
  ", word, PCI_SEC_STATUS);
  		PRINT ("  memory base =                 0x%.4x
  ", word, PCI_MEMORY_BASE);
  		PRINT ("  memory limit =                0x%.4x
  ", word, PCI_MEMORY_LIMIT);
  		PRINT ("  prefetch memory base =        0x%.4x
  ", word, PCI_PREF_MEMORY_BASE);
  		PRINT ("  prefetch memory limit =       0x%.4x
  ", word, PCI_PREF_MEMORY_LIMIT);
  		PRINT ("  prefetch memory base upper =  0x%.8x
  ", dword, PCI_PREF_BASE_UPPER32);
  		PRINT ("  prefetch memory limit upper = 0x%.8x
  ", dword, PCI_PREF_LIMIT_UPPER32);
  		PRINT ("  IO base upper 16 bits =       0x%.4x
  ", word, PCI_IO_BASE_UPPER16);
  		PRINT ("  IO limit upper 16 bits =      0x%.4x
  ", word, PCI_IO_LIMIT_UPPER16);
  		PRINT ("  expansion ROM base address =  0x%.8x
  ", dword, PCI_ROM_ADDRESS1);
  		PRINT ("  interrupt line =              0x%.2x
  ", byte, PCI_INTERRUPT_LINE);
  		PRINT ("  interrupt pin =               0x%.2x
  ", byte, PCI_INTERRUPT_PIN);
  		PRINT ("  bridge control =              0x%.4x
  ", word, PCI_BRIDGE_CONTROL);
7c7a23bd5   wdenk   * Patch by Hans-J...
246
247
248
249
250
251
252
253
254
255
256
257
258
259
  		break;
  
  	case PCI_HEADER_TYPE_CARDBUS:	/* PCI-to-CardBus bridge */
  
  		PRINT ("  capabilities =                0x%.2x
  ", byte, PCI_CB_CAPABILITY_LIST);
  		PRINT ("  secondary status =            0x%.4x
  ", word, PCI_CB_SEC_STATUS);
  		PRINT ("  primary bus number =          0x%.2x
  ", byte, PCI_CB_PRIMARY_BUS);
  		PRINT ("  CardBus number =              0x%.2x
  ", byte, PCI_CB_CARD_BUS);
  		PRINT ("  subordinate bus number =      0x%.2x
  ", byte, PCI_CB_SUBORDINATE_BUS);
8bde7f776   wdenk   * Code cleanup:
260
261
  		PRINT ("  CardBus latency timer =       0x%.2x
  ", byte, PCI_CB_LATENCY_TIMER);
7c7a23bd5   wdenk   * Patch by Hans-J...
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
  		PRINT ("  CardBus memory base 0 =       0x%.8x
  ", dword, PCI_CB_MEMORY_BASE_0);
  		PRINT ("  CardBus memory limit 0 =      0x%.8x
  ", dword, PCI_CB_MEMORY_LIMIT_0);
  		PRINT ("  CardBus memory base 1 =       0x%.8x
  ", dword, PCI_CB_MEMORY_BASE_1);
  		PRINT ("  CardBus memory limit 1 =      0x%.8x
  ", dword, PCI_CB_MEMORY_LIMIT_1);
  		PRINT ("  CardBus IO base 0 =           0x%.4x
  ", word, PCI_CB_IO_BASE_0);
  		PRINT ("  CardBus IO base high 0 =      0x%.4x
  ", word, PCI_CB_IO_BASE_0_HI);
  		PRINT ("  CardBus IO limit 0 =          0x%.4x
  ", word, PCI_CB_IO_LIMIT_0);
  		PRINT ("  CardBus IO limit high 0 =     0x%.4x
  ", word, PCI_CB_IO_LIMIT_0_HI);
  		PRINT ("  CardBus IO base 1 =           0x%.4x
  ", word, PCI_CB_IO_BASE_1);
  		PRINT ("  CardBus IO base high 1 =      0x%.4x
  ", word, PCI_CB_IO_BASE_1_HI);
  		PRINT ("  CardBus IO limit 1 =          0x%.4x
  ", word, PCI_CB_IO_LIMIT_1);
  		PRINT ("  CardBus IO limit high 1 =     0x%.4x
  ", word, PCI_CB_IO_LIMIT_1_HI);
  		PRINT ("  interrupt line =              0x%.2x
  ", byte, PCI_INTERRUPT_LINE);
  		PRINT ("  interrupt pin =               0x%.2x
  ", byte, PCI_INTERRUPT_PIN);
  		PRINT ("  bridge control =              0x%.4x
  ", word, PCI_CB_BRIDGE_CONTROL);
  		PRINT ("  subvendor ID =                0x%.4x
  ", word, PCI_CB_SUBSYSTEM_VENDOR_ID);
  		PRINT ("  subdevice ID =                0x%.4x
  ", word, PCI_CB_SUBSYSTEM_ID);
  		PRINT ("  PC Card 16bit base address =  0x%.8x
  ", dword, PCI_CB_LEGACY_MODE_BASE);
  		break;
8bde7f776   wdenk   * Code cleanup:
299

7c7a23bd5   wdenk   * Patch by Hans-J...
300
301
302
  	default:
  		printf("unknown header
  ");
8bde7f776   wdenk   * Code cleanup:
303
  		break;
c609719b8   wdenk   Initial revision
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
      }
  
  #undef PRINT
  #undef PRINT2
  }
  
  /* Convert the "bus.device.function" identifier into a number.
   */
  static pci_dev_t get_pci_dev(char* name)
  {
  	char cnum[12];
  	int len, i, iold, n;
  	int bdfs[3] = {0,0,0};
  
  	len = strlen(name);
  	if (len > 8)
  		return -1;
  	for (i = 0, iold = 0, n = 0; i < len; i++) {
  		if (name[i] == '.') {
  			memcpy(cnum, &name[iold], i - iold);
  			cnum[i - iold] = '\0';
  			bdfs[n++] = simple_strtoul(cnum, NULL, 16);
  			iold = i + 1;
  		}
  	}
  	strcpy(cnum, &name[iold]);
  	if (n == 0)
  		n = 1;
  	bdfs[n] = simple_strtoul(cnum, NULL, 16);
  	return PCI_BDF(bdfs[0], bdfs[1], bdfs[2]);
  }
  
  static int pci_cfg_display(pci_dev_t bdf, ulong addr, ulong size, ulong length)
  {
  #define DISP_LINE_LEN	16
  	ulong i, nbytes, linebytes;
  	int rc = 0;
  
  	if (length == 0)
  		length = 0x40 / size; /* Standard PCI configuration space */
  
  	/* Print the lines.
  	 * once, and all accesses are with the specified bus width.
  	 */
  	nbytes = length * size;
  	do {
  		uint	val4;
  		ushort  val2;
  		u_char	val1;
  
  		printf("%08lx:", addr);
  		linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes;
  		for (i=0; i<linebytes; i+= size) {
  			if (size == 4) {
  				pci_read_config_dword(bdf, addr, &val4);
  				printf(" %08x", val4);
  			} else if (size == 2) {
  				pci_read_config_word(bdf, addr, &val2);
  				printf(" %04x", val2);
  			} else {
  				pci_read_config_byte(bdf, addr, &val1);
  				printf(" %02x", val1);
  			}
  			addr += size;
  		}
  		printf("
  ");
  		nbytes -= linebytes;
  		if (ctrlc()) {
  			rc = 1;
  			break;
  		}
  	} while (nbytes > 0);
  
  	return (rc);
  }
  
  static int pci_cfg_write (pci_dev_t bdf, ulong addr, ulong size, ulong value)
  {
  	if (size == 4) {
  		pci_write_config_dword(bdf, addr, value);
  	}
  	else if (size == 2) {
  		ushort val = value & 0xffff;
  		pci_write_config_word(bdf, addr, val);
  	}
  	else {
  		u_char val = value & 0xff;
  		pci_write_config_byte(bdf, addr, val);
  	}
  	return 0;
  }
  
  static int
  pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag)
  {
  	ulong	i;
  	int	nbytes;
c609719b8   wdenk   Initial revision
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
  	uint	val4;
  	ushort  val2;
  	u_char	val1;
  
  	/* Print the address, followed by value.  Then accept input for
  	 * the next value.  A non-converted value exits.
  	 */
  	do {
  		printf("%08lx:", addr);
  		if (size == 4) {
  			pci_read_config_dword(bdf, addr, &val4);
  			printf(" %08x", val4);
  		}
  		else if (size == 2) {
  			pci_read_config_word(bdf, addr, &val2);
  			printf(" %04x", val2);
  		}
  		else {
  			pci_read_config_byte(bdf, addr, &val1);
  			printf(" %02x", val1);
  		}
e1bf824df   Simon Glass   Add cli_ prefix t...
423
  		nbytes = cli_readline(" ? ");
c609719b8   wdenk   Initial revision
424
425
426
427
428
429
430
  		if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
  			/* <CR> pressed as only input, don't modify current
  			 * location and move to next. "-" pressed will go back.
  			 */
  			if (incrflag)
  				addr += nbytes ? -size : size;
  			nbytes = 1;
b26440f1f   Simon Glass   Rename bootretry ...
431
432
  			/* good enough to not time out */
  			bootretry_reset_cmd_timeout();
c609719b8   wdenk   Initial revision
433
434
435
436
437
438
439
440
441
442
443
  		}
  #ifdef CONFIG_BOOT_RETRY_TIME
  		else if (nbytes == -2) {
  			break;	/* timed out, exit the command	*/
  		}
  #endif
  		else {
  			char *endp;
  			i = simple_strtoul(console_buffer, &endp, 16);
  			nbytes = endp - console_buffer;
  			if (nbytes) {
c609719b8   wdenk   Initial revision
444
445
  				/* good enough to not time out
  				 */
b26440f1f   Simon Glass   Rename bootretry ...
446
  				bootretry_reset_cmd_timeout();
c609719b8   wdenk   Initial revision
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
  				pci_cfg_write (bdf, addr, size, i);
  				if (incrflag)
  					addr += size;
  			}
  		}
  	} while (nbytes);
  
  	return 0;
  }
  
  /* PCI Configuration Space access commands
   *
   * Syntax:
   *	pci display[.b, .w, .l] bus.device.function} [addr] [len]
   *	pci next[.b, .w, .l] bus.device.function [addr]
   *      pci modify[.b, .w, .l] bus.device.function [addr]
   *      pci write[.b, .w, .l] bus.device.function addr value
   */
088f1b199   Kim Phillips   common/cmd_*.c: s...
465
  static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
c609719b8   wdenk   Initial revision
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
  {
  	ulong addr = 0, value = 0, size = 0;
  	pci_dev_t bdf = 0;
  	char cmd = 's';
  
  	if (argc > 1)
  		cmd = argv[1][0];
  
  	switch (cmd) {
  	case 'd':		/* display */
  	case 'n':		/* next */
  	case 'm':		/* modify */
  	case 'w':		/* write */
  		/* Check for a size specification. */
  		size = cmd_get_data_size(argv[1], 4);
  		if (argc > 3)
  			addr = simple_strtoul(argv[3], NULL, 16);
  		if (argc > 4)
  			value = simple_strtoul(argv[4], NULL, 16);
  	case 'h':		/* header */
  		if (argc < 3)
  			goto usage;
  		if ((bdf = get_pci_dev(argv[2])) == -1)
  			return 1;
  		break;
96d616032   John Schmoller   pci: Add ability ...
491
492
493
494
  #ifdef CONFIG_CMD_PCI_ENUM
  	case 'e':
  		break;
  #endif
c609719b8   wdenk   Initial revision
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
  	default:		/* scan bus */
  		value = 1; /* short listing */
  		bdf = 0;   /* bus number  */
  		if (argc > 1) {
  			if (argv[argc-1][0] == 'l') {
  				value = 0;
  				argc--;
  			}
  			if (argc > 1)
  				bdf = simple_strtoul(argv[1], NULL, 16);
  		}
  		pciinfo(bdf, value);
  		return 0;
  	}
  
  	switch (argv[1][0]) {
  	case 'h':		/* header */
  		pci_header_show(bdf);
  		return 0;
  	case 'd':		/* display */
  		return pci_cfg_display(bdf, addr, size, value);
96d616032   John Schmoller   pci: Add ability ...
516
517
518
519
520
  #ifdef CONFIG_CMD_PCI_ENUM
  	case 'e':
  		pci_init();
  		return 0;
  #endif
c609719b8   wdenk   Initial revision
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
  	case 'n':		/* next */
  		if (argc < 4)
  			goto usage;
  		return pci_cfg_modify(bdf, addr, size, value, 0);
  	case 'm':		/* modify */
  		if (argc < 4)
  			goto usage;
  		return pci_cfg_modify(bdf, addr, size, value, 1);
  	case 'w':		/* write */
  		if (argc < 5)
  			goto usage;
  		return pci_cfg_write(bdf, addr, size, value);
  	}
  
  	return 1;
   usage:
4c12eeb8b   Simon Glass   Convert cmd_usage...
537
  	return CMD_RET_USAGE;
c609719b8   wdenk   Initial revision
538
  }
8bde7f776   wdenk   * Code cleanup:
539
  /***************************************************/
088f1b199   Kim Phillips   common/cmd_*.c: s...
540
541
  #ifdef CONFIG_SYS_LONGHELP
  static char pci_help_text[] =
8bde7f776   wdenk   * Code cleanup:
542
543
544
545
  	"[bus] [long]
  "
  	"    - short or long list of PCI devices on bus 'bus'
  "
96d616032   John Schmoller   pci: Add ability ...
546
547
548
549
550
551
  #ifdef CONFIG_CMD_PCI_ENUM
  	"pci enum
  "
  	"    - re-enumerate PCI buses
  "
  #endif
8bde7f776   wdenk   * Code cleanup:
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
  	"pci header b.d.f
  "
  	"    - show header of PCI device 'bus.device.function'
  "
  	"pci display[.b, .w, .l] b.d.f [address] [# of objects]
  "
  	"    - display PCI configuration space (CFG)
  "
  	"pci next[.b, .w, .l] b.d.f address
  "
  	"    - modify, read and keep CFG address
  "
  	"pci modify[.b, .w, .l] b.d.f address
  "
  	"    -  modify, auto increment CFG address
  "
  	"pci write[.b, .w, .l] b.d.f address value
  "
088f1b199   Kim Phillips   common/cmd_*.c: s...
570
571
572
573
574
575
  	"    - write to CFG address";
  #endif
  
  U_BOOT_CMD(
  	pci,	5,	1,	do_pci,
  	"list and access PCI Configuration Space", pci_help_text
8bde7f776   wdenk   * Code cleanup:
576
  );