Home | History | Annotate | Line # | Download | only in ic
rtl81x9var.h revision 1.1
      1 /*	$NetBSD: rtl81x9var.h,v 1.1 2000/04/26 14:02:35 tsutsui Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1997, 1998
      5  *	Bill Paul <wpaul (at) ctr.columbia.edu>.  All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     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.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by Bill Paul.
     18  * 4. Neither the name of the author nor the names of any co-contributors
     19  *    may be used to endorse or promote products derived from this software
     20  *    without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
     23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
     26  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     32  * THE POSSIBILITY OF SUCH DAMAGE.
     33  *
     34  *	FreeBSD Id: if_rlreg.h,v 1.9 1999/06/20 18:56:09 wpaul Exp
     35  */
     36 
     37 #define RL_ETHER_ALIGN	2
     38 
     39 struct rl_chain_data {
     40 	u_int16_t		cur_rx;
     41 	caddr_t			rl_rx_buf;
     42 	caddr_t			rl_rx_buf_ptr;
     43 
     44 	struct mbuf		*rl_tx_chain[RL_TX_LIST_CNT];
     45 	u_int8_t		last_tx;
     46 	u_int8_t		cur_tx;
     47 };
     48 
     49 #define RL_INC(x)		(x = (x + 1) % RL_TX_LIST_CNT)
     50 #define RL_CUR_TXADDR(x)	((x->rl_cdata.cur_tx * 4) + RL_TXADDR0)
     51 #define RL_CUR_TXSTAT(x)	((x->rl_cdata.cur_tx * 4) + RL_TXSTAT0)
     52 #define RL_CUR_TXMBUF(x)	(x->rl_cdata.rl_tx_chain[x->rl_cdata.cur_tx])
     53 #define RL_LAST_TXADDR(x)	((x->rl_cdata.last_tx * 4) + RL_TXADDR0)
     54 #define RL_LAST_TXSTAT(x)	((x->rl_cdata.last_tx * 4) + RL_TXSTAT0)
     55 #define RL_LAST_TXMBUF(x)	(x->rl_cdata.rl_tx_chain[x->rl_cdata.last_tx])
     56 
     57 struct rl_type {
     58 	u_int16_t		rl_vid;
     59 	u_int16_t		rl_did;
     60 	char			*rl_name;
     61 };
     62 
     63 struct rl_mii_frame {
     64 	u_int8_t		mii_stdelim;
     65 	u_int8_t		mii_opcode;
     66 	u_int8_t		mii_phyaddr;
     67 	u_int8_t		mii_regaddr;
     68 	u_int8_t		mii_turnaround;
     69 	u_int16_t		mii_data;
     70 };
     71 
     72 /*
     73  * MII constants
     74  */
     75 #define RL_MII_STARTDELIM	0x01
     76 #define RL_MII_READOP		0x02
     77 #define RL_MII_WRITEOP		0x01
     78 #define RL_MII_TURNAROUND	0x02
     79 
     80 #define RL_8129			1
     81 #define RL_8139			2
     82 
     83 struct rl_softc {
     84 	struct device sc_dev;		/* generic device structures */
     85 	struct ethercom		ethercom;		/* interface info */
     86 	struct mii_data		mii;
     87 	struct callout		rl_tick_ch;	/* tick callout */
     88 	bus_space_handle_t	rl_bhandle;	/* bus space handle */
     89 	bus_space_tag_t		rl_btag;	/* bus space tag */
     90 	u_int8_t		rl_type;
     91 	struct rl_chain_data	rl_cdata;
     92 	void *sc_ih;
     93 	bus_dma_tag_t sc_dmat;
     94 	bus_dmamap_t recv_dmamap, snd_dmamap[RL_TX_LIST_CNT];
     95 };
     96 
     97 /*
     98  * register space access macros
     99  */
    100 #define CSR_WRITE_4(sc, reg, val)	\
    101 	bus_space_write_4(sc->rl_btag, sc->rl_bhandle, reg, val)
    102 #define CSR_WRITE_2(sc, reg, val)	\
    103 	bus_space_write_2(sc->rl_btag, sc->rl_bhandle, reg, val)
    104 #define CSR_WRITE_1(sc, reg, val)	\
    105 	bus_space_write_1(sc->rl_btag, sc->rl_bhandle, reg, val)
    106 
    107 #define CSR_READ_4(sc, reg)		\
    108 	bus_space_read_4(sc->rl_btag, sc->rl_bhandle, reg)
    109 #define CSR_READ_2(sc, reg)		\
    110 	bus_space_read_2(sc->rl_btag, sc->rl_bhandle, reg)
    111 #define CSR_READ_1(sc, reg)		\
    112 	bus_space_read_1(sc->rl_btag, sc->rl_bhandle, reg)
    113 
    114 #define RL_TIMEOUT		1000
    115 
    116 /*
    117  * PCI low memory base and low I/O base register, and
    118  * other PCI registers.
    119  */
    120 
    121 #define RL_PCI_LOIO		0x10
    122 #define RL_PCI_LOMEM		0x14
    123 
    124 #define RL_PSTATE_MASK		0x0003
    125 #define RL_PSTATE_D0		0x0000
    126 #define RL_PSTATE_D1		0x0002
    127 #define RL_PSTATE_D2		0x0002
    128 #define RL_PSTATE_D3		0x0003
    129 #define RL_PME_EN		0x0010
    130 #define RL_PME_STATUS		0x8000
    131 
    132 #ifdef _KERNEL
    133 void	rl_attach	__P((struct rl_softc *, const u_int8_t *));
    134 int	rl_intr		__P((void *));
    135 void	rl_read_eeprom	__P((struct rl_softc *, caddr_t, int, int, int));
    136 void	rl_reset	__P((struct rl_softc *));
    137 #endif /* _KERNEL */
    138