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

Commit 8f98bf46 authored by Manaf Meethalavalappu Pallikunhi's avatar Manaf Meethalavalappu Pallikunhi
Browse files

drivers: thermal: qmi_sensor: Add support for extended sensor list



The QMI TS get sensor list supports maximum 32 sensors. But there
are targets that support more than 32 QMI TS sensors. To add more
sensors support as well as to make sure backward compatibility with
legacy sensor list, add new optional extended sensor list variable
in QMI TS interface. The first 32 sensors will be filled in legacy
sensor list variable and all other sensors will be filled with new
extended sensor list variable.

Add support to qmi sensor driver to get extended sensor list if any.

Change-Id: If31f0caf9a0a8a0639315d4b01f7d526e47e5c1b
Signed-off-by: default avatarManaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
parent 6bd93187
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -482,6 +482,29 @@ static int verify_sensor_and_register(struct qmi_ts_instance *ts)
		}
	}

	/* Check and get sensor list extended */
	for (i = 0; ts_resp->sensor_list_ext01_valid &&
		 (i < ts_resp->sensor_list_ext01_len); i++) {
		struct qmi_sensor *qmi_sens = NULL;

		list_for_each_entry(qmi_sens, &ts->ts_sensor_list,
					ts_node) {
			if ((strncasecmp(qmi_sens->qmi_name,
				ts_resp->sensor_list_ext01[i].sensor_id,
				QMI_TS_SENSOR_ID_LENGTH_MAX_V01)))
				continue;

			qmi_sens->connection_active = true;
			/*
			 * Send a temperature request notification.
			 */
			qmi_ts_request(qmi_sens, true);
			if (!qmi_sens->tz_dev)
				ret = qmi_register_sensor_device(qmi_sens);
			break;
		}
	}

	kfree(ts_resp);
	return ret;

+53 −22
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 */

#include <linux/soc/qcom/qmi.h>
@@ -19,7 +19,7 @@ static struct qmi_elem_info ts_sensor_type_v01_ei[] = {
	{
		.data_type      = QMI_EOTI,
		.array_type       = NO_ARRAY,
		.array_type       = QMI_COMMON_TLV_TYPE,
		.tlv_type       = QMI_COMMON_TLV_TYPE,
	},
};

@@ -27,7 +27,7 @@ struct qmi_elem_info ts_get_sensor_list_req_msg_v01_ei[] = {
	{
		.data_type      = QMI_EOTI,
		.array_type       = NO_ARRAY,
		.array_type       = QMI_COMMON_TLV_TYPE,
		.tlv_type       = QMI_COMMON_TLV_TYPE,
	},
};

@@ -45,7 +45,7 @@ struct qmi_elem_info ts_get_sensor_list_resp_msg_v01_ei[] = {
	{
		.data_type      = QMI_OPT_FLAG,
		.elem_len       = 1,
		.elem_size      = sizeof(uint8_t),
		.elem_size      = sizeof(u8),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x10,
		.offset         =
@@ -55,7 +55,7 @@ struct qmi_elem_info ts_get_sensor_list_resp_msg_v01_ei[] = {
	{
		.data_type      = QMI_DATA_LEN,
		.elem_len       = 1,
		.elem_size      = sizeof(uint8_t),
		.elem_size      = sizeof(u8),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x10,
		.offset         =
@@ -73,10 +73,41 @@ struct qmi_elem_info ts_get_sensor_list_resp_msg_v01_ei[] = {
					   sensor_list),
		.ei_array      = ts_sensor_type_v01_ei,
	},
	{
		.data_type      = QMI_OPT_FLAG,
		.elem_len       = 1,
		.elem_size      = sizeof(u8),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x11,
		.offset         =
			offsetof(struct ts_get_sensor_list_resp_msg_v01,
					   sensor_list_ext01_valid),
	},
	{
		.data_type      = QMI_DATA_LEN,
		.elem_len       = 1,
		.elem_size      = sizeof(u8),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x11,
		.offset         =
			offsetof(struct ts_get_sensor_list_resp_msg_v01,
					   sensor_list_ext01_len),
	},
	{
		.data_type      = QMI_STRUCT,
		.elem_len       = QMI_TS_SENSOR_LIST_EXT01_MAX_V01,
		.elem_size      = sizeof(struct ts_sensor_type_v01),
		.array_type       = VAR_LEN_ARRAY,
		.tlv_type       = 0x11,
		.offset         =
			offsetof(struct ts_get_sensor_list_resp_msg_v01,
					   sensor_list_ext01),
		.ei_array      = ts_sensor_type_v01_ei,
	},
	{
		.data_type      = QMI_EOTI,
		.array_type       = NO_ARRAY,
		.array_type       = QMI_COMMON_TLV_TYPE,
		.tlv_type       = QMI_COMMON_TLV_TYPE,
	},
};

@@ -95,7 +126,7 @@ struct qmi_elem_info ts_register_notification_temp_req_msg_v01_ei[] = {
	{
		.data_type      = QMI_UNSIGNED_1_BYTE,
		.elem_len       = 1,
		.elem_size      = sizeof(uint8_t),
		.elem_size      = sizeof(u8),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x02,
		.offset         = offsetof(
@@ -105,7 +136,7 @@ struct qmi_elem_info ts_register_notification_temp_req_msg_v01_ei[] = {
	{
		.data_type      = QMI_OPT_FLAG,
		.elem_len       = 1,
		.elem_size      = sizeof(uint8_t),
		.elem_size      = sizeof(u8),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x10,
		.offset         = offsetof(
@@ -115,7 +146,7 @@ struct qmi_elem_info ts_register_notification_temp_req_msg_v01_ei[] = {
	{
		.data_type      = QMI_UNSIGNED_4_BYTE,
		.elem_len       = 1,
		.elem_size      = sizeof(int),
		.elem_size      = sizeof(u32),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x10,
		.offset         = offsetof(
@@ -125,7 +156,7 @@ struct qmi_elem_info ts_register_notification_temp_req_msg_v01_ei[] = {
	{
		.data_type      = QMI_OPT_FLAG,
		.elem_len       = 1,
		.elem_size      = sizeof(uint8_t),
		.elem_size      = sizeof(u8),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x11,
		.offset         = offsetof(
@@ -135,7 +166,7 @@ struct qmi_elem_info ts_register_notification_temp_req_msg_v01_ei[] = {
	{
		.data_type      = QMI_UNSIGNED_4_BYTE,
		.elem_len       = 1,
		.elem_size      = sizeof(int),
		.elem_size      = sizeof(u32),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x11,
		.offset         = offsetof(
@@ -145,7 +176,7 @@ struct qmi_elem_info ts_register_notification_temp_req_msg_v01_ei[] = {
	{
		.data_type      = QMI_OPT_FLAG,
		.elem_len       = 1,
		.elem_size      = sizeof(uint8_t),
		.elem_size      = sizeof(u8),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x12,
		.offset         = offsetof(
@@ -155,7 +186,7 @@ struct qmi_elem_info ts_register_notification_temp_req_msg_v01_ei[] = {
	{
		.data_type      = QMI_UNSIGNED_4_BYTE,
		.elem_len       = 1,
		.elem_size      = sizeof(uint32_t),
		.elem_size      = sizeof(u32),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x12,
		.offset         = offsetof(
@@ -165,7 +196,7 @@ struct qmi_elem_info ts_register_notification_temp_req_msg_v01_ei[] = {
	{
		.data_type      = QMI_EOTI,
		.array_type       = NO_ARRAY,
		.array_type       = QMI_COMMON_TLV_TYPE,
		.tlv_type       = QMI_COMMON_TLV_TYPE,
	},
};

@@ -184,7 +215,7 @@ struct qmi_elem_info ts_register_notification_temp_resp_msg_v01_ei[] = {
	{
		.data_type      = QMI_EOTI,
		.array_type       = NO_ARRAY,
		.array_type       = QMI_COMMON_TLV_TYPE,
		.tlv_type       = QMI_COMMON_TLV_TYPE,
	},
};

@@ -211,7 +242,7 @@ struct qmi_elem_info ts_temp_report_ind_msg_v01_ei[] = {
	{
		.data_type      = QMI_OPT_FLAG,
		.elem_len       = 1,
		.elem_size      = sizeof(uint8_t),
		.elem_size      = sizeof(u8),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x10,
		.offset         = offsetof(struct ts_temp_report_ind_msg_v01,
@@ -220,7 +251,7 @@ struct qmi_elem_info ts_temp_report_ind_msg_v01_ei[] = {
	{
		.data_type      = QMI_UNSIGNED_4_BYTE,
		.elem_len       = 1,
		.elem_size      = sizeof(int),
		.elem_size      = sizeof(u32),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x10,
		.offset         = offsetof(struct ts_temp_report_ind_msg_v01,
@@ -229,7 +260,7 @@ struct qmi_elem_info ts_temp_report_ind_msg_v01_ei[] = {
	{
		.data_type      = QMI_OPT_FLAG,
		.elem_len       = 1,
		.elem_size      = sizeof(uint8_t),
		.elem_size      = sizeof(u8),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x11,
		.offset         = offsetof(struct ts_temp_report_ind_msg_v01,
@@ -238,7 +269,7 @@ struct qmi_elem_info ts_temp_report_ind_msg_v01_ei[] = {
	{
		.data_type      = QMI_UNSIGNED_4_BYTE,
		.elem_len       = 1,
		.elem_size      = sizeof(uint32_t),
		.elem_size      = sizeof(u32),
		.array_type       = NO_ARRAY,
		.tlv_type       = 0x11,
		.offset         = offsetof(struct ts_temp_report_ind_msg_v01,
@@ -247,7 +278,7 @@ struct qmi_elem_info ts_temp_report_ind_msg_v01_ei[] = {
	{
		.data_type      = QMI_EOTI,
		.array_type     = NO_ARRAY,
		.array_type       = QMI_COMMON_TLV_TYPE,
		.tlv_type       = QMI_COMMON_TLV_TYPE,
	},
};
+17 −13
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 */

#ifndef THERMAL_SENSOR_SERVICE_V01_H
@@ -21,6 +21,7 @@

#define QMI_TS_SENSOR_ID_LENGTH_MAX_V01 32
#define QMI_TS_SENSOR_LIST_MAX_V01 32
#define QMI_TS_SENSOR_LIST_EXT01_MAX_V01 64

struct ts_sensor_type_v01 {
	char sensor_id[QMI_TS_SENSOR_ID_LENGTH_MAX_V01 + 1];
@@ -34,22 +35,25 @@ extern struct qmi_elem_info ts_get_sensor_list_req_msg_v01_ei[];

struct ts_get_sensor_list_resp_msg_v01 {
	struct qmi_response_type_v01 resp;
	uint8_t sensor_list_valid;
	uint32_t sensor_list_len;
	u8 sensor_list_valid;
	u32 sensor_list_len;
	struct ts_sensor_type_v01 sensor_list[QMI_TS_SENSOR_LIST_MAX_V01];
	u8 sensor_list_ext01_valid;
	u32 sensor_list_ext01_len;
	struct ts_sensor_type_v01 sensor_list_ext01[QMI_TS_SENSOR_LIST_EXT01_MAX_V01];
};
#define TS_GET_SENSOR_LIST_RESP_MSG_V01_MAX_MSG_LEN 1067
#define TS_GET_SENSOR_LIST_RESP_MSG_V01_MAX_MSG_LEN 3183
extern struct qmi_elem_info ts_get_sensor_list_resp_msg_v01_ei[];

struct ts_register_notification_temp_req_msg_v01 {
	struct ts_sensor_type_v01 sensor_id;
	uint8_t send_current_temp_report;
	uint8_t temp_threshold_high_valid;
	u8 send_current_temp_report;
	u8 temp_threshold_high_valid;
	int temp_threshold_high;
	uint8_t temp_threshold_low_valid;
	u8 temp_threshold_low_valid;
	int temp_threshold_low;
	uint8_t seq_num_valid;
	uint32_t seq_num;
	u8 seq_num_valid;
	u32 seq_num;
};
#define TS_REGISTER_NOTIFICATION_TEMP_REQ_MSG_V01_MAX_MSG_LEN 61
extern struct qmi_elem_info ts_register_notification_temp_req_msg_v01_ei[];
@@ -71,10 +75,10 @@ enum ts_temp_report_type_enum_v01 {
struct ts_temp_report_ind_msg_v01 {
	struct ts_sensor_type_v01 sensor_id;
	enum ts_temp_report_type_enum_v01 report_type;
	uint8_t temp_valid;
	long temp;
	uint8_t seq_num_valid;
	uint32_t seq_num;
	u8 temp_valid;
	int temp;
	u8 seq_num_valid;
	u32 seq_num;
};
#define TS_TEMP_REPORT_IND_MSG_V01_MAX_MSG_LEN 57
extern struct qmi_elem_info ts_temp_report_ind_msg_v01_ei[];