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