xref: /freebsd/sys/powerpc/include/openpicreg.h (revision 05c62b81bf0744f523e710c6fd41c3e0d0eb4f30)
1b7ac1056SBenno Rice /*-
2b7ac1056SBenno Rice  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
3b7ac1056SBenno Rice  *
4b7ac1056SBenno Rice  * Redistribution and use in source and binary forms, with or without
5b7ac1056SBenno Rice  * modification, are permitted provided that the following conditions
6b7ac1056SBenno Rice  * are met:
7b7ac1056SBenno Rice  * 1. Redistributions of source code must retain the above copyright
8b7ac1056SBenno Rice  *    notice, this list of conditions and the following disclaimer.
9b7ac1056SBenno Rice  * 2. Redistributions in binary form must reproduce the above copyright
10b7ac1056SBenno Rice  *    notice, this list of conditions and the following disclaimer in the
11b7ac1056SBenno Rice  *    documentation and/or other materials provided with the distribution.
12b7ac1056SBenno Rice  * 3. The name of the author may not be used to endorse or promote products
13b7ac1056SBenno Rice  *    derived from this software without specific prior written permission.
14b7ac1056SBenno Rice  *
15b7ac1056SBenno Rice  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16b7ac1056SBenno Rice  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17b7ac1056SBenno Rice  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18b7ac1056SBenno Rice  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19b7ac1056SBenno Rice  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20b7ac1056SBenno Rice  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21b7ac1056SBenno Rice  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22b7ac1056SBenno Rice  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23b7ac1056SBenno Rice  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24b7ac1056SBenno Rice  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25b7ac1056SBenno Rice  *
26ca019208SBenno Rice  * from NetBSD: openpicreg.h,v 1.3 2001/08/30 03:08:52 briggs Exp
27b7ac1056SBenno Rice  * $FreeBSD$
28b7ac1056SBenno Rice  */
29b7ac1056SBenno Rice 
30b7ac1056SBenno Rice /*
31ca019208SBenno Rice  * Size of OpenPIC register space
32ca019208SBenno Rice  */
33ca019208SBenno Rice #define	OPENPIC_SIZE			0x40000
34ca019208SBenno Rice 
35ca019208SBenno Rice /*
3605c62b81SMarcel Moolenaar  * Per Processor Registers [private access] (0x00000 - 0x00fff)
3705c62b81SMarcel Moolenaar  */
3805c62b81SMarcel Moolenaar 
3905c62b81SMarcel Moolenaar /* IPI dispatch command reg */
4005c62b81SMarcel Moolenaar #define	OPENPIC_IPI_DISPATCH(ipi)	(0x40 + (ipi) * 0x10)
4105c62b81SMarcel Moolenaar 
4205c62b81SMarcel Moolenaar /* current task priority reg */
4305c62b81SMarcel Moolenaar #define	OPENPIC_TPR			0x80
4405c62b81SMarcel Moolenaar #define  OPENPIC_TPR_MASK			0x0000000f
4505c62b81SMarcel Moolenaar 
4605c62b81SMarcel Moolenaar #define	OPENPIC_WHOAMI			0x90
4705c62b81SMarcel Moolenaar 
4805c62b81SMarcel Moolenaar /* interrupt acknowledge reg */
4905c62b81SMarcel Moolenaar #define	OPENPIC_IACK			0xa0
5005c62b81SMarcel Moolenaar 
5105c62b81SMarcel Moolenaar /* end of interrupt reg */
5205c62b81SMarcel Moolenaar #define	OPENPIC_EOI			0xb0
5305c62b81SMarcel Moolenaar 
5405c62b81SMarcel Moolenaar /*
5505c62b81SMarcel Moolenaar  * Global registers (0x01000-0x0ffff)
56b7ac1056SBenno Rice  */
57b7ac1056SBenno Rice 
58b7ac1056SBenno Rice /* feature reporting reg 0 */
59b7ac1056SBenno Rice #define OPENPIC_FEATURE			0x1000
60ca019208SBenno Rice #define	 OPENPIC_FEATURE_VERSION_MASK		0x000000ff
61ca019208SBenno Rice #define	 OPENPIC_FEATURE_LAST_CPU_MASK		0x00001f00
62ca019208SBenno Rice #define	 OPENPIC_FEATURE_LAST_CPU_SHIFT		8
63ca019208SBenno Rice #define	 OPENPIC_FEATURE_LAST_IRQ_MASK		0x07ff0000
64ca019208SBenno Rice #define	 OPENPIC_FEATURE_LAST_IRQ_SHIFT		16
65b7ac1056SBenno Rice 
66b7ac1056SBenno Rice /* global config reg 0 */
67b7ac1056SBenno Rice #define OPENPIC_CONFIG			0x1020
68b7ac1056SBenno Rice #define  OPENPIC_CONFIG_RESET			0x80000000
69b7ac1056SBenno Rice #define  OPENPIC_CONFIG_8259_PASSTHRU_DISABLE	0x20000000
70b7ac1056SBenno Rice 
71ca019208SBenno Rice /* interrupt configuration mode (direct or serial) */
72ca019208SBenno Rice #define OPENPIC_ICR			0x1030
73ca019208SBenno Rice #define  OPENPIC_ICR_SERIAL_MODE		(1 << 27)
74ca019208SBenno Rice #define  OPENPIC_ICR_SERIAL_RATIO_MASK		(0x7 << 28)
75ca019208SBenno Rice #define  OPENPIC_ICR_SERIAL_RATIO_SHIFT		28
76ca019208SBenno Rice 
77b7ac1056SBenno Rice /* vendor ID */
78b7ac1056SBenno Rice #define OPENPIC_VENDOR_ID		0x1080
79b7ac1056SBenno Rice 
80b7ac1056SBenno Rice /* processor initialization reg */
81b7ac1056SBenno Rice #define OPENPIC_PROC_INIT		0x1090
82b7ac1056SBenno Rice 
83b7ac1056SBenno Rice /* IPI vector/priority reg */
84b7ac1056SBenno Rice #define OPENPIC_IPI_VECTOR(ipi)		(0x10a0 + (ipi) * 0x10)
85b7ac1056SBenno Rice 
86b7ac1056SBenno Rice /* spurious intr. vector */
87b7ac1056SBenno Rice #define OPENPIC_SPURIOUS_VECTOR		0x10e0
88b7ac1056SBenno Rice 
8905c62b81SMarcel Moolenaar /* Timer registers */
9005c62b81SMarcel Moolenaar #define	OPENPIC_TIMERS			4
9105c62b81SMarcel Moolenaar #define	OPENPIC_TFREQ			0x10f0
9205c62b81SMarcel Moolenaar #define	OPENPIC_TCNT(t)			(0x1100 + (t) * 0x40)
9305c62b81SMarcel Moolenaar #define	OPENPIC_TBASE(t)		(0x1110 + (t) * 0x40)
9405c62b81SMarcel Moolenaar #define	OPENPIC_TVEC(t)			(0x1120 + (t) * 0x40)
9505c62b81SMarcel Moolenaar #define	OPENPIC_TDST(t)			(0x1130 + (t) * 0x40)
96b7ac1056SBenno Rice 
97b7ac1056SBenno Rice /*
9805c62b81SMarcel Moolenaar  * Interrupt Source Configuration Registers (0x10000 - 0x1ffff)
99b7ac1056SBenno Rice  */
100b7ac1056SBenno Rice 
101b7ac1056SBenno Rice /* interrupt vector/priority reg */
102b7ac1056SBenno Rice #ifndef OPENPIC_SRC_VECTOR
103b7ac1056SBenno Rice #define OPENPIC_SRC_VECTOR(irq)		(0x10000 + (irq) * 0x20)
104b7ac1056SBenno Rice #endif
105b7ac1056SBenno Rice #define  OPENPIC_SENSE_LEVEL			0x00400000
106b7ac1056SBenno Rice #define  OPENPIC_SENSE_EDGE			0x00000000
107b7ac1056SBenno Rice #define  OPENPIC_POLARITY_POSITIVE		0x00800000
108b7ac1056SBenno Rice #define  OPENPIC_POLARITY_NEGATIVE		0x00000000
109b7ac1056SBenno Rice #define  OPENPIC_IMASK				0x80000000
110b7ac1056SBenno Rice #define  OPENPIC_ACTIVITY			0x40000000
111b7ac1056SBenno Rice #define  OPENPIC_PRIORITY_MASK			0x000f0000
112b7ac1056SBenno Rice #define  OPENPIC_PRIORITY_SHIFT			16
113b7ac1056SBenno Rice #define  OPENPIC_VECTOR_MASK			0x000000ff
114b7ac1056SBenno Rice 
115b7ac1056SBenno Rice /* interrupt destination cpu */
116b7ac1056SBenno Rice #ifndef OPENPIC_IDEST
117b7ac1056SBenno Rice #define OPENPIC_IDEST(irq)		(0x10010 + (irq) * 0x20)
118b7ac1056SBenno Rice #endif
119b7ac1056SBenno Rice 
120b7ac1056SBenno Rice /*
12105c62b81SMarcel Moolenaar  * Per Processor Registers [global access] (0x20000 - 0x3ffff)
122b7ac1056SBenno Rice  */
123b7ac1056SBenno Rice 
12405c62b81SMarcel Moolenaar #define	OPENPIC_PCPU_BASE(cpu)		(0x20000 + (cpu) * 0x1000)
125b7ac1056SBenno Rice 
12605c62b81SMarcel Moolenaar #define	OPENPIC_PCPU_IPI_DISPATCH(cpu, ipi)	\
12705c62b81SMarcel Moolenaar 	(OPENPIC_PCPU_BASE(cpu) + OPENPIC_IPI_DISPATCH(ipi))
128b7ac1056SBenno Rice 
12905c62b81SMarcel Moolenaar #define	OPENPIC_PCPU_TPR(cpu)		\
13005c62b81SMarcel Moolenaar 	(OPENPIC_PCPU_BASE(cpu) + OPENPIC_TPR)
131b7ac1056SBenno Rice 
13205c62b81SMarcel Moolenaar #define	OPENPIC_PCPU_WHOAMI(cpu)		\
13305c62b81SMarcel Moolenaar 	(OPENPIC_PCPU_BASE(cpu) + OPENPIC_WHOAMI)
13405c62b81SMarcel Moolenaar 
13505c62b81SMarcel Moolenaar #define OPENPIC_PCPU_IACK(cpu)			\
13605c62b81SMarcel Moolenaar 	(OPENPIC_PCPU_BASE(cpu) + OPENPIC_IACK)
13705c62b81SMarcel Moolenaar 
13805c62b81SMarcel Moolenaar #define OPENPIC_PCPU_EOI(cpu)			\
13905c62b81SMarcel Moolenaar 	(OPENPIC_PCPU_BASE(cpu) + OPENPIC_EOI)
14005c62b81SMarcel Moolenaar 
141