2
* throttling.c --CPU throttling control feature
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2, or (at your option) any
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* Written by Mathieu Bérard <mathieu.berard@crans.org>, 2007
21
* Throttling level/rate mapping found in ICH6M datasheets
22
* the output is set to mimic the one of /proc/acpi/cpu/CPU0/throttling
23
* XXX: We always assume that there are 8 T-States and one processor.
25
static const int trate[8] = { 0, 12, 25, 37, 50, 62, 75, 87 };
27
static int omnibook_throttle_read(char *buffer, struct omnibook_operation *io_op)
33
retval = backend_throttle_get(io_op, &tstate);
37
len += sprintf(buffer + len, "state count: 8\n");
38
len += sprintf(buffer + len, "active state: T%d\n", tstate);
39
for (i = 0; i < 8; i += 1)
41
len += sprintf(buffer + len, " %cT%d: %02d%%\n",
42
(i == tstate ? '*' : ' '),
50
static int omnibook_throttle_write(char *buffer, struct omnibook_operation *io_op)
56
data = simple_strtoul(buffer, &endp, 10);
57
if ((endp == buffer) || (data > 7)) /* There are 8 throttling levels */
60
retval = backend_throttle_set(io_op, data);
66
static struct omnibook_tbl throttle_table[] __initdata = {
67
{TSM70 | TSX205, {ACPI,}},
71
struct omnibook_feature __declared_feature throttle_driver = {
74
.read = omnibook_throttle_read,
75
.write = omnibook_throttle_write,
76
.ectypes = TSM70 | TSX205,
77
.tbl = throttle_table,
80
module_param_named(throttle, throttle_driver.enabled, int, S_IRUGO);
81
MODULE_PARM_DESC(throttle, "Use 0 to disable, 1 to enable CPU throttling control");