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

« back to all changes in this revision

Viewing changes to ubuntu/omnibook/cooling.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
 * colling.c -- cooling methods 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
static int omnibook_cooling_read(char *buffer, struct omnibook_operation *io_op)
 
21
{
 
22
        int len = 0;
 
23
 
 
24
        if(mutex_lock_interruptible(&io_op->backend->mutex))
 
25
                return -ERESTARTSYS;
 
26
 
 
27
        len += sprintf(buffer + len, "Cooling method : %s\n", 
 
28
                        io_op->backend->cooling_state ? "Performance"  : "Powersave" );
 
29
 
 
30
        mutex_unlock(&io_op->backend->mutex);
 
31
        return len;
 
32
}
 
33
 
 
34
static int omnibook_cooling_write(char *buffer, struct omnibook_operation *io_op)
 
35
{
 
36
        int retval = 0;
 
37
 
 
38
        if(mutex_lock_interruptible(&io_op->backend->mutex))
 
39
                return -ERESTARTSYS;
 
40
 
 
41
 
 
42
        if (*buffer == '0') {
 
43
                retval = __backend_byte_write(io_op, 
 
44
                                TSM70_COOLING_OFFSET + TSM70_COOLING_POWERSAVE);
 
45
        } else if (*buffer == '1') {
 
46
                retval = __backend_byte_write(io_op,
 
47
                                TSM70_COOLING_OFFSET + TSM70_COOLING_PERF);
 
48
        } else {
 
49
                retval = -EINVAL;
 
50
                goto out;
 
51
        }
 
52
 
 
53
        /* *buffer is either '0' or '1' here */
 
54
        if (!retval)
 
55
                io_op->backend->cooling_state = *buffer - '0' ;
 
56
 
 
57
        mutex_unlock(&io_op->backend->mutex);
 
58
 
 
59
        out:
 
60
        return retval;
 
61
}
 
62
 
 
63
static int __init omnibook_cooling_init(struct omnibook_operation *io_op)
 
64
{
 
65
        mutex_lock(&io_op->backend->mutex);
 
66
        /* XXX: Assumed default cooling method: performance */
 
67
        io_op->backend->cooling_state = TSM70_COOLING_PERF;
 
68
        mutex_unlock(&io_op->backend->mutex);
 
69
        return 0;
 
70
}
 
71
 
 
72
static void __exit omnibook_cooling_exit(struct omnibook_operation *io_op)
 
73
{
 
74
        /* Set back cooling method to performance */    
 
75
        backend_byte_write(io_op, TSM70_COOLING_OFFSET + TSM70_COOLING_PERF);
 
76
}
 
77
 
 
78
static struct omnibook_tbl cooling_table[] __initdata = {
 
79
        {TSM70 | TSX205, {CDI, 0, TSM70_FN_INDEX, 0, 0, 0 }},
 
80
        {0,}
 
81
};
 
82
 
 
83
struct omnibook_feature __declared_feature cooling_driver = {
 
84
        .name = "cooling",
 
85
        .enabled = 1,
 
86
        .read = omnibook_cooling_read,
 
87
        .write = omnibook_cooling_write,
 
88
        .init = omnibook_cooling_init,
 
89
        .exit = omnibook_cooling_exit,
 
90
        .ectypes = TSM70 | TSX205,
 
91
        .tbl = cooling_table,
 
92
};
 
93
 
 
94
module_param_named(cooling, cooling_driver.enabled, int, S_IRUGO);
 
95
MODULE_PARM_DESC(cooling, "Use 0 to disable, 1 to enable CPU cooling method control");
 
96
 
 
97
/* End of file */