4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
30 * Header file for the audio810 device driver
34 * Driver supported configuration information
36 #define I810_NAME "audio810"
37 #define I810_MOD_NAME "audio810 audio driver"
39 #define I810_INTS (120) /* default interrupt rate */
40 #define I810_MIN_INTS (24) /* minimum interrupt rate */
41 #define I810_MAX_INTS (500) /* maximum interrupt rate */
42 #define I810_NFRAGS (8) /* default # fragments */
48 #define I810_BD_NUMS (32)
49 #define I810_NUM_PORTS (2)
50 #define I810_MOD_SIZE (16)
52 #define I810_ROUNDUP(x, algn) (((x) + ((algn) - 1)) & ~((algn) - 1))
53 #define I810_KIOP(X) ((kstat_intr_t *)(X->ksp->ks_data))
55 /* The size of each entry of "reg" property is 5 integers */
56 #define I810_INTS_PER_REG_PROP 5
58 /* offset from the base of specified DMA engine */
59 #define I810_OFFSET_BD_BASE (0x00)
60 #define I810_OFFSET_CIV (0x04)
61 #define I810_OFFSET_LVI (0x05)
62 #define I810_OFFSET_SR (0x06)
63 #define I810_OFFSET_PICB (0x08)
64 #define I810_OFFSET_PIV (0x0A)
65 #define I810_OFFSET_CR (0x0B)
67 /* DMA engine offset from base */
68 #define I810_BASE_PCM_IN (0x00)
69 #define I810_BASE_PCM_OUT (0x10)
70 #define I810_BASE_MIC (0x20)
72 #define I810_REG_GCR 0x2C
73 #define I810_REG_GSR 0x30
74 #define I810_REG_CASR 0x34
75 #define I810_REG_SISCTL 0x4C /* SiS 7012 control */
77 /* bits of bus master status register */
78 #define I810_BM_SR_DCH 0x01
79 #define I810_BM_SR_CELV 0x02
80 #define I810_BM_SR_LVBCI 0x04
81 #define I810_BM_SR_BCIS 0x08
82 #define I810_BM_SR_FIFOE 0x10
84 /* bits of bus master control register */
85 #define I810_BM_CR_RUN 0x01
86 #define I810_BM_CR_RST 0x02
87 #define I810_BM_CR_LVBIE 0x04
88 #define I810_BM_CR_FEIE 0x08
89 #define I810_BM_CR_IOCE 0x10
91 #define I810_BM_CR_PAUSE 0x00
94 * Global Control Register
96 #define I810_GCR_GPIE 0x00000001
97 #define I810_GCR_COLD_RST 0x00000002
98 #define I810_GCR_WARM_RST 0x00000004
99 #define I810_GCR_ACLINK_OFF 0x00000008
100 #define I810_GCR_PRI_INTR_ENABLE 0x00000010
101 #define I810_GCR_SEC_INTR_ENABLE 0x00000020
103 /* For ICH2 or more, bit21:20 is the PCM 4/6-channel enable bits */
104 #define I810_GCR_2_CHANNELS (0 << 20)
105 #define I810_GCR_4_CHANNELS (1 << 20)
106 #define I810_GCR_6_CHANNELS (2 << 20)
107 #define I810_GCR_CHANNELS_MASK (3 << 20)
108 /* SiS 7012 has its own flags here */
109 #define I810_GCR_SIS_2_CHANNELS (0 << 6)
110 #define I810_GCR_SIS_4_CHANNELS (1 << 6)
111 #define I810_GCR_SIS_6_CHANNELS (2 << 6)
112 #define I810_GCR_SIS_CHANNELS_MASK (3 << 6)
116 * Global Status Register
118 #define I810_GSR_TRI_READY 0x10000000 /* for ICH4/5 */
119 #define I810_GSR_CAP8CH 0x00400000
120 #define I810_GSR_CAP6CH 0x00200000
121 #define I810_GSR_CAP4CH 0x00100000
122 #define I810_GSR_READ_COMPL 0x00008000
123 #define I810_GSR_INTR_SEC_RESUME 0x00000800
124 #define I810_GSR_INTR_PRI_RESUME 0x00000400
125 #define I810_GSR_SEC_READY 0x00000200
126 #define I810_GSR_PRI_READY 0x00000100
127 #define I810_GSR_INTR_MIC 0x00000080
128 #define I810_GSR_INTR_POUT 0x00000040
129 #define I810_GSR_INTR_PIN 0x00000020
130 #define I810_GSR_INTR_MO 0x00000004
131 #define I810_GSR_INTR_MI 0x00000002
132 #define I810_GSR_INTR_GSI 0x00000001
133 #define I810_GSR_USE_INTR 0x00000060 /* PCM-IN ,PCM-OUT */
136 * SiS Control Register
138 #define I810_SISCTL_UNMUTE 0x01
141 * Macro for AD1980 codec
143 #define AD1980_VID1 0x4144
144 #define AD1980_VID2 0x5370
145 #define AD1985_VID2 0x5375
146 #define CODEC_AD_REG_MISC 0x76 /* offset of ad1980 misc control reg */
147 #define AD1980_MISC_LOSEL 0x0020 /* Line-out amplifier output selector */
148 #define AD1980_MISC_HPSEL 0x0400 /* HP-out amplifier output selector */
149 #define AD1980_SURR_MUTE 0x8080 /* Mute for surround volume register */
151 #define I810_PCM_IN 0
152 #define I810_PCM_OUT 1
154 struct audio810_port
{
155 struct audio810_state
*statep
;
157 ddi_dma_handle_t samp_dmah
;
158 ddi_acc_handle_t samp_acch
;
163 ddi_dma_handle_t bdl_dmah
;
164 ddi_acc_handle_t bdl_acch
;
177 uint8_t stsoff
; /* status offset */
178 uint8_t picboff
; /* picb offset */
185 audio_engine_t
*engine
;
187 typedef struct audio810_port audio810_port_t
;
190 * buffer descripter list entry, sees datasheet
192 struct i810_bd_entry
{
193 uint32_t buf_base
; /* the address of the buffer */
194 uint16_t buf_len
; /* the number of samples */
197 typedef struct i810_bd_entry i810_bd_entry_t
;
198 #define BUF_CMD_BUP 0x4000
199 #define BUF_CMD_IOC 0x8000
201 typedef enum i810_quirk
{
203 QUIRK_SIS7012
, /* weird registers and such */
207 * audio810_state_t -per instance state and operation data
209 struct audio810_state
{
210 kmutex_t inst_lock
; /* state protection lock */
212 ddi_iblock_cookie_t iblock
;
213 dev_info_t
*dip
; /* used by audio810_getinfo() */
216 audio810_port_t
*ports
[2];
218 ddi_acc_handle_t am_regs_handle
; /* for audio mixer register */
219 ddi_acc_handle_t bm_regs_handle
; /* for bus master register */
220 caddr_t am_regs_base
; /* base of audio mixer regs */
221 caddr_t bm_regs_base
; /* base of bus master regs */
223 kstat_t
*ksp
; /* kernel statistics */
225 boolean_t intr_added
;
226 boolean_t suspended
; /* suspend/resume state */
230 typedef struct audio810_state audio810_state_t
;
233 * Useful bit twiddlers
235 #define I810_BM_GET8(reg) \
236 ddi_get8(statep->bm_regs_handle, \
237 (void *)((char *)statep->bm_regs_base + (reg)))
239 #define I810_BM_GET16(reg) \
240 ddi_get16(statep->bm_regs_handle, \
241 (void *)((char *)statep->bm_regs_base + (reg)))
243 #define I810_BM_GET32(reg) \
244 ddi_get32(statep->bm_regs_handle, \
245 (void *)((char *)statep->bm_regs_base + (reg)))
247 #define I810_BM_PUT8(reg, val) \
248 ddi_put8(statep->bm_regs_handle, \
249 (void *)((char *)statep->bm_regs_base + (reg)), (val))
251 #define I810_BM_PUT16(reg, val) \
252 ddi_put16(statep->bm_regs_handle, \
253 (void *)((char *)statep->bm_regs_base + (reg)), (val))
255 #define I810_BM_PUT32(reg, val) \
256 ddi_put32(statep->bm_regs_handle, \
257 (void *)((char *)statep->bm_regs_base + (reg)), (val))
259 #define I810_AM_GET16(reg) \
260 ddi_get16(statep->am_regs_handle, \
261 (void *)((char *)statep->am_regs_base + (reg)))
263 #define I810_AM_PUT16(reg, val) \
264 ddi_put16(statep->am_regs_handle, \
265 (void *)((char *)statep->am_regs_base + (reg)), (val))
267 #endif /* _AUDIO810_H_ */