xref: /openbsd-src/sys/dev/pcmcia/if_xereg.h (revision 2ba33ebb5d2f321e2910dde58414c3732a1b7ac9)
1*2ba33ebbSjmc /*	$OpenBSD: if_xereg.h,v 1.4 2003/10/22 09:58:46 jmc Exp $	*/
20ceb825aSniklas 
30ceb825aSniklas /*
40ceb825aSniklas  * Copyright (c) 1999 Niklas Hallqvist, C Stone, Job de Haas
50ceb825aSniklas  * All rights reserved.
60ceb825aSniklas  *
70ceb825aSniklas  * Redistribution and use in source and binary forms, with or without
80ceb825aSniklas  * modification, are permitted provided that the following conditions
90ceb825aSniklas  * are met:
100ceb825aSniklas  * 1. Redistributions of source code must retain the above copyright
110ceb825aSniklas  *    notice, this list of conditions and the following disclaimer.
120ceb825aSniklas  * 2. Redistributions in binary form must reproduce the above copyright
130ceb825aSniklas  *    notice, this list of conditions and the following disclaimer in the
140ceb825aSniklas  *    documentation and/or other materials provided with the distribution.
150ceb825aSniklas  * 3. All advertising materials mentioning features or use of this software
160ceb825aSniklas  *    must display the following acknowledgement:
170ceb825aSniklas  *      This product includes software developed by Niklas Hallqvist,
180ceb825aSniklas  *	C Stone and Job de Haas.
190ceb825aSniklas  * 4. The name of the author may not be used to endorse or promote products
200ceb825aSniklas  *    derived from this software without specific prior written permission
210ceb825aSniklas  *
220ceb825aSniklas  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
230ceb825aSniklas  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
240ceb825aSniklas  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
250ceb825aSniklas  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
260ceb825aSniklas  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
270ceb825aSniklas  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
280ceb825aSniklas  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
290ceb825aSniklas  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
300ceb825aSniklas  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
310ceb825aSniklas  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
320ceb825aSniklas  */
330ceb825aSniklas 
340ceb825aSniklas /* Additional Card Configuration Registers on Dingo */
350ceb825aSniklas 
360ceb825aSniklas #define PCMCIA_CCR_DCOR0		0x20
370ceb825aSniklas #define PCMCIA_CCR_DCOR0_MRST_SFRST		0x80
380ceb825aSniklas #define PCMCIA_CCR_DCOR0_MRST_SFPWDN		0x40
390ceb825aSniklas #define PCMCIA_CCR_DCOR0_LED3_SFRST		0x20
400ceb825aSniklas #define PCMCIA_CCR_DCOR0_LED3_SFPWDN		0x10
410ceb825aSniklas #define PCMCIA_CCR_DCOR0_BUS			0x08
420ceb825aSniklas #define PCMCIA_CCR_DCOR0_DECODE			0x04
430ceb825aSniklas #define PCMCIA_CCR_DCOR0_SFINT			0x01
440ceb825aSniklas #define PCMCIA_CCR_DCOR1		0x22
450ceb825aSniklas #define PCMCIA_CCR_DCOR1_SFCSR_WAIT		0xC0
460ceb825aSniklas #define PCMCIA_CCR_DCOR1_SHADOW_SFIOB		0x20
470ceb825aSniklas #define PCMCIA_CCR_DCOR1_SHADOW_SFCSR		0x10
480ceb825aSniklas #define PCMCIA_CCR_DCOR1_FORCE_LEVIREQ		0x08
490ceb825aSniklas #define PCMCIA_CCR_DCOR1_D6			0x04
500ceb825aSniklas #define PCMCIA_CCR_DCOR1_SF_STSCHG		0x02
510ceb825aSniklas #define PCMCIA_CCR_DCOR1_SF_IREQ		0x01
520ceb825aSniklas #define PCMCIA_CCR_DCOR2		0x24
530ceb825aSniklas #define PCMCIA_CCR_DCOR2_SHADOW_SFCOR		0x10
540ceb825aSniklas #define PCMCIA_CCR_DCOR2_SMEM_BASE		0x0F
550ceb825aSniklas #define PCMCIA_CCR_DCOR3		0x26
560ceb825aSniklas #define PCMCIA_CCR_DCOR4		0x28
570ceb825aSniklas #define PCMCIA_CCR_SFCOR		0x40
580ceb825aSniklas #define PCMCIA_CCR_SFCOR_SRESET			0x80
590ceb825aSniklas #define PCMCIA_CCR_SFCOR_LEVIREQ		0x40
600ceb825aSniklas #define PCMCIA_CCR_SFCOR_IRQ_STSCHG		0x20
610ceb825aSniklas #define PCMCIA_CCR_SFCOR_CFINDEX		0x18
620ceb825aSniklas #define PCMCIA_CCR_SFCOR_IREQ_ENABLE		0x04
630ceb825aSniklas #define PCMCIA_CCR_SFCOR_ADDR_DECODE		0x02
640ceb825aSniklas #define PCMCIA_CCR_SFCOR_FUNC_ENABLE		0x01
650ceb825aSniklas #define PCMCIA_CCR_SFCSR		0x42
660ceb825aSniklas #define PCMCIA_CCR_SFCSR_IOIS8			0x20
670ceb825aSniklas #define PCMCIA_CCR_SFCSR_AUDIO			0x08
680ceb825aSniklas #define PCMCIA_CCR_SFCSR_PWRDWN			0x04
690ceb825aSniklas #define PCMCIA_CCR_SFCSR_INTR			0x02
700ceb825aSniklas #define PCMCIA_CCR_SFCSR_INTRACK		0x01
710ceb825aSniklas #define PCMCIA_CCR_SFIOBASE0		0x4A
720ceb825aSniklas #define PCMCIA_CCR_SFIOBASE1		0x4C
730ceb825aSniklas #define PCMCIA_CCR_SFILR		0x52
740ceb825aSniklas 
750ceb825aSniklas #define PCMCIA_CCR_SIZE_DINGO		0x54
760ceb825aSniklas 
770ceb825aSniklas /* All pages */
780ceb825aSniklas #define CR	0x0	/* W  - Command register */
790ceb825aSniklas #define ESR	0x0	/* R  - Ethernet status register */
800ceb825aSniklas #define PR	0x1	/* RW - Page register select */
81b1188718Sfgsch #define EDP	0x4	/* RW - Ethernet data port, 4 registers */
82*2ba33ebbSjmc #define ISR0	0x6	/* R  - Ethernet interrupt status register */
830ceb825aSniklas #define GIR	0x7	/* RW - Global interrupt register */
840ceb825aSniklas #define PTR	0xd	/* R  - Packets Transmitted register */
850ceb825aSniklas 
860ceb825aSniklas /* Page 0 */
870ceb825aSniklas #define TSO0	0x8	/* R  - Transmit space open, 3 registers */
880ceb825aSniklas #define TSO1	0x9
890ceb825aSniklas #define TSO2	0xa
900ceb825aSniklas #define DO0	0xc	/* W  - Data offset, 2 registers */
910ceb825aSniklas #define DO1	0xd
920ceb825aSniklas #define RSR	0xc	/* R  - Rx status register */
930ceb825aSniklas #define TPR	0xd	/* R  - Tx packets register */
940ceb825aSniklas #define RBC0	0xe	/* R  - Rx byte count, 2 registers */
950ceb825aSniklas #define RBC1	0xf
960ceb825aSniklas 
970ceb825aSniklas /* Page 1 */
980ceb825aSniklas #define IMR0	0xc	/* RW - Interrupt mask, 2 registers */
990ceb825aSniklas #define IMR1	0xd
1000ceb825aSniklas #define ECR	0xe	/* RW - Ethernet config register */
1010ceb825aSniklas 
1020ceb825aSniklas /* Page 2 */
1030ceb825aSniklas #define RBS0	0x8	/* RW - Receive buffer start, 2 registers */
1040ceb825aSniklas #define RBS1	0x9
1050ceb825aSniklas #define LED	0xa	/* RW - LED control register */
1060ceb825aSniklas #define LED3	0xb	/* RW - LED3 control register */
1070ceb825aSniklas #define MSR	0xc	/* RW - Misc. setup register */
1080ceb825aSniklas #define GP2	0xd	/* RW - General purpose register 2 */
1090ceb825aSniklas 
1100ceb825aSniklas /* Page 3 */
1110ceb825aSniklas #define TPT0	0xa	/* RW - Tx packet threshold, 2 registers */
1120ceb825aSniklas #define TPT1	0xb
1130ceb825aSniklas 
1140ceb825aSniklas /* Page 4 */
1150ceb825aSniklas #define GP0	0x8	/* RW - General purpose register 0 */
1160ceb825aSniklas #define GP1	0x9	/* RW - General purpose register 1 */
1170ceb825aSniklas #define BV	0xa	/* R  - Bonding version register */
1180ceb825aSniklas #define EES	0xb	/* RW - EEPROM control register */
1190ceb825aSniklas 
1200ceb825aSniklas /* Page 5 */
1210ceb825aSniklas #define RHSA0	0xa	/* RX host start address */
1220ceb825aSniklas 
1230ceb825aSniklas /* Page 6 */
1240ceb825aSniklas 
1250ceb825aSniklas /* Page 7 */
1260ceb825aSniklas 
1270ceb825aSniklas /* Page 8 */
1280ceb825aSniklas 
1290ceb825aSniklas /* Page 16 */
1300ceb825aSniklas 
1310ceb825aSniklas /* Page 0x40 */
1320ceb825aSniklas #define CMD0	0x8	/* W  - Receive status register */
1330ceb825aSniklas #define RXST0	0x9	/* RW - Receive status register */
1340ceb825aSniklas #define TXST0	0xb	/* RW - Transmit status, 2 registers */
1350ceb825aSniklas #define TXST1	0xc
1360ceb825aSniklas #define RX0MSK	0xd	/* RW - Receive status mask register */
1370ceb825aSniklas #define TX0MSK	0xe	/* RW - Transmit status mask, 2 registers */
1380ceb825aSniklas #define TX1MSK	0xf	/* RW - Dingo does not define this register */
1390ceb825aSniklas 
1400ceb825aSniklas /* Page 0x42 */
1410ceb825aSniklas #define SWC0	0x8	/* RW - Software configuration, 2 registers */
1420ceb825aSniklas #define SWC1	0x9
1430ceb825aSniklas 
1440ceb825aSniklas /* Page 0x50-0x57 */
1450ceb825aSniklas #define	IA	0x8	/* RW - Individual address */
1460ceb825aSniklas 
1470ceb825aSniklas /* CR register bits */
1480ceb825aSniklas #define TX_PKT		0x01	/* Transmit packet. */
1490ceb825aSniklas #define SOFT_RESET	0x02	/* Software reset. */
1500ceb825aSniklas #define ENABLE_INT	0x04	/* Enable interrupt. */
1510ceb825aSniklas #define FORCE_INT	0x08	/* Force interrupt. */
1520ceb825aSniklas #define CLR_TX_FIFO	0x10	/* Clear transmit FIFO. */
1530ceb825aSniklas #define CLR_RX_OVERRUN	0x20	/* Clear receive overrun. */
1540ceb825aSniklas #define RESTART_TX	0x40	/* Restart transmit process. */
1550ceb825aSniklas 
1560ceb825aSniklas /* ESR register bits */
1570ceb825aSniklas #define FULL_PKT_RCV	0x01	/* Full packet received. */
1580ceb825aSniklas #define PKT_REJECTED	0x04	/* A packet was rejected. */
1590ceb825aSniklas #define TX_PKT_PEND	0x08	/* TX Packet Pending. */
1600ceb825aSniklas #define INCOR_POLARITY	0x10	/* XXX from linux driver, but not used there */
1610ceb825aSniklas #define MEDIA_SELECT	0x20	/* set if TP, clear if AUI */
1620ceb825aSniklas 
1630ceb825aSniklas /* DO register bits */
1640ceb825aSniklas #define DO_OFF_MASK	0x1fff	/* Mask for offset value. */
1650ceb825aSniklas #define DO_CHG_OFFSET	0x2000	/* Change offset command. */
1660ceb825aSniklas #define DO_SHM_MODE	0x4000	/* Shared memory mode. */
1670ceb825aSniklas #define DO_SKIP_RX_PKT	0x8000	/* Skip Rx packet. */
1680ceb825aSniklas 
1690ceb825aSniklas /* RBC register bits */
1700ceb825aSniklas #define RBC_COUNT_MASK	0x1fff	/* Mask for byte count. */
1710ceb825aSniklas #define RBC_RX_FULL	0x2000	/* Receive full packet. */
1720ceb825aSniklas #define RBC_RX_PARTIAL	0x4000	/* Receive partial packet. */
1730ceb825aSniklas #define RBC_RX_PKT_REJ	0x8000	/* Receive packet rejected. */
1740ceb825aSniklas 
1750ceb825aSniklas /* ISR0(/IMR0) register bits */
1760ceb825aSniklas #define ISR_TX_OFLOW	0x01	/* Transmit buffer overflow. */
1770ceb825aSniklas #define ISR_PKT_TX	0x02	/* Packet transmitted. */
1780ceb825aSniklas #define ISR_MAC_INT	0x04	/* MAC interrupt. */
1790ceb825aSniklas #define ISR_RX_EARLY	0x10	/* Receive early packet. */
1800ceb825aSniklas #define ISR_RX_FULL	0x20	/* Receive full packet. */
1810ceb825aSniklas #define ISR_RX_PKT_REJ	0x40	/* Receive packet rejected. */
1820ceb825aSniklas #define ISR_FORCED_INT	0x80	/* Forced interrupt. */
1830ceb825aSniklas 
1840ceb825aSniklas /* ECR register bits */
1850ceb825aSniklas #define ECR_EARLY_TX	0x01	/* Early transmit mode. */
1860ceb825aSniklas #define ECR_EARLY_RX	0x02	/* Early receive mode. */
1870ceb825aSniklas #define ECR_FULL_DUPLEX	0x04	/* Full duplex select. */
1880ceb825aSniklas #define ECR_LNK_PLS_DIS	0x20	/* Link pulse disable. */
1890ceb825aSniklas #define ECR_SW_COMPAT	0x80	/* Software compatibility switch. */
1900ceb825aSniklas 
1910ceb825aSniklas /* GP0 register bits */
1920ceb825aSniklas #define GP1_WR		0x01	/* GP1 pin output value. */
1930ceb825aSniklas #define GP2_WR		0x02	/* GP2 pin output value. */
1940ceb825aSniklas #define GP1_OUT		0x04	/* GP1 pin output select. */
1950ceb825aSniklas #define GP2_OUT		0x08	/* GP2 pin output select. */
1960ceb825aSniklas #define GP1_RD		0x10	/* GP1 pin input value. */
1970ceb825aSniklas #define GP2_RD		0x20	/* GP2 pin input value. */
1980ceb825aSniklas 
1990ceb825aSniklas /* GP1 register bits */
2000ceb825aSniklas #define POWER_UP	0x01	/* When 0, power down analogue part of chip. */
2010ceb825aSniklas 
2020ceb825aSniklas /* LED register bits */
2030ceb825aSniklas #define LED0_SHIFT	0	/* LED0 Output shift & mask */
2040ceb825aSniklas #define LED0_MASK	0x7
2050ceb825aSniklas #define LED1_SHIFT	3	/* LED1 Output shift & mask */
2060ceb825aSniklas #define LED1_MASK	0x38
2070ceb825aSniklas #define LED0_RX_ENA	0x40	/* LED0 - receive enable */
2080ceb825aSniklas #define LED1_RX_ENA	0x80	/* LED1 - receive enable */
2090ceb825aSniklas 
2100ceb825aSniklas /* LED3 register bits */
2110ceb825aSniklas #define LED3_SHIFT	0	/* LED0 output shift & mask */
2120ceb825aSniklas #define LED3_MASK	0x7
2130ceb825aSniklas #define LED3_RX_ENA	0x40	/* LED0 - receive enable */
2140ceb825aSniklas 
2150ceb825aSniklas /* LED output values */
2160ceb825aSniklas #define LED_DISABLE	0	/* LED disabled */
2170ceb825aSniklas #define LED_COLL_ACT	1	/* Collision activity */
2180ceb825aSniklas #define LED_COLL_INACT	2	/* (NOT) Collision activity */
2190ceb825aSniklas #define LED_10MB_LINK	3	/* 10 Mb link detected */
2200ceb825aSniklas #define LED_100MB_LINK	4	/* 100 Mb link detected */
2210ceb825aSniklas #define LED_LINK	5	/* 10 Mb or 100 Mb link detected */
2220ceb825aSniklas #define LED_AUTO	6	/* Automatic assertion */
2230ceb825aSniklas #define LED_TX_ACT	7	/* Transmit activity */
2240ceb825aSniklas 
2250ceb825aSniklas /* MSR register bits */
2260ceb825aSniklas #define SRAM_128K_EXT	0x01	/* 128K SRAM extension */
2270ceb825aSniklas #define RBS_BIT16	0x02	/* RBS bit 16 */
2280ceb825aSniklas #define SELECT_MII	0x08	/* Select MII */
2290ceb825aSniklas #define HASH_TBL_ENA	0x20	/* Hash table enable */
2300ceb825aSniklas 
2310ceb825aSniklas /* GP2 register bits */
2320ceb825aSniklas #define GP3_WR		0x01	/* GP3 pin output value. */
2330ceb825aSniklas #define GP4_WR		0x02	/* GP4 pin output value. */
2340ceb825aSniklas #define GP3_OUT		0x04	/* GP3 pin output select. */
2350ceb825aSniklas #define GP4_OUT		0x08	/* GP4 pin output select. */
2360ceb825aSniklas #define GP3_RD		0x10	/* GP3 pin input value. */
2370ceb825aSniklas #define GP4_RD		0x20	/* GP4 pin input value. */
2380ceb825aSniklas 
2390ceb825aSniklas /* RSR register bits */
2400ceb825aSniklas #define RSR_NOTMCAST	0x01	/* clear when multicast packet */
2410ceb825aSniklas #define RSR_BCAST	0x02	/* set when broadcast packet */
2420ceb825aSniklas #define RSR_TOO_LONG	0x04	/* set if packet is longer than 1518 octets */
2430ceb825aSniklas #define RSR_ALIGNERR	0x10	/* incorrect CRC and last octet not complete */
2440ceb825aSniklas #define RSR_CRCERR	0x20	/* incorrect CRC and last octet complete */
2450ceb825aSniklas #define RSR_RX_OK	0x80	/* packet received okay */
2460ceb825aSniklas 
2470ceb825aSniklas /* CMD0 register bits */
2480ceb825aSniklas #define ONLINE		0x04	/* Online */
2490ceb825aSniklas #define OFFLINE		0x08	/* Online */
2505b4e4e58Snate #define ENABLE_RX	0x20	/* Enable receiver */
2510ceb825aSniklas #define DISABLE_RX	0x80	/* Disable receiver */
2520ceb825aSniklas 
2530ceb825aSniklas /* RX0Msk register bits */
2540ceb825aSniklas #define PKT_TOO_LONG	0x02	/* Packet too long mask. */
2550ceb825aSniklas #define CRC_ERR		0x08	/* CRC error mask. */
2560ceb825aSniklas #define RX_OVERRUN	0x10	/* Receive overrun mask. */
2570ceb825aSniklas #define RX_ABORT	0x40	/* Receive abort mask. */
2580ceb825aSniklas #define RX_OK		0x80	/* Receive OK mask. */
2590ceb825aSniklas 
2600ceb825aSniklas /* TX0Msk register bits */
2610ceb825aSniklas #define CARRIER_LOST	0x01	/* Carrier sense lost. */
2620ceb825aSniklas #define EXCESSIVE_COLL	0x02	/* Excessive collisions mask. */
2630ceb825aSniklas #define TX_UNDERRUN	0x08	/* Transmit underrun mask. */
2640ceb825aSniklas #define LATE_COLLISION	0x10	/* Late collision mask. */
2650ceb825aSniklas #define SQE		0x20	/* Signal quality error mask.. */
2660ceb825aSniklas #define TX_ABORT	0x40	/* Transmit abort mask. */
2670ceb825aSniklas #define TX_OK		0x80	/* Transmit OK mask. */
2680ceb825aSniklas 
2690ceb825aSniklas /* SWC1 register bits */
2700ceb825aSniklas #define SWC1_IND_ADDR	0x01	/* Individual address enable. */
2710ceb825aSniklas #define SWC1_MCAST_PROM	0x02	/* Multicast promiscuous enable. */
2720ceb825aSniklas #define SWC1_PROMISC	0x04	/* Promiscuous mode enable. */
2730ceb825aSniklas #define SWC1_BCAST_DIS	0x08	/* Broadcast disable. */
2740ceb825aSniklas #define SWC1_MEDIA_SEL	0x40	/* Media select (Mohawk). */
2750ceb825aSniklas #define SWC1_AUTO_MEDIA	0x80	/* Automatic media select (Mohawk). */
2760ceb825aSniklas 
2770ceb825aSniklas /* Misc. defines. */
2780ceb825aSniklas 
2790ceb825aSniklas #define PAGE(sc, page)	\
2800ceb825aSniklas     bus_space_write_1((sc->sc_bst), (sc->sc_bsh), (sc->sc_offset) + PR, (page))
2810ceb825aSniklas 
2820ceb825aSniklas /*
2830ceb825aSniklas  * GP3 is connected to the MDC pin of the NS DP83840A PHY, GP4 is
2840ceb825aSniklas  * connected to the MDIO pin.  These are utility macros to enhance
2850ceb825aSniklas  * readability of the code.
2860ceb825aSniklas  */
2870ceb825aSniklas #define MDC_LOW		GP3_OUT
2880ceb825aSniklas #define MDC_HIGH	(GP3_OUT | GP3_WR)
2890ceb825aSniklas #define MDIO_LOW	GP4_OUT
2900ceb825aSniklas #define MDIO_HIGH	(GP4_OUT | GP4_WR)
2910ceb825aSniklas #define MDIO		GP4_RD
2920ceb825aSniklas 
2930ceb825aSniklas /* Values found in MANFID. */
2940ceb825aSniklas #define XEMEDIA_ETHER		0x01
2950ceb825aSniklas #define XEMEDIA_TOKEN		0x02
2960ceb825aSniklas #define XEMEDIA_ARC		0x04
2970ceb825aSniklas #define XEMEDIA_WIRELESS	0x08
2980ceb825aSniklas #define XEMEDIA_MODEM		0x10
2990ceb825aSniklas #define XEMEDIA_GSM		0x20
3000ceb825aSniklas 
3010ceb825aSniklas #define XEPROD_IDMASK		0x0f
3020ceb825aSniklas #define XEPROD_POCKET		0x10
3030ceb825aSniklas #define XEPROD_EXTERNAL		0x20
3040ceb825aSniklas #define XEPROD_CREDITCARD	0x40
3050ceb825aSniklas #define XEPROD_CARDBUS		0x80
306