1 /*	$NetBSD: oboereg.h,v 1.2 2008/04/28 20:23:55 martin Exp $	*/
2 
3 /*-
4  * Copyright (c) 2000 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jan Sparud.
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  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /*
33  * Toshiba OBOE SIR/FIR driver header file.
34  */
35 
36 #ifndef OBOE_H
37 #define OBOE_H
38 
39 /* Registers */
40 /*Receive and transmit task registers (read only) */
41 #define OBOE_RCVT	(0x00)
42 #define OBOE_XMTT	(0x01)
43 #define OBOE_XMTT_OFFSET	0x40
44 
45 /*Page pointers to the TaskFile structure */
46 #define OBOE_TFP2	(0x02)
47 #define OBOE_TFP0	(0x04)
48 #define OBOE_TFP1	(0x05)
49 
50 /*Dunno */
51 #define OBOE_REG_3	(0x03)
52 
53 /*Number of tasks to use in Xmit and Recv queues */
54 #define OBOE_NTR	(0x07)
55 #define OBOE_NTR_XMIT4	0x00
56 #define OBOE_NTR_XMIT8	0x10
57 #define OBOE_NTR_XMIT16	0x30
58 #define OBOE_NTR_XMIT32	0x70
59 #define OBOE_NTR_XMIT64	0xf0
60 #define OBOE_NTR_RECV4	0x00
61 #define OBOE_NTR_RECV8	0x01
62 #define OBOE_NTR_RECV6	0x03
63 #define OBOE_NTR_RECV32	0x07
64 #define OBOE_NTR_RECV64	0x0f
65 
66 /* Dunno */
67 #define OBOE_REG_9	(0x09)
68 
69 /* Interrupt Status Register */
70 #define OBOE_ISR	(0x0c)
71 #define OBOE_ISR_TXDONE	0x80
72 #define OBOE_ISR_RXDONE	0x40
73 #define OBOE_ISR_20	0x20
74 #define OBOE_ISR_10	0x10
75 #define OBOE_ISR_8	0x08         /*This is collision or parity or something */
76 #define OBOE_ISR_4	0x08
77 #define OBOE_ISR_2	0x08
78 #define OBOE_ISR_1	0x08
79 
80 /*Dunno */
81 #define OBOE_REG_D	(0x0d)
82 
83 /*Register Lock Register */
84 #define OBOE_LOCK	(0x0e)
85 
86 /*Speed control registers */
87 #define OBOE_PMDL	(0x10)
88 #define OBOE_PMDL_SIR	0x18
89 #define OBOE_PMDL_MIR	0xa0
90 #define OBOE_PMDL_FIR	0x40
91 
92 #define OBOE_SMDL	(0x18)
93 #define OBOE_SMDL_SIR	0x20
94 #define OBOE_SMDL_MIR	0x01
95 #define OBOE_SMDL_FIR	0x0f
96 
97 #define OBOE_UDIV	(0x19)
98 
99 /*Dunno */
100 #define OBOE_REG_11	(0x11)
101 
102 /*Chip Reset Register */
103 #define OBOE_RST	(0x15)
104 #define OBOE_RST_WRAP	0x8
105 
106 /*Dunno */
107 #define OBOE_REG_1A	(0x1a)
108 #define OBOE_REG_1B	(0x1b)
109 
110 #define OBOE_IOSIZE	0x1f
111 
112 #define IO_BAR		0x10
113 
114 typedef unsigned int dword;
115 typedef unsigned short int word;
116 typedef unsigned char byte;
117 typedef dword Paddr;
118 
119 struct OboeTask {
120 	uint16_t len;
121 	uint8_t unused;
122 	uint8_t control;
123 	uint32_t buffer;
124 };
125 
126 #define OBOE_NTASKS 64
127 
128 struct OboeTaskFile {
129 	struct OboeTask recv[OBOE_NTASKS];
130 	struct OboeTask xmit[OBOE_NTASKS];
131 };
132 
133 #define OBOE_TASK_BUF_LEN (sizeof(struct OboeTaskFile) << 1)
134 
135 /*These set the number of slots in use */
136 #define TX_SLOTS	8
137 #define RX_SLOTS	8
138 
139 #define RX_BUF_SZ 	4196
140 #define TX_BUF_SZ	4196
141 
142 /* You need also to change this, toshiba uses 4,8 and 4,4 */
143 /* It makes no difference if you are only going to use ONETASK mode */
144 /* remember each buffer use XX_BUF_SZ more _PHYSICAL_ memory */
145 #define OBOE_NTR_VAL 	(OBOE_NTR_XMIT8 | OBOE_NTR_RECV8)
146 
147 #define OUTB(sc, val, off) \
148   bus_space_write_1(sc->sc_iot, sc->sc_ioh, off, val)
149 
150 #define INB(sc, off) \
151   bus_space_read_1(sc->sc_iot, sc->sc_ioh, off)
152 
153 #endif
154