RTEMS 7.0-rc1
Loading...
Searching...
No Matches
openpic.h
1/* SPDX-License-Identifier: GPL-2.0+-with-RTEMS-exception */
2
3/*
4 * openpic.h -- OpenPIC definitions
5 *
6 * Copyright (C) 1997 Geert Uytterhoeven
7 *
8 * This file is based on the following documentation:
9 *
10 * The Open Programmable Interrupt Controller (PIC)
11 * Register Interface Specification Revision 1.2
12 *
13 * Issue Date: October 1995
14 *
15 * Issued jointly by Advanced Micro Devices and Cyrix Corporation
16 *
17 * AMD is a registered trademark of Advanced Micro Devices, Inc.
18 * Copyright (C) 1995, Advanced Micro Devices, Inc. and Cyrix, Inc.
19 * All Rights Reserved.
20 *
21 * To receive a copy of this documentation, send an email to openpic@amd.com.
22 *
23 * This file is subject to the terms and conditions of the GNU General Public
24 * License. See the file COPYING in the main directory of this archive
25 * for more details.
26 *
27 * Modified to compile in RTEMS development environment
28 * by Eric Valette
29 *
30 * Copyright (c) 1999 Eric Valette <eric.valette@free.fr>
31 *
32 * The license and distribution terms for this file may be
33 * found in the file LICENSE in this distribution or at
34 * http://www.rtems.org/license/LICENSE.
35 */
36
37#ifndef _RTEMS_OPENPIC_H
38#define _RTEMS_OPENPIC_H
39
40 /*
41 * OpenPIC supports up to 2048 interrupt sources and up to 32 processors
42 */
43#define OPENPIC_MAX_SOURCES 2048
44#define OPENPIC_MAX_PROCESSORS 32
45
46#define OPENPIC_NUM_TIMERS 4
47#define OPENPIC_NUM_IPI 4
48#define OPENPIC_NUM_PRI 16
49#define OPENPIC_NUM_VECTORS 256
50
51 /*
52 * Vector numbers
53 */
54
55#define OPENPIC_VEC_SOURCE 0x10 /* and up */
56#define OPENPIC_VEC_TIMER 0x40 /* and up */
57#define OPENPIC_VEC_IPI 0x50 /* and up */
58#define OPENPIC_VEC_SPURIOUS 99
59
60 /*
61 * OpenPIC Registers are 32 bits and aligned on 128 bit boundaries
62 */
63
64typedef struct _OpenPIC_Reg {
65 unsigned int Reg; /* Little endian! */
66 char Pad[0xc];
68
69 /*
70 * Per Processor Registers
71 */
72
73typedef struct _OpenPIC_Processor {
74 /*
75 * Private Shadow Registers (for SLiC backwards compatibility)
76 */
77 unsigned int IPI0_Dispatch_Shadow; /* Write Only */
78 char Pad1[0x4];
79 unsigned int IPI0_Vector_Priority_Shadow; /* Read/Write */
80 char Pad2[0x34];
81 /*
82 * Interprocessor Interrupt Command Ports
83 */
84 OpenPIC_Reg _IPI_Dispatch[OPENPIC_NUM_IPI]; /* Write Only */
85 /*
86 * Current Task Priority Register
87 */
88 OpenPIC_Reg _Current_Task_Priority; /* Read/Write */
89 char Pad3[0x10];
90 /*
91 * Interrupt Acknowledge Register
92 */
93 OpenPIC_Reg _Interrupt_Acknowledge; /* Read Only */
94 /*
95 * End of Interrupt (EOI) Register
96 */
97 OpenPIC_Reg _EOI; /* Read/Write */
98 char Pad5[0xf40];
100
101 /*
102 * Timer Registers
103 */
104
105typedef struct _OpenPIC_Timer {
106 OpenPIC_Reg _Current_Count; /* Read Only */
107 OpenPIC_Reg _Base_Count; /* Read/Write */
108 OpenPIC_Reg _Vector_Priority; /* Read/Write */
109 OpenPIC_Reg _Destination; /* Read/Write */
111
112 /*
113 * Global Registers
114 */
115
116typedef struct _OpenPIC_Global {
117 /*
118 * Feature Reporting Registers
119 */
120 OpenPIC_Reg _Feature_Reporting0; /* Read Only */
121 OpenPIC_Reg _Feature_Reporting1; /* Future Expansion */
122 /*
123 * Global Configuration Registers
124 */
125 OpenPIC_Reg _Global_Configuration0; /* Read/Write */
126 OpenPIC_Reg _Global_Configuration1; /* Future Expansion */
127 /*
128 * Vendor Specific Registers
129 */
130 OpenPIC_Reg _Vendor_Specific[4];
131 /*
132 * Vendor Identification Register
133 */
134 OpenPIC_Reg _Vendor_Identification; /* Read Only */
135 /*
136 * Processor Initialization Register
137 */
138 OpenPIC_Reg _Processor_Initialization; /* Read/Write */
139 /*
140 * IPI Vector/Priority Registers
141 */
142 OpenPIC_Reg _IPI_Vector_Priority[OPENPIC_NUM_IPI]; /* Read/Write */
143 /*
144 * Spurious Vector Register
145 */
146 OpenPIC_Reg _Spurious_Vector; /* Read/Write */
147 /*
148 * Global Timer Registers
149 */
150 OpenPIC_Reg _Timer_Frequency; /* Read/Write */
151 OpenPIC_Timer Timer[OPENPIC_NUM_TIMERS];
152 char Pad1[0xee00];
154
155 /*
156 * Interrupt Source Registers
157 */
158
159typedef struct _OpenPIC_Source {
160 OpenPIC_Reg _Vector_Priority; /* Read/Write */
161 OpenPIC_Reg _Destination; /* Read/Write */
163
164 /*
165 * OpenPIC Register Map
166 */
167
168struct OpenPIC {
169 char Pad1[0x1000];
170 /*
171 * Global Registers
172 */
173 OpenPIC_Global Global;
174 /*
175 * Interrupt Source Configuration Registers
176 */
177 OpenPIC_Source Source[OPENPIC_MAX_SOURCES];
178 /*
179 * Per Processor Registers
180 */
181 OpenPIC_Processor Processor[OPENPIC_MAX_PROCESSORS];
182};
183
184extern volatile struct OpenPIC *OpenPIC;
185
186 /*
187 * Current Task Priority Register
188 */
189
190#define OPENPIC_CURRENT_TASK_PRIORITY_MASK 0x0000000f
191
192 /*
193 * Who Am I Register
194 */
195
196#define OPENPIC_WHO_AM_I_ID_MASK 0x0000001f
197
198 /*
199 * Feature Reporting Register 0
200 */
201
202#define OPENPIC_FEATURE_LAST_SOURCE_MASK 0x07ff0000
203#define OPENPIC_FEATURE_LAST_SOURCE_SHIFT 16
204#define OPENPIC_FEATURE_LAST_PROCESSOR_MASK 0x00001f00
205#define OPENPIC_FEATURE_LAST_PROCESSOR_SHIFT 8
206#define OPENPIC_FEATURE_VERSION_MASK 0x000000ff
207
208 /*
209 * Global Configuration Register 0
210 */
211
212#define OPENPIC_CONFIG_RESET 0x80000000
213#define OPENPIC_CONFIG_8259_PASSTHROUGH_DISABLE 0x20000000
214#define OPENPIC_CONFIG_BASE_MASK 0x000fffff
215
216 /*
217 * Vendor Identification Register
218 */
219
220#define OPENPIC_VENDOR_ID_STEPPING_MASK 0x00ff0000
221#define OPENPIC_VENDOR_ID_STEPPING_SHIFT 16
222#define OPENPIC_VENDOR_ID_DEVICE_ID_MASK 0x0000ff00
223#define OPENPIC_VENDOR_ID_DEVICE_ID_SHIFT 8
224#define OPENPIC_VENDOR_ID_VENDOR_ID_MASK 0x000000ff
225
226 /*
227 * Vector/Priority Registers
228 */
229
230#define OPENPIC_MASK 0x80000000
231#define OPENPIC_ACTIVITY 0x40000000 /* Read Only */
232#define OPENPIC_PRIORITY_MASK 0x000f0000
233#define OPENPIC_PRIORITY_SHIFT 16
234#define OPENPIC_VECTOR_MASK 0x000000ff
235
236 /*
237 * Interrupt Source Registers
238 */
239
240#define OPENPIC_SENSE_POLARITY 0x00800000 /* Undoc'd */
241#define OPENPIC_SENSE_LEVEL 0x00400000
242
243 /*
244 * Timer Registers
245 */
246
247#define OPENPIC_COUNT_MASK 0x7fffffff
248#define OPENPIC_TIMER_TOGGLE 0x80000000
249#define OPENPIC_TIMER_COUNT_INHIBIT 0x80000000
250
251 /*
252 * Aliases to make life simpler
253 */
254
255/* Per Processor Registers */
256#define IPI_Dispatch(i) _IPI_Dispatch[i].Reg
257#define Current_Task_Priority _Current_Task_Priority.Reg
258#define Interrupt_Acknowledge _Interrupt_Acknowledge.Reg
259#define EOI _EOI.Reg
260
261/* Global Registers */
262#define Feature_Reporting0 _Feature_Reporting0.Reg
263#define Feature_Reporting1 _Feature_Reporting1.Reg
264#define Global_Configuration0 _Global_Configuration0.Reg
265#define Global_Configuration1 _Global_Configuration1.Reg
266#define Vendor_Specific(i) _Vendor_Specific[i].Reg
267#define Vendor_Identification _Vendor_Identification.Reg
268#define Processor_Initialization _Processor_Initialization.Reg
269#define IPI_Vector_Priority(i) _IPI_Vector_Priority[i].Reg
270#define Spurious_Vector _Spurious_Vector.Reg
271#define Timer_Frequency _Timer_Frequency.Reg
272
273/* Timer Registers */
274#define Current_Count _Current_Count.Reg
275#define Base_Count _Base_Count.Reg
276#define Vector_Priority _Vector_Priority.Reg
277#define Destination _Destination.Reg
278
279/* Interrupt Source Registers */
280#define Vector_Priority _Vector_Priority.Reg
281#define Destination _Destination.Reg
282
283 /*
284 * Vendor and Device IDs
285 */
286
287#define OPENPIC_VENDOR_ID_APPLE 0x14
288#define OPENPIC_DEVICE_ID_APPLE_HYDRA 0x46
289
290 /*
291 * OpenPIC Operations
292 */
293
294/*
295 * Handle EPIC differences. Unfortunately, I don't know of an easy
296 * way to tell an EPIC from a normal PIC at run-time. Therefore,
297 * the BSP must enable a few quirks if it knows that an EPIC is being
298 * used:
299 * - If the BSP uses the serial interrupt mode / 'multiplexer' then
300 * EOI must be delayed by at least 16 SRAM_CLK cycles to avoid
301 * spurious interrupts.
302 * It is the BSP's responsibility to set up an appropriate delay
303 * (in timebase-clock cycles) at init time using
304 * 'openpic_set_eoi_delay()'. This is ONLY necessary when using
305 * an EPIC in serial mode.
306 * - The EPIC sources start at an offset of 16 in the register
307 * map, i.e., on an EPIC you'd say Sources[ x + 16 ] where
308 * on a PIC you would say Sources[ x ].
309 * Again, the BSP can set an offset that is used by the
310 * calls dealing with 'Interrupt Sources'
311 * openpic_enable_irq()
312 * openpic_disable_irq()
313 * openpic_initirq()
314 * openpic_mapirq()
315 * openpic_set_sense()
316 * openpic_get_source_priority()
317 * openpic_set_source_priority()
318 * the desired source offset parameter is passed to openpic_init().
319 *
320 * The routine 'openpic_set_eoi_delay()' returns the previous/old
321 * value of the delay parameter.
322 */
323extern unsigned openpic_set_eoi_delay(unsigned tb_cycles);
324
325
326/* Global Operations */
327
328/* num_sources: number of sources to use; if zero this value
329 * is read from the device, if nonzero the value read from
330 * the device is overridden.
331 * 'polarities' and 'senses' are arrays defining the desired
332 * polarities (active hi [nonzero]/lo [zero]) and
333 * senses (level [nonzero]/edge [zero]).
334 * Either of the two array pointers may be NULL resulting
335 * in the driver choosing default values of: 'active low'
336 * and 'level sensitive', respectively.
337 * NOTE: if you do pass arrays then their size must either
338 * match the number of sources read from the device or
339 * that value must be overridden by specifying
340 * a non-zero 'num_sources' parameter.
341 *
342 * Nonzero 'epic_freq' activates the EOI delay if the EPIC is
343 * configured in serial mode (driver assumes firmware performs initial
344 * EPIC setup). The BSP must pass the clock frequency of the EPIC
345 * serial interface here.
346 */
347extern void openpic_init(int main_pic, unsigned char *polarities, unsigned char *senses, int num_sources, int source_offset, unsigned long epic_freq);
348
349extern void openpic_reset(void);
350extern void openpic_enable_8259_pass_through(void);
351extern void openpic_disable_8259_pass_through(void);
352extern unsigned int openpic_irq(unsigned int cpu);
353extern void openpic_eoi(unsigned int cpu);
354extern unsigned int openpic_get_priority(unsigned int cpu);
355extern void openpic_set_priority(unsigned int cpu, unsigned int pri);
356extern unsigned int openpic_get_spurious(void);
357extern void openpic_set_spurious(unsigned int vector);
358extern void openpic_init_processor(unsigned int cpumask);
359
360/* Interprocessor Interrupts */
361extern void openpic_initipi(unsigned int ipi, unsigned int pri, unsigned int vector);
362extern void openpic_cause_IPI(unsigned int cpu, unsigned int ipi, unsigned int cpumask);
363
364/* Timer Interrupts */
365extern void openpic_inittimer(unsigned int timer, unsigned int pri, unsigned int vector);
366extern void openpic_settimer(unsigned int timer, unsigned int base_count, int irq_enable);
367extern unsigned int openpic_gettimer(unsigned int timer);
368extern void openpic_maptimer(unsigned int timer, unsigned int cpumask);
369
370/* Interrupt Sources */
371extern void openpic_enable_irq(unsigned int irq);
372extern int openpic_disable_irq(unsigned int irq);
373extern void openpic_initirq(unsigned int irq, unsigned int pri, unsigned int vector, int polarity,
374 int is_level);
375extern void openpic_mapirq(unsigned int irq, unsigned int cpumask);
376extern void openpic_set_sense(unsigned int irq, int sense);
377extern unsigned int openpic_get_source_priority(unsigned int irq);
378extern void openpic_set_source_priority(unsigned int irq, unsigned int pri);
379
380#endif /* RTEMS_OPENPIC_H */
Definition: openpic.h:168
Definition: openpic.h:116
Definition: openpic.h:73
Definition: openpic.h:64
Definition: openpic.h:159
Definition: openpic.h:105