rockchip,isp,cifphy = <1>;
rockchip,isp,mipiphy1,reg = <0xff968000 0x4000>;
rockchip,gpios = <&gpio7 GPIO_B5 GPIO_ACTIVE_HIGH>;
+ rockchip,isp,iommu_enable = <0>;
status = "okay";
};
case CamSys_Flash_Trigger:
{
camsys_dev->flash_trigger_cb(camsys_dev, devctl->on);
+ break;
+ }
+ case CamSys_IOMMU:
+ {
+ if(camsys_dev->iommu_cb(camsys_dev, devctl) < 0){
+ err = -1;
+ }
+ break;
}
default:
break;
return -EFAULT;
break;
}
-
+ case CAMSYS_QUREYIOMMU:
+ {
+ int iommu_enabled = 0;
+ #ifdef CONFIG_ROCKCHIP_IOMMU
+ of_property_read_u32(camsys_dev->pdev->dev.of_node, "rockchip,isp,iommu_enable", &iommu_enabled);
+ #endif
+ if (copy_to_user((void __user *)arg,(void*)&iommu_enabled, sizeof(iommu_enabled)))
+ return -EFAULT;
+ break;
+ }
case CAMSYS_I2CRD:
{
camsys_i2c_info_t i2cinfo;
return -EFAULT;
err = camsys_sysctl(&devctl, camsys_dev);
+ if ((err==0) && (devctl.ops == CamSys_IOMMU)){
+ if (copy_to_user((void __user *)arg,(void*)&devctl, sizeof(camsys_sysctrl_t)))
+ return -EFAULT;
+ }
break;
}
#include <linux/of_gpio.h>
#include <linux/rockchip/cpu.h>
#include <media/camsys_head.h>
+#include <linux/rockchip/sysmmu.h>
+#include <linux/rockchip/iovmm.h>
1) add flash_prelight control.
*v0.0x11.0:
1) raise qos of isp up to the same as lcdc.
+*v0.0x12.0:
+ 1) support iommu.
*/
-#define CAMSYS_DRIVER_VERSION KERNEL_VERSION(0,0x11,0)
+#define CAMSYS_DRIVER_VERSION KERNEL_VERSION(0,0x12,0)
#define CAMSYS_PLATFORM_DRV_NAME "RockChip-CamSys"
int (*iomux)(camsys_extdev_t *extdev,void *ptr);
int (*platform_remove)(struct platform_device *pdev);
int (*flash_trigger_cb)(void *ptr, unsigned int on);
+ int (*iommu_cb)(void *ptr,camsys_sysctrl_t *devctl);
} camsys_dev_t;
#include <linux/rockchip/common.h>
#include <dt-bindings/clock/rk_system_status.h>
+#include <linux/rockchip_ion.h>
+#include <linux/file.h>
extern int rockchip_set_system_status(unsigned long status);
extern int rockchip_clear_system_status(unsigned long status);
return retval;
}
+static int camsys_mrv_iommu_cb(void *ptr,camsys_sysctrl_t *devctl)
+{
+ struct device *iommu_dev = NULL,*dev = NULL;
+ struct file *file = NULL;
+ struct ion_client *client = NULL;
+ struct ion_handle *handle = NULL;
+ camsys_iommu_t *iommu = NULL;
+ int ret = 0,iommu_enabled = 0;
+ camsys_dev_t * camsys_dev = (camsys_dev_t *)ptr;
+
+ of_property_read_u32(camsys_dev->pdev->dev.of_node, "rockchip,isp,iommu_enable", &iommu_enabled);
+ if(iommu_enabled != 1){
+ camsys_err("isp iommu have not been enabled!\n");
+ ret = -1;
+ goto iommu_end;
+ }
+
+ iommu_dev = rockchip_get_sysmmu_device_by_compatible("iommu,isp_mmu");
+ if(!iommu_dev){
+ camsys_err("get iommu device erro!\n");
+ ret = -1;
+ goto iommu_end;
+ }
+ dev = &(camsys_dev->pdev->dev);
+ iommu = (camsys_iommu_t *)(devctl->rev);
+ file = fget(iommu->client_fd);
+ if(!file){
+ camsys_err("get client_fd file erro!\n");
+ ret = -1;
+ goto iommu_end;
+ }
+
+ client = file->private_data;
+
+ if(!client){
+ camsys_err("get ion_client erro!\n");
+ ret = -1;
+ goto iommu_end;
+ }
+
+ fput(file);
+
+ handle = ion_import_dma_buf(client,iommu->map_fd);
+ camsys_trace(1,"map fd %d ,client fd %d\n",iommu->map_fd,iommu->client_fd);
+ if(!handle){
+ camsys_err("get ion_handle erro!\n");
+ ret = -1;
+ goto iommu_end;
+ }
+ if(devctl->on){
+ platform_set_sysmmu(iommu_dev,dev);
+ ret = iovmm_activate(dev);
+
+ ret = ion_map_iommu(dev,client,handle,&(iommu->linear_addr),&(iommu->len));
+
+ }else{
+ ion_unmap_iommu(dev,client,handle);
+ platform_set_sysmmu(iommu_dev,dev);
+ iovmm_deactivate(dev);
+ }
+iommu_end:
+ return ret;
+}
static int camsys_mrv_reset_cb(void *ptr,unsigned int on)
{
camsys_dev_t *camsys_dev = (camsys_dev_t*)ptr;
int err = 0;
camsys_mrv_clk_t *mrv_clk=NULL;
- err = request_irq(camsys_dev->irq.irq_id, camsys_mrv_irq, 0, CAMSYS_MARVIN_IRQNAME,camsys_dev);
+ err = request_irq(camsys_dev->irq.irq_id, camsys_mrv_irq, IRQF_SHARED, CAMSYS_MARVIN_IRQNAME,camsys_dev);
if (err) {
camsys_err("request irq for %s failed",CAMSYS_MARVIN_IRQNAME);
goto end;
camsys_dev->reset_cb = camsys_mrv_reset_cb;
camsys_dev->iomux = camsys_mrv_iomux_cb;
camsys_dev->flash_trigger_cb = camsys_mrv_flash_trigger_cb;
+ camsys_dev->iommu_cb = camsys_mrv_iommu_cb;
camsys_dev->miscdev.minor = MISC_DYNAMIC_MINOR;
camsys_dev->miscdev.name = miscdev_name;
* 2) add support io domain and mclk driver strength configuration;
*v0.7.0:
1) add flash_trigger_out control
+*v0.8.0:
+ 1) support isp iommu
*/
-#define CAMSYS_HEAD_VERSION KERNEL_VERSION(0,7,0)
+#define CAMSYS_HEAD_VERSION KERNEL_VERSION(0,8,0)
#define CAMSYS_MARVIN_DEVNAME "camsys_marvin"
#define CAMSYS_CIF0_DEVNAME "camsys_cif0"
#define CAMSYS_DEVID_EXTERNAL 0xFF000000
#define CAMSYS_DEVID_EXTERNAL_NUM 8
-#define CAMSYS_DEVCFG_FLASHLIGHT 0x00000001
-#define CAMSYS_DEVCFG_PREFLASHLIGHT 0x00000002
-#define CAMSYS_DEVCFG_SHUTTER 0x00000004
+#define CAMSYS_DEVCFG_FLASHLIGHT 0x00000001
+#define CAMSYS_DEVCFG_PREFLASHLIGHT 0x00000002
+#define CAMSYS_DEVCFG_SHUTTER 0x00000004
typedef struct camsys_irqsta_s {
unsigned int ris; //Raw interrupt status
CamSys_Phy_End_Tag,
CamSys_Flash_Trigger_Start_Tag,
CamSys_Flash_Trigger,
- CamSys_Flash_Trigger_End_Tag
+ CamSys_Flash_Trigger_End_Tag,
+ CamSys_IOMMU
} camsys_sysctrl_ops_t;
unsigned int active;
} camsys_gpio_info_t;
+typedef struct camsys_iommu_s{
+ int client_fd;
+ int map_fd;
+ unsigned long linear_addr;
+ unsigned long len;
+}camsys_iommu_t;
+
typedef struct camsys_sysctrl_s {
unsigned int dev_mask;
camsys_sysctrl_ops_t ops;
#define CAMSYS_IRQDISCONNECT _IOW(CAMSYS_IOC_MAGIC, 10, camsys_irqcnnt_t)
#define CAMSYS_QUREYMEM _IOR(CAMSYS_IOC_MAGIC, 11, camsys_querymem_t)
+#define CAMSYS_QUREYIOMMU _IOW(CAMSYS_IOC_MAGIC, 12, int)
#endif