summaryrefslogtreecommitdiff
path: root/tools/power/cpupower/cpupower.sh
blob: a37dd4cfdb2b9de52fb01dceccff64bdf3d930f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2012, Sébastien Luttringer
# Copyright (C) 2024, Francesco Poli <invernomuto@paranoici.org>

ESTATUS=0

# apply CPU clock frequency options
if test -n "$FREQ"
then
    cpupower frequency-set -f "$FREQ" > /dev/null || ESTATUS=1
elif test -n "${GOVERNOR}${MIN_FREQ}${MAX_FREQ}"
then
    cpupower frequency-set \
      ${GOVERNOR:+ -g "$GOVERNOR"} \
      ${MIN_FREQ:+ -d "$MIN_FREQ"} ${MAX_FREQ:+ -u "$MAX_FREQ"} \
      > /dev/null || ESTATUS=1
fi

# apply CPU policy options
if test -n "$PERF_BIAS"
then
    cpupower set -b "$PERF_BIAS" > /dev/null || ESTATUS=1
fi

exit $ESTATUS