~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/pci/cs5535audio/cs5535audio_pm.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Power management for audio on multifunction CS5535 companion device
  3  * Copyright (C) Jaya Kumar
  4  *
  5  * This program is free software; you can redistribute it and/or modify
  6  * it under the terms of the GNU General Public License as published by
  7  * the Free Software Foundation; either version 2 of the License, or
  8  * (at your option) any later version.
  9  *
 10  * This program is distributed in the hope that it will be useful,
 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  * GNU General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU General Public License
 16  * along with this program; if not, write to the Free Software
 17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 18  *
 19  */
 20 
 21 #include <linux/init.h>
 22 #include <linux/pci.h>
 23 #include <linux/delay.h>
 24 #include <sound/core.h>
 25 #include <sound/control.h>
 26 #include <sound/initval.h>
 27 #include <sound/asoundef.h>
 28 #include <sound/pcm.h>
 29 #include <sound/ac97_codec.h>
 30 #include "cs5535audio.h"
 31 
 32 static void snd_cs5535audio_stop_hardware(struct cs5535audio *cs5535au)
 33 {
 34         /* 
 35         we depend on snd_ac97_suspend to tell the
 36         AC97 codec to shutdown. the amd spec suggests
 37         that the LNK_SHUTDOWN be done at the same time
 38         that the codec power-down is issued. instead,
 39         we do it just after rather than at the same 
 40         time. excluding codec specific build_ops->suspend
 41         ac97 powerdown hits:
 42         0x8000 EAPD 
 43         0x4000 Headphone amplifier 
 44         0x0300 ADC & DAC 
 45         0x0400 Analog Mixer powerdown (Vref on) 
 46         I am not sure if this is the best that we can do.
 47         The remainder to be investigated are:
 48         - analog mixer (vref off) 0x0800
 49         - AC-link powerdown 0x1000
 50         - codec internal clock 0x2000
 51         */
 52 
 53         /* set LNK_SHUTDOWN to shutdown AC link */
 54         cs_writel(cs5535au, ACC_CODEC_CNTL, ACC_CODEC_CNTL_LNK_SHUTDOWN);
 55 
 56 }
 57 
 58 static int snd_cs5535audio_suspend(struct device *dev)
 59 {
 60         struct pci_dev *pci = to_pci_dev(dev);
 61         struct snd_card *card = dev_get_drvdata(dev);
 62         struct cs5535audio *cs5535au = card->private_data;
 63         int i;
 64 
 65         snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 66         snd_pcm_suspend_all(cs5535au->pcm);
 67         snd_ac97_suspend(cs5535au->ac97);
 68         for (i = 0; i < NUM_CS5535AUDIO_DMAS; i++) {
 69                 struct cs5535audio_dma *dma = &cs5535au->dmas[i];
 70                 if (dma && dma->substream)
 71                         dma->saved_prd = dma->ops->read_prd(cs5535au);
 72         }
 73         /* save important regs, then disable aclink in hw */
 74         snd_cs5535audio_stop_hardware(cs5535au);
 75 
 76         if (pci_save_state(pci)) {
 77                 printk(KERN_ERR "cs5535audio: pci_save_state failed!\n");
 78                 return -EIO;
 79         }
 80         pci_disable_device(pci);
 81         pci_set_power_state(pci, PCI_D3hot);
 82         return 0;
 83 }
 84 
 85 static int snd_cs5535audio_resume(struct device *dev)
 86 {
 87         struct pci_dev *pci = to_pci_dev(dev);
 88         struct snd_card *card = dev_get_drvdata(dev);
 89         struct cs5535audio *cs5535au = card->private_data;
 90         u32 tmp;
 91         int timeout;
 92         int i;
 93 
 94         pci_set_power_state(pci, PCI_D0);
 95         pci_restore_state(pci);
 96         if (pci_enable_device(pci) < 0) {
 97                 printk(KERN_ERR "cs5535audio: pci_enable_device failed, "
 98                        "disabling device\n");
 99                 snd_card_disconnect(card);
100                 return -EIO;
101         }
102         pci_set_master(pci);
103 
104         /* set LNK_WRM_RST to reset AC link */
105         cs_writel(cs5535au, ACC_CODEC_CNTL, ACC_CODEC_CNTL_LNK_WRM_RST);
106 
107         timeout = 50;
108         do {
109                 tmp = cs_readl(cs5535au, ACC_CODEC_STATUS);
110                 if (tmp & PRM_RDY_STS)
111                         break;
112                 udelay(1);
113         } while (--timeout);
114 
115         if (!timeout)
116                 snd_printk(KERN_ERR "Failure getting AC Link ready\n");
117 
118         /* set up rate regs, dma. actual initiation is done in trig */
119         for (i = 0; i < NUM_CS5535AUDIO_DMAS; i++) {
120                 struct cs5535audio_dma *dma = &cs5535au->dmas[i];
121                 if (dma && dma->substream) {
122                         dma->substream->ops->prepare(dma->substream);
123                         dma->ops->setup_prd(cs5535au, dma->saved_prd);
124                 }
125         }
126 
127         /* we depend on ac97 to perform the codec power up */
128         snd_ac97_resume(cs5535au->ac97);
129         snd_power_change_state(card, SNDRV_CTL_POWER_D0);
130 
131         return 0;
132 }
133 
134 SIMPLE_DEV_PM_OPS(snd_cs5535audio_pm, snd_cs5535audio_suspend, snd_cs5535audio_resume);
135 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp