xref: /dragonfly/sys/dev/sound/pci/via8233.h (revision 2cd2d2b5)
1 /*
2  * Copyright (c) 2002 Orion Hodson <orion@freebsd.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD: src/sys/dev/sound/pci/via8233.h,v 1.1.2.1 2002/08/22 17:32:48 orion Exp $
27  * $DragonFly: src/sys/dev/sound/pci/via8233.h,v 1.2 2003/06/17 04:28:30 dillon Exp $
28  */
29 
30 #ifndef _SYS_SOUND_PCI_VIA8233_H_
31 #define _SYS_SOUND_PCI_VIA8233_H_
32 
33 /*
34  * VIA Technologies VT8233 Southbridge Audio Driver
35  *
36  * Documentation sources:
37  *
38  * V8233C specs. from VIA, gratefully received under NDA.
39  * AC97 R2.2 specs.
40  * ALSA driver (very useful comments)
41  */
42 
43 #define VIA_PCI_ACLINK_STAT	0x40
44 #	define VIA_PCI_ACLINK_C11_READY	0x20
45 #	define VIA_PCI_ACLINK_C10_READY	0x10
46 #	define VIA_PCI_ACLINK_C01_READY	0x04
47 #	define VIA_PCI_ACLINK_LOW_POWER	0x02
48 #	define VIA_PCI_ACLINK_C00_READY	0x01
49 
50 #define VIA_PCI_ACLINK_CTRL	0x41
51 #	define VIA_PCI_ACLINK_EN	0x80
52 #	define VIA_PCI_ACLINK_NRST	0x40
53 #	define VIA_PCI_ACLINK_SYNC	0x20
54 #	define VIA_PCI_ACLINK_SERIAL	0x10
55 #	define VIA_PCI_ACLINK_VRATE	0x08
56 #	define VIA_PCI_ACLINK_SGD	0x04
57 
58 #define VIA_MC_SGD_STATUS	0x40
59 #define VIA_WR0_SGD_STATUS	0x60
60 #define VIA_WR1_SGD_STATUS	0x70
61 #	define SGD_STATUS_ACTIVE	0x80
62 #	define SGD_STATUS_AT_STOP	0x40
63 #	define SGD_STATUS_TRIGGER_Q	0x08
64 #	define SGD_STATUS_STOP_I_S	0x04
65 #	define SGD_STATUS_EOL		0x02
66 #	define SGD_STATUS_FLAG		0x01
67 #	define SGD_STATUS_INTR		(SGD_STATUS_EOL | SGD_STATUS_FLAG)
68 
69 #define VIA_MC_SGD_CONTROL	0x41
70 #define VIA_WR0_SGD_CONTROL	0x61
71 #define VIA_WR1_SGD_CONTROL	0x71
72 #	define SGD_CONTROL_START	0x80
73 #	define SGD_CONTROL_STOP		0x40
74 #	define SGD_CONTROL_AUTOSTART	0x20
75 #	define SGD_CONTROL_PAUSE	0x08
76 #	define SGD_CONTROL_I_STOP	0x04
77 #	define SGD_CONTROL_I_EOL	0x02
78 #	define SGD_CONTROL_I_FLAG	0x01
79 
80 #define VIA_MC_SGD_FORMAT	0x42
81 #	define MC_SGD_16BIT		0x80
82 #	define MC_SGD_8BIT		0x00
83 #	define MC_SGD_CHANNELS(x)	(((x)& 0x07) << 4)
84 
85 #define VIA_WR0_SGD_FORMAT	0x62
86 #define VIA_WR1_SGD_FORMAT	0x72
87 #	define WR_FIFO_ENABLE		0x40
88 
89 #define VIA_WR0_SGD_INPUT	0x63
90 #define VIA_WR1_SGD_INPUT	0x73
91 #	define WR_LINE_IN		0x00
92 #	define WR_MIC_IN		0x04
93 #	define WR_PRIMARY_CODEC		0x00
94 #	define WR_SECONDARY_CODEC1	0x01
95 #	define WR_SECONDARY_CODEC2	0x02
96 #	define WR_SECONDARY_CODEC3	0x03
97 
98 #define VIA_MC_TABLE_PTR_BASE	0x44
99 #define VIA_WR0_TABLE_PTR_BASE	0x64
100 #define VIA_WR1_TABLE_PTR_BASE	0x74
101 
102 #define VIA_MC_SLOT_SELECT	0x48
103 #	define SLOT3(x)			(x)
104 #	define SLOT4(x)			((x) << 4)
105 #	define SLOT7(x)			((x) << 8)
106 #	define SLOT8(x)			((x) << 12)
107 #	define SLOT6(x)			((x) << 16)
108 #	define SLOT9(x)			((x) << 20)
109 
110 #define VIA_MC_CURRENT_COUNT	0x4c
111 
112 #define VIA_WR0_FORMAT		0x68
113 #define VIA_WR1_FORMAT		0x78
114 #	define WR_FORMAT_STOP_INDEX	0xff000000
115 #	define WR_FORMAT_STEREO		0x00100000
116 #	define WR_FORMAT_16BIT		0x00200000
117 
118 /* Relative offsets */
119 #define VIA_RP_STATUS		0x00
120 #define VIA_RP_CONTROL		0x01
121 #define VIA_RP_TABLE_PTR	0x04
122 #define VIA_RP_CURRENT_COUNT	0x0c
123 
124 #define VIA_AC97_CONTROL	0x80
125 #	define VIA_AC97_CODECID11	0xc0000000
126 #	define VIA_AC97_CODECID10	0x80000000
127 #	define VIA_AC97_CODECID01	0x40000000
128 #	define VIA_AC97_CODEC11_VALID	0x20000000
129 #	define VIA_AC97_CODEC10_VALID	0x10000000
130 #	define VIA_AC97_CODEC01_VALID	0x08000000
131 #	define VIA_AC97_CODEC00_VALID	0x02000000
132 #	define VIA_AC97_BUSY		0x01000000
133 #	define VIA_AC97_READ		0x00800000
134 #	define VIA_AC97_INDEX(x)	((x) << 16)
135 #	define VIA_AC97_DATA(x)		((x) & 0xffff)
136 
137 
138 #define         VIA_CODEC_BUSY                0x01000000
139 #define         VIA_CODEC_PRIVALID            0x02000000
140 #define         VIA_CODEC_INDEX(x)            ((x)<<16)
141 
142 #endif /* SYS_SOUND_PCI_VIA8233_H_ */
143