From patchwork Sat May 16 20:34:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatolij Gustschin X-Patchwork-Id: 245875 List-Id: U-Boot discussion From: agust at denx.de (Anatolij Gustschin) Date: Sat, 16 May 2020 22:34:19 +0200 Subject: [PATCH 1/2] cpu: imx8: fix type and rate detection Message-ID: <20200516203420.24409-1-agust@denx.de> CPU type and rate detection is broken, for A35 cpu we get A53: ... sc_pm_get_clock_rate: resource:0 clk:2: res:3 Could not read CPU frequency: -22 CPU: NXP i.MX8QXP RevB A53 at 0 MHz at 47C Fixes: 55bc96f3b675 ("cpu: imx8: fix get core name and rate") Signed-off-by: Anatolij Gustschin Reviewed-by: Peng Fan --- drivers/cpu/imx8_cpu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index 95c14c98d8..896e1ac776 100644 --- a/drivers/cpu/imx8_cpu.c +++ b/drivers/cpu/imx8_cpu.c @@ -52,11 +52,11 @@ const char *get_imx8_rev(u32 rev) const char *get_core_name(struct udevice *dev) { - if (!device_is_compatible(dev, "arm,cortex-a35")) + if (device_is_compatible(dev, "arm,cortex-a35")) return "A35"; - else if (!device_is_compatible(dev, "arm,cortex-a53")) + else if (device_is_compatible(dev, "arm,cortex-a53")) return "A53"; - else if (!device_is_compatible(dev, "arm,cortex-a72")) + else if (device_is_compatible(dev, "arm,cortex-a72")) return "A72"; else return "?"; @@ -183,11 +183,11 @@ static ulong imx8_get_cpu_rate(struct udevice *dev) ulong rate; int ret, type; - if (!device_is_compatible(dev, "arm,cortex-a35")) + if (device_is_compatible(dev, "arm,cortex-a35")) type = SC_R_A35; - else if (!device_is_compatible(dev, "arm,cortex-a53")) + else if (device_is_compatible(dev, "arm,cortex-a53")) type = SC_R_A53; - else if (!device_is_compatible(dev, "arm,cortex-a72")) + else if (device_is_compatible(dev, "arm,cortex-a72")) type = SC_R_A72; else return 0; From patchwork Sat May 16 20:34:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatolij Gustschin X-Patchwork-Id: 245876 List-Id: U-Boot discussion From: agust at denx.de (Anatolij Gustschin) Date: Sat, 16 May 2020 22:34:20 +0200 Subject: [PATCH 2/2] thermal: imx_scu_thermal: fix getting DT alert property value In-Reply-To: <20200516203420.24409-1-agust@denx.de> References: <20200516203420.24409-1-agust@denx.de> Message-ID: <20200516203420.24409-2-agust@denx.de> Fix boot hang with endless loop outputting: CPU Temperature (47200C) has beyond alert (0C), close to critical (0C) waiting... Signed-off-by: Anatolij Gustschin --- i.MX8QXP is broken again, this should be appied ASAP! drivers/thermal/imx_scu_thermal.c | 101 ++++++++++++------------------ 1 file changed, 41 insertions(+), 60 deletions(-) diff --git a/drivers/thermal/imx_scu_thermal.c b/drivers/thermal/imx_scu_thermal.c index da13121a09..679ce4e244 100644 --- a/drivers/thermal/imx_scu_thermal.c +++ b/drivers/thermal/imx_scu_thermal.c @@ -57,7 +57,7 @@ int imx_sc_thermal_get_temp(struct udevice *dev, int *temp) if (ret) return ret; - while (cpu_temp >= pdata->alert) { + while (cpu_temp >= pdata->alert && pdata->alert) { printf("CPU Temperature (%dC) has beyond alert (%dC), close to critical (%dC)", cpu_temp, pdata->alert, pdata->critical); puts(" waiting...\n"); @@ -78,7 +78,47 @@ static const struct dm_thermal_ops imx_sc_thermal_ops = { static int imx_sc_thermal_probe(struct udevice *dev) { + struct imx_sc_thermal_plat *pdata = dev_get_platdata(dev); + struct fdtdec_phandle_args args; + ofnode node, trips_np; + int ret; + debug("%s dev name %s\n", __func__, dev->name); + + trips_np = ofnode_path("/thermal-zones/cpu-thermal0/trips"); + node = ofnode_get_parent(trips_np); + ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, node.of_offset, + "thermal-sensors", + "#thermal-sensor-cells", + 0, 0, &args); + if (ret) + return ret; + + if (args.args_count >= 1) + pdata->id = args.args[0]; + else + pdata->id = 0; + + debug("args.args_count %d, id %d\n", args.args_count, pdata->id); + + pdata->polling_delay = ofnode_read_u32_default(node, "polling-delay", + 1000); + ofnode_for_each_subnode(trips_np, trips_np) { + const char *type; + + type = ofnode_get_property(trips_np, "type", NULL); + if (!type) + continue; + if (!strcmp(type, "critical")) + pdata->critical = + ofnode_read_u32_default(trips_np, "temperature", 85); + else if (!strcmp(type, "passive")) + pdata->alert = + ofnode_read_u32_default(trips_np, "temperature", 80); + } + + debug("id %d polling_delay %d, critical %d, alert %d\n", + pdata->id, pdata->polling_delay, pdata->critical, pdata->alert); return 0; } @@ -121,64 +161,6 @@ static int imx_sc_thermal_bind(struct udevice *dev) return 0; } -static int imx_sc_thermal_ofdata_to_platdata(struct udevice *dev) -{ - struct imx_sc_thermal_plat *pdata = dev_get_platdata(dev); - struct fdtdec_phandle_args args; - const char *type; - int ret; - int trips_np; - - debug("%s dev name %s\n", __func__, dev->name); - - if (pdata->zone_node) - return 0; - - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), - "thermal-sensors", - "#thermal-sensor-cells", - 0, 0, &args); - if (ret) - return ret; - - if (args.node != dev_of_offset(dev->parent)) - return -EFAULT; - - if (args.args_count >= 1) - pdata->id = args.args[0]; - else - pdata->id = 0; - - debug("args.args_count %d, id %d\n", args.args_count, pdata->id); - - pdata->polling_delay = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "polling-delay", 1000); - - trips_np = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(dev), - "trips"); - fdt_for_each_subnode(trips_np, gd->fdt_blob, trips_np) { - type = fdt_getprop(gd->fdt_blob, trips_np, "type", NULL); - if (type) { - if (strcmp(type, "critical") == 0) { - pdata->critical = fdtdec_get_int(gd->fdt_blob, - trips_np, - "temperature", - 85); - } else if (strcmp(type, "passive") == 0) { - pdata->alert = fdtdec_get_int(gd->fdt_blob, - trips_np, - "temperature", - 80); - } - } - } - - debug("id %d polling_delay %d, critical %d, alert %d\n", pdata->id, - pdata->polling_delay, pdata->critical, pdata->alert); - - return 0; -} - static const sc_rsrc_t imx8qm_sensor_rsrc[] = { SC_R_A53, SC_R_A72, SC_R_GPU_0_PID0, SC_R_GPU_1_PID0, SC_R_DRC_0, SC_R_DRC_1, SC_R_VPU_PID0, SC_R_PMIC_0, @@ -205,7 +187,6 @@ U_BOOT_DRIVER(imx_sc_thermal) = { .of_match = imx_sc_thermal_ids, .bind = imx_sc_thermal_bind, .probe = imx_sc_thermal_probe, - .ofdata_to_platdata = imx_sc_thermal_ofdata_to_platdata, .platdata_auto_alloc_size = sizeof(struct imx_sc_thermal_plat), .flags = DM_FLAG_PRE_RELOC, };