aboutsummaryrefslogtreecommitdiffstats
path: root/sound/sparc
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-08-27 03:30:59 -0400
committerDavid S. Miller <davem@davemloft.net>2008-08-29 05:14:56 -0400
commit2bd320f89d417c370f4cf45470d102332c25ea24 (patch)
tree23d4dcf6da68a303bb306692177c9285565920c8 /sound/sparc
parentdc8aa2e9d6c965c11ddd05fca721b2218585b9f0 (diff)
dbri: Convert to pure OF driver.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'sound/sparc')
-rw-r--r--sound/sparc/dbri.c59
1 files changed, 27 insertions, 32 deletions
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index 5242ecbb91d5..446f985b76fb 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -67,7 +67,7 @@
67#include <sound/initval.h> 67#include <sound/initval.h>
68 68
69#include <linux/of.h> 69#include <linux/of.h>
70#include <asm/sbus.h> 70#include <linux/of_device.h>
71#include <asm/atomic.h> 71#include <asm/atomic.h>
72 72
73MODULE_AUTHOR("Rudolf Koenig, Brent Baccala and Martin Habets"); 73MODULE_AUTHOR("Rudolf Koenig, Brent Baccala and Martin Habets");
@@ -298,7 +298,7 @@ struct dbri_streaminfo {
298/* This structure holds the information for both chips (DBRI & CS4215) */ 298/* This structure holds the information for both chips (DBRI & CS4215) */
299struct snd_dbri { 299struct snd_dbri {
300 int regs_size, irq; /* Needed for unload */ 300 int regs_size, irq; /* Needed for unload */
301 struct sbus_dev *sdev; /* SBUS device info */ 301 struct of_device *op; /* OF device info */
302 spinlock_t lock; 302 spinlock_t lock;
303 303
304 struct dbri_dma *dma; /* Pointer to our DMA block */ 304 struct dbri_dma *dma; /* Pointer to our DMA block */
@@ -2099,7 +2099,7 @@ static int snd_dbri_hw_params(struct snd_pcm_substream *substream,
2099 direction = DMA_FROM_DEVICE; 2099 direction = DMA_FROM_DEVICE;
2100 2100
2101 info->dvma_buffer = 2101 info->dvma_buffer =
2102 dma_map_single(&dbri->sdev->ofdev.dev, 2102 dma_map_single(&dbri->op->dev,
2103 runtime->dma_area, 2103 runtime->dma_area,
2104 params_buffer_bytes(hw_params), 2104 params_buffer_bytes(hw_params),
2105 direction); 2105 direction);
@@ -2127,7 +2127,7 @@ static int snd_dbri_hw_free(struct snd_pcm_substream *substream)
2127 else 2127 else
2128 direction = DMA_FROM_DEVICE; 2128 direction = DMA_FROM_DEVICE;
2129 2129
2130 dma_unmap_single(&dbri->sdev->ofdev.dev, info->dvma_buffer, 2130 dma_unmap_single(&dbri->op->dev, info->dvma_buffer,
2131 substream->runtime->buffer_size, direction); 2131 substream->runtime->buffer_size, direction);
2132 info->dvma_buffer = 0; 2132 info->dvma_buffer = 0;
2133 } 2133 }
@@ -2516,17 +2516,17 @@ static void __devinit snd_dbri_proc(struct snd_card *card)
2516static void snd_dbri_free(struct snd_dbri *dbri); 2516static void snd_dbri_free(struct snd_dbri *dbri);
2517 2517
2518static int __devinit snd_dbri_create(struct snd_card *card, 2518static int __devinit snd_dbri_create(struct snd_card *card,
2519 struct sbus_dev *sdev, 2519 struct of_device *op,
2520 int irq, int dev) 2520 int irq, int dev)
2521{ 2521{
2522 struct snd_dbri *dbri = card->private_data; 2522 struct snd_dbri *dbri = card->private_data;
2523 int err; 2523 int err;
2524 2524
2525 spin_lock_init(&dbri->lock); 2525 spin_lock_init(&dbri->lock);
2526 dbri->sdev = sdev; 2526 dbri->op = op;
2527 dbri->irq = irq; 2527 dbri->irq = irq;
2528 2528
2529 dbri->dma = dma_alloc_coherent(&sdev->ofdev.dev, 2529 dbri->dma = dma_alloc_coherent(&op->dev,
2530 sizeof(struct dbri_dma), 2530 sizeof(struct dbri_dma),
2531 &dbri->dma_dvma, GFP_ATOMIC); 2531 &dbri->dma_dvma, GFP_ATOMIC);
2532 memset((void *)dbri->dma, 0, sizeof(struct dbri_dma)); 2532 memset((void *)dbri->dma, 0, sizeof(struct dbri_dma));
@@ -2535,12 +2535,12 @@ static int __devinit snd_dbri_create(struct snd_card *card,
2535 dbri->dma, dbri->dma_dvma); 2535 dbri->dma, dbri->dma_dvma);
2536 2536
2537 /* Map the registers into memory. */ 2537 /* Map the registers into memory. */
2538 dbri->regs_size = sdev->reg_addrs[0].reg_size; 2538 dbri->regs_size = resource_size(&op->resource[0]);
2539 dbri->regs = sbus_ioremap(&sdev->resource[0], 0, 2539 dbri->regs = of_ioremap(&op->resource[0], 0,
2540 dbri->regs_size, "DBRI Registers"); 2540 dbri->regs_size, "DBRI Registers");
2541 if (!dbri->regs) { 2541 if (!dbri->regs) {
2542 printk(KERN_ERR "DBRI: could not allocate registers\n"); 2542 printk(KERN_ERR "DBRI: could not allocate registers\n");
2543 dma_free_coherent(&sdev->ofdev.dev, sizeof(struct dbri_dma), 2543 dma_free_coherent(&op->dev, sizeof(struct dbri_dma),
2544 (void *)dbri->dma, dbri->dma_dvma); 2544 (void *)dbri->dma, dbri->dma_dvma);
2545 return -EIO; 2545 return -EIO;
2546 } 2546 }
@@ -2549,8 +2549,8 @@ static int __devinit snd_dbri_create(struct snd_card *card,
2549 "DBRI audio", dbri); 2549 "DBRI audio", dbri);
2550 if (err) { 2550 if (err) {
2551 printk(KERN_ERR "DBRI: Can't get irq %d\n", dbri->irq); 2551 printk(KERN_ERR "DBRI: Can't get irq %d\n", dbri->irq);
2552 sbus_iounmap(dbri->regs, dbri->regs_size); 2552 of_iounmap(&op->resource[0], dbri->regs, dbri->regs_size);
2553 dma_free_coherent(&sdev->ofdev.dev, sizeof(struct dbri_dma), 2553 dma_free_coherent(&op->dev, sizeof(struct dbri_dma),
2554 (void *)dbri->dma, dbri->dma_dvma); 2554 (void *)dbri->dma, dbri->dma_dvma);
2555 return err; 2555 return err;
2556 } 2556 }
@@ -2575,28 +2575,23 @@ static void snd_dbri_free(struct snd_dbri *dbri)
2575 free_irq(dbri->irq, dbri); 2575 free_irq(dbri->irq, dbri);
2576 2576
2577 if (dbri->regs) 2577 if (dbri->regs)
2578 sbus_iounmap(dbri->regs, dbri->regs_size); 2578 of_iounmap(&dbri->op->resource[0], dbri->regs, dbri->regs_size);
2579 2579
2580 if (dbri->dma) 2580 if (dbri->dma)
2581 dma_free_coherent(&dbri->sdev->ofdev.dev, 2581 dma_free_coherent(&dbri->op->dev,
2582 sizeof(struct dbri_dma), 2582 sizeof(struct dbri_dma),
2583 (void *)dbri->dma, dbri->dma_dvma); 2583 (void *)dbri->dma, dbri->dma_dvma);
2584} 2584}
2585 2585
2586static int __devinit dbri_probe(struct of_device *of_dev, 2586static int __devinit dbri_probe(struct of_device *op, const struct of_device_id *match)
2587 const struct of_device_id *match)
2588{ 2587{
2589 struct sbus_dev *sdev = to_sbus_device(&of_dev->dev);
2590 struct snd_dbri *dbri; 2588 struct snd_dbri *dbri;
2591 int irq;
2592 struct resource *rp; 2589 struct resource *rp;
2593 struct snd_card *card; 2590 struct snd_card *card;
2594 static int dev = 0; 2591 static int dev = 0;
2592 int irq;
2595 int err; 2593 int err;
2596 2594
2597 dprintk(D_GEN, "DBRI: Found %s in SBUS slot %d\n",
2598 sdev->prom_name, sdev->slot);
2599
2600 if (dev >= SNDRV_CARDS) 2595 if (dev >= SNDRV_CARDS)
2601 return -ENODEV; 2596 return -ENODEV;
2602 if (!enable[dev]) { 2597 if (!enable[dev]) {
@@ -2604,7 +2599,7 @@ static int __devinit dbri_probe(struct of_device *of_dev,
2604 return -ENOENT; 2599 return -ENOENT;
2605 } 2600 }
2606 2601
2607 irq = sdev->irqs[0]; 2602 irq = op->irqs[0];
2608 if (irq <= 0) { 2603 if (irq <= 0) {
2609 printk(KERN_ERR "DBRI-%d: No IRQ.\n", dev); 2604 printk(KERN_ERR "DBRI-%d: No IRQ.\n", dev);
2610 return -ENODEV; 2605 return -ENODEV;
@@ -2617,12 +2612,12 @@ static int __devinit dbri_probe(struct of_device *of_dev,
2617 2612
2618 strcpy(card->driver, "DBRI"); 2613 strcpy(card->driver, "DBRI");
2619 strcpy(card->shortname, "Sun DBRI"); 2614 strcpy(card->shortname, "Sun DBRI");
2620 rp = &sdev->resource[0]; 2615 rp = &op->resource[0];
2621 sprintf(card->longname, "%s at 0x%02lx:0x%016Lx, irq %d", 2616 sprintf(card->longname, "%s at 0x%02lx:0x%016Lx, irq %d",
2622 card->shortname, 2617 card->shortname,
2623 rp->flags & 0xffL, (unsigned long long)rp->start, irq); 2618 rp->flags & 0xffL, (unsigned long long)rp->start, irq);
2624 2619
2625 err = snd_dbri_create(card, sdev, irq, dev); 2620 err = snd_dbri_create(card, op, irq, dev);
2626 if (err < 0) { 2621 if (err < 0) {
2627 snd_card_free(card); 2622 snd_card_free(card);
2628 return err; 2623 return err;
@@ -2639,7 +2634,7 @@ static int __devinit dbri_probe(struct of_device *of_dev,
2639 2634
2640 /* /proc file handling */ 2635 /* /proc file handling */
2641 snd_dbri_proc(card); 2636 snd_dbri_proc(card);
2642 dev_set_drvdata(&of_dev->dev, card); 2637 dev_set_drvdata(&op->dev, card);
2643 2638
2644 err = snd_card_register(card); 2639 err = snd_card_register(card);
2645 if (err < 0) 2640 if (err < 0)
@@ -2647,7 +2642,7 @@ static int __devinit dbri_probe(struct of_device *of_dev,
2647 2642
2648 printk(KERN_INFO "audio%d at %p (irq %d) is DBRI(%c)+CS4215(%d)\n", 2643 printk(KERN_INFO "audio%d at %p (irq %d) is DBRI(%c)+CS4215(%d)\n",
2649 dev, dbri->regs, 2644 dev, dbri->regs,
2650 dbri->irq, sdev->prom_name[9], dbri->mm.version); 2645 dbri->irq, op->node->name[9], dbri->mm.version);
2651 dev++; 2646 dev++;
2652 2647
2653 return 0; 2648 return 0;
@@ -2658,14 +2653,14 @@ _err:
2658 return err; 2653 return err;
2659} 2654}
2660 2655
2661static int __devexit dbri_remove(struct of_device *dev) 2656static int __devexit dbri_remove(struct of_device *op)
2662{ 2657{
2663 struct snd_card *card = dev_get_drvdata(&dev->dev); 2658 struct snd_card *card = dev_get_drvdata(&op->dev);
2664 2659
2665 snd_dbri_free(card->private_data); 2660 snd_dbri_free(card->private_data);
2666 snd_card_free(card); 2661 snd_card_free(card);
2667 2662
2668 dev_set_drvdata(&dev->dev, NULL); 2663 dev_set_drvdata(&op->dev, NULL);
2669 2664
2670 return 0; 2665 return 0;
2671} 2666}
@@ -2692,7 +2687,7 @@ static struct of_platform_driver dbri_sbus_driver = {
2692/* Probe for the dbri chip and then attach the driver. */ 2687/* Probe for the dbri chip and then attach the driver. */
2693static int __init dbri_init(void) 2688static int __init dbri_init(void)
2694{ 2689{
2695 return of_register_driver(&dbri_sbus_driver, &sbus_bus_type); 2690 return of_register_driver(&dbri_sbus_driver, &of_bus_type);
2696} 2691}
2697 2692
2698static void __exit dbri_exit(void) 2693static void __exit dbri_exit(void)