Merge tag 'pm-urgent-4.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[deliverable/linux.git] / arch / powerpc / platforms / pseries / power.c
CommitLineData
5d30bf30
MA
1/*
2 * Interface for power-management for ppc64 compliant platform
3 *
4 * Manish Ahuja <mahuja@us.ibm.com>
5 *
6 * Feb 2007
7 *
8 * Copyright (C) 2007 IBM Corporation.
9 *
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.
13 *
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.
18 *
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
22 */
23
24#include <linux/kobject.h>
25#include <linux/string.h>
26#include <linux/errno.h>
27#include <linux/init.h>
8e83e905 28#include <asm/machdep.h>
5d30bf30
MA
29
30unsigned long rtas_poweron_auto; /* default and normal state is 0 */
31
79393fc4
GKH
32static ssize_t auto_poweron_show(struct kobject *kobj,
33 struct kobj_attribute *attr, char *buf)
5d30bf30
MA
34{
35 return sprintf(buf, "%lu\n", rtas_poweron_auto);
36}
37
79393fc4
GKH
38static ssize_t auto_poweron_store(struct kobject *kobj,
39 struct kobj_attribute *attr,
40 const char *buf, size_t n)
5d30bf30
MA
41{
42 int ret;
43 unsigned long ups_restart;
44 ret = sscanf(buf, "%lu", &ups_restart);
45
46 if ((ret == 1) && ((ups_restart == 1) || (ups_restart == 0))){
47 rtas_poweron_auto = ups_restart;
48 return n;
49 }
50 return -EINVAL;
51}
52
79393fc4
GKH
53static struct kobj_attribute auto_poweron_attr =
54 __ATTR(auto_poweron, 0644, auto_poweron_show, auto_poweron_store);
5d30bf30
MA
55
56#ifndef CONFIG_PM
d76e15fb 57struct kobject *power_kobj;
5d30bf30
MA
58
59static struct attribute *g[] = {
60 &auto_poweron_attr.attr,
61 NULL,
62};
63
64static struct attribute_group attr_group = {
65 .attrs = g,
66};
67
68static int __init pm_init(void)
69{
d76e15fb
GKH
70 power_kobj = kobject_create_and_add("power", NULL);
71 if (!power_kobj)
039a5dcd 72 return -ENOMEM;
d76e15fb 73 return sysfs_create_group(power_kobj, &attr_group);
5d30bf30 74}
8e83e905 75machine_core_initcall(pseries, pm_init);
5d30bf30 76#else
5d30bf30
MA
77static int __init apo_pm_init(void)
78{
3d5d27c4 79 return (sysfs_create_file(power_kobj, &auto_poweron_attr.attr));
5d30bf30 80}
8e83e905 81machine_device_initcall(pseries, apo_pm_init);
5d30bf30 82#endif
This page took 0.825195 seconds and 5 git commands to generate.