[Feature]add MT2731_MP2_MR2_SVN388 baseline version
Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/apps/ivt-base/thermal-manager/Makefile b/src/apps/ivt-base/thermal-manager/Makefile
new file mode 100644
index 0000000..7208696
--- /dev/null
+++ b/src/apps/ivt-base/thermal-manager/Makefile
@@ -0,0 +1,33 @@
+TARGET := thermal_manager
+SOURCES := thermal_manager.c
+OBJ_PATH = thermal_manager.o
+#OBJECTS := $(SOURCES:.c=.o)
+OBJ = thermal_manager.o
+LDFLAGS += -lmtcloader
+
+CFLAGS += -O3 -D__EXTERN_C_LIB__ -ldl
+GET_LOCAL_DIR = $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
+
+.PHONY: all clean install
+
+all: $(TARGET)
+
+${TARGET}:${OBJ_PATH}
+ ${CC} ${OBJ} ${CFLAGS} -o $@
+
+#$(TARGET): $(OBJECTS)
+# $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
+
+clean:
+ $(RM) $(OBJECTS) $(TARGET)
+
+MTKTHERMAL_DIR_INSTALL = "/usr/bin/"
+
+install: $(TARGET)
+ echo $(DESTDIR)
+ echo $(PREFIX)
+ echo $(shell pwd)
+ install -d $(DESTDIR)$(PREFIX)/bin/
+ install -d $(DESTDIR)$(PREFIX)/lib/
+ install -d ${DESTDIR}${PREFIX}/lib/pkgconfig/
+ install -m 755 $(TARGET) $(DESTDIR)$(PREFIX)/bin/
diff --git a/src/apps/ivt-base/thermal-manager/dis_thermal.conf b/src/apps/ivt-base/thermal-manager/dis_thermal.conf
new file mode 100644
index 0000000..a4db549
--- /dev/null
+++ b/src/apps/ivt-base/thermal-manager/dis_thermal.conf
@@ -0,0 +1,62 @@
+Sec_Chip_Name
+MT2731
+Sec_End
+Sec_CD_TM
+/proc/mtkcooler/mtktscpu-sysrst
+
+/proc/mtkcooler/cpu00
+EXIT 6000
+/proc/mtkcooler/cpu_adaptive_0
+EXIT 6000
+/proc/mtkcooler/mtktspmic-sysrst
+
+/proc/mtkcooler/mtktspa4g-sysrst
+
+/proc/mtkcooler/mtk-cl-PApower
+
+/proc/mtkcooler/mtk-cl-noIMS
+
+/proc/mtkcooler/mtk-cl-adp-mutt
+
+/proc/mtkcooler/mtktsrf-sysrst
+
+/proc/mtkcooler/mtktsdram-sysrst
+
+/proc/mtkcooler/mtktsaplt-sysrst
+
+Sec_End
+Sec_ITP
+/proc/driver/thermal/clatm_setting
+0 1000 10 15 1 200 0 10 0
+/proc/driver/thermal/clmutt
+0 400 100 300 200 200 200 100 25500 105000
+Sec_End
+Sec_RTP
+/proc/driver/thermal/tzcpu
+1 135000 0 mtktscpu-sysrst 105000 0 cpu00 100000 0 cpu_adaptive_0 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 1000
+/proc/driver/thermal/tzpmic
+1 145000 0 mtktspmic-sysrst 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 1000
+/proc/driver/thermal/tzpa4g
+1 125000 0 mtktspa4g-sysrst 115000 0 mtk-cl-PApower 110000 0 mtk-cl-noIMS 105000 0 mtk-cl-adp-mutt 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 1000
+/proc/driver/thermal/tzrf
+1 125000 0 mtktsrf-sysrst 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 1000
+/proc/driver/thermal/tzdram
+1 125000 0 mtktsdram-sysrst 0 0 no-cooler 53000 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 1000
+/proc/driver/thermal/tzaplt
+1 125000 0 mtktsaplt-sysrst 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 1000
+Sec_End
+Sec_TZ_TM
+/proc/mtktz/mtktscpu
+ma_len 1
+/proc/mtktz/mtktspmic
+ma_len 1
+/proc/mtktz/mtktspa4g
+ma_len 1
+/proc/mtktz/mtktsrf
+ma_len 1
+/proc/mtktz/mtktsdram
+ma_len 1
+/proc/mtktz/mtktsaplt
+ma_len 1
+Sec_End
+EOF
diff --git a/src/apps/ivt-base/thermal-manager/lib/libmtcloader.so b/src/apps/ivt-base/thermal-manager/lib/libmtcloader.so
new file mode 100644
index 0000000..ab21659
--- /dev/null
+++ b/src/apps/ivt-base/thermal-manager/lib/libmtcloader.so
Binary files differ
diff --git a/src/apps/ivt-base/thermal-manager/lib64/libmtcloader.so b/src/apps/ivt-base/thermal-manager/lib64/libmtcloader.so
new file mode 100644
index 0000000..1979748
--- /dev/null
+++ b/src/apps/ivt-base/thermal-manager/lib64/libmtcloader.so
Binary files differ
diff --git a/src/apps/ivt-base/thermal-manager/thermal-manager.service b/src/apps/ivt-base/thermal-manager/thermal-manager.service
new file mode 100644
index 0000000..77160c3
--- /dev/null
+++ b/src/apps/ivt-base/thermal-manager/thermal-manager.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=thermal_manager
+
+[Service]
+ExecStart=/usr/bin/thermal_manager /data/thermal/thermal.conf
+Type=simple
+
+[Install]
+WantedBy=multi-user.target
diff --git a/src/apps/ivt-base/thermal-manager/thermal.conf b/src/apps/ivt-base/thermal-manager/thermal.conf
new file mode 100644
index 0000000..134c9b5
--- /dev/null
+++ b/src/apps/ivt-base/thermal-manager/thermal.conf
@@ -0,0 +1,62 @@
+Sec_Chip_Name
+MT2731
+Sec_End
+Sec_CD_TM
+/proc/mtkcooler/mtktscpu-sysrst
+
+/proc/mtkcooler/cpu00
+EXIT 6000
+/proc/mtkcooler/cpu_adaptive_0
+EXIT 6000
+/proc/mtkcooler/mtktspmic-sysrst
+
+/proc/mtkcooler/mtktspa4g-sysrst
+
+/proc/mtkcooler/mtk-cl-PApower
+EXIT 2000
+/proc/mtkcooler/mtk-cl-noIMS
+
+/proc/mtkcooler/mtk-cl-adp-mutt
+
+/proc/mtkcooler/mtktsrf-sysrst
+
+/proc/mtkcooler/mtktsdram-sysrst
+
+/proc/mtkcooler/mtktsaplt-sysrst
+
+Sec_End
+Sec_ITP
+/proc/driver/thermal/clatm_setting
+0 1000 10 15 1 200 0 10 0
+/proc/driver/thermal/clmutt
+0 400 100 300 200 200 200 100 25500 105000
+Sec_End
+Sec_RTP
+/proc/driver/thermal/tzcpu
+3 125000 0 mtktscpu-sysrst 120000 0 cpu00 115000 0 cpu_adaptive_0 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 1000
+/proc/driver/thermal/tzpmic
+1 125000 0 mtktspmic-sysrst 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 1000
+/proc/driver/thermal/tzpa4g
+4 125000 0 mtktspa4g-sysrst 115000 0 mtk-cl-PApower 110000 0 mtk-cl-noIMS 105000 0 mtk-cl-adp-mutt 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 1000
+/proc/driver/thermal/tzrf
+1 125000 0 mtktsrf-sysrst 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 1000
+/proc/driver/thermal/tzdram
+1 125000 0 mtktsdram-sysrst 0 0 no-cooler 53000 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 1000
+/proc/driver/thermal/tzaplt
+1 125000 0 mtktsaplt-sysrst 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 0 0 no-cooler 1000
+Sec_End
+Sec_TZ_TM
+/proc/mtktz/mtktscpu
+ma_len 1
+/proc/mtktz/mtktspmic
+ma_len 1
+/proc/mtktz/mtktspa4g
+ma_len 1
+/proc/mtktz/mtktsrf
+ma_len 1
+/proc/mtktz/mtktsdram
+ma_len 1
+/proc/mtktz/mtktsaplt
+ma_len 1
+Sec_End
+EOF
diff --git a/src/apps/ivt-base/thermal-manager/thermal_manager.c b/src/apps/ivt-base/thermal-manager/thermal_manager.c
new file mode 100644
index 0000000..29fa32d
--- /dev/null
+++ b/src/apps/ivt-base/thermal-manager/thermal_manager.c
@@ -0,0 +1,144 @@
+/* Copyright Statement:
+ *
+ * This software/firmware and related documentation ("MediaTek Software") are
+ * protected under relevant copyright laws. The information contained herein is
+ * confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+ * the prior written permission of MediaTek inc. and/or its licensors, any
+ * reproduction, modification, use or disclosure of MediaTek Software, and
+ * information contained herein, in whole or in part, shall be strictly
+ * prohibited.
+ *
+ * MediaTek Inc. (C) 2012. All rights reserved.
+ *
+ * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+ * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+ * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ * ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+ * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+ * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+ * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+ * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+ * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+ * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+ * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+ * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+ * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+ * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+ * RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+ * MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+ * CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+ *
+ * The following software/firmware and/or related documentation ("MediaTek
+ * Software") have been modified by MediaTek Inc. All revisions are subject to
+ * any receiver's applicable license agreements with MediaTek Inc.
+ */
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * thermal_manager.c
+ *
+ * Project:
+ * --------
+ * YuSu
+ *
+ * Description:
+ * ------------
+ * Set default values to all thermal zone device drivers and cooling device drivers when
+ * system init.
+ *
+ * Author:
+ * -------
+ * CT Fang (mtk02403)
+ *
+ ****************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+//#include <cutils/properties.h>
+//#include <android/log.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <dlfcn.h>
+//#include <utils/Log.h>
+//#include <cutils/log.h>
+
+#if 0
+#define MTK_LOG_ENABLE (1)
+#define TM_LOG_TAG "thermal_mgr"
+
+#if MTK_LOG_ENABLE
+#define TM_LOG(_priority_, _fmt_, args...) LOG_PRI(_priority_, TM_LOG_TAG, _fmt_, ##args)
+static int _tm_debug_on = 1;
+#else
+#define TM_LOG(_priority_, _fmt_, args...)
+#endif
+#endif
+
+int (*loadmtc)(char *) = NULL;
+#define LIB_FULL_NAME "libmtcloader.so"
+
+typedef int (*load)(char *);
+
+int (*loadchange_policy)(char *, int) = NULL;
+typedef int (*load_change_policy)(char *, int);
+
+int main(int argc, char **argv)
+{
+ int i = 0;
+ void *handle, *func, *func2;
+
+printf("[thermal_manager]main\n");
+
+ for (; i < argc; i++) {
+ printf("[thermal_manager] argv[%d] %s.\n", i, argv[i]);
+ }
+
+ handle = dlopen(LIB_FULL_NAME, RTLD_NOW);
+
+ if (handle == NULL) {
+ printf("[thermal_manager] fails to load lib err: %s.\n", dlerror());
+ return -1;
+ }
+
+ func = dlsym(handle, "loadmtc");
+ loadmtc = (load)func;
+
+ if (loadmtc == NULL) {
+ printf("[thermal_manager] loadmtc err: %s.\n", dlerror());
+ dlclose(handle);
+ return -1;
+ }
+
+ if (argc - 1 > 0) {
+ int ret = 0;
+
+ if (argc == 2) {
+ ret = loadmtc(argv[1]);
+ } else if (argc == 3) {
+ func2 = dlsym(handle, "change_policy");
+ loadchange_policy = (load_change_policy)func2;
+
+ if (loadchange_policy == NULL) {
+ dlclose(handle);
+ return -1;
+ }
+ ret = loadchange_policy(argv[1], atoi(argv[2]));
+ }
+ dlclose(handle);
+ return ret;
+ } else {
+ //int ret = loadmtc("/vendor/etc/.tp/thermal.conf"); /* default policy */
+ int ret = loadmtc("/data/thermal/thermal.conf"); /* default policy */
+ dlclose(handle);
+ return ret;
+ }
+}
+