xref: /netbsd-src/sys/dev/pci/if_tlvar.h (revision 3b435a73967be44dfb4a27315acd72bfacde430c)
1 /*	$NetBSD: if_tlvar.h,v 1.3 1999/01/11 22:45:42 tron Exp $	*/
2 
3 /*
4  * Copyright (c) 1997 Manuel Bouyer.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *  This product includes software developed by Manuel Bouyer.
17  * 4. The name of the author may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /*
33  * Texas Instruments ThunderLAN ethernet controller
34  * ThunderLAN Programmer's Guide (TI Literature Number SPWU013A)
35  * available from www.ti.com
36  */
37 
38 struct tl_product_desc {
39 	u_int32_t tp_product;
40 	int tp_tlphymedia;
41 	const char *tp_desc;
42 };
43 
44 struct tl_softc {
45 	struct device sc_dev;		/* base device */
46 	bus_space_tag_t tl_bustag;
47 	bus_space_handle_t tl_bushandle; /* CSR region handle */
48 	const struct tl_product_desc *tl_product;
49 	void* tl_ih;
50 	struct ethercom tl_ec;
51 	u_int8_t tl_enaddr[ETHER_ADDR_LEN];	/* hardware adress */
52 	u_int16_t tl_flags;
53 #define TL_IFACT 0x0001 /* chip has interface activity */
54 	u_int8_t tl_lasttx; /* we were without input this many seconds */
55 	i2c_adapter_t i2cbus;		/* i2c bus, for eeprom */
56 	mii_data_t tl_mii;		/* mii bus */
57 	struct Rx_list *Rx_list;	/* Receive and transmit lists */
58 	struct Tx_list *Tx_list;
59 	struct Rx_list *active_Rx, *last_Rx;
60 	struct Tx_list *active_Tx, *last_Tx;
61 	struct Tx_list *Free_Tx;
62 	int opkt;		/* used to detect link up/down for AUI/BNC */
63 	int stats_exesscoll;	/* idem */
64 #ifdef TL_PRIV_STATS
65 	int ierr_overr;
66 	int ierr_code;
67 	int ierr_crc;
68 	int ierr_nomem;
69 	int oerr_underr;
70 	int oerr_deffered;
71 	int oerr_coll;
72 	int oerr_multicoll;
73 	int oerr_latecoll;
74 	int oerr_exesscoll;
75 	int oerr_carrloss;
76 	int oerr_mcopy;
77 #endif
78 };
79 #define tl_if            tl_ec.ec_if
80 #define tl_bpf   tl_if.if_bpf
81 
82 typedef struct tl_softc tl_softc_t;
83 typedef u_long ioctl_cmd_t;
84 
85 #define TL_HR_READ(sc, reg) \
86 	bus_space_read_4(sc->tl_bustag, sc->tl_bushandle, (reg))
87 #define TL_HR_READ_BYTE(sc, reg) \
88 	bus_space_read_1(sc->tl_bustag, sc->tl_bushandle, (reg))
89 #define TL_HR_WRITE(sc, reg, data) \
90 	bus_space_write_4(sc->tl_bustag, sc->tl_bushandle, (reg), (data))
91 #define TL_HR_WRITE_BYTE(sc, reg, data) \
92 	bus_space_write_1(sc->tl_bustag, sc->tl_bushandle, (reg), (data))
93 #define ETHER_MIN_TX (ETHERMIN + sizeof(struct ether_header))
94