fix mali for ttab
authorStricted <info@stricted.net>
Fri, 22 Feb 2019 12:21:37 +0000 (12:21 +0000)
committerStricted <info@stricted.net>
Fri, 22 Feb 2019 17:02:37 +0000 (17:02 +0000)
14 files changed:
drivers/misc/mediatek/gpu/ged/src/ged_bridge.c
drivers/misc/mediatek/gpu/ged/src/ged_dvfs.c
drivers/misc/mediatek/gpu/ged/src/ged_hal.c
drivers/misc/mediatek/gpu/ged/src/ged_main.c
drivers/misc/mediatek/gpu/ged/src/ged_mm.c
drivers/misc/mediatek/gpu/ged/src/ged_monitor_3D_fence.c
drivers/misc/mediatek/gpu/ged/src/ged_notify_sw_vsync.c
drivers/misc/mediatek/gpu/hal/mtk_gpu_utility.c
drivers/misc/mediatek/gpu/mt8127/mali/mali/common/mali_hw_core.h
drivers/misc/mediatek/gpu/mt8127/mali/mali/common/mali_kernel_common.h
drivers/misc/mediatek/gpu/mt8127/mali/mali/linux/mali_kernel_linux.c
drivers/misc/mediatek/gpu/mt8127/mali/mali/linux/mali_osk_misc.c
drivers/misc/mediatek/gpu/mt8127/mali/mali/platform/platform.c
drivers/misc/mediatek/gpu/mt8127/mali/mali/platform/platform_pmm.c

index 435ef78e7f0c1aed09cdbb524a8556730a974c55..6b14b2ad3d48410ff5e62a66d4a5cd6ecf71b6d2 100644 (file)
@@ -1,5 +1,5 @@
 #include <linux/kernel.h>
-#include <mt-plat/mtk_gpu_utility.h>
+#include <linux/mtk_gpu_utility.h>
 
 #include "ged_base.h"
 #include "ged_bridge.h"
index 6e7f13bf4602f6b5626906f88ae6cd98eda04663..4a5838ed258770016c73a749cd8832fdaaf40e74 100644 (file)
@@ -7,7 +7,7 @@
 #endif
 
 #include <trace/events/mtk_events.h>
-#include <mt-plat/mtk_gpu_utility.h>
+#include <linux/mtk_gpu_utility.h>
 
 #include <asm/siginfo.h>
 #include <linux/sched.h>
index a05eb5c1ecc8412f953b60ccf2c90ef9a697a00d..62ed53d63d74970237ffaab31e33bf8ef7b78539 100644 (file)
@@ -8,7 +8,7 @@
 //#include <linux/xlog.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
-#include <mt-plat/mtk_gpu_utility.h>
+#include <linux/mtk_gpu_utility.h>
 
 #include "ged_base.h"
 #include "ged_hal.h"
index bf563493de104422b12ec316c77154cfb8763a37..e61f14fc6b563032a1c53373311dea08c9464dff 100644 (file)
@@ -26,7 +26,7 @@
 #include <linux/semaphore.h>
 #include <linux/workqueue.h>
 #include <linux/kthread.h>
-#include <mt-plat/aee.h>
+#include <linux/aee.h>
 
 #include "ged_debugFS.h"
 #include "ged_log.h"
index caa4dda9d3f11fb31393c09921f5cdf953045158..4a855ae7ba9319ec043bf5326a22a8af98bc71d3 100644 (file)
@@ -10,7 +10,7 @@
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
-#include <mt-plat/mtk_gpu_utility.h>
+#include <linux/mtk_gpu_utility.h>
 
 #include "ged_base.h"
 #include "ged_mm.h"
index 4057441d8f32114d7fe1a45b876a7221b12d9a4c..2adc96172ebb13c848b56bd3b89cc5b460fa851c 100644 (file)
@@ -10,7 +10,7 @@
 #include <../drivers/staging/android/sync.h>
 #endif
 
-#include <mt-plat/mtk_gpu_utility.h>
+#include <linux/mtk_gpu_utility.h>
 #include <trace/events/gpu.h>
 #ifdef GED_DVFS_ENABLE
 #include <mt_gpufreq.h>
index f77c15d397ec370308f19362d41a49abdaeecebb..7eb3ba29548d91525a1e26533a4e94a4f951a77b 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <asm/div64.h>
 
-#include <mt-plat/mtk_gpu_utility.h>
+#include <linux/mtk_gpu_utility.h>
 #include "ged_notify_sw_vsync.h"
 #include "ged_log.h"
 #include "ged_base.h"
index e7ecb1e546a17fa391e8a9d8364dd042bc36c924..a103826701ef70f2e452b609911666eb598c07be 100644 (file)
@@ -1,6 +1,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <mt-plat/mtk_gpu_utility.h>
+#include <linux/mtk_gpu_utility.h>
 
 unsigned int (*mtk_get_gpu_memory_usage_fp)(void) = NULL;
 EXPORT_SYMBOL(mtk_get_gpu_memory_usage_fp);
index fc780903f93518a5e38ff9b1583023e91215b38c..c82675c264fb5228bffb5211935af5311c34b01d 100644 (file)
@@ -26,7 +26,7 @@ struct mali_hw_core {
        const char *description;          /**< Name of unit (as specified in device configuration) */
 };
 
-#define MALI_REG_POLL_COUNT_FAST 1000000
+#define MALI_REG_POLL_COUNT_FAST 1000
 #define MALI_REG_POLL_COUNT_SLOW 1000000
 
 /*
index 38b10035d200910de5d0756d9f3357c848bdecf5..7725779c8d8756a0cce524f4a94e6651529829be 100644 (file)
@@ -15,7 +15,7 @@
 
 /* Make sure debug is defined when it should be */
 #ifndef DEBUG
-#if defined(_DEBUG)
+#if 1
 #define DEBUG
 #endif
 #endif
index efe417d3d8a4bc1d721e0e31aca8edf87a2d6fb4..b7880bbb6869b41e7fa68c7dbbc03578cccba1d0 100644 (file)
@@ -39,7 +39,7 @@
 #include "mali_memory.h"
 #include "mali_memory_dma_buf.h"
 #include "mali_memory_manager.h"
-#include "mt_smi.h"
+
 #include "platform_pmm.h"
 
 #if defined(CONFIG_MALI400_INTERNAL_PROFILING)
@@ -464,10 +464,12 @@ static int mali_probe(struct platform_device *pdev)
        int err;
 
        MALI_DEBUG_PRINT(2, ("mali_probe(): Called for platform device %s\n", pdev->name));
+#ifdef CONFIG_MALI_DT
        if(!mtk_mfg_is_ready()){
                pr_warn("mfg is not ready, Mali id defer\n");
                return -EPROBE_DEFER;
        }
+#endif
        if (NULL != mali_platform_device) {
                /* Already connected to a device, return error */
                MALI_PRINT_ERROR(("mali_probe(): The Mali driver is already connected with a Mali device."));
index 48781d9fc8afb25278f8848156bb7ba7b01f3166..5fd13e1a18da2be6e0ac4f8e84f69df24898a27f 100644 (file)
@@ -20,7 +20,9 @@
 #include <linux/module.h>
 #include "mali_osk.h"
 
+#ifdef CONFIG_MALI_DT
 extern void dump_clk_state(void);
+#endif
 
 #if !defined(CONFIG_MALI_QUIET)
 void _mali_osk_dbgmsg(const char *fmt, ...)
@@ -64,7 +66,9 @@ void _mali_osk_abort(void)
 
 void _mali_osk_break(void)
 {
+#ifdef CONFIG_MALI_DT
        dump_clk_state();
+#endif
        _mali_osk_abort();
 }
 
index 571b7e569de2f93928642db0842a625182d16659..6919a25cdd1e9c42096d43ce79ce996986af7824 100644 (file)
@@ -20,7 +20,7 @@
 #include "arm_core_scaling.h"
 #include "mali_executor.h"
 #include "platform_pmm.h"
-
+#include "mach/mt_reg_base.h"
 
 static int mali_core_scaling_enable = 0;
 extern unsigned int current_sample_utilization;
@@ -112,107 +112,142 @@ static struct mali_gpu_device_data mali_gpu_data = {
 #endif
 };
 
-
 #ifndef CONFIG_MALI_DT
+static struct resource mali_gpu_resources[] =
+{
+    MALI_GPU_RESOURCES_MALI450_MP4(
+                    IO_VIRT_TO_PHYS(MALI_BASE),
+                    MT_MFG_IRQ0_ID,
+                    MT_MFG_IRQ1_ID,
+                    MT_MFG_IRQ2_ID,
+                    MT_MFG_IRQ3_ID,
+                    MT_MFG_IRQ4_ID,
+                    MT_MFG_IRQ5_ID,
+                    MT_MFG_IRQ6_ID,
+                    MT_MFG_IRQ7_ID,
+                    MT_MFG_IRQ8_ID,
+                    MT_MFG_IRQ9_ID,
+                    MT_MFG_IRQ10_ID
+                )
+};
+
+static struct resource mali_gpu_resources_MP3[] =
+{
+    MALI_GPU_RESOURCES_MALI450_MP3(
+                    IO_VIRT_TO_PHYS(MALI_BASE),
+                    MT_MFG_IRQ0_ID,
+                    MT_MFG_IRQ1_ID,
+                    MT_MFG_IRQ2_ID,
+                    MT_MFG_IRQ3_ID,
+                    MT_MFG_IRQ4_ID,
+                    MT_MFG_IRQ5_ID,
+                    MT_MFG_IRQ6_ID,
+                    MT_MFG_IRQ7_ID,                   
+                    MT_MFG_IRQ10_ID
+                )
+};
+
+static struct resource mali_gpu_resources_MP2[] =
+{
+    MALI_GPU_RESOURCES_MALI450_MP2(
+                    IO_VIRT_TO_PHYS(MALI_BASE),
+                    MT_MFG_IRQ0_ID,
+                    MT_MFG_IRQ1_ID,
+                    MT_MFG_IRQ2_ID,
+                    MT_MFG_IRQ3_ID,
+                    MT_MFG_IRQ4_ID,
+                    MT_MFG_IRQ5_ID,
+                    MT_MFG_IRQ10_ID
+                )
+};
+
 static struct platform_device mali_gpu_device = {
        .name = MALI_GPU_NAME_UTGARD,
        .id = 0,
+    .num_resources = ARRAY_SIZE(mali_gpu_resources),
+    .resource = (struct resource *)&mali_gpu_resources,
+    .dev.platform_data = &mali_gpu_data,
        .dev.release = mali_platform_device_release,
-       .dev.dma_mask = &mali_gpu_device.dev.coherent_dma_mask,
        .dev.coherent_dma_mask = DMA_BIT_MASK(32),
+       .dev.dma_mask = &mali_gpu_device.dev.coherent_dma_mask,
 
-       .dev.platform_data = &mali_gpu_data,
 #if defined(CONFIG_ARM64)
        .dev.archdata.dma_ops = &noncoherent_swiotlb_dma_ops,
 #endif
 };
 
-int mali_platform_device_register(void)
-{
-       int err = -1;
-       int num_pp_cores = 0;
-#if defined(CONFIG_ARCH_REALVIEW)
-       u32 m400_gp_version;
-#endif
-
-       MALI_DEBUG_PRINT(4, ("mali_platform_device_register() called\n"));
-
-       /* Detect present Mali GPU and connect the correct resources to the device */
-#if defined(CONFIG_ARCH_VEXPRESS)
+static u32 get_devinfo() {
+       /*TODO: replace this with get_devinfo_with_index*/
+    return *(volatile u32 *)0xf0206174;
+}
+static u32 get_gpuinfo() {
+       /*TODO: replace this with get_devinfo_with_index*/
+    return *(volatile u32 *)0xf0206040;
+}
 
-#if defined(CONFIG_ARM64)
-       if (mali_read_phys(0x6F000000) == 0x40601450) {
-               MALI_DEBUG_PRINT(4, ("Registering Mali-450 MP6 device\n"));
-               num_pp_cores = 6;
-               mali_gpu_device.num_resources = ARRAY_SIZE(mali_gpu_resources_m450_mp6);
-               mali_gpu_device.resource = mali_gpu_resources_m450_mp6;
-       }
+#define MALI_REASSIGN_RESOURCE(device, X) \
+do {\
+       device->resource = (struct resource *)&(X);\
+       device->num_resources = ARRAY_SIZE((X));\
+}while(0)
+
+static void update_dev_info(struct platform_device * device ) {
+    u32 info = get_devinfo();
+       MALI_DEBUG_PRINT(1, ("devinfo %#x\n", info));
+
+    /*if(0x0 == (info & (0x1 << 31))) { t or b*/
+    /*T*/
+    u32 gpuinfo = get_gpuinfo();
+       MALI_DEBUG_PRINT(1, ("gpuinfo %#x\n", gpuinfo));
+    u32 pp = (gpuinfo & 0x60000) >> 17;
+    if(pp == 0x1) {
+               MALI_DEBUG_PRINT(1, ("Found devinfo of MP3 %s\n", __FUNCTION__));
+               MALI_REASSIGN_RESOURCE(device, mali_gpu_resources_MP3);
+    } else if(pp == 0x2 || pp == 0x3) {
+               MALI_DEBUG_PRINT(1, ("Found devinfo of MP2 %s, %d\n", __FUNCTION__, pp));
+               MALI_REASSIGN_RESOURCE(device, mali_gpu_resources_MP2);
+    } else {
+#ifdef MTK_NR_MALI_PP
+#if (MTK_NR_MALI_PP == 3)
+        MALI_DEBUG_PRINT(1, ("Mali MP3 %s (MTK_NR_MALI_PP)\n", __FUNCTION__));
+        MALI_REASSIGN_RESOURCE(device, mali_gpu_resources_MP3);            
+#elif (MTK_NR_MALI_PP == 2)
+        MALI_DEBUG_PRINT(1, ("Mali MP2 %s (MTK_NR_MALI_PP)\n", __FUNCTION__));
+        MALI_REASSIGN_RESOURCE(device, mali_gpu_resources_MP2);            
 #else
-       if (mali_read_phys(0xFC000000) == 0x00000450) {
-               MALI_DEBUG_PRINT(4, ("Registering Mali-450 MP8 device\n"));
-               num_pp_cores = 8;
-               mali_gpu_device.num_resources = ARRAY_SIZE(mali_gpu_resources_m450_mp8);
-               mali_gpu_device.resource = mali_gpu_resources_m450_mp8;
-       } else if (mali_read_phys(0xFC000000) == 0x40600450) {
-               MALI_DEBUG_PRINT(4, ("Registering Mali-450 MP6 device\n"));
-               num_pp_cores = 6;
-               mali_gpu_device.num_resources = ARRAY_SIZE(mali_gpu_resources_m450_mp6);
-               mali_gpu_device.resource = mali_gpu_resources_m450_mp6;
-       } else if (mali_read_phys(0xFC000000) == 0x40400450) {
-               MALI_DEBUG_PRINT(4, ("Registering Mali-450 MP4 device\n"));
-               num_pp_cores = 4;
-               mali_gpu_device.num_resources = ARRAY_SIZE(mali_gpu_resources_m450_mp4);
-               mali_gpu_device.resource = mali_gpu_resources_m450_mp4;
+               MALI_DEBUG_PRINT(1, ("Default MP4 %s, ignore cfg: %d\n", __FUNCTION__, MTK_NR_MALI_PP));
+#endif
+#else 
+        MALI_DEBUG_PRINT(1, ("Default MP4 %s\n", __FUNCTION__));
+#endif
        }
-#endif /* CONFIG_ARM64 */
+}
 
-#elif defined(CONFIG_ARCH_REALVIEW)
+extern unsigned int get_max_DRAM_size (void);
+int mali_platform_device_register(void)
+{
+    int num_pp_cores = 4; //TODO: Need specify if we are using diff config
+    int err = -1;
+    MALI_DEBUG_PRINT(1, ("%s\n", __FUNCTION__));
+    mali_gpu_data.shared_mem_size = get_max_DRAM_size();
 
-       m400_gp_version = mali_read_phys(0xC000006C);
-       if ((m400_gp_version & 0xFFFF0000) == 0x0C070000) {
-               MALI_DEBUG_PRINT(4, ("Registering Mali-300 device\n"));
-               num_pp_cores = 1;
-               mali_gpu_device.num_resources = ARRAY_SIZE(mali_gpu_resources_m300);
-               mali_gpu_device.resource = mali_gpu_resources_m300;
-               mali_write_phys(0xC0010020, 0xA); /* Enable direct memory mapping for FPGA */
-       } else if ((m400_gp_version & 0xFFFF0000) == 0x0B070000) {
-               u32 fpga_fw_version = mali_read_phys(0xC0010000);
-               if (fpga_fw_version == 0x130C008F || fpga_fw_version == 0x110C008F) {
-                       /* Mali-400 MP1 r1p0 or r1p1 */
-                       MALI_DEBUG_PRINT(4, ("Registering Mali-400 MP1 device\n"));
-                       num_pp_cores = 1;
-                       mali_gpu_device.num_resources = ARRAY_SIZE(mali_gpu_resources_m400_mp1);
-                       mali_gpu_device.resource = mali_gpu_resources_m400_mp1;
-                       mali_write_phys(0xC0010020, 0xA); /* Enable direct memory mapping for FPGA */
-               } else if (fpga_fw_version == 0x130C000F) {
-                       /* Mali-400 MP2 r1p1 */
-                       MALI_DEBUG_PRINT(4, ("Registering Mali-400 MP2 device\n"));
-                       num_pp_cores = 2;
-                       mali_gpu_device.num_resources = ARRAY_SIZE(mali_gpu_resources_m400_mp2);
-                       mali_gpu_device.resource = mali_gpu_resources_m400_mp2;
-                       mali_write_phys(0xC0010020, 0xA); /* Enable direct memory mapping for FPGA */
-               }
-       }
+    update_dev_info(&mali_gpu_device);
+    
+    err = platform_device_register(&mali_gpu_device);
+                   
+    if (0 == err) 
+    {
+        mali_pmm_init(&mali_gpu_device);
+        mali_core_scaling_init(num_pp_cores);
 
-#endif
+        return 0;
+    }
 
-       /* Register the platform device */
-       err = platform_device_register(&mali_gpu_device);
-       if (0 == err) {
-#ifdef CONFIG_PM_RUNTIME
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
-               pm_runtime_set_autosuspend_delay(&(mali_gpu_device.dev), 1000);
-               pm_runtime_use_autosuspend(&(mali_gpu_device.dev));
-#endif
-               pm_runtime_enable(&(mali_gpu_device.dev));
-#endif
-               MALI_DEBUG_ASSERT(0 < num_pp_cores);
-               mali_core_scaling_init(num_pp_cores);
+    MALI_DEBUG_PRINT(1, ("%s err=%d\n",__FUNCTION__, err));
 
-               return 0;
-       }
+    platform_device_unregister(&mali_gpu_device);
 
-       return err;
+    return err;
 }
 
 void mali_platform_device_unregister(void)
index d75b6eee52b708489734ce7ed51774f4d32e611e..cd48e6bd8a815daef1224205e112fa107c71bfb0 100644 (file)
 #include <linux/proc_fs.h>
 #else
 #include "mach/mt_gpufreq.h"
+#include "mach/mt_clkmgr.h"
 #endif
 
-/*
+
 extern unsigned long (*mtk_thermal_get_gpu_loading_fp) (void);
 extern unsigned long (*mtk_get_gpu_loading_fp) (void);
-*/
+
 
 static int bPoweroff;
 unsigned int current_sample_utilization;
@@ -43,6 +44,13 @@ unsigned int current_sample_utilization;
 extern u32 get_devinfo_with_index(u32 index);
 static int _need_univpll;
 
+#define MFG_SPD_MASK 0x80000
+
+#define mfg_pwr_unlock(flags) \
+do { \
+    spin_unlock_irqrestore(&mali_pwr_lock, flags); \
+} while(0)
+
 #ifdef CONFIG_MALI_DT
 
 /* MFG begin
@@ -59,7 +67,7 @@ static int _need_univpll;
 #define MFG_CG_CLR 0x8
 #define MFG_DEBUG_SEL 0x180
 #define MFG_DEBUG_STAT 0x184
-#define MFG_SPD_MASK 0x80000
+//#define MFG_SPD_MASK 0x80000
 #define MFG_GPU_QUAL_MASK 0x3
 
 #define MFG_READ32(r) __raw_readl((void __iomem *)((unsigned long)mfg_start + (r)))
@@ -356,24 +364,42 @@ int mali_clk_disable(struct device *device)
 }
 #endif
 
+static u32 check_need_univpll() {
+    u32 info = *(volatile u32 *)0xf0206174;
+       /*get_devinfo_with_index (15);*/
+    /*if(0x0 == (info & (0x1 << 31))) { t or b?*/
+        /*T*/
+       u32 devinfo = *(volatile u32* )0xf0206040;/*get_devinfo_with_index(3);*/
+    if(devinfo & 0x80000) {
+        MALI_DEBUG_PRINT(1, ("GPU use univ with devinfo 0x%x\n", devinfo));
+        return 1;
+    } else {
+#ifdef MTK_MALI_UNIV
+        MALI_DEBUG_PRINT(1, ("GPU use univ with MTK_MALI_UNIV\n"));
+        return 1;
+#else
+        return 0;
+#endif  
+    }
+    
+}
+
 int mali_pmm_init(struct platform_device *device)
 {
        int err = 0;
-       u32 idx = 0;
+    
        MALI_DEBUG_PRINT(1, ("%s\n", __FUNCTION__));
-       idx = get_devinfo_with_index(3);
-       if (idx & MFG_SPD_MASK)
-               _need_univpll = 1;
-       else
-               _need_univpll = 0;
-       MALI_DEBUG_PRINT(2, ("need univ src pll idx0x%d %d\n", idx, _need_univpll));
+    
+       _need_univpll = check_need_univpll();
+    
+       MALI_DEBUG_PRINT(1, ("need univ src pll %d\n", _need_univpll));
 
        /* Because clkmgr may do 'default on' for some clock.
           We check the clock state on init and set power state atomic.
         */
 
        MALI_DEBUG_PRINT(1, ("MFG G3D init enable if it is on0621\n"));
-#ifndef CONFIG_MALI_DT
+
        mtk_thermal_get_gpu_loading_fp = gpu_get_current_utilization;
        mtk_get_gpu_loading_fp = gpu_get_current_utilization;
        if (clock_is_on(MT_CG_MFG_G3D)) {
@@ -388,12 +414,7 @@ int mali_pmm_init(struct platform_device *device)
                MALI_DEBUG_PRINT(1, ("MFG G3D init default off\n"));
                atomic_set((atomic_t *) & bPoweroff, 1);
        }
-#else
-       err = mali_mfgsys_init(device);
-       if (err)
-               return err;
-       atomic_set((atomic_t *) & bPoweroff, 1);
-#endif
+    
        mali_platform_power_mode_change(&(device->dev), MALI_POWER_MODE_ON);
 
        return err;
@@ -404,7 +425,9 @@ void mali_pmm_deinit(struct platform_device *device)
        MALI_DEBUG_PRINT(1, ("%s\n", __FUNCTION__));
 
        mali_platform_power_mode_change(&device->dev, MALI_POWER_MODE_DEEP_SLEEP);
+#ifdef CONFIG_MALI_DT
        mali_mfgsys_deinit(device);
+#endif
 }
 
 unsigned int gpu_get_current_utilization(void)