Merge branch 'r4p0-01' into mali-dev
authorKasin Lee <kasin.li@amlogic.com>
Tue, 5 Aug 2014 08:08:33 +0000 (16:08 +0800)
committerKasin Lee <kasin.li@amlogic.com>
Tue, 5 Aug 2014 08:08:33 +0000 (16:08 +0800)
Conflicts:
mali/common/mali_mmu.c
mali/common/mali_pmu.c
mali/linux/mali_osk_irq.c
mali/platform/mali_clock.c
mali/platform/meson_m450/platform_m8.c
mali/platform/meson_m450/platform_m8b.c
mali/platform/meson_m450/scaling_m8.c
mali/platform/meson_m450/scaling_m8b.c
mali/platform/meson_main.h
mali/platform/mpgpu.c

Change-Id: I21563425e0923c3faaf78a84fdbe02b203b6ffcd

1  2 
mali/Kbuild
mali/common/mali_group.c
mali/common/mali_mmu.c
mali/common/mali_mmu.h
mali/common/mali_pmu.c
mali/common/mali_pp_scheduler.c
mali/linux/mali_osk_irq.c
mali/linux/mali_sync.c
mali/platform/mali_clock.c
mali/platform/meson_m450/platform_m8.c
mali/platform/meson_m450/platform_m8b.c

diff --cc mali/Kbuild
Simple merge
Simple merge
index 566156eda9126cd1a83a05c6a4baf9852e51c9c8,c9d4b52b438661bf1765aa5402fe90ba75a548ef..81754a00b306a5ea58c8ca55e5ae9c499ff4701e
mode 100644,100755..100755
Simple merge
index ec782a99802bfff3a30f8e78dffbb01d6c6d9dba,34165b7cc76cced0c7d91baf1ae539db12a10818..27484dc08b166882cd60a4198f8c2543f3bbec1f
@@@ -164,9 -175,16 +175,15 @@@ static _mali_osk_errcode_t mali_pmu_pow
                                return err;
                        }
                }
+               mask_ck = mask_ck >> 1;
        }
-       /* Kasin Added for restore config value. */
-       mali_hw_core_register_write_relaxed(&pmu->hw_core, PMU_REG_ADDR_MGMT_SW_DELAY, pmu->switch_delay);
+       if (xxd != 0) {
+               printk("@@@@ warn\n");
+               printk("mask_ck:%d,active_mask:%d\n", mask_ck, active_mask);
+               //panic(0);
+         }
+         if (swt_dly != pmu->switch_delay)
+               mali_hw_core_register_write_relaxed(&pmu->hw_core, PMU_REG_ADDR_MGMT_SW_DELAY, pmu->switch_delay);
 -
  #endif
  
  #if defined(DEBUG)
Simple merge
index 8d24222a9e9c27082bddefce131e3d4925a46595,bd213aad376f15fdf98da111d4cdfe0171663a4c..6e555c859080b1d7b92de64e0b359667e38d4a5a
@@@ -28,9 -30,20 +30,19 @@@ typedef struct _mali_osk_irq_t_struct 
  } mali_osk_irq_object_t;
  
  typedef irqreturn_t (*irq_handler_func_t)(int, void *, struct pt_regs *);
 -static irqreturn_t irq_handler_upper_half (int port_name, void* dev_id ); /* , struct pt_regs *regs*/
 +static irqreturn_t irq_handler_upper_half(int port_name, void *dev_id);   /* , struct pt_regs *regs*/
  
+ #if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6
+ u32 get_irqnum(struct _mali_osk_irq_t_struct* irq)
+ {
+       if (irq)
+               return irq->irqnum;
+       else
+               return 0;
+ }
+ #endif
  #if defined(DEBUG)
 -#if 0
  
  struct test_interrupt_data {
        _mali_osk_irq_ack_t ack_func;
index 4022fee64d377d53cd5980e865f1e4bc775b5d07,7ae5a88db71f27546a86331bb58c3d99458131f6..bc5f56c59f08987eeb5b6e3a3853e1fb8c36e2b3
mode 100644,100755..100755
index 7e0d2b5b3442905fa8f7f412ea0ea71064559af7,a44db8ddda22cabde6d1e02d8d1c0f21ae866aa5..23a3623eac46355d246a74b1e53bec94e1b24e0b
@@@ -7,28 -7,37 +7,36 @@@
  #include <mach/io.h>
  #include <plat/io.h>
  #include <asm/io.h>
  #include "meson_main.h"
  
+ #if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6TVD
  #define FCLK_MPLL2 (2 << 9)
 -
  static DEFINE_SPINLOCK(lock);
+ static mali_plat_info_t* pmali_plat = NULL;
+ static u32 mali_extr_backup = 0;
+ static u32 mali_extr_sample_backup = 0;
  
- static u32 mali_extr_backup;
+ int mali_clock_init(mali_plat_info_t* mali_plat)
+ {
+       u32 def_clk_data;
+       if (mali_plat == NULL) {
+               printk(" Mali platform data is NULL!!!\n");
+               return -1;
+       }
  
- #if MESON_CPU_TYPE > MESON_CPU_TYPE_MESON8
- #define HAVE_MALI_CLOCK_SWITCH 1
- #endif
+       pmali_plat = mali_plat;
+       if (pmali_plat->have_switch) {
+               def_clk_data = pmali_plat->clk[pmali_plat->def_clock];
+               writel(def_clk_data | (def_clk_data << 16), (u32*)P_HHI_MALI_CLK_CNTL);
+               setbits_le32((u32)P_HHI_MALI_CLK_CNTL, 1 << 24);
+               setbits_le32((u32)P_HHI_MALI_CLK_CNTL, 1 << 8);
+       } else {
+               mali_clock_set(pmali_plat->def_clock);
+       }
  
- int mali_clock_init(u32 def_clk_idx)
- {
- #ifdef HAVE_MALI_CLOCK_SWITCH
-       writel((mali_dvfs_clk[def_clk_idx]<<16)|(mali_dvfs_clk[def_clk_idx]<<16), (u32*)P_HHI_MALI_CLK_CNTL);
-       setbits_le32((u32)P_HHI_MALI_CLK_CNTL, 1 << 24);
-       setbits_le32((u32)P_HHI_MALI_CLK_CNTL, 1 << 8);
- #else
-       mali_clock_set(def_clk_idx);
- #endif
-       mali_extr_backup = mali_dvfs_clk[get_mali_tbl_size() -1];
+       mali_extr_backup = pmali_plat->clk[pmali_plat->clk_len - 1];
+       mali_extr_sample_backup = pmali_plat->clk_sample[pmali_plat->clk_len - 1];
        return 0;
  }
  
index cb65c313692e5b608139cd233d0689c3b6e0321b,a7ee6bbff27a6b5ab64d68d69a424011dae70d9c..d0dc4e5ae2f3670de93ad6006e9ad4f14125d0f4
@@@ -59,21 -59,85 +59,87 @@@ static u32 mali_dvfs_clk_sample[] = 
        637,     /* 637.5 Mhz */
  };
  
+ static mali_dvfs_threshold_table mali_dvfs_table[]={
+               { 0, 0, 3,  70, 180}, /* for 182.1  */
+               { 1, 1, 3, 108, 205}, /* for 318.7  */
+               { 2, 2, 3, 150, 215}, /* for 425.0  */
+               { 3, 3, 3, 170, 253}, /* for 510.0  */
+               { 4, 4, 3, 230, 256},  /* for 637.5  */
+               { 0, 0, 3,   0,   0}
+ };
+ static void mali_plat_preheat(void);
+ static mali_plat_info_t mali_plat_data = {
+       .cfg_pp = CFG_PP,  /* number of pp. */
+       .cfg_min_pp = CFG_MIN_PP,
+       .turbo_clock = 4, /* reserved clock src. */
+       .def_clock = 2, /* gpu clock used most of time.*/
+       .cfg_clock = CFG_CLOCK, /* max gpu clock. */
+       .cfg_clock_bkup = CFG_CLOCK,
+       .cfg_min_clock = CFG_MIN_CLOCK,
+       .sc_mpp = 3, /* number of pp used most of time.*/
+       .bst_gpu = 210, /* threshold for boosting gpu. */
+       .bst_pp = 160, /* threshold for boosting PP. */
+       .clk = mali_dvfs_clk, /* clock source table. */
+       .clk_sample = mali_dvfs_clk_sample, /* freqency table for show. */
+       .clk_len = sizeof(mali_dvfs_clk) / sizeof(mali_dvfs_clk[0]),
+       .have_switch = 1,
+       .dvfs_table = mali_dvfs_table, /* DVFS table. */
+       .dvfs_table_size = sizeof(mali_dvfs_table) / sizeof(mali_dvfs_threshold_table),
+       .scale_info = {
+               CFG_MIN_PP, /* minpp */
+               CFG_PP, /* maxpp, should be same as cfg_pp */
+               CFG_MIN_CLOCK, /* minclk */
+               CFG_CLOCK, /* maxclk should be same as cfg_clock */
+       },
+       .limit_on = 1,
+       .plat_preheat = mali_plat_preheat,
+ };
+ static void mali_plat_preheat(void)
+ {
+       u32 pre_fs;
+       u32 clk, pp;
+       if (get_mali_schel_mode() != MALI_PP_FS_SCALING)
+               return;
+       get_mali_rt_clkpp(&clk, &pp);
+       pre_fs = mali_plat_data.def_clock + 1;
+       if (clk < pre_fs)
+               clk = pre_fs;
+       if (pp < mali_plat_data.sc_mpp)
+               pp = mali_plat_data.sc_mpp;
+       set_mali_rt_clkpp(clk, pp, 1);
+ }
+ mali_plat_info_t* get_mali_plat_data(void) {
+       return &mali_plat_data;
+ }
  int get_mali_freq_level(int freq)
  {
 +      int mali_freq_num;
        int i = 0, level = -1;
+       int mali_freq_num;
        if(freq < 0)
                return level;
-       mali_freq_num = sizeof(mali_dvfs_clk_sample) / sizeof(mali_dvfs_clk_sample[0]) - 1;
-       if(freq <= mali_dvfs_clk_sample[0])
++
+       mali_freq_num = mali_plat_data.dvfs_table_size - 1;
+       if(freq <= mali_plat_data.clk_sample[0])
                level = mali_freq_num-1;
-       if(freq >= mali_dvfs_clk_sample[mali_freq_num - 1])
+       if(freq >= mali_plat_data.clk_sample[mali_freq_num - 1])
                level = 0;
        for(i=0; i<mali_freq_num - 1 ;i++) {
-               if(freq >= mali_dvfs_clk_sample[i] && freq<=mali_dvfs_clk_sample[i+1]) {
+               if(freq >= mali_plat_data.clk_sample[i] && freq<=mali_plat_data.clk_sample[i + 1]) {
                        level = i;
-                       level = mali_freq_num-level-1;
+                       level = mali_freq_num-level - 1;
                }
        }
        return level;
index 269016f58f65c2ecac0f7502b504ac6b9ed9669c,ce1d70d144313d2eeb9628a54c17cd9ea3c95924..4c4272b2eb6c497e7e0713292009c151f4b90267
@@@ -186,5 -320,59 +320,61 @@@ static int mali_cri_deep_resume(size_t 
                ret = device->driver->pm->resume(device);
        }
        return ret;
 -
+ }
+ int mali_light_suspend(struct device *device)
+ {
+       int ret = 0;
+ #ifdef CONFIG_MALI400_PROFILING
+       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
+                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+                                       0, 0,   0,      0,      0);
+ #endif
+       /* clock scaling. Kasin..*/
+       ret = mali_clock_critical(mali_cri_light_suspend, (size_t)device);
+       disable_clock();
+       return ret;
+ }
+ int mali_light_resume(struct device *device)
+ {
+       int ret = 0;
+       enable_clock();
+       ret = mali_clock_critical(mali_cri_light_resume, (size_t)device);
+ #ifdef CONFIG_MALI400_PROFILING
+       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
+                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+                                       get_current_frequency(), 0,     0,      0,      0);
+ #endif
+       return ret;
+ }
+ int mali_deep_suspend(struct device *device)
+ {
+       int ret = 0;
++      struct mali_pmu_core *pmu;
++
++      pmu = mali_pmu_get_global_pmu_core();
+       enable_clock();
+       flush_scaling_job();
+       /* clock scaling off. Kasin... */
+       ret = mali_clock_critical(mali_cri_deep_suspend, (size_t)device);
+       disable_clock();
+       return ret;
+ }
+ int mali_deep_resume(struct device *device)
+ {
+       int ret = 0;
+       /* clock scaling up. Kasin.. */
+       enable_clock();
+       ret = mali_clock_critical(mali_cri_deep_resume, (size_t)device);
+       return ret;
  }