xref: /openbmc/u-boot/drivers/pci/pci_internal.h (revision baefb63a)
1 /*
2  * Internal PCI functions, not exported outside drivers/pci
3  *
4  * Copyright (c) 2015 Google, Inc
5  * Written by Simon Glass <sjg@chromium.org>
6  *
7  * SPDX-License-Identifier:	GPL-2.0+
8  */
9 
10 #ifndef __pci_internal_h
11 #define __pci_internal_h
12 
13 /**
14  * dm_pciauto_prescan_setup_bridge() - Set up a bridge for scanning
15  *
16  * This gets a bridge ready so that its downstream devices can be scanned.
17  * It sets up the bus number and memory range registers. Once the scan is
18  * completed, dm_pciauto_postscan_setup_bridge() should be called.
19  *
20  * @dev:	Bridge device to be scanned
21  * @sub_bus:	Bus number of the 'other side' of the bridge
22  */
23 void dm_pciauto_prescan_setup_bridge(struct udevice *dev, int sub_bus);
24 
25 /**
26  * dm_pciauto_postscan_setup_bridge() - Finish set up of a bridge after scanning
27  *
28  * This should be called after a bus scan is complete. It adjusts the memory
29  * ranges to fit with the devices actually found on the other side (downstream)
30  * of the bridge.
31  *
32  * @dev:	Bridge device that was scanned
33  * @sub_bus:	Bus number of the 'other side' of the bridge
34  */
35 void dm_pciauto_postscan_setup_bridge(struct udevice *dev, int sub_bus);
36 
37 /**
38  * dm_pciauto_config_device() - Configure a PCI device ready for use
39  *
40  * If the device is a bridge, downstream devices will be probed.
41  *
42  * @dev:	Device to configure
43  * @return the maximum PCI bus number found by this device. If there are no
44  * bridges, this just returns the device's bus number. If the device is a
45  * bridge then it will return a larger number, depending on the devices on
46  * that bridge. On error, returns a -ve error number.
47  */
48 int dm_pciauto_config_device(struct udevice *dev);
49 
50 /**
51  * pci_get_bus() - Get a pointer to a bus, given its number
52  *
53  * This looks up a PCI bus based on its bus number. The bus is probed if
54  * necessary.
55  *
56  * @busnum:	PCI bus number to look up
57  * @busp:	Returns PCI bus on success
58  * @return 0 on success, or -ve error
59  */
60 int pci_get_bus(int busnum, struct udevice **busp);
61 
62 #endif
63