Path: blob/master/arch/powerpc/platforms/pseries/power.c
10818 views
/*1* Interface for power-management for ppc64 compliant platform2*3* Manish Ahuja <[email protected]>4*5* Feb 20076*7* Copyright (C) 2007 IBM Corporation.8*9* This program is free software; you can redistribute it and/or modify10* it under the terms of the GNU General Public License as published by11* the Free Software Foundation; version 2 of the License.12*13* This program is distributed in the hope that it will be useful,14* but WITHOUT ANY WARRANTY; without even the implied warranty of15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16* GNU General Public License for more details.17*18* You should have received a copy of the GNU General Public License19* along with this program; if not, write to the Free Software20* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA21*/2223#include <linux/kobject.h>24#include <linux/string.h>25#include <linux/errno.h>26#include <linux/init.h>2728unsigned long rtas_poweron_auto; /* default and normal state is 0 */2930static ssize_t auto_poweron_show(struct kobject *kobj,31struct kobj_attribute *attr, char *buf)32{33return sprintf(buf, "%lu\n", rtas_poweron_auto);34}3536static ssize_t auto_poweron_store(struct kobject *kobj,37struct kobj_attribute *attr,38const char *buf, size_t n)39{40int ret;41unsigned long ups_restart;42ret = sscanf(buf, "%lu", &ups_restart);4344if ((ret == 1) && ((ups_restart == 1) || (ups_restart == 0))){45rtas_poweron_auto = ups_restart;46return n;47}48return -EINVAL;49}5051static struct kobj_attribute auto_poweron_attr =52__ATTR(auto_poweron, 0644, auto_poweron_show, auto_poweron_store);5354#ifndef CONFIG_PM55struct kobject *power_kobj;5657static struct attribute *g[] = {58&auto_poweron_attr.attr,59NULL,60};6162static struct attribute_group attr_group = {63.attrs = g,64};6566static int __init pm_init(void)67{68power_kobj = kobject_create_and_add("power", NULL);69if (!power_kobj)70return -ENOMEM;71return sysfs_create_group(power_kobj, &attr_group);72}73core_initcall(pm_init);74#else75static int __init apo_pm_init(void)76{77return (sysfs_create_file(power_kobj, &auto_poweron_attr.attr));78}79__initcall(apo_pm_init);80#endif818283