1139749Simp/*-
226003Smsmith * Redistribution and use in source and binary forms, with or without
326003Smsmith * modification, are permitted provided that the following conditions
426003Smsmith * are met:
526003Smsmith * 1. Redistributions of source code must retain all copyright
626003Smsmith *    notices, this list of conditions and the following disclaimer.
726003Smsmith * 2. The names of the authors may not be used to endorse or promote products
897748Sschweikh *    derived from this software without specific prior written permission
926003Smsmith *
1026003Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
1126003Smsmith * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1226003Smsmith * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1326003Smsmith * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
1426003Smsmith * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1526003Smsmith * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1626003Smsmith * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1726003Smsmith * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1826003Smsmith * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1926003Smsmith * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2026003Smsmith *
2159874Speter * $FreeBSD$
2226003Smsmith */
2326003Smsmith/* Definitions for WaveLAN driver */
2426003Smsmith
2526003Smsmith#ifndef	_IF_WL_H
2626003Smsmith#define _IF_WL_H
2726003Smsmith
2826003Smsmith#define	STATUS_TRIES	15000
2926003Smsmith
3026003Smsmith#define N_FD			100
3126003Smsmith#define N_RBD			100
3226003Smsmith#define N_TBD			72
3326003Smsmith#define RCVBUFSIZE		540
3426003Smsmith#define I82586NULL		0xffff
3526003Smsmith
3626003Smsmith#define DSF_RUNNING	1
3726003Smsmith
3826003Smsmith#define MOD_ENAL 1
3926003Smsmith#define MOD_PROM 2
4026003Smsmith
4126003Smsmithtypedef struct {
4226003Smsmith	rbd_t	r;
4326003Smsmith	char	rbd_pad[2];
4426003Smsmith	char	rbuffer[RCVBUFSIZE];
4526003Smsmith} ru_t;
4626003Smsmith
4726003Smsmith/* Board 64k RAM layout. Offsets from 0x0000 */
4826003Smsmith
4926003Smsmith#define OFFSET_RU		0x0000		/* 0x64 * fd_t = 0x898 */
5026003Smsmith#define OFFSET_RBD		0x0900		/* 0x64 * ru_t = 0xd7a0 */
5126003Smsmith#define OFFSET_CU		0xe0a0		/* 0x100 */
5226003Smsmith#define OFFSET_TBD		0xe1a0		/* 0x48 * tbd_t = 0x240 */
5326003Smsmith#define OFFSET_TBUF		0xe3e0		/* 0x1bfe */
5426003Smsmith#define OFFSET_SCB		0xffde		/* 0x1 * scb_t = 0x10 */
5526003Smsmith#define OFFSET_ISCP		0xffee		/* 0x1 * iscp_t = 0x8 */
5626003Smsmith#define OFFSET_SCP		0xfff6		/* 0x1 * scp_t = 0xa */
5726003Smsmith
5826003Smsmith/* WaveLAN host interface definitions */
5926003Smsmith
60274758Sjhb#define HACR			0x0	/* Host Adapter Command Register */
61274758Sjhb#define HASR			0x0	/* Host Adapter Status Register */
62274758Sjhb#define MMCR			0x2	/* Modem Management Ctrl Register */
63274758Sjhb#define PIOR0			0x4	/* Program I/O Address Register 0 */
64274758Sjhb#define PIOP0			0x6	/* Program I/O Port 0 */
65274758Sjhb#define PIOR1			0x8	/* Program I/O Address Register 1 */
66274758Sjhb#define PIOP1			0xa	/* Program I/O Port 1 */
67274758Sjhb#define PIOR2			0xc	/* Program I/O Address Register 2 */
68274758Sjhb#define PIOP2			0xe	/* Program I/O Port 2 */
6926003Smsmith
7026003Smsmith/* Program I/O Mode Register values */
7126003Smsmith
7226003Smsmith#define STATIC_PIO		0	/* Mode 1: static mode */
7326003Smsmith#define AUTOINCR_PIO		1	/* Mode 2: auto increment mode */
7426003Smsmith#define AUTODECR_PIO		2	/* Mode 3: auto decrement mode */
7526003Smsmith#define PARAM_ACCESS_PIO	3	/* Mode 4: LAN parameter access mode */
7626003Smsmith#define PIO_MASK		3	/* register mask */
7726003Smsmith#define PIOM(cmd,piono)		((u_short)cmd << 10 << (piono * 2))
7826003Smsmith
7926003Smsmith/* Host Adapter status register definitions */
8026003Smsmith
8126003Smsmith#define HASR_INTR		0x0001	/* Interrupt request from 82586 */
8226003Smsmith#define HASR_MMC_INTR		0x0002	/* Interrupt request from MMC */
8326003Smsmith#define HASR_MMC_BUSY		0x0004	/* MMC busy indication */
8426003Smsmith#define HASR_PARA_BUSY		0x0008	/* LAN parameter storage area busy */
8526003Smsmith
8626003Smsmith/* Host Adapter command register definitions */
8726003Smsmith
8826003Smsmith#define HACR_RESET		0x0001	/* Reset board */
8926003Smsmith#define HACR_CA			0x0002	/* Set Channel Attention for 82586 */
9026003Smsmith#define HACR_16BITS		0x0004	/* 1==16 bits operation, 0==8 bits */
9126003Smsmith#define HACR_OUT1		0x0008	/* General purpose output pin */
9226003Smsmith#define HACR_OUT2		0x0010	/* General purpose output pin */
9326003Smsmith#define HACR_MASK_82586		0x0020	/* Mask 82586 interrupts, 1==unmask */
9426003Smsmith#define HACR_MASK_MMC		0x0040	/* Mask MMC interrupts, 1==unmask */
9526003Smsmith#define HACR_INTR_CLEN		0x0080	/* interrupt status clear enable */
9626003Smsmith
9726003Smsmith#define HACR_DEFAULT	(HACR_OUT1 | HACR_OUT2 | HACR_16BITS | PIOM(STATIC_PIO, 0) | PIOM(AUTOINCR_PIO, 1) | PIOM(PARAM_ACCESS_PIO, 2))
9826003Smsmith#define HACR_INTRON	(HACR_MASK_82586 | HACR_MASK_MMC | HACR_INTR_CLEN)
99274758Sjhb
100274758Sjhb#define	WL_READ_1(sc, reg)	bus_read_1((sc)->res_ioport, (reg))
101274758Sjhb#define	WL_READ_2(sc, reg)	bus_read_2((sc)->res_ioport, (reg))
102274758Sjhb#define	WL_READ_MULTI_2(sc, reg, buf, len)				\
103274758Sjhb	bus_read_multi_2((sc)->res_ioport, (reg), (uint16_t *)(buf), (len))
104274758Sjhb#define	WL_WRITE_1(sc, reg, val)					\
105274758Sjhb	bus_write_1((sc)->res_ioport, (reg), (val))
106274758Sjhb#define	WL_WRITE_2(sc, reg, val)					\
107274758Sjhb	bus_write_2((sc)->res_ioport, (reg), (val))
108274758Sjhb#define	WL_WRITE_MULTI_2(sc, reg, buf, len)				\
109274758Sjhb	bus_write_multi_2((sc)->res_ioport, (reg), (uint16_t *)(buf), (len))
110274758Sjhb
111274758Sjhb#define CMD(sc)	  \
11226003Smsmith		{ \
113274758Sjhb		   WL_WRITE_2(sc, HACR, sc->hacr);		\
11426003Smsmith		   /* delay for 50 us, might only be needed sometimes */ \
11526003Smsmith		   DELAY(DELAYCONST); \
11626003Smsmith	        }
11726003Smsmith
11826003Smsmith/* macro for setting the channel attention bit.  No delays here since
11926003Smsmith * it is used in critical sections
12026003Smsmith */
121113571Sjhay#define SET_CHAN_ATTN(sc)   \
12226003Smsmith      { \
123274758Sjhb         WL_WRITE_2(sc, HACR, sc->hacr | HACR_CA); \
12426003Smsmith      }
12526003Smsmith
12626003Smsmith
12726003Smsmith#define MMC_WRITE(cmd,val)	\
128274758Sjhb	while (WL_READ_2(sc, HASR) & HASR_MMC_BUSY) ;	\
129274758Sjhb	WL_WRITE_2(sc, MMCR,				\
13026003Smsmith	     (u_short)(((u_short)(val) << 8) | ((cmd) << 1) | 1))
13126003Smsmith
13241616Seivind#endif	/* _IF_WL_H */
13326003Smsmith
134