edgetpu: thermal: tmu: add tpu pause/resume feature

Add tpu pause/resume feature

Bug: 194307914
Test: boot to home and tpu pause/resume worked properly
Change-Id: I737dc6d10cb8f1300459e72045d6b47788e3ee2c
Signed-off-by: David Chao <davidchao@google.com>
diff --git a/drivers/edgetpu/abrolhos-thermal.c b/drivers/edgetpu/abrolhos-thermal.c
index 6e7141f..82a8a5a 100644
--- a/drivers/edgetpu/abrolhos-thermal.c
+++ b/drivers/edgetpu/abrolhos-thermal.c
@@ -16,6 +16,7 @@
 #include <linux/slab.h>
 #include <linux/thermal.h>
 #include <linux/version.h>
+#include <soc/google/gs101_tmu.h>
 
 #include "abrolhos-platform.h"
 #include "abrolhos-pm.h"
@@ -323,6 +324,21 @@
 
 static DEVICE_ATTR_RW(user_vote);
 
+static int tpu_pause_callback(enum thermal_pause_state action, void *dev)
+{
+	int ret = -EINVAL;
+
+	if (!dev)
+		return ret;
+
+	if (action == THERMAL_SUSPEND)
+		ret = edgetpu_thermal_suspend(dev);
+	else if (action == THERMAL_RESUME)
+		ret = edgetpu_thermal_resume(dev);
+
+	return ret;
+}
+
 static int
 tpu_thermal_cooling_register(struct edgetpu_thermal *thermal, char *type)
 {
@@ -369,6 +385,8 @@
 		return err;
 	}
 
+	register_tpu_thermal_pause_cb(tpu_pause_callback, dev);
+
 	return 0;
 }
 
@@ -413,7 +431,6 @@
 	mutex_unlock(&cooling->lock);
 	return ret;
 }
-EXPORT_SYMBOL_GPL(edgetpu_thermal_suspend);
 
 int edgetpu_thermal_resume(struct device *dev)
 {
@@ -435,4 +452,3 @@
 	mutex_unlock(&cooling->lock);
 	return ret;
 }
-EXPORT_SYMBOL_GPL(edgetpu_thermal_resume);