xref: /netbsd-src/sys/dev/ebus/ebusreg.h (revision 0b988ad4808006a53e444f835873b8cb143b1c54)
1*0b988ad4Sandvar /*	$NetBSD: ebusreg.h,v 1.10 2022/07/21 14:41:59 andvar Exp $	*/
218b82a67Smrg 
318b82a67Smrg /*
418b82a67Smrg  * Copyright (c) 1999 Matthew R. Green
518b82a67Smrg  * All rights reserved.
618b82a67Smrg  *
718b82a67Smrg  * Redistribution and use in source and binary forms, with or without
818b82a67Smrg  * modification, are permitted provided that the following conditions
918b82a67Smrg  * are met:
1018b82a67Smrg  * 1. Redistributions of source code must retain the above copyright
1118b82a67Smrg  *    notice, this list of conditions and the following disclaimer.
1218b82a67Smrg  * 2. Redistributions in binary form must reproduce the above copyright
1318b82a67Smrg  *    notice, this list of conditions and the following disclaimer in the
1418b82a67Smrg  *    documentation and/or other materials provided with the distribution.
1518b82a67Smrg  *
1618b82a67Smrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1718b82a67Smrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1818b82a67Smrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1918b82a67Smrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2018b82a67Smrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
2118b82a67Smrg  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2218b82a67Smrg  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2318b82a67Smrg  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2418b82a67Smrg  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2518b82a67Smrg  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2618b82a67Smrg  * SUCH DAMAGE.
2718b82a67Smrg  */
2818b82a67Smrg 
29ea8decf1Suwe #ifndef _DEV_EBUS_EBUSREG_H_
30ea8decf1Suwe #define _DEV_EBUS_EBUSREG_H_
3118b82a67Smrg 
3218b82a67Smrg /*
3318b82a67Smrg  * SPARC `ebus'
3418b82a67Smrg  *
3518b82a67Smrg  * The `ebus' bus is designed to plug traditional PC-ISA devices into
3618b82a67Smrg  * an SPARC system with as few costs as possible, without sacrificing
3718b82a67Smrg  * to performance.  Typically, it is implemented in the PCIO IC from
3818b82a67Smrg  * SME, which also implements a `hme-compatible' PCI network device
3918b82a67Smrg  * (`network').  The ebus has 4 DMA channels, similar to the DMA seen
4018b82a67Smrg  * in the ESP SCSI DMA.
4118b82a67Smrg  *
4218b82a67Smrg  * Typical UltraSPARC systems have a NatSemi SuperIO IC to provide
4318b82a67Smrg  * serial ports for the keyboard and mouse (`se'), floppy disk
4418b82a67Smrg  * controller (`fdthree'), parallel port controller (`bpp') connected
4518b82a67Smrg  * to the ebus, and a PCI-IDE controller (connected directly to the
4618b82a67Smrg  * PCI bus, of course), as well as a Siemens Nixdorf SAB82532 dual
4718b82a67Smrg  * channel serial controller (`su' providing ttya and ttyb), an MK48T59
4818b82a67Smrg  * EEPROM/clock controller (also where the idprom, including the
4918b82a67Smrg  * ethernet address, is located), the audio system (`SUNW,CS4231', same
5018b82a67Smrg  * as other UltraSPARC and some SPARC systems), and other various
5118b82a67Smrg  * internal devices found on traditional SPARC systems such as the
5218b82a67Smrg  * `power', `flashprom', etc., devices.  Other machines with this
53ea8decf1Suwe  * device include microSPARC-IIep based systems, e.g. JavaStation10.
5418b82a67Smrg  *
5518b82a67Smrg  * The ebus uses an interrupt mapping scheme similar to PCI, though
5618b82a67Smrg  * the actual structures are different.
5718b82a67Smrg  */
5818b82a67Smrg 
5918b82a67Smrg /*
60ea8decf1Suwe  * EBus PROM structures.  There's no official OFW binding for EBus,
61ea8decf1Suwe  * so ms-IIep PROMs deviate from de-facto standard used on Ultra's.
62ea8decf1Suwe  *
63ea8decf1Suwe  * EBus address is represented in PROM by 2 cells: bar and offset.
64ea8decf1Suwe  * "bar" specifies the EBus BAR register used to translate the
65ea8decf1Suwe  * "offset" into PCI address space.
66ea8decf1Suwe  *
67ea8decf1Suwe  * On Ultra the bar is the _offset_ of the BAR in PCI config space but
68ea8decf1Suwe  * in (some?) ms-IIep systems (e.g. Krups) it's the _number_ of the
69ea8decf1Suwe  * BAR - e.g. BAR1 is represented by 1 in Krups PROM, while on Ultra
70ea8decf1Suwe  * it's 0x14.
7118b82a67Smrg  */
7218b82a67Smrg 
7318b82a67Smrg struct ebus_regs {
7456109695Skent 	uint32_t	hi;		/* high bits of physaddr */
7556109695Skent 	uint32_t	lo;
7656109695Skent 	uint32_t	size;
7718b82a67Smrg };
7818b82a67Smrg 
79ea8decf1Suwe #define	EBUS_ADDR_FROM_REG(reg)		BUS_ADDR((reg)->hi, (reg)->lo)
80ea8decf1Suwe 
81ea8decf1Suwe 
8218b82a67Smrg struct ebus_ranges {
8356109695Skent 	uint32_t	child_hi;	/* child high phys addr */
8456109695Skent 	uint32_t	child_lo;	/* child low phys addr */
8556109695Skent 	uint32_t	phys_hi;	/* parent high phys addr */
8656109695Skent 	uint32_t	phys_mid;	/* parent mid phys addr */
8756109695Skent 	uint32_t	phys_lo;	/* parent low phys addr */
8856109695Skent 	uint32_t	size;
8918b82a67Smrg };
9018b82a67Smrg 
9186de1d61Smrg struct ebus_mainbus_ranges {
9286de1d61Smrg 	u_int32_t	child_hi;
9386de1d61Smrg 	u_int32_t	child_lo;
9486de1d61Smrg 	u_int32_t	phys_hi;
9586de1d61Smrg 	u_int32_t	phys_lo;
9686de1d61Smrg 	u_int32_t	size;
9786de1d61Smrg };
9886de1d61Smrg 
99ea8decf1Suwe 
100ea8decf1Suwe /* NB: ms-IIep PROMs lack these interrupt-related properties */
10118b82a67Smrg struct ebus_interrupt_map {
10256109695Skent 	uint32_t	hi;		/* high phys addr mask */
10356109695Skent 	uint32_t	lo;		/* low phys addr mask */
10456109695Skent 	uint32_t	intr;		/* interrupt mask */
10518b82a67Smrg 	int32_t		cnode;		/* child node */
10656109695Skent 	uint32_t	cintr;		/* child interrupt */
10718b82a67Smrg };
10818b82a67Smrg 
10918b82a67Smrg struct ebus_interrupt_map_mask {
11056109695Skent 	uint32_t	hi;		/* high phys addr */
11156109695Skent 	uint32_t	lo;		/* low phys addr */
11256109695Skent 	uint32_t	intr;		/* interrupt */
11318b82a67Smrg };
11418b82a67Smrg 
115ea8decf1Suwe 
116ea8decf1Suwe /*
117ea8decf1Suwe  * DMA controller registers.
118ea8decf1Suwe  *
119ea8decf1Suwe  * The "next" registers are at the same locations.
120ea8decf1Suwe  * Which one you write to depends on EN_NEXT bit in the DCSR.
121ea8decf1Suwe  */
122ea8decf1Suwe #define EBUS_DMAC_DCSR	0	/* control/status register */
123ea8decf1Suwe #define EBUS_DMAC_DACR	4	/* address count register */
124ea8decf1Suwe #define EBUS_DMAC_DNAR	4	/* next address register */
125ea8decf1Suwe #define EBUS_DMAC_DBCR	8	/* byte count register */
126ea8decf1Suwe #define EBUS_DMAC_DNBR	8	/* next byte register */
127ea8decf1Suwe 
128284be9baSuwe #define EBUS_DMAC_SIZE	12
129284be9baSuwe 
130ea8decf1Suwe 
131ea8decf1Suwe /*
132ea8decf1Suwe  * DCSR bits (PCIO manual, Table 7-23, pp 134-135)
133ea8decf1Suwe  *
134ea8decf1Suwe  * On Reset all the register bits except ID will be 0 and CYC_PENDING
135ea8decf1Suwe  * will reflect the status of any pending requests.
136ea8decf1Suwe  */
137ea8decf1Suwe #define EBDMA_INT_PEND		0x00000001 /* interrupt pending */
138ea8decf1Suwe #define EBDMA_ERR_PEND		0x00000002 /* error pending */
139ea8decf1Suwe #define EBDMA_DRAIN		0x00000004 /* fifo's being drained to memory */
140ea8decf1Suwe #define EBDMA_INT_EN		0x00000010 /* enable interrupts */
141ea8decf1Suwe #define EBDMA_RESET		0x00000080 /* reset - write 0 to clear */
142ea8decf1Suwe #define EBDMA_WRITE		0x00000100 /* 0: mem->dev, 1: dev->mem */
143ea8decf1Suwe #define EBDMA_EN_DMA		0x00000200 /* enable DMA */
144ea8decf1Suwe #define EBDMA_CYC_PEND		0x00000400 /* DMA cycle pending
145ea8decf1Suwe 					      - not safe to clear reset */
146ea8decf1Suwe #define EBDMA_DIAG_RD_DONE	0x00000800 /* DIAG mode: DMA read completed */
147ea8decf1Suwe #define EBDMA_DIAG_WR_DONE	0x00001000 /* DIAG mode: DMA write completed */
148ea8decf1Suwe #define EBDMA_EN_CNT		0x00002000 /* enable byte counter */
149ea8decf1Suwe #define EBDMA_TC		0x00004000 /* terminal count
150ea8decf1Suwe 					      - write 1 to clear */
151ea8decf1Suwe #define EBDMA_DIS_CSR_DRN	0x00010000 /* disable fifo draining
152ea8decf1Suwe 					      on slave writes to CSR */
153ea8decf1Suwe #define EBDMA_BURST_SIZE_MASK	0x000c0000 /* burst sizes: */
154ea8decf1Suwe #define EBDMA_BURST_SIZE_4	    0x00000000 /* 00 -  4 words */
155ea8decf1Suwe #define EBDMA_BURST_SIZE_8	    0x00040000 /* 01 -  8 words */
156ea8decf1Suwe #define EBDMA_BURST_SIZE_1	    0x00080000 /* 10 -  1 word  */
157ea8decf1Suwe #define EBDMA_BURST_SIZE_16	    0x000c0000 /* 11 - 16 words */
158ea8decf1Suwe #define EBDMA_DIAG_EN		0x00100000 /* enable diag mode */
159ea8decf1Suwe #define EBDMA_DIS_ERR_PEND	0x00400000 /* disable stop/interrupt
160*0b988ad4Sandvar 					      on error pending */
161ea8decf1Suwe #define EBDMA_TCI_DIS		0x00800000 /* disable interrupt on TC */
162ea8decf1Suwe #define EBDMA_EN_NEXT		0x01000000 /* enable next address autoload
163ea8decf1Suwe 					      (must set EN_CNT too) */
164ea8decf1Suwe #define EBDMA_DMA_ON		0x02000000 /* DMA is able to respond */
165ea8decf1Suwe #define EBDMA_A_LOADED		0x04000000 /* DACR loaded
166ea8decf1Suwe 					      (directly or from DNAR) */
167ea8decf1Suwe #define EBDMA_NA_LOADED		0x08000000 /* DNAR loaded */
168ea8decf1Suwe #define EBDMA_ID_MASK		0xf0000000 /* Device ID = 0xC */
169ea8decf1Suwe 
170ea8decf1Suwe #define EBUS_DCSR_BITS \
171ea8decf1Suwe     "\20\34NA_LOADED\33A_LOADED\32DMA_ON\31EN_NEXT\30TCI_DIS\27DIS_ERR_PEND" \
172ea8decf1Suwe     "\25DIAG_EN\21DIS_CSR_DRN\17TC\16EN_CNT\15DIAG_WR_DONE\14DIAG_RD_DONE"   \
173ea8decf1Suwe     "\13CYC_PEND\12EN_DMA\11WRITE\10RESET\6INT_EN\3DRAIN\2ERR_PEND\1INT_PEND"
174ea8decf1Suwe 
175ea8decf1Suwe #endif /* _DEV_EBUS_EBUSREG_H_ */
176