pci.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2019 Google, Inc
  4. */
  5. #ifndef __DM_PCI_H
  6. #define __DM_PCI_H
  7. struct udevice;
  8. /**
  9. * pci_get_devfn() - Extract the devfn from fdt_pci_addr of the device
  10. *
  11. * Get devfn from fdt_pci_addr of the specified device
  12. *
  13. * This returns an int to avoid a dependency on pci.h
  14. *
  15. * @dev: PCI device
  16. * @return devfn in bits 15...8 if found (pci_dev_t format), or -ENODEV if not
  17. * found
  18. */
  19. int pci_get_devfn(struct udevice *dev);
  20. /**
  21. * pci_ofplat_get_devfn() - Get the PCI dev/fn from of-platdata
  22. *
  23. * This function is used to obtain a PCI device/function from of-platdata
  24. * register data. In this case the first cell of the 'reg' property contains
  25. * the required information.
  26. *
  27. * This returns an int to avoid a dependency on pci.h
  28. *
  29. * @reg: reg value from dt-plat.c array (first member). This is not a
  30. * pointer type, since the caller may use fdt32_t or fdt64_t depending on
  31. * the address sizes.
  32. * @return device/function for that device (pci_dev_t format)
  33. */
  34. static inline int pci_ofplat_get_devfn(u32 reg)
  35. {
  36. return reg & 0xff00;
  37. }
  38. #endif