mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 04:12:04 -04:00
Merge "defconfig: msm: Enable thermal drivers for autogen3 targets"
This commit is contained in:
commit
822e2263a6
2 changed files with 52 additions and 3 deletions
|
|
@ -68,3 +68,9 @@ CONFIG_BRIDGE=y
|
|||
CONFIG_QTI_TZ_LOG=y
|
||||
CONFIG_CRYPTO_SHA1_ARM64_CE=y
|
||||
CONFIG_MSM_NPU=y
|
||||
CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=10000
|
||||
CONFIG_THERMAL_WRITABLE_TRIPS=y
|
||||
CONFIG_THERMAL_TSENS=y
|
||||
CONFIG_QTI_QMI_COOLING_DEVICE=y
|
||||
CONFIG_QTI_CPU_ISOLATE_COOLING_DEVICE=y
|
||||
CONFIG_QTI_THERMAL_LIMITS_DCVS=y
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "%s:%s " fmt, KBUILD_MODNAME, __func__
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
#include <linux/platform_device.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/thermal.h>
|
||||
#include <linux/ipc_logging.h>
|
||||
|
||||
#include "../thermal_core.h"
|
||||
|
||||
|
|
@ -52,6 +53,15 @@
|
|||
#define BCL_VBAT_THRESH_BASE 2250
|
||||
|
||||
#define MAX_PERPH_COUNT 2
|
||||
#define IPC_LOGPAGES 2
|
||||
|
||||
#define BCL_IPC(dev, msg, args...) do { \
|
||||
if ((dev) && (dev)->ipc_log) { \
|
||||
ipc_log_string((dev)->ipc_log, \
|
||||
"[%s]: %s: " msg, \
|
||||
current->comm, __func__, args); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
enum bcl_dev_type {
|
||||
BCL_IBAT_LVL0,
|
||||
|
|
@ -95,6 +105,7 @@ struct bcl_device {
|
|||
struct device *dev;
|
||||
struct regmap *regmap;
|
||||
uint16_t fg_bcl_addr;
|
||||
void *ipc_log;
|
||||
struct bcl_peripheral_data param[BCL_TYPE_MAX];
|
||||
};
|
||||
|
||||
|
|
@ -269,6 +280,8 @@ static int bcl_read_ibat(void *data, int *adc_value)
|
|||
bat_data->last_val = *adc_value;
|
||||
}
|
||||
pr_debug("ibat:%d mA ADC:0x%02x\n", bat_data->last_val, val);
|
||||
BCL_IPC(bat_data->dev, "ibat:%d mA ADC:0x%02x\n",
|
||||
bat_data->last_val, val);
|
||||
|
||||
bcl_read_exit:
|
||||
return ret;
|
||||
|
|
@ -338,6 +351,8 @@ static int bcl_read_vbat_tz(struct thermal_zone_device *tzd, int *adc_value)
|
|||
bat_data->last_val = *adc_value;
|
||||
}
|
||||
pr_debug("vbat:%d mv\n", bat_data->last_val);
|
||||
BCL_IPC(bat_data->dev, "vbat:%d mv ADC:0x%02x\n",
|
||||
bat_data->last_val, val);
|
||||
|
||||
bcl_read_exit:
|
||||
return ret;
|
||||
|
|
@ -402,6 +417,7 @@ static int bcl_set_lbat(void *data, int low, int high)
|
|||
static int bcl_read_lbat(void *data, int *adc_value)
|
||||
{
|
||||
int ret = 0;
|
||||
int ibat = 0, vbat = 0;
|
||||
unsigned int val = 0;
|
||||
struct bcl_peripheral_data *bat_data =
|
||||
(struct bcl_peripheral_data *)data;
|
||||
|
|
@ -429,6 +445,12 @@ static int bcl_read_lbat(void *data, int *adc_value)
|
|||
bat_data->last_val = *adc_value;
|
||||
pr_debug("lbat:%d val:%d\n", bat_data->type,
|
||||
bat_data->last_val);
|
||||
if (bcl_perph->param[BCL_IBAT_LVL0].tz_dev)
|
||||
bcl_read_ibat(&bcl_perph->param[BCL_IBAT_LVL0], &ibat);
|
||||
if (bcl_perph->param[BCL_VBAT_LVL0].tz_dev)
|
||||
bcl_read_vbat_tz(bcl_perph->param[BCL_VBAT_LVL0].tz_dev, &vbat);
|
||||
BCL_IPC(bcl_perph, "LVLbat:%d val:%d\n", bat_data->type,
|
||||
bat_data->last_val);
|
||||
|
||||
bcl_read_exit:
|
||||
return ret;
|
||||
|
|
@ -439,15 +461,25 @@ static irqreturn_t bcl_handle_irq(int irq, void *data)
|
|||
struct bcl_peripheral_data *perph_data =
|
||||
(struct bcl_peripheral_data *)data;
|
||||
unsigned int irq_status = 0;
|
||||
int ibat = 0, vbat = 0;
|
||||
struct bcl_device *bcl_perph;
|
||||
|
||||
bcl_perph = perph_data->dev;
|
||||
bcl_read_register(bcl_perph, BCL_IRQ_STATUS, &irq_status);
|
||||
if (bcl_perph->param[BCL_IBAT_LVL0].tz_dev)
|
||||
bcl_read_ibat(&bcl_perph->param[BCL_IBAT_LVL0], &ibat);
|
||||
if (bcl_perph->param[BCL_VBAT_LVL0].tz_dev)
|
||||
bcl_read_vbat_tz(bcl_perph->param[BCL_VBAT_LVL0].tz_dev, &vbat);
|
||||
|
||||
if (irq_status & perph_data->status_bit_idx) {
|
||||
pr_debug("Irq:%d triggered for bcl type:%s. status:%u\n",
|
||||
pr_debug(
|
||||
"Irq:%d triggered for bcl type:%s. status:%u ibat=%d vbat=%d\n",
|
||||
irq, bcl_int_names[perph_data->type],
|
||||
irq_status);
|
||||
irq_status, ibat, vbat);
|
||||
BCL_IPC(bcl_perph,
|
||||
"Irq:%d triggered for bcl type:%s. status:%u ibat=%d vbat=%d\n",
|
||||
irq, bcl_int_names[perph_data->type],
|
||||
irq_status, ibat, vbat);
|
||||
of_thermal_handle_trip_temp(perph_data->dev->dev,
|
||||
perph_data->tz_dev,
|
||||
perph_data->status_bit_idx);
|
||||
|
|
@ -636,6 +668,7 @@ static int bcl_remove(struct platform_device *pdev)
|
|||
static int bcl_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct bcl_device *bcl_perph = NULL;
|
||||
char bcl_name[40];
|
||||
|
||||
if (bcl_device_ct >= MAX_PERPH_COUNT) {
|
||||
dev_err(&pdev->dev, "Max bcl peripheral supported already.\n");
|
||||
|
|
@ -663,6 +696,16 @@ static int bcl_probe(struct platform_device *pdev)
|
|||
|
||||
dev_set_drvdata(&pdev->dev, bcl_perph);
|
||||
|
||||
snprintf(bcl_name, sizeof(bcl_name), "bcl_0x%04x_%d",
|
||||
bcl_perph->fg_bcl_addr,
|
||||
bcl_device_ct - 1);
|
||||
|
||||
bcl_perph->ipc_log = ipc_log_context_create(IPC_LOGPAGES,
|
||||
bcl_name, 0);
|
||||
if (!bcl_perph->ipc_log)
|
||||
pr_err("%s: unable to create IPC Logging for %s\n",
|
||||
__func__, bcl_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue