1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <command.h>
26#include <pci.h>
27#include <pci_ids.h>
28#include <asm/4xx_pci.h>
29
30
31#if defined(CONFIG_CMD_BSP)
32
33
34
35
36int do_setdevice(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
37{
38 int idx = 1;
39 pci_dev_t bdf = 0;
40 u32 addr;
41
42 while (bdf >= 0) {
43 if ((bdf = pci_find_device(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_405GP, idx++)) < 0) {
44 break;
45 }
46 printf("Found device nr %d at %x!\n", idx-1, bdf);
47 pci_read_config_dword(bdf, PCI_BASE_ADDRESS_1, &addr);
48 addr &= ~0xf;
49 *(u32 *)addr = (bdf & 0x0000f800) >> 11;
50 printf("Wrote %x at %x!\n", (bdf & 0x0000f800) >> 11, addr);
51 }
52
53 return 0;
54}
55U_BOOT_CMD(
56 setdevice, 1, 1, do_setdevice,
57 "Set device number on pci adapter boards",
58 ""
59);
60
61
62
63
64
65int do_getdevice(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
66{
67 u32 device;
68 char str[32];
69
70 device = *(u32 *)0x0;
71 device = 0x16 - device;
72 sprintf(str, "%d", device);
73 setenv("slot", str);
74 printf("Variabel slot set to %x\n", device);
75
76 return 0;
77}
78U_BOOT_CMD(
79 getdevice, 1, 1, do_getdevice,
80 "Get device number and set slot env variable",
81 ""
82);
83
84#endif
85