pci_internal.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #ifndef __pci_internal_h
  10. #define __pci_internal_h
  11. /**
  12. * dm_pciauto_prescan_setup_bridge() - Set up a bridge for scanning
  13. *
  14. * This gets a bridge ready so that its downstream devices can be scanned.
  15. * It sets up the bus number and memory range registers. Once the scan is
  16. * completed, dm_pciauto_postscan_setup_bridge() should be called.
  17. *
  18. * @dev: Bridge device to be scanned
  19. * @sub_bus: Bus number of the 'other side' of the bridge
  20. */
  21. void dm_pciauto_prescan_setup_bridge(struct udevice *dev, int sub_bus);
  22. /**
  23. * dm_pciauto_postscan_setup_bridge() - Finish set up of a bridge after scanning
  24. *
  25. * This should be called after a bus scan is complete. It adjusts the memory
  26. * ranges to fit with the devices actually found on the other side (downstream)
  27. * of the bridge.
  28. *
  29. * @dev: Bridge device that was scanned
  30. * @sub_bus: Bus number of the 'other side' of the bridge
  31. */
  32. void dm_pciauto_postscan_setup_bridge(struct udevice *dev, int sub_bus);
  33. /**
  34. * dm_pciauto_config_device() - Configure a PCI device ready for use
  35. *
  36. * If the device is a bridge, downstream devices will be probed.
  37. *
  38. * @dev: Device to configure
  39. * @return the maximum PCI bus number found by this device. If there are no
  40. * bridges, this just returns the device's bus number. If the device is a
  41. * bridge then it will return a larger number, depending on the devices on
  42. * that bridge. On error, returns a -ve error number.
  43. */
  44. int dm_pciauto_config_device(struct udevice *dev);
  45. /**
  46. * pci_get_bus() - Get a pointer to a bus, given its number
  47. *
  48. * This looks up a PCI bus based on its bus number. The bus is probed if
  49. * necessary.
  50. *
  51. * @busnum: PCI bus number to look up
  52. * @busp: Returns PCI bus on success
  53. * @return 0 on success, or -ve error
  54. */
  55. int pci_get_bus(int busnum, struct udevice **busp);
  56. #endif