#include <linux/slab.h>
#include <linux/types.h>
#include <linux/amlogic/cpu_version.h>
-#include <linux/amlogic/scpi_protocol.h>
#include <linux/printk.h>
#include <linux/platform_device.h>
#include <linux/of.h>
struct thermal_zone_device *tzd;
};
+static struct meson_cooldev *meson_gcooldev;
+
static int get_cool_dev_type(char *type)
{
if (!strcmp(type, "cpufreq"))
return NULL;
}
+static struct cool_dev *get_gcool_dev_by_node(struct meson_cooldev *mgcooldev,
+ struct device_node *np)
+{
+ int i;
+ struct cool_dev *dev;
+
+ if (!np)
+ return NULL;
+ for (i = 0; i < mgcooldev->cool_dev_num; i++) {
+ dev = &mgcooldev->cool_devs[i];
+ if (dev->np == np)
+ return dev;
+ }
+ return NULL;
+}
+
+
static int meson_set_min_status(struct thermal_cooling_device *cdev,
unsigned long min_state)
{
return err;
}
+int meson_gcooldev_min_update(struct thermal_cooling_device *cdev)
+{
+ struct gpufreq_cooling_device *gf_cdev;
+ struct gpucore_cooling_device *gc_cdev;
+ //struct device_node *parent;
+ struct cool_dev *cool = NULL;
+ long min_state;
+ int ret;
+
+ cool = get_gcool_dev_by_node(meson_gcooldev, cdev->np);
+ if (!cool)
+ return -ENODEV;
+
+ if (cool->cooling_dev == NULL)
+ cool->cooling_dev = cdev;
+
+ if (cool->min_state == 0)
+ return 0;
+
+ switch (get_cool_dev_type(cool->device_type)) {
+ case COOL_DEV_TYPE_GPU_CORE:
+ gc_cdev = (struct gpucore_cooling_device *)cdev->devdata;
+ cdev->ops->get_max_state(cdev, &min_state);
+ min_state = min_state - cool->min_state;
+ break;
+
+ case COOL_DEV_TYPE_GPU_FREQ:
+ gf_cdev = (struct gpufreq_cooling_device *)cdev->devdata;
+ min_state = gf_cdev->get_gpu_freq_level(cool->min_state);
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ ret = meson_set_min_status(cdev, min_state);
+ if (!ret)
+ pr_info("meson_cdev set min sussces\n");
+ return 0;
+}
+EXPORT_SYMBOL(meson_gcooldev_min_update);
+
int meson_cooldev_min_update(struct platform_device *pdev, int index)
{
struct meson_cooldev *mcooldev = platform_get_drvdata(pdev);
int ret;
int cpu, c_id;
+ /*save pdev for mali ko api*/
+ meson_gcooldev = platform_get_drvdata(pdev);
cool = get_cool_dev_by_node(pdev, cdev->np);
if (!cool)
return -ENODEV;
--- /dev/null
+/*
+ * include/linux/amlogic/meson_cooldev.h
+ *
+ * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#ifndef __MESON_COOLDEV_H__
+#define __MESON_COOLDEV_H__
+
+#ifndef mc_capable
+#define mc_capable() 0
+#endif
+
+struct thermal_cooling_device;
+extern int meson_gcooldev_min_update(struct thermal_cooling_device *cdev);
+#endif
+