xref: /haiku/src/add-ons/kernel/drivers/audio/hda/hda_controller_defs.h (revision 268f99dd7dc4bd7474a8bd2742d3f1ec1de6752a)
144f16897SAxel Dörfler /*
20a361580SAxel Dörfler  * Copyright 2007-2012, Haiku, Inc. All Rights Reserved.
344f16897SAxel Dörfler  * Distributed under the terms of the MIT License.
444f16897SAxel Dörfler  *
544f16897SAxel Dörfler  * Authors:
644f16897SAxel Dörfler  *		Ithamar Adema, ithamar AT unet DOT nl
7a9410600SAxel Dörfler  *		Axel Dörfler, axeld@pinc-software.de
844f16897SAxel Dörfler  */
989db0a5bSIthamar R. Adema #ifndef HDAC_REGS_H
1089db0a5bSIthamar R. Adema #define HDAC_REGS_H
1189db0a5bSIthamar R. Adema 
12a9410600SAxel Dörfler 
1389db0a5bSIthamar R. Adema #include <SupportDefs.h>
1489db0a5bSIthamar R. Adema 
1589db0a5bSIthamar R. Adema 
16a9410600SAxel Dörfler /* Controller register definitions */
17a9410600SAxel Dörfler #define HDAC_GLOBAL_CAP					0x00	// 16bits, GCAP
18a9410600SAxel Dörfler #define GLOBAL_CAP_OUTPUT_STREAMS(cap)	(((cap) >> 12) & 15)
19a9410600SAxel Dörfler #define GLOBAL_CAP_INPUT_STREAMS(cap)	(((cap) >> 8) & 15)
20a9410600SAxel Dörfler #define GLOBAL_CAP_BIDIR_STREAMS(cap)	(((cap) >> 3) & 15)
21a9410600SAxel Dörfler #define GLOBAL_CAP_NUM_SDO(cap)			((((cap) >> 1) & 3) ? (cap & 6) : 1)
22a9410600SAxel Dörfler #define GLOBAL_CAP_64BIT(cap)			(((cap) & 1) != 0)
2389db0a5bSIthamar R. Adema 
24a9410600SAxel Dörfler #define HDAC_VERSION_MINOR				0x02	// 8bits, VMIN
25a9410600SAxel Dörfler #define HDAC_VERSION_MAJOR				0x03	// 8bits, VMAJ
2689db0a5bSIthamar R. Adema 
27a9410600SAxel Dörfler #define HDAC_GLOBAL_CONTROL				0x08	// 32bits, GCTL
28a9410600SAxel Dörfler #define GLOBAL_CONTROL_UNSOLICITED		(1 << 8)
29a9410600SAxel Dörfler 	// accept unsolicited responses
30a9410600SAxel Dörfler #define GLOBAL_CONTROL_FLUSH			(1 << 1)
31a9410600SAxel Dörfler #define GLOBAL_CONTROL_RESET			(1 << 0)
3289db0a5bSIthamar R. Adema 
33a9410600SAxel Dörfler #define HDAC_WAKE_ENABLE				0x0c	// 16bits, WAKEEN
3484dfba29SJulian Harnath #define HDAC_WAKE_ENABLE_MASK			0x7fff
35a9410600SAxel Dörfler #define HDAC_STATE_STATUS				0x0e	// 16bits, STATESTS
3689db0a5bSIthamar R. Adema 
37a9410600SAxel Dörfler #define HDAC_INTR_CONTROL				0x20	// 32bits, INTCTL
3897f865f7SJérôme Duval #define INTR_CONTROL_GLOBAL_ENABLE		(1U << 31)
39a9410600SAxel Dörfler #define INTR_CONTROL_CONTROLLER_ENABLE	(1 << 30)
4089db0a5bSIthamar R. Adema 
41a9410600SAxel Dörfler #define HDAC_INTR_STATUS				0x24	// 32bits, INTSTS
4297f865f7SJérôme Duval #define INTR_STATUS_GLOBAL				(1U << 31)
43a9410600SAxel Dörfler #define INTR_STATUS_CONTROLLER			(1 << 30)
44a9410600SAxel Dörfler #define INTR_STATUS_STREAM_MASK			0x3fffffff
4589db0a5bSIthamar R. Adema 
46a9410600SAxel Dörfler #define HDAC_CORB_BASE_LOWER			0x40	// 32bits, CORBLBASE
47a9410600SAxel Dörfler #define HDAC_CORB_BASE_UPPER			0x44	// 32bits, CORBUBASE
48a9410600SAxel Dörfler #define HDAC_CORB_WRITE_POS				0x48	// 16bits, CORBWP
4984dfba29SJulian Harnath #define HDAC_CORB_WRITE_POS_MASK		0xff
5089db0a5bSIthamar R. Adema 
51a9410600SAxel Dörfler #define HDAC_CORB_READ_POS				0x4a	// 16bits, CORBRP
52a9410600SAxel Dörfler #define CORB_READ_POS_RESET				(1 << 15)
5389db0a5bSIthamar R. Adema 
54a9410600SAxel Dörfler #define HDAC_CORB_CONTROL				0x4c	// 8bits, CORBCTL
5584dfba29SJulian Harnath #define HDAC_CORB_CONTROL_MASK			0x3
56a9410600SAxel Dörfler #define CORB_CONTROL_RUN				(1 << 1)
57a9410600SAxel Dörfler #define CORB_CONTROL_MEMORY_ERROR_INTR	(1 << 0)
5889db0a5bSIthamar R. Adema 
59a9410600SAxel Dörfler #define HDAC_CORB_STATUS				0x4d	// 8bits, CORBSTS
60a9410600SAxel Dörfler #define CORB_STATUS_MEMORY_ERROR		(1 << 0)
6189db0a5bSIthamar R. Adema 
62a9410600SAxel Dörfler #define HDAC_CORB_SIZE					0x4e	// 8bits, CORBSIZE
6384dfba29SJulian Harnath #define HDAC_CORB_SIZE_MASK				0x3
64a9410600SAxel Dörfler #define CORB_SIZE_CAP_2_ENTRIES			(1 << 4)
65a9410600SAxel Dörfler #define CORB_SIZE_CAP_16_ENTRIES		(1 << 5)
66a9410600SAxel Dörfler #define CORB_SIZE_CAP_256_ENTRIES		(1 << 6)
67a9410600SAxel Dörfler #define CORB_SIZE_2_ENTRIES				0x00	// 8 byte
68a9410600SAxel Dörfler #define CORB_SIZE_16_ENTRIES			0x01	// 64 byte
69a9410600SAxel Dörfler #define CORB_SIZE_256_ENTRIES			0x02	// 1024 byte
7089db0a5bSIthamar R. Adema 
71a9410600SAxel Dörfler #define HDAC_RIRB_BASE_LOWER			0x50	// 32bits, RIRBLBASE
72a9410600SAxel Dörfler #define HDAC_RIRB_BASE_UPPER			0x54	// 32bits, RIRBUBASE
7389db0a5bSIthamar R. Adema 
74a9410600SAxel Dörfler #define HDAC_RIRB_WRITE_POS				0x58	// 16bits, RIRBWP
75a9410600SAxel Dörfler #define RIRB_WRITE_POS_RESET			(1 << 15)
7689db0a5bSIthamar R. Adema 
77a9410600SAxel Dörfler #define HDAC_RESPONSE_INTR_COUNT		0x5a	// 16bits, RINTCNT
7884dfba29SJulian Harnath #define HDAC_RESPONSE_INTR_COUNT_MASK	0xff
7989db0a5bSIthamar R. Adema 
80a9410600SAxel Dörfler #define HDAC_RIRB_CONTROL				0x5c	// 8bits, RIRBCTL
8184dfba29SJulian Harnath #define HDAC_RIRB_CONTROL_MASK			0x7
82a9410600SAxel Dörfler #define RIRB_CONTROL_OVERRUN_INTR		(1 << 2)
83a9410600SAxel Dörfler #define RIRB_CONTROL_DMA_ENABLE			(1 << 1)
84a9410600SAxel Dörfler #define RIRB_CONTROL_RESPONSE_INTR		(1 << 0)
8589db0a5bSIthamar R. Adema 
86a9410600SAxel Dörfler #define HDAC_RIRB_STATUS				0x5d	// 8bits, RIRBSTS
87a9410600SAxel Dörfler #define RIRB_STATUS_OVERRUN				(1 << 2)
88a9410600SAxel Dörfler #define RIRB_STATUS_RESPONSE			(1 << 0)
8989db0a5bSIthamar R. Adema 
90a9410600SAxel Dörfler #define HDAC_RIRB_SIZE					0x5e	// 8bits, RIRBSIZE
9184dfba29SJulian Harnath #define HDAC_RIRB_SIZE_MASK				0x3
92a9410600SAxel Dörfler #define RIRB_SIZE_CAP_2_ENTRIES			(1 << 4)
93a9410600SAxel Dörfler #define RIRB_SIZE_CAP_16_ENTRIES		(1 << 5)
94a9410600SAxel Dörfler #define RIRB_SIZE_CAP_256_ENTRIES		(1 << 6)
95a9410600SAxel Dörfler #define RIRB_SIZE_2_ENTRIES				0x00
96a9410600SAxel Dörfler #define RIRB_SIZE_16_ENTRIES			0x01
97a9410600SAxel Dörfler #define RIRB_SIZE_256_ENTRIES			0x02
9889db0a5bSIthamar R. Adema 
99a9410600SAxel Dörfler #define HDAC_DMA_POSITION_BASE_LOWER	0x70	// 32bits, DPLBASE
100a9410600SAxel Dörfler #define HDAC_DMA_POSITION_BASE_UPPER	0x74	// 32bits, DPUBASE
1017ef3822cSAxel Dörfler #define DMA_POSITION_ENABLED			1
1027ef3822cSAxel Dörfler 
103a9410600SAxel Dörfler /* Stream Descriptor Registers */
104a9410600SAxel Dörfler #define HDAC_STREAM_BASE				0x80
105a9410600SAxel Dörfler #define HDAC_STREAM_SIZE				0x20
10689db0a5bSIthamar R. Adema 
107a9410600SAxel Dörfler #define HDAC_STREAM_CONTROL0			0x00	// 8bits, CTL0
108a9410600SAxel Dörfler #define CONTROL0_RESET					(1 << 0)
109a9410600SAxel Dörfler #define CONTROL0_RUN					(1 << 1)
110a9410600SAxel Dörfler #define CONTROL0_BUFFER_COMPLETED_INTR	(1 << 2)
111a9410600SAxel Dörfler #define CONTROL0_FIFO_ERROR_INTR		(1 << 3)
112a9410600SAxel Dörfler #define CONTROL0_DESCRIPTOR_ERROR_INTR	(1 << 4)
113a9410600SAxel Dörfler #define HDAC_STREAM_CONTROL1			0x01	// 8bits, CTL1
114a9410600SAxel Dörfler #define HDAC_STREAM_CONTROL2			0x02	// 8bits, CTL2
115a9410600SAxel Dörfler #define CONTROL2_STREAM_MASK			0xf0
116a9410600SAxel Dörfler #define CONTROL2_STREAM_SHIFT			4
117a9410600SAxel Dörfler #define CONTROL2_BIDIR					(1 << 3)
118a9410600SAxel Dörfler #define CONTROL2_TRAFFIC_PRIORITY		(1 << 2)
119a9410600SAxel Dörfler #define CONTROL2_STRIPE_SDO_MASK		0x03
120a9410600SAxel Dörfler #define HDAC_STREAM_STATUS				0x03	// 8bits, STS
121a9410600SAxel Dörfler #define STATUS_BUFFER_COMPLETED			(1 << 2)
122a9410600SAxel Dörfler #define STATUS_FIFO_ERROR				(1 << 3)
123a9410600SAxel Dörfler #define STATUS_DESCRIPTOR_ERROR			(1 << 4)
124a9410600SAxel Dörfler #define STATUS_FIFO_READY				(1 << 5)
125a9410600SAxel Dörfler #define HDAC_STREAM_POSITION			0x04	// 32bits, LPIB
126a9410600SAxel Dörfler #define HDAC_STREAM_BUFFER_SIZE			0x08	// 32bits, CBL
127a9410600SAxel Dörfler #define HDAC_STREAM_LAST_VALID			0x0c	// 16bits, LVI
128a9410600SAxel Dörfler #define HDAC_STREAM_FIFO_SIZE			0x10	// 16bits, FIFOS
129a9410600SAxel Dörfler #define HDAC_STREAM_FORMAT				0x12	// 16bits, FMT
130a9410600SAxel Dörfler #define FORMAT_8BIT						(0 << 4)
131a9410600SAxel Dörfler #define FORMAT_16BIT					(1 << 4)
132a9410600SAxel Dörfler #define FORMAT_20BIT					(2 << 4)
133a9410600SAxel Dörfler #define FORMAT_24BIT					(3 << 4)
134a9410600SAxel Dörfler #define FORMAT_32BIT					(4 << 4)
135a9410600SAxel Dörfler #define FORMAT_44_1_BASE_RATE			(1 << 14)
136a9410600SAxel Dörfler #define FORMAT_MULTIPLY_RATE_SHIFT		11
137a9410600SAxel Dörfler #define FORMAT_DIVIDE_RATE_SHIFT		8
138a9410600SAxel Dörfler #define HDAC_STREAM_BUFFERS_BASE_LOWER	0x18	// 32bits, BDPL
139a9410600SAxel Dörfler #define HDAC_STREAM_BUFFERS_BASE_UPPER	0x1c	// 32bits, BDPU
14089db0a5bSIthamar R. Adema 
1411708513cSJérôme Duval /* PCI space register definitions */
1421708513cSJérôme Duval #define PCI_HDA_TCSEL					0x44
143321e633fSJérôme Duval #define PCI_HDA_TCSEL_MASK				0xf8
144321e633fSJérôme Duval 
145321e633fSJérôme Duval #define ATI_HDA_MISC_CNTR2				0x42
146321e633fSJérôme Duval #define ATI_HDA_MISC_CNTR2_MASK   		0xf8
147321e633fSJérôme Duval #define ATI_HDA_ENABLE_SNOOP      		0x02
14807fbbf9bSJérôme Duval #define NVIDIA_HDA_OSTRM_COH			0x4c
14907fbbf9bSJérôme Duval #define NVIDIA_HDA_ISTRM_COH			0x4d
15007fbbf9bSJérôme Duval #define NVIDIA_HDA_ENABLE_COHBIT		0x01
151321e633fSJérôme Duval #define NVIDIA_HDA_TRANSREG				0x4e
152321e633fSJérôme Duval #define NVIDIA_HDA_TRANSREG_MASK		0xf0
153321e633fSJérôme Duval #define NVIDIA_HDA_ENABLE_COHBITS		0x0f
154*7f276d83SAlexander von Gluck IV 
155*7f276d83SAlexander von Gluck IV #define INTEL_SCH_HDA_CGCTL				0x48
156*7f276d83SAlexander von Gluck IV #define INTEL_SCH_HDA_CGCTL_MISCBDCGE	(1 << 6)
15707fbbf9bSJérôme Duval #define INTEL_SCH_HDA_DEVC				0x78
158*7f276d83SAlexander von Gluck IV #define INTEL_SCH_HDA_DEVC_SNOOP		(1 << 11)
159321e633fSJérôme Duval 
1601708513cSJérôme Duval 
16189db0a5bSIthamar R. Adema typedef uint32 corb_t;
16289db0a5bSIthamar R. Adema typedef struct {
16389db0a5bSIthamar R. Adema 	uint32 response;
164105152d1SAxel Dörfler 	uint32 flags;
16589db0a5bSIthamar R. Adema } rirb_t;
16689db0a5bSIthamar R. Adema 
167105152d1SAxel Dörfler #define RESPONSE_FLAGS_CODEC_MASK		0x0000000f
168105152d1SAxel Dörfler #define RESPONSE_FLAGS_UNSOLICITED		(1 << 4)
169105152d1SAxel Dörfler 
17089db0a5bSIthamar R. Adema typedef struct {
1711708513cSJérôme Duval 	uint32	lower;
1721708513cSJérôme Duval 	uint32	upper;
17389db0a5bSIthamar R. Adema 	uint32	length;
17489db0a5bSIthamar R. Adema 	uint32	ioc;
17589db0a5bSIthamar R. Adema } bdl_entry_t;
17689db0a5bSIthamar R. Adema 
17789db0a5bSIthamar R. Adema #endif /* HDAC_REGS_H */
178