diff options
author | Burt P <pburt0@gmail.com> | 2017-07-19 19:51:47 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2017-07-21 05:14:20 -0700 |
commit | f843ee52fe2c230083a63a262ec120c94f97203a (patch) | |
tree | 07ed187ff88f2780d0823c0daf16a6dcc2159959 /modules | |
parent | e3c217f47dcfff0967bf48cdd9efa3e3e4f07d50 (diff) |
device tree: rpi: improve rpi detection on non-Raspbian
When running Arch's AArch64 kernel on Raspberry Pi 3,
for example.
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/devices/devicetree.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/modules/devices/devicetree.c b/modules/devices/devicetree.c index 778e3693..7252323b 100644 --- a/modules/devices/devicetree.c +++ b/modules/devices/devicetree.c @@ -159,10 +159,11 @@ char *get_dt_string(char *path, int decode) { } gchar *get_summary() { - char *model = NULL, *serial = NULL, *compat = NULL, *ret = NULL; + char *model = NULL, *compat = NULL; + char *tmp[10]; + char *ret = NULL; model = get_dt_string("/model", 0); - serial = get_dt_string("/serial-number", 0); compat = get_dt_string("/compatible", 1); /* Expand on the DT information from known machines, like RPi. @@ -171,10 +172,33 @@ gchar *get_summary() { * together for DT machines, with a nice fallback. * PPC Macs could be handled this way too. They store * machine identifiers in /proc/cpuinfo. */ - if ( strstr(model, "Raspberry Pi") != NULL ) - ret = rpi_board_details(); + if ( strstr(model, "Raspberry Pi") != NULL + || strstr(compat, "raspberrypi") != NULL ) { + tmp[0] = get_dt_string("/serial-number", 0); + tmp[1] = get_dt_string("/soc/gpu/compatible", 1); + tmp[9] = rpi_board_details(); + tmp[8] = g_strdup_printf( + "[%s]\n" "%s=%s\n" "%s=%s\n", + _("Platform"), + _("Compatible"), compat, + _("GPU-compatible"), tmp[1] ); + if (tmp[9] != NULL) { + ret = g_strdup_printf("%s%s", tmp[9], tmp[8]); + } else { + ret = g_strdup_printf( + "[%s]\n" "%s=%s\n" "%s=%s\n" "%s=%s\n" "%s", + _("Raspberry Pi or Compatible"), + _("Model"), model, + _("Serial Number"), tmp[0], + _("RCode"), _("No revision code available; unable to lookup model details."), + tmp[8]); + } + free(tmp[0]); free(tmp[1]); + free(tmp[9]); free(tmp[8]); + } if (ret == NULL) { + tmp[0] = get_dt_string("/serial-number", 0); ret = g_strdup_printf( "[%s]\n" "%s=%s\n" @@ -182,12 +206,11 @@ gchar *get_summary() { "%s=%s\n", _("Board"), _("Model"), model, - _("Serial Number"), serial, + _("Serial Number"), tmp[0], _("Compatible"), compat); + free(tmp[0]); } - free(model); - free(serial); return ret; } |