From: zyc Date: Thu, 27 Mar 2014 03:26:25 +0000 (+0800) Subject: isp:camsys_head ver:v0.0.5 X-Git-Tag: firefly_0821_release~5789 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=056772e2f24b6baa456f0e244f381f509323ca8b;p=firefly-linux-kernel-4.4.55.git isp:camsys_head ver:v0.0.5 update D-phy driver,support one lane now. --- diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi index 181ca0244c8e..58f08be10544 100755 --- a/arch/arm/boot/dts/rk3288.dtsi +++ b/arch/arm/boot/dts/rk3288.dtsi @@ -1052,9 +1052,9 @@ >; }; - isp:isp@0xFF910000{ + isp:isp@ff910000{ compatible = "rockchip,isp"; - reg = <0xFF910000 0x10000>; + reg = <0xff910000 0x10000>; interrupts = ; clocks = <&clk_gates16 2>, <&clk_gates16 1>, <&clk_isp>, <&clk_isp_jpe>, <&dummy>, <&clk_cif_out>; clock_names = "aclk_isp", "hclk_isp", "clk_isp", "clk_isp_jpe", "pclkin_isp", "clk_vipout"; @@ -1064,7 +1064,7 @@ pinctrl-2 = <&isp_mipi &isp_dvp_sync_d2d9 &isp_dvp_d0d1>; pinctrl-3 = <&isp_mipi &isp_dvp_sync_d2d9 &isp_dvp_d0d1 &isp_dvpd10d11>; - status = "disabled"; + status = "okay"; }; tsadc: tsadc@ff280000{ diff --git a/drivers/media/video/rk_camsys/Kconfig b/drivers/media/video/rk_camsys/Kconfig index c4aba692c677..8d22522235c7 100755 --- a/drivers/media/video/rk_camsys/Kconfig +++ b/drivers/media/video/rk_camsys/Kconfig @@ -1,13 +1,13 @@ config CAMSYS_DRV tristate "camsys driver " - default n + default y menu "RockChip camera system driver" depends on CAMSYS_DRV config CAMSYS_MRV tristate "camsys driver for marvin isp " - default n + default y ---help--- config CAMSYS_CIF diff --git a/drivers/media/video/rk_camsys/camsys_drv.c b/drivers/media/video/rk_camsys/camsys_drv.c index fb2a2a0cedd9..e662c080f943 100755 --- a/drivers/media/video/rk_camsys/camsys_drv.c +++ b/drivers/media/video/rk_camsys/camsys_drv.c @@ -174,13 +174,13 @@ static int camsys_extdev_register(camsys_devio_name_t *devio, camsys_dev_t *cams camsys_gpio_info_t *gpio_info; camsys_gpio_t *gpio; - if ((devio->dev_id & CAMSYS_DEVID_EXTERNAL) == 0) { err = -EINVAL; camsys_err("dev_id: 0x%x is not support for camsys!",devio->dev_id); goto end; } +#if 0 if (devio->phy.type == CamSys_Phy_Mipi) { if (camsys_find_devmem(CAMSYS_REGISTER_MIPIPHY_RES_NAME, camsys_dev) == NULL) { camsys_err("dev_id: 0x%x is connect to MIPI CSI, but %s isn't support",devio->dev_id, @@ -190,7 +190,7 @@ static int camsys_extdev_register(camsys_devio_name_t *devio, camsys_dev_t *cams goto end; } } - +#endif extdev = camsys_find_extdev(devio->dev_id, camsys_dev); if (extdev != NULL) { @@ -235,7 +235,7 @@ static int camsys_extdev_register(camsys_devio_name_t *devio, camsys_dev_t *cams gpio_info = &devio->pwrdn; gpio = &extdev->pwrdn; - for (i=0; i<4; i++) { + for (i=0; i<5; i++) { if (strcmp(gpio_info->name,"NC")) { gpio->io = camsys_gpio_get(gpio_info->name); if (gpio->io < 0) { @@ -401,6 +401,15 @@ static int camsys_sysctl(camsys_sysctrl_t *devctl, camsys_dev_t *camsys_dev) camsys_dev->reset_cb(camsys_dev); break; } + #if 0 + //for mipi + case CamSys_Gpio_Tag: + { + if((camsys_dev->mipiphy.ops )){ + camsys_dev->mipiphy.ops(NULL,NULL,devctl->on); + } + } + #endif default: break; @@ -480,7 +489,13 @@ static int camsys_irq_connect(camsys_irqcnnt_t *irqcnnt, camsys_dev_t *camsys_de err = -EINVAL; goto end; } - +#if 0 + //zyc for test mipi + if((camsys_dev->mipiphy.ops ) && (irqcnnt->mis == MRV_ISP_MIS)){ + camsys_dev->mipiphy.ops(NULL,NULL,0); + } +#endif + spin_lock_irqsave(&camsys_dev->irq.lock,flags); if (!list_empty(&camsys_dev->irq.irq_pool)) { list_for_each_entry(irqpool, &camsys_dev->irq.irq_pool, list) { @@ -579,7 +594,7 @@ static int camsys_irq_wait(camsys_irqsta_t *irqsta, camsys_dev_t *camsys_dev) list_add_tail(&irqstas->list,&irqpool->deactive); spin_unlock_irqrestore(&irqpool->lock,flags); } else { - camsys_warn("Thread(pid: %d) wait irq timeout!!",current->pid); + // camsys_warn("Thread(pid: %d) wait irq timeout!!",current->pid); err = -EAGAIN; } } else { @@ -606,7 +621,6 @@ static int camsys_irq_disconnect(camsys_irqcnnt_t *irqcnnt, camsys_dev_t *camsys if (all == false) { spin_lock_irqsave(&camsys_dev->irq.lock,flags); - printk("%s++++++++++++++++\n",__func__); if (!list_empty(&camsys_dev->irq.irq_pool)) { list_for_each_entry(irqpool, &camsys_dev->irq.irq_pool, list) { if (irqpool->pid == irqcnnt->pid) { @@ -616,7 +630,6 @@ static int camsys_irq_disconnect(camsys_irqcnnt_t *irqcnnt, camsys_dev_t *camsys } } } - printk("%s -------------\n",__func__); spin_unlock_irqrestore(&camsys_dev->irq.lock,flags); if (find_pool == false) { @@ -861,9 +874,7 @@ static long camsys_ioctl(struct file *filp,unsigned int cmd, unsigned long arg) if (copy_from_user((void*)&irqcnnt,(void __user *)arg, sizeof(camsys_irqcnnt_t))) return -EFAULT; - printk("disconnect ++++++++++++++++\n"); err = camsys_irq_disconnect(&irqcnnt,camsys_dev,false); - printk("disconnect ----------------\n"); break; } @@ -981,7 +992,7 @@ struct file_operations camsys_fops = { .mmap = camsys_mmap, }; -static int camsys_platform_probe_new(struct platform_device *pdev){ +static int camsys_platform_probe(struct platform_device *pdev){ int err = 0; camsys_dev_t *camsys_dev; struct resource register_res ; @@ -989,7 +1000,6 @@ static int camsys_platform_probe_new(struct platform_device *pdev){ unsigned long i2cmem; camsys_meminfo_t *meminfo; unsigned int irq_id; - err = of_address_to_resource(dev->of_node, 0, ®ister_res); if (err < 0){ camsys_err("Get register resource from %s platform device failed!",pdev->name); @@ -1083,7 +1093,8 @@ static int camsys_platform_probe_new(struct platform_device *pdev){ camsys_err("Mipi phy probe failed!"); } } - + +#if 0 if (strcmp(dev_name(&pdev->dev),CAMSYS_PLATFORM_MARVIN_NAME) == 0) { #if (defined(CONFIG_CAMSYS_MRV)) camsys_mrv_probe_cb(pdev, camsys_dev); @@ -1097,179 +1108,15 @@ static int camsys_platform_probe_new(struct platform_device *pdev){ camsys_err("CIF controller camsys driver haven't been complie!!!"); #endif } - - camsys_trace(1, "%s memory:",dev_name(&pdev->dev)); - list_for_each_entry(meminfo, &camsys_dev->devmems.memslist, list) { - if (strcmp(meminfo->name,CAMSYS_I2C_MEM_NAME) == 0) { - camsys_dev->devmems.i2cmem = meminfo; - camsys_trace(1," I2c memory (phy: 0x%x vir: 0x%x size: 0x%x)", - meminfo->phy_base,meminfo->vir_base,meminfo->size); - } - if (strcmp(meminfo->name,CAMSYS_REGISTER_MEM_NAME) == 0) { - camsys_dev->devmems.registermem = meminfo; - camsys_trace(1," Register memory (phy: 0x%x vir: 0x%x size: 0x%x)", - meminfo->phy_base,meminfo->vir_base,meminfo->size); - } - } - - camsys_dev->phy_cb = camsys_phy_ops; - platform_set_drvdata(pdev,(void*)camsys_dev); - //Camsys_devs list add - spin_lock(&camsys_devs.lock); - list_add_tail(&camsys_dev->list, &camsys_devs.devs); - spin_unlock(&camsys_devs.lock); - - - camsys_trace(1, "Probe %s device success ", dev_name(&pdev->dev)); - return 0; -request_mem_fail: - if (camsys_dev != NULL) { - - while(!list_empty(&camsys_dev->devmems.memslist)) { - meminfo = list_first_entry(&camsys_dev->devmems.memslist, camsys_meminfo_t, list); - if (meminfo) { - list_del_init(&meminfo->list); - if (strcmp(meminfo->name,CAMSYS_REGISTER_MEM_NAME)==0) { - iounmap((void __iomem *)meminfo->vir_base); - release_mem_region(meminfo->phy_base,meminfo->size); - } else if (strcmp(meminfo->name,CAMSYS_I2C_MEM_NAME)==0) { - kfree((void*)meminfo->vir_base); - } - kfree(meminfo); - meminfo = NULL; - } - } - - kfree(camsys_dev); - camsys_dev = NULL; - } -fail_end: - return -1; - - -} -#if 0 -static int camsys_platform_probe(struct platform_device *pdev) -{ - int err = 0; - unsigned int irq_id; - camsys_dev_t *camsys_dev; - unsigned long i2cmem; - camsys_meminfo_t *meminfo; - struct resource *register_res, *mipiphy_register_res; - - camsys_trace(1, "Probe %s device now", dev_name(&pdev->dev)); - register_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, CAMSYS_REGISTER_RES_NAME); - if (register_res == NULL) { - camsys_err("Get register resource from %s platform device failed!",pdev->name); - err = -ENODEV; - goto fail_end; - } - - mipiphy_register_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, CAMSYS_REGISTER_MIPIPHY_RES_NAME); - - irq_id = platform_get_irq_byname(pdev, CAMSYS_IRQ_RES_NAME); - if (irq_id < 0) { - camsys_err("Get irq resource from %s platform device failed!",pdev->name); - err = -ENODEV; - goto fail_end; - } - - camsys_dev = (camsys_dev_t*)kzalloc(sizeof(camsys_dev_t), GFP_KERNEL); - if (camsys_dev == NULL) { - camsys_err("Allocate camsys_dev for %s platform device failed",pdev->name); - err = -ENOMEM; - goto fail_end; - } - - //spin_lock_init(&camsys_dev->lock); - mutex_init(&camsys_dev->extdevs.mut); - INIT_LIST_HEAD(&camsys_dev->extdevs.list); - INIT_LIST_HEAD(&camsys_dev->extdevs.active); - INIT_LIST_HEAD(&camsys_dev->list); - - - //IRQ init - camsys_dev->irq.irq_id = irq_id; - spin_lock_init(&camsys_dev->irq.lock); - INIT_LIST_HEAD(&camsys_dev->irq.irq_pool); - //init_waitqueue_head(&camsys_dev->irq.irq_done); - - INIT_LIST_HEAD(&camsys_dev->devmems.memslist); - if (!request_mem_region(register_res->start, register_res->end - register_res->start + 1, - dev_name(&pdev->dev))) { - err = -ENOMEM; - goto request_mem_fail; - } - - //Register mem init - meminfo = kzalloc(sizeof(camsys_meminfo_t),GFP_KERNEL); - if (meminfo == NULL) { - err = -ENOMEM; - goto request_mem_fail; - } - - meminfo->vir_base = (unsigned int)ioremap(register_res->start, register_res->end - register_res->start + 1); - if (meminfo->vir_base == 0) { - camsys_err("%s ioremap %s failed",dev_name(&pdev->dev), CAMSYS_REGISTER_MEM_NAME); - err = -ENXIO; - goto request_mem_fail; - } - - strlcpy(meminfo->name, CAMSYS_REGISTER_MEM_NAME,sizeof(meminfo->name)); - meminfo->phy_base = register_res->start; - meminfo->size = register_res->end - register_res->start + 1; - list_add_tail(&meminfo->list, &camsys_dev->devmems.memslist); - - //I2c mem init - i2cmem = __get_free_page(GFP_KERNEL); - if (i2cmem == 0) { - camsys_err("Allocate i2cmem failed!"); - err = -ENOMEM; - goto request_mem_fail; - } - SetPageReserved(virt_to_page(i2cmem)); - - meminfo = kzalloc(sizeof(camsys_meminfo_t),GFP_KERNEL); - if (meminfo == NULL) { - err = -ENOMEM; - goto request_mem_fail; - } - strlcpy(meminfo->name,CAMSYS_I2C_MEM_NAME,sizeof(meminfo->name)); - meminfo->vir_base = i2cmem; - meminfo->phy_base = virt_to_phys((void*)i2cmem); - meminfo->size = PAGE_SIZE; - list_add_tail(&meminfo->list, &camsys_dev->devmems.memslist); - - { - unsigned int *tmpp; - - tmpp = (unsigned int*)meminfo->vir_base; - *tmpp = 0xfa561243; - } - - //Special init - - if (mipiphy_register_res) { - if (camsys_mipiphy_probe_cb(pdev, camsys_dev) <0) { - camsys_err("Mipi phy probe failed!"); - } - } - - if (strcmp(dev_name(&pdev->dev),CAMSYS_PLATFORM_MARVIN_NAME) == 0) { +#else #if (defined(CONFIG_CAMSYS_MRV)) camsys_mrv_probe_cb(pdev, camsys_dev); - #else - camsys_err("Marvin controller camsys driver haven't been complie!!!"); - #endif - } else { - #if (defined(CONFIG_CAMSYS_CIF)) + #elif (defined(CONFIG_CAMSYS_CIF)) camsys_cif_probe_cb(pdev,camsys_dev); #else - camsys_err("CIF controller camsys driver haven't been complie!!!"); + camsys_err("camsys driver haven't been complie!!!"); #endif - } - +#endif camsys_trace(1, "%s memory:",dev_name(&pdev->dev)); list_for_each_entry(meminfo, &camsys_dev->devmems.memslist, list) { if (strcmp(meminfo->name,CAMSYS_I2C_MEM_NAME) == 0) { @@ -1284,10 +1131,11 @@ static int camsys_platform_probe(struct platform_device *pdev) } } + camsys_dev->phy_cb = camsys_phy_ops; camsys_dev->pdev = pdev; + platform_set_drvdata(pdev,(void*)camsys_dev); - //Camsys_devs list add spin_lock(&camsys_devs.lock); list_add_tail(&camsys_dev->list, &camsys_devs.devs); @@ -1319,8 +1167,9 @@ request_mem_fail: } fail_end: return -1; + + } -#endif static int camsys_platform_remove(struct platform_device *pdev) { camsys_dev_t *camsys_dev = platform_get_drvdata(pdev); @@ -1378,7 +1227,7 @@ static int camsys_platform_remove(struct platform_device *pdev) static const struct of_device_id cif_of_match[] = { - { .compatible = "rodkchip,isp" }, + { .compatible = "rockchip,isp" }, }; MODULE_DEVICE_TABLE(of, cif_of_match); @@ -1386,13 +1235,13 @@ static struct platform_driver camsys_platform_driver = { .driver = { .name = CAMSYS_PLATFORM_DRV_NAME, - .of_match_table = cif_of_match, + .of_match_table = of_match_ptr(cif_of_match), }, - .probe = camsys_platform_probe_new, + .probe = camsys_platform_probe, .remove = (camsys_platform_remove), }; - +MODULE_ALIAS(CAMSYS_PLATFORM_DRV_NAME); static int __init camsys_platform_init(void) { printk("CamSys driver version: v%d.%d.%d, CamSys head file version: v%d.%d.%d\n", @@ -1403,7 +1252,7 @@ static int __init camsys_platform_init(void) spin_lock_init(&camsys_devs.lock); INIT_LIST_HEAD(&camsys_devs.devs); platform_driver_register(&camsys_platform_driver); - + // platform_driver_probe(&camsys_platform_driver, camsys_platform_probe_new); return 0; } diff --git a/drivers/media/video/rk_camsys/camsys_internal.h b/drivers/media/video/rk_camsys/camsys_internal.h index e027dca69efb..15c540d90b3f 100755 --- a/drivers/media/video/rk_camsys/camsys_internal.h +++ b/drivers/media/video/rk_camsys/camsys_internal.h @@ -170,6 +170,7 @@ typedef struct camsys_extdev_s { camsys_gpio_t rst; camsys_gpio_t afpwr; camsys_gpio_t afpwrdn; + camsys_gpio_t pwren; camsys_flash_t fl; diff --git a/drivers/media/video/rk_camsys/camsys_marvin.c b/drivers/media/video/rk_camsys/camsys_marvin.c index 295355793416..0a7a0282dc5e 100755 --- a/drivers/media/video/rk_camsys/camsys_marvin.c +++ b/drivers/media/video/rk_camsys/camsys_marvin.c @@ -2,7 +2,6 @@ static const char miscdev_name[] = CAMSYS_MARVIN_DEVNAME; - static int camsys_mrv_iomux_cb(camsys_extdev_t *extdev,void *ptr) { unsigned int cif_vol_sel; @@ -76,6 +75,10 @@ static int camsys_mrv_iomux_cb(camsys_extdev_t *extdev,void *ptr) } } + //set 1.8v vol domain for rk32 + __raw_writel(((1<<1)|(1<<(1+16))),RK_GRF_VIRT+0x0380); + __raw_writel(0xffffffff, RK_GRF_VIRT+0x01d4); + //set cif vol domain if (extdev->phy.type == CamSys_Phy_Cif) { @@ -90,11 +93,13 @@ static int camsys_mrv_iomux_cb(camsys_extdev_t *extdev,void *ptr) __raw_writel(((1<<1)|(1<<(1+16))),RK30_GRF_BASE+0x018c); } #else - __raw_writel(((1<<1)|(1<<(1+16))),RK_GRF_VIRT+0x018c); + + //set 1.8v vol domain + __raw_writel(((1<<1)|(1<<(1+16))),RK_GRF_VIRT+0x0380); #endif //set driver strength - __raw_writel(0xffffffff, RK_GRF_VIRT+0x01dc); + // __raw_writel(0xffffffff, RK_GRF_VIRT+0x01dc); } return 0; @@ -117,14 +122,26 @@ static int camsys_mrv_clkin_cb(void *ptr, unsigned int on) camsys_dev_t *camsys_dev = (camsys_dev_t*)ptr; camsys_mrv_clk_t *clk = (camsys_mrv_clk_t*)camsys_dev->clk; - spin_lock(&clk->lock); - if (on && !clk->in_on) { - clk_enable(clk->pd_isp); - clk_enable(clk->aclk_isp); - clk_enable(clk->hclk_isp); - clk_enable(clk->isp); - clk_enable(clk->isp_jpe); - clk_enable(clk->pclkin_isp); + // spin_lock(&clk->lock); + if (on && !clk->in_on) { + clk_set_rate(clk->isp,180000000); + clk_set_rate(clk->isp_jpe, 180000000); + // clk_set_rate(clk->aclk_isp,24000000); + // clk_set_rate(clk->hclk_isp,24000000); + + + clk_prepare_enable(clk->aclk_isp); + clk_prepare_enable(clk->hclk_isp); + clk_prepare_enable(clk->isp); + clk_prepare_enable( clk->isp_jpe); + + + // clk_enable(clk->pd_isp); + // clk_enable(clk->aclk_isp); + // clk_enable(clk->hclk_isp); + // clk_enable(clk->isp); + // clk_enable(clk->isp_jpe); + // clk_enable(clk->pclkin_isp); clk->in_on = true; @@ -132,16 +149,24 @@ static int camsys_mrv_clkin_cb(void *ptr, unsigned int on) camsys_mrv_reset_cb(ptr); } else if (!on && clk->in_on) { - clk_disable(clk->pd_isp); - clk_disable(clk->aclk_isp); - clk_disable(clk->hclk_isp); - clk_disable(clk->isp); - clk_disable(clk->isp_jpe); - clk_disable(clk->pclkin_isp); + + + clk_disable_unprepare(clk->aclk_isp); + clk_disable_unprepare(clk->hclk_isp); + clk_disable_unprepare(clk->isp); + clk_disable_unprepare( clk->isp_jpe); + + // clk_disable(clk->pd_isp); + // clk_disable(clk->aclk_isp); + // clk_disable(clk->hclk_isp); + // clk_disable(clk->isp); + // clk_disable(clk->isp_jpe); + // clk_disable(clk->pclkin_isp); + clk->in_on = false; camsys_trace(1, "%s clock in turn off",dev_name(camsys_dev->miscdev.this_device)); } - spin_unlock(&clk->lock); + // spin_unlock(&clk->lock); return 0; } @@ -152,8 +177,10 @@ static int camsys_mrv_clkout_cb(void *ptr, unsigned int on) struct clk *cif_clk_out_div; spin_lock(&clk->lock); - if (on && (clk->out_on != on)) { - clk_enable(clk->cif_clk_out); + if (on && (clk->out_on != on)) { + clk_prepare_enable(clk->cif_clk_out); + +// clk_enable(clk->cif_clk_out); clk_set_rate(clk->cif_clk_out,on); clk->out_on = on; @@ -171,7 +198,10 @@ static int camsys_mrv_clkout_cb(void *ptr, unsigned int on) } else { camsys_warn("%s clock out may be not off!", dev_name(camsys_dev->miscdev.this_device)); } - clk_disable(clk->cif_clk_out); + + clk_disable_unprepare( clk->cif_clk_out); +// clk_disable(clk->cif_clk_out); + clk->out_on = 0; camsys_trace(1, "%s clock out turn off",dev_name(camsys_dev->miscdev.this_device)); @@ -194,7 +224,7 @@ static irqreturn_t camsys_mrv_irq(int irq, void *data) __raw_writel(isp_mis, (void volatile *)(camsys_dev->devmems.registermem->vir_base + MRV_ISP_ICR)); __raw_writel(mipi_mis, (void volatile *)(camsys_dev->devmems.registermem->vir_base + MRV_MIPI_ICR)); __raw_writel(mi_mis, (void volatile *)(camsys_dev->devmems.registermem->vir_base + MRV_MI_ICR)); - + spin_lock(&camsys_dev->irq.lock); if (!list_empty(&camsys_dev->irq.irq_pool)) { list_for_each_entry(irqpool, &camsys_dev->irq.irq_pool, list) { @@ -307,22 +337,24 @@ int camsys_mrv_probe_cb(struct platform_device *pdev, camsys_dev_t *camsys_dev) // mrv_clk->pd_isp = devm_clk_get(&pdev->dev, "pd_isp"); mrv_clk->pd_isp = NULL; - mrv_clk->aclk_isp = devm_clk_get(&pdev->dev, "aclk_isp"); - mrv_clk->hclk_isp = devm_clk_get(&pdev->dev, "hclk_isp"); + mrv_clk->aclk_isp = devm_clk_get(&pdev->dev, "g_aclk_isp"); + mrv_clk->hclk_isp = devm_clk_get(&pdev->dev, "g_hclk_isp"); mrv_clk->isp = devm_clk_get(&pdev->dev, "clk_isp"); mrv_clk->isp_jpe = devm_clk_get(&pdev->dev, "clk_isp_jpe"); mrv_clk->pclkin_isp = devm_clk_get(&pdev->dev, "pclkin_isp"); - mrv_clk->cif_clk_out = devm_clk_get(&pdev->dev, "clk_vipout"); + mrv_clk->cif_clk_out = devm_clk_get(&pdev->dev, "clk_cif_out"); + if (/*IS_ERR_OR_NULL(mrv_clk->pd_isp) ||*/ IS_ERR_OR_NULL(mrv_clk->aclk_isp) || IS_ERR_OR_NULL(mrv_clk->hclk_isp) || - IS_ERR_OR_NULL(mrv_clk->isp) || IS_ERR_OR_NULL(mrv_clk->isp_jpe) || IS_ERR_OR_NULL(mrv_clk->pclkin_isp) || + IS_ERR_OR_NULL(mrv_clk->isp) || IS_ERR_OR_NULL(mrv_clk->isp_jpe) /*|| IS_ERR_OR_NULL(mrv_clk->pclkin_isp)*/ || IS_ERR_OR_NULL(mrv_clk->cif_clk_out)) { camsys_err("Get %s clock resouce failed!\n",miscdev_name); err = -EINVAL; goto clk_failed; } + - clk_set_rate(mrv_clk->isp,320000000); - clk_set_rate(mrv_clk->isp_jpe,320000000); +// clk_set_rate(mrv_clk->isp,1800000000); +// clk_set_rate(mrv_clk->isp_jpe,180000000); spin_lock_init(&mrv_clk->lock); diff --git a/drivers/media/video/rk_camsys/camsys_mipicsi_phy.c b/drivers/media/video/rk_camsys/camsys_mipicsi_phy.c index 62335ad55ec7..f973906d43ca 100755 --- a/drivers/media/video/rk_camsys/camsys_mipicsi_phy.c +++ b/drivers/media/video/rk_camsys/camsys_mipicsi_phy.c @@ -17,62 +17,160 @@ #define DPHY_RX0_TESTEN (1<<2) #define DPHY_RX0_TESTDIN_OFFSET (3) +#define DPHY_TX1RX1_ENABLECLK_MASK (0x1<<28) +#define DPHY_RX1_SRC_SEL_MASK (0x1<<29) +#define DPHY_TX1RX1_MASTERSLAVEZ_MASK (0x1<<30) +#define DPHY_TX1RX1_BASEDIR_OFFSET (0x1<<31) + +#define DPHY_TX1RX1_ENABLECLK (0x1<<12) +#define DPHY_TX1RX1_DISABLECLK (0x0<<12) +#define DPHY_RX1_SRC_SEL_ISP (0x1<<13) +#define DPHY_TX1RX1_SLAVEZ (0x0<<14) +#define DPHY_TX1RX1_BASEDIR_REC (0x1<<15) + + //GRF_SOC_CON6 //bit 0 grf_con_disable_isp //bit 1 grf_con_isp_dphy_sel 1'b0 mipi phy rx0 #define GRF_SOC_CON6_OFFSET (0x025c) -#define MIPI_PHY_RX0_MASK (0x1<<16) -#define MIPI_PHY_RX0 (0x1<<0) +#define MIPI_PHY_DISABLE_ISP_MASK (0x1<<16) +#define MIPI_PHY_DISABLE_ISP (0x0<<0) + +#define DSI_CSI_TESTBUS_SEL_MASK (0x1<<30) +#define DSI_CSI_TESTBUS_SEL_OFFSET_BIT (14) + + +#define MIPI_PHY_DPHYSEL_OFFSET_MASK (0x1<<17) +#define MIPI_PHY_DPHYSEL_OFFSET_BIT (0x1) + +//GRF_SOC_CON10 +//bit12:15 grf_dphy_rx0_enable +//bit 0:3 turn disable +#define GRF_SOC_CON10_OFFSET (0x026c) +#define DPHY_RX0_TURN_DISABLE_MASK (0xf<<16) +#define DPHY_RX0_TURN_DISABLE_OFFSET_BITS (0x0) +#define DPHY_RX0_ENABLE_MASK (0xf<<28) +#define DPHY_RX0_ENABLE_OFFSET_BITS (12) + +//GRF_SOC_CON9 +//bit12:15 grf_dphy_rx0_enable +//bit 0:3 turn disable +#define GRF_SOC_CON9_OFFSET (0x0268) +#define DPHY_TX1RX1_TURN_DISABLE_MASK (0xf<<16) +#define DPHY_TX1RX1_TURN_DISABLE_OFFSET_BITS (0x0) +#define DPHY_TX1RX1_ENABLE_MASK (0xf<<28) +#define DPHY_TX1RX1_ENABLE_OFFSET_BITS (12) + +//GRF_SOC_CON15 +//bit 0:3 turn request +#define GRF_SOC_CON15_OFFSET (0x03a4) +#define DPHY_RX0_TURN_REQUEST_MASK (0xf<<16) +#define DPHY_RX0_TURN_REQUEST_OFFSET_BITS (0x0) + +#define DPHY_TX1RX1_TURN_REQUEST_MASK (0xf<<20) +#define DPHY_TX1RX1_TURN_REQUEST_OFFSET_BITS (0x0) + #endif -static void phy0_WriteReg(uint8_t addr, uint8_t data) + +static void phy_select(uint8_t index) { + if((index == 0) || (index == 1)){ + write_grf_reg(GRF_SOC_CON6_OFFSET, MIPI_PHY_DPHYSEL_OFFSET_MASK | (index<> DPHY_RX0_TESTDIN_OFFSET) & (0xff)); - - camsys_err("%s phy addr = 0x%x,value = 0x%x\n",__func__,addr,data); return data ; } - -static void PHY0_Init(int numLane,int clkfreq) +static void phy_config_num_lane(uint8_t index,int numLane) { - -// select phy rx0 - write_grf_reg(GRF_SOC_CON6_OFFSET, MIPI_PHY_RX0_MASK | MIPI_PHY_RX0); + uint8_t lane_mask =0; + int i = 0; + for(i=0;i 1) + phy0_WriteReg(0x54,0x10); +#endif //**********************************************************************// //Normal operation - phy0_ReadReg(0x00); + phy0_WriteReg(0x0,-1); //TESTCLK=1 write_grf_reg(GRF_SOC_CON14_OFFSET, DPHY_RX0_TESTCLK_MASK |DPHY_RX0_TESTCLK); //TESTEN =0 - write_grf_reg(GRF_SOC_CON14_OFFSET, (DPHY_RX0_TESTEN)); + write_grf_reg(GRF_SOC_CON14_OFFSET, (DPHY_RX0_TESTEN_MASK)); + +} - } static int camsys_mipiphy_ops (void *phy, void *phyinfo, unsigned int on) { - PHY0_Init(1,0); +#if 0 + camsys_phyinfo_t* phyinfo_s = (camsys_phyinfo_t*)phyinfo; + struct camsys_mipiphy_s* phy_s = (struct camsys_mipiphy_s*)phy; + if(phy_s->phy_index == 0){ + phy_select(phy_s->phy_index); + phy_config_num_lane(phy_s->data_en_bit); + phy0_start(0,phy_s->data_en_bit); + + }else if(phy_s->phy_index == 1){ + + }else{ + + camsys_err("phy index is erro!"); + } +#else +#if 0 + if(on == 1){ + //disable isp + write_grf_reg(GRF_SOC_CON6_OFFSET, MIPI_PHY_DISABLE_ISP_MASK | 1); + phy_select(0); + // phy_config_num_lane(0,2); + phy0_start(0,2); + + phy_config_num_lane(0,2); + udelay(200); + //enable isp + write_grf_reg(GRF_SOC_CON6_OFFSET, MIPI_PHY_DISABLE_ISP_MASK | 0); + }else +#endif + { + //disable isp + write_grf_reg(GRF_SOC_CON6_OFFSET, MIPI_PHY_DISABLE_ISP_MASK | 1); + phy_select(0); + // phy_config_num_lane(0,2); + phy0_start(0,1); + + phy_config_num_lane(0,1); + udelay(200); + //enable isp + write_grf_reg(GRF_SOC_CON6_OFFSET, MIPI_PHY_DISABLE_ISP_MASK | 0); + } + +#endif return 0; } @@ -120,6 +264,7 @@ int camsys_mipiphy_probe_cb(struct platform_device *pdev, camsys_dev_t *camsys_d camsys_dev->mipiphy.ops = camsys_mipiphy_ops; camsys_dev->mipiphy.remove = camsys_mipiphy_remove_cb; + return 0; } diff --git a/include/media/camsys_head.h b/include/media/camsys_head.h index 3adc33a13c73..44974b1dfc25 100755 --- a/include/media/camsys_head.h +++ b/include/media/camsys_head.h @@ -14,8 +14,10 @@ * 1) add support cif phy for marvin; *v0.0.4: * 1) add clock information in struct camsys_devio_name_s; +*v0.0.5: + 1) add pwren control */ -#define CAMSYS_HEAD_VERSION KERNEL_VERSION(0,0,4) +#define CAMSYS_HEAD_VERSION KERNEL_VERSION(0,0,5) #define CAMSYS_MARVIN_DEVNAME "camsys_marvin" #define CAMSYS_CIF0_DEVNAME "camsys_cif0" @@ -95,7 +97,8 @@ typedef enum camsys_sysctrl_ops_e { CamSys_Rst, CamSys_AfPwr, CamSys_AfPwrDn, - + CamSys_PwrEn, + CamSys_Gpio_Tag = 50, CamSys_ClkIn @@ -124,6 +127,10 @@ typedef struct camsys_flash_info_s { typedef struct camsys_mipiphy_s { unsigned int data_en_bit; //data lane enable bit; + #if 0 + unsigned int freq; + unsigned int phy_index; //phy0,phy1 + #endif } camsys_mipiphy_t; typedef enum camsys_fmt_e { @@ -176,9 +183,11 @@ typedef struct camsys_devio_name_s { camsys_regulator_info_t afvdd; camsys_gpio_info_t pwrdn; // standby gpio name - camsys_gpio_info_t rst; // hard reset gpio name + camsys_gpio_info_t rst; // hard reset gpio name camsys_gpio_info_t afpwr; // auto focus vcm driver ic power gpio name camsys_gpio_info_t afpwrdn; // auto focus vcm driver ic standby gpio + camsys_gpio_info_t pwren; // power enable gpio name + camsys_flash_info_t fl;