From: Sundar Raman Date: Thu, 18 Jul 2013 22:40:57 +0000 (-0500) Subject: gc320: Adapt GC320 driver for K3.8 X-Git-Tag: android-3.8-6AJ.1.1~18^2^2~5 X-Git-Url: https://git.ti.com/gitweb?p=android-sdk%2Fkernel-video.git;a=commitdiff_plain;h=0ce75959352b4cc7ca4779b7706aa4590fc0d39b gc320: Adapt GC320 driver for K3.8 Modified SOC checks and a few other minor changes. Change-Id: I426c2f017bea0384c7602dd50c0b558329d79b1a Signed-off-by: Sundar Raman --- diff --git a/drivers/misc/gcx/gcbv/gcmain.c b/drivers/misc/gcx/gcbv/gcmain.c index aa8be6601ba..c9d7e8feb96 100644 --- a/drivers/misc/gcx/gcbv/gcmain.c +++ b/drivers/misc/gcx/gcbv/gcmain.c @@ -13,9 +13,6 @@ */ #include "gcbv.h" -#include -#include - /******************************************************************************* * BLTsville interface exposure. @@ -244,9 +241,10 @@ static int __init mod_init(void) { bv_init(); - /* Assign BV function parameters only if SoC contains a GC core */ - if (cpu_is_omap447x()) + if (gc_is_hw_present()) gcbv_assign(); + else + GCERR("gcx hardware is not present\n"); return 0; } diff --git a/drivers/misc/gcx/gccore/gcmain.c b/drivers/misc/gcx/gccore/gcmain.c index 26939ed0e0d..2cc723451ab 100644 --- a/drivers/misc/gcx/gccore/gcmain.c +++ b/drivers/misc/gcx/gccore/gcmain.c @@ -17,13 +17,13 @@ #include #include #include -#include #include #include -#include -#include +#include #include "gcmain.h" + + #define GCZONE_NONE 0 #define GCZONE_ALL (~0U) #define GCZONE_INIT (1 << 0) @@ -188,11 +188,12 @@ void gc_write_reg(unsigned int address, unsigned int data) static void gcpwr_enable_clock(struct gccorecontext *gccorecontext) { - bool ctxlost; + int ctxlost; GCENTER(GCZONE_POWER); ctxlost = gccorecontext->plat->get_context_loss_count(gccorecontext->device); + GCDBG(GCZONE_POWER, "lost count = %d\n", ctxlost); if (!gccorecontext->clockenabled) { /* Enable the clock. */ @@ -217,6 +218,7 @@ static void gcpwr_enable_clock(struct gccorecontext *gccorecontext) if (ctxlost || (gccorecontext->gcpower == GCPWR_UNKNOWN)) gcpwr_reset(gccorecontext); + GCEXIT(GCZONE_POWER); } @@ -235,6 +237,9 @@ static void gcpwr_disable_clock(struct gccorecontext *gccorecontext) /* Clock disabled. */ gccorecontext->clockenabled = false; + + /* Reset the current pipe. */ + gccorecontext->gcpipe = GCPWR_UNKNOWN; } GCDBG(GCZONE_POWER, "clock %s.\n", @@ -249,6 +254,9 @@ static void gcpwr_scale(struct gccorecontext *gccorecontext, int index) GCENTERARG(GCZONE_FREQSCALE, "index=%d\n", index); + if (gccorecontext->opp_count == 0) + goto exit; + if ((index < 0) || (index >= gccorecontext->opp_count)) { GCERR("invalid index %d.\n", index); goto exit; @@ -260,6 +268,7 @@ static void gcpwr_scale(struct gccorecontext *gccorecontext, int index) goto exit; } + if (gccorecontext->cur_freq == gccorecontext->opp_freqs[index]) goto exit; @@ -493,6 +502,13 @@ unsigned int gcpwr_get_speed(void) * Public API. */ +bool gc_is_hw_present(void) +{ + struct gccorecontext *gccorecontext = &g_context; + return gccorecontext->plat->is_hw_present; +} + + void gc_caps(struct gcicaps *gcicaps) { struct gccorecontext *gccorecontext = &g_context; @@ -871,22 +887,30 @@ done: static int gc_probe(struct platform_device *pdev) { struct gccorecontext *gccorecontext = &g_context; + int ret; GCENTER(GCZONE_PROBE); gccorecontext->bb2ddevice = &pdev->dev; gccorecontext->plat = (struct omap_gcx_platform_data *) pdev->dev.platform_data; + + if (!gccorecontext->plat->is_hw_present) { + GCERR("gc_probe failed. gcx hardware is not present\n"); + return -ENODEV; + } + gccorecontext->regbase = gccorecontext->plat->regbase; gccorecontext->irqline = platform_get_irq(pdev, pdev->id); gccorecontext->device = &pdev->dev; + pm_runtime_enable(gccorecontext->device); gccorecontext->plat->get_context_loss_count(gccorecontext->device); gc_probe_opp(pdev); - pm_runtime_get_sync(gccorecontext->device); + ret = pm_runtime_get_sync(gccorecontext->device); gccorecontext->gcmodel = gc_read_reg(GC_CHIP_ID_Address); gccorecontext->gcrevision = gc_read_reg(GC_CHIP_REV_Address); @@ -987,12 +1011,6 @@ static int gc_init(struct gccorecontext *gccorecontext) GCENTER(GCZONE_INIT); - /* check if hardware is available */ - if (!cpu_is_omap447x()) { - GCDBG(GCZONE_INIT, "gcx hardware is not present\n"); - goto exit; - } - /* Initialize data structutres. */ GCLOCK_INIT(&gccorecontext->powerlock); GCLOCK_INIT(&gccorecontext->resetlock); @@ -1003,13 +1021,6 @@ static int gc_init(struct gccorecontext *gccorecontext) /* Pulse skipping isn't known. */ gccorecontext->pulseskipping = -1; - /* Initialize MMU. */ - if (gcmmu_init(gccorecontext) != GCERR_NONE) { - GCERR("failed to initialize MMU.\n"); - result = -EINVAL; - goto fail; - } - result = platform_driver_register(&plat_drv); if (result < 0) { GCERR("failed to register platform driver.\n"); @@ -1017,6 +1028,13 @@ static int gc_init(struct gccorecontext *gccorecontext) } gccorecontext->platdriver = true; + /* Initialize MMU. */ + if (gcmmu_init(gccorecontext) != GCERR_NONE) { + GCERR("failed to initialize MMU.\n"); + result = -EINVAL; + goto fail; + } + #if CONFIG_HAS_EARLYSUSPEND register_early_suspend(&early_suspend_info); #endif @@ -1031,7 +1049,6 @@ static int gc_init(struct gccorecontext *gccorecontext) /* Create debugfs entry. */ gc_debug_init(); -exit: GCEXIT(GCZONE_INIT); return 0; @@ -1046,7 +1063,7 @@ static void gc_exit(struct gccorecontext *gccorecontext) { GCENTER(GCZONE_INIT); - if (cpu_is_omap447x()) { + if (gc_is_hw_present()) { /* Stop command queue thread. */ gcqueue_stop(gccorecontext); @@ -1094,6 +1111,7 @@ static void __exit gc_exit_wrapper(void) GCDBG_EXIT(); } + MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("www.vivantecorp.com"); MODULE_AUTHOR("www.ti.com"); diff --git a/drivers/misc/gcx/gcioctl/gcif.c b/drivers/misc/gcx/gcioctl/gcif.c index 262522c5084..267ada8bab8 100644 --- a/drivers/misc/gcx/gcioctl/gcif.c +++ b/drivers/misc/gcx/gcioctl/gcif.c @@ -945,10 +945,12 @@ static struct device *dev_object; static int dev_open(struct inode *inode, struct file *file) { - if (cpu_is_omap447x()) + if (gc_is_hw_present()) { return 0; - else - return -1; + } else { + GCERR("gcx hardware is not present\n"); + return -ENODEV; + } } static int dev_release(struct inode *inode, struct file *file) diff --git a/include/linux/gccore.h b/include/linux/gccore.h index ce9ed4fb75e..ae64f2f75c6 100644 --- a/include/linux/gccore.h +++ b/include/linux/gccore.h @@ -18,6 +18,10 @@ #include "sched.h" #include "gcioctl.h" + +/* Hw availability query */ +bool gc_is_hw_present(void); + /* Capability query. */ void gc_caps(struct gcicaps *gcicaps);