pci_svc.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2021, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef PCI_SVC_H
  7. #define PCI_SVC_H
  8. #include <lib/utils_def.h>
  9. /* SMCCC PCI platform functions */
  10. #define SMC_PCI_VERSION U(0x84000130)
  11. #define SMC_PCI_FEATURES U(0x84000131)
  12. #define SMC_PCI_READ U(0x84000132)
  13. #define SMC_PCI_WRITE U(0x84000133)
  14. #define SMC_PCI_SEG_INFO U(0x84000134)
  15. #define is_pci_fid(_fid) (((_fid) >= SMC_PCI_VERSION) && \
  16. ((_fid) <= SMC_PCI_SEG_INFO))
  17. uint64_t pci_smc_handler(uint32_t smc_fid, u_register_t x1, u_register_t x2,
  18. u_register_t x3, u_register_t x4, void *cookie,
  19. void *handle, u_register_t flags);
  20. #define PCI_ADDR_FUN(dev) ((dev) & U(0x7))
  21. #define PCI_ADDR_DEV(dev) (((dev) >> U(3)) & U(0x001F))
  22. #define PCI_ADDR_BUS(dev) (((dev) >> U(8)) & U(0x00FF))
  23. #define PCI_ADDR_SEG(dev) (((dev) >> U(16)) & U(0xFFFF))
  24. #define PCI_OFFSET_MASK U(0xFFF)
  25. typedef union {
  26. struct {
  27. uint16_t minor;
  28. uint16_t major;
  29. } __packed;
  30. uint32_t val;
  31. } pcie_version;
  32. /*
  33. * platforms are responsible for providing implementations of these
  34. * three functions in a manner which conforms to the Arm PCI Configuration
  35. * Space Access Firmware Interface (DEN0115) and the PCIe specification's
  36. * sections on PCI configuration access. See the rpi4_pci_svc.c example.
  37. */
  38. uint32_t pci_read_config(uint32_t addr, uint32_t off, uint32_t sz, uint32_t *val);
  39. uint32_t pci_write_config(uint32_t addr, uint32_t off, uint32_t sz, uint32_t val);
  40. uint32_t pci_get_bus_for_seg(uint32_t seg, uint32_t *bus_range, uint32_t *nseg);
  41. /* Return codes for Arm PCI Config Space Access Firmware SMC calls */
  42. #define SMC_PCI_CALL_SUCCESS U(0)
  43. #define SMC_PCI_CALL_NOT_SUPPORTED -1
  44. #define SMC_PCI_CALL_INVAL_PARAM -2
  45. #define SMC_PCI_CALL_NOT_IMPL -3
  46. #define SMC_PCI_SZ_8BIT U(1)
  47. #define SMC_PCI_SZ_16BIT U(2)
  48. #define SMC_PCI_SZ_32BIT U(4)
  49. #endif /* PCI_SVC_H */