]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/ppc/pmac.c
[PATCH] m68knommu: allow configure of FEC for M520x CPU family
[linux-2.6-omap-h63xx.git] / sound / ppc / pmac.c
index 222765fd0dc56412031696519d862ed695a5dadb..a642e4cfcf45e2188104b0b4488f26c6d6c12e97 100644 (file)
 #include <asm/pci-bridge.h>
 
 
-#ifdef CONFIG_PM
-static int snd_pmac_register_sleep_notifier(struct snd_pmac *chip);
-static int snd_pmac_unregister_sleep_notifier(struct snd_pmac *chip);
-static int snd_pmac_suspend(struct snd_card *card, pm_message_t state);
-static int snd_pmac_resume(struct snd_card *card);
-#endif
-
-
 /* fixed frequency table for awacs, screamer, burgundy, DACA (44100 max) */
 static int awacs_freqs[8] = {
        44100, 29400, 22050, 17640, 14700, 11025, 8820, 7350
@@ -784,9 +776,6 @@ static int snd_pmac_free(struct snd_pmac *chip)
        }
 
        snd_pmac_sound_feature(chip, 0);
-#ifdef CONFIG_PM
-       snd_pmac_unregister_sleep_notifier(chip);
-#endif
 
        /* clean up mixer if any */
        if (chip->mixer_free)
@@ -814,21 +803,17 @@ static int snd_pmac_free(struct snd_pmac *chip)
                iounmap(chip->playback.dma);
        if (chip->capture.dma)
                iounmap(chip->capture.dma);
-#ifndef CONFIG_PPC64
+
        if (chip->node) {
                int i;
-
                for (i = 0; i < 3; i++) {
-                       if (chip->of_requested & (1 << i)) {
-                               if (chip->is_k2)
-                                       release_OF_resource(chip->node->parent,
-                                                           i);
-                               else
-                                       release_OF_resource(chip->node, i);
-                       }
+                       if (chip->requested & (1 << i))
+                               release_mem_region(chip->rsrc[i].start,
+                                                  chip->rsrc[i].end -
+                                                  chip->rsrc[i].start + 1);
                }
        }
-#endif /* CONFIG_PPC64 */
+
        if (chip->pdev)
                pci_dev_put(chip->pdev);
        kfree(chip);
@@ -984,11 +969,11 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
                 * single frequency until proper i2s control is implemented
                 */
                switch(layout_id) {
-               case 0x48:
-               case 0x46:
-               case 0x33:
-               case 0x29:
                case 0x24:
+               case 0x29:
+               case 0x33:
+               case 0x46:
+               case 0x48:
                case 0x50:
                case 0x5c:
                        chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
@@ -1002,6 +987,11 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
                        chip->can_byte_swap = 0; /* FIXME: check this */
                        chip->control_mask = MASK_IEPC | 0x11;/* disable IEE */
                        break;
+               default:
+                       printk(KERN_ERR "snd: Unknown layout ID 0x%x\n",
+                              layout_id);
+                       return -ENODEV;
+
                }
        }
        prop = (unsigned int *)get_property(sound, "device-id", NULL);
@@ -1186,46 +1176,69 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
        }
 
        np = chip->node;
+       chip->requested = 0;
        if (chip->is_k2) {
-               if (np->parent->n_addrs < 2 || np->n_intrs < 3) {
+               static char *rnames[] = {
+                       "Sound Control", "Sound DMA" };
+               if (np->n_intrs < 3) {
                        err = -ENODEV;
                        goto __error;
                }
-               for (i = 0; i < 2; i++) {
-#ifndef CONFIG_PPC64
-                       static char *name[2] = { "- Control", "- DMA" };
-                       if (! request_OF_resource(np->parent, i, name[i])) {
-                               snd_printk(KERN_ERR "pmac: can't request resource %d!\n", i);
+               for (i = 0; i < 2; i ++) {
+                       if (of_address_to_resource(np->parent, i,
+                                                  &chip->rsrc[i])) {
+                               printk(KERN_ERR "snd: can't translate rsrc "
+                                      " %d (%s)\n", i, rnames[i]);
+                               err = -ENODEV;
+                               goto __error;
+                       }
+                       if (request_mem_region(chip->rsrc[i].start,
+                                              chip->rsrc[i].end -
+                                              chip->rsrc[i].start + 1,
+                                              rnames[i]) == NULL) {
+                               printk(KERN_ERR "snd: can't request rsrc "
+                                      " %d (%s: 0x%08lx:%08lx)\n",
+                                      i, rnames[i], chip->rsrc[i].start,
+                                      chip->rsrc[i].end);
                                err = -ENODEV;
                                goto __error;
                        }
-                       chip->of_requested |= (1 << i);
-#endif /* CONFIG_PPC64 */
-                       ctrl_addr = np->parent->addrs[0].address;
-                       txdma_addr = np->parent->addrs[1].address;
-                       rxdma_addr = txdma_addr + 0x100;
+                       chip->requested |= (1 << i);
                }
-
+               ctrl_addr = chip->rsrc[0].start;
+               txdma_addr = chip->rsrc[1].start;
+               rxdma_addr = txdma_addr + 0x100;
        } else {
-               if (np->n_addrs < 3 || np->n_intrs < 3) {
+               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++) {
-#ifndef CONFIG_PPC64
-                       static char *name[3] = { "- Control", "- Tx DMA", "- Rx DMA" };
-                       if (! request_OF_resource(np, i, name[i])) {
-                               snd_printk(KERN_ERR "pmac: can't request resource %d!\n", i);
+               for (i = 0; i < 3; i ++) {
+                       if (of_address_to_resource(np->parent, i,
+                                                  &chip->rsrc[i])) {
+                               printk(KERN_ERR "snd: can't translate rsrc "
+                                      " %d (%s)\n", i, rnames[i]);
+                               err = -ENODEV;
+                               goto __error;
+                       }
+                       if (request_mem_region(chip->rsrc[i].start,
+                                              chip->rsrc[i].end -
+                                              chip->rsrc[i].start + 1,
+                                              rnames[i]) == NULL) {
+                               printk(KERN_ERR "snd: can't request rsrc "
+                                      " %d (%s: 0x%08lx:%08lx)\n",
+                                      i, rnames[i], chip->rsrc[i].start,
+                                      chip->rsrc[i].end);
                                err = -ENODEV;
                                goto __error;
                        }
-                       chip->of_requested |= (1 << i);
-#endif /* CONFIG_PPC64 */
-                       ctrl_addr = np->addrs[0].address;
-                       txdma_addr = np->addrs[1].address;
-                       rxdma_addr = np->addrs[2].address;
+                       chip->requested |= (1 << i);
                }
+               ctrl_addr = chip->rsrc[0].start;
+               txdma_addr = chip->rsrc[1].start;
+               rxdma_addr = chip->rsrc[2].start;
        }
 
        chip->awacs = ioremap(ctrl_addr, 0x1000);
@@ -1277,9 +1290,11 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
        } else if (chip->is_pbook_G3) {
                struct device_node* mio;
                for (mio = chip->node->parent; mio; mio = mio->parent) {
-                       if (strcmp(mio->name, "mac-io") == 0
-                           && mio->n_addrs > 0) {
-                               chip->macio_base = ioremap(mio->addrs[0].address, 0x40);
+                       if (strcmp(mio->name, "mac-io") == 0) {
+                               struct resource r;
+                               if (of_address_to_resource(mio, 0, &r) == 0)
+                                       chip->macio_base =
+                                               ioremap(r.start, 0x40);
                                break;
                        }
                }
@@ -1298,12 +1313,6 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
        /* Reset dbdma channels */
        snd_pmac_dbdma_reset(chip);
 
-#ifdef CONFIG_PM
-       /* add sleep notifier */
-       if (! snd_pmac_register_sleep_notifier(chip))
-               snd_card_set_pm_callback(chip->card, snd_pmac_suspend, snd_pmac_resume, chip);
-#endif
-
        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
                goto __error;
 
@@ -1328,11 +1337,11 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
  * Save state when going to sleep, restore it afterwards.
  */
 
-static int snd_pmac_suspend(struct snd_card *card, pm_message_t state)
+void snd_pmac_suspend(struct snd_pmac *chip)
 {
-       struct snd_pmac *chip = card->pm_private_data;
        unsigned long flags;
 
+       snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
        if (chip->suspend)
                chip->suspend(chip);
        snd_pcm_suspend_all(chip->pcm);
@@ -1346,22 +1355,18 @@ static int snd_pmac_suspend(struct snd_card *card, pm_message_t state)
        if (chip->rx_irq >= 0)
                disable_irq(chip->rx_irq);
        snd_pmac_sound_feature(chip, 0);
-       return 0;
 }
 
-static int snd_pmac_resume(struct snd_card *card)
+void snd_pmac_resume(struct snd_pmac *chip)
 {
-       struct snd_pmac *chip = card->pm_private_data;
-
        snd_pmac_sound_feature(chip, 1);
        if (chip->resume)
                chip->resume(chip);
        /* enable CD sound input */
-       if (chip->macio_base && chip->is_pbook_G3) {
+       if (chip->macio_base && chip->is_pbook_G3)
                out_8(chip->macio_base + 0x37, 3);
-       } else if (chip->is_pbook_3400) {
+       else if (chip->is_pbook_3400)
                in_8(chip->latch_base + 0x190);
-       }
 
        snd_pmac_pcm_set_format(chip);
 
@@ -1372,53 +1377,7 @@ static int snd_pmac_resume(struct snd_card *card)
        if (chip->rx_irq >= 0)
                enable_irq(chip->rx_irq);
 
-       return 0;
-}
-
-/* the chip is stored statically by snd_pmac_register_sleep_notifier
- * because we can't have any private data for notify callback.
- */
-static struct snd_pmac *sleeping_pmac = NULL;
-
-static int snd_pmac_sleep_notify(struct pmu_sleep_notifier *self, int when)
-{
-       struct snd_pmac *chip;
-
-       chip = sleeping_pmac;
-       if (! chip)
-               return 0;
-
-       switch (when) {
-       case PBOOK_SLEEP_NOW:
-               snd_pmac_suspend(chip->card, PMSG_SUSPEND);
-               break;
-       case PBOOK_WAKE:
-               snd_pmac_resume(chip->card);
-               break;
-       }
-       return PBOOK_SLEEP_OK;
-}
-
-static struct pmu_sleep_notifier snd_pmac_sleep_notifier = {
-       snd_pmac_sleep_notify, SLEEP_LEVEL_SOUND,
-};
-
-static int __init snd_pmac_register_sleep_notifier(struct snd_pmac *chip)
-{
-       /* should be protected here.. */
-       snd_assert(! sleeping_pmac, return -EBUSY);
-       sleeping_pmac = chip;
-       pmu_register_sleep_notifier(&snd_pmac_sleep_notifier);
-       return 0;
-}
-                                                   
-static int snd_pmac_unregister_sleep_notifier(struct snd_pmac *chip)
-{
-       /* should be protected here.. */
-       snd_assert(sleeping_pmac == chip, return -ENODEV);
-       pmu_unregister_sleep_notifier(&snd_pmac_sleep_notifier);
-       sleeping_pmac = NULL;
-       return 0;
+       snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
 }
 
 #endif /* CONFIG_PM */