123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- /****************************************************************************
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2020 VeriSilicon Holdings Co., Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- *****************************************************************************
- *
- * The GPL License (GPL)
- *
- * Copyright (c) 2020 VeriSilicon Holdings Co., Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;
- *
- *****************************************************************************
- *
- * Note: This software is released under dual MIT and GPL licenses. A
- * recipient may use this file under the terms of either the MIT license or
- * GPL License. If you wish to use only one license not the other, you can
- * indicate your decision by deleting one of the above license notices in your
- * version of this file.
- *
- *****************************************************************************/
- #include <linux/module.h>
- #include <linux/uaccess.h>
- #include "soc_ioctl.h"
- #include "vsi_core_gen6.h"
- int gen6_write_reg(void* dev,unsigned int addr,unsigned int val)
- {
- struct vvcam_soc_dev *soc_dev;
- soc_dev = (struct vvcam_soc_dev *)dev;
- if (soc_dev == NULL)
- return -1;
- writel(val,soc_dev->base + addr);
- return 0;
- }
- int gen6_read_reg(void* dev,unsigned int addr,unsigned int *val)
- {
- struct vvcam_soc_dev *soc_dev;
- soc_dev = (struct vvcam_soc_dev *)dev;
- if (soc_dev == NULL)
- return -1;
- *val = readl(soc_dev->base + addr);
- return 0;
- }
- static int gen6_set_isp_power(void* dev,unsigned int id,unsigned int status)
- {
- return 0;
- }
- static int gen6_get_isp_power(void* dev,unsigned int id,unsigned int *status)
- {
- return 0;
- }
- static int gen6_set_isp_reset(void* dev,unsigned int id,unsigned int status)
- {
- unsigned int ret = 0;
- struct vvcam_soc_dev *soc_dev;;
- unsigned int reg_addr;
- unsigned int reg_value;
- reg_addr = 0;
- soc_dev = (struct vvcam_soc_dev *)dev;
- if (soc_dev == NULL)
- return -1;
- if (id == 0)
- {
- reg_addr = REG_TPG0;
- }else{
- reg_addr = REG_TPG1;
- }
- ret = soc_dev->soc_access.read(dev,reg_addr,®_value);
- if (status == 0)
- {
- reg_value &= ~(1<<24);
- }else{
- reg_value |= (1<<24);
- }
- ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
- ret |= soc_dev->soc_access.write(dev,REG_TPG0,reg_value);
- return ret;
- }
- static int gen6_set_isp_clk(void* dev,unsigned int id,unsigned int freq)
- {
- return 0;
- }
- static int gen6_get_isp_clk(void* dev,unsigned int id,unsigned int *freq)
- {
- return 0;
- }
- static int gen6_set_dwe_power(void* dev,unsigned int id,unsigned int status)
- {
- return 0;
- }
- static int gen6_get_dwe_power(void* dev, unsigned int id,unsigned int *status)
- {
- return 0;
- }
- static int gen6_set_dwe_reset(void* dev,unsigned int id,unsigned int status)
- {
- unsigned int ret = 0;
- struct vvcam_soc_dev *soc_dev;;
- unsigned int reg_addr;
- unsigned int reg_value;
- reg_addr = 0;
- soc_dev = (struct vvcam_soc_dev *)dev;
- if (soc_dev == NULL)
- return -1;
- reg_addr = REG_DWE_CTRL;
- ret = soc_dev->soc_access.read(dev,reg_addr,®_value);
- if (status == 0)
- {
- reg_value &= ~(1<<0);
- }else{
- reg_value |= (1<<0);
- }
- ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
- return ret;
- }
- static int gen6_set_dwe_clk(void* dev,unsigned int id,unsigned int freq)
- {
- return 0;
- }
- static int gen6_get_dwe_clk(void* dev,unsigned int id,unsigned int *freq)
- {
- return 0;
- }
- static int gen6_set_vse_power(void* dev,unsigned int id,unsigned int status)
- {
- return 0;
- }
- static int gen6_get_vse_power(void* dev,unsigned int id,unsigned int *status)
- {
- return 0;
- }
- static int gen6_set_vse_reset(void* dev,unsigned int id,unsigned int status)
- {
- unsigned int ret = 0;
- struct vvcam_soc_dev *soc_dev;;
- unsigned int reg_addr;
- unsigned int reg_value;
- reg_addr = 0;
- soc_dev = (struct vvcam_soc_dev *)dev;
- if (soc_dev == NULL)
- return -1;
- reg_addr = REG_VSE_CTRL;
- ret = soc_dev->soc_access.read(dev,reg_addr,®_value);
- if (status == 0)
- {
- reg_value &= ~(1<<0);
- }else{
- reg_value |= (1<<0);
- }
- ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
- return ret;
- }
- static int gen6_set_vse_clk(void* dev,unsigned int id,unsigned int freq)
- {
- return 0;
- }
- static int gen6_get_vse_clk(void* dev,unsigned int id,unsigned int *freq)
- {
- return 0;
- }
- static int gen6_set_csi_power(void* dev,unsigned int id,unsigned int status)
- {
- return 0;
- }
- static int gen6_get_csi_power(void* dev,unsigned int id,unsigned int *status)
- {
- return 0;
- }
- static int gen6_set_csi_reset(void* dev,unsigned int id,unsigned int status)
- {
- unsigned int ret = 0;
- struct vvcam_soc_dev *soc_dev;;
- unsigned int reg_addr;
- unsigned int reg_value;
- reg_addr = 0;
- soc_dev = (struct vvcam_soc_dev *)dev;
- if (soc_dev == NULL)
- return -1;
- if (id == 0)
- {
- reg_addr = REG_TPG0;
- }else{
- reg_addr = REG_TPG1;
- }
- ret = soc_dev->soc_access.read(dev,reg_addr,®_value);
- if (status == 0)
- {
- reg_value &= ~(1<<4 | 1<<28);
- }else{
- reg_value |= 0x30000210;
- }
- ret |= soc_dev->soc_access.write(dev,reg_addr,reg_value);
- return ret;
- }
- static int gen6_set_csi_clk(void* dev,unsigned int id,unsigned int freq)
- {
- return 0;
- }
- static int gen6_get_csi_clk(void* dev,unsigned int id,unsigned int *freq)
- {
- return 0;
- }
- static int gen6_set_sensor_power(void* dev,unsigned int id,unsigned int status)
- {
- return 0;
- }
- static int gen6_get_sensor_power(void* dev,unsigned int id,unsigned int *status)
- {
- return 0;
- }
- static int gen6_set_sensor_reset(void* dev,unsigned int id,unsigned int status)
- {
- return 0;
- }
- static int gen6_set_sensor_clk(void* dev,unsigned int id,unsigned int freq)
- {
- return 0;
- }
- static int gen6_get_sensor_clk(void* dev,unsigned int id,unsigned int *freq)
- {
- return 0;
- }
- struct vvcam_soc_function_s gen6_soc_function = {
- .isp_func.set_power = gen6_set_isp_power,
- .isp_func.get_power = gen6_get_isp_power,
- .isp_func.set_reset = gen6_set_isp_reset,
- .isp_func.set_clk = gen6_set_isp_clk,
- .isp_func.get_clk = gen6_get_isp_clk,
- .dwe_func.set_power = gen6_set_dwe_power,
- .dwe_func.get_power = gen6_get_dwe_power,
- .dwe_func.set_reset = gen6_set_dwe_reset,
- .dwe_func.set_clk = gen6_set_dwe_clk,
- .dwe_func.get_clk = gen6_get_dwe_clk,
- .vse_func.set_power = gen6_set_vse_power,
- .vse_func.get_power = gen6_get_vse_power,
- .vse_func.set_reset = gen6_set_vse_reset,
- .vse_func.set_clk = gen6_set_vse_clk,
- .vse_func.get_clk = gen6_get_vse_clk,
- .csi_func.set_power = gen6_set_csi_power,
- .csi_func.get_power = gen6_get_csi_power,
- .csi_func.set_reset = gen6_set_csi_reset,
- .csi_func.set_clk = gen6_set_csi_clk,
- .csi_func.get_clk = gen6_get_csi_clk,
- .sensor_func.set_power = gen6_set_sensor_power,
- .sensor_func.get_power = gen6_get_sensor_power,
- .sensor_func.set_reset = gen6_set_sensor_reset,
- .sensor_func.set_clk = gen6_set_sensor_clk,
- .sensor_func.get_clk = gen6_get_sensor_clk,
- };
|