Path: blob/master/arch/powerpc/platforms/pseries/power.c
26481 views
// SPDX-License-Identifier: GPL-2.0-only1/*2* Interface for power-management for ppc64 compliant platform3*4* Manish Ahuja <[email protected]>5*6* Feb 20077*8* Copyright (C) 2007 IBM Corporation.9*/1011#include <linux/kobject.h>12#include <linux/string.h>13#include <linux/errno.h>14#include <linux/init.h>15#include <asm/machdep.h>1617#include "pseries.h"1819unsigned long rtas_poweron_auto; /* default and normal state is 0 */2021static ssize_t auto_poweron_show(struct kobject *kobj,22struct kobj_attribute *attr, char *buf)23{24return sprintf(buf, "%lu\n", rtas_poweron_auto);25}2627static ssize_t auto_poweron_store(struct kobject *kobj,28struct kobj_attribute *attr,29const char *buf, size_t n)30{31int ret;32unsigned long ups_restart;33ret = sscanf(buf, "%lu", &ups_restart);3435if ((ret == 1) && ((ups_restart == 1) || (ups_restart == 0))){36rtas_poweron_auto = ups_restart;37return n;38}39return -EINVAL;40}4142static struct kobj_attribute auto_poweron_attr =43__ATTR(auto_poweron, 0644, auto_poweron_show, auto_poweron_store);4445#ifndef CONFIG_PM46struct kobject *power_kobj;4748static struct attribute *g[] = {49&auto_poweron_attr.attr,50NULL,51};5253static const struct attribute_group attr_group = {54.attrs = g,55};5657static int __init pm_init(void)58{59power_kobj = kobject_create_and_add("power", NULL);60if (!power_kobj)61return -ENOMEM;62return sysfs_create_group(power_kobj, &attr_group);63}64machine_core_initcall(pseries, pm_init);65#else66static int __init apo_pm_init(void)67{68return (sysfs_create_file(power_kobj, &auto_poweron_attr.attr));69}70machine_device_initcall(pseries, apo_pm_init);71#endif727374