Linux Audio

Check our new training course

Loading...
v3.15
  1/* pmc - Driver implementation for power management functions
  2 * of Power Management Controller (PMC) on SPARCstation-Voyager.
  3 *
  4 * Copyright (c) 2002 Eric Brower (ebrower@usa.net)
  5 */
  6
  7#include <linux/kernel.h>
  8#include <linux/fs.h>
  9#include <linux/errno.h>
 10#include <linux/init.h>
 11#include <linux/pm.h>
 12#include <linux/of.h>
 13#include <linux/of_device.h>
 14#include <linux/module.h>
 15
 16#include <asm/io.h>
 17#include <asm/oplib.h>
 18#include <asm/uaccess.h>
 19#include <asm/auxio.h>
 20#include <asm/processor.h>
 21
 22/* Debug
 23 *
 24 * #define PMC_DEBUG_LED
 25 * #define PMC_NO_IDLE
 26 */
 27
 28#define PMC_OBPNAME	"SUNW,pmc"
 29#define PMC_DEVNAME	"pmc"
 30
 31#define PMC_IDLE_REG	0x00
 32#define PMC_IDLE_ON	0x01
 33
 34static u8 __iomem *regs;
 35
 36#define pmc_readb(offs)		(sbus_readb(regs+offs))
 37#define pmc_writeb(val, offs)	(sbus_writeb(val, regs+offs))
 38
 39/*
 40 * CPU idle callback function
 41 * See .../arch/sparc/kernel/process.c
 42 */
 43static void pmc_swift_idle(void)
 44{
 45#ifdef PMC_DEBUG_LED
 46	set_auxio(0x00, AUXIO_LED);
 47#endif
 48
 49	pmc_writeb(pmc_readb(PMC_IDLE_REG) | PMC_IDLE_ON, PMC_IDLE_REG);
 50
 51#ifdef PMC_DEBUG_LED
 52	set_auxio(AUXIO_LED, 0x00);
 53#endif
 54}
 55
 56static int pmc_probe(struct platform_device *op)
 57{
 58	regs = of_ioremap(&op->resource[0], 0,
 59			  resource_size(&op->resource[0]), PMC_OBPNAME);
 60	if (!regs) {
 61		printk(KERN_ERR "%s: unable to map registers\n", PMC_DEVNAME);
 62		return -ENODEV;
 63	}
 64
 65#ifndef PMC_NO_IDLE
 66	/* Assign power management IDLE handler */
 67	sparc_idle = pmc_swift_idle;
 68#endif
 69
 70	printk(KERN_INFO "%s: power management initialized\n", PMC_DEVNAME);
 71	return 0;
 72}
 73
 74static struct of_device_id pmc_match[] = {
 75	{
 76		.name = PMC_OBPNAME,
 77	},
 78	{},
 79};
 80MODULE_DEVICE_TABLE(of, pmc_match);
 81
 82static struct platform_driver pmc_driver = {
 83	.driver = {
 84		.name = "pmc",
 85		.owner = THIS_MODULE,
 86		.of_match_table = pmc_match,
 87	},
 88	.probe		= pmc_probe,
 89};
 90
 91static int __init pmc_init(void)
 92{
 93	return platform_driver_register(&pmc_driver);
 94}
 95
 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:
 99 */
100__initcall(pmc_init);
v3.1
 1/* pmc - Driver implementation for power management functions
 2 * of Power Management Controller (PMC) on SPARCstation-Voyager.
 3 *
 4 * Copyright (c) 2002 Eric Brower (ebrower@usa.net)
 5 */
 6
 7#include <linux/kernel.h>
 8#include <linux/fs.h>
 9#include <linux/errno.h>
10#include <linux/init.h>
11#include <linux/pm.h>
12#include <linux/of.h>
13#include <linux/of_device.h>
 
14
15#include <asm/io.h>
16#include <asm/oplib.h>
17#include <asm/uaccess.h>
18#include <asm/auxio.h>
 
19
20/* Debug
21 *
22 * #define PMC_DEBUG_LED
23 * #define PMC_NO_IDLE
24 */
25
26#define PMC_OBPNAME	"SUNW,pmc"
27#define PMC_DEVNAME	"pmc"
28
29#define PMC_IDLE_REG	0x00
30#define PMC_IDLE_ON	0x01
31
32static u8 __iomem *regs;
33
34#define pmc_readb(offs)		(sbus_readb(regs+offs))
35#define pmc_writeb(val, offs)	(sbus_writeb(val, regs+offs))
36
37/*
38 * CPU idle callback function
39 * See .../arch/sparc/kernel/process.c
40 */
41static void pmc_swift_idle(void)
42{
43#ifdef PMC_DEBUG_LED
44	set_auxio(0x00, AUXIO_LED);
45#endif
46
47	pmc_writeb(pmc_readb(PMC_IDLE_REG) | PMC_IDLE_ON, PMC_IDLE_REG);
48
49#ifdef PMC_DEBUG_LED
50	set_auxio(AUXIO_LED, 0x00);
51#endif
52}
53
54static int __devinit pmc_probe(struct platform_device *op)
55{
56	regs = of_ioremap(&op->resource[0], 0,
57			  resource_size(&op->resource[0]), PMC_OBPNAME);
58	if (!regs) {
59		printk(KERN_ERR "%s: unable to map registers\n", PMC_DEVNAME);
60		return -ENODEV;
61	}
62
63#ifndef PMC_NO_IDLE
64	/* Assign power management IDLE handler */
65	pm_idle = pmc_swift_idle;
66#endif
67
68	printk(KERN_INFO "%s: power management initialized\n", PMC_DEVNAME);
69	return 0;
70}
71
72static struct of_device_id pmc_match[] = {
73	{
74		.name = PMC_OBPNAME,
75	},
76	{},
77};
78MODULE_DEVICE_TABLE(of, pmc_match);
79
80static struct platform_driver pmc_driver = {
81	.driver = {
82		.name = "pmc",
83		.owner = THIS_MODULE,
84		.of_match_table = pmc_match,
85	},
86	.probe		= pmc_probe,
87};
88
89static int __init pmc_init(void)
90{
91	return platform_driver_register(&pmc_driver);
92}
93
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:
97 */
98__initcall(pmc_init);