Home | History | Annotate | Line # | Download | only in usb
if_auereg.h revision 1.2
      1  1.2  augustss /*	$NetBSD: if_auereg.h,v 1.2 2000/01/19 00:25:23 augustss Exp $	*/
      2  1.1  augustss /*
      3  1.1  augustss  * Copyright (c) 1997, 1998, 1999
      4  1.1  augustss  *	Bill Paul <wpaul (at) ee.columbia.edu>.  All rights reserved.
      5  1.1  augustss  *
      6  1.1  augustss  * Redistribution and use in source and binary forms, with or without
      7  1.1  augustss  * modification, are permitted provided that the following conditions
      8  1.1  augustss  * are met:
      9  1.1  augustss  * 1. Redistributions of source code must retain the above copyright
     10  1.1  augustss  *    notice, this list of conditions and the following disclaimer.
     11  1.1  augustss  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  augustss  *    notice, this list of conditions and the following disclaimer in the
     13  1.1  augustss  *    documentation and/or other materials provided with the distribution.
     14  1.1  augustss  * 3. All advertising materials mentioning features or use of this software
     15  1.1  augustss  *    must display the following acknowledgement:
     16  1.1  augustss  *	This product includes software developed by Bill Paul.
     17  1.1  augustss  * 4. Neither the name of the author nor the names of any co-contributors
     18  1.1  augustss  *    may be used to endorse or promote products derived from this software
     19  1.1  augustss  *    without specific prior written permission.
     20  1.1  augustss  *
     21  1.1  augustss  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
     22  1.1  augustss  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  1.1  augustss  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  1.1  augustss  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
     25  1.1  augustss  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26  1.1  augustss  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27  1.1  augustss  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28  1.1  augustss  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29  1.1  augustss  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30  1.1  augustss  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     31  1.1  augustss  * THE POSSIBILITY OF SUCH DAMAGE.
     32  1.1  augustss  *
     33  1.1  augustss  * $FreeBSD: src/sys/dev/usb/if_auereg.h,v 1.2 2000/01/08 06:52:36 wpaul Exp $
     34  1.1  augustss  */
     35  1.1  augustss 
     36  1.1  augustss /*
     37  1.1  augustss  * Register definitions for ADMtek Pegasus AN986 USB to Ethernet
     38  1.1  augustss  * chip. The Pegasus uses a total of four USB endpoints: the control
     39  1.1  augustss  * endpoint (0), a bulk read endpoint for receiving packets (1),
     40  1.1  augustss  * a bulk write endpoint for sending packets (2) and an interrupt
     41  1.1  augustss  * endpoint for passing RX and TX status (3). Endpoint 0 is used
     42  1.1  augustss  * to read and write the ethernet module's registers. All registers
     43  1.1  augustss  * are 8 bits wide.
     44  1.1  augustss  *
     45  1.1  augustss  * Packet transfer is done in 64 byte chunks. The last chunk in a
     46  1.1  augustss  * transfer is denoted by having a length less that 64 bytes. For
     47  1.1  augustss  * the RX case, the data includes an optional RX status word.
     48  1.1  augustss  */
     49  1.1  augustss 
     50  1.1  augustss #define AUE_UR_READREG		0xF0
     51  1.1  augustss #define AUE_UR_WRITEREG		0xF1
     52  1.1  augustss 
     53  1.1  augustss #define AUE_CONFIG_NO		1
     54  1.1  augustss #define AUE_IFACE_IDX		0
     55  1.1  augustss 
     56  1.1  augustss /*
     57  1.1  augustss  * Note that while the ADMtek technically has four
     58  1.1  augustss  * endpoints, the control endpoint (endpoint 0) is
     59  1.1  augustss  * regarded as special by the USB code and drivers
     60  1.1  augustss  * don't have direct access to it. (We access it
     61  1.1  augustss  * using usbd_do_request() when reading/writing
     62  1.1  augustss  * registers.) Consequently, our endpoint indexes
     63  1.1  augustss  * don't match those in the ADMtek Pegasus manual:
     64  1.1  augustss  * we consider the RX data endpoint to be index 0
     65  1.1  augustss  * and work up from there.
     66  1.1  augustss  */
     67  1.1  augustss #define AUE_ENDPT_RX		0x0
     68  1.1  augustss #define AUE_ENDPT_TX		0x1
     69  1.1  augustss #define AUE_ENDPT_INTR		0x2
     70  1.1  augustss #define AUE_ENDPT_MAX		0x3
     71  1.1  augustss 
     72  1.1  augustss #define AUE_CTL0		0x00
     73  1.1  augustss #define AUE_CTL1		0x01
     74  1.1  augustss #define AUE_CTL2		0x02
     75  1.1  augustss #define AUE_MAR0		0x08
     76  1.1  augustss #define AUE_MAR1		0x09
     77  1.1  augustss #define AUE_MAR2		0x0A
     78  1.1  augustss #define AUE_MAR3		0x0B
     79  1.1  augustss #define AUE_MAR4		0x0C
     80  1.1  augustss #define AUE_MAR5		0x0D
     81  1.1  augustss #define AUE_MAR6		0x0E
     82  1.1  augustss #define AUE_MAR7		0x0F
     83  1.1  augustss #define AUE_MAR			AUE_MAR0
     84  1.1  augustss #define AUE_PAR0		0x10
     85  1.1  augustss #define AUE_PAR1		0x11
     86  1.1  augustss #define AUE_PAR2		0x12
     87  1.1  augustss #define AUE_PAR3		0x13
     88  1.1  augustss #define AUE_PAR4		0x14
     89  1.1  augustss #define AUE_PAR5		0x15
     90  1.1  augustss #define AUE_PAR			AUE_PAR0
     91  1.1  augustss #define AUE_PAUSE0		0x18
     92  1.1  augustss #define AUE_PAUSE1		0x19
     93  1.1  augustss #define AUE_PAUSE		AUE_PAUSE0
     94  1.1  augustss #define AUE_RX_FLOWCTL_CNT	0x1A
     95  1.1  augustss #define AUE_RX_FLOWCTL_FIFO	0x1B
     96  1.1  augustss #define AUE_EE_REG		0x20
     97  1.1  augustss #define AUE_EE_DATA0		0x21
     98  1.1  augustss #define AUE_EE_DATA1		0x22
     99  1.1  augustss #define AUE_EE_DATA		AUE_EE_DATA0
    100  1.1  augustss #define AUE_EE_CTL		0x23
    101  1.1  augustss #define AUE_PHY_ADDR		0x25
    102  1.1  augustss #define AUE_PHY_DATA0		0x26
    103  1.1  augustss #define AUE_PHY_DATA1		0x27
    104  1.1  augustss #define AUE_PHY_DATA		AUE_PHY_DATA0
    105  1.1  augustss #define AUE_PHY_CTL		0x28
    106  1.1  augustss #define AUE_USB_STS		0x2A
    107  1.1  augustss #define AUE_TXSTAT0		0x2B
    108  1.1  augustss #define AUE_TXSTAT1		0x2C
    109  1.1  augustss #define AUE_TXSTAT		AUE_TXSTAT0
    110  1.1  augustss #define AUE_RXSTAT		0x2D
    111  1.1  augustss #define AUE_PKTLOST0		0x2E
    112  1.1  augustss #define AUE_PKTLOST1		0x2F
    113  1.1  augustss #define AUE_PKTLOST		AUE_PKTLOST0
    114  1.1  augustss 
    115  1.1  augustss #define AUE_GPIO0		0x7E
    116  1.1  augustss #define AUE_GPIO1		0x7F
    117  1.1  augustss 
    118  1.1  augustss #define AUE_CTL0_INCLUDE_RXCRC	0x01
    119  1.1  augustss #define AUE_CTL0_ALLMULTI	0x02
    120  1.1  augustss #define AUE_CTL0_STOP_BACKOFF	0x04
    121  1.1  augustss #define AUE_CTL0_RXSTAT_APPEND	0x08
    122  1.1  augustss #define AUE_CTL0_WAKEON_ENB	0x10
    123  1.1  augustss #define AUE_CTL0_RXPAUSE_ENB	0x20
    124  1.1  augustss #define AUE_CTL0_RX_ENB		0x40
    125  1.1  augustss #define AUE_CTL0_TX_ENB		0x80
    126  1.1  augustss 
    127  1.1  augustss #define AUE_CTL1_HOMELAN	0x04
    128  1.1  augustss #define AUE_CTL1_RESETMAC	0x08
    129  1.1  augustss #define AUE_CTL1_SPEEDSEL	0x10	/* 0 = 10mbps, 1 = 100mbps */
    130  1.1  augustss #define AUE_CTL1_DUPLEX		0x20	/* 0 = half, 1 = full */
    131  1.1  augustss #define AUE_CTL1_DELAYHOME	0x40
    132  1.1  augustss 
    133  1.1  augustss #define AUE_CTL2_EP3_CLR	0x01	/* reading EP3 clrs status regs */
    134  1.1  augustss #define AUE_CTL2_RX_BADFRAMES	0x02
    135  1.1  augustss #define AUE_CTL2_RX_PROMISC	0x04
    136  1.1  augustss #define AUE_CTL2_LOOPBACK	0x08
    137  1.1  augustss #define AUE_CTL2_EEPROMWR_ENB	0x10
    138  1.1  augustss #define AUE_CTL2_EEPROM_LOAD	0x20
    139  1.1  augustss 
    140  1.1  augustss #define AUE_EECTL_WRITE		0x01
    141  1.1  augustss #define AUE_EECTL_READ		0x02
    142  1.1  augustss #define AUE_EECTL_DONE		0x04
    143  1.1  augustss 
    144  1.1  augustss #define AUE_PHYCTL_PHYREG	0x1F
    145  1.1  augustss #define AUE_PHYCTL_WRITE	0x20
    146  1.1  augustss #define AUE_PHYCTL_READ		0x40
    147  1.1  augustss #define AUE_PHYCTL_DONE		0x80
    148  1.1  augustss 
    149  1.1  augustss #define AUE_USBSTS_SUSPEND	0x01
    150  1.1  augustss #define AUE_USBSTS_RESUME	0x02
    151  1.1  augustss 
    152  1.1  augustss #define AUE_TXSTAT0_JABTIMO	0x04
    153  1.1  augustss #define AUE_TXSTAT0_CARLOSS	0x08
    154  1.1  augustss #define AUE_TXSTAT0_NOCARRIER	0x10
    155  1.1  augustss #define AUE_TXSTAT0_LATECOLL	0x20
    156  1.1  augustss #define AUE_TXSTAT0_EXCESSCOLL	0x40
    157  1.1  augustss #define AUE_TXSTAT0_UNDERRUN	0x80
    158  1.1  augustss 
    159  1.1  augustss #define AUE_TXSTAT1_PKTCNT	0x0F
    160  1.1  augustss #define AUE_TXSTAT1_FIFO_EMPTY	0x40
    161  1.1  augustss #define AUE_TXSTAT1_FIFO_FULL	0x80
    162  1.1  augustss 
    163  1.1  augustss #define AUE_RXSTAT_OVERRUN	0x01
    164  1.1  augustss #define AUE_RXSTAT_PAUSE	0x02
    165  1.1  augustss 
    166  1.1  augustss #define AUE_GPIO_IN0		0x01
    167  1.1  augustss #define AUE_GPIO_OUT0		0x02
    168  1.1  augustss #define AUE_GPIO_SEL0		0x04
    169  1.1  augustss #define AUE_GPIO_IN1		0x08
    170  1.1  augustss #define AUE_GPIO_OUT1		0x10
    171  1.1  augustss #define AUE_GPIO_SEL1		0x20
    172  1.1  augustss 
    173  1.1  augustss struct aue_intrpkt {
    174  1.1  augustss 	u_int8_t		aue_txstat0;
    175  1.1  augustss 	u_int8_t		aue_txstat1;
    176  1.1  augustss 	u_int8_t		aue_rxstat;
    177  1.1  augustss 	u_int8_t		aue_rxlostpkt0;
    178  1.1  augustss 	u_int8_t		aue_rxlostpkt1;
    179  1.1  augustss 	u_int8_t		aue_wakeupstat;
    180  1.1  augustss 	u_int8_t		aue_rsvd;
    181  1.1  augustss 	u_int8_t		_pad;
    182  1.1  augustss };
    183  1.1  augustss #define AUE_INTR_PKTLEN 8
    184  1.1  augustss 
    185  1.1  augustss struct aue_rxpkt {
    186  1.1  augustss 	uWord			aue_pktlen;
    187  1.1  augustss 	uByte			aue_rxstat;
    188  1.1  augustss };
    189  1.1  augustss 
    190  1.1  augustss #define AUE_RXSTAT_MCAST	0x01
    191  1.1  augustss #define AUE_RXSTAT_GIANT	0x02
    192  1.1  augustss #define AUE_RXSTAT_RUNT		0x04
    193  1.1  augustss #define AUE_RXSTAT_CRCERR	0x08
    194  1.1  augustss #define AUE_RXSTAT_DRIBBLE	0x10
    195  1.1  augustss #define AUE_RXSTAT_MASK		0x1E
    196  1.1  augustss 
    197  1.1  augustss 
    198  1.1  augustss /*************** The rest belongs in if_auevar.h *************/
    199  1.1  augustss 
    200  1.1  augustss struct aue_type {
    201  1.1  augustss 	u_int16_t		aue_vid;
    202  1.1  augustss 	u_int16_t		aue_did;
    203  1.1  augustss };
    204  1.1  augustss 
    205  1.1  augustss #define AUE_TX_LIST_CNT		1
    206  1.1  augustss #define AUE_RX_LIST_CNT		1
    207  1.1  augustss 
    208  1.1  augustss struct aue_softc;
    209  1.1  augustss 
    210  1.1  augustss struct aue_chain {
    211  1.1  augustss 	struct aue_softc	*aue_sc;
    212  1.1  augustss 	usbd_xfer_handle	aue_xfer;
    213  1.1  augustss 	char			*aue_buf;
    214  1.1  augustss 	struct mbuf		*aue_mbuf;
    215  1.1  augustss 	int			aue_accum;
    216  1.1  augustss 	int			aue_idx;
    217  1.1  augustss };
    218  1.1  augustss 
    219  1.1  augustss struct aue_cdata {
    220  1.1  augustss 	struct aue_chain	aue_tx_chain[AUE_TX_LIST_CNT];
    221  1.1  augustss 	struct aue_chain	aue_rx_chain[AUE_RX_LIST_CNT];
    222  1.1  augustss 	struct aue_intrpkt	aue_ibuf;
    223  1.1  augustss 	int			aue_tx_prod;
    224  1.1  augustss 	int			aue_tx_cons;
    225  1.1  augustss 	int			aue_tx_cnt;
    226  1.1  augustss 	int			aue_rx_prod;
    227  1.1  augustss };
    228  1.1  augustss 
    229  1.1  augustss #define AUE_INC(x, y)		(x) = (x + 1) % y
    230  1.1  augustss 
    231  1.1  augustss struct aue_softc {
    232  1.1  augustss 	USBBASEDEVICE		aue_dev;
    233  1.1  augustss 
    234  1.1  augustss #if defined(__FreeBSD__)
    235  1.1  augustss 	struct arpcom		arpcom;
    236  1.1  augustss 	device_t		aue_miibus;
    237  1.1  augustss 	struct callout_handle	aue_stat_ch;
    238  1.1  augustss #define GET_IFP(sc) (&(sc)->arpcom.ac_if)
    239  1.1  augustss #define GET_MII(sc) (device_get_softc((sc)->aue_miibus))
    240  1.1  augustss #elif defined(__NetBSD__)
    241  1.1  augustss 	struct ethercom		aue_ec;
    242  1.1  augustss 	struct mii_data		aue_mii;
    243  1.1  augustss 	char			aue_dying;
    244  1.1  augustss #define GET_IFP(sc) (&(sc)->aue_ec.ec_if)
    245  1.1  augustss #define GET_MII(sc) (&(sc)->aue_mii)
    246  1.1  augustss #endif
    247  1.1  augustss 
    248  1.1  augustss 	usbd_device_handle	aue_udev;
    249  1.1  augustss 	usbd_interface_handle	aue_iface;
    250  1.1  augustss 	u_int16_t		aue_vendor;
    251  1.1  augustss 	u_int16_t		aue_product;
    252  1.1  augustss 	int			aue_ed[AUE_ENDPT_MAX];
    253  1.1  augustss 	usbd_pipe_handle	aue_ep[AUE_ENDPT_MAX];
    254  1.1  augustss 	u_int8_t		aue_link;
    255  1.1  augustss 	int			aue_if_flags;
    256  1.1  augustss 	struct aue_cdata	aue_cdata;
    257  1.1  augustss };
    258  1.1  augustss 
    259  1.1  augustss #define AUE_TIMEOUT		1000
    260  1.1  augustss #define ETHER_ALIGN		2
    261  1.1  augustss #define AUE_BUFSZ		1536
    262  1.1  augustss #define AUE_CUTOFF		1088
    263  1.1  augustss //#define AUE_CUTOFF		1536
    264  1.1  augustss #define AUE_MIN_FRAMELEN	60
    265  1.1  augustss #define AUE_TX_TIMEOUT		10000 /* ms */
    266  1.2  augustss #define AUE_INTR_INTERVAL	100 /* ms */
    267