summaryrefslogtreecommitdiff
path: root/drivers/char/rio/rio.h
blob: 1bf36223a4e86e6216c7c9e81e59139fc33b0a20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
** -----------------------------------------------------------------------------
**
**  Perle Specialix driver for Linux
**  Ported from existing RIO Driver for SCO sources.
 *
 *  (C) 1990 - 1998 Specialix International Ltd., Byfleet, Surrey, UK.
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
**	Module		: rio.h
**	SID		: 1.3
**	Last Modified	: 11/6/98 11:34:13
**	Retrieved	: 11/6/98 11:34:22
**
**  ident @(#)rio.h	1.3
**
** -----------------------------------------------------------------------------
*/

#ifndef	__rio_rio_h__
#define	__rio_rio_h__

/*
**	Maximum numbers of things
*/
#define	RIO_SLOTS	4	/* number of configuration slots */
#define	RIO_HOSTS	4	/* number of hosts that can be found */
#define	PORTS_PER_HOST	128	/* number of ports per host */
#define	LINKS_PER_UNIT	4	/* number of links from a host */
#define	RIO_PORTS	(PORTS_PER_HOST * RIO_HOSTS)	/* max. no. of ports */
#define	RTAS_PER_HOST	(MAX_RUP)	/* number of RTAs per host */
#define	PORTS_PER_RTA	(PORTS_PER_HOST/RTAS_PER_HOST)	/* ports on a rta */
#define	PORTS_PER_MODULE 4	/* number of ports on a plug-in module */
				/* number of modules on an RTA */
#define	MODULES_PER_RTA	 (PORTS_PER_RTA/PORTS_PER_MODULE)
#define MAX_PRODUCT	16	/* numbr of different product codes */
#define MAX_MODULE_TYPES 16	/* number of different types of module */

#define RIO_CONTROL_DEV	128	/* minor number of host/control device */
#define RIO_INVALID_MAJOR 0	/* test first host card's major no for validity */

/*
** number of RTAs that can be bound to a master
*/
#define MAX_RTA_BINDINGS (MAX_RUP * RIO_HOSTS)

/*
**	Unit types
*/
#define PC_RTA16	0x90000000
#define PC_RTA8		0xe0000000
#define TYPE_HOST	0
#define TYPE_RTA8	1
#define TYPE_RTA16	2

/*
**	Flag values returned by functions
*/

#define	RIO_FAIL	-1

/*
** SysPort value for something that hasn't any ports
*/
#define	NO_PORT	0xFFFFFFFF

/*
** Unit ID Of all hosts
*/
#define	HOST_ID	0

/*
** Break bytes into nybles
*/
#define	LONYBLE(X)	((X) & 0xF)
#define	HINYBLE(X)	(((X)>>4) & 0xF)

/*
** Flag values passed into some functions
*/
#define	DONT_SLEEP	0
#define	OK_TO_SLEEP	1

#define	DONT_PRINT	1
#define	DO_PRINT	0

#define PRINT_TO_LOG_CONS	0
#define PRINT_TO_CONS	1
#define PRINT_TO_LOG	2

/*
** Timeout has trouble with times of less than 3 ticks...
*/
#define	MIN_TIMEOUT	3

/*
**	Generally useful constants
*/

#define	HUNDRED_MS		((HZ/10)?(HZ/10):1)
#define	ONE_MEG			0x100000
#define	SIXTY_FOUR_K		0x10000

#define	RIO_AT_MEM_SIZE		SIXTY_FOUR_K
#define	RIO_EISA_MEM_SIZE	SIXTY_FOUR_K
#define	RIO_MCA_MEM_SIZE	SIXTY_FOUR_K

#define	COOK_WELL		0
#define	COOK_MEDIUM		1
#define	COOK_RAW		2

/*
**	Pointer manipulation stuff
**	RIO_PTR takes hostp->Caddr and the offset into the DP RAM area
**	and produces a UNIX caddr_t (pointer) to the object
**	RIO_OBJ takes hostp->Caddr and a UNIX pointer to an object and
**	returns the offset into the DP RAM area.
*/
#define	RIO_PTR(C,O) (((unsigned char __iomem *)(C))+(0xFFFF&(O)))
#define	RIO_OFF(C,O) ((unsigned char __iomem *)(O)-(unsigned char __iomem *)(C))

/*
**	How to convert from various different device number formats:
**	DEV is a dev number, as passed to open, close etc - NOT a minor
**	number!
**/

#define	RIO_MODEM_MASK		0x1FF
#define	RIO_MODEM_BIT		0x200
#define	RIO_UNMODEM(DEV)	(MINOR(DEV) & RIO_MODEM_MASK)
#define	RIO_ISMODEM(DEV)	(MINOR(DEV) & RIO_MODEM_BIT)
#define RIO_PORT(DEV,FIRST_MAJ)	( (MAJOR(DEV) - FIRST_MAJ) * PORTS_PER_HOST) \
					+ MINOR(DEV)
#define CSUM(pkt_ptr)  (((u16 *)(pkt_ptr))[0] + ((u16 *)(pkt_ptr))[1] + \
			((u16 *)(pkt_ptr))[2] + ((u16 *)(pkt_ptr))[3] + \
			((u16 *)(pkt_ptr))[4] + ((u16 *)(pkt_ptr))[5] + \
			((u16 *)(pkt_ptr))[6] + ((u16 *)(pkt_ptr))[7] + \
			((u16 *)(pkt_ptr))[8] + ((u16 *)(pkt_ptr))[9] )

#define	RIO_LINK_ENABLE	0x80FF	/* FF is a hack, mainly for Mips, to        */
			       /* prevent a really stupid race condition.  */

#define	NOT_INITIALISED	0
#define	INITIALISED	1

#define	NOT_POLLING	0
#define	POLLING		1

#define	NOT_CHANGED	0
#define	CHANGED		1

#define	NOT_INUSE	0

#define	DISCONNECT	0
#define	CONNECT		1

/* ------ Control Codes ------ */

#define	CONTROL		'^'
#define IFOAD		( CONTROL + 1 )
#define	IDENTIFY	( CONTROL + 2 )
#define	ZOMBIE		( CONTROL + 3 )
#define	UFOAD		( CONTROL + 4 )
#define IWAIT		( CONTROL + 5 )

#define	IFOAD_MAGIC	0xF0AD	/* of course */
#define	ZOMBIE_MAGIC	(~0xDEAD)	/* not dead -> zombie */
#define	UFOAD_MAGIC	0xD1E	/* kill-your-neighbour */
#define	IWAIT_MAGIC	0xB1DE	/* Bide your time */

/* ------ Error Codes ------ */

#define E_NO_ERROR                       ((ushort) 0)

/* ------ Free Lists ------ */

struct rio_free_list {
	u16 next;
	u16 prev;
};

/* NULL for card side linked lists */
#define	TPNULL	((ushort)(0x8000))
/* We can add another packet to a transmit queue if the packet pointer pointed
 * to by the TxAdd pointer has PKT_IN_USE clear in its address. */
#define PKT_IN_USE    0x1

/* ------ Topology ------ */

struct Top {
	u8 Unit;
	u8 Link;
};

#endif				/* __rio_h__ */