]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00225735-3 GPU: add gpu regulator disable/enable in gpu driver
authorRobin Gong <b38343@freescale.com>
Tue, 25 Sep 2012 08:47:48 +0000 (16:47 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:35:29 +0000 (08:35 +0200)
add gpu regulator management in gpu driver
Signed-off-by: Robin Gong <b38343@freescale.com>
Acked-by: Lily Zhang
Signed-off-by: Robin Gong <b38343@freescale.com>
drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.c
drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.h
drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_linux.h
drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c

index 890d13e17c50f5dd72dac70b91c4f89e3625c508..eba81b64be92f083fef4d62830e065f27d6c9796 100644 (file)
@@ -358,6 +358,15 @@ gckGALDEVICE_Construct(
                gckDebugFileSystemSetCurrentNode(device->dbgnode);
        }
     }
+    /*get gpu regulator*/
+    device->gpu_regulator = regulator_get(NULL, "cpu_vddgpu");
+    if (IS_ERR(device->gpu_regulator)) {
+       gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER,
+               "%s(%d): Failed to get gpu regulator  %s/%s \n",
+               __FUNCTION__, __LINE__,
+               PARENT_FILE, DEBUG_FILE);
+       gcmkONERROR(gcvSTATUS_NOT_FOUND);
+    }
 
     /*Initialize the clock structure*/
     if (IrqLine != -1) {
index 03f7f9b2201e8ec65bf95e57fde9e0270d99f9a2..c15989894600ec4723160aa56b5e19d9364d16b3 100644 (file)
@@ -89,6 +89,9 @@ typedef struct _gckGALDEVICE
     struct clk         *clk_2d_axi;
     struct clk         *clk_vg_axi;
 
+    /*Power management.*/
+    struct regulator      *gpu_regulator;
+
 }
 * gckGALDEVICE;
 
index 30fb13596dda62ea97917d7ed1666b3024f95053..a6ed03ffc0f950de120b3ccec274fa847fb926fe 100644 (file)
@@ -47,6 +47,7 @@
 
 #if ENABLE_GPU_CLOCK_BY_DRIVER && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
 #include <linux/clk.h>
+#include <linux/regulator/consumer.h>
 #endif
 
 #define NTSTRSAFE_NO_CCH_FUNCTIONS
index 4d1a71dfa91aa3beea89a175953daf77181341ea..4091ccdb61d42d059aa9926058fc30a97fbd5c70 100644 (file)
@@ -6947,6 +6947,7 @@ gckOS_SetGPUPower(
     struct clk *clk_vg_axi = Os->device->clk_vg_axi;
 
     gctBOOL oldClockState = gcvFALSE;
+    gctBOOL oldPowerState = gcvFALSE;
 
     gcmkHEADER_ARG("Os=0x%X Core=%d Clock=%d Power=%d", Os, Core, Clock, Power);
 
@@ -6956,15 +6957,20 @@ gckOS_SetGPUPower(
         if (Core == gcvCORE_VG)
         {
             oldClockState = Os->device->kernels[Core]->vg->hardware->clockState;
+            oldPowerState = Os->device->kernels[Core]->vg->hardware->powerState;
         }
         else
         {
 #endif
             oldClockState = Os->device->kernels[Core]->hardware->clockState;
+            oldPowerState = Os->device->kernels[Core]->hardware->powerState;
 #if gcdENABLE_VG
         }
 #endif
     }
+       if((Power == gcvTRUE) && (oldPowerState == gcvFALSE) &&
+               !IS_ERR(Os->device->gpu_regulator))
+            regulator_enable(Os->device->gpu_regulator);
 
     if (Clock == gcvTRUE) {
         if (oldClockState == gcvFALSE) {
@@ -7007,8 +7013,10 @@ gckOS_SetGPUPower(
             }
         }
     }
-
-
+       if((Power == gcvFALSE) && (oldPowerState == gcvTRUE) &&
+               !IS_ERR(Os->device->gpu_regulator))
+            regulator_disable(Os->device->gpu_regulator);
+    /* TODO: Put your code here. */
     gcmkFOOTER_NO();
     return gcvSTATUS_OK;
 }