diff options
author | Loren HUANG <b02279@freescle.com> | 2012-11-09 12:51:41 +0800 |
---|---|---|
committer | Loren Huang <b02279@freescale.com> | 2013-01-25 13:08:22 +0800 |
commit | ca2426a9529060636d40a262647093c3bf139486 (patch) | |
tree | 3a1a2ab60857b7c716b9db962916e6cc0466fbf1 /drivers/mxc/gpu-viv | |
parent | ebd9fef83f074c3483bc48c562dbbd92c9650b2d (diff) |
ENGR00240988-5 Update gpu code to support 3.5 kernel
Cherry-pick from imx_3.5.7 branch.
-Comment regulator setting code temperarily for 3.5 kernel.
-Adjust clock setting code based on new clock framework.
-Disable dynamic frequency change feature as it depends on thermal
driver.
-Use DTS to get reserved memory information.
-Comment cpu check code for 3.5 kernel.
-Comment GPU reset code for 3.5 kernel.
Signed-off-by: Loren HUANG <b02279@freescale.com>
Acked-by: Lily Zhang
Diffstat (limited to 'drivers/mxc/gpu-viv')
5 files changed, 132 insertions, 17 deletions
diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_options.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_options.h index 75d4c678d126..e7e148d5558c 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_options.h +++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_options.h @@ -161,7 +161,7 @@ When non-zero, FSCALE_VAL when gcvPOWER_ON can be adjusted externally. */ #ifndef gcdENABLE_FSCALE_VAL_ADJUST -# define gcdENABLE_FSCALE_VAL_ADJUST 1 +# define gcdENABLE_FSCALE_VAL_ADJUST 0 #endif /* diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.c index f3bb11064ad2..a5eed3539a6e 100644 --- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.c +++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.c @@ -304,6 +304,7 @@ gckGALDEVICE_Construct( IN gctUINT32 PhysSize, IN gctINT Signal, IN gctUINT LogFileSize, + IN struct device *pdev, OUT gckGALDEVICE *Device ) { @@ -358,8 +359,12 @@ gckGALDEVICE_Construct( gckDebugFileSystemSetCurrentNode(device->dbgnode); } } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) + device->gpu_regulator =(struct regulator*)0xffffffff ; + +#else /*get gpu regulator*/ - device->gpu_regulator = regulator_get(NULL, "cpu_vddgpu"); + device->gpu_regulator = regulator_get(pdev, "cpu_vddgpu"); if (IS_ERR(device->gpu_regulator)) { gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER, "%s(%d): Failed to get gpu regulator %s/%s \n", @@ -367,13 +372,14 @@ gckGALDEVICE_Construct( PARENT_FILE, DEBUG_FILE); gcmkONERROR(gcvSTATUS_NOT_FOUND); } - +#endif /*Initialize the clock structure*/ if (IrqLine != -1) { - device->clk_3d_core = clk_get(NULL, "gpu3d_clk"); + device->clk_3d_core = clk_get(pdev, "gpu3d_clk"); if (!IS_ERR(device->clk_3d_core)) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) if (cpu_is_mx6q()) { - device->clk_3d_shader = clk_get(NULL, "gpu3d_shader_clk"); + device->clk_3d_shader = clk_get(pdev, "gpu3d_shader_clk"); if (IS_ERR(device->clk_3d_shader)) { IrqLine = -1; clk_put(device->clk_3d_core); @@ -381,7 +387,18 @@ gckGALDEVICE_Construct( device->clk_3d_shader = NULL; gckOS_Print("galcore: clk_get gpu3d_shader_clk failed, disable 3d!\n"); } - } + } +#else + device->clk_3d_axi = clk_get(pdev, "gpu3d_axi_clk"); + device->clk_3d_shader = clk_get(pdev, "gpu3d_shader_clk"); + if (IS_ERR(device->clk_3d_shader)) { + IrqLine = -1; + clk_put(device->clk_3d_core); + device->clk_3d_core = NULL; + device->clk_3d_shader = NULL; + gckOS_Print("galcore: clk_get gpu3d_shader_clk failed, disable 3d!\n"); + } +#endif } else { IrqLine = -1; device->clk_3d_core = NULL; @@ -389,7 +406,7 @@ gckGALDEVICE_Construct( } } if ((IrqLine2D != -1) || (IrqLineVG != -1)) { - device->clk_2d_core = clk_get(NULL, "gpu2d_clk"); + device->clk_2d_core = clk_get(pdev, "gpu2d_clk"); if (IS_ERR(device->clk_2d_core)) { IrqLine2D = -1; IrqLineVG = -1; @@ -397,7 +414,7 @@ gckGALDEVICE_Construct( gckOS_Print("galcore: clk_get 2d core clock failed, disable 2d/vg!\n"); } else { if (IrqLine2D != -1) { - device->clk_2d_axi = clk_get(NULL, "gpu2d_axi_clk"); + device->clk_2d_axi = clk_get(pdev, "gpu2d_axi_clk"); if (IS_ERR(device->clk_2d_axi)) { device->clk_2d_axi = NULL; IrqLine2D = -1; @@ -405,7 +422,7 @@ gckGALDEVICE_Construct( } } if (IrqLineVG != -1) { - device->clk_vg_axi = clk_get(NULL, "openvg_axi_clk"); + device->clk_vg_axi = clk_get(pdev, "openvg_axi_clk"); if (IS_ERR(device->clk_vg_axi)) { IrqLineVG = -1; device->clk_vg_axi = NULL; @@ -1000,6 +1017,12 @@ gckGALDEVICE_Destroy( } /*Disable clock*/ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) + if (Device->clk_3d_axi) { + clk_put(Device->clk_3d_axi); + Device->clk_3d_axi = NULL; + } +#endif if (Device->clk_3d_core) { clk_put(Device->clk_3d_core); Device->clk_3d_core = NULL; diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.h b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.h index c15989894600..1635ff690db7 100644 --- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.h +++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_device.h @@ -85,6 +85,7 @@ typedef struct _gckGALDEVICE /* Clock management.*/ struct clk *clk_3d_core; struct clk *clk_3d_shader; + struct clk *clk_3d_axi; struct clk *clk_2d_core; struct clk *clk_2d_axi; struct clk *clk_vg_axi; @@ -164,6 +165,7 @@ gceSTATUS gckGALDEVICE_Construct( IN gctUINT32 PhysSize, IN gctINT Signal, IN gctUINT LogFileSize, + IN struct device *pdev, OUT gckGALDEVICE *Device ); 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 9683cb7bedcf..4da49fe3c7b0 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,8 +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" @@ -43,6 +41,10 @@ # include <linux/resmem_account.h> #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) +#include <mach/viv_gpu.h> +#endif + /* Zone used for header/footer. */ #define _GC_OBJ_ZONE gcvZONE_DRIVER @@ -685,7 +687,7 @@ OnError: #if !USE_PLATFORM_DRIVER static int __init drv_init(void) #else -static int drv_init(void) +static int drv_init(struct device *pdev) #endif { int ret; @@ -792,6 +794,7 @@ static int drv_init(void) contiguousBase, contiguousSize, bankSize, fastClear, compression, baseAddress, physSize, signal, logFileSize, + pdev, &device )); @@ -953,8 +956,12 @@ static int __devinit gpu_probe(struct platform_device *pdev) { int ret = -ENODEV; struct resource* res; - struct viv_gpu_platform_data *pdata; - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) + struct device_node *dn =pdev->dev.of_node; + const u32 *prop; +#else + struct viv_gpu_platform_data *pdata; +#endif gcmkHEADER(); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phys_baseaddr"); @@ -994,13 +1001,21 @@ static int __devinit gpu_probe(struct platform_device *pdev) registerMemSizeVG = res->end - res->start + 1; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) + prop = of_get_property(dn, "contiguousbase", NULL); + if(prop) + contiguousBase = *prop; + of_property_read_u32(dn,"contiguoussize", (u32 *)&contiguousSize); +#else pdata = pdev->dev.platform_data; if (pdata) { contiguousBase = pdata->reserved_mem_base; contiguousSize = pdata->reserved_mem_size; } - - ret = drv_init(); +#endif + if (contiguousSize == 0) + gckOS_Print("Warning: No contiguous memory is reserverd for gpu.!\n "); + ret = drv_init(&pdev->dev); if (!ret) { @@ -1143,6 +1158,14 @@ static int __devinit gpu_resume(struct platform_device *dev) return 0; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) +static const struct of_device_id mxs_gpu_dt_ids[] = { + { .compatible = "fsl,imx6q-gpu", }, + {/* sentinel */} +}; +MODULE_DEVICE_TABLE(of, mxs_gpu_dt_ids); +#endif + static struct platform_driver gpu_driver = { .probe = gpu_probe, .remove = gpu_remove, @@ -1152,6 +1175,9 @@ static struct platform_driver gpu_driver = { .driver = { .name = DEVICE_NAME, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) + .of_match_table = mxs_gpu_dt_ids, +#endif } }; diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c index f4843e5abe56..e9e4e07106a6 100644 --- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c +++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c @@ -6709,6 +6709,9 @@ gckOS_SetGPUPower( { struct clk *clk_3dcore = Os->device->clk_3d_core; struct clk *clk_3dshader = Os->device->clk_3d_shader; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) + struct clk *clk_3d_axi = Os->device->clk_3d_axi; +#endif struct clk *clk_2dcore = Os->device->clk_2d_core; struct clk *clk_2d_axi = Os->device->clk_2d_axi; struct clk *clk_vg_axi = Os->device->clk_vg_axi; @@ -6739,6 +6742,7 @@ gckOS_SetGPUPower( !IS_ERR(Os->device->gpu_regulator)) regulator_enable(Os->device->gpu_regulator); +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) if (Clock == gcvTRUE) { if (oldClockState == gcvFALSE) { switch (Core) { @@ -6780,6 +6784,65 @@ gckOS_SetGPUPower( } } } +#else + if (Clock == gcvTRUE) { + if (oldClockState == gcvFALSE) { + switch (Core) { + case gcvCORE_MAJOR: + clk_prepare(clk_3dcore); + clk_enable(clk_3dcore); + /*if (cpu_is_mx6q())*/ + clk_prepare(clk_3dshader); + clk_enable(clk_3dshader); + clk_prepare(clk_3d_axi); + clk_enable(clk_3d_axi); + break; + case gcvCORE_2D: + clk_prepare(clk_2dcore); + clk_enable(clk_2dcore); + clk_prepare(clk_2d_axi); + clk_enable(clk_2d_axi); + break; + case gcvCORE_VG: + clk_prepare(clk_2dcore); + clk_enable(clk_2dcore); + clk_prepare(clk_vg_axi); + clk_enable(clk_vg_axi); + break; + default: + break; + } + } + } else { + if (oldClockState == gcvTRUE) { + switch (Core) { + case gcvCORE_MAJOR: + /*if (cpu_is_mx6q())*/ + clk_disable(clk_3dshader); + clk_unprepare(clk_3dshader); + clk_disable(clk_3dcore); + clk_unprepare(clk_3dcore); + clk_disable(clk_3d_axi); + clk_unprepare(clk_3d_axi); + break; + case gcvCORE_2D: + clk_disable(clk_2dcore); + clk_unprepare(clk_2dcore); + clk_disable(clk_2d_axi); + clk_unprepare(clk_2d_axi); + break; + case gcvCORE_VG: + clk_disable(clk_2dcore); + clk_unprepare(clk_2dcore); + clk_disable(clk_vg_axi); + clk_unprepare(clk_vg_axi); + break; + default: + break; + } + } + } +#endif if((Power == gcvFALSE) && (oldPowerState == gcvTRUE) && !IS_ERR(Os->device->gpu_regulator)) regulator_disable(Os->device->gpu_regulator); @@ -6815,7 +6878,7 @@ gckOS_ResetGPU( #define SRC_SCR_OFFSET 0 #define BP_SRC_SCR_GPU3D_RST 1 #define BP_SRC_SCR_GPU2D_RST 4 - +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) void __iomem *src_base = IO_ADDRESS(SRC_BASE_ADDR); gctUINT32 bit_offset,val; @@ -6839,6 +6902,7 @@ gckOS_ResetGPU( } gcmkFOOTER_NO(); +#endif return gcvSTATUS_OK; } |