• 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
22cluster_active_states = OrderedDict([
23    ( 208000, ActiveState(capacity=178, power=16)),
24    ( 432000, ActiveState(capacity=369, power=29)),
25    ( 729000, ActiveState(capacity=622, power=47)),
26    ( 960000, ActiveState(capacity=819, power=75)),
27    (1200000, ActiveState(capacity=1024, power=112))
28])
29
30cluster_idle_states = OrderedDict([
31    ('WFI', 47),
32    ('cpu-sleep', 47),
33    ('cluster-sleep', 0)
34])
35
36cpu_active_states = OrderedDict([
37    ( 208000,  ActiveState(capacity=178,  power=69)),
38    ( 432000,  ActiveState(capacity=369,  power=124)),
39    ( 729000,  ActiveState(capacity=622,  power=224)),
40    ( 960000,  ActiveState(capacity=819,  power=367)),
41    (1200000, ActiveState(capacity=1024, power=670))
42])
43
44cpu_idle_states = OrderedDict([
45    ('WFI', 15), ('cpu-sleep', 0), ('cluster-sleep', 0)
46])
47
48def cpu_pd(cpu):
49    return PowerDomain(cpu=cpu, idle_states=['WFI', 'cpu-sleep'])
50
51def cpu_node(cpu):
52    return EnergyModelNode(cpu=cpu,
53                           active_states=cpu_active_states,
54                           idle_states=cpu_idle_states)
55hikey_energy = EnergyModel(
56    root_node=EnergyModelRoot(children=[
57        EnergyModelNode(name='cluster0',
58                        children=[cpu_node(c) for c in [0, 1, 2, 3]],
59                        active_states=cluster_active_states,
60                        idle_states=cluster_idle_states),
61        EnergyModelNode(name='cluster1',
62                        children=[cpu_node(c) for c in [4, 5, 6, 7]],
63                        active_states=cluster_active_states,
64                        idle_states=cluster_idle_states)]),
65    root_power_domain=PowerDomain(idle_states=[], children=[
66        PowerDomain(idle_states=["cluster-sleep"], children=[
67            cpu_pd(c) for c in [0, 1, 2, 3]]),
68        PowerDomain(idle_states=["cluster-sleep"], children=[
69            cpu_pd(c) for c in [4, 5, 6, 7]])]),
70    freq_domains=[[0, 1, 2, 3, 4, 5, 6, 7]])
71