| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 1 | #ifndef __SOUND_CS5535AUDIO_H | 
|  | 2 | #define __SOUND_CS5535AUDIO_H | 
|  | 3 |  | 
| Takashi Iwai | 3e87317 | 2005-11-17 10:15:37 +0100 | [diff] [blame] | 4 | #define cs_writel(cs5535au, reg, val)	outl(val, (cs5535au)->port + reg) | 
|  | 5 | #define cs_writeb(cs5535au, reg, val)	outb(val, (cs5535au)->port + reg) | 
|  | 6 | #define cs_readl(cs5535au, reg)		inl((cs5535au)->port + reg) | 
|  | 7 | #define cs_readw(cs5535au, reg)		inw((cs5535au)->port + reg) | 
|  | 8 | #define cs_readb(cs5535au, reg)		inb((cs5535au)->port + reg) | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 9 |  | 
|  | 10 | #define CS5535AUDIO_MAX_DESCRIPTORS	128 | 
|  | 11 |  | 
|  | 12 | /* acc_codec bar0 reg addrs */ | 
|  | 13 | #define ACC_GPIO_STATUS			0x00 | 
|  | 14 | #define ACC_CODEC_STATUS		0x08 | 
|  | 15 | #define ACC_CODEC_CNTL			0x0C | 
|  | 16 | #define ACC_IRQ_STATUS			0x12 | 
|  | 17 | #define ACC_BM0_CMD			0x20 | 
|  | 18 | #define ACC_BM1_CMD			0x28 | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 19 | #define ACC_BM0_PRD			0x24 | 
|  | 20 | #define ACC_BM1_PRD			0x2C | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 21 | #define ACC_BM0_STATUS			0x21 | 
|  | 22 | #define ACC_BM1_STATUS			0x29 | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 23 | #define ACC_BM0_PNTR			0x60 | 
|  | 24 | #define ACC_BM1_PNTR			0x64 | 
| Andres Salomon | 4ea2416 | 2007-09-03 15:43:43 +0200 | [diff] [blame] | 25 |  | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 26 | /* acc_codec bar0 reg bits */ | 
|  | 27 | /* ACC_IRQ_STATUS */ | 
|  | 28 | #define IRQ_STS 			0 | 
|  | 29 | #define WU_IRQ_STS 			1 | 
|  | 30 | #define BM0_IRQ_STS 			2 | 
|  | 31 | #define BM1_IRQ_STS 			3 | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 32 | /* ACC_BMX_STATUS */ | 
|  | 33 | #define EOP				(1<<0) | 
|  | 34 | #define BM_EOP_ERR			(1<<1) | 
|  | 35 | /* ACC_BMX_CTL */ | 
| Andres Salomon | 506ea68 | 2007-09-03 15:43:18 +0200 | [diff] [blame] | 36 | #define BM_CTL_EN			0x01 | 
|  | 37 | #define BM_CTL_PAUSE			0x03 | 
|  | 38 | #define BM_CTL_DIS			0x00 | 
|  | 39 | #define BM_CTL_BYTE_ORD_LE		0x00 | 
|  | 40 | #define BM_CTL_BYTE_ORD_BE		0x04 | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 41 | /* cs5535 specific ac97 codec register defines */ | 
|  | 42 | #define CMD_MASK			0xFF00FFFF | 
|  | 43 | #define CMD_NEW				0x00010000 | 
|  | 44 | #define STS_NEW				0x00020000 | 
|  | 45 | #define PRM_RDY_STS			0x00800000 | 
|  | 46 | #define ACC_CODEC_CNTL_WR_CMD		(~0x80000000) | 
|  | 47 | #define ACC_CODEC_CNTL_RD_CMD		0x80000000 | 
| Jaya Kumar | 9ac2559 | 2006-04-28 14:34:49 +0200 | [diff] [blame] | 48 | #define ACC_CODEC_CNTL_LNK_SHUTDOWN	0x00040000 | 
|  | 49 | #define ACC_CODEC_CNTL_LNK_WRM_RST	0x00020000 | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 50 | #define PRD_JMP				0x2000 | 
|  | 51 | #define PRD_EOP				0x4000 | 
|  | 52 | #define PRD_EOT				0x8000 | 
|  | 53 |  | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 54 | enum { CS5535AUDIO_DMA_PLAYBACK, CS5535AUDIO_DMA_CAPTURE, NUM_CS5535AUDIO_DMAS }; | 
| Takashi Iwai | 66f8df6 | 2005-11-17 14:56:21 +0100 | [diff] [blame] | 55 |  | 
|  | 56 | struct cs5535audio; | 
|  | 57 |  | 
|  | 58 | struct cs5535audio_dma_ops { | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 59 | int type; | 
| Takashi Iwai | 66f8df6 | 2005-11-17 14:56:21 +0100 | [diff] [blame] | 60 | void (*enable_dma)(struct cs5535audio *cs5535au); | 
|  | 61 | void (*disable_dma)(struct cs5535audio *cs5535au); | 
|  | 62 | void (*pause_dma)(struct cs5535audio *cs5535au); | 
|  | 63 | void (*setup_prd)(struct cs5535audio *cs5535au, u32 prd_addr); | 
| Jaya Kumar | 9ac2559 | 2006-04-28 14:34:49 +0200 | [diff] [blame] | 64 | u32 (*read_prd)(struct cs5535audio *cs5535au); | 
| Takashi Iwai | 66f8df6 | 2005-11-17 14:56:21 +0100 | [diff] [blame] | 65 | u32 (*read_dma_pntr)(struct cs5535audio *cs5535au); | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 66 | }; | 
|  | 67 |  | 
| Takashi Iwai | 66f8df6 | 2005-11-17 14:56:21 +0100 | [diff] [blame] | 68 | struct cs5535audio_dma_desc { | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 69 | u32 addr; | 
|  | 70 | u16 size; | 
|  | 71 | u16 ctlreserved; | 
| Takashi Iwai | 66f8df6 | 2005-11-17 14:56:21 +0100 | [diff] [blame] | 72 | }; | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 73 |  | 
| Takashi Iwai | 66f8df6 | 2005-11-17 14:56:21 +0100 | [diff] [blame] | 74 | struct cs5535audio_dma { | 
|  | 75 | const struct cs5535audio_dma_ops *ops; | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 76 | struct snd_dma_buffer desc_buf; | 
| Takashi Iwai | 66f8df6 | 2005-11-17 14:56:21 +0100 | [diff] [blame] | 77 | struct snd_pcm_substream *substream; | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 78 | unsigned int buf_addr, buf_bytes; | 
|  | 79 | unsigned int period_bytes, periods; | 
| Jaya Kumar | 9ac2559 | 2006-04-28 14:34:49 +0200 | [diff] [blame] | 80 | u32 saved_prd; | 
| Jaya Kumar | b035ce0 | 2008-11-05 17:30:08 -0500 | [diff] [blame] | 81 | int pcm_open_flag; | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 82 | }; | 
|  | 83 |  | 
| Takashi Iwai | 66f8df6 | 2005-11-17 14:56:21 +0100 | [diff] [blame] | 84 | struct cs5535audio { | 
|  | 85 | struct snd_card *card; | 
|  | 86 | struct snd_ac97 *ac97; | 
| Jaya Kumar | 9ac2559 | 2006-04-28 14:34:49 +0200 | [diff] [blame] | 87 | struct snd_pcm *pcm; | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 88 | int irq; | 
|  | 89 | struct pci_dev *pci; | 
|  | 90 | unsigned long port; | 
|  | 91 | spinlock_t reg_lock; | 
| Takashi Iwai | 66f8df6 | 2005-11-17 14:56:21 +0100 | [diff] [blame] | 92 | struct snd_pcm_substream *playback_substream; | 
|  | 93 | struct snd_pcm_substream *capture_substream; | 
|  | 94 | struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS]; | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 95 | }; | 
|  | 96 |  | 
| Andres Salomon | b6c52a2 | 2008-11-05 17:30:30 -0500 | [diff] [blame] | 97 | #ifdef CONFIG_PM | 
| Jaya Kumar | 9ac2559 | 2006-04-28 14:34:49 +0200 | [diff] [blame] | 98 | int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state); | 
|  | 99 | int snd_cs5535audio_resume(struct pci_dev *pci); | 
| Andres Salomon | b6c52a2 | 2008-11-05 17:30:30 -0500 | [diff] [blame] | 100 | #endif | 
|  | 101 |  | 
| Andres Salomon | 3c55494 | 2009-12-14 18:00:36 -0800 | [diff] [blame] | 102 | #ifdef CONFIG_OLPC | 
| Andres Salomon | 3556d18 | 2008-11-06 16:44:08 -0500 | [diff] [blame] | 103 | void __devinit olpc_prequirks(struct snd_card *card, | 
|  | 104 | struct snd_ac97_template *ac97); | 
|  | 105 | int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97); | 
| Andres Salomon | 3c55494 | 2009-12-14 18:00:36 -0800 | [diff] [blame] | 106 | void __devexit olpc_quirks_cleanup(void); | 
| Andres Salomon | d6276b7 | 2008-11-06 16:49:38 -0500 | [diff] [blame] | 107 | void olpc_analog_input(struct snd_ac97 *ac97, int on); | 
| Andres Salomon | bf1e527 | 2008-11-06 16:53:03 -0500 | [diff] [blame] | 108 | void olpc_mic_bias(struct snd_ac97 *ac97, int on); | 
|  | 109 |  | 
|  | 110 | static inline void olpc_capture_open(struct snd_ac97 *ac97) | 
|  | 111 | { | 
| Andres Salomon | 01da024 | 2008-11-06 16:53:11 -0500 | [diff] [blame] | 112 | /* default to Analog Input off */ | 
|  | 113 | olpc_analog_input(ac97, 0); | 
| Andres Salomon | bf1e527 | 2008-11-06 16:53:03 -0500 | [diff] [blame] | 114 | /* enable MIC Bias for recording */ | 
|  | 115 | olpc_mic_bias(ac97, 1); | 
|  | 116 | } | 
|  | 117 |  | 
|  | 118 | static inline void olpc_capture_close(struct snd_ac97 *ac97) | 
|  | 119 | { | 
| Andres Salomon | 01da024 | 2008-11-06 16:53:11 -0500 | [diff] [blame] | 120 | /* disable Analog Input */ | 
|  | 121 | olpc_analog_input(ac97, 0); | 
| Andres Salomon | bf1e527 | 2008-11-06 16:53:03 -0500 | [diff] [blame] | 122 | /* disable the MIC Bias (so the recording LED turns off) */ | 
|  | 123 | olpc_mic_bias(ac97, 0); | 
|  | 124 | } | 
| Jaya Kumar | 57d4bf6 | 2008-11-06 16:43:34 -0500 | [diff] [blame] | 125 | #else | 
| Andres Salomon | 3556d18 | 2008-11-06 16:44:08 -0500 | [diff] [blame] | 126 | static inline void olpc_prequirks(struct snd_card *card, | 
|  | 127 | struct snd_ac97_template *ac97) { } | 
|  | 128 | static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) | 
|  | 129 | { | 
|  | 130 | return 0; | 
|  | 131 | } | 
| Andres Salomon | 3c55494 | 2009-12-14 18:00:36 -0800 | [diff] [blame] | 132 | static inline void olpc_quirks_cleanup(void) { } | 
| Andres Salomon | d6276b7 | 2008-11-06 16:49:38 -0500 | [diff] [blame] | 133 | static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { } | 
| Andres Salomon | bf1e527 | 2008-11-06 16:53:03 -0500 | [diff] [blame] | 134 | static inline void olpc_mic_bias(struct snd_ac97 *ac97, int on) { } | 
|  | 135 | static inline void olpc_capture_open(struct snd_ac97 *ac97) { } | 
|  | 136 | static inline void olpc_capture_close(struct snd_ac97 *ac97) { } | 
| Jaya Kumar | 57d4bf6 | 2008-11-06 16:43:34 -0500 | [diff] [blame] | 137 | #endif | 
|  | 138 |  | 
| Takashi Iwai | 66f8df6 | 2005-11-17 14:56:21 +0100 | [diff] [blame] | 139 | int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535audio); | 
|  | 140 |  | 
| Jaya Kumar | 9b4ffa4 | 2005-11-17 10:12:23 +0100 | [diff] [blame] | 141 | #endif /* __SOUND_CS5535AUDIO_H */ | 
|  | 142 |  |