Home | History | Annotate | Line # | Download | only in usb
if_auereg.h revision 1.17.4.1
      1  1.17.4.1    bouyer /*	$NetBSD: if_auereg.h,v 1.17.4.1 2008/01/21 20:43:34 bouyer 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.15  augustss #define AUE_REG_1D		0x1D
     97       1.1  augustss #define AUE_EE_REG		0x20
     98       1.1  augustss #define AUE_EE_DATA0		0x21
     99       1.1  augustss #define AUE_EE_DATA1		0x22
    100       1.1  augustss #define AUE_EE_DATA		AUE_EE_DATA0
    101       1.1  augustss #define AUE_EE_CTL		0x23
    102       1.1  augustss #define AUE_PHY_ADDR		0x25
    103       1.1  augustss #define AUE_PHY_DATA0		0x26
    104       1.1  augustss #define AUE_PHY_DATA1		0x27
    105       1.1  augustss #define AUE_PHY_DATA		AUE_PHY_DATA0
    106       1.1  augustss #define AUE_PHY_CTL		0x28
    107       1.1  augustss #define AUE_USB_STS		0x2A
    108       1.1  augustss #define AUE_TXSTAT0		0x2B
    109       1.1  augustss #define AUE_TXSTAT1		0x2C
    110       1.1  augustss #define AUE_TXSTAT		AUE_TXSTAT0
    111       1.1  augustss #define AUE_RXSTAT		0x2D
    112       1.1  augustss #define AUE_PKTLOST0		0x2E
    113       1.1  augustss #define AUE_PKTLOST1		0x2F
    114       1.1  augustss #define AUE_PKTLOST		AUE_PKTLOST0
    115       1.1  augustss 
    116      1.15  augustss #define AUE_REG_7B		0x7B
    117       1.1  augustss #define AUE_GPIO0		0x7E
    118       1.1  augustss #define AUE_GPIO1		0x7F
    119      1.15  augustss #define AUE_REG_81		0x81
    120       1.1  augustss 
    121       1.1  augustss #define AUE_CTL0_INCLUDE_RXCRC	0x01
    122       1.1  augustss #define AUE_CTL0_ALLMULTI	0x02
    123       1.1  augustss #define AUE_CTL0_STOP_BACKOFF	0x04
    124       1.1  augustss #define AUE_CTL0_RXSTAT_APPEND	0x08
    125       1.1  augustss #define AUE_CTL0_WAKEON_ENB	0x10
    126       1.1  augustss #define AUE_CTL0_RXPAUSE_ENB	0x20
    127       1.1  augustss #define AUE_CTL0_RX_ENB		0x40
    128       1.1  augustss #define AUE_CTL0_TX_ENB		0x80
    129       1.1  augustss 
    130       1.1  augustss #define AUE_CTL1_HOMELAN	0x04
    131       1.1  augustss #define AUE_CTL1_RESETMAC	0x08
    132       1.1  augustss #define AUE_CTL1_SPEEDSEL	0x10	/* 0 = 10mbps, 1 = 100mbps */
    133       1.1  augustss #define AUE_CTL1_DUPLEX		0x20	/* 0 = half, 1 = full */
    134       1.1  augustss #define AUE_CTL1_DELAYHOME	0x40
    135       1.1  augustss 
    136       1.1  augustss #define AUE_CTL2_EP3_CLR	0x01	/* reading EP3 clrs status regs */
    137       1.1  augustss #define AUE_CTL2_RX_BADFRAMES	0x02
    138       1.1  augustss #define AUE_CTL2_RX_PROMISC	0x04
    139       1.1  augustss #define AUE_CTL2_LOOPBACK	0x08
    140       1.1  augustss #define AUE_CTL2_EEPROMWR_ENB	0x10
    141       1.1  augustss #define AUE_CTL2_EEPROM_LOAD	0x20
    142       1.1  augustss 
    143       1.1  augustss #define AUE_EECTL_WRITE		0x01
    144       1.1  augustss #define AUE_EECTL_READ		0x02
    145       1.1  augustss #define AUE_EECTL_DONE		0x04
    146       1.1  augustss 
    147       1.1  augustss #define AUE_PHYCTL_PHYREG	0x1F
    148       1.1  augustss #define AUE_PHYCTL_WRITE	0x20
    149       1.1  augustss #define AUE_PHYCTL_READ		0x40
    150       1.1  augustss #define AUE_PHYCTL_DONE		0x80
    151       1.1  augustss 
    152       1.1  augustss #define AUE_USBSTS_SUSPEND	0x01
    153       1.1  augustss #define AUE_USBSTS_RESUME	0x02
    154       1.1  augustss 
    155       1.1  augustss #define AUE_TXSTAT0_JABTIMO	0x04
    156       1.1  augustss #define AUE_TXSTAT0_CARLOSS	0x08
    157       1.1  augustss #define AUE_TXSTAT0_NOCARRIER	0x10
    158       1.1  augustss #define AUE_TXSTAT0_LATECOLL	0x20
    159       1.1  augustss #define AUE_TXSTAT0_EXCESSCOLL	0x40
    160       1.1  augustss #define AUE_TXSTAT0_UNDERRUN	0x80
    161       1.1  augustss 
    162       1.1  augustss #define AUE_TXSTAT1_PKTCNT	0x0F
    163       1.1  augustss #define AUE_TXSTAT1_FIFO_EMPTY	0x40
    164       1.1  augustss #define AUE_TXSTAT1_FIFO_FULL	0x80
    165       1.1  augustss 
    166       1.1  augustss #define AUE_RXSTAT_OVERRUN	0x01
    167       1.1  augustss #define AUE_RXSTAT_PAUSE	0x02
    168       1.1  augustss 
    169       1.1  augustss #define AUE_GPIO_IN0		0x01
    170       1.1  augustss #define AUE_GPIO_OUT0		0x02
    171       1.1  augustss #define AUE_GPIO_SEL0		0x04
    172       1.1  augustss #define AUE_GPIO_IN1		0x08
    173       1.1  augustss #define AUE_GPIO_OUT1		0x10
    174       1.1  augustss #define AUE_GPIO_SEL1		0x20
    175       1.1  augustss 
    176       1.1  augustss struct aue_intrpkt {
    177       1.1  augustss 	u_int8_t		aue_txstat0;
    178       1.1  augustss 	u_int8_t		aue_txstat1;
    179       1.1  augustss 	u_int8_t		aue_rxstat;
    180       1.1  augustss 	u_int8_t		aue_rxlostpkt0;
    181       1.1  augustss 	u_int8_t		aue_rxlostpkt1;
    182       1.1  augustss 	u_int8_t		aue_wakeupstat;
    183       1.1  augustss 	u_int8_t		aue_rsvd;
    184       1.1  augustss 	u_int8_t		_pad;
    185       1.1  augustss };
    186       1.1  augustss #define AUE_INTR_PKTLEN 8
    187       1.1  augustss 
    188       1.1  augustss struct aue_rxpkt {
    189       1.1  augustss 	uWord			aue_pktlen;
    190       1.1  augustss 	uByte			aue_rxstat;
    191       1.1  augustss };
    192       1.1  augustss 
    193       1.1  augustss #define AUE_RXSTAT_MCAST	0x01
    194       1.1  augustss #define AUE_RXSTAT_GIANT	0x02
    195       1.1  augustss #define AUE_RXSTAT_RUNT		0x04
    196       1.1  augustss #define AUE_RXSTAT_CRCERR	0x08
    197       1.1  augustss #define AUE_RXSTAT_DRIBBLE	0x10
    198       1.1  augustss #define AUE_RXSTAT_MASK		0x1E
    199       1.1  augustss 
    200       1.1  augustss 
    201       1.1  augustss /*************** The rest belongs in if_auevar.h *************/
    202       1.1  augustss 
    203       1.1  augustss #define AUE_TX_LIST_CNT		1
    204       1.1  augustss #define AUE_RX_LIST_CNT		1
    205       1.1  augustss 
    206       1.1  augustss struct aue_softc;
    207       1.1  augustss 
    208       1.1  augustss struct aue_chain {
    209       1.1  augustss 	struct aue_softc	*aue_sc;
    210       1.1  augustss 	usbd_xfer_handle	aue_xfer;
    211       1.1  augustss 	char			*aue_buf;
    212       1.1  augustss 	struct mbuf		*aue_mbuf;
    213       1.1  augustss 	int			aue_idx;
    214       1.1  augustss };
    215       1.1  augustss 
    216       1.1  augustss struct aue_cdata {
    217       1.1  augustss 	struct aue_chain	aue_tx_chain[AUE_TX_LIST_CNT];
    218       1.1  augustss 	struct aue_chain	aue_rx_chain[AUE_RX_LIST_CNT];
    219       1.1  augustss 	struct aue_intrpkt	aue_ibuf;
    220       1.1  augustss 	int			aue_tx_prod;
    221       1.1  augustss 	int			aue_tx_cons;
    222       1.1  augustss 	int			aue_tx_cnt;
    223       1.1  augustss 	int			aue_rx_prod;
    224       1.1  augustss };
    225       1.1  augustss 
    226       1.1  augustss struct aue_softc {
    227       1.1  augustss 	USBBASEDEVICE		aue_dev;
    228       1.1  augustss 
    229       1.1  augustss #if defined(__FreeBSD__)
    230       1.1  augustss 	struct arpcom		arpcom;
    231       1.1  augustss 	device_t		aue_miibus;
    232       1.1  augustss #define GET_IFP(sc) (&(sc)->arpcom.ac_if)
    233       1.1  augustss #define GET_MII(sc) (device_get_softc((sc)->aue_miibus))
    234       1.1  augustss #elif defined(__NetBSD__)
    235       1.1  augustss 	struct ethercom		aue_ec;
    236       1.1  augustss 	struct mii_data		aue_mii;
    237       1.4  augustss #if NRND > 0
    238       1.4  augustss 	rndsource_element_t	rnd_source;
    239       1.4  augustss #endif
    240  1.17.4.1    bouyer 	struct proc		*aue_thread;
    241  1.17.4.1    bouyer 	int			aue_closing;
    242       1.1  augustss #define GET_IFP(sc) (&(sc)->aue_ec.ec_if)
    243       1.1  augustss #define GET_MII(sc) (&(sc)->aue_mii)
    244      1.10  augustss #elif defined(__OpenBSD__)
    245      1.10  augustss 	struct arpcom		arpcom;
    246      1.10  augustss 	struct mii_data		aue_mii;
    247      1.10  augustss #if NRND > 0
    248      1.10  augustss 	rndsource_element_t	rnd_source;
    249      1.10  augustss #endif
    250      1.10  augustss #define GET_IFP(sc) (&(sc)->arpcom.ac_if)
    251      1.11  augustss #define GET_MII(sc) (&(sc)->aue_mii)
    252       1.1  augustss #endif
    253       1.8  augustss 
    254       1.8  augustss 	usb_callout_t		aue_stat_ch;
    255       1.1  augustss 
    256       1.1  augustss 	usbd_device_handle	aue_udev;
    257       1.1  augustss 	usbd_interface_handle	aue_iface;
    258       1.1  augustss 	u_int16_t		aue_vendor;
    259       1.1  augustss 	u_int16_t		aue_product;
    260       1.1  augustss 	int			aue_ed[AUE_ENDPT_MAX];
    261       1.1  augustss 	usbd_pipe_handle	aue_ep[AUE_ENDPT_MAX];
    262       1.1  augustss 	u_int8_t		aue_link;
    263       1.1  augustss 	int			aue_if_flags;
    264       1.1  augustss 	struct aue_cdata	aue_cdata;
    265      1.13  augustss 
    266      1.15  augustss 	u_int16_t		aue_flags;
    267       1.4  augustss 
    268      1.16  augustss 	int			aue_refcnt;
    269       1.4  augustss 	char			aue_dying;
    270       1.5  augustss 	char			aue_attached;
    271       1.6  augustss 	u_int			aue_rx_errs;
    272      1.12  augustss 	u_int			aue_intr_errs;
    273       1.6  augustss 	struct timeval		aue_rx_notice;
    274      1.14  augustss 
    275      1.14  augustss 	struct usb_task		aue_tick_task;
    276      1.14  augustss 	struct usb_task		aue_stop_task;
    277      1.14  augustss 
    278      1.14  augustss 	struct lock		aue_mii_lock;
    279      1.16  augustss 
    280       1.1  augustss };
    281       1.1  augustss 
    282       1.1  augustss #define AUE_TIMEOUT		1000
    283       1.1  augustss #define ETHER_ALIGN		2
    284       1.1  augustss #define AUE_BUFSZ		1536
    285       1.1  augustss #define AUE_MIN_FRAMELEN	60
    286       1.1  augustss #define AUE_TX_TIMEOUT		10000 /* ms */
    287       1.2  augustss #define AUE_INTR_INTERVAL	100 /* ms */
    288