aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/parport/parport_sunbpp.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-08-27 03:17:50 -0400
committerDavid S. Miller <davem@davemloft.net>2008-08-29 05:14:44 -0400
commit27167e0e63a9c53477a7de1c55888bd660c3f9a6 (patch)
treeae8222375a18742a6e304fea08d97d5752668306 /drivers/parport/parport_sunbpp.c
parent8e912b333981a90959e9665e6ec2758be36ab805 (diff)
parport_sunbpp: Convert to pure OF driver.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/parport/parport_sunbpp.c')
-rw-r--r--drivers/parport/parport_sunbpp.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c
index 9d595aa91e46..e4f00c6dfe09 100644
--- a/drivers/parport/parport_sunbpp.c
+++ b/drivers/parport/parport_sunbpp.c
@@ -26,6 +26,8 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/of.h>
30#include <linux/of_device.h>
29 31
30#include <linux/parport.h> 32#include <linux/parport.h>
31 33
@@ -34,7 +36,6 @@
34 36
35#include <asm/io.h> 37#include <asm/io.h>
36#include <asm/oplib.h> /* OpenProm Library */ 38#include <asm/oplib.h> /* OpenProm Library */
37#include <asm/sbus.h>
38#include <asm/dma.h> /* BPP uses LSI 64854 for DMA */ 39#include <asm/dma.h> /* BPP uses LSI 64854 for DMA */
39#include <asm/irq.h> 40#include <asm/irq.h>
40#include <asm/sunbpp.h> 41#include <asm/sunbpp.h>
@@ -285,38 +286,37 @@ static struct parport_operations parport_sunbpp_ops =
285 .owner = THIS_MODULE, 286 .owner = THIS_MODULE,
286}; 287};
287 288
288static int __devinit init_one_port(struct sbus_dev *sdev) 289static int __devinit bpp_probe(struct of_device *op, const struct of_device_id *match)
289{ 290{
290 struct parport *p;
291 /* at least in theory there may be a "we don't dma" case */
292 struct parport_operations *ops; 291 struct parport_operations *ops;
293 void __iomem *base;
294 int irq, dma, err = 0, size;
295 struct bpp_regs __iomem *regs; 292 struct bpp_regs __iomem *regs;
293 int irq, dma, err = 0, size;
296 unsigned char value_tcr; 294 unsigned char value_tcr;
295 void __iomem *base;
296 struct parport *p;
297 297
298 irq = sdev->irqs[0]; 298 irq = op->irqs[0];
299 base = sbus_ioremap(&sdev->resource[0], 0, 299 base = of_ioremap(&op->resource[0], 0,
300 sdev->reg_addrs[0].reg_size, 300 resource_size(&op->resource[0]),
301 "sunbpp"); 301 "sunbpp");
302 if (!base) 302 if (!base)
303 return -ENODEV; 303 return -ENODEV;
304 304
305 size = sdev->reg_addrs[0].reg_size; 305 size = resource_size(&op->resource[0]);
306 dma = PARPORT_DMA_NONE; 306 dma = PARPORT_DMA_NONE;
307 307
308 ops = kmalloc(sizeof(struct parport_operations), GFP_KERNEL); 308 ops = kmalloc(sizeof(struct parport_operations), GFP_KERNEL);
309 if (!ops) 309 if (!ops)
310 goto out_unmap; 310 goto out_unmap;
311 311
312 memcpy (ops, &parport_sunbpp_ops, sizeof (struct parport_operations)); 312 memcpy (ops, &parport_sunbpp_ops, sizeof(struct parport_operations));
313 313
314 dprintk(("register_port\n")); 314 dprintk(("register_port\n"));
315 if (!(p = parport_register_port((unsigned long)base, irq, dma, ops))) 315 if (!(p = parport_register_port((unsigned long)base, irq, dma, ops)))
316 goto out_free_ops; 316 goto out_free_ops;
317 317
318 p->size = size; 318 p->size = size;
319 p->dev = &sdev->ofdev.dev; 319 p->dev = &op->dev;
320 320
321 if ((err = request_irq(p->irq, parport_irq_handler, 321 if ((err = request_irq(p->irq, parport_irq_handler,
322 IRQF_SHARED, p->name, p)) != 0) { 322 IRQF_SHARED, p->name, p)) != 0) {
@@ -333,7 +333,7 @@ static int __devinit init_one_port(struct sbus_dev *sdev)
333 333
334 printk(KERN_INFO "%s: sunbpp at 0x%lx\n", p->name, p->base); 334 printk(KERN_INFO "%s: sunbpp at 0x%lx\n", p->name, p->base);
335 335
336 dev_set_drvdata(&sdev->ofdev.dev, p); 336 dev_set_drvdata(&op->dev, p);
337 337
338 parport_announce_port(p); 338 parport_announce_port(p);
339 339
@@ -346,21 +346,14 @@ out_free_ops:
346 kfree(ops); 346 kfree(ops);
347 347
348out_unmap: 348out_unmap:
349 sbus_iounmap(base, size); 349 of_iounmap(&op->resource[0], base, size);
350 350
351 return err; 351 return err;
352} 352}
353 353
354static int __devinit bpp_probe(struct of_device *dev, const struct of_device_id *match) 354static int __devexit bpp_remove(struct of_device *op)
355{
356 struct sbus_dev *sdev = to_sbus_device(&dev->dev);
357
358 return init_one_port(sdev);
359}
360
361static int __devexit bpp_remove(struct of_device *dev)
362{ 355{
363 struct parport *p = dev_get_drvdata(&dev->dev); 356 struct parport *p = dev_get_drvdata(&op->dev);
364 struct parport_operations *ops = p->ops; 357 struct parport_operations *ops = p->ops;
365 358
366 parport_remove_port(p); 359 parport_remove_port(p);
@@ -370,11 +363,11 @@ static int __devexit bpp_remove(struct of_device *dev)
370 free_irq(p->irq, p); 363 free_irq(p->irq, p);
371 } 364 }
372 365
373 sbus_iounmap((void __iomem *) p->base, p->size); 366 of_iounmap(&op->resource[0], (void __iomem *) p->base, p->size);
374 parport_put_port(p); 367 parport_put_port(p);
375 kfree(ops); 368 kfree(ops);
376 369
377 dev_set_drvdata(&dev->dev, NULL); 370 dev_set_drvdata(&op->dev, NULL);
378 371
379 return 0; 372 return 0;
380} 373}
@@ -397,7 +390,7 @@ static struct of_platform_driver bpp_sbus_driver = {
397 390
398static int __init parport_sunbpp_init(void) 391static int __init parport_sunbpp_init(void)
399{ 392{
400 return of_register_driver(&bpp_sbus_driver, &sbus_bus_type); 393 return of_register_driver(&bpp_sbus_driver, &of_bus_type);
401} 394}
402 395
403static void __exit parport_sunbpp_exit(void) 396static void __exit parport_sunbpp_exit(void)