cam_cpas_hw_intf.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2019, 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_INVALID,
  36. };
  37. /**
  38. * struct cam_cpas_hw_cmd_reg_read_write : CPAS cmd struct for reg read, write
  39. *
  40. * @client_handle: Client handle
  41. * @reg_base: Register base type
  42. * @offset: Register offset
  43. * @value: Register value
  44. * @mb: Whether to do operation with memory barrier
  45. *
  46. */
  47. struct cam_cpas_hw_cmd_reg_read_write {
  48. uint32_t client_handle;
  49. enum cam_cpas_reg_base reg_base;
  50. uint32_t offset;
  51. uint32_t value;
  52. bool mb;
  53. };
  54. /**
  55. * struct cam_cpas_hw_cmd_ahb_vote : CPAS cmd struct for AHB vote
  56. *
  57. * @client_handle: Client handle
  58. * @ahb_vote: AHB voting info
  59. *
  60. */
  61. struct cam_cpas_hw_cmd_ahb_vote {
  62. uint32_t client_handle;
  63. struct cam_ahb_vote *ahb_vote;
  64. };
  65. /**
  66. * struct cam_cpas_hw_cmd_axi_vote : CPAS cmd struct for AXI vote
  67. *
  68. * @client_handle: Client handle
  69. * @axi_vote: axi bandwidth vote
  70. *
  71. */
  72. struct cam_cpas_hw_cmd_axi_vote {
  73. uint32_t client_handle;
  74. struct cam_axi_vote *axi_vote;
  75. };
  76. /**
  77. * struct cam_cpas_hw_cmd_start : CPAS cmd struct for start
  78. *
  79. * @client_handle: Client handle
  80. *
  81. */
  82. struct cam_cpas_hw_cmd_start {
  83. uint32_t client_handle;
  84. struct cam_ahb_vote *ahb_vote;
  85. struct cam_axi_vote *axi_vote;
  86. };
  87. /**
  88. * struct cam_cpas_hw_cmd_stop : CPAS cmd struct for stop
  89. *
  90. * @client_handle: Client handle
  91. *
  92. */
  93. struct cam_cpas_hw_cmd_stop {
  94. uint32_t client_handle;
  95. };
  96. /**
  97. * struct cam_cpas_hw_caps : CPAS HW capabilities
  98. *
  99. * @camera_family: Camera family type
  100. * @camera_version: Camera version
  101. * @cpas_version: CPAS version
  102. * @camera_capability: Camera hw capabilities
  103. *
  104. */
  105. struct cam_cpas_hw_caps {
  106. uint32_t camera_family;
  107. struct cam_hw_version camera_version;
  108. struct cam_hw_version cpas_version;
  109. uint32_t camera_capability;
  110. };
  111. int cam_cpas_hw_probe(struct platform_device *pdev,
  112. struct cam_hw_intf **hw_intf);
  113. int cam_cpas_hw_remove(struct cam_hw_intf *cpas_hw_intf);
  114. /**
  115. * @brief : API to register CPAS hw to platform framework.
  116. * @return struct platform_device pointer on on success, or ERR_PTR() on error.
  117. */
  118. int cam_cpas_dev_init_module(void);
  119. /**
  120. * @brief : API to remove CPAS interface from platform framework.
  121. */
  122. void cam_cpas_dev_exit_module(void);
  123. #endif /* _CAM_CPAS_HW_INTF_H_ */