aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-08-27 05:45:36 -0400
committerDavid S. Miller <davem@davemloft.net>2008-08-29 05:15:08 -0400
commit7e7e2f035663c5ceb029bfb9d91e75099b0a5625 (patch)
tree5dcff583f5dae7f25ca03bdc876535abca83d5da /arch/sparc/kernel
parent4b1c5df2af38b2681b7c1a058534d17c54aaf6cf (diff)
sparc32: Convert apc to OF driver.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel')
-rw-r--r--arch/sparc/kernel/apc.c72
1 files changed, 38 insertions, 34 deletions
diff --git a/arch/sparc/kernel/apc.c b/arch/sparc/kernel/apc.c
index 5267d48fb2c6..0a20cd85fd31 100644
--- a/arch/sparc/kernel/apc.c
+++ b/arch/sparc/kernel/apc.c
@@ -12,9 +12,10 @@
12#include <linux/miscdevice.h> 12#include <linux/miscdevice.h>
13#include <linux/smp_lock.h> 13#include <linux/smp_lock.h>
14#include <linux/pm.h> 14#include <linux/pm.h>
15#include <linux/of.h>
16#include <linux/of_device.h>
15 17
16#include <asm/io.h> 18#include <asm/io.h>
17#include <asm/sbus.h>
18#include <asm/oplib.h> 19#include <asm/oplib.h>
19#include <asm/uaccess.h> 20#include <asm/uaccess.h>
20#include <asm/auxio.h> 21#include <asm/auxio.h>
@@ -29,11 +30,10 @@
29#define APC_OBPNAME "power-management" 30#define APC_OBPNAME "power-management"
30#define APC_DEVNAME "apc" 31#define APC_DEVNAME "apc"
31 32
32volatile static u8 __iomem *regs; 33static u8 __iomem *regs;
33static int apc_regsize;
34static int apc_no_idle __initdata = 0; 34static int apc_no_idle __initdata = 0;
35 35
36#define apc_readb(offs) (sbus_readb(regs+offs)) 36#define apc_readb(offs) (sbus_readb(regs+offs))
37#define apc_writeb(val, offs) (sbus_writeb(val, regs+offs)) 37#define apc_writeb(val, offs) (sbus_writeb(val, regs+offs))
38 38
39/* Specify "apc=noidle" on the kernel command line to 39/* Specify "apc=noidle" on the kernel command line to
@@ -69,9 +69,9 @@ static void apc_swift_idle(void)
69#endif 69#endif
70} 70}
71 71
72static inline void apc_free(void) 72static inline void apc_free(struct of_device *op)
73{ 73{
74 sbus_iounmap(regs, apc_regsize); 74 of_iounmap(&op->resource[0], regs, resource_size(&op->resource[0]));
75} 75}
76 76
77static int apc_open(struct inode *inode, struct file *f) 77static int apc_open(struct inode *inode, struct file *f)
@@ -153,52 +153,56 @@ static const struct file_operations apc_fops = {
153 153
154static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops }; 154static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops };
155 155
156static int __init apc_probe(void) 156static int __devinit apc_probe(struct of_device *op,
157 const struct of_device_id *match)
157{ 158{
158 struct sbus_bus *sbus = NULL; 159 int err;
159 struct sbus_dev *sdev = NULL;
160 int iTmp = 0;
161
162 for_each_sbus(sbus) {
163 for_each_sbusdev(sdev, sbus) {
164 if (!strcmp(sdev->prom_name, APC_OBPNAME)) {
165 goto sbus_done;
166 }
167 }
168 }
169 160
170sbus_done: 161 regs = of_ioremap(&op->resource[0], 0,
171 if (!sdev) { 162 resource_size(&op->resource[0]), APC_OBPNAME);
172 return -ENODEV; 163 if (!regs) {
173 }
174
175 apc_regsize = sdev->reg_addrs[0].reg_size;
176 regs = sbus_ioremap(&sdev->resource[0], 0,
177 apc_regsize, APC_OBPNAME);
178 if(!regs) {
179 printk(KERN_ERR "%s: unable to map registers\n", APC_DEVNAME); 164 printk(KERN_ERR "%s: unable to map registers\n", APC_DEVNAME);
180 return -ENODEV; 165 return -ENODEV;
181 } 166 }
182 167
183 iTmp = misc_register(&apc_miscdev); 168 err = misc_register(&apc_miscdev);
184 if (iTmp != 0) { 169 if (err) {
185 printk(KERN_ERR "%s: unable to register device\n", APC_DEVNAME); 170 printk(KERN_ERR "%s: unable to register device\n", APC_DEVNAME);
186 apc_free(); 171 apc_free(op);
187 return -ENODEV; 172 return -ENODEV;
188 } 173 }
189 174
190 /* Assign power management IDLE handler */ 175 /* Assign power management IDLE handler */
191 if(!apc_no_idle) 176 if (!apc_no_idle)
192 pm_idle = apc_swift_idle; 177 pm_idle = apc_swift_idle;
193 178
194 printk(KERN_INFO "%s: power management initialized%s\n", 179 printk(KERN_INFO "%s: power management initialized%s\n",
195 APC_DEVNAME, apc_no_idle ? " (CPU idle disabled)" : ""); 180 APC_DEVNAME, apc_no_idle ? " (CPU idle disabled)" : "");
181
196 return 0; 182 return 0;
197} 183}
198 184
185static struct of_device_id apc_match[] = {
186 {
187 .name = APC_OBPNAME,
188 },
189 {},
190};
191MODULE_DEVICE_TABLE(of, apc_match);
192
193static struct of_platform_driver apc_driver = {
194 .name = "apc",
195 .match_table = apc_match,
196 .probe = apc_probe,
197};
198
199static int __init apc_init(void)
200{
201 return of_register_driver(&apc_driver, &of_bus_type);
202}
203
199/* This driver is not critical to the boot process 204/* This driver is not critical to the boot process
200 * and is easiest to ioremap when SBus is already 205 * and is easiest to ioremap when SBus is already
201 * initialized, so we install ourselves thusly: 206 * initialized, so we install ourselves thusly:
202 */ 207 */
203__initcall(apc_probe); 208__initcall(apc_init);
204