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