[COMMON] thermal: samsung: Logging MCINFO MR4 status
authorHyeonseong Gil <hs.gil@samsung.com>
Wed, 19 Oct 2016 05:08:45 +0000 (14:08 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:13:31 +0000 (17:13 +0900)
Change-Id: I04823d0c9a92af9a8c433ca847189687cdbd9298
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/thermal/samsung/exynos_tmu.c

index 655aadb8b5872e13129d095c63d73b4c3ac9705f..628e6148e775845b346cc662d551f06ec52306cf 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/exynos-ss.h>
 #include <soc/samsung/tmu.h>
 #include <soc/samsung/ect_parser.h>
+#include <soc/samsung/exynos-mcinfo.h>
 #include <dt-bindings/thermal/thermal_exynos.h>
 
 #include "exynos_tmu.h"
@@ -703,10 +704,18 @@ static void exynos8895_tmu_control(struct platform_device *pdev, bool on)
                writel(global_avg_con, data->base + EXYNOS_TMU_REG_AVG_CON);
 
 }
+
+#define MCINFO_LOG_THRESHOLD   (4)
+
 static int exynos_get_temp(void *p, int *temp)
 {
        struct exynos_tmu_data *data = p;
        struct thermal_cooling_device *cdev;
+       unsigned int mcinfo_count;
+       unsigned int mcinfo_result[4] = {0, 0, 0, 0};
+       unsigned int mcinfo_logging = 0;
+       unsigned int mcinfo_temp = 0;
+       unsigned int i;
 
        if (!data || !data->tmu_read)
                return -EINVAL;
@@ -733,6 +742,21 @@ static int exynos_get_temp(void *p, int *temp)
        mutex_unlock(&thermal_suspend_lock);
 
        exynos_ss_thermal(data->pdata, *temp / 1000, data->tmu_name, 0);
+
+       if (data->id == 0) {
+               mcinfo_count = get_mcinfo_base_count();
+               get_refresh_rate(mcinfo_result);
+
+               for (i = 0; i < mcinfo_count; i++) {
+                       mcinfo_temp |= (mcinfo_result[i] & 0xf) << (8 * i);
+
+                       if (mcinfo_result[i] >= MCINFO_LOG_THRESHOLD)
+                               mcinfo_logging = 1;
+               }
+
+               if (mcinfo_logging == 1)
+                       exynos_ss_thermal(NULL, mcinfo_temp, "MCINFO", 0);
+       }
        return 0;
 }