Home | History | Annotate | Line # | Download | only in at91
at91emacreg.h revision 1.2
      1  1.2  matt /*	$Id: at91emacreg.h,v 1.2 2008/07/03 01:15:38 matt Exp $	*/
      2  1.2  matt /*      $NetBSD: at91emacreg.h,v 1.2 2008/07/03 01:15:38 matt Exp $	*/
      3  1.2  matt /*-
      4  1.2  matt  * Copyright (c) 2007 Embedtronics Oy
      5  1.2  matt  * All rights reserved
      6  1.2  matt  *
      7  1.2  matt  * Redistribution and use in source and binary forms, with or without
      8  1.2  matt  * modification, are permitted provided that the following conditions
      9  1.2  matt  * are met:
     10  1.2  matt  * 1. Redistributions of source code must retain the above copyright
     11  1.2  matt  *    notice, this list of conditions and the following disclaimer.
     12  1.2  matt  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.2  matt  *    notice, this list of conditions and the following disclaimer in the
     14  1.2  matt  *    documentation and/or other materials provided with the distribution.
     15  1.2  matt  * 3. All advertising materials mentioning features or use of this software
     16  1.2  matt  *    must display the following acknowledgement:
     17  1.2  matt  *      This product includes software developed by the NetBSD
     18  1.2  matt  *      Foundation, Inc. and its contributors.
     19  1.2  matt  * 4. Neither the name of The NetBSD Foundation nor the names of its
     20  1.2  matt  *    contributors may be used to endorse or promote products derived
     21  1.2  matt  *    from this software without specific prior written permission.
     22  1.2  matt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23  1.2  matt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  1.2  matt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  1.2  matt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26  1.2  matt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  1.2  matt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  1.2  matt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  1.2  matt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  1.2  matt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  1.2  matt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  1.2  matt  * SUCH DAMAGE.
     33  1.2  matt  *
     34  1.2  matt  */
     35  1.2  matt 
     36  1.2  matt #ifndef	_AT91EMACREG_H_
     37  1.2  matt #define	_AT91EMACREG_H_	1
     38  1.2  matt 
     39  1.2  matt /* Ethernet MAC (EMAC),
     40  1.2  matt  * at91rm9200.pdf, page 573 */
     41  1.2  matt 
     42  1.2  matt #define	ETH_CTL		0x00U	/* 0x00: Control Register		*/
     43  1.2  matt #define	ETH_CFG		0x04U	/* 0x04: Configuration Register		*/
     44  1.2  matt #define	ETH_SR		0x08U	/* 0x08: Status Register		*/
     45  1.2  matt #define	ETH_TAR		0x0CU	/* 0x0C: Transmit Address Register	*/
     46  1.2  matt #define	ETH_TCR		0x10U	/* 0x10: Transmit Control Register	*/
     47  1.2  matt #define	ETH_TSR		0x14U	/* 0x14: Transmit Status Register	*/
     48  1.2  matt #define	ETH_RBQP	0x18U	/* 0x18: Receive Buffer Queue Pointer	*/
     49  1.2  matt #define	ETH_RSR		0x20U	/* 0x20: Receive Status Register	*/
     50  1.2  matt #define	ETH_ISR		0x24U	/* 0x24: Interrupt Status Register	*/
     51  1.2  matt #define	ETH_IER		0x28U	/* 0x28: Interrupt Enable Register	*/
     52  1.2  matt #define	ETH_IDR		0x2CU	/* 0x2C: Interrupt Disable Register	*/
     53  1.2  matt #define	ETH_IMR		0x30U	/* 0x30: Interrupt Mask Register	*/
     54  1.2  matt #define	ETH_MAN		0x34U	/* 0x34: PHY Maintenance Register	*/
     55  1.2  matt 
     56  1.2  matt #define	ETH_FRA		0x40U	/* 0x40: Frames Transmitted OK		*/
     57  1.2  matt #define	ETH_SCOL	0x44U	/* 0x44: Single Collision Frames	*/
     58  1.2  matt #define	ETH_MCOL	0x48U	/* 0x48: Multiple Collision Frames	*/
     59  1.2  matt #define	ETH_OK		0x4CU	/* 0x4C: Frames Received OK		*/
     60  1.2  matt #define	ETH_SEQE	0x50U	/* 0x50: Frame Check Sequence Errors	*/
     61  1.2  matt #define	ETH_ALE		0x54U	/* 0x54: Alignment Errors		*/
     62  1.2  matt #define	ETH_DTE		0x58U	/* 0x58: Deferred Transmission Frame	*/
     63  1.2  matt #define	ETH_LCOL	0x5CU	/* 0x5C: Late Collisions		*/
     64  1.2  matt #define	ETH_ECOL	0x60U	/* 0x60: Excessive Collisions		*/
     65  1.2  matt #define	ETH_CSE		0x64U	/* 0x64: Carrier Sense Errors		*/
     66  1.2  matt #define	ETH_TUE		0x68U	/* 0x68: Transmit Underrun Errors	*/
     67  1.2  matt #define	ETH_CDE		0x6CU	/* 0x6C: Code Errors			*/
     68  1.2  matt #define	ETH_ELR		0x70U	/* 0x70: Excessive Length Errors	*/
     69  1.2  matt #define	ETH_RJB		0x74U	/* 0x74: Receive Jabbers		*/
     70  1.2  matt #define	ETH_USF		0x78U	/* 0x78: Undersize Frames		*/
     71  1.2  matt #define	ETH_SQEE	0x7CU	/* 0x7C: SQE Test Errors		*/
     72  1.2  matt #define	ETH_DRFC	0x80U	/* 0x80: Discarded RX Frames		*/
     73  1.2  matt 
     74  1.2  matt #define	ETH_HSH		0x90U	/* 0x90: Hash Address High		*/
     75  1.2  matt #define	ETH_HSL		0x94U	/* 0x94: Hash Address Low		*/
     76  1.2  matt 
     77  1.2  matt #define	ETH_SA1L	0x98U	/* 0x98: Specific Address 1 Low		*/
     78  1.2  matt #define	ETH_SA1H	0x9CU	/* 0x9C: Specific Address 1 High	*/
     79  1.2  matt 
     80  1.2  matt #define	ETH_SA2L	0xA0U	/* 0xA0: Specific Address 2 Low		*/
     81  1.2  matt #define	ETH_SA2H	0xA4U	/* 0xA4: Specific Address 2 High	*/
     82  1.2  matt 
     83  1.2  matt #define	ETH_SA3L	0xA8U	/* 0xA8: Specific Address 3 Low		*/
     84  1.2  matt #define	ETH_SA3H	0xACU	/* 0xAC: Specific Address 3 High	*/
     85  1.2  matt 
     86  1.2  matt #define	ETH_SA4L	0xB0U	/* 0xB0: Specific Address 4 Low		*/
     87  1.2  matt #define	ETH_SA4H	0xB4U	/* 0xB4: Specific Address 4 High	*/
     88  1.2  matt 
     89  1.2  matt 
     90  1.2  matt /* Control Register bits: */
     91  1.2  matt #define	ETH_CTL_BP	0x100U	/* 1 = back pressure enabled		*/
     92  1.2  matt #define	ETH_CTL_WES	0x080U	/* 1 = statistics registers writeable	*/
     93  1.2  matt #define	ETH_CTL_ISR	0x040U	/* 1 = increment statistics registers	*/
     94  1.2  matt #define	ETH_CTL_CSR	0x020U	/* 1 = clear statistics registers	*/
     95  1.2  matt #define	ETH_CTL_MPE	0x010U	/* 1 = management port enabled		*/
     96  1.2  matt #define	ETH_CTL_TE	0x008U	/* 1 = transmit enable			*/
     97  1.2  matt #define	ETH_CTL_RE	0x004U	/* 1 = receive enable			*/
     98  1.2  matt #define	ETH_CTL_LBL	0x002U	/* 1 = local loopback enabled		*/
     99  1.2  matt #define	ETH_CTL_LB	0x001U	/* 1 = loopback signal is at high level	*/
    100  1.2  matt 
    101  1.2  matt 
    102  1.2  matt /* Configuration Register bits: */
    103  1.2  matt #define	ETH_CFG_RMII	0x2000U	/* 1 = enable RMII (Reduce MII)		*/
    104  1.2  matt #define	ETH_CFG_RTY	0x1000U	/* 1 = retry test enabled		*/
    105  1.2  matt 
    106  1.2  matt #define	ETH_CFG_CLK	0x0C00U	/* clock				*/
    107  1.2  matt #define	ETH_CFG_CLK_8	0x0000U
    108  1.2  matt #define	ETH_CFG_CLK_16	0x0400U
    109  1.2  matt #define	ETH_CFG_CLK_32	0x0800U
    110  1.2  matt #define	ETH_CFG_CLK_64	0x0C00U
    111  1.2  matt 
    112  1.2  matt #define	ETH_CFG_EAE	0x0200U	/* 1 = external address match enable	*/
    113  1.2  matt #define	ETH_CFG_BIG	0x0100U	/* 1 = receive up to 1522 bytes	(VLAN)	*/
    114  1.2  matt #define	ETH_CFG_UNI	0x0080U	/* 1 = enable unicast hash		*/
    115  1.2  matt #define	ETH_CFG_MTI	0x0040U	/* 1 = enable multicast hash		*/
    116  1.2  matt #define	ETH_CFG_NBC	0x0020U	/* 1 = ignore received broadcasts	*/
    117  1.2  matt #define	ETH_CFG_CAF	0x0010U	/* 1 = receive all valid frames		*/
    118  1.2  matt #define	ETH_CFG_BR	0x0004U
    119  1.2  matt #define	ETH_CFG_FD	0x0002U	/* 1 = force full duplex		*/
    120  1.2  matt #define	ETH_CFG_SPD	0x0001U	/* 1 = 100 Mbps				*/
    121  1.2  matt 
    122  1.2  matt 
    123  1.2  matt /* Status Register bits: */
    124  1.2  matt #define	ETH_SR_IDLE	0x0004U	/* 1 = PHY logic is running		*/
    125  1.2  matt #define	ETH_SR_MDIO	0x0002U	/* 1 = MDIO pin set			*/
    126  1.2  matt #define	ETH_SR_LINK	0x0001U
    127  1.2  matt 
    128  1.2  matt 
    129  1.2  matt /* Transmit Control Register bits: */
    130  1.2  matt #define	ETH_TCR_NCRC	0x8000U	/* 1 = don't append CRC			*/
    131  1.2  matt #define	ETH_TCR_LEN	0x07FFU	/* transmit frame length		*/
    132  1.2  matt 
    133  1.2  matt 
    134  1.2  matt /* Transmit Status Register bits: */
    135  1.2  matt #define	ETH_TSR_UND	0x40U	/* 1 = transmit underrun detected	*/
    136  1.2  matt #define	ETH_TSR_COMP	0x20U	/* 1 = transmit complete		*/
    137  1.2  matt #define	ETH_TSR_BNQ	0x10U	/* 1 = transmit buffer not queued	*/
    138  1.2  matt #define	ETH_TSR_IDLE	0x08U	/* 1 = transmitter idle			*/
    139  1.2  matt #define	ETH_TSR_RLE	0x04U	/* 1 = retry limit exceeded		*/
    140  1.2  matt #define	ETH_TSR_COL	0x02U	/* 1 = collision occurred		*/
    141  1.2  matt #define	ETH_TSR_OVR	0x01U	/* 1 = transmit buffer overrun		*/
    142  1.2  matt 
    143  1.2  matt 
    144  1.2  matt /* Receive Status Register bits: */
    145  1.2  matt #define	ETH_RSR_OVR	0x04U	/* 1 = RX overrun			*/
    146  1.2  matt #define	ETH_RSR_REC	0x02U	/* 1 = frame received			*/
    147  1.2  matt #define	ETH_RSR_BNA	0x01U	/* 1 = buffer not available		*/
    148  1.2  matt 
    149  1.2  matt 
    150  1.2  matt /* Interrupt bits: */
    151  1.2  matt #define	ETH_ISR_ABT	0x0800U	/* 1 = abort during DMA transfer	*/
    152  1.2  matt #define	ETH_ISR_ROVR	0x0400U	/* 1 = RX overrun			*/
    153  1.2  matt #define	ETH_ISR_LINK	0x0200U	/* 1 = link pin changed			*/
    154  1.2  matt #define	ETH_ISR_TIDLE	0x0100U	/* 1 = transmitter idle			*/
    155  1.2  matt #define	ETH_ISR_TCOM	0x0080U	/* 1 = transmit complete		*/
    156  1.2  matt #define	ETH_ISR_TBRE	0x0040U	/* 1 = transmit buffer register empty	*/
    157  1.2  matt #define	ETH_ISR_RTRY	0x0020U	/* 1 = retry limit exceeded		*/
    158  1.2  matt #define	ETH_ISR_TUND	0x0010U	/* 1 = transmit buffer underrun		*/
    159  1.2  matt #define	ETH_ISR_TOVR	0x0008U	/* 1 = transmit buffer overrun		*/
    160  1.2  matt #define	ETH_ISR_RBNA	0x0004U	/* 1 = receive buffer not available	*/
    161  1.2  matt #define	ETH_ISR_RCOM	0x0002U	/* 1 = receive complete			*/
    162  1.2  matt #define	ETH_ISR_DONE	0x0001U	/* 1 = management done			*/
    163  1.2  matt 
    164  1.2  matt 
    165  1.2  matt /* PHY Maintenance Register bits: */
    166  1.2  matt #define	ETH_MAN_LOW	0x80000000U /* must not be set			*/
    167  1.2  matt #define	ETH_MAN_HIGH	0x40000000U /* must be set			*/
    168  1.2  matt 
    169  1.2  matt #define	ETH_MAN_RW	0x30000000U
    170  1.2  matt #define	ETH_MAN_RW_RD	0x20000000U
    171  1.2  matt #define	ETH_MAN_RW_WR	0x10000000U
    172  1.2  matt 
    173  1.2  matt #define	ETH_MAN_PHYA	0x0F800000U /* PHY address (normally 0)		*/
    174  1.2  matt #define	ETH_MAN_PHYA_SHIFT 23U
    175  1.2  matt #define	ETH_MAN_REGA	0x007C0000U
    176  1.2  matt #define	ETH_MAN_REGA_SHIFT 18U
    177  1.2  matt #define	ETH_MAN_CODE	0x00030000U /* must be 10			*/
    178  1.2  matt #define	ETH_MAN_CODE_IEEE802_3 \
    179  1.2  matt 			0x00020000U
    180  1.2  matt #define	ETH_MAN_DATA	0x0000FFFFU /* data to be written to the PHY	*/
    181  1.2  matt 
    182  1.2  matt #define	ETH_MAN_VAL	(ETH_MAN_HIGH|ETH_MAN_CODE_IEEE802_3)
    183  1.2  matt 
    184  1.2  matt 
    185  1.2  matt /* received buffer descriptor: */
    186  1.2  matt #define	ETH_RDSC_ADDR		0x00U
    187  1.2  matt #define	ETH_RDSC_FLAGS		0x00U
    188  1.2  matt #define	ETH_RDSC_INFO		0x04U
    189  1.2  matt #define	ETH_RDSC_SIZE		0x08U
    190  1.2  matt 
    191  1.2  matt typedef struct eth_rdsc {
    192  1.2  matt 	volatile u_int32_t	Addr;
    193  1.2  matt 	volatile u_int32_t	Info;
    194  1.2  matt } __attribute__ ((aligned(4))) eth_rdsc_t;
    195  1.2  matt 
    196  1.2  matt /* flags: */
    197  1.2  matt #define	ETH_RDSC_F_WRAP		0x00000002U
    198  1.2  matt #define	ETH_RDSC_F_USED		0x00000001U
    199  1.2  matt 
    200  1.2  matt /* frame info bits: */
    201  1.2  matt #define	ETH_RDSC_I_BCAST	0x80000000U
    202  1.2  matt #define	ETH_RDSC_I_MULTICAST	0x40000000U
    203  1.2  matt #define	ETH_RDSC_I_UNICAST	0x20000000U
    204  1.2  matt #define	ETH_RDSC_I_VLAN		0x10000000U
    205  1.2  matt #define	ETH_RDSC_I_UNKNOWN_SRC	0x08000000U
    206  1.2  matt #define	ETH_RDSC_I_MATCH1	0x04000000U
    207  1.2  matt #define	ETH_RDSC_I_MATCH2	0x02000000U
    208  1.2  matt #define	ETH_RDSC_I_MATCH3	0x01000000U
    209  1.2  matt #define	ETH_RDSC_I_MATCH4	0x00800000U
    210  1.2  matt #define	ETH_RDSC_I_LEN		0x000007FFU
    211  1.2  matt 
    212  1.2  matt #define	ETHREG(offset)		*((volatile uint32_t *)(0xfffbc000 + (offset)))
    213  1.2  matt 
    214  1.2  matt #endif /* !_AT91EMACREG_H_ */
    215