1PCI with Driver Model
2=====================
3
4How busses are scanned
5----------------------
6
7Any config read will end up at pci_read_config(). This uses
8uclass_get_device_by_seq() to get the PCI bus for a particular bus number.
9Bus number 0 will need to  be requested first, and the alias in the device
10tree file will point to the correct device:
11
12
13	aliases {
14		pci0 = &pci;
15	};
16
17	pci: pci-controller {
18		compatible = "sandbox,pci";
19		...
20	};
21
22
23If there is no alias the devices will be numbered sequentially in the device
24tree.
25
26The call to uclass_get_device by seq() will cause the PCI bus to be probed.
27This does a scan of the bus to locate available devices. These devices are
28bound to their appropriate driver if available. If there is no driver, then
29they are bound to a generic PCI driver which does nothing.
30
31After probing a bus, the available devices will appear in the device tree
32under that bus.
33
34Note that this is all done on a lazy basis, as needed, so until something is
35touched on PCI it will not be probed.
36
37PCI devices can appear in the device tree. If they do this serves to specify
38the driver to use for the device. In this case they will be bound at
39start-up.
40
41
42Sandbox
43-------
44
45With sandbox we need a device emulator for each device on the bus since there
46is no real PCI bus. This works by looking in the device tree node for a
47driver. For example:
48
49
50	pci@1f,0 {
51		compatible = "pci-generic";
52		reg = <0xf800 0 0 0 0>;
53		emul@1f,0 {
54			compatible = "sandbox,swap-case";
55		};
56	};
57
58This means that there is a 'sandbox,swap-case' driver at that bus position.
59Note that the first cell in the 'reg' value is the bus/device/function. See
60PCI_BDF() for the encoding (it is also specified in the IEEE Std 1275-1994
61PCI bus binding document, v2.1)
62
63When this bus is scanned we will end up with something like this:
64
65`- * pci-controller @ 05c660c8, 0
66 `-   pci@1f,0 @ 05c661c8, 63488
67  `-   emul@1f,0 @ 05c662c8
68
69When accesses go to the pci@1f,0 device they are forwarded to its child, the
70emulator.
71