From f1b4bf2845886e25a1999e7d3493b2f5b7718cc4 Mon Sep 17 00:00:00 2001
From: Brendan Jackman <brendan.jackman@arm.com>
Date: Mon, 10 Oct 2016 14:05:09 +0100
Subject: [PATCH] cpufreq: Add function to get CPUs in frequency domain

---
 devlib/module/cpufreq.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/devlib/module/cpufreq.py b/devlib/module/cpufreq.py
index 3a3eec9..a0d77f6 100644
--- a/devlib/module/cpufreq.py
+++ b/devlib/module/cpufreq.py
@@ -408,3 +408,14 @@ class CpufreqModule(Module):
         """
         return self.target._execute_util('cpufreq_trace_all_frequencies', as_root=True)
 
+    @memoized
+    def get_domain_cpus(self, cpu):
+        """
+        Get the CPUs that share a frequency domain with the given CPU
+        """
+        if isinstance(cpu, int):
+            cpu = 'cpu{}'.format(cpu)
+
+        sysfile = '/sys/devices/system/cpu/{}/cpufreq/affected_cpus'.format(cpu)
+
+        return [int(c) for c in self.target.read_value(sysfile).split()]