Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / sparc64 / kernel / power.c
blob381b6a9f61cedaa700ee65a76048a6c6c9792780
1 /* power.c: Power management driver.
3 * Copyright (C) 1999, 2007 David S. Miller (davem@davemloft.net)
4 */
6 #include <linux/kernel.h>
7 #include <linux/module.h>
8 #include <linux/init.h>
9 #include <linux/sched.h>
10 #include <linux/signal.h>
11 #include <linux/delay.h>
12 #include <linux/interrupt.h>
13 #include <linux/pm.h>
14 #include <linux/syscalls.h>
15 #include <linux/reboot.h>
17 #include <asm/system.h>
18 #include <asm/auxio.h>
19 #include <asm/prom.h>
20 #include <asm/of_device.h>
21 #include <asm/io.h>
22 #include <asm/sstate.h>
23 <<<<<<< HEAD:arch/sparc64/kernel/power.c
24 =======
25 #include <asm/reboot.h>
26 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/power.c
28 #include <linux/unistd.h>
31 * sysctl - toggle power-off restriction for serial console
32 * systems in machine_power_off()
34 int scons_pwroff = 1;
36 static void __iomem *power_reg;
38 static irqreturn_t power_handler(int irq, void *dev_id)
40 orderly_poweroff(true);
42 /* FIXME: Check registers for status... */
43 return IRQ_HANDLED;
46 <<<<<<< HEAD:arch/sparc64/kernel/power.c
47 extern void machine_halt(void);
48 extern void machine_alt_power_off(void);
49 =======
50 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/power.c
51 static void (*poweroff_method)(void) = machine_alt_power_off;
53 void machine_power_off(void)
55 sstate_poweroff();
56 if (strcmp(of_console_device->type, "serial") || scons_pwroff) {
57 if (power_reg) {
58 /* Both register bits seem to have the
59 * same effect, so until I figure out
60 * what the difference is...
62 writel(AUXIO_PCIO_CPWR_OFF | AUXIO_PCIO_SPWR_OFF, power_reg);
63 } else {
64 if (poweroff_method != NULL) {
65 poweroff_method();
66 /* not reached */
70 machine_halt();
73 void (*pm_power_off)(void) = machine_power_off;
74 EXPORT_SYMBOL(pm_power_off);
76 static int __init has_button_interrupt(unsigned int irq, struct device_node *dp)
78 if (irq == 0xffffffff)
79 return 0;
80 if (!of_find_property(dp, "button", NULL))
81 return 0;
83 return 1;
86 static int __devinit power_probe(struct of_device *op, const struct of_device_id *match)
88 struct resource *res = &op->resource[0];
89 unsigned int irq= op->irqs[0];
91 power_reg = of_ioremap(res, 0, 0x4, "power");
93 printk(KERN_INFO "%s: Control reg at %lx\n",
94 op->node->name, res->start);
96 poweroff_method = machine_halt; /* able to use the standard halt */
98 if (has_button_interrupt(irq, op->node)) {
99 if (request_irq(irq,
100 power_handler, 0, "power", NULL) < 0)
101 printk(KERN_ERR "power: Cannot setup IRQ handler.\n");
104 return 0;
107 static struct of_device_id power_match[] = {
109 .name = "power",
114 static struct of_platform_driver power_driver = {
115 .match_table = power_match,
116 .probe = power_probe,
117 .driver = {
118 .name = "power",
122 void __init power_init(void)
124 of_register_driver(&power_driver, &of_platform_bus_type);
125 return;