Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / sparc / kernel / pmc.c
blobb5c1eb33b9518aab087fcb81c08a3da3e0e63873
1 // SPDX-License-Identifier: GPL-2.0
2 /* pmc - Driver implementation for power management functions
3 * of Power Management Controller (PMC) on SPARCstation-Voyager.
5 * Copyright (c) 2002 Eric Brower (ebrower@usa.net)
6 */
8 #include <linux/kernel.h>
9 #include <linux/fs.h>
10 #include <linux/errno.h>
11 #include <linux/init.h>
12 #include <linux/pm.h>
13 #include <linux/of.h>
14 #include <linux/of_device.h>
15 #include <linux/module.h>
17 #include <asm/io.h>
18 #include <asm/oplib.h>
19 #include <linux/uaccess.h>
20 #include <asm/auxio.h>
21 #include <asm/processor.h>
23 /* Debug
25 * #define PMC_DEBUG_LED
26 * #define PMC_NO_IDLE
29 #define PMC_OBPNAME "SUNW,pmc"
30 #define PMC_DEVNAME "pmc"
32 #define PMC_IDLE_REG 0x00
33 #define PMC_IDLE_ON 0x01
35 static u8 __iomem *regs;
37 #define pmc_readb(offs) (sbus_readb(regs+offs))
38 #define pmc_writeb(val, offs) (sbus_writeb(val, regs+offs))
41 * CPU idle callback function
42 * See .../arch/sparc/kernel/process.c
44 static void pmc_swift_idle(void)
46 #ifdef PMC_DEBUG_LED
47 set_auxio(0x00, AUXIO_LED);
48 #endif
50 pmc_writeb(pmc_readb(PMC_IDLE_REG) | PMC_IDLE_ON, PMC_IDLE_REG);
52 #ifdef PMC_DEBUG_LED
53 set_auxio(AUXIO_LED, 0x00);
54 #endif
57 static int pmc_probe(struct platform_device *op)
59 regs = of_ioremap(&op->resource[0], 0,
60 resource_size(&op->resource[0]), PMC_OBPNAME);
61 if (!regs) {
62 printk(KERN_ERR "%s: unable to map registers\n", PMC_DEVNAME);
63 return -ENODEV;
66 #ifndef PMC_NO_IDLE
67 /* Assign power management IDLE handler */
68 sparc_idle = pmc_swift_idle;
69 #endif
71 printk(KERN_INFO "%s: power management initialized\n", PMC_DEVNAME);
72 return 0;
75 static const struct of_device_id pmc_match[] = {
77 .name = PMC_OBPNAME,
79 {},
81 MODULE_DEVICE_TABLE(of, pmc_match);
83 static struct platform_driver pmc_driver = {
84 .driver = {
85 .name = "pmc",
86 .of_match_table = pmc_match,
88 .probe = pmc_probe,
91 static int __init pmc_init(void)
93 return platform_driver_register(&pmc_driver);
96 /* This driver is not critical to the boot process
97 * and is easiest to ioremap when SBus is already
98 * initialized, so we install ourselves thusly:
100 __initcall(pmc_init);