diff options
author | Stefan Agner <stefan.agner@toradex.com> | 2015-05-09 12:29:34 +0200 |
---|---|---|
committer | Stefan Agner <stefan.agner@toradex.com> | 2015-05-11 08:26:51 +0200 |
commit | 3974fc382adcc18c49228506bf256a7eaa211b06 (patch) | |
tree | c3a99945e7e68c9bc183e43f0e9aa473121acfd3 /board | |
parent | 0fa5ed9af80300a67c61e750205ff0c44cf516c4 (diff) |
toradex: common: set board-rev and product-id
Set board revision and Toradex product ID as device tree property.
This transfers the Toradex configblock information to Linux user-
space, where it can be read conviniently through the proc file
system files:
- /proc/device-tree/serial-number
- /proc/device-tree/toradex,board-rev
- /proc/device-tree/toradex,product-id
In case the Toradex config block is missing or corrupted, the
device tree properties won't be created by the boot loader and
hence those file won't exist in that case.
Diffstat (limited to 'board')
-rw-r--r-- | board/toradex/common/common.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/board/toradex/common/common.c b/board/toradex/common/common.c index 0869337baf3..ac1b73430bc 100644 --- a/board/toradex/common/common.c +++ b/board/toradex/common/common.c @@ -10,6 +10,7 @@ #include <libfdt.h> static char trdx_serial_str[9]; +static char trdx_board_rev_str[6]; __weak int checkboard_fallback(void) { @@ -90,6 +91,12 @@ int checkboard(void) /* board serial-number */ sprintf(trdx_serial_str, "%08u", trdx_serial); + sprintf(trdx_board_rev_str, "V%1d.%1d%c", + trdx_hw_tag.ver_major, + trdx_hw_tag.ver_minor, + (char)trdx_hw_tag.ver_assembly + 'A'); + + setenv("serial#", trdx_serial_str); /* @@ -111,12 +118,10 @@ int checkboard(void) } #endif - printf("Model: Toradex %s V%d.%d%c, Serial# %08u\n", + printf("Model: Toradex %s %s, Serial# %s\n", toradex_modules[trdx_hw_tag.prodid], - trdx_hw_tag.ver_major, - trdx_hw_tag.ver_minor, - (char)trdx_hw_tag.ver_assembly + 'A', - trdx_serial); + trdx_board_rev_str, + trdx_serial_str); #else checkboard_fallback(); #endif @@ -141,8 +146,20 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) defined(CONFIG_TRDX_CFG_BLOCK) int ft_system_setup(void *blob, bd_t *bd) { - fdt_setprop(blob, 0, "serial-number", trdx_serial_str, - strlen(trdx_serial_str) + 1); + if (trdx_serial) { + fdt_setprop(blob, 0, "serial-number", trdx_serial_str, + strlen(trdx_serial_str) + 1); + } + + if (trdx_hw_tag.ver_major) { + char prod_id[5]; + + sprintf(prod_id, "%04u", trdx_hw_tag.prodid); + fdt_setprop(blob, 0, "toradex,product-id", prod_id, 5); + + fdt_setprop(blob, 0, "toradex,board-rev", trdx_board_rev_str, + strlen(trdx_board_rev_str) + 1); + } return 0; } |