Home | History | Annotate | Line # | Download | only in ic
rtl81x9var.h revision 1.8
      1 /*	$NetBSD: rtl81x9var.h,v 1.8 2001/02/02 03:51:51 thorpej 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 RTK_ETHER_ALIGN	2
     38 #define RTK_RXSTAT_LEN	4
     39 
     40 struct rtk_chain_data {
     41 	struct mbuf		*rtk_tx_chain[RTK_TX_LIST_CNT];
     42 	int			last_tx;
     43 	int			cur_tx;
     44 };
     45 
     46 #define RTK_INC(x)		(x = (x + 1) % RTK_TX_LIST_CNT)
     47 #define RTK_CUR_TXADDR(x)	((x->rtk_cdata.cur_tx * 4) + RTK_TXADDR0)
     48 #define RTK_CUR_TXSTAT(x)	((x->rtk_cdata.cur_tx * 4) + RTK_TXSTAT0)
     49 #define RTK_CUR_TXMBUF(x)	(x->rtk_cdata.rtk_tx_chain[x->rtk_cdata.cur_tx])
     50 #define RTK_LAST_TXADDR(x)	((x->rtk_cdata.last_tx * 4) + RTK_TXADDR0)
     51 #define RTK_LAST_TXSTAT(x)	((x->rtk_cdata.last_tx * 4) + RTK_TXSTAT0)
     52 #define RTK_LAST_TXMBUF(x)	(x->rtk_cdata.rtk_tx_chain[x->rtk_cdata.last_tx])
     53 
     54 struct rtk_type {
     55 	u_int16_t		rtk_vid;
     56 	u_int16_t		rtk_did;
     57 	const char		*rtk_name;
     58 	int			rtk_type;
     59 };
     60 
     61 struct rtk_mii_frame {
     62 	u_int8_t		mii_stdelim;
     63 	u_int8_t		mii_opcode;
     64 	u_int8_t		mii_phyaddr;
     65 	u_int8_t		mii_regaddr;
     66 	u_int8_t		mii_turnaround;
     67 	u_int16_t		mii_data;
     68 };
     69 
     70 /*
     71  * MII constants
     72  */
     73 #define RTK_MII_STARTDELIM	0x01
     74 #define RTK_MII_READOP		0x02
     75 #define RTK_MII_WRITEOP		0x01
     76 #define RTK_MII_TURNAROUND	0x02
     77 
     78 #define RTK_8129		1
     79 #define RTK_8139		2
     80 
     81 struct rtk_softc {
     82 	struct device sc_dev;		/* generic device structures */
     83 	struct ethercom		ethercom;	/* interface info */
     84 	struct mii_data		mii;
     85 	struct callout		rtk_tick_ch;	/* tick callout */
     86 	bus_space_handle_t	rtk_bhandle;	/* bus space handle */
     87 	bus_space_tag_t		rtk_btag;	/* bus space tag */
     88 	int			rtk_type;
     89 	bus_dma_tag_t 		sc_dmat;
     90 	bus_dma_segment_t 	sc_dmaseg;
     91 	int			sc_dmanseg;
     92 
     93 	bus_dmamap_t 		recv_dmamap;
     94 	caddr_t			rtk_rx_buf;
     95 
     96 	struct rtk_chain_data	rtk_cdata;
     97 	bus_dmamap_t		snd_dmamap[RTK_TX_LIST_CNT];
     98 
     99 	int			sc_flags;	/* misc flags */
    100 	void	*sc_sdhook;			/* shutdown hook */
    101 	void	*sc_powerhook;			/* power management hook */
    102 
    103 	/* Power management hooks. */
    104 	int	(*sc_enable)	__P((struct rtk_softc *));
    105 	void	(*sc_disable)	__P((struct rtk_softc *));
    106 	void	(*sc_power)	__P((struct rtk_softc *, int));
    107 };
    108 
    109 #define RTK_ATTACHED 0x00000001 /* attach has succeeded */
    110 #define RTK_ENABLED  0x00000002 /* chip is enabled	*/
    111 
    112 #define RTK_IS_ENABLED(sc)	((sc)->sc_flags & RTK_ENABLED)
    113 /*
    114  * register space access macros
    115  */
    116 #define CSR_WRITE_4(sc, reg, val)	\
    117 	bus_space_write_4(sc->rtk_btag, sc->rtk_bhandle, reg, val)
    118 #define CSR_WRITE_2(sc, reg, val)	\
    119 	bus_space_write_2(sc->rtk_btag, sc->rtk_bhandle, reg, val)
    120 #define CSR_WRITE_1(sc, reg, val)	\
    121 	bus_space_write_1(sc->rtk_btag, sc->rtk_bhandle, reg, val)
    122 
    123 #define CSR_READ_4(sc, reg)		\
    124 	bus_space_read_4(sc->rtk_btag, sc->rtk_bhandle, reg)
    125 #define CSR_READ_2(sc, reg)		\
    126 	bus_space_read_2(sc->rtk_btag, sc->rtk_bhandle, reg)
    127 #define CSR_READ_1(sc, reg)		\
    128 	bus_space_read_1(sc->rtk_btag, sc->rtk_bhandle, reg)
    129 
    130 #define RTK_TIMEOUT		1000
    131 
    132 /*
    133  * PCI low memory base and low I/O base register, and
    134  * other PCI registers.
    135  */
    136 
    137 #define RTK_PCI_LOIO		0x10
    138 #define RTK_PCI_LOMEM		0x14
    139 
    140 #define RTK_PSTATE_MASK		0x0003
    141 #define RTK_PSTATE_D0		0x0000
    142 #define RTK_PSTATE_D1		0x0002
    143 #define RTK_PSTATE_D2		0x0002
    144 #define RTK_PSTATE_D3		0x0003
    145 #define RTK_PME_EN		0x0010
    146 #define RTK_PME_STATUS		0x8000
    147 
    148 #ifdef _KERNEL
    149 void	rtk_attach	__P((struct rtk_softc *));
    150 int	rtk_detach	__P((struct rtk_softc *));
    151 int	rtk_activate	__P((struct device *, enum devact));
    152 int	rtk_intr	__P((void *));
    153 #endif /* _KERNEL */
    154