diff options
Diffstat (limited to 'sound/sparc/dbri.c')
-rw-r--r-- | sound/sparc/dbri.c | 89 |
1 files changed, 44 insertions, 45 deletions
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index c534a2a849fa..c257ad8bdfbc 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c | |||
@@ -57,6 +57,7 @@ | |||
57 | #include <linux/delay.h> | 57 | #include <linux/delay.h> |
58 | #include <linux/irq.h> | 58 | #include <linux/irq.h> |
59 | #include <linux/io.h> | 59 | #include <linux/io.h> |
60 | #include <linux/dma-mapping.h> | ||
60 | 61 | ||
61 | #include <sound/core.h> | 62 | #include <sound/core.h> |
62 | #include <sound/pcm.h> | 63 | #include <sound/pcm.h> |
@@ -66,7 +67,7 @@ | |||
66 | #include <sound/initval.h> | 67 | #include <sound/initval.h> |
67 | 68 | ||
68 | #include <linux/of.h> | 69 | #include <linux/of.h> |
69 | #include <asm/sbus.h> | 70 | #include <linux/of_device.h> |
70 | #include <asm/atomic.h> | 71 | #include <asm/atomic.h> |
71 | 72 | ||
72 | MODULE_AUTHOR("Rudolf Koenig, Brent Baccala and Martin Habets"); | 73 | MODULE_AUTHOR("Rudolf Koenig, Brent Baccala and Martin Habets"); |
@@ -297,7 +298,7 @@ struct dbri_streaminfo { | |||
297 | /* This structure holds the information for both chips (DBRI & CS4215) */ | 298 | /* This structure holds the information for both chips (DBRI & CS4215) */ |
298 | struct snd_dbri { | 299 | struct snd_dbri { |
299 | int regs_size, irq; /* Needed for unload */ | 300 | int regs_size, irq; /* Needed for unload */ |
300 | struct sbus_dev *sdev; /* SBUS device info */ | 301 | struct of_device *op; /* OF device info */ |
301 | spinlock_t lock; | 302 | spinlock_t lock; |
302 | 303 | ||
303 | struct dbri_dma *dma; /* Pointer to our DMA block */ | 304 | struct dbri_dma *dma; /* Pointer to our DMA block */ |
@@ -2093,14 +2094,15 @@ static int snd_dbri_hw_params(struct snd_pcm_substream *substream, | |||
2093 | */ | 2094 | */ |
2094 | if (info->dvma_buffer == 0) { | 2095 | if (info->dvma_buffer == 0) { |
2095 | if (DBRI_STREAMNO(substream) == DBRI_PLAY) | 2096 | if (DBRI_STREAMNO(substream) == DBRI_PLAY) |
2096 | direction = SBUS_DMA_TODEVICE; | 2097 | direction = DMA_TO_DEVICE; |
2097 | else | 2098 | else |
2098 | direction = SBUS_DMA_FROMDEVICE; | 2099 | direction = DMA_FROM_DEVICE; |
2099 | 2100 | ||
2100 | info->dvma_buffer = sbus_map_single(dbri->sdev, | 2101 | info->dvma_buffer = |
2101 | runtime->dma_area, | 2102 | dma_map_single(&dbri->op->dev, |
2102 | params_buffer_bytes(hw_params), | 2103 | runtime->dma_area, |
2103 | direction); | 2104 | params_buffer_bytes(hw_params), |
2105 | direction); | ||
2104 | } | 2106 | } |
2105 | 2107 | ||
2106 | direction = params_buffer_bytes(hw_params); | 2108 | direction = params_buffer_bytes(hw_params); |
@@ -2121,12 +2123,12 @@ static int snd_dbri_hw_free(struct snd_pcm_substream *substream) | |||
2121 | */ | 2123 | */ |
2122 | if (info->dvma_buffer) { | 2124 | if (info->dvma_buffer) { |
2123 | if (DBRI_STREAMNO(substream) == DBRI_PLAY) | 2125 | if (DBRI_STREAMNO(substream) == DBRI_PLAY) |
2124 | direction = SBUS_DMA_TODEVICE; | 2126 | direction = DMA_TO_DEVICE; |
2125 | else | 2127 | else |
2126 | direction = SBUS_DMA_FROMDEVICE; | 2128 | direction = DMA_FROM_DEVICE; |
2127 | 2129 | ||
2128 | sbus_unmap_single(dbri->sdev, info->dvma_buffer, | 2130 | dma_unmap_single(&dbri->op->dev, info->dvma_buffer, |
2129 | substream->runtime->buffer_size, direction); | 2131 | substream->runtime->buffer_size, direction); |
2130 | info->dvma_buffer = 0; | 2132 | info->dvma_buffer = 0; |
2131 | } | 2133 | } |
2132 | if (info->pipe != -1) { | 2134 | if (info->pipe != -1) { |
@@ -2519,31 +2521,32 @@ static void __devinit snd_dbri_proc(struct snd_card *card) | |||
2519 | static void snd_dbri_free(struct snd_dbri *dbri); | 2521 | static void snd_dbri_free(struct snd_dbri *dbri); |
2520 | 2522 | ||
2521 | static int __devinit snd_dbri_create(struct snd_card *card, | 2523 | static int __devinit snd_dbri_create(struct snd_card *card, |
2522 | struct sbus_dev *sdev, | 2524 | struct of_device *op, |
2523 | int irq, int dev) | 2525 | int irq, int dev) |
2524 | { | 2526 | { |
2525 | struct snd_dbri *dbri = card->private_data; | 2527 | struct snd_dbri *dbri = card->private_data; |
2526 | int err; | 2528 | int err; |
2527 | 2529 | ||
2528 | spin_lock_init(&dbri->lock); | 2530 | spin_lock_init(&dbri->lock); |
2529 | dbri->sdev = sdev; | 2531 | dbri->op = op; |
2530 | dbri->irq = irq; | 2532 | dbri->irq = irq; |
2531 | 2533 | ||
2532 | dbri->dma = sbus_alloc_consistent(sdev, sizeof(struct dbri_dma), | 2534 | dbri->dma = dma_alloc_coherent(&op->dev, |
2533 | &dbri->dma_dvma); | 2535 | sizeof(struct dbri_dma), |
2536 | &dbri->dma_dvma, GFP_ATOMIC); | ||
2534 | memset((void *)dbri->dma, 0, sizeof(struct dbri_dma)); | 2537 | memset((void *)dbri->dma, 0, sizeof(struct dbri_dma)); |
2535 | 2538 | ||
2536 | dprintk(D_GEN, "DMA Cmd Block 0x%p (0x%08x)\n", | 2539 | dprintk(D_GEN, "DMA Cmd Block 0x%p (0x%08x)\n", |
2537 | dbri->dma, dbri->dma_dvma); | 2540 | dbri->dma, dbri->dma_dvma); |
2538 | 2541 | ||
2539 | /* Map the registers into memory. */ | 2542 | /* Map the registers into memory. */ |
2540 | dbri->regs_size = sdev->reg_addrs[0].reg_size; | 2543 | dbri->regs_size = resource_size(&op->resource[0]); |
2541 | dbri->regs = sbus_ioremap(&sdev->resource[0], 0, | 2544 | dbri->regs = of_ioremap(&op->resource[0], 0, |
2542 | dbri->regs_size, "DBRI Registers"); | 2545 | dbri->regs_size, "DBRI Registers"); |
2543 | if (!dbri->regs) { | 2546 | if (!dbri->regs) { |
2544 | printk(KERN_ERR "DBRI: could not allocate registers\n"); | 2547 | printk(KERN_ERR "DBRI: could not allocate registers\n"); |
2545 | sbus_free_consistent(sdev, sizeof(struct dbri_dma), | 2548 | dma_free_coherent(&op->dev, sizeof(struct dbri_dma), |
2546 | (void *)dbri->dma, dbri->dma_dvma); | 2549 | (void *)dbri->dma, dbri->dma_dvma); |
2547 | return -EIO; | 2550 | return -EIO; |
2548 | } | 2551 | } |
2549 | 2552 | ||
@@ -2551,9 +2554,9 @@ static int __devinit snd_dbri_create(struct snd_card *card, | |||
2551 | "DBRI audio", dbri); | 2554 | "DBRI audio", dbri); |
2552 | if (err) { | 2555 | if (err) { |
2553 | printk(KERN_ERR "DBRI: Can't get irq %d\n", dbri->irq); | 2556 | printk(KERN_ERR "DBRI: Can't get irq %d\n", dbri->irq); |
2554 | sbus_iounmap(dbri->regs, dbri->regs_size); | 2557 | of_iounmap(&op->resource[0], dbri->regs, dbri->regs_size); |
2555 | sbus_free_consistent(sdev, sizeof(struct dbri_dma), | 2558 | dma_free_coherent(&op->dev, sizeof(struct dbri_dma), |
2556 | (void *)dbri->dma, dbri->dma_dvma); | 2559 | (void *)dbri->dma, dbri->dma_dvma); |
2557 | return err; | 2560 | return err; |
2558 | } | 2561 | } |
2559 | 2562 | ||
@@ -2577,27 +2580,23 @@ static void snd_dbri_free(struct snd_dbri *dbri) | |||
2577 | free_irq(dbri->irq, dbri); | 2580 | free_irq(dbri->irq, dbri); |
2578 | 2581 | ||
2579 | if (dbri->regs) | 2582 | if (dbri->regs) |
2580 | sbus_iounmap(dbri->regs, dbri->regs_size); | 2583 | of_iounmap(&dbri->op->resource[0], dbri->regs, dbri->regs_size); |
2581 | 2584 | ||
2582 | if (dbri->dma) | 2585 | if (dbri->dma) |
2583 | sbus_free_consistent(dbri->sdev, sizeof(struct dbri_dma), | 2586 | dma_free_coherent(&dbri->op->dev, |
2584 | (void *)dbri->dma, dbri->dma_dvma); | 2587 | sizeof(struct dbri_dma), |
2588 | (void *)dbri->dma, dbri->dma_dvma); | ||
2585 | } | 2589 | } |
2586 | 2590 | ||
2587 | static int __devinit dbri_probe(struct of_device *of_dev, | 2591 | static int __devinit dbri_probe(struct of_device *op, const struct of_device_id *match) |
2588 | const struct of_device_id *match) | ||
2589 | { | 2592 | { |
2590 | struct sbus_dev *sdev = to_sbus_device(&of_dev->dev); | ||
2591 | struct snd_dbri *dbri; | 2593 | struct snd_dbri *dbri; |
2592 | int irq; | ||
2593 | struct resource *rp; | 2594 | struct resource *rp; |
2594 | struct snd_card *card; | 2595 | struct snd_card *card; |
2595 | static int dev = 0; | 2596 | static int dev = 0; |
2597 | int irq; | ||
2596 | int err; | 2598 | int err; |
2597 | 2599 | ||
2598 | dprintk(D_GEN, "DBRI: Found %s in SBUS slot %d\n", | ||
2599 | sdev->prom_name, sdev->slot); | ||
2600 | |||
2601 | if (dev >= SNDRV_CARDS) | 2600 | if (dev >= SNDRV_CARDS) |
2602 | return -ENODEV; | 2601 | return -ENODEV; |
2603 | if (!enable[dev]) { | 2602 | if (!enable[dev]) { |
@@ -2605,7 +2604,7 @@ static int __devinit dbri_probe(struct of_device *of_dev, | |||
2605 | return -ENOENT; | 2604 | return -ENOENT; |
2606 | } | 2605 | } |
2607 | 2606 | ||
2608 | irq = sdev->irqs[0]; | 2607 | irq = op->irqs[0]; |
2609 | if (irq <= 0) { | 2608 | if (irq <= 0) { |
2610 | printk(KERN_ERR "DBRI-%d: No IRQ.\n", dev); | 2609 | printk(KERN_ERR "DBRI-%d: No IRQ.\n", dev); |
2611 | return -ENODEV; | 2610 | return -ENODEV; |
@@ -2618,12 +2617,12 @@ static int __devinit dbri_probe(struct of_device *of_dev, | |||
2618 | 2617 | ||
2619 | strcpy(card->driver, "DBRI"); | 2618 | strcpy(card->driver, "DBRI"); |
2620 | strcpy(card->shortname, "Sun DBRI"); | 2619 | strcpy(card->shortname, "Sun DBRI"); |
2621 | rp = &sdev->resource[0]; | 2620 | rp = &op->resource[0]; |
2622 | sprintf(card->longname, "%s at 0x%02lx:0x%016Lx, irq %d", | 2621 | sprintf(card->longname, "%s at 0x%02lx:0x%016Lx, irq %d", |
2623 | card->shortname, | 2622 | card->shortname, |
2624 | rp->flags & 0xffL, (unsigned long long)rp->start, irq); | 2623 | rp->flags & 0xffL, (unsigned long long)rp->start, irq); |
2625 | 2624 | ||
2626 | err = snd_dbri_create(card, sdev, irq, dev); | 2625 | err = snd_dbri_create(card, op, irq, dev); |
2627 | if (err < 0) { | 2626 | if (err < 0) { |
2628 | snd_card_free(card); | 2627 | snd_card_free(card); |
2629 | return err; | 2628 | return err; |
@@ -2640,7 +2639,7 @@ static int __devinit dbri_probe(struct of_device *of_dev, | |||
2640 | 2639 | ||
2641 | /* /proc file handling */ | 2640 | /* /proc file handling */ |
2642 | snd_dbri_proc(card); | 2641 | snd_dbri_proc(card); |
2643 | dev_set_drvdata(&of_dev->dev, card); | 2642 | dev_set_drvdata(&op->dev, card); |
2644 | 2643 | ||
2645 | err = snd_card_register(card); | 2644 | err = snd_card_register(card); |
2646 | if (err < 0) | 2645 | if (err < 0) |
@@ -2648,7 +2647,7 @@ static int __devinit dbri_probe(struct of_device *of_dev, | |||
2648 | 2647 | ||
2649 | printk(KERN_INFO "audio%d at %p (irq %d) is DBRI(%c)+CS4215(%d)\n", | 2648 | printk(KERN_INFO "audio%d at %p (irq %d) is DBRI(%c)+CS4215(%d)\n", |
2650 | dev, dbri->regs, | 2649 | dev, dbri->regs, |
2651 | dbri->irq, sdev->prom_name[9], dbri->mm.version); | 2650 | dbri->irq, op->node->name[9], dbri->mm.version); |
2652 | dev++; | 2651 | dev++; |
2653 | 2652 | ||
2654 | return 0; | 2653 | return 0; |
@@ -2659,19 +2658,19 @@ _err: | |||
2659 | return err; | 2658 | return err; |
2660 | } | 2659 | } |
2661 | 2660 | ||
2662 | static int __devexit dbri_remove(struct of_device *dev) | 2661 | static int __devexit dbri_remove(struct of_device *op) |
2663 | { | 2662 | { |
2664 | struct snd_card *card = dev_get_drvdata(&dev->dev); | 2663 | struct snd_card *card = dev_get_drvdata(&op->dev); |
2665 | 2664 | ||
2666 | snd_dbri_free(card->private_data); | 2665 | snd_dbri_free(card->private_data); |
2667 | snd_card_free(card); | 2666 | snd_card_free(card); |
2668 | 2667 | ||
2669 | dev_set_drvdata(&dev->dev, NULL); | 2668 | dev_set_drvdata(&op->dev, NULL); |
2670 | 2669 | ||
2671 | return 0; | 2670 | return 0; |
2672 | } | 2671 | } |
2673 | 2672 | ||
2674 | static struct of_device_id dbri_match[] = { | 2673 | static const struct of_device_id dbri_match[] = { |
2675 | { | 2674 | { |
2676 | .name = "SUNW,DBRIe", | 2675 | .name = "SUNW,DBRIe", |
2677 | }, | 2676 | }, |
@@ -2693,7 +2692,7 @@ static struct of_platform_driver dbri_sbus_driver = { | |||
2693 | /* Probe for the dbri chip and then attach the driver. */ | 2692 | /* Probe for the dbri chip and then attach the driver. */ |
2694 | static int __init dbri_init(void) | 2693 | static int __init dbri_init(void) |
2695 | { | 2694 | { |
2696 | return of_register_driver(&dbri_sbus_driver, &sbus_bus_type); | 2695 | return of_register_driver(&dbri_sbus_driver, &of_bus_type); |
2697 | } | 2696 | } |
2698 | 2697 | ||
2699 | static void __exit dbri_exit(void) | 2698 | static void __exit dbri_exit(void) |