Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81de8624 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drivers: thermal: virtual-sensor: Add virtual sensor"

parents aa74733e 0b90b1e7
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
Regulator cooling device.

The regulator cooling device, will be used to place a voltage floor
restriction on a rail.

Properties:

- compatible:
	Usage: required
	Value type: <string>
	Definition: shall be "qcom,regulator-cooling-device"

- cdev-supply:
	Usage: required
	Value type: <phandle>
	Definition: phandle to the regulator to which the cooling device will
			place a floor mitigation.

- regulator-levels:
	Usage: required
	Value type: <U32 array>
	Definition: Array of regulator voltages the cooling device should
			use to place a floor restriction. The voltages should
			be specified in descending order.

- #cooling-cells: Must be 2. Please refer to
			<devicetree/bindings/thermal/thermal.txt> for more
			details.

Example:

	mv_cdev: mx-cdev-lvl {
		compatible = "qcom,regulator-cooling-device";
		cdev-supply = <&regulator-cdev-supply>;
		regulator-levels = <RPMH_REGULATOR_LEVEL_NOM
			RPMH_REGULATOR_LEVEL_OFF>;
		#cooling-cells = <2>;
	};
+21 −0
Original line number Diff line number Diff line
@@ -21,6 +21,16 @@ config QTI_THERMAL_LIMITS_DCVS
	  tracking temperatures of the CPUs and taking thermal action in the
	  hardware without s/w intervention.

config QTI_VIRTUAL_SENSOR
	bool "QTI Virtual Sensor driver"
	depends on THERMAL_OF
	help
	  This driver has the information about the virtual sensors used by
	  QTI chipset's and registers the virtual sensors to a thermal zone.
	  The virtual sensor information includes the underlying thermal
	  sensors to query for temperature and the aggregation logic to
	  determine the virtual sensor temperature.

config QTI_AOP_REG_COOLING_DEVICE
	bool "QTI AOP Regulator cooling device"
	depends on THERMAL_OF && MSM_QMP
@@ -29,3 +39,14 @@ config QTI_AOP_REG_COOLING_DEVICE
	  device will be used by QTI chipset to place a floor voltage
	  restriction at low temperatures. The cooling device will message
	  the AOP using mail box to establish the floor voltage.

config REGULATOR_COOLING_DEVICE
	bool "Regulator voltage floor cooling device"
	depends on REGULATOR && THERMAL_OF
	help
	  This implements a mitigation device to place a minimum voltage floor
	  on a particular regulator. This mitigation device will be used by low
	  temperature reliability rules to mitigate a regulator at nominal
	  voltage.

	  If you want this support, you should say Y here.
+2 −0
Original line number Diff line number Diff line
obj-$(CONFIG_QCOM_TSENS)	+= qcom_tsens.o
qcom_tsens-y			+= tsens.o tsens-common.o tsens-8916.o tsens-8974.o tsens-8960.o tsens-8996.o
obj-$(CONFIG_QTI_THERMAL_LIMITS_DCVS) += msm_lmh_dcvs.o lmh_dbg.o
obj-$(CONFIG_QTI_VIRTUAL_SENSOR) += qti_virtual_sensor.o
obj-$(CONFIG_QTI_AOP_REG_COOLING_DEVICE) += regulator_aop_cdev.o
obj-$(CONFIG_REGULATOR_COOLING_DEVICE) += regulator_cdev.o
+103 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2017-2018, The Linux Foundation. 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 version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * 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.
 */


#include <linux/thermal.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/err.h>
#include <linux/platform_device.h>

#include "qti_virtual_sensor.h"

static const struct virtual_sensor_data qti_virtual_sensors[] = {
	{
		.virt_zone_name = "gpu-virt-max-step",
		.num_sensors = 2,
		.sensor_names = {"gpu0-usr",
				"gpu1-usr"},
		.logic = VIRT_MAXIMUM,
	},
	{
		.virt_zone_name = "silv-virt-max-step",
		.num_sensors = 4,
		.sensor_names = {"cpu0-silver-usr",
				"cpu1-silver-usr",
				"cpu2-silver-usr",
				"cpu3-silver-usr"},
		.logic = VIRT_MAXIMUM,
	},
	{
		.virt_zone_name = "gold-virt-max-step",
		.num_sensors = 4,
		.sensor_names = {"cpu0-gold-usr",
				"cpu1-gold-usr",
				"cpu2-gold-usr",
				"cpu3-gold-usr"},
		.logic = VIRT_MAXIMUM,
	},
	{
		.virt_zone_name = "hexa-silv-max-step",
		.num_sensors = 6,
		.sensor_names = {"cpu0-silver-usr",
				"cpu1-silver-usr",
				"cpu2-silver-usr",
				"cpu3-silver-usr",
				"cpu4-silver-usr",
				"cpu5-silver-usr"},
		.logic = VIRT_MAXIMUM,
	},
	{
		.virt_zone_name = "dual-gold-max-step",
		.num_sensors = 2,
		.sensor_names = {"cpu0-gold-usr",
				"cpu1-gold-usr"},
		.logic = VIRT_MAXIMUM,
	},
	{
		.virt_zone_name = "deca-cpu-max-step",
		.num_sensors = 10,
		.sensor_names = {"apc0-cpu0-usr",
				"apc0-cpu1-usr",
				"apc0-cpu2-usr",
				"apc0-cpu3-usr",
				"apc0-l2-usr",
				"apc1-cpu0-usr",
				"apc1-cpu1-usr",
				"apc1-cpu2-usr",
				"apc1-cpu3-usr",
				"apc1-l2-usr"},
		.logic = VIRT_MAXIMUM,
	},
};

int qti_virtual_sensor_register(struct device *dev)
{
	int sens_ct = 0;
	static int idx;
	struct thermal_zone_device *tz;

	sens_ct = ARRAY_SIZE(qti_virtual_sensors);
	for (; idx < sens_ct; idx++) {
		tz = devm_thermal_of_virtual_sensor_register(dev,
				&qti_virtual_sensors[idx]);
		if (IS_ERR(tz))
			dev_dbg(dev, "sensor:%d register error:%ld\n",
					idx, PTR_ERR(tz));
		else
			dev_dbg(dev, "sensor:%d registered\n", idx);
	}

	return 0;
}
EXPORT_SYMBOL(qti_virtual_sensor_register);
+29 −0
Original line number Diff line number Diff line
/* Copyright (c) 2017-2018, The Linux Foundation. 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 version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * 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 __QTI_VIRT_SENS_H__
#define __QTI_VIRT_SENS_H__

#ifdef CONFIG_QTI_VIRTUAL_SENSOR

int qti_virtual_sensor_register(struct device *dev);

#else

static inline int qti_virtual_sensor_register(struct device *dev)
{
	return -ENODEV;
}

#endif /* CONFIG_QTI_VIRTUAL_SENSOR */

#endif /* __QTI_VIRT_SENS_H__ */
Loading