• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: Apache-2.0
2#
3# Copyright (C) 2016, ARM Limited and contributors.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17from energy_model import (ActiveState, EnergyModelNode, EnergyModelRoot,
18                          PowerDomain, EnergyModel)
19
20from collections import OrderedDict
21
22silver_cpu_active_states = OrderedDict([
23    ( 307200, ActiveState(capacity=149, power=90)),
24    ( 384000, ActiveState(capacity=188, power=111)),
25    ( 460800, ActiveState(capacity=225, power=133)),
26    ( 537600, ActiveState(capacity=257, power=160)),
27    ( 614400, ActiveState(capacity=281, power=182)),
28    ( 691200, ActiveState(capacity=315, power=210)),
29    ( 768000, ActiveState(capacity=368, power=251)),
30    ( 844800, ActiveState(capacity=406, power=306)),
31    ( 902400, ActiveState(capacity=428, power=332)),
32    ( 979200, ActiveState(capacity=469, power=379)),
33    (1056000, ActiveState(capacity=502, power=438)),
34    (1132800, ActiveState(capacity=538, power=494)),
35    (1209600, ActiveState(capacity=581, power=550)),
36    (1286400, ActiveState(capacity=611, power=613)),
37    (1363200, ActiveState(capacity=648, power=670)),
38    (1440000, ActiveState(capacity=684, power=752)),
39    (1516800, ActiveState(capacity=729, power=848)),
40    (1593600, ActiveState(capacity=763, power=925)),
41])
42
43silver_cluster_active_states = OrderedDict([
44    ( 307200, ActiveState(power=4)),
45    ( 384000, ActiveState(power=4)),
46    ( 460800, ActiveState(power=4)),
47    ( 537600, ActiveState(power=4)),
48    ( 614400, ActiveState(power=4)),
49    ( 691200, ActiveState(power=4)),
50    ( 768000, ActiveState(power=8)),
51    ( 844800, ActiveState(power=9)),
52    ( 902400, ActiveState(power=15)),
53    ( 979200, ActiveState(power=16)),
54    (1056000, ActiveState(power=21)),
55    (1132800, ActiveState(power=22)),
56    (1209600, ActiveState(power=29)),
57    (1286400, ActiveState(power=32)),
58    (1363200, ActiveState(power=42)),
59    (1440000, ActiveState(power=49)),
60    # This power value is 41 (invalid!) in the released kernel. Patch it to
61    # avoid errors.
62    (1516800, ActiveState(power=52)),
63    (1593600, ActiveState(power=52)),
64])
65
66gold_cpu_active_states = OrderedDict([
67    ( 307200, ActiveState(capacity=149, power=93)),
68    ( 384000, ActiveState(capacity=188, power=111)),
69    ( 460800, ActiveState(capacity=225, power=133)),
70    ( 537600, ActiveState(capacity=257, power=160)),
71    ( 614400, ActiveState(capacity=281, power=182)),
72    ( 691200, ActiveState(capacity=315, power=210)),
73    ( 748800, ActiveState(capacity=348, power=252)),
74    ( 825600, ActiveState(capacity=374, power=290)),
75    ( 902400, ActiveState(capacity=428, power=332)),
76    ( 979200, ActiveState(capacity=469, power=379)),
77    (1056000, ActiveState(capacity=502, power=438)),
78    (1132800, ActiveState(capacity=538, power=494)),
79    (1209600, ActiveState(capacity=581, power=550)),
80    (1286400, ActiveState(capacity=611, power=613)),
81    (1363200, ActiveState(capacity=648, power=670)),
82    (1440000, ActiveState(capacity=684, power=752)),
83    (1516800, ActiveState(capacity=729, power=848)),
84    (1593600, ActiveState(capacity=763, power=925)),
85    (1670400, ActiveState(capacity=795, power=1018)),
86    (1747200, ActiveState(capacity=832, power=1073)),
87    (1824000, ActiveState(capacity=868, power=1209)),
88    (1900800, ActiveState(capacity=905, power=1298)),
89    (1977600, ActiveState(capacity=952, power=1428)),
90    (2054400, ActiveState(capacity=979, power=1521)),
91    (2150400, ActiveState(capacity=1024, power=1715)),
92])
93
94gold_cluster_active_states = OrderedDict([
95    ( 307200, ActiveState(power=4)),
96    ( 384000, ActiveState(power=4)),
97    ( 460800, ActiveState(power=4)),
98    ( 537600, ActiveState(power=4)),
99    ( 614400, ActiveState(power=4)),
100    ( 691200, ActiveState(power=4)),
101    ( 748800, ActiveState(power=7)),
102    ( 825600, ActiveState(power=10)),
103    ( 902400, ActiveState(power=15)),
104    ( 979200, ActiveState(power=16)),
105    (1056000, ActiveState(power=21)),
106    (1132800, ActiveState(power=22)),
107    (1209600, ActiveState(power=29)),
108    (1286400, ActiveState(power=32)),
109    (1363200, ActiveState(power=42)),
110    (1440000, ActiveState(power=49)),
111    # This power value is 41 (invalid!) in the released kernel. Patch it to
112    # avoid errors.
113    (1516800, ActiveState(power=52)),
114    (1593600, ActiveState(power=52)),
115    (1670400, ActiveState(power=62)),
116    (1747200, ActiveState(power=69)),
117    (1824000, ActiveState(power=75)),
118    (1900800, ActiveState(power=81)),
119    (1977600, ActiveState(power=90)),
120    (2054400, ActiveState(power=93)),
121    (2150400, ActiveState(power=96)),
122])
123
124# TODO warn if any of the idle states aren't represented by power domains
125cpu_idle_states = OrderedDict([
126    ("WFI",               2),
127    ("cpu-sleep-0",       0),
128    ("cluster-sleep-0",   0),
129])
130
131cluster_idle_states = OrderedDict([
132    ("WFI",               0),
133    ("cpu-sleep-0",       0),
134    ("cluster-sleep-0",   0),
135])
136
137silvers = [0, 1]
138golds = [2, 3]
139
140def silver_cpu_node(cpu):
141    return EnergyModelNode(cpu=cpu,
142                           active_states=silver_cpu_active_states,
143                           idle_states=cpu_idle_states)
144
145def gold_cpu_node(cpu):
146    return EnergyModelNode(cpu=cpu,
147                           active_states=gold_cpu_active_states,
148                           idle_states=cpu_idle_states)
149
150def cpu_pd(cpu):
151    return PowerDomain(cpu=cpu, idle_states=["WFI", "cpu-sleep-0"])
152
153pixel_energy = EnergyModel(
154    root_node=EnergyModelRoot(children=[
155        EnergyModelNode(name='cluster_silver',
156                        children=[silver_cpu_node(c) for c in silvers],
157                        active_states=silver_cluster_active_states,
158                        idle_states=cluster_idle_states),
159        EnergyModelNode(name='cluster_gold',
160                        children=[gold_cpu_node(c) for c in golds],
161                        active_states=gold_cluster_active_states,
162                        idle_states=cluster_idle_states)]),
163    root_power_domain=PowerDomain(idle_states=[], children=[
164        PowerDomain(idle_states=['cluster-sleep-0'], children=[
165            cpu_pd(c) for c in silvers]),
166        PowerDomain(idle_states=['cluster-sleep-0'], children=[
167            cpu_pd(c) for c in golds])]),
168    freq_domains=[silvers, golds])
169