~ubuntu-branches/ubuntu/precise/linux-ti-omap/precise

« back to all changes in this revision

Viewing changes to ubuntu/omnibook/throttling.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bader, Amit Kucheria
  • Date: 2010-03-23 18:05:12 UTC
  • Revision ID: james.westby@ubuntu.com-20100323180512-iavj906ocnphdubp
Tags: 2.6.33-500.3
[ Amit Kucheria ]

* [Config] Fix the debug package name to end in -dbgsym
* SAUCE: Add the ubuntu/ drivers to omap
* SAUCE: Re-export the symbols for aufs
* [Config] Enable AUFS and COMPCACHE

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * throttling.c --CPU throttling control feature
 
3
 * 
 
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
 
7
 * later version.
 
8
 * 
 
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.
 
13
 *
 
14
 * Written by Mathieu Bérard <mathieu.berard@crans.org>, 2007
 
15
 */
 
16
 
 
17
#include "omnibook.h"
 
18
#include "hardware.h"
 
19
 
 
20
/*
 
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.
 
24
 */
 
25
static const int trate[8] = { 0, 12, 25, 37, 50, 62, 75, 87 };
 
26
 
 
27
static int omnibook_throttle_read(char *buffer, struct omnibook_operation *io_op)
 
28
{
 
29
        int len = 0;
 
30
        int tstate = 0;
 
31
        int retval, i;
 
32
 
 
33
        retval = backend_throttle_get(io_op, &tstate);
 
34
        if (retval < 0)
 
35
                return retval;
 
36
 
 
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)
 
40
        {
 
41
                len += sprintf(buffer + len, "   %cT%d:                  %02d%%\n",
 
42
                        (i == tstate ? '*' : ' '),
 
43
                        i,
 
44
                        trate[i]);
 
45
        }
 
46
 
 
47
        return len;
 
48
}
 
49
 
 
50
static int omnibook_throttle_write(char *buffer, struct omnibook_operation *io_op)
 
51
{
 
52
        int retval = 0;
 
53
        int data;
 
54
        char *endp;
 
55
 
 
56
        data = simple_strtoul(buffer, &endp, 10);
 
57
        if ((endp == buffer) || (data > 7)) /* There are 8 throttling levels */
 
58
                return -EINVAL;
 
59
        else
 
60
                retval = backend_throttle_set(io_op, data);
 
61
        
 
62
        return retval;
 
63
}
 
64
 
 
65
 
 
66
static struct omnibook_tbl throttle_table[] __initdata = {
 
67
        {TSM70 | TSX205, {ACPI,}},
 
68
        {0,}
 
69
};
 
70
 
 
71
struct omnibook_feature __declared_feature throttle_driver = {
 
72
        .name = "throttling",
 
73
        .enabled = 1,
 
74
        .read = omnibook_throttle_read,
 
75
        .write = omnibook_throttle_write,
 
76
        .ectypes = TSM70 | TSX205,
 
77
        .tbl = throttle_table,
 
78
};
 
79
 
 
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");
 
82
 
 
83
/* End of file */