Merge tag 'v4.4-rc4'
[firefly-linux-kernel-4.4.55.git] / drivers / media / video / rk_camsys / camsys_marvin.c
index 588cea3bc4afb09e3e07bd3c72ecfa32c60dbaf3..abad592f54af7a9b0d8565441d486971d49b30d9 100755 (executable)
@@ -37,7 +37,9 @@ static int camsys_mrv_iomux_cb(camsys_extdev_t *extdev,void *ptr)
                     strcpy(state_str,"isp_dvp8bit0");
                 } else if (extdev->phy.info.cif.cifio == CamSys_SensorBit0_CifBit2) {
                     strcpy(state_str,"isp_dvp8bit2");
-                } else {
+                } else if (extdev->phy.info.cif.cifio == CamSys_SensorBit0_CifBit4) {
+                    strcpy(state_str,"isp_dvp8bit4");
+                }else {
                     camsys_err("extdev->phy.info.cif.cifio: 0x%x is invalidate!", extdev->phy.info.cif.cifio);
                     goto fail;
                 }
@@ -302,7 +304,7 @@ static int camsys_mrv_reset_cb(void *ptr,unsigned int on)
     if (camsys_dev->soc) {
         soc = (camsys_soc_priv_t*)camsys_dev->soc;
         if (soc->soc_cfg) {
-            (soc->soc_cfg)(Isp_SoftRst,(void*)on);
+            (soc->soc_cfg)(Isp_SoftRst,(void*)(unsigned long)on);
         } else {
             camsys_err("camsys_dev->soc->soc_cfg is NULL!");
         }
@@ -331,16 +333,18 @@ static int camsys_mrv_clkin_cb(void *ptr, unsigned int on)
                clk_set_rate(clk->isp,isp_clk);
         clk_set_rate(clk->isp_jpe, isp_clk);
 
+               clk_prepare_enable(clk->pd_isp);
         clk_prepare_enable(clk->aclk_isp);
         clk_prepare_enable(clk->hclk_isp);
         clk_prepare_enable(clk->isp);
-        clk_prepare_enable(clk->isp_jpe);        
+        clk_prepare_enable(clk->isp_jpe);
         clk_prepare_enable(clk->pclkin_isp); 
                if(CHIP_TYPE == 3368){
+
                        clk_prepare_enable(clk->cif_clk_out);
                        clk_prepare_enable(clk->pclk_dphyrx);
+                       clk_prepare_enable(clk->clk_vio0_noc);
                }else{
-                       clk_prepare_enable(clk->pd_isp);
                        clk_prepare_enable(clk->clk_mipi_24m);          
                }
         clk->in_on = true;
@@ -356,14 +360,17 @@ static int camsys_mrv_clkin_cb(void *ptr, unsigned int on)
         clk_disable_unprepare(clk->hclk_isp);
         clk_disable_unprepare(clk->isp);
         clk_disable_unprepare(clk->isp_jpe);
-        clk_disable_unprepare(clk->pclkin_isp); 
+        clk_disable_unprepare(clk->pclkin_isp);
                if(CHIP_TYPE == 3368){
                clk_disable_unprepare(clk->cif_clk_out);
                        clk_disable_unprepare(clk->pclk_dphyrx);
+                       clk_disable_unprepare(clk->clk_vio0_noc);
+
                }else{
                clk_disable_unprepare(clk->clk_mipi_24m); 
-                       clk_disable_unprepare(clk->pd_isp);
                }
+               clk_disable_unprepare(clk->pd_isp);
+
                rockchip_clear_system_status(SYS_STATUS_ISP);
         clk->in_on = false;
         camsys_trace(1, "%s clock in turn off",dev_name(camsys_dev->miscdev.this_device));
@@ -529,6 +536,9 @@ static int camsys_mrv_remove_cb(struct platform_device *pdev)
         if (!IS_ERR_OR_NULL(mrv_clk->cif_clk_out)) {
             devm_clk_put(&pdev->dev,mrv_clk->cif_clk_out);
         }
+        if (!IS_ERR_OR_NULL(mrv_clk->clk_vio0_noc)) {
+            devm_clk_put(&pdev->dev,mrv_clk->clk_vio0_noc);
+        }
 
         kfree(mrv_clk);
         mrv_clk = NULL;
@@ -555,7 +565,7 @@ int camsys_mrv_probe_cb(struct platform_device *pdev, camsys_dev_t *camsys_dev)
         goto clk_failed;
     }
     if(CHIP_TYPE == 3368){
-           mrv_clk->pd_isp = NULL;
+           mrv_clk->pd_isp = devm_clk_get(&pdev->dev, "pd_isp");
            mrv_clk->aclk_isp = devm_clk_get(&pdev->dev, "aclk_isp");
            mrv_clk->hclk_isp = devm_clk_get(&pdev->dev, "hclk_isp");
            mrv_clk->isp = devm_clk_get(&pdev->dev, "clk_isp");
@@ -564,11 +574,12 @@ int camsys_mrv_probe_cb(struct platform_device *pdev, camsys_dev_t *camsys_dev)
            mrv_clk->cif_clk_out = devm_clk_get(&pdev->dev, "clk_cif_out");
            mrv_clk->cif_clk_pll = devm_clk_get(&pdev->dev, "clk_cif_pll");
            mrv_clk->pclk_dphyrx = devm_clk_get(&pdev->dev, "pclk_dphyrx");    
-           
-           
+           mrv_clk->clk_vio0_noc = devm_clk_get(&pdev->dev, "clk_vio0_noc");
+
                if (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->cif_clk_out) || IS_ERR_OR_NULL(mrv_clk->pclk_dphyrx)) {
+               IS_ERR_OR_NULL(mrv_clk->cif_clk_out) || IS_ERR_OR_NULL(mrv_clk->pclk_dphyrx)||
+               IS_ERR_OR_NULL(mrv_clk->pd_isp) || IS_ERR_OR_NULL(mrv_clk->clk_vio0_noc)) {
                camsys_err("Get %s clock resouce failed!\n",miscdev_name);
                err = -EINVAL;
                goto clk_failed;
@@ -657,6 +668,9 @@ clk_failed:
                if (!IS_ERR_OR_NULL(mrv_clk->pclk_dphyrx)) {
                    clk_put(mrv_clk->pclk_dphyrx);
                }
+               if (!IS_ERR_OR_NULL(mrv_clk->clk_vio0_noc)) {
+                       clk_put(mrv_clk->clk_vio0_noc);
+               }
                }
 
         kfree(mrv_clk);