From 4d330bafa3b4cba7d5e6d7db0fa04171a23fafc5 Mon Sep 17 00:00:00 2001 From: aosp Date: Thu, 1 Mar 2018 12:09:19 +0100 Subject: [PATCH] hi3798mv200 support --- .../driver/src/devicedrv/mali/Kbuild | 31 +- .../driver/src/devicedrv/mali/Kconfig | 14 +- .../driver/src/devicedrv/mali/MALI_CONFIGURATION | 18 + .../driver/src/devicedrv/mali/Makefile | 18 +- .../src/devicedrv/mali/common/mali_executor.c | 3 +- .../src/devicedrv/mali/common/mali_executor.h | 2 + .../driver/src/devicedrv/mali/common/mali_gp_job.c | 2 +- .../src/devicedrv/mali/common/mali_pm_metrics.c | 58 ++ .../src/devicedrv/mali/common/mali_pm_metrics.h | 6 + .../src/devicedrv/mali/common/mali_soft_job.c | 4 + .../driver/src/devicedrv/mali/kbuild_flags | 111 ++++ .../driver/src/devicedrv/mali/linux/mali_devfreq.c | 27 + .../src/devicedrv/mali/linux/mali_kernel_linux.c | 19 + .../src/devicedrv/mali/linux/mali_linux_trace.h | 2 + .../src/devicedrv/mali/platform/dt/drv_gpu_ext.h | 17 + .../src/devicedrv/mali/platform/dt/hi_drv_module.h | 57 ++ .../src/devicedrv/mali/platform/dt/hi_module.h | 182 ++++++ .../src/devicedrv/mali/platform/dt/hi_type.h | 142 +++++ .../src/devicedrv/mali/platform/dt/mali4xx_cfg.h | 25 + .../src/devicedrv/mali/platform/dt/mali4xx_dt.c | 652 +++++++++++++++++++++ .../src/devicedrv/mali/platform/dt/mali4xx_dt.h | 41 ++ .../src/devicedrv/mali/platform/dt/mali4xx_opp.c | 270 +++++++++ .../src/devicedrv/mali/platform/dt/mali4xx_opp.h | 29 + .../src/devicedrv/mali/platform/dt/mali4xx_proc.c | 384 ++++++++++++ .../src/devicedrv/mali/platform/dt/mali4xx_proc.h | 15 + .../devicedrv/mali/platform/dt/mali4xx_scaling.c | 118 ++++ .../devicedrv/mali/platform/dt/mali4xx_scaling.h | 31 + 27 files changed, 2249 insertions(+), 29 deletions(-) create mode 100755 driver/src/devicedrv/mali/MALI_CONFIGURATION create mode 100755 driver/src/devicedrv/mali/kbuild_flags create mode 100755 driver/src/devicedrv/mali/platform/dt/drv_gpu_ext.h create mode 100755 driver/src/devicedrv/mali/platform/dt/hi_drv_module.h create mode 100755 driver/src/devicedrv/mali/platform/dt/hi_module.h create mode 100755 driver/src/devicedrv/mali/platform/dt/hi_type.h create mode 100755 driver/src/devicedrv/mali/platform/dt/mali4xx_cfg.h create mode 100755 driver/src/devicedrv/mali/platform/dt/mali4xx_dt.c create mode 100755 driver/src/devicedrv/mali/platform/dt/mali4xx_dt.h create mode 100755 driver/src/devicedrv/mali/platform/dt/mali4xx_opp.c create mode 100755 driver/src/devicedrv/mali/platform/dt/mali4xx_opp.h create mode 100755 driver/src/devicedrv/mali/platform/dt/mali4xx_proc.c create mode 100755 driver/src/devicedrv/mali/platform/dt/mali4xx_proc.h create mode 100755 driver/src/devicedrv/mali/platform/dt/mali4xx_scaling.c create mode 100755 driver/src/devicedrv/mali/platform/dt/mali4xx_scaling.h diff --git a/driver/src/devicedrv/mali/Kbuild b/driver/src/devicedrv/mali/Kbuild index 37cdeb9..7412e9e --- a/driver/src/devicedrv/mali/Kbuild +++ b/driver/src/devicedrv/mali/Kbuild @@ -11,9 +11,10 @@ # This file is called by the Linux build system. # set up defaults if not defined by the user +include $(src)/kbuild_flags TIMESTAMP ?= default OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB ?= 16 -USING_GPU_UTILIZATION ?= 0 +USING_GPU_UTILIZATION ?= 1 PROFILING_SKIP_PP_JOBS ?= 0 PROFILING_SKIP_PP_AND_GP_JOBS ?= 0 MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP ?= 0 @@ -25,21 +26,21 @@ MALI_ENABLE_CPU_CYCLES ?= 0 # For customer releases the Linux Device Drivers will be provided as ARM proprietary and GPL releases: # The ARM proprietary product will only include the license/proprietary directory # The GPL product will only include the license/gpl directory -ifeq ($(wildcard $(src)/linux/license/gpl/*),) - ccflags-y += -I$(src)/linux/license/proprietary - ifeq ($(CONFIG_MALI400_PROFILING),y) - $(error Profiling is incompatible with non-GPL license) - endif - ifeq ($(CONFIG_PM_RUNTIME),y) - $(error Runtime PM is incompatible with non-GPL license) - endif - ifeq ($(CONFIG_DMA_SHARED_BUFFER),y) - $(error DMA-BUF is incompatible with non-GPL license) - endif - $(error Linux Device integration is incompatible with non-GPL license) -else +#ifeq ($(wildcard $(src)/linux/license/gpl/*),) +# ccflags-y += -I$(src)/linux/license/proprietary +# ifeq ($(CONFIG_MALI400_PROFILING),y) +# $(error Profiling is incompatible with non-GPL license) +# endif +# ifeq ($(CONFIG_PM_RUNTIME),y) +# $(error Runtime PM is incompatible with non-GPL license) +# endif +# ifeq ($(CONFIG_DMA_SHARED_BUFFER),y) +# $(error DMA-BUF is incompatible with non-GPL license) +# endif +# $(error Linux Device integration is incompatible with non-GPL license) +#else ccflags-y += -I$(src)/linux/license/gpl -endif +#endif ifeq ($(USING_GPU_UTILIZATION), 1) ifeq ($(USING_DVFS), 1) diff --git a/driver/src/devicedrv/mali/Kconfig b/driver/src/devicedrv/mali/Kconfig index 7b4e9fb..18fd377 --- a/driver/src/devicedrv/mali/Kconfig +++ b/driver/src/devicedrv/mali/Kconfig @@ -69,7 +69,7 @@ config MALI_DMA_BUF_MAP_ON_ATTACH config MALI_SHARED_INTERRUPTS bool "Support for shared interrupts" depends on MALI400 - default n + default y ---help--- Adds functionality required to properly support shared interrupts. Without this support, the device driver will fail during insmod if it detects shared interrupts. This also @@ -115,3 +115,15 @@ config MALI_QUIET This forces the Mali driver to never print any messages. If unsure, say N. +config GPU_MAX_SHARE_MEM_SIZE + hex "Mali400 and OS maximal shared memory size" + depends on MALI400 + default "0x10000000" + ---help--- + This constricts the maximal memory GPU could get from os memory. +config GPU_DVFS_ENABLE + bool "Enable GPU DVFS" + depends on MALI400 + default n + ---help--- + This enables GPU DVFS function. diff --git a/driver/src/devicedrv/mali/MALI_CONFIGURATION b/driver/src/devicedrv/mali/MALI_CONFIGURATION new file mode 100644 index 0000000..be93771 --- /dev/null +++ b/driver/src/devicedrv/mali/MALI_CONFIGURATION @@ -0,0 +1,12 @@ +include kbuild_flags +#=============================================================================== +# export variables +#=============================================================================== +USING_UMP:=0 +MALI_SHARED_INTERRUPTS:=1 + +# Location of default kernels +KDIR-$(TARGET_PLATFORM):=$(LINUX_DIR) + +# Name of platform directory with platform specific code (should be built into kernel on a real system) +MALI_PLATFORM-$(TARGET_PLATFORM)=mali450 diff --git a/driver/src/devicedrv/mali/Makefile b/driver/src/devicedrv/mali/Makefile old mode 100755 new mode 100644 index f39ae4d..5a27cd4 --- a/driver/src/devicedrv/mali/Makefile +++ b/driver/src/devicedrv/mali/Makefile @@ -10,8 +10,8 @@ USE_UMPV2=0 USING_PROFILING ?= 1 -USING_INTERNAL_PROFILING ?= 0 -USING_DVFS ?= 1 +USING_INTERNAL_PROFILING ?= 1 +USING_DVFS ?= 0 USING_DMA_BUF_FENCE ?= 0 MALI_HEATMAPS_ENABLED ?= 0 MALI_DMA_BUF_MAP_ON_ATTACH ?= 1 @@ -52,7 +52,7 @@ $(warning "You have specified the CPU variable which is no longer in used. Use T endif # Include the mapping between TARGET_PLATFORM and KDIR + MALI_PLATFORM --include MALI_CONFIGURATION +include MALI_CONFIGURATION export KDIR ?= $(KDIR-$(TARGET_PLATFORM)) export MALI_PLATFORM ?= $(MALI_PLATFORM-$(TARGET_PLATFORM)) @@ -89,7 +89,6 @@ endif KDIR-$(shell uname -m):=/lib/modules/$(shell uname -r)/build include $(KDIR)/.config - ifeq ($(ARCH), arm) # when compiling for ARM we're cross compiling export CROSS_COMPILE ?= $(call check_cc2, arm-linux-gnueabi-gcc, arm-linux-gnueabi-, arm-none-linux-gnueabi-) @@ -103,13 +102,11 @@ $(warning MALI_PLATFORM $(MALI_PLATFORM)) endif # Set up build config -export CONFIG_MALI400=m -export CONFIG_MALI450=y -export CONFIG_MALI470=y +#export CONFIG_MALI400=m +#export CONFIG_MALI450=y -export EXTRA_DEFINES += -DCONFIG_MALI400=1 -export EXTRA_DEFINES += -DCONFIG_MALI450=1 -export EXTRA_DEFINES += -DCONFIG_MALI470=1 +#export EXTRA_DEFINES += -DCONFIG_MALI400=1 +#export EXTRA_DEFINES += -DCONFIG_MALI450=1 ifneq ($(MALI_PLATFORM),) export EXTRA_DEFINES += -DMALI_FAKE_PLATFORM_DEVICE=1 @@ -122,6 +119,7 @@ $(warning CONFIG_TRACEPOINTS required for profiling) else export CONFIG_MALI400_PROFILING=y export EXTRA_DEFINES += -DCONFIG_MALI400_PROFILING=1 + ifeq ($(USING_INTERNAL_PROFILING),1) export CONFIG_MALI400_INTERNAL_PROFILING=y export EXTRA_DEFINES += -DCONFIG_MALI400_INTERNAL_PROFILING=1 diff --git a/driver/src/devicedrv/mali/common/mali_executor.c b/driver/src/devicedrv/mali/common/mali_executor.c old mode 100755 new mode 100644 index 21acccc..45186e3 --- a/driver/src/devicedrv/mali/common/mali_executor.c +++ b/driver/src/devicedrv/mali/common/mali_executor.c @@ -125,7 +125,6 @@ static void mali_executor_disable_empty_virtual(void); static mali_bool mali_executor_physical_rejoin_virtual(struct mali_group *group); static mali_bool mali_executor_has_virtual_group(void); static mali_bool mali_executor_virtual_group_is_usable(void); -static void mali_executor_schedule(void); static void mali_executor_wq_schedule(void *arg); static void mali_executor_send_gp_oom_to_user(struct mali_gp_job *job); static void mali_executor_complete_group(struct mali_group *group, @@ -1556,7 +1555,7 @@ static mali_bool mali_executor_schedule_is_early_out(mali_bool *gpu_secure_mode_ /* * This is where jobs are actually started. */ -static void mali_executor_schedule(void) +void mali_executor_schedule(void) { u32 i; u32 num_physical_needed = 0; diff --git a/driver/src/devicedrv/mali/common/mali_executor.h b/driver/src/devicedrv/mali/common/mali_executor.h old mode 100755 new mode 100644 index 1d69dc3..780f472 --- a/driver/src/devicedrv/mali/common/mali_executor.h +++ b/driver/src/devicedrv/mali/common/mali_executor.h @@ -40,6 +40,8 @@ void mali_executor_depopulate(void); void mali_executor_suspend(void); void mali_executor_resume(void); +void mali_executor_schedule(void); + u32 mali_executor_get_num_cores_total(void); u32 mali_executor_get_num_cores_enabled(void); struct mali_pp_core *mali_executor_get_virtual_pp(void); diff --git a/driver/src/devicedrv/mali/common/mali_gp_job.c b/driver/src/devicedrv/mali/common/mali_gp_job.c old mode 100755 new mode 100644 index 00a2d1e..fb8dcd8 --- a/driver/src/devicedrv/mali/common/mali_gp_job.c +++ b/driver/src/devicedrv/mali/common/mali_gp_job.c @@ -133,7 +133,7 @@ struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_ goto fail1; } - memory_list = (u32 __user *)(uintptr_t)uargs->deferred_mem_list; + memory_list = (u32 __user *)(uintptr_t)job->uargs.deferred_mem_list; if (0 != _mali_osk_copy_from_user(job->varying_list, memory_list, sizeof(u32) * job->uargs.deferred_mem_num)) { MALI_PRINT_ERROR(("Mali GP job: Failed to copy varying list from user space!\n")); diff --git a/driver/src/devicedrv/mali/common/mali_pm_metrics.c b/driver/src/devicedrv/mali/common/mali_pm_metrics.c old mode 100755 new mode 100644 index 981ec81..5439a47 --- a/driver/src/devicedrv/mali/common/mali_pm_metrics.c +++ b/driver/src/devicedrv/mali/common/mali_pm_metrics.c @@ -174,15 +174,45 @@ void mali_pm_record_gpu_active(mali_bool is_gp) static void mali_pm_get_dvfs_utilisation_calc(struct mali_device *mdev, ktime_t now) { ktime_t diff; +#if defined(UTGARD_HISILICON_PLUGIN) + ktime_t diff_gp, diff_pp; +#endif MALI_DEBUG_ASSERT(mdev != NULL); diff = ktime_sub(now, mdev->mali_metrics.time_period_start); +#if defined(UTGARD_HISILICON_PLUGIN) + diff_gp = ktime_sub(now, mdev->mali_metrics.time_period_start_gp); + diff_pp = ktime_sub(now, mdev->mali_metrics.time_period_start_pp); +#endif + if (mdev->mali_metrics.gpu_active) { mdev->mali_metrics.time_busy += (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT); + +#if defined(UTGARD_HISILICON_PLUGIN) + if(1 == mdev->mali_metrics.num_running_gp_cores) + { + mdev->mali_metrics.time_busy_gp += (u64)(ktime_to_ns(diff_gp) >> MALI_PM_TIME_SHIFT); + } + else + { + mdev->mali_metrics.time_busy_pp[0] += (u64)(ktime_to_ns(diff_pp) >> MALI_PM_TIME_SHIFT); + } +#endif } else { mdev->mali_metrics.time_idle += (u64)(ktime_to_ns(diff) >> MALI_PM_TIME_SHIFT); + +#if defined(UTGARD_HISILICON_PLUGIN) + if(1 == mdev->mali_metrics.num_running_gp_cores) + { + mdev->mali_metrics.time_idle_gp += (u64)(ktime_to_ns(diff_gp) >> MALI_PM_TIME_SHIFT); + } + else + { + mdev->mali_metrics.time_idle_pp[0] += (u64)(ktime_to_ns(diff_pp) >> MALI_PM_TIME_SHIFT); + } +#endif } } @@ -193,6 +223,13 @@ static void mali_pm_reset_dvfs_utilisation_unlocked(struct mali_device *mdev, kt mdev->mali_metrics.prev_idle = mdev->mali_metrics.time_idle; mdev->mali_metrics.prev_busy = mdev->mali_metrics.time_busy; +#if defined(UTGARD_HISILICON_PLUGIN) + mdev->mali_metrics.prev_idle_gp = mdev->mali_metrics.time_idle_gp; + mdev->mali_metrics.prev_busy_gp = mdev->mali_metrics.time_busy_gp; + mdev->mali_metrics.prev_idle_pp[0] = mdev->mali_metrics.time_idle_pp[0]; + mdev->mali_metrics.prev_busy_pp[0] = mdev->mali_metrics.time_busy_pp[0]; +#endif + /* Reset current values */ mdev->mali_metrics.time_period_start = now; mdev->mali_metrics.time_period_start_gp = now; @@ -220,6 +257,11 @@ void mali_pm_get_dvfs_utilisation(struct mali_device *mdev, u64 busy = 0; u64 total = 0; +#if defined(UTGARD_HISILICON_PLUGIN) + u64 busy_gp = 0, total_gp = 0; + u64 busy_pp = 0, total_pp = 0; +#endif + _mali_osk_spinlock_irq_lock(mdev->mali_metrics.lock); mali_pm_get_dvfs_utilisation_calc(mdev, now); @@ -227,6 +269,13 @@ void mali_pm_get_dvfs_utilisation(struct mali_device *mdev, busy = mdev->mali_metrics.time_busy; total = busy + mdev->mali_metrics.time_idle; +#if defined(UTGARD_HISILICON_PLUGIN) + busy_gp = mdev->mali_metrics.time_busy_gp; + total_gp = busy_gp + mdev->mali_metrics.time_idle_gp; + busy_pp = mdev->mali_metrics.time_busy_pp[0]; + total_pp = busy_pp + mdev->mali_metrics.time_idle_pp[0]; +#endif + /* Reset stats if older than MALI_UTILIZATION_MAX_PERIOD (default * 100ms) */ if (total >= MALI_UTILIZATION_MAX_PERIOD) { @@ -235,6 +284,15 @@ void mali_pm_get_dvfs_utilisation(struct mali_device *mdev, total += mdev->mali_metrics.prev_idle + mdev->mali_metrics.prev_busy; busy += mdev->mali_metrics.prev_busy; + +#if defined(UTGARD_HISILICON_PLUGIN) + total_gp += mdev->mali_metrics.prev_idle_gp + + mdev->mali_metrics.prev_busy_gp; + busy_gp += mdev->mali_metrics.prev_busy_gp; + total_pp += mdev->mali_metrics.prev_idle_pp[0] + + mdev->mali_metrics.prev_busy_pp[0]; + busy_pp += mdev->mali_metrics.prev_busy_pp[0]; +#endif } *total_out = (unsigned long)total; diff --git a/driver/src/devicedrv/mali/common/mali_pm_metrics.h b/driver/src/devicedrv/mali/common/mali_pm_metrics.h old mode 100755 new mode 100644 index 256f448..88283e8 --- a/driver/src/devicedrv/mali/common/mali_pm_metrics.h +++ b/driver/src/devicedrv/mali/common/mali_pm_metrics.h @@ -31,9 +31,15 @@ struct mali_pm_metrics_data { ktime_t time_period_start_gp; u64 time_busy_gp; u64 time_idle_gp; + u64 prev_busy_gp; + u64 prev_idle_gp; + ktime_t time_period_start_pp; u64 time_busy_pp[MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS]; u64 time_idle_pp[MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS]; + u64 prev_busy_pp[MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS]; + u64 prev_idle_pp[MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS]; + mali_bool gpu_active; _mali_osk_spinlock_irq_t *lock; }; diff --git a/driver/src/devicedrv/mali/common/mali_soft_job.c b/driver/src/devicedrv/mali/common/mali_soft_job.c old mode 100755 new mode 100644 index c76d1fe..2798435 --- a/driver/src/devicedrv/mali/common/mali_soft_job.c +++ b/driver/src/devicedrv/mali/common/mali_soft_job.c @@ -435,4 +435,8 @@ void mali_soft_job_system_abort(struct mali_soft_job_system *system) mali_soft_job_destroy(job); } + + mali_executor_lock(); + mali_executor_schedule(); + mali_executor_unlock(); } diff --git a/driver/src/devicedrv/mali/kbuild_flags b/driver/src/devicedrv/mali/kbuild_flags new file mode 100644 index 0000000..8daeb3f --- /dev/null +++ b/driver/src/devicedrv/mali/kbuild_flags @@ -0,0 +1,111 @@ +#=============================================================================== +# export variables +#=============================================================================== + +#SDK include header files +export EXTRA_CFLAGS += -I$(COMMON_UNF_INCLUDE) \ + -I$(COMMON_DRV_INCLUDE) \ + -I$(MSP_DRV_INCLUDE) + +#build in or not +export CONFIG_MALI400=$(HI_DRV_BUILDTYPE) + +export CONFIG_MALI450=$(HI_DRV_BUILDTYPE) + +export EXTRA_DEFINES += -DCONFIG_MALI450=1 +export TARGET_PLATFORM=mali450 + +#SDK flags +export EXTRA_DEFINES += $(CFG_HI_KMOD_CFLAGS) + +#if use pmu, we need i2c driver +ifeq ($(CFG_HI_PMU_DEVICE_SELECT),y) +export EXTRA_DEFINES += -DCONFIG_HI_PMU_DEVICE_SELECT +export EXTRA_DEFINES += -I$(COMMON_UNF_INCLUDE) -I$(COMMON_DRV_INCLUDE) -I$(MSP_DRV_INCLUDE) +endif + +# Max GPU and OS shared memory size +export EXTRA_DEFINES += -DCONFIG_GPU_MAX_SHARE_MEM_SIZE=0x20000000 + +# Enable DMA Buffer map on attach +export CONFIG_MALI_DMA_BUF_MAP_ON_ATTACH=y +export EXTRA_DEFINES += -DCONFIG_MALI_DMA_BUF_MAP_ON_ATTACH + +#whether enable dvfs or not +export CONFIG_GPU_DVFS_ENABLE=y +export EXTRA_DEFINES += -DCONFIG_GPU_DVFS_ENABLE + +#whether enable avs or not +ifeq ($(CFG_HI_AVS_SUPPORT),y) +export CONFIG_GPU_AVS_ENABLE=y +export EXTRA_DEFINES += -DCONFIG_GPU_AVS_ENABLE +endif + +#if buildin, we should enable share interrupt and FAKE Driver here +export CONFIG_MALI_SHARED_INTERRUPTS=y +export EXTRA_DEFINES += -DCONFIG_MALI_SHARED_INTERRUPTS + +#debug or release +ifeq ($(CONFIG_MALI400_DEBUG),y) +BUILD=debug +else +BUILD=release +endif + +HI_GPU_PROFILING=y +HI_GPU_INTERNAL_PROFILING=n + +#profiling +ifeq ($(CFG_HI_ADVCA_SUPPORT), y) +HI_GPU_PROFILING=n +HI_GPU_INTERNAL_PROFILING=n +endif + +ifeq ($(CONFIG_MALI_QUIET),y) +export EXTRA_DEFINES += -DCONFIG_MALI_QUIET +endif + +ifeq ($(HI_GPU_PROFILING), y) +USING_PROFILING=1 +export CONFIG_MALI400_PROFILING=y +export EXTRA_DEFINES += -DCONFIG_MALI400_PROFILING=1 +else +USING_PROFILING=0 +endif + +#internal profiling +ifeq ($(HI_GPU_INTERNAL_PROFILING), y) +USING_INTERNAL_PROFILING=1 +export CONFIG_MALI400_INTERNAL_PROFILING=y +export EXTRA_DEFINES += -DCONFIG_MALI400_INTERNAL_PROFILING=1 +else +USING_INTERNAL_PROFILING=0 +endif + +ifeq ($(CFG_HI_TEMP_CTRL_CONFIG), y) +export EXTRA_DEFINES += -DCFG_TEMP_CTRL_CONFIG=1 +export EXTRA_DEFINES += -DCFG_TEMP_CTRL_DOWN_THRESHOLD=$(CFG_HI_TEMP_CTRL_DOWN_THRESHOLD) +export EXTRA_DEFINES += -DCFG_TEMP_CTRL_UP_THRESHOLD=$(CFG_HI_TEMP_CTRL_UP_THRESHOLD) +endif + +#device tree + +export CONFIG_MALI_DT=y +export EXTRA_DEFINES += -DCONFIG_MALI_DT=1 +export EXTRA_DEFINES += -DUTGARD_HISILICON_PLUGIN=1 +#hisi integration +export EXTRA_DEFINES += -DMALI_FAKE_PLATFORM_DEVICE=1 + +export CONFIG_MALI_DT=y +export EXTRA_DEFINES += -DCONFIG_MALI_DT=1 +export CONFIG_MALI_DEVFREQ=y +export EXTRA_DEFINES += -DCONFIG_MALI_DEVFREQ=1 +export MALI_PLATFORM_FILES = platform/dt/mali4xx_dt.c \ + platform/dt/mali4xx_proc.c \ + platform/dt/mali4xx_scaling.c \ + platform/dt/mali4xx_opp.c + + + + + diff --git a/driver/src/devicedrv/mali/linux/mali_devfreq.c b/driver/src/devicedrv/mali/linux/mali_devfreq.c old mode 100755 new mode 100644 index 0b0ba14..407f588 --- a/driver/src/devicedrv/mali/linux/mali_devfreq.c +++ b/driver/src/devicedrv/mali/linux/mali_devfreq.c @@ -36,6 +36,12 @@ #include "mali_pm_metrics.h" +#if defined(UTGARD_HISILICON_PLUGIN) +#include "platform/dt/mali4xx_dt.h" +#include "platform/dt/mali4xx_opp.h" +#include "platform/dt/mali4xx_cfg.h" +#endif + static int mali_devfreq_target(struct device *dev, unsigned long *target_freq, u32 flags) { @@ -121,10 +127,17 @@ mali_devfreq_status(struct device *dev, struct devfreq_dev_status *stat) stat->current_frequency = mdev->current_freq; +#if defined(UTGARD_HISILICON_PLUGIN) + stat->private_data = mali_adp_get_configuration(mdev); + + mali_pm_get_dvfs_utilisation(mdev, + &stat->total_time, &stat->busy_time); +#else mali_pm_get_dvfs_utilisation(mdev, &stat->total_time, &stat->busy_time); stat->private_data = NULL; +#endif #ifdef CONFIG_DEVFREQ_THERMAL memcpy(&mdev->devfreq->last_status, stat, sizeof(*stat)); @@ -133,6 +146,9 @@ mali_devfreq_status(struct device *dev, struct devfreq_dev_status *stat) return 0; } +#if defined(UTGARD_HISILICON_PLUGIN) + +#else /* setup platform specific opp in platform.c*/ int __weak setup_opps(void) { @@ -144,6 +160,7 @@ int __weak term_opps(struct device *dev) { return 0; } +#endif static int mali_devfreq_init_freq_table(struct mali_device *mdev, struct devfreq_dev_profile *dp) @@ -153,7 +170,11 @@ static int mali_devfreq_init_freq_table(struct mali_device *mdev, unsigned long freq = 0; struct dev_pm_opp *opp; +#if defined(UTGARD_HISILICON_PLUGIN) + err = setup_opps(mdev->dev); +#else err = setup_opps(); +#endif if (err) return err; @@ -235,8 +256,14 @@ int mali_devfreq_init(struct mali_device *mdev) if (mali_devfreq_init_freq_table(mdev, dp)) return -EFAULT; +#if defined(UTGARD_HISILICON_PLUGIN) + mdev->devfreq = devfreq_add_device(mdev->dev, dp, + "gpu_ondemand", NULL); +#else mdev->devfreq = devfreq_add_device(mdev->dev, dp, "simple_ondemand", NULL); +#endif + if (IS_ERR(mdev->devfreq)) { mali_devfreq_term_freq_table(mdev); return PTR_ERR(mdev->devfreq); diff --git a/driver/src/devicedrv/mali/linux/mali_kernel_linux.c b/driver/src/devicedrv/mali/linux/mali_kernel_linux.c old mode 100755 new mode 100644 index 9bfa2bd..6a98adc --- a/driver/src/devicedrv/mali/linux/mali_kernel_linux.c +++ b/driver/src/devicedrv/mali/linux/mali_kernel_linux.c @@ -561,7 +561,12 @@ static int mali_probe(struct platform_device *pdev) mdev->clock = NULL; /* Allow probe to continue without clock. */ } else { +#if defined(UTGARD_HISILICON_PLUGIN) + err = clk_prepare(mdev->clock); + err |= clk_enable(mdev->clock); +#else err = clk_prepare_enable(mdev->clock); +#endif if (err) { MALI_PRINT_ERROR(("Failed to prepare and enable clock (%d)\n", err)); goto clock_prepare_failed; @@ -593,6 +598,10 @@ static int mali_probe(struct platform_device *pdev) if (0 == err) { MALI_DEBUG_PRINT(2, ("mali_probe(): Successfully initialized driver for platform device %s\n", pdev->name)); +#if defined(UTGARD_HISILICON_PLUGIN) && defined(CONFIG_MALI_DEVFREQ) + /* Disable clock, for make the count to be 0, and the power change function can enable the clock */ + clk_disable(mdev->clock); +#endif return 0; } else { MALI_PRINT_ERROR(("mali_probe(): failed to register sysfs entries")); @@ -613,7 +622,12 @@ static int mali_probe(struct platform_device *pdev) devfreq_init_failed: mali_pm_metrics_term(mdev); pm_metrics_init_failed: +#if defined(UTGARD_HISILICON_PLUGIN) + clk_disable(mdev->clock); + clk_unprepare(mdev->clock); +#else clk_disable_unprepare(mdev->clock); +#endif clock_prepare_failed: clk_put(mdev->clock); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) && defined(CONFIG_OF) \ @@ -653,7 +667,12 @@ static int mali_remove(struct platform_device *pdev) mali_pm_metrics_term(mdev); if (mdev->clock) { +#if defined(UTGARD_HISILICON_PLUGIN) + /* Because the power change fucntion had already disable the clock */ + clk_unprepare(mdev->clock); +#else clk_disable_unprepare(mdev->clock); +#endif clk_put(mdev->clock); mdev->clock = NULL; } diff --git a/driver/src/devicedrv/mali/linux/mali_linux_trace.h b/driver/src/devicedrv/mali/linux/mali_linux_trace.h old mode 100755 new mode 100644 index 2c91ddc..ecf9bf7 --- a/driver/src/devicedrv/mali/linux/mali_linux_trace.h +++ b/driver/src/devicedrv/mali/linux/mali_linux_trace.h @@ -18,7 +18,9 @@ #undef TRACE_SYSTEM #define TRACE_SYSTEM mali +#ifndef TRACEPOINTS_ENABLED #define TRACE_SYSTEM_STRING __stringfy(TRACE_SYSTEM) +#endif #define TRACE_INCLUDE_PATH . #define TRACE_INCLUDE_FILE mali_linux_trace diff --git a/driver/src/devicedrv/mali/platform/dt/drv_gpu_ext.h b/driver/src/devicedrv/mali/platform/dt/drv_gpu_ext.h new file mode 100644 index 0000000..a2908bb --- /dev/null +++ b/driver/src/devicedrv/mali/platform/dt/drv_gpu_ext.h @@ -0,0 +1,17 @@ +#ifndef __DRV_GPU_EXT_H__ +#define __DRV_GPU_EXT_H__ + +#include "hi_drv_module.h" +#include "hi_module.h" +#include "hi_type.h" + +typedef HI_S32 (*FN_GPU_Set_Freq_And_Volt)(HI_S32 s32Freq, HI_S32 s32Volt, HI_S32 s32DvfsEnable); +typedef HI_S32 (*FN_GPU_Set_Max_Freq)(HI_S32 s32Freq); +typedef struct +{ + FN_GPU_Set_Freq_And_Volt pfnGPUSetFreqAndVolt; + FN_GPU_Set_Max_Freq pfnGPUSetMaxFreq; +}GPU_EXT_FUNC_S; + +#endif /* __DRV_GPU_EXT_H__ */ + diff --git a/driver/src/devicedrv/mali/platform/dt/hi_drv_module.h b/driver/src/devicedrv/mali/platform/dt/hi_drv_module.h new file mode 100644 index 0000000..55330d5 --- /dev/null +++ b/driver/src/devicedrv/mali/platform/dt/hi_drv_module.h @@ -0,0 +1,57 @@ +/****************************************************************************** +Copyright (C), 2012-2014, Hisilicon Tech. Co., Ltd. +****************************************************************************** +File Name : hi_drv_module.h +Version : V1.0 Initial Draft +Author : sdk +Created : 2012/6/19 +Last Modified : +Description : The module manager. +Function List : None. +History : +******************************************************************************/ + +#ifndef __HI_DRV_MODULE_H__ +#define __HI_DRV_MODULE_H__ + +#include "hi_type.h" + +#ifdef __cplusplus + #if __cplusplus +extern "C" { + #endif +#endif /* __cplusplus */ + +#define HI_KMODULE_MAX_COUNT (256) +#define HI_KMODULE_MEM_MAX_COUNT (256*256) + +#define HI_FATAL_MODULE(fmt...) HI_FATAL_PRINT(HI_ID_MODULE, fmt) +#define HI_ERR_MODULE(fmt...) HI_ERR_PRINT(HI_ID_MODULE, fmt) +#define HI_WARN_MODULE(fmt...) HI_WARN_PRINT(HI_ID_MODULE, fmt) +#define HI_INFO_MODULE(fmt...) HI_INFO_PRINT(HI_ID_MODULE, fmt) + +HI_S32 HI_DRV_MMNGR_Init(HI_U32 u32ModuleCount, HI_U32 u32ModuleMemCount); +HI_VOID HI_DRV_MMNGR_Exit(HI_VOID); + +HI_S32 HI_DRV_MODULE_AllocId(HI_U8* pu8ModuleName, HI_U32 *pu32ModuleID, HI_S32 *ps32Status); +HI_S32 HI_DRV_MODULE_Register(HI_U32 u32ModuleID, const HI_U8* pu8ModuleName, HI_VOID* pFunc); +HI_S32 HI_DRV_MODULE_UnRegister(HI_U32 u32ModuleID); + +#ifdef CMN_MMGR_SUPPORT +HI_U8* HI_DRV_MODULE_GetNameByID(HI_U32 u32ModuleID); +HI_U32 HI_DRV_MODULE_GetIDByName(HI_U8* pu8Name); +#endif + +HI_S32 HI_DRV_MODULE_GetFunction(HI_U32 u32ModuleID, HI_VOID** ppFunc); + +HI_S32 MMNGR_DRV_ModInit(HI_U32 u32ModuleCount, HI_U32 u32ModuleMemCount); +HI_VOID MMNGR_DRV_ModExit(HI_VOID); + +#ifdef __cplusplus + #if __cplusplus +} + #endif +#endif /* __cplusplus */ + +#endif /* __HI_DRV_MODULE_H__ */ + diff --git a/driver/src/devicedrv/mali/platform/dt/hi_module.h b/driver/src/devicedrv/mali/platform/dt/hi_module.h new file mode 100755 index 0000000..3300708 --- /dev/null +++ b/driver/src/devicedrv/mali/platform/dt/hi_module.h @@ -0,0 +1,182 @@ +/****************************************************************************** +Copyright (C), 2012-2014, Hisilicon Tech. Co., Ltd. +****************************************************************************** +File Name : hi_module.h +Version : V1.0 Initial Draft +Author : sdk +Created : 2012/6/19 +Last Modified : +Description : The module name definition for all the MODULES +Function List : None. +History : +******************************************************************************/ +/** @addtogroup MODULES */ +/** @{ */ /** |<--- 8bit --->|<--- 8bit --->| + |--------------------------------------------------------------| + | HI_MOD_ID_E | mod defined data | chnID | + |--------------------------------------------------------------| + +mod defined data: private data define by each module(for example: sub-mod id), usually, set to 0. +*/ + +#define HI_HANDLE_MAKEHANDLE(mod, privatedata, chnid) (HI_HANDLE)( (((mod)& 0xffff) << 16) | ((((privatedata)& 0xff) << 8) ) | (((chnid) & 0xff)) ) + +#define HI_HANDLE_GET_MODID(handle) (((handle) >> 16) & 0xffff) +#define HI_HANDLE_GET_PriDATA(handle) (((handle) >> 8) & 0xff) +#define HI_HANDLE_GET_CHNID(handle) (((handle)) & 0xff) + +#define HI_UNUSED(x) ((x)=(x)) + +/** @} */ /**