diff options
Diffstat (limited to 'arch/sparc/kernel/pmc.c')
-rw-r--r-- | arch/sparc/kernel/pmc.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/arch/sparc/kernel/pmc.c b/arch/sparc/kernel/pmc.c index 7eca8871ff47..814eb3ce039b 100644 --- a/arch/sparc/kernel/pmc.c +++ b/arch/sparc/kernel/pmc.c | |||
@@ -10,9 +10,10 @@ | |||
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/miscdevice.h> | 11 | #include <linux/miscdevice.h> |
12 | #include <linux/pm.h> | 12 | #include <linux/pm.h> |
13 | #include <linux/of.h> | ||
14 | #include <linux/of_device.h> | ||
13 | 15 | ||
14 | #include <asm/io.h> | 16 | #include <asm/io.h> |
15 | #include <asm/sbus.h> | ||
16 | #include <asm/oplib.h> | 17 | #include <asm/oplib.h> |
17 | #include <asm/uaccess.h> | 18 | #include <asm/uaccess.h> |
18 | #include <asm/auxio.h> | 19 | #include <asm/auxio.h> |
@@ -30,10 +31,9 @@ | |||
30 | #define PMC_IDLE_REG 0x00 | 31 | #define PMC_IDLE_REG 0x00 |
31 | #define PMC_IDLE_ON 0x01 | 32 | #define PMC_IDLE_ON 0x01 |
32 | 33 | ||
33 | volatile static u8 __iomem *regs; | 34 | static u8 __iomem *regs; |
34 | static int pmc_regsize; | ||
35 | 35 | ||
36 | #define pmc_readb(offs) (sbus_readb(regs+offs)) | 36 | #define pmc_readb(offs) (sbus_readb(regs+offs)) |
37 | #define pmc_writeb(val, offs) (sbus_writeb(val, regs+offs)) | 37 | #define pmc_writeb(val, offs) (sbus_writeb(val, regs+offs)) |
38 | 38 | ||
39 | /* | 39 | /* |
@@ -53,31 +53,11 @@ void pmc_swift_idle(void) | |||
53 | #endif | 53 | #endif |
54 | } | 54 | } |
55 | 55 | ||
56 | static inline void pmc_free(void) | 56 | static int __devinit pmc_probe(struct of_device *op, |
57 | const struct of_device_id *match) | ||
57 | { | 58 | { |
58 | sbus_iounmap(regs, pmc_regsize); | 59 | regs = of_ioremap(&op->resource[0], 0, |
59 | } | 60 | resource_size(&op->resource[0]), PMC_OBPNAME); |
60 | |||
61 | static int __init pmc_probe(void) | ||
62 | { | ||
63 | struct sbus_bus *sbus = NULL; | ||
64 | struct sbus_dev *sdev = NULL; | ||
65 | for_each_sbus(sbus) { | ||
66 | for_each_sbusdev(sdev, sbus) { | ||
67 | if (!strcmp(sdev->prom_name, PMC_OBPNAME)) { | ||
68 | goto sbus_done; | ||
69 | } | ||
70 | } | ||
71 | } | ||
72 | |||
73 | sbus_done: | ||
74 | if (!sdev) { | ||
75 | return -ENODEV; | ||
76 | } | ||
77 | |||
78 | pmc_regsize = sdev->reg_addrs[0].reg_size; | ||
79 | regs = sbus_ioremap(&sdev->resource[0], 0, | ||
80 | pmc_regsize, PMC_OBPNAME); | ||
81 | if (!regs) { | 61 | if (!regs) { |
82 | printk(KERN_ERR "%s: unable to map registers\n", PMC_DEVNAME); | 62 | printk(KERN_ERR "%s: unable to map registers\n", PMC_DEVNAME); |
83 | return -ENODEV; | 63 | return -ENODEV; |
@@ -92,8 +72,27 @@ sbus_done: | |||
92 | return 0; | 72 | return 0; |
93 | } | 73 | } |
94 | 74 | ||
75 | static struct of_device_id __initdata pmc_match[] = { | ||
76 | { | ||
77 | .name = PMC_OBPNAME, | ||
78 | }, | ||
79 | {}, | ||
80 | }; | ||
81 | MODULE_DEVICE_TABLE(of, pmc_match); | ||
82 | |||
83 | static struct of_platform_driver pmc_driver = { | ||
84 | .name = "pmc", | ||
85 | .match_table = pmc_match, | ||
86 | .probe = pmc_probe, | ||
87 | }; | ||
88 | |||
89 | static int __init pmc_init(void) | ||
90 | { | ||
91 | return of_register_driver(&pmc_driver, &of_bus_type); | ||
92 | } | ||
93 | |||
95 | /* This driver is not critical to the boot process | 94 | /* This driver is not critical to the boot process |
96 | * and is easiest to ioremap when SBus is already | 95 | * and is easiest to ioremap when SBus is already |
97 | * initialized, so we install ourselves thusly: | 96 | * initialized, so we install ourselves thusly: |
98 | */ | 97 | */ |
99 | __initcall(pmc_probe); | 98 | __initcall(pmc_init); |