Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
[powerpc.git] / sound / ppc / pmac.c
index 90db9a1..5a2bef4 100644 (file)
@@ -713,7 +713,7 @@ void snd_pmac_beep_dma_stop(struct snd_pmac *chip)
  * interrupt handlers
  */
 static irqreturn_t
-snd_pmac_tx_intr(int irq, void *devid, struct pt_regs *regs)
+snd_pmac_tx_intr(int irq, void *devid)
 {
        struct snd_pmac *chip = devid;
        snd_pmac_pcm_update(chip, &chip->playback);
@@ -722,7 +722,7 @@ snd_pmac_tx_intr(int irq, void *devid, struct pt_regs *regs)
 
 
 static irqreturn_t
-snd_pmac_rx_intr(int irq, void *devid, struct pt_regs *regs)
+snd_pmac_rx_intr(int irq, void *devid)
 {
        struct snd_pmac *chip = devid;
        snd_pmac_pcm_update(chip, &chip->capture);
@@ -731,7 +731,7 @@ snd_pmac_rx_intr(int irq, void *devid, struct pt_regs *regs)
 
 
 static irqreturn_t
-snd_pmac_ctrl_intr(int irq, void *devid, struct pt_regs *regs)
+snd_pmac_ctrl_intr(int irq, void *devid)
 {
        struct snd_pmac *chip = devid;
        int ctrl = in_le32(&chip->awacs->control);
@@ -816,6 +816,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
 
        if (chip->pdev)
                pci_dev_put(chip->pdev);
+       of_node_put(chip->node);
        kfree(chip);
        return 0;
 }
@@ -842,7 +843,7 @@ static void __init detect_byte_swap(struct snd_pmac *chip)
        /* if seems that Keylargo can't byte-swap  */
        for (mio = chip->node->parent; mio; mio = mio->parent) {
                if (strcmp(mio->name, "mac-io") == 0) {
-                       if (device_is_compatible(mio, "Keylargo"))
+                       if (of_device_is_compatible(mio, "Keylargo"))
                                chip->can_byte_swap = 0;
                        break;
                }
@@ -863,8 +864,10 @@ static void __init detect_byte_swap(struct snd_pmac *chip)
  */
 static int __init snd_pmac_detect(struct snd_pmac *chip)
 {
-       struct device_node *sound = NULL;
-       unsigned int *prop, l;
+       struct device_node *sound;
+       struct device_node *dn;
+       const unsigned int *prop;
+       unsigned int l;
        struct macio_chip* macio;
 
        if (!machine_is(powermac))
@@ -890,25 +893,24 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
        else if (machine_is_compatible("PowerBook1,1")
                 || machine_is_compatible("AAPL,PowerBook1998"))
                chip->is_pbook_G3 = 1;
-       chip->node = find_devices("awacs");
-       if (chip->node)
-               sound = chip->node;
+       chip->node = of_find_node_by_name(NULL, "awacs");
+       sound = of_node_get(chip->node);
 
        /*
         * powermac G3 models have a node called "davbus"
         * with a child called "sound".
         */
        if (!chip->node)
-               chip->node = find_devices("davbus");
+               chip->node = of_find_node_by_name(NULL, "davbus");
        /*
         * if we didn't find a davbus device, try 'i2s-a' since
         * this seems to be what iBooks have
         */
        if (! chip->node) {
-               chip->node = find_devices("i2s-a");
+               chip->node = of_find_node_by_name(NULL, "i2s-a");
                if (chip->node && chip->node->parent &&
                    chip->node->parent->parent) {
-                       if (device_is_compatible(chip->node->parent->parent,
+                       if (of_device_is_compatible(chip->node->parent->parent,
                                                 "K2-Keylargo"))
                                chip->is_k2 = 1;
                }
@@ -917,41 +919,44 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
                return -ENODEV;
 
        if (!sound) {
-               sound = find_devices("sound");
+               sound = of_find_node_by_name(NULL, "sound");
                while (sound && sound->parent != chip->node)
-                       sound = sound->next;
+                       sound = of_find_node_by_name(sound, "sound");
        }
-       if (! sound)
+       if (! sound) {
+               of_node_put(chip->node);
                return -ENODEV;
-       prop = (unsigned int *) get_property(sound, "sub-frame", NULL);
+       }
+       prop = of_get_property(sound, "sub-frame", NULL);
        if (prop && *prop < 16)
                chip->subframe = *prop;
-       prop = (unsigned int *) get_property(sound, "layout-id", NULL);
+       prop = of_get_property(sound, "layout-id", NULL);
        if (prop) {
                /* partly deprecate snd-powermac, for those machines
                 * that have a layout-id property for now */
                printk(KERN_INFO "snd-powermac no longer handles any "
                                 "machines with a layout-id property "
                                 "in the device-tree, use snd-aoa.\n");
+               of_node_put(chip->node);
                return -ENODEV;
        }
        /* This should be verified on older screamers */
-       if (device_is_compatible(sound, "screamer")) {
+       if (of_device_is_compatible(sound, "screamer")) {
                chip->model = PMAC_SCREAMER;
                // chip->can_byte_swap = 0; /* FIXME: check this */
        }
-       if (device_is_compatible(sound, "burgundy")) {
+       if (of_device_is_compatible(sound, "burgundy")) {
                chip->model = PMAC_BURGUNDY;
                chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */
        }
-       if (device_is_compatible(sound, "daca")) {
+       if (of_device_is_compatible(sound, "daca")) {
                chip->model = PMAC_DACA;
                chip->can_capture = 0;  /* no capture */
                chip->can_duplex = 0;
                // chip->can_byte_swap = 0; /* FIXME: check this */
                chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */
        }
-       if (device_is_compatible(sound, "tumbler")) {
+       if (of_device_is_compatible(sound, "tumbler")) {
                chip->model = PMAC_TUMBLER;
                chip->can_capture = 0;  /* no capture */
                chip->can_duplex = 0;
@@ -960,17 +965,19 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
                chip->freq_table = tumbler_freqs;
                chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */
        }
-       if (device_is_compatible(sound, "snapper")) {
+       if (of_device_is_compatible(sound, "snapper")) {
                chip->model = PMAC_SNAPPER;
                // chip->can_byte_swap = 0; /* FIXME: check this */
                chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
                chip->freq_table = tumbler_freqs;
                chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */
        }
-       prop = (unsigned int *)get_property(sound, "device-id", NULL);
+       prop = of_get_property(sound, "device-id", NULL);
        if (prop)
                chip->device_id = *prop;
-       chip->has_iic = (find_devices("perch") != NULL);
+       dn = of_find_node_by_name(NULL, "perch");
+       chip->has_iic = (dn != NULL);
+       of_node_put(dn);
 
        /* We need the PCI device for DMA allocations, let's use a crude method
         * for now ...
@@ -997,10 +1004,9 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
 
        /* look for a property saying what sample rates
           are available */
-       prop = (unsigned int *) get_property(sound, "sample-rates", &l);
+       prop = of_get_property(sound, "sample-rates", &l);
        if (! prop)
-               prop = (unsigned int *) get_property(sound,
-                                                    "output-frame-rates", &l);
+               prop = of_get_property(sound, "output-frame-rates", &l);
        if (prop) {
                int i;
                chip->freqs_ok = 0;
@@ -1021,6 +1027,7 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
                chip->freqs_ok = 1;
        }
 
+       of_node_put(sound);
        return 0;
 }
 
@@ -1120,6 +1127,7 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
        struct snd_pmac *chip;
        struct device_node *np;
        int i, err;
+       unsigned int irq;
        unsigned long ctrl_addr, txdma_addr, rxdma_addr;
        static struct snd_device_ops ops = {
                .dev_free =     snd_pmac_dev_free,
@@ -1153,10 +1161,6 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
        if (chip->is_k2) {
                static char *rnames[] = {
                        "Sound Control", "Sound DMA" };
-               if (np->n_intrs < 3) {
-                       err = -ENODEV;
-                       goto __error;
-               }
                for (i = 0; i < 2; i ++) {
                        if (of_address_to_resource(np->parent, i,
                                                   &chip->rsrc[i])) {
@@ -1185,10 +1189,6 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
        } else {
                static char *rnames[] = {
                        "Sound Control", "Sound Tx DMA", "Sound Rx DMA" };
-               if (np->n_intrs < 3) {
-                       err = -ENODEV;
-                       goto __error;
-               }
                for (i = 0; i < 3; i ++) {
                        if (of_address_to_resource(np, i,
                                                   &chip->rsrc[i])) {
@@ -1220,28 +1220,30 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
        chip->playback.dma = ioremap(txdma_addr, 0x100);
        chip->capture.dma = ioremap(rxdma_addr, 0x100);
        if (chip->model <= PMAC_BURGUNDY) {
-               if (request_irq(np->intrs[0].line, snd_pmac_ctrl_intr, 0,
+               irq = irq_of_parse_and_map(np, 0);
+               if (request_irq(irq, snd_pmac_ctrl_intr, 0,
                                "PMac", (void*)chip)) {
-                       snd_printk(KERN_ERR "pmac: unable to grab IRQ %d\n", np->intrs[0].line);
+                       snd_printk(KERN_ERR "pmac: unable to grab IRQ %d\n",
+                                  irq);
                        err = -EBUSY;
                        goto __error;
                }
-               chip->irq = np->intrs[0].line;
+               chip->irq = irq;
        }
-       if (request_irq(np->intrs[1].line, snd_pmac_tx_intr, 0,
-                       "PMac Output", (void*)chip)) {
-               snd_printk(KERN_ERR "pmac: unable to grab IRQ %d\n", np->intrs[1].line);
+       irq = irq_of_parse_and_map(np, 1);
+       if (request_irq(irq, snd_pmac_tx_intr, 0, "PMac Output", (void*)chip)){
+               snd_printk(KERN_ERR "pmac: unable to grab IRQ %d\n", irq);
                err = -EBUSY;
                goto __error;
        }
-       chip->tx_irq = np->intrs[1].line;
-       if (request_irq(np->intrs[2].line, snd_pmac_rx_intr, 0,
-                       "PMac Input", (void*)chip)) {
-               snd_printk(KERN_ERR "pmac: unable to grab IRQ %d\n", np->intrs[2].line);
+       chip->tx_irq = irq;
+       irq = irq_of_parse_and_map(np, 2);
+       if (request_irq(irq, snd_pmac_rx_intr, 0, "PMac Input", (void*)chip)) {
+               snd_printk(KERN_ERR "pmac: unable to grab IRQ %d\n", irq);
                err = -EBUSY;
                goto __error;
        }
-       chip->rx_irq = np->intrs[2].line;
+       chip->rx_irq = irq;
 
        snd_pmac_sound_feature(chip, 1);