1139825Simp/*-
288699Stmm * Copyright (c) 1992, 1993
388699Stmm *	The Regents of the University of California.  All rights reserved.
488699Stmm *
588699Stmm * This software was developed by the Computer Systems Engineering group
688699Stmm * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
788699Stmm * contributed to Berkeley.
888699Stmm *
988699Stmm * Redistribution and use in source and binary forms, with or without
1088699Stmm * modification, are permitted provided that the following conditions
1188699Stmm * are met:
1288699Stmm * 1. Redistributions of source code must retain the above copyright
1388699Stmm *    notice, this list of conditions and the following disclaimer.
1488699Stmm * 2. Redistributions in binary form must reproduce the above copyright
1588699Stmm *    notice, this list of conditions and the following disclaimer in the
1688699Stmm *    documentation and/or other materials provided with the distribution.
1788699Stmm * 4. Neither the name of the University nor the names of its contributors
1888699Stmm *    may be used to endorse or promote products derived from this software
1988699Stmm *    without specific prior written permission.
2088699Stmm *
2188699Stmm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2288699Stmm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2388699Stmm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2488699Stmm * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2588699Stmm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2688699Stmm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2788699Stmm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2888699Stmm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2988699Stmm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3088699Stmm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3188699Stmm * SUCH DAMAGE.
3288699Stmm *
3388699Stmm *	form: @(#)sbusreg.h	8.1 (Berkeley) 6/11/93
3488699Stmm *	from: NetBSD: iommureg.h,v 1.6 2001/07/20 00:07:13 eeh Exp
3588699Stmm *
3688699Stmm * $FreeBSD$
3788699Stmm */
3888699Stmm
3988699Stmm#ifndef _MACHINE_BUS_COMMON_H_
40172064Smarius#define	_MACHINE_BUS_COMMON_H_
4188699Stmm
42200878Smarius#define	INTCLR_PENDING		0x000000003ULL	/* Interrupt queued to CPU */
43200878Smarius#define	INTCLR_RECEIVED		0x000000001ULL	/* Interrupt received */
44200878Smarius#define	INTCLR_IDLE		0x000000000ULL	/* Interrupt idle */
45200878Smarius
46200876Smarius#define	INTMAP_V		0x080000000ULL	/* Interrupt valid (enabled) */
47200876Smarius#define	INTMAP_TID_MASK		0x07c000000ULL	/* UPA target ID */
48172064Smarius#define	INTMAP_TID_SHIFT	26
49200876Smarius#define	INTMAP_IGN_MASK		0x0000007c0ULL	/* Interrupt group no. */
50172064Smarius#define	INTMAP_IGN_SHIFT	6
51200876Smarius#define	INTMAP_INO_MASK		0x00000003fULL	/* Interrupt number */
52172064Smarius#define	INTMAP_INR_MASK		(INTMAP_IGN_MASK | INTMAP_INO_MASK)
53200876Smarius#define	INTMAP_SBUSSLOT_MASK	0x000000018ULL	/* SBus slot # */
54200876Smarius#define	INTMAP_PCIBUS_MASK	0x000000010ULL	/* PCI bus number (A or B) */
55200876Smarius#define	INTMAP_PCISLOT_MASK	0x00000000cULL	/* PCI slot # */
56200876Smarius#define	INTMAP_PCIINT_MASK	0x000000003ULL	/* PCI interrupt #A,#B,#C,#D */
57200876Smarius#define	INTMAP_OBIO_MASK	0x000000020ULL	/* Onboard device */
58172066Smarius#define	INTIGN(x)		(((x) & INTMAP_IGN_MASK) >> INTMAP_IGN_SHIFT)
59172064Smarius#define	INTVEC(x)		((x) & INTMAP_INR_MASK)
60172064Smarius#define	INTSLOT(x)		(((x) >> 3) & 0x7)
61107477Stmm#define	INTPRI(x)		((x) & 0x7)
62107477Stmm#define	INTINO(x)		((x) & INTMAP_INO_MASK)
63178443Smarius#define	INTMAP_ENABLE(mr, mid)						\
64178443Smarius	(INTMAP_TID((mr), (mid)) | INTMAP_V)
65178443Smarius#define	INTMAP_TID(mr, mid)						\
66178443Smarius	(((mr) & ~INTMAP_TID_MASK) | ((mid) << INTMAP_TID_SHIFT))
67200878Smarius#define	INTMAP_VEC(ign, ino)						\
68178443Smarius	((((ign) << INTMAP_IGN_SHIFT) & INTMAP_IGN_MASK) |		\
69200878Smarius	((ino) & INTMAP_INO_MASK))
7088699Stmm
7190619Stmm/* counter-timer support. */
72178840Smariusvoid sparc64_counter_init(const char *name, bus_space_tag_t tag,
73178840Smarius    bus_space_handle_t handle, bus_addr_t offset);
7490619Stmm
7588699Stmm#endif	/* !_MACHINE_BUS_COMMON_H_ */
76