iommu/msm: Add iommu_group support
[linux/fpc-iii.git] / arch / sparc / kernel / power.c
blob4b60f385c98fdfa59c4b56a8bd422e2efd3cc773
1 /* power.c: Power management driver.
3 * Copyright (C) 1999, 2007, 2008 David S. Miller (davem@davemloft.net)
4 */
6 #include <linux/kernel.h>
7 #include <linux/export.h>
8 #include <linux/init.h>
9 #include <linux/interrupt.h>
10 #include <linux/reboot.h>
11 #include <linux/of_device.h>
13 #include <asm/prom.h>
14 #include <asm/io.h>
16 static void __iomem *power_reg;
18 static irqreturn_t power_handler(int irq, void *dev_id)
20 orderly_poweroff(true);
22 /* FIXME: Check registers for status... */
23 return IRQ_HANDLED;
26 static int has_button_interrupt(unsigned int irq, struct device_node *dp)
28 if (irq == 0xffffffff)
29 return 0;
30 if (!of_find_property(dp, "button", NULL))
31 return 0;
33 return 1;
36 static int power_probe(struct platform_device *op)
38 struct resource *res = &op->resource[0];
39 unsigned int irq = op->archdata.irqs[0];
41 power_reg = of_ioremap(res, 0, 0x4, "power");
43 printk(KERN_INFO "%s: Control reg at %llx\n",
44 op->dev.of_node->name, res->start);
46 if (has_button_interrupt(irq, op->dev.of_node)) {
47 if (request_irq(irq,
48 power_handler, 0, "power", NULL) < 0)
49 printk(KERN_ERR "power: Cannot setup IRQ handler.\n");
52 return 0;
55 static const struct of_device_id power_match[] = {
57 .name = "power",
59 {},
62 static struct platform_driver power_driver = {
63 .probe = power_probe,
64 .driver = {
65 .name = "power",
66 .of_match_table = power_match,
70 builtin_platform_driver(power_driver);