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

Commit 450de015 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drivers: thermal: Snapshot of bcl driver from msm-4.14"

parents f8960f5f e58e59cd
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
===============================================================================
BCL Peripheral driver for PMIC5:
===============================================================================
Qualcomm Technologies, Inc's PMIC has battery current limiting peripheral,
which can monitor for high battery current and low battery voltage in the
hardware. The BCL peripheral driver interacts with the PMIC peripheral using
the SPMI driver interface. The hardware can take threshold for notifying for
high battery current or low battery voltage events. This driver works only
with PMIC version 5, where the same BCL peripheral can be found in multiple
PMIC's that are used in a device, with limited functionalities. For example,
one PMIC can have only vbat monitoring, while the other PMIC can have both
vbat and ibat monitoring. This is a common driver, that can interact
with the multiple BCL peripherals.

Required Parameters:
- compatible: must be
	'qcom,bcl-v5' for bcl peripheral in PMIC version 5.
- reg: <a b> where 'a' is the starting register address of the PMIC
	peripheral and 'b' is the size of the peripheral address space.
- interrupts: <a b c d> Where,
		'a' is the SLAVE ID of the PMIC,
		'b' is the peripheral ID,
		'c' is the interrupt number in PMIC and
		'd' is the interrupt type.
- interrupt-names: user defined names for the interrupts. These
		interrupt names will be used by the drivers to identify the
		interrupts, instead of specifying the ID's. bcl driver will
		accept these standard interrupts.
		"bcl-ibat-lvl0",
		"bcl-ibat-lvl1",
		"bcl-vbat-lvl0",
		"bcl-vbat-lvl1",
		"bcl-vbat-lvl2",

Example:
		bcl@4200 {
			compatible = "qcom,bcl-v5";
			reg = <0x4200 0x100>;
			interrupts = <0x2 0x42 0x0 IRQ_TYPE_NONE>,
					<0x2 0x42 0x1 IRQ_TYPE_NONE>;
			interrupt-names = "bcl-ibat-lvl0",
						"bcl-vbat-lvl0";
		};
+14 −0
Original line number Diff line number Diff line
===============================================================================
PMIC state of charge driver:
===============================================================================
Battery state of charge driver can monitor for change in battery charge and
notify thermal framework, when the value goes below a certain threshold.

Required Parameters:
- compatible: must be 'qcom,msm-bcl-soc' for battery state of charge driver.

Optional Parameters:

		bcl-soc {
			compatible = "qcom,msm-bcl-soc";
		};
+46 −4
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ struct devfreq_cooling_device {
	struct thermal_cooling_device *cdev;
	struct devfreq *devfreq;
	unsigned long cooling_state;
	unsigned long cooling_min_state;
	u32 *power_table;
	u32 *freq_table;
	size_t freq_table_size;
@@ -70,13 +71,15 @@ struct devfreq_cooling_device {
/**
 * partition_enable_opps() - disable all opps above a given state
 * @dfc:	Pointer to devfreq we are operating on
 * @cdev_state:	cooling device state we're setting
 * @cdev_max_state: Max cooling device state we're setting
 * @cdev_min_state: Min cooling device state we're setting
 *
 * Go through the OPPs of the device, enabling all OPPs until
 * @cdev_state and disabling those frequencies above it.
 */
static int partition_enable_opps(struct devfreq_cooling_device *dfc,
				 unsigned long cdev_state)
				 unsigned long cdev_max_state,
				 unsigned long cdev_min_state)
{
	int i;
	struct device *dev = dfc->devfreq->dev.parent;
@@ -85,7 +88,8 @@ static int partition_enable_opps(struct devfreq_cooling_device *dfc,
		struct dev_pm_opp *opp;
		int ret = 0;
		unsigned int freq = dfc->freq_table[i];
		bool want_enable = i >= cdev_state ? true : false;
		bool want_enable = (i >= cdev_max_state) &&
				      (i <= cdev_min_state);

		opp = dev_pm_opp_find_freq_exact(dev, freq, !want_enable);

@@ -118,6 +122,41 @@ static int devfreq_cooling_get_max_state(struct thermal_cooling_device *cdev,
	return 0;
}

static int devfreq_cooling_get_min_state(struct thermal_cooling_device *cdev,
					 unsigned long *state)
{
	struct devfreq_cooling_device *dfc = cdev->devdata;

	*state = dfc->cooling_min_state;

	return 0;
}

static int devfreq_cooling_set_min_state(struct thermal_cooling_device *cdev,
					 unsigned long state)
{
	struct devfreq_cooling_device *dfc = cdev->devdata;
	struct devfreq *df = dfc->devfreq;
	struct device *dev = df->dev.parent;
	int ret;

	if (state == dfc->cooling_min_state)
		return 0;

	dev_dbg(dev, "Setting cooling min state %lu\n", state);

	if (state >= dfc->freq_table_size)
		state = dfc->freq_table_size - 1;

	ret = partition_enable_opps(dfc, dfc->cooling_state, state);
	if (ret)
		return ret;

	dfc->cooling_min_state = state;

	return 0;
}

static int devfreq_cooling_get_cur_state(struct thermal_cooling_device *cdev,
					 unsigned long *state)
{
@@ -144,7 +183,7 @@ static int devfreq_cooling_set_cur_state(struct thermal_cooling_device *cdev,
	if (state >= dfc->freq_table_size)
		return -EINVAL;

	ret = partition_enable_opps(dfc, state);
	ret = partition_enable_opps(dfc, state, dfc->cooling_min_state);
	if (ret)
		return ret;

@@ -396,6 +435,8 @@ static struct thermal_cooling_device_ops devfreq_cooling_ops = {
	.get_max_state = devfreq_cooling_get_max_state,
	.get_cur_state = devfreq_cooling_get_cur_state,
	.set_cur_state = devfreq_cooling_set_cur_state,
	.get_min_state = devfreq_cooling_get_min_state,
	.set_min_state = devfreq_cooling_set_min_state,
};

/**
@@ -534,6 +575,7 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
		goto free_tables;
	dfc->id = err;

	dfc->cooling_min_state = dfc->freq_table_size - 1;
	snprintf(dev_name, sizeof(dev_name), "thermal-devfreq-%d", dfc->id);

	cdev = thermal_of_cooling_device_register(np, dev_name, dfc,
+22 −0
Original line number Diff line number Diff line
@@ -9,3 +9,25 @@ config QCOM_TSENS
	  thermal zone device via the mode file results in disabling the sensor.
	  Also able to set threshold temperature for both hot and cold and update
	  when a threshold is reached.

config QTI_BCL_PMIC5
	bool "BCL driver for BCL peripherals in PMIC5"
	depends on SPMI && THERMAL_OF
	help
	  Say Y here to enable this BCL driver for PMIC5. This driver
	  provides routines to configure and monitor the BCL
	  PMIC peripheral. This driver registers the battery current and
	  voltage sensors with the thermal core framework and can take
	  threshold input and notify the thermal core when the threshold is
	  reached.

config QTI_BCL_SOC_DRIVER
	bool "QTI Battery state of charge sensor driver"
	depends on THERMAL_OF
	help
	  This driver registers battery state of charge as a sensor with
	  thermal zone. This sensor can monitor for state of charge
	  threshold and notify the thermal framework.

	  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-v2.o
obj-$(CONFIG_QTI_BCL_PMIC5) += bcl_pmic5.o
obj-$(CONFIG_QTI_BCL_SOC_DRIVER) += bcl_soc.o
Loading