hrowpicvar.h revision 139825
1168515Sgshapiro/*-
2168515Sgshapiro * Copyright 2003 by Peter Grehan. All rights reserved.
3168515Sgshapiro *
4168515Sgshapiro * Redistribution and use in source and binary forms, with or without
5244833Sgshapiro * modification, are permitted provided that the following conditions
6168515Sgshapiro * are met:
7168515Sgshapiro * 1. Redistributions of source code must retain the above copyright
8168515Sgshapiro *    notice, this list of conditions and the following disclaimer.
9168515Sgshapiro * 2. Redistributions in binary form must reproduce the above copyright
10168515Sgshapiro *    notice, this list of conditions and the following disclaimer in the
11168515Sgshapiro *    documentation and/or other materials provided with the distribution.
12168515Sgshapiro * 3. The name of the author may not be used to endorse or promote products
13168515Sgshapiro *    derived from this software without specific prior written permission.
14168515Sgshapiro *
15168515Sgshapiro * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16168515Sgshapiro * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17168515Sgshapiro * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18168515Sgshapiro * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19168515Sgshapiro * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20168515Sgshapiro * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21168515Sgshapiro * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22168515Sgshapiro * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23168515Sgshapiro * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24168515Sgshapiro * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25168515Sgshapiro * SUCH DAMAGE.
26168515Sgshapiro *
27168515Sgshapiro * $FreeBSD: head/sys/powerpc/powermac/hrowpicvar.h 139825 2005-01-07 02:29:27Z imp $
28168515Sgshapiro */
29168515Sgshapiro
30168515Sgshapiro#ifndef  _POWERPC_POWERMAC_HROWPICVAR_H_
31168515Sgshapiro#define  _POWERPC_POWERMAC_HROWPICVAR_H_
32168515Sgshapiro
33168515Sgshapiro#define HROWPIC_IRQMAX	64
34168515Sgshapiro#define HROWPIC_IRQ_REGNUM	32	/* irqs per register */
35168515Sgshapiro#define HROWPIC_IRQ_SHIFT	5	/* high or low irq word */
36168515Sgshapiro#define HROWPIC_IRQ_MASK ((HROWPIC_IRQMAX-1) >> 1)  /* irq bit pos in word */
37168515Sgshapiro
38168515Sgshapiro/*
39168515Sgshapiro * Register offsets within bank. There are two identical banks,
40168515Sgshapiro * separated by 16 bytes. Interrupts 0->31 are processed in the
41168515Sgshapiro * second bank, and 32->63 in the first bank.
42168515Sgshapiro */
43168515Sgshapiro#define  HPIC_STATUS	0x00		/* active interrupt sources */
44168515Sgshapiro#define  HPIC_ENABLE	0x04		/* interrupt asserts ppc EXTINT */
45168515Sgshapiro#define  HPIC_CLEAR	0x08		/* clear int source */
46168515Sgshapiro#define  HPIC_TRIGGER	0x0c		/* edge/level int trigger */
47168515Sgshapiro
48168515Sgshapiro#define HPIC_PRIMARY	1	/* primary register bank */
49168515Sgshapiro#define HPIC_SECONDARY  0       /* secondary register bank */
50168515Sgshapiro
51168515Sgshapiro/*
52168515Sgshapiro * Convert an interrupt into a prim/sec bank number
53168515Sgshapiro */
54168515Sgshapiro#define HPIC_INT_TO_BANK(x) \
55168515Sgshapiro	(((x) >> HROWPIC_IRQ_SHIFT) ^ 1)
56168515Sgshapiro
57168515Sgshapiro/*
58168515Sgshapiro * Convert an interrupt into the bit number within a bank register
59168515Sgshapiro */
60168515Sgshapiro#define HPIC_INT_TO_REGBIT(x) \
61168515Sgshapiro	((x) & HROWPIC_IRQ_MASK)
62168515Sgshapiro
63168515Sgshapiro#define  HPIC_1ST_OFFSET  0x10		/* offset to primary reg bank */
64168515Sgshapiro
65168515Sgshapiro
66168515Sgshapirostruct hrowpic_softc {
67168515Sgshapiro	struct		rman sc_rman;		/* resource mgr for IRQs */
68168515Sgshapiro	u_int32_t	sc_irq[HROWPIC_IRQMAX];	/* allocated IRQ flags */
69168515Sgshapiro	u_int32_t	sc_softreg[2];		/* ENABLE reg copy */
70168515Sgshapiro	device_t       	sc_maciodev;		/* macio device */
71168515Sgshapiro	struct resource *sc_memr;		/* macio bus resource */
72168515Sgshapiro	bus_space_tag_t sc_bt;			/* macio bus tag/handle */
73168515Sgshapiro	bus_space_handle_t sc_bh;
74168515Sgshapiro};
75168515Sgshapiro
76168515Sgshapiro
77168515Sgshapiro#endif  /* _POWERPC_POWERMAC_HROWPICVAR_H_ */
78168515Sgshapiro