vsi_core_gen6.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. #ifdef ISP8000L_V2008
  56. #include <linux/io.h> //Fix thead compile error.
  57. #endif
  58. #include "soc_ioctl.h"
  59. #include "vsi_core_gen6.h"
  60. int gen6_write_reg(void* dev,unsigned int addr,unsigned int val)
  61. {
  62. struct vvcam_soc_dev *soc_dev;
  63. soc_dev = (struct vvcam_soc_dev *)dev;
  64. if (soc_dev == NULL)
  65. return -1;
  66. writel(val,soc_dev->base + addr);
  67. return 0;
  68. }
  69. int gen6_read_reg(void* dev,unsigned int addr,unsigned int *val)
  70. {
  71. struct vvcam_soc_dev *soc_dev;
  72. soc_dev = (struct vvcam_soc_dev *)dev;
  73. if (soc_dev == NULL)
  74. return -1;
  75. *val = readl(soc_dev->base + addr);
  76. return 0;
  77. }
  78. static int gen6_set_isp_power(void* dev,unsigned int id,unsigned int status)
  79. {
  80. return 0;
  81. }
  82. static int gen6_get_isp_power(void* dev,unsigned int id,unsigned int *status)
  83. {
  84. return 0;
  85. }
  86. static int gen6_set_isp_reset(void* dev,unsigned int id,unsigned int status)
  87. {
  88. unsigned int reg_addr;
  89. unsigned int reg_value;
  90. unsigned int ret;
  91. struct vvcam_soc_dev *soc_dev;;
  92. reg_addr = 0;
  93. ret = 0;
  94. soc_dev = (struct vvcam_soc_dev *)dev;
  95. pr_info("isp reset enter id = %d, status = %d\n", id, status);
  96. if (soc_dev == NULL)
  97. return -1;
  98. if (id == 0)
  99. {
  100. reg_addr = REG_TPG0;
  101. }else{
  102. reg_addr = REG_TPG1;
  103. }
  104. reg_addr = 0x100;
  105. ret = soc_dev->soc_access.read(dev,reg_addr,&reg_value);
  106. if (status == 0)
  107. {
  108. reg_value &= ~(1<<0);
  109. }else{
  110. reg_value |= (1<<0);
  111. }
  112. ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
  113. pr_info("isp reset exit\n");
  114. return ret;
  115. }
  116. static int gen6_set_isp_clk(void* dev,unsigned int id,unsigned int freq)
  117. {
  118. return 0;
  119. }
  120. static int gen6_get_isp_clk(void* dev,unsigned int id,unsigned int *freq)
  121. {
  122. return 0;
  123. }
  124. static int gen6_set_isp_ry_power(void* dev,unsigned int id,unsigned int status)
  125. {
  126. return 0;
  127. }
  128. static int gen6_get_isp_ry_power(void* dev,unsigned int id,unsigned int *status)
  129. {
  130. return 0;
  131. }
  132. static int gen6_set_isp_ry_reset(void* dev,unsigned int id,unsigned int status)
  133. {
  134. unsigned int reg_addr;
  135. unsigned int reg_value;
  136. unsigned int ret;
  137. struct vvcam_soc_dev *soc_dev;;
  138. reg_addr = 0;
  139. ret = 0;
  140. soc_dev = (struct vvcam_soc_dev *)dev;
  141. pr_info("isp ry reset enter id = %d, status = %d\n", id, status);
  142. if (soc_dev == NULL)
  143. return -1;
  144. if (id == 0)
  145. {
  146. reg_addr = REG_TPG0;
  147. }else{
  148. reg_addr = REG_TPG1;
  149. }
  150. reg_addr = 0x100;
  151. ret = soc_dev->soc_access.read(dev,reg_addr,&reg_value);
  152. if (status == 0)
  153. {
  154. reg_value &= ~(1<<4);
  155. }else{
  156. reg_value |= (1<<4);
  157. }
  158. ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
  159. pr_info("isp ry reset exit\n");
  160. return ret;
  161. }
  162. static int gen6_set_isp_ry_clk(void* dev,unsigned int id,unsigned int freq)
  163. {
  164. return 0;
  165. }
  166. static int gen6_get_isp_ry_clk(void* dev,unsigned int id,unsigned int *freq)
  167. {
  168. return 0;
  169. }
  170. static int gen6_set_dwe_power(void* dev,unsigned int id,unsigned int status)
  171. {
  172. return 0;
  173. }
  174. static int gen6_get_dwe_power(void* dev, unsigned int id,unsigned int *status)
  175. {
  176. return 0;
  177. }
  178. static int gen6_set_dwe_reset(void* dev,unsigned int id,unsigned int status)
  179. {
  180. unsigned int ret = 0;
  181. unsigned int reg_addr;
  182. unsigned int reg_value;
  183. struct vvcam_soc_dev *soc_dev;
  184. pr_info("dw200 reset enter id = %d, status = %d\n", id, status);
  185. soc_dev = (struct vvcam_soc_dev *)dev;
  186. reg_addr = 0;
  187. if (soc_dev == NULL)
  188. return -1;
  189. reg_addr = REG_DWE_CTRL;
  190. reg_addr = 0x100;
  191. ret = soc_dev->soc_access.read(dev,reg_addr,&reg_value);
  192. if (status == 0)
  193. {
  194. reg_value &= ~(1<<31);
  195. }else{
  196. reg_value |= (1<<31);
  197. }
  198. ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
  199. pr_info("dw200 reset exit\n");
  200. return ret;
  201. }
  202. static int gen6_set_dwe_clk(void* dev,unsigned int id,unsigned int freq)
  203. {
  204. return 0;
  205. }
  206. static int gen6_get_dwe_clk(void* dev,unsigned int id,unsigned int *freq)
  207. {
  208. return 0;
  209. }
  210. static int gen6_set_vse_power(void* dev,unsigned int id,unsigned int status)
  211. {
  212. return 0;
  213. }
  214. static int gen6_get_vse_power(void* dev,unsigned int id,unsigned int *status)
  215. {
  216. return 0;
  217. }
  218. static int gen6_set_vse_reset(void* dev,unsigned int id,unsigned int status)
  219. {
  220. unsigned int ret = 0;
  221. struct vvcam_soc_dev *soc_dev;
  222. unsigned int reg_addr;
  223. unsigned int reg_value;
  224. soc_dev = (struct vvcam_soc_dev *)dev;
  225. reg_addr = 0;
  226. if (soc_dev == NULL)
  227. return -1;
  228. reg_addr = REG_VSE_CTRL;
  229. ret = soc_dev->soc_access.read(dev,reg_addr,&reg_value);
  230. if (status == 0)
  231. {
  232. reg_value &= ~(1<<0);
  233. }else{
  234. reg_value |= (1<<0);
  235. }
  236. ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
  237. return ret;
  238. }
  239. static int gen6_set_vse_clk(void* dev,unsigned int id,unsigned int freq)
  240. {
  241. return 0;
  242. }
  243. static int gen6_get_vse_clk(void* dev,unsigned int id,unsigned int *freq)
  244. {
  245. return 0;
  246. }
  247. static int gen6_set_csi_power(void* dev,unsigned int id,unsigned int status)
  248. {
  249. return 0;
  250. }
  251. static int gen6_get_csi_power(void* dev,unsigned int id,unsigned int *status)
  252. {
  253. return 0;
  254. }
  255. static int gen6_set_csi_reset(void* dev,unsigned int id,unsigned int status)
  256. {
  257. unsigned int ret = 0;
  258. struct vvcam_soc_dev *soc_dev;
  259. unsigned int reg_addr;
  260. unsigned int reg_value;
  261. soc_dev = (struct vvcam_soc_dev *)dev;
  262. reg_addr = 0;
  263. if (soc_dev == NULL)
  264. return -1;
  265. if (id == 0)
  266. {
  267. reg_addr = REG_TPG0;
  268. }else{
  269. reg_addr = REG_TPG1;
  270. }
  271. ret = soc_dev->soc_access.read(dev,reg_addr,&reg_value);
  272. if (status == 0)
  273. {
  274. reg_value &= ~(1<<4 | 1<<28);
  275. }else{
  276. reg_value |= 0x30000210;
  277. }
  278. ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
  279. return ret;
  280. }
  281. static int gen6_set_csi_clk(void* dev,unsigned int id,unsigned int freq)
  282. {
  283. return 0;
  284. }
  285. static int gen6_get_csi_clk(void* dev,unsigned int id,unsigned int *freq)
  286. {
  287. return 0;
  288. }
  289. static int gen6_set_sensor_power(void* dev,unsigned int id,unsigned int status)
  290. {
  291. return 0;
  292. }
  293. static int gen6_get_sensor_power(void* dev,unsigned int id,unsigned int *status)
  294. {
  295. return 0;
  296. }
  297. static int gen6_set_sensor_reset(void* dev,unsigned int id,unsigned int status)
  298. {
  299. return 0;
  300. }
  301. static int gen6_set_sensor_clk(void* dev,unsigned int id,unsigned int freq)
  302. {
  303. return 0;
  304. }
  305. static int gen6_get_sensor_clk(void* dev,unsigned int id,unsigned int *freq)
  306. {
  307. return 0;
  308. }
  309. struct vvcam_soc_function_s gen6_soc_function = {
  310. .isp_func.set_power = gen6_set_isp_power,
  311. .isp_func.get_power = gen6_get_isp_power,
  312. .isp_func.set_reset = gen6_set_isp_reset,
  313. .isp_func.set_clk = gen6_set_isp_clk,
  314. .isp_func.get_clk = gen6_get_isp_clk,
  315. .dwe_func.set_power = gen6_set_dwe_power,
  316. .dwe_func.get_power = gen6_get_dwe_power,
  317. .dwe_func.set_reset = gen6_set_dwe_reset,
  318. .dwe_func.set_clk = gen6_set_dwe_clk,
  319. .dwe_func.get_clk = gen6_get_dwe_clk,
  320. .vse_func.set_power = gen6_set_vse_power,
  321. .vse_func.get_power = gen6_get_vse_power,
  322. .vse_func.set_reset = gen6_set_vse_reset,
  323. .vse_func.set_clk = gen6_set_vse_clk,
  324. .vse_func.get_clk = gen6_get_vse_clk,
  325. .csi_func.set_power = gen6_set_csi_power,
  326. .csi_func.get_power = gen6_get_csi_power,
  327. .csi_func.set_reset = gen6_set_csi_reset,
  328. .csi_func.set_clk = gen6_set_csi_clk,
  329. .csi_func.get_clk = gen6_get_csi_clk,
  330. .sensor_func.set_power = gen6_set_sensor_power,
  331. .sensor_func.get_power = gen6_get_sensor_power,
  332. .sensor_func.set_reset = gen6_set_sensor_reset,
  333. .sensor_func.set_clk = gen6_set_sensor_clk,
  334. .sensor_func.get_clk = gen6_get_sensor_clk,
  335. .isp_ry_func.set_power = gen6_set_isp_ry_power,
  336. .isp_ry_func.get_power = gen6_get_isp_ry_power,
  337. .isp_ry_func.set_reset = gen6_set_isp_ry_reset,
  338. .isp_ry_func.set_clk = gen6_set_isp_ry_clk,
  339. .isp_ry_func.get_clk = gen6_get_isp_ry_clk,
  340. };