gpu-viv: convert to device tree and fix build errors

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 263e8f3..5649dd1 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -571,5 +571,15 @@
 				status = "disabled";
 			};
 		};
+
+		galcore@virtual {
+			compatible = "viv,galcore";
+			reg = <0x00130000 0x4000>, /* gc2000 */
+			      <0x00134000 0x4000>, /* gc320 */
+			      <0x02204000 0x4000>; /* gc355 */
+			interrupts = <0 9 0x04	 /* gc2000 */
+				      0 10 0x04  /* gc320 */
+				      0 11 0x04>; /* gc355 */
+		};
 	};
 };
diff --git a/drivers/mxc/gpu-viv/Kconfig b/drivers/mxc/gpu-viv/Kconfig
index 682d8ed..e9cc4b2 100644
--- a/drivers/mxc/gpu-viv/Kconfig
+++ b/drivers/mxc/gpu-viv/Kconfig
@@ -1,5 +1,5 @@
 menu "MXC Vivante GPU support"
-	depends on ARCH_MX6
+	depends on SOC_IMX6Q
 
 config MXC_GPU_VIV
 	tristate "MXC Vivante GPU support"
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_debug.h b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_debug.h
index a9b633e..af2785f 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_debug.h
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_debug.h
@@ -46,7 +46,7 @@
     va_end(Arguments)
 
 #define gcmkDECLARE_LOCK(__spinLock__) \
-    static spinlock_t __spinLock__ = SPIN_LOCK_UNLOCKED;
+    static DEFINE_SPINLOCK(__spinLock__)
 
 #define gcmkLOCKSECTION(__spinLock__) \
     spin_lock(&__spinLock__)
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c
index e7cc92f..4262e32 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c
@@ -24,7 +24,6 @@
 
 #include <linux/device.h>
 #include <linux/slab.h>
-#include <mach/viv_gpu.h>
 
 #include "gc_hal_kernel_linux.h"
 #include "gc_hal_driver.h"
@@ -944,49 +943,48 @@
 {
     int ret = -ENODEV;
     struct resource* res;
-    struct viv_gpu_platform_data *pdata;
 
     gcmkHEADER();
 
-    res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq_3d");
-    if (res)
-        irqLine = res->start;
+    ret = platform_get_irq(pdev, 0);
+    if (ret >= 0)
+        irqLine = ret;
 
-    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "iobase_3d");
+    res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
     if (res)
     {
         registerMemBase = res->start;
         registerMemSize = res->end - res->start + 1;
     }
 
-    res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq_2d");
-    if (res)
-        irqLine2D = res->start;
+    ret = platform_get_irq(pdev, 1);
+    if (ret >= 0)
+        irqLine2D = ret;
 
-    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "iobase_2d");
+    res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
     if (res)
     {
         registerMemBase2D = res->start;
         registerMemSize2D = res->end - res->start + 1;
     }
 
-    res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq_vg");
-    if (res)
-        irqLineVG = res->start;
+    ret = platform_get_irq(pdev, 2);
+    if (ret >= 0)
+        irqLineVG = ret;
 
-    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "iobase_vg");
+    res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
     if (res)
     {
         registerMemBaseVG = res->start;
         registerMemSizeVG = res->end - res->start + 1;
     }
-
+#if 0
     pdata = pdev->dev.platform_data;
     if (pdata) {
         contiguousBase = pdata->reserved_mem_base;
         contiguousSize = pdata->reserved_mem_size;
      }
-
+#endif
     ret = drv_init();
 
     if (!ret)
@@ -1076,6 +1074,10 @@
     return 0;
 }
 
+static const struct of_device_id gpu_viv_dt_ids[] = {
+	{ .compatible = "viv,galcore", },
+	{ /* sentinel */ }
+};
 static struct platform_driver gpu_driver = {
     .probe      = gpu_probe,
     .remove     = gpu_remove,
@@ -1084,6 +1086,7 @@
     .resume     = gpu_resume,
 
     .driver     = {
+	.of_match_table = gpu_viv_dt_ids,
         .name   = DEVICE_NAME,
     }
 };