xref: /openbsd/sys/arch/luna88k/cbus/nec86reg.h (revision 09871713)
1 /*	$OpenBSD: nec86reg.h,v 1.1 2014/12/28 13:03:18 aoyama Exp $	*/
2 /*	$NecBSD: nec86reg.h,v 1.5 1998/03/14 07:04:56 kmatsuda Exp $	*/
3 /*	$NetBSD$	*/
4 
5 /*
6  * [NetBSD for NEC PC-98 series]
7  *  Copyright (c) 1996, 1997, 1998
8  *	NetBSD/pc98 porting staff. All rights reserved.
9  *
10  *  Redistribution and use in source and binary forms, with or without
11  *  modification, are permitted provided that the following conditions
12  *  are met:
13  *  1. Redistributions of source code must retain the above copyright
14  *     notice, this list of conditions and the following disclaimer.
15  *  2. Redistributions in binary form must reproduce the above copyright
16  *     notice, this list of conditions and the following disclaimer in the
17  *     documentation and/or other materials provided with the distribution.
18  *  3. The name of the author may not be used to endorse or promote products
19  *     derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
25  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * nec86reg.h
36  *
37  * NEC PC-9801-86 SoundBoard PCM driver for NetBSD/pc98.
38  * Written by NAGAO Tadaaki, Feb 10, 1996.
39  */
40 
41 #ifndef	_NEC86REG_H_
42 #define	_NEC86REG_H_
43 
44 #define NEC86_PORT		16
45 
46 /*
47  * Offsets from PCM I/O base address
48  */
49 #define NEC86_SOUND_ID		0
50 
51 #define	NEC86_COREOFFSET	6	/* core chip base */
52 #define	NEC86_CORESIZE		7
53 #define NEC86_FIFOSTAT		0	/* readonly */
54 #define NEC86_VOLUME		0	/* writeonly */
55 #define NEC86_FIFOCTL		2
56 #define NEC86_CTRL		4	/* when FIFO not running */
57 #define NEC86_FIFOINTRBLK	4	/* when FIFO running, writeonly */
58 #define NEC86_FIFODATA		6
59 
60 /*
61  * FIFO status bits
62  */
63 #define NEC86_FIFOSTAT_FULL	0x80
64 #define NEC86_FIFOSTAT_EMPTY	0x40
65 #define NEC86_FIFOSTAT_OVERFLOW	0x20
66 #define NEC86_FIFOSTAT_LRCLK	0x01
67 
68 /*
69  * FIFO control bits
70  */
71 #define NEC86_FIFOCTL_RUN	0x80
72 #define NEC86_FIFOCTL_RECMODE	0x40
73 #define NEC86_FIFOCTL_ENBLINTR	0x20
74 #define NEC86_FIFOCTL_INTRFLG	0x10
75 #define NEC86_FIFOCTL_INIT	0x08
76 
77 #define NEC86_FIFOCTL_MASK_RATE 0x07
78 #define NEC86_NRATE		8
79 
80 /*
81  * Card control bits
82  */
83 #define NEC86_CTRL_8BITS	0x40
84 #define NEC86_CTRL_PAN_L	0x20
85 #define NEC86_CTRL_PAN_R	0x10
86 
87 #define NEC86_CTRL_MASK_PAN	0x30
88 #define NEC86_CTRL_MASK_PORT	0x0f
89 
90 #define NEC86_CTRL_PORT_STD	0x02	/* PC-9801-86 supports only this */
91 
92 /*
93  * Volume
94  */
95 #define NEC86_VOLUME_MASK_PORT	0xe0
96 #define NEC86_VOLUME_MASK_VOL	0x0f
97 
98 #define NEC86_VOLUME_PORT_OPNAD	0	/* OPNA -> LINEOUT */
99 #define NEC86_VOLUME_PORT_OPNAI	1	/* OPNA -> ADC */
100 #define NEC86_VOLUME_PORT_LINED 2	/* LINEIN (& CDDA) -> LINEOUT */
101 #define NEC86_VOLUME_PORT_LINEI 3	/* LINEIN (& CDDA) -> ADC */
102 #define NEC86_VOLUME_PORT_CDDAD 4	/* CDDA -> LINEOUT (PC-98GS only) */
103 #define NEC86_VOLUME_PORT_PCMD	5	/* DAC -> LINEOUT */
104 
105 #define NEC86_MINVOL		0
106 #define NEC86_MAXVOL		15
107 
108 #define NEC86_VOL_TO_BITS(p, v)	(((p) << 5) | ((v) ^ 0xf))
109 
110 /*
111  * Unit size of the interrupt watermark (NEC86_FIFOINTRBLK).
112  */
113 #define NEC86_INTRBLK_UNIT	128	/* 128 bytes */
114 
115 /*
116  * Size of the FIFO ring buffer on the board.
117  *
118  * XXX -  We define this value a little less than the actual size to work
119  *	  around the bug at 'buffer full' in Q-Vision's cards.
120  *	  ... Too paranoid?
121  */
122 #define NEC86_BUFFSIZE	(32768 - 2 * 2)	/* 2(stereo) * 2(16bits sampling) */
123 
124 /*
125  * I/O base addresses for YAMAHA FM sound chip OPNA (YM2608/YMF288)
126  */
127 #define OPNA_IOBASE0	0x088
128 #define OPNA_IOBASE1	0x188
129 #define OPNA_IOBASE2	0x288
130 #define OPNA_IOBASE3	0x388
131 
132 /*
133  * Macros to detect valid hardware configuration data
134  */
135 #define NEC86_IRQ_VALID(irq)	(((irq) == 3) || ((irq) == 10) || \
136 				 ((irq) == 12) || ((irq) == 13))
137 #define NEC86_BASE_VALID(base)	(((base) == 0xa460) || ((base) == 0xa470) || \
138 				 ((base) == 0xa480) || ((base) == 0xa490))
139 #endif	/* !_NEC86REG_H_ */
140