aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-06-24 01:22:13 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-06-24 02:16:19 -0400
commit4f62d158a32d9f470377a7bd6dcb797b42afe5f3 (patch)
tree728af64e1de30a6049d03f1799f094fb1dda75f7
parent9eccf1b3121f7e407d3159908f29252887194a16 (diff)
[PARPORT] sunbpp: Convert to new SBUS device framework.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/parport/parport_sunbpp.c134
1 files changed, 70 insertions, 64 deletions
diff --git a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c
index 36a1556e64c7..69a4bbd4cbee 100644
--- a/drivers/parport/parport_sunbpp.c
+++ b/drivers/parport/parport_sunbpp.c
@@ -1,5 +1,4 @@
1/* $Id: parport_sunbpp.c,v 1.12 2001/05/26 03:01:42 davem Exp $ 1/* parport_sunbpp.c: Parallel-port routines for SBUS
2 * Parallel-port routines for Sun architecture
3 * 2 *
4 * Author: Derrick J. Brashear <shadow@dementia.org> 3 * Author: Derrick J. Brashear <shadow@dementia.org>
5 * 4 *
@@ -14,6 +13,9 @@
14 * Gus Baldauf (gbaldauf@ix.netcom.com) 13 * Gus Baldauf (gbaldauf@ix.netcom.com)
15 * Peter Zaitcev 14 * Peter Zaitcev
16 * Tom Dyas 15 * Tom Dyas
16 *
17 * Updated to new SBUS device framework: David S. Miller <davem@davemloft.net>
18 *
17 */ 19 */
18 20
19#include <linux/string.h> 21#include <linux/string.h>
@@ -287,14 +289,7 @@ static struct parport_operations parport_sunbpp_ops =
287 .owner = THIS_MODULE, 289 .owner = THIS_MODULE,
288}; 290};
289 291
290typedef struct { 292static int __devinit init_one_port(struct sbus_dev *sdev)
291 struct list_head list;
292 struct parport *port;
293} Node;
294/* no locks, everything's serialized */
295static LIST_HEAD(port_list);
296
297static int __init init_one_port(struct sbus_dev *sdev)
298{ 293{
299 struct parport *p; 294 struct parport *p;
300 /* at least in theory there may be a "we don't dma" case */ 295 /* at least in theory there may be a "we don't dma" case */
@@ -303,109 +298,120 @@ static int __init init_one_port(struct sbus_dev *sdev)
303 int irq, dma, err = 0, size; 298 int irq, dma, err = 0, size;
304 struct bpp_regs __iomem *regs; 299 struct bpp_regs __iomem *regs;
305 unsigned char value_tcr; 300 unsigned char value_tcr;
306 Node *node;
307
308 dprintk((KERN_DEBUG "init_one_port(%p): ranges, alloc_io, ", sdev));
309 node = kmalloc(sizeof(Node), GFP_KERNEL);
310 if (!node)
311 goto out0;
312 301
313 irq = sdev->irqs[0]; 302 irq = sdev->irqs[0];
314 base = sbus_ioremap(&sdev->resource[0], 0, 303 base = sbus_ioremap(&sdev->resource[0], 0,
315 sdev->reg_addrs[0].reg_size, 304 sdev->reg_addrs[0].reg_size,
316 "sunbpp"); 305 "sunbpp");
317 if (!base) 306 if (!base)
318 goto out1; 307 return -ENODEV;
319 308
320 size = sdev->reg_addrs[0].reg_size; 309 size = sdev->reg_addrs[0].reg_size;
321 dma = PARPORT_DMA_NONE; 310 dma = PARPORT_DMA_NONE;
322 311
323 dprintk(("alloc(ppops), ")); 312 ops = kmalloc(sizeof(struct parport_operations), GFP_KERNEL);
324 ops = kmalloc (sizeof (struct parport_operations), GFP_KERNEL);
325 if (!ops) 313 if (!ops)
326 goto out2; 314 goto out_unmap;
327 315
328 memcpy (ops, &parport_sunbpp_ops, sizeof (struct parport_operations)); 316 memcpy (ops, &parport_sunbpp_ops, sizeof (struct parport_operations));
329 317
330 dprintk(("register_port\n")); 318 dprintk(("register_port\n"));
331 if (!(p = parport_register_port((unsigned long)base, irq, dma, ops))) 319 if (!(p = parport_register_port((unsigned long)base, irq, dma, ops)))
332 goto out3; 320 goto out_free_ops;
333 321
334 p->size = size; 322 p->size = size;
335 323
336 dprintk((KERN_DEBUG "init_one_port: request_irq(%08x:%p:%x:%s:%p) ",
337 p->irq, parport_sunbpp_interrupt, SA_SHIRQ, p->name, p));
338 if ((err = request_irq(p->irq, parport_sunbpp_interrupt, 324 if ((err = request_irq(p->irq, parport_sunbpp_interrupt,
339 SA_SHIRQ, p->name, p)) != 0) { 325 SA_SHIRQ, p->name, p)) != 0) {
340 dprintk(("ERROR %d\n", err)); 326 goto out_put_port;
341 goto out4;
342 } 327 }
343 dprintk(("OK\n")); 328
344 parport_sunbpp_enable_irq(p); 329 parport_sunbpp_enable_irq(p);
345 330
346 regs = (struct bpp_regs __iomem *)p->base; 331 regs = (struct bpp_regs __iomem *)p->base;
347 dprintk((KERN_DEBUG "forward\n")); 332
348 value_tcr = sbus_readb(&regs->p_tcr); 333 value_tcr = sbus_readb(&regs->p_tcr);
349 value_tcr &= ~P_TCR_DIR; 334 value_tcr &= ~P_TCR_DIR;
350 sbus_writeb(value_tcr, &regs->p_tcr); 335 sbus_writeb(value_tcr, &regs->p_tcr);
351 336
352 printk(KERN_INFO "%s: sunbpp at 0x%lx\n", p->name, p->base); 337 printk(KERN_INFO "%s: sunbpp at 0x%lx\n", p->name, p->base);
353 node->port = p;
354 list_add(&node->list, &port_list);
355 parport_announce_port (p);
356 338
357 return 1; 339 dev_set_drvdata(&sdev->ofdev.dev, p);
340
341 parport_announce_port(p);
342
343 return 0;
358 344
359out4: 345out_put_port:
360 parport_put_port(p); 346 parport_put_port(p);
361out3: 347
348out_free_ops:
362 kfree(ops); 349 kfree(ops);
363out2: 350
351out_unmap:
364 sbus_iounmap(base, size); 352 sbus_iounmap(base, size);
365out1: 353
366 kfree(node);
367out0:
368 return err; 354 return err;
369} 355}
370 356
371static int __init parport_sunbpp_init(void) 357static int __devinit bpp_probe(struct of_device *dev, const struct of_device_id *match)
372{ 358{
373 struct sbus_bus *sbus; 359 struct sbus_dev *sdev = to_sbus_device(&dev->dev);
374 struct sbus_dev *sdev; 360
375 int count = 0; 361 return init_one_port(sdev);
376 362}
377 for_each_sbus(sbus) { 363
378 for_each_sbusdev(sdev, sbus) { 364static int __devexit bpp_remove(struct of_device *dev)
379 if (!strcmp(sdev->prom_name, "SUNW,bpp")) 365{
380 count += init_one_port(sdev); 366 struct parport *p = dev_get_drvdata(&dev->dev);
381 } 367 struct parport_operations *ops = p->ops;
368
369 parport_remove_port(p);
370
371 if (p->irq != PARPORT_IRQ_NONE) {
372 parport_sunbpp_disable_irq(p);
373 free_irq(p->irq, p);
382 } 374 }
383 return count ? 0 : -ENODEV; 375
376 sbus_iounmap((void __iomem *) p->base, p->size);
377 parport_put_port(p);
378 kfree(ops);
379
380 dev_set_drvdata(&dev->dev, NULL);
381
382 return 0;
383}
384
385static struct of_device_id bpp_match[] = {
386 {
387 .name = "SUNW,bpp",
388 },
389 {},
390};
391
392MODULE_DEVICE_TABLE(of, qec_sbus_match);
393
394static struct of_platform_driver bpp_sbus_driver = {
395 .name = "bpp",
396 .match_table = bpp_match,
397 .probe = bpp_probe,
398 .remove = __devexit_p(bpp_remove),
399};
400
401static int __init parport_sunbpp_init(void)
402{
403 return of_register_driver(&bpp_sbus_driver, &sbus_bus_type);
384} 404}
385 405
386static void __exit parport_sunbpp_exit(void) 406static void __exit parport_sunbpp_exit(void)
387{ 407{
388 while (!list_empty(&port_list)) { 408 of_unregister_driver(&bpp_sbus_driver);
389 Node *node = list_entry(port_list.next, Node, list);
390 struct parport *p = node->port;
391 struct parport_operations *ops = p->ops;
392 parport_remove_port(p);
393
394 if (p->irq != PARPORT_IRQ_NONE) {
395 parport_sunbpp_disable_irq(p);
396 free_irq(p->irq, p);
397 }
398 sbus_iounmap((void __iomem *)p->base, p->size);
399 parport_put_port(p);
400 kfree (ops);
401 list_del(&node->list);
402 kfree (node);
403 }
404} 409}
405 410
406MODULE_AUTHOR("Derrick J Brashear"); 411MODULE_AUTHOR("Derrick J Brashear");
407MODULE_DESCRIPTION("Parport Driver for Sparc bidirectional Port"); 412MODULE_DESCRIPTION("Parport Driver for Sparc bidirectional Port");
408MODULE_SUPPORTED_DEVICE("Sparc Bidirectional Parallel Port"); 413MODULE_SUPPORTED_DEVICE("Sparc Bidirectional Parallel Port");
414MODULE_VERSION("2.0");
409MODULE_LICENSE("GPL"); 415MODULE_LICENSE("GPL");
410 416
411module_init(parport_sunbpp_init) 417module_init(parport_sunbpp_init)