camsys driver: v0.0x21.3
authordalon.zhang <dalon.zhang@rock-chips.com>
Fri, 1 Jul 2016 07:03:59 +0000 (15:03 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 5 Jul 2016 05:58:56 +0000 (13:58 +0800)
Change-Id: Ibbea044aade566ee95184cc9f6dfec76752a3b0a
Signed-off-by: dalon.zhang <dalon.zhang@rock-chips.com>
drivers/media/video/rk_camsys/camsys_drv.c
drivers/media/video/rk_camsys/camsys_internal.h [changed mode: 0755->0644]
drivers/media/video/rk_camsys/camsys_marvin.c

index bbfa0516b209227970cc0374cc569dab512422b5..679217b00cec6fe55290160966578fecc52d8895 100755 (executable)
@@ -924,7 +924,7 @@ static long camsys_ioctl_compat(struct file *filp, unsigned int cmd, unsigned
                        of_property_read_u32(vpu_node,
                                "iommu_enabled", &vpu_iommu_enabled);
                        of_property_read_u32(camsys_dev->pdev->dev.of_node,
-                               "rockchip,isp,iommu_enable", &iommu_enabled);
+                               "rockchip,isp,iommu-enable", &iommu_enabled);
                        of_node_put(vpu_node);
                        if (iommu_enabled != vpu_iommu_enabled) {
                                camsys_err(
@@ -1132,7 +1132,7 @@ static long camsys_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                        of_property_read_u32(vpu_node,
                                "iommu_enabled", &vpu_iommu_enabled);
                        of_property_read_u32(camsys_dev->pdev->dev.of_node,
-                               "rockchip,isp,iommu_enable", &iommu_enabled);
+                               "rockchip,isp,iommu-enable", &iommu_enabled);
                        of_node_put(vpu_node);
                        if (iommu_enabled != vpu_iommu_enabled) {
                                camsys_err(
old mode 100755 (executable)
new mode 100644 (file)
index b77949f..318cc9f
                1) support rk3368-sheep kernel ver4.4.
 *v0.0x21.2:
                1) support rk3399.
+*v0.0x21.3:
+               1) some modifications.
 */
-#define CAMSYS_DRIVER_VERSION                   KERNEL_VERSION(0, 0x21, 2)
+#define CAMSYS_DRIVER_VERSION                   KERNEL_VERSION(0, 0x21, 3)
 
 #define CAMSYS_PLATFORM_DRV_NAME                "RockChip-CamSys"
 #define CAMSYS_PLATFORM_MARVIN_NAME             "Platform_MarvinDev"
@@ -304,7 +306,7 @@ typedef struct camsys_dev_s {
 static inline camsys_extdev_t *camsys_find_extdev(
 unsigned int dev_id, camsys_dev_t *camsys_dev)
 {
-       camsys_extdev_t *extdev;
+       camsys_extdev_t *extdev = NULL;
 
        if (!list_empty(&camsys_dev->extdevs.list)) {
                list_for_each_entry(extdev,
index 0018aed10c216777467fa18852e2d626bb841970..8373a951c89b40ce598a88e4132db14b1da96c7e 100755 (executable)
@@ -270,7 +270,7 @@ static int camsys_mrv_iommu_cb(void *ptr, camsys_sysctrl_t *devctl)
        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);
+               "rockchip,isp,iommu-enable", &iommu_enabled);
        if (iommu_enabled != 1) {
                camsys_err("isp iommu have not been enabled!\n");
                ret = -1;
@@ -388,6 +388,7 @@ static int camsys_mrv_clkin_cb(void *ptr, unsigned int on)
                                clk_prepare_enable(clk->pclk_dphytxrx);
 
                                clk_prepare_enable(clk->pclkin_isp);
+                               clk_prepare_enable(clk->cif_clk_out);
                        } else{
                                clk_set_rate(clk->clk_isp0, isp_clk);
                                clk_prepare_enable(clk->hclk_isp0_noc);
@@ -424,7 +425,6 @@ static int camsys_mrv_clkin_cb(void *ptr, unsigned int on)
                                clk_disable_unprepare(clk->pclk_dphy_ref);
 
                                clk_disable_unprepare(clk->pclkin_isp);
-
                        } else{
                                clk_disable_unprepare(clk->hclk_isp0_noc);
                                clk_disable_unprepare(clk->hclk_isp0_wrapper);
@@ -751,7 +751,14 @@ int camsys_mrv_probe_cb(struct platform_device *pdev, camsys_dev_t *camsys_dev)
 {
        int err = 0;
        camsys_mrv_clk_t *mrv_clk = NULL;
-       const char *compatible = NULL;
+       struct resource register_res;
+
+       err = of_address_to_resource(pdev->dev.of_node, 0, &register_res);
+       if (err < 0) {
+               camsys_err(
+                       "Get register resource from %s platform device failed!",
+                       pdev->name);
+       }
 
        err = request_irq(camsys_dev->irq.irq_id, camsys_mrv_irq,
                                        IRQF_SHARED, CAMSYS_MARVIN_IRQNAME,
@@ -809,68 +816,76 @@ int camsys_mrv_probe_cb(struct platform_device *pdev, camsys_dev_t *camsys_dev)
        } else if (CHIP_TYPE == 3399) {
 
                pm_runtime_enable(&pdev->dev);
-               mrv_clk->hclk_isp0_noc     =
-                       devm_clk_get(&pdev->dev, "hclk_isp0_noc");
-               mrv_clk->hclk_isp0_wrapper =
-                       devm_clk_get(&pdev->dev, "hclk_isp0_wrapper");
-               mrv_clk->aclk_isp0_noc     =
-                       devm_clk_get(&pdev->dev, "aclk_isp0_noc");
-               mrv_clk->aclk_isp0_wrapper =
-                       devm_clk_get(&pdev->dev, "aclk_isp0_wrapper");
-               mrv_clk->clk_isp0                  =
-                       devm_clk_get(&pdev->dev, "clk_isp0");
+               if (register_res.start == 0xff920000) {
+                       mrv_clk->hclk_isp1_noc     =
+                               devm_clk_get(&pdev->dev, "hclk_isp1_noc");
+                       mrv_clk->hclk_isp1_wrapper =
+                               devm_clk_get(&pdev->dev, "hclk_isp1_wrapper");
+                       mrv_clk->aclk_isp1_noc     =
+                               devm_clk_get(&pdev->dev, "aclk_isp1_noc");
+                       mrv_clk->aclk_isp1_wrapper =
+                               devm_clk_get(&pdev->dev, "aclk_isp1_wrapper");
+                       mrv_clk->clk_isp1                  =
+                               devm_clk_get(&pdev->dev, "clk_isp1");
+                       mrv_clk->pclkin_isp        =
+                               devm_clk_get(&pdev->dev, "pclk_isp1");
+                       mrv_clk->pclk_dphytxrx     =
+                               devm_clk_get(&pdev->dev, "pclk_dphytxrx");
+               }
+               else
+               {
+                       mrv_clk->hclk_isp0_noc     =
+                               devm_clk_get(&pdev->dev, "hclk_isp0_noc");
+                       mrv_clk->hclk_isp0_wrapper =
+                               devm_clk_get(&pdev->dev, "hclk_isp0_wrapper");
+                       mrv_clk->aclk_isp0_noc     =
+                               devm_clk_get(&pdev->dev, "aclk_isp0_noc");
+                       mrv_clk->aclk_isp0_wrapper =
+                               devm_clk_get(&pdev->dev, "aclk_isp0_wrapper");
+                       mrv_clk->clk_isp0                  =
+                               devm_clk_get(&pdev->dev, "clk_isp0");
+                       mrv_clk->pclk_dphyrx       =
+                               devm_clk_get(&pdev->dev, "pclk_dphyrx");
+               }
                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->pclk_dphy_ref     =
                        devm_clk_get(&pdev->dev, "pclk_dphy_ref");
-
-               mrv_clk->hclk_isp1_noc     =
-                       devm_clk_get(&pdev->dev, "hclk_isp1_noc");
-               mrv_clk->hclk_isp1_wrapper =
-                       devm_clk_get(&pdev->dev, "hclk_isp1_wrapper");
-               mrv_clk->aclk_isp1_noc     =
-                       devm_clk_get(&pdev->dev, "aclk_isp1_noc");
-               mrv_clk->aclk_isp1_wrapper =
-                       devm_clk_get(&pdev->dev, "aclk_isp1_wrapper");
-               mrv_clk->pclkin_isp        =
-                       devm_clk_get(&pdev->dev, "pclk_isp1");
-
-               mrv_clk->clk_isp1                  =
-                       devm_clk_get(&pdev->dev, "clk_isp1");
-               mrv_clk->pclk_dphytxrx     =
-                       devm_clk_get(&pdev->dev, "pclk_dphytxrx");
-
-               if (IS_ERR_OR_NULL(mrv_clk->hclk_isp0_noc)       ||
-                       IS_ERR_OR_NULL(mrv_clk->hclk_isp0_wrapper)   ||
-                       IS_ERR_OR_NULL(mrv_clk->aclk_isp0_noc)       ||
-                       IS_ERR_OR_NULL(mrv_clk->aclk_isp0_wrapper)   ||
-                       IS_ERR_OR_NULL(mrv_clk->clk_isp0)            ||
-                       IS_ERR_OR_NULL(mrv_clk->cif_clk_out)             ||
-                       IS_ERR_OR_NULL(mrv_clk->cif_clk_pll)         ||
-                       IS_ERR_OR_NULL(mrv_clk->pclk_dphyrx)) {
-                       camsys_err("Get %s clock resouce failed!\n",
-                               miscdev_name);
-                       err = -EINVAL;
-                       goto clk_failed;
-               }
-
-               err = of_property_read_string(pdev->dev.of_node,
-                       "compatible", &compatible);
-               if (err < 0) {
-                       camsys_err("get compatible failed!");
-               } else {
-                       camsys_trace(1, "compatible is %s\n", compatible);
+               if (register_res.start == 0xff920000) {
+                       if (IS_ERR_OR_NULL(mrv_clk->hclk_isp1_noc)       ||
+                               IS_ERR_OR_NULL(mrv_clk->hclk_isp1_wrapper)   ||
+                               IS_ERR_OR_NULL(mrv_clk->aclk_isp1_noc)       ||
+                               IS_ERR_OR_NULL(mrv_clk->aclk_isp1_wrapper)   ||
+                               IS_ERR_OR_NULL(mrv_clk->clk_isp1)            ||
+                               IS_ERR_OR_NULL(mrv_clk->cif_clk_out)         ||
+                               IS_ERR_OR_NULL(mrv_clk->cif_clk_pll)         ||
+                               IS_ERR_OR_NULL(mrv_clk->pclkin_isp)          ||
+                               IS_ERR_OR_NULL(mrv_clk->pclk_dphytxrx)) {
+                               camsys_err("Get %s clock resouce failed!\n",
+                                       miscdev_name);
+                               err = -EINVAL;
+                               goto clk_failed;
+                       }
                }
-               if (strstr(compatible, "isp1")) {
-                       clk_set_rate(mrv_clk->clk_isp1, 210000000);
-               } else{
-                       clk_set_rate(mrv_clk->clk_isp0, 210000000);
+               else
+               {
+                       if (IS_ERR_OR_NULL(mrv_clk->hclk_isp0_noc)       ||
+                               IS_ERR_OR_NULL(mrv_clk->hclk_isp0_wrapper)   ||
+                               IS_ERR_OR_NULL(mrv_clk->aclk_isp0_noc)       ||
+                               IS_ERR_OR_NULL(mrv_clk->aclk_isp0_wrapper)   ||
+                               IS_ERR_OR_NULL(mrv_clk->clk_isp0)            ||
+                               IS_ERR_OR_NULL(mrv_clk->cif_clk_out)         ||
+                               IS_ERR_OR_NULL(mrv_clk->cif_clk_pll)         ||
+                               IS_ERR_OR_NULL(mrv_clk->pclk_dphyrx)) {
+                               camsys_err("Get %s clock resouce failed!\n",
+                                       miscdev_name);
+                               err = -EINVAL;
+                               goto clk_failed;
+                       }
                }
-
+       clk_set_rate(mrv_clk->clk_isp0, 210000000);
        } else{
                mrv_clk->pd_isp           =
                        devm_clk_get(&pdev->dev, "pd_isp");
@@ -891,11 +906,11 @@ int camsys_mrv_probe_cb(struct platform_device *pdev, camsys_dev_t *camsys_dev)
                mrv_clk->clk_mipi_24m =
                        devm_clk_get(&pdev->dev, "clk_mipi_24m");
 
-               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)         ||
+               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->cif_clk_out) ||
                        IS_ERR_OR_NULL(mrv_clk->clk_mipi_24m)) {
@@ -929,7 +944,7 @@ int camsys_mrv_probe_cb(struct platform_device *pdev, camsys_dev_t *camsys_dev)
        camsys_dev->miscdev.fops = &camsys_fops;
 
        if (CHIP_TYPE == 3399) {
-               if (strstr(compatible, "isp1")) {
+               if (register_res.start == 0xff920000) {
                        camsys_dev->miscdev.name = "camsys_marvin1";
                        camsys_dev->miscdev.nodename = "camsys_marvin1";
                }