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

Commit 546c5318 authored by Siddartha Mohanadoss's avatar Siddartha Mohanadoss
Browse files

thermal: tsens: Update TSENS property for reading efuse data



TSENS (temperature sensor) controller provides capability
to program the gain and offset for individual sensors so that
the controller reports the temperature. The efuse information
for gain and offset can be read during boot and programmed
at boot initialization and the application TSENS driver
does not need to support reading from the efuse region.
Update the property for reading the tsens efuse as optional
for such cases.

Change-Id: Icd637fcd264565b06bcb90f8e6f7b26c8d112f24
Signed-off-by: default avatarSiddartha Mohanadoss <smohanad@codeaurora.org>
parent 956d9b1a
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -34,16 +34,22 @@ Required properties:
	       should be "qcom,msmfalcon-tsens" for falcon TSENS driver.
	       The compatible property is used to identify the respective fusemap to use
	       for the corresponding SoC.
- reg : offset and length of the TSENS registers.
- reg : offset and length of the QFPROM registers used for storing
	the calibration data for the individual sensors.
- reg : offset and length of the TSENS registers with associated property in reg-names
	as "tsens_physical" and QFPROM registers with associated property in reg-names
	as "tsens_eeprom_physical". The efuse registers are used for storing
	the calibration data for the individual sensors. If the gain and offset are
	programmed by the TSENS control registers then adding the QFPROM register property
	is optional.
- reg-names : resource names used for the physical address of the TSENS
	      registers, the QFPROM efuse primary calibration address region,
	      Should be "tsens_physical" for physical address of the TSENS,
	      "tsens_eeprom_physical" for physical address where primary
	      calibration data is stored. This includes the backup
	      calibration address region if TSENS calibration data is stored
	      in the region.
	      in the region. The reg-name "tsens_eeprom_physical" property is
	      optional if the gain and offset are programmed by the TSENS
	      control registers and the status registers directly reports the TSENS
	      temperature readings.
- interrupts : TSENS interrupt to notify Upper/Lower temperature threshold.
- interrupt-names: Should be "tsens-upper-lower" for temperature threshold.
		   Add "tsens-critical" for Critical temperature threshold notification
@@ -53,7 +59,8 @@ Required properties:
- qcom,slope : One point calibration characterized slope data for each
	       sensor used to compute the offset. Slope is represented
	       as ADC code/DegC and the value is multipled by a factor
	       of 1000.
	       of 1000. If gain and offset are programmed by the TSENS control
	       registers then this property is optional.

Optional properties:
- qcom,calibration-less-mode : If present the pre-characterized data for offsets
+33 −27
Original line number Diff line number Diff line
@@ -831,6 +831,7 @@ struct tsens_tm_device {
	bool				prev_reading_avail;
	bool				calibration_less_mode;
	bool				tsens_local_init;
	bool				gain_offset_programmed;
	int				tsens_factor;
	uint32_t			tsens_num_sensor;
	int				tsens_irq;
@@ -5341,6 +5342,13 @@ static int get_device_tree_data(struct platform_device *pdev,
		return -ENODEV;
	}

	/* TSENS calibration region */
	tmdev->res_calib_mem = platform_get_resource_byname(pdev,
				IORESOURCE_MEM, "tsens_eeprom_physical");
	if (!tmdev->res_calib_mem) {
		pr_debug("Using controller programmed gain and offset\n");
		tmdev->gain_offset_programmed = true;
	} else {
		tsens_slope_data = devm_kzalloc(&pdev->dev,
			tsens_num_sensors * sizeof(u32), GFP_KERNEL);
		if (!tsens_slope_data)
@@ -5349,9 +5357,10 @@ static int get_device_tree_data(struct platform_device *pdev,
		rc = of_property_read_u32_array(of_node,
			"qcom,slope", tsens_slope_data, tsens_num_sensors);
		if (rc) {
		dev_err(&pdev->dev, "invalid or missing property: tsens-slope\n");
			dev_err(&pdev->dev, "missing property: tsens-slope\n");
			return rc;
		};
	}

	if (!of_match_node(tsens_match, of_node)) {
		pr_err("Need to read SoC specific fuse map\n");
@@ -5364,9 +5373,13 @@ static int get_device_tree_data(struct platform_device *pdev,
		return -ENODEV;
	}

	if (!tmdev->gain_offset_programmed) {
		for (i = 0; i < tsens_num_sensors; i++)
		tmdev->sensor[i].slope_mul_tsens_factor = tsens_slope_data[i];
			tmdev->sensor[i].slope_mul_tsens_factor =
							tsens_slope_data[i];
		tmdev->tsens_factor = TSENS_SLOPE_FACTOR;
	}

	tmdev->tsens_num_sensor = tsens_num_sensors;
	tmdev->calibration_less_mode = of_property_read_bool(of_node,
				"qcom,calibration-less-mode");
@@ -5536,15 +5549,7 @@ static int get_device_tree_data(struct platform_device *pdev,
		goto fail_unmap_tsens_region;
	}

	/* TSENS calibration region */
	tmdev->res_calib_mem = platform_get_resource_byname(pdev,
				IORESOURCE_MEM, "tsens_eeprom_physical");
	if (!tmdev->res_calib_mem) {
		pr_err("Could not get qfprom physical address resource\n");
		rc = -EINVAL;
		goto fail_unmap_tsens;
	}

	if (!tmdev->gain_offset_programmed) {
		tmdev->calib_len = tmdev->res_calib_mem->end -
					tmdev->res_calib_mem->start + 1;

@@ -5555,6 +5560,7 @@ static int get_device_tree_data(struct platform_device *pdev,
			rc = -EINVAL;
			goto fail_unmap_tsens;
		}
	}

	return 0;