Home | History | Annotate | Line # | Download | only in dev
aereg.h revision 1.1
      1 /*	$NetBSD: aereg.h,v 1.1 2006/03/21 08:15:19 gdamore Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the NetBSD
     22  *	Foundation, Inc. and its contributors.
     23  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  *    contributors may be used to endorse or promote products derived
     25  *    from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 #ifndef _MIPS_ATHEROS_DEV_AEREG_H_
     41 #define	_MIPS_ATHEROS_DEV_AEREG_H_
     42 
     43 /*
     44  * This device is much like a standard Tulip Ethernet chip, but it is
     45  * an on-chip core on the AR5312 processors.  It differs in having two
     46  * register windows, and the details of some of the contents of those
     47  * registers.  It has about 80% in common to a typical tulip.
     48  */
     49 
     50 /*
     51  * Buffer descriptor.  Must be 4-byte aligned.
     52  *
     53  * Note for receive descriptors, the byte count fields must
     54  * be a multiple of 4.
     55  */
     56 struct ae_desc {
     57 	volatile u_int32_t ad_status;	  /* Status */
     58 	volatile u_int32_t ad_ctl;	  /* Control and Byte Counts */
     59 	volatile u_int32_t ad_bufaddr1; /* Buffer Address 1 */
     60 	volatile u_int32_t ad_bufaddr2; /* Buffer Address 2 */
     61 };
     62 
     63 /*
     64  * Descriptor Status bits common to transmit and receive.
     65  */
     66 #define	ADSTAT_OWN	0x80000000	/* Tulip owns descriptor */
     67 #define	ADSTAT_ES	0x00008000	/* Error Summary */
     68 
     69 /*
     70  * Descriptor Status bits for Receive Descriptor.
     71  */
     72 #define	ADSTAT_Rx_FF	0x40000000	/* Filtering Fail */
     73 #define	ADSTAT_Rx_FL	0x3fff0000	/* Frame Length including CRC */
     74 #define	ADSTAT_Rx_DE	0x00004000	/* Descriptor Error */
     75 #define	ADSTAT_Rx_LE	0x00001000	/* Length Error */
     76 #define	ADSTAT_Rx_RF	0x00000800	/* Runt Frame */
     77 #define	ADSTAT_Rx_MF	0x00000400	/* Multicast Frame */
     78 #define	ADSTAT_Rx_FS	0x00000200	/* First Descriptor */
     79 #define	ADSTAT_Rx_LS	0x00000100	/* Last Descriptor */
     80 #define	ADSTAT_Rx_TL	0x00000080	/* Frame Too Long */
     81 #define	ADSTAT_Rx_CS	0x00000040	/* Collision Seen */
     82 #define	ADSTAT_Rx_RT	0x00000020	/* Frame Type */
     83 #define	ADSTAT_Rx_RW	0x00000010	/* Receive Watchdog */
     84 #define	ADSTAT_Rx_RE	0x00000008	/* Report on MII Error */
     85 #define	ADSTAT_Rx_DB	0x00000004	/* Dribbling Bit */
     86 #define	ADSTAT_Rx_CE	0x00000002	/* CRC Error */
     87 #define	ADSTAT_Rx_ZER	0x00000001	/* Zero (always 0) */
     88 
     89 #define	ADSTAT_Rx_LENGTH(x)	(((x) & ADSTAT_Rx_FL) >> 16)
     90 
     91 /*
     92  * Descriptor Status bits for Transmit Descriptor.
     93  */
     94 #define	ADSTAT_Tx_TO	0x00004000	/* Transmit Jabber Timeout */
     95 #define	ADSTAT_Tx_LO	0x00000800	/* Loss of Carrier */
     96 #define	ADSTAT_Tx_NC	0x00000400	/* No Carrier */
     97 #define	ADSTAT_Tx_LC	0x00000200	/* Late Collision */
     98 #define	ADSTAT_Tx_EC	0x00000100	/* Excessive Collisions */
     99 #define	ADSTAT_Tx_HF	0x00000080	/* Heartbeat Fail */
    100 #define	ADSTAT_Tx_CC	0x00000078	/* Collision Count */
    101 #define	ADSTAT_Tx_ED	0x00000004	/* Excessive Deferral */
    102 #define	ADSTAT_Tx_UF	0x00000002	/* Underflow Error */
    103 #define	ADSTAT_Tx_DE	0x00000001	/* Deferred */
    104 
    105 #define	ADSTAT_Tx_COLLISIONS(x)	(((x) & ADSTAT_Tx_CC) >> 3)
    106 
    107 /*
    108  * Descriptor Control bits common to transmit and receive.
    109  */
    110 #define	ADCTL_SIZE1	0x000007ff	/* Size of buffer 1 */
    111 #define	ADCTL_SIZE1_SHIFT 0
    112 
    113 #define	ADCTL_SIZE2	0x003ff800	/* Size of buffer 2 */
    114 #define	ADCTL_SIZE2_SHIFT 11
    115 
    116 #define	ADCTL_ER	0x02000000	/* End of Ring */
    117 #define	ADCTL_CH	0x01000000	/* Second Address Chained */
    118 
    119 /*
    120  * Descriptor Control bits for Transmit Descriptor.
    121  */
    122 #define	ADCTL_Tx_IC	0x80000000	/* Interrupt on Completion */
    123 #define	ADCTL_Tx_LS	0x40000000	/* Last Segment */
    124 #define	ADCTL_Tx_FS	0x20000000	/* First Segment */
    125 #define	ADCTL_Tx_AC	0x04000000	/* Add CRC Disable */
    126 #define	ADCTL_Tx_DPD	0x00800000	/* Disabled Padding */
    127 
    128 /*
    129  * Control registers.
    130  */
    131 
    132 /* tese are registers only found on this part */
    133 #define	CSR_MACCTL	0x0000		/* mac control */
    134 #define	CSR_MACHI	0x0004
    135 #define	CSR_MACLO	0x0008
    136 #define	CSR_HTHI	0x000C		/* multicast table high */
    137 #define	CSR_HTLO	0x0010		/* multicast table low */
    138 #define	CSR_MIIADDR	0x0014		/* mii address */
    139 #define	CSR_MIIDATA	0x0018		/* mii data */
    140 #define	CSR_FLOWC	0x001C		/* flow control */
    141 #define	CSR_VL1		0x0020		/* vlan 1 tag */
    142 
    143 /* these are more or less normal Tulip registers */
    144 #define	CSR_BUSMODE	0x1000		/* bus mode */
    145 #define	CSR_TXPOLL	0x1004		/* tx poll demand */
    146 #define	CSR_RXPOLL	0x1008		/* rx poll demand */
    147 #define	CSR_RXLIST	0x100C		/* rx base descriptor address */
    148 #define	CSR_TXLIST	0x1010		/* tx base descriptor address */
    149 #define	CSR_STATUS	0x1014		/* (interrupt) status */
    150 #define	CSR_OPMODE	0x1018		/* operation mode */
    151 #define	CSR_INTEN	0x101C		/* interrupt enable */
    152 #define	CSR_MISSED	0x1020		/* missed frame counter */
    153 #define	CSR_HTBA	0x1050		/* host tx buffer address (ro) */
    154 #define	CSR_HRBA	0x1054		/* host rx buffer address (ro) */
    155 
    156 /* CSR_MACCTL - Mac Control */
    157 #define	MACCTL_RE		0x00000004	/* rx enable */
    158 #define	MACCTL_TE		0x00000008	/* tx enable */
    159 #define	MACCTL_DC		0x00000020	/* deferral check */
    160 #define	MACCTL_PSTR		0x00000100	/* automatic pad strip */
    161 #define	MACCTL_DTRY		0x00000400	/* disable retry */
    162 #define	MACCTL_DBF		0x00000800	/* disable broadcast frames */
    163 #define	MACCTL_LCC		0x00001000	/* late collision control */
    164 #define	MACCTL_HASH		0x00002000	/* hash filtering enable */
    165 #define	MACCTL_HO		0x00008000	/* disable perfect filtering */
    166 #define	MACCTL_PB		0x00010000	/* pass bad frames */
    167 #define	MACCTL_IF		0x00020000	/* inverse filtering */
    168 #define	MACCTL_PR		0x00040000	/* promiscuous mode */
    169 #define	MACCTL_PM		0x00080000	/* pass all multicast */
    170 #define	MACCTL_FDX		0x00100000	/* full duplex mode */
    171 #define	MACCTL_LOOP		0x00600000	/* loopback mask */
    172 #define	MACCTL_LOOP_INT		0x00200000	/* internal loopback */
    173 #define	MACCTL_LOOP_EXT		0x00400000	/* external loopback */
    174 #define	MACCTL_LOOP_NONE	0x00000000
    175 #define	MACCTL_DRO		0x00800000	/* disable receive own */
    176 #define	MACCTL_PS		0x08000000	/* port select, 0 = mii */
    177 #define	MACCTL_HBD		0x10000000	/* heartbeat disable */
    178 #define	MACCTL_BLE		0x40000000	/* mac big endian */
    179 #define	MACCTL_RA		0x80000000	/* receive all packets */
    180 
    181 /* CSR_MIIADDR - MII Addess */
    182 #define	MIIADDR_BUSY		0x00000001	/* mii busy */
    183 #define	MIIADDR_WRITE		0x00000002	/* mii write */
    184 #define	MIIADDR_REG_MASK	0x000007C0	/* mii register */
    185 #define	MIIADDR_REG_SHIFT	6
    186 #define	MIIADDR_PHY_MASK	0x0000F800	/* mii phy */
    187 #define	MIIADDR_PHY_SHIFT	11
    188 
    189 #define	MIIADDR_GETREG(x)	(((x) & MIIADDR_REG) >> 6)
    190 #define	MIIADDR_PUTREG(x)	(((x) << 6) & MIIADR_REG)
    191 #define	MIIADDR_GETPHY(x)	(((x) & MIIADDR_PHY) >> 11)
    192 #define	MIIADDR_PUTPHY(x)	(((x) << 6) & MIIADR_PHY)
    193 
    194 /* CSR_FLOWC - Flow Control */
    195 #define	FLOWC_FCB		0x00000001	/* flow control busy */
    196 #define	FLOWC_FCE		0x00000002	/* flow control enable */
    197 #define	FLOWC_PCF		0x00000004	/* pass control frames */
    198 #define	FLOWC_PT		0xffff0000	/* pause time */
    199 
    200 /* CSR_BUSMODE - Bus Mode */
    201 #define	BUSMODE_SWR		0x00000001	/* software reset */
    202 #define	BUSMODE_BAR		0x00000002	/* bus arbitration */
    203 #define	BUSMODE_DSL		0x0000007c	/* descriptor skip length */
    204 #define	BUSMODE_BLE		0x00000080	/* data buf endian */
    205 						/* programmable burst length */
    206 #define	BUSMODE_PBL_DEFAULT	0x00000000	/*     default value */
    207 #define	BUSMODE_PBL_1LW		0x00000100	/*     1 longword */
    208 #define	BUSMODE_PBL_2LW		0x00000200	/*     2 longwords */
    209 #define	BUSMODE_PBL_4LW		0x00000400	/*     4 longwords */
    210 #define	BUSMODE_PBL_8LW		0x00000800	/*     8 longwords */
    211 #define	BUSMODE_PBL_16LW	0x00001000	/*    16 longwords */
    212 #define	BUSMODE_PBL_32LW	0x00002000	/*    32 longwords */
    213 #define	BUSMODE_DBO		0x00100000	/* descriptor endian */
    214 #define	BUSMODE_ALIGN_16B	0x01000000	/* force oddhw rx buf align */
    215 
    216 /* CSR_TXPOLL - Transmit Poll Demand */
    217 #define	TXPOLL_TPD		0x00000001	/* transmit poll demand */
    218 
    219 
    220 /* CSR_RXPOLL - Receive Poll Demand */
    221 #define	RXPOLL_RPD		0x00000001	/* receive poll demand */
    222 
    223 /* CSR_STATUS - Status */
    224 #define	STATUS_TI		0x00000001	/* transmit interrupt */
    225 #define	STATUS_TPS		0x00000002	/* transmit process stopped */
    226 #define	STATUS_TU		0x00000004	/* transmit buffer unavail */
    227 #define	STATUS_TJT		0x00000008	/* transmit jabber timeout */
    228 #define	STATUS_UNF		0x00000020	/* transmit underflow */
    229 #define	STATUS_RI		0x00000040	/* receive interrupt */
    230 #define	STATUS_RU		0x00000080	/* receive buffer unavail */
    231 #define	STATUS_RPS		0x00000100	/* receive process stopped */
    232 #define	STATUS_ETI		0x00000400	/* early transmit interrupt */
    233 #define	STATUS_SE		0x00002000	/* system error */
    234 #define	STATUS_ER		0x00004000	/* early receive (21041) */
    235 #define	STATUS_AIS		0x00008000	/* abnormal intr summary */
    236 #define	STATUS_NIS		0x00010000	/* normal interrupt summary */
    237 #define	STATUS_RS		0x000e0000	/* receive process state */
    238 #define	STATUS_RS_STOPPED	0x00000000	/* Stopped */
    239 #define	STATUS_RS_FETCH		0x00020000	/* Running - fetch receive
    240 						   descriptor */
    241 #define	STATUS_RS_CHECK		0x00040000	/* Running - check for end
    242 						   of receive */
    243 #define	STATUS_RS_WAIT		0x00060000	/* Running - wait for packet */
    244 #define	STATUS_RS_SUSPENDED	0x00080000	/* Suspended */
    245 #define	STATUS_RS_CLOSE		0x000a0000	/* Running - close receive
    246 						   descriptor */
    247 #define	STATUS_RS_FLUSH		0x000c0000	/* Running - flush current
    248 						   frame from FIFO */
    249 #define	STATUS_RS_QUEUE		0x000e0000	/* Running - queue current
    250 						   frame from FIFO into
    251 						   buffer */
    252 #define	STATUS_TS		0x00700000	/* transmit process state */
    253 #define	STATUS_TS_STOPPED	0x00000000	/* Stopped */
    254 #define	STATUS_TS_FETCH		0x00100000	/* Running - fetch transmit
    255 						   descriptor */
    256 #define	STATUS_TS_WAIT		0x00200000	/* Running - wait for end
    257 						   of transmission */
    258 #define	STATUS_TS_READING	0x00300000	/* Running - read buffer from
    259 						   memory and queue into
    260 						   FIFO */
    261 #define	STATUS_TS_SUSPENDED	0x00600000	/* Suspended */
    262 #define	STATUS_TS_CLOSE		0x00700000	/* Running - close transmit
    263 						   descriptor */
    264 #define	STATUS_TX_ABORT		0x00800000	/* Transmit bus abort */
    265 #define	STATUS_RX_ABORT		0x01000000	/* Transmit bus abort */
    266 
    267 /* CSR_OPMODE - Operation Mode */
    268 #define	OPMODE_SR		0x00000002	/* start receive */
    269 #define	OPMODE_OSF		0x00000004	/* operate on second frame */
    270 #define	OPMODE_ST		0x00002000	/* start transmitter */
    271 #define	OPMODE_TR		0x0000c000	/* threshold control */
    272 #define	OPMODE_TR_32		0x00000000	/*     32 words */
    273 #define	OPMODE_TR_64		0x00004000	/*     64 words */
    274 #define	OPMODE_TR_128		0x00008000	/*    128 words */
    275 #define	OPMODE_TR_256		0x0000c000	/*    256 words */
    276 #define	OPMODE_SF		0x00200000	/* store and forward mode */
    277 
    278 /* CSR_INTEN - Interrupt Enable */
    279 	/* See bits for CSR_STATUS -- Status */
    280 
    281 
    282 /* CSR_MISSED - Missed Frames */
    283 #define	MISSED_MFC		0xffff0000	/* missed packet count */
    284 #define	MISSED_FOC		0x0000ffff	/* fifo overflow counter */
    285 
    286 #define	MISSED_GETMFC(x)	((x) & MISSED_MFC)
    287 #define	MISSED_GETFOC(x)	(((x) & MISSED_FOC) >> 16)
    288 
    289 #endif /* _MIPS_ATHEROS_DEV_AEREG_H_ */
    290