Lines 10-34
Link Here
|
10 |
#include <linux/signal.h> |
10 |
#include <linux/signal.h> |
11 |
#include <linux/delay.h> |
11 |
#include <linux/delay.h> |
12 |
#include <linux/interrupt.h> |
12 |
#include <linux/interrupt.h> |
13 |
#include <linux/pm.h> |
|
|
14 |
#include <linux/syscalls.h> |
13 |
#include <linux/syscalls.h> |
15 |
#include <linux/reboot.h> |
14 |
#include <linux/reboot.h> |
16 |
#include <linux/of_device.h> |
15 |
#include <linux/of_device.h> |
17 |
|
16 |
|
18 |
#include <asm/system.h> |
17 |
#include <asm/system.h> |
19 |
#include <asm/auxio.h> |
|
|
20 |
#include <asm/prom.h> |
18 |
#include <asm/prom.h> |
21 |
#include <asm/io.h> |
19 |
#include <asm/io.h> |
22 |
#include <asm/sstate.h> |
|
|
23 |
#include <asm/reboot.h> |
24 |
|
20 |
|
25 |
#include <linux/unistd.h> |
21 |
#include <linux/unistd.h> |
26 |
|
22 |
|
27 |
/* |
|
|
28 |
* sysctl - toggle power-off restriction for serial console |
29 |
* systems in machine_power_off() |
30 |
*/ |
31 |
int scons_pwroff = 1; |
32 |
|
23 |
|
33 |
static void __iomem *power_reg; |
24 |
static void __iomem *power_reg; |
34 |
|
25 |
|
Lines 40-70
Link Here
|
40 |
return IRQ_HANDLED; |
31 |
return IRQ_HANDLED; |
41 |
} |
32 |
} |
42 |
|
33 |
|
43 |
static void (*poweroff_method)(void) = machine_alt_power_off; |
|
|
44 |
|
45 |
void machine_power_off(void) |
46 |
{ |
47 |
sstate_poweroff(); |
48 |
if (strcmp(of_console_device->type, "serial") || scons_pwroff) { |
49 |
if (power_reg) { |
50 |
/* Both register bits seem to have the |
51 |
* same effect, so until I figure out |
52 |
* what the difference is... |
53 |
*/ |
54 |
writel(AUXIO_PCIO_CPWR_OFF | AUXIO_PCIO_SPWR_OFF, power_reg); |
55 |
} else { |
56 |
if (poweroff_method != NULL) { |
57 |
poweroff_method(); |
58 |
/* not reached */ |
59 |
} |
60 |
} |
61 |
} |
62 |
machine_halt(); |
63 |
} |
64 |
|
65 |
void (*pm_power_off)(void) = machine_power_off; |
66 |
EXPORT_SYMBOL(pm_power_off); |
67 |
|
68 |
static int __init has_button_interrupt(unsigned int irq, struct device_node *dp) |
34 |
static int __init has_button_interrupt(unsigned int irq, struct device_node *dp) |
69 |
{ |
35 |
{ |
70 |
if (irq == 0xffffffff) |
36 |
if (irq == 0xffffffff) |
Lines 85-92
Link Here
|
85 |
printk(KERN_INFO "%s: Control reg at %lx\n", |
51 |
printk(KERN_INFO "%s: Control reg at %lx\n", |
86 |
op->node->name, res->start); |
52 |
op->node->name, res->start); |
87 |
|
53 |
|
88 |
poweroff_method = machine_halt; /* able to use the standard halt */ |
|
|
89 |
|
90 |
if (has_button_interrupt(irq, op->node)) { |
54 |
if (has_button_interrupt(irq, op->node)) { |
91 |
if (request_irq(irq, |
55 |
if (request_irq(irq, |
92 |
power_handler, 0, "power", NULL) < 0) |
56 |
power_handler, 0, "power", NULL) < 0) |