pci_compat.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #define DEBUG
  9. #include <common.h>
  10. #include <dm.h>
  11. #include <errno.h>
  12. #include <malloc.h>
  13. #include <pci.h>
  14. #include <dm/device-internal.h>
  15. #include <dm/lists.h>
  16. #define PCI_HOSE_OP(rw, name, size, type) \
  17. int pci_hose_##rw##_config_##name(struct pci_controller *hose, \
  18. pci_dev_t dev, \
  19. int offset, type value) \
  20. { \
  21. return pci_##rw##_config##size(dev, offset, value); \
  22. }
  23. PCI_HOSE_OP(read, byte, 8, u8 *)
  24. PCI_HOSE_OP(read, word, 16, u16 *)
  25. PCI_HOSE_OP(read, dword, 32, u32 *)
  26. PCI_HOSE_OP(write, byte, 8, u8)
  27. PCI_HOSE_OP(write, word, 16, u16)
  28. PCI_HOSE_OP(write, dword, 32, u32)
  29. pci_dev_t pci_find_devices(struct pci_device_id *ids, int index)
  30. {
  31. struct pci_child_platdata *pplat;
  32. struct udevice *bus, *dev;
  33. if (pci_find_device_id(ids, index, &dev))
  34. return -1;
  35. bus = dev->parent;
  36. pplat = dev_get_parent_platdata(dev);
  37. return PCI_ADD_BUS(bus->seq, pplat->devfn);
  38. }