• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from devlib.module import Module
2
3
4class BigLittleModule(Module):
5
6    name = 'bl'
7
8    @staticmethod
9    def probe(target):
10        return target.big_core is not None
11
12    @property
13    def bigs(self):
14        return [i for i, c in enumerate(self.target.platform.core_names)
15                if c == self.target.platform.big_core]
16
17    @property
18    def littles(self):
19        return [i for i, c in enumerate(self.target.platform.core_names)
20                if c == self.target.platform.little_core]
21
22    @property
23    def bigs_online(self):
24        return list(sorted(set(self.bigs).intersection(self.target.list_online_cpus())))
25
26    @property
27    def littles_online(self):
28        return list(sorted(set(self.littles).intersection(self.target.list_online_cpus())))
29
30    # hotplug
31
32    def online_all_bigs(self):
33        self.target.hotplug.online(*self.bigs)
34
35    def offline_all_bigs(self):
36        self.target.hotplug.offline(*self.bigs)
37
38    def online_all_littles(self):
39        self.target.hotplug.online(*self.littles)
40
41    def offline_all_littles(self):
42        self.target.hotplug.offline(*self.littles)
43
44    # cpufreq
45
46    def list_bigs_frequencies(self):
47        return self.target.cpufreq.list_frequencies(self.bigs_online[0])
48
49    def list_bigs_governors(self):
50        return self.target.cpufreq.list_governors(self.bigs_online[0])
51
52    def list_bigs_governor_tunables(self):
53        return self.target.cpufreq.list_governor_tunables(self.bigs_online[0])
54
55    def list_littles_frequencies(self):
56        return self.target.cpufreq.list_frequencies(self.littles_online[0])
57
58    def list_littles_governors(self):
59        return self.target.cpufreq.list_governors(self.littles_online[0])
60
61    def list_littles_governor_tunables(self):
62        return self.target.cpufreq.list_governor_tunables(self.littles_online[0])
63
64    def get_bigs_governor(self):
65        return self.target.cpufreq.get_governor(self.bigs_online[0])
66
67    def get_bigs_governor_tunables(self):
68        return self.target.cpufreq.get_governor_tunables(self.bigs_online[0])
69
70    def get_bigs_frequency(self):
71        return self.target.cpufreq.get_frequency(self.bigs_online[0])
72
73    def get_bigs_min_frequency(self):
74        return self.target.cpufreq.get_min_frequency(self.bigs_online[0])
75
76    def get_bigs_max_frequency(self):
77        return self.target.cpufreq.get_max_frequency(self.bigs_online[0])
78
79    def get_littles_governor(self):
80        return self.target.cpufreq.get_governor(self.littles_online[0])
81
82    def get_littles_governor_tunables(self):
83        return self.target.cpufreq.get_governor_tunables(self.littles_online[0])
84
85    def get_littles_frequency(self):
86        return self.target.cpufreq.get_frequency(self.littles_online[0])
87
88    def get_littles_min_frequency(self):
89        return self.target.cpufreq.get_min_frequency(self.littles_online[0])
90
91    def get_littles_max_frequency(self):
92        return self.target.cpufreq.get_max_frequency(self.littles_online[0])
93
94    def set_bigs_governor(self, governor, **kwargs):
95        self.target.cpufreq.set_governor(self.bigs_online[0], governor, **kwargs)
96
97    def set_bigs_governor_tunables(self, governor, **kwargs):
98        self.target.cpufreq.set_governor_tunables(self.bigs_online[0], governor, **kwargs)
99
100    def set_bigs_frequency(self, frequency, exact=True):
101        self.target.cpufreq.set_frequency(self.bigs_online[0], frequency, exact)
102
103    def set_bigs_min_frequency(self, frequency, exact=True):
104        self.target.cpufreq.set_min_frequency(self.bigs_online[0], frequency, exact)
105
106    def set_bigs_max_frequency(self, frequency, exact=True):
107        self.target.cpufreq.set_max_frequency(self.bigs_online[0], frequency, exact)
108
109    def set_littles_governor(self, governor, **kwargs):
110        self.target.cpufreq.set_governor(self.littles_online[0], governor, **kwargs)
111
112    def set_littles_governor_tunables(self, governor, **kwargs):
113        self.target.cpufreq.set_governor_tunables(self.littles_online[0], governor, **kwargs)
114
115    def set_littles_frequency(self, frequency, exact=True):
116        self.target.cpufreq.set_frequency(self.littles_online[0], frequency, exact)
117
118    def set_littles_min_frequency(self, frequency, exact=True):
119        self.target.cpufreq.set_min_frequency(self.littles_online[0], frequency, exact)
120
121    def set_littles_max_frequency(self, frequency, exact=True):
122        self.target.cpufreq.set_max_frequency(self.littles_online[0], frequency, exact)
123