aboutsummaryrefslogtreecommitdiffstats
path: root/sys-boot/grub/files/grub-2.06-011-support-loading-device-trees.patch
blob: f892376f91b66b0ddd493e11a643cbf31d6e0b64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
diff --git a/docs/grub.texi b/docs/grub.texi
index eeac9b2ce..64cf95e6f 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -1560,6 +1560,12 @@ This option may be set to a list of GRUB module names separated by spaces.
 Each module will be loaded as early as possible, at the start of
 @file{grub.cfg}.

+@item GRUB_LOAD_DEVICE_TREE
+If this option is set to @samp{true}, a devicetree command will be added
+to the Linux menu entries in @file{grub.cfg}. Device-trees require fix-ups
+by the firmware. You should use this option only if your firmware supports
+the EFI Device Tree Fixup Protocol.
+
 @end table

 The following options are still accepted for compatibility with existing
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index d3e879b8e..3d7fd54f3 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -230,6 +230,7 @@ export GRUB_DEFAULT \
   GRUB_CMDLINE_GNUMACH \
   GRUB_EARLY_INITRD_LINUX_CUSTOM \
   GRUB_EARLY_INITRD_LINUX_STOCK \
+  GRUB_LOAD_DEVICETREE \
   GRUB_TERMINAL_INPUT \
   GRUB_TERMINAL_OUTPUT \
   GRUB_SERIAL_COMMAND \
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index e8b01c0d0..15bc26ba8 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -143,6 +143,15 @@ linux_entry ()
        echo    '$(echo "$message" | grub_quote)'
        linux   ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
 EOF
+  if [ "x${GRUB_LOAD_DEVICETREE}" = "xtrue" ]; then
+    if test -n "${dtb}" ; then
+      message="$(gettext_printf "Loading device tree ...")"
+      sed "s/^/$submenu_indentation/" << EOF
+       echo    '$(echo "$message" | grub_quote)'
+       devicetree      ${rel_dirname}/${dtb}
+EOF
+    fi
+  fi
   if test -n "${initrd}" ; then
     # TRANSLATORS: ramdisk isn't identifier. Should be translated.
     message="$(gettext_printf "Loading initial ramdisk ...")"
@@ -244,6 +253,20 @@ while [ "x$list" != "x" ] ; do
     fi
   done

+  if [ "x${GRUB_LOAD_DEVICETREE}" = "xtrue" ]; then
+    dtb=
+    for i in "dtb-${version}" "dtb" ; do
+      if test -e "${dirname}/${i}" ; then
+        dtb="${i}"
+        break
+      fi
+    done
+
+    if test -n "${dtb}" ; then
+      gettext_printf "Found dtb: %s\n" "${dirname}/${dtb}" >&2
+    fi
+  fi
+
   initramfs=
   if test -n "${config}" ; then
       initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr 
-d \"`
--
2.30.0