1d9cbf529SGarrett D'Amore /*
2d9cbf529SGarrett D'Amore  * CDDL HEADER START
3d9cbf529SGarrett D'Amore  *
4d9cbf529SGarrett D'Amore  * The contents of this file are subject to the terms of the
5d9cbf529SGarrett D'Amore  * Common Development and Distribution License (the "License").
6d9cbf529SGarrett D'Amore  * You may not use this file except in compliance with the License.
7d9cbf529SGarrett D'Amore  *
8d9cbf529SGarrett D'Amore  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9d9cbf529SGarrett D'Amore  * or http://www.opensolaris.org/os/licensing.
10d9cbf529SGarrett D'Amore  * See the License for the specific language governing permissions
11d9cbf529SGarrett D'Amore  * and limitations under the License.
12d9cbf529SGarrett D'Amore  *
13d9cbf529SGarrett D'Amore  * When distributing Covered Code, include this CDDL HEADER in each
14d9cbf529SGarrett D'Amore  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15d9cbf529SGarrett D'Amore  * If applicable, add the following below this CDDL HEADER, with the
16d9cbf529SGarrett D'Amore  * fields enclosed by brackets "[]" replaced with your own identifying
17d9cbf529SGarrett D'Amore  * information: Portions Copyright [yyyy] [name of copyright owner]
18d9cbf529SGarrett D'Amore  *
19d9cbf529SGarrett D'Amore  * CDDL HEADER END
20d9cbf529SGarrett D'Amore  */
21d9cbf529SGarrett D'Amore 
22d9cbf529SGarrett D'Amore /*
23*68c47f65SGarrett D'Amore  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24d9cbf529SGarrett D'Amore  * Use is subject to license terms.
25d9cbf529SGarrett D'Amore  */
26d9cbf529SGarrett D'Amore 
27d9cbf529SGarrett D'Amore /*
28d9cbf529SGarrett D'Amore  * Purpose: Definitions for the CS 4281 AC97 driver
29d9cbf529SGarrett D'Amore  */
30d9cbf529SGarrett D'Amore /*
31d9cbf529SGarrett D'Amore  * This file is part of Open Sound System
32d9cbf529SGarrett D'Amore  *
33d9cbf529SGarrett D'Amore  * Copyright (C) 4Front Technologies 1996-2009.
34d9cbf529SGarrett D'Amore  *
35d9cbf529SGarrett D'Amore  * This software is released under CDDL 1.0 source license.
36d9cbf529SGarrett D'Amore  * See the COPYING file included in the main directory of this source
37d9cbf529SGarrett D'Amore  * distribution for the license terms and conditions.
38d9cbf529SGarrett D'Amore  */
39d9cbf529SGarrett D'Amore #ifndef	AUDIOP16X_H
40d9cbf529SGarrett D'Amore #define	AUDIOP16X_H
41d9cbf529SGarrett D'Amore 
42d9cbf529SGarrett D'Amore #define	P16X_NAME		"audiop16x"
43d9cbf529SGarrett D'Amore 
44d9cbf529SGarrett D'Amore #define	P16X_NUM_PORT	2
45d9cbf529SGarrett D'Amore 
46d9cbf529SGarrett D'Amore #define	CREATIVE_VENDOR_ID	0x1102
47d9cbf529SGarrett D'Amore #define	SB_P16X_ID		0x0006
48d9cbf529SGarrett D'Amore 
49d9cbf529SGarrett D'Amore typedef struct _p16x_dev_t p16x_dev_t;
50d9cbf529SGarrett D'Amore typedef struct _p16x_port_t p16x_port_t;
51d9cbf529SGarrett D'Amore 
52d9cbf529SGarrett D'Amore struct _p16x_port_t
53d9cbf529SGarrett D'Amore {
54d9cbf529SGarrett D'Amore 	p16x_dev_t 		*dev;
55d9cbf529SGarrett D'Amore 	audio_engine_t 		*engine;
56d9cbf529SGarrett D'Amore 
57d9cbf529SGarrett D'Amore 	caddr_t			base;
58d9cbf529SGarrett D'Amore 
59d9cbf529SGarrett D'Amore 	int			port_num;
60d9cbf529SGarrett D'Amore #define	P16X_PLAY		0
61d9cbf529SGarrett D'Amore #define	P16X_REC		1
62d9cbf529SGarrett D'Amore 	ddi_dma_handle_t	buf_dmah;	/* dma for buffers */
63d9cbf529SGarrett D'Amore 	ddi_acc_handle_t	buf_acch;
64d9cbf529SGarrett D'Amore 	uint32_t		buf_paddr;
65d9cbf529SGarrett D'Amore 	caddr_t			buf_kaddr;
66d9cbf529SGarrett D'Amore 	size_t			buf_size;
67d9cbf529SGarrett D'Amore 	uint32_t		buf_frames;
68d9cbf529SGarrett D'Amore 	int			syncdir;
69d9cbf529SGarrett D'Amore 	int			nchan;
70d9cbf529SGarrett D'Amore 	uint64_t		count;
71d9cbf529SGarrett D'Amore 	uint32_t		offset;
72d9cbf529SGarrett D'Amore };
73d9cbf529SGarrett D'Amore 
74d9cbf529SGarrett D'Amore struct _p16x_dev_t
75d9cbf529SGarrett D'Amore {
76d9cbf529SGarrett D'Amore 	dev_info_t		*dip;
77d9cbf529SGarrett D'Amore 	audio_dev_t		*adev;
78d9cbf529SGarrett D'Amore 	ac97_t			*ac97;
79d9cbf529SGarrett D'Amore 	boolean_t		suspended;
80d9cbf529SGarrett D'Amore 	ddi_acc_handle_t	pcih;
81d9cbf529SGarrett D'Amore 	ddi_acc_handle_t	regsh;
82d9cbf529SGarrett D'Amore 	caddr_t			base;
83*68c47f65SGarrett D'Amore 	kmutex_t		mutex;	/* For low level routines */
84d9cbf529SGarrett D'Amore 
85d9cbf529SGarrett D'Amore 	p16x_port_t 		*port[P16X_NUM_PORT];
86d9cbf529SGarrett D'Amore };
87d9cbf529SGarrett D'Amore 
88d9cbf529SGarrett D'Amore #define	INL(dev, reg)	\
89d9cbf529SGarrett D'Amore 	ddi_get32(dev->regsh, (void *)((char *)dev->base+(reg)))
90d9cbf529SGarrett D'Amore #define	INW(dev, reg)	\
91d9cbf529SGarrett D'Amore 	ddi_get16(dev->regsh, (void *)((char *)dev->base+(reg)))
92d9cbf529SGarrett D'Amore #define	INB(dev, reg)	\
93d9cbf529SGarrett D'Amore 	ddi_get8(dev->regsh, (void *)((char *)dev->base+(reg)))
94d9cbf529SGarrett D'Amore 
95d9cbf529SGarrett D'Amore #define	OUTL(dev, val, reg)	\
96d9cbf529SGarrett D'Amore 	ddi_put32(dev->regsh, (void *)((char *)dev->base+(reg)), (val))
97d9cbf529SGarrett D'Amore #define	OUTW(dev, val, reg)	\
98d9cbf529SGarrett D'Amore 	ddi_put16(dev->regsh, (void *)((char *)dev->base+(reg)), (val))
99d9cbf529SGarrett D'Amore #define	OUTB(dev, val, reg)	\
100d9cbf529SGarrett D'Amore 	ddi_put8(dev->regsh, (void *)((char *)dev->base+(reg)), (val))
101d9cbf529SGarrett D'Amore 
102d9cbf529SGarrett D'Amore /*
103d9cbf529SGarrett D'Amore  * SB P16X Registers
104d9cbf529SGarrett D'Amore  */
105d9cbf529SGarrett D'Amore 
106d9cbf529SGarrett D'Amore #define	PTR 	0x00
107d9cbf529SGarrett D'Amore #define	DR	0x04
108d9cbf529SGarrett D'Amore #define	IP	0x08
109d9cbf529SGarrett D'Amore #define	IE	0x0C
110d9cbf529SGarrett D'Amore #define	HC	0x14
111d9cbf529SGarrett D'Amore #define	GPIO	0x18
112d9cbf529SGarrett D'Amore #define	AC97D	0x1C
113d9cbf529SGarrett D'Amore #define	AC97A	0x1E
114d9cbf529SGarrett D'Amore 
115d9cbf529SGarrett D'Amore /*
116d9cbf529SGarrett D'Amore  * Indirect registers
117d9cbf529SGarrett D'Amore  */
118d9cbf529SGarrett D'Amore 
119d9cbf529SGarrett D'Amore #define	PTBA	0x000
120d9cbf529SGarrett D'Amore #define	PTBS	0x001
121d9cbf529SGarrett D'Amore #define	PTCA	0x002
122d9cbf529SGarrett D'Amore #define	PFBA	0x004
123d9cbf529SGarrett D'Amore #define	PFBS	0x005
124d9cbf529SGarrett D'Amore #define	CPFA	0x006
125d9cbf529SGarrett D'Amore #define	PFEA	0x007
126d9cbf529SGarrett D'Amore #define	CPCAV	0x008
127d9cbf529SGarrett D'Amore #define	RFBA	0x010
128d9cbf529SGarrett D'Amore #define	RFBS	0x011
129d9cbf529SGarrett D'Amore #define	CRFA	0x012
130d9cbf529SGarrett D'Amore #define	CRCAV	0x013
131d9cbf529SGarrett D'Amore #define	CDL	0x020
132d9cbf529SGarrett D'Amore #define	CDR	0x030
133d9cbf529SGarrett D'Amore #define	SA	0x040
134d9cbf529SGarrett D'Amore #define	EA_aux	0x041
135d9cbf529SGarrett D'Amore #define	SCS0	0x042
136d9cbf529SGarrett D'Amore #define	SCS1	0x043
137d9cbf529SGarrett D'Amore #define	SCS2	0x044
138d9cbf529SGarrett D'Amore #define	SPC	0x045
139d9cbf529SGarrett D'Amore #define	WMARK	0x046
140d9cbf529SGarrett D'Amore #define	MUDAT	0x047
141d9cbf529SGarrett D'Amore #define	MUCMD	0x048
142d9cbf529SGarrett D'Amore #define	RCD	0x050
143d9cbf529SGarrett D'Amore 
144d9cbf529SGarrett D'Amore /*
145d9cbf529SGarrett D'Amore  * Interrupt bits
146d9cbf529SGarrett D'Amore  */
147d9cbf529SGarrett D'Amore 
148d9cbf529SGarrett D'Amore #define	INTR_RFF	(1<<19)
149d9cbf529SGarrett D'Amore #define	INTR_RFH	(1<<16)
150d9cbf529SGarrett D'Amore #define	INTR_PFF	(3<<11)
151d9cbf529SGarrett D'Amore #define	INTR_PFH	(3<<8)
152d9cbf529SGarrett D'Amore #define	INTR_EAI	(1<<29)
153d9cbf529SGarrett D'Amore #define	INTR_PCI	1
154d9cbf529SGarrett D'Amore #define	INTR_UART_RX	2
155d9cbf529SGarrett D'Amore #define	INTR_UART_TX	4
156d9cbf529SGarrett D'Amore #define	INTR_AC97	0x10
157d9cbf529SGarrett D'Amore #define	INTR_GPIO	0x40
158d9cbf529SGarrett D'Amore #define	INTR_PLAY	(INTR_PFF | INTR_PFH)
159d9cbf529SGarrett D'Amore #define	INTR_REC	(INTR_RFF | INTR_RFH)
160d9cbf529SGarrett D'Amore #define	INTR_ALL	(INTR_PLAY | INTR_REC | INTR_PCI)
161d9cbf529SGarrett D'Amore 
162d9cbf529SGarrett D'Amore #endif /* AUDIOP16X_H */
163