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