diff --git a/MAINTAINERS b/MAINTAINERS index 9817d928c404..af6c0842aeda 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14367,6 +14367,7 @@ AMLOGIC THERMAL DRIVER M: Huan Biao F: drivers/amlgoic/thermal/meson_tsensor.c F: drivers/amlogic/thermal/meson_cooldev.c +F: include/linux/amlogic/meson_cooldev.h AMLOGIC G12A Audio DRIVER M: Xing Wang diff --git a/drivers/amlogic/thermal/cpucore_cooling.c b/drivers/amlogic/thermal/cpucore_cooling.c index f3c0f8c4a9c4..58055c232a70 100644 --- a/drivers/amlogic/thermal/cpucore_cooling.c +++ b/drivers/amlogic/thermal/cpucore_cooling.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include /** * struct cpucore_cooling_device - data for cooling device with cpucore diff --git a/drivers/amlogic/thermal/meson_cooldev.c b/drivers/amlogic/thermal/meson_cooldev.c index e89578cd8f43..2e3282bb7e73 100644 --- a/drivers/amlogic/thermal/meson_cooldev.c +++ b/drivers/amlogic/thermal/meson_cooldev.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -62,6 +61,8 @@ struct meson_cooldev { struct thermal_zone_device *tzd; }; +static struct meson_cooldev *meson_gcooldev; + static int get_cool_dev_type(char *type) { if (!strcmp(type, "cpufreq")) @@ -92,6 +93,23 @@ static struct cool_dev *get_cool_dev_by_node(struct platform_device *pdev, 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) { @@ -136,6 +154,48 @@ end: 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); @@ -147,6 +207,8 @@ int meson_cooldev_min_update(struct platform_device *pdev, int index) 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; diff --git a/include/linux/amlogic/meson_cooldev.h b/include/linux/amlogic/meson_cooldev.h new file mode 100644 index 000000000000..bee2582b6d76 --- /dev/null +++ b/include/linux/amlogic/meson_cooldev.h @@ -0,0 +1,28 @@ +/* + * 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 +