multibus_pci.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include "hif.h"
  20. #include "hif_main.h"
  21. #include "multibus.h"
  22. #include "pci_api.h"
  23. #include "hif_io32.h"
  24. #include "dummy.h"
  25. #include "ce_api.h"
  26. /**
  27. * hif_initialize_pci_ops() - initialize the pci ops
  28. * @bus_ops: hif_bus_ops table pointer to initialize
  29. *
  30. * Return: QDF_STATUS_SUCCESS
  31. */
  32. QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc)
  33. {
  34. struct hif_bus_ops *bus_ops = &hif_sc->bus_ops;
  35. bus_ops->hif_bus_open = &hif_pci_open;
  36. bus_ops->hif_bus_close = &hif_pci_close;
  37. bus_ops->hif_bus_prevent_linkdown = &hif_pci_prevent_linkdown;
  38. bus_ops->hif_reset_soc = &hif_pci_reset_soc;
  39. bus_ops->hif_bus_suspend = &hif_pci_bus_suspend;
  40. bus_ops->hif_bus_resume = &hif_pci_bus_resume;
  41. bus_ops->hif_bus_suspend_noirq = &hif_pci_bus_suspend_noirq;
  42. bus_ops->hif_bus_resume_noirq = &hif_pci_bus_resume_noirq;
  43. /* do not put the target to sleep for epping or maxperf mode */
  44. if (CONFIG_ATH_PCIE_MAX_PERF == 0 &&
  45. !QDF_IS_EPPING_ENABLED(hif_get_conparam(hif_sc)))
  46. bus_ops->hif_target_sleep_state_adjust =
  47. &hif_pci_target_sleep_state_adjust;
  48. else
  49. bus_ops->hif_target_sleep_state_adjust =
  50. &hif_dummy_target_sleep_state_adjust;
  51. bus_ops->hif_disable_isr = &hif_pci_disable_isr;
  52. bus_ops->hif_nointrs = &hif_pci_nointrs;
  53. bus_ops->hif_enable_bus = &hif_pci_enable_bus;
  54. bus_ops->hif_disable_bus = &hif_pci_disable_bus;
  55. #ifdef FEATURE_RUNTIME_PM
  56. bus_ops->hif_bus_get_rpm_ctx = &hif_pci_get_rpm_ctx;
  57. bus_ops->hif_bus_get_dev = &hif_pci_get_dev;
  58. #endif
  59. bus_ops->hif_bus_configure = &hif_pci_bus_configure;
  60. bus_ops->hif_get_config_item = &hif_dummy_get_config_item;
  61. bus_ops->hif_set_mailbox_swap = &hif_dummy_set_mailbox_swap;
  62. bus_ops->hif_claim_device = &hif_dummy_claim_device;
  63. bus_ops->hif_shutdown_device = &hif_ce_stop;
  64. bus_ops->hif_stop = &hif_ce_stop;
  65. bus_ops->hif_cancel_deferred_target_sleep =
  66. &hif_pci_cancel_deferred_target_sleep;
  67. bus_ops->hif_irq_disable = &hif_pci_irq_disable;
  68. bus_ops->hif_irq_enable = &hif_pci_irq_enable;
  69. bus_ops->hif_dump_registers = &hif_pci_dump_registers;
  70. bus_ops->hif_dump_target_memory = &hif_ce_dump_target_memory;
  71. bus_ops->hif_reg_read32 = &hif_pci_reg_read32;
  72. bus_ops->hif_reg_write32 = &hif_pci_reg_write32;
  73. bus_ops->hif_ipa_get_ce_resource = &hif_ce_ipa_get_ce_resource;
  74. bus_ops->hif_mask_interrupt_call = &hif_dummy_mask_interrupt_call;
  75. bus_ops->hif_enable_power_management =
  76. &hif_pci_enable_power_management;
  77. bus_ops->hif_disable_power_management =
  78. &hif_pci_disable_power_management;
  79. bus_ops->hif_grp_irq_configure = &hif_pci_configure_grp_irq;
  80. bus_ops->hif_grp_irq_deconfigure = &hif_pci_deconfigure_grp_irq;
  81. bus_ops->hif_display_stats =
  82. &hif_pci_display_stats;
  83. bus_ops->hif_clear_stats =
  84. &hif_pci_clear_stats;
  85. bus_ops->hif_addr_in_boundary = &hif_pci_addr_in_boundary;
  86. /* default to legacy mapping handler; override as needed */
  87. bus_ops->hif_map_ce_to_irq = &hif_pci_legacy_map_ce_to_irq;
  88. bus_ops->hif_needs_bmi = &hif_pci_needs_bmi;
  89. bus_ops->hif_config_irq_affinity =
  90. &hif_pci_config_irq_affinity;
  91. bus_ops->hif_config_irq_by_ceid = &hif_ce_msi_configure_irq_by_ceid;
  92. bus_ops->hif_config_irq_clear_cpu_affinity =
  93. &hif_pci_config_irq_clear_cpu_affinity;
  94. bus_ops->hif_log_bus_info = &hif_log_pcie_info;
  95. #ifdef FEATURE_IRQ_AFFINITY
  96. bus_ops->hif_set_grp_intr_affinity = &hif_pci_set_grp_intr_affinity;
  97. #endif
  98. return QDF_STATUS_SUCCESS;
  99. }
  100. /**
  101. * hif_update_irq_ops_with_pci() - reinitialize the pci ops
  102. * for hybrid bus type device qcn6122 ie.connected to pci slot
  103. * but act as ahb bus device from host perspective
  104. *
  105. * @hif_sc: hif_softc to get bus ops
  106. *
  107. * Return: QDF_STATUS_SUCCESS
  108. */
  109. QDF_STATUS hif_update_irq_ops_with_pci(struct hif_softc *hif_sc)
  110. {
  111. struct hif_bus_ops *bus_ops = &hif_sc->bus_ops;
  112. bus_ops->hif_grp_irq_configure = &hif_pci_configure_grp_irq;
  113. bus_ops->hif_grp_irq_deconfigure = &hif_pci_deconfigure_grp_irq;
  114. bus_ops->hif_nointrs = &hif_pci_nointrs;
  115. bus_ops->hif_irq_disable = &hif_pci_irq_disable;
  116. bus_ops->hif_irq_enable = &hif_pci_irq_enable;
  117. bus_ops->hif_disable_isr = &hif_pci_disable_isr;
  118. return QDF_STATUS_SUCCESS;
  119. }
  120. /**
  121. * hif_pci_get_context_size() - return the size of the pci context
  122. *
  123. * Return the size of the context. (0 for invalid bus)
  124. */
  125. int hif_pci_get_context_size(void)
  126. {
  127. return sizeof(struct hif_pci_softc);
  128. }