Home | History | Annotate | Line # | Download | only in usb
if_auereg.h revision 1.25.24.3
      1  1.25.24.3     skrll /*	$NetBSD: if_auereg.h,v 1.25.24.3 2015/06/06 14:40:13 skrll 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.25.24.3     skrll #include <sys/rndsource.h>
     51  1.25.24.3     skrll 
     52        1.1  augustss #define AUE_UR_READREG		0xF0
     53        1.1  augustss #define AUE_UR_WRITEREG		0xF1
     54        1.1  augustss 
     55        1.1  augustss #define AUE_CONFIG_NO		1
     56        1.1  augustss #define AUE_IFACE_IDX		0
     57        1.1  augustss 
     58        1.1  augustss /*
     59        1.1  augustss  * Note that while the ADMtek technically has four
     60        1.1  augustss  * endpoints, the control endpoint (endpoint 0) is
     61        1.1  augustss  * regarded as special by the USB code and drivers
     62        1.1  augustss  * don't have direct access to it. (We access it
     63        1.1  augustss  * using usbd_do_request() when reading/writing
     64        1.1  augustss  * registers.) Consequently, our endpoint indexes
     65        1.1  augustss  * don't match those in the ADMtek Pegasus manual:
     66        1.1  augustss  * we consider the RX data endpoint to be index 0
     67        1.1  augustss  * and work up from there.
     68        1.1  augustss  */
     69        1.1  augustss #define AUE_ENDPT_RX		0x0
     70        1.1  augustss #define AUE_ENDPT_TX		0x1
     71        1.1  augustss #define AUE_ENDPT_INTR		0x2
     72        1.1  augustss #define AUE_ENDPT_MAX		0x3
     73        1.1  augustss 
     74        1.1  augustss #define AUE_CTL0		0x00
     75        1.1  augustss #define AUE_CTL1		0x01
     76        1.1  augustss #define AUE_CTL2		0x02
     77        1.1  augustss #define AUE_MAR0		0x08
     78        1.1  augustss #define AUE_MAR1		0x09
     79        1.1  augustss #define AUE_MAR2		0x0A
     80        1.1  augustss #define AUE_MAR3		0x0B
     81        1.1  augustss #define AUE_MAR4		0x0C
     82        1.1  augustss #define AUE_MAR5		0x0D
     83        1.1  augustss #define AUE_MAR6		0x0E
     84        1.1  augustss #define AUE_MAR7		0x0F
     85        1.1  augustss #define AUE_MAR			AUE_MAR0
     86        1.1  augustss #define AUE_PAR0		0x10
     87        1.1  augustss #define AUE_PAR1		0x11
     88        1.1  augustss #define AUE_PAR2		0x12
     89        1.1  augustss #define AUE_PAR3		0x13
     90        1.1  augustss #define AUE_PAR4		0x14
     91        1.1  augustss #define AUE_PAR5		0x15
     92        1.1  augustss #define AUE_PAR			AUE_PAR0
     93        1.1  augustss #define AUE_PAUSE0		0x18
     94        1.1  augustss #define AUE_PAUSE1		0x19
     95        1.1  augustss #define AUE_PAUSE		AUE_PAUSE0
     96        1.1  augustss #define AUE_RX_FLOWCTL_CNT	0x1A
     97        1.1  augustss #define AUE_RX_FLOWCTL_FIFO	0x1B
     98       1.15  augustss #define AUE_REG_1D		0x1D
     99        1.1  augustss #define AUE_EE_REG		0x20
    100        1.1  augustss #define AUE_EE_DATA0		0x21
    101        1.1  augustss #define AUE_EE_DATA1		0x22
    102        1.1  augustss #define AUE_EE_DATA		AUE_EE_DATA0
    103        1.1  augustss #define AUE_EE_CTL		0x23
    104        1.1  augustss #define AUE_PHY_ADDR		0x25
    105        1.1  augustss #define AUE_PHY_DATA0		0x26
    106        1.1  augustss #define AUE_PHY_DATA1		0x27
    107        1.1  augustss #define AUE_PHY_DATA		AUE_PHY_DATA0
    108        1.1  augustss #define AUE_PHY_CTL		0x28
    109        1.1  augustss #define AUE_USB_STS		0x2A
    110        1.1  augustss #define AUE_TXSTAT0		0x2B
    111        1.1  augustss #define AUE_TXSTAT1		0x2C
    112        1.1  augustss #define AUE_TXSTAT		AUE_TXSTAT0
    113        1.1  augustss #define AUE_RXSTAT		0x2D
    114        1.1  augustss #define AUE_PKTLOST0		0x2E
    115        1.1  augustss #define AUE_PKTLOST1		0x2F
    116        1.1  augustss #define AUE_PKTLOST		AUE_PKTLOST0
    117        1.1  augustss 
    118       1.15  augustss #define AUE_REG_7B		0x7B
    119        1.1  augustss #define AUE_GPIO0		0x7E
    120        1.1  augustss #define AUE_GPIO1		0x7F
    121       1.15  augustss #define AUE_REG_81		0x81
    122        1.1  augustss 
    123        1.1  augustss #define AUE_CTL0_INCLUDE_RXCRC	0x01
    124        1.1  augustss #define AUE_CTL0_ALLMULTI	0x02
    125        1.1  augustss #define AUE_CTL0_STOP_BACKOFF	0x04
    126        1.1  augustss #define AUE_CTL0_RXSTAT_APPEND	0x08
    127        1.1  augustss #define AUE_CTL0_WAKEON_ENB	0x10
    128        1.1  augustss #define AUE_CTL0_RXPAUSE_ENB	0x20
    129        1.1  augustss #define AUE_CTL0_RX_ENB		0x40
    130        1.1  augustss #define AUE_CTL0_TX_ENB		0x80
    131        1.1  augustss 
    132        1.1  augustss #define AUE_CTL1_HOMELAN	0x04
    133        1.1  augustss #define AUE_CTL1_RESETMAC	0x08
    134        1.1  augustss #define AUE_CTL1_SPEEDSEL	0x10	/* 0 = 10mbps, 1 = 100mbps */
    135        1.1  augustss #define AUE_CTL1_DUPLEX		0x20	/* 0 = half, 1 = full */
    136        1.1  augustss #define AUE_CTL1_DELAYHOME	0x40
    137        1.1  augustss 
    138        1.1  augustss #define AUE_CTL2_EP3_CLR	0x01	/* reading EP3 clrs status regs */
    139        1.1  augustss #define AUE_CTL2_RX_BADFRAMES	0x02
    140        1.1  augustss #define AUE_CTL2_RX_PROMISC	0x04
    141        1.1  augustss #define AUE_CTL2_LOOPBACK	0x08
    142        1.1  augustss #define AUE_CTL2_EEPROMWR_ENB	0x10
    143        1.1  augustss #define AUE_CTL2_EEPROM_LOAD	0x20
    144        1.1  augustss 
    145        1.1  augustss #define AUE_EECTL_WRITE		0x01
    146        1.1  augustss #define AUE_EECTL_READ		0x02
    147        1.1  augustss #define AUE_EECTL_DONE		0x04
    148        1.1  augustss 
    149        1.1  augustss #define AUE_PHYCTL_PHYREG	0x1F
    150        1.1  augustss #define AUE_PHYCTL_WRITE	0x20
    151        1.1  augustss #define AUE_PHYCTL_READ		0x40
    152        1.1  augustss #define AUE_PHYCTL_DONE		0x80
    153        1.1  augustss 
    154        1.1  augustss #define AUE_USBSTS_SUSPEND	0x01
    155        1.1  augustss #define AUE_USBSTS_RESUME	0x02
    156        1.1  augustss 
    157        1.1  augustss #define AUE_TXSTAT0_JABTIMO	0x04
    158        1.1  augustss #define AUE_TXSTAT0_CARLOSS	0x08
    159        1.1  augustss #define AUE_TXSTAT0_NOCARRIER	0x10
    160        1.1  augustss #define AUE_TXSTAT0_LATECOLL	0x20
    161        1.1  augustss #define AUE_TXSTAT0_EXCESSCOLL	0x40
    162        1.1  augustss #define AUE_TXSTAT0_UNDERRUN	0x80
    163        1.1  augustss 
    164        1.1  augustss #define AUE_TXSTAT1_PKTCNT	0x0F
    165        1.1  augustss #define AUE_TXSTAT1_FIFO_EMPTY	0x40
    166        1.1  augustss #define AUE_TXSTAT1_FIFO_FULL	0x80
    167        1.1  augustss 
    168        1.1  augustss #define AUE_RXSTAT_OVERRUN	0x01
    169        1.1  augustss #define AUE_RXSTAT_PAUSE	0x02
    170        1.1  augustss 
    171        1.1  augustss #define AUE_GPIO_IN0		0x01
    172        1.1  augustss #define AUE_GPIO_OUT0		0x02
    173        1.1  augustss #define AUE_GPIO_SEL0		0x04
    174        1.1  augustss #define AUE_GPIO_IN1		0x08
    175        1.1  augustss #define AUE_GPIO_OUT1		0x10
    176        1.1  augustss #define AUE_GPIO_SEL1		0x20
    177        1.1  augustss 
    178        1.1  augustss struct aue_intrpkt {
    179  1.25.24.1     skrll 	uint8_t		aue_txstat0;
    180  1.25.24.1     skrll 	uint8_t		aue_txstat1;
    181  1.25.24.1     skrll 	uint8_t		aue_rxstat;
    182  1.25.24.1     skrll 	uint8_t		aue_rxlostpkt0;
    183  1.25.24.1     skrll 	uint8_t		aue_rxlostpkt1;
    184  1.25.24.1     skrll 	uint8_t		aue_wakeupstat;
    185  1.25.24.1     skrll 	uint8_t		aue_rsvd;
    186  1.25.24.1     skrll 	uint8_t		_pad;
    187        1.1  augustss };
    188        1.1  augustss #define AUE_INTR_PKTLEN 8
    189        1.1  augustss 
    190        1.1  augustss struct aue_rxpkt {
    191        1.1  augustss 	uWord			aue_pktlen;
    192        1.1  augustss 	uByte			aue_rxstat;
    193        1.1  augustss };
    194        1.1  augustss 
    195        1.1  augustss #define AUE_RXSTAT_MCAST	0x01
    196        1.1  augustss #define AUE_RXSTAT_GIANT	0x02
    197        1.1  augustss #define AUE_RXSTAT_RUNT		0x04
    198        1.1  augustss #define AUE_RXSTAT_CRCERR	0x08
    199        1.1  augustss #define AUE_RXSTAT_DRIBBLE	0x10
    200        1.1  augustss #define AUE_RXSTAT_MASK		0x1E
    201        1.1  augustss 
    202        1.1  augustss 
    203        1.1  augustss /*************** The rest belongs in if_auevar.h *************/
    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.25.24.2     skrll 	struct usbd_xfer	*aue_xfer;
    213        1.1  augustss 	char			*aue_buf;
    214        1.1  augustss 	struct mbuf		*aue_mbuf;
    215        1.1  augustss 	int			aue_idx;
    216        1.1  augustss };
    217        1.1  augustss 
    218        1.1  augustss struct aue_cdata {
    219        1.1  augustss 	struct aue_chain	aue_tx_chain[AUE_TX_LIST_CNT];
    220        1.1  augustss 	struct aue_chain	aue_rx_chain[AUE_RX_LIST_CNT];
    221        1.1  augustss 	struct aue_intrpkt	aue_ibuf;
    222        1.1  augustss 	int			aue_tx_prod;
    223        1.1  augustss 	int			aue_tx_cons;
    224        1.1  augustss 	int			aue_tx_cnt;
    225        1.1  augustss 	int			aue_rx_prod;
    226        1.1  augustss };
    227        1.1  augustss 
    228        1.1  augustss struct aue_softc {
    229       1.23    dyoung 	device_t aue_dev;
    230        1.1  augustss 
    231        1.1  augustss 	struct ethercom		aue_ec;
    232        1.1  augustss 	struct mii_data		aue_mii;
    233       1.24       tls 	krndsource_t	rnd_source;
    234       1.20        is 	struct lwp		*aue_thread;
    235       1.20        is 	int			aue_closing;
    236       1.20        is 	kcondvar_t		aue_domc;
    237       1.20        is 	kcondvar_t		aue_closemc;
    238       1.20        is 	kmutex_t		aue_mcmtx;
    239        1.1  augustss #define GET_IFP(sc) (&(sc)->aue_ec.ec_if)
    240        1.1  augustss #define GET_MII(sc) (&(sc)->aue_mii)
    241        1.8  augustss 
    242       1.23    dyoung 	struct callout aue_stat_ch;
    243        1.1  augustss 
    244  1.25.24.2     skrll 	struct usbd_device	*aue_udev;
    245  1.25.24.2     skrll 	struct usbd_interface	*aue_iface;
    246  1.25.24.1     skrll 	uint16_t		aue_vendor;
    247  1.25.24.1     skrll 	uint16_t		aue_product;
    248        1.1  augustss 	int			aue_ed[AUE_ENDPT_MAX];
    249  1.25.24.2     skrll 	struct usbd_pipe	*aue_ep[AUE_ENDPT_MAX];
    250  1.25.24.1     skrll 	uint8_t			aue_link;
    251        1.1  augustss 	int			aue_if_flags;
    252        1.1  augustss 	struct aue_cdata	aue_cdata;
    253       1.13  augustss 
    254  1.25.24.1     skrll 	uint16_t		aue_flags;
    255        1.4  augustss 
    256       1.16  augustss 	int			aue_refcnt;
    257        1.4  augustss 	char			aue_dying;
    258        1.5  augustss 	char			aue_attached;
    259        1.6  augustss 	u_int			aue_rx_errs;
    260       1.12  augustss 	u_int			aue_intr_errs;
    261        1.6  augustss 	struct timeval		aue_rx_notice;
    262       1.14  augustss 
    263       1.14  augustss 	struct usb_task		aue_tick_task;
    264       1.14  augustss 	struct usb_task		aue_stop_task;
    265       1.14  augustss 
    266       1.18        ad 	kmutex_t		aue_mii_lock;
    267        1.1  augustss };
    268        1.1  augustss 
    269        1.1  augustss #define AUE_TIMEOUT		1000
    270        1.1  augustss #define ETHER_ALIGN		2
    271        1.1  augustss #define AUE_BUFSZ		1536
    272        1.1  augustss #define AUE_MIN_FRAMELEN	60
    273        1.1  augustss #define AUE_TX_TIMEOUT		10000 /* ms */
    274        1.2  augustss #define AUE_INTR_INTERVAL	100 /* ms */
    275