• 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 collections import OrderedDict
18
19from energy_model import (ActiveState, EnergyModelNode, EnergyModelRoot,
20                          PowerDomain, EnergyModel)
21
22a53_cluster_active_states = OrderedDict([
23    (450000, ActiveState(power=26)),
24    (575000, ActiveState(power=30)),
25    (700000, ActiveState(power=39)),
26    (775000, ActiveState(power=47)),
27    (850000, ActiveState(power=57)),
28])
29
30# TODO warn if any of the idle states aren't represented by power domains
31a53_cluster_idle_states = OrderedDict([
32    ("WFI",               56),
33    ("cpu-sleep-0",       56),
34    ("cluster-sleep-0",   17),
35])
36
37a53_cpu_active_states = OrderedDict([
38    (450000, ActiveState(capacity=235, power=33)),
39    (575000, ActiveState(capacity=302, power=46)),
40    (700000, ActiveState(capacity=368, power=61)),
41    (775000, ActiveState(capacity=406, power=76)),
42    (850000, ActiveState(capacity=447, power=93)),
43])
44
45a53_cpu_idle_states = OrderedDict([
46    ("WFI",               6),
47    ("cpu-sleep-0",       0),
48    ("cluster-sleep-0",   0),
49])
50
51a53s = [0, 3, 4, 5]
52
53def a53_cpu_node(cpu):
54    return EnergyModelNode(cpu=cpu,
55                           active_states=a53_cpu_active_states,
56                           idle_states=a53_cpu_idle_states)
57
58a57_cluster_active_states = OrderedDict([
59    ( 450000, ActiveState(power=24)),
60    ( 625000, ActiveState(power=32)),
61    ( 800000, ActiveState(power=43)),
62    ( 950000, ActiveState(power=49)),
63    (1100000, ActiveState(power=64)),
64])
65
66a57_cluster_idle_states = OrderedDict([
67    ("WFI",               65),
68    ("cpu-sleep-0",       65),
69    ("cluster-sleep-0",   24),
70])
71
72a57_cpu_active_states = OrderedDict([
73    (450000,  ActiveState(capacity=417,   power=168)),
74    (625000,  ActiveState(capacity=579,   power=251)),
75    (800000,  ActiveState(capacity=744,   power=359)),
76    (950000,  ActiveState(capacity=883,   power=479)),
77    (1100000, ActiveState(capacity=1023,  power=616)),
78])
79
80a57_cpu_idle_states = OrderedDict([
81    ("WFI",               15),
82    ("cpu-sleep-0",       0),
83    ("cluster-sleep-0",   0),
84])
85
86a57s = [1, 2]
87
88def a57_cpu_node(cpu):
89    return EnergyModelNode(cpu=cpu,
90                           active_states=a57_cpu_active_states,
91                           idle_states=a57_cpu_idle_states)
92
93juno_energy = EnergyModel(
94    root_node=EnergyModelRoot(
95        children=[
96            EnergyModelNode(
97                name="cluster_a53",
98                active_states=a53_cluster_active_states,
99                idle_states=a53_cluster_idle_states,
100                children=[a53_cpu_node(c) for c in a53s]),
101            EnergyModelNode(
102                name="cluster_a57",
103                active_states=a57_cluster_active_states,
104                idle_states=a57_cluster_idle_states,
105                children=[a57_cpu_node(c) for c in a57s])]),
106    root_power_domain=PowerDomain(idle_states=[], children=[
107        PowerDomain(
108            idle_states=["cluster-sleep-0"],
109            children=[PowerDomain(idle_states=["WFI", "cpu-sleep-0"], cpu=c)
110                      for c in a57s]),
111        PowerDomain(
112            idle_states=["cluster-sleep-0"],
113            children=[PowerDomain(idle_states=["WFI", "cpu-sleep-0"], cpu=c)
114                      for c in a53s])]),
115    freq_domains=[a53s, a57s])
116