cam_cpas_hw_intf.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _CAM_CPAS_HW_INTF_H_
  6. #define _CAM_CPAS_HW_INTF_H_
  7. #include <linux/platform_device.h>
  8. #include "cam_cpas_api.h"
  9. #include "cam_hw.h"
  10. #include "cam_hw_intf.h"
  11. #include "cam_debug_util.h"
  12. /* Number of times to retry while polling */
  13. #define CAM_CPAS_POLL_RETRY_CNT 5
  14. /* Minimum usecs to sleep while polling */
  15. #define CAM_CPAS_POLL_MIN_USECS 200
  16. /* Maximum usecs to sleep while polling */
  17. #define CAM_CPAS_POLL_MAX_USECS 250
  18. /**
  19. * enum cam_cpas_hw_type - Enum for CPAS HW type
  20. */
  21. enum cam_cpas_hw_type {
  22. CAM_HW_CPASTOP,
  23. CAM_HW_CAMSSTOP,
  24. };
  25. /**
  26. * enum cam_cpas_hw_cmd_process - Enum for CPAS HW process command type
  27. */
  28. enum cam_cpas_hw_cmd_process {
  29. CAM_CPAS_HW_CMD_REGISTER_CLIENT,
  30. CAM_CPAS_HW_CMD_UNREGISTER_CLIENT,
  31. CAM_CPAS_HW_CMD_REG_WRITE,
  32. CAM_CPAS_HW_CMD_REG_READ,
  33. CAM_CPAS_HW_CMD_AHB_VOTE,
  34. CAM_CPAS_HW_CMD_AXI_VOTE,
  35. CAM_CPAS_HW_CMD_LOG_VOTE,
  36. CAM_CPAS_HW_CMD_SELECT_QOS,
  37. CAM_CPAS_HW_CMD_INVALID,
  38. };
  39. /**
  40. * struct cam_cpas_hw_cmd_reg_read_write : CPAS cmd struct for reg read, write
  41. *
  42. * @client_handle: Client handle
  43. * @reg_base: Register base type
  44. * @offset: Register offset
  45. * @value: Register value
  46. * @mb: Whether to do operation with memory barrier
  47. *
  48. */
  49. struct cam_cpas_hw_cmd_reg_read_write {
  50. uint32_t client_handle;
  51. enum cam_cpas_reg_base reg_base;
  52. uint32_t offset;
  53. uint32_t value;
  54. bool mb;
  55. };
  56. /**
  57. * struct cam_cpas_hw_cmd_ahb_vote : CPAS cmd struct for AHB vote
  58. *
  59. * @client_handle: Client handle
  60. * @ahb_vote: AHB voting info
  61. *
  62. */
  63. struct cam_cpas_hw_cmd_ahb_vote {
  64. uint32_t client_handle;
  65. struct cam_ahb_vote *ahb_vote;
  66. };
  67. /**
  68. * struct cam_cpas_hw_cmd_axi_vote : CPAS cmd struct for AXI vote
  69. *
  70. * @client_handle: Client handle
  71. * @axi_vote: axi bandwidth vote
  72. *
  73. */
  74. struct cam_cpas_hw_cmd_axi_vote {
  75. uint32_t client_handle;
  76. struct cam_axi_vote *axi_vote;
  77. };
  78. /**
  79. * struct cam_cpas_hw_cmd_start : CPAS cmd struct for start
  80. *
  81. * @client_handle: Client handle
  82. *
  83. */
  84. struct cam_cpas_hw_cmd_start {
  85. uint32_t client_handle;
  86. struct cam_ahb_vote *ahb_vote;
  87. struct cam_axi_vote *axi_vote;
  88. };
  89. /**
  90. * struct cam_cpas_hw_cmd_stop : CPAS cmd struct for stop
  91. *
  92. * @client_handle: Client handle
  93. *
  94. */
  95. struct cam_cpas_hw_cmd_stop {
  96. uint32_t client_handle;
  97. };
  98. /**
  99. * struct cam_cpas_hw_caps : CPAS HW capabilities
  100. *
  101. * @camera_family: Camera family type
  102. * @camera_version: Camera version
  103. * @cpas_version: CPAS version
  104. * @camera_capability: Camera hw capabilities
  105. *
  106. */
  107. struct cam_cpas_hw_caps {
  108. uint32_t camera_family;
  109. struct cam_hw_version camera_version;
  110. struct cam_hw_version cpas_version;
  111. uint32_t camera_capability;
  112. };
  113. int cam_cpas_hw_probe(struct platform_device *pdev,
  114. struct cam_hw_intf **hw_intf);
  115. int cam_cpas_hw_remove(struct cam_hw_intf *cpas_hw_intf);
  116. /**
  117. * @brief : API to register CPAS hw to platform framework.
  118. * @return struct platform_device pointer on on success, or ERR_PTR() on error.
  119. */
  120. int cam_cpas_dev_init_module(void);
  121. /**
  122. * @brief : API to remove CPAS interface from platform framework.
  123. */
  124. void cam_cpas_dev_exit_module(void);
  125. #endif /* _CAM_CPAS_HW_INTF_H_ */