device.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-10-24 GuEe-GUI first version
  9. */
  10. #include <drivers/pci.h>
  11. void rt_pci_msi_init(struct rt_pci_device *pdev)
  12. {
  13. if (pdev && (pdev->msi_cap = rt_pci_find_capability(pdev, PCIY_MSI)))
  14. {
  15. rt_uint16_t ctrl;
  16. rt_pci_read_config_u16(pdev, pdev->msi_cap + PCIR_MSI_CTRL, &ctrl);
  17. if (ctrl & PCIM_MSICTRL_MSI_ENABLE)
  18. {
  19. rt_pci_write_config_u16(pdev, pdev->msi_cap + PCIR_MSI_CTRL, ctrl & ~PCIM_MSICTRL_MSI_ENABLE);
  20. }
  21. if (!(ctrl & PCIM_MSICTRL_64BIT))
  22. {
  23. pdev->no_64bit_msi = RT_TRUE;
  24. }
  25. }
  26. }
  27. void rt_pci_msix_init(struct rt_pci_device *pdev)
  28. {
  29. if (pdev && (pdev->msix_cap = rt_pci_find_capability(pdev, PCIY_MSIX)))
  30. {
  31. rt_uint16_t ctrl;
  32. rt_pci_read_config_u16(pdev, pdev->msix_cap + PCIR_MSIX_CTRL, &ctrl);
  33. if (ctrl & PCIM_MSIXCTRL_MSIX_ENABLE)
  34. {
  35. rt_pci_write_config_u16(pdev, pdev->msix_cap + PCIR_MSIX_CTRL, ctrl & ~PCIM_MSIXCTRL_MSIX_ENABLE);
  36. }
  37. }
  38. }