Commit 10be5b5d3a8d8dd1aa8be95d339c0fdf498c3687
Committed by
Simon Glass
1 parent
d8abb46b37
Exists in
v2017.01-smarct4x
and in
34 other branches
fdt: Pass the device serial number through devicetree
Before device-tree, the device serial number used to be passed to the kernel using ATAGs (on ARM). This is now deprecated and all the handover to the kernel should now be done using device-tree. Thus, this passes the serial-number property to the kernel using the serial-number property of the root node, as expected by the kernel. The serial number is a string that somewhat represents the device's serial number. It might come from some form of storage (e.g. an eeprom) and be programmed at factory-time by the manufacturer or come from identification bits available in e.g. the SoC. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Reviewed-by: Simon Glass <sgj@chromium.org>
Showing 4 changed files with 34 additions and 0 deletions Side-by-side Diff
common/fdt_support.c
... | ... | @@ -194,6 +194,31 @@ |
194 | 194 | return fdt_setprop_u32(fdt, nodeoffset, name, (uint32_t)val); |
195 | 195 | } |
196 | 196 | |
197 | +int fdt_root(void *fdt) | |
198 | +{ | |
199 | + char *serial; | |
200 | + int err; | |
201 | + | |
202 | + err = fdt_check_header(fdt); | |
203 | + if (err < 0) { | |
204 | + printf("fdt_root: %s\n", fdt_strerror(err)); | |
205 | + return err; | |
206 | + } | |
207 | + | |
208 | + serial = getenv("serial#"); | |
209 | + if (serial) { | |
210 | + err = fdt_setprop(fdt, 0, "serial-number", serial, | |
211 | + strlen(serial) + 1); | |
212 | + | |
213 | + if (err < 0) { | |
214 | + printf("WARNING: could not set serial-number %s.\n", | |
215 | + fdt_strerror(err)); | |
216 | + return err; | |
217 | + } | |
218 | + } | |
219 | + | |
220 | + return 0; | |
221 | +} | |
197 | 222 | |
198 | 223 | int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end) |
199 | 224 | { |
common/image-fdt.c
doc/device-tree-bindings/root.txt
include/fdt_support.h
... | ... | @@ -16,6 +16,7 @@ |
16 | 16 | const char *prop, const u32 dflt); |
17 | 17 | u32 fdt_getprop_u32_default(const void *fdt, const char *path, |
18 | 18 | const char *prop, const u32 dflt); |
19 | +int fdt_root(void *fdt); | |
19 | 20 | int fdt_chosen(void *fdt); |
20 | 21 | int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end); |
21 | 22 | void do_fixup_by_path(void *fdt, const char *path, const char *prop, |