Browse Source

hw/arm/imx8mp-evk: Remove unimplemented cpu-idle-states properties from devicetree

The cpu-idle-states property causes a hard boot hang. Rather than documenting
the workaround, perform the removal from the devicetree automatically.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
[Bernhard: split patch, update documentation, adapt commit message]
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Message-ID: <20250405214900.7114-3-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Guenter Roeck 4 months ago
parent
commit
764ca3ec89
2 changed files with 16 additions and 10 deletions
  1. 2 10
      docs/system/arm/imx8mp-evk.rst
  2. 14 0
      hw/arm/imx8mp-evk.c

+ 2 - 10
docs/system/arm/imx8mp-evk.rst

@@ -35,7 +35,7 @@ Direct Linux Kernel Boot
 
 
 Probably the easiest way to get started with a whole Linux system on the machine
 Probably the easiest way to get started with a whole Linux system on the machine
 is to generate an image with Buildroot. Version 2024.11.1 is tested at the time
 is to generate an image with Buildroot. Version 2024.11.1 is tested at the time
-of writing and involves three steps. First run the following commands in the
+of writing and involves two steps. First run the following commands in the
 toplevel directory of the Buildroot source tree:
 toplevel directory of the Buildroot source tree:
 
 
 .. code-block:: bash
 .. code-block:: bash
@@ -50,14 +50,6 @@ it and resize the SD card image to a power of two:
 
 
   $ qemu-img resize sdcard.img 256M
   $ qemu-img resize sdcard.img 256M
 
 
-Finally, the device tree needs to be patched with the following commands which
-will remove the ``cpu-idle-states`` properties from CPU nodes:
-
-.. code-block:: bash
-
-  $ dtc imx8mp-evk.dtb | sed '/cpu-idle-states/d' > imx8mp-evk-patched.dts
-  $ dtc imx8mp-evk-patched.dts -o imx8mp-evk-patched.dtb
-
 Now that everything is prepared the machine can be started as follows:
 Now that everything is prepared the machine can be started as follows:
 
 
 .. code-block:: bash
 .. code-block:: bash
@@ -65,6 +57,6 @@ Now that everything is prepared the machine can be started as follows:
   $ qemu-system-aarch64 -M imx8mp-evk -smp 4 -m 3G \
   $ qemu-system-aarch64 -M imx8mp-evk -smp 4 -m 3G \
       -display none -serial null -serial stdio \
       -display none -serial null -serial stdio \
       -kernel Image \
       -kernel Image \
-      -dtb imx8mp-evk-patched.dtb \
+      -dtb imx8mp-evk.dtb \
       -append "root=/dev/mmcblk2p2" \
       -append "root=/dev/mmcblk2p2" \
       -drive file=sdcard.img,if=sd,bus=2,format=raw,id=mmcblk2
       -drive file=sdcard.img,if=sd,bus=2,format=raw,id=mmcblk2

+ 14 - 0
hw/arm/imx8mp-evk.c

@@ -15,6 +15,19 @@
 #include "system/qtest.h"
 #include "system/qtest.h"
 #include "qemu/error-report.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qapi/error.h"
+#include <libfdt.h>
+
+static void imx8mp_evk_modify_dtb(const struct arm_boot_info *info, void *fdt)
+{
+    int offset;
+
+    /* Remove cpu-idle-states property from CPU nodes */
+    offset = fdt_node_offset_by_compatible(fdt, -1, "arm,cortex-a53");
+    while (offset >= 0) {
+        fdt_nop_property(fdt, offset, "cpu-idle-states");
+        offset = fdt_node_offset_by_compatible(fdt, offset, "arm,cortex-a53");
+    }
+}
 
 
 static void imx8mp_evk_init(MachineState *machine)
 static void imx8mp_evk_init(MachineState *machine)
 {
 {
@@ -32,6 +45,7 @@ static void imx8mp_evk_init(MachineState *machine)
         .board_id = -1,
         .board_id = -1,
         .ram_size = machine->ram_size,
         .ram_size = machine->ram_size,
         .psci_conduit = QEMU_PSCI_CONDUIT_SMC,
         .psci_conduit = QEMU_PSCI_CONDUIT_SMC,
+        .modify_dtb = imx8mp_evk_modify_dtb,
     };
     };
 
 
     s = FSL_IMX8MP(object_new(TYPE_FSL_IMX8MP));
     s = FSL_IMX8MP(object_new(TYPE_FSL_IMX8MP));