aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-05-22 10:28:26 -0400
committerTom Rini <trini@konsulko.com>2020-05-22 10:28:26 -0400
commita9f793a30dc091290dddae1d8d3798d25e39c710 (patch)
tree92d3b9e259bde3d747d7b3f22b3b62b1c00a52ee /drivers
parent2fdb5cd69ce05392f2f7e556484a34ed0a77f43c (diff)
parent4e7413a998ba5666aa4ee0b4f49789f52b1281b1 (diff)
downloadu-boot-a9f793a30dc091290dddae1d8d3798d25e39c710.zip
u-boot-a9f793a30dc091290dddae1d8d3798d25e39c710.tar.gz
u-boot-a9f793a30dc091290dddae1d8d3798d25e39c710.tar.bz2
Merge tag 'imx8qxp-fixes' of https://gitlab.denx.de/u-boot/custodians/u-boot-video
- Fix i.MX8QXP boot hang when getting CPU temperature
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cpu/imx8_cpu.c50
-rw-r--r--drivers/thermal/imx_scu_thermal.c4
2 files changed, 28 insertions, 26 deletions
diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c
index dddd12d..6345cd0 100644
--- a/drivers/cpu/imx8_cpu.c
+++ b/drivers/cpu/imx8_cpu.c
@@ -20,6 +20,7 @@ struct cpu_imx_platdata {
const char *name;
const char *rev;
const char *type;
+ u32 cpu_rsrc;
u32 cpurev;
u32 freq_mhz;
u32 mpidr;
@@ -52,16 +53,23 @@ const char *get_imx8_rev(u32 rev)
}
}
-const char *get_core_name(struct udevice *dev)
+static void set_core_data(struct udevice *dev)
{
- if (!device_is_compatible(dev, "arm,cortex-a35"))
- return "A35";
- else if (!device_is_compatible(dev, "arm,cortex-a53"))
- return "A53";
- else if (!device_is_compatible(dev, "arm,cortex-a72"))
- return "A72";
- else
- return "?";
+ struct cpu_imx_platdata *plat = dev_get_platdata(dev);
+
+ if (device_is_compatible(dev, "arm,cortex-a35")) {
+ plat->cpu_rsrc = SC_R_A35;
+ plat->name = "A35";
+ } else if (device_is_compatible(dev, "arm,cortex-a53")) {
+ plat->cpu_rsrc = SC_R_A53;
+ plat->name = "A53";
+ } else if (device_is_compatible(dev, "arm,cortex-a72")) {
+ plat->cpu_rsrc = SC_R_A72;
+ plat->name = "A72";
+ } else {
+ plat->cpu_rsrc = SC_R_A53;
+ plat->name = "?";
+ }
}
#if IS_ENABLED(CONFIG_IMX_SCU_THERMAL)
@@ -69,12 +77,12 @@ static int cpu_imx_get_temp(struct cpu_imx_platdata *plat)
{
struct udevice *thermal_dev;
int cpu_tmp, ret;
+ int idx = 1; /* use "cpu-thermal0" device */
- if (!strcmp(plat->name, "A72"))
- ret = uclass_get_device(UCLASS_THERMAL, 1, &thermal_dev);
- else
- ret = uclass_get_device(UCLASS_THERMAL, 0, &thermal_dev);
+ if (plat->cpu_rsrc == SC_R_A72)
+ idx = 2; /* use "cpu-thermal1" device */
+ ret = uclass_get_device(UCLASS_THERMAL, idx, &thermal_dev);
if (!ret) {
ret = thermal_get_temp(thermal_dev, &cpu_tmp);
if (ret)
@@ -182,19 +190,11 @@ static const struct udevice_id cpu_imx8_ids[] = {
static ulong imx8_get_cpu_rate(struct udevice *dev)
{
+ struct cpu_imx_platdata *plat = dev_get_platdata(dev);
ulong rate;
- int ret, type;
-
- if (!device_is_compatible(dev, "arm,cortex-a35"))
- type = SC_R_A35;
- else if (!device_is_compatible(dev, "arm,cortex-a53"))
- type = SC_R_A53;
- else if (!device_is_compatible(dev, "arm,cortex-a72"))
- type = SC_R_A72;
- else
- return 0;
+ int ret;
- ret = sc_pm_get_clock_rate(-1, type, SC_PM_CLK_CPU,
+ ret = sc_pm_get_clock_rate(-1, plat->cpu_rsrc, SC_PM_CLK_CPU,
(sc_pm_clock_rate_t *)&rate);
if (ret) {
printf("Could not read CPU frequency: %d\n", ret);
@@ -209,9 +209,9 @@ static int imx8_cpu_probe(struct udevice *dev)
struct cpu_imx_platdata *plat = dev_get_platdata(dev);
u32 cpurev;
+ set_core_data(dev);
cpurev = get_cpu_rev();
plat->cpurev = cpurev;
- plat->name = get_core_name(dev);
plat->rev = get_imx8_rev(cpurev & 0xFFF);
plat->type = get_imx8_type((cpurev & 0xFF000) >> 12);
plat->freq_mhz = imx8_get_cpu_rate(dev) / 1000000;
diff --git a/drivers/thermal/imx_scu_thermal.c b/drivers/thermal/imx_scu_thermal.c
index 321f905..83ec753 100644
--- a/drivers/thermal/imx_scu_thermal.c
+++ b/drivers/thermal/imx_scu_thermal.c
@@ -61,13 +61,15 @@ int imx_sc_thermal_get_temp(struct udevice *dev, int *temp)
return ret;
while (cpu_temp >= pdata->alert) {
- printf("CPU Temperature (%dC) has beyond alert (%dC), close to critical (%dC)",
+ printf("CPU Temperature (%dC) beyond alert (%dC), close to critical (%dC)",
cpu_temp, pdata->alert, pdata->critical);
puts(" waiting...\n");
mdelay(pdata->polling_delay);
ret = read_temperature(dev, &cpu_temp);
if (ret)
return ret;
+ if (cpu_temp >= pdata->alert && !pdata->alert)
+ break;
}
*temp = cpu_temp / 1000;