[PATCH V2] ARM: imx: imx8m: Adjust thermal trip points for Industrial parts
Andrejs Cainikovs
andrejs.cainikovs at toradex.com
Mon May 9 09:38:28 CEST 2022
Hi Adam and all,
Thanks for your work. I was about to send a similar patch by myself, but
I came up with slightly different code. I'm sending my version for
downstream version of NXP (should apply with minor conflicts to
upstream) at the end of this mail. Plus some code review.
On 07/05/2022 14:04, Adam Ford wrote:
> If the thermal sensor is enabled in U-Boot, adjust the cpu-thermal
Should be not only for `cpu-thermal`. See below.
> V2: Switch the check from looking for industrial or checkoing for
> anything but commerical. This expands the trip point updates
> other grades as well.
Typos: checkoing, commerical.
> +#include <imx_thermal.h>
Not needed if you drop temp grade check. See below.
> +#if defined(CONFIG_IMX_TMU)
I believe this is needed only if you do the temperature reading.
get_cpu_temp_grade() does not require this. Please remove.
> + nodeoff = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
This is enough for all variants except 8MP, which has 2 temperature
sensors: `cpu-thermal` and `soc-thermal`. Both needs to be updated with
equal trips.
> + /* Only update non-Commerical grade parts */
> + if (get_cpu_temp_grade(&minc, &maxc) != TEMP_COMMERCIAL) {
As others said, I would remove this check, as I don't see any issues if
code would set trips for a commercial grade as well. This implies
removing the include I mentioned above.
My version which I was going to sent (after rebasing) is below. Feel
free to modify/rework/adjust your patch with or without parts from my code.
>> Are the industrial and automotive trip points identical ?
>
> I do not know nor do I have any to test...
After you're done with the new patchset I can test it for you. I have
access to commercial and industrial variants.
Best regards,
Andrejs Cainikovs
---
diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index
e93ecd28467ccc33ab35f0073840963eb3a01800..d4438b78887b91c600aaf22db47ef8985462ccd8
100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -1001,8 +1001,52 @@ static int disable_cpu_nodes(void *blob, u32
disabled_cores)
return 0;
}
+int fixup_thermal_trips(void *blob, const char *name)
+{
+ int minc, maxc;
+ int node, trip;
+ const char *type;
+ int temp, ret;
+
+ node = fdt_path_offset(blob, "/thermal-zones");
+ if (node < 0)
+ return node;
+
+ node = fdt_subnode_offset(blob, node, name);
+ if (node < 0)
+ return node;
+
+ node = fdt_subnode_offset(blob, node, "trips");
+ if (node < 0)
+ return node;
+
+ get_cpu_temp_grade(&minc, &maxc);
+
+ fdt_for_each_subnode(trip, blob, node) {
+ type = fdt_getprop(blob, trip, "type", NULL);
+
+ temp = 0;
+ if (!strcmp(type, "critical")) {
+ temp = 1000 * maxc;
+ } else if (!strcmp(type, "passive")) {
+ temp = 1000 * (maxc - 10);
+ }
+ if (temp) {
+ ret = fdt_setprop_u32(blob, trip, "temperature", temp);
+ if (ret) {
+ printf("Could not update thermal trip\n");
+ return ret;
+ }
+ }
+ }
+
+ return 0;
+}
+
int ft_system_setup(void *blob, bd_t *bd)
{
+ int ret;
+
#ifdef CONFIG_IMX8MQ
int i = 0;
int rc;
@@ -1128,6 +1172,16 @@ usb_modify_speed:
disable_cpu_nodes(blob, 2);
#endif
+ ret = fixup_thermal_trips(blob, "cpu-thermal");
+#ifdef CONFIG_IMX8MP
+ if (!ret)
+ ret = fixup_thermal_trips(blob, "soc-thermal");
+#endif
+ if (ret) {
+ printf("Failed to update thermal trip\n");
+ return ret;
+ }
+
return ft_add_optee_node(blob, bd);
}
#endif
More information about the U-Boot
mailing list