add rga 3288 dts/modify rga2 driver
authorzsq <zsq@rock-chips.com>
Sat, 1 Mar 2014 08:39:31 +0000 (16:39 +0800)
committerzsq <zsq@rock-chips.com>
Sat, 1 Mar 2014 08:39:31 +0000 (16:39 +0800)
arch/arm/boot/dts/rk3288.dtsi
drivers/video/rockchip/rga/rga_drv.c
drivers/video/rockchip/rga2/rga2_drv.c

index 6469a084be744b64974dc746de1adfd19300934b..28a7b2dfb8c0944fb5528f33386ba3d0c428eb23 100755 (executable)
                rockchip,wake-irq = <0>;
                status = "disabled";
        };
+       
+       rga@ff930000 {
+               compatible = "rockchip,rga";
+               reg = <0xff930000 0x1000>;
+               interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&clk_gates6 10>, <&clk_gates6 11>;
+    clock-names = "hclk_rga", "aclk_rga"; 
+               status = "disabled";
+        };
 };
index 15d20b64511f21b356085ee7504155615aeb8320..53f685b823d7257dae11646d4f22a5bdfb0af659 100755 (executable)
@@ -1209,7 +1209,7 @@ err_irq:
        iounmap(data->rga_base);\r
 err_ioremap:\r
        wake_lock_destroy(&data->wake_lock);\r
-       kfree(data);\r
+       //kfree(data);\r
 \r
        return ret;\r
 }\r
index 2dce2f46a7d28b228df4c9a9c83fb06da1e6afc2..c6a6046f309177339543a0853d0beb944d5bd90b 100644 (file)
 \r
 #define RGA2_MAJOR             255\r
 \r
-#if defined(CONFIG_ROCKCHIP_RGA2)\r
-#define RK32_RGA2_PHYS         0xFFC70000\r
-#define RK32_RGA2_SIZE         0x00001000\r
-#endif\r
 #define RGA2_RESET_TIMEOUT     1000\r
 \r
 /* Driver information */\r
@@ -256,10 +252,10 @@ static void rga2_power_on(void)
        if (rga2_service.enable)\r
                return;\r
 \r
-    clk_enable(rga2_drvdata->rga2);\r
+    //clk_enable(rga2_drvdata->rga2);\r
        clk_enable(rga2_drvdata->aclk_rga2);\r
        clk_enable(rga2_drvdata->hclk_rga2);\r
-       clk_enable(rga2_drvdata->pd_rga2);\r
+       //clk_enable(rga2_drvdata->pd_rga2);\r
        wake_lock(&rga2_drvdata->wake_lock);\r
        rga2_service.enable = true;\r
 }\r
@@ -281,8 +277,8 @@ static void rga2_power_off(void)
                rga2_dump();\r
        }\r
 \r
-       clk_disable(rga2_drvdata->pd_rga2);\r
-    clk_disable(rga2_drvdata->rga2);\r
+       //clk_disable(rga2_drvdata->pd_rga2);\r
+    //clk_disable(rga2_drvdata->rga2);\r
        clk_disable(rga2_drvdata->aclk_rga2);\r
        clk_disable(rga2_drvdata->hclk_rga2);\r
        wake_unlock(&rga2_drvdata->wake_lock);\r
@@ -999,9 +995,16 @@ static struct miscdevice rga2_dev ={
     .fops  = &rga2_fops,\r
 };\r
 \r
+static const struct of_device_id rockchip_rga_of_match[] = {\r
+       { .compatible = "rockchip,rga", .data = NULL, },\r
+       {},\r
+};\r
+\r
 static int __devinit rga2_drv_probe(struct platform_device *pdev)\r
 {\r
        struct rga2_drvdata_t *data;\r
+    struct resource *res;\r
+    struct device_node *np = pdev->dev.of_node;\r
        int ret = 0;\r
 \r
        INIT_LIST_HEAD(&rga2_service.waiting);\r
@@ -1015,7 +1018,7 @@ static int __devinit rga2_drv_probe(struct platform_device *pdev)
        rga2_service.last_prc_src_format = 1; /* default is yuv first*/\r
        rga2_service.enable = false;\r
 \r
-       data = kzalloc(sizeof(struct rga2_drvdata_t), GFP_KERNEL);\r
+       data = devm_kzalloc(&pdev->dev, sizeof(struct rga2_drvdata_t), GFP_KERNEL);\r
        if(NULL == data)\r
        {\r
                ERR("failed to allocate driver data.\n");\r
@@ -1025,21 +1028,18 @@ static int __devinit rga2_drv_probe(struct platform_device *pdev)
        INIT_DELAYED_WORK(&data->power_off_work, rga2_power_off_work);\r
        wake_lock_init(&data->wake_lock, WAKE_LOCK_SUSPEND, "rga");\r
 \r
-       data->pd_rga2 = clk_get(NULL, "pd_rga");\r
-    data->rga2 = clk_get(NULL, "rga");\r
-       data->aclk_rga2 = clk_get(NULL, "aclk_rga");\r
-       data->hclk_rga2 = clk_get(NULL, "hclk_rga");\r
+       //data->pd_rga2 = clk_get(NULL, "pd_rga");\r
+    //data->rga2 = clk_get(NULL, "rga");\r
+       data->aclk_rga = devm_clk_get(&pdev->dev, "aclk_rga");\r
+    data->hclk_rga = devm_clk_get(&pdev->dev, "hclk_rga");\r
 \r
-       /* map the memory */\r
-       if (!request_mem_region(RK32_RGA2_PHYS, RK32_RGA2_SIZE, "rga_io"))\r
-       {\r
-               pr_info("failed to reserve rga HW regs\n");\r
-               return -EBUSY;\r
-       }\r
+    clk_prepare_enable(data->aclk_rga);\r
+    clk_prepare_enable(data->hclk_rga);\r
 \r
-       data->rga_base = (void*)ioremap_nocache(RK32_RGA2_PHYS, RK32_RGA2_SIZE);\r
-       if (data->rga_base == NULL)\r
-       {\r
+       /* map the registers */\r
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);\r
+       data->rga_base = devm_ioremap_resource(&pdev->dev, res);\r
+       if (!data->rga_base) {\r
                ERR("rga ioremap failed\n");\r
                ret = -ENOENT;\r
                goto err_ioremap;\r
@@ -1047,15 +1047,14 @@ static int __devinit rga2_drv_probe(struct platform_device *pdev)
 \r
        /* get the IRQ */\r
        data->irq = platform_get_irq(pdev, 0);\r
-       if (data->irq <= 0)\r
-       {\r
+       if (data->irq <= 0) {\r
                ERR("failed to get rga irq resource (%d).\n", data->irq);\r
                ret = data->irq;\r
                goto err_irq;\r
        }\r
 \r
        /* request the IRQ */\r
-       ret = request_threaded_irq(data->irq, rga2_irq, rga2_irq_thread, 0, "rga", pdev);\r
+       ret = devm_request_threaded_irq(&pdev->dev, data->irq, rga2_irq, rga2_irq_thread, 0, "rga", pdev);\r
        if (ret)\r
        {\r
                ERR("rga request_irq failed (%d).\n", ret);\r
@@ -1082,7 +1081,7 @@ err_irq:
        iounmap(data->rga_base);\r
 err_ioremap:\r
        wake_lock_destroy(&data->wake_lock);\r
-       kfree(data);\r
+       //kfree(data);\r
 \r
        return ret;\r
 }\r
@@ -1097,8 +1096,11 @@ static int rga2_drv_remove(struct platform_device *pdev)
        free_irq(data->irq, &data->miscdev);\r
        iounmap((void __iomem *)(data->rga_base));\r
 \r
-       clk_put(data->pd_rga2);\r
-    clk_put(data->rga2);\r
+    clk_disable_unprepare(data->aclk_rga);\r
+    clk_disable_unprepare(data->hclk_rga);\r
+\r
+       //clk_put(data->pd_rga2);\r
+    //clk_put(data->rga2);\r
        clk_put(data->aclk_rga2);\r
        clk_put(data->hclk_rga2);\r
 \r