cepci.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. #ifndef __CEPCI_H__
  27. #define __CEPCI_H__
  28. /*
  29. * Support for Copy Engine over PCI.
  30. * Structures shared between Host software and Target firmware.
  31. */
  32. #include <a_types.h> /* A_UINT32 */
  33. /*
  34. * Total number of PCIe MSI interrupts requested for all interrupt sources.
  35. * PCIe standard forces this to be a power of 2.
  36. * Some Host OS's limit MSI requests that can be granted to 8
  37. * so for now we abide by this limit and avoid requesting more
  38. * than that.
  39. */
  40. #define MSI_NUM_REQUEST_LOG2 3
  41. #define MSI_NUM_REQUEST (1<<MSI_NUM_REQUEST_LOG2)
  42. /*
  43. * Granted MSIs are assigned as follows:
  44. * Firmware uses the first
  45. * Remaining MSIs, if any, are used by Copy Engines
  46. * This mapping is known to both Target firmware and Host software.
  47. * It may be changed as long as Host and Target are kept in sync.
  48. */
  49. #define MSI_ASSIGN_FW 0 /* 1 MSI for firmware (errors, etc.) */
  50. #define MSI_ASSIGN_CE_INITIAL 1 /* 7 MSIs for Copy Engines */
  51. #define MSI_ASSIGN_CE_MAX 7
  52. /*
  53. * PCI-specific Target state. Much of this may be of interest
  54. * to the Host so HOST_INTEREST->hi_interconnect_state points
  55. * here (and all members are 32-bit quantities in order to
  56. * facilitate Host access). In particular, Host software is
  57. * required to initialize pipe_cfg_addr and svc_to_pipe_map.
  58. */
  59. struct pcie_state_s {
  60. A_UINT32 pipe_cfg_addr; /* Pipe configuration Target address */
  61. /* NB: CE_pipe_config[CE_COUNT] */
  62. A_UINT32 svc_to_pipe_map; /* Service to pipe map Target address */
  63. /* NB: service_to_pipe[PIPE_TO_CE_MAP_CN] */
  64. A_UINT32 MSI_requested; /* number of MSI interrupts requested */
  65. A_UINT32 MSI_granted; /* number of MSI interrupts granted */
  66. A_UINT32 MSI_addr; /* Message Signalled Interrupt address */
  67. A_UINT32 MSI_data; /* Base data */
  68. A_UINT32 MSI_fw_intr_data; /* Data for firmware interrupt;
  69. MSI data for other interrupts are
  70. in various SoC registers */
  71. A_UINT32 power_mgmt_method; /* PCIE_PWR_METHOD_* */
  72. A_UINT32 config_flags; /* PCIE_CONFIG_FLAG_* */
  73. };
  74. /*
  75. * PCIE_CONFIG_FLAG definitions
  76. */
  77. #define PCIE_CONFIG_FLAG_ENABLE_L1 0x0000001
  78. #define CE_PKTLOG_PIPE 8 /* used by both host and target side */
  79. #define PCIE_CONFIG_FLAG_CLK_GATING_L1 0x0000001
  80. #define PCIE_CONFIG_FLAG_CLK_SWITCH_WAIT 0x0000002
  81. #define PCIE_CONFIG_FLAG_AXI_CLK_GATE 0x0000004
  82. #define PCIE_CONFIG_FLAG_CLK_REQ_L1 0x0000008
  83. #define PIPE_TO_CE_MAP_CNT 32 /* simple implementation constant */
  84. /*
  85. * Configuration information for a Copy Engine pipe.
  86. * Passed from Host to Target during startup (one per CE).
  87. */
  88. struct CE_pipe_config {
  89. A_UINT32 pipenum;
  90. A_UINT32 pipedir;
  91. A_UINT32 nentries;
  92. A_UINT32 nbytes_max;
  93. A_UINT32 flags;
  94. A_UINT32 reserved;
  95. };
  96. #endif /* __CEPCI_H__ */