i386 removal, part 14/x: Remove i386 specific code from ext2fs.
[dragonfly.git] / sys / dev / netif / sr / if_srregs.h
1 /*
2  * Copyright (c) 1995 - 2001 John Hay.
3  * Copyright (c) 1996 SDL Communications, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the author nor the names of any co-contributors
15  *    may be used to endorse or promote products derived from this software
16  *    without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $FreeBSD: src/sys/dev/sr/if_srregs.h,v 1.6.2.1 2002/06/17 15:10:58 jhay Exp $
31  * $DragonFly: src/sys/dev/netif/sr/if_srregs.h,v 1.2 2003/06/17 04:28:31 dillon Exp $
32  */
33 #ifndef _IF_SRREGS_H_
34 #define _IF_SRREGS_H_
35
36 #define NCHAN                   2    /* A HD64570 chip have 2 channels */
37
38 #define SR_BUF_SIZ              512
39 #define SR_TX_BLOCKS            2    /* Sepperate sets of tx buffers */
40
41 #define SR_CRD_N2               1
42 #define SR_CRD_N2PCI            2
43
44 /*
45  * RISCom/N2 ISA card.
46  */
47 #define SRC_IO_SIZ              0x10 /* Actually a lie. It uses a lot more. */
48 #define SRC_WIN_SIZ             0x00004000
49 #define SRC_WIN_MSK             (SRC_WIN_SIZ - 1)
50 #define SRC_WIN_SHFT            14
51
52 #define SR_FLAGS_NCHAN_MSK      0x0000000F
53 #define SR_FLAGS_0_CLK_MSK      0x00000030
54 #define SR_FLAGS_0_EXT_CLK      0x00000000 /* External RX clock shared by TX */
55 #define SR_FLAGS_0_EXT_SEP_CLK  0x00000010 /* Sepperate external clocks */
56 #define SR_FLAGS_0_INT_CLK      0x00000020 /* Internal clock */
57 #define SR_FLAGS_1_CLK_MSK      0x000000C0
58 #define SR_FLAGS_1_EXT_CLK      0x00000000 /* External RX clock shared by TX */
59 #define SR_FLAGS_1_EXT_SEP_CLK  0x00000040 /* Sepperate external clocks */
60 #define SR_FLAGS_1_INT_CLK      0x00000080 /* Internal clock */
61
62 #define SR_FLAGS_CLK_SHFT       4
63 #define SR_FLAGS_CLK_CHAN_SHFT  2
64 #define SR_FLAGS_EXT_CLK        0x00000000 /* External RX clock shared by TX */
65 #define SR_FLAGS_EXT_SEP_CLK    0x00000001 /* Sepperate external clocks */
66 #define SR_FLAGS_INT_CLK        0x00000002 /* Internal clock */
67
68 #define SR_PCR                  0x00 /* RW, PC Control Register */
69 #define SR_BAR                  0x02 /* RW, Base Address Register */
70 #define SR_PSR                  0x04 /* RW, Page Scan Register */
71 #define SR_MCR                  0x06 /* RW, Modem Control Register */
72
73 #define SR_PCR_SCARUN           0x01 /* !Reset */
74 #define SR_PCR_EN_VPM           0x02 /* Running above 1M */
75 #define SR_PCR_MEM_WIN          0x04 /* Open memory window */
76 #define SR_PCR_ISA16            0x08 /* 16 bit ISA mode */
77 #define SR_PCR_16M_SEL          0xF0 /* A20-A23 Addresses */
78
79 #define SR_PSR_PG_SEL           0x1F /* Page 0 - 31 select */
80 #define SR_PG_MSK               0x1F
81 #define SR_PSR_WIN_SIZ          0x60 /* Window size select */
82 #define SR_PSR_WIN_16K          0x00
83 #define SR_PSR_WIN_32K          0x20
84 #define SR_PSR_WIN_64K          0x40
85 #define SR_PSR_WIN_128K         0x60
86 #define SR_PSR_EN_SCA_DMA       0x80 /* Enable the SCA DMA */
87
88 #define SR_MCR_DTR0             0x01 /* Deactivate DTR0 */
89 #define SR_MCR_DTR1             0x02 /* Deactivate DTR1 */
90 #define SR_MCR_DSR0             0x04 /* DSR0 Status */
91 #define SR_MCR_DSR1             0x08 /* DSR1 Status */
92 #define SR_MCR_TE0              0x10 /* Enable RS422 TXD */
93 #define SR_MCR_TE1              0x20 /* Enable RS422 TXD */
94 #define SR_MCR_ETC0             0x40 /* Enable Ext Clock out */
95 #define SR_MCR_ETC1             0x80 /* Enable Ext Clock out */
96
97 /*
98  * RISCom/N2 PCI card.
99  */
100 #define SR_FECR                 0x0200 /* Front End Control Register */
101 #define SR_FECR_ETC0            0x0001 /* Enable Ext Clock out */
102 #define SR_FECR_ETC1            0x0002 /* Enable Ext Clock out */
103 #define SR_FECR_TE0             0x0004 /* Enable RS422 TXD */
104 #define SR_FECR_TE1             0x0008 /* Enable RS422 TXD */
105 #define SR_FECR_GPO0            0x0010 /* General Purpose Output */
106 #define SR_FECR_GPO1            0x0020 /* General Purpose Output */
107 #define SR_FECR_DTR0            0x0040 /* 0 for active, 1 for inactive */
108 #define SR_FECR_DTR1            0x0080 /* 0 for active, 1 for inactive */
109 #define SR_FECR_DSR0            0x0100 /* DSR0 Status */
110 #define SR_FECR_ID0             0x0E00 /* ID of channel 0 */
111 #define SR_FECR_DSR1            0x1000 /* DSR1 Status */
112 #define SR_FECR_ID1             0xE000 /* ID of channel 1 */
113
114 #define SR_FE_ID_V35            0x00   /* V.35 Interface */
115 #define SR_FE_ID_RS232          0x01   /* RS232 Interface */
116 #define SR_FE_ID_TEST           0x02   /* Test Board */
117 #define SR_FE_ID_RS422          0x03   /* RS422 Interface */
118 #define SR_FE_ID_HSSI           0x05   /* HSSI Interface */
119 #define SR_FE_ID_X21            0x06   /* X.21 Interface */
120 #define SR_FE_ID_NONE           0x07   /* No card present */
121 #define SR_FE_ID0_SHFT             9
122 #define SR_FE_ID1_SHFT            13
123
124 /*
125  * These macros are used to hide the difference between the way the
126  * ISA N2 cards and the PCI N2 cards access the Hitachi 64570 SCA.
127  */
128 #define SRC_GET8(base,off)      (*hc->src_get8)(base,(u_int)&off)
129 #define SRC_GET16(base,off)     (*hc->src_get16)(base,(u_int)&off)
130 #define SRC_PUT8(base,off,d)    (*hc->src_put8)(base,(u_int)&off,d)
131 #define SRC_PUT16(base,off,d)   (*hc->src_put16)(base,(u_int)&off,d)
132
133 /*
134  * Define the hardware (card information) structure needed to keep
135  * track of the device itself... There is only one per card.
136  */
137 struct sr_hardc {
138         struct  sr_softc *sc;           /* software channels */
139         int     cunit;                  /* card w/in system */
140
141         int     cardtype;
142         int     numports;               /* # of ports on cd */
143         int     mempages;
144         u_int   memsize;                /* DPRAM size: bytes */
145         u_int   winmsk;
146         vm_offset_t     sca_base;
147         vm_offset_t     mem_pstart;     /* start of buffer */
148         caddr_t mem_start;              /* start of DP RAM */
149         caddr_t mem_end;                /* end of DP RAM */
150         caddr_t plx_base;
151
152         sca_regs        *sca;           /* register array */
153
154         bus_space_tag_t bt;
155         bus_space_handle_t bh;
156         int rid_memory;
157         int rid_plx_memory;
158         int rid_irq;
159         struct resource* res_memory;    /* resource for mem range */
160         struct resource* res_plx_memory;
161         struct resource* res_irq;       /* resource for irq range */
162         void    *intr_cookie;
163
164         /*
165          * We vectorize the following functions to allow re-use between the
166          * ISA card's needs and those of the PCI card.
167          */
168         void    (*src_put8)(u_int base, u_int off, u_int val);
169         void    (*src_put16)(u_int base, u_int off, u_int val);
170         u_int   (*src_get8)(u_int base, u_int off);
171         u_int   (*src_get16)(u_int base, u_int off);
172 };
173
174 extern devclass_t sr_devclass;
175
176 int sr_allocate_ioport(device_t device, int rid, u_long size);
177 int sr_allocate_irq(device_t device, int rid, u_long size);
178 int sr_allocate_memory(device_t device, int rid, u_long size);
179 int sr_allocate_plx_memory(device_t device, int rid, u_long size);
180 int sr_deallocate_resources(device_t device);
181 int sr_attach(device_t device);
182 int sr_detach(device_t device);
183
184 #endif /* _IF_SRREGS_H_ */