aboutsummaryrefslogtreecommitdiffstats
path: root/sound/sparc/amd7930.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/sparc/amd7930.c')
-rw-r--r--sound/sparc/amd7930.c85
1 files changed, 21 insertions, 64 deletions
diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c
index 49acee0c4840..f87933e48812 100644
--- a/sound/sparc/amd7930.c
+++ b/sound/sparc/amd7930.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Driver for AMD7930 sound chips found on Sparcs. 2 * Driver for AMD7930 sound chips found on Sparcs.
3 * Copyright (C) 2002 David S. Miller <davem@redhat.com> 3 * Copyright (C) 2002, 2008 David S. Miller <davem@davemloft.net>
4 * 4 *
5 * Based entirely upon drivers/sbus/audio/amd7930.c which is: 5 * Based entirely upon drivers/sbus/audio/amd7930.c which is:
6 * Copyright (C) 1996,1997 Thomas K. Dyas (tdyas@eden.rutgers.edu) 6 * Copyright (C) 1996,1997 Thomas K. Dyas (tdyas@eden.rutgers.edu)
@@ -35,6 +35,8 @@
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/moduleparam.h> 37#include <linux/moduleparam.h>
38#include <linux/of.h>
39#include <linux/of_device.h>
38 40
39#include <sound/core.h> 41#include <sound/core.h>
40#include <sound/pcm.h> 42#include <sound/pcm.h>
@@ -44,7 +46,6 @@
44 46
45#include <asm/io.h> 47#include <asm/io.h>
46#include <asm/irq.h> 48#include <asm/irq.h>
47#include <asm/sbus.h>
48#include <asm/prom.h> 49#include <asm/prom.h>
49 50
50static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
@@ -335,8 +336,8 @@ struct snd_amd7930 {
335 int pgain; 336 int pgain;
336 int mgain; 337 int mgain;
337 338
339 struct of_device *op;
338 unsigned int irq; 340 unsigned int irq;
339 unsigned int regs_size;
340 struct snd_amd7930 *next; 341 struct snd_amd7930 *next;
341}; 342};
342 343
@@ -905,13 +906,16 @@ static int __devinit snd_amd7930_mixer(struct snd_amd7930 *amd)
905 906
906static int snd_amd7930_free(struct snd_amd7930 *amd) 907static int snd_amd7930_free(struct snd_amd7930 *amd)
907{ 908{
909 struct of_device *op = amd->op;
910
908 amd7930_idle(amd); 911 amd7930_idle(amd);
909 912
910 if (amd->irq) 913 if (amd->irq)
911 free_irq(amd->irq, amd); 914 free_irq(amd->irq, amd);
912 915
913 if (amd->regs) 916 if (amd->regs)
914 sbus_iounmap(amd->regs, amd->regs_size); 917 of_iounmap(&op->resource[0], amd->regs,
918 resource_size(&op->resource[0]));
915 919
916 kfree(amd); 920 kfree(amd);
917 921
@@ -930,13 +934,12 @@ static struct snd_device_ops snd_amd7930_dev_ops = {
930}; 934};
931 935
932static int __devinit snd_amd7930_create(struct snd_card *card, 936static int __devinit snd_amd7930_create(struct snd_card *card,
933 struct resource *rp, 937 struct of_device *op,
934 unsigned int reg_size,
935 int irq, int dev, 938 int irq, int dev,
936 struct snd_amd7930 **ramd) 939 struct snd_amd7930 **ramd)
937{ 940{
938 unsigned long flags;
939 struct snd_amd7930 *amd; 941 struct snd_amd7930 *amd;
942 unsigned long flags;
940 int err; 943 int err;
941 944
942 *ramd = NULL; 945 *ramd = NULL;
@@ -946,9 +949,10 @@ static int __devinit snd_amd7930_create(struct snd_card *card,
946 949
947 spin_lock_init(&amd->lock); 950 spin_lock_init(&amd->lock);
948 amd->card = card; 951 amd->card = card;
949 amd->regs_size = reg_size; 952 amd->op = op;
950 953
951 amd->regs = sbus_ioremap(rp, 0, amd->regs_size, "amd7930"); 954 amd->regs = of_ioremap(&op->resource[0], 0,
955 resource_size(&op->resource[0]), "amd7930");
952 if (!amd->regs) { 956 if (!amd->regs) {
953 snd_printk("amd7930-%d: Unable to map chip registers.\n", dev); 957 snd_printk("amd7930-%d: Unable to map chip registers.\n", dev);
954 return -EIO; 958 return -EIO;
@@ -997,12 +1001,15 @@ static int __devinit snd_amd7930_create(struct snd_card *card,
997 return 0; 1001 return 0;
998} 1002}
999 1003
1000static int __devinit amd7930_attach_common(struct resource *rp, int irq) 1004static int __devinit amd7930_sbus_probe(struct of_device *op, const struct of_device_id *match)
1001{ 1005{
1006 struct resource *rp = &op->resource[0];
1002 static int dev_num; 1007 static int dev_num;
1003 struct snd_card *card; 1008 struct snd_card *card;
1004 struct snd_amd7930 *amd; 1009 struct snd_amd7930 *amd;
1005 int err; 1010 int err, irq;
1011
1012 irq = op->irqs[0];
1006 1013
1007 if (dev_num >= SNDRV_CARDS) 1014 if (dev_num >= SNDRV_CARDS)
1008 return -ENODEV; 1015 return -ENODEV;
@@ -1023,8 +1030,7 @@ static int __devinit amd7930_attach_common(struct resource *rp, int irq)
1023 (unsigned long long)rp->start, 1030 (unsigned long long)rp->start,
1024 irq); 1031 irq);
1025 1032
1026 if ((err = snd_amd7930_create(card, rp, 1033 if ((err = snd_amd7930_create(card, op,
1027 (rp->end - rp->start) + 1,
1028 irq, dev_num, &amd)) < 0) 1034 irq, dev_num, &amd)) < 0)
1029 goto out_err; 1035 goto out_err;
1030 1036
@@ -1049,43 +1055,7 @@ out_err:
1049 return err; 1055 return err;
1050} 1056}
1051 1057
1052static int __devinit amd7930_obio_attach(struct device_node *dp) 1058static const struct of_device_id amd7930_match[] = {
1053{
1054 const struct linux_prom_registers *regs;
1055 const struct linux_prom_irqs *irqp;
1056 struct resource res, *rp;
1057 int len;
1058
1059 irqp = of_get_property(dp, "intr", &len);
1060 if (!irqp) {
1061 snd_printk("%s: Firmware node lacks IRQ property.\n",
1062 dp->full_name);
1063 return -ENODEV;
1064 }
1065
1066 regs = of_get_property(dp, "reg", &len);
1067 if (!regs) {
1068 snd_printk("%s: Firmware node lacks register property.\n",
1069 dp->full_name);
1070 return -ENODEV;
1071 }
1072
1073 rp = &res;
1074 rp->start = regs->phys_addr;
1075 rp->end = rp->start + regs->reg_size - 1;
1076 rp->flags = IORESOURCE_IO | (regs->which_io & 0xff);
1077
1078 return amd7930_attach_common(rp, irqp->pri);
1079}
1080
1081static int __devinit amd7930_sbus_probe(struct of_device *dev, const struct of_device_id *match)
1082{
1083 struct sbus_dev *sdev = to_sbus_device(&dev->dev);
1084
1085 return amd7930_attach_common(&sdev->resource[0], sdev->irqs[0]);
1086}
1087
1088static struct of_device_id amd7930_match[] = {
1089 { 1059 {
1090 .name = "audio", 1060 .name = "audio",
1091 }, 1061 },
@@ -1100,20 +1070,7 @@ static struct of_platform_driver amd7930_sbus_driver = {
1100 1070
1101static int __init amd7930_init(void) 1071static int __init amd7930_init(void)
1102{ 1072{
1103 struct device_node *dp; 1073 return of_register_driver(&amd7930_sbus_driver, &of_bus_type);
1104
1105 /* Try to find the sun4c "audio" node first. */
1106 dp = of_find_node_by_path("/");
1107 dp = dp->child;
1108 while (dp) {
1109 if (!strcmp(dp->name, "audio"))
1110 amd7930_obio_attach(dp);
1111
1112 dp = dp->sibling;
1113 }
1114
1115 /* Probe each SBUS for amd7930 chips. */
1116 return of_register_driver(&amd7930_sbus_driver, &sbus_bus_type);
1117} 1074}
1118 1075
1119static void __exit amd7930_exit(void) 1076static void __exit amd7930_exit(void)