1 /* $NetBSD: magmareg.h,v 1.15 2009/05/12 14:43:59 cegger Exp $ */
4 * Copyright (c) 1998 Iain Hibbert
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #define dprintf(x) printf x
34 /* The mapping of minor device number -> card and port is done as
37 * +---+---+---+---+---+---+---+---+
38 * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
39 * +---+---+---+---+---+---+---+---+
41 * | | | | +---+---+---+---> port number
43 * | | | +-------------------> dialout (on tty ports)
45 * | | +-----------------------> unused
47 * +---+---------------------------> card number
51 #define MAGMA_MAX_CARDS 4
52 #define MAGMA_MAX_TTY 16
53 #define MAGMA_MAX_BPP 2
54 #define MAGMA_MAX_CD1400 4
55 #define MAGMA_MAX_CD1190 2
57 #define MAGMA_CARD(x) ((minor(x) >> 6) & 0x03)
58 #define MAGMA_PORT(x) (minor(x) & 0x0f)
60 #define MTTY_DIALOUT(x) (minor(x) & 0x10)
63 * Supported Card Types
65 struct magma_board_info
{
66 const char *mb_sbusname
; /* sbus_attach_args.sa_name */
67 const char *mb_name
; /* cardname to match against */
68 const char *mb_realname
; /* english card name */
69 int mb_nser
; /* number of serial ports */
70 int mb_npar
; /* number of parallel ports */
71 int mb_ncd1400
; /* number of CD1400 chips */
72 int mb_svcackr
; /* svcackr offset */
73 int mb_svcackt
; /* svcackt offset */
74 int mb_svcackm
; /* svcackm offset */
75 int mb_cd1400
[MAGMA_MAX_CD1400
];/* cd1400 chip register offsets */
76 int mb_ncd1190
; /* number of CD1190 chips */
77 int mb_cd1190
[MAGMA_MAX_CD1190
];/* cd1190 chip register offsets */
84 volatile u_char
*cd_reg
; /* chip registers */
85 int cd_chiprev
; /* chip revision */
86 int cd_clock
; /* clock speed in MHz */
87 int cd_parmode
; /* parallel mode operation */
94 volatile u_char
*cd_reg
; /* chip registers */
95 int cd_chiprev
; /* chip revision */
98 /* software state for each card */
100 struct device ms_dev
; /* required. must be first in softc */
101 struct evcnt ms_intrcnt
; /* statistics */
103 /* cd1400 chip info */
105 struct cd1400 ms_cd1400
[MAGMA_MAX_CD1400
];
106 volatile u_char
*ms_svcackr
; /* CD1400 service acknowledge receive */
107 volatile u_char
*ms_svcackt
; /* CD1400 service acknowledge transmit */
108 volatile u_char
*ms_svcackm
; /* CD1400 service acknowledge modem */
110 /* cd1190 chip info */
112 struct cd1190 ms_cd1190
[MAGMA_MAX_CD1190
];
114 struct magma_board_info
*ms_board
; /* what am I? */
116 struct mtty_softc
*ms_mtty
;
117 struct mbpp_softc
*ms_mbpp
;
119 /* softintr(9) cookie */
123 #define MTTY_RBUF_SIZE (2 * 512)
124 #define MTTY_RX_FIFO_THRESHOLD 6
125 #define MTTY_RX_DTR_THRESHOLD 9
128 struct cd1400
*mp_cd1400
; /* ptr to chip */
129 int mp_channel
; /* and channel */
132 int mp_openflags
; /* default tty flags */
133 int mp_flags
; /* port flags */
134 int mp_carrier
; /* state of carrier */
136 u_char
*mp_rbuf
; /* ring buffer start */
137 u_char
*mp_rend
; /* ring buffer end */
138 u_char
*mp_rget
; /* ring buffer read pointer */
139 u_char
*mp_rput
; /* ring buffer write pointer */
141 u_char
*mp_txp
; /* transmit character pointer */
142 int mp_txc
; /* transmit character counter */
145 #define MTTYF_CARRIER_CHANGED (1<<0)
146 #define MTTYF_SET_BREAK (1<<1)
147 #define MTTYF_CLR_BREAK (1<<2)
148 #define MTTYF_DONE (1<<3)
149 #define MTTYF_STOP (1<<4)
150 #define MTTYF_RING_OVERFLOW (1<<5)
153 struct device ms_dev
; /* device info */
154 int ms_nports
; /* tty ports */
155 struct mtty_port ms_port
[MAGMA_MAX_TTY
];
158 #define MBPP_RX_FIFO_THRESHOLD 25
161 struct cd1400
*mp_cd1400
; /* for LC2+1Sp card */
162 struct cd1190
*mp_cd1190
; /* all the others */
164 struct callout mp_timeout_ch
;
165 struct callout mp_start_ch
;
169 struct mbpp_param mp_param
;
170 #define mp_burst mp_param.bp_burst
171 #define mp_timeout mp_param.bp_timeout
172 #define mp_delay mp_param.bp_delay
174 u_char
*mp_ptr
; /* pointer to I/O data */
175 int mp_cnt
; /* count of I/O chars */
178 #define MBPPF_OPEN (1<<0)
179 #define MBPPF_TIMEOUT (1<<1)
180 #define MBPPF_UIO (1<<2)
181 #define MBPPF_DELAY (1<<3)
182 #define MBPPF_WAKEUP (1<<4)
185 struct device ms_dev
; /* device info */
186 int ms_nports
; /* parallel ports */
187 struct mbpp_port ms_port
[MAGMA_MAX_BPP
];
193 #define SET(t, f) ((t) |= (f))
194 #define CLR(t, f) ((t) &= ~(f))
195 #define ISSET(t, f) ((t) & (f))
197 /* internal function prototypes */
199 int cd1400_compute_baud(speed_t
, int, int *, int *);
200 __inline
void cd1400_write_ccr(struct cd1400
*, u_char
);
201 __inline u_char
cd1400_read_reg(struct cd1400
*, int);
202 __inline
void cd1400_write_reg(struct cd1400
*, int, u_char
);
203 void cd1400_enable_transmitter(struct cd1400
*, int);
205 int magma_match(device_t
, cfdata_t
, void *);
206 void magma_attach(device_t
, device_t
, void *);
207 int magma_hard(void *);
208 void magma_soft(void *);
210 int mtty_match(device_t
, cfdata_t
, void *);
211 void mtty_attach(device_t
, device_t
, void *);
212 int mtty_modem_control(struct mtty_port
*, int, int);
213 int mtty_param(struct tty
*, struct termios
*);
214 void mtty_start(struct tty
*);
216 int mbpp_match(device_t
, cfdata_t
, void *);
217 void mbpp_attach(device_t
, device_t
, void *);
218 void mbpp_timeout(void *);
219 void mbpp_start(void *);
220 int mbpp_send(struct mbpp_port
*, void *, int);
221 int mbpp_recv(struct mbpp_port
*, void *, int);
222 int mbpp_hztoms(int);
223 int mbpp_mstohz(int);