pci_compat.c 906 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Compatibility functions for pre-driver-model code
  3. *
  4. * Copyright (C) 2014 Google, Inc
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <dm.h>
  10. #include <errno.h>
  11. #include <malloc.h>
  12. #include <pci.h>
  13. #include <dm/device-internal.h>
  14. #include <dm/lists.h>
  15. #define PCI_HOSE_OP(rw, name, size, type) \
  16. int pci_hose_##rw##_config_##name(struct pci_controller *hose, \
  17. pci_dev_t dev, \
  18. int offset, type value) \
  19. { \
  20. return pci_##rw##_config##size(dev, offset, value); \
  21. }
  22. PCI_HOSE_OP(read, byte, 8, u8 *)
  23. PCI_HOSE_OP(read, word, 16, u16 *)
  24. PCI_HOSE_OP(read, dword, 32, u32 *)
  25. PCI_HOSE_OP(write, byte, 8, u8)
  26. PCI_HOSE_OP(write, word, 16, u16)
  27. PCI_HOSE_OP(write, dword, 32, u32)
  28. pci_dev_t pci_find_devices(struct pci_device_id *ids, int index)
  29. {
  30. struct udevice *dev;
  31. if (pci_find_device_id(ids, index, &dev))
  32. return -1;
  33. return pci_get_bdf(dev);
  34. }