Home | History | Annotate | Line # | Download | only in ebus
ebusreg.h revision 1.8.26.1
      1  1.8.26.1  jruoho /*	$NetBSD: ebusreg.h,v 1.8.26.1 2011/06/06 09:07:48 jruoho Exp $	*/
      2       1.1     mrg 
      3       1.1     mrg /*
      4       1.1     mrg  * Copyright (c) 1999 Matthew R. Green
      5       1.1     mrg  * All rights reserved.
      6       1.1     mrg  *
      7       1.1     mrg  * Redistribution and use in source and binary forms, with or without
      8       1.1     mrg  * modification, are permitted provided that the following conditions
      9       1.1     mrg  * are met:
     10       1.1     mrg  * 1. Redistributions of source code must retain the above copyright
     11       1.1     mrg  *    notice, this list of conditions and the following disclaimer.
     12       1.1     mrg  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1     mrg  *    notice, this list of conditions and the following disclaimer in the
     14       1.1     mrg  *    documentation and/or other materials provided with the distribution.
     15       1.1     mrg  *
     16       1.1     mrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17       1.1     mrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18       1.1     mrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19       1.1     mrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20       1.1     mrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21       1.1     mrg  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22       1.1     mrg  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23       1.1     mrg  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24       1.1     mrg  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25       1.1     mrg  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26       1.1     mrg  * SUCH DAMAGE.
     27       1.1     mrg  */
     28       1.1     mrg 
     29       1.2     uwe #ifndef _DEV_EBUS_EBUSREG_H_
     30       1.2     uwe #define _DEV_EBUS_EBUSREG_H_
     31       1.1     mrg 
     32       1.1     mrg /*
     33       1.1     mrg  * SPARC `ebus'
     34       1.1     mrg  *
     35       1.1     mrg  * The `ebus' bus is designed to plug traditional PC-ISA devices into
     36       1.1     mrg  * an SPARC system with as few costs as possible, without sacrificing
     37       1.1     mrg  * to performance.  Typically, it is implemented in the PCIO IC from
     38       1.1     mrg  * SME, which also implements a `hme-compatible' PCI network device
     39       1.1     mrg  * (`network').  The ebus has 4 DMA channels, similar to the DMA seen
     40       1.1     mrg  * in the ESP SCSI DMA.
     41       1.1     mrg  *
     42       1.1     mrg  * Typical UltraSPARC systems have a NatSemi SuperIO IC to provide
     43       1.1     mrg  * serial ports for the keyboard and mouse (`se'), floppy disk
     44       1.1     mrg  * controller (`fdthree'), parallel port controller (`bpp') connected
     45       1.1     mrg  * to the ebus, and a PCI-IDE controller (connected directly to the
     46       1.1     mrg  * PCI bus, of course), as well as a Siemens Nixdorf SAB82532 dual
     47       1.1     mrg  * channel serial controller (`su' providing ttya and ttyb), an MK48T59
     48       1.1     mrg  * EEPROM/clock controller (also where the idprom, including the
     49       1.1     mrg  * ethernet address, is located), the audio system (`SUNW,CS4231', same
     50       1.1     mrg  * as other UltraSPARC and some SPARC systems), and other various
     51       1.1     mrg  * internal devices found on traditional SPARC systems such as the
     52       1.1     mrg  * `power', `flashprom', etc., devices.  Other machines with this
     53       1.2     uwe  * device include microSPARC-IIep based systems, e.g. JavaStation10.
     54       1.1     mrg  *
     55       1.1     mrg  * The ebus uses an interrupt mapping scheme similar to PCI, though
     56       1.1     mrg  * the actual structures are different.
     57       1.1     mrg  */
     58       1.1     mrg 
     59       1.1     mrg /*
     60       1.2     uwe  * EBus PROM structures.  There's no official OFW binding for EBus,
     61       1.2     uwe  * so ms-IIep PROMs deviate from de-facto standard used on Ultra's.
     62       1.2     uwe  *
     63       1.2     uwe  * EBus address is represented in PROM by 2 cells: bar and offset.
     64       1.2     uwe  * "bar" specifies the EBus BAR register used to translate the
     65       1.2     uwe  * "offset" into PCI address space.
     66       1.6   perry  *
     67       1.2     uwe  * On Ultra the bar is the _offset_ of the BAR in PCI config space but
     68       1.2     uwe  * in (some?) ms-IIep systems (e.g. Krups) it's the _number_ of the
     69       1.2     uwe  * BAR - e.g. BAR1 is represented by 1 in Krups PROM, while on Ultra
     70       1.2     uwe  * it's 0x14.
     71       1.1     mrg  */
     72       1.1     mrg 
     73       1.1     mrg struct ebus_regs {
     74       1.5    kent 	uint32_t	hi;		/* high bits of physaddr */
     75       1.5    kent 	uint32_t	lo;
     76       1.5    kent 	uint32_t	size;
     77       1.1     mrg };
     78       1.1     mrg 
     79       1.2     uwe #define	EBUS_ADDR_FROM_REG(reg)		BUS_ADDR((reg)->hi, (reg)->lo)
     80       1.2     uwe 
     81       1.2     uwe 
     82       1.1     mrg struct ebus_ranges {
     83       1.5    kent 	uint32_t	child_hi;	/* child high phys addr */
     84       1.5    kent 	uint32_t	child_lo;	/* child low phys addr */
     85       1.5    kent 	uint32_t	phys_hi;	/* parent high phys addr */
     86       1.5    kent 	uint32_t	phys_mid;	/* parent mid phys addr */
     87       1.5    kent 	uint32_t	phys_lo;	/* parent low phys addr */
     88       1.5    kent 	uint32_t	size;
     89       1.1     mrg };
     90       1.1     mrg 
     91  1.8.26.1  jruoho struct ebus_mainbus_ranges {
     92  1.8.26.1  jruoho 	u_int32_t	child_hi;
     93  1.8.26.1  jruoho 	u_int32_t	child_lo;
     94  1.8.26.1  jruoho 	u_int32_t	phys_hi;
     95  1.8.26.1  jruoho 	u_int32_t	phys_lo;
     96  1.8.26.1  jruoho 	u_int32_t	size;
     97  1.8.26.1  jruoho };
     98  1.8.26.1  jruoho 
     99       1.2     uwe 
    100       1.2     uwe /* NB: ms-IIep PROMs lack these interrupt-related properties */
    101       1.1     mrg struct ebus_interrupt_map {
    102       1.5    kent 	uint32_t	hi;		/* high phys addr mask */
    103       1.5    kent 	uint32_t	lo;		/* low phys addr mask */
    104       1.5    kent 	uint32_t	intr;		/* interrupt mask */
    105       1.1     mrg 	int32_t		cnode;		/* child node */
    106       1.5    kent 	uint32_t	cintr;		/* child interrupt */
    107       1.1     mrg };
    108       1.1     mrg 
    109       1.1     mrg struct ebus_interrupt_map_mask {
    110       1.5    kent 	uint32_t	hi;		/* high phys addr */
    111       1.5    kent 	uint32_t	lo;		/* low phys addr */
    112       1.5    kent 	uint32_t	intr;		/* interrupt */
    113       1.1     mrg };
    114       1.1     mrg 
    115       1.2     uwe 
    116       1.2     uwe /*
    117       1.2     uwe  * DMA controller registers.
    118       1.6   perry  *
    119       1.2     uwe  * The "next" registers are at the same locations.
    120       1.2     uwe  * Which one you write to depends on EN_NEXT bit in the DCSR.
    121       1.2     uwe  */
    122       1.2     uwe #define EBUS_DMAC_DCSR	0	/* control/status register */
    123       1.2     uwe #define EBUS_DMAC_DACR	4	/* address count register */
    124       1.2     uwe #define EBUS_DMAC_DNAR	4	/* next address register */
    125       1.2     uwe #define EBUS_DMAC_DBCR	8	/* byte count register */
    126       1.2     uwe #define EBUS_DMAC_DNBR	8	/* next byte register */
    127       1.2     uwe 
    128       1.4     uwe #define EBUS_DMAC_SIZE	12
    129       1.4     uwe 
    130       1.2     uwe 
    131       1.2     uwe /*
    132       1.2     uwe  * DCSR bits (PCIO manual, Table 7-23, pp 134-135)
    133       1.6   perry  *
    134       1.2     uwe  * On Reset all the register bits except ID will be 0 and CYC_PENDING
    135       1.2     uwe  * will reflect the status of any pending requests.
    136       1.2     uwe  */
    137       1.2     uwe #define EBDMA_INT_PEND		0x00000001 /* interrupt pending */
    138       1.2     uwe #define EBDMA_ERR_PEND		0x00000002 /* error pending */
    139       1.2     uwe #define EBDMA_DRAIN		0x00000004 /* fifo's being drained to memory */
    140       1.2     uwe #define EBDMA_INT_EN		0x00000010 /* enable interrupts */
    141       1.2     uwe #define EBDMA_RESET		0x00000080 /* reset - write 0 to clear */
    142       1.2     uwe #define EBDMA_WRITE		0x00000100 /* 0: mem->dev, 1: dev->mem */
    143       1.2     uwe #define EBDMA_EN_DMA		0x00000200 /* enable DMA */
    144       1.6   perry #define EBDMA_CYC_PEND		0x00000400 /* DMA cycle pending
    145       1.2     uwe 					      - not safe to clear reset */
    146       1.2     uwe #define EBDMA_DIAG_RD_DONE	0x00000800 /* DIAG mode: DMA read completed */
    147       1.2     uwe #define EBDMA_DIAG_WR_DONE	0x00001000 /* DIAG mode: DMA write completed */
    148       1.2     uwe #define EBDMA_EN_CNT		0x00002000 /* enable byte counter */
    149       1.2     uwe #define EBDMA_TC		0x00004000 /* terminal count
    150       1.2     uwe 					      - write 1 to clear */
    151       1.2     uwe #define EBDMA_DIS_CSR_DRN	0x00010000 /* disable fifo draining
    152       1.2     uwe 					      on slave writes to CSR */
    153       1.2     uwe #define EBDMA_BURST_SIZE_MASK	0x000c0000 /* burst sizes: */
    154       1.2     uwe #define EBDMA_BURST_SIZE_4	    0x00000000 /* 00 -  4 words */
    155       1.2     uwe #define EBDMA_BURST_SIZE_8	    0x00040000 /* 01 -  8 words */
    156       1.2     uwe #define EBDMA_BURST_SIZE_1	    0x00080000 /* 10 -  1 word  */
    157       1.2     uwe #define EBDMA_BURST_SIZE_16	    0x000c0000 /* 11 - 16 words */
    158       1.2     uwe #define EBDMA_DIAG_EN		0x00100000 /* enable diag mode */
    159       1.2     uwe #define EBDMA_DIS_ERR_PEND	0x00400000 /* disable stop/interrupt
    160       1.2     uwe 					      on error pedning */
    161       1.2     uwe #define EBDMA_TCI_DIS		0x00800000 /* disable interrupt on TC */
    162       1.2     uwe #define EBDMA_EN_NEXT		0x01000000 /* enable next address autoload
    163       1.2     uwe 					      (must set EN_CNT too) */
    164       1.2     uwe #define EBDMA_DMA_ON		0x02000000 /* DMA is able to respond */
    165       1.2     uwe #define EBDMA_A_LOADED		0x04000000 /* DACR loaded
    166       1.2     uwe 					      (directly or from DNAR) */
    167       1.2     uwe #define EBDMA_NA_LOADED		0x08000000 /* DNAR loaded */
    168       1.2     uwe #define EBDMA_ID_MASK		0xf0000000 /* Device ID = 0xC */
    169       1.2     uwe 
    170       1.2     uwe #define EBUS_DCSR_BITS \
    171       1.2     uwe     "\20\34NA_LOADED\33A_LOADED\32DMA_ON\31EN_NEXT\30TCI_DIS\27DIS_ERR_PEND" \
    172       1.2     uwe     "\25DIAG_EN\21DIS_CSR_DRN\17TC\16EN_CNT\15DIAG_WR_DONE\14DIAG_RD_DONE"   \
    173       1.2     uwe     "\13CYC_PEND\12EN_DMA\11WRITE\10RESET\6INT_EN\3DRAIN\2ERR_PEND\1INT_PEND"
    174       1.2     uwe 
    175       1.2     uwe #endif /* _DEV_EBUS_EBUSREG_H_ */
    176