base_utils: determine ARM SoC family type from devicetree
Determine ARM SoC family from the "compatible" property at the base node
of devicetree, if it exists. Otherwise try the old cpuinfo path.
BUG=chrome-os-partner:57291
TEST=test_that graphics_Idle on kevin
Change-Id: I90767d55b760a1c80acf82d0b0a8d7815c99a458
Reviewed-on: https://chromium-review.googlesource.com/390317
Commit-Ready: Haixia Shi <[email protected]>
Tested-by: Haixia Shi <[email protected]>
Reviewed-by: Ilja H. Friedel <[email protected]>
diff --git a/client/bin/base_utils.py b/client/bin/base_utils.py
index f44730f..0384591 100644
--- a/client/bin/base_utils.py
+++ b/client/bin/base_utils.py
@@ -297,8 +297,30 @@
return 'i386'
+def get_arm_soc_family_from_devicetree():
+ """
+ Work out which ARM SoC we're running on based on the 'compatible' property
+ of the base node of devicetree, if it exists.
+ """
+ devicetree_compatible = '/sys/firmware/devicetree/base/compatible'
+ if not os.path.isfile(devicetree_compatible):
+ return None
+ f = open(devicetree_compatible, 'r')
+ compatible = f.readlines()
+ f.close()
+ if list_grep(compatible, 'rk3399'):
+ return 'rockchip'
+ elif list_grep(compatible, 'mt8173'):
+ return 'mediatek'
+ return None
+
+
def get_arm_soc_family():
"""Work out which ARM SoC we're running on"""
+ family = get_arm_soc_family_from_devicetree()
+ if family is not None:
+ return family
+
f = open('/proc/cpuinfo', 'r')
cpuinfo = f.readlines()
f.close()