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>
16 #include <asm/oplib.h>
17 #include <asm/uaccess.h>
18 #include <asm/auxio.h>
22 * #define PMC_DEBUG_LED
26 #define PMC_MINOR MISC_DYNAMIC_MINOR
27 #define PMC_OBPNAME "SUNW,pmc"
28 #define PMC_DEVNAME "pmc"
30 #define PMC_IDLE_REG 0x00
31 #define PMC_IDLE_ON 0x01
33 volatile static u8 __iomem
*regs
;
34 static int pmc_regsize
;
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 inline void pmc_free(void)
58 sbus_iounmap(regs
, pmc_regsize
);
61 static int __init
pmc_probe(void)
63 struct sbus_bus
*sbus
= NULL
;
64 struct sbus_dev
*sdev
= NULL
;
66 for_each_sbusdev(sdev
, sbus
) {
67 if (!strcmp(sdev
->prom_name
, PMC_OBPNAME
)) {
78 pmc_regsize
= sdev
->reg_addrs
[0].reg_size
;
79 regs
= sbus_ioremap(&sdev
->resource
[0], 0,
80 pmc_regsize
, PMC_OBPNAME
);
82 printk(KERN_ERR
"%s: unable to map registers\n", PMC_DEVNAME
);
87 /* Assign power management IDLE handler */
88 pm_idle
= pmc_swift_idle
;
91 printk(KERN_INFO
"%s: power management initialized\n", PMC_DEVNAME
);
95 /* This driver is not critical to the boot process
96 * and is easiest to ioremap when SBus is already
97 * initialized, so we install ourselves thusly:
99 __initcall(pmc_probe
);