diff --git a/drivers/soc/rockchip/Kconfig b/drivers/soc/rockchip/Kconfig index 0377c11b47fe..7305f2deaec8 100644 --- a/drivers/soc/rockchip/Kconfig +++ b/drivers/soc/rockchip/Kconfig @@ -90,4 +90,10 @@ config ROCKCHIP_SUSPEND_MODE help Say Y here if you want to set the suspend mode to the ATF. +config ROCKCHIP_SYSTEM_MONITOR + bool "Rockchip system monitor support" + default y + help + Say y here to enable rockchip system monitor support. + endif diff --git a/drivers/soc/rockchip/Makefile b/drivers/soc/rockchip/Makefile index a9df72f7e0d8..0d246ba0f475 100644 --- a/drivers/soc/rockchip/Makefile +++ b/drivers/soc/rockchip/Makefile @@ -13,7 +13,7 @@ obj-$(CONFIG_ROCKCHIP_IPA) += rockchip_ipa.o obj-$(CONFIG_ROCKCHIP_OPP) += rockchip_opp_select.o obj-$(CONFIG_ROCKCHIP_PVTM) += rockchip_pvtm.o obj-$(CONFIG_ROCKCHIP_SUSPEND_MODE) += rockchip_pm_config.o +obj-$(CONFIG_ROCKCHIP_SYSTEM_MONITOR) += rockchip_system_monitor.o obj-$(CONFIG_ROCK_CHIP_SOC_CAMERA) += rk_camera.o obj-y += rk_vendor_storage.o -obj-y += rockchip_system_monitor.o diff --git a/drivers/soc/rockchip/rockchip_system_monitor.c b/drivers/soc/rockchip/rockchip_system_monitor.c index 9642219c209e..ae20db1fc17b 100644 --- a/drivers/soc/rockchip/rockchip_system_monitor.c +++ b/drivers/soc/rockchip/rockchip_system_monitor.c @@ -698,6 +698,18 @@ int rockchip_monitor_cpu_high_temp_adjust(struct monitor_dev_info *info, } EXPORT_SYMBOL(rockchip_monitor_cpu_high_temp_adjust); +static int rockchip_monitor_update_devfreq(struct devfreq *df) +{ + int ret = 0; + +#ifdef CONFIG_PM_DEVFREQ + mutex_lock(&df->lock); + ret = update_devfreq(df); + mutex_unlock(&df->lock); +#endif + return ret; +}; + int rockchip_monitor_dev_low_temp_adjust(struct monitor_dev_info *info, bool is_low) { @@ -712,9 +724,7 @@ int rockchip_monitor_dev_low_temp_adjust(struct monitor_dev_info *info, if (info->devp && info->devp->data) { df = (struct devfreq *)info->devp->data; - mutex_lock(&df->lock); - update_devfreq(df); - mutex_unlock(&df->lock); + rockchip_monitor_update_devfreq(df); } return 0; @@ -735,9 +745,7 @@ int rockchip_monitor_dev_high_temp_adjust(struct monitor_dev_info *info, if (info->devp && info->devp->data) { df = (struct devfreq *)info->devp->data; - mutex_lock(&df->lock); - update_devfreq(df); - mutex_unlock(&df->lock); + rockchip_monitor_update_devfreq(df); } return 0; diff --git a/include/soc/rockchip/rockchip-system-status.h b/include/soc/rockchip/rockchip-system-status.h index 99e4428ba8f8..8a40ed16f8a8 100644 --- a/include/soc/rockchip/rockchip-system-status.h +++ b/include/soc/rockchip/rockchip-system-status.h @@ -1,18 +1,12 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */ /* - * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope 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. + * Copyright (C) 2019, Fuzhou Rockchip Electronics Co., Ltd */ + #ifndef __SOC_ROCKCHIP_SYSTEM_STATUS_H #define __SOC_ROCKCHIP_SYSTEM_STATUS_H +#ifdef CONFIG_ROCKCHIP_SYSTEM_MONITOR int rockchip_register_system_status_notifier(struct notifier_block *nb); int rockchip_unregister_system_status_notifier(struct notifier_block *nb); void rockchip_set_system_status(unsigned long status); @@ -20,5 +14,40 @@ void rockchip_clear_system_status(unsigned long status); unsigned long rockchip_get_system_status(void); int rockchip_add_system_status_interface(struct device *dev); void rockchip_update_system_status(const char *buf); +#else +static inline int +rockchip_register_system_status_notifier(struct notifier_block *nb) +{ + return -ENOTSUPP; +}; + +static inline int +rockchip_unregister_system_status_notifier(struct notifier_block *nb) +{ + return -ENOTSUPP; +}; + +static inline void rockchip_set_system_status(unsigned long status) +{ +}; + +static inline void rockchip_clear_system_status(unsigned long status) +{ +}; + +static inline unsigned long rockchip_get_system_status(void) +{ + return 0; +}; + +static inline int rockchip_add_system_status_interface(struct device *dev) +{ + return -ENOTSUPP; +}; + +static inline void rockchip_update_system_status(const char *buf) +{ +}; +#endif /* CONFIG_ROCKCHIP_SYSTEM_MONITOR */ #endif diff --git a/include/soc/rockchip/rockchip_system_monitor.h b/include/soc/rockchip/rockchip_system_monitor.h index 9f0806d2d8d6..d35e3671249e 100644 --- a/include/soc/rockchip/rockchip_system_monitor.h +++ b/include/soc/rockchip/rockchip_system_monitor.h @@ -103,6 +103,7 @@ struct monitor_dev_profile { struct cpumask allowed_cpus; }; +#ifdef CONFIG_ROCKCHIP_SYSTEM_MONITOR struct monitor_dev_info * rockchip_system_monitor_register(struct device *dev, struct monitor_dev_profile *devp); @@ -119,4 +120,58 @@ int rockchip_monitor_suspend_low_temp_adjust(struct monitor_dev_info *info); int rockchip_system_monitor_adjust_cdev_state(struct thermal_cooling_device *cdev, int temp, unsigned long *state); +#else +static inline struct monitor_dev_info * +rockchip_system_monitor_register(struct device *dev, + struct monitor_dev_profile *devp) +{ + return ERR_PTR(-ENOTSUPP); +}; + +static inline void +rockchip_system_monitor_unregister(struct monitor_dev_info *info) +{ +} + +static inline int +rockchip_monitor_cpu_low_temp_adjust(struct monitor_dev_info *info, bool is_low) +{ + return 0; +}; + +static inline int +rockchip_monitor_cpu_high_temp_adjust(struct monitor_dev_info *info, + bool is_high) +{ + return 0; +}; + +static inline int +rockchip_monitor_dev_low_temp_adjust(struct monitor_dev_info *info, bool is_low) +{ + return 0; +}; + +static inline int +rockchip_monitor_dev_high_temp_adjust(struct monitor_dev_info *info, + bool is_high) +{ + return 0; +}; + +static inline int +rockchip_monitor_suspend_low_temp_adjust(struct monitor_dev_info *info) +{ + return 0; +}; + +static inline int +rockchip_system_monitor_adjust_cdev_state(struct thermal_cooling_device *cdev, + int temp, unsigned long *state) +{ + return 0; +} + +#endif /* CONFIG_ROCKCHIP_SYSTEM_MONITOR */ + #endif