~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise-security

« back to all changes in this revision

Viewing changes to arch/sh/kernel/cpu/shmobile/cpuidle.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2011-12-06 15:56:07 UTC
  • Revision ID: package-import@ubuntu.com-20111206155607-pcf44kv5fmhk564f
Tags: 3.2.0-1401.1
[ Paolo Pisati ]

* Rebased on top of Ubuntu-3.2.0-3.8
* Tilt-tracking @ ef2487af4bb15bdd0689631774b5a5e3a59f74e2
* Delete debian.ti-omap4/control, it shoudln't be tracked
* Fix architecture spelling (s/armel/armhf/)
* [Config] Update configs following 3.2 import
* [Config] Fix compilation: disable CODA and ARCH_OMAP3
* [Config] Fix compilation: disable Ethernet Faraday
* Update series to precise

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#include <linux/io.h>
15
15
#include <linux/suspend.h>
16
16
#include <linux/cpuidle.h>
 
17
#include <linux/export.h>
17
18
#include <asm/suspend.h>
18
19
#include <asm/uaccess.h>
19
20
#include <asm/hwblk.h>
25
26
};
26
27
 
27
28
static int cpuidle_sleep_enter(struct cpuidle_device *dev,
28
 
                               struct cpuidle_state *state)
 
29
                                struct cpuidle_driver *drv,
 
30
                                int index)
29
31
{
30
32
        unsigned long allowed_mode = arch_hwblk_sleep_mode();
31
33
        ktime_t before, after;
32
 
        int requested_state = state - &dev->states[0];
 
34
        int requested_state = index;
33
35
        int allowed_state;
34
36
        int k;
35
37
 
46
48
         */
47
49
        k = min_t(int, allowed_state, requested_state);
48
50
 
49
 
        dev->last_state = &dev->states[k];
50
51
        before = ktime_get();
51
52
        sh_mobile_call_standby(cpuidle_mode[k]);
52
53
        after = ktime_get();
53
 
        return ktime_to_ns(ktime_sub(after, before)) >> 10;
 
54
 
 
55
        dev->last_residency = (int)ktime_to_ns(ktime_sub(after, before)) >> 10;
 
56
 
 
57
        return k;
54
58
}
55
59
 
56
60
static struct cpuidle_device cpuidle_dev;
62
66
void sh_mobile_setup_cpuidle(void)
63
67
{
64
68
        struct cpuidle_device *dev = &cpuidle_dev;
 
69
        struct cpuidle_driver *drv = &cpuidle_driver;
65
70
        struct cpuidle_state *state;
66
71
        int i;
67
72
 
68
 
        cpuidle_register_driver(&cpuidle_driver);
69
73
 
70
74
        for (i = 0; i < CPUIDLE_STATE_MAX; i++) {
71
 
                dev->states[i].name[0] = '\0';
72
 
                dev->states[i].desc[0] = '\0';
 
75
                drv->states[i].name[0] = '\0';
 
76
                drv->states[i].desc[0] = '\0';
73
77
        }
74
78
 
75
79
        i = CPUIDLE_DRIVER_STATE_START;
76
80
 
77
 
        state = &dev->states[i++];
 
81
        state = &drv->states[i++];
78
82
        snprintf(state->name, CPUIDLE_NAME_LEN, "C1");
79
83
        strncpy(state->desc, "SuperH Sleep Mode", CPUIDLE_DESC_LEN);
80
84
        state->exit_latency = 1;
84
88
        state->flags |= CPUIDLE_FLAG_TIME_VALID;
85
89
        state->enter = cpuidle_sleep_enter;
86
90
 
87
 
        dev->safe_state = state;
 
91
        drv->safe_state_index = i-1;
88
92
 
89
93
        if (sh_mobile_sleep_supported & SUSP_SH_SF) {
90
 
                state = &dev->states[i++];
 
94
                state = &drv->states[i++];
91
95
                snprintf(state->name, CPUIDLE_NAME_LEN, "C2");
92
96
                strncpy(state->desc, "SuperH Sleep Mode [SF]",
93
97
                        CPUIDLE_DESC_LEN);
100
104
        }
101
105
 
102
106
        if (sh_mobile_sleep_supported & SUSP_SH_STANDBY) {
103
 
                state = &dev->states[i++];
 
107
                state = &drv->states[i++];
104
108
                snprintf(state->name, CPUIDLE_NAME_LEN, "C3");
105
109
                strncpy(state->desc, "SuperH Mobile Standby Mode [SF]",
106
110
                        CPUIDLE_DESC_LEN);
112
116
                state->enter = cpuidle_sleep_enter;
113
117
        }
114
118
 
 
119
        drv->state_count = i;
115
120
        dev->state_count = i;
116
121
 
 
122
        cpuidle_register_driver(&cpuidle_driver);
 
123
 
117
124
        cpuidle_register_device(dev);
118
125
}