mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-18 16:01:32 +01:00
thermal: Convert .get_temp() return value to millicelsius
Linux kernel .get_temp() callback reports values in millicelsius, U-Boot currently reports them in celsius. Align the two and report in millicelsius. Update drivers accordingly. Update callsites that use thermal_get_temp() as well. The 'temperature' command now reports temperature in millicelsius as well, with additional accuracy. This changes command line ABI slightly. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: David Zang <davidzangcs@gmail.com> [trini: Update test/cmd/temperature.c] Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
79fe4655d6
commit
0ee639ff5a
@ -230,6 +230,7 @@ int print_cpuinfo(void)
|
||||
ret = uclass_get_device(UCLASS_THERMAL, 0, &thermal_dev);
|
||||
if (!ret) {
|
||||
ret = thermal_get_temp(thermal_dev, &cpu_tmp);
|
||||
cpu_tmp /= 1000;
|
||||
|
||||
if (!ret)
|
||||
printf(" at %dC", cpu_tmp);
|
||||
|
||||
@ -279,7 +279,7 @@ int print_cpuinfo(void)
|
||||
if (!ret) {
|
||||
ret = thermal_get_temp(udev, &temp);
|
||||
if (!ret)
|
||||
printf("CPU current temperature: %dC\n", temp);
|
||||
printf("CPU current temperature: %dC\n", temp / 1000);
|
||||
else
|
||||
debug(" - failed to get CPU current temperature\n");
|
||||
} else {
|
||||
|
||||
@ -32,7 +32,7 @@ static int do_get(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
if (ret)
|
||||
return CMD_RET_FAILURE;
|
||||
|
||||
printf("%s: %d C\n", dev->name, temp);
|
||||
printf("%s: %d mC\n", dev->name, temp);
|
||||
|
||||
return CMD_RET_SUCCESS;
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ static int cpu_imx_get_temp(struct cpu_imx_plat *plat)
|
||||
return 0xdeadbeef;
|
||||
}
|
||||
|
||||
return cpu_tmp;
|
||||
return cpu_tmp / 1000;
|
||||
}
|
||||
#else
|
||||
static int cpu_imx_get_temp(struct cpu_imx_plat *plat)
|
||||
|
||||
@ -651,6 +651,7 @@ static int omap_hsmmc_execute_tuning(struct udevice *dev, uint opcode)
|
||||
printf("Couldn't get temperature for tuning\n");
|
||||
return ret;
|
||||
}
|
||||
temperature /= 1000;
|
||||
val = readl(&mmc_base->dll);
|
||||
val |= DLL_SWT;
|
||||
writel(val, &mmc_base->dll);
|
||||
|
||||
@ -72,7 +72,7 @@ int imx_sc_thermal_get_temp(struct udevice *dev, int *temp)
|
||||
break;
|
||||
}
|
||||
|
||||
*temp = cpu_temp / 1000;
|
||||
*temp = cpu_temp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ int imx_thermal_get_temp(struct udevice *dev, int *temp)
|
||||
cpu_tmp = read_cpu_temperature(dev);
|
||||
}
|
||||
|
||||
*temp = cpu_tmp;
|
||||
*temp = cpu_tmp * 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ int imx_tmu_get_temp(struct udevice *dev, int *temp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
*temp = cpu_tmp / 1000;
|
||||
*temp = cpu_tmp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ static int rcar_gen3_thermal_get_temp(struct udevice *dev, int *temp)
|
||||
const struct equation_set_coef *coef;
|
||||
int adj, decicelsius, reg, thcode;
|
||||
|
||||
/* Read register and convert to degree Celsius */
|
||||
/* Read register and convert to millidegree Celsius */
|
||||
reg = rcar_gen3_thermal_read(tsc, REG_GEN3_TEMP) & CTEMP_MASK;
|
||||
|
||||
if (reg < tsc->thcode[1]) {
|
||||
@ -183,8 +183,8 @@ static int rcar_gen3_thermal_get_temp(struct udevice *dev, int *temp)
|
||||
|
||||
/* Guaranteed operating range is -40C to 125C. */
|
||||
|
||||
/* Reporting is done in degree Celsius */
|
||||
*temp = (decicelsius * 100 + adj * 1000) / 1000;
|
||||
/* Reporting is done in millidegree Celsius */
|
||||
*temp = decicelsius * 100 + adj * 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
static int sandbox_thermal_get_temp(struct udevice *dev, int *temp)
|
||||
{
|
||||
/* Simply return 100 deg C */
|
||||
*temp = 100;
|
||||
*temp = 100 * 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ static int ti_bandgap_get_temp(struct udevice *dev, int *temp)
|
||||
struct ti_bandgap *bgp = dev_get_priv(dev);
|
||||
|
||||
bgp->adc_val = 0x3ff & readl(bgp->base + CTRL_CORE_TEMP_SENSOR_MPU);
|
||||
*temp = dra752_adc_to_temp[bgp->adc_val - DRA752_ADC_START_VALUE];
|
||||
*temp = dra752_adc_to_temp[bgp->adc_val - DRA752_ADC_START_VALUE] * 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ static int ti_lm74_get_temp(struct udevice *dev, int *temp)
|
||||
|
||||
raw = ((buf[0] << 8) + buf[1]) >> 3;
|
||||
|
||||
*temp = (((int)raw * 125) + 1000) / 2000;
|
||||
*temp = (((int)raw * 125) + 1000) / 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ struct dm_thermal_ops {
|
||||
* It will enable and initialize any Thermal hardware as necessary.
|
||||
*
|
||||
* @dev: The Thermal device
|
||||
* @temp: pointer that returns the measured temperature
|
||||
* @temp: pointer that returns the measured temperature in millidegree Celsius
|
||||
*/
|
||||
int (*get_temp)(struct udevice *dev, int *temp);
|
||||
};
|
||||
|
||||
@ -27,7 +27,7 @@ static int dm_test_cmd_temperature(struct unit_test_state *uts)
|
||||
/* Test that "temperature get thermal" returns expected value */
|
||||
console_record_reset();
|
||||
ut_assertok(run_command("temperature get thermal", 0));
|
||||
ut_assert_nextline("thermal: 100 C");
|
||||
ut_assert_nextline("thermal: 100000 mC");
|
||||
ut_assert_console_end();
|
||||
|
||||
return 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user