RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / arch / powerpc / platforms / pseries / power.c
blob73e69023d90a9f57b76a718c910dde2aa3b24f0b
1 /*
2 * Interface for power-management for ppc64 compliant platform
4 * Manish Ahuja <mahuja@us.ibm.com>
6 * Feb 2007
8 * Copyright (C) 2007 IBM Corporation.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2 of the License.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <linux/kobject.h>
25 #include <linux/string.h>
26 #include <linux/errno.h>
27 #include <linux/init.h>
29 unsigned long rtas_poweron_auto; /* default and normal state is 0 */
31 static ssize_t auto_poweron_show(struct kset *kset, char *buf)
33 return sprintf(buf, "%lu\n", rtas_poweron_auto);
36 static ssize_t
37 auto_poweron_store(struct kset *kset, const char *buf, size_t n)
39 int ret;
40 unsigned long ups_restart;
41 ret = sscanf(buf, "%lu", &ups_restart);
43 if ((ret == 1) && ((ups_restart == 1) || (ups_restart == 0))){
44 rtas_poweron_auto = ups_restart;
45 return n;
47 return -EINVAL;
50 static struct subsys_attribute auto_poweron_attr = {
51 .attr = {
52 .name = __stringify(auto_poweron),
53 .mode = 0644,
55 .show = auto_poweron_show,
56 .store = auto_poweron_store,
59 #ifndef CONFIG_PM
60 decl_subsys(power,NULL,NULL);
62 static struct attribute *g[] = {
63 &auto_poweron_attr.attr,
64 NULL,
67 static struct attribute_group attr_group = {
68 .attrs = g,
71 static int __init pm_init(void)
73 int error = subsystem_register(&power_subsys);
74 if (!error)
75 error = sysfs_create_group(&power_subsys.kobj, &attr_group);
76 return error;
78 core_initcall(pm_init);
79 #else
80 extern struct kset power_subsys;
82 static int __init apo_pm_init(void)
84 return (subsys_create_file(&power_subsys, &auto_poweron_attr));
86 __initcall(apo_pm_init);
87 #endif