1 /* pmc - Driver implementation for power management functions
2 * of Power Management Controller (PMC) on SPARCstation-Voyager.
4 * Copyright (c) 2002 Eric Brower (ebrower@usa.net)
7 #include <linux/kernel.h>
9 #include <linux/errno.h>
10 #include <linux/init.h>
11 #include <linux/miscdevice.h>
14 #include <linux/of_device.h>
17 #include <asm/oplib.h>
18 #include <asm/uaccess.h>
19 #include <asm/auxio.h>
23 * #define PMC_DEBUG_LED
27 #define PMC_MINOR MISC_DYNAMIC_MINOR
28 #define PMC_OBPNAME "SUNW,pmc"
29 #define PMC_DEVNAME "pmc"
31 #define PMC_IDLE_REG 0x00
32 #define PMC_IDLE_ON 0x01
34 static u8 __iomem *regs;
36 #define pmc_readb(offs) (sbus_readb(regs+offs))
37 #define pmc_writeb(val, offs) (sbus_writeb(val, regs+offs))
40 * CPU idle callback function
41 * See .../arch/sparc/kernel/process.c
43 void pmc_swift_idle(void)
46 set_auxio(0x00, AUXIO_LED);
49 pmc_writeb(pmc_readb(PMC_IDLE_REG) | PMC_IDLE_ON, PMC_IDLE_REG);
52 set_auxio(AUXIO_LED, 0x00);
56 static int __devinit pmc_probe(struct of_device *op,
57 const struct of_device_id *match)
59 regs = of_ioremap(&op->resource[0], 0,
60 resource_size(&op->resource[0]), PMC_OBPNAME);
62 printk(KERN_ERR "%s: unable to map registers\n", PMC_DEVNAME);
67 /* Assign power management IDLE handler */
68 pm_idle = pmc_swift_idle;
71 printk(KERN_INFO "%s: power management initialized\n", PMC_DEVNAME);
75 static struct of_device_id __initdata pmc_match[] = {
81 MODULE_DEVICE_TABLE(of, pmc_match);
83 static struct of_platform_driver pmc_driver = {
85 .match_table = pmc_match,
89 static int __init pmc_init(void)
91 return of_register_driver(&pmc_driver, &of_bus_type);
94 /* This driver is not critical to the boot process
95 * and is easiest to ioremap when SBus is already
96 * initialized, so we install ourselves thusly: