hif_io32.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2015-2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef __HIF_IO32_H__
  19. #define __HIF_IO32_H__
  20. #include <linux/io.h>
  21. #include "hif.h"
  22. #include "hif_main.h"
  23. #define hif_read32_mb(addr) ioread32((void __iomem *)addr)
  24. #define hif_write32_mb(addr, value) \
  25. iowrite32((u32)(value), (void __iomem *)(addr))
  26. #define Q_TARGET_ACCESS_BEGIN(scn) \
  27. hif_target_sleep_state_adjust(scn, false, true)
  28. #define Q_TARGET_ACCESS_END(scn) \
  29. hif_target_sleep_state_adjust(scn, true, false)
  30. #define TARGET_REGISTER_ACCESS_ALLOWED(scn)\
  31. hif_is_target_register_access_allowed(scn)
  32. /*
  33. * A_TARGET_ACCESS_LIKELY will not wait for the target to wake up before
  34. * continuing execution. Because A_TARGET_ACCESS_LIKELY does not guarantee
  35. * that the target is awake before continuing, Q_TARGET_ACCESS macros must
  36. * protect the actual target access. Since Q_TARGET_ACCESS protect the actual
  37. * target access, A_TARGET_ACCESS_LIKELY hints are optional.
  38. *
  39. * To ignore "LIKELY" hints, set CONFIG_TARGET_ACCESS_LIKELY to 0
  40. * (slightly worse performance, less power)
  41. *
  42. * To use "LIKELY" hints, set CONFIG_TARGET_ACCESS_LIKELY to 1
  43. * (slightly better performance, more power)
  44. *
  45. * note: if a bus doesn't use hif_target_sleep_state_adjust, this will have
  46. * no impact.
  47. */
  48. #define CONFIG_TARGET_ACCESS_LIKELY 0
  49. #if CONFIG_TARGET_ACCESS_LIKELY
  50. #define A_TARGET_ACCESS_LIKELY(scn) \
  51. hif_target_sleep_state_adjust(scn, false, false)
  52. #define A_TARGET_ACCESS_UNLIKELY(scn) \
  53. hif_target_sleep_state_adjust(scn, true, false)
  54. #else /* CONFIG_ATH_PCIE_ACCESS_LIKELY */
  55. #define A_TARGET_ACCESS_LIKELY(scn) \
  56. do { \
  57. unsigned long unused = (unsigned long)(scn); \
  58. unused = unused; \
  59. } while (0)
  60. #define A_TARGET_ACCESS_UNLIKELY(scn) \
  61. do { \
  62. unsigned long unused = (unsigned long)(scn); \
  63. unused = unused; \
  64. } while (0)
  65. #endif /* CONFIG_ATH_PCIE_ACCESS_LIKELY */
  66. #ifdef HIF_PCI
  67. #include "hif_io32_pci.h"
  68. #endif
  69. #ifdef HIF_SNOC
  70. #include "hif_io32_snoc.h"
  71. #endif /* HIF_PCI */
  72. #ifdef CONFIG_IO_MEM_ACCESS_DEBUG
  73. uint32_t hif_target_read_checked(struct hif_softc *scn,
  74. uint32_t offset);
  75. void hif_target_write_checked(struct hif_softc *scn, uint32_t offset,
  76. uint32_t value);
  77. #define A_TARGET_READ(scn, offset) \
  78. hif_target_read_checked(scn, (offset))
  79. #define A_TARGET_WRITE(scn, offset, value) \
  80. hif_target_write_checked(scn, (offset), (value))
  81. #else /* CONFIG_ATH_PCIE_ACCESS_DEBUG */
  82. #define A_TARGET_READ(scn, offset) \
  83. hif_read32_mb(scn->mem + (offset))
  84. #define A_TARGET_WRITE(scn, offset, value) \
  85. hif_write32_mb((scn->mem) + (offset), value)
  86. #endif
  87. void hif_irq_enable(struct hif_softc *scn, int irq_id);
  88. void hif_irq_disable(struct hif_softc *scn, int irq_id);
  89. #endif /* __HIF_IO32_H__ */