#include <generated/utsrelease.h>
 #include <linux/string_helpers.h>
 #include <linux/devfreq.h>
+#include <linux/devfreq_cooling.h>
 #include <linux/devcoredump.h>
 #include <linux/sched/task.h>
 
        if (IS_ERR(gpu->devfreq.devfreq)) {
                DRM_DEV_ERROR(&gpu->pdev->dev, "Couldn't initialize GPU devfreq\n");
                gpu->devfreq.devfreq = NULL;
+               return;
        }
 
        devfreq_suspend_device(gpu->devfreq.devfreq);
+
+       gpu->cooling = of_devfreq_cooling_register(gpu->pdev->dev.of_node,
+                       gpu->devfreq.devfreq);
+       if (IS_ERR(gpu->cooling)) {
+               DRM_DEV_ERROR(&gpu->pdev->dev,
+                               "Couldn't register GPU cooling device\n");
+               gpu->cooling = NULL;
+       }
 }
 
 static int enable_pwrrail(struct msm_gpu *gpu)
        if (gpu->worker) {
                kthread_destroy_worker(gpu->worker);
        }
+
+       devfreq_cooling_unregister(gpu->cooling);
 }
 
        struct msm_gpu_state *crashstate;
        /* True if the hardware supports expanded apriv (a650 and newer) */
        bool hw_apriv;
+
+       struct thermal_cooling_device *cooling;
 };
 
 static inline struct msm_gpu *dev_to_gpu(struct device *dev)