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

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

Merge "thermal: tsens: Update sensor ID index"

parents dee200e2 389d449f
Loading
Loading
Loading
Loading
+13 −17
Original line number Diff line number Diff line
@@ -1820,7 +1820,7 @@ int32_t qpnp_adc_get_devicetree_data(struct platform_device *pdev,
	struct qpnp_adc_amux *adc_channel_list;
	struct qpnp_adc_properties *adc_prop;
	struct qpnp_adc_amux_properties *amux_prop;
	int count_adc_channel_list = 0, decimation, rc = 0, i = 0;
	int count_adc_channel_list = 0, decimation = 0, rc = 0, i = 0;
	int decimation_tm_hc = 0, fast_avg_setup_tm_hc = 0, cal_val_hc = 0;
	bool adc_hc;

@@ -1927,22 +1927,6 @@ int32_t qpnp_adc_get_devicetree_data(struct platform_device *pdev,
				return -EINVAL;
			}

			/*
			 * ADC_TM_HC decimation setting is common across
			 * channels.
			 */
			if (!of_device_is_compatible(node,
						"qcom,qpnp-adc-tm-hc")) {
				rc = of_property_read_u32(child,
					"qcom,decimation", &decimation);
				if (rc) {
					pr_err("Invalid decimation\n");
					return -EINVAL;
				}
			} else {
				decimation = decimation_tm_hc;
			}

			if (!strcmp(calibration_param, "absolute")) {
				if (adc_hc)
					calib_type = ADC_HC_ABS_CAL;
@@ -1980,6 +1964,18 @@ int32_t qpnp_adc_get_devicetree_data(struct platform_device *pdev,
			fast_avg_setup = fast_avg_setup_tm_hc;
		}

		/* ADC_TM_HC decimation setting is common across channels */
		if (!of_device_is_compatible(node, "qcom,qpnp-adc-tm-hc")) {
			rc = of_property_read_u32(child,
				"qcom,decimation", &decimation);
			if (rc) {
				pr_err("Invalid decimation\n");
				return -EINVAL;
			}
		} else {
			decimation = decimation_tm_hc;
		}

		if (of_device_is_compatible(node, "qcom,qpnp-vadc-hc")) {
			rc = of_property_read_u32(child, "qcom,cal-val",
							&cal_val_hc);
+47 −50
Original line number Diff line number Diff line
@@ -1066,20 +1066,28 @@ static int tsens_get_sw_id_mapping_for_controller(
	return 0;
}

int tsens_get_hw_id_mapping(int sensor_sw_id, int *sensor_client_id)
int tsens_get_hw_id_mapping(int thermal_sensor_num, int *sensor_client_id)
{
	int i = 0;
	bool id_found = false;
	struct tsens_tm_device *tmdev = NULL;
	struct device_node *of_node = NULL;
	const struct of_device_id *id;
	uint32_t tsens_max_sensors = 0, idx = 0, i = 0;

	tmdev = get_tsens_controller_for_client_id(sensor_sw_id);
	if (tmdev == NULL) {
		pr_debug("TSENS early init not done\n");
	if (list_empty(&tsens_device_list)) {
		pr_err("%s: TSENS controller not available\n", __func__);
		return -EPROBE_DEFER;
	}

	list_for_each_entry(tmdev, &tsens_device_list, list)
		tsens_max_sensors += tmdev->tsens_num_sensor;

	if (tsens_max_sensors != thermal_sensor_num) {
		pr_err("TSENS total sensors is %d, thermal expects:%d\n",
			tsens_max_sensors, thermal_sensor_num);
		return -EINVAL;
	}

	list_for_each_entry(tmdev, &tsens_device_list, list) {
		of_node = tmdev->pdev->dev.of_node;
		if (of_node == NULL) {
			pr_err("Invalid of_node??\n");
@@ -1100,34 +1108,26 @@ int tsens_get_hw_id_mapping(int sensor_sw_id, int *sensor_client_id)
		if (!strcmp(id->compatible, "qcom,msm8996-tsens") ||
			(!strcmp(id->compatible, "qcom,msmcobalt-tsens")) ||
			(!strcmp(id->compatible, "qcom,msmhamster-tsens"))) {
		/* Assign a client id which will be used to get the
			/* Assign client id's that is used to get the
			 * controller and hw_sensor details
			 */
		while (i < tmdev->tsens_num_sensor && !id_found) {
			if (sensor_sw_id == tmdev->sensor[i].sensor_client_id) {
				*sensor_client_id =
			for (i = 0; i < tmdev->tsens_num_sensor; i++) {
				sensor_client_id[idx] =
					tmdev->sensor[i].sensor_client_id;
				id_found = true;
			}
			i++;
				idx++;
			}
		} else {
		/* Assign the corresponding hw sensor number which is done
			/* Assign the corresponding hw sensor number
			 * prior to support for multiple controllres
			 */
		while (i < tmdev->tsens_num_sensor && !id_found) {
			if (sensor_sw_id == tmdev->sensor[i].sensor_client_id) {
				*sensor_client_id =
			for (i = 0; i < tmdev->tsens_num_sensor; i++) {
				sensor_client_id[idx] =
					tmdev->sensor[i].sensor_hw_num;
				id_found = true;
				idx++;
			}
			i++;
		}
	}

	if (!id_found)
		return -EINVAL;

	return 0;
}
EXPORT_SYMBOL(tsens_get_hw_id_mapping);
@@ -1383,7 +1383,7 @@ static int msm_tsens_get_temp(int sensor_client_id, int *temp)
	}

	if ((!tmdev->prev_reading_avail) && !tmdev->tsens_valid_status_check) {
		while (!((readl_relaxed(trdy_addr)) & TSENS_TRDY_MASK))
		while (!((readl_relaxed_no_log(trdy_addr)) & TSENS_TRDY_MASK))
			usleep_range(TSENS_TRDY_RDY_MIN_TIME,
				TSENS_TRDY_RDY_MAX_TIME);
		tmdev->prev_reading_avail = true;
@@ -1394,7 +1394,7 @@ static int msm_tsens_get_temp(int sensor_client_id, int *temp)
	else
		last_temp_mask = TSENS_SN_STATUS_TEMP_MASK;

	code = readl_relaxed(sensor_addr +
	code = readl_relaxed_no_log(sensor_addr +
			(sensor_hw_num << TSENS_STATUS_ADDR_OFFSET));
	last_temp = code & last_temp_mask;

@@ -1406,14 +1406,14 @@ static int msm_tsens_get_temp(int sensor_client_id, int *temp)
		if (code & valid_status_mask)
			last_temp_valid = true;
		else {
			code = readl_relaxed(sensor_addr +
			code = readl_relaxed_no_log(sensor_addr +
				(sensor_hw_num << TSENS_STATUS_ADDR_OFFSET));
			last_temp2 = code & last_temp_mask;
			if (code & valid_status_mask) {
				last_temp = last_temp2;
				last_temp2_valid = true;
			} else {
				code = readl_relaxed(sensor_addr +
				code = readl_relaxed_no_log(sensor_addr +
					(sensor_hw_num <<
					TSENS_STATUS_ADDR_OFFSET));
				last_temp3 = code & last_temp_mask;
@@ -5700,8 +5700,6 @@ static void tsens_debugfs_init(void)
	}
}

int tsens_sensor_sw_idx = 0;

static int tsens_thermal_zone_register(struct tsens_tm_device *tmdev)
{
	int rc = 0, i = 0;
@@ -5715,7 +5713,7 @@ static int tsens_thermal_zone_register(struct tsens_tm_device *tmdev)
		char name[18];

		snprintf(name, sizeof(name), "tsens_tz_sensor%d",
					tsens_sensor_sw_idx);
			tmdev->sensor[i].sensor_client_id);
		tmdev->sensor[i].mode = THERMAL_DEVICE_ENABLED;
		tmdev->sensor[i].tm = tmdev;
		if (tmdev->tsens_type == TSENS_TYPE3) {
@@ -5741,7 +5739,6 @@ static int tsens_thermal_zone_register(struct tsens_tm_device *tmdev)
				goto fail;
			}
		}
		tsens_sensor_sw_idx++;
	}

	if (tmdev->tsens_type == TSENS_TYPE3) {
+4 −14
Original line number Diff line number Diff line
@@ -2460,7 +2460,6 @@ fail:

static int create_sensor_id_map(struct device *dev)
{
	int i = 0;
	int ret = 0;

	tsens_id_map = devm_kzalloc(dev,
@@ -2471,20 +2470,11 @@ static int create_sensor_id_map(struct device *dev)
		return -ENOMEM;
	}

	for (i = 0; i < max_tsens_num; i++) {
		ret = tsens_get_hw_id_mapping(i, &tsens_id_map[i]);
		/* If return -ENXIO, hw_id is default in sequence */
	ret = tsens_get_hw_id_mapping(max_tsens_num, tsens_id_map);
	if (ret) {
			if (ret == -ENXIO) {
				tsens_id_map[i] = i;
				ret = 0;
			} else {
				pr_err("Failed to get hw id for id:%d.err:%d\n",
						i, ret);
		pr_err("Failed to get tsens id's:%d\n", ret);
		goto fail;
	}
		}
	}

	return ret;
fail:
+1 −1
Original line number Diff line number Diff line
@@ -492,7 +492,7 @@ static int32_t qpnp_adc_tm_rc_check_channel_en(struct qpnp_adc_tm_chip *chip)
{
	u8 adc_tm_ctl = 0, status_low = 0, status_high = 0;
	int rc = 0, i = 0;
	bool ldo_en;
	bool ldo_en = false;

	for (i = 0; i < chip->max_channels_available; i++) {
		rc = qpnp_adc_tm_read_reg(chip, QPNP_BTM_Mn_CTL(i),