soc_ioctl.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /****************************************************************************
  2. *
  3. * The MIT License (MIT)
  4. *
  5. * Copyright (c) 2020 VeriSilicon Holdings Co., Ltd.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. *
  25. *****************************************************************************
  26. *
  27. * The GPL License (GPL)
  28. *
  29. * Copyright (c) 2020 VeriSilicon Holdings Co., Ltd.
  30. *
  31. * This program is free software; you can redistribute it and/or
  32. * modify it under the terms of the GNU General Public License
  33. * as published by the Free Software Foundation; either version 2
  34. * of the License, or (at your option) any later version.
  35. *
  36. * This program is distributed in the hope that it will be useful,
  37. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  39. * GNU General Public License for more details.
  40. *
  41. * You should have received a copy of the GNU General Public License
  42. * along with this program;
  43. *
  44. *****************************************************************************
  45. *
  46. * Note: This software is released under dual MIT and GPL licenses. A
  47. * recipient may use this file under the terms of either the MIT license or
  48. * GPL License. If you wish to use only one license not the other, you can
  49. * indicate your decision by deleting one of the above license notices in your
  50. * version of this file.
  51. *
  52. *****************************************************************************/
  53. #ifndef _SOC_IOC_H_
  54. #define _SOC_IOC_H_
  55. #ifndef __KERNEL__
  56. #include <stdint.h>
  57. #endif
  58. #include <linux/ioctl.h>
  59. enum {
  60. VVSOC_IOC_S_RESET_ISP = _IO('r', 0),
  61. VVSOC_IOC_S_POWER_ISP,
  62. VVSOC_IOC_G_POWER_ISP,
  63. VVSOC_IOC_S_CLOCK_ISP,
  64. VVSOC_IOC_G_CLOCK_ISP,
  65. VVSOC_IOC_S_RESET_DWE,
  66. VVSOC_IOC_S_POWER_DWE,
  67. VVSOC_IOC_G_POWER_DWE,
  68. VVSOC_IOC_S_CLOCK_DWE,
  69. VVSOC_IOC_G_CLOCK_DWE,
  70. VVSOC_IOC_S_RESET_VSE,
  71. VVSOC_IOC_S_POWER_VSE,
  72. VVSOC_IOC_G_POWER_VSE,
  73. VVSOC_IOC_S_CLOCK_VSE,
  74. VVSOC_IOC_G_CLOCK_VSE,
  75. VVSOC_IOC_S_RESET_CSI,
  76. VVSOC_IOC_S_POWER_CSI,
  77. VVSOC_IOC_G_POWER_CSI,
  78. VVSOC_IOC_S_CLOCK_CSI,
  79. VVSOC_IOC_G_CLOCK_CSI,
  80. VVSOC_IOC_S_RESET_SENSOR,
  81. VVSOC_IOC_S_POWER_SENSOR,
  82. VVSOC_IOC_G_POWER_SENSOR,
  83. VVSOC_IOC_S_CLOCK_SENSOR,
  84. VVSOC_IOC_G_CLOCK_SENSOR,
  85. VVSOC_IOC_S_RESET_ISP_RY,
  86. VVSOC_IOC_S_POWER_ISP_RY,
  87. VVSOC_IOC_G_POWER_ISP_RY,
  88. VVSOC_IOC_S_CLOCK_ISP_RY,
  89. VVSOC_IOC_G_CLOCK_ISP_RY,
  90. VVSOC_IOC_MAX,
  91. };
  92. struct soc_control_context {
  93. uint32_t device_idx;
  94. uint32_t control_value;
  95. };
  96. struct vvcam_soc_func_s
  97. {
  98. int (*set_power)(void*,unsigned int,unsigned int);
  99. int (*get_power)(void*,unsigned int,unsigned int *);
  100. int (*set_reset)(void*,unsigned int,unsigned int);
  101. int (*set_clk)(void*,unsigned int,unsigned int);
  102. int (*get_clk)(void*,unsigned int,unsigned int *);
  103. };
  104. struct vvcam_soc_function_s
  105. {
  106. struct vvcam_soc_func_s isp_func;
  107. struct vvcam_soc_func_s dwe_func;
  108. struct vvcam_soc_func_s vse_func;
  109. struct vvcam_soc_func_s csi_func;
  110. struct vvcam_soc_func_s sensor_func;
  111. };
  112. struct vvcam_soc_access_s
  113. {
  114. int (*write)(void * ctx, uint32_t address, uint32_t data);
  115. int (*read)(void * ctx, uint32_t address, uint32_t *data);
  116. };
  117. #ifdef __KERNEL__
  118. struct vvcam_soc_dev {
  119. void __iomem *base;
  120. struct soc_control_context isp0;
  121. struct soc_control_context isp1;
  122. struct soc_control_context dwe;
  123. struct soc_control_context vse;
  124. struct vvcam_soc_function_s soc_func;
  125. struct vvcam_soc_access_s soc_access;
  126. void * csi_private;
  127. };
  128. // internal functions
  129. long soc_priv_ioctl(struct vvcam_soc_dev *dev, unsigned int cmd, void *args);
  130. int vvnative_soc_init(struct vvcam_soc_dev *dev);
  131. int vvnative_soc_deinit(struct vvcam_soc_dev *dev);
  132. #else
  133. //User space connections
  134. #endif
  135. #endif // _SOC_IOC_H_