166550Snyan/*	$FreeBSD$	*/
266550Snyan/*	$NecBSD: if_snreg.h,v 1.3 1999/01/24 01:39:52 kmatsuda Exp $	*/
366550Snyan/*	$NetBSD$	*/
466550Snyan
5139749Simp/*-
666550Snyan * Copyright (c) 1997, 1998, 1999
766550Snyan *	Kouichi Matsuda.  All rights reserved.
866550Snyan *
966550Snyan * Redistribution and use in source and binary forms, with or without
1066550Snyan * modification, are permitted provided that the following conditions
1166550Snyan * are met:
1266550Snyan * 1. Redistributions of source code must retain the above copyright
1366550Snyan *    notice, this list of conditions and the following disclaimer.
1466550Snyan * 2. Redistributions in binary form must reproduce the above copyright
1566550Snyan *    notice, this list of conditions and the following disclaimer in the
1666550Snyan *    documentation and/or other materials provided with the distribution.
1766550Snyan * 3. All advertising materials mentioning features or use of this software
1866550Snyan *    must display the following acknowledgement:
1966550Snyan *      This product includes software developed by Kouichi Matsuda for
2066550Snyan *      NetBSD/pc98.
2166550Snyan * 4. The name of the author may not be used to endorse or promote products
2266550Snyan *    derived from this software without specific prior written permission
2366550Snyan *
2466550Snyan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2566550Snyan * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2666550Snyan * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2766550Snyan * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2866550Snyan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2966550Snyan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3066550Snyan * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3166550Snyan * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3266550Snyan * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3366550Snyan * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3466550Snyan */
3566550Snyan/*
3666550Snyan * Modified for NetBSD/pc98 1.2.1 from NetBSD/mac68k 1.2D by Kouichi Matsuda.
3766550Snyan * Make adapted for NEC PC-9801-83, 84, PC-9801-103, 104, PC-9801N-25 and
3866550Snyan * PC-9801N-J02R, which uses National Semiconductor DP83934AVQB as
3966550Snyan * Ethernet Controller and National Semiconductor NS46C46 as (64 * 16 bits)
4066550Snyan * Microwire Serial EEPROM.
4166550Snyan */
4266550Snyan
4366550Snyan/*
4466550Snyan * XXX: Should not be HERE. (Should be shared with...)
4566550Snyan */
4666550Snyan
4766550Snyan/*
4866550Snyan * NEC/SONIC port mappings, offset from iobase.
4966550Snyan */
5066550Snyan#define	SNEC_CTRL	0	/* SONIC control port (word) */
5166550Snyan#define	SNEC_CTRLB	1	/* NEC/SONIC control port (byte) */
5266550Snyan#define	SNEC_RSVD0	2	/* not used */
5366550Snyan#define	SNEC_ADDR	3	/* SONIC, NEC/SONIC register address set port */
5466550Snyan#define	SNEC_RSVD1	4	/* not used */
5566550Snyan#define	SNEC_RSVD2	5	/* not used */
5666550Snyan
5766550Snyan#define	SNEC_NREGS	6
5866550Snyan
5966550Snyan/* bank memory size */
60179442Sjhb#define	SNEC_NMEMS	(PAGE_SIZE * 2)
6166550Snyan/* how many bank */
6266550Snyan#define	SNEC_NBANK	0x10
6366550Snyan/* internal buffer size */
6466550Snyan#define	SNEC_NBUF	(SNEC_NMEMS * SNEC_NBANK)
6566550Snyan
6666550Snyan
6766550Snyan/*
6866550Snyan * NEC/SONIC specific internal registers.
6966550Snyan */
7066550Snyan
7166550Snyan/*
7266550Snyan *	Memory Bank Select Register (MEMBS)
7366550Snyan */
7466550Snyan#define	SNECR_MEMBS	0x80
7566550Snyan#define	SNECR_MEMBS_BSEN	0x01	/* enable memory bank select */
7666550Snyan#define	SNECR_MEMBS_EBNMSK	0x1c	/* encoded bank select number */
7766550Snyan/* Translate bank number to encoded bank select number. */
7866550Snyan#define	SNECR_MEMBS_B2EB(bank)	(bank << 2)
7966550Snyan#define	SNECR_MEMBS_PCMCIABUS	0x80	/* bus type identification */
8066550Snyan
8166550Snyan/*
8266550Snyan *	Memory Base Address Select Register (MEMSEL)
8366550Snyan */
8466550Snyan#define	SNECR_MEMSEL	0x82
8566550Snyan/* Translate base phys address to encoded select number. */
8666550Snyan#define	SNECR_MEMSEL_PHYS2EN(maddr)	((maddr >> 13) & 0x0f)
8766550Snyan
8866550Snyan/*
8966550Snyan *	Encoded Irq Select Register (IRQSEL)
9066550Snyan */
9166550Snyan#define	SNECR_IRQSEL	0x84
9266550Snyan
9366550Snyan/*
9466550Snyan *	EEPROM Access Register (EEP)
9566550Snyan */
9666550Snyan#define	SNECR_EEP	0x86
9766550Snyan#define	SNECR_EEP_DI		0x10	/* EEPROM Serial Data Input (high) */
9866550Snyan#define	SNECR_EEP_CS		0x20	/* EEPROM Chip Select (high) */
9966550Snyan#define	SNECR_EEP_SK		0x40	/* EEPROM Serial Data Clock (high) */
10066550Snyan#define	SNECR_EEP_DO		0x80	/* EEPROM Serial Data Output (high) */
10166550Snyan
10266550Snyan/* EEPROM data locations */
10366550Snyan#define	SNEC_EEPROM_KEY0	6	/* Station Address Check Sum Key #1 */
10466550Snyan#define	SNEC_EEPROM_KEY1	7	/* Station Address Check Sum Key #2 */
10566550Snyan#define	SNEC_EEPROM_SA0		8	/* Station Address #1 */
10666550Snyan#define	SNEC_EEPROM_SA1		9	/* Station Address #2 */
10766550Snyan#define	SNEC_EEPROM_SA2		10	/* Station Address #3 */
10866550Snyan#define	SNEC_EEPROM_SA3		11	/* Station Address #4 */
10966550Snyan#define	SNEC_EEPROM_SA4		12	/* Station Address #5 */
11066550Snyan#define	SNEC_EEPROM_SA5		13	/* Station Address #6 */
11166550Snyan#define	SNEC_EEPROM_CKSUM	14	/* Station Address Check Sum */
11266550Snyan
11366550Snyan#define	SNEC_EEPROM_SIZE	32	/* valid EEPROM data (max 128 bytes) */
11466550Snyan
11566550Snyan/*
11666550Snyan *	Bus and Mode Identification Register (IDENT)
11766550Snyan */
11866550Snyan#define	SNECR_IDENT	0x88
11966550Snyan	/* Bit 0: Bus Identification. */
12066550Snyan#define	SNECR_IDENT_CBUS	0x01	/* on PC-98 C-Bus */
12166550Snyan#define	SNECR_IDENT_PCMCIABUS	0x00	/* on PCMCIA Bus */
12266550Snyan	/* Bit 2: always 1 */
12366550Snyan#define	SNECR_IDENT_MAGIC	0x04
12466550Snyan	/* Bit 4: Bus Configuration Mode Identification. */
12566550Snyan#define	SNECR_IDENT_PNP		0x10	/* Plug and Play (C-Bus and PCMCIA) */
12666550Snyan#define	SNECR_IDENT_LEGACY	0x00	/* Legacy C-Bus */
12766550Snyan
12866550Snyan#define	SNECR_IDENT_LEGACY_CBUS		\
12966550Snyan	(SNECR_IDENT_LEGACY | SNECR_IDENT_MAGIC | SNECR_IDENT_CBUS)
13066550Snyan#define	SNECR_IDENT_PNP_CBUS		\
13166550Snyan	(SNECR_IDENT_PNP | SNECR_IDENT_MAGIC | SNECR_IDENT_CBUS)
13266550Snyan#define	SNECR_IDENT_PNP_PCMCIABUS	\
13366550Snyan	(SNECR_IDENT_PNP | SNECR_IDENT_MAGIC | SNECR_IDENT_PCMCIABUS)
13466550Snyan
13566550Snyan/*
13666550Snyan * XXX: parent bus type aliases
13766550Snyan */
13866550Snyan#define	SNEC_TYPE_LEGACY	0
13966550Snyan#define	SNEC_TYPE_PNP		1
14066550Snyan
141