OMAP3 SRF: Generic shared resource f/w
[linux-ginger.git] / arch / arm / mach-omap2 / pm.c
blob9b2c51dd2c7bbd4de227c86c2051c1273aefbeb4
1 /*
2 * linux/arch/arm/mach-omap2/pm.c
4 * OMAP Power Management Common Routines
6 * Copyright (C) 2005 Texas Instruments, Inc.
7 * Copyright (C) 2006-2008 Nokia Corporation
9 * Written by:
10 * Richard Woodruff <r-woodruff2@ti.com>
11 * Tony Lindgren
12 * Juha Yrjola
13 * Amit Kucheria <amit.kucheria@nokia.com>
14 * Igor Stoppa <igor.stoppa@nokia.com>
15 * Jouni Hogander
17 * Based on pm.c for omap1
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License version 2 as
21 * published by the Free Software Foundation.
24 #include <linux/suspend.h>
25 #include <linux/time.h>
26 #include <linux/platform_device.h>
28 #include <plat/cpu.h>
29 #include <asm/mach/time.h>
30 #include <asm/atomic.h>
32 #include <plat/powerdomain.h>
33 #include <plat/omapdev.h>
35 #include "prm-regbits-34xx.h"
36 #include "pm.h"
38 atomic_t sleep_block = ATOMIC_INIT(0);
40 static ssize_t idle_show(struct kobject *, struct kobj_attribute *, char *);
41 static ssize_t idle_store(struct kobject *k, struct kobj_attribute *,
42 const char *buf, size_t n);
44 static ssize_t idle_show(struct kobject *kobj, struct kobj_attribute *attr,
45 char *buf)
47 return -EINVAL;
50 static ssize_t idle_store(struct kobject *kobj, struct kobj_attribute *attr,
51 const char *buf, size_t n)
53 unsigned short value;
55 if (sscanf(buf, "%hu", &value) != 1 ||
56 (value != 0 && value != 1)) {
57 printk(KERN_ERR "idle_store: Invalid value\n");
58 return -EINVAL;
61 return n;
64 void omap2_block_sleep(void)
66 atomic_inc(&sleep_block);
69 void omap2_allow_sleep(void)
71 int i;
73 i = atomic_dec_return(&sleep_block);
74 BUG_ON(i < 0);
77 unsigned get_last_off_on_transaction_id(struct device *dev)
79 struct platform_device *pdev = to_platform_device(dev);
80 struct omapdev *odev = omapdev_find_pdev(pdev);
81 struct powerdomain *pwrdm;
83 if (odev) {
84 pwrdm = omapdev_get_pwrdm(odev);
85 if (pwrdm)
86 return pwrdm->state_counter[0];
89 return 0;
92 static int __init omap_pm_init(void)
94 int error = -1;
96 return error;
98 late_initcall(omap_pm_init);