vsi_core_gen6.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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. #include <linux/module.h>
  54. #include <linux/uaccess.h>
  55. #include "soc_ioctl.h"
  56. #include "vsi_core_gen6.h"
  57. int gen6_write_reg(void* dev,unsigned int addr,unsigned int val)
  58. {
  59. struct vvcam_soc_dev *soc_dev;
  60. soc_dev = (struct vvcam_soc_dev *)dev;
  61. if (soc_dev == NULL)
  62. return -1;
  63. writel(val,soc_dev->base + addr);
  64. return 0;
  65. }
  66. int gen6_read_reg(void* dev,unsigned int addr,unsigned int *val)
  67. {
  68. struct vvcam_soc_dev *soc_dev;
  69. soc_dev = (struct vvcam_soc_dev *)dev;
  70. if (soc_dev == NULL)
  71. return -1;
  72. *val = readl(soc_dev->base + addr);
  73. return 0;
  74. }
  75. static int gen6_set_isp_power(void* dev,unsigned int id,unsigned int status)
  76. {
  77. return 0;
  78. }
  79. static int gen6_get_isp_power(void* dev,unsigned int id,unsigned int *status)
  80. {
  81. return 0;
  82. }
  83. static int gen6_set_isp_reset(void* dev,unsigned int id,unsigned int status)
  84. {
  85. unsigned int ret = 0;
  86. struct vvcam_soc_dev *soc_dev;;
  87. unsigned int reg_addr;
  88. unsigned int reg_value;
  89. reg_addr = 0;
  90. soc_dev = (struct vvcam_soc_dev *)dev;
  91. if (soc_dev == NULL)
  92. return -1;
  93. if (id == 0)
  94. {
  95. reg_addr = REG_TPG0;
  96. }else{
  97. reg_addr = REG_TPG1;
  98. }
  99. ret = soc_dev->soc_access.read(dev,reg_addr,&reg_value);
  100. if (status == 0)
  101. {
  102. reg_value &= ~(1<<24);
  103. }else{
  104. reg_value |= (1<<24);
  105. }
  106. ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
  107. ret |= soc_dev->soc_access.write(dev,REG_TPG0,reg_value);
  108. return ret;
  109. }
  110. static int gen6_set_isp_clk(void* dev,unsigned int id,unsigned int freq)
  111. {
  112. return 0;
  113. }
  114. static int gen6_get_isp_clk(void* dev,unsigned int id,unsigned int *freq)
  115. {
  116. return 0;
  117. }
  118. static int gen6_set_dwe_power(void* dev,unsigned int id,unsigned int status)
  119. {
  120. return 0;
  121. }
  122. static int gen6_get_dwe_power(void* dev, unsigned int id,unsigned int *status)
  123. {
  124. return 0;
  125. }
  126. static int gen6_set_dwe_reset(void* dev,unsigned int id,unsigned int status)
  127. {
  128. unsigned int ret = 0;
  129. struct vvcam_soc_dev *soc_dev;;
  130. unsigned int reg_addr;
  131. unsigned int reg_value;
  132. reg_addr = 0;
  133. soc_dev = (struct vvcam_soc_dev *)dev;
  134. if (soc_dev == NULL)
  135. return -1;
  136. reg_addr = REG_DWE_CTRL;
  137. ret = soc_dev->soc_access.read(dev,reg_addr,&reg_value);
  138. if (status == 0)
  139. {
  140. reg_value &= ~(1<<0);
  141. }else{
  142. reg_value |= (1<<0);
  143. }
  144. ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
  145. return ret;
  146. }
  147. static int gen6_set_dwe_clk(void* dev,unsigned int id,unsigned int freq)
  148. {
  149. return 0;
  150. }
  151. static int gen6_get_dwe_clk(void* dev,unsigned int id,unsigned int *freq)
  152. {
  153. return 0;
  154. }
  155. static int gen6_set_vse_power(void* dev,unsigned int id,unsigned int status)
  156. {
  157. return 0;
  158. }
  159. static int gen6_get_vse_power(void* dev,unsigned int id,unsigned int *status)
  160. {
  161. return 0;
  162. }
  163. static int gen6_set_vse_reset(void* dev,unsigned int id,unsigned int status)
  164. {
  165. unsigned int ret = 0;
  166. struct vvcam_soc_dev *soc_dev;;
  167. unsigned int reg_addr;
  168. unsigned int reg_value;
  169. reg_addr = 0;
  170. soc_dev = (struct vvcam_soc_dev *)dev;
  171. if (soc_dev == NULL)
  172. return -1;
  173. reg_addr = REG_VSE_CTRL;
  174. ret = soc_dev->soc_access.read(dev,reg_addr,&reg_value);
  175. if (status == 0)
  176. {
  177. reg_value &= ~(1<<0);
  178. }else{
  179. reg_value |= (1<<0);
  180. }
  181. ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
  182. return ret;
  183. }
  184. static int gen6_set_vse_clk(void* dev,unsigned int id,unsigned int freq)
  185. {
  186. return 0;
  187. }
  188. static int gen6_get_vse_clk(void* dev,unsigned int id,unsigned int *freq)
  189. {
  190. return 0;
  191. }
  192. static int gen6_set_csi_power(void* dev,unsigned int id,unsigned int status)
  193. {
  194. return 0;
  195. }
  196. static int gen6_get_csi_power(void* dev,unsigned int id,unsigned int *status)
  197. {
  198. return 0;
  199. }
  200. static int gen6_set_csi_reset(void* dev,unsigned int id,unsigned int status)
  201. {
  202. unsigned int ret = 0;
  203. struct vvcam_soc_dev *soc_dev;;
  204. unsigned int reg_addr;
  205. unsigned int reg_value;
  206. reg_addr = 0;
  207. soc_dev = (struct vvcam_soc_dev *)dev;
  208. if (soc_dev == NULL)
  209. return -1;
  210. if (id == 0)
  211. {
  212. reg_addr = REG_TPG0;
  213. }else{
  214. reg_addr = REG_TPG1;
  215. }
  216. ret = soc_dev->soc_access.read(dev,reg_addr,&reg_value);
  217. if (status == 0)
  218. {
  219. reg_value &= ~(1<<4 | 1<<28);
  220. }else{
  221. reg_value |= 0x30000210;
  222. }
  223. ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
  224. return ret;
  225. }
  226. static int gen6_set_csi_clk(void* dev,unsigned int id,unsigned int freq)
  227. {
  228. return 0;
  229. }
  230. static int gen6_get_csi_clk(void* dev,unsigned int id,unsigned int *freq)
  231. {
  232. return 0;
  233. }
  234. static int gen6_set_sensor_power(void* dev,unsigned int id,unsigned int status)
  235. {
  236. return 0;
  237. }
  238. static int gen6_get_sensor_power(void* dev,unsigned int id,unsigned int *status)
  239. {
  240. return 0;
  241. }
  242. static int gen6_set_sensor_reset(void* dev,unsigned int id,unsigned int status)
  243. {
  244. return 0;
  245. }
  246. static int gen6_set_sensor_clk(void* dev,unsigned int id,unsigned int freq)
  247. {
  248. return 0;
  249. }
  250. static int gen6_get_sensor_clk(void* dev,unsigned int id,unsigned int *freq)
  251. {
  252. return 0;
  253. }
  254. struct vvcam_soc_function_s gen6_soc_function = {
  255. .isp_func.set_power = gen6_set_isp_power,
  256. .isp_func.get_power = gen6_get_isp_power,
  257. .isp_func.set_reset = gen6_set_isp_reset,
  258. .isp_func.set_clk = gen6_set_isp_clk,
  259. .isp_func.get_clk = gen6_get_isp_clk,
  260. .dwe_func.set_power = gen6_set_dwe_power,
  261. .dwe_func.get_power = gen6_get_dwe_power,
  262. .dwe_func.set_reset = gen6_set_dwe_reset,
  263. .dwe_func.set_clk = gen6_set_dwe_clk,
  264. .dwe_func.get_clk = gen6_get_dwe_clk,
  265. .vse_func.set_power = gen6_set_vse_power,
  266. .vse_func.get_power = gen6_get_vse_power,
  267. .vse_func.set_reset = gen6_set_vse_reset,
  268. .vse_func.set_clk = gen6_set_vse_clk,
  269. .vse_func.get_clk = gen6_get_vse_clk,
  270. .csi_func.set_power = gen6_set_csi_power,
  271. .csi_func.get_power = gen6_get_csi_power,
  272. .csi_func.set_reset = gen6_set_csi_reset,
  273. .csi_func.set_clk = gen6_set_csi_clk,
  274. .csi_func.get_clk = gen6_get_csi_clk,
  275. .sensor_func.set_power = gen6_set_sensor_power,
  276. .sensor_func.get_power = gen6_get_sensor_power,
  277. .sensor_func.set_reset = gen6_set_sensor_reset,
  278. .sensor_func.set_clk = gen6_set_sensor_clk,
  279. .sensor_func.get_clk = gen6_get_sensor_clk,
  280. };